|
|
@ -142,7 +142,11 @@ func (impl *BalanceServiceImplement) GetCustomerArticleDemand(user *global.User, |
|
|
|
return nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
|
|
|
|
|
data_ArticleStockLevel, err := dao_ArticleStockLevel.Select([]grmi.Predicate{meta.ArticleStockLevel_PlantNr.NewPredicate(grmi.Equal, user.PlantNr)}, nil) |
|
|
|
data_ArticleStock, err := dao_ArticleStock.Select([]grmi.Predicate{}, nil) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
|
data_ArticleStockLevel, err := dao_ArticleStockLevel.Select([]grmi.Predicate{}, nil) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
@ -167,19 +171,12 @@ func (impl *BalanceServiceImplement) GetCustomerArticleDemand(user *global.User, |
|
|
|
} |
|
|
|
for _, artStockInfo := range artStockList { |
|
|
|
if artStockInfo.ArtId == artInfo.ArtId { |
|
|
|
switch artStockInfo.StockType { |
|
|
|
case "FG": |
|
|
|
custArtStockInfo.FGStock = artStockInfo.FGQty |
|
|
|
case "SFG": |
|
|
|
custArtStockInfo.SFGStock = artStockInfo.SFGQty |
|
|
|
case "WIP": |
|
|
|
custArtStockInfo.WIPStock = artStockInfo.WIPQty |
|
|
|
case "PUC": |
|
|
|
custArtStockInfo.PUCStock = artStockInfo.PUCQty |
|
|
|
case "OSC": |
|
|
|
custArtStockInfo.OSCStock = artStockInfo.OSCQty |
|
|
|
} |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
data = append(data, custArtStockInfo) |
|
|
@ -210,7 +207,7 @@ func (impl *BalanceServiceImplement) GetCustomerArticleDemand(user *global.User, |
|
|
|
//if err != nil {
|
|
|
|
// return nil, grmi.NewDataBaseError(err)
|
|
|
|
//}
|
|
|
|
data_ArticleDemand_new, err := impl.refreshMpsArticleDemand(false, data_ArticleStockLevel, data_ArticleDemand, data_ArticleResourceLst, mpsSettingOne) |
|
|
|
data_ArticleDemand_new, err := impl.refreshMpsArticleDemand(false, data_ArticleStock, data_ArticleStockLevel, data_ArticleDemand, data_ArticleResourceLst, mpsSettingOne) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
@ -230,6 +227,22 @@ func (impl *BalanceServiceImplement) GetCustomerArticleDemand(user *global.User, |
|
|
|
} |
|
|
|
data = data[:size] |
|
|
|
|
|
|
|
var keyList []string |
|
|
|
for _, info:= range data{ |
|
|
|
for _, key := range info.ArticleDemandLst{ |
|
|
|
isIn:= false |
|
|
|
for _, keyNow := range keyList{ |
|
|
|
if key.DemandKey == keyNow{ |
|
|
|
isIn = true |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
if !isIn{ |
|
|
|
keyList = append(keyList, key.DemandKey) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
sort.Strings(keyList) |
|
|
|
//var CustArtStockItemLst []model.CustArtStockItem
|
|
|
|
var CustArtStockaLL model.CustArtStockItem |
|
|
|
CustArtStockaLL.ItemLst = *new([]map[string]string) |
|
|
@ -245,10 +258,10 @@ func (impl *BalanceServiceImplement) GetCustomerArticleDemand(user *global.User, |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-Descr1") |
|
|
|
//CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-CustomerId")
|
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-FGStock") |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-SFGStock") |
|
|
|
//CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-SFGStock")
|
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-WIPStock") |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-PUCStock") |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-OSCStock") |
|
|
|
//CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-OSCStock")
|
|
|
|
} |
|
|
|
|
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-ArtId"] = info.ArtId |
|
|
@ -256,16 +269,27 @@ func (impl *BalanceServiceImplement) GetCustomerArticleDemand(user *global.User, |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Descr1"] = info.Descr1 |
|
|
|
//CustArtStockItem.ItemLst[i]["AP_ArticleDemand-CustomerId"] = info.CustomerId
|
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-FGStock"] = utils.FloatToString(info.FGStock, 2) |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-SFGStock"] = utils.FloatToString(info.SFGStock, 2) |
|
|
|
//CustArtStockItem.ItemLst[i]["AP_ArticleDemand-SFGStock"] = utils.FloatToString(info.SFGStock, 2)
|
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-WIPStock"] = utils.FloatToString(info.WIPStock, 2) |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-PUCStock"] = utils.FloatToString(info.PUCStock, 2) |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-OSCStock"] = utils.FloatToString(info.OSCStock, 2) |
|
|
|
//CustArtStockItem.ItemLst[i]["AP_ArticleDemand-OSCStock"] = utils.FloatToString(info.OSCStock, 2)
|
|
|
|
|
|
|
|
for _,key := range keyList{ |
|
|
|
var detail *model.ArticleDemand |
|
|
|
for _, nowDetail := range info.ArticleDemandLst { |
|
|
|
if nowDetail.DemandKey == key{ |
|
|
|
detail = &nowDetail |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
if detail == nil{ |
|
|
|
detail = new(model.ArticleDemand) |
|
|
|
detail.DemandKey = key |
|
|
|
} |
|
|
|
|
|
|
|
for _, detail := range info.ArticleDemandLst { |
|
|
|
if i == 0 && index == 0 { |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, detail.DemandKey) |
|
|
|
} |
|
|
|
|
|
|
|
switch i { |
|
|
|
case 0: |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Label"] = "AP_ArticleDemand-NetDemandQty" |
|
|
@ -298,11 +322,8 @@ func (impl *BalanceServiceImplement) GetCustomerArticleDemand(user *global.User, |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Label"] = "AP_ArticleDemand-EndingInventory" |
|
|
|
CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.FloatToString(detail.EndingInventory, 2) |
|
|
|
} |
|
|
|
//CustArtStockItem.CustArtStockDetail["Label"] = *new(model.ArticleDemand)
|
|
|
|
|
|
|
|
//CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.ValueToString(detail.NetDemandQty, "")
|
|
|
|
//CustArtStockItem.CustArtStockDetail[detail.DemandKey] = detail
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
CustArtStockaLL.ItemLst = append(CustArtStockaLL.ItemLst, CustArtStockItem.ItemLst...) |
|
|
|
} |
|
|
@ -319,7 +340,7 @@ func (impl *BalanceServiceImplement) RefreshCustomerArticleDemand(user *global.U |
|
|
|
//dao_CustArtlst := dal.NewCustArtlstDAO(session, user.PlantNr, user.UserId)
|
|
|
|
dao_ArticleDemand := dal.NewArticleDemandDAO(session, user.PlantNr, user.UserId) |
|
|
|
dao_ArticleStock := dal_base.NewArticleStockDAO(session, user.PlantNr, user.UserId) |
|
|
|
dao_ArticleStockLevel := dal.NewArticleStockLevelDAO(session, user.PlantNr, user.UserId) |
|
|
|
//dao_ArticleStockLevel := dal.NewArticleStockLevelDAO(session, user.PlantNr, user.UserId)
|
|
|
|
artResourceDao := dal.NewArticleResourceDAO(session, user.PlantNr, user.UserId) |
|
|
|
//dao_CustDemandModel := dal.NewCustDemandModelDAO(session, user.PlantNr, user.UserId)
|
|
|
|
//dao_Customer := dal_base.NewCustomerDAO(session, user.PlantNr, user.UserId)
|
|
|
@ -350,7 +371,12 @@ func (impl *BalanceServiceImplement) RefreshCustomerArticleDemand(user *global.U |
|
|
|
return nil, nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
|
|
|
|
|
data_ArticleStockLevel, err := dao_ArticleStockLevel.Select([]grmi.Predicate{meta.ArticleStockLevel_PlantNr.NewPredicate(grmi.Equal, user.PlantNr)}, nil) |
|
|
|
dao_ArticleStockLevel := dal.NewArticleStockLevelDAO(session, user.PlantNr, user.UserId) |
|
|
|
data_ArticleStockLevel, err := dao_ArticleStockLevel.Select([]grmi.Predicate{}, nil) |
|
|
|
if err != nil { |
|
|
|
return nil, nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
|
data_ArticleStock, err := dao_ArticleStock.Select([]grmi.Predicate{meta.ArticleStockLevel_PlantNr.NewPredicate(grmi.Equal, user.PlantNr)}, nil) |
|
|
|
if err != nil { |
|
|
|
return nil, nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
@ -453,7 +479,7 @@ func (impl *BalanceServiceImplement) RefreshCustomerArticleDemand(user *global.U |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
data_ArticleDemand_new, err := impl.refreshMpsArticleDemand(true, data_ArticleStockLevel, data_ArticleDemand, data_ArticleResourceLst, mpsSettingOne) |
|
|
|
data_ArticleDemand_new, err := impl.refreshMpsArticleDemand(true, data_ArticleStock,data_ArticleStockLevel, data_ArticleDemand, data_ArticleResourceLst, mpsSettingOne) |
|
|
|
if err != nil { |
|
|
|
return nil, nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
@ -480,18 +506,11 @@ func (impl *BalanceServiceImplement) RefreshCustomerArticleDemand(user *global.U |
|
|
|
} |
|
|
|
for _, artStockInfo := range artStockList { |
|
|
|
if artStockInfo.ArtId == ArtId { |
|
|
|
switch artStockInfo.StockType { |
|
|
|
case "FG": |
|
|
|
custArtStockInfo.FGStock = artStockInfo.FGQty |
|
|
|
case "SFG": |
|
|
|
custArtStockInfo.SFGStock = artStockInfo.SFGQty |
|
|
|
case "WIP": |
|
|
|
custArtStockInfo.WIPStock = artStockInfo.WIPQty |
|
|
|
case "PUC": |
|
|
|
custArtStockInfo.PUCStock = artStockInfo.PUCQty |
|
|
|
case "OSC": |
|
|
|
custArtStockInfo.OSCStock = artStockInfo.OSCQty |
|
|
|
} |
|
|
|
custArtStockInfo.FGStock = artStockInfo.FGQty |
|
|
|
custArtStockInfo.SFGStock = artStockInfo.SFGQty |
|
|
|
custArtStockInfo.WIPStock = artStockInfo.WIPQty |
|
|
|
custArtStockInfo.PUCStock = artStockInfo.PUCQty |
|
|
|
custArtStockInfo.OSCStock = artStockInfo.OSCQty |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
@ -514,10 +533,10 @@ func (impl *BalanceServiceImplement) RefreshCustomerArticleDemand(user *global.U |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-Descr1") |
|
|
|
//CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-CustomerId")
|
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-FGStock") |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-SFGStock") |
|
|
|
//CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-SFGStock")
|
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-WIPStock") |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-PUCStock") |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-OSCStock") |
|
|
|
//CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-OSCStock")
|
|
|
|
} |
|
|
|
|
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-ArtId"] = info.ArtId |
|
|
@ -525,10 +544,10 @@ func (impl *BalanceServiceImplement) RefreshCustomerArticleDemand(user *global.U |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Descr1"] = info.Descr1 |
|
|
|
//CustArtStockItem.ItemLst[i]["AP_ArticleDemand-CustomerId"] = info.CustomerId
|
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-FGStock"] = utils.FloatToString(info.FGStock, 2) |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-SFGStock"] = utils.FloatToString(info.SFGStock, 2) |
|
|
|
//CustArtStockItem.ItemLst[i]["AP_ArticleDemand-SFGStock"] = utils.FloatToString(info.SFGStock, 2)
|
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-WIPStock"] = utils.FloatToString(info.WIPStock, 2) |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-PUCStock"] = utils.FloatToString(info.PUCStock, 2) |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-OSCStock"] = utils.FloatToString(info.OSCStock, 2) |
|
|
|
//CustArtStockItem.ItemLst[i]["AP_ArticleDemand-OSCStock"] = utils.FloatToString(info.OSCStock, 2)
|
|
|
|
|
|
|
|
for _, detail := range info.ArticleDemandLst { |
|
|
|
if i == 0 && index == 0 { |
|
|
@ -1063,6 +1082,8 @@ func (impl *BalanceServiceImplement) CustomerOrderReviewOne(user *global.User, q |
|
|
|
dao_CustDemandModel := dal.NewCustDemandModelDAO(session, user.PlantNr, user.UserId) |
|
|
|
dao_Customer := dal_base.NewCustomerDAO(session, user.PlantNr, user.UserId) |
|
|
|
dao_MpsSetting := dal.NewMpsSettingDAO(session, user.PlantNr, user.UserId) |
|
|
|
dao_ArticleStock := dal_base.NewArticleStockDAO(session, user.PlantNr, user.UserId) |
|
|
|
dao_ArticleStockLevel := dal.NewArticleStockLevelDAO(session, user.PlantNr, user.UserId) |
|
|
|
|
|
|
|
data_plant, err := dao_plant.SelectOne(user.PlantNr) |
|
|
|
if err != nil { |
|
|
@ -1097,12 +1118,15 @@ func (impl *BalanceServiceImplement) CustomerOrderReviewOne(user *global.User, q |
|
|
|
if data_ArticleDemand == nil { |
|
|
|
return nil, grmi.NewBusinessError("未查询到客户订单") |
|
|
|
} |
|
|
|
dao_ArticleStockLevel := dal.NewArticleStockLevelDAO(session, user.PlantNr, user.UserId) |
|
|
|
data_ArticleStockLevel, err := dao_ArticleStockLevel.Select([]grmi.Predicate{meta.ArticleStockLevel_PlantNr.NewPredicate(grmi.Equal, user.PlantNr)}, nil) |
|
|
|
|
|
|
|
data_ArticleStock, err := dao_ArticleStock.Select([]grmi.Predicate{}, nil) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
|
data_ArticleStockLevel, err := dao_ArticleStockLevel.Select([]grmi.Predicate{}, nil) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
|
|
|
|
|
var rockData []model.ArticleDemand |
|
|
|
for index, info := range data_ArticleDemand { |
|
|
|
if info.DemandKey[len(info.DemandKey)-1:len(info.DemandKey)] == "*" { |
|
|
@ -1113,7 +1137,7 @@ func (impl *BalanceServiceImplement) CustomerOrderReviewOne(user *global.User, q |
|
|
|
|
|
|
|
var data_ArticleResourceLst []model.ArticleResource |
|
|
|
data_ArticleResourceLst = append(data_ArticleResourceLst, *articleResource) |
|
|
|
data_ArticleDemand_new, err := impl.refreshMpsArticleDemand(false, data_ArticleStockLevel, data_ArticleDemand, data_ArticleResourceLst, mpsSettingOne) |
|
|
|
data_ArticleDemand_new, err := impl.refreshMpsArticleDemand(false, data_ArticleStock,data_ArticleStockLevel, data_ArticleDemand, data_ArticleResourceLst, mpsSettingOne) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
@ -1149,10 +1173,6 @@ func (impl *BalanceServiceImplement) CustomerOrderReviewOne(user *global.User, q |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
|
data_ArticleStockLevel, err = dao_ArticleStockLevel.Select([]grmi.Predicate{meta.ArticleStockLevel_PlantNr.NewPredicate(grmi.Equal, user.PlantNr)}, nil) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
|
|
|
|
|
data_ArticleDemand, err = dao_ArticleDemand.Select([]grmi.Predicate{meta.ArticleDemand_PlantNr.NewPredicate(grmi.Equal, user.PlantNr)}, nil) |
|
|
|
if err != nil { |
|
|
@ -1170,7 +1190,7 @@ func (impl *BalanceServiceImplement) CustomerOrderReviewOne(user *global.User, q |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
_, mainmpsGroupLst, _, err2, done := impl.makeMpsGroup(false, user, articleResource.ResourceId, "", mainselectArticleDemandList, data_ArticleStockLevel, articleDemandListMap, dao_Customer, dao_CustDemandModel, data_ArticleResource, mpsSettingOne) |
|
|
|
_, mainmpsGroupLst, _, err2, done := impl.makeMpsGroup(data_ArticleStock,false, user, articleResource.ResourceId, "", mainselectArticleDemandList, data_ArticleStockLevel, articleDemandListMap, dao_Customer, dao_CustDemandModel, data_ArticleResource, mpsSettingOne) |
|
|
|
if done { |
|
|
|
return nil, err2 |
|
|
|
} |
|
|
@ -1486,7 +1506,7 @@ func (impl *BalanceServiceImplement) CustomerOrderReviewExport(user *global.User |
|
|
|
return result, err |
|
|
|
} |
|
|
|
|
|
|
|
func (impl *BalanceServiceImplement) refreshMpsArticleDemand(isRefresh bool, data_ArticleStockLevel []model.ArticleStockLevel, data_ArticleDemand []model.ArticleDemand, data_ArticleResource []model.ArticleResource, mpsSetting *model.MpsSetting) ([]model.ArticleDemand, error) { |
|
|
|
func (impl *BalanceServiceImplement) refreshMpsArticleDemand(isRefresh bool, data_ArticleStock []model_base.ArticleStock,data_ArticleStockLevel []model.ArticleStockLevel, data_ArticleDemand []model.ArticleDemand, data_ArticleResource []model.ArticleResource, mpsSetting *model.MpsSetting) ([]model.ArticleDemand, error) { |
|
|
|
if data_ArticleDemand == nil || len(data_ArticleDemand) == 0 { |
|
|
|
fmt.Println(data_ArticleDemand) |
|
|
|
return nil, nil |
|
|
@ -1509,23 +1529,23 @@ func (impl *BalanceServiceImplement) refreshMpsArticleDemand(isRefresh bool, dat |
|
|
|
// lockWeek = mpsSetting.DefaultLockWeeks
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
////2.计算最小覆盖周期和最大覆盖周期
|
|
|
|
//for index, _ := range data_ArticleDemand {
|
|
|
|
// if mpsSetting.UseFixedStockCoverToggle {
|
|
|
|
// data_ArticleDemand[index].MinCoverPeriod = mpsSetting.DefaultMinCoverPeriod
|
|
|
|
// data_ArticleDemand[index].MaxCoverPeriod = mpsSetting.DefaultMaxCoverPeriod
|
|
|
|
// } else {
|
|
|
|
// //查询周期
|
|
|
|
// for _, articleStockLevelInfo := range data_ArticleStockLevel {
|
|
|
|
// if articleStockLevelInfo.ArtId == data_ArticleDemand[index].ArtId && articleStockLevelInfo.MinCoverPeriodType == data_ArticleDemand[0].DemandPeriodType {
|
|
|
|
// data_ArticleDemand[index].MinCoverPeriod = articleStockLevelInfo.MinCoverPeriod
|
|
|
|
// }
|
|
|
|
// if articleStockLevelInfo.ArtId == data_ArticleDemand[index].ArtId && articleStockLevelInfo.MaxCoverPeriodType == data_ArticleDemand[0].DemandPeriodType {
|
|
|
|
// data_ArticleDemand[index].MaxCoverPeriod = articleStockLevelInfo.MaxCoverPeriod
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//2.计算最小覆盖周期和最大覆盖周期
|
|
|
|
for index, _ := range data_ArticleDemand { |
|
|
|
if mpsSetting.UseFixedStockCoverToggle { |
|
|
|
data_ArticleDemand[index].MinCoverPeriod = mpsSetting.DefaultMinCoverPeriod |
|
|
|
data_ArticleDemand[index].MaxCoverPeriod = mpsSetting.DefaultMaxCoverPeriod |
|
|
|
} else { |
|
|
|
//查询周期
|
|
|
|
for _, articleStockLevelInfo := range data_ArticleStockLevel { |
|
|
|
if articleStockLevelInfo.ArtId == data_ArticleDemand[index].ArtId && articleStockLevelInfo.MinCoverPeriodType == data_ArticleDemand[0].DemandPeriodType { |
|
|
|
data_ArticleDemand[index].MinCoverPeriod = articleStockLevelInfo.MinCoverPeriod |
|
|
|
} |
|
|
|
if articleStockLevelInfo.ArtId == data_ArticleDemand[index].ArtId && articleStockLevelInfo.MaxCoverPeriodType == data_ArticleDemand[0].DemandPeriodType { |
|
|
|
data_ArticleDemand[index].MaxCoverPeriod = articleStockLevelInfo.MaxCoverPeriod |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//
|
|
|
|
////需求周期 > 当前时间+ mps策略表偏离周数 并且 需求周期 < (当前时间+吸收期+最大覆盖周期)
|
|
|
|
//startIndex, endIndex := 0, 0
|
|
|
@ -1548,15 +1568,14 @@ func (impl *BalanceServiceImplement) refreshMpsArticleDemand(isRefresh bool, dat |
|
|
|
|
|
|
|
for index, _ := range data_ArticleDemand { |
|
|
|
//期初库存
|
|
|
|
//if index == 0 {
|
|
|
|
// //todo
|
|
|
|
// //STK_InventoryStruct := _struct.STK_InventoryStruct{
|
|
|
|
// // FormId: "STK_Inventory",
|
|
|
|
// // FieldKeys: "FMaterialId.FNumber,FBaseQty",
|
|
|
|
// //}
|
|
|
|
// //utilService.STK_InventoryInit().GetSTK_Inventory(STK_InventoryStruct)
|
|
|
|
// data_ArticleDemand[index].OpeningInventory = 80.0
|
|
|
|
//}
|
|
|
|
if index == 0 { |
|
|
|
for _, articleStock := range data_ArticleStock{ |
|
|
|
if articleStock.ArtId == data_ArticleDemand[index].ArtId{ |
|
|
|
data_ArticleDemand[index].OpeningInventory =articleStock.FGQty |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//最小库存水平
|
|
|
|
MinInventory := 0.0 |
|
|
@ -1764,6 +1783,12 @@ func (impl *BalanceServiceImplement) GetMpsPlan(user *global.User, resouceId, se |
|
|
|
dao_Customer := dal_base.NewCustomerDAO(session, user.PlantNr, user.UserId) |
|
|
|
dao_MpsSetting := dal.NewMpsSettingDAO(session, user.PlantNr, user.UserId) |
|
|
|
|
|
|
|
dao_ArticleStock := dal_base.NewArticleStockDAO(session, user.PlantNr, user.UserId) |
|
|
|
data_ArticleStock, err := dao_ArticleStock.Select([]grmi.Predicate{}, nil) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
|
|
|
|
|
dao_plant := dal_base.NewPlantDAO(session, user.UserId) |
|
|
|
|
|
|
|
data_plant, err := dao_plant.SelectOne(user.PlantNr) |
|
|
@ -1812,7 +1837,7 @@ func (impl *BalanceServiceImplement) GetMpsPlan(user *global.User, resouceId, se |
|
|
|
|
|
|
|
var rockData []model.ArticleDemand |
|
|
|
for index, info := range data_ArticleDemand { |
|
|
|
if info.DemandKey[len(info.DemandKey)-1:len(info.DemandKey)] == "!" { |
|
|
|
if info.DemandKey[len(info.DemandKey)-1:len(info.DemandKey)] == "*" { |
|
|
|
rockData = append(rockData, info) |
|
|
|
data_ArticleDemand = append(data_ArticleDemand[:index], data_ArticleDemand[index+1:]...) |
|
|
|
} |
|
|
@ -1839,7 +1864,7 @@ func (impl *BalanceServiceImplement) GetMpsPlan(user *global.User, resouceId, se |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
alternativeArticleDemandList, mpsGroupLst, plan, err2, done := impl.makeMpsGroup(false, user, AlternativeResource.AlternativeResourceId, secondresourceid, alternativeselectArticleDemandList, data_ArticleStockLevel, articleDemandListMap, dao_Customer, dao_CustDemandModel, data_ArticleResource, mpsSettingOne) |
|
|
|
alternativeArticleDemandList, mpsGroupLst, plan, err2, done := impl.makeMpsGroup(data_ArticleStock,false, user, AlternativeResource.AlternativeResourceId, secondresourceid, alternativeselectArticleDemandList, data_ArticleStockLevel, articleDemandListMap, dao_Customer, dao_CustDemandModel, data_ArticleResource, mpsSettingOne) |
|
|
|
if done { |
|
|
|
return plan, err2 |
|
|
|
} |
|
|
@ -1862,7 +1887,7 @@ func (impl *BalanceServiceImplement) GetMpsPlan(user *global.User, resouceId, se |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
mainArticleDemandList, mainmpsGroupLst, plan, err2, done := impl.makeMpsGroup(false, user, resouceId, secondresourceid, mainselectArticleDemandList, data_ArticleStockLevel, articleDemandListMap, dao_Customer, dao_CustDemandModel, data_ArticleResource, mpsSettingOne) |
|
|
|
mainArticleDemandList, mainmpsGroupLst, plan, err2, done := impl.makeMpsGroup(data_ArticleStock,false, user, resouceId, secondresourceid, mainselectArticleDemandList, data_ArticleStockLevel, articleDemandListMap, dao_Customer, dao_CustDemandModel, data_ArticleResource, mpsSettingOne) |
|
|
|
if done { |
|
|
|
return plan, err2 |
|
|
|
} |
|
|
@ -1886,7 +1911,7 @@ func (impl *BalanceServiceImplement) GetMpsPlan(user *global.User, resouceId, se |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
secondArticleDemandList, mpsGroupLst, plan, err2, done := impl.makeMpsGroup(false, user, resouceId, secondresourceid, secondselectArticleDemandList, data_ArticleStockLevel, articleDemandListMap, dao_Customer, dao_CustDemandModel, data_ArticleResource, mpsSettingOne) |
|
|
|
secondArticleDemandList, mpsGroupLst, plan, err2, done := impl.makeMpsGroup(data_ArticleStock,false, user, resouceId, secondresourceid, secondselectArticleDemandList, data_ArticleStockLevel, articleDemandListMap, dao_Customer, dao_CustDemandModel, data_ArticleResource, mpsSettingOne) |
|
|
|
if done { |
|
|
|
return plan, err2 |
|
|
|
} |
|
|
@ -1908,7 +1933,7 @@ func (impl *BalanceServiceImplement) GetMpsPlan(user *global.User, resouceId, se |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
secondArticleDemandList, mpsGroupLst, plan, err2, done := impl.makeMpsGroup(false, user, resouceId, secondresourceid, secondselectArticleDemandList, data_ArticleStockLevel, articleDemandListMap, dao_Customer, dao_CustDemandModel, data_ArticleResource, mpsSettingOne) |
|
|
|
secondArticleDemandList, mpsGroupLst, plan, err2, done := impl.makeMpsGroup(data_ArticleStock,false, user, resouceId, secondresourceid, secondselectArticleDemandList, data_ArticleStockLevel, articleDemandListMap, dao_Customer, dao_CustDemandModel, data_ArticleResource, mpsSettingOne) |
|
|
|
if done { |
|
|
|
return plan, err2 |
|
|
|
} |
|
|
@ -1921,11 +1946,12 @@ func (impl *BalanceServiceImplement) GetMpsPlan(user *global.User, resouceId, se |
|
|
|
return mpsPlan, err |
|
|
|
} |
|
|
|
|
|
|
|
func (impl *BalanceServiceImplement) makeMpsGroup(isrefresh bool, user *global.User, resouceId string, secondresourceid string, selectArticleDemandList []model.ArticleDemand, data_ArticleStockLevel []model.ArticleStockLevel, articleDemandListMap map[string][]model.ArticleDemand, dao_Customer dal_base.CustomerDAO, dao_CustDemandModel dal.CustDemandModelDAO, data_ArticleResource []model.ArticleResource, mpsSettingOne *model.MpsSetting) ([]model.ArticleDemand, []model.ArticleResourceMpsGroup, *model.MpsPlan, error, bool) { |
|
|
|
func (impl *BalanceServiceImplement) makeMpsGroup(data_ArticleStock []model_base.ArticleStock, isrefresh bool, user *global.User, resouceId string, secondresourceid string, selectArticleDemandList []model.ArticleDemand, data_ArticleStockLevel []model.ArticleStockLevel, articleDemandListMap map[string][]model.ArticleDemand, dao_Customer dal_base.CustomerDAO, dao_CustDemandModel dal.CustDemandModelDAO, data_ArticleResource []model.ArticleResource, mpsSettingOne *model.MpsSetting) ([]model.ArticleDemand, []model.ArticleResourceMpsGroup, *model.MpsPlan, error, bool) { |
|
|
|
var ( |
|
|
|
finalArticleDemandList []model.ArticleDemand |
|
|
|
mpsGroupLst []model.ArticleResourceMpsGroup |
|
|
|
) |
|
|
|
|
|
|
|
//2.计算最小覆盖周期和最大覆盖周期
|
|
|
|
for index, _ := range selectArticleDemandList { |
|
|
|
if mpsSettingOne.UseFixedStockCoverToggle { |
|
|
@ -1974,7 +2000,7 @@ func (impl *BalanceServiceImplement) makeMpsGroup(isrefresh bool, user *global.U |
|
|
|
//if err != nil {
|
|
|
|
// return nil, nil, nil, grmi.NewDataBaseError(err), true
|
|
|
|
//}
|
|
|
|
ArticleDemandList, err := impl.refreshMpsArticleDemand(isrefresh, data_ArticleStockLevel, group, data_ArticleResource, mpsSettingOne) |
|
|
|
ArticleDemandList, err := impl.refreshMpsArticleDemand(isrefresh, data_ArticleStock,data_ArticleStockLevel, group, data_ArticleResource, mpsSettingOne) |
|
|
|
if err != nil || ArticleDemandList == nil { |
|
|
|
return nil, nil, nil, err, true |
|
|
|
} |
|
|
@ -2064,7 +2090,11 @@ func (impl *BalanceServiceImplement) MpsPlan(user *global.User, resouceId, secon |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
|
|
|
|
|
dao_ArticleStock := dal_base.NewArticleStockDAO(session, user.PlantNr, user.UserId) |
|
|
|
data_ArticleStock, err := dao_ArticleStock.Select([]grmi.Predicate{}, nil) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
|
//dao_ArticleResource := dal.NewArticleResourceDAO(session, user.PlantNr, user.UserId)
|
|
|
|
dao_ArticleStockLevel := dal.NewArticleStockLevelDAO(session, user.PlantNr, user.UserId) |
|
|
|
dao_ArticleAlternativeResource := dal.NewArticleAlternativeResourceDAO(session, user.PlantNr, user.UserId) |
|
|
@ -2142,7 +2172,7 @@ func (impl *BalanceServiceImplement) MpsPlan(user *global.User, resouceId, secon |
|
|
|
mpsPlan.ArticleDemandLst = append(mpsPlan.ArticleDemandLst, groupArticleInfo.ArticleDemandLst...) |
|
|
|
} |
|
|
|
|
|
|
|
for _, ArticleAlternativeDemand := range mpsPlan.ArticleAlternativeDemandLst { |
|
|
|
for index, ArticleAlternativeDemand := range mpsPlan.ArticleAlternativeDemandLst { |
|
|
|
for _, info := range ArticleAlternativeDemand { |
|
|
|
if info.NetDemandQty == 0 { |
|
|
|
continue |
|
|
@ -2151,7 +2181,8 @@ func (impl *BalanceServiceImplement) MpsPlan(user *global.User, resouceId, secon |
|
|
|
if len(demandWeek) == 1 { |
|
|
|
demandWeek = "0" + demandWeek |
|
|
|
} |
|
|
|
demandKey := strconv.Itoa(info.DemandYear) + "." + demandWeek + "_" + info.ResourceId + "*" |
|
|
|
//demandKey := strconv.Itoa(info.DemandYear) + "." + demandWeek + "_" + info.ResourceId + "*"
|
|
|
|
demandKey := strconv.Itoa(info.DemandYear) + "." + demandWeek |
|
|
|
AlternativeDemandInfo := model.ArticleDemand{ |
|
|
|
PlantNr: info.PlantNr, |
|
|
|
ArtId: info.ArtId, |
|
|
@ -2178,7 +2209,7 @@ func (impl *BalanceServiceImplement) MpsPlan(user *global.User, resouceId, secon |
|
|
|
|
|
|
|
CanWrite: false, |
|
|
|
} |
|
|
|
mpsPlan.ArticleDemandLst = append(mpsPlan.ArticleDemandLst, AlternativeDemandInfo) |
|
|
|
mpsPlan.ArticleAlternativeDemandLst[index] = append(mpsPlan.ArticleAlternativeDemandLst[index], AlternativeDemandInfo) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -2187,7 +2218,6 @@ func (impl *BalanceServiceImplement) MpsPlan(user *global.User, resouceId, secon |
|
|
|
} |
|
|
|
|
|
|
|
dao_CustArtlst := dal.NewCustArtlstDAO(session, user.PlantNr, user.UserId) |
|
|
|
dao_ArticleStock := dal_base.NewArticleStockDAO(session, user.PlantNr, user.UserId) |
|
|
|
artResourceDao := dal.NewArticleResourceDAO(session, user.PlantNr, user.UserId) |
|
|
|
//dao_CustDemandModel := dal.NewCustDemandModelDAO(session, user.PlantNr, user.UserId)
|
|
|
|
//dao_Customer := dal_base.NewCustomerDAO(session, user.PlantNr, user.UserId)
|
|
|
@ -2222,18 +2252,11 @@ func (impl *BalanceServiceImplement) MpsPlan(user *global.User, resouceId, secon |
|
|
|
} |
|
|
|
for _, artStockInfo := range artStockList { |
|
|
|
if artStockInfo.ArtId == custArtInfo.ArtId { |
|
|
|
switch artStockInfo.StockType { |
|
|
|
case "FG": |
|
|
|
custArtStockInfo.FGStock = artStockInfo.FGQty |
|
|
|
case "SFG": |
|
|
|
custArtStockInfo.SFGStock = artStockInfo.SFGQty |
|
|
|
case "WIP": |
|
|
|
custArtStockInfo.WIPStock = artStockInfo.WIPQty |
|
|
|
case "PUC": |
|
|
|
custArtStockInfo.PUCStock = artStockInfo.PUCQty |
|
|
|
case "OSC": |
|
|
|
custArtStockInfo.OSCStock = artStockInfo.OSCQty |
|
|
|
} |
|
|
|
custArtStockInfo.FGStock = artStockInfo.FGQty |
|
|
|
custArtStockInfo.SFGStock = artStockInfo.SFGQty |
|
|
|
custArtStockInfo.WIPStock = artStockInfo.WIPQty |
|
|
|
custArtStockInfo.PUCStock = artStockInfo.PUCQty |
|
|
|
custArtStockInfo.OSCStock = artStockInfo.OSCQty |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
@ -2258,13 +2281,29 @@ func (impl *BalanceServiceImplement) MpsPlan(user *global.User, resouceId, secon |
|
|
|
} |
|
|
|
var data_ArticleResourceLst []model.ArticleResource |
|
|
|
data_ArticleResourceLst = append(data_ArticleResourceLst, *articleResource) |
|
|
|
data_ArticleDemand_new, err := impl.refreshMpsArticleDemand(false, data_ArticleStockLevel, data_ArticleDemand, data_ArticleResourceLst, mpsSettingOne) |
|
|
|
data_ArticleDemand_new, err := impl.refreshMpsArticleDemand(false, data_ArticleStock,data_ArticleStockLevel, data_ArticleDemand, data_ArticleResourceLst, mpsSettingOne) |
|
|
|
if err != nil { |
|
|
|
return nil, grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
|
data[index].ArticleDemandLst = data_ArticleDemand_new |
|
|
|
} |
|
|
|
|
|
|
|
var keyList []string |
|
|
|
for _, info:= range data{ |
|
|
|
for _, key := range info.ArticleDemandLst{ |
|
|
|
isIn:= false |
|
|
|
for _, keyNow := range keyList{ |
|
|
|
if key.DemandKey == keyNow{ |
|
|
|
isIn = true |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
if !isIn{ |
|
|
|
keyList = append(keyList, key.DemandKey) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
sort.Strings(keyList) |
|
|
|
//var CustArtStockItemLst []model.CustArtStockItem
|
|
|
|
var CustArtStockaLL model.CustArtStockItem |
|
|
|
CustArtStockaLL.ItemLst = *new([]map[string]string) |
|
|
@ -2280,10 +2319,10 @@ func (impl *BalanceServiceImplement) MpsPlan(user *global.User, resouceId, secon |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-Descr1") |
|
|
|
//CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-CustomerId")
|
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-FGStock") |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-SFGStock") |
|
|
|
//CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-SFGStock")
|
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-WIPStock") |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-PUCStock") |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-OSCStock") |
|
|
|
//CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-OSCStock")
|
|
|
|
} |
|
|
|
|
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-ArtId"] = info.ArtId |
|
|
@ -2291,16 +2330,27 @@ func (impl *BalanceServiceImplement) MpsPlan(user *global.User, resouceId, secon |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Descr1"] = info.Descr1 |
|
|
|
//CustArtStockItem.ItemLst[i]["AP_ArticleDemand-CustomerId"] = info.CustomerId
|
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-FGStock"] = utils.FloatToString(info.FGStock, 2) |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-SFGStock"] = utils.FloatToString(info.SFGStock, 2) |
|
|
|
//CustArtStockItem.ItemLst[i]["AP_ArticleDemand-SFGStock"] = utils.FloatToString(info.SFGStock, 2)
|
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-WIPStock"] = utils.FloatToString(info.WIPStock, 2) |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-PUCStock"] = utils.FloatToString(info.PUCStock, 2) |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-OSCStock"] = utils.FloatToString(info.OSCStock, 2) |
|
|
|
//CustArtStockItem.ItemLst[i]["AP_ArticleDemand-OSCStock"] = utils.FloatToString(info.OSCStock, 2)
|
|
|
|
|
|
|
|
for _,key := range keyList{ |
|
|
|
var detail *model.ArticleDemand |
|
|
|
for _, nowDetail := range info.ArticleDemandLst { |
|
|
|
if nowDetail.DemandKey == key{ |
|
|
|
detail = &nowDetail |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
if detail == nil{ |
|
|
|
detail = new(model.ArticleDemand) |
|
|
|
detail.DemandKey = key |
|
|
|
} |
|
|
|
|
|
|
|
for _, detail := range info.ArticleDemandLst { |
|
|
|
if i == 0 && index == 0 { |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, detail.DemandKey) |
|
|
|
} |
|
|
|
|
|
|
|
switch i { |
|
|
|
case 0: |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Label"] = "AP_ArticleDemand-NetDemandQty" |
|
|
@ -2333,11 +2383,8 @@ func (impl *BalanceServiceImplement) MpsPlan(user *global.User, resouceId, secon |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Label"] = "AP_ArticleDemand-EndingInventory" |
|
|
|
CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.FloatToString(detail.EndingInventory, 2) |
|
|
|
} |
|
|
|
//CustArtStockItem.CustArtStockDetail["Label"] = *new(model.ArticleDemand)
|
|
|
|
|
|
|
|
//CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.ValueToString(detail.NetDemandQty, "")
|
|
|
|
//CustArtStockItem.CustArtStockDetail[detail.DemandKey] = detail
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
CustArtStockaLL.ItemLst = append(CustArtStockaLL.ItemLst, CustArtStockItem.ItemLst...) |
|
|
|
} |
|
|
@ -2797,6 +2844,22 @@ func (impl *BalanceServiceImplement) RefreshBalanceData(user *global.User) error |
|
|
|
return grmi.NewBusinessError("不存在客户需求版本详细数据") |
|
|
|
} |
|
|
|
|
|
|
|
dao_MpsSetting := dal.NewMpsSettingDAO(session, user.PlantNr, user.UserId) |
|
|
|
|
|
|
|
dao_plant := dal_base.NewPlantDAO(session, user.UserId) |
|
|
|
|
|
|
|
data_plant, err := dao_plant.SelectOne(user.PlantNr) |
|
|
|
if err != nil { |
|
|
|
return grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
|
|
|
|
|
mpsSettingOne, err := dao_MpsSetting.SelectOne(data_plant.DefaultMpsSettingNr) |
|
|
|
if err != nil || mpsSettingOne == nil { |
|
|
|
return grmi.NewDataBaseError(err) |
|
|
|
} |
|
|
|
|
|
|
|
frontday := mpsSettingOne.SalesOrderFetchLeadTimeByDay |
|
|
|
|
|
|
|
var articleMap = make(map[string]int) |
|
|
|
for _, info := range demandLstLi { |
|
|
|
_, isIn := articleMap[info.ArtId] |
|
|
@ -2854,7 +2917,8 @@ func (impl *BalanceServiceImplement) RefreshBalanceData(user *global.User) error |
|
|
|
demandWeek = "0" + demandWeek |
|
|
|
} |
|
|
|
|
|
|
|
demandKey := strconv.Itoa(info.DemandYear) + "." + demandWeek + "_" + resourceId |
|
|
|
//demandKey := strconv.Itoa(info.DemandYear) + "." + demandWeek + "_" + resourceId
|
|
|
|
demandKey := strconv.Itoa(info.DemandYear) + "." + demandWeek |
|
|
|
|
|
|
|
custArticleList, err := dao_CustArticle.Select([]grmi.Predicate{meta.CustArtlst_ArtId.NewPredicate(grmi.Equal, info.ArtId)}, nil) |
|
|
|
if err != nil { |
|
|
@ -2884,9 +2948,9 @@ func (impl *BalanceServiceImplement) RefreshBalanceData(user *global.User) error |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//需求周期 > 当前时间+ mps策略表偏离周数 并且 需求周期 < (当前时间+吸收期+最大覆盖周期)
|
|
|
|
//需求周期 + mps策略表偏离天数 > 当前时间+ 并且 需求周期 < (当前时间+吸收期+最大覆盖周期)
|
|
|
|
weekTimeNow := utils.WeekDayMondayZeroTs(timeNow) |
|
|
|
weekTimeDemand := utils.WeekDayMondayZeroTs(info.DemandDate.Restore()) |
|
|
|
weekTimeDemand := utils.WeekDayMondayZeroTs(info.DemandDate.Restore().Add(time.Duration(frontday*24*7) * time.Hour)) |
|
|
|
if weekTimeNow.After(weekTimeDemand) { |
|
|
|
continue |
|
|
|
} |
|
|
@ -2920,6 +2984,7 @@ func (impl *BalanceServiceImplement) RefreshBalanceData(user *global.User) error |
|
|
|
MinCoverPeriod: MinCoverPeriod, |
|
|
|
MaxCoverPeriod: MaxCoverPeriod, |
|
|
|
MinCoverPeriodType: "W", |
|
|
|
ResourceId: resourceId, |
|
|
|
} |
|
|
|
firstDemandList = append(firstDemandList, firstArticleDemand) |
|
|
|
} |
|
|
@ -2956,10 +3021,10 @@ func (impl *BalanceServiceImplement) RefreshBalanceData(user *global.User) error |
|
|
|
} |
|
|
|
|
|
|
|
go func() { |
|
|
|
// 期初库存
|
|
|
|
err := erp.GetArticleDemandErpQty(user.PlantNr, user.UserId, &alldata_Article) |
|
|
|
if err != nil { |
|
|
|
} |
|
|
|
//// 期初库存
|
|
|
|
//err := erp.GetArticleDemandErpQty(user.PlantNr, user.UserId, &alldata_Article)
|
|
|
|
//if err != nil {
|
|
|
|
//}
|
|
|
|
// 订单需求
|
|
|
|
err = erp.GetOrderQty(user.PlantNr, user.UserId, &alldata_Article) |
|
|
|
if err != nil { |
|
|
|