|
|
@ -30,6 +30,7 @@ import ( |
|
|
|
var DefaultConditionOfReclinerReclst = grmi.NewCondition( |
|
|
|
map[string]grmi.ConditionItem{ |
|
|
|
meta.ReclinerReclst_RecNr.UrlParameterName: grmi.NewConditionItem(meta.ReclinerReclst_RecNr, grmi.Equal, true), |
|
|
|
meta.ReclinerReclst_RecType.UrlParameterName: grmi.NewConditionItem(meta.ReclinerReclst_RecType, grmi.Equal, true), |
|
|
|
meta.ReclinerReclst_Line.UrlParameterName: grmi.NewConditionItem(meta.ReclinerReclst_Line, grmi.Equal, true), |
|
|
|
meta.ReclinerReclst_ArtId.UrlParameterName: grmi.NewConditionItem(meta.ReclinerReclst_ArtId, grmi.Equal, false), |
|
|
|
meta.ReclinerReclst_SerialOrderId.UrlParameterName: grmi.NewConditionItem(meta.ReclinerReclst_SerialOrderId, grmi.Equal, false), |
|
|
@ -136,6 +137,8 @@ func (impl *ReclinerReclstServiceImplement) InsertOne(user *models.Usertab, enti |
|
|
|
artId = artIds[0] |
|
|
|
} |
|
|
|
entity.ArtId = artId |
|
|
|
entity.RecType = model.QM_REC_TYPE |
|
|
|
entity.Status = "N" |
|
|
|
err = dao.InsertOne(entity) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
@ -143,6 +146,130 @@ func (impl *ReclinerReclstServiceImplement) InsertOne(user *models.Usertab, enti |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
/****************************************************************************** |
|
|
|
* |
|
|
|
* @Reference LAPP_GAAS_GFrame_BACKEND/services/qm/ReclinerReclstService.InsertSeriOne |
|
|
|
* |
|
|
|
******************************************************************************/ |
|
|
|
func (impl *ReclinerReclstServiceImplement) InsertSeriOne(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() |
|
|
|
dao := dal.NewReclinerReclstDAO(session, user.Pid, user.Userid) |
|
|
|
seriDao := omDal.NewSerialOrderDAO(session, user.Pid, user.Userid) |
|
|
|
seriInfo, err := seriDao.SelectBySerialOrder(entity.SerialOrderId) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
if seriInfo == nil { |
|
|
|
return grmi.NewBusinessError("不存在指定记录!") |
|
|
|
} |
|
|
|
if seriInfo.PlanResourceId != "G-Frame Assy" { |
|
|
|
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 |
|
|
|
entity.Line = seriInfo.PlanResourceId |
|
|
|
entity.RecType = model.QM_SERI_TYPE |
|
|
|
entity.Status = "N" |
|
|
|
if len(orderId) < 27{ |
|
|
|
return grmi.NewBusinessError("序列订单长度错误!") |
|
|
|
} |
|
|
|
entity.ReclinerNr = orderId[0:19] + "R" + orderId[20:27] |
|
|
|
err = dao.InsertOne(entity) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
/****************************************************************************** |
|
|
|
* |
|
|
|
* @Reference LAPP_GAAS_GFrame_BACKEND/services/qm/ReclinerReclstService.SelectSeriOne |
|
|
|
* |
|
|
|
******************************************************************************/ |
|
|
|
func (impl *ReclinerReclstServiceImplement) SelectSeriOne(user *models.Usertab, orderId string) (*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() |
|
|
|
seriDao := omDal.NewSerialOrderDAO(session, user.Pid, user.Userid) |
|
|
|
seriInfo, err := seriDao.SelectBySerialOrder(orderId) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
if seriInfo == nil { |
|
|
|
return nil, grmi.NewBusinessError("不存在指定记录!") |
|
|
|
} |
|
|
|
if seriInfo.PlanResourceId != "G-Frame Assy" { |
|
|
|
return nil, grmi.NewBusinessError("该产线不是装配线!") |
|
|
|
} |
|
|
|
bDao := baseDal.NewLabelParserHeadDAO(session, user.Pid, user.Userid) |
|
|
|
result, err := bDao.SelectOne("Barcode") |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
entity := new(model.ReclinerReclst) |
|
|
|
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 nil, err |
|
|
|
} |
|
|
|
result.Valst = list |
|
|
|
if len(orderId) < result.Length { |
|
|
|
return nil, grmi.NewBusinessError("序列订单错误!") |
|
|
|
} |
|
|
|
codeInfos := bmodel.ParseBarcode(orderId, result.Valst) |
|
|
|
artId = codeInfos["artId"] |
|
|
|
} else { |
|
|
|
artIds := strings.Split(orderId, result.Split) |
|
|
|
artId = artIds[0] |
|
|
|
} |
|
|
|
entity.PlantNr = user.Pid |
|
|
|
entity.ArtId = artId |
|
|
|
entity.SerialOrderId = orderId |
|
|
|
entity.Line = seriInfo.PlanResourceId |
|
|
|
entity.RecType = model.QM_SERI_TYPE |
|
|
|
if len(orderId) < 27{ |
|
|
|
return nil, grmi.NewBusinessError("序列订单长度错误!") |
|
|
|
} |
|
|
|
entity.ReclinerNr = orderId[0:19] + "R" + orderId[20:27] |
|
|
|
return entity, nil |
|
|
|
} |
|
|
|
|
|
|
|
/****************************************************************************** |
|
|
|
* |
|
|
|
* @Reference LAPP_GAAS_GFrame_BACKEND/services/qm/ReclinerReclstService.AddPrinterInfo |
|
|
@ -192,7 +319,7 @@ func (impl *ReclinerReclstServiceImplement) AddPrinterInfo(user *models.Usertab, |
|
|
|
snr := new(models.Snrtab) |
|
|
|
snr.Finr = bmodel.PlantNr |
|
|
|
snr.Snrid = "PrintId" |
|
|
|
headId,err := snr.GetNextSnr("PrintId") |
|
|
|
headId, err := snr.GetNextSnr("PrintId") |
|
|
|
if err != nil { |
|
|
|
fmt.Println(err) |
|
|
|
return grmi.NewBusinessError("打印头部生成错误!") |
|
|
@ -246,6 +373,108 @@ func (impl *ReclinerReclstServiceImplement) AddPrinterInfo(user *models.Usertab, |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************** |
|
|
|
* |
|
|
|
* @Reference LAPP_GAAS_GFrame_BACKEND/services/qm/ReclinerReclstService.CreatePackOrderPrintInfo |
|
|
|
* |
|
|
|
******************************************************************************/ |
|
|
|
func (impl *ReclinerReclstServiceImplement) CreateRecPrintInfo(entity model.ReclinerReclst) error { |
|
|
|
|
|
|
|
engine := db.Eloquent.Master() |
|
|
|
session := engine.NewSession() |
|
|
|
defer session.Close() |
|
|
|
|
|
|
|
templateId := "TSC-BARCODE" |
|
|
|
dao := baseDal.NewLabelTemplateHeadDAO(session, bmodel.PlantNr, "Rec") |
|
|
|
result, err := dao.SelectOne(templateId) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
lstdao := baseDal.NewLabelTemplateDetailDAO(session, bmodel.PlantNr, "Rec") |
|
|
|
list, err := lstdao.Select([]grmi.Predicate{ |
|
|
|
bmeta.LabelTemplateDetail_LabelTemplateId.NewPredicate(grmi.Equal, templateId), |
|
|
|
}, nil) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
result.LabelTemplateDetail = list |
|
|
|
|
|
|
|
//查询物料主数据表
|
|
|
|
artDao := baseDal.NewArticleDAO(session, bmodel.PlantNr, "Rec") |
|
|
|
artInfo, err := artDao.SelectOne(entity.ArtId) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
if artInfo == nil { |
|
|
|
return grmi.NewBusinessError("客户订单号没有维护!") |
|
|
|
} |
|
|
|
//查询序列订单表
|
|
|
|
orderDao := omDal.NewSerialOrderDAO(session, bmodel.PlantNr, "Rec") |
|
|
|
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.NewLabelHeadDAO(session, bmodel.PlantNr, "Rec") |
|
|
|
head := new(bmodel.LabelHead) |
|
|
|
head.PlantNr = result.PlantNr |
|
|
|
head.LabelId = headId |
|
|
|
head.Status = 0 |
|
|
|
head.LabelTemplateId = result.LabelTemplateId |
|
|
|
head.PrinterId = result.PrinterId |
|
|
|
head.PrintQty = 1 |
|
|
|
head.BusinessObjType = "BACK" |
|
|
|
head.BusinessObjId = entity.SerialOrderId |
|
|
|
err = headDao.InsertOne(head) |
|
|
|
if err != nil { |
|
|
|
session.Rollback() |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
detailDao := baseDal.NewLabelDetailDAO(session, bmodel.PlantNr, "Rec") |
|
|
|
for k, v := range list { |
|
|
|
detail := new(bmodel.LabelDetail) |
|
|
|
head.PlantNr = result.PlantNr |
|
|
|
detail.LabelId = headId |
|
|
|
detail.Pos = (k + 1) |
|
|
|
detail.VariableName = v.LabelItemValue |
|
|
|
//映射值
|
|
|
|
if detail.VariableName == "$SN$" { |
|
|
|
detail.VariableValue = entity.SerialOrderId |
|
|
|
} else if detail.VariableName == "$DATE$" { |
|
|
|
dateStr := utils.TimeFormat(orderInfo.PlanStartTime.Restore(), "yyyy/MM/dd") |
|
|
|
detail.VariableValue = dateStr |
|
|
|
} else if detail.VariableName == "$CUSTID$" { |
|
|
|
detail.VariableValue = artInfo.AlternativeArtId |
|
|
|
} else if detail.VariableName == "$ORDERID$" { |
|
|
|
detail.VariableValue = 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 |
|
|
@ -445,3 +674,43 @@ func (impl *ReclinerReclstServiceImplement) Update(user *models.Usertab, entitie |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************** |
|
|
|
* |
|
|
|
* @Reference LAPP_GAAS_GFrame_BACKEND/services/log/PackOrderService.SelectUnPrint |
|
|
|
* |
|
|
|
******************************************************************************/ |
|
|
|
func (impl *ReclinerReclstServiceImplement) SelectUnPrint(num int) ([]model.ReclinerReclst, error) { |
|
|
|
engine := db.Eloquent.Master() |
|
|
|
session := engine.NewSession() |
|
|
|
defer session.Close() |
|
|
|
dao := dal.NewReclinerReclstDAO(session, bmodel.PlantNr, "Rec") |
|
|
|
if num < 1 { |
|
|
|
num = 50 |
|
|
|
} |
|
|
|
result, err := dao.SelectUnPrint(num) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return result, nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/****************************************************************************** |
|
|
|
* |
|
|
|
* @Reference LAPP_GAAS_GFrame_BACKEND/services/log/PackOrderService.UpdateUnPrint |
|
|
|
* |
|
|
|
******************************************************************************/ |
|
|
|
func (impl *ReclinerReclstServiceImplement) UpdateUnPrint(recIds []int) error { |
|
|
|
engine := db.Eloquent.Master() |
|
|
|
session := engine.NewSession() |
|
|
|
defer session.Close() |
|
|
|
dao := dal.NewReclinerReclstDAO(session, bmodel.PlantNr, "Rec") |
|
|
|
err := dao.UpdateUnPrint(recIds) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |