|
|
@ -4,11 +4,18 @@ package implments |
|
|
|
|
|
|
|
import ( |
|
|
|
dal "LAPP_GAAS_GFrame_BACKEND/dao/qm" |
|
|
|
baseDal "LAPP_GAAS_GFrame_BACKEND/dao/base" |
|
|
|
omDal "LAPP_GAAS_GFrame_BACKEND/dao/om" |
|
|
|
"LAPP_GAAS_GFrame_BACKEND/db" |
|
|
|
"LAPP_GAAS_GFrame_BACKEND/grmi" |
|
|
|
meta "LAPP_GAAS_GFrame_BACKEND/meta/qm" |
|
|
|
bmeta "LAPP_GAAS_GFrame_BACKEND/meta/base" |
|
|
|
model "LAPP_GAAS_GFrame_BACKEND/models/qm" |
|
|
|
bmodel "LAPP_GAAS_GFrame_BACKEND/models/base" |
|
|
|
"LAPP_GAAS_GFrame_BACKEND/utils" |
|
|
|
"LAPP_GAAS_GFrame_BACKEND/web/models" |
|
|
|
"fmt" |
|
|
|
"strings" |
|
|
|
) |
|
|
|
|
|
|
|
/****************************************************************************** |
|
|
@ -103,6 +110,32 @@ func (impl *ReclinerReclstServiceImplement) InsertOne(user *models.Usertab, enti |
|
|
|
if record != nil { |
|
|
|
return grmi.NewBusinessError("已经存在相同主键的记录!") |
|
|
|
} |
|
|
|
bDao := baseDal.NewLabelParserHeadDAO(session, user.Pid, user.Userid) |
|
|
|
result, err := bDao.SelectOne("Barcode") |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
orderId := entity.SerialOrderId |
|
|
|
var artId string |
|
|
|
if utils.ValueIsEmpty(result.Split) { |
|
|
|
lstdao := baseDal.NewLabelParserDetailLstDAO(session, user.Pid, user.Userid) |
|
|
|
list, err := lstdao.Select([]grmi.Predicate{ |
|
|
|
bmeta.LabelParserDetailLst_ParserId.NewPredicate(grmi.Equal, "Barcode"), |
|
|
|
}, nil) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
result.Valst = list |
|
|
|
if len(orderId) < result.Length { |
|
|
|
return grmi.NewBusinessError("序列订单错误!") |
|
|
|
} |
|
|
|
codeInfos := bmodel.ParseBarcode(orderId, result.Valst) |
|
|
|
artId = codeInfos["artId"] |
|
|
|
} else { |
|
|
|
artIds := strings.Split(orderId, result.Split) |
|
|
|
artId = artIds[0] |
|
|
|
} |
|
|
|
entity.ArtId = artId |
|
|
|
err = dao.InsertOne(entity) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
@ -110,6 +143,109 @@ func (impl *ReclinerReclstServiceImplement) InsertOne(user *models.Usertab, enti |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
/****************************************************************************** |
|
|
|
* |
|
|
|
* @Reference LAPP_GAAS_GFrame_BACKEND/services/qm/ReclinerReclstService.AddPrinterInfo |
|
|
|
* |
|
|
|
******************************************************************************/ |
|
|
|
func (impl *ReclinerReclstServiceImplement) AddPrinterInfo(user *models.Usertab, entity *model.ReclinerReclst) error { |
|
|
|
|
|
|
|
grmi.Log(user, "/services/qm/implments/ReclinerReclst.service.impl.go", "InsertOneReclinerReclst", "插入一个ReclinerReclst") |
|
|
|
|
|
|
|
engine := db.Eloquent.Master() |
|
|
|
session := engine.NewSession() |
|
|
|
defer session.Close() |
|
|
|
|
|
|
|
templateId := "TSC-BARCODE" |
|
|
|
dao := baseDal.NewPrinterTemplateDAO(session, user.Pid, user.Userid) |
|
|
|
result, err := dao.SelectOne(templateId) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
lstdao := baseDal.NewPrinterTemplateLstDAO(session, user.Pid, user.Userid) |
|
|
|
list, err := lstdao.Select([]grmi.Predicate{ |
|
|
|
bmeta.PrinterTemplateLst_TemplateId.NewPredicate(grmi.Equal, templateId), |
|
|
|
}, nil) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
result.PrinterTemplateLst = list |
|
|
|
|
|
|
|
//查询物料主数据表
|
|
|
|
artDao := baseDal.NewArticleDAO(session, user.Pid, user.Userid) |
|
|
|
artInfo, err := artDao.SelectOne(entity.ArtId) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
if artInfo == nil { |
|
|
|
return grmi.NewBusinessError("客户订单号没有维护!") |
|
|
|
} |
|
|
|
//查询序列订单表
|
|
|
|
orderDao := omDal.NewSerialOrderDAO(session, user.Pid, user.Userid) |
|
|
|
orderInfo, err := orderDao.SelectBySerialOrder(entity.SerialOrderId) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
if orderInfo == nil { |
|
|
|
return grmi.NewBusinessError("序列订单订单不存在!") |
|
|
|
} |
|
|
|
snr := new(models.Snrtab) |
|
|
|
snr.Finr = bmodel.PlantNr |
|
|
|
snr.Snrid = "PrintId" |
|
|
|
headId,err := snr.GetNextSnr("PrintId") |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err) |
|
|
|
return grmi.NewBusinessError("打印头部生成错误!") |
|
|
|
} |
|
|
|
|
|
|
|
// add Begin() before any action
|
|
|
|
if err := session.Begin(); err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
headDao := baseDal.NewPrintHeadDAO(session, user.Pid, user.Userid) |
|
|
|
head := new(bmodel.PrintHead) |
|
|
|
head.PlantNr = result.PlantNr |
|
|
|
head.PrintHeadId = headId |
|
|
|
head.Status = "N" |
|
|
|
head.TemplateFile = result.TemplateFile |
|
|
|
head.PrinterId = result.PrinterId |
|
|
|
head.PrintCopies = 1 |
|
|
|
head.PrintFileType = result.TemplateTye |
|
|
|
err = headDao.InsertOne(head) |
|
|
|
if err != nil { |
|
|
|
session.Rollback() |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
detailDao := baseDal.NewPrintDetailDAO(session, user.Pid, user.Userid) |
|
|
|
for k, v := range list { |
|
|
|
detail := new(bmodel.PrintDetail) |
|
|
|
head.PlantNr = result.PlantNr |
|
|
|
detail.PrintHeadId = headId |
|
|
|
detail.Pos = (k + 1) |
|
|
|
detail.VarName = v.VarName |
|
|
|
//映射值
|
|
|
|
if detail.VarName == "$SN$" { |
|
|
|
detail.VarValue = entity.SerialOrderId |
|
|
|
} else if detail.VarName == "$DATE$" { |
|
|
|
dateStr := utils.TimeFormat(orderInfo.PlanStartTime.Restore(), "yyyy/MM/dd") |
|
|
|
detail.VarValue = dateStr |
|
|
|
} else if detail.VarName == "$CUSTID$" { |
|
|
|
detail.VarValue = artInfo.CustArtId |
|
|
|
} else if detail.VarName == "$ORDERID$" { |
|
|
|
detail.VarValue = entity.SerialOrderId |
|
|
|
} |
|
|
|
|
|
|
|
err = detailDao.InsertOne(detail) |
|
|
|
if err != nil { |
|
|
|
session.Rollback() |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
session.Commit() |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
/****************************************************************************** |
|
|
|
* |
|
|
|
* @Reference LAPP_GAAS_GFrame_BACKEND/services/qm/ReclinerReclstService.DeleteOne |
|
|
|