|
|
@@ -5,6 +5,7 @@ using Business.Dto;
|
|
|
using Business.EntityFrameworkCore.SqlRepositories;
|
|
|
using Business.ResourceExamineManagement.Dto;
|
|
|
using Business.SaleForecast;
|
|
|
+using Business.StructuredDB.WMS;
|
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
|
using Spire.Pdf.General.Render.Decode.Jpeg2000.j2k.quantization;
|
|
|
using System;
|
|
|
@@ -128,6 +129,21 @@ namespace Business.SaleForecastManagement
|
|
|
/// </summary>
|
|
|
private IRepository<crm_planorder, long> _crm_planorder;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 平台库存监控月份
|
|
|
+ /// </summary>
|
|
|
+ private IRepository<PlatStockMonitorSetting, long> _platStockMonitorSetting;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 平台库存表
|
|
|
+ /// </summary>
|
|
|
+ private IRepository<PlatformInventory, long> _platformInventory;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 参数设置表
|
|
|
+ /// </summary>
|
|
|
+ private ISqlRepository<GeneralizedCodeMaster> _generalizedCodeMaster;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 雪花算法
|
|
|
/// </summary>
|
|
|
@@ -158,7 +174,10 @@ namespace Business.SaleForecastManagement
|
|
|
IRepository<OverallDemandPlan, long> overallDemandPlan,
|
|
|
IRepository<MonthlyProdCapacityDtl, long> monthlyProdCapacityDtl,
|
|
|
IRepository<SkuVersionSet, long> skuVersionSet,
|
|
|
- IRepository<crm_planorder, long> crm_planorder
|
|
|
+ IRepository<crm_planorder, long> crm_planorder,
|
|
|
+ IRepository<PlatStockMonitorSetting, long> platStockMonitorSetting,
|
|
|
+ IRepository<PlatformInventory, long> platformInventory,
|
|
|
+ ISqlRepository<GeneralizedCodeMaster> generalizedCodeMaster
|
|
|
)
|
|
|
{
|
|
|
_ic_item = ic_item;
|
|
|
@@ -181,6 +200,9 @@ namespace Business.SaleForecastManagement
|
|
|
_monthlyProdCapacityDtl = monthlyProdCapacityDtl;
|
|
|
_skuVersionSet= skuVersionSet;
|
|
|
_crm_planorder= crm_planorder;
|
|
|
+ _platStockMonitorSetting = platStockMonitorSetting;
|
|
|
+ _platformInventory = platformInventory;
|
|
|
+ _generalizedCodeMaster = generalizedCodeMaster;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
@@ -212,6 +234,8 @@ namespace Business.SaleForecastManagement
|
|
|
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;
|
|
|
//1.3、获取国内终端预测-T1汇总数据
|
|
|
List<DomesticTerminalFcst> domesticFcst = _domesticTerminalFcst.GetListAsync(p =>p.TypeEnum == 2 && 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;
|
|
|
+ //1.3.1、获取T2-海王,T2-国科数据
|
|
|
+ List<DomesticTerminalFcst> T2Fcsts = _domesticTerminalFcst.GetListAsync(p => (p.TypeEnum == 4 || p.TypeEnum == 5) && 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;
|
|
|
//1.4、根据年度生产大纲,获取规格型号对应的补货周期
|
|
|
List<string> allModels = yearDemands.Select(p=>p.Model).Distinct().ToList();
|
|
|
if (nextYearDemands.Any())
|
|
|
@@ -231,7 +255,8 @@ namespace Business.SaleForecastManagement
|
|
|
//List<WorkOrdMaster> workOrds = _workOrdMaster.Select(p=>p.Domain);
|
|
|
//1.9、获取节假日设置
|
|
|
List<HolidayMaster> holidays = _holidayMaster.Select(p => (p.Dated.Value.Year == input.year || p.Dated.Value.Year == (input.year + 1)) && p.Domain == input.factory_id.ToString() && p.IsActive);
|
|
|
-
|
|
|
+ //2.0、获取平台库存监控月份设置
|
|
|
+ List<PlatStockMonitorSetting> monitorSettings = _platStockMonitorSetting.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;
|
|
|
#region 数据校验
|
|
|
//1、校验当前年的年度生产大纲是否导入
|
|
|
if (!yearDemands.Any())
|
|
|
@@ -424,7 +449,9 @@ namespace Business.SaleForecastManagement
|
|
|
//生成下一个月的补货计划
|
|
|
var nextMonPFcsts = platformFcsts.Where(p => p.PlanMonth == strN2).ToList();
|
|
|
var nextMonDFcsts = domesticFcst.Where(p => p.PlanMonth == strN2).ToList();
|
|
|
- var replenishs = MonthlyReplenish(input, nextMonPFcsts, nextMonDFcsts, standards, items, holidays);
|
|
|
+ var nextMonT2Fcsts = T2Fcsts.Where(p => p.PlanMonth == strN2).ToList();
|
|
|
+ var nextMonMonitors = monitorSettings.Where(p => p.PlanMonth == strN1).ToList();
|
|
|
+ var replenishs = MonthlyReplenish(input, nextMonPFcsts, nextMonDFcsts, nextMonT2Fcsts, standards, items, holidays, nextMonMonitors);
|
|
|
|
|
|
//保存数据
|
|
|
using (var unitOfWork = _unitOfWorkManager.Begin(false, true))
|
|
|
@@ -593,8 +620,9 @@ namespace Business.SaleForecastManagement
|
|
|
/// <param name="standards">标准SKU设置</param>
|
|
|
/// <param name="items">物料</param>
|
|
|
/// <param name="holidays">节假日</param>
|
|
|
+ /// <param name="monitorSettings">库存监控月份设置</param>
|
|
|
/// <returns></returns>
|
|
|
- public List<crm_planorder> MonthlyReplenish(InputDto input, List<PlatformFcstCollect> platformFcsts, List<DomesticTerminalFcst> domesticFcsts, List<StandardItemModelSet> standards, List<ic_item> items, List<HolidayMaster> holidays)
|
|
|
+ public List<crm_planorder> MonthlyReplenish(InputDto input, List<PlatformFcstCollect> platformFcsts, List<DomesticTerminalFcst> domesticFcsts, List<DomesticTerminalFcst> T2Fcsts, List<StandardItemModelSet> standards, List<ic_item> items, List<HolidayMaster> holidays, List<PlatStockMonitorSetting> monitorSettings)
|
|
|
{
|
|
|
List<crm_planorder> planorders = new List<crm_planorder>();
|
|
|
//获取T1、平台预测数据中规格型号对应的不同版本的物料编码
|
|
|
@@ -604,9 +632,16 @@ namespace Business.SaleForecastManagement
|
|
|
models.AddRange(PModels);
|
|
|
models = models.Distinct().ToList();
|
|
|
List<SkuVersionSet> skus = _skuVersionSet.GetListAsync(p=>models.Contains(p.Model) && p.tenant_id == input.tenant_id && p.company_id == input.company_id && p.factory_id == input.factory_id).Result;
|
|
|
- //获取库存
|
|
|
+ //获取T1库存
|
|
|
List<string> itemNums = skus.Select(p=>p.ItemNum).Distinct().ToList();
|
|
|
List<LocationDetail> locationDetails = _locationDetail.Select(p=> itemNums.Contains(p.ItemNum) && p.Domain == input.factory_id.ToString() && p.IsActive);
|
|
|
+ //获取临期库存设置
|
|
|
+ GeneralizedCodeMaster master = _generalizedCodeMaster.Select(p=>p.Domain == input.factory_id.ToString() && p.IsActive && p.Val == "LongPeriodItemPlanMonth").FirstOrDefault();
|
|
|
+ int month = master == null ? 0 : Convert.ToInt16(master.UDeci1);
|
|
|
+ DateTime strTime = Convert.ToDateTime(platformFcsts[0].PlanMonth + "-01").AddMonths(month);
|
|
|
+ //获取平台库存
|
|
|
+ List<PlatformInventory> pInventories = _platformInventory.GetListAsync(p=> p.tenant_id == input.tenant_id && p.company_id == input.company_id && p.factory_id == input.factory_id && p.PeriodOfValidity >= strTime).Result;
|
|
|
+
|
|
|
//计算T1补货
|
|
|
foreach (var item in T1Models)
|
|
|
{
|
|
|
@@ -655,7 +690,7 @@ namespace Business.SaleForecastManagement
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- //计算平台补货
|
|
|
+ //计算平台补货:海王+国科
|
|
|
foreach (var item in PModels)
|
|
|
{
|
|
|
|