|
@ -829,7 +829,7 @@ func (impl *BalanceServiceImplement) refreshMpsArticleDemand(isRefresh bool,data |
|
|
MinInventory += data_ArticleDemand[now].ForecastDemandQty |
|
|
MinInventory += data_ArticleDemand[now].ForecastDemandQty |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
articleDemandInfo.MinInventory = MinInventory |
|
|
|
|
|
|
|
|
data_ArticleDemand[index].MinInventory = MinInventory |
|
|
|
|
|
|
|
|
//目标库存水平
|
|
|
//目标库存水平
|
|
|
TargetInventory := 0.0 |
|
|
TargetInventory := 0.0 |
|
@ -839,42 +839,46 @@ func (impl *BalanceServiceImplement) refreshMpsArticleDemand(isRefresh bool,data |
|
|
TargetInventory += data_ArticleDemand[now].ForecastDemandQty |
|
|
TargetInventory += data_ArticleDemand[now].ForecastDemandQty |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
articleDemandInfo.TargetInventory = TargetInventory |
|
|
|
|
|
|
|
|
data_ArticleDemand[index].TargetInventory = TargetInventory |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 需求
|
|
|
|
|
|
for index, _ := range data_ArticleDemand { |
|
|
|
|
|
//需求 = 预测和订单需求最大值 + 外购 + 独立
|
|
|
|
|
|
needQty := data_ArticleDemand[index].OrderQty + data_ArticleDemand[index].OutSourcingQty + data_ArticleDemand[index].IndependentDemandQty |
|
|
|
|
|
if data_ArticleDemand[index].ForecastDemandQty > data_ArticleDemand[index].OrderQty { |
|
|
|
|
|
needQty = data_ArticleDemand[index].ForecastDemandQty + data_ArticleDemand[index].OutSourcingQty + data_ArticleDemand[index].IndependentDemandQty |
|
|
|
|
|
} |
|
|
|
|
|
data_ArticleDemand[index].NeedQty = needQty |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//IF (期初库存 – 需求) < 最低库存
|
|
|
//IF (期初库存 – 需求) < 最低库存
|
|
|
//触发生产
|
|
|
//触发生产
|
|
|
//MPS 计划量 = 目标库存 - ( 期初库存 – 需求 )
|
|
|
|
|
|
|
|
|
//净生产量 = 目标库存 - ( 期初库存 – 需求 )
|
|
|
//ELSE
|
|
|
//ELSE
|
|
|
//不触发生产
|
|
|
//不触发生产
|
|
|
//MPS 计划量 = 0
|
|
|
|
|
|
|
|
|
//净生产量 = 0
|
|
|
//END IF
|
|
|
//END IF
|
|
|
//计算需求
|
|
|
//计算需求
|
|
|
|
|
|
|
|
|
for index, articleDemandInfo := range data_ArticleDemand { |
|
|
|
|
|
needQty := articleDemandInfo.IndependentDemandQty + articleDemandInfo.OutSourcingQty + articleDemandInfo.OrderQty |
|
|
|
|
|
if articleDemandInfo.ForecastDemandQty > articleDemandInfo.OrderQty { |
|
|
|
|
|
needQty = articleDemandInfo.ForecastDemandQty + articleDemandInfo.OutSourcingQty + articleDemandInfo.OrderQty |
|
|
|
|
|
} |
|
|
|
|
|
data_ArticleDemand[index].NeedQty = needQty |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !isRefresh { |
|
|
if !isRefresh { |
|
|
if articleDemandInfo.OpeningInventory-articleDemandInfo.NeedQty < articleDemandInfo.MinInventory { |
|
|
|
|
|
articleDemandInfo.NetDemandQty = articleDemandInfo.TargetInventory - (articleDemandInfo.OpeningInventory - articleDemandInfo.NeedQty) |
|
|
|
|
|
|
|
|
if data_ArticleDemand[index].OpeningInventory-data_ArticleDemand[index].NeedQty < data_ArticleDemand[index].MinInventory { |
|
|
|
|
|
data_ArticleDemand[index].NetDemandQty = data_ArticleDemand[index].TargetInventory - (data_ArticleDemand[index].OpeningInventory - data_ArticleDemand[index].NeedQty) |
|
|
} else { |
|
|
} else { |
|
|
articleDemandInfo.NetDemandQty = 0 |
|
|
|
|
|
|
|
|
data_ArticleDemand[index].NetDemandQty = 0 |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 期末库存
|
|
|
|
|
|
articleDemandInfo.EndingInventory = articleDemandInfo.NetDemandQty + articleDemandInfo.OpeningInventory - articleDemandInfo.NeedQty |
|
|
|
|
|
|
|
|
// 期末库存 = 净生产量 + 期初库存 - 需求
|
|
|
|
|
|
data_ArticleDemand[index].EndingInventory = data_ArticleDemand[index].NetDemandQty + data_ArticleDemand[index].OpeningInventory - data_ArticleDemand[index].NeedQty |
|
|
|
|
|
|
|
|
data_ArticleDemand[index].MinInventory = articleDemandInfo.MinInventory |
|
|
|
|
|
data_ArticleDemand[index].TargetInventory = articleDemandInfo.TargetInventory |
|
|
|
|
|
data_ArticleDemand[index].NetDemandQty = articleDemandInfo.NetDemandQty |
|
|
|
|
|
data_ArticleDemand[index].EndingInventory = articleDemandInfo.EndingInventory |
|
|
|
|
|
|
|
|
//data_ArticleDemand[index].MinInventory = articleDemandInfo.MinInventory
|
|
|
|
|
|
//data_ArticleDemand[index].TargetInventory = articleDemandInfo.TargetInventory
|
|
|
|
|
|
//data_ArticleDemand[index].NetDemandQty = articleDemandInfo.NetDemandQty
|
|
|
|
|
|
//data_ArticleDemand[index].EndingInventory = articleDemandInfo.EndingInventory
|
|
|
|
|
|
|
|
|
if index != len(data_ArticleDemand)-1 { |
|
|
if index != len(data_ArticleDemand)-1 { |
|
|
|
|
|
//下期期初 = 本期期末
|
|
|
data_ArticleDemand[index+1].OpeningInventory = data_ArticleDemand[index].EndingInventory |
|
|
data_ArticleDemand[index+1].OpeningInventory = data_ArticleDemand[index].EndingInventory |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -883,7 +887,7 @@ func (impl *BalanceServiceImplement) refreshMpsArticleDemand(isRefresh bool,data |
|
|
for index, ArticleDemandDDataInfo := range data_ArticleDemand { |
|
|
for index, ArticleDemandDDataInfo := range data_ArticleDemand { |
|
|
for _, articleResourceInfo := range data_ArticleResource { |
|
|
for _, articleResourceInfo := range data_ArticleResource { |
|
|
if articleResourceInfo.ArtId == ArticleDemandDDataInfo.ArtId { |
|
|
if articleResourceInfo.ArtId == ArticleDemandDDataInfo.ArtId { |
|
|
data_ArticleDemand[index].MpsWorkTime = ArticleDemandDDataInfo.NetDemandQty / articleResourceInfo.QuantityPerHour |
|
|
|
|
|
|
|
|
data_ArticleDemand[index].MpsWorkTime = data_ArticleDemand[index].NetDemandQty / articleResourceInfo.QuantityPerHour |
|
|
break |
|
|
break |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|