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

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

# Conflicts:
#	MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/DomesticTerminalFcst.cs
#	MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/OverseasSaleFcst.cs
#	MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/PlatformFcstCollect.cs
#	MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/StandardItemModelSet.cs
#	MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/YearDemandManagement.cs
tangdi 2 лет назад
Родитель
Сommit
ed9508b128
42 измененных файлов с 637 добавлено и 511 удалено
  1. 1 4
      MicroServices/Business/Buissness.UnitTest/Security/FakeCurrentPrincipalAccessor.cs
  2. 19 4
      MicroServices/Business/Business.Application.Contracts/Dto/InputDto.cs
  3. 6 6
      MicroServices/Business/Business.Application.Contracts/SaleForecast/IMonthlyCapacityLoadAppService.cs
  4. 10 10
      MicroServices/Business/Business.Application/ResourceExamineManagement/CalcBomViewAppService.cs
  5. 1 1
      MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs
  6. 179 81
      MicroServices/Business/Business.Application/SaleForecastManagement/MonthlyCapacityLoadAppService.cs
  7. 75 302
      MicroServices/Business/Business.Application/SystemJobManagement/SystemJobAppService.cs
  8. 2 2
      MicroServices/Business/Business.Core/Configuration/AppConfigurations.cs
  9. 11 11
      MicroServices/Business/Business.Core/Utilities/Encrypt.cs
  10. 3 3
      MicroServices/Business/Business.Core/Utilities/MongoHelper.cs
  11. 2 1
      MicroServices/Business/Business.Domain/MongoDB/Base/MoBaseEntity.cs
  12. 0 11
      MicroServices/Business/Business.Domain/MongoDB/MES/IC/mo_ic_bom.cs
  13. 2 1
      MicroServices/Business/Business.Domain/StructuredDB/Base/BaseEntity.cs
  14. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_bom.cs
  15. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_bom_child.cs
  16. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_item.cs
  17. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_item_stock.cs
  18. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_item_stockoccupy.cs
  19. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/Production/MonthlyProdCapacityDtl.cs
  20. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/Production/MonthlyProdCapacityMain.cs
  21. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/Production/OverallDemandPlanDtl.cs
  22. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_po_list.cs
  23. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_po_main.cs
  24. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_pr_main.cs
  25. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_purchase.cs
  26. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_supplier.cs
  27. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/Sale/crm_customer.cs
  28. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/Sale/crm_seorder.cs
  29. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/Sale/crm_seorderentry.cs
  30. 11 5
      MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/DomesticTerminalFcst.cs
  31. 11 5
      MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/OverseasSaleFcst.cs
  32. 67 0
      MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/PlatStockMonitorSetting.cs
  33. 11 5
      MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/PlatformFcstCollect.cs
  34. 1 1
      MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/StandardItemModelSet.cs
  35. 14 8
      MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/YearDemandManagement.cs
  36. 73 0
      MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/YearDemandManagementHistory.cs
  37. 69 20
      MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/BusinessDbContextModelCreatingExtensions.cs
  38. 30 0
      MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/DOP/BusinessDbContext.cs
  39. 9 0
      MicroServices/Business/Business.Host/BusinessHostModule.cs
  40. 1 1
      MicroServices/Business/Business.Host/appsettings.json
  41. 11 11
      MicroServices/Business/Business.HttpApi/Controllers/MonthlyCapacityLoadController.cs
  42. 2 2
      MicroServices/Business/Bussiness.EntityFrameworkCore.Test/EntityFrameworkCore/EntityFrameworkCoreTestModule.cs

+ 1 - 4
MicroServices/Business/Buissness.UnitTest/Security/FakeCurrentPrincipalAccessor.cs

@@ -21,9 +21,7 @@ namespace Buissness.TestBase
             {
                 lock (this)
                 {
-                    if (_principal == null)
-                    {
-                        _principal = new ClaimsPrincipal(
+                    _principal ??= new ClaimsPrincipal(
                             new ClaimsIdentity(
                                 new List<Claim>
                                 {
@@ -33,7 +31,6 @@ namespace Buissness.TestBase
                                 }
                             )
                         );
-                    }
                 }
             }
 

+ 19 - 4
MicroServices/Business/Business.Application.Contracts/Dto/InputDto.cs

@@ -22,18 +22,33 @@ namespace Business.Dto
         public int month { get; set; }
 
         // <summary>
-        /// 版本号
+        /// 租户id
         /// </summary>
-        public string version { get; set; }
+        public long tenant_id { get; set; }
 
         // <summary>
-        /// 集团id
+        /// 公司id
         /// </summary>
-        public long tenant_id { get; set; }
+        public long company_id { get; set; }
 
         // <summary>
         /// 工厂id
         /// </summary>
         public long factory_id { get; set; }
+
+        // <summary>
+        /// 组织id
+        /// </summary>
+        public long org_id { get; set; }
+
+        // <summary>
+        /// 用户id
+        /// </summary>
+        public long create_by { get; set; }
+
+        // <summary>
+        /// 用户名称
+        /// </summary>
+        public string create_by_name { get; set; }
     }
 }

+ 6 - 6
MicroServices/Business/Business.Application.Contracts/SaleForecast/IMonthlyCapacityLoadAppService.cs

@@ -21,11 +21,11 @@ namespace Business.SaleForecast
         ///// <returns></returns>
         //Task<string> CapacityAnalysis(InputDto input);
 
-        ///// <summary>
-        ///// 月度需求分析
-        ///// </summary>
-        ///// <param name="input"></param>
-        ///// <returns></returns>
-        //Task<string> DemandAnalysis(InputDto input);
+        /// <summary>
+        /// 月度需求分析
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        Task<string> DemandAnalysis(InputDto input);
     }
 }

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

@@ -291,7 +291,7 @@ namespace Business.ResourceExamineManagement
                             if (level1Dto.lack_qty > 0)
                             {
                                 //先计算末级数据的齐套时间。
-                                if (childList.Count() > 0)
+                                if (childList.Count > 0)
                                 {
                                     MatterTileDevelop(level1Dto, childList, returnlist, sklist, bangid, plan_date, sentrys, icitemlist);
                                     level1Dto.kitting_time = childList.Max(s => s.kitting_time);
@@ -657,7 +657,7 @@ namespace Business.ResourceExamineManagement
                         item.lack_qty -= moo_qty;
                         item.kitting_time = DateTime.Now;
                         //先计算末级数据的齐套时间。
-                        if (cilList.Count() > 0)
+                        if (cilList.Count > 0)
                         {
                             CalcIcitem(cilList, returnlist, bangid, sklist, plan_date, icitemlist, sentrys, childidList);
                             
@@ -709,7 +709,7 @@ namespace Business.ResourceExamineManagement
                     if (item.lack_qty > 0 && (param.checkflag || (!param.checkflag && param.checkPlan)))
                     {
                         //先计算末级数据的齐套时间。
-                        if (cilList.Count() > 0)
+                        if (cilList.Count > 0)
                         {
                             CalcIcitem(cilList, returnlist, bangid, sklist, plan_date, icitemlist, sentrys, childidList);
                             item.kitting_time = cilList.Max(s => s.kitting_time);
@@ -740,7 +740,7 @@ namespace Business.ResourceExamineManagement
                 {
                     item.kitting_time = DateTime.Now;
                     //先计算末级数据的齐套时间。
-                    if (cilList.Count() > 0)
+                    if (cilList.Count > 0)
                     {
                         CalcIcitem(cilList, returnlist, bangid, sklist, plan_date, icitemlist, sentrys, childidList);
                         item.kitting_time = cilList.Max(s => s.kitting_time);
@@ -789,7 +789,7 @@ namespace Business.ResourceExamineManagement
                     break;
                 case 2://整批加混用
                     WholeBatchCheck(sublist, returnlist, sklist, select, bangid);
-                    if (select.Count() == 0)
+                    if (select.Count == 0)
                     {
                         //走混用
                         MixedUse(item, sublist, returnlist, sklist, bangid, parent, plan_date, icitemlist, sentrys, childidList);
@@ -851,7 +851,7 @@ namespace Business.ResourceExamineManagement
         public void WholeBatch(BomChildExamineDto item, List<BomChildExamineDto> sublist, List<BomChildExamineDto> returnlist, List<mo_ic_item_stockoccupy> sklist, List<BomChildExamineDto> select, long bangid, BomChildExamineDto parent, DateTime
             ? plan_date, List<mo_ic_item> icitemlist, crm_seorderentry sentrys, List<long> childidList)
         {
-            if (select.Count() == 0)
+            if (select.Count == 0)
             {
                 //如果为空,则默认使用优先级为0的集合作为替代关系
                 if (item.substitute_mode == 0)
@@ -1065,7 +1065,7 @@ namespace Business.ResourceExamineManagement
                         if (sct.erp_cls == 1)
                         {
                             //先计算末级数据的齐套时间。
-                            if (cilList.Count() > 0)
+                            if (cilList.Count > 0)
                             {
                                 CalcIcitem(cilList, returnlist, bangid, sklist, plan_date, icitemlist, sentrys, childidList);
                                 sct.kitting_time = cilList.Max(s => s.kitting_time);
@@ -1112,7 +1112,7 @@ namespace Business.ResourceExamineManagement
                             if (sct.lack_qty > 0 && (param.checkflag || (!param.checkflag && param.checkPlan)))
                             {
                                 //先计算末级数据的齐套时间。
-                                if (cilList.Count() > 0)
+                                if (cilList.Count > 0)
                                 {
                                     CalcIcitem(cilList, returnlist, bangid, sklist, plan_date, icitemlist, sentrys, childidList);
                                     sct.kitting_time = cilList.Max(s => s.kitting_time);
@@ -1140,7 +1140,7 @@ namespace Business.ResourceExamineManagement
                         }
                         else
                         {
-                            if (cilList.Count() > 0)
+                            if (cilList.Count > 0)
                             {
                                 CalcIcitem(cilList, returnlist, bangid, sklist, plan_date, icitemlist, sentrys, childidList);
                                 sct.kitting_time = cilList.Max(s => s.kitting_time);
@@ -1165,7 +1165,7 @@ namespace Business.ResourceExamineManagement
             //再计算一边占用情况,这里根据父级产品额缺料量*当前子料的使用数量-子料库存量。得出当前子物料的缺料数量
             var parent = returnlist.Find(s => s.fid == item.parent_id);
             decimal stockQty = sklist.Where(s => s.icitem_id == item.item_id && s.bang_id == bangid).Sum(p => p.quantity);
-            item.sqty = item.sqty - stockQty;
+            item.sqty -= stockQty;
             item.lack_qty = parent.lack_qty * item.qty - item.sqty;
             item.lack_qty = item.lack_qty > 0 ? item.lack_qty : 0;
             item.self_lack_qty = item.lack_qty;

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

@@ -1036,7 +1036,7 @@ namespace Business.ResourceExamineManagement
             var moPrlist = ObjectMapper.Map<List<srm_pr_main>, List<mo_srm_pr_main>>(prlist);
             foreach (var pr in prlist)
             {
-                bool bl = pr.sentry_id == null ? true : false;
+                bool bl = pr.sentry_id == null;
                 //找到是否生成了新的PR
                 //var newPr = insetPrList.Find(s => s.pr_purchaseid == pr.pr_purchaseid && s.icitem_id == pr.icitem_id && (s.sentry_id == null) == bl);
                 var newPr = insetPrList.Find(s => s.pr_purchaseid == pr.pr_purchaseid && s.icitem_id == pr.icitem_id);

+ 179 - 81
MicroServices/Business/Business.Application/SaleForecastManagement/MonthlyCapacityLoadAppService.cs

@@ -20,99 +20,127 @@ namespace Business.SaleForecastManagement
     /// </summary>
     public class MonthlyCapacityLoadAppService : ApplicationService, IMonthlyCapacityLoadAppService, ITransientDependency
     {
-        //#region 服务
-        ///// <summary>
-        ///// 物料
-        ///// </summary>
-        //private IRepository<ic_item, long> _ic_item;
+        #region 服务
+        /// <summary>
+        /// 物料
+        /// </summary>
+        private IRepository<ic_item, long> _ic_item;
 
-        ///// <summary>
-        ///// 整体需求计划明细
-        ///// </summary>
-        //private ISqlRepository<OverallDemandPlanDtl> _overallDemandPlanDtl;
+        /// <summary>
+        /// 整体需求计划明细
+        /// </summary>
+        private ISqlRepository<OverallDemandPlanDtl> _overallDemandPlanDtl;
 
-        ///// <summary>
-        ///// 生产线明细
-        ///// </summary>
-        //private ISqlRepository<ProdLineDetail> _prodLineDetail;
+        /// <summary>
+        /// 生产线明细
+        /// </summary>
+        private ISqlRepository<ProdLineDetail> _prodLineDetail;
 
-        ///// <summary>
-        ///// 工作日历数据
-        ///// </summary>
-        //private ISqlRepository<ShopCalendarWorkCtr> _shopCalendarWorkCtr;
+        /// <summary>
+        /// 工作日历数据
+        /// </summary>
+        private ISqlRepository<ShopCalendarWorkCtr> _shopCalendarWorkCtr;
 
-        ///// <summary>
-        ///// 产线休息时间记录表
-        ///// </summary>
-        //private ISqlRepository<QualityLineWorkDetail> _qualityLineWorkDetail;
+        /// <summary>
+        /// 产线休息时间记录表
+        /// </summary>
+        private ISqlRepository<QualityLineWorkDetail> _qualityLineWorkDetail;
 
-        ///// <summary>
-        ///// 节假日记录表
-        ///// </summary>
-        //private ISqlRepository<HolidayMaster> _holidayMaster;
+        /// <summary>
+        /// 节假日记录表
+        /// </summary>
+        private ISqlRepository<HolidayMaster> _holidayMaster;
 
-        ///// <summary>
-        ///// 月度产能共识主表
-        ///// </summary>
-        //private ISqlRepository<MonthlyProdCapacityMain> _monthlyProdCapacityMain;
+        /// <summary>
+        /// 月度产能共识主表
+        /// </summary>
+        private ISqlRepository<MonthlyProdCapacityMain> _monthlyProdCapacityMain;
 
-        ///// <summary>
-        ///// 月度产能共识明细表
-        ///// </summary>
-        //private ISqlRepository<MonthlyProdCapacityDtl> _monthlyProdCapacityDtl;
+        /// <summary>
+        /// 月度产能共识明细表
+        /// </summary>
+        private ISqlRepository<MonthlyProdCapacityDtl> _monthlyProdCapacityDtl;
 
-        ///// <summary>
-        ///// 标准物料规格型号设置表
-        ///// </summary>
-        //private ISqlRepository<StandardItemModelSet> _standardItemModelSet;
+        /// <summary>
+        /// 工作单元
+        /// </summary>
+        private readonly IUnitOfWorkManager _unitOfWorkManager;
 
-        ///// <summary>
-        ///// 工作单元
-        ///// </summary>
-        //private readonly IUnitOfWorkManager _unitOfWorkManager;
+        /// <summary>
+        /// 日志
+        /// </summary>
+        private readonly ICurrentTenant _currentTenant;
 
-        ///// <summary>
-        ///// 日志
-        ///// </summary>
-        //private readonly ICurrentTenant _currentTenant;
+        /// <summary>
+        /// 年度生产需求大纲
+        /// </summary>
+        private IRepository<YearDemandManagement, long> _yearDemandManagement;
 
-        ///// <summary>
-        ///// 雪花算法
-        ///// </summary>
-        //SnowFlake help = new SnowFlake();
-        //#endregion
+        /// <summary>
+        /// 国内终端预测
+        /// </summary>
+        private IRepository<DomesticTerminalFcst, long> _domesticTerminalFcst;
 
-        //#region 构造函数
-        ///// <summary>
-        ///// 构造函数
-        ///// </summary>
-        //public MonthlyCapacityLoadAppService(
-        //    IRepository<ic_item, long> ic_item,
-        //    ISqlRepository<OverallDemandPlanDtl> overallDemandPlanDtl,
-        //    ISqlRepository<ProdLineDetail> prodLineDetail,
-        //    ISqlRepository<ShopCalendarWorkCtr> shopCalendarWorkCtr,
-        //    ISqlRepository<QualityLineWorkDetail> qualityLineWorkDetail,
-        //    ISqlRepository<HolidayMaster> holidayMaster,
-        //    ISqlRepository<MonthlyProdCapacityMain> monthlyProdCapacityMain,
-        //    ISqlRepository<MonthlyProdCapacityDtl> monthlyProdCapacityDtl,
-        //    IUnitOfWorkManager unitOfWorkManager,
-        //    ICurrentTenant currentTenant,
-        //    ISqlRepository<StandardItemModelSet> standardItemModelSet
-        //    ) 
-        //{ 
-        //    _ic_item= ic_item;
-        //    _overallDemandPlanDtl= overallDemandPlanDtl;
-        //    _prodLineDetail= prodLineDetail;
-        //    _shopCalendarWorkCtr= shopCalendarWorkCtr;
-        //    _qualityLineWorkDetail= qualityLineWorkDetail;
-        //    _holidayMaster= holidayMaster;
-        //    _monthlyProdCapacityMain= monthlyProdCapacityMain;
-        //    _monthlyProdCapacityDtl= monthlyProdCapacityDtl;
-        //    _unitOfWorkManager= unitOfWorkManager;
-        //    _currentTenant= currentTenant;
-        //    _standardItemModelSet= standardItemModelSet;
-        //}
-        //#endregion
+        /// <summary>
+        /// 海外销售预测
+        /// </summary>
+        private IRepository<OverseasSaleFcst, long> _overseasSaleFcst;
+
+        /// <summary>
+        /// 平台预测收集
+        /// </summary>
+        private IRepository<PlatformFcstCollect, long> _platformFcstCollect;
+
+        /// <summary>
+        /// 标准物料规格型号设置表
+        /// </summary>
+        private IRepository<StandardItemModelSet,long> _standardItemModelSet;
+
+        /// <summary>
+        /// 雪花算法
+        /// </summary>
+        SnowFlake help = new SnowFlake();
+        #endregion
+
+        #region 构造函数
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        public MonthlyCapacityLoadAppService(
+            IRepository<ic_item, long> ic_item,
+            ISqlRepository<OverallDemandPlanDtl> overallDemandPlanDtl,
+            ISqlRepository<ProdLineDetail> prodLineDetail,
+            ISqlRepository<ShopCalendarWorkCtr> shopCalendarWorkCtr,
+            ISqlRepository<QualityLineWorkDetail> qualityLineWorkDetail,
+            ISqlRepository<HolidayMaster> holidayMaster,
+            ISqlRepository<MonthlyProdCapacityMain> monthlyProdCapacityMain,
+            ISqlRepository<MonthlyProdCapacityDtl> monthlyProdCapacityDtl,
+            IUnitOfWorkManager unitOfWorkManager,
+            ICurrentTenant currentTenant,
+            IRepository<StandardItemModelSet,long> standardItemModelSet,
+            IRepository<YearDemandManagement, long> yearDemandManagement,
+            IRepository<DomesticTerminalFcst, long> domesticTerminalFcst,
+            IRepository<OverseasSaleFcst, long> overseasSaleFcst,
+            IRepository<PlatformFcstCollect, long> platformFcstCollect
+            )
+        {
+            _ic_item = ic_item;
+            _overallDemandPlanDtl = overallDemandPlanDtl;
+            _prodLineDetail = prodLineDetail;
+            _shopCalendarWorkCtr = shopCalendarWorkCtr;
+            _qualityLineWorkDetail = qualityLineWorkDetail;
+            _holidayMaster = holidayMaster;
+            _monthlyProdCapacityMain = monthlyProdCapacityMain;
+            _monthlyProdCapacityDtl = monthlyProdCapacityDtl;
+            _unitOfWorkManager = unitOfWorkManager;
+            _currentTenant = currentTenant;
+            _standardItemModelSet = standardItemModelSet;
+            _yearDemandManagement= yearDemandManagement;
+            _domesticTerminalFcst= domesticTerminalFcst;
+            _overallDemandPlanDtl= overallDemandPlanDtl;
+            _platformFcstCollect= platformFcstCollect;
+        }
+        #endregion
 
         ///// <summary>
         ///// 产能分析
@@ -254,5 +282,75 @@ namespace Business.SaleForecastManagement
         //    }
         //    return sumDays;
         //}
+
+        /// <summary>
+        /// 月度需求预测更新
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        /// <exception cref="NotImplementedException"></exception>
+        public async Task<string> DemandAnalysis(InputDto input)
+        {
+            //1.0 获取年度生产需求大纲
+            List<YearDemandManagement> yearDemands = _yearDemandManagement.GetListAsync(p => p.Year == input.year && p.tenant_id == input.tenant_id && p.company_id == input.company_id && p.factory_id == input.factory_id && !p.IsDeleted).Result;
+            if (yearDemands.Count() == 0)
+            {
+                new NLogHelper("MonthlyCapacityLoadAppService").WriteLog("DemandAnalysis", "请导入" + input.year + "年年度生产需求数据后再操作!", _currentTenant.Id.ToString());
+                return "NO|请导入" + input.year + "年年度生产需求数据后再操作!";
+            }
+            //1.1、获取海外销售预测数据
+            List<OverseasSaleFcst> overseasSales = _overseasSaleFcst.GetListAsync(p => p.Year == input.year && p.Month == input.month && p.tenant_id == input.tenant_id && p.company_id == input.company_id && p.factory_id == input.factory_id && !p.IsDeleted).Result;
+            if (overseasSales.Count() == 0)
+            {
+                new NLogHelper("MonthlyCapacityLoadAppService").WriteLog("DemandAnalysis", "请导入"+input.year+"年"+input.month+"月海外预测数据后再操作!", _currentTenant.Id.ToString());
+                return "NO|请导入"+input.year+"年"+input.month+"月海外预测数据后再操作!";
+            }
+            //1.2、获取平台预测收集数据
+            List<PlatformFcstCollect> platformFcsts = _platformFcstCollect.GetListAsync(p => p.Year == input.year && p.Month == input.month && p.tenant_id == input.tenant_id && p.company_id == input.company_id && p.factory_id == input.factory_id && !p.IsDeleted).Result;
+            if (platformFcsts.Count() == 0)
+            {
+                new NLogHelper("MonthlyCapacityLoadAppService").WriteLog("DemandAnalysis", "请导入" + input.year + "年" + input.month + "月平台需求预测数据后再操作!", _currentTenant.Id.ToString());
+                return "NO|请导入" + input.year + "年" + input.month + "月平台需求预测数据后再操作!";
+            }
+            //1.3、获取国内终端预测-T1汇总数据
+            List<DomesticTerminalFcst> domesticFcst = _domesticTerminalFcst.GetListAsync(p => p.Year == input.year && p.Month == input.month && p.tenant_id == input.tenant_id && p.company_id == input.company_id && p.factory_id == input.factory_id && !p.IsDeleted).Result;
+            if (domesticFcst.Count() == 0)
+            {
+                new NLogHelper("MonthlyCapacityLoadAppService").WriteLog("DemandAnalysis", "请导入" + input.year + "年" + input.month + "月国内终端预测数据后再操作!", _currentTenant.Id.ToString());
+                return "NO|请导入" + input.year + "年" + input.month + "月国内终端预测数据后再操作!";
+            }
+            //1.4、根据年度生产大纲,获取规格型号对应的补货周期
+            List<string> models = yearDemands.Select(p=>p.Model).Distinct().ToList();  
+            List<StandardItemModelSet> standards = _standardItemModelSet.GetListAsync(p=>models.Contains(p.Model) && p.tenant_id == input.tenant_id && p.company_id == input.company_id && p.factory_id == input.factory_id && !p.IsDeleted).Result;
+            //1.5、获取规格型号对应的标准SKU数据
+            List<string> itemNums = standards.Select(p=>p.ItemNumber).Distinct().ToList();
+            List<ic_item> items = _ic_item.GetListAsync(p=> itemNums.Contains(p.number) && p.tenant_id == input.tenant_id && p.company_id == input.company_id && p.factory_id == input.factory_id && !p.IsDeleted).Result;
+
+            //计算海外预测
+
+
+            //保存数据
+            using (var unitOfWork = _unitOfWorkManager.Begin(false, true))
+            {
+                try
+                {
+                    ////先删除数据
+                    //_monthlyProdCapacityMain.Delete(p => p.tenant_id == input.tenant_id && p.factory_id == input.factory_id && p.Version.Contains(input.version.Substring(0, 7)));
+                    //_monthlyProdCapacityDtl.Delete(p => p.tenant_id == input.tenant_id && p.factory_id == input.factory_id && p.Version.Contains(input.version.Substring(0, 7)));
+
+                    ////插入数据
+                    //_monthlyProdCapacityMain.Insert(capacityMains);
+                    //_monthlyProdCapacityDtl.Insert(capacityDtls);
+                    //await unitOfWork.CompleteAsync();
+                }
+                catch (Exception e)
+                {
+                    unitOfWork.Dispose();
+                    new NLogHelper("MonthlyCapacityLoadAppService").WriteLog("CapacityAnalysis", "生成【" + input.year + "年" + input.month + "月】月度产能共识失败:" + e.Message, _currentTenant.Id.ToString());
+                    return "NO|" + e.Message;
+                };
+            }
+            return "OK|发布成功!";
+        }
     }
 }

+ 75 - 302
MicroServices/Business/Business.Application/SystemJobManagement/SystemJobAppService.cs

@@ -1,18 +1,12 @@
-using Business.Core.Attributes;
-using Business.Core.Configuration;
-using Business.Core.Utilities;
-using Business.Core.Web;
+using Business.Core.Utilities;
 using Business.Domain;
 using Business.EntityFrameworkCore;
 using Business.EntityFrameworkCore.SqlRepositories;
 using Business.ResourceExamineManagement;
 using Business.SystemJob;
-using MongoDB.Driver;
 using NLog;
 using System;
 using System.Collections.Generic;
-using System.Configuration;
-using System.Linq;
 using System.Threading.Tasks;
 using Volo.Abp.Application.Services;
 using Volo.Abp.Domain.Repositories;
@@ -26,31 +20,26 @@ namespace Business.SystemJobManagement
         /// 物料bom
         /// </summary>
         private IRepository<ic_bom, long> _mysql_ic_bom;
-        private readonly IRepository<mo_ic_bom, long> _ic_bom;
 
         /// <summary>
         /// 物料bom子表
         /// </summary>
         private IRepository<ic_bom_child, long> _mysql_ic_bom_child;
-        private readonly IRepository<mo_ic_bom_child, long> _ic_bom_child;
 
         /// <summary>
         /// 物料
         /// </summary>
         private IRepository<ic_item, long> _mysql_ic_item;
-        private readonly IRepository<mo_ic_item, long> _ic_item;
 
         /// <summary>
         /// 供应商
         /// </summary>
         private IRepository<srm_supplier, long> _mysql_srm_supplier;
-        private readonly IRepository<mo_srm_supplier, long> _srm_supplier;
 
         /// <summary>
         /// 物料采购报价单
         /// </summary>
         private IRepository<srm_purchase, long> _mysql_srm_purchase;
-        private readonly IRepository<mo_srm_purchase, long> _srm_purchase;
 
         /// <summary>
         /// 物料采购报价单
@@ -81,19 +70,16 @@ namespace Business.SystemJobManagement
         /// <summary>
         /// 替代群组
         /// </summary>
-        private readonly IRepository<mo_ic_substitute, long> _ic_substitute;
         private IRepository<ic_substitute, long> _mysql_ic_substitute;
 
         /// <summary>
         /// 物料替代多群组
         /// </summary>
-        private readonly IRepository<mo_ic_substitute_group, long> _ic_substitute_group;
         private IRepository<ic_substitute_group, long> _mysql_ic_substitute_group;
 
         /// <summary>
         /// 物料替代多群组明细
         /// </summary>
-        private readonly IRepository<mo_ic_substitute_group_detail, long> _ic_substitute_group_detail;
         private IRepository<ic_substitute_group_detail, long> _mysql_ic_substitute_group_detail;
 
         /// <summary>
@@ -115,87 +101,10 @@ namespace Business.SystemJobManagement
         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;
-        private readonly IRepository<mo_srm_pr_main, long> _srm_pr_main;
-        private IRepository<srm_pr_main, long> _mysql_srm_pr_main;
-        private readonly IRepository<mo_srm_po_main, long> _srm_po_main;
-        private IRepository<srm_po_main, long> _mysql_srm_po_main;
-        private readonly IRepository<mo_srm_po_list, long> _srm_po_list;
-        private IRepository<srm_po_list, long> _mysql_srm_po_list;
-
-        private IRepository<b_mo_order, long> _mysql_b_mo_order;
 
         public SystemJobAppService(
          IRepository<ic_bom, long> mysql_ic_bom,
@@ -217,36 +126,10 @@ 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,
-         IRepository<mo_ic_bom,long> ic_bom,
-         IRepository<mo_ic_bom_child,long> ic_bom_child,
-         IRepository<mo_ic_item, long> ic_item,
-         IRepository<mo_ic_substitute, long> ic_substitute,
-         IRepository<mo_ic_substitute_group, long> ic_substitute_group,
-         IRepository<mo_ic_substitute_group_detail, long> ic_substitute_group_detail,
-         IRepository<mo_srm_supplier, long> srm_supplier,
          IRepository<mo_mes_technique, long> mes_technique,
          IRepository<mo_mes_process, long> mes_process,
          IRepository<mo_mes_tech_process, long> mes_tech_process,
-         IRepository<mo_srm_purchase, long> srm_purchase,
          ProductionScheduleAppService productionScheduleAppService,
-         IRepository<b_mo_order, long> mysql_b_mo_order,
-         IRepository<mo_srm_pr_main, long> srm_pr_main,
-         IRepository<srm_pr_main, long> mysql_srm_pr_main,
-         IRepository<mo_srm_po_list, long> srm_po_list,
-         IRepository<srm_po_list, long> mysql_srm_po_list,
-         IRepository<mo_srm_po_main, long> srm_po_main,
-         IRepository<srm_po_main, long> mysql_srm_po_main,
          BusinessDbContext businessDbContext
          )
         {
@@ -269,37 +152,11 @@ namespace Business.SystemJobManagement
             _consigneeAddressMaster = consigneeAddressMaster;
             _itemMaster = itemMaster;
             _productStructureMaster = productStructureMaster;
-            _ic_bom = ic_bom;
-            _ic_bom_child = ic_bom_child;
-            _ic_item = ic_item;
-            _ic_substitute = ic_substitute;
-            _ic_substitute_group = ic_substitute_group;
-            _ic_substitute_group_detail = ic_substitute_group_detail;
-            _srm_supplier = srm_supplier;
             _mes_technique = mes_technique;
             _mes_process = mes_process;
             _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;
-            _mysql_b_mo_order = mysql_b_mo_order;
-            _mysql_srm_po_list = mysql_srm_po_list;
-            _srm_po_list = srm_po_list;
-            _mysql_srm_po_main = mysql_srm_po_main;
-            _srm_po_main = srm_po_main;
-            _mysql_srm_pr_main = mysql_srm_pr_main;
-            _srm_pr_main = srm_pr_main;
             _productionScheduleAppService = productionScheduleAppService;
         }
 
@@ -339,176 +196,92 @@ namespace Business.SystemJobManagement
         {
             try
             {
-                //var srm_purchase1 = _mysql_srm_pr_main.GetListAsync().Result;
-                //if (srm_purchase1.Count > 0)
-                //{
-                //    //先清空表数据
-                //    await MongoHelper<mo_srm_pr_main>.DeleteManyAsync(p => p.mysql_id != -1);
-                //    var mosrm_purchase = ObjectMapper.Map<List<srm_pr_main>, List<mo_srm_pr_main>>(srm_purchase1);
-                //    mosrm_purchase.ForEach(s => s.GenerateNewId(help.NextId()));
-                //    await MongoHelper<mo_srm_pr_main>.InsertManyAsync(mosrm_purchase);
-                //}
-
-                //var srm_purchase2 = _mysql_srm_po_main.GetListAsync().Result;
-                //if (srm_purchase2.Count > 0)
-                //{
-                //    //先清空表数据
-                //    await MongoHelper<mo_srm_po_main>.DeleteManyAsync(p => p.mysql_id != -1);
-                //    var mosrm_purchase = ObjectMapper.Map<List<srm_po_main>, List<mo_srm_po_main>>(srm_purchase2);
-                //    mosrm_purchase.ForEach(s => s.GenerateNewId(help.NextId()));
-                //    await MongoHelper<mo_srm_po_main>.InsertManyAsync(mosrm_purchase);
-                //}
-
-                //var srm_purchase3 = _mysql_srm_po_list.GetListAsync().Result;
-                //if (srm_purchase3.Count > 0)
-                //{
-                //    //先清空表数据
-                //    await MongoHelper<mo_srm_po_list>.DeleteManyAsync(p => p.mysql_id != -1);
-                //    var mosrm_purchase = ObjectMapper.Map<List<srm_po_list>, List<mo_srm_po_list>>(srm_purchase3);
-                //    mosrm_purchase.ForEach(s => s.GenerateNewId(help.NextId()));
-                //    await MongoHelper<mo_srm_po_list>.InsertManyAsync(mosrm_purchase);
-                //}
                 //物料采购报价单
-                //List<srm_purchase> srm_purchases = _mysql_srm_purchase.GetListAsync().Result;
-                //if (srm_purchases.Count > 0)
-                //{
-                //    //先清空表数据
-                //    await _srm_purchase.DeleteAsync(p => p.mysql_id != -1);
-                //    var mosrm_purchase = ObjectMapper.Map<List<srm_purchase>, List<mo_srm_purchase>>(srm_purchases);
-                //    mosrm_purchase.ForEach(s => s.GenerateNewId(help.NextId()));
-                //    //_srm_purchase.InsertManyAsync(mosrm_purchase);
-                //    await MongoHelper<mo_srm_purchase>.InsertManyAsync(mosrm_purchase);
-                //}
+                List<srm_purchase> srm_purchases = _mysql_srm_purchase.GetListAsync().Result;
+                if (srm_purchases.Count > 0)
+                {
+                    //先清空表数据
+                    await MongoHelper<mo_srm_purchase>.DeleteManyAsync(p => p.mysql_id != -1);
+                    var mosrm_purchase = ObjectMapper.Map<List<srm_purchase>, List<mo_srm_purchase>>(srm_purchases);
+                    mosrm_purchase.ForEach(s => s.GenerateNewId(help.NextId()));
+                    await MongoHelper<mo_srm_purchase>.InsertManyAsync(mosrm_purchase);
+                }
                 //同步物料BOM明细数据
-                //var icbom_childs = _mysql_ic_bom_child.GetListAsync().Result;
-                //if (icbom_childs.Count > 0)
-                //{
-                //    //先清空表数据
-                //    //await _ic_bom_child.DeleteAsync(p => p.mysql_id != -1);
-                //    await MongoHelper<mo_ic_bom_child>.DeleteManyAsync(p => p.mysql_id != -1);
-                //    var moIcbom_childs = ObjectMapper.Map<List<ic_bom_child>, List<mo_ic_bom_child>>(icbom_childs);
-                //    moIcbom_childs.ForEach(s => s.GenerateNewId(help.NextId()));
-                //    //插入数据
-                //    //_ic_bom_child.InsertManyAsync(moIcbom_childs);
-                //    await MongoHelper<mo_ic_bom_child>.InsertManyAsync(moIcbom_childs);
-                //}
-
-                ////同步物料Bom数据
-                //var icBoms = _mysql_ic_bom.GetListAsync().Result;
-                //if (icBoms.Count > 0)
-                //{
-                //    //先清空表数据
-                //    await _ic_bom.DeleteAsync(p => p.mysql_id != -1);
-                //    var moIcBoms = ObjectMapper.Map<List<ic_bom>, List<mo_ic_bom>>(icBoms);
-                //    moIcBoms.ForEach(s => s.GenerateNewId(help.NextId()));
-                //    //插入数据
-                //    //_ic_bom.InsertManyAsync(moIcBoms);
-                //    await MongoHelper<mo_ic_bom>.InsertManyAsync(moIcBoms);
-                //}
+                var icbom_childs = _mysql_ic_bom_child.GetListAsync().Result;
+                if (icbom_childs.Count > 0)
+                {
+                    //先清空表数据
+                    await MongoHelper<mo_ic_bom_child>.DeleteManyAsync(p => p.mysql_id != -1);
+                    var moIcbom_childs = ObjectMapper.Map<List<ic_bom_child>, List<mo_ic_bom_child>>(icbom_childs);
+                    moIcbom_childs.ForEach(s => s.GenerateNewId(help.NextId()));
+                    await MongoHelper<mo_ic_bom_child>.InsertManyAsync(moIcbom_childs);
+                }
+
+                //同步物料Bom数据
+                var icBoms = _mysql_ic_bom.GetListAsync().Result;
+                if (icBoms.Count > 0)
+                {
+                    //先清空表数据
+                    await MongoHelper<mo_ic_bom>.DeleteManyAsync(p => p.mysql_id != -1);
+                    var moIcBoms = ObjectMapper.Map<List<ic_bom>, List<mo_ic_bom>>(icBoms);
+                    moIcBoms.ForEach(s => s.GenerateNewId(help.NextId()));
+                    await MongoHelper<mo_ic_bom>.InsertManyAsync(moIcBoms);
+                }
 
                 //同步物料数据
-                //var icItems = _mysql_ic_item.GetListAsync().Result;
-                //if (icItems.Count > 0)
-                //{
-                //    //先清空表数据
-                //    await MongoHelper<mo_ic_item>.DeleteManyAsync(p => p.mysql_id != -1);
-                //    var moIcItems = ObjectMapper.Map<List<ic_item>, List<mo_ic_item>>(icItems);
-                //    moIcItems.ForEach(s => s.GenerateNewId(help.NextId()));
-                //    //插入数据
-                //    //_ic_item.InsertManyAsync(moIcItems);
-                //    await MongoHelper<mo_ic_item>.InsertManyAsync(moIcItems);
-                //}
+                var icItems = _mysql_ic_item.GetListAsync().Result;
+                if (icItems.Count > 0)
+                {
+                    //先清空表数据
+                    await MongoHelper<mo_ic_item>.DeleteManyAsync(p => p.mysql_id != -1);
+                    var moIcItems = ObjectMapper.Map<List<ic_item>, List<mo_ic_item>>(icItems);
+                    moIcItems.ForEach(s => s.GenerateNewId(help.NextId()));
+                    await MongoHelper<mo_ic_item>.InsertManyAsync(moIcItems);
+                }
 
                 //同步替代群组数据
-                //var subtitutes = _mysql_ic_substitute.GetListAsync().Result;
-                //if (subtitutes.Count > 0)
-                //{
-                //    //先清空表数据
-                //    await _ic_substitute.DeleteAsync(p => p.mysql_id != -1);
-                //    var moSubtitutes = ObjectMapper.Map<List<ic_substitute>, List<mo_ic_substitute>>(subtitutes);
-                //    moSubtitutes.ForEach(s => s.GenerateNewId(help.NextId()));
-                //    //插入数据
-                //    //_ic_substitute.InsertManyAsync(moSubtitutes);
-                //    await MongoHelper<mo_ic_substitute>.InsertManyAsync(moSubtitutes);
-                //}
+                var subtitutes = _mysql_ic_substitute.GetListAsync().Result;
+                if (subtitutes.Count > 0)
+                {
+                    //先清空表数据
+                    await MongoHelper<mo_ic_substitute>.DeleteManyAsync(p => p.mysql_id != -1);
+                    var moSubtitutes = ObjectMapper.Map<List<ic_substitute>, List<mo_ic_substitute>>(subtitutes);
+                    moSubtitutes.ForEach(s => s.GenerateNewId(help.NextId()));
+                    await MongoHelper<mo_ic_substitute>.InsertManyAsync(moSubtitutes);
+                }
 
                 //同步物料替代多群组数据
-                //var subAlls = _mysql_ic_substitute_group.GetListAsync().Result;
-                //if (subAlls.Count > 0)
-                //{
-                //    //先清空表数据
-                //    await _ic_substitute_group.DeleteAsync(p => p.mysql_id != -1);
-                //    var moSubAlls = ObjectMapper.Map<List<ic_substitute_group>, List<mo_ic_substitute_group>>(subAlls);
-                //    moSubAlls.ForEach(s => s.GenerateNewId(help.NextId()));
-                //    //插入数据
-                //    //_ic_substitute_group.InsertManyAsync(moSubAlls);
-                //    await MongoHelper<mo_ic_substitute_group>.InsertManyAsync(moSubAlls);
-                //}
+                var subAlls = _mysql_ic_substitute_group.GetListAsync().Result;
+                if (subAlls.Count > 0)
+                {
+                    //先清空表数据
+                    await MongoHelper<mo_ic_substitute_group>.DeleteManyAsync(p => p.mysql_id != -1);
+                    var moSubAlls = ObjectMapper.Map<List<ic_substitute_group>, List<mo_ic_substitute_group>>(subAlls);
+                    moSubAlls.ForEach(s => s.GenerateNewId(help.NextId()));
+                    await MongoHelper<mo_ic_substitute_group>.InsertManyAsync(moSubAlls);
+                }
 
                 //同步物料替代多群组明细数据
-                //var subAllDtls = _mysql_ic_substitute_group_detail.GetListAsync().Result;
-                //if (subAllDtls.Count > 0)
-                //{
-                //    //先清空表数据
-                //    await _ic_substitute_group_detail.DeleteAsync(p => p.mysql_id != -1);
-                //    var moSubAllDtls = ObjectMapper.Map<List<ic_substitute_group_detail>, List<mo_ic_substitute_group_detail>>(subAllDtls);
-                //    moSubAllDtls.ForEach(s => s.GenerateNewId(help.NextId()));
-                //    //插入数据
-                //    //_ic_substitute_group_detail.InsertManyAsync(moSubAllDtls);
-                //    await MongoHelper<mo_ic_substitute_group_detail>.InsertManyAsync(moSubAllDtls);
-                //}
+                var subAllDtls = _mysql_ic_substitute_group_detail.GetListAsync().Result;
+                if (subAllDtls.Count > 0)
+                {
+                    //先清空表数据
+                    await MongoHelper<mo_ic_substitute_group_detail>.DeleteManyAsync(p => p.mysql_id != -1);
+                    var moSubAllDtls = ObjectMapper.Map<List<ic_substitute_group_detail>, List<mo_ic_substitute_group_detail>>(subAllDtls);
+                    moSubAllDtls.ForEach(s => s.GenerateNewId(help.NextId()));
+                    await MongoHelper<mo_ic_substitute_group_detail>.InsertManyAsync(moSubAllDtls);
+                }
 
                 //同步供应商数据
-                //var suppliers = _mysql_srm_supplier.GetListAsync().Result;
-                //if (suppliers.Count > 0)
-                //{
-                //    //先清空表数据
-                //    await _srm_supplier.DeleteAsync(p => p.mysql_id != -1);
-                //    var moSuppliers = ObjectMapper.Map<List<srm_supplier>, List<mo_srm_supplier>>(suppliers);
-                //    moSuppliers.ForEach(s => s.GenerateNewId(help.NextId()));
-                //    //插入数据
-                //    //_srm_supplier.InsertManyAsync(moSuppliers);
-                //    await MongoHelper<mo_srm_supplier>.InsertManyAsync(moSuppliers);
-                //}
-
-                //同步工艺路径数据
-                //var techs = _mysql_mes_technique.GetListAsync().Result;
-                //if (techs.Count > 0)
-                //{
-                //    //先清空表数据
-                //    await _mes_technique.DeleteAsync(p => p.mysql_id != -1);
-                //    var moTechs = ObjectMapper.Map<List<mes_technique>, List<mo_mes_technique>>(techs);
-                //    moTechs.ForEach(s => s.GenerateNewId(help.NextId()));
-                //    //插入数据
-                //    //_mes_technique.InsertManyAsync(moTechs);
-                //    await MongoHelper<mo_mes_technique>.InsertManyAsync(moTechs);
-                //}
-
-                //同步工序数据
-                //var processes = _mysql_mes_process.GetListAsync().Result;
-                //if (processes.Count > 0)
-                //{
-                //    //先清空表数据
-                //    await _mes_process.DeleteAsync(p => p.mysql_id != -1);
-                //    var moProcesses = ObjectMapper.Map<List<mes_process>, List<mo_mes_process>>(processes);
-                //    moProcesses.ForEach(s => s.GenerateNewId(help.NextId()));
-                //    //插入数据
-                //    //_mes_process.InsertManyAsync(moProcesses);
-                //    await MongoHelper<mo_mes_process>.InsertManyAsync(moProcesses);
-                //}
-
-                //同步工艺关联工序数据
-                //var tech_procs = _mysql_mes_tech_process.GetListAsync().Result;
-                //if (tech_procs.Count > 0)
-                //{
-                //    //先清空表数据
-                //    await _mes_tech_process.DeleteAsync(p => p.mysql_id != -1);
-                //    var moTech_procs = ObjectMapper.Map<List<mes_tech_process>, List<mo_mes_tech_process>>(tech_procs);
-                //    moTech_procs.ForEach(s => s.GenerateNewId(help.NextId()));
-                //    //插入数据
-                //    //_mes_tech_process.InsertManyAsync(moTech_procs);
-                //    await MongoHelper<mo_mes_tech_process>.InsertManyAsync(moTech_procs);
-                //}
+                var suppliers = _mysql_srm_supplier.GetListAsync().Result;
+                if (suppliers.Count > 0)
+                {
+                    //先清空表数据
+                    await MongoHelper<mo_srm_supplier>.DeleteManyAsync(p => p.mysql_id != -1);
+                    var moSuppliers = ObjectMapper.Map<List<srm_supplier>, List<mo_srm_supplier>>(suppliers);
+                    moSuppliers.ForEach(s => s.GenerateNewId(help.NextId()));
+                    await MongoHelper<mo_srm_supplier>.InsertManyAsync(moSuppliers);
+                }
             }
             catch (Exception ex)
             {

+ 2 - 2
MicroServices/Business/Business.Core/Configuration/AppConfigurations.cs

@@ -12,7 +12,7 @@ namespace Business.Core.Configuration
             ConfigurationCache = new ConcurrentDictionary<string, IConfigurationRoot>();
         }
 
-        public static IConfigurationRoot Get(string path, string environmentName = null)
+        public static IConfigurationRoot Get(string path, string? environmentName = null)
         {
             var cacheKey = path + "#" + environmentName;
             return ConfigurationCache.GetOrAdd(
@@ -21,7 +21,7 @@ namespace Business.Core.Configuration
             );
         }
 
-        private static IConfigurationRoot BuildConfiguration(string path, string environmentName = null)
+        private static IConfigurationRoot BuildConfiguration(string path, string? environmentName = null)
         {
             var builder = new ConfigurationBuilder()
                 .SetBasePath(path)

+ 11 - 11
MicroServices/Business/Business.Core/Utilities/Encrypt.cs

@@ -81,7 +81,7 @@ namespace Business.Core.Utilities
         /// <summary>
         /// DES密钥,24位字符串
         /// </summary>
-        public static string DesKey = "#s^un2ye21fcv%|f0XpR,+vh";
+        private static string DesKey = "#s^un2ye21fcv%|f0XpR,+vh";
 
         /// <summary>
         /// DES加密
@@ -100,7 +100,7 @@ namespace Business.Core.Utilities
         /// <param name="encoding">编码</param>
         /// <param name="cipherMode">加密模式</param>
         /// <param name="paddingMode">填充模式</param>
-        public static string DesEncrypt(object value, string key, Encoding encoding = null, CipherMode cipherMode = CipherMode.ECB, PaddingMode paddingMode = PaddingMode.PKCS7)
+        public static string DesEncrypt(object value, string key, Encoding? encoding = null, CipherMode cipherMode = CipherMode.ECB, PaddingMode paddingMode = PaddingMode.PKCS7)
         {
             string text = value.SafeString();
             if (ValidateDes(text, key) == false)
@@ -134,7 +134,7 @@ namespace Business.Core.Utilities
         /// <summary>
         /// 获取加密结果
         /// </summary>
-        private static string GetEncryptResult(string value, Encoding encoding, ICryptoTransform transform)
+        private static string GetEncryptResult(string value, Encoding? encoding, ICryptoTransform transform)
         {
             encoding ??= Encoding.UTF8;
             var bytes = encoding.GetBytes(value);
@@ -159,7 +159,7 @@ namespace Business.Core.Utilities
         /// <param name="encoding">编码</param>
         /// <param name="cipherMode">加密模式</param>
         /// <param name="paddingMode">填充模式</param>
-        public static string DesDecrypt(object value, string key, Encoding encoding = null, CipherMode cipherMode = CipherMode.ECB, PaddingMode paddingMode = PaddingMode.PKCS7)
+        public static string DesDecrypt(object value, string key, Encoding? encoding = null, CipherMode cipherMode = CipherMode.ECB, PaddingMode paddingMode = PaddingMode.PKCS7)
         {
             string text = value.SafeString();
             if (!ValidateDes(text, key))
@@ -171,7 +171,7 @@ namespace Business.Core.Utilities
         /// <summary>
         /// 获取解密结果
         /// </summary>
-        private static string GetDecryptResult(string value, Encoding encoding, ICryptoTransform transform)
+        private static string GetDecryptResult(string value, Encoding? encoding, ICryptoTransform transform)
         {
             encoding ??= Encoding.UTF8;
             var bytes = System.Convert.FromBase64String(value);
@@ -208,7 +208,7 @@ namespace Business.Core.Utilities
         /// <summary>
         /// AES密钥
         /// </summary>
-        public static string AesKey = "QaP1AF8utIarcBqdhYTZpVGbiNQ9M6IL";
+        private static string AesKey = "QaP1AF8utIarcBqdhYTZpVGbiNQ9M6IL";
 
         /// <summary>
         /// AES加密
@@ -228,7 +228,7 @@ namespace Business.Core.Utilities
         /// <param name="cipherMode">加密模式</param>
         /// <param name="paddingMode">填充模式</param>
         /// <param name="iv">初始化向量</param>
-        public static string AesEncrypt(string value, string key, Encoding encoding = null, CipherMode cipherMode = CipherMode.CBC, PaddingMode paddingMode = PaddingMode.PKCS7, byte[] iv = null)
+        public static string AesEncrypt(string value, string key, Encoding? encoding = null, CipherMode cipherMode = CipherMode.CBC, PaddingMode paddingMode = PaddingMode.PKCS7, byte[]? iv = null)
         {
             if (value.IsEmpty() || key.IsEmpty())
                 return string.Empty;
@@ -269,7 +269,7 @@ namespace Business.Core.Utilities
         /// <param name="cipherMode">加密模式</param>
         /// <param name="paddingMode">填充模式</param>
         /// <param name="iv">初始化向量</param>
-        public static string AesDecrypt(string value, string key, Encoding encoding = null, CipherMode cipherMode = CipherMode.CBC, PaddingMode paddingMode = PaddingMode.PKCS7, byte[] iv = null)
+        public static string AesDecrypt(string value, string key, Encoding? encoding = null, CipherMode cipherMode = CipherMode.CBC, PaddingMode paddingMode = PaddingMode.PKCS7, byte[]? iv = null)
         {
             if (value.IsEmpty() || key.IsEmpty())
                 return string.Empty;
@@ -289,7 +289,7 @@ namespace Business.Core.Utilities
         /// <param name="value">值</param>
         /// <param name="key">密钥</param>
         /// <param name="encoding">字符编码</param>
-        public static string HmacSha256(string value, string key, Encoding encoding = null)
+        public static string HmacSha256(string value, string key, Encoding? encoding = null)
         {
             if (value.IsEmpty() || key.IsEmpty())
                 return string.Empty;
@@ -311,7 +311,7 @@ namespace Business.Core.Utilities
         /// <param name="encoding">编码</param>
         /// <param name="hashAlgorithm">加密算法,默认值: HashAlgorithmName.SHA1</param>
         /// <param name="rsaKeyType">Rsa密钥类型,默认值: Pkcs1</param>
-        public static string RsaSign(string value, string privateKey, Encoding encoding = null, HashAlgorithmName? hashAlgorithm = null, RSAKeyType rsaKeyType = RSAKeyType.Pkcs1)
+        public static string RsaSign(string value, string privateKey, Encoding? encoding = null, HashAlgorithmName? hashAlgorithm = null, RSAKeyType rsaKeyType = RSAKeyType.Pkcs1)
         {
             if (value.IsEmpty() || privateKey.IsEmpty())
                 return string.Empty;
@@ -339,7 +339,7 @@ namespace Business.Core.Utilities
         /// <param name="sign">签名</param>
         /// <param name="encoding">编码</param>
         /// <param name="hashAlgorithm">加密算法,默认值: HashAlgorithmName.SHA1</param>
-        public static bool RsaVerify(string value, string publicKey, string sign, Encoding encoding = null, HashAlgorithmName? hashAlgorithm = null)
+        public static bool RsaVerify(string value, string publicKey, string sign, Encoding? encoding = null, HashAlgorithmName? hashAlgorithm = null)
         {
             if (value.IsEmpty() || publicKey.IsEmpty() || sign.IsEmpty())
                 return false;

+ 3 - 3
MicroServices/Business/Business.Core/Utilities/MongoHelper.cs

@@ -13,9 +13,9 @@ namespace Business.Core.Utilities
             var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());
             string mongodbUrl = configuration["ConnectionStrings:MongoDB"];
             MongoClient client = new MongoClient(mongodbUrl);
-            CollectionNameAttribute collectonName_T = typeof(T).GetCustomAttributes(typeof(CollectionNameAttribute), true).FirstOrDefault() as CollectionNameAttribute;
-            IMongoDatabase dataBase_T = client.GetDatabase(collectonName_T.DatabaseName);
-            IMongoCollection<T> mongoCollection_T = dataBase_T.GetCollection<T>(collectonName_T.CollectionName);
+            CollectionNameAttribute? collectonName_T = typeof(T).GetCustomAttributes(typeof(CollectionNameAttribute), true).FirstOrDefault() as CollectionNameAttribute;
+            IMongoDatabase dataBase_T = client.GetDatabase(collectonName_T?.DatabaseName);
+            IMongoCollection<T> mongoCollection_T = dataBase_T.GetCollection<T>(collectonName_T?.CollectionName);
             return mongoCollection_T;
         }
         public static async Task InsertManyAsync(IEnumerable<T> documents, CancellationToken cancellationToken = default(CancellationToken))

+ 2 - 1
MicroServices/Business/Business.Domain/MongoDB/Base/MoBaseEntity.cs

@@ -72,7 +72,8 @@ namespace Business.Domain
         /// </summary>
         [Required]
         [Comment("租户ID")]
-        public virtual long? tenant_id { get; set; }
+        [DefaultValue(1000)]
+        public virtual long tenant_id { get; set; }
         /// <summary>
         /// 公司ID
         /// </summary>

+ 0 - 11
MicroServices/Business/Business.Domain/MongoDB/MES/IC/mo_ic_bom.cs

@@ -2,17 +2,6 @@
 using Microsoft.EntityFrameworkCore;
 using System;
 using System.ComponentModel.DataAnnotations;
-using Business.Core.Attributes;
-using Microsoft.EntityFrameworkCore;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Volo.Abp;
 
 namespace Business.Domain
 {

+ 2 - 1
MicroServices/Business/Business.Domain/StructuredDB/Base/BaseEntity.cs

@@ -67,7 +67,8 @@ namespace Business.Domain
         /// </summary>
         [Required]
         [Comment("租户ID")]
-        public virtual long? tenant_id { get; set; }
+        [DefaultValue(1000)]
+        public virtual long tenant_id { get; set; }
 
         /// <summary>
         /// 公司ID

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_bom.cs

@@ -10,7 +10,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "ic_bom")]
     [Comment("物料BOM")]
-    [Index(nameof(bom_number), nameof(item_number), nameof(version), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(bom_number), nameof(item_number), nameof(version), nameof(tenant_id), nameof(company_id), nameof(factory_id),IsUnique = true)]
     public class ic_bom : BaseEntity
     {
         public ic_bom(long Id) : base(Id)

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_bom_child.cs

@@ -10,7 +10,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "ic_bom_child")]
     [Comment("物料BOM明细")]
-    [Index(nameof(bom_number), nameof(item_number), nameof(version), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(bom_number), nameof(item_number), nameof(version), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class ic_bom_child : BaseEntity
     {
         public ic_bom_child(long Id) : base(Id)

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_item.cs

@@ -10,7 +10,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "ic_item")]
     [Comment("物料详情")]
-    [Index(nameof(number), nameof(fversion), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(number), nameof(fversion), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class ic_item : BaseEntity
     {
         public ic_item(long Id) : base(Id)

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_item_stock.cs

@@ -10,7 +10,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "ic_item_stock")]
     [Comment("物料库存表")]
-    [Index(nameof(icitem_number), nameof(fversion), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(icitem_number), nameof(fversion), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class ic_item_stock : BaseEntity
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/MES/IC/ic_item_stockoccupy.cs

@@ -10,7 +10,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "ic_item_stockoccupy")]
     [Comment("资源检查物料占用明细表")]
-    [Index(nameof(orderentry_id), nameof(icitem_number), nameof(fversion), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(orderentry_id), nameof(icitem_number), nameof(fversion), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class ic_item_stockoccupy : BaseEntity
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/Production/MonthlyProdCapacityDtl.cs

@@ -13,7 +13,7 @@ namespace Business.Domain
     /// 月度产能共识明细表
     /// </summary>
     [Comment("月度产能共识主表")]
-    [Index(nameof(Year), nameof(Month), nameof(ProdLine), nameof(tenant_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Year), nameof(Month), nameof(ProdLine), nameof(tenant_id), nameof(tenant_id), nameof(factory_id), IsUnique = true)]
     public class MonthlyProdCapacityDtl
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/Production/MonthlyProdCapacityMain.cs

@@ -13,7 +13,7 @@ namespace Business.Domain
     /// 月度产能共识主表
     /// </summary>
     [Comment("月度产能共识主表")]
-    [Index(nameof(Year), nameof(Month), nameof(ProdRange), nameof(Model), nameof(ProdLine), nameof(tenant_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Year), nameof(Month), nameof(ProdRange), nameof(Model), nameof(ProdLine), nameof(tenant_id), nameof(tenant_id), nameof(factory_id), IsUnique = true)]
     public class MonthlyProdCapacityMain
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/Production/OverallDemandPlanDtl.cs

@@ -13,7 +13,7 @@ namespace Business.Domain
     /// 整体需求计划明细表
     /// </summary>
     [Comment("整体需求计划明细表")]
-    [Index(nameof(Version), nameof(ProdRange), nameof(Model), nameof(PlanDate), nameof(tenant_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Version), nameof(ProdRange), nameof(Model), nameof(PlanDate), nameof(tenant_id), nameof(tenant_id), nameof(factory_id), IsUnique = true)]
     public class OverallDemandPlanDtl
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_po_list.cs

@@ -11,7 +11,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "srm_po_list")]
     [Comment("采购订单明细详情")]
-    [Index(nameof(po_billno), nameof(polist_row), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(po_billno), nameof(polist_row), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class srm_po_list : BaseEntity
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_po_main.cs

@@ -11,7 +11,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "srm_po_main")]
     [Comment("采购订单")]
-    [Index(nameof(po_billno), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(po_billno), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class srm_po_main : BaseEntity
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_pr_main.cs

@@ -11,7 +11,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "srm_pr_main")]
     [Comment("采购申请单")]
-    [Index(nameof(pr_billno), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(pr_billno), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class srm_pr_main : BaseEntity
     {
         /// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_purchase.cs

@@ -10,7 +10,7 @@ namespace Business.Domain
     /// </summary>
     [CollectionName("dopbase", "srm_purchase")]
     [Comment("物料采购报价单")]
-    [Index(nameof(number), nameof(supplier_number), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(number), nameof(supplier_number), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class srm_purchase : BaseEntity
     {
 

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SRM/srm_supplier.cs

@@ -11,7 +11,7 @@ namespace Business.Domain
     /// </summary>
     [Comment("供应商")]
     [CollectionName("dopbase", "srm_supplier")]
-    [Index(nameof(supplier_no), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(supplier_no), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class srm_supplier : BaseEntity
     {
         ///// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/Sale/crm_customer.cs

@@ -10,7 +10,7 @@ namespace Business.Domain
     /// </summary>
     [Comment("客户")]
     [CollectionName("dopbase", "crm_customer")]
-    [Index(nameof(customer_no), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(customer_no), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class crm_customer : BaseEntity
     {
         ///// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/Sale/crm_seorder.cs

@@ -12,7 +12,7 @@ namespace Business.Domain
     /// </summary>
     [Comment("销售订单表")]
     [CollectionName("dopbase", "crm_seorder")]
-    [Index(nameof(bill_no), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(bill_no), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class crm_seorder : BaseEntity
     {
         ///// <summary>

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/Sale/crm_seorderentry.cs

@@ -12,7 +12,7 @@ namespace Business.Domain
     /// </summary>
     [Comment("销售订单明细表")]
     [CollectionName("dopbase", "crm_seorderentry")]
-    [Index(nameof(bill_no), nameof(entry_seq), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(bill_no), nameof(entry_seq), nameof(tenant_id), nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class crm_seorderentry : BaseEntity
     {
         ///// <summary>

+ 11 - 5
MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/DomesticTerminalFcst.cs

@@ -13,7 +13,7 @@ namespace Business.Domain
     /// 国内终端预测表
     /// </summary>
     [Comment("国内终端预测表")]
-    [Index(nameof(Year), nameof(Month), nameof(ProdLine), nameof(Model),nameof(TypeEnum),nameof(PlanMonth),nameof(company_id),nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Year), nameof(Month), nameof(ProdLine), nameof(Model),nameof(TypeEnum),nameof(PlanMonth),nameof(tenant_id), nameof(company_id),nameof(factory_id), IsUnique = true)]
     public class DomesticTerminalFcst:BaseEntity
     {
         /// <summary>
@@ -32,13 +32,13 @@ namespace Business.Domain
         /// 产品线
         /// </summary>
         [Comment("产品线")]
-        public string? ProdLine { get; set; }
+        public string ProdLine { get; set; }
 
         /// <summary>
         /// 规格型号
         /// </summary>
         [Comment("规格型号")]
-        public string? Model { get; set; }
+        public string Model { get; set; }
 
         /// <summary>
         /// 类别枚举:1-需求总计;2-T1需求总计;3-T2需求总计;4-海王;5-国科
@@ -50,18 +50,24 @@ namespace Business.Domain
         /// 类别名称
         /// </summary>
         [Comment("类别名称")]
-        public string? TypeName { get; set; }
+        public string TypeName { get; set; }
 
         /// <summary>
         /// 计划年月
         /// </summary>
         [Comment("计划年月")]
-        public string? PlanMonth { get; set; }
+        public string PlanMonth { get; set; }
 
         /// <summary>
         /// 产品数量
         /// </summary>
         [Comment("产品数量")]
         public decimal? Qty { get; set; }
+
+        /// <summary>
+        /// 排序编码
+        /// </summary>
+        [Comment("排序编码")]
+        public int OrderNum { get; set; }
     }
 }

+ 11 - 5
MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/OverseasSaleFcst.cs

@@ -13,7 +13,7 @@ namespace Business.Domain
     /// 海外销售预测表
     /// </summary>
     [Comment("海外销售预测表")]
-    [Index(nameof(Year), nameof(Month), nameof(ProdLine), nameof(Model),nameof(Language),nameof(PlanMonth),nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Year), nameof(Month), nameof(ProdLine), nameof(Model),nameof(Language),nameof(PlanMonth),nameof(tenant_id),nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class OverseasSaleFcst : BaseEntity
     {
         /// <summary>
@@ -32,30 +32,36 @@ namespace Business.Domain
         /// 产品线
         /// </summary>
         [Comment("产品线")]
-        public string? ProdLine { get; set; }
+        public string ProdLine { get; set; }
 
         /// <summary>
         /// 规格型号
         /// </summary>
         [Comment("规格型号")]
-        public string? Model { get; set; }
+        public string Model { get; set; }
 
         /// <summary>
         /// 语种
         /// </summary>
         [Comment("语种")]
-        public string? Language { get; set; }
+        public string Language { get; set; }
 
         /// <summary>
         /// 计划年月
         /// </summary>
         [Comment("计划年月")]
-        public string? PlanMonth { get; set; }
+        public string PlanMonth { get; set; }
 
         /// <summary>
         /// 产品数量
         /// </summary>
         [Comment("产品数量")]
         public decimal? Qty { get; set; }
+
+        /// <summary>
+        /// 排序编码
+        /// </summary>
+        [Comment("排序编码")]
+        public int OrderNum { get; set; }
     }
 }

+ 67 - 0
MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/PlatStockMonitorSetting.cs

@@ -0,0 +1,67 @@
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.Domain
+{
+    /// <summary>
+    /// 平台库存监控设置表
+    /// </summary>
+    [Comment("平台库存监控设置表")]
+    [Index(nameof(Year), nameof(Month), nameof(Platform), nameof(ProdType),nameof(PlanMonth),nameof(tenant_id),nameof(company_id),nameof(factory_id), IsUnique = true)]
+    public class PlatStockMonitorSetting : BaseEntity
+    {
+        /// <summary>
+        /// 年
+        /// </summary>
+        [Comment("年")]
+        public int? Year { get; set; }
+
+        /// <summary>
+        /// 月
+        /// </summary>
+        [Comment("月")]
+        public int? Month { get; set; }
+
+        /// <summary>
+        /// 平台
+        /// </summary>
+        [Comment("平台")]
+        public string Platform { get; set; }
+
+        /// <summary>
+        /// 产品类型
+        /// </summary>
+        [Comment("产品类型")]
+        public string ProdType { get; set; }
+
+        /// <summary>
+        /// 计划年月
+        /// </summary>
+        [Comment("计划年月")]
+        public string PlanMonth { get; set; }
+
+        /// <summary>
+        /// 最低库存覆盖月份
+        /// </summary>
+        [Comment("最低库存覆盖月份")]
+        public decimal? MinTimes { get; set; }
+
+        /// <summary>
+        /// 最高库存覆盖月份
+        /// </summary>
+        [Comment("最高库存覆盖月份")]
+        public decimal? MaxTimes { get; set; }
+
+        /// <summary>
+        /// 排序编码
+        /// </summary>
+        [Comment("排序编码")]
+        public int OrderNum { get; set; }
+    }
+}

+ 11 - 5
MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/PlatformFcstCollect.cs

@@ -13,7 +13,7 @@ namespace Business.Domain
     /// 平台预测收集表
     /// </summary>
     [Comment("平台预测收集表")]
-    [Index(nameof(Year), nameof(Month), nameof(Platform), nameof(Model),nameof(ProdType),nameof(PlanMonth),nameof(company_id),nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Year), nameof(Month), nameof(Platform), nameof(Model),nameof(ProdType),nameof(PlanMonth),nameof(tenant_id),nameof(company_id),nameof(factory_id), IsUnique = true)]
     public class PlatformFcstCollect : BaseEntity
     {
         /// <summary>
@@ -32,30 +32,36 @@ namespace Business.Domain
         /// 平台
         /// </summary>
         [Comment("平台")]
-        public string? Platform { get; set; }
+        public string Platform { get; set; }
 
         /// <summary>
         /// 规格型号
         /// </summary>
         [Comment("规格型号")]
-        public string? Model { get; set; }
+        public string Model { get; set; }
 
         /// <summary>
         /// 产品类型
         /// </summary>
         [Comment("产品类型")]
-        public string? ProdType { get; set; }
+        public string ProdType { get; set; }
 
         /// <summary>
         /// 计划年月
         /// </summary>
         [Comment("计划年月")]
-        public string? PlanMonth { get; set; }
+        public string PlanMonth { get; set; }
 
         /// <summary>
         /// 产品数量
         /// </summary>
         [Comment("产品数量")]
         public decimal? Qty { get; set; }
+
+        /// <summary>
+        /// 排序编码
+        /// </summary>
+        [Comment("排序编码")]
+        public int OrderNum { get; set; }
     }
 }

+ 1 - 1
MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/StandardItemModelSet.cs

@@ -14,7 +14,7 @@ namespace Business.Domain
     /// 标准物料规格型号设置表
     /// </summary>
     [Comment("标准物料规格型号设置表")]
-    [Index(nameof(Model),nameof(ItemNumber), nameof(company_id), nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Model),nameof(ItemNumber), nameof(tenant_id),nameof(company_id), nameof(factory_id), IsUnique = true)]
     public class StandardItemModelSet:BaseEntity
     {
         /// <summary>

+ 14 - 8
MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/YearDemandManagement.cs

@@ -13,7 +13,7 @@ namespace Business.Domain
     /// 年度生产需求管理表
     /// </summary>
     [Comment("年度生产需求管理表")]
-    [Index(nameof(Year), nameof(Area), nameof(ProdLine),nameof(ProdRange), nameof(Line),nameof(Model),nameof(PlanMonth), nameof(company_id),nameof(factory_id), IsUnique = true)]
+    [Index(nameof(Year), nameof(Area), nameof(ProdLine),nameof(ProdRange), nameof(Line),nameof(Model),nameof(PlanMonth),nameof(tenant_id), nameof(company_id),nameof(factory_id), IsUnique = true)]
     public class YearDemandManagement:BaseEntity
     {
         /// <summary>
@@ -26,42 +26,48 @@ namespace Business.Domain
         /// 区域
         /// </summary>
         [Comment("区域")]
-        public string? Area { get; set; }
+        public string Area { get; set; }
 
         /// <summary>
         /// 产品线
         /// </summary>
         [Comment("产品线")]
-        public string? ProdLine { get; set; }
+        public string ProdLine { get; set; }
 
         /// <summary>
         /// 产品系列
         /// </summary>
         [Comment("产品系列")]
-        public string? ProdRange { get; set; }
+        public string ProdRange { get; set; }
 
         /// <summary>
         /// 车间线体
         /// </summary>
         [Comment("车间线体")]
-        public string? Line { get; set; }
+        public string Line { get; set; }
 
         /// <summary>
         /// 规格型号
         /// </summary>
         [Comment("规格型号")]
-        public string? Model { get; set; }
+        public string Model { get; set; }
 
         /// <summary>
         /// 计划年月
         /// </summary>
         [Comment("计划年月")]
-        public string? PlanMonth { get; set; }
+        public string PlanMonth { get; set; }
 
         /// <summary>
         /// 产品数量
         /// </summary>
         [Comment("产品数量")]
-        public decimal? Qty { get; set; }
+        public decimal Qty { get; set; }
+
+        /// <summary>
+        /// 排序编码
+        /// </summary>
+        [Comment("排序编码")]
+        public int OrderNum { get; set; }
     }
 }

+ 73 - 0
MicroServices/Business/Business.Domain/StructuredDB/SaleFcst/YearDemandManagementHistory.cs

@@ -0,0 +1,73 @@
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Business.Domain
+{
+    /// <summary>
+    /// 年度生产需求管理历史表
+    /// </summary>
+    [Comment("年度生产需求管理表")]
+    [Index(nameof(Year), nameof(Area), nameof(ProdLine),nameof(ProdRange), nameof(Line),nameof(Model),nameof(PlanMonth),nameof(tenant_id), nameof(company_id),nameof(factory_id), IsUnique = true)]
+    public class YearDemandManagementHistory : BaseEntity
+    {
+        /// <summary>
+        /// 年
+        /// </summary>
+        [Comment("年")]
+        public int? Year { get; set; }
+
+        /// <summary>
+        /// 区域
+        /// </summary>
+        [Comment("区域")]
+        public string Area { get; set; }
+
+        /// <summary>
+        /// 产品线
+        /// </summary>
+        [Comment("产品线")]
+        public string ProdLine { get; set; }
+
+        /// <summary>
+        /// 产品系列
+        /// </summary>
+        [Comment("产品系列")]
+        public string ProdRange { get; set; }
+
+        /// <summary>
+        /// 车间线体
+        /// </summary>
+        [Comment("车间线体")]
+        public string Line { get; set; }
+
+        /// <summary>
+        /// 规格型号
+        /// </summary>
+        [Comment("规格型号")]
+        public string Model { get; set; }
+
+        /// <summary>
+        /// 计划年月
+        /// </summary>
+        [Comment("计划年月")]
+        public string PlanMonth { get; set; }
+
+        /// <summary>
+        /// 产品数量
+        /// </summary>
+        [Comment("产品数量")]
+        public decimal? Qty { get; set; }
+
+        /// <summary>
+        /// 排序编码
+        /// </summary>
+        [Comment("排序编码")]
+        public int OrderNum { get; set; }
+    }
+}

+ 69 - 20
MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/BusinessDbContextModelCreatingExtensions.cs

@@ -14,7 +14,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<ic_bom>(b =>
             {
                 b.ToTable("ic_bom");
-                b.HasIndex(b => new { b.bom_number, b.item_number,b.version, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.bom_number, b.item_number,b.version,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -22,7 +22,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<ic_bom_child>(b =>
             {
                 b.ToTable("ic_bom_child");
-                b.HasIndex(b => new { b.bom_id,b.bom_number, b.item_number, b.version, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.bom_id,b.bom_number, b.item_number, b.version,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -30,7 +30,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<ic_item>(b =>
             {
                 b.ToTable("ic_item");
-                b.HasIndex(b => new { b.number, b.name,b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.number, b.name,b.tenant_id,b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -38,7 +38,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<ic_item_stock>(b =>
             {
                 b.ToTable("ic_item_stock");
-                b.HasIndex(b => new { b.icitem_id, b.icitem_name, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.icitem_id, b.icitem_name,b.tenant_id, b.company_id, b.factory_id });
                 //不映射到数据库中
                 b.Ignore(x => x.bang_id);
                 b.ConfigureByConvention();
@@ -48,7 +48,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<ic_substitute>(b =>
             {
                 b.ToTable("ic_substitute");
-                b.HasIndex(b => new { b.substitute_code, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.substitute_code,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -56,7 +56,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<ic_substitute_group>(b =>
             {
                 b.ToTable("ic_substitute_group");
-                b.HasIndex(b => new { b.substitute_code, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.substitute_code,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -64,7 +64,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<ic_substitute_group_detail>(b =>
             {
                 b.ToTable("ic_substitute_group_detail");
-                b.HasIndex(b => new { b.substitute_code,b.icitem_number, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.substitute_code,b.icitem_number,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -72,7 +72,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<srm_po_list>(b =>
             {
                 b.ToTable("srm_po_list");
-                b.HasIndex(b => new { b.po_billno, b.number, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.po_billno, b.number,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -80,7 +80,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<srm_po_main>(b =>
             {
                 b.ToTable("srm_po_main");
-                b.HasIndex(b => new { b.po_billno, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.po_billno,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -88,7 +88,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<srm_purchase>(b =>
             {
                 b.ToTable("srm_purchase");
-                b.HasIndex(b => new {b.icitem_id, b.supplier_number, b.company_id, b.factory_id });
+                b.HasIndex(b => new {b.icitem_id, b.supplier_number,b.tenant_id, b.company_id, b.factory_id });
                 b.Ignore(x => x.bang_id);
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
@@ -97,7 +97,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<srm_po_occupy>(b =>
             {
                 b.ToTable("srm_po_occupy");
-                b.HasIndex(b => new { b.polist_id, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.polist_id,b.tenant_id, b.company_id, b.factory_id });
                 b.Ignore(v => v.bang_id);
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
@@ -106,7 +106,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<srm_pr_main>(b =>
             {
                 b.ToTable("srm_pr_main");
-                b.HasIndex(b => new { b.pr_billno,b.pr_purchasenumber,b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.pr_billno, b.pr_purchasenumber, b.tenant_id, b.company_id, b.factory_id });
                 b.Ignore(v => v.bang_id);
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
@@ -115,7 +115,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<mes_moentry>(b =>
             {
                 b.ToTable("mes_moentry");
-                b.HasIndex(b => new { b.moentry_moid, b.moentry_mono, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.moentry_moid, b.moentry_mono, b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -123,7 +123,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<mes_mooccupy>(b =>
             {
                 b.ToTable("mes_mooccupy");
-                b.HasIndex(b => new { b.moo_id_billid, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.moo_id_billid,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -131,7 +131,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<mes_morder>(b =>
             {
                 b.ToTable("mes_morder");
-                b.HasIndex(b => new { b.morder_no, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.morder_no,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -147,7 +147,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<mes_stockoccupy>(b =>
             {
                 b.ToTable("mes_stockoccupy");
-                b.HasIndex(b => new { b.fbill_no,b.fitem_number, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.fbill_no,b.fitem_number,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -157,7 +157,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<crm_seorder>(b =>
             {
                 b.ToTable("crm_seorder");
-                b.HasIndex(b => new { b.bill_no, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.bill_no,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -165,7 +165,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<crm_seorderentry>(b =>
             {
                 b.ToTable("crm_seorderentry");
-                b.HasIndex(b => new { b.seorder_id, b.bill_no,b.item_number,b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.seorder_id, b.bill_no,b.item_number,b.tenant_id,b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -173,7 +173,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<crm_customer>(b =>
             {
                 b.ToTable("crm_customer");
-                b.HasIndex(b => new { b.customer_no, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.customer_no,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -181,7 +181,7 @@ namespace Business.EntityFrameworkCore
             builder.Entity<srm_supplier>(b =>
             {
                 b.ToTable("srm_supplier");
-                b.HasIndex(b => new { b.supplier_no, b.company_id, b.factory_id });
+                b.HasIndex(b => new { b.supplier_no,b.tenant_id, b.company_id, b.factory_id });
                 b.ConfigureByConvention();
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
@@ -224,6 +224,55 @@ namespace Business.EntityFrameworkCore
                 b.Property(x => x.Id).ValueGeneratedNever();//迁移sqlserver默认是自增,需要配置一下
             });
 
+            builder.Entity<StandardItemModelSet>(b =>
+            {
+                b.ToTable("StandardItemModelSet");
+                b.HasIndex(b => new { b.Model,b.ItemNumber, b.tenant_id,b.company_id, b.factory_id });
+                b.ConfigureByConvention();
+            });
+
+            builder.Entity<DomesticTerminalFcst>(b =>
+            {
+                b.ToTable("DomesticTerminalFcst");
+                b.HasIndex(b => new { b.Year,b.Month,b.ProdLine,b.Model, b.TypeEnum,b.PlanMonth, b.tenant_id, b.company_id, b.factory_id });
+                b.ConfigureByConvention();
+            });
+
+            builder.Entity<OverseasSaleFcst>(b =>
+            {
+                b.ToTable("OverseasSaleFcst");
+                b.HasIndex(b => new { b.Year, b.Month, b.ProdLine, b.Model, b.Language, b.PlanMonth, b.tenant_id, b.company_id, b.factory_id });
+                b.ConfigureByConvention();
+            });
+
+            builder.Entity<PlatformFcstCollect>(b =>
+            {
+                b.ToTable("PlatformFcstCollect");
+                b.HasIndex(b => new { b.Year, b.Month, b.Platform, b.Model, b.ProdType, b.PlanMonth, b.tenant_id, b.company_id, b.factory_id });
+                b.ConfigureByConvention();
+            });
+
+            builder.Entity<YearDemandManagement>(b =>
+            {
+                b.ToTable("YearDemandManagement");
+                b.HasIndex(b => new { b.Year, b.Area, b.ProdLine,b.ProdRange,b.Line,b.Model,b.PlanMonth, b.tenant_id, b.company_id, b.factory_id });
+                b.ConfigureByConvention();
+            });
+
+            builder.Entity<YearDemandManagementHistory>(b =>
+            {
+                b.ToTable("YearDemandManagementHistory");
+                b.HasIndex(b => new { b.Year, b.Area, b.ProdLine, b.ProdRange, b.Line, b.Model, b.PlanMonth, b.tenant_id, b.company_id, b.factory_id });
+                b.ConfigureByConvention();
+            });
+
+            builder.Entity<PlatStockMonitorSetting>(b =>
+            {
+                b.ToTable("PlatStockMonitorSetting");
+                b.HasIndex(b => new { b.Year, b.Month, b.Platform, b.ProdType, b.PlanMonth, b.tenant_id, b.company_id, b.factory_id });
+                b.ConfigureByConvention();
+            });
+
             //Code generation...
 
             //添加表名字段名描述属性,请放在最后,会导致NotMap不生效

+ 30 - 0
MicroServices/Business/Business.EntityFrameworkCore/EntityFrameworkCore/DOP/BusinessDbContext.cs

@@ -168,6 +168,36 @@ namespace Business.EntityFrameworkCore
         /// </summary>
         public DbSet<StandardItemModelSet> StandardItemModelSet { get; set; }
 
+        /// <summary>
+        /// 国内终端预测表
+        /// </summary>
+        public DbSet<DomesticTerminalFcst> DomesticTerminalFcst { get; set; }
+
+        /// <summary>
+        /// 海外销售预测表
+        /// </summary>
+        public DbSet<OverseasSaleFcst> OverseasSaleFcst { get; set; }
+
+        /// <summary>
+        /// 平台预测收集表
+        /// </summary>
+        public DbSet<PlatformFcstCollect> PlatformFcstCollect { get; set; }
+
+        /// <summary>
+        /// 年度生产需求大纲表
+        /// </summary>
+        public DbSet<YearDemandManagement> YearDemandManagement { get; set; }
+
+        /// <summary>
+        /// 年度生产需求大纲历史表
+        /// </summary>
+        public DbSet<YearDemandManagementHistory> YearDemandManagementHistory { get; set; }
+
+        /// <summary>
+        /// 平台库存监控设置表
+        /// </summary>
+        public DbSet<PlatStockMonitorSetting> PlatStockMonitorSetting { get; set; }
+
         /// <summary>
         /// 系统配置表
         /// </summary>

+ 9 - 0
MicroServices/Business/Business.Host/BusinessHostModule.cs

@@ -165,6 +165,7 @@ namespace Business
                Ascending(_ => _.bom_number).
                Ascending(_ => _.item_number).
                Ascending(_ => _.version).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id)
                , new CreateIndexOptions
@@ -183,6 +184,7 @@ namespace Business
                Ascending(_ => _.bom_number).
                Ascending(_ => _.item_number).
                Ascending(_ => _.version).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id)
                , new CreateIndexOptions
@@ -200,6 +202,7 @@ namespace Business
                Builders<mo_ic_item>.IndexKeys.
                Ascending(_ => _.number).
                Ascending(_ => _.fversion).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id)
                , new CreateIndexOptions
@@ -217,6 +220,7 @@ namespace Business
                Builders<mo_ic_item_stock>.IndexKeys.
                Ascending(_ => _.icitem_number).
                Ascending(_ => _.fversion).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id).
                Ascending(_ => _.bang_id)
@@ -236,6 +240,7 @@ namespace Business
                Builders<mo_srm_po_list>.IndexKeys.
                Ascending(_ => _.po_billno).
                Ascending(_ => _.polist_row).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id).
                Ascending(_ => _.bang_id)
@@ -253,6 +258,7 @@ namespace Business
             CreateIndexModel<mo_srm_po_main> indexModel_mo_srm_po_main = new CreateIndexModel<mo_srm_po_main>(
                Builders<mo_srm_po_main>.IndexKeys.
                Ascending(_ => _.po_billno).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id).
                Ascending(_ => _.bang_id)
@@ -270,6 +276,7 @@ namespace Business
             CreateIndexModel<mo_srm_pr_main> indexModel_mo_srm_pr_main = new CreateIndexModel<mo_srm_pr_main>(
                Builders<mo_srm_pr_main>.IndexKeys.
                Ascending(_ => _.pr_billno).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id).
                Ascending(_ => _.bang_id)
@@ -288,6 +295,7 @@ namespace Business
                Builders<mo_srm_purchase>.IndexKeys.
                Ascending(_ => _.number).
                Ascending(_ => _.supplier_number).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id).
                Ascending(_ => _.bang_id)
@@ -305,6 +313,7 @@ namespace Business
             CreateIndexModel<mo_srm_supplier> indexModel_mo_srm_supplier = new CreateIndexModel<mo_srm_supplier>(
                Builders<mo_srm_supplier>.IndexKeys.
                Ascending(_ => _.supplier_no).
+               Ascending(_ => _.tenant_id).
                Ascending(_ => _.company_id).
                Ascending(_ => _.factory_id)
                , new CreateIndexOptions

+ 1 - 1
MicroServices/Business/Business.Host/appsettings.json

@@ -17,7 +17,7 @@
     "DOPLog": "Server=123.60.180.165;Database=dopbiz;uid=sa;pwd=5h3n9)uN;Trusted_Connection=false;TrustServerCertificate=True",
     "DOPBang": "Server=123.60.180.165;Database=dopbiz;uid=sa;pwd=5h3n9)uN;Trusted_Connection=false;TrustServerCertificate=True",
     "DOPExt": "Server=123.60.180.165;Database=dopbiz;uid=sa;pwd=5h3n9)uN;Trusted_Connection=false;TrustServerCertificate=True",
-    "MongoDB": "mongodb://zzydop:h1Q$us3r@123.60.180.165/dopbase",
+    "MongoDB": "mongodb://zzydop:h1Q$us3r@123.60.180.165/dopbase"
   },
   "Redis": {
     "Configuration": "192.168.1.191"

+ 11 - 11
MicroServices/Business/Business.HttpApi/Controllers/MonthlyCapacityLoadController.cs

@@ -46,16 +46,16 @@ namespace Business.Controllers
         //    return _MonthlyCapacityLoadAppService.CapacityAnalysis(input);
         //}
 
-        ///// <summary>
-        ///// 月度需求分析
-        ///// </summary>
-        ///// <param name="input"></param>
-        ///// <returns></returns>
-        //[HttpPost]
-        //[Route("demandanalysis")]
-        //public Task<string> DemandAnalysis(InputDto input)
-        //{
-        //    return _MonthlyCapacityLoadAppService.DemandAnalysis(input);
-        //}
+        /// <summary>
+        /// 月度需求分析
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [Route("demandanalysis")]
+        public Task<string> DemandAnalysis(InputDto input)
+        {
+            return _MonthlyCapacityLoadAppService.DemandAnalysis(input);
+        }
     }
 }

+ 2 - 2
MicroServices/Business/Bussiness.EntityFrameworkCore.Test/EntityFrameworkCore/EntityFrameworkCoreTestModule.cs

@@ -18,7 +18,7 @@ namespace Bussiness.EntityFrameworkCore.Test
         )]
     public class EntityFrameworkCoreTestModule : AbpModule
     {
-        private SqliteConnection _sqliteConnection;
+        private SqliteConnection? _sqliteConnection;
 
         public override void ConfigureServices(ServiceConfigurationContext context)
         {
@@ -45,7 +45,7 @@ namespace Bussiness.EntityFrameworkCore.Test
 
         public override void OnApplicationShutdown(ApplicationShutdownContext context)
         {
-            _sqliteConnection.Dispose();
+            _sqliteConnection?.Dispose();
         }
 
         private static SqliteConnection CreateDatabaseAndGetConnection()