فهرست منبع

Merge branch 'master' of http://123.60.180.165:4647/ZZYDOP/DOPCore

# Conflicts:
#	MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs
tangdi 3 سال پیش
والد
کامیت
e33301a43b
31فایلهای تغییر یافته به همراه474 افزوده شده و 296 حذف شده
  1. 58 0
      MicroServices/Business/Business.Application.Contracts/ResourceExamineManagement/Dto/GenerateMorderDto.cs
  2. 35 0
      MicroServices/Business/Business.Application.Contracts/ResourceExamineManagement/Dto/TechProcDto.cs
  3. 115 64
      MicroServices/Business/Business.Application/ResourceExamineManagement/MorderAppService.cs
  4. 97 48
      MicroServices/Business/Business.Application/ResourceExamineManagement/ProductExamineAppService.cs
  5. 22 10
      MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs
  6. 74 149
      MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/BusinessDbContext.cs
  7. 1 1
      MicroServices/Business/Business.Host/BusinessHostModule.cs
  8. 3 1
      MicroServices/Business/Bussiness.Model/SIM/sim_base.cs
  9. 3 1
      MicroServices/Business/Bussiness.Model/SIM/sim_issue_type.cs
  10. 3 1
      MicroServices/Business/Bussiness.Model/SIM/sim_plant.cs
  11. 3 1
      MicroServices/Business/Bussiness.Model/SIM/sim_user_relation.cs
  12. 3 1
      MicroServices/Business/Bussiness.Model/Sale/crm_seorderprog.cs
  13. 3 1
      MicroServices/Business/Bussiness.Model/Sale/crm_seorderreview.cs
  14. 3 1
      MicroServices/Business/Bussiness.Model/Sale/wms_prdprogress.cs
  15. 3 1
      MicroServices/Business/Bussiness.Model/Sale/wms_shipnotice.cs
  16. 3 1
      MicroServices/Business/Bussiness.Model/Sale/wms_shipnoticelist.cs
  17. 3 1
      MicroServices/Business/Bussiness.Model/Sale/wms_shipplan.cs
  18. 3 1
      MicroServices/Business/Bussiness.Model/Sale/wms_shipplanlist.cs
  19. 3 1
      MicroServices/Business/Bussiness.Model/SystemData/crm_customer.cs
  20. 3 1
      MicroServices/Business/Bussiness.Model/SystemData/sys_code.cs
  21. 3 1
      MicroServices/Business/Bussiness.Model/SystemData/sys_code_pre.cs
  22. 3 1
      MicroServices/Business/Bussiness.Model/SystemData/sys_config.cs
  23. 3 1
      MicroServices/Business/Bussiness.Model/SystemData/sys_measure_unit.cs
  24. 3 1
      MicroServices/Business/Bussiness.Model/SystemData/sys_post.cs
  25. 3 1
      MicroServices/Business/Bussiness.Model/SystemData/sys_post_staff.cs
  26. 3 1
      MicroServices/Business/Bussiness.Model/SystemData/sys_schedule.cs
  27. 3 1
      MicroServices/Business/Bussiness.Model/SystemData/sys_shift.cs
  28. 3 1
      MicroServices/Business/Bussiness.Model/SystemData/sys_shift_invalid_time.cs
  29. 3 1
      MicroServices/Business/Bussiness.Model/SystemData/sys_shift_schedule.cs
  30. 3 1
      MicroServices/Business/Bussiness.Model/SystemData/sys_staff.cs
  31. 3 1
      MicroServices/Business/Bussiness.Model/SystemData/sys_upload.cs

+ 58 - 0
MicroServices/Business/Business.Application.Contracts/ResourceExamineManagement/Dto/GenerateMorderDto.cs

@@ -0,0 +1,58 @@
+using Bussiness.Model.MES.IC;
+using Bussiness.Model.Sale;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.ResourceExamineManagement.Dto
+{
+    public class GenerateMorderDto
+    {
+        /// <summary>
+        /// 销售订单子表
+        /// </summary>
+        public crm_seorderentry seorderentry { get; set; }
+        /// <summary>
+        /// 物料详情
+        /// </summary>
+        public ic_item ic_Item { get; set; }
+        /// <summary>
+        /// Bom编码
+        /// </summary>
+        public string BomNumber { get; set; }
+        /// <summary>
+        /// Bom版本
+        /// </summary>
+        public string version { get; set; }
+        /// <summary>
+        /// 物料编码
+        /// </summary>
+        public string number { get; set; }
+        /// <summary>
+        /// 需要数量
+        /// </summary>
+        public decimal? Quantity { get; set; }
+        /// <summary>
+        /// 父级ID
+        /// </summary>
+        public long? ParentId { get; set; } = null;
+        /// <summary>
+        /// 生产工单类型
+        /// </summary>
+        public string morder_type { get; set; }
+        /// <summary>
+        /// 工单类型
+        /// </summary>
+        public string work_order_type { get; set; }
+        /// <summary>
+        /// 工单状态
+        /// </summary>
+        public string morder_state { get; set; }
+        /// <summary>
+        /// 工单建议开始时间
+        /// </summary>
+        public DateTime? moentry_sys_stime { get; set; } = null;
+    }
+}

+ 35 - 0
MicroServices/Business/Business.Application.Contracts/ResourceExamineManagement/Dto/TechProcDto.cs

@@ -0,0 +1,35 @@
+using Bussiness.Model.Tech;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.ResourceExamineManagement.Dto
+{
+    /// <summary>
+    /// 工艺路径处理Dto
+    /// </summary>
+    public class TechProcDto
+    {
+        /// <summary>
+        /// 工艺路径序号
+        /// </summary>
+        public int serialno { get; set; }
+
+        /// <summary>
+        /// 工艺路径
+        /// </summary>
+        public List<mes_tech_process> processes { get; set; }
+
+        /// <summary>
+        /// 工序详细情况
+        /// </summary>
+        public List<StartTimeDto> details { get; set; }
+
+        /// <summary>
+        /// 当前工序耗时
+        /// </summary>
+        public decimal sumTimes { get; set; }
+    }
+}

+ 115 - 64
MicroServices/Business/Business.Application/ResourceExamineManagement/MorderAppService.cs

@@ -40,6 +40,10 @@ namespace Business.ResourceExamineManagement
         /// 销售订单明细
         /// </summary>
         private readonly IRepository<crm_seorderentry, long> _mysql_crm_seorderentry;
+        /// <summary>
+        /// 产能检查
+        /// </summary>
+        private readonly ProductExamineAppService _productExamineAppService;
 
         #endregion
         #region 构造函数
@@ -53,7 +57,8 @@ namespace Business.ResourceExamineManagement
             IMongoDB<mes_moentry> mes_moentry,
             IMongoDB<mes_mooccupy> mes_mooccupy,
             IRepository<crm_seorder, long> mysql_crm_seorder,
-            IRepository<crm_seorderentry, long> mysql_crm_seorderentry
+            IRepository<crm_seorderentry, long> mysql_crm_seorderentry,
+            ProductExamineAppService productExamineAppService
             )
         {
 
@@ -62,6 +67,7 @@ namespace Business.ResourceExamineManagement
             _mes_mooccupy = mes_mooccupy;
             _mysql_crm_seorder = mysql_crm_seorder;
             _mysql_crm_seorderentry = mysql_crm_seorderentry;
+            _productExamineAppService = productExamineAppService;
 
         }
         #endregion
@@ -75,51 +81,58 @@ namespace Business.ResourceExamineManagement
         /// <param name="number">物料编码</param>
         /// <param name="Quantity"></param>
         /// <param name="ParentId"></param>
-        public Mes_MorderDto GenerateMorder(crm_seorderentry seorderentry, ic_item ic_Item, string BomNumber, string version, string number, decimal? Quantity, long? ParentId = null)
+        public Mes_MorderDto GenerateMorder(GenerateMorderDto generateMorderDto)
         {
             //1.库存、在制工单检查完成后 当前BOM需要自制时 产生工单。
 
             //2.每一个销售订单行对应一个工单。
             //TODO:考虑性能问题 循环调用,后期改造传递数组,批量处理数据后,批量保存。
             //获取销售订单信息
-            var seorder = _mysql_crm_seorder.FindAsync(x => x.Id == seorderentry.seorder_id).Result;
-            //物料BOM
-            //var ic_bom = _ic_bom.GetManyByCondition(x => x.bom_number == BomNumber && x.factory_id == seorderentry.factory_id).Result.FirstOrDefault();
-            //物料详情
-            //var ic_item = _ic_item.GetManyByCondition(x => x.number == number && x.factory_id == seorderentry.factory_id).Result.FirstOrDefault();
+            var seorder = _mysql_crm_seorder.FindAsync(x => x.Id == generateMorderDto.seorderentry.seorder_id).Result;
 
             mes_morder mes_Morder = new mes_morder();
             mes_Morder.GenerateNewId();
-            mes_Morder.morder_type = "销售工单";
-            mes_Morder.parent_id = ParentId;
+            mes_Morder.morder_type = generateMorderDto.morder_type;
+            mes_Morder.parent_id = generateMorderDto.ParentId;
             //mes_Morder.morder_icitem_type
-            mes_Morder.work_order_type = "常规工单";
-            mes_Morder.morder_state = "初始";
+            mes_Morder.work_order_type = generateMorderDto.work_order_type;
+            mes_Morder.morder_state = generateMorderDto.morder_state;
             mes_Morder.morder_no = string.Format("VMO{0}", DateTime.Now.ToString("yyyyMMddhhmmss"));//测试编码
-            mes_Morder.fms_number = ic_Item.fms_number;
-            mes_Morder.bom_number = BomNumber;
-            mes_Morder.fmodel = ic_Item.model;
-            //最早的开工时间3天后、 最晚时间为订单承诺时间-采购提前期-质检提前期-入库提前期-发料提前期 =最晚开工时间  最早或最晚为系统建议开工日期
-            //根绝系统配置参数 取最早或者最晚开始日期
-            //var StartDate = DateTime.Now.Date.AddDays(3);
-            //mes_Morder.moentry_sys_stime = StartDate;
-            //if (!string.IsNullOrEmpty(BomNumber))
-            //{
-            //    var ProductiveDate = ProductiveExamine(BomNumber, version, (int)(Quantity.Value));
-            //    //系统建议完工日期为 开工日期+产能检查时间=完工日期
-            //    var Day = ProductiveDate.Result / (60 * 10); //返回的分钟除以十个小时得出工作天数;
-            //    mes_Morder.moentry_sys_etime = StartDate.AddDays((double)Day);
-            //    mes_Morder.morder_need_time = ProductiveDate.Result;
-            //}
+            mes_Morder.fms_number = generateMorderDto.ic_Item.fms_number;
+            mes_Morder.bom_number = generateMorderDto.BomNumber;
+            mes_Morder.fmodel = generateMorderDto.ic_Item.model;
+            if (generateMorderDto.ParentId != null && generateMorderDto.moentry_sys_stime != null)
+            {
+                //最早的开工时间3天后、 最晚时间为订单承诺时间 - 采购提前期 - 质检提前期 - 入库提前期 - 发料提前期 = 最晚开工时间  最早或最晚为系统建议开工日期
+                //var StartDate = DateTime.Now.Date.AddDays(3);
+                mes_Morder.moentry_sys_stime = generateMorderDto.moentry_sys_stime;
+                if (!string.IsNullOrEmpty(generateMorderDto.BomNumber))
+                {
+                    ProdExamineParamDto prodExamine = new ProdExamineParamDto()
+                    {
+                        bom_number = generateMorderDto.BomNumber,
+                        version = generateMorderDto.version,
+                        packages = (int)generateMorderDto.Quantity.GetValueOrDefault(),
+                        tenantId = generateMorderDto.seorderentry.tenant_id,
+                        factoryId = generateMorderDto.seorderentry.factory_id.GetValueOrDefault()
+                    };
+                    var ProductiveDate = _productExamineAppService.ProductiveExamine(prodExamine);
+                    //系统建议完工日期为 开工日期+产能检查时间=完工日期
+                    var Day = ProductiveDate.Result / (60 * 10); //返回的分钟除以十个小时得出工作天数;
+                    mes_Morder.moentry_sys_etime = mes_Morder.moentry_sys_stime.GetValueOrDefault().AddDays((double)Day);
+                    mes_Morder.morder_need_time = ProductiveDate.Result;
+                }
+            }
+
             mes_Morder.moentry_startup_status = 0;
-            mes_Morder.tenant_id = seorderentry.tenant_id;
-            mes_Morder.factory_id = seorderentry.factory_id;
-            mes_Morder.product_code = number;
-            mes_Morder.product_name = ic_Item.name;
+            mes_Morder.tenant_id = generateMorderDto.seorderentry.tenant_id;
+            mes_Morder.factory_id = generateMorderDto.seorderentry.factory_id;
+            mes_Morder.product_code = generateMorderDto.number;
+            mes_Morder.product_name = generateMorderDto.ic_Item.name;
             mes_Morder.project_name = seorder.project_name;
-            mes_Morder.planner_num = seorderentry.planner_no;
-            mes_Morder.planner_name = seorderentry.planner_name;
-            mes_Morder.morder_date = DateTime.Now.Date;
+            mes_Morder.planner_num = generateMorderDto.seorderentry.planner_no;
+            mes_Morder.planner_name = generateMorderDto.seorderentry.planner_name;
+            mes_Morder.morder_date = DateTime.Now.Date.AddDays(1);
             //mes_Morder.morder_fstate = "计划";
             //TODO:目前没有取值位置
             mes_Morder.moentry_prd = null;
@@ -128,23 +141,23 @@ namespace Business.ResourceExamineManagement
             mes_Morder.moentry_wrkcname = null;
             mes_Morder.picking_qty = 0;
             //TODO:可删除主表字段
-            mes_Morder.unit = ic_Item.unit;
-            mes_Morder.morder_production_number = Quantity;
-            mes_Morder.need_number = Quantity;
+            mes_Morder.unit = generateMorderDto.ic_Item.unit;
+            mes_Morder.morder_production_number = generateMorderDto.Quantity;
+            mes_Morder.need_number = generateMorderDto.Quantity;
             mes_Morder.remaining_number = 0;
             //生成工单子表数据
             mes_moentry mes_Moentry = new mes_moentry();
             mes_Moentry.GenerateNewId();
             mes_Moentry.moentry_moid = mes_Morder.Id;
             mes_Moentry.moentry_mono = mes_Morder.morder_no;
-            mes_Moentry.soentry_id = seorderentry.Id;
-            mes_Moentry.fbill_no = seorderentry.bill_no;
-            mes_Moentry.fentry_id = seorderentry.entry_seq.Value;
-            mes_Moentry.unit = ic_Item.unit;
-            mes_Moentry.morder_production_number = Quantity;
-            mes_Moentry.need_number = Quantity;
+            mes_Moentry.soentry_id = generateMorderDto.seorderentry.Id;
+            mes_Moentry.fbill_no = generateMorderDto.seorderentry.bill_no;
+            mes_Moentry.fentry_id = generateMorderDto.seorderentry.entry_seq.Value;
+            mes_Moentry.unit = generateMorderDto.ic_Item.unit;
+            mes_Moentry.morder_production_number = generateMorderDto.Quantity;
+            mes_Moentry.need_number = generateMorderDto.Quantity;
             mes_Moentry.remaining_number = 0;
-            mes_Moentry.factory_id = seorderentry.factory_id;
+            mes_Moentry.factory_id = generateMorderDto.seorderentry.factory_id;
 
             Mes_MorderDto mes_MorderDto = new Mes_MorderDto();
             mes_MorderDto.mes_Morders = new List<mes_morder>();
@@ -183,7 +196,6 @@ namespace Business.ResourceExamineManagement
             //var seorderentry = await _mysql_crm_seorderentry.FindAsync(x => x.Id == seorderentry_id);
             //根据Bom编码查询出对应工单并且状态不为完成、关闭,非委外工单。
             //TODO:工单类型;
-            //TODO:占用时间是使用生产工单开始结束日期、还是系统建议开始结束时间。
             var morderList = await _mes_morder.GetManyByCondition(x => x.bom_number == bomNumber && (x.morder_state != "完成" || x.morder_state != "关闭"
             && x.morder_icitem_type != "相关委外工单") && !x.IsDeleted && x.tenant_id == seorderentry.tenant_id);
 
@@ -196,40 +208,79 @@ namespace Business.ResourceExamineManagement
 
             //首先满足需求数量工单其次判断是否满足交付日期、当数量不满足时继续查找最早交付日期订单 工单数量累加。
             //当前工单计划日期-1天 小于交付日期 && 计算生产数量-入库数据并且大于需求产品数量。
-            var morderDataList = morderList.Where(x => x.moentry_sys_etime.Value.AddDays(-1) < DeliverDate &&
+            var morderDataList = morderList.Where(x => x.moentry_sys_etime.GetValueOrDefault().AddDays(-1) < DeliverDate &&
             (x.morder_production_number - x.inventory_number) > Quantity).OrderByDescending(x => x.planner_end_date).ToList();
             List<mes_mooccupy> mes_Mooccupies = new List<mes_mooccupy>();
             //当数量或日期不满足的时候,寻找最早日期的工单
             if (morderDataList.Count == 0)
             {
-                morderDataList = morderList.Where(x => x.moentry_sys_etime.Value.AddDays(-1) < DeliverDate).OrderByDescending(x => x.planner_end_date).ToList();
+                morderDataList = morderList.Where(x => x.moentry_sys_etime.GetValueOrDefault().AddDays(-1) < DeliverDate).OrderByDescending(x => x.planner_end_date).ToList();
             }
             //存在此数据满足当前BOM交付找到最早日期工单,则返回无需后续继续检查。
             foreach (var item in morderDataList)
             {
                 //查询当前工单是否存在占用情况
                 var mooccupies = mes_mooccupyList.Where(x => x.moo_moid == item.Id).ToList();
-                if (mooccupies.Count > 0)
+                //已占用数据
+                var Sumqty = mooccupies.Count > 0 ? mooccupies.Sum(x => x.moo_qty) : 0.00m;
+                //判断此工单剩余可占用数量
+                if (item.morder_production_number - item.inventory_number - Sumqty > 0)
                 {
-                    var Sumqty = mooccupies.Count > 0 ? mooccupies.Sum(x => x.moo_qty) : 0.00m;
-                    //判断此工单剩余可占用数量
-                    if (item.morder_production_number - item.inventory_number - Sumqty > 0)
+                    #region 注释
+                    //if (Sumqty > 0 || item.inventory_number > 0)
+                    //{
+                    //    ProdExamineParamDto prodExamine = new ProdExamineParamDto()
+                    //    {
+                    //        bom_number = item.bom_number,
+                    //        version = version,
+                    //        packages = (int)(item.inventory_number + Sumqty).GetValueOrDefault(),
+                    //        tenantId = item.tenant_id,
+                    //        factoryId = item.factory_id.GetValueOrDefault()
+
+                    //    };
+                    //    //获取入库和已占用的数据的生产时长
+                    //    var ProductiveDate = _productExamineAppService.ProductiveExamine(prodExamine);
+                    //    var Day = ProductiveDate.Result / (60 * 10);
+                    //    //工单被完全占用结束日期为工单结束时间
+                    //    if (Quantity - (item.morder_production_number - item.inventory_number - Sumqty) == 0)
+                    //    {
+
+                    //        var date = item.moentry_sys_stime.GetValueOrDefault().AddDays((double)Day);
+                    //        var endDate = item.moentry_sys_etime;
+                    //    }
+                    //    //工单未被完成占用计算结束日期
+                    //    else if (item.morder_production_number - item.inventory_number - Sumqty - Quantity > 0)
+                    //    {
+                    //        var date = item.moentry_sys_stime.GetValueOrDefault().AddDays((double)Day);
+                    //        ProdExamineParamDto EndprodExamine = new ProdExamineParamDto()
+                    //        {
+                    //            bom_number = item.bom_number,
+                    //            version = version,
+                    //            packages = (int)Quantity.GetValueOrDefault(),
+                    //            tenantId = item.tenant_id,
+                    //            factoryId = item.factory_id.GetValueOrDefault()
+
+                    //        };
+                    //        var EndProductiveDate = _productExamineAppService.ProductiveExamine(EndprodExamine);
+                    //        var EndDay = ProductiveDate.Result / (60 * 10);
+                    //        var endDate = date.AddDays((double)EndDay);
+                    //    }
+
+                    //}
+
+                    #endregion
+                    var Sum = item.morder_production_number - item.inventory_number - Sumqty;
+                    //剩余需要数量= 需要数量 -(计划数量 - 入库数量 - 已占用量)
+                    Quantity = Quantity - (item.morder_production_number - item.inventory_number - Sumqty);
+                    var mes_Mooccupy = GetMooccupies(seorderentry, ic_Item, item, Sum);
+                    mes_Mooccupies.Add(mes_Mooccupy);
+                    //当剩余需要数量大于0则继续寻找可占用工单,已满足需要数量停止循环查找
+                    if (Quantity <= 0)
                     {
-                        var Sum = item.morder_production_number - item.inventory_number - Sumqty;
-                        //剩余需要数量= 需要数量 -(计划数量 - 入库数量 - 已占用量)
-                        Quantity = Quantity - (item.morder_production_number - item.inventory_number - Sumqty);
-                        //当剩余需要数量大于0则继续寻找可占用工单,已满足需要数量停止循环查找
-                        if (Quantity > 0)
-                        {
-                            var mes_Mooccupy = GetMooccupies(seorderentry, ic_Item, item, Sum);
-                            mes_Mooccupies.Add(mes_Mooccupy);
-                        }
-                        else
-                        {
-                            break;
-                        }
+                        break;
                     }
                 }
+
             }
             await _mes_mooccupy.InsertMany(mes_Mooccupies);
             #region 注释
@@ -333,7 +384,7 @@ namespace Business.ResourceExamineManagement
             //生成mes_mooccupy工单占用表数据,代表多个工单被某个销售订单已占用。 
             mes_mooccupy mes_Mooccupy = new mes_mooccupy();
             mes_Mooccupy.GenerateNewId();
-            mes_Mooccupy.moo_id_type = "分配";
+            mes_Mooccupy.moo_id_type = "资源检查";
             mes_Mooccupy.moo_id_billid = seorderentry.seorder_id;//销售订单ID
             mes_Mooccupy.fbill_no = seorderentry.bill_no;//销售订单号
             mes_Mooccupy.fentry_id = seorderentry.entry_seq.Value;//销售订单行

+ 97 - 48
MicroServices/Business/Business.Application/ResourceExamineManagement/ProductExamineAppService.cs

@@ -105,7 +105,7 @@ namespace Business.ResourceExamineManagement
             //1.3、获取当前工艺路径下的工序数据
             //FilterDefinition<mes_process> filter = Builders<mes_process>.Filter.In(s => s.Id, tech_Processes.Select(m => m.proc_id).ToList());
             //List<mes_process> process = await _mes_process.GetManyByIds(filter);
-            List<long> procIds = tech_Processes.Select(m => m.proc_id.Value).ToList();
+            List<long> procIds = tech_Processes.Select(m => m.proc_id.GetValueOrDefault()).ToList();
             List<mes_process> process = await _mes_process.GetManyByCondition(p => procIds.Contains(p.Id) && p.tenant_id == param.tenantId && p.factory_id == param.factoryId && !p.IsDeleted);
 
             //1.3、获取工艺工序关联工位信息
@@ -113,42 +113,72 @@ namespace Business.ResourceExamineManagement
             List<mes_tech_proc_workshop> tech_Proc_Workshops = await _mes_tech_proc_workshop.GetManyByCondition(p => techProcIds.Contains(p.tech_proc_id.Value) && p.tenant_id == param.tenantId && p.factory_id == param.factoryId && !p.IsDeleted);
             #endregion
 
-            //1、获取工艺路径下的第一层级工序
-            List<mes_tech_process> fistChilds = tech_Processes.Where(p => p.parentprocid == tech.Id).ToList();
-            if (fistChilds.Count == 0)
+            //1、获取工艺路径下的第一层级工序:目前只考虑第一层级
+            List<mes_tech_process> fistLevels = tech_Processes.Where(p => p.parentprocid == tech.Id).ToList();
+            if (fistLevels.Count == 0)
             {
                 throw new NotImplementedException("当前工艺路径没有配置工序,请调整!");
             }
-            List<mes_tech_process> sortChilds = new List<mes_tech_process>();
-            //添加最后一个工序
-            var last = fistChilds.FirstOrDefault(p => p.nextprocid == null);
-            if (last == null)
+            //工艺预处理
+            List<TechProcDto> teches = TechProcPretreatment(fistLevels,param.packages);
+            decimal sumTimes = teches.OrderByDescending(p => p.sumTimes).First().sumTimes;
+            return sumTimes;
+        }
+
+        /// <summary>
+        /// 工序预处理,按照多分支生成多条单独的工艺路径
+        /// </summary>
+        /// <param name="proc">当前工序</param>
+        /// <param name="processes">工艺关联工序list</param>
+        /// <param name="packages">生产件数</param>
+        /// <returns></returns>
+        private List<TechProcDto> TechProcPretreatment(List<mes_tech_process> processes,int packages)
+        { 
+            //工艺路径预处理dto
+            List<TechProcDto> techProcDtos = new List<TechProcDto>();
+            TechProcDto dto;
+            //获取下一步工序id
+            List<long> nextProcIds = processes.Where(p=>p.nextprocid != null).Select(p => p.nextprocid.GetValueOrDefault()).ToList();
+            //获取起点工序
+            var startProcs = processes.Where(p => !nextProcIds.Contains(p.proc_id.GetValueOrDefault())).ToList();
+            //递归处理工序返回值
+            List<mes_tech_process> rtnList;
+            for (int i = 0; i < startProcs.Count; i++)
             {
-                throw new NotImplementedException("当前工艺路径没有配置最终工序,请调整!");
+                dto = new TechProcDto();
+                rtnList = new List<mes_tech_process>();
+                GetNextProc(startProcs[i], processes, rtnList);
+                dto.serialno = i + 1;
+                dto.processes = rtnList;
+                dto.details = CalcTakeTimeByLq(rtnList, packages);//通过Lq计算
+                //dto.details = CalcTakeTimeByLqt(rtnList, packages);//通过Lqt计算
+                dto.sumTimes = dto.details.Sum(p=>p.wait_time);
+                techProcDtos.Add(dto);
             }
-            sortChilds.Add(last);
-            //递归按工序先后顺序排序
-            SortProcess(fistChilds, last.proc_id.Value, sortChilds);
-            //总耗时(分钟)
-            //decimal sumTimes = CalcTakeTimeByLq(sortChilds, param.packages);//通过Lq计算
-            decimal sumTimes = CalcTakeTimeByLqt(sortChilds, param.packages);//通过Lqt计算
-            return sumTimes;
+            return techProcDtos;
         }
 
         /// <summary>
-        /// 递归:工序按照先后顺序排序-暂时不考虑两个分支合并到一个分支的情况
+        /// 递归:根据起始工序,获取后续工序
         /// </summary>
-        /// <param name="Processes"></param>
-        /// <param name="processId"></param>
-        /// <param name="sortProcesses"></param>
-        private void SortProcess(List<mes_tech_process> Processes, long processId, List<mes_tech_process> sortProcesses)
+        /// <param name="proc"></param>
+        /// <param name="processes"></param>
+        /// <param name="rtnList"></param>
+        private void GetNextProc(mes_tech_process proc, List<mes_tech_process> processes, List<mes_tech_process> rtnList)
         {
-            var curProcess = Processes.Where(p => p.nextprocid == processId).FirstOrDefault();
-            if (curProcess != null)
+            rtnList.Add(proc);
+            //下一工序id为null,终止
+            if (proc?.nextprocid == null)
+            {
+                return;
+            }
+            //获取下一个工序
+            var nextProc = processes.FirstOrDefault(p=>p.proc_id == proc.nextprocid);
+            if (nextProc == null) 
             {
-                sortProcesses.AddFirst(curProcess);
-                SortProcess(Processes, curProcess.proc_id.Value, sortProcesses);
+                return;
             }
+            GetNextProc(nextProc, processes, rtnList);
         }
 
         /// <summary>
@@ -157,9 +187,8 @@ namespace Business.ResourceExamineManagement
         /// <param name="Processes"></param>
         /// <param name="packages"></param>
         /// <returns></returns>
-        private decimal CalcTakeTimeByLq(List<mes_tech_process> Processes, int packages)
+        private List<StartTimeDto> CalcTakeTimeByLq(List<mes_tech_process> Processes, int packages)
         {
-            decimal sumTimes = 0.00m;//总耗时(分钟)
             //工序需要等待时间记录
             List<StartTimeDto> starts = new List<StartTimeDto>();
             StartTimeDto dto;
@@ -173,13 +202,12 @@ namespace Business.ResourceExamineManagement
                 }
                 else
                 {
-                    dto = CalcProcTakeTimeByLq(chd, chd.lq.Value, packages);
+                    dto = CalcProcTakeTimeByLq(chd, chd.lq.GetValueOrDefault(), packages);
                 }
-                sumTimes += dto.wait_time;
                 //添加记录
                 starts.Add(dto);
             }
-            return sumTimes;
+            return starts;
         }
 
         /// <summary>
@@ -194,23 +222,35 @@ namespace Business.ResourceExamineManagement
             //记录当前工序耗时
             StartTimeDto dto = new StartTimeDto();
             //添加耗时记录
-            dto.tech_id = proc.tech_id.Value;
-            dto.proc_id = proc.proc_id.Value;
+            dto.tech_id = proc.tech_id.GetValueOrDefault();
+            dto.proc_id = proc.proc_id.GetValueOrDefault();
             dto.nextproc_id = proc.nextprocid;
             if (proc.wctype == 1)//人工型:数量/uph(一小时生产数量)*60(小时转换为分钟)/wsinuse(工位数)
             {
-                dto.wait_time = quantity / proc.uph.Value * 60 / proc.wsinuse.Value;
-                dto.take_time = packages / proc.uph.Value * 60 / proc.wsinuse.Value;
+                if ( proc.uph.GetValueOrDefault() == 0 || proc.wsinuse.GetValueOrDefault() == 0)
+                {
+                    throw new NotImplementedException("当前工序uph或wsinuse参数配置错误,请调整!");
+                }
+                dto.wait_time = quantity / proc.uph.GetValueOrDefault() * 60 / proc.wsinuse.GetValueOrDefault();
+                dto.take_time = packages / proc.uph.GetValueOrDefault() * 60 / proc.wsinuse.GetValueOrDefault();
             }
             else if (proc.wctype == 2)//流水线型:数量*ct(生产一件所需时间)/wsinuse(工位数)
             {
-                dto.wait_time = quantity * proc.ct.Value / proc.wsinuse.Value;
-                dto.take_time = packages * proc.ct.Value / proc.wsinuse.Value;
+                if (proc.ct.GetValueOrDefault() == 0 || proc.wsinuse.GetValueOrDefault() == 0)
+                {
+                    throw new NotImplementedException("当前工序ct或wsinuse参数配置错误,请调整!");
+                }
+                dto.wait_time = quantity * proc.ct.GetValueOrDefault() / proc.wsinuse.GetValueOrDefault();
+                dto.take_time = packages * proc.ct.GetValueOrDefault() / proc.wsinuse.GetValueOrDefault();
             }
             else if (proc.wctype == 3)//设备型:向上取整(数量/一次可加工数量/wsinuse(工位数))*ct(老化一次所需时间)
             {
-                dto.wait_time = Math.Ceiling(quantity / proc.upe.Value / proc.wsinuse.Value) * proc.ct.Value;
-                dto.take_time = Math.Ceiling(packages / proc.upe.Value / proc.wsinuse.Value) * proc.ct.Value;
+                if (proc.upe.GetValueOrDefault() == 0 || proc.wsinuse.GetValueOrDefault() == 0|| proc.ct.GetValueOrDefault() == 0)
+                {
+                    throw new NotImplementedException("当前工序upe或ct或wsinuse参数配置错误,请调整!");
+                }
+                dto.wait_time = Math.Ceiling(quantity / proc.upe.GetValueOrDefault() / proc.wsinuse.GetValueOrDefault()) * proc.ct.GetValueOrDefault();
+                dto.take_time = Math.Ceiling(packages / proc.upe.GetValueOrDefault() / proc.wsinuse.GetValueOrDefault()) * proc.ct.GetValueOrDefault();
             }
             return dto;
         }
@@ -221,10 +261,8 @@ namespace Business.ResourceExamineManagement
         /// <param name="Processes"></param>
         /// <param name="packages"></param>
         /// <returns></returns>
-        private decimal CalcTakeTimeByLqt(List<mes_tech_process> Processes, int packages)
+        private List<StartTimeDto> CalcTakeTimeByLqt(List<mes_tech_process> Processes, int packages)
         {
-            //总耗时
-            decimal sumTimes = 0;
             //工序需要等待时间记录
             List<StartTimeDto> starts = new List<StartTimeDto>();
             StartTimeDto dto;
@@ -232,8 +270,8 @@ namespace Business.ResourceExamineManagement
             {
                 dto = new StartTimeDto();
                 //添加耗时记录
-                dto.tech_id = chd.tech_id.Value;
-                dto.proc_id = chd.proc_id.Value;
+                dto.tech_id = chd.tech_id.GetValueOrDefault();
+                dto.proc_id = chd.proc_id.GetValueOrDefault();
                 dto.nextproc_id = chd.nextprocid;
 
                 //计算当前工序生产耗时
@@ -246,11 +284,10 @@ namespace Business.ResourceExamineManagement
                 {
                     dto.wait_time = chd.lqt.Value;
                 }
-                sumTimes += dto.wait_time;
                 //添加记录
                 starts.Add(dto);
             }
-            return sumTimes;
+            return starts;
         }
 
         /// <summary>
@@ -266,15 +303,27 @@ namespace Business.ResourceExamineManagement
 
             if (proc.wctype == 1)//人工型:数量/uph(一小时生产数量)*60(小时转换为分钟)/wsinuse(工位数)
             {
-                takeTiem = packages / proc.uph.Value * 60 / proc.wsinuse.Value;
+                if (proc.uph.GetValueOrDefault() == 0 || proc.wsinuse.GetValueOrDefault() == 0)
+                {
+                    throw new NotImplementedException("当前工序uph或wsinuse参数配置错误,请调整!");
+                }
+                takeTiem = packages / proc.uph.GetValueOrDefault() * 60 / proc.wsinuse.GetValueOrDefault();
             }
             else if (proc.wctype == 2)//流水线型:数量*ct(生产一件所需时间)/wsinuse(工位数)
             {
-                takeTiem = packages * proc.ct.Value / proc.wsinuse.Value;
+                if (proc.ct.GetValueOrDefault() == 0 || proc.wsinuse.GetValueOrDefault() == 0)
+                {
+                    throw new NotImplementedException("当前工序ct或wsinuse参数配置错误,请调整!");
+                }
+                takeTiem = packages * proc.ct.GetValueOrDefault() / proc.wsinuse.GetValueOrDefault();
             }
             else if (proc.wctype == 3)//设备型:向上取整(数量/一次可加工数量/wsinuse(工位数))*ct(老化一次所需时间)
             {
-                takeTiem = Math.Ceiling(packages / proc.upe.Value / proc.wsinuse.Value) * proc.ct.Value;
+                if (proc.upe.GetValueOrDefault() == 0 || proc.wsinuse.GetValueOrDefault() == 0 || proc.ct.GetValueOrDefault() == 0)
+                {
+                    throw new NotImplementedException("当前工序upe或ct或wsinuse参数配置错误,请调整!");
+                }
+                takeTiem = Math.Ceiling(packages / proc.upe.GetValueOrDefault() / proc.wsinuse.GetValueOrDefault()) * proc.ct.GetValueOrDefault();
             }
             return takeTiem;
         }

+ 22 - 10
MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs

@@ -416,9 +416,9 @@ namespace Business.ResourceExamineManagement
                 //GenerateMorder(o, 0);
             }
             //订单行资源检查明细list
-            rtn.examines = examines;
             rtn.srm_pr_list = SRMPRDtoList;
             rtn.order_list = orderList;
+            rtn.examines = examines;
             rtn.sklist = sklist;
             return JsonConvert.SerializeObject(rtn);
         }
@@ -922,7 +922,21 @@ namespace Business.ResourceExamineManagement
                     returnlist[0].satisfy_time = mooccupylist[0]?.moo_etime;
                     returnlist[0].stock_state = 0;
                     //生成主工单
-                    mes_MorderDto = _morderAppService.GenerateMorder(sentrys, ic_item, returnlist[0].bom_number, returnlist[0].version, returnlist[0].item_number, returnlist[0].lack_qty);
+                    GenerateMorderDto generateMorderDto = new GenerateMorderDto()
+                    {
+                        seorderentry = sentrys,
+                        ic_Item = ic_item,
+                        BomNumber = returnlist[0].bom_number,
+                        version = returnlist[0].version,
+                        number = returnlist[0].item_number,
+                        Quantity = returnlist[0].lack_qty,
+                        morder_type = "销售工单",
+                        work_order_type = "常规工单",
+                        morder_state = "初始",
+
+                    };
+                    //生成主工单
+                    mes_MorderDto = _morderAppService.GenerateMorder(generateMorderDto);
                 }
             }
             else {
@@ -940,9 +954,8 @@ namespace Business.ResourceExamineManagement
             //这里更新产品得满足时间。
             if (mes_MorderDto != null)
             {
-                //TODO:目前不考虑子工单 只存在单条数据先这样取值;
-                var mes_Morders = mes_MorderDto.mes_Morders.FirstOrDefault();
-                var mes_Moentry = mes_MorderDto.mes_Moentries.FirstOrDefault();
+                //主工单最后计算满足日期
+                var mes_Morders = mes_MorderDto.mes_Morders.Where(x => x.parent_id == null).FirstOrDefault();
                 if (mes_Morders != null)
                 {
                     if (!string.IsNullOrEmpty(mes_Morders.bom_number))
@@ -961,13 +974,12 @@ namespace Business.ResourceExamineManagement
                         var ProductiveDate = _productExamineAppService.ProductiveExamine(prodExamine);
                         var Day = ProductiveDate.Result / (60 * 10); //返回的分钟除以十个小时得出工作天数;
                         mes_Morders.moentry_sys_stime = returnlist[0].kitting_time.Value.AddDays(1);//数据齐套完成后隔天开始生产;
+                        //结束日期=开始时间+生产时长+自检提前期+入库提前期+发运提前期;
                         var LeadTime = Day + plan.self_inspection_date.Value + plan.Shipping_date.Value + plan.Warehousing_date.Value;
-                        mes_Morders.moentry_sys_etime = returnlist[0].kitting_time.Value.AddDays((double)LeadTime);//结束日期=开始时间+生产时长+自检提前期+入库提前期+发运提前期;
+                        mes_Morders.moentry_sys_etime = mes_Morders.moentry_sys_stime.Value.AddDays((double)Day);
                         mes_Morders.morder_need_time = ProductiveDate.Result;
-                        if (!returnlist[0].satisfy_time.HasValue || returnlist[0].satisfy_time < mes_Morders.moentry_sys_etime)
-                        {
-                            returnlist[0].satisfy_time = mes_Morders.moentry_sys_etime;
-                        }
+                        //满足资源检查的时间需加上提前期
+                        returnlist[0].satisfy_time = mes_Morders.moentry_sys_stime.Value.AddDays((double)LeadTime);
                     }
                     //批量保存 后期考虑子工单
                     _mes_morder.InsertMany(mes_MorderDto.mes_Morders);

+ 74 - 149
MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/BusinessDbContext.cs

@@ -2,7 +2,9 @@ using Business.Model;
 using Business.Models;
 using Bussiness.Model.MES.IC;
 using Bussiness.Model.Production;
+using Bussiness.Model.ProductionProcess;
 using Bussiness.Model.Sale;
+using Bussiness.Model.SIM;
 using Bussiness.Model.SRM;
 using Bussiness.Model.SystemData;
 using Bussiness.Model.Tech;
@@ -23,185 +25,108 @@ namespace Business.EntityFrameworkCore
 
         public DbSet<PrintTemplate> PrintTemplate { get; set; }
 
-        public DbSet<ic_bom> ic_Bom { get; set; }
-
-        public DbSet<wms_prdprogress> wms_Prdprogresses { get; set; }
-
-        /// <summary>
-        /// 销售订单
-        /// </summary>
-        public DbSet<crm_seorder> crm_seorder { get; set; }
-        /// <summary>
-        /// 销售订单子表
-        /// </summary>
-        public DbSet<crm_seorderentry> crm_seorderentry { get; set; }
-        #region 工单
-        /// <summary>
-        /// 在制工单占用记录表
-        /// </summary>
-        public DbSet<mes_mooccupy> mes_mooccupy { get; set; }
-        /// <summary>
-        /// 工单主表
-        /// </summary>
-        public DbSet<mes_morder> mes_morder { get; set; }
-        /// <summary>
-        /// 工单子表
-        /// </summary>
-        public DbSet<mes_moentry> mes_moentry { get; set; }
-        #endregion
-        #region 物料
-        /// <summary>
-        /// 物料详情
-        /// </summary>
-        public DbSet<ic_item> ic_Item { get; set; }
-
-        /// <summary>
-        /// 物料BOM
-        /// </summary>
+        #region MES/IC
         public DbSet<ic_bom> ic_bom { get; set; }
-
-        /// <summary>
-        /// 物料BOM明细
-        /// </summary>
         public DbSet<ic_bom_child> ic_bom_child { get; set; }
-
-        /// <summary>
-        /// 物料质检
-        /// </summary>
         public DbSet<ic_check> ic_check { get; set; }
-
-        /// <summary>
-        /// 工厂物料明细表
-        /// </summary>
         public DbSet<ic_factory_details> ic_factory_details { get; set; }
-
-        /// <summary>
-        /// 物料IE信息
-        /// </summary>
+        public DbSet<ic_item> ic_item { get; set; }
         public DbSet<ic_item_ie> ic_item_ie { get; set; }
-
-        /// <summary>
-        /// 物料库存明细表
-        /// </summary>
         public DbSet<ic_item_inventory> ic_item_inventory { get; set; }
-
-        /// <summary>
-        /// 物料采购报价单
-        /// </summary>
         public DbSet<ic_item_pur> ic_item_pur { get; set; }
-
-        /// <summary>
-        /// 物料库存表
-        /// </summary>
         public DbSet<ic_item_stock> ic_item_stock { get; set; }
-
-        /// <summary>
-        /// 物料计量表
-        /// </summary>
+        public DbSet<ic_item_stockoccupy> ic_item_stockoccupy { get; set; }
         public DbSet<ic_metering_unit> ic_metering_unit { get; set; }
-
-        /// <summary>
-        /// 物料采购计划表
-        /// </summary>
         public DbSet<ic_plan> ic_plan { get; set; }
-
-        /// <summary>
-        /// 替代群组
-        /// </summary>
         public DbSet<ic_substitute> ic_substitute { get; set; }
-
-        /// <summary>
-        /// 物料替代多群组
-        /// </summary>
         public DbSet<ic_substitute_all> ic_substitute_all { get; set; }
-
-        /// <summary>
-        /// 物料替代多群组明细
-        /// </summary>
         public DbSet<ic_substitute_all_dtl> ic_substitute_all_dtl { get; set; }
         #endregion
 
-        #region 工艺路径
+        #region Production
+        public DbSet<mes_moentry> mes_moentry { get; set; }
+        public DbSet<mes_mooccupy> mes_mooccupy { get; set; }
+        public DbSet<mes_morder> mes_morder { get; set; }
+        public DbSet<mes_morder_loss_time> mes_morder_loss_time { get; set; }
+        public DbSet<mes_oorder> mes_oorder { get; set; }
+        public DbSet<mes_schedule_occupy> mes_schedule_occupy { get; set; }
+        public DbSet<mes_stockoccupy> mes_stockoccupy { get; set; }
+        #endregion
 
-        /// <summary>
-        /// 工序
-        /// </summary>
-        public DbSet<mes_process> mes_process { get; set; }
+        #region ProductionProcess
+        public DbSet<mes_loss_time_record> mes_loss_time_record { get; set; }
+        public DbSet<mes_meaction> mes_meaction { get; set; }
+        public DbSet<mes_mebycard> mes_mebycard { get; set; }
+        public DbSet<mes_merecheck> mes_merecheck { get; set; }
+        public DbSet<mes_mereport> mes_mereport { get; set; }
+        public DbSet<mes_prd_sendmat> mes_prd_sendmat { get; set; }
+        public DbSet<mes_prd_sendmat_list> mes_prd_sendmat_list { get; set; }
+        public DbSet<mes_prdlog> mes_prdlog { get; set; }
+        public DbSet<mes_product_work_time> mes_product_work_time { get; set; }
+        public DbSet<mes_stock_enter> mes_stock_enter { get; set; }
+        public DbSet<mes_stock_out> mes_stock_out { get; set; }
+        public DbSet<mes_swipe_card> mes_swipe_card { get; set; }
+        #endregion
 
-        /// <summary>
-        /// 治具表
-        /// </summary>
-        public DbSet<mes_tech_proc_accessory> mes_tech_proc_accessory { get; set; }
+        #region Sale
+        public DbSet<crm_seorder> crm_seorder { get; set; }
+        public DbSet<crm_seorderentry> crm_seorderentry { get; set; }
+        public DbSet<crm_seorderprog> crm_seorderprog { get; set; }
+        public DbSet<crm_seorderreview> crm_seorderreview { get; set; }
+        public DbSet<wms_prdprogress> wms_prdprogress { get; set; }
+        public DbSet<wms_shipnotice> wms_shipnotice { get; set; }
+        public DbSet<wms_shipnoticelist> wms_shipnoticelist { get; set; }
+        public DbSet<wms_shipplan> wms_shipplan { get; set; }
+        public DbSet<wms_shipplanlist> wms_shipplanlist { get; set; }
+        #endregion
 
-        /// <summary>
-        /// 工序作业指导书表
-        /// </summary>
-        public DbSet<mes_tech_proc_document> mes_tech_proc_document { get; set; }
+        #region SIM
+        public DbSet<sim_base> sim_base { get; set; }
+        public DbSet<sim_issue_type> sim_issue_type { get; set; }
+        public DbSet<sim_plant> sim_plant { get; set; }
+        public DbSet<sim_user_relation> sim_user_relation { get; set; }
+        #endregion
 
-        /// <summary>
-        /// 工序关联设备表
-        /// </summary>
-        public DbSet<mes_tech_proc_equipment> mes_tech_proc_equipment { get; set; }
+        #region SRM
+        public DbSet<srm_po_list> srm_po_list { get; set; }
+        public DbSet<srm_po_main> srm_po_main { get; set; }
+        public DbSet<srm_po_occupy> srm_po_occupy { get; set; }
+        public DbSet<srm_pr_main> srm_pr_main { get; set; }
+        public DbSet<srm_purchase> srm_purchase { get; set; }
+        #endregion
 
-        /// <summary>
-        /// 发料到工序表
-        /// </summary>
-        public DbSet<mes_tech_proc_icitem> mes_tech_proc_icitem { get; set; }
+        #region SystemData
+        public DbSet<crm_customer> crm_customer { get; set; }
+        public DbSet<srm_supplier> srm_supplier { get; set; }
+        public DbSet<sys_code> sys_code { get; set; }
+        public DbSet<sys_code_pre> sys_code_pre { get; set; }
+        public DbSet<sys_config> sys_config { get; set; }
+        public DbSet<sys_measure_unit> sys_measure_unit { get; set; }
+        public DbSet<sys_post> sys_post { get; set; }
+        public DbSet<sys_post_staff> sys_post_staff { get; set; }
+        public DbSet<sys_schedule> sys_schedule { get; set; }
+        public DbSet<sys_shift> sys_shift { get; set; }
+        public DbSet<sys_shift_invalid_time> sys_shift_invalid_time { get; set; }
+        public DbSet<sys_shift_schedule> sys_shift_schedule { get; set; }
+        public DbSet<sys_staff> sys_staff { get; set; }
+        public DbSet<sys_upload> sys_upload { get; set; }
+        #endregion
 
-        /// <summary>
-        /// 工艺路径关联工位表
-        /// </summary>
+        #region Tech
+        public DbSet<mes_process> mes_process { get; set; }
+        public DbSet<mes_tech_proc_accessory> mes_tech_proc_accessory { get; set; }
+        public DbSet<mes_tech_proc_document> mes_tech_proc_document { get; set; }
+        public DbSet<mes_tech_proc_equipment> mes_tech_proc_equipment { get; set; }
+        public DbSet<mes_tech_proc_icitem> mes_tech_proc_icitem { get; set; }
         public DbSet<mes_tech_proc_workshop> mes_tech_proc_workshop { get; set; }
-
-        /// <summary>
-        /// 工序工位员工信息表
-        /// </summary>
         public DbSet<mes_tech_proc_workshop_staff> mes_tech_proc_workshop_staff { get; set; }
-
-        /// <summary>
-        /// 工艺关联工序表
-        /// </summary>
         public DbSet<mes_tech_process> mes_tech_process { get; set; }
-
-        /// <summary>
-        /// 工艺路径表
-        /// </summary>
         public DbSet<mes_technique> mes_technique { get; set; }
-
-        /// <summary>
-        /// 工作日历
-        /// </summary>
         public DbSet<mes_work_calendar> mes_work_calendar { get; set; }
-
-        /// <summary>
-        /// 工作日历明细表
-        /// </summary>
         public DbSet<mes_work_calendar_list> mes_work_calendar_list { get; set; }
-
-        /// <summary>
-        /// 工位表
-        /// </summary>
         public DbSet<mes_workshop> mes_workshop { get; set; }
-
-        /// <summary>
-        /// 工位关联线边仓表
-        /// </summary>
         public DbSet<mes_workshop_shelf> mes_workshop_shelf { get; set; }
         #endregion
-
-        #region SRM
-        public DbSet<srm_pr_main> srm_pr_main { get; set; }
-        public DbSet<mes_oorder> mes_oorder { get; set; }
-        public DbSet<srm_po_main> srm_po_main { get; set; }
-        public DbSet<srm_po_list> srm_po_list { get; set; }
-
-        public DbSet<srm_po_occupy> srm_po_occupy { get; set; }
-
-        /// <summary>
-        /// 供应商
-        /// </summary>
-        public DbSet<srm_supplier> srm_supplier { get; set; }
-        #endregion
         //Code generation...
         public BusinessDbContext(DbContextOptions<BusinessDbContext> options)
             : base(options)

+ 1 - 1
MicroServices/Business/Business.Host/BusinessHostModule.cs

@@ -316,7 +316,7 @@ namespace Business
                 DashboardTitle = "任务调度中心"
             });
 
-            RecurringJob.AddOrUpdate<IHangFireJobService>(a=>a.SyncDataMySQLData(),CronType.Day(0,0,1));
+            RecurringJob.AddOrUpdate<IHangFireJobService>(a=>a.SyncDataMySQLData(),CronType.Day(0,0,1),TimeZoneInfo.Local);
             AsyncHelper.RunSync(async () =>
             {
                 using (var scope = context.ServiceProvider.CreateScope())

+ 3 - 1
MicroServices/Business/Bussiness.Model/SIM/sim_base.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.SIM
     /// sim基本表
     /// </summary>
     [Comment("sim基本表")]
+    [CollectionName("dopbase", "sim_base")]
     public class sim_base:BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SIM/sim_issue_type.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.SIM
     /// sim事项类别表
     /// </summary>
     [Comment("上升时间")]
+    [CollectionName("dopbase", "sim_issue_type")]
     public class sim_issue_type: BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SIM/sim_plant.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.SIM
     /// sim事项表
     /// </summary>
     [Comment("sim事项表")]
+    [CollectionName("dopbase", "sim_plant")]
     public class sim_plant:BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SIM/sim_user_relation.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.SIM
     /// sim用户关联表
     /// </summary>
     [Comment("sim用户关联表")]
+    [CollectionName("dopbase", "sim_user_relation")]
     public class sim_user_relation: BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/Sale/crm_seorderprog.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.Sale
     ///销售订单进度表
     /// </summary>
     [Comment("销售订单进度表")]
+    [CollectionName("dopbase", "crm_seorderprog")]
     public class crm_seorderprog : BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/Sale/crm_seorderreview.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.Sale
     ///销售订单评审表
     /// </summary>
     [Comment("销售订单评审表")]
+    [CollectionName("dopbase", "crm_seorderreview")]
     public class crm_seorderreview : BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/Sale/wms_prdprogress.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.Sale
     ///进度字典
     /// </summary>
     [Comment("进度字典表")]
+    [CollectionName("dopbase", "wms_prdprogress")]
     public class wms_prdprogress: BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/Sale/wms_shipnotice.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.Sale
     /// 发运通知单
     /// </summary>
     [Comment("发运通知单")]
+    [CollectionName("dopbase", "wms_shipnotice")]
     public class wms_shipnotice : BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/Sale/wms_shipnoticelist.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.Sale
     /// 发运通知单详情清单
     /// </summary>
     [Comment("发运通知单详情清单")]
+    [CollectionName("dopbase", "wms_shipnoticelist")]
     public class wms_shipnoticelist : BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/Sale/wms_shipplan.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.Sale
     /// 发货计划表
     /// </summary>
     [Comment("发货计划表")]
+    [CollectionName("dopbase", "wms_shipplan")]
     public class wms_shipplan : BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/Sale/wms_shipplanlist.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.Sale
     /// 发货计划详情清单
     /// </summary>
     [Comment("发货计划详情清单")]
+    [CollectionName("dopbase", "wms_shipplanlist")]
     public class wms_shipplanlist : BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SystemData/crm_customer.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.SystemData
     /// 客户
     /// </summary>
     [Comment("客户")]
+    [CollectionName("dopbase", "crm_customer")]
     public class crm_customer:BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SystemData/sys_code.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -11,6 +12,7 @@ namespace Bussiness.Model.SystemData
     /// 系统编码表
     /// </summary>
     [Comment("系统编码表")]
+    [CollectionName("dopbase", "sys_code")]
     public class sys_code:Entity<long>
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SystemData/sys_code_pre.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -10,6 +11,7 @@ namespace Bussiness.Model.SystemData
     /// 系统编码前置表
     /// </summary>
     [Comment("系统编码前置表")]
+    [CollectionName("dopbase", "sys_code_pre")]
     public class sys_code_pre:Entity<long>
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SystemData/sys_config.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -10,6 +11,7 @@ namespace Bussiness.Model.SystemData
     /// 系统配置表
     /// </summary>
     [Comment("系统配置表")]
+    [CollectionName("dopbase", "sys_config")]
     public class sys_config:Entity<long>
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SystemData/sys_measure_unit.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -10,6 +11,7 @@ namespace Bussiness.Model.SystemData
     /// 计量单位信息表
     /// </summary>
     [Comment("计量单位信息表")]
+    [CollectionName("dopbase", "sys_measure_unit")]
     public class sys_measure_unit:Entity<long>
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SystemData/sys_post.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.SystemData
     /// 岗位表
     /// </summary>
     [Comment("岗位表")]
+    [CollectionName("dopbase", "sys_post")]
     public class sys_post: BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SystemData/sys_post_staff.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.SystemData
     /// 员工岗位关联表
     /// </summary>
     [Comment("员工岗位关联表")]
+    [CollectionName("dopbase", "sys_post_staff")]
     public class sys_post_staff: BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SystemData/sys_schedule.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.SystemData
     /// 班次表
     /// </summary>
     [Comment("班次表")]
+    [CollectionName("dopbase", "sys_schedule")]
     public class sys_schedule: BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SystemData/sys_shift.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.SystemData
     /// 班制表
     /// </summary>
     [Comment("班制表")]
+    [CollectionName("dopbase", "sys_shift")]
     public class sys_shift: BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SystemData/sys_shift_invalid_time.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.SystemData
     /// 班次无效时间表
     /// </summary>
     [Comment("班次无效时间表")]
+    [CollectionName("dopbase", "sys_shift_invalid_time")]
     public class sys_shift_invalid_time:BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SystemData/sys_shift_schedule.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.SystemData
     /// 班制班次关联表
     /// </summary>
     [Comment("班制班次关联表")]
+    [CollectionName("dopbase", "sys_shift_schedule")]
     public class sys_shift_schedule:BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SystemData/sys_staff.cs

@@ -1,4 +1,5 @@
-using Business.Model;
+using Business.Core.Attributes;
+using Business.Model;
 using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.SystemData
     /// 员工表
     /// </summary>
     [Comment("员工表")]
+    [CollectionName("dopbase", "sys_staff")]
     public class sys_staff:BaseEntity
     {
         ///// <summary>

+ 3 - 1
MicroServices/Business/Bussiness.Model/SystemData/sys_upload.cs

@@ -1,4 +1,5 @@
-using Microsoft.EntityFrameworkCore;
+using Business.Core.Attributes;
+using Microsoft.EntityFrameworkCore;
 using System.ComponentModel;
 using System.ComponentModel.DataAnnotations;
 using Volo.Abp.Domain.Entities;
@@ -9,6 +10,7 @@ namespace Bussiness.Model.SystemData
     /// 文件上传表
     /// </summary>
     [Comment("文件上传表")]
+    [CollectionName("dopbase", "sys_upload")]
     public class sys_upload:Entity<long>
     {
         ///// <summary>