Prechádzať zdrojové kódy

Merge branch 'dev' of http://123.60.180.165:4647/ZZYDOP/DOPCore into dev

tangdi 2 rokov pred
rodič
commit
9982b346ab
19 zmenil súbory, kde vykonal 216 pridanie a 367 odobranie
  1. 0 7
      MicroServices/Business/Business.Application.Contracts/ResourceExamineManagement/ISerialNumberAppService.cs
  2. 5 3
      MicroServices/Business/Business.Application.Contracts/SystemJob/ISystemJobAppService.cs
  3. 0 16
      MicroServices/Business/Business.Application/Quartz/IQuartzJobService.cs
  4. 0 16
      MicroServices/Business/Business.Application/Quartz/IWMSJobService.cs
  5. 0 20
      MicroServices/Business/Business.Application/Quartz/LogHostedService.cs
  6. 0 34
      MicroServices/Business/Business.Application/Quartz/NLogJob.cs
  7. 0 38
      MicroServices/Business/Business.Application/Quartz/ProductionScheduleJob.cs
  8. 0 33
      MicroServices/Business/Business.Application/Quartz/QuartzJobService.cs
  9. 0 34
      MicroServices/Business/Business.Application/Quartz/SyncMySQLDataJob.cs
  10. 0 29
      MicroServices/Business/Business.Application/Quartz/WMSJob.cs
  11. 0 33
      MicroServices/Business/Business.Application/Quartz/WMSJobService.cs
  12. 47 42
      MicroServices/Business/Business.Application/ResourceExamineManagement/ProductionScheduleAppService.cs
  13. 0 1
      MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs
  14. 123 6
      MicroServices/Business/Business.Application/SystemJobManagement/SystemJobAppService.cs
  15. 26 37
      MicroServices/Business/Business.Host/BusinessHostModule.cs
  16. 0 3
      MicroServices/Business/Business.Host/Startup.cs
  17. 0 11
      MicroServices/Business/Business.HttpApi/Controllers/SerialNumberController.cs
  18. 14 3
      MicroServices/Business/Business.HttpApi/Controllers/SystemJobController.cs
  19. 1 1
      MicroServices/Business/QuartzSettings/task_job.json

+ 0 - 7
MicroServices/Business/Business.Application.Contracts/ResourceExamineManagement/ISerialNumberAppService.cs

@@ -18,12 +18,5 @@ namespace Business.ResourceExamineManagement
         /// <param name="id"></param>
         /// <returns></returns>
         string GetSerialNumber(long id);
-
-        /// <summary>
-        /// 定时创建NLog日志按月分表
-        /// </summary>
-        /// <param name="id"></param>
-        /// <returns></returns>
-        string LogInstall();
     }
 }

+ 5 - 3
MicroServices/Business/Business.Application.Contracts/SystemJob/ISystemJobAppService.cs

@@ -20,20 +20,22 @@ namespace Business.SystemJob
         /// </summary>
         /// <param name="id"></param>
         /// <returns></returns>
-        string SyncWMSDataToMySQL();
+        string SyncWMSDataToMySQLJob();
 
         /// <summary>
         /// 定时创建NLog日志按月分表
         /// </summary>
         /// <param name="id"></param>
         /// <returns></returns>
-        string LogInstall();
+        string LogInstallJob();
 
         /// <summary>
         /// 定时同步MySQL基础数据到MongoDB
         /// </summary>
         /// <param name="id"></param>
         /// <returns></returns>
-        string SyncBaseDataToMongoDB();
+        string SyncBaseDataToMongoDBJob();
+
+        string DoProductShceduleJob();
     }
 }

+ 0 - 16
MicroServices/Business/Business.Application/Quartz/IQuartzJobService.cs

@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Business.Quartz
-{
-    public interface IQuartzJobService
-    {
-        /// <summary>
-        /// 定时同步mysql数据到mongodb中
-        /// </summary>
-        void SyncDataMySQLData();
-    }
-}

+ 0 - 16
MicroServices/Business/Business.Application/Quartz/IWMSJobService.cs

@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Business.Quartz
-{
-    public interface IWMSJobService
-    {
-        /// <summary>
-        /// 定时同步mysql数据到mongodb中
-        /// </summary>
-        void SyncWMSData();
-    }
-}

+ 0 - 20
MicroServices/Business/Business.Application/Quartz/LogHostedService.cs

@@ -1,20 +0,0 @@
-using Microsoft.Extensions.Hosting;
-using NLog;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Business.Quartz
-{
-    //Nlog日志按月分表,需要每天凌晨检查是否存在表,不存在就要新建表,程序启动的时候也要检查一次。类似初始化
-    public class LogHostedService
-    {
-        public void LogInstall()
-        {
-            LogManager.Configuration.Install(new NLog.Config.InstallationContext());//每天0点执行一次
-        }
-    }
-}

+ 0 - 34
MicroServices/Business/Business.Application/Quartz/NLogJob.cs

@@ -1,34 +0,0 @@
-using Business.SyncDataManagement;
-using Quartz;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Business.Quartz
-{
-    public class NLogJob : IJob
-    {
-
-        /// <summary>
-        /// Nlog日志按月分表,需要每天凌晨检查是否存在表,不存在就要新建表,程序启动的时候也要检查一次。类似初始化
-        /// </summary>
-        public readonly LogHostedService _logHostedService;
-
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        public NLogJob(LogHostedService logHostedService)
-        {
-            _logHostedService = logHostedService;
-        }
-        public Task Execute(IJobExecutionContext context)
-        {
-            _logHostedService.LogInstall();
-
-            return Task.CompletedTask;
-        }
-    }
-}

+ 0 - 38
MicroServices/Business/Business.Application/Quartz/ProductionScheduleJob.cs

@@ -1,38 +0,0 @@
-using Quartz;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Business.Quartz
-{
-    /// <summary>
-    /// 排产定时任务
-    /// </summary>
-    public class ProductionScheduleJob : IJob
-    {
-        public readonly ProductionScheduleAppService _appService;
-
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        public ProductionScheduleJob(ProductionScheduleAppService appService)
-        {
-            _appService = appService;
-        }
-
-        /// <summary>
-        /// 执行
-        /// </summary>
-        /// <param name="context"></param>
-        /// <returns></returns>
-        /// <exception cref="NotImplementedException"></exception>
-        public Task Execute(IJobExecutionContext context)
-        {
-            _appService.DoExt();
-
-            return Task.CompletedTask;
-        }
-    }
-}

+ 0 - 33
MicroServices/Business/Business.Application/Quartz/QuartzJobService.cs

@@ -1,33 +0,0 @@
-using Business.SyncDataManagement;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Business.Quartz
-{
-    public class QuartzJobService : IQuartzJobService
-    {
-        /// <summary>
-        /// 同步数据到mongodb服务
-        /// </summary>
-        public readonly SyncMySQLDataAppService _syncDataAppservice;
-
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        public QuartzJobService(SyncMySQLDataAppService syncDataAppservice)
-        {
-            _syncDataAppservice = syncDataAppservice;
-        }
-
-        /// <summary>
-        /// 定时同步mysql数据到mongodb中
-        /// </summary>
-        public void SyncDataMySQLData()
-        {
-            _syncDataAppservice.SyncBaseDataToMongoDB();
-        }
-    }
-}

+ 0 - 34
MicroServices/Business/Business.Application/Quartz/SyncMySQLDataJob.cs

@@ -1,34 +0,0 @@
-using Business.SyncDataManagement;
-using Quartz;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Business.Quartz
-{
-    public class SyncMySQLDataJob : IJob
-    {
-
-        /// <summary>
-        /// 同步数据到mongodb服务
-        /// </summary>
-        public readonly SyncMySQLDataAppService _syncDataAppservice;
-
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        public SyncMySQLDataJob(SyncMySQLDataAppService syncDataAppservice)
-        {
-            _syncDataAppservice = syncDataAppservice;
-        }
-        public Task Execute(IJobExecutionContext context)
-        {
-            _syncDataAppservice.SyncBaseDataToMongoDB();
-
-            return Task.CompletedTask;
-        }
-    }
-}

+ 0 - 29
MicroServices/Business/Business.Application/Quartz/WMSJob.cs

@@ -1,29 +0,0 @@
-using Business.SyncDataManagement;
-using Quartz;
-using System.Threading.Tasks;
-
-namespace Business.Quartz
-{
-    public class WMSJob : IJob
-    {
-
-        /// <summary>
-        /// 同步数据到mongodb服务
-        /// </summary>
-        public readonly SyncWMSDataAppService _syncDataAppservice;
-
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        public WMSJob(SyncWMSDataAppService syncDataAppservice)
-        {
-            _syncDataAppservice = syncDataAppservice;
-        }
-        public Task Execute(IJobExecutionContext context)
-        {
-            _syncDataAppservice.SyncWMSDataToMySQL();
-
-            return Task.CompletedTask;
-        }
-    }
-}

+ 0 - 33
MicroServices/Business/Business.Application/Quartz/WMSJobService.cs

@@ -1,33 +0,0 @@
-using Business.SyncDataManagement;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Business.Quartz
-{
-    public class WMSJobService : IWMSJobService
-    {
-        /// <summary>
-        /// 同步数据到mongodb服务
-        /// </summary>
-        public readonly SyncWMSDataAppService _syncDataAppservice;
-
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        public WMSJobService(SyncWMSDataAppService syncDataAppservice)
-        {
-            _syncDataAppservice = syncDataAppservice;
-        }
-
-        /// <summary>
-        /// 定时同步mysql数据到mongodb中
-        /// </summary>
-        public void SyncWMSData()
-        {
-            _syncDataAppservice.SyncWMSDataToMySQL();
-        }
-    }
-}

+ 47 - 42
MicroServices/Business/Business.Application/Quartz/ProductionScheduleAppService.cs → MicroServices/Business/Business.Application/ResourceExamineManagement/ProductionScheduleAppService.cs

@@ -16,7 +16,7 @@ using System.Transactions;
 using Volo.Abp.Application.Services;
 using Volo.Abp.MultiTenancy;
 
-namespace Business.Quartz
+namespace Business.ResourceExamineManagement
 {
     /// <summary>
     /// 生产排产服务
@@ -121,19 +121,19 @@ namespace Business.Quartz
             ISqlRepository<HolidayMaster> holidayMaster,
             ICurrentTenant currentTenant
             )
-        { 
-            _itemMaster= itemMaster;
-            _workOrdMaster= workOrdMaster;
-            _workOrdDetail= workOrdDetail;
-            _workOrdRouting= workOrdRouting;
+        {
+            _itemMaster = itemMaster;
+            _workOrdMaster = workOrdMaster;
+            _workOrdDetail = workOrdDetail;
+            _workOrdRouting = workOrdRouting;
             _prodLineDetail = prodLineDetail;
             _periodSequenceDet = periodSequenceDet;
-            _scheduleResultOpMaster= scheduleResultOpMaster;
-            _invMaster= invMaster;
-            _shopCalendarWorkCtr= shopCalendarWorkCtr;
-            _qualityLineWorkDetail= qualityLineWorkDetail;
+            _scheduleResultOpMaster = scheduleResultOpMaster;
+            _invMaster = invMaster;
+            _shopCalendarWorkCtr = shopCalendarWorkCtr;
+            _qualityLineWorkDetail = qualityLineWorkDetail;
             _holidayMaster = holidayMaster;
-            _currentTenant= currentTenant;
+            _currentTenant = currentTenant;
         }
         #endregion
 
@@ -171,11 +171,11 @@ namespace Business.Quartz
             List<ProdLineDetail> prodLines = _prodLineDetail.Select(p => workOrds.Select(m => m.ItemNum).Contains(p.Part) && p.Domain == "1001" && p.IsActive);
             List<string> lines = prodLines.Select(p => p.Line).ToList();
             //获取生产周期数据
-            List<PeriodSequenceDet> dbPeriodSequences = _periodSequenceDet.Select(p=> lines.Contains(p.Line) && p.PlanDate >= earlist && p.Domain == "1001" && p.IsActive);
+            List<PeriodSequenceDet> dbPeriodSequences = _periodSequenceDet.Select(p => lines.Contains(p.Line) && p.PlanDate >= earlist && p.Domain == "1001" && p.IsActive);
             //获取当前日期往后的排产记录数据
             List<ScheduleResultOpMaster> dbSchedules = _scheduleResultOpMaster.Select(p => lines.Contains(p.Line) && p.WorkDate >= earlist && p.Domain == "1001");
             //获取工作日历数据
-            calendars = _shopCalendarWorkCtr.Select(p=>p.Domain == "1001" && p.IsActive);
+            calendars = _shopCalendarWorkCtr.Select(p => p.Domain == "1001" && p.IsActive);
             //获取产线休息记录数据
             qualityLines = _qualityLineWorkDetail.Select(p => p.Domain == "1001" && p.IsActive);
             //获取节假日记录数据
@@ -201,16 +201,16 @@ namespace Business.Quartz
 
                 //工序预处理:确定每层级工序对应的产线
                 List<WorkOrdRoutingDto> routingDtos = ProcPretreatment(item, workOrdRoutings.Where(p => p.WorkOrd == item.WorkOrd).ToList(), prodLines, allResults);
-                
+
                 //排产前的数据校验
                 if (routingDtos.Count == 0)//没有维护主工序
                 {
                     //记录排产异常原因
-                    new NLogHelper("ProductionScheduleAppService").WriteLog("DoProductShcedule", "工单<"+ item.WorkOrd + ">的工序数据维护错误", _currentTenant.Id.ToString());
+                    new NLogHelper("ProductionScheduleAppService").WriteLog("DoProductShcedule", "工单<" + item.WorkOrd + ">的工序数据维护错误", _currentTenant.Id.ToString());
                     continue;
                 }
                 //校验每层级工序是否都维护了产线
-                if (routingDtos.Exists(p=> string.IsNullOrEmpty(p.Line)))
+                if (routingDtos.Exists(p => string.IsNullOrEmpty(p.Line)))
                 {
                     //记录排产异常原因
                     new NLogHelper("ProductionScheduleAppService").WriteLog("DoProductShcedule", "工单<" + item.WorkOrd + ">的产线数据维护错误", _currentTenant.Id.ToString());
@@ -221,7 +221,7 @@ namespace Business.Quartz
                 foreach (var rut in routingDtos)
                 {
                     var lineCals = calendars.Where(p => p.ProdLine == rut.Line).ToList();
-                    if (lineCals.Select(p=>p.WeekDay).Distinct().Count() !=7)
+                    if (lineCals.Select(p => p.WeekDay).Distinct().Count() != 7)
                     {
                         flag = true;
                         break;
@@ -242,20 +242,21 @@ namespace Business.Quartz
             }
             using (TransactionScope scope = new TransactionScope())
             {
-                try {
+                try
+                {
                     //记录排产数据
                     /*_workOrdMaster.Update(workOrds);*/
                     _periodSequenceDet.Insert(periodSequenceDtls);
                     _scheduleResultOpMaster.Insert(scheduleMasters);
                     scope.Complete();
                 }
-                catch(Exception ex)
+                catch (Exception ex)
                 {
                     new NLogHelper("ProductionScheduleAppService").WriteLog("DoProductShcedule", "记录排产数据失败:" + ex.Message, _currentTenant.Id.ToString());
                     scope.Dispose();
                 }
             }
-            
+
         }
 
         /// <summary>
@@ -265,7 +266,7 @@ namespace Business.Quartz
         /// <param name="routingDtos">每层级工序对应的产线信息,从小到大排序</param>
         /// <param name="periodsDet">生产周期</param>
         /// <param name="scheduleResults">排产结果</param>
-        public void LineSchedule(WorkOrdMaster workOrd,List<WorkOrdRoutingDto> routingDtos,List<PeriodSequenceDet> periodsDet, List<ScheduleResultOpMaster> scheduleResults)
+        public void LineSchedule(WorkOrdMaster workOrd, List<WorkOrdRoutingDto> routingDtos, List<PeriodSequenceDet> periodsDet, List<ScheduleResultOpMaster> scheduleResults)
         {
             //生产周期
             List<PeriodSequenceDet> curSequences = new List<PeriodSequenceDet>();
@@ -273,7 +274,7 @@ namespace Business.Quartz
             List<ScheduleResultOpMaster> curScheduleRsts = new List<ScheduleResultOpMaster>();
             //产线排产开始时间
             List<LineStartDto> lineStarts = new List<LineStartDto>();
-            
+
             //循环产线,排产
             foreach (var item in routingDtos)
             {
@@ -431,8 +432,8 @@ namespace Business.Quartz
         /// <param name="curCalendars"></param>
         /// <param name="curQtyDtls"></param>
         /// <returns></returns>
-        public LineScheduledDto GetScheduledPoint(WorkOrdRoutingDto routingDto,DateTime startTime, List<ShopCalendarWorkCtr> curCalendars, List<QualityLineWorkDetail> curQtyDtls)
-        { 
+        public LineScheduledDto GetScheduledPoint(WorkOrdRoutingDto routingDto, DateTime startTime, List<ShopCalendarWorkCtr> curCalendars, List<QualityLineWorkDetail> curQtyDtls)
+        {
             LineScheduledDto scheduledDto = new LineScheduledDto();
             //当天排产开始时间
             scheduledDto.StartTime = startTime;
@@ -503,12 +504,13 @@ namespace Business.Quartz
                     //获取下一个工作日开始时间
                     actStart = GetNextWorkDay(weekDay, startTime, curCalendars);
                 }
-                else {//开始时间位于当天的休息时间段
+                else
+                {//开始时间位于当天的休息时间段
                     foreach (var item in workPoints)
                     {
                         //获取下一个时间段
-                        var next = workPoints.First(p=>p.Level == item.Level + 1);
-                        if (item.EndPoint < startTime &&  startTime < next.StartPoint)
+                        var next = workPoints.First(p => p.Level == item.Level + 1);
+                        if (item.EndPoint < startTime && startTime < next.StartPoint)
                         {
                             actStart = next.StartPoint;
                             break;
@@ -601,7 +603,7 @@ namespace Business.Quartz
         /// <param name="curCalendars">当前产线工作日历</param>
         /// <param name="curQtyDtls">当前产线休息记录</param>
         /// <returns></returns>
-        public DateTime DealChildStartTime(DateTime startTime,decimal setupTime, List<ShopCalendarWorkCtr> curCalendars, List<QualityLineWorkDetail> curQtyDtls)
+        public DateTime DealChildStartTime(DateTime startTime, decimal setupTime, List<ShopCalendarWorkCtr> curCalendars, List<QualityLineWorkDetail> curQtyDtls)
         {
             //提前期转换成分钟
             decimal needMinute = setupTime * 60;
@@ -629,7 +631,7 @@ namespace Business.Quartz
             //剩余提前期
             needMinute -= curMins;
             //获取前层级时间段
-            var prePoints = workPoints.Where(p => p.Level < curPoint.Level).OrderByDescending(p=>p.Level).ToList();
+            var prePoints = workPoints.Where(p => p.Level < curPoint.Level).OrderByDescending(p => p.Level).ToList();
             bool flag = true;//标志位
             foreach (var item in prePoints)
             {
@@ -654,7 +656,7 @@ namespace Business.Quartz
                 //获取前一个工作日
                 perStartTime = GetPreWorkDay(perStartTime, curCalendars);
                 //获取前一个工作日的工作时间段数据,倒序排
-                workPoints = DealWorkDayToLevels(perStartTime, shopCal, curQtyDtls).OrderByDescending(p=>p.Level).ToList();
+                workPoints = DealWorkDayToLevels(perStartTime, shopCal, curQtyDtls).OrderByDescending(p => p.Level).ToList();
                 //当天的工作时长(分钟)
                 decimal sumWorkMins = workPoints.Sum(p => p.WorkMinutes);
                 if (sumWorkMins >= needMinute)//当天可用提前期满足
@@ -671,7 +673,8 @@ namespace Business.Quartz
                     }
                     flag = false;
                 }
-                else {
+                else
+                {
                     //当天可用提前期不满足
                     needMinute -= sumWorkMins;
                 }
@@ -695,7 +698,7 @@ namespace Business.Quartz
             DateTime nextDate = startTime.Date.AddDays(1);
             //下一天是周几
             int nextWeekDay = (weekDay + 1) % 7;
-            var calendar = curCalendars.FirstOrDefault(p=>p.WeekDay == nextWeekDay);
+            var calendar = curCalendars.FirstOrDefault(p => p.WeekDay == nextWeekDay);
             string strStart = calendar.ShiftsStart1.ToString("0.00").Replace(".", ":");
             //判断下一天是否是工作日
             if (nextWeekDay == 0 || nextWeekDay == 6)//下一天是周六或者周日,需要判断是否调班,需要加班
@@ -773,7 +776,7 @@ namespace Business.Quartz
             int weekDay = (int)startTime.DayOfWeek;
             //计算当天的开工时间点,停工时间点
             string strStart = shopCal.ShiftsStart1.ToString("0.00").Replace(".", ":");
-            DateTime dayStartPoint = Convert.ToDateTime(date + " "+ strStart);
+            DateTime dayStartPoint = Convert.ToDateTime(date + " " + strStart);
             DateTime dayEndPoint = dayStartPoint.AddHours(Convert.ToDouble(shopCal.ShiftsHours1));
             //工作时间段
             List<LineWorkPointDto> workPoints = new List<LineWorkPointDto>();
@@ -787,7 +790,7 @@ namespace Business.Quartz
             foreach (var item in curQtyDtls)
             {
                 DateTime endPoint = Convert.ToDateTime(date + " " + item.RestTimePoint);
-                dto.EndPoint= endPoint;
+                dto.EndPoint = endPoint;
                 span = dto.EndPoint - dto.StartPoint;
                 dto.WorkMinutes = (decimal)span.TotalMinutes;
                 workPoints.Add(dto);
@@ -814,13 +817,13 @@ namespace Business.Quartz
         /// <param name="prodLines">产线</param>
         /// <param name="schedules">当前工单对应产品的排产记录</param>
         /// <returns></returns>
-        public List<WorkOrdRoutingDto> ProcPretreatment(WorkOrdMaster workOrd,List<WorkOrdRouting> woRuntings, List<ProdLineDetail> prodLines, List<ScheduleResultOpMaster> schedules)
+        public List<WorkOrdRoutingDto> ProcPretreatment(WorkOrdMaster workOrd, List<WorkOrdRouting> woRuntings, List<ProdLineDetail> prodLines, List<ScheduleResultOpMaster> schedules)
         {
             List<WorkOrdRoutingDto> routingDtos = new List<WorkOrdRoutingDto>();
             //当前工单计划开始时间(默认加两天)
             DateTime planStart = workOrd.OrdDate.GetValueOrDefault().AddDays(2);
             //取主工序(第一层级工序)
-            var firsts = woRuntings.Where(p =>p.ParentOp == 0).OrderByDescending(p => p.OP).ToList();
+            var firsts = woRuntings.Where(p => p.ParentOp == 0).OrderByDescending(p => p.OP).ToList();
             if (firsts.Count == 0)
             {
                 return routingDtos;
@@ -840,13 +843,14 @@ namespace Business.Quartz
             }
             //主工序对应的产线(目前只考虑一个产品对应一条产线的情况)
             var line = prodLines.Where(p => p.Part == lastOp.ItemNum && p.Op == lastOp.OP).FirstOrDefault();
-            if (line != null) {
+            if (line != null)
+            {
                 dto.Line = line.Line;
                 dto.Rate = line.Rate;
                 dto.SetupTime = 0;
                 //获取产线占用结束时间
                 var schedule = schedules.Where(p => p.Line == line.Line).OrderByDescending(p => p.WorkEndTime).FirstOrDefault();
-                dto.StartTime = schedule == null ? planStart : (schedule.WorkEndTime <= planStart ? planStart : schedule.WorkEndTime);
+                dto.StartTime = schedule == null ? planStart : schedule.WorkEndTime <= planStart ? planStart : schedule.WorkEndTime;
             }
             routingDtos.Add(dto);
 
@@ -867,7 +871,7 @@ namespace Business.Quartz
         public void RecursionProc(List<WorkOrdRouting> woRuntings, List<WorkOrdRouting> preLevels, int level, List<WorkOrdRoutingDto> routingDtos, List<ProdLineDetail> prodLines)
         {
             //获取当前层级工序
-            var curLevels = woRuntings.Where(p => preLevels.Select(m=>m.OP).Contains(p.ParentOp)).ToList();
+            var curLevels = woRuntings.Where(p => preLevels.Select(m => m.OP).Contains(p.ParentOp)).ToList();
             if (curLevels.Count == 0)
             {
                 return;
@@ -877,8 +881,9 @@ namespace Business.Quartz
             foreach (var item in parentOps)
             {
                 var dto = new WorkOrdRoutingDto();
-                var lastOp = curLevels.Where(p=>p.ParentOp == item).OrderByDescending(m=>m.OP).FirstOrDefault();
-                if (lastOp == null){
+                var lastOp = curLevels.Where(p => p.ParentOp == item).OrderByDescending(m => m.OP).FirstOrDefault();
+                if (lastOp == null)
+                {
                     continue;
                 }
                 dto.Op = lastOp.OP;
@@ -902,7 +907,7 @@ namespace Business.Quartz
                 routingDtos.Add(dto);
             }
             //递归
-            RecursionProc(woRuntings, curLevels, level + 1, routingDtos,prodLines);
+            RecursionProc(woRuntings, curLevels, level + 1, routingDtos, prodLines);
         }
     }
 }

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

@@ -15,7 +15,6 @@ using Business.MongoModel.Production;
 using Business.MongoModel.SRM;
 using Business.MongoModel.Tech;
 using Business.PriorityManagement;
-using Business.Quartz;
 using Business.ResourceExamineManagement.Dto;
 using EFCore.BulkExtensions;
 using Microsoft.EntityFrameworkCore;

+ 123 - 6
MicroServices/Business/Business.Application/SystemJobManagement/SystemJobAppService.cs

@@ -1,16 +1,20 @@
 using Abp.Application.Services;
 using Abp.Dependency;
+using Business.Business.Dto;
 using Business.Core.MongoDBHelper;
 using Business.Core.Utilities;
+using Business.Dto;
 using Business.EntityFrameworkCore;
 using Business.EntityFrameworkCore.SqlRepositories;
 using Business.Model.MES.IC;
+using Business.Model.Production;
 using Business.Model.Sale;
 using Business.Model.SRM;
 using Business.Model.Tech;
 using Business.MongoModel.MES.IC;
 using Business.MongoModel.SRM;
 using Business.MongoModel.Tech;
+using Business.ResourceExamineManagement;
 using Business.SystemJob;
 using EFCore.BulkExtensions;
 using NLog;
@@ -18,7 +22,9 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
+using System.Transactions;
 using Volo.Abp.Domain.Repositories;
+using Volo.Abp.MultiTenancy;
 
 namespace Business.SystemJobManagement
 {
@@ -80,9 +86,6 @@ namespace Business.SystemJobManagement
         private readonly ISqlRepository<ItemMaster> _itemMaster;
         private readonly ISqlRepository<ProductStructureMaster> _productStructureMaster;
 
-
-
-
         /// <summary>
         /// 替代群组
         /// </summary>
@@ -119,6 +122,81 @@ namespace Business.SystemJobManagement
         private readonly IMongoDB<mo_mes_tech_process> _mes_tech_process;
         private IRepository<mes_tech_process, long> _mysql_mes_tech_process;
 
+
+
+        /// <summary>
+        /// 工单
+        /// </summary>
+        private ISqlRepository<WorkOrdMaster> _workOrdMaster;
+
+        /// <summary>
+        /// 工单物料明细
+        /// </summary>
+        private ISqlRepository<WorkOrdDetail> _workOrdDetail;
+
+        /// <summary>
+        /// 工单工艺路线明细
+        /// </summary>
+        private ISqlRepository<WorkOrdRouting> _workOrdRouting;
+
+        /// <summary>
+        /// 库存主数据
+        /// </summary>
+        private ISqlRepository<InvMaster> _invMaster;
+
+        /// <summary>
+        /// 生产线明细
+        /// </summary>
+        private ISqlRepository<ProdLineDetail> _prodLineDetail;
+
+        /// <summary>
+        /// 生产周期明细
+        /// </summary>
+        private ISqlRepository<PeriodSequenceDet> _periodSequenceDet;
+
+        /// <summary>
+        /// 排产结果明细
+        /// </summary>
+        private ISqlRepository<ScheduleResultOpMaster> _scheduleResultOpMaster;
+
+        /// <summary>
+        /// 工作日历数据
+        /// </summary>
+        private ISqlRepository<ShopCalendarWorkCtr> _shopCalendarWorkCtr;
+
+        /// <summary>
+        /// 产线休息时间记录表
+        /// </summary>
+        private ISqlRepository<QualityLineWorkDetail> _qualityLineWorkDetail;
+
+        /// <summary>
+        /// 节假日记录表
+        /// </summary>
+        private ISqlRepository<HolidayMaster> _holidayMaster;
+
+
+        private readonly ICurrentTenant _currentTenant;
+
+        /// <summary>
+        /// 工作日历数据
+        /// </summary>
+        private List<ShopCalendarWorkCtr> calendars;
+
+        /// <summary>
+        /// 产线休息记录数据
+        /// </summary>
+        private List<QualityLineWorkDetail> qualityLines;
+
+        /// <summary>
+        /// 节假日记录数据
+        /// </summary>
+        private List<HolidayMaster> holidays;
+
+        /// <summary>
+        /// 生产排产
+        /// </summary>
+        private readonly ProductionScheduleAppService _productionScheduleAppService;
+
         public SystemJobAppService(
          IRepository<ic_bom, long> mysql_ic_bom,
          IRepository<ic_bom_child, long> mysql_ic_bom_child,
@@ -139,6 +217,17 @@ namespace Business.SystemJobManagement
          ISqlRepository<ConsigneeAddressMaster> consigneeAddressMaster,
          ISqlRepository<ItemMaster> itemMaster,
          ISqlRepository<ProductStructureMaster> productStructureMaster,
+         ISqlRepository<WorkOrdMaster> workOrdMaster,
+         ISqlRepository<WorkOrdDetail> workOrdDetail,
+        ISqlRepository<WorkOrdRouting> workOrdRouting,
+        ISqlRepository<ProdLineDetail> prodLineDetail,
+        ISqlRepository<PeriodSequenceDet> periodSequenceDet,
+        ISqlRepository<ScheduleResultOpMaster> scheduleResultOpMaster,
+        ISqlRepository<InvMaster> invMaster,
+        ISqlRepository<ShopCalendarWorkCtr> shopCalendarWorkCtr,
+        ISqlRepository<QualityLineWorkDetail> qualityLineWorkDetail,
+        ISqlRepository<HolidayMaster> holidayMaster,
+        ICurrentTenant currentTenant,
          IMongoDB<mo_ic_bom> ic_bom,
          IMongoDB<mo_ic_bom_child> ic_bom_child,
          IMongoDB<mo_ic_item> ic_item,
@@ -150,6 +239,7 @@ namespace Business.SystemJobManagement
          IMongoDB<mo_mes_process> mes_process,
          IMongoDB<mo_mes_tech_process> mes_tech_process,
          IMongoDB<mo_srm_purchase> srm_purchase,
+         ProductionScheduleAppService productionScheduleAppService,
          BusinessDbContext businessDbContext
          )
         {
@@ -184,9 +274,22 @@ namespace Business.SystemJobManagement
             _mes_tech_process = mes_tech_process;
             _srm_purchase = srm_purchase;
             _businessDbContext = businessDbContext;
+            _itemMaster = itemMaster;
+            _workOrdMaster = workOrdMaster;
+            _workOrdDetail = workOrdDetail;
+            _workOrdRouting = workOrdRouting;
+            _prodLineDetail = prodLineDetail;
+            _periodSequenceDet = periodSequenceDet;
+            _scheduleResultOpMaster = scheduleResultOpMaster;
+            _invMaster = invMaster;
+            _shopCalendarWorkCtr = shopCalendarWorkCtr;
+            _qualityLineWorkDetail = qualityLineWorkDetail;
+            _holidayMaster = holidayMaster;
+            _currentTenant = currentTenant;
+            _productionScheduleAppService = productionScheduleAppService;
         }
 
-        public string SyncWMSDataToMySQL()
+        public string SyncWMSDataToMySQLJob()
         {
             try
             {
@@ -204,7 +307,7 @@ namespace Business.SystemJobManagement
             return "同步完成";
         }
 
-        public string LogInstall()
+        public string LogInstallJob()
         {
             try
             {
@@ -218,7 +321,7 @@ namespace Business.SystemJobManagement
 
         }
 
-        public string SyncBaseDataToMongoDB()
+        public string SyncBaseDataToMongoDBJob()
         {
             try
             {
@@ -940,5 +1043,19 @@ namespace Business.SystemJobManagement
         //    }
         //    return list;
         //}
+
+        public string DoProductShceduleJob()
+        {
+            try
+            {
+                _productionScheduleAppService.DoExt();
+            }
+            catch (Exception ex)
+            {
+                return ex.Message;
+            }
+            return "任务执行成功";
+
+        }
     }
 }

+ 26 - 37
MicroServices/Business/Business.Host/BusinessHostModule.cs

@@ -1,10 +1,7 @@
-using Autofac.Core;
-using Business.Core.MongoDBHelper;
-using Business.Core.Utilities;
+using Business.Core.MongoDBHelper;
 using Business.EntityFrameworkCore;
 using Business.MultiTenancy;
-using Business.Quartz;
-using GZY.Quartz.MUI.EFContext;
+using Bussiness.MongoDB;
 using GZY.Quartz.MUI.Extensions;
 using Microsoft.AspNetCore.Authentication.JwtBearer;
 using Microsoft.AspNetCore.Builder;
@@ -15,13 +12,9 @@ using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
-using Microsoft.Extensions.Logging;
 using Microsoft.OpenApi.Models;
 using NLog;
-using NLog.Extensions.Logging;
-using NLog.Web;
 using Quartz;
-using Serilog.Events;
 using StackExchange.Redis;
 using System;
 using System.Collections.Generic;
@@ -35,14 +28,11 @@ using Volo.Abp.AspNetCore.Mvc;
 using Volo.Abp.AspNetCore.Serilog;
 using Volo.Abp.Autofac;
 using Volo.Abp.Caching;
-using Volo.Abp.Data;
 using Volo.Abp.EntityFrameworkCore.MySQL;
 using Volo.Abp.Localization;
 using Volo.Abp.Modularity;
 using Volo.Abp.MultiTenancy;
-using Volo.Abp.Threading;
 using Volo.Abp.VirtualFileSystem;
-using Bussiness.MongoDB;
 
 namespace Business
 {
@@ -105,39 +95,38 @@ namespace Business
         private void ConfigureQuartz(ServiceConfigurationContext context, IConfiguration configuration)
         {
             //程序启动执行一次日志分表检查,可以自己初始化避免需要部署脚本
-            LogHostedService logHostedService = new LogHostedService();
-            logHostedService.LogInstall();
+            LogManager.Configuration.Install(new NLog.Config.InstallationContext());//每天0点执行一次
 
             context.Services.AddQuartz(q =>
             {
-                q.UseMicrosoftDependencyInjectionScopedJobFactory();
-                // Just use the name of your job that you created in the Jobs folder.
-                var jobKey = new JobKey("SyncDataJob");
-                q.AddJob<SyncMySQLDataJob>(opts => opts.WithIdentity(jobKey));
+                //q.UseMicrosoftDependencyInjectionScopedJobFactory();
+                //// Just use the name of your job that you created in the Jobs folder.
+                //var jobKey = new JobKey("SyncDataJob");
+                //q.AddJob<SyncMySQLDataJob>(opts => opts.WithIdentity(jobKey));
 
-                q.AddTrigger(opts => opts
-                    .ForJob(jobKey)
-                    .WithIdentity("SyncDataJob-trigger")
-                    .WithCronSchedule("0 38 10 * * ?")
-                    .WithDescription("定时同步MySQL基础数据到MongoDB"));
+                //q.AddTrigger(opts => opts
+                //    .ForJob(jobKey)
+                //    .WithIdentity("SyncDataJob-trigger")
+                //    .WithCronSchedule("0 38 10 * * ?")
+                //    .WithDescription("定时同步MySQL基础数据到MongoDB"));
 
-                var NLogJobKey = new JobKey("NLogJob");
-                q.AddJob<NLogJob>(opts => opts.WithIdentity(NLogJobKey));
+                //var NLogJobKey = new JobKey("NLogJob");
+                //q.AddJob<NLogJob>(opts => opts.WithIdentity(NLogJobKey));
 
-                q.AddTrigger(opts => opts
-                    .ForJob(NLogJobKey)
-                    .WithIdentity("NLogJob-trigger")
-                    .WithCronSchedule("0 01 01 * * ?")
-                    .WithDescription("定时创建NLog日志按月分表"));
+                //q.AddTrigger(opts => opts
+                //    .ForJob(NLogJobKey)
+                //    .WithIdentity("NLogJob-trigger")
+                //    .WithCronSchedule("0 01 01 * * ?")
+                //    .WithDescription("定时创建NLog日志按月分表"));
 
-                var WMSJobKey = new JobKey("WMSJob");
-                q.AddJob<WMSJob>(opts => opts.WithIdentity(WMSJobKey));
+                //var WMSJobKey = new JobKey("WMSJob");
+                //q.AddJob<WMSJob>(opts => opts.WithIdentity(WMSJobKey));
 
-                q.AddTrigger(opts => opts
-                    .ForJob(WMSJobKey)
-                    .WithIdentity("WMSJob-trigger")
-                    .WithCronSchedule("0 32 15 * * ?")
-                    .WithDescription("定时同步WMS物料订单等基础数据到MySQL"));
+                //q.AddTrigger(opts => opts
+                //    .ForJob(WMSJobKey)
+                //    .WithIdentity("WMSJob-trigger")
+                //    .WithCronSchedule("0 32 15 * * ?")
+                //    .WithDescription("定时同步WMS物料订单等基础数据到MySQL"));
 
                 //var ProductionScheduleJobKey = new JobKey("ProductionScheduleJob");
                 //q.AddJob<ProductionScheduleJob>(opts => opts.WithIdentity(ProductionScheduleJobKey));

+ 0 - 3
MicroServices/Business/Business.Host/Startup.cs

@@ -1,9 +1,7 @@
 using Business.Core.MongoDBHelper;
 using Business.EntityFrameworkCore.SqlRepositories;
-using Business.Quartz;
 using Business.SystemJob;
 using Business.SystemJobManagement;
-using GZY.Quartz.MUI.Extensions;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.Extensions.DependencyInjection;
@@ -20,7 +18,6 @@ namespace Business
             services.AddScoped(typeof(IMongoDB<>), typeof(MongoDBTools<>));
             services.AddScoped(typeof(ISqlRepository<>), typeof(SqlRepository<>));
             services.AddScoped<Config>();
-            services.AddScoped<LogHostedService>();
             services.AddScoped(typeof(ISystemJobAppService), typeof(SystemJobAppService));
             services.AddScoped<GZY.Quartz.MUI.Areas.MyFeature.Pages.MainModel>();
         }

+ 0 - 11
MicroServices/Business/Business.HttpApi/Controllers/SerialNumberController.cs

@@ -29,16 +29,5 @@ namespace Business.Controllers
         {
             return _SerialNumberAppService.GetSerialNumber(id);
         }
-
-        /// <summary>
-        /// 定时创建NLog日志按月分表
-        /// </summary>
-        /// <returns></returns>
-        [HttpGet]
-        [Route("loginstall")]
-        public string LogInstall()
-        {
-            return _SerialNumberAppService.LogInstall();
-        }
     }
 }

+ 14 - 3
MicroServices/Business/Business.HttpApi/Controllers/SystemJobController.cs

@@ -28,7 +28,7 @@ namespace Business.Controllers
         [Route("syncwmsdatatomysql")]
         public string SyncWMSDataToMySQL()
         {
-            return _SystemJobAppService.SyncWMSDataToMySQL();
+            return _SystemJobAppService.SyncWMSDataToMySQLJob();
         }
 
         /// <summary>
@@ -39,7 +39,7 @@ namespace Business.Controllers
         [Route("loginstall")]
         public string LogInstall()
         {
-            return _SystemJobAppService.LogInstall();
+            return _SystemJobAppService.LogInstallJob();
         }
 
         /// <summary>
@@ -50,7 +50,18 @@ namespace Business.Controllers
         [Route("syncbasedatatomongodb")]
         public string SyncBaseDataToMongoDB()
         {
-            return _SystemJobAppService.SyncBaseDataToMongoDB();
+            return _SystemJobAppService.SyncBaseDataToMongoDBJob();
+        }
+
+        /// <summary>
+        /// 排产
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet]
+        [Route("DoProductShcedule")]
+        public string DoProductShcedule()
+        {
+            return _SystemJobAppService.DoProductShceduleJob();
         }
     }
 }

+ 1 - 1
MicroServices/Business/QuartzSettings/task_job.json

@@ -1 +1 @@
-[{"TaskName":"测试定时任务","GroupName":"测试","Interval":"0 0 0 * * ?","ApiUrl":"http://123.60.180.165:8028/api/business/serialnumber","Describe":null,"LastRunTime":"2023-06-12T15:32:57","Status":6,"TaskType":2,"ApiRequestType":"GET","ApiAuthKey":null,"ApiAuthValue":null,"ApiParameter":"421240081346629","DllClassName":null,"DllActionName":null,"id":1,"timeflag":null,"changetime":null},{"TaskName":"定时任务","GroupName":"分组2","Interval":"0 0 10,14,16 * * ? ","ApiUrl":"http://123.60.180.165:8028/api/business/addon/demo","Describe":"测试定时任务,勿删","LastRunTime":"2023-06-12T15:31:30","Status":6,"TaskType":2,"ApiRequestType":"GET","ApiAuthKey":null,"ApiAuthValue":null,"ApiParameter":null,"DllClassName":null,"DllActionName":null,"id":2,"timeflag":null,"changetime":null}]
+[{"TaskName":"定时同步WMS物料订单等基础数据到MySQL","GroupName":"systemquartzjob","Interval":"0 32 15 * * ?","ApiUrl":"http://123.60.180.165:8028/api/business/systemquartzjob/syncwmsdatatomysql","Describe":"系统定时任务,勿删勿动","LastRunTime":null,"Status":6,"TaskType":2,"ApiRequestType":"GET","ApiAuthKey":null,"ApiAuthValue":null,"ApiParameter":null,"DllClassName":null,"DllActionName":null,"id":4,"timeflag":null,"changetime":null},{"TaskName":"定时同步MySQL基础数据到MongoDB","GroupName":"systemquartzjob","Interval":"0 38 10 * * ?","ApiUrl":"http://123.60.180.165:8028/api/business/systemquartzjob/syncbasedatatomongodb","Describe":"系统定时任务,勿删勿动","LastRunTime":null,"Status":6,"TaskType":2,"ApiRequestType":"GET","ApiAuthKey":null,"ApiAuthValue":null,"ApiParameter":null,"DllClassName":null,"DllActionName":null,"id":6,"timeflag":null,"changetime":null},{"TaskName":"定时创建NLog日志按月分表","GroupName":"systemquartzjob","Interval":"0 01 01 * * ?","ApiUrl":"http://123.60.180.165:8028/api/business/systemquartzjob/loginstall","Describe":"系统定时任务,勿删勿动","LastRunTime":null,"Status":6,"TaskType":2,"ApiRequestType":"GET","ApiAuthKey":null,"ApiAuthValue":null,"ApiParameter":null,"DllClassName":null,"DllActionName":null,"id":5,"timeflag":null,"changetime":null}]