|
|
@@ -16,6 +16,7 @@ using EFCore.BulkExtensions;
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
using MongoDB.Driver;
|
|
|
using MongoDB.Driver.Linq;
|
|
|
+using Newtonsoft.Json;
|
|
|
using System;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
@@ -4749,10 +4750,17 @@ namespace Business.Replenishment
|
|
|
List<AlignmentCalcDto> AlignmentCalcList = new List<AlignmentCalcDto>();
|
|
|
if (IsWeekPlan)
|
|
|
{
|
|
|
- var nbrList = _nbrMaster.Select(x => x.Domain == param.factoryId.ToString() && (x.Type == "SM" || x.Type == "Z07") && x.Status.ToUpper() != "C").ToList();
|
|
|
+ var locationRange = _configurationItem.Select(x => x.FldName == "MRPLocationRange" && x.Domain == param.factoryId.ToString()).FirstOrDefault();
|
|
|
+ List<string> locationList = new List<string> { "1000", "1001", "5008", "8000", "8001" };
|
|
|
+ if (locationRange != null && locationRange.Val != null)
|
|
|
+ {
|
|
|
+ locationList = locationRange.Val.SplitToArray(",").ToList();
|
|
|
+ }
|
|
|
+ List<string> nbrType = new List<string> { "SM", "OA", "IA"};
|
|
|
+ var nbrList = _nbrMaster.Select(x => x.Domain == param.factoryId.ToString() && nbrType.Contains(x.Type) && x.Status.ToUpper() != "C").ToList();
|
|
|
if (nbrList.Any())
|
|
|
{
|
|
|
- var nbrDtlList = _nbrDetail.Select(x => nbrList.Select(c => c.RecID).Contains(x.NbrRecID) && x.Status.ToUpper() != "C").ToList();
|
|
|
+ var nbrDtlList = _nbrDetail.Select(x => nbrList.Select(c => c.RecID).Contains(x.NbrRecID) && locationList.Contains(x.LocationFrom) && x.Status.ToUpper() != "C").ToList();
|
|
|
if (nbrDtlList.Any())
|
|
|
{
|
|
|
nbrDtlList.ForEach(x => {
|
|
|
@@ -4770,6 +4778,29 @@ namespace Business.Replenishment
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+ //退料单逻辑相反
|
|
|
+ var wodNbrList = _nbrMaster.Select(x => x.Domain == param.factoryId.ToString() && x.Type == "WOD" && x.Status.ToUpper() != "C").ToList();
|
|
|
+ if (wodNbrList.Any())
|
|
|
+ {
|
|
|
+ //WOD是退料
|
|
|
+ var wodNbrDtlList = _nbrDetail.Select(x => wodNbrList.Select(c => c.RecID).Contains(x.NbrRecID) && locationList.Contains(x.LocationTo) && x.Status.ToUpper() != "C").ToList();
|
|
|
+ if (wodNbrDtlList.Any())
|
|
|
+ {
|
|
|
+ wodNbrDtlList.ForEach(x => {
|
|
|
+ if (x.QtyOrd - x.QtyRec > 0)
|
|
|
+ {
|
|
|
+ var dto = AlignmentCalcList.Find(s => s.ItemNum == x.ItemNum);
|
|
|
+ if (dto == null)
|
|
|
+ {
|
|
|
+ dto = new AlignmentCalcDto();
|
|
|
+ dto.ItemNum = x.ItemNum;
|
|
|
+ AlignmentCalcList.Add(dto);
|
|
|
+ }
|
|
|
+ dto.NeedQty -= x.QtyOrd - x.QtyRec;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
itemNums.AddRange(AlignmentCalcList.Select(x => x.ItemNum));
|
|
|
}
|
|
|
var pretreatList = pretreatments.Select(x => x.item_number).Distinct().ToList();
|
|
|
@@ -4894,8 +4925,7 @@ namespace Business.Replenishment
|
|
|
//暂时屏蔽重新生成工单物料明细
|
|
|
List<WorkOrdDetail> mainWorkOrdDetails = new List<WorkOrdDetail>();
|
|
|
List<WorkOrdDetail> delWorkOrddetails = new List<WorkOrdDetail>();
|
|
|
- if (isChangePriority)
|
|
|
- {
|
|
|
+
|
|
|
//成品虚拟件对应关系
|
|
|
var productOpList = _productStructureOp.Select(x => mo_Mes_Morders.Select(c => c.product_code).Contains(x.ProductItem) && x.Domain == param.factoryId.ToString());
|
|
|
var workOrds = _workOrdMaster.Select(a => mo_Mes_Morders.Select(p => p.morder_no).ToList().Contains(a.WorkOrd) && a.Domain == param.factoryId.ToString() && a.IsActive);
|
|
|
@@ -4960,7 +4990,7 @@ namespace Business.Replenishment
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
List<srm_pr_main> updatPrList = new List<srm_pr_main>();
|
|
|
List<srm_pr_main> deletePrList = new List<srm_pr_main>();
|
|
|
@@ -5051,6 +5081,7 @@ namespace Business.Replenishment
|
|
|
}
|
|
|
//数据库需要减少的PR集合
|
|
|
CalcPrDel(prDelList, dbPurchaseList, ic_items, DBprmainList.Where(x=>x.state==1).ToList(), updatPrList, deletePrList);//只取新增状态的PR,可以做删除或者修改
|
|
|
+ new NLogHelper("AlignmentCalcList").WriteLog("AlignmentCalcList", JsonConvert.SerializeObject(AlignmentCalcList), _currentTenant.Id.ToString());
|
|
|
}
|
|
|
|
|
|
using (var unitOfWork = _unitOfWorkManager.Begin(false, true))
|
|
|
@@ -5123,16 +5154,13 @@ namespace Business.Replenishment
|
|
|
srmpooccupyInsert.ForEach(x => { x.GenerateNewId(help.NextId()); });
|
|
|
_businessDbContext.BulkInsert(srmpooccupyInsert);
|
|
|
}
|
|
|
- if(isChangePriority)
|
|
|
+ if (delWorkOrddetails.Any())
|
|
|
{
|
|
|
- if (delWorkOrddetails.Any())
|
|
|
- {
|
|
|
- _businessDbContext.BulkDelete(delWorkOrddetails);
|
|
|
- }
|
|
|
- if (mainWorkOrdDetails.Any())
|
|
|
- {
|
|
|
- _businessDbContext.BulkInsert(mainWorkOrdDetails);
|
|
|
- }
|
|
|
+ _businessDbContext.BulkDelete(delWorkOrddetails);
|
|
|
+ }
|
|
|
+ if (mainWorkOrdDetails.Any())
|
|
|
+ {
|
|
|
+ _businessDbContext.BulkInsert(mainWorkOrdDetails);
|
|
|
}
|
|
|
if (IsWeekPlan)
|
|
|
{
|
|
|
@@ -5185,6 +5213,8 @@ namespace Business.Replenishment
|
|
|
if (itemPr.pr_aqty > qty)//一个PR够减
|
|
|
{
|
|
|
itemPr.pr_aqty = itemPr.pr_aqty - qty;
|
|
|
+ itemPr.pr_rqty = itemPr.pr_aqty;
|
|
|
+ itemPr.pr_sqty = itemPr.pr_aqty;
|
|
|
updatPrList.Add(itemPr);
|
|
|
dto.updatePrlist.Add(itemPr);
|
|
|
dto.updateQty = qty;
|
|
|
@@ -6822,7 +6852,7 @@ namespace Business.Replenishment
|
|
|
}
|
|
|
|
|
|
//采购单按照需求日期从小到大排
|
|
|
- pchPurDtls = curPurDtls.OrderBy(p => p.DueDate).ToList();
|
|
|
+ pchPurDtls = pchPurDtls.OrderBy(p => p.DueDate).ToList();
|
|
|
for (int k = 0; k < pchPurDtls.Count; k++)
|
|
|
{
|
|
|
if (sumNeedQty >= needQty)
|
|
|
@@ -7034,7 +7064,7 @@ namespace Business.Replenishment
|
|
|
entity.um = "";
|
|
|
entity.purgroup = "";
|
|
|
entity.suppliercode = pch.supplier_number;
|
|
|
- entity.supplier = pch.supplier_name;
|
|
|
+ entity.supplier = string.IsNullOrEmpty(pch.supplier_name) ? "" : pch.supplier_name;
|
|
|
entity.requestdate = demandplans[i].arrivaldate;
|
|
|
entity.needdate = demandplans[i].requestdate;
|
|
|
entity.ponumber = pud.PurOrd;
|