Browse Source

Merge branch 'develop' of http://101.201.121.115:3000/leo/LAPP_CHEERSSON_BACKEND into feature_mps_2

pull/242/head
DESKTOP-4672LME\Xu Tengfei 3 years ago
parent
commit
953b9d8634
3 changed files with 120 additions and 18 deletions
  1. +9
    -9
      models/ap/ap.go
  2. +21
    -9
      services/ap/implments/Balance.service.impl.go
  3. +90
    -0
      services/base/implments/Article.service.impl.go

+ 9
- 9
models/ap/ap.go View File

@ -238,15 +238,15 @@ type ArtStockAndResource struct {
type ArticleDemandData struct {
ArtId string
Desc string
OpeningInventory float64
OutSourcingQty float64
IndependentDemandQty float64
WipQty float64
SFGStockQty float64
OutsourcingCriticalWip float64
FgCriticalWip float64
SfgWip float64
OurtsourcingWip float64
OpeningInventory float64 //成品库存
OutSourcingQty float64 //采购量
IndependentDemandQty float64 //独立需求
WipQty float64 //在制量
SFGStockQty float64 //成品关键在制
OutsourcingCriticalWip float64 //委外在制
FgCriticalWip float64 //委外关键在制
SfgWip float64 //半成品库存
OurtsourcingWip float64 //在制冲压
DemandQtyLi []QtyData
ProductQtyLi []QtyData
}


+ 21
- 9
services/ap/implments/Balance.service.impl.go View File

@ -3649,11 +3649,19 @@ func (impl *BalanceServiceImplement) MpsPlanExport(user *global.User, CustArtSto
}
}
}
//daoArticle := dal_base.NewArticleDAO(session, user.PlantNr, user.UserId)
//articleLi, err := daoArticle.Select([]grmi.Predicate{meta_base.Article_ArtId.NewPredicate(grmi.Include, artIdLi...)}, nil)
//if err != nil {
// return "", grmi.NewBusinessError("查询物料数据失败, 错误:" + err.Error())
//}
//查询物料库存,在制库存,采购量
daoArticleStock := dal_base.NewArticleStockDAO(session, user.PlantNr, user.UserId)
articleStockList, err := daoArticleStock.Select([]grmi.Predicate{}, nil)
if err != nil {
return "", grmi.NewBusinessError("查询物料数据失败, 错误:" + err.Error())
}
articleStockMap := make(map[string]model_base.ArticleStock)
for _,v := range articleStockList{
key := v.ArtId
articleStockMap[key] = v
}
if len(articleLi) != len(artIdLi) {
return "", grmi.NewBusinessError("需要导出的物料不是都存在")
}
@ -3723,9 +3731,16 @@ func (impl *BalanceServiceImplement) MpsPlanExport(user *global.User, CustArtSto
artDemandData.OurtsourcingWip = val.OurtsourcingWip
artDemandData.SFGStockQty = val.SFGStock
}
stockInfo,ok := articleStockMap[artId]
if ok {
artDemandData.OpeningInventory = stockInfo.FGQty
artDemandData.WipQty = stockInfo.WIPQty
artDemandData.OutSourcingQty = stockInfo.PUCQty
}
artDemandData.ArtId = artId
artDemandData.Desc = artDescMap[artId]
artDemandData.OpeningInventory = artOpeningInventoryMap[artId]
for _, demandKey := range demandKeyLi {
artDemandLi, exist := demandKeyMap[demandKey.(string)]
var demandQty model.QtyData
@ -3743,9 +3758,6 @@ func (impl *BalanceServiceImplement) MpsPlanExport(user *global.User, CustArtSto
qty = qty + artDemand.IndependentDemandQty - artDemand.OutSourcingQty- artDemand.WipQty
demandQty.Qty += qty
productQty.Qty += artDemand.NetDemandQty
artDemandData.OutSourcingQty += artDemand.OutSourcingQty
artDemandData.OpeningInventory += artDemandData.OpeningInventory
artDemandData.WipQty += artDemand.WipQty
}
}
artDemandData.DemandQtyLi = append(artDemandData.DemandQtyLi, demandQty)


+ 90
- 0
services/base/implments/Article.service.impl.go View File

@ -3,6 +3,9 @@
package implments
import (
"errors"
"fmt"
"github.com/360EntSecGroup-Skylar/excelize"
dalAp "leit.com/LAPP_CHEERSSON_BACKEND/dao/ap"
dal "leit.com/LAPP_CHEERSSON_BACKEND/dao/base"
dalMe "leit.com/LAPP_CHEERSSON_BACKEND/dao/me"
@ -14,6 +17,7 @@ import (
model "leit.com/LAPP_CHEERSSON_BACKEND/models/base"
modelMe "leit.com/LAPP_CHEERSSON_BACKEND/models/me"
"leit.com/LAPP_CHEERSSON_BACKEND/utils"
"strings"
)
/******************************************************************************
@ -691,3 +695,89 @@ func (impl *ArticleServiceImplement) Update(user *global.User, entities *[]model
}
return nil
}
/******************************************************************************
*
* @Reference leit.com/LAPP_CHEERSSON_BACKEND/services/ap/CustDemandVerHeadService.ImportArtcleLockWeekFile
*
******************************************************************************/
func (impl *ArticleServiceImplement) ImportArtcleLockWeekFile(user *global.User, savePath string) error {
grmi.Log(user, "/services/ap/implments/Article.service.impl.go", "ImportArtcleFile", "导入物料吸收期文件")
engine := db.Eloquent.Master()
session := engine.NewSession()
defer session.Close()
dao := dal.NewArticleDAO(session, user.PlantNr, user.UserId)
daoAp := dalAp.NewArticleStockLevelDAO(session, user.PlantNr, user.UserId)
//第一步:读取文件,构造一个map数组
xlsx, err := excelize.OpenFile(savePath)
if err != nil {
return grmi.NewBusinessError("打开文件错误!")
}
rows := xlsx.GetRows("物料参数")
for k, row := range rows {
if k == 0 {
continue
}
//开启session
err = session.Begin()
if err != nil{
return err
}
//判断客户是否相同,不相同continue
ArtId := strings.TrimSpace(utils.ValueToString(row[0], ""))
lockWeek := strings.TrimSpace(utils.ValueToString(row[1], ""))
smallStockWeek := strings.TrimSpace(utils.ValueToString(row[2], ""))
targetStockWeek := strings.TrimSpace(utils.ValueToString(row[3], ""))
//查询物料信息
artInfo,err := dao.SelectOne(ArtId)
if err != nil{
session.Rollback()
return err
}
if artInfo == nil{
session.Rollback()
return errors.New(fmt.Sprintf("物料编号:%s没有维护",ArtId))
}
artInfo.DeliveryBuffer = utils.ValueToFloat(lockWeek,0.0)
err = dao.UpdateOne(artInfo)
if err != nil {
session.Rollback()
return err
}
//更新吸收期
lockArt,err := daoAp.SelectOne(ArtId)
if lockArt == nil{
stockArt := new(modelAp.ArticleStockLevel)
stockArt.PlantNr = user.PlantNr
stockArt.Descr = artInfo.Descr1
stockArt.ArtId = ArtId
stockArt.MaxCoverPeriod = utils.ValueToFloat(targetStockWeek,0.0)
stockArt.MinCoverPeriod =utils.ValueToFloat(smallStockWeek,0.0)
stockArt.MaxCoverPeriodType = "W"
stockArt.MinCoverPeriodType = "W"
err = daoAp.InsertOne(stockArt)
if err != nil {
session.Rollback()
return err
}
}else{
lockArt.MaxCoverPeriod = utils.ValueToFloat(targetStockWeek,0.0)
lockArt.MinCoverPeriod =utils.ValueToFloat(smallStockWeek,0.0)
lockArt.MaxCoverPeriodType = "W"
lockArt.MinCoverPeriodType = "W"
err := daoAp.UpdateOne(lockArt)
if err != nil {
session.Rollback()
return err
}
}
session.Commit()
}
return nil
}

Loading…
Cancel
Save