|
|
@@ -46,9 +46,8 @@ namespace Business.Replenishment
|
|
|
/// </summary>
|
|
|
SnowFlake help = new SnowFlake();
|
|
|
private readonly IRepository<ReplenishmentROP, long> _replenishmentROP;
|
|
|
- private readonly IRepository<DomesticTerminalFcst, long> _domesticTerminalFcst;
|
|
|
private readonly ISqlRepository<ASNBOLShipperDetail> _ASNBOLShipperDetail;
|
|
|
- private readonly IRepository<StandardItemModelSet, long> _standardItemModelSet;
|
|
|
+ private readonly ISqlRepository<ASNBOLShipperMaster> _ASNBOLShipperMaster;
|
|
|
private readonly ISqlRepository<InvTransHist> _invTransHist;
|
|
|
private readonly ISqlRepository<SAPInv> _SAPInv;
|
|
|
private readonly IRepository<srm_purchase, long> _srmPurchase;
|
|
|
@@ -110,6 +109,12 @@ namespace Business.Replenishment
|
|
|
private readonly IRepository<b_examine_result, long> _mysql_examine_result;
|
|
|
private readonly IRepository<b_bom_child_examine, long> _mysql_bom_child_examine;
|
|
|
private readonly IRepository<ReplenishmentServiceLevel, long> _replenishmentServiceLevel;
|
|
|
+ private readonly ISqlRepository<DMS_IN_ITEMMAPPING> _DMS_IN_ITEMMAPPING;
|
|
|
+ private readonly ISqlRepository<DMS_IN_LOCDETAIL> _DMS_IN_LOCDETAIL;
|
|
|
+ private readonly ISqlRepository<DMS_IN_PODETAIL> _DMS_IN_PODETAIL;
|
|
|
+ private readonly ISqlRepository<DMS_IN_RETAILER> _DMS_IN_RETAILER;
|
|
|
+ private readonly ISqlRepository<DMS_IN_SHIPPINGDETAIL> _DMS_IN_SHIPPINGDETAIL;
|
|
|
+ private readonly IRepository<ReplenishmentTurnOverSet> _ReplenishmentTurnOverSet;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 年度销售预测
|
|
|
@@ -235,6 +240,7 @@ namespace Business.Replenishment
|
|
|
IRepository<ReplenishmentROP, long> replenishmentROP,
|
|
|
IRepository<DomesticTerminalFcst, long> domesticTerminalFcst,
|
|
|
ISqlRepository<ASNBOLShipperDetail> ASNBOLShipperDetail,
|
|
|
+ ISqlRepository<ASNBOLShipperMaster> ASNBOLShipperMaster,
|
|
|
IRepository<StandardItemModelSet, long> standardItemModelSet,
|
|
|
ISqlRepository<InvTransHist> invTransHist,
|
|
|
ISqlRepository<SAPInv> SAPInv,
|
|
|
@@ -308,6 +314,13 @@ namespace Business.Replenishment
|
|
|
IRepository<b_bom_child_examine, long> mysql_bom_child_examine,
|
|
|
IRepository<ReplenishmentServiceLevel, long> replenishmentServiceLevel,
|
|
|
|
|
|
+ ISqlRepository<DMS_IN_ITEMMAPPING> DMS_IN_ITEMMAPPING,
|
|
|
+ ISqlRepository<DMS_IN_LOCDETAIL> DMS_IN_LOCDETAIL,
|
|
|
+ ISqlRepository<DMS_IN_PODETAIL> DMS_IN_PODETAIL,
|
|
|
+ ISqlRepository<DMS_IN_RETAILER> DMS_IN_RETAILER,
|
|
|
+ ISqlRepository<DMS_IN_SHIPPINGDETAIL> DMS_IN_SHIPPINGDETAIL,
|
|
|
+ IRepository<ReplenishmentTurnOverSet> ReplenishmentTurnOverSet,
|
|
|
+
|
|
|
SerialNumberAppService serialNumberAppService,
|
|
|
PretreatmentAppService pretreatmentAppService,
|
|
|
PurchaseOrderAppService purchaseOrderAppService,
|
|
|
@@ -319,9 +332,8 @@ namespace Business.Replenishment
|
|
|
IUnitOfWorkManager unitOfWorkManager)
|
|
|
{
|
|
|
_replenishmentROP = replenishmentROP;
|
|
|
- _domesticTerminalFcst = domesticTerminalFcst;
|
|
|
_ASNBOLShipperDetail = ASNBOLShipperDetail;
|
|
|
- _standardItemModelSet = standardItemModelSet;
|
|
|
+ _ASNBOLShipperMaster = ASNBOLShipperMaster;
|
|
|
_invTransHist = invTransHist;
|
|
|
_SAPInv = SAPInv;
|
|
|
_srmPurchase = srmPurchase;
|
|
|
@@ -396,6 +408,13 @@ namespace Business.Replenishment
|
|
|
_crm_planorder = crm_planorder;
|
|
|
_platformInventory = platformInventory;
|
|
|
|
|
|
+ _DMS_IN_ITEMMAPPING = DMS_IN_ITEMMAPPING;
|
|
|
+ _DMS_IN_LOCDETAIL = DMS_IN_LOCDETAIL;
|
|
|
+ _DMS_IN_PODETAIL = DMS_IN_PODETAIL;
|
|
|
+ _DMS_IN_RETAILER = DMS_IN_RETAILER;
|
|
|
+ _DMS_IN_SHIPPINGDETAIL = DMS_IN_SHIPPINGDETAIL;
|
|
|
+ _ReplenishmentTurnOverSet= ReplenishmentTurnOverSet;
|
|
|
+
|
|
|
_serialNumberAppService= serialNumberAppService;
|
|
|
_pretreatmentAppService = pretreatmentAppService;
|
|
|
_CalcBomViewAppService = CalcBomViewAppService;
|
|
|
@@ -715,26 +734,6 @@ namespace Business.Replenishment
|
|
|
return "OK|刷新成功!";
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 计算当月有多少个周末
|
|
|
- /// </summary>
|
|
|
- /// <param name="days"></param>
|
|
|
- /// <param name="startDay"></param>
|
|
|
- /// <returns></returns>
|
|
|
- private int CalcWeekDays(int days, DateTime startDay)
|
|
|
- {
|
|
|
- int sumDays = 0;
|
|
|
- for (int i = 0; i < days; i++)
|
|
|
- {
|
|
|
- int weekDays = (int)startDay.AddDays(i).DayOfWeek;
|
|
|
- if (weekDays == 0 || weekDays == 6)
|
|
|
- {
|
|
|
- sumDays++;
|
|
|
- }
|
|
|
- }
|
|
|
- return sumDays;
|
|
|
- }
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 调整ROP和最高库存水位(按照成品展开到原材料,原材料用领料算出库)
|
|
|
/// </summary>
|
|
|
@@ -744,6 +743,11 @@ namespace Business.Replenishment
|
|
|
{
|
|
|
//1.获取补货模型全局参数
|
|
|
ReplenishmentDto replenishmentDto = GetROPParam(input.factory_id.ToString());
|
|
|
+ List<ReplenishmentROP> addList = new List<ReplenishmentROP>();
|
|
|
+ List<ReplenishmentROP> updateList = new List<ReplenishmentROP>();//更新上一个月的实际出库数量
|
|
|
+ List<ReplenishmentServiceLevel> addServiceLevelList = new List<ReplenishmentServiceLevel>();
|
|
|
+ List<ReplenishmentServiceLevel> updateServiceLevelList = new List<ReplenishmentServiceLevel>();
|
|
|
+ var turnOverlist=_ReplenishmentTurnOverSet.GetListAsync(a=>a.factory_id==input.factory_id).Result;
|
|
|
//获取月度发货计划(一次导入三个月的销售预测),因为是固定格式yyyy-MM所以可以用字符串比较,避免写很多字符串判断相等
|
|
|
string planMonth = $"{DateTime.Now.Year}-{DateTime.Now.Month.ToString("00")}";
|
|
|
string planMonthMax = $"{DateTime.Now.AddMonths(replenishmentDto.SaleFcstMonth).Year}-{DateTime.Now.AddMonths(replenishmentDto.SaleFcstMonth).Month.ToString("00")}";
|
|
|
@@ -770,53 +774,113 @@ namespace Business.Replenishment
|
|
|
|
|
|
//获取补货模型前H周期和未来F个周期的数据
|
|
|
var ropModelList = _replenishmentROP.GetListAsync(a => a.zero_based_seqno >= -1 * replenishmentDto.HistoryOutStockMonth && a.zero_based_seqno <= replenishmentDto.SaleFcstMonth).Result;
|
|
|
+
|
|
|
//获取成品库存、灭菌库存、在制库存(会从SAP同步的库存表更新到LocationDetail、ic_item表中)
|
|
|
- //List<SAPInv> sAPInvs = _SAPInv.Select(p => p.WERKS == input.factory_id.ToString() && itemNums.Contains(p.MATNR));
|
|
|
var locations = _locationDetail.Select(p => p.Domain == input.factory_id.ToString() && pretreatments.Select(p => p.item_number).Contains(p.ItemNum) && p.IsActive);
|
|
|
var sapItemInv = _SAPInv.Select(a => pretreatments.Select(p => p.item_number).Contains(a.MATNR) && a.WERKS == input.factory_id.ToString());
|
|
|
+ var DMSItemList=_DMS_IN_ITEMMAPPING.Select(a => planList.Select(p => p.SAPItemNumber).ToList().Contains(a.CfnERPCode));
|
|
|
+ var gkhwStock=_DMS_IN_LOCDETAIL.Select(a => (a.DealerCode == "RQ000005" || a.DealerCode == "RQ000002"));
|
|
|
|
|
|
//取过去6个月发货出库记录
|
|
|
var listShip = pretreatments.Select(p => p.item_number).ToList();
|
|
|
var dateBegin = getMonthStartTime(-6);
|
|
|
var dateEnd = getMonthStartTime(-1);
|
|
|
var dateCurrent = getMonthStartTime(-1);
|
|
|
- var shipList = _ASNBOLShipperDetail.Select(a => a.Domain == input.factory_id.ToString() && a.IsActive && a.shtype == "SH" && a.Typed != "S" && a.RealQty > 0 && listShip.Contains(a.ContainerItem) && a.ShipDate >= dateBegin && a.ShipDate <= dateEnd);
|
|
|
+ var gkhwList=_ASNBOLShipperMaster.Select(a => a.Domain == input.factory_id.ToString() && (a.SoldTo == "10002080" || a.SoldTo == "10001981"));
|
|
|
+
|
|
|
+ var recidList = gkhwList.Select(a => a.RecID).ToList();
|
|
|
+ var shipList = _ASNBOLShipperDetail.Select(a => a.Domain == input.factory_id.ToString() && a.IsActive && a.shtype == "SH" && a.Typed != "S" && a.RealQty > 0
|
|
|
+ && listShip.Contains(a.ContainerItem) && a.ShipDate >= dateBegin && a.ShipDate <= dateEnd && !recidList.Contains(a.ASNBOLShipperRecID));//瑞奇只算瑞奇排除国科海王
|
|
|
+
|
|
|
+ var DMSItemListGK = _DMS_IN_ITEMMAPPING.Select(a => planList.Where(p=>p.DistributionChannel=="国科").Select(p => p.SAPItemNumber).ToList().Contains(a.CfnERPCode));
|
|
|
+ var shipListGK = _DMS_IN_SHIPPINGDETAIL.Select(a =>
|
|
|
+ DMSItemListGK.Select(g=>g.CfnCode).Contains(a.UPN) && a.ParentDealerCode== "RQ000005" && a.ShipmentDate >= DateOnly.FromDateTime(dateBegin) && a.ShipmentDate <= DateOnly.FromDateTime(dateEnd));//国科
|
|
|
+ var DMSItemListHW = _DMS_IN_ITEMMAPPING.Select(a => planList.Where(p => p.DistributionChannel == "国科").Select(p => p.SAPItemNumber).ToList().Contains(a.CfnERPCode));
|
|
|
+ var shipListHW = _DMS_IN_SHIPPINGDETAIL.Select(a =>
|
|
|
+ DMSItemListHW.Select(g => g.CfnCode).Contains(a.UPN) && a.ParentDealerCode == "RQ000002" && a.ShipmentDate >= DateOnly.FromDateTime(dateBegin) && a.ShipmentDate <= DateOnly.FromDateTime(dateEnd));//海王
|
|
|
+
|
|
|
//领料出库记录
|
|
|
- //var pickbilllist = _NbrDetail.Select(a => a.Domain == input.factory_id.ToString() && a.Type == "SM" && a.IsActive && a.UpdateTime >= DateTime.Now.AddMonths(replenishmentDto.HistoryOutStockMonth * -1) && itemNumList.Contains(a.ItemNum));
|
|
|
- var pickbilllist = _invTransHist.Select(a => a.Domain == input.factory_id.ToString() && a.TransType == "iss-wo" && a.IsActive && a.CreateTime >= DateTime.Now.AddMonths(-6) && pretreatments.Select(p => p.item_number).Contains(a.ItemNum));
|
|
|
+ var pickbilllist = _invTransHist.Select(a => a.Domain == input.factory_id.ToString() && a.TransType == "iss-wo" && a.IsActive
|
|
|
+ && a.CreateTime >= DateTime.Now.AddMonths(-6) && pretreatments.Select(p => p.item_number).Contains(a.ItemNum));
|
|
|
//取本月发货出库记录
|
|
|
- var shipMList = _ASNBOLShipperDetail.Select(a => a.Domain == input.factory_id.ToString() && a.IsActive && a.shtype == "SH" && a.Typed != "S" && a.RealQty > 0 && listShip.Contains(a.ContainerItem) && a.ShipDate>= dateCurrent && a.ShipDate <= DateTime.Now);
|
|
|
- //按照物料分组统计出货金额
|
|
|
+ var shipMList = _ASNBOLShipperDetail.Select(a => a.Domain == input.factory_id.ToString() && a.IsActive && a.shtype == "SH" && a.Typed != "S" && a.RealQty > 0
|
|
|
+ && listShip.Contains(a.ContainerItem) && a.ShipDate>= dateCurrent && a.ShipDate <= DateTime.Now && !recidList.Contains(a.ASNBOLShipperRecID));//瑞奇只算瑞奇排除国科海王
|
|
|
+ var shipMListGK = _DMS_IN_SHIPPINGDETAIL.Select(a =>
|
|
|
+ DMSItemListGK.Select(g => g.CfnCode).Contains(a.UPN) && a.ParentDealerCode == "RQ000005" && a.ShipmentDate >= DateOnly.FromDateTime(dateCurrent) && a.ShipmentDate <= DateOnly.FromDateTime(DateTime.Now));//国科
|
|
|
+ var shipMListHW = _DMS_IN_SHIPPINGDETAIL.Select(a =>
|
|
|
+ DMSItemListHW.Select(g => g.CfnCode).Contains(a.UPN) && a.ParentDealerCode == "RQ000002" && a.ShipmentDate >= DateOnly.FromDateTime(dateCurrent) && a.ShipmentDate <= DateOnly.FromDateTime(DateTime.Now));//海王
|
|
|
+
|
|
|
var itemGroup = shipList.GroupBy(p => p.ContainerItem)
|
|
|
.Select(p => new ASNBOLShipperDetail
|
|
|
{
|
|
|
QtyToShip = p.Sum(a => a.QtyToShip),
|
|
|
ContainerItem = p.Key
|
|
|
}).ToList();
|
|
|
- //按照物料分组统计出货金额
|
|
|
var itemMGroup = shipMList.GroupBy(p => p.ContainerItem)
|
|
|
.Select(p => new ASNBOLShipperDetail
|
|
|
{
|
|
|
QtyToShip = p.Sum(a => a.QtyToShip),
|
|
|
ContainerItem = p.Key
|
|
|
}).ToList();
|
|
|
- List<ReplenishmentROP> addList = new List<ReplenishmentROP>();
|
|
|
- List<ReplenishmentROP> updateList = new List<ReplenishmentROP>();//更新上一个月的实际出库数量
|
|
|
+
|
|
|
+ var itemGroupGK = shipListGK.GroupBy(p => p.UPN)
|
|
|
+ .Select(p => new ASNBOLShipperDetail
|
|
|
+ {
|
|
|
+ QtyToShip = p.Sum(a => a.Qty),
|
|
|
+ ContainerItem = p.Key
|
|
|
+ }).ToList();
|
|
|
+ var itemMGroupGK = shipMListGK.GroupBy(p => p.UPN)
|
|
|
+ .Select(p => new ASNBOLShipperDetail
|
|
|
+ {
|
|
|
+ QtyToShip = p.Sum(a => a.Qty),
|
|
|
+ ContainerItem = p.Key
|
|
|
+ }).ToList();
|
|
|
+
|
|
|
+ var itemGroupHW = shipListHW.GroupBy(p => p.UPN)
|
|
|
+ .Select(p => new ASNBOLShipperDetail
|
|
|
+ {
|
|
|
+ QtyToShip = p.Sum(a => a.Qty),
|
|
|
+ ContainerItem = p.Key
|
|
|
+ }).ToList();
|
|
|
+ var itemMGroupHW = shipMListHW.GroupBy(p => p.UPN)
|
|
|
+ .Select(p => new ASNBOLShipperDetail
|
|
|
+ {
|
|
|
+ QtyToShip = p.Sum(a => a.Qty),
|
|
|
+ ContainerItem = p.Key
|
|
|
+ }).ToList();
|
|
|
+
|
|
|
var mathtool = new MathNet.Numerics.Distributions.Normal();
|
|
|
ropModelList?.Where(r => r.isparam && r.seqno == DateTime.Now.AddMonths(-1).Month && r.year == DateTime.Now.AddMonths(-1).Year).ToList()?.ForEach
|
|
|
(m =>
|
|
|
{
|
|
|
- if (itemGroup.Any(a => a.ContainerItem == m.number))
|
|
|
+ if(m.distributionchannel=="瑞奇")
|
|
|
+ {
|
|
|
+ if (itemGroup.Any(a => a.ContainerItem == m.number))
|
|
|
+ {
|
|
|
+ m.actual_out_qty = itemGroup.Find(a => a.ContainerItem == m.number)?.QtyToShip;
|
|
|
+ updateList.Add(m);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (m.distributionchannel == "国科")
|
|
|
+ {
|
|
|
+ if (itemGroupGK.Any(a => a.ContainerItem == m.number))
|
|
|
+ {
|
|
|
+ m.actual_out_qty = itemGroup.Find(a => a.ContainerItem == m.number)?.QtyToShip;
|
|
|
+ updateList.Add(m);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (m.distributionchannel == "海王")
|
|
|
{
|
|
|
- m.actual_out_qty = itemGroup.Find(a => a.ContainerItem == m.number)?.QtyToShip;
|
|
|
- updateList.Add(m);
|
|
|
+ if (itemGroupHW.Any(a => a.ContainerItem == m.number))
|
|
|
+ {
|
|
|
+ m.actual_out_qty = itemGroup.Find(a => a.ContainerItem == m.number)?.QtyToShip;
|
|
|
+ updateList.Add(m);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
var serviceList=_replenishmentServiceLevel.GetListAsync(a => a.factory_id == input.factory_id).Result;
|
|
|
- List<ReplenishmentServiceLevel> addServiceLevelList = new List<ReplenishmentServiceLevel>();
|
|
|
- List<ReplenishmentServiceLevel> updateServiceLevelList = new List<ReplenishmentServiceLevel>();
|
|
|
- //需要按照成品资源检查计算原材料
|
|
|
- planList?.Where(s => s.PlanMonth == planMonth).ToList()?.ForEach(a =>
|
|
|
+
|
|
|
+ planList?.Where(s => s.PlanMonth == planMonth&& s.DistributionChannel=="瑞奇").ToList()?.ForEach(a =>
|
|
|
{
|
|
|
var itemSourceId = boms.Find(b => b.item_number == a.SAPItemNumber)?.mysql_id;
|
|
|
if (itemSourceId != null)
|
|
|
@@ -837,16 +901,9 @@ namespace Business.Replenishment
|
|
|
rop.min_pack_qty = icItem.minpackqty;
|
|
|
rop.moq = icItem.moq;
|
|
|
}
|
|
|
- rop.actual_period_start_instock = 0;
|
|
|
- if (rop.distributionchannel == "海王" || rop.distributionchannel == "国科")
|
|
|
- {
|
|
|
- rop.actual_period_start_instock = locations.Find(l => l.ItemNum == pretreatments[i].item_number)?.QtyOnHand;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- rop.actual_period_start_instock = sapItemInv.Find(s => s.MATNR == pretreatments[i].item_number)?.LABST.ToDecimal();
|
|
|
- }
|
|
|
rop.distributionchannel = a.DistributionChannel;
|
|
|
+ rop.actual_period_start_instock = 0;
|
|
|
+ rop.actual_period_start_instock = sapItemInv.Find(s => s.MATNR == pretreatments[i].item_number)?.LABST.ToDecimal();
|
|
|
rop.lifecycle = a.LifeCycle;
|
|
|
rop.area = a.Area;
|
|
|
rop.plan_out_qty = Math.Ceiling(a.Qty);
|
|
|
@@ -872,22 +929,47 @@ namespace Business.Replenishment
|
|
|
}
|
|
|
|
|
|
rop.monthl_avg_demand_variance = Math.Ceiling(Convert.ToDecimal(CalcVariance(planList, pretreatments[i].item_number, rop.erp_cls, rop.monthl_avg_demand, pickbilllist)));
|
|
|
- rop.monthl_avg_outstock = CalcAvgOutStock(ropModelList, replenishmentDto, rop.actual_out_qty.Value, pretreatments[i].item_number);
|
|
|
- rop.supply_leadtime = 1;//默认
|
|
|
- if (mesItemList.Find(s => s.ItemNum == pretreatments[i].item_number) != null)
|
|
|
+ rop.monthl_avg_outstock = CalcAvgOutStock(ropModelList, replenishmentDto, rop.actual_out_qty.Value, pretreatments[i].item_number,"瑞奇");
|
|
|
+ rop.supply_leadtime = 15;//默认
|
|
|
+
|
|
|
+ //先判断是不是成品
|
|
|
+ if(rop.number== a.SAPItemNumber)
|
|
|
{
|
|
|
- rop.stock_turnover = mesItemList.Find(s => s.ItemNum == pretreatments[i].item_number).StockTurnOver;
|
|
|
- rop.supply_leadtime = mesItemList.Find(s => s.ItemNum == pretreatments[i].item_number)?.PurLT;
|
|
|
- rop.stock_turnover = mesItemList.Find(s => s.ItemNum == pretreatments[i].item_number)?.StockTurnOver;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- rop.stock_turnover = 4;
|
|
|
- }
|
|
|
- if (srm_purchaseList.Find(s => s.number == pretreatments[i].item_number) != null)
|
|
|
+ //存货周转率先取规格型号,没有再取产品系列,没有取产品线,再没有取物料配置的(主要是原材料),再没有就默认
|
|
|
+ if (turnOverlist.Find(t => t.Model == rop.model) != null)
|
|
|
+ {
|
|
|
+ rop.stock_turnover = turnOverlist.Find(t => t.Model == rop.model).RQTurnOver;
|
|
|
+ }
|
|
|
+ else if (turnOverlist.Find(t => t.ProdRange == a.ProdRange) != null)
|
|
|
+ {
|
|
|
+ rop.stock_turnover = turnOverlist.Find(t => t.ProdRange == a.ProdRange).RQTurnOver;
|
|
|
+ }else if(turnOverlist.Find(t => t.ProdLine == a.ProdLine) != null)
|
|
|
+ {
|
|
|
+ rop.stock_turnover = turnOverlist.Find(t => t.ProdLine == a.ProdLine).RQTurnOver;
|
|
|
+ }else if(mesItemList.Find(s => s.ItemNum == pretreatments[i].item_number) != null)
|
|
|
+ {
|
|
|
+ rop.stock_turnover = mesItemList.Find(s => s.ItemNum == pretreatments[i].item_number).StockTurnOver;
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ rop.stock_turnover = 4;
|
|
|
+ }
|
|
|
+ }else
|
|
|
{
|
|
|
- rop.supply_leadtime = srm_purchaseList.Find(s => s.number == pretreatments[i].item_number).lead_time;
|
|
|
+ if (mesItemList.Find(s => s.ItemNum == pretreatments[i].item_number) != null)
|
|
|
+ {
|
|
|
+ rop.stock_turnover = mesItemList.Find(s => s.ItemNum == pretreatments[i].item_number).StockTurnOver;
|
|
|
+ rop.supply_leadtime = mesItemList.Find(s => s.ItemNum == pretreatments[i].item_number)?.PurLT;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ rop.stock_turnover = 4;
|
|
|
+ }
|
|
|
+ if (srm_purchaseList.Find(s => s.number == pretreatments[i].item_number) != null)
|
|
|
+ {
|
|
|
+ rop.supply_leadtime = srm_purchaseList.Find(s => s.number == pretreatments[i].item_number).lead_time;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
CalcFMRAndABC(rop, replenishmentDto, shipList, pickbilllist, input);
|
|
|
if(serviceList.Any(s=>s.number==rop.number))
|
|
|
{
|
|
|
@@ -988,6 +1070,205 @@ namespace Business.Replenishment
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+ //国科海王只有成品
|
|
|
+ planList?.Where(s => s.PlanMonth == planMonth && (s.DistributionChannel == "海王"|| s.DistributionChannel == "国科")).ToList()?.ForEach(a =>
|
|
|
+ {
|
|
|
+ ReplenishmentROP rop = new ReplenishmentROP();
|
|
|
+ rop.number = a.SAPItemNumber;
|
|
|
+ var icItem = itemList.Find(s => s.number == a.SAPItemNumber);
|
|
|
+ if (icItem != null)
|
|
|
+ {
|
|
|
+ rop.name = icItem.name;
|
|
|
+ rop.model = a.Model;
|
|
|
+ rop.erp_cls = icItem.erp_cls; //物料属性: 0.配置类 1.自制 2.委外加工 3.外购 4.虚拟件
|
|
|
+ rop.fversion = icItem.fversion;
|
|
|
+ rop.min_pack_qty = icItem.minpackqty;
|
|
|
+ rop.moq = icItem.moq;
|
|
|
+ }
|
|
|
+ rop.distributionchannel = a.DistributionChannel;
|
|
|
+ rop.actual_period_start_instock = 0;
|
|
|
+ if(a.DistributionChannel == "海王")
|
|
|
+ {
|
|
|
+ if (DMSItemList.Find(d => d.CfnERPCode == rop.number) != null)
|
|
|
+ {
|
|
|
+ var itemDMS = gkhwStock.Where(o => o.UPN == DMSItemList.Find(d => d.CfnERPCode == rop.number).CfnCode && o.DealerCode== "RQ000002").ToList();
|
|
|
+ if (itemDMS.Count > 0)
|
|
|
+ {
|
|
|
+ var maxDate = itemDMS.OrderByDescending(i => i.InventoryDate).First();
|
|
|
+ rop.actual_period_start_instock = itemDMS.Where(i => i.InventoryDate == maxDate.InventoryDate).Sum(q => q.Qty);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ if (DMSItemList.Find(d => d.CfnERPCode == rop.number) != null)
|
|
|
+ {
|
|
|
+ var itemDMS = gkhwStock.Where(o => o.UPN == DMSItemList.Find(d => d.CfnERPCode == rop.number).CfnCode && o.DealerCode == "RQ000005").ToList();
|
|
|
+ if (itemDMS.Count > 0)
|
|
|
+ {
|
|
|
+ var maxDate = itemDMS.OrderByDescending(i => i.InventoryDate).First();
|
|
|
+ rop.actual_period_start_instock = itemDMS.Where(i => i.InventoryDate == maxDate.InventoryDate).Sum(q => q.Qty);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rop.lifecycle = a.LifeCycle;
|
|
|
+ rop.area = a.Area;
|
|
|
+ rop.plan_out_qty = Math.Ceiling(a.Qty);
|
|
|
+ rop.actual_out_qty = 0;
|
|
|
+ if(a.DistributionChannel == "海王")
|
|
|
+ {
|
|
|
+ if (itemMGroup.Any(m => m.ContainerItem == a.SAPItemNumber))
|
|
|
+ {
|
|
|
+ rop.actual_out_qty = itemMGroupHW.Find(m => m.ContainerItem == a.SAPItemNumber)?.QtyToShip;
|
|
|
+ }
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ if (itemMGroup.Any(m => m.ContainerItem == a.SAPItemNumber))
|
|
|
+ {
|
|
|
+ rop.actual_out_qty = itemMGroupGK.Find(m => m.ContainerItem == a.SAPItemNumber)?.QtyToShip;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ rop.year = DateTime.Now.Year;
|
|
|
+ rop.long_period = "Y";
|
|
|
+ rop.short_period = "M";
|
|
|
+ rop.seqno = DateTime.Now.Month;
|
|
|
+ rop.zero_based_seqno = 0;
|
|
|
+ rop.period_start_date = getMonthStartTime(0);
|
|
|
+ rop.period_end_date = getMonthEndTime(0);
|
|
|
+
|
|
|
+ if(a.DistributionChannel == "海王")
|
|
|
+ {
|
|
|
+ if (planList.Where(i => i.SAPItemNumber == a.SAPItemNumber && i.DistributionChannel == "海王").Count() > 0)
|
|
|
+ {
|
|
|
+ rop.monthl_avg_demand=planList.Where(i => i.SAPItemNumber == a.SAPItemNumber && i.DistributionChannel == "海王").Average(a => a.Qty);
|
|
|
+ var nums = planList.Where(i => i.SAPItemNumber == a.SAPItemNumber && i.DistributionChannel == "海王").Select(a => a.Qty);
|
|
|
+ if (nums.Count() <= 1)
|
|
|
+ {
|
|
|
+ rop.monthl_avg_demand_variance = 0;
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ rop.monthl_avg_demand_variance = Math.Ceiling(Convert.ToDecimal(Math.Sqrt(nums.Sum(x => Math.Pow(Convert.ToDouble(x) - Convert.ToDouble(rop.monthl_avg_demand), 2)) / (nums.Count() - 1))));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ rop.monthl_avg_demand = 0;
|
|
|
+ rop.monthl_avg_demand_variance = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (planList.Where(i => i.SAPItemNumber == a.SAPItemNumber && i.DistributionChannel == "国科").Count() > 0)
|
|
|
+ {
|
|
|
+ rop.monthl_avg_demand = planList.Where(i => i.SAPItemNumber == a.SAPItemNumber && i.DistributionChannel == "国科").Average(a => a.Qty);
|
|
|
+ var nums = planList.Where(i => i.SAPItemNumber == a.SAPItemNumber && i.DistributionChannel == "国科").Select(a => a.Qty);
|
|
|
+ if (nums.Count() <= 1)
|
|
|
+ {
|
|
|
+ rop.monthl_avg_demand_variance = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ rop.monthl_avg_demand_variance = Math.Ceiling(Convert.ToDecimal(Math.Sqrt(nums.Sum(x => Math.Pow(Convert.ToDouble(x) - Convert.ToDouble(rop.monthl_avg_demand), 2)) / (nums.Count() - 1))));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ rop.monthl_avg_demand = 0;
|
|
|
+ rop.monthl_avg_demand_variance = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rop.monthl_avg_outstock = CalcAvgOutStock(ropModelList, replenishmentDto, rop.actual_out_qty.Value, a.SAPItemNumber,a.DistributionChannel);
|
|
|
+ rop.supply_leadtime = 15;//默认
|
|
|
+
|
|
|
+
|
|
|
+ //存货周转率先取规格型号,没有再取产品系列,没有取产品线,再没有取物料配置的(主要是原材料),再没有就默认
|
|
|
+ if (turnOverlist.Find(t => t.Model == rop.model) != null)
|
|
|
+ {
|
|
|
+ rop.stock_turnover = turnOverlist.Find(t => t.Model == rop.model).RQTurnOver;
|
|
|
+ }
|
|
|
+ else if (turnOverlist.Find(t => t.ProdRange == a.ProdRange) != null)
|
|
|
+ {
|
|
|
+ rop.stock_turnover = turnOverlist.Find(t => t.ProdRange == a.ProdRange).RQTurnOver;
|
|
|
+ }
|
|
|
+ else if (turnOverlist.Find(t => t.ProdLine == a.ProdLine) != null)
|
|
|
+ {
|
|
|
+ rop.stock_turnover = turnOverlist.Find(t => t.ProdLine == a.ProdLine).RQTurnOver;
|
|
|
+ }
|
|
|
+ else if (mesItemList.Find(s => s.ItemNum == a.SAPItemNumber) != null)
|
|
|
+ {
|
|
|
+ rop.stock_turnover = mesItemList.Find(s => s.ItemNum == a.SAPItemNumber).StockTurnOver;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ rop.stock_turnover = 4;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ CalcFMRAndABC(rop, replenishmentDto, shipList, pickbilllist, input);
|
|
|
+ if (serviceList.Any(s => s.number == rop.number))
|
|
|
+ {
|
|
|
+ var rs = serviceList.Find(s => s.number == rop.number);
|
|
|
+ //总的移库次数
|
|
|
+ int totalCount =a.DistributionChannel=="海王"? shipListHW.Count(): shipListGK.Count();
|
|
|
+ //平均出库次数
|
|
|
+ decimal avgOutStock = totalCount / replenishmentDto.HistoryOutStockMonth;
|
|
|
+ rs.number = rop.number;
|
|
|
+ rs.name = rop.name;
|
|
|
+ rs.model = rop.model;
|
|
|
+ rs.item_type = icItem.item_type;
|
|
|
+ rs.fversion = rop.fversion;
|
|
|
+ rs.totalCount = totalCount;
|
|
|
+ rs.avgOutStock = avgOutStock;
|
|
|
+ rs.totalPrice =0;
|
|
|
+ rs.Price = 0;
|
|
|
+ rs.abc = rop.abc;
|
|
|
+ rs.fmr = rop.fmr;
|
|
|
+ rs.service_level_pct = rop.service_level_pct;
|
|
|
+ rs.factory_id = input.factory_id;
|
|
|
+ rs.tenant_id = input.tenant_id;
|
|
|
+ rs.company_id = input.company_id;
|
|
|
+ rs.update_time = DateTime.Now;
|
|
|
+ updateServiceLevelList.Add(rs);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //总的移库次数
|
|
|
+ int totalCount = a.DistributionChannel == "海王" ? shipListHW.Count() : shipListGK.Count();
|
|
|
+ //平均出库次数
|
|
|
+ decimal avgOutStock = totalCount / replenishmentDto.HistoryOutStockMonth;
|
|
|
+ ReplenishmentServiceLevel rs = new ReplenishmentServiceLevel();
|
|
|
+ rs.number = rop.number;
|
|
|
+ rs.name = rop.name;
|
|
|
+ rs.model = rop.model;
|
|
|
+ rs.item_type = icItem.item_type;
|
|
|
+ rs.fversion = rop.fversion;
|
|
|
+ rs.totalCount = totalCount;
|
|
|
+ rs.avgOutStock = avgOutStock;
|
|
|
+ rs.totalPrice = 0;
|
|
|
+ rs.Price = 0;
|
|
|
+ rs.abc = rop.abc;
|
|
|
+ rs.fmr = rop.fmr;
|
|
|
+ rs.service_level_pct = rop.service_level_pct;
|
|
|
+ rs.factory_id = input.factory_id;
|
|
|
+ rs.tenant_id = input.tenant_id;
|
|
|
+ rs.company_id = input.company_id;
|
|
|
+ rs.create_time = DateTime.Now;
|
|
|
+ rs.GenerateNewId(help.NextId());
|
|
|
+ addServiceLevelList.Add(rs);
|
|
|
+ }
|
|
|
+ rop.security_stock = Math.Ceiling((decimal)(mathtool.InverseCumulativeDistribution((double)rop.service_level_pct.Value) * (double)rop.monthl_avg_demand_variance));
|
|
|
+ rop.eop = Math.Ceiling(rop.monthl_avg_demand.Value * rop.supply_leadtime.Value / DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month));
|
|
|
+ rop.rop_computed = rop.security_stock + rop.eop;
|
|
|
+ rop.max_stock_level = rop.monthl_avg_outstock * (12 / rop.stock_turnover);
|
|
|
+ rop.rop_revised = Math.Min(rop.rop_computed.Value, rop.max_stock_level.Value);
|
|
|
+ rop.isparam = true;
|
|
|
+ rop.tenant_id = input.tenant_id;
|
|
|
+ rop.factory_id = input.factory_id;
|
|
|
+ rop.create_time = DateTime.Now;
|
|
|
+ rop.org_id = input.org_id;
|
|
|
+ addList.Add(rop);
|
|
|
+ });
|
|
|
addList?.ForEach(item => { item.GenerateNewId(help.NextId()); });
|
|
|
addServiceLevelList?.ForEach(item => { item.GenerateNewId(help.NextId()); });
|
|
|
await _replenishmentROP.InsertManyAsync(addList);
|
|
|
@@ -1821,6 +2102,7 @@ namespace Business.Replenishment
|
|
|
workOrd.IsConfirm = true;
|
|
|
workOrd.CreateTime = DateTime.Now;
|
|
|
workOrd.Typed = "";
|
|
|
+ workOrd.SalesJob = item.morder_no;
|
|
|
workOrds.Add(workOrd);
|
|
|
|
|
|
//添加工单工艺路线数据
|
|
|
@@ -2127,6 +2409,14 @@ namespace Business.Replenishment
|
|
|
var molist=_mysql_mes_morder.GetListAsync(a => itemNumbers.Contains(a.product_code) && a.factory_id == input.factory_id && !a.IsDeleted).Result;
|
|
|
var proccupylist=_mysql_srm_pr_main_occupy.GetListAsync(a=> molist.Select(p=>p.morder_no).ToList().Contains(a.morder_mo) && a.factory_id == input.factory_id && !a.IsDeleted).Result;
|
|
|
|
|
|
+ //TODO:完善占用逻辑
|
|
|
+ //srm_pr_main pr = new srm_pr_main();
|
|
|
+ //pr.state = 1;
|
|
|
+ //srm_po_main po = new srm_po_main();
|
|
|
+ ////po.state.GetValueOrDefault() != 3;
|
|
|
+ //srm_po_occupy srm_Po_Occupy = new srm_po_occupy();
|
|
|
+ ////srm_Po_Occupy.polist_id = pr.Id;po.id;
|
|
|
+
|
|
|
itemNumbers.ForEach(a =>
|
|
|
{
|
|
|
EOPDto eOPDto=new EOPDto();
|
|
|
@@ -3332,48 +3622,91 @@ namespace Business.Replenishment
|
|
|
return replenishmentDto;
|
|
|
}
|
|
|
|
|
|
+ ///// <summary>
|
|
|
+ ///// 计算ABC分类和FMR分类
|
|
|
+ ///// </summary>
|
|
|
+ ///// <param name="replenishmentModels"></param>
|
|
|
+ //public void CalcFMRAndABC(ReplenishmentROP replenishmentModel, ReplenishmentDto replenishmentDto,List<ASNBOLShipperDetail> shipList,List<InvTransHist> pickbilllist, InputDto input)
|
|
|
+ //{
|
|
|
+ // //总的移库次数
|
|
|
+ // int totalCount = shipList.Count() + pickbilllist.Count();
|
|
|
+ // //平均出库次数
|
|
|
+ // decimal avgOutStock = totalCount / replenishmentDto.HistoryOutStockMonth;
|
|
|
+
|
|
|
+ // //总出货金额
|
|
|
+ // decimal? totalPrice = shipList.Sum(a => a.Price * a.QtyToShip);
|
|
|
+ // //按照物料分组统计出货金额
|
|
|
+ // var itemGroup = shipList.GroupBy(p => p.ContainerItem)
|
|
|
+ // .Select(p => new ASNBOLShipperDetail
|
|
|
+ // {
|
|
|
+ // Price = p.Sum(a => a.Price * a.QtyToShip) * 100 / totalPrice,
|
|
|
+ // ContainerItem = p.Key
|
|
|
+ // }).ToList().OrderByDescending(c => c.Price).ThenByDescending(c => c.ContainerItem);
|
|
|
+ // var AIndex = (int)Math.Ceiling(itemGroup.Count() * 0.75);//A类:0-75%
|
|
|
+ // var BIndex = (int)Math.Ceiling(itemGroup.Count() * 0.9) - AIndex;//A类:75%-90%
|
|
|
+ // var CIndex = itemGroup.Count() - AIndex - BIndex;//A类:90%-100%
|
|
|
+ // var AItem = itemGroup.Take(AIndex);
|
|
|
+ // var BItem = itemGroup.Skip(AIndex).Take(BIndex);
|
|
|
+ // var CItem = itemGroup.Skip(AIndex + BIndex).Take(CIndex);
|
|
|
+ // if (AItem.Any(a => a.ContainerItem == replenishmentModel.number))
|
|
|
+ // {
|
|
|
+ // replenishmentModel.abc = "A";//金额占比前75%的物料划为A类
|
|
|
+ // }
|
|
|
+ // else if (BItem.Any(a => a.ContainerItem == replenishmentModel.number))
|
|
|
+ // {
|
|
|
+ // replenishmentModel.abc = "B";//金额占比前75%-90%的物料划为B类
|
|
|
+ // }
|
|
|
+ // else if (CItem.Any(a => a.ContainerItem == replenishmentModel.number))
|
|
|
+ // {
|
|
|
+ // replenishmentModel.abc = "C";//金额占比后10%的物料划为C类
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // replenishmentModel.abc = "B";//原材料默认为B
|
|
|
+ // }
|
|
|
+ // int itemMoveCount = shipList.Count(a => a.ContainerItem == replenishmentModel.number) + pickbilllist.Count(a => a.ItemNum == replenishmentModel.number);
|
|
|
+ // if (itemMoveCount >= avgOutStock)
|
|
|
+ // {
|
|
|
+ // replenishmentModel.fmr = "F";
|
|
|
+ // }
|
|
|
+ // else if (itemMoveCount >= avgOutStock / 2 && itemMoveCount < avgOutStock || itemMoveCount == 0)
|
|
|
+ // {
|
|
|
+ // replenishmentModel.fmr = "M";//没有出库移库记录的默认为M
|
|
|
+ // }
|
|
|
+ // else if (itemMoveCount < avgOutStock / 2)
|
|
|
+ // {
|
|
|
+ // replenishmentModel.fmr = "R";
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (replenishmentModel.abc == "A" && replenishmentModel.fmr == "R")
|
|
|
+ // {
|
|
|
+ // replenishmentModel.service_level_pct = (decimal?)0.8;
|
|
|
+ // }
|
|
|
+ // if (replenishmentModel.fmr != "R")
|
|
|
+ // {
|
|
|
+ // replenishmentModel.service_level_pct = (decimal?)0.96;
|
|
|
+ // }
|
|
|
+ // if (replenishmentModel.abc != "A" && replenishmentModel.fmr == "R")
|
|
|
+ // {
|
|
|
+ // replenishmentModel.service_level_pct = (decimal?)0.9;
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 计算ABC分类和FMR分类
|
|
|
/// </summary>
|
|
|
/// <param name="replenishmentModels"></param>
|
|
|
- public void CalcFMRAndABC(ReplenishmentROP replenishmentModel, ReplenishmentDto replenishmentDto,List<ASNBOLShipperDetail> shipList,List<InvTransHist> pickbilllist, InputDto input)
|
|
|
+ public void CalcFMRAndABC(ReplenishmentROP replenishmentModel, ReplenishmentDto replenishmentDto, List<ASNBOLShipperDetail> shipList, List<InvTransHist> pickbilllist, InputDto input)
|
|
|
{
|
|
|
//总的移库次数
|
|
|
int totalCount = shipList.Count() + pickbilllist.Count();
|
|
|
//平均出库次数
|
|
|
decimal avgOutStock = totalCount / replenishmentDto.HistoryOutStockMonth;
|
|
|
+ //瑞奇不提供价格敏感信息,ABC类都默认为B,全部当做无出库金额的物料
|
|
|
+ //无出库金额的物料 FMR分类 F 96 % M 90 % R 80 %
|
|
|
+ //有出库金额的物料 ABC/ FMR分类 AF 96 % AM 90 % AR 80 % BF 96 % BM 90 % BR 80 % CF 96 % CM 90 % CR 80 %
|
|
|
+ replenishmentModel.abc = "B";//原材料默认为B
|
|
|
|
|
|
- //总出货金额
|
|
|
- decimal? totalPrice = shipList.Sum(a => a.Price * a.QtyToShip);
|
|
|
- //按照物料分组统计出货金额
|
|
|
- var itemGroup = shipList.GroupBy(p => p.ContainerItem)
|
|
|
- .Select(p => new ASNBOLShipperDetail
|
|
|
- {
|
|
|
- Price = p.Sum(a => a.Price * a.QtyToShip) * 100 / totalPrice,
|
|
|
- ContainerItem = p.Key
|
|
|
- }).ToList().OrderByDescending(c => c.Price).ThenByDescending(c => c.ContainerItem);
|
|
|
- var AIndex = (int)Math.Ceiling(itemGroup.Count() * 0.75);//A类:0-75%
|
|
|
- var BIndex = (int)Math.Ceiling(itemGroup.Count() * 0.9) - AIndex;//A类:75%-90%
|
|
|
- var CIndex = itemGroup.Count() - AIndex - BIndex;//A类:90%-100%
|
|
|
- var AItem = itemGroup.Take(AIndex);
|
|
|
- var BItem = itemGroup.Skip(AIndex).Take(BIndex);
|
|
|
- var CItem = itemGroup.Skip(AIndex + BIndex).Take(CIndex);
|
|
|
- if (AItem.Any(a => a.ContainerItem == replenishmentModel.number))
|
|
|
- {
|
|
|
- replenishmentModel.abc = "A";//金额占比前75%的物料划为A类
|
|
|
- }
|
|
|
- else if (BItem.Any(a => a.ContainerItem == replenishmentModel.number))
|
|
|
- {
|
|
|
- replenishmentModel.abc = "B";//金额占比前75%-90%的物料划为B类
|
|
|
- }
|
|
|
- else if (CItem.Any(a => a.ContainerItem == replenishmentModel.number))
|
|
|
- {
|
|
|
- replenishmentModel.abc = "C";//金额占比后10%的物料划为C类
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- replenishmentModel.abc = "B";//原材料默认为B
|
|
|
- }
|
|
|
int itemMoveCount = shipList.Count(a => a.ContainerItem == replenishmentModel.number) + pickbilllist.Count(a => a.ItemNum == replenishmentModel.number);
|
|
|
if (itemMoveCount >= avgOutStock)
|
|
|
{
|
|
|
@@ -3388,18 +3721,18 @@ namespace Business.Replenishment
|
|
|
replenishmentModel.fmr = "R";
|
|
|
}
|
|
|
|
|
|
- if (replenishmentModel.abc == "A" && replenishmentModel.fmr == "R")
|
|
|
- {
|
|
|
- replenishmentModel.service_level_pct = (decimal?)0.8;
|
|
|
- }
|
|
|
- if (replenishmentModel.fmr != "R")
|
|
|
+ if (replenishmentModel.fmr == "F")
|
|
|
{
|
|
|
replenishmentModel.service_level_pct = (decimal?)0.96;
|
|
|
}
|
|
|
- if (replenishmentModel.abc != "A" && replenishmentModel.fmr == "R")
|
|
|
+ if (replenishmentModel.fmr == "M")
|
|
|
{
|
|
|
replenishmentModel.service_level_pct = (decimal?)0.9;
|
|
|
}
|
|
|
+ if (replenishmentModel.fmr == "R")
|
|
|
+ {
|
|
|
+ replenishmentModel.service_level_pct = (decimal?)0.8;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -3414,9 +3747,9 @@ namespace Business.Replenishment
|
|
|
{
|
|
|
if(erp_cls!=3)
|
|
|
{
|
|
|
- if(list.Where(i => i.SAPItemNumber == itemNum).Count()>0)
|
|
|
+ if(list.Where(i => i.SAPItemNumber == itemNum && i.DistributionChannel=="瑞奇").Count()>0)
|
|
|
{
|
|
|
- return list.Where(i => i.SAPItemNumber == itemNum).Average(a => a.Qty);
|
|
|
+ return list.Where(i => i.SAPItemNumber == itemNum && i.DistributionChannel == "瑞奇").Average(a => a.Qty);
|
|
|
}
|
|
|
return 0;
|
|
|
}else
|
|
|
@@ -3438,9 +3771,9 @@ namespace Business.Replenishment
|
|
|
/// <param name="replenishmentDto">全局参数</param>
|
|
|
/// <param name="itemNum">物料编码</param>
|
|
|
/// <returns></returns>
|
|
|
- public decimal CalcAvgOutStock(List<ReplenishmentROP> list, ReplenishmentDto replenishmentDto, decimal MQty, string itemNum)
|
|
|
+ public decimal CalcAvgOutStock(List<ReplenishmentROP> list, ReplenishmentDto replenishmentDto, decimal MQty, string itemNum,string distributionchannel)
|
|
|
{
|
|
|
- return (list.Where(i => i.number == itemNum && i.zero_based_seqno > 1 - replenishmentDto.HistoryOutStockMonth && i.zero_based_seqno <= 0).Select(a => a.actual_out_qty.Value).Sum() + MQty) / (replenishmentDto.HistoryOutStockMonth + 1);
|
|
|
+ return (list.Where(i => i.number == itemNum && i.distributionchannel== distributionchannel && i.zero_based_seqno > 1 - replenishmentDto.HistoryOutStockMonth && i.zero_based_seqno <= 0).Select(a => a.actual_out_qty.Value).Sum() + MQty) / (replenishmentDto.HistoryOutStockMonth + 1);
|
|
|
}
|
|
|
|
|
|
public double CalcVariance(List<MonthlyShipmentPlan> list, string itemNum, int? erp_cls,decimal? monthl_avg_demand, List<InvTransHist> pickbilllist = null)
|
|
|
@@ -3473,33 +3806,6 @@ namespace Business.Replenishment
|
|
|
return weekOfYear;
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 获取指定日期在该月的第几周
|
|
|
- /// </summary>
|
|
|
- /// <param name="day"></param>
|
|
|
- /// <param name="WeekStart">1表示周一至周日为一周,2表示周日至周六为一周</param>
|
|
|
- /// <returns></returns>
|
|
|
- public static int WeekOfMonth(DateTime day, int WeekStart)
|
|
|
- {
|
|
|
- DateTime FirstofMonth = Convert.ToDateTime(day.Date.Year + "-" + day.Date.Month + "-" + 1);
|
|
|
-
|
|
|
- int i = (int)FirstofMonth.Date.DayOfWeek;
|
|
|
- if (i == 0)
|
|
|
- {
|
|
|
- i = 7;
|
|
|
- }
|
|
|
-
|
|
|
- if (WeekStart == 1)
|
|
|
- {
|
|
|
- return (day.Date.Day + i - 2) / 7 + 1;
|
|
|
- }
|
|
|
- if (WeekStart == 2)
|
|
|
- {
|
|
|
- return (day.Date.Day + i - 1) / 7;
|
|
|
-
|
|
|
- }
|
|
|
- return 0;
|
|
|
- }
|
|
|
//获取上周开始时间
|
|
|
public static DateTime getPreWeekStartTime()
|
|
|
{
|