diff --git a/conf/htm_log_config.yaml b/conf/htm_log_config.yaml index e6fc31b..2e5058d 100644 --- a/conf/htm_log_config.yaml +++ b/conf/htm_log_config.yaml @@ -7,7 +7,8 @@ config: default: "" # 支持文件的最大个数 MaxAge: 30 - info : "
时间:[time]错误提示:[info]
Request:[request]
Response:[response]

" + body: + info : "
时间:[time]错误提示:[info]
Request:[request]
Response:[response]

" replace : - "time" - "info" @@ -20,7 +21,8 @@ config: default: "" # 支持文件的最大个数 MaxAge: 30 - info: "
时间:[time]错误提示:[info]
Request:[request]
Response:[response]

" + body: + info: "
时间:[time]错误提示:[info]
Request:[request]
Response:[response]

" replace: - "time" - "info" @@ -33,9 +35,24 @@ config: default: "" # 支持文件的最大个数 MaxAge: 30 - info: "
时间:[time]错误提示:[info]
Request:[request]
Response:[response]

" + body: + info: "
时间:[time]错误提示:[info]
Request:[request]
Response:[response]

" replace: - "time" - "info" - "request" - - "response" \ No newline at end of file + - "response" + planlog: + filename: ./log/planlog + filetype: html-page + default: "[title][table_head]" + body: + info: "[info_one]" + info_two: "[info_two]" + bottom: "
" + replace: + - "title" + - "table_head" + - "info_one" + - "info_two" + - "info_two_title" \ No newline at end of file diff --git a/services/ap/PlanOrderVersion.service.go b/services/ap/PlanOrderVersion.service.go index d81af64..8c34a83 100644 --- a/services/ap/PlanOrderVersion.service.go +++ b/services/ap/PlanOrderVersion.service.go @@ -214,6 +214,8 @@ type PlanOrderVersionService interface { * ******************************************************************************/ GetExistVersion(user *global.User) (*model.PublishIdentifyMessage, error) + GetExistVersionAll(user *global.User) (*model.PublishIdentifyMessage, error) + /****************************************************************************** * * @Function Name : RelPublish diff --git a/services/ap/implments/Balance.service.impl.go b/services/ap/implments/Balance.service.impl.go index cc0f21e..d3526e7 100644 --- a/services/ap/implments/Balance.service.impl.go +++ b/services/ap/implments/Balance.service.impl.go @@ -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 += "" + _v + "" + } + 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 += "" + v[_v] + "" + } else { + infoTwo += "" + v[_v] + "" + } + } + 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 diff --git a/services/ap/implments/PlanOrderVersion.service.impl.go b/services/ap/implments/PlanOrderVersion.service.impl.go index caf8ddb..efe7397 100644 --- a/services/ap/implments/PlanOrderVersion.service.impl.go +++ b/services/ap/implments/PlanOrderVersion.service.impl.go @@ -177,7 +177,7 @@ func (impl *PlanOrderVersionServiceImplement) Publish(info utils.ChannelsInfo) ( message["info"] = "版本:" + v.VersionNr + " 物料:" + v.ArtId + " 计划周:" + utils.ValueToString(v.PlanYear, "") + "-" + utils.ValueToString(v.PlanWeek, "") message["request"] = req message["response"] = res - logUtils.Write("plan", message, v.VersionNr) + logUtils.Write("plan", message, v.VersionNr, "info") } else { if ids != "" { ids += "," @@ -488,6 +488,28 @@ func (impl *PlanOrderVersionServiceImplement) Update(user *global.User, entities return nil } +//获取所有历史版本 +func (impl *PlanOrderVersionServiceImplement) GetExistVersionAll(user *global.User) (*model.PublishIdentifyMessage, error) { + result := &model.PublishIdentifyMessage{} + grmi.Log(user, "/services/ap/implments/PlanOrderVersion.service.impl.go", "GetExistVersionAll", "获取所有历史版本") + engine := db.Eloquent.Master() + session := engine.NewSession() + defer session.Close() + dao := dal.NewPlanOrderVersionDAO(session, user.PlantNr, user.UserId) + planOrderVersionLi, err := dao.Select(nil, []grmi.Field{meta.PlanOrderVersion_CreateTime}) + if err != nil { + return nil, grmi.NewBusinessError("查询已存在发布版本失败, error:" + err.Error()) + } + for _, planOrderVersion := range planOrderVersionLi { + var versionData model.PublishedVersion + versionData.PublishedVersionNr = planOrderVersion.VersionNr + versionData.Status = planOrderVersion.Status + versionData.PlanOrderId = planOrderVersion.PlanOrderId + result.PublishedVersionLi = append(result.PublishedVersionLi, versionData) + } + return result, nil +} + // GetExistVersion 获取已存在的版本信息 func (impl *PlanOrderVersionServiceImplement) GetExistVersion(user *global.User) (*model.PublishIdentifyMessage, error) { result := &model.PublishIdentifyMessage{} diff --git a/services/base/implments/EscalateModelHead.service.impl.go b/services/base/implments/EscalateModelHead.service.impl.go index 39e918a..eefcc0e 100644 --- a/services/base/implments/EscalateModelHead.service.impl.go +++ b/services/base/implments/EscalateModelHead.service.impl.go @@ -96,27 +96,27 @@ func NewEscalateModelHeadServiceImplement() *EscalateModelHeadServiceImplement { escalateModelHeadServiceImplement := &EscalateModelHeadServiceImplement{} ////创建队列 - //utils.EmailSendFoudnMap["escalatemodelhead"] = escalateModelHeadServiceImplement - //utils.EmailSendStruct["escalatemodelhead"] = utils.NewEmailSendStruct(10, "escalatemodelhead", 10) - //headMsgConfig = make(map[string]model.EscalateModelHead) - ////将配置放入map中 - //engine := db.Eloquent.Master() - //session := engine.NewSession() - //escalateModelHeadDAO := dal.NewEscalateModelHeadDAO(session, model.PlantNr, "system") - //_headMsgConfig, err := escalateModelHeadDAO.SelectAll() - //if err != nil { - // panic("邮件配置导入失败") - //} - //headMsgConfig = _headMsgConfig - ////将未完成信息写入队列 - //escalateMsgDao := dal.NewEscalateMsgDAO(session, model.PlantNr, "system") - //urlParameters := make(map[string]string) - //urlParameters["Status"] = "2" - //predicates, err := DefaultConditionOfEscalateMsg.BuildPredicates(urlParameters) - //msgList, err := escalateMsgDao.Select(predicates, nil) - //for _, _v := range msgList { - // utils.EmailSendStruct["escalatemodelhead"].SeyChannels(utils.ChannelsInfo{Key: _v.MsgId, Info: _v}) - //} + utils.EmailSendFoudnMap["escalatemodelhead"] = escalateModelHeadServiceImplement + utils.EmailSendStruct["escalatemodelhead"] = utils.NewEmailSendStruct(10, "escalatemodelhead", 10, "ManageFunction") + headMsgConfig = make(map[string]model.EscalateModelHead) + //将配置放入map中 + engine := db.Eloquent.Master() + session := engine.NewSession() + escalateModelHeadDAO := dal.NewEscalateModelHeadDAO(session, model.PlantNr, "system") + _headMsgConfig, err := escalateModelHeadDAO.SelectAll() + if err != nil { + panic("邮件配置导入失败") + } + headMsgConfig = _headMsgConfig + //将未完成信息写入队列 + escalateMsgDao := dal.NewEscalateMsgDAO(session, model.PlantNr, "system") + urlParameters := make(map[string]string) + urlParameters["Status"] = "2" + predicates, err := DefaultConditionOfEscalateMsg.BuildPredicates(urlParameters) + msgList, err := escalateMsgDao.Select(predicates, nil) + for _, _v := range msgList { + utils.EmailSendStruct["escalatemodelhead"].SeyChannels(utils.ChannelsInfo{Key: _v.MsgId, Info: _v}) + } return escalateModelHeadServiceImplement } diff --git a/services/erp/erp.go b/services/erp/erp.go index bb23a70..4ec66ce 100644 --- a/services/erp/erp.go +++ b/services/erp/erp.go @@ -229,7 +229,7 @@ func GetChaigouQty(PlantNr int, UserId string, alldata_Article *[]model.Article) //var ArticleStockList []model_base.ArticleStock dao_ArticleStock := dal_base.NewArticleStockDAO(session, PlantNr, UserId) FilerString := "" - FilerString += "FDocumentStatus = 'C'" + FilerString += "FDocumentStatus = 'C' and FBusinessType not IN('WW')" dataList := utilService.PUR_PurchaseOrder_Init().Search(FilerString, "") articlestockMap := make(map[string]float64) @@ -285,9 +285,10 @@ func GetWeiWaiQty(PlantNr int, UserId string, alldata_Article *[]model.Article) //var ArticleStockList []model_base.ArticleStock dao_ArticleStock := dal_base.NewArticleStockDAO(session, PlantNr, UserId) + FilerString := "" - FilerString += "FDocumentStatus = 'C' and FCancelStatus='A'" - dataList := utilService.SUB_SUBREQORDERInit().Search(FilerString, "") + FilerString += "FDocumentStatus = 'C' and FCancelStatus='A' and FBusinessType = 'WW'" + dataList := utilService.PUR_PurchaseOrder_Init().Search(FilerString, "") articlestockMap := make(map[string]float64) for _, info := range dataList { @@ -597,7 +598,7 @@ func GetWaigouWeekQty(PlantNr int, UserId string, allData *[]model.Article) (err dao_SalesOrder.DeleteWhere([]grmi.Predicate{meta.SalesOrder_ProductType.NewPredicate(grmi.Equal, "WG")}) FilerString := "" - FilerString += "FDocumentStatus = 'C'" + FilerString += "FDocumentStatus = 'C' and FBusinessType not IN('WW')" dataList := utilService.PUR_PurchaseOrder_Init().Search(FilerString, "") for _, info := range dataList { @@ -736,9 +737,11 @@ func GetWeiWaiWeekQty(PlantNr int, UserId string, allData *[]model.Article) (err dao_SalesOrder := dal_base.NewSalesOrderDAO(session, PlantNr, UserId) dao_SalesOrder.DeleteWhere([]grmi.Predicate{meta.SalesOrder_ProductType.NewPredicate(grmi.Equal, "WW")}) + FilerString := "" - FilerString += "FDocumentStatus = 'C' and FCancelStatus='A'" - dataList := utilService.SUB_SUBREQORDERInit().Search(FilerString, "") + FilerString += "FDocumentStatus = 'C' and FCancelStatus='A' and FBusinessType = 'WW'" + dataList := utilService.PUR_PurchaseOrder_Init().Search(FilerString, "") + if err = session.Begin(); err != nil { return } diff --git a/utils/k3cloud.go b/utils/k3cloud.go index 8076623..65b3f40 100644 --- a/utils/k3cloud.go +++ b/utils/k3cloud.go @@ -45,14 +45,14 @@ func K3configTestInit() { } //UAT新 -//const k3url = "http://10.11.12.24/K3Cloud/" -//const accID = "61cff33d2cf273" -//const username = "aps001" -//const password = "aps202101" -//const OrgId1 = "100729" -//const OrgId2 = "100726" -//const NoId1 = "9999" -//const NoId2 = "9897" +const k3url = "http://10.11.12.24/K3Cloud/" +const accID = "61cff33d2cf273" +const username = "aps001" +const password = "aps202101" +const OrgId1 = "100729" +const OrgId2 = "100726" +const NoId1 = "9999" +const NoId2 = "9897" //瑞玛测试服UAT //const k3url = "http://10.11.12.24/K3Cloud/" @@ -92,14 +92,14 @@ func K3configInit() { } //瑞玛正式 -const k3url = "http://10.11.12.24/K3Cloud/" -const accID = "6178dbe238ea56" -const username = "aps001" -const password = "aps202101" -const OrgId1 = "100729" -const OrgId2 = "100726" -const NoId1 = "9999" -const NoId2 = "9897" +//const k3url = "http://10.11.12.24/K3Cloud/" +//const accID = "6178dbe238ea56" +//const username = "aps001" +//const password = "aps202101" +//const OrgId1 = "100729" +//const OrgId2 = "100726" +//const NoId1 = "9999" +//const NoId2 = "9897" /** K3cloud 登录 diff --git a/utils/log/log.go b/utils/log/log.go index 8c00181..2e24f23 100644 --- a/utils/log/log.go +++ b/utils/log/log.go @@ -50,10 +50,52 @@ func Read(model string, _fileName string) []byte { return bytes } +func NewEmptyFile(model string, info map[string]string, _fileName string) { + year, month, day := time.Now().Date() + fileName := utils.ValueToString(year, "") + utils.ValueToString(month, "") + utils.ValueToString(day, "") + "." + loggerConfig.Config[model].Filetype + if _fileName != "" { + fileName = _fileName + "." + loggerConfig.Config[model].Filetype + } + path := loggerConfig.Config[model].Filename + "/" + fileName + + defaultStr := loggerConfig.Config[model].Default + for _, v := range loggerConfig.Config[model].Replace { + defaultStr = strings.Replace(defaultStr, "["+v+"]", info[v], -1) + } + + file, err := os.OpenFile(path, os.O_CREATE, 0666) + if err != nil { + panic(err) + } + defer file.Close() + file.Write([]byte(defaultStr)) +} + +func WriteFileBottom(model string, info map[string]string, _fileName string) { + year, month, day := time.Now().Date() + fileName := utils.ValueToString(year, "") + utils.ValueToString(month, "") + utils.ValueToString(day, "") + "." + loggerConfig.Config[model].Filetype + if _fileName != "" { + fileName = _fileName + "." + loggerConfig.Config[model].Filetype + } + path := loggerConfig.Config[model].Filename + "/" + fileName + + bottomStr := loggerConfig.Config[model].Bottom + for _, v := range loggerConfig.Config[model].Replace { + bottomStr = strings.Replace(bottomStr, "["+v+"]", info[v], -1) + } + + file, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND, 0666) + if err != nil { + panic(err) + } + defer file.Close() + file.Write([]byte(bottomStr)) +} + /** 写入文件 */ -func Write(model string, info map[string]string, _fileName string) { +func Write(model string, info map[string]string, _fileName string, body string) { year, month, day := time.Now().Date() fileName := utils.ValueToString(year, "") + utils.ValueToString(month, "") + utils.ValueToString(day, "") + "." + loggerConfig.Config[model].Filetype if _fileName != "" { @@ -61,12 +103,18 @@ func Write(model string, info map[string]string, _fileName string) { } path := loggerConfig.Config[model].Filename + "/" + fileName var file *os.File - message := loggerConfig.Config[model].Info + bodyTitle := body + if bodyTitle == "" { + bodyTitle = "info" + } + message := loggerConfig.Config[model].Body[bodyTitle] + defaultStr := loggerConfig.Config[model].Default for _, v := range loggerConfig.Config[model].Replace { + defaultStr = strings.Replace(defaultStr, "["+v+"]", info[v], -1) message = strings.Replace(message, "["+v+"]", info[v], -1) } if !IsExist(path) { - message = loggerConfig.Config[model].Default + message + message = defaultStr + message } file, err := os.OpenFile(path, os.O_CREATE|os.O_APPEND, 0666) if err != nil { @@ -97,12 +145,14 @@ type outputSettings struct { Config map[string]outputDriver `yaml:"config"` } type outputDriver struct { - Filename string `yaml:"filename"` - Filetype string `yaml:"filetype"` - Default string `yaml:"default"` - MaxAge string `yaml:"MaxAge"` - Info string `yaml:"info"` - Replace []string `yaml:"replace"` + Filename string `yaml:"filename"` + Filetype string `yaml:"filetype"` + Default string `yaml:"default"` + MaxAge string `yaml:"MaxAge"` + Body map[string]string `yaml:"body"` + Bottom string `yaml:"bottom"` + //Info string `yaml:"info"` + Replace []string `yaml:"replace"` } func LogFileMapInit() { diff --git a/web/controllers/ap/ap.go b/web/controllers/ap/ap.go index e8c5418..c890f83 100644 --- a/web/controllers/ap/ap.go +++ b/web/controllers/ap/ap.go @@ -682,10 +682,11 @@ func RegisterRoutes() { // RegisterUpdatePlanOrderVersion(planorderversion, "/update", serviceOfPlanOrderVersion.Update) // PlanOrderVersion获取发布确认信息 RegisterGetPlanOrderVersionPublishIdentifyMessage(planorderversion, "/publishidentify", serviceOfPlanOrderVersion.GetExistVersion) + RegisterGetPlanOrderVersionPublishIdentifyMessage(planorderversion, "/publishidentifyall", serviceOfPlanOrderVersion.GetExistVersionAll) + // PlanOrderVersion 再次发布 RegisterRelPublish(planorderversion, "/relpublish", serviceOfPlanOrderVersion.RelPublish) - // PlanOrder的路由组 planorder := party.Party("/planorder") // PlanOrder的服务实例