diff --git a/services/me/implments/Product.service.impl.go b/services/me/implments/Product.service.impl.go index 889af40..8c50866 100644 --- a/services/me/implments/Product.service.impl.go +++ b/services/me/implments/Product.service.impl.go @@ -13,6 +13,7 @@ import ( meta "LAPP_ACURA_MOM_BACKEND/meta/me" baseModel "LAPP_ACURA_MOM_BACKEND/models/base" model "LAPP_ACURA_MOM_BACKEND/models/me" + "fmt" ) /****************************************************************************** @@ -708,6 +709,9 @@ func (impl *ProductServiceImplement) GenerateSnr(user *global.User, productId st if product == nil { return grmi.NewBusinessError("总成不存在") } + if product.MachineCode == "" { + return grmi.NewBusinessError(fmt.Sprintf("总成%s的机种代码为空", product.ProductId)) + } snrDao := baseDal.NewSnrDAO(session, user.PlantNr, user.UserId) snr, err := snrDao.SelectOne(conf.DbConfig.StandardSerialOrderSnr) if err != nil { @@ -717,9 +721,20 @@ func (impl *ProductServiceImplement) GenerateSnr(user *global.User, productId st return grmi.NewBusinessError("标准流水号不存在") } newSnr := snr - snrId := productId + "_" + projectId + "_SerialOrderSnr" - newSnr.SnrId = snrId + snrId := product.MachineCode + "_SerialOrderSnr" product.SerialOrderSnr = snrId + existSnr, err := snrDao.SelectOne(snrId) + if err != nil { + return grmi.NewBusinessError("查询流水号失败, 错误:" + err.Error()) + } + if existSnr != nil { + err = dao.UpdateOne(product) + if err != nil { + return grmi.NewBusinessError("更新总成数据失败, 错误:" + err.Error()) + } + return nil + } + newSnr.SnrId = snrId if err = session.Begin(); err != nil { return grmi.NewBusinessError("开启事务失败, 错误:" + err.Error()) } @@ -739,6 +754,4 @@ func (impl *ProductServiceImplement) GenerateSnr(user *global.User, productId st return grmi.NewBusinessError("保存流水号失败,错误:" + err.Error()) } return nil - - } \ No newline at end of file