|
|
@@ -3237,7 +3237,7 @@ namespace Business.Replenishment
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 根据月度计划生成周计划
|
|
|
+ /// 根据周计划生成周工单
|
|
|
/// </summary>
|
|
|
/// <param name="input"></param>
|
|
|
/// <returns></returns>
|
|
|
@@ -3315,19 +3315,24 @@ namespace Business.Replenishment
|
|
|
moentryList[i].moentry_mono = morder_noList[i].NbrResult;
|
|
|
weekplans[i].ProductionOrder = morder_noList[i].NbrResult;
|
|
|
}
|
|
|
- await PlanOrderResourceCheck(moList.OrderBy(a => a.moentry_sys_stime).ToList(), moentryList, bang_id, "",false);
|
|
|
-
|
|
|
- var examine_resultList = _mysql_examine_result.GetListAsync(a => a.bangid == bang_id).Result;
|
|
|
await _businessDbContext.BulkInsertAsync(moList);
|
|
|
await _businessDbContext.BulkInsertAsync(moentryList);
|
|
|
|
|
|
+ //2024/01/10:卫亮工单需求对齐采购需求,取所有未下达的工单做资源检查
|
|
|
+ var moListCheck=_mysql_mes_morder.GetListAsync(a=>(a.morder_state==MorderEnum.Initial_state|| string.IsNullOrEmpty(a.morder_state)) && a.factory_id == input.factory_id).Result;
|
|
|
+ var moEntryListCheck = _mysql_mes_moentry.GetListAsync(a => moListCheck.Select(b=>b.morder_no).ToList().Contains(a.moentry_mono) && a.factory_id == input.factory_id).Result;
|
|
|
+
|
|
|
+ await PlanOrderResourceCheck(moListCheck.OrderBy(a => a.moentry_sys_stime).ToList(), moEntryListCheck, bang_id, "",false);
|
|
|
+
|
|
|
+ var examine_resultList = _mysql_examine_result.GetListAsync(a => a.bangid == bang_id).Result;
|
|
|
+
|
|
|
+
|
|
|
//批量保存 后期考虑子工单
|
|
|
List<WorkOrdMaster> workOrdSave = new List<WorkOrdMaster>();
|
|
|
List<WorkOrdRouting> workOrdRoutingSave = new List<WorkOrdRouting>();
|
|
|
List<WorkOrdDetail> workOrdDetails = new List<WorkOrdDetail>();
|
|
|
if (moList.Any())
|
|
|
{
|
|
|
- moList.ForEach(s => { s.create_time = DateTime.Now; });
|
|
|
List<b_bom_child_examine> childExamineList = _mysql_bom_child_examine.GetListAsync(c => examine_resultList.Select(x => x.Id).Contains(c.examine_id.GetValueOrDefault())).Result;
|
|
|
//同步工单
|
|
|
CreateWorkOrdDates(moList, routingOps, workOrdSave, workOrdRoutingSave, workOrdDetails, examine_resultList, childExamineList);
|
|
|
@@ -3356,44 +3361,43 @@ namespace Business.Replenishment
|
|
|
_businessDbContext.BulkInsert(workOrdDetails);
|
|
|
}
|
|
|
|
|
|
- weekplans.ForEach(a =>
|
|
|
+ var weekplanList = _replenishmentWeekPlan.GetListAsync(a => moListCheck.Select(b=>b.morder_no).ToList().Contains(a.ProductionOrder) && a.IsReplenishmentModel=="N" && a.factory_id == input.factory_id).Result;
|
|
|
+
|
|
|
+ weekplanList.ForEach(a =>
|
|
|
{
|
|
|
- if (a.IsReplenishmentModel == "N")
|
|
|
+ var moItem = examine_resultList.Find(b => b.morder_no == a.ProductionOrder);
|
|
|
+ List<RoutingOpDetail> routingOp = routingOps.Where(x => x.RoutingCode == a.ItemNumber).ToList();
|
|
|
+ //组装标准工时
|
|
|
+ var Assembly = routingOp.Where(x => x.Ufld1 == "组装" && x.MilestoneOp).FirstOrDefault();
|
|
|
+ //热封标准工时
|
|
|
+ var HeatSealing = routingOp.Where(x => x.Ufld1 == "热封" && x.MilestoneOp).FirstOrDefault();
|
|
|
+ //包装标准工时
|
|
|
+ var Packaging = routingOp.Where(x => x.Descr == "包装" && x.MilestoneOp).FirstOrDefault();
|
|
|
+ if (moItem != null && moItem.kitting_times < a.PlanStartDate)
|
|
|
+ {
|
|
|
+ a.ItemStatus = "齐套";
|
|
|
+ a.PlanKittingDate = moItem.kitting_times;
|
|
|
+ a.AssembleHours = Assembly == null ? 0 : Assembly.RunTime * a.Qty;
|
|
|
+ a.HeatSealHours = HeatSealing == null ? 0 : HeatSealing.RunTime * a.Qty;
|
|
|
+ a.PackageHours = Packaging == null ? 0 : Packaging.RunTime * a.Qty;
|
|
|
+ a.TotalHours = a.AssembleHours + a.HeatSealHours + a.PackageHours;
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- var moItem = examine_resultList.Find(b => b.morder_no == a.ProductionOrder);
|
|
|
- List<RoutingOpDetail> routingOp = routingOps.Where(x => x.RoutingCode == a.ItemNumber).ToList();
|
|
|
- //组装标准工时
|
|
|
- var Assembly = routingOp.Where(x => x.Ufld1 == "组装" && x.MilestoneOp).FirstOrDefault();
|
|
|
- //热封标准工时
|
|
|
- var HeatSealing = routingOp.Where(x => x.Ufld1 == "热封" && x.MilestoneOp).FirstOrDefault();
|
|
|
- //包装标准工时
|
|
|
- var Packaging = routingOp.Where(x => x.Descr == "包装" && x.MilestoneOp).FirstOrDefault();
|
|
|
- if (moItem != null && moItem.kitting_times < a.PlanStartDate)
|
|
|
- {
|
|
|
- a.ItemStatus = "齐套";
|
|
|
- a.PlanKittingDate = moItem.kitting_times;
|
|
|
- a.AssembleHours = Assembly == null ? 0 : Assembly.RunTime * a.Qty;
|
|
|
- a.HeatSealHours = HeatSealing == null ? 0 : HeatSealing.RunTime * a.Qty;
|
|
|
- a.PackageHours = Packaging == null ? 0 : Packaging.RunTime * a.Qty;
|
|
|
- a.TotalHours = a.AssembleHours + a.HeatSealHours + a.PackageHours;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- a.ItemStatus = "欠料";
|
|
|
- a.PlanKittingDate = moItem.kitting_times;
|
|
|
- a.AssembleHours = Assembly == null ? 0 : Assembly.RunTime * a.Qty;
|
|
|
- a.HeatSealHours = HeatSealing == null ? 0 : HeatSealing.RunTime * a.Qty;
|
|
|
- a.PackageHours = Packaging == null ? 0 : Packaging.RunTime * a.Qty;
|
|
|
- a.TotalHours = a.AssembleHours + a.HeatSealHours + a.PackageHours;
|
|
|
- }
|
|
|
- var workOrd = workOrdSave.Find(b => b.WorkOrd == a.ProductionOrder);
|
|
|
- if (workOrd != null)
|
|
|
- {
|
|
|
- a.Priority = workOrd.Priority;
|
|
|
- }
|
|
|
+ a.ItemStatus = "欠料";
|
|
|
+ a.PlanKittingDate = moItem.kitting_times;
|
|
|
+ a.AssembleHours = Assembly == null ? 0 : Assembly.RunTime * a.Qty;
|
|
|
+ a.HeatSealHours = HeatSealing == null ? 0 : HeatSealing.RunTime * a.Qty;
|
|
|
+ a.PackageHours = Packaging == null ? 0 : Packaging.RunTime * a.Qty;
|
|
|
+ a.TotalHours = a.AssembleHours + a.HeatSealHours + a.PackageHours;
|
|
|
+ }
|
|
|
+ var workOrd = workOrdSave.Find(b => b.WorkOrd == a.ProductionOrder);
|
|
|
+ if (workOrd != null)
|
|
|
+ {
|
|
|
+ a.Priority = workOrd.Priority;
|
|
|
}
|
|
|
});
|
|
|
- await _businessDbContext.BulkUpdateAsync(weekplans);
|
|
|
+ await _businessDbContext.BulkUpdateAsync(weekplanList);
|
|
|
return "OK";
|
|
|
}
|
|
|
|