|
|
@ -69,6 +69,268 @@ func NewBalanceServiceImplement() *BalanceServiceImplement { |
|
|
|
return &BalanceServiceImplement{} |
|
|
|
} |
|
|
|
|
|
|
|
// 显示计划列表
|
|
|
|
func (impl *BalanceServiceImplement) GetCustomerArticleDemandHtml(user *global.User, versionId string) { |
|
|
|
grmi.Log(user, "/services/ap/implments/ArticleDemand.service.impl.go", "GetCustomerArticleDemand", "GetCustomerArticleDemand") |
|
|
|
engine := db.Eloquent.Master() |
|
|
|
session := engine.NewSession() |
|
|
|
defer session.Close() |
|
|
|
dao_ArticleDemand := dal.NewArticleDemandDAO(session, user.PlantNr, user.UserId) |
|
|
|
var artList []string |
|
|
|
allArticleDemandList, err := dao_ArticleDemand.Select([]grmi.Predicate{}, nil) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
var artIdMap = make(map[string]int) |
|
|
|
for _, info := range allArticleDemandList { |
|
|
|
_, isIn := artIdMap[info.ArtId] |
|
|
|
if isIn { |
|
|
|
artIdMap[info.ArtId] += 1 |
|
|
|
} else { |
|
|
|
artIdMap[info.ArtId] = 1 |
|
|
|
} |
|
|
|
} |
|
|
|
for artId, _ := range artIdMap { |
|
|
|
artList = append(artList, artId) |
|
|
|
} |
|
|
|
// 三个搜索条件
|
|
|
|
var custArtlst1, custArtlst2, custArtlst3 []string |
|
|
|
custArtlst1 = artList |
|
|
|
custArtlst2 = artList |
|
|
|
custArtlst3 = artList |
|
|
|
finalArtIdMap := make(map[string]string) |
|
|
|
for _, info1 := range custArtlst1 { |
|
|
|
for _, info2 := range custArtlst2 { |
|
|
|
for _, info3 := range custArtlst3 { |
|
|
|
if info1 == info2 && info2 == info3 { |
|
|
|
_, isIn := finalArtIdMap[info1] |
|
|
|
if !isIn { |
|
|
|
finalArtIdMap[info1] = info1 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
var artStockList []model_base.ArticleStock |
|
|
|
for _, artId := range finalArtIdMap { |
|
|
|
isIn := false |
|
|
|
for _, info := range alldata_ArticleStock { |
|
|
|
if info.ArtId == artId { |
|
|
|
artStockList = append(artStockList, info) |
|
|
|
isIn = true |
|
|
|
} |
|
|
|
} |
|
|
|
if !isIn { |
|
|
|
var artStockInfo = new(model_base.ArticleStock) |
|
|
|
artStockInfo.ArtId = artId |
|
|
|
artStockList = append(artStockList, *artStockInfo) |
|
|
|
} |
|
|
|
} |
|
|
|
//排序
|
|
|
|
sort.Slice(artStockList, func(i, j int) bool { |
|
|
|
return artStockList[i].ArtId < artStockList[j].ArtId |
|
|
|
}) |
|
|
|
data := make([]model.CustArtStockInfo, 0, 10) |
|
|
|
for _, artStockInfo := range artStockList { |
|
|
|
var artInfo *model_base.Article |
|
|
|
for _, info := range alldata_Article { |
|
|
|
if info.ArtId == artStockInfo.ArtId { |
|
|
|
artInfo = &info |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
if artInfo == nil { |
|
|
|
continue |
|
|
|
} |
|
|
|
custArtStockInfo := model.CustArtStockInfo{ |
|
|
|
//CustomerId: custArtInfo.CustomerId,
|
|
|
|
ArtId: artInfo.ArtId, |
|
|
|
Descr1: artInfo.Descr1, |
|
|
|
Descr2: artInfo.Descr2, |
|
|
|
} |
|
|
|
for _, artStockInfo := range artStockList { |
|
|
|
if artStockInfo.ArtId == artInfo.ArtId { |
|
|
|
custArtStockInfo.FGStock = artStockInfo.FGQty |
|
|
|
custArtStockInfo.SFGStock = artStockInfo.SFGQty |
|
|
|
custArtStockInfo.WIPStock = artStockInfo.WIPQty |
|
|
|
custArtStockInfo.PUCStock = artStockInfo.PUCQty |
|
|
|
custArtStockInfo.OSCStock = artStockInfo.OSCQty |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
data = append(data, custArtStockInfo) |
|
|
|
} |
|
|
|
for index, artStockInfo := range data { |
|
|
|
var data_ArticleDemand []model.ArticleDemand |
|
|
|
for _, info := range allArticleDemandList { |
|
|
|
if info.ArtId == artStockInfo.ArtId { |
|
|
|
data_ArticleDemand = append(data_ArticleDemand, info) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
sort.Slice(data_ArticleDemand, func(i, j int) bool { |
|
|
|
duration := data_ArticleDemand[i].DemandDate.Restore().Sub(data_ArticleDemand[j].DemandDate.Restore()) |
|
|
|
return duration < 0 |
|
|
|
}) |
|
|
|
|
|
|
|
data[index].ArticleDemandLst = data_ArticleDemand |
|
|
|
} |
|
|
|
//去空
|
|
|
|
size := len(data) |
|
|
|
for i := 0; i < size; i++ { |
|
|
|
if data[i].ArticleDemandLst == nil { |
|
|
|
data = append(data[:i], data[i+1:]...) |
|
|
|
i-- |
|
|
|
size-- |
|
|
|
} |
|
|
|
} |
|
|
|
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) |
|
|
|
for index, info := range data { |
|
|
|
var CustArtStockItem model.CustArtStockItem |
|
|
|
//净生产量
|
|
|
|
for i := 0; i < 12; i++ { |
|
|
|
CustArtStockItem.ItemLst = append(CustArtStockItem.ItemLst, make(map[string]string)) |
|
|
|
|
|
|
|
if i == 0 && index == 0 { |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-ArtId") |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-State") |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-Descr1") |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-FGStock") |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-WIPStock") |
|
|
|
CustArtStockaLL.SortKeys = append(CustArtStockaLL.SortKeys, "AP_ArticleDemand-PUCStock") |
|
|
|
} |
|
|
|
|
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-ArtId"] = info.ArtId |
|
|
|
state := "未发布" |
|
|
|
if info.ArticleDemandLst[0].Status == 2 { |
|
|
|
state = "已发布" |
|
|
|
} |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-State"] = state |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Descr1"] = info.Descr1 |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-FGStock"] = utils.FloatToString(info.FGStock, 0) |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-WIPStock"] = utils.FloatToString(info.WIPStock, 0) |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-PUCStock"] = utils.FloatToString(info.PUCStock, 0) |
|
|
|
|
|
|
|
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 |
|
|
|
} |
|
|
|
|
|
|
|
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" |
|
|
|
CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.FloatToString(detail.NetDemandQty, 0) |
|
|
|
case 1: |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Label"] = "AP_ArticleDemand-ForecastDemandQty" |
|
|
|
CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.FloatToString(detail.ForecastDemandQty, 0) |
|
|
|
case 2: |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Label"] = "AP_ArticleDemand-OrderQty" |
|
|
|
CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.FloatToString(detail.OrderQty, 0) |
|
|
|
case 3: |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Label"] = "AP_ArticleDemand-OutSourcingQty" |
|
|
|
CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.FloatToString(detail.OutSourcingQty, 0) |
|
|
|
case 4: |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Label"] = "AP_ArticleDemand-IndependentDemandQty" |
|
|
|
CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.FloatToString(detail.IndependentDemandQty, 0) |
|
|
|
case 5: |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Label"] = "AP_ArticleDemand-WipQty" |
|
|
|
CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.FloatToString(detail.WipQty, 0) |
|
|
|
case 6: |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Label"] = "AP_ArticleDemand-WeiwaiQty" |
|
|
|
CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.FloatToString(detail.WeiwaiQty, 0) |
|
|
|
case 7: |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Label"] = "AP_ArticleDemand-ZaituQty" |
|
|
|
CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.FloatToString(detail.ZaituQty, 0) |
|
|
|
case 8: |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Label"] = "AP_ArticleDemand-OpeningInventory" |
|
|
|
CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.FloatToString(detail.OpeningInventory, 0) |
|
|
|
case 9: |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Label"] = "AP_ArticleDemand-TargetInventory" |
|
|
|
CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.FloatToString(detail.TargetInventory, 0) |
|
|
|
case 10: |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Label"] = "AP_ArticleDemand-MinInventory" |
|
|
|
CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.FloatToString(detail.MinInventory, 0) |
|
|
|
case 11: |
|
|
|
CustArtStockItem.ItemLst[i]["AP_ArticleDemand-Label"] = "AP_ArticleDemand-EndingInventory" |
|
|
|
CustArtStockItem.ItemLst[i][detail.DemandKey] = utils.FloatToString(detail.EndingInventory, 0) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
CustArtStockaLL.ItemLst = append(CustArtStockaLL.ItemLst, CustArtStockItem.ItemLst...) |
|
|
|
} |
|
|
|
messageHead := make(map[string]string) |
|
|
|
messageHead["title"] = versionId |
|
|
|
tableHead := "" |
|
|
|
for _, _v := range CustArtStockaLL.SortKeys { |
|
|
|
tableHead += "<th>" + _v + "</th>" |
|
|
|
} |
|
|
|
messageHead["table_head"] = tableHead |
|
|
|
//渲染表头
|
|
|
|
logUtils.NewEmptyFile("planlog", messageHead, versionId) |
|
|
|
|
|
|
|
messageOne := make(map[string]string) |
|
|
|
messageTwo := make(map[string]string) |
|
|
|
var infoOne string |
|
|
|
var infoTwo string |
|
|
|
i := len(CustArtStockaLL.SortKeys) |
|
|
|
for _, v := range CustArtStockaLL.ItemLst { |
|
|
|
infoOne = "" |
|
|
|
infoTwo = "" |
|
|
|
for _, _v := range CustArtStockaLL.SortKeys { |
|
|
|
if i == len(CustArtStockaLL.SortKeys) { |
|
|
|
infoOne += "<td>" + v[_v] + "</td>" |
|
|
|
} else { |
|
|
|
infoTwo += "<td>" + v[_v] + "</td>" |
|
|
|
} |
|
|
|
} |
|
|
|
if i == len(CustArtStockaLL.SortKeys) { |
|
|
|
messageOne["info_one"] = infoOne |
|
|
|
logUtils.Write("planlog", messageOne, versionId, "info") |
|
|
|
} else { |
|
|
|
messageTwo["info_two"] = infoOne |
|
|
|
messageTwo["info_two_title"] = v["AP_ArticleDemand-ArtId"] |
|
|
|
logUtils.Write("planlog", messageTwo, versionId, "info_two") |
|
|
|
} |
|
|
|
i-- |
|
|
|
if i == 0 { |
|
|
|
i = len(CustArtStockaLL.SortKeys) |
|
|
|
} |
|
|
|
} |
|
|
|
logUtils.WriteFileBottom("planlog", messageHead, versionId) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 显示计划列表
|
|
|
|
func (impl *BalanceServiceImplement) GetCustomerArticleDemand(user *global.User, ArtId, CustomerId, Planner string, pageNumber, pageSize int) (*model.CustArtStockItem, error) { |
|
|
|
grmi.Log(user, "/services/ap/implments/ArticleDemand.service.impl.go", "GetCustomerArticleDemand", "GetCustomerArticleDemand") |
|
|
@ -2798,12 +3060,8 @@ func (impl *BalanceServiceImplement) PublishMpsPlan(user *global.User, version s |
|
|
|
week, year, _ := utils.WeekByDate(now) |
|
|
|
dao_PlanOrderVersion := dal.NewPlanOrderVersionDAO(session, user.PlantNr, user.UserId) |
|
|
|
dao_PlanOrder := dal.NewPlanOrderDAO(session, user.PlantNr, user.UserId) |
|
|
|
//dao_Independent := dal.NewArticleIndependentDemandDAO(session, user.PlantNr, user.UserId)
|
|
|
|
dao_CustDemandVerHead := dal.NewCustDemandVerHeadDAO(session, user.PlantNr, user.UserId) |
|
|
|
dao_ArticleDemand := dal.NewArticleDemandDAO(session, user.PlantNr, user.UserId) |
|
|
|
//daoArticleCustomer := dal.NewCustArtlstDAO(session, user.PlantNr, user.UserId)
|
|
|
|
//daoArticle := dal_base.NewArticleDAO(session, user.PlantNr, user.UserId)
|
|
|
|
//daoCustomer := dal_base.NewCustomerDAO(session, user.PlantNr, user.UserId)
|
|
|
|
daoPlant := dal_base.NewPlantDAO(session, user.UserId) |
|
|
|
daoMpsSetting := dal.NewMpsSettingDAO(session, user.PlantNr, user.UserId) |
|
|
|
existLi, err := dao_PlanOrderVersion.Select([]grmi.Predicate{meta.PlanOrderVersion_VersionNr.NewPredicate(grmi.Equal, version)}, nil) |
|
|
@ -2825,25 +3083,6 @@ func (impl *BalanceServiceImplement) PublishMpsPlan(user *global.User, version s |
|
|
|
return grmi.NewBusinessError("存在未全局发布的版本 客户:" + info.CustomerId) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//PlanOrderVersionList, err := dao_PlanOrderVersion.Select([]grmi.Predicate{}, []grmi.Field{meta.PlanOrderVersion_VersionNr})
|
|
|
|
//if err != nil {
|
|
|
|
// return grmi.NewDataBaseError(err)
|
|
|
|
//}
|
|
|
|
//if len(PlanOrderVersionList) > 0 {
|
|
|
|
// CloseVersionNr := PlanOrderVersionList[len(PlanOrderVersionList)-1].VersionNr
|
|
|
|
// planList, err := dao_PlanOrder.Select([]grmi.Predicate{meta.PlanOrder_VersionNr.NewPredicate(grmi.Equal, CloseVersionNr)}, nil)
|
|
|
|
// if err != nil {
|
|
|
|
// return grmi.NewDataBaseError(err)
|
|
|
|
// }
|
|
|
|
// for _, info := range planList {
|
|
|
|
// err = utilService.PLN_PLANORDER_Init().Close(user.PlantNr, user.UserId, &info)
|
|
|
|
// if err != nil {
|
|
|
|
// fmt.Println(err)
|
|
|
|
// //return grmi.NewDataBaseError(err)
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
// 获取吸收期
|
|
|
|
// 1. 获取所有物料需求中的物料id
|
|
|
|
// 2. 查询所有物料 从物料上获取最大的吸收期
|
|
|
@ -2861,75 +3100,6 @@ func (impl *BalanceServiceImplement) PublishMpsPlan(user *global.User, version s |
|
|
|
if mpsSetting == nil { |
|
|
|
return grmi.NewBusinessError("不存在全局配置mps策略, 策略ID:" + strconv.Itoa(data_plant.DefaultMpsSettingNr)) |
|
|
|
} |
|
|
|
//var lockWeeks int
|
|
|
|
//if mpsSetting.UseCustDemandLockToggle {
|
|
|
|
// allArtId, err := dao_ArticleDemand.SelectAllArtId()
|
|
|
|
// if err != nil {
|
|
|
|
// return grmi.NewBusinessError("查询物料需求中所有物料ID失败, 错误:" + err.Error())
|
|
|
|
// }
|
|
|
|
// if len(allArtId) == 0 {
|
|
|
|
// return grmi.NewBusinessError("不存在物料需求计划")
|
|
|
|
// }
|
|
|
|
// artIdLi := make([]interface{}, 0, len(allArtId))
|
|
|
|
// for _, artId := range allArtId {
|
|
|
|
// artIdLi = append(artIdLi, artId)
|
|
|
|
// }
|
|
|
|
// //articleLi, err := daoArticle.Select([]grmi.Predicate{meta_base.Article_ArtId.NewPredicate(grmi.Include, artIdLi...)}, nil)
|
|
|
|
// //if err != nil {
|
|
|
|
// // return grmi.NewBusinessError("查询物料数据失败, 错误:" + err.Error())
|
|
|
|
// //}
|
|
|
|
// var articleLi []model_base.Article
|
|
|
|
// for _, artInfo := range alldata_Article{
|
|
|
|
// for _, artId := range artIdLi{
|
|
|
|
// if artId == artInfo.ArtId{
|
|
|
|
// articleLi = append(articleLi, artInfo)
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if len(articleLi) == 0 {
|
|
|
|
// return grmi.NewBusinessError("不存在需求的物料数据")
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// for _, article := range articleLi {
|
|
|
|
// if int(article.DeliveryBuffer) > lockWeeks {
|
|
|
|
// lockWeeks = int(article.DeliveryBuffer)
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if lockWeeks == 0 {
|
|
|
|
// customerIdLi, err := daoArticleCustomer.SelectCustomerIdByArt(allArtId)
|
|
|
|
// if err != nil {
|
|
|
|
// return grmi.NewBusinessError("查询客户物料关联关系失败, 错误:" + err.Error())
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// var customerLi []model_base.Customer
|
|
|
|
// for _, customerInfo := range alldata_Customer{
|
|
|
|
// for _, customerId := range customerIdLi{
|
|
|
|
// if customerInfo.CustomerId == customerId{
|
|
|
|
// customerLi = append(customerLi, customerInfo)
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// //customerLi, err := daoCustomer.Select([]grmi.Predicate{meta_base.Customer_CustomerId.NewPredicate(grmi.Include, customerIdLi...)}, nil)
|
|
|
|
// //if err != nil {
|
|
|
|
// // return grmi.NewBusinessError("查询客户数据失败, 错误:" + err.Error())
|
|
|
|
// //}
|
|
|
|
// for _, customer := range customerLi {
|
|
|
|
// if customer.LockWeeks > lockWeeks {
|
|
|
|
// lockWeeks = customer.LockWeeks
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if lockWeeks == 0 {
|
|
|
|
// lockWeeks = mpsSetting.DefaultLockWeeks
|
|
|
|
// }
|
|
|
|
//} else {
|
|
|
|
// lockWeeks = mpsSetting.DefaultLockWeeks
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//if lockWeeks == 0 {
|
|
|
|
// return grmi.NewBusinessError("未获取到吸收期")
|
|
|
|
//}
|
|
|
|
|
|
|
|
prePlanOrderVersion, err := dao_PlanOrderVersion.SelectPrePlanOrder() |
|
|
|
if err != nil { |
|
|
@ -2954,19 +3124,6 @@ func (impl *BalanceServiceImplement) PublishMpsPlan(user *global.User, version s |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
//var currentEndWeek int
|
|
|
|
//var nextEndWeek int
|
|
|
|
//for i := 0; i < lockWeeks; i++ {
|
|
|
|
// nowTime := time.Now().AddDate(0, 0, i*7)
|
|
|
|
// //查询该用户当前周是否有未发布的版本
|
|
|
|
// nowWeek, nowYear, _ := utils.WeekByDate(nowTime)
|
|
|
|
// if nowYear == year {
|
|
|
|
// currentEndWeek = nowWeek
|
|
|
|
// } else {
|
|
|
|
// nextEndWeek = nowWeek
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
timeNow := time.Now() |
|
|
|
allArticleDemandList, err := dao_ArticleDemand.Select([]grmi.Predicate{}, nil) |
|
|
|
if err != nil { |
|
|
@ -3028,26 +3185,6 @@ func (impl *BalanceServiceImplement) PublishMpsPlan(user *global.User, version s |
|
|
|
} |
|
|
|
data_ArticleDemand = append(data_ArticleDemand, articleDemand) |
|
|
|
} |
|
|
|
|
|
|
|
//if nextEndWeek == 0 {
|
|
|
|
// currentYearLi, err := dao_ArticleDemand.Select([]grmi.Predicate{meta.ArticleDemand_DemandYear.NewPredicate(grmi.Equal, year), meta.ArticleDemand_DemandWeek.NewPredicate(grmi.LessOrEqual, currentEndWeek), meta.ArticleDemand_DemandWeek.NewPredicate(grmi.GreaterOrEqual, week)}, nil)
|
|
|
|
// if err != nil {
|
|
|
|
// return grmi.NewBusinessError("查询物料需求数据失败, 错误" + err.Error())
|
|
|
|
// }
|
|
|
|
// data_ArticleDemand = append(data_ArticleDemand, currentYearLi...)
|
|
|
|
//}
|
|
|
|
//if nextEndWeek != 0 {
|
|
|
|
// currentYearLi, err := dao_ArticleDemand.Select([]grmi.Predicate{meta.ArticleDemand_DemandYear.NewPredicate(grmi.Equal, year), meta.ArticleDemand_DemandWeek.NewPredicate(grmi.GreaterOrEqual, week)}, nil)
|
|
|
|
// if err != nil {
|
|
|
|
// return grmi.NewBusinessError("查询物料需求数据失败, 错误" + err.Error())
|
|
|
|
// }
|
|
|
|
// data_ArticleDemand = append(data_ArticleDemand, currentYearLi...)
|
|
|
|
// nextYearLi, err := dao_ArticleDemand.Select([]grmi.Predicate{meta.ArticleDemand_DemandYear.NewPredicate(grmi.Equal, year+1), meta.ArticleDemand_DemandWeek.NewPredicate(grmi.LessOrEqual, nextEndWeek)}, nil)
|
|
|
|
// if err != nil {
|
|
|
|
// return grmi.NewBusinessError("查询物料需求数据失败, 错误" + err.Error())
|
|
|
|
// }
|
|
|
|
// data_ArticleDemand = append(data_ArticleDemand, nextYearLi...)
|
|
|
|
//}
|
|
|
|
if err = session.Begin(); err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
@ -3097,34 +3234,10 @@ func (impl *BalanceServiceImplement) PublishMpsPlan(user *global.User, version s |
|
|
|
PlanWeek: info.DemandWeek, |
|
|
|
PlanMonth: info.DemandMonth, |
|
|
|
PlanQty: info.NetDemandQty, |
|
|
|
//RunTime
|
|
|
|
//Operator string `xorm:"nvarchar(40) 'Operator' not null" json:"AP_PlanOrder-Operator"`
|
|
|
|
//MpsSettingNr int `xorm:"int 'MpsSettingNr' not null" json:"AP_PlanOrder-MpsSettingNr"`
|
|
|
|
} |
|
|
|
pos++ |
|
|
|
planOrderList = append(planOrderList, planOrder) |
|
|
|
} |
|
|
|
|
|
|
|
//if info.OutSourcingQty-info.OriginOutSourcingQty > 0 {
|
|
|
|
// date := info.DemandDate
|
|
|
|
// if !utils.WeekDayMondayZeroTs(info.DemandDate.Restore()).Before(utils.WeekDayMondayZeroTs(time.Now())) {
|
|
|
|
// date = grmi.Date(time.Now())
|
|
|
|
// }
|
|
|
|
// IndependentDemandQty := model.ArticleIndependentDemand{
|
|
|
|
// PlantNr: user.PlantNr,
|
|
|
|
// ArtId: info.ArtId,
|
|
|
|
// DemandKey: info.DemandKey,
|
|
|
|
// VersionNr: data_PlanOrderVersion.VersionNr,
|
|
|
|
// ProjectId: info.ProjectId,
|
|
|
|
// CustomerId: info.CustomerId,
|
|
|
|
// DemandDate: date,
|
|
|
|
// DemandYear: info.DemandYear,
|
|
|
|
// DemandWeek: info.DemandWeek,
|
|
|
|
// DemandMonth: info.DemandMonth,
|
|
|
|
// DemandQty: info.OutSourcingQty - info.OriginOutSourcingQty,
|
|
|
|
// }
|
|
|
|
// IndependentDemandQtyList = append(IndependentDemandQtyList, IndependentDemandQty)
|
|
|
|
//}
|
|
|
|
// 已发布
|
|
|
|
info.Status = 2 |
|
|
|
info.PublishedVersionNr = version |
|
|
@ -3158,18 +3271,10 @@ func (impl *BalanceServiceImplement) PublishMpsPlan(user *global.User, version s |
|
|
|
return grmi.NewBusinessError("写入发布计划明细失败, 错误:" + err.Error()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//err = dao_Independent.Insert(&IndependentDemandQtyList)
|
|
|
|
//if err != nil {
|
|
|
|
// _ = session.Rollback()
|
|
|
|
// return grmi.NewBusinessError("写入外购需求数据失败, 错误:" + err.Error())
|
|
|
|
//}
|
|
|
|
|
|
|
|
utils.EmailSendStruct["planOrderVersion_publish"].SeyChannels(utils.ChannelsInfo{ |
|
|
|
Key: utils.ValueToString(data_PlanOrderVersion.PlanOrderId, ""), |
|
|
|
Info: data_PlanOrderVersion, |
|
|
|
}) |
|
|
|
|
|
|
|
// 已经发布
|
|
|
|
for index, _ := range demandHeadList { |
|
|
|
demandHeadList[index].MpsStatus = 1 |
|
|
@ -3180,6 +3285,7 @@ func (impl *BalanceServiceImplement) PublishMpsPlan(user *global.User, version s |
|
|
|
} |
|
|
|
} |
|
|
|
_ = session.Commit() |
|
|
|
impl.GetCustomerArticleDemandHtml(user, version) |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
@ -3497,8 +3603,8 @@ func (impl *BalanceServiceImplement) RefreshBalanceData(user *global.User) error |
|
|
|
MaxCoverPeriod: MaxCoverPeriod, |
|
|
|
MinCoverPeriodType: "W", |
|
|
|
ResourceId: resourceId, |
|
|
|
WeiwaiQty: 0, |
|
|
|
ZaituQty: 0, |
|
|
|
WeiwaiQty: 0, |
|
|
|
ZaituQty: 0, |
|
|
|
} |
|
|
|
|
|
|
|
firstDemandList = append(firstDemandList, firstArticleDemand) |
|
|
@ -3539,7 +3645,7 @@ func (impl *BalanceServiceImplement) RefreshBalanceData(user *global.User) error |
|
|
|
message["request"] = "主要资源不存在" |
|
|
|
message["response"] = "" |
|
|
|
fmt.Println(message["info"]) |
|
|
|
logUtils.Write("salesorder", message, "") |
|
|
|
logUtils.Write("salesorder", message, "", "info") |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
@ -3560,7 +3666,7 @@ func (impl *BalanceServiceImplement) RefreshBalanceData(user *global.User) error |
|
|
|
message["request"] = "物料不存在" |
|
|
|
message["response"] = "" |
|
|
|
fmt.Println(message["info"]) |
|
|
|
logUtils.Write("salesorder", message, "") |
|
|
|
logUtils.Write("salesorder", message, "", "info") |
|
|
|
continue |
|
|
|
} |
|
|
|
if MidBatchQuantity == 0 { |
|
|
@ -3686,8 +3792,8 @@ func (impl *BalanceServiceImplement) RefreshBalanceData(user *global.User) error |
|
|
|
MaxCoverPeriod: MaxCoverPeriod, |
|
|
|
MinCoverPeriodType: "W", |
|
|
|
ResourceId: resourceId, |
|
|
|
WeiwaiQty: 0, |
|
|
|
ZaituQty: 0, |
|
|
|
WeiwaiQty: 0, |
|
|
|
ZaituQty: 0, |
|
|
|
} |
|
|
|
|
|
|
|
firstDemandList = append(firstDemandList, firstArticleDemand) |
|
|
@ -3724,7 +3830,7 @@ func (impl *BalanceServiceImplement) RefreshBalanceData(user *global.User) error |
|
|
|
session.Rollback() |
|
|
|
return grmi.NewBusinessError("查询SalesOrder失败, error:" + err.Error()) |
|
|
|
} |
|
|
|
DLQty, WGQty, ZZQty, DDQty,WWQty := 0.0, 0.0, 0.0, 0.0, 0.0 |
|
|
|
DLQty, WGQty, ZZQty, DDQty, WWQty := 0.0, 0.0, 0.0, 0.0, 0.0 |
|
|
|
for _, info := range SalesOrderList { |
|
|
|
if info.ProductType == "DL" { |
|
|
|
DLQty = info.PlanQty |
|
|
@ -4347,7 +4453,7 @@ func (impl *BalanceServiceImplement) ArticleDemandEmergencyCreate(user *global.U |
|
|
|
message["request"] = "主要资源不存在" |
|
|
|
message["response"] = "" |
|
|
|
fmt.Println(message["info"]) |
|
|
|
logUtils.Write("salesorder", message, "") |
|
|
|
logUtils.Write("salesorder", message, "", "info") |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
@ -4368,7 +4474,7 @@ func (impl *BalanceServiceImplement) ArticleDemandEmergencyCreate(user *global.U |
|
|
|
message["request"] = "物料不存在" |
|
|
|
message["response"] = "" |
|
|
|
fmt.Println(message["info"]) |
|
|
|
logUtils.Write("salesorder", message, "") |
|
|
|
logUtils.Write("salesorder", message, "", "info") |
|
|
|
continue |
|
|
|
} |
|
|
|
if MidBatchQuantity == 0 { |
|
|
@ -4692,7 +4798,7 @@ func (impl *BalanceServiceImplement) ArticleDemandEmergencyCreate(user *global.U |
|
|
|
session.Rollback() |
|
|
|
return grmi.NewBusinessError("查询SalesOrder失败, error:" + err.Error()) |
|
|
|
} |
|
|
|
DLQty, WGQty, ZZQty, DD_TEMPQty,WWQty := 0.0, 0.0, 0.0, 0.0, 0.0 |
|
|
|
DLQty, WGQty, ZZQty, DD_TEMPQty, WWQty := 0.0, 0.0, 0.0, 0.0, 0.0 |
|
|
|
for _, info := range SalesOrderList { |
|
|
|
if info.ProductType == "DD_TEMP" { |
|
|
|
DD_TEMPQty = info.PlanQty |
|
|
@ -4912,7 +5018,7 @@ func (impl *BalanceServiceImplement) ArticleDemandEmergencyCreate(user *global.U |
|
|
|
MinCoverPeriodType: info.MinCoverPeriodType, |
|
|
|
ResourceId: info.ResourceId, |
|
|
|
ZaituQty: info.ZaituQty, |
|
|
|
WeiwaiQty: info.WeiwaiQty, |
|
|
|
WeiwaiQty: info.WeiwaiQty, |
|
|
|
} |
|
|
|
err := dao_ArticleDemandEmergency.InsertOne(&articleDemandEmergency) |
|
|
|
if err != nil { |
|
|
@ -5325,7 +5431,7 @@ func (impl *BalanceServiceImplement) ArticleDemandEmergencyPublish(user *global. |
|
|
|
message["info"] = "紧急插单 物料:" + planOrder.ArtId + " 计划周:" + utils.ValueToString(planOrder.PlanYear, "") + "-" + utils.ValueToString(planOrder.PlanWeek, "") |
|
|
|
message["request"] = req |
|
|
|
message["response"] = res + err.Error() |
|
|
|
logUtils.Write("plan", message, planOrder.ArtId) |
|
|
|
logUtils.Write("plan", message, planOrder.ArtId, "info") |
|
|
|
} else { |
|
|
|
// 已发布
|
|
|
|
info.Status = 2 |
|
|
|