Ver Fonte

解决冲突

Murphy há 3 anos atrás
pai
commit
1333899882
21 ficheiros alterados com 192 adições e 125 exclusões
  1. 5 0
      MicroServices/Business/Business.Application.Contracts/Dto/LineStartDto.cs
  2. 7 1
      MicroServices/Business/Business.Application.Contracts/Dto/WorkOrdRoutingDto.cs
  3. 10 54
      MicroServices/Business/Business.Application/Quartz/ExtJobService.cs
  4. 115 27
      MicroServices/Business/Business.Application/Quartz/ProductionScheduleAppService.cs
  5. 1 0
      MicroServices/Business/Business.Application/ResourceExamineManagement/CalcBomViewAppService.cs
  6. 24 21
      MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs
  7. 1 1
      MicroServices/Business/Business.EntityFrameworkCore/Business.EntityFrameworkCore.csproj
  8. 3 3
      MicroServices/Business/Business.EntityFrameworkCore/Repository/SqlRepositories/SqlRepository.cs
  9. 1 1
      MicroServices/Business/Bussiness.Model/MES/IC/InvMaster.cs
  10. 1 1
      MicroServices/Business/Bussiness.Model/MES/IC/ItemMaster.cs
  11. 1 1
      MicroServices/Business/Bussiness.Model/MES/IC/NbrDetail.cs
  12. 1 1
      MicroServices/Business/Bussiness.Model/MES/IC/NbrMaster.cs
  13. 2 1
      MicroServices/Business/Bussiness.Model/Production/HolidayMaster.cs
  14. 7 1
      MicroServices/Business/Bussiness.Model/Production/PeriodSequenceDet.cs
  15. 1 1
      MicroServices/Business/Bussiness.Model/Production/ProdLineDetail.cs
  16. 3 2
      MicroServices/Business/Bussiness.Model/Production/QualityLineWorkDetail.cs
  17. 1 1
      MicroServices/Business/Bussiness.Model/Production/ScheduleResultOpMaster.cs
  18. 3 3
      MicroServices/Business/Bussiness.Model/Production/ShopCalendarWorkCtr.cs
  19. 1 1
      MicroServices/Business/Bussiness.Model/Production/WorkOrdDetail.cs
  20. 2 2
      MicroServices/Business/Bussiness.Model/Production/WorkOrdMaster.cs
  21. 2 2
      MicroServices/Business/Bussiness.Model/Production/WorkOrdRouting.cs

+ 5 - 0
MicroServices/Business/Business.Application.Contracts/Dto/LineStartDto.cs

@@ -30,5 +30,10 @@ namespace Business.Dto
         /// 产线排产实际开始日期
         /// </summary>
         public DateTime StartTime { get; set; }
+
+        /// <summary>
+        /// 当前层级有子级的工序集合
+        /// </summary>
+        public List<int> ChdParentOps { get; set; }
     }
 }

+ 7 - 1
MicroServices/Business/Business.Application.Contracts/Dto/WorkOrdRoutingDto.cs

@@ -1,4 +1,5 @@
-using System;
+using Microsoft.Extensions.FileSystemGlobbing.Internal.PathSegments;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Runtime.CompilerServices;
@@ -46,5 +47,10 @@ namespace Business.Business.Dto
         /// 产线可开工日期
         /// </summary>
         public DateTime StartTime { get; set; }
+
+        /// <summary>
+        /// 当前层级有子级的工序
+        /// </summary>
+        public List<int> ChdParentOps { get; set; }
     }
 }

+ 10 - 54
MicroServices/Business/Business.Application/Quartz/ExtJobService.cs

@@ -3,6 +3,7 @@ using Business.EntityFrameworkCore;
 using Business.Model.Ext;
 using Business.Model.MES.IC;
 using Business.Model.SRM;
+using EFCore.BulkExtensions;
 using NLog;
 using System.Collections.Generic;
 using System.Linq;
@@ -300,96 +301,51 @@ namespace Business.Quartz
                 if (ic_itemListAdd.Count > 0)
                 {
                     //await _ic_item.InsertManyAsync(ic_itemListAdd);
-                    await _businessDbContext.ic_item.BulkInsertAsync(ic_itemListAdd, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.InsertIfNotExists = true;
-                        options.AutoMapOutputDirection = false;
-                    });
+                    _businessDbContext.BulkInsert(ic_itemListAdd);
                 }
                 if (ic_itemListUpdate.Count > 0)
                 {
                     //await _ic_item.UpdateManyAsync(ic_itemListUpdate);
-                    await _businessDbContext.ic_item.BulkUpdateAsync(ic_itemListUpdate, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.AutoMapOutputDirection = false;
-                        options.ColumnPrimaryKeyExpression = c => c.Id;
-                    });
+                    _businessDbContext.BulkUpdate(ic_itemListUpdate);
                 }
 
                 if (ic_factory_detailsListAdd.Count > 0)
                 {
                     //await _ic_factory_details.InsertManyAsync(ic_factory_detailsListAdd);
-                    await _businessDbContext.ic_factory_details.BulkInsertAsync(ic_factory_detailsListAdd, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.InsertIfNotExists = true;
-                        options.AutoMapOutputDirection = false;
-                    });
+                    _businessDbContext.BulkInsert(ic_factory_detailsListAdd);
                 }
                 if (ic_factory_detailsListUpdate.Count > 0)
                 {
                     //await _ic_factory_details.UpdateManyAsync(ic_factory_detailsListUpdate);
-                    await _businessDbContext.ic_factory_details.BulkUpdateAsync(ic_factory_detailsListUpdate, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.AutoMapOutputDirection = false;
-                        options.ColumnPrimaryKeyExpression = c => c.Id;
-                    });
+                    _businessDbContext.BulkUpdate(ic_factory_detailsListUpdate);
                 }
 
                 if (srm_purchaseListAdd.Count > 0)
                 {
                     //await _ic_item_pur.InsertManyAsync(ic_item_purListAdd);
-                    await _businessDbContext.srm_purchase.BulkInsertAsync(srm_purchaseListAdd, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.InsertIfNotExists = true;
-                        options.AutoMapOutputDirection = false;
-                    });
+                    _businessDbContext.BulkInsert(srm_purchaseListAdd);
                 }
                 if (srm_purchaseListUpdate.Count > 0)
                 {
                     //await _ic_item_pur.UpdateManyAsync(ic_item_purListUpdate);
-                    await _businessDbContext.srm_purchase.BulkUpdateAsync(srm_purchaseListUpdate, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.AutoMapOutputDirection = false;
-                        options.ColumnPrimaryKeyExpression = c => c.Id;
-                    });
+                    _businessDbContext.BulkUpdate(srm_purchaseListUpdate);
                 }
 
                 if (ic_planListAdd.Count > 0)
                 {
                     //await _ic_plan.InsertManyAsync(ic_planListAdd);
-                    await _businessDbContext.ic_plan.BulkInsertAsync(ic_planListAdd, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.InsertIfNotExists = true;
-                        options.AutoMapOutputDirection = false;
-                    });
+                    _businessDbContext.BulkInsert(ic_planListAdd);
                 }
                 if (ic_planListUpdate.Count > 0)
                 {
                     //await _ic_plan.UpdateManyAsync(ic_planListUpdate);
-                    await _businessDbContext.ic_plan.BulkUpdateAsync(ic_planListUpdate, options =>
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.AutoMapOutputDirection = false;
-                        options.ColumnPrimaryKeyExpression = c => c.Id;
-                    });
+                    _businessDbContext.BulkUpdate(ic_planListUpdate);
                 }
 
                 if (ext_xrefList.Count > 0)
                 {
                     //await _ext_xref.UpdateManyAsync(ext_xrefList);
-                    await _businessExtDbContext.ext_xref.BulkInsertAsync(ext_xrefList, options => 
-                    {
-                        options.InsertKeepIdentity = true;
-                        options.InsertIfNotExists = true;
-                        options.AutoMapOutputDirection = false;
-                    });
+                    _businessExtDbContext.BulkInsert(ext_xrefList);
                 }
             }
         }

+ 115 - 27
MicroServices/Business/Business.Application/Quartz/ProductionScheduleAppService.cs

@@ -5,9 +5,11 @@ using Business.EntityFrameworkCore;
 using Business.EntityFrameworkCore.SqlRepositories;
 using Business.Model.MES.IC;
 using Business.Model.Production;
+using EFCore.BulkExtensions;
 using System;
 using System.Collections.Generic;
 using System.Collections.Immutable;
+using System.Globalization;
 using System.Linq;
 using System.Threading.Tasks;
 using Volo.Abp.Application.Services;
@@ -154,7 +156,8 @@ namespace Business.Quartz
         public async Task DoProductShcedule()
         {
             //1、获取需要排产的工单:Status为空且IsActive==1
-            List<WorkOrdMaster> workOrds = _workOrdMaster.Select(p => string.IsNullOrEmpty(p.Status) && p.IsActive == 1).Result;
+            //List<WorkOrdMaster> workOrds = _workOrdMaster.Select(p => string.IsNullOrEmpty(p.Status) && p.IsActive == 1).Result;
+            List<WorkOrdMaster> workOrds = _workOrdMaster.Select(p => p.WorkOrd == "Test0000001").Result;
             if (workOrds.Count == 0)
             {
                 return;
@@ -163,19 +166,19 @@ namespace Business.Quartz
             DateTime earlist = workOrds.Min(p => p.OrdDate.GetValueOrDefault()).Date;
             //2、获取数据
             //获取工单工艺路径数据
-            List<WorkOrdRouting> workOrdRoutings = _workOrdRouting.Select(p => workOrds.Select(m => m.WorkOrd).Contains(p.WorkOrd) && p.Domain == "1001" && p.Status != "C" && p.IsActive == 1).Result;
+            List<WorkOrdRouting> workOrdRoutings = _workOrdRouting.Select(p => workOrds.Select(m => m.WorkOrd).Contains(p.WorkOrd) && p.Domain == "1001" && p.Status != "C" && p.IsActive).Result;
             //获取物料对应的生产线信息:物料、工序对应的生产线
-            List<ProdLineDetail> prodLines = _prodLineDetail.Select(p => workOrds.Select(m => m.ItemNum).Contains(p.Part) && p.Domain == "1001" && p.IsActive == 1).Result;
+            List<ProdLineDetail> prodLines = _prodLineDetail.Select(p => workOrds.Select(m => m.ItemNum).Contains(p.Part) && p.Domain == "1001" && p.IsActive).Result;
             //获取生产周期数据
-            List<PeriodSequenceDet> dbPeriodSequences = _periodSequenceDet.Select(p=> workOrds.Select(m => m.ItemNum).Contains(p.ItemNum) && p.PlanDate >= earlist && p.Domain == "1001" && p.IsActive == 1).Result;
+            List<PeriodSequenceDet> dbPeriodSequences = _periodSequenceDet.Select(p=> workOrds.Select(m => m.ItemNum).Contains(p.ItemNum) && p.PlanDate >= earlist && p.Domain == "1001" && p.IsActive).Result;
             //获取当前日期往后的排产记录数据
             List<ScheduleResultOpMaster> dbSchedules = _scheduleResultOpMaster.Select(p => workOrds.Select(m => m.ItemNum).Contains(p.ItemNum) && p.WorkDate >= earlist && p.Domain == "1001").Result;
             //获取工作日历数据
-            calendars = _shopCalendarWorkCtr.Select(p=>p.Domain == "1001" && p.IsActive == 1).Result;
+            calendars = _shopCalendarWorkCtr.Select(p=>p.Domain == "1001" && p.IsActive).Result;
             //获取产线休息记录数据
-            qualityLines = _qualityLineWorkDetail.Select(p => p.Domain == "1001" && p.IsActive == 1).Result;
+            qualityLines = _qualityLineWorkDetail.Select(p => p.Domain == "1001" && p.IsActive).Result;
             //获取节假日记录数据
-            holidays = _holidayMaster.Select(p => p.Domain == "1001" && p.IsActive == 1 && p.Dated >= earlist).Result;
+            holidays = _holidayMaster.Select(p => p.Domain == "1001" && p.IsActive && p.Dated >= earlist).Result;
 
             //3、排产
             //排产异常记录
@@ -252,12 +255,12 @@ namespace Business.Quartz
 
                 //更新工单表
                 item.Status = "w";
-                await _workOrdMaster.Update(item);
             }
+            _businessDbContext.UpdateRange(workOrds);
             //记录排产数据
-            await _businessDbContext.PeriodSequenceDet.BulkInsertAsync(periodSequenceDtls);
-            await _businessDbContext.ScheduleResultOpMaster.BulkInsertAsync(scheduleMasters);
-            await _businessDbContext.ScheduleExceptionMaster.BulkInsertAsync(scheduleExceptions);
+            _businessDbContext.BulkInsert(periodSequenceDtls);
+            _businessDbContext.BulkInsert(scheduleMasters);
+            _businessDbContext.BulkInsert(scheduleExceptions);
         }
 
         /// <summary>
@@ -282,7 +285,7 @@ namespace Business.Quartz
                 //当前产线的工作日历
                 var mLCalendars = calendars.Where(p => p.ProdLine == item.Line).ToList();
                 //当前产线的每天休息时间记录
-                var mlqtyWorkDtls = qualityLines.Where(p => p.ProdLine == item.Line).ToList();
+                var mlqtyWorkDtls = qualityLines.Where(p => p.ProdLine == item.Line).OrderBy(p => p.Line).ToList();
 
                 //产线已排产数量
                 decimal sumQty = 0m;
@@ -296,15 +299,17 @@ namespace Business.Quartz
                 {
                     //子产线获取实际排产开始日期
                     //获取父级排产开始时间
-                    DateTime parentStartTime = lineStarts.First(p => p.Op == item.ParentOp).StartTime;
+                    DateTime parentStartTime = lineStarts.First(p => p.ChdParentOps.Contains(item.ParentOp)).StartTime;
                     workStartTime = DealChildStartTime(parentStartTime, item.SetupTime, mLCalendars, mlqtyWorkDtls);
                 }
                 //记录产线排产开始时间
-                lineStarts.Add(new LineStartDto { 
+                lineStarts.Add(new LineStartDto
+                {
                     level = item.level,
                     Line = item.Line,
-                    Op= item.Op,
-                    StartTime = workStartTime
+                    Op = item.Op,
+                    StartTime = workStartTime,
+                    ChdParentOps = item.ChdParentOps
                 });
                 //排产
                 while (sumQty < workOrd.QtyOrded)
@@ -324,7 +329,8 @@ namespace Business.Quartz
                             Period = 1,//目前只考虑一班制
                             OrdQty = dto.ProductQty,
                             WorkOrds = workOrd.WorkOrd,
-                            IsActive = 1
+                            Op = item.Op,
+                            IsActive = true
                         });
                         //记录排产记录
                         curScheduleRsts.Add(new ScheduleResultOpMaster
@@ -338,7 +344,7 @@ namespace Business.Quartz
                             WorkQty = dto.ProductQty,
                             WorkStartTime = dto.StartTime,
                             WorkEndTime = dto.EndTime,
-                            CreatTime = DateTime.Now
+                            CreateTime = DateTime.Now
                         });
                         //累计已排产数量
                         sumQty += dto.ProductQty;
@@ -350,7 +356,7 @@ namespace Business.Quartz
                         //剩余需要排产的数量
                         decimal residueQty = workOrd.QtyOrded - sumQty;
                         //剩余数量生产需要时长(分钟)
-                        decimal workTime = residueQty / item.Rate * 60;
+                        decimal workTime = Math.Ceiling(residueQty / item.Rate * 60);
                         //获取当天的工作时间段
                         List<LineWorkPointDto> workPoints = DealWorkDayToLevels(workStartTime, mLCalendars.First(p => p.WeekDay == (int)workStartTime.DayOfWeek), mlqtyWorkDtls);
                         var curPoint = workPoints.First(p => p.StartPoint >= workStartTime && workStartTime <= p.EndPoint);
@@ -378,6 +384,7 @@ namespace Business.Quartz
                                 nextMins -= p.WorkMinutes;
                             }
                         }
+                        sumQty = workOrd.QtyOrded;
                         //记录生产周期
                         curSequences.Add(new PeriodSequenceDet
                         {
@@ -388,7 +395,8 @@ namespace Business.Quartz
                             Period = 1,//目前只考虑一班制
                             OrdQty = residueQty,
                             WorkOrds = workOrd.WorkOrd,
-                            IsActive = 1
+                            Op = item.Op,
+                            IsActive = true
                         });
                         //记录排产记录
                         curScheduleRsts.Add(new ScheduleResultOpMaster
@@ -402,7 +410,7 @@ namespace Business.Quartz
                             WorkQty = residueQty,
                             WorkStartTime = workStartTime,
                             WorkEndTime = workEndTime,
-                            CreatTime = DateTime.Now
+                            CreateTime = DateTime.Now
                         });
                     }
                 }
@@ -445,7 +453,7 @@ namespace Business.Quartz
                 scheduledDto.EffTime += (decimal)span.TotalHours;
             }
             //计算当天的产能
-            scheduledDto.ProductQty = scheduledDto.EffTime * routingDto.Rate;
+            scheduledDto.ProductQty = Math.Floor(scheduledDto.EffTime * routingDto.Rate);
             return scheduledDto;
         }
 
@@ -462,12 +470,48 @@ namespace Business.Quartz
             DateTime actStart = startTime;
             //开始时间是周几
             int weekDay = (int)startTime.DayOfWeek;
+            //判断当天是否是工作日
+            bool isWorkDay = CheckIsWorkDay(startTime);
+            if (!isWorkDay)//不是工作日
+            {
+                //获取下一个工作日开始时间
+                actStart = GetNextWorkDay(weekDay, startTime, curCalendars);
+                return actStart;
+            }
+
             //当天的工作日历
             var shopCal = curCalendars.Where(p => p.WeekDay == weekDay).First();
             //当前日期的工作时间段
             List<LineWorkPointDto> workPoints = DealWorkDayToLevels(startTime, shopCal, curQtyDtls);
             //计算starttime处于那个工作时间段
             var curPoint = workPoints.Where(p => startTime >= p.StartPoint && startTime <= p.EndPoint).FirstOrDefault();
+            if (curPoint == null)//不处于工作时间段
+            {
+                //开始时间小于当天工作开始时间
+                if (startTime < workPoints.First().StartPoint)
+                {
+                    actStart = workPoints.First().StartPoint;
+                }
+                //开始时间大于当前工作结束时间
+                else if (startTime > workPoints.Last().EndPoint)
+                {
+                    //获取下一个工作日开始时间
+                    actStart = GetNextWorkDay(weekDay, startTime, curCalendars);
+                }
+                else {//开始时间位于当天的休息时间段
+                    foreach (var item in workPoints)
+                    {
+                        //获取下一个时间段
+                        var next = workPoints.First(p=>p.Level == item.Level + 1);
+                        if (item.EndPoint < startTime &&  startTime < next.StartPoint)
+                        {
+                            actStart = next.StartPoint;
+                            break;
+                        }
+                    }
+                }
+                return actStart;
+            }
             if (startTime != curPoint.EndPoint)
             {
                 return actStart;
@@ -483,6 +527,33 @@ namespace Business.Quartz
             return actStart;
         }
 
+        /// <summary>
+        /// 判断当天是否是工作日
+        /// </summary>
+        /// <param name="dateTime"></param>
+        /// <returns></returns>
+        public bool CheckIsWorkDay(DateTime dateTime)
+        {
+            bool isWorkDay = true;
+            //周几
+            int weekDay = (int)dateTime.DayOfWeek;
+            //判断当天是否是工作日
+            if (weekDay == 0 || weekDay == 6)//周六或者周日,需要判断是否调休,需要加班
+            {
+                if (!holidays.Exists(p => p.Dated.GetValueOrDefault().Date == dateTime.Date && p.Ufld1 == "调休"))//不是调休
+                {
+                    isWorkDay = false;
+                }
+                return isWorkDay;
+            }
+            //不是周六周日,需要判断是不是节假日
+            if (holidays.Exists(p => p.Dated.GetValueOrDefault().Date == dateTime.Date && p.Ufld1 == "休假"))//是节假日
+            {
+                isWorkDay = false;
+            }
+            return isWorkDay;
+        }
+
         /// <summary>
         /// 计算子产线实际排产开始时间
         /// </summary>
@@ -574,6 +645,7 @@ namespace Business.Quartz
             //下一天是周几
             int nextWeekDay = (weekDay + 1) % 7;
             var calendar = curCalendars.FirstOrDefault(p=>p.WeekDay == nextWeekDay);
+            string strStart = calendar.ShiftsStart1.ToString("0.00").Replace(".", ":");
             //判断下一天是否是工作日
             if (nextWeekDay == 0 || nextWeekDay == 6)//下一天是周六或者周日,需要判断是否调休,需要加班
             {
@@ -582,7 +654,7 @@ namespace Business.Quartz
                     //递归继续找下一个工作日
                     GetNextWorkDay(nextWeekDay, nextDate, curCalendars);
                 }
-                rtnData = nextDate.AddHours((double)calendar.ShiftsStart1);
+                rtnData = Convert.ToDateTime(nextDate.ToString("yyyy-MM-dd") + " " + strStart);
                 return rtnData;
             }
             //下一天不是周六周日,需要判断是不是节假日
@@ -591,7 +663,7 @@ namespace Business.Quartz
                 //递归继续找下一个工作日
                 GetNextWorkDay(nextWeekDay, nextDate, curCalendars);
             }
-            rtnData = nextDate.AddHours((double)calendar.ShiftsStart1);
+            rtnData = Convert.ToDateTime(nextDate.ToString("yyyy-MM-dd") + " " + strStart);
             return rtnData;
         }
 
@@ -609,6 +681,7 @@ namespace Business.Quartz
             //前一天是周几
             int preWeekDay = (int)preDate.DayOfWeek;
             var calendar = curCalendars.FirstOrDefault(p => p.WeekDay == preWeekDay);
+            string strStart = calendar.ShiftsStart1.ToString("0.00").Replace(".", ":");
             //判断前一天是否是工作日
             if (preWeekDay == 0 || preWeekDay == 6)//前一天是周六或者周日,需要判断是否调休,需要加班
             {
@@ -617,7 +690,7 @@ namespace Business.Quartz
                     //递归继续找下一个工作日
                     GetPreWorkDay(preDate, curCalendars);
                 }
-                rtnData = preDate.AddHours((double)calendar.ShiftsStart1);
+                rtnData = Convert.ToDateTime(preDate.ToString("yyyy-MM-dd") + " " + strStart);
                 return rtnData;
             }
             //前一天不是周六周日,需要判断是不是节假日
@@ -626,7 +699,7 @@ namespace Business.Quartz
                 //递归继续找前一个工作日
                 GetPreWorkDay(preDate, curCalendars);
             }
-            rtnData = preDate.AddHours((double)calendar.ShiftsStart1);
+            rtnData = Convert.ToDateTime(preDate.ToString("yyyy-MM-dd") + " " + strStart);
             return rtnData;
         }
 
@@ -644,7 +717,8 @@ namespace Business.Quartz
             //排产记录结束日期是周几
             int weekDay = (int)startTime.DayOfWeek;
             //计算当天的开工时间点,停工时间点
-            DateTime dayStartPoint = startTime.Date.AddHours(Convert.ToDouble(shopCal.ShiftsStart1));
+            string strStart = shopCal.ShiftsStart1.ToString("0.00").Replace(".", ":");
+            DateTime dayStartPoint = Convert.ToDateTime(date + " "+ strStart);
             DateTime dayEndPoint = dayStartPoint.AddHours(Convert.ToDouble(shopCal.ShiftsHours1));
             //工作时间段
             List<LineWorkPointDto> workPoints = new List<LineWorkPointDto>();
@@ -702,6 +776,13 @@ namespace Business.Quartz
             dto.ParentOp = lastOp.ParentOp;
             dto.level = 1;
             dto.Op = lastOp.OP;
+            dto.ChdParentOps = new List<int>();
+            //获取当前层级工序中有子级的工序集合
+            var childs = woRuntings.Where(p => firsts.Select(m => m.OP).Contains(p.ParentOp)).Select(m => m.ParentOp).Distinct().ToList();
+            if (childs.Count() > 0)
+            {
+                dto.ChdParentOps = childs;
+            }
             //主工序对应的产线(目前只考虑一个产品对应一条产线的情况)
             var line = prodLines.Where(p => p.Part == lastOp.ItemNum && p.Op == lastOp.OP).FirstOrDefault();
             if (line != null) {
@@ -748,6 +829,13 @@ namespace Business.Quartz
                 dto.Op = lastOp.OP;
                 dto.ParentOp = lastOp.ParentOp;
                 dto.level = level + 1;
+                dto.ChdParentOps = new List<int>();
+                //获取当前层级工序中有子级的工序集合
+                var childs = woRuntings.Where(p => curLevels.Where(p => p.ParentOp == item).Select(m => m.OP).Contains(p.ParentOp)).Select(m => m.ParentOp).Distinct().ToList();
+                if (childs.Count() > 0)
+                {
+                    dto.ChdParentOps = childs;
+                }
                 //当前层级工序对应的产线
                 var maxRateLine = prodLines.Where(p => p.Part == lastOp.ItemNum && p.Op == lastOp.OP).OrderByDescending(p => p.Rate).FirstOrDefault();
                 if (maxRateLine != null)

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

@@ -1155,6 +1155,7 @@ namespace Business.ResourceExamineManagement
                 //_srm_pr_main.InsertOne(srm_Pr);
                 decimal? totalLeadTime = leadTime.transportation_leadtime + leadTime.stock_leadtime + leadTime.production_leadtime + leadTime.order_leadtime;
                 srm_Pr.totalLeadTime= totalLeadTime;
+                srm_Pr.create_time = DateTime.Now;
                 sRMPR.srm_Pr_Main.Add(srm_Pr);
             });
             if (sRMPR.srm_Pr_Main.Any())

+ 24 - 21
MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs

@@ -27,10 +27,8 @@ using Volo.Abp.Application.Services;
 using Volo.Abp.DependencyInjection;
 using Volo.Abp.Domain.Repositories;
 using Volo.Abp.MultiTenancy;
-using Z.EntityFramework.Plus;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.ComponentModel.DataAnnotations;
-using Spire.Pdf.General.Render.Decode.Jpeg2000.j2k.wavelet.synthesis;
+using EFCore.BulkExtensions;
+using Business.Quartz;
 
 namespace Business.ResourceExamineManagement
 {
@@ -242,6 +240,8 @@ namespace Business.ResourceExamineManagement
         private readonly BusinessBangDbContext _businessBangDbContext;
         private readonly BusinessDbContext _businessDbContext;
         private readonly ISqlRepository<TagMaster> _tagMasterRepository;
+
+        private readonly ProductionScheduleAppService _productionScheduleAppService;
         #endregion
 
         #region 构造函数
@@ -312,7 +312,8 @@ namespace Business.ResourceExamineManagement
             ICurrentTenant currentTenant,
             MorderAppService morderAppService,
             BusinessBangDbContext businessBangDbContext,
-            BusinessDbContext businessDbContext
+            BusinessDbContext businessDbContext,
+            ProductionScheduleAppService productionScheduleAppService
             )
         {
             _mes_technique = mes_technique;
@@ -374,6 +375,7 @@ namespace Business.ResourceExamineManagement
             _morderAppService = morderAppService;
             _businessBangDbContext = businessBangDbContext;
             _businessDbContext = businessDbContext;
+            _productionScheduleAppService= productionScheduleAppService;
         }
         #endregion
 
@@ -539,7 +541,7 @@ namespace Business.ResourceExamineManagement
             {
                 await _mes_morder.InsertMany(_CalcBomViewAppService.mordersInsertList);
                 var mesorders = ObjectMapper.Map<List<mo_mes_morder>, List<mes_morder>>(_CalcBomViewAppService.mordersInsertList);
-                await _businessDbContext.mes_morder.BulkInsertAsync(mesorders, options => options.InsertKeepIdentity = true);
+                _businessDbContext.BulkInsert(mesorders);
                 rtn.mordersList = _CalcBomViewAppService.mordersInsertList;
             }
             if (_CalcBomViewAppService.mooccupyAllInsertList.Any())
@@ -551,13 +553,13 @@ namespace Business.ResourceExamineManagement
             {
                 await _mes_moentry.InsertMany(_CalcBomViewAppService.moentriesList);
                 var mesmoentrys = ObjectMapper.Map<List<mo_mes_moentry>, List<mes_moentry>>(_CalcBomViewAppService.moentriesList);
-                await _businessDbContext.mes_moentry.BulkInsertAsync(mesmoentrys, options => options.InsertKeepIdentity = true);
+                _businessDbContext.BulkInsert(mesmoentrys);
             }
             if (_CalcBomViewAppService.orderList.Any())
             {
                 await _mes_oorder.InsertMany(_CalcBomViewAppService.orderList);
                 var ooders = ObjectMapper.Map<List<mo_mes_oorder>, List<mes_oorder>>(_CalcBomViewAppService.orderList);
-                await _businessDbContext.mes_oorder.BulkInsertAsync(ooders, options => options.InsertKeepIdentity = true);
+                _businessDbContext.BulkInsert(ooders);
                 rtn.order_list = _CalcBomViewAppService.orderList;
             }
             if (sklist.Any())
@@ -584,7 +586,7 @@ namespace Business.ResourceExamineManagement
                 {
                     await _srm_pr_main.InsertMany(list);
                     var pr_mainlist = ObjectMapper.Map<List<mo_srm_pr_main>, List<srm_pr_main>>(list);
-                    await _businessDbContext.srm_pr_main.BulkInsertAsync(pr_mainlist, options => options.InsertKeepIdentity = true);
+                    _businessDbContext.BulkInsert(pr_mainlist);
                 }
                 rtn.srm_pr_list = _CalcBomViewAppService.SRMPRDtoList;
             }
@@ -662,31 +664,31 @@ namespace Business.ResourceExamineManagement
             }
             if (examineList.Any())
             {
-                await _businessBangDbContext.b_examine_result.BulkInsertAsync(examineList, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(examineList);
             }
             if (bomExamineList.Any())
             {
-                await _businessBangDbContext.b_bom_child_examine.BulkInsertAsync(bomExamineList.OrderBy(s => s.num_order).ToList(), options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(bomExamineList.OrderBy(s => s.num_order).ToList());
             }
             if (mooccupyList.Any())
             {
-                await _businessBangDbContext.b_mo_occupy.BulkInsertAsync(mooccupyList, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(mooccupyList);
             }
             if (moorderList.Any())
             {
-                await _businessBangDbContext.b_mo_order.BulkInsertAsync(moorderList, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(moorderList);
             }
             if (ooderList.Any())
             {
-                await _businessBangDbContext.b_ooder.BulkInsertAsync(ooderList, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(ooderList);
             }
             if (purchaseList.Any())
             {
-                await _businessBangDbContext.b_purchase.BulkInsertAsync(purchaseList, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(purchaseList);
             }
             if (purchaseoccupyList.Any())
             {
-                await _businessBangDbContext.b_purchase_occupy.BulkInsertAsync(purchaseoccupyList, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(purchaseoccupyList);
             }
             //清空快照数据
             await ClearSnapShot(bangid);
@@ -1594,15 +1596,15 @@ namespace Business.ResourceExamineManagement
             }
             if (examineList.Any())
             {
-                await _businessBangDbContext.b_order_examine_result.BulkInsertAsync(examineList, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(examineList);
             }
             if (daybulletinboards.Any())
             {
-                await _businessBangDbContext.b_day_bulletin_board.BulkInsertAsync(daybulletinboards, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(daybulletinboards);
             }
             if (orderDetails.Any())
             {
-                await _businessBangDbContext.b_order_detail.BulkInsertAsync(orderDetails, options => options.InsertKeepIdentity = true);
+                _businessBangDbContext.BulkInsert(orderDetails);
             }
             
         }
@@ -2012,11 +2014,12 @@ namespace Business.ResourceExamineManagement
             }
             if (deleteList.Any())
             {
-                 _businessDbContext.b_bom_pretreatment.BulkDelete(deleteList);
+                 _businessDbContext.BulkDelete(deleteList);
             }
             if (addList.Any())
             {
-                _businessDbContext.b_bom_pretreatment.BulkInsert(addList, options => options.InsertKeepIdentity = true);
+                _businessDbContext.BulkInsert(addList);
+
                 //await _mysql_b_bom_pretreatment.InsertManyAsync(addList);
             }
         }

+ 1 - 1
MicroServices/Business/Business.EntityFrameworkCore/Business.EntityFrameworkCore.csproj

@@ -11,6 +11,7 @@
 
   <ItemGroup>
     <PackageReference Include="Abp" Version="3.4.0" />
+    <PackageReference Include="EFCore.BulkExtensions" Version="6.0.3" />
     <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.5">
       <PrivateAssets>all</PrivateAssets>
       <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -24,7 +25,6 @@
     <PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="6.0.0" />
     <PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="6.0.3" />
     <PackageReference Include="Volo.Abp.TenantManagement.EntityFrameworkCore" Version="6.0.0" />
-    <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="6.20.1" />
   </ItemGroup>
 
   <ItemGroup>

+ 3 - 3
MicroServices/Business/Business.EntityFrameworkCore/Repository/SqlRepositories/SqlRepository.cs

@@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore;
 using System.Collections;
 using Business.EntityFrameworkCore;
 using System.Linq.Expressions;
-using Z.EntityFramework.Plus;
 using System.Data.SqlClient;
+using EFCore.BulkExtensions;
 
 namespace Business.EntityFrameworkCore.SqlRepositories
 {
@@ -38,13 +38,13 @@ namespace Business.EntityFrameworkCore.SqlRepositories
 
         public  async Task<int> Update(Expression<Func<T, bool>> whereLambda, Expression<Func<T, T>> entity)
         {
-            _dbContextProvider.GetDbContext().Set<T>().Where(whereLambda).Update(entity);
+            _dbContextProvider.GetDbContext().Set<T>().Where(whereLambda).BatchUpdate(entity);
             return await _dbContextProvider.GetDbContext().SaveChangesAsync();
         }
 
         public  async Task<int> Delete(Expression<Func<T, bool>> whereLambda)
         {
-            _dbContextProvider.GetDbContext().Set<T>().Where(whereLambda).Delete();
+            _dbContextProvider.GetDbContext().Set<T>().Where(whereLambda).BatchDelete();
             return await _dbContextProvider.GetDbContext().SaveChangesAsync();
         }
 

+ 1 - 1
MicroServices/Business/Bussiness.Model/MES/IC/InvMaster.cs

@@ -50,6 +50,6 @@ namespace Business.Model.MES.IC
         /// 是否有效:1-有效;0-无效
         /// </summary>
         [Comment("是否有效")]
-        public int? IsActive { get; set; }
+        public Boolean IsActive { get; set; }
     }
 }

+ 1 - 1
MicroServices/Business/Bussiness.Model/MES/IC/ItemMaster.cs

@@ -56,7 +56,7 @@ namespace Business.Model.MES.IC
         /// 是否有效:1-有效;0-无效
         /// </summary>
         [Comment("是否有效")]
-        public int? IsActive { get; set; }
+        public Boolean IsActive { get; set; }
 
     }
 }

+ 1 - 1
MicroServices/Business/Bussiness.Model/MES/IC/NbrDetail.cs

@@ -74,6 +74,6 @@ namespace Business.Model.MES.IC
         /// 是否有效:1-有效;0-无效
         /// </summary>
         [Comment("是否有效")]
-        public int? IsActive { get; set; }
+        public Boolean IsActive { get; set; }
     }
 }

+ 1 - 1
MicroServices/Business/Bussiness.Model/MES/IC/NbrMaster.cs

@@ -74,6 +74,6 @@ namespace Business.Model.MES.IC
         /// 是否有效:1-有效;0-无效
         /// </summary>
         [Comment("是否有效")]
-        public int IsActive { get; set; }
+        public Boolean IsActive { get; set; }
     }
 }

+ 2 - 1
MicroServices/Business/Bussiness.Model/Production/HolidayMaster.cs

@@ -11,6 +11,7 @@ namespace Business.Model.Production
     /// <summary>
     /// 节假日记录表
     /// </summary>
+    [Comment("节假日记录表")]
     public class HolidayMaster
     {
         /// <summary>
@@ -48,6 +49,6 @@ namespace Business.Model.Production
         /// 是否有效
         /// </summary>
         [Comment("是否有效")]
-        public int IsActive { get; set; }
+        public Boolean IsActive { get; set; }
     }
 }

+ 7 - 1
MicroServices/Business/Bussiness.Model/Production/PeriodSequenceDet.cs

@@ -64,10 +64,16 @@ namespace Business.Model.Production
         [Comment("工单")]
         public string? WorkOrds { get; set; }
 
+        /// <summary>
+        /// 工序
+        /// </summary>
+        [Comment("工序")]
+        public int Op { get; set; }
+
         /// <summary>
         /// 是否有效:1-有效;0-无效
         /// </summary>
         [Comment("是否有效")]
-        public int? IsActive { get; set; }
+        public Boolean IsActive { get; set; }
     }
 }

+ 1 - 1
MicroServices/Business/Bussiness.Model/Production/ProdLineDetail.cs

@@ -56,7 +56,7 @@ namespace Business.Model.Production
         /// 是否有效:1-有效;0-无效
         /// </summary>
         [Comment("是否有效")]
-        public int? IsActive { get; set; }
+        public Boolean IsActive { get; set; }
 
         /// <summary>
         /// 当前产线提前期(小时)

+ 3 - 2
MicroServices/Business/Bussiness.Model/Production/QualityLineWorkDetail.cs

@@ -11,6 +11,7 @@ namespace Business.Model.Production
     /// <summary>
     /// 产线休息时间记录表
     /// </summary>
+    [Comment("产线休息时间记录表")]
     public class QualityLineWorkDetail
     {
         /// <summary>
@@ -36,7 +37,7 @@ namespace Business.Model.Production
         /// 项次号
         /// </summary>
         [Comment("项次号")]
-        public string Line { get; set; }
+        public int Line { get; set; }
 
         /// <summary>
         /// 休息开始时间点(例如 11:50)
@@ -54,6 +55,6 @@ namespace Business.Model.Production
         /// 是否有效
         /// </summary>
         [Comment("是否有效")]
-        public int IsActive { get; set; }
+        public Boolean IsActive { get; set; }
     }
 }

+ 1 - 1
MicroServices/Business/Bussiness.Model/Production/ScheduleResultOpMaster.cs

@@ -92,7 +92,7 @@ namespace Business.Model.Production
         /// 创建时间
         /// </summary>
         [Comment("创建时间")]
-        public DateTime CreatTime { get; set; }
+        public DateTime CreateTime { get; set; }
 
     }
 }

+ 3 - 3
MicroServices/Business/Bussiness.Model/Production/ShopCalendarWorkCtr.cs

@@ -11,7 +11,7 @@ namespace Business.Model.Production
     /// <summary>
     /// 工作日历表
     /// </summary>
-    [Comment("工单工艺流程表")]
+    [Comment("工作日历表")]
     public class ShopCalendarWorkCtr
     {
         /// <summary>
@@ -43,7 +43,7 @@ namespace Business.Model.Production
         /// 是否工作日
         /// </summary>
         [Comment("是否工作日")]
-        public int IsWorkDay { get; set; }
+        public Boolean IsWorkDay { get; set; }
 
         /// <summary>
         /// 班次1开始时间
@@ -97,6 +97,6 @@ namespace Business.Model.Production
         /// 是否有效:1-有效;0-无效
         /// </summary>
         [Comment("是否有效")]
-        public int? IsActive { get; set; }
+        public Boolean IsActive { get; set; }
     }
 }

+ 1 - 1
MicroServices/Business/Bussiness.Model/Production/WorkOrdDetail.cs

@@ -74,6 +74,6 @@ namespace Business.Model.Production
         /// 是否有效:1-有效;0-无效
         /// </summary>
         [Comment("是否有效")]
-        public int? IsActive { get; set; }
+        public Boolean IsActive { get; set; }
     }
 }

+ 2 - 2
MicroServices/Business/Bussiness.Model/Production/WorkOrdMaster.cs

@@ -26,7 +26,7 @@ namespace Business.Model.Production
         /// 域名
         /// </summary>
         [Comment("域名")]
-        public string? Domain { get; set; }
+        public string Domain { get; set; }
 
         /// <summary>
         /// 计划开始日期
@@ -80,6 +80,6 @@ namespace Business.Model.Production
         /// 是否有效:1-有效;0-无效
         /// </summary>
         [Comment("是否有效")]
-        public int? IsActive { get; set; }
+        public Boolean IsActive { get; set; }
     }
 }

+ 2 - 2
MicroServices/Business/Bussiness.Model/Production/WorkOrdRouting.cs

@@ -44,7 +44,7 @@ namespace Business.Model.Production
         /// 关键工序(需要报工的工序)
         /// </summary>
         [Comment("关键工序")]
-        public int? MilestoneOp { get; set; }
+        public Boolean MilestoneOp { get; set; }
 
         /// <summary>
         /// 工单
@@ -98,6 +98,6 @@ namespace Business.Model.Production
         /// 是否有效:1-有效;0-无效
         /// </summary>
         [Comment("是否有效")]
-        public int? IsActive { get; set; }
+        public Boolean IsActive { get; set; }
     }
 }