|
|
@@ -1820,24 +1820,20 @@ namespace Business.Replenishment
|
|
|
weekPlanTime = weekPlanTime.AddDays(7 * k);
|
|
|
string kMonth = $"{weekPlanTime.Year}-{weekPlanTime.Month.ToString("00")}";
|
|
|
//如果该10月有发布的2周生产计划,则周补货量=10月补货量-已发布的2周生产计划数量/剩余周次(2)
|
|
|
- var monthWeekPlan = planList.Where(a => a.planmonth == kMonth).ToList();
|
|
|
+ //周补货计划只计算成品,不需要到原材料
|
|
|
+ var monthWeekPlan = planList.Where(a => a.planmonth == kMonth && planItemList.Contains(a.number)).ToList();
|
|
|
foreach (var item in monthWeekPlan)
|
|
|
{
|
|
|
- //周补货计划只计算成品,不需要到原材料
|
|
|
- if (planItemList.Contains(item.number))
|
|
|
+ int publishedWeekCount = weekProductPlanList.Where(a => a.PlanMonth == kMonth && a.ItemNumber == item.number && a.ProductionStatus == "已发布" && a.DistributionChannel == item.distributionchannel).Count();
|
|
|
+ decimal publishedWeekQtySum = weekProductPlanList.Where(a => a.PlanMonth == kMonth && a.ItemNumber == item.number && a.ProductionStatus == "已发布" && a.DistributionChannel == item.distributionchannel).Sum(a => a.Qty);
|
|
|
+ var weekItemPlan = weekPlanList.Find(a => a.PlanMonth == kMonth && a.ItemNumber == item.number && a.WeekSeq == WeekOfMonth(weekPlanTime, 1) && a.DistributionChannel == item.distributionchannel);
|
|
|
+ if(publishedWeekCount<4)
|
|
|
{
|
|
|
- int publishedWeekCount = weekProductPlanList.Where(a => a.PlanMonth == kMonth && a.ItemNumber == item.number && a.ProductionStatus == "已发布" && a.DistributionChannel == item.distributionchannel).Count();
|
|
|
- decimal publishedWeekQtySum = weekProductPlanList.Where(a => a.PlanMonth == kMonth && a.ItemNumber == item.number && a.ProductionStatus == "已发布" && a.DistributionChannel == item.distributionchannel).Sum(a => a.Qty);
|
|
|
- var weekItemPlan = weekPlanList.Find(a => a.PlanMonth == kMonth && a.ItemNumber == item.number && a.WeekSeq == WeekOfMonth(weekPlanTime, 1) && a.DistributionChannel == item.distributionchannel);
|
|
|
- if (weekItemPlan != null)
|
|
|
+ if(weekItemPlan!=null)
|
|
|
{
|
|
|
- if (weekItemPlan.ProductionStatus != "已发布" && publishedWeekCount < 4)
|
|
|
- {
|
|
|
- weekItemPlan.Qty = Math.Ceiling((item.montheop1.GetValueOrDefault() + item.montheop2.GetValueOrDefault() - publishedWeekQtySum) / (4 - publishedWeekCount));
|
|
|
- updateRopList.Add(weekItemPlan);
|
|
|
- }
|
|
|
- }
|
|
|
- else if (publishedWeekCount < 4)
|
|
|
+ weekItemPlan.Qty = Math.Ceiling((item.montheop1.GetValueOrDefault() + item.montheop2.GetValueOrDefault() - publishedWeekQtySum) / (4 - publishedWeekCount));
|
|
|
+ updateRopList.Add(weekItemPlan);
|
|
|
+ }else
|
|
|
{
|
|
|
ReplenishmentWeekPlan weekItemPlanAdd = new ReplenishmentWeekPlan();
|
|
|
weekItemPlanAdd.Area = item.area;
|
|
|
@@ -3192,7 +3188,7 @@ namespace Business.Replenishment
|
|
|
|
|
|
private DateTime GetNextMonday()
|
|
|
{
|
|
|
- var preSunday = DateTime.Now.AddDays(0 - Convert.ToInt16(DateTime.Now.DayOfWeek) - 7);//上周日
|
|
|
+ var preSunday = DateTime.Now.AddDays(0 - (int)DateTime.Now.DayOfWeek);//上周日
|
|
|
return Convert.ToDateTime(preSunday.AddDays(8).ToString("yyyy-MM-dd 00:00:00.000"));////上周日加八天即为下周一
|
|
|
}
|
|
|
|
|
|
@@ -5341,7 +5337,7 @@ namespace Business.Replenishment
|
|
|
//await _mysql_mes_morder.InsertManyAsync(moList);
|
|
|
//await _mysql_mes_moentry.InsertManyAsync(moentryList);
|
|
|
moList = moList.OrderBy(a => a.moentry_sys_stime).ToList();
|
|
|
- await PlanOrderResourceCheck(moList,moentryList, bangid, "V"+string.Format("{0:yyyyMMddHHmm}", DateTime.Now), input);
|
|
|
+ await PlanOrderResourceCheck(moList,moentryList, bangid, $"V{DateTime.Now.ToString("yyyyMMddHHmm")}", input);
|
|
|
return "OK";
|
|
|
}
|
|
|
|