Browse Source

Merge pull request '批量导入维护客户物料关系' (#283) from fix_blukInsertArt into develop

Reviewed-on: http://101.201.121.115:3000/leo/LAPP_CHEERSSON_BACKEND/pulls/283
pull/284/head
zhangxin 3 years ago
parent
commit
081bccefac
1 changed files with 28 additions and 9 deletions
  1. +28
    -9
      services/ap/implments/CustDemandVerHead.service.impl.go

+ 28
- 9
services/ap/implments/CustDemandVerHead.service.impl.go View File

@ -1534,7 +1534,7 @@ func (impl *CustDemandVerHeadServiceImplement) BulkImportFile(user *global.User,
//记录版本信息
var headVersionId string
//物料 查询
articleMap := make(map[string]int)
articleMap := make(map[string]*baseModel.Article)
articleDao := basedal.NewArticleDAO(session, user.PlantNr, user.UserId)
bomDao := meDal.NewBomHeadDAO(session, user.PlantNr, user.UserId)
for k, row := range rows {
@ -1551,7 +1551,10 @@ func (impl *CustDemandVerHeadServiceImplement) BulkImportFile(user *global.User,
//判断物料bom是否需要维护
if _, ok := articleMap[ArtId]; !ok {
//查询物料
_article, _ := articleDao.SelectOne(ArtId)
_article, err := articleDao.SelectOne(ArtId)
if err != nil {
return err
}
if _article == nil {
errInfo := new(model.ErrorDatalst)
errInfo.ErrorInfo = "物料不存在 物料编号:" + ArtId
@ -1559,11 +1562,14 @@ func (impl *CustDemandVerHeadServiceImplement) BulkImportFile(user *global.User,
errInfo.ErrorStatus = "error"
errInfo.TargetSource = savePath
_ = errDao.InsertOne(errInfo)
articleMap[ArtId] = 1
continue
} else {
if _article.ArtSize1 != "1" {
//查询bom
_bom, _ := bomDao.SelectOne(ArtId)
_bom, err := bomDao.SelectOne(ArtId)
if err != nil {
return err
}
if _bom == nil {
errInfo := new(model.ErrorDatalst)
errInfo.ErrorInfo = "bom未配置 物料编号:" + ArtId
@ -1571,12 +1577,10 @@ func (impl *CustDemandVerHeadServiceImplement) BulkImportFile(user *global.User,
errInfo.ErrorStatus = "error"
errInfo.TargetSource = savePath
_ = errDao.InsertOne(errInfo)
articleMap[ArtId] = 1
}
}
}
articleMap[ArtId] = 2
articleMap[ArtId] = _article
}
//判断客户是否存在
customerId := utils.ValueToString(row[2], "")
@ -1677,10 +1681,25 @@ func (impl *CustDemandVerHeadServiceImplement) BulkImportFile(user *global.User,
errInfo := new(model.ErrorDatalst)
errInfo.ErrorInfo = fmt.Sprintf("客户%s物料号%s没有维护!", custInfo.CustomerId, ArtId)
errInfo.ErrorType = "BulkImportFile"
errInfo.ErrorStatus = "error"
errInfo.ErrorStatus = "ok"
errInfo.TargetSource = savePath
_ = errDao.InsertOne(errInfo)
continue
//插入客户物料维护关系
if val, ok := articleMap[ArtId]; ok {
//插入客户物料维护关系
artCust := new(model.CustArtlst)
artCust.PlantNr = user.PlantNr
artCust.ArtId = ArtId
artCust.CustomerId = customerId
artCust.Descr1 = val.Descr1
artCust.Descr2 = val.Descr2
artCust.CustArtId = val.CustArtId
err = artListDao.InsertOne(artCust)
if err != nil {
return err
}
artInfo = artCust
}
}
//数据长度:保存多少周的数据
lenData := mInfo.DemandWeeks


Loading…
Cancel
Save