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

建议交期功能实现调整。

tangdi 2 лет назад
Родитель
Сommit
50fca2a07f

+ 1 - 1
MicroServices/Business/Business.Application/ResourceExamineManagement/CalcBomViewAppService.cs

@@ -388,7 +388,7 @@ namespace Business.ResourceExamineManagement
                         DateTime LeadTime;
                         if (plan != null)
                         {
-                            var TQdate = plan.self_inspection_date.GetValueOrDefault() + plan.Warehousing_date.GetValueOrDefault();
+                            var TQdate = plan.self_inspection_date.GetValueOrDefault() + plan.Warehousing_date.GetValueOrDefault()+ plan.Shipping_date.GetValueOrDefault();
                             LeadTime = ProductiveDate.AddDays((double)TQdate);
                         }
                         else

+ 39 - 20
MicroServices/Business/Business.Application/ResourceExamineManagement/ProductExamineAppService.cs

@@ -13,6 +13,8 @@ using Volo.Abp.Application.Services;
 using Volo.Abp.Domain.Repositories;
 using Business.Dto;
 using Business.Model.Sale;
+using Business.MongoModel.MES.IC;
+using MongoDB.Driver.Linq;
 
 namespace Business.ResourceExamineManagement
 {
@@ -167,7 +169,7 @@ namespace Business.ResourceExamineManagement
         /// <param name="sentrys"></param>
         /// <param name="kittingTimes"></param>
         /// <returns></returns>
-        public void CalcSuggestTime(List<crm_seorderentry> sentrys, List<KittingTimeDto> kittingTimes)
+        public void CalcSuggestTime(List<crm_seorderentry> sentrys, List<KittingTimeDto> kittingTimes, List<mo_ic_item> icitemlist)
         {
             ProdExamineParamDto param;
             foreach (var item in sentrys)
@@ -182,6 +184,7 @@ namespace Business.ResourceExamineManagement
                     item.sys_material_date = dto.kitting_time;
                     item.sys_capacity_date = dto.kitting_time;
                 }
+                var icitem = icitemlist.Find(s => s.number == item.item_number);
                 //计算系统建议交期(物料)
                 param = new ProdExamineParamDto
                 {
@@ -189,34 +192,50 @@ namespace Business.ResourceExamineManagement
                     QtyOrd = dto.LackQty,
                     PlanStart = dto.kitting_time.Date.AddDays(1)
                 };
-                item.sys_material_date = ProductiveExamine(param);
-                item.sys_capacity_date = item.sys_material_date;
+                var time = ProductiveExamine(param);
+                item.sys_material_date = time;
+                item.sys_capacity_date = time;
+                if (icitem != null)
+                {
+                    //加上自检、入库、发运提前期
+                    item.sys_material_date = time.AddDays((double)(icitem.self_inspection_date.GetValueOrDefault() + icitem.Warehousing_date.GetValueOrDefault() + icitem.Shipping_date.GetValueOrDefault()));
+                }
+                param.PlanStart = dto.kitting_time.Date.AddDays(3);
+
                 //计算系统交期(产能)
                 //获取主线最后一道工序
+                List<PeriodSequenceDet> schedules = new List<PeriodSequenceDet>();
                 var routings = routingOps.Where(p => p.RoutingCode == item.item_number && p.ParentOp == 0).OrderBy(p=>p.Op).ToList();
-                if (routings.Count() == 0)
+                if (routings.Count() != 0)
                 {
-                    continue;
+                    //获取产线
+                    var prodLine = prodLines.FirstOrDefault(p => p.Part == item.item_number && p.Op == routings.Last().Op);
+                    if (prodLine != null)
+                    {
+                        //获取产线空闲开始时间
+                        schedules = periodSequences.Where(p => p.ItemNum == item.item_number && p.Op == prodLine.Op && p.Line == prodLine.Line).OrderByDescending(p => p.PlanDate).ToList();
+                    }
                 }
-                //获取产线
-                var prodLine = prodLines.FirstOrDefault(p=>p.Part == item.item_number && p.Op == routings.Last().Op);
-                if (prodLine == null)
+                if (schedules.Any())
                 {
-                    continue;
+                    //产线空闲开始时间
+                    var lastTime = schedules.First().PlanDate.GetValueOrDefault().Date;
+                    if (lastTime >= param.PlanStart)//如果产线空闲时间大于或者等于系统建议交期(物料)的开工时间
+                    {
+                        param.PlanStart = lastTime;
+                        item.sys_capacity_date = ProductiveExamine(param);
+                    }
+                    else {
+                        item.sys_capacity_date = ProductiveExamine(param);
+                    }
                 }
-                //获取产线空闲开始时间
-                var schedules= periodSequences.Where(p => p.ItemNum == item.item_number && p.Op == prodLine.Op && p.Line == prodLine.Line).OrderByDescending(p => p.PlanDate).ToList();
-                if (schedules.Count() == 0)
-                {
-                    continue;
+                else {
+                    item.sys_capacity_date = ProductiveExamine(param);
                 }
-                //产线空闲开始时间
-                var lastTime = schedules.First().PlanDate.GetValueOrDefault().Date;
-                if (lastTime >= param.PlanStart)//如果产线空闲时间大于或者等于系统建议交期(物料)的开工时间
+                if (icitem != null)
                 {
-                    //取下一天开始计算生产结束时间
-                    param.PlanStart = lastTime.AddDays(1);
-                    item.sys_capacity_date = ProductiveExamine(param);
+                    //加上自检、入库、发运提前期
+                    item.sys_capacity_date = item.sys_capacity_date.GetValueOrDefault().AddDays((double)(icitem.self_inspection_date.GetValueOrDefault() + icitem.Warehousing_date.GetValueOrDefault() + icitem.Shipping_date.GetValueOrDefault()));
                 }
             }
         }