Просмотр исходного кода

解决提前下达导致交货计划不对的问题

Murphy 2 лет назад
Родитель
Сommit
5ac477d554

+ 28 - 17
MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs

@@ -5706,8 +5706,13 @@ namespace Business.ResourceExamineManagement
                 var workords=_workOrdMaster.Select(a => a.OrdDate >= beginTime && a.OrdDate <= endTime && a.Domain == domain && a.Status!="C");
                 var workordList = workords.Select(x => x.WorkOrd).Distinct().ToList();
 
+                //存在提前开工的情况
                 var workordsPickBill = _workOrdMaster.Select(a => a.OrdDate < beginTime && (a.Status=="R"|| a.Status=="W") && a.Domain == domain);
                 var workordListPickBill = workordsPickBill.Select(x => x.WorkOrd).Distinct().ToList();
+                if(workordList.Count>0)
+                {
+                    workordListPickBill.AddRange(workordList);
+                }
 
                 var workExamineResult=_businessBangDbContext.b_examine_result.Where(a => workordList.Contains(a.morder_no) && a.factory_id.ToString()==domain).GroupBy(i => i.morder_no).Select(g => new
                 {
@@ -5751,27 +5756,33 @@ namespace Business.ResourceExamineManagement
                     {
                         foreach (var item in workItem)
                         {
-                            var examids = workExamineResult.Find(a => item.WorkOrd==a.workOrd);
-                            if(examids!=null && examids.examineId>0)
+                            //存在提前开工,提前下达的已经算在待发料里面了
+                            if(item.Status.ToUpper()!="R")
                             {
-                                var itemLackList=examines.Where(a => a.examine_id == examids.examineId).ToList();
-                                itemLackList?.ForEach(a =>
+                                var examids = workExamineResult.Find(a => item.WorkOrd == a.workOrd);
+                                if (examids != null && examids.examineId > 0)
                                 {
-                                    if(itemQty.Any(s=>s.ItemNum==a.item_number))
-                                    {
-                                        itemQty.Find(s=>s.ItemNum==a.item_number).LackQty+= a.lack_qty.GetValueOrDefault();
-                                        itemQty.Find(s => s.ItemNum == a.item_number).NeedQty += a.needCount.GetValueOrDefault();
-                                    }
-                                    else
+                                    var itemLackList = examines.Where(a => a.examine_id == examids.examineId).ToList();
+                                    itemLackList?.ForEach(a =>
                                     {
-                                        DemandscheduleDto demandscheduleDto = new DemandscheduleDto() { ItemNum = a.item_number,LackQty= a.lack_qty.GetValueOrDefault(),NeedQty = a.needCount.GetValueOrDefault()};
-                                        itemQty.Add(demandscheduleDto);
-                                    }
-                                });
-                            }else
-                            {
-                                new NLogHelper("ResourceExamineAppService").WriteLog("CreateDemandSchedule", "生成交货计划:" + item.WorkOrd+"找不到资源检查记录", _currentTenant.Id.ToString());
+                                        if (itemQty.Any(s => s.ItemNum == a.item_number))
+                                        {
+                                            itemQty.Find(s => s.ItemNum == a.item_number).LackQty += a.lack_qty.GetValueOrDefault();
+                                            itemQty.Find(s => s.ItemNum == a.item_number).NeedQty += a.needCount.GetValueOrDefault();
+                                        }
+                                        else
+                                        {
+                                            DemandscheduleDto demandscheduleDto = new DemandscheduleDto() { ItemNum = a.item_number, LackQty = a.lack_qty.GetValueOrDefault(), NeedQty = a.needCount.GetValueOrDefault() };
+                                            itemQty.Add(demandscheduleDto);
+                                        }
+                                    });
+                                }
+                                else
+                                {
+                                    new NLogHelper("ResourceExamineAppService").WriteLog("CreateDemandSchedule", "生成交货计划:" + item.WorkOrd + "找不到资源检查记录", _currentTenant.Id.ToString());
+                                }
                             }
+                            
                         }
                         var requestdate = workItem.Min(a => a.OrdDate);