|
|
@@ -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;
|
|
|
@@ -4742,10 +4743,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 => {
|
|
|
@@ -4763,6 +4771,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();
|
|
|
@@ -4887,8 +4918,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 = CalcPriority(mo_Mes_Morders.Select(p => p.morder_no).ToList(), param.factoryId.ToString());
|
|
|
@@ -4953,7 +4983,7 @@ namespace Business.Replenishment
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
List<srm_pr_main> updatPrList = new List<srm_pr_main>();
|
|
|
List<srm_pr_main> deletePrList = new List<srm_pr_main>();
|
|
|
@@ -5044,6 +5074,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))
|
|
|
@@ -5116,16 +5147,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)
|
|
|
{
|
|
|
@@ -5178,6 +5206,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;
|