Browse Source

修改解析顺引999之后解析0

pull/216/head
zhangxin 2 years ago
parent
commit
82141fc5e5
3 changed files with 36 additions and 28 deletions
  1. +1
    -1
      dao/pln/ToyotaCalloff.dao.go
  2. +14
    -14
      dao/pln/implments/ToyotaCalloff.dao.impl.go
  3. +21
    -13
      services/pln/implments/ToyotaCalloff.service.impl.go

+ 1
- 1
dao/pln/ToyotaCalloff.dao.go View File

@ -256,7 +256,7 @@ type ToyotaCalloffDAO interface {
* @Date : 2022-01-27
*
******************************************************************************/
SelectMaxSeqCallOff(projectId string) (*model.ToyotaCalloff, error)
SelectMaxSeqCallOff() (*model.ToyotaCalloff, error)
}
/******************************************************************************


+ 14
- 14
dao/pln/implments/ToyotaCalloff.dao.impl.go View File

@ -273,16 +273,17 @@ func (impl *ToyotaCalloffDAOImplement) SelectAndPaging(paging *grmi.Paging, pred
return grmi.EmptyPagingResult, err
}
orderBy := " order by " + meta.ToyotaCalloff_PlantNr.ColumnName
if orderByFields != nil {
for _, field := range orderByFields {
if orderBy == " order by " {
orderBy += field.ColumnName
} else {
orderBy += ", " + field.ColumnName
}
}
}
//orderBy := " order by " + meta.ToyotaCalloff_PlantNr.ColumnName
//if orderByFields != nil {
// for _, field := range orderByFields {
// if orderBy == " order by " {
// orderBy += field.ColumnName
// } else {
// orderBy += ", " + field.ColumnName
// }
// }
//}
orderBy := " order by " + meta.ToyotaCalloff_OrderTime.SortColumnName + " desc "
parameters = append(parameters, paging.Offset(), paging.Size)
data := make([]model.ToyotaCalloff, 0, 10)
where = " where " + where
@ -347,12 +348,11 @@ func (impl *ToyotaCalloffDAOImplement) UpdateWhere(predicates []grmi.Predicate,
* @Reference LAPP_ACURA_MOM_BACKEND/dao/pln/ToyotaCalloffDAO.SelectMaxSeqCallOff
*
******************************************************************************/
func (impl *ToyotaCalloffDAOImplement) SelectMaxSeqCallOff(projectId string) (*model.ToyotaCalloff, error) {
func (impl *ToyotaCalloffDAOImplement) SelectMaxSeqCallOff() (*model.ToyotaCalloff, error) {
parameters := []interface{}{impl.plantNr, projectId, model.CALLOFF_STATUS_PARSED}
where := fmt.Sprintf("%s = ? and %s = ? and %s = ?",
parameters := []interface{}{impl.plantNr, model.CALLOFF_STATUS_PARSED}
where := fmt.Sprintf("%s = ? and %s = ?",
meta.ToyotaCalloff_PlantNr.ColumnName,
meta.ToyotaCalloff_ProjectId.ColumnName,
meta.ToyotaCalloff_Parsed.ColumnName)
var data model.ToyotaCalloff
ok, err := impl.session.Table(impl.meta.TableName).Where(where, parameters...).Desc(meta.ToyotaCalloff_CheckSequence.Name).Get(&data)


+ 21
- 13
services/pln/implments/ToyotaCalloff.service.impl.go View File

@ -588,7 +588,7 @@ func (impl *ToyotaCalloffServiceImplement) ParseCallOffData(user *global.User, p
if len(waitParseLi) == 0 {
log.Info("解析CallOff数据, 没有待解析的CallOff数据")
}
maxSeqCallOff, err := callOffDao.SelectMaxSeqCallOff(project.ProjectId)
maxSeqCallOff, err := callOffDao.SelectMaxSeqCallOff()
if err != nil {
log.Error("解析CallOff数据,获取已解析的最大连番号CallOff数据失败, error:" + err.Error())
return
@ -598,9 +598,15 @@ func (impl *ToyotaCalloffServiceImplement) ParseCallOffData(user *global.User, p
// log.Error("解析CallOff数据, 获取最大sortNr失败, error:" + err.Error())
// return
//}
var maxSeq int
var needParseSeq int
if maxSeqCallOff != nil {
maxSeq = maxSeqCallOff.CheckSequence
if maxSeqCallOff.CheckSequence == 999 {
needParseSeq = 0
} else {
needParseSeq = maxSeqCallOff.CheckSequence + 1
}
} else {
needParseSeq = -1
}
if err = session.Begin(); err != nil {
log.Error("解析CallOff数据, 开启事务失败, error:" + err.Error())
@ -622,13 +628,13 @@ func (impl *ToyotaCalloffServiceImplement) ParseCallOffData(user *global.User, p
log.Error("解析CallOff数据,删除已存在的错误数据失败, error:" + err.Error())
return
}
if maxSeq != 0 {
if callOffData.CheckSequence != maxSeq+1 {
if callOffData.CheckSequence != needParseSeq {
if callOffData.CheckSequence != needParseSeq+1 || (needParseSeq == 999 && callOffData.CheckSequence != 0) {
callOffError := model.ToyotaCallOffErrorLst{
DemandId: callOffData.DemandId,
Pos: 1,
ErrorType: model.ERROR_TYPE_HINT,
ErrorInfo: "连番号不连续,当前已解析的最大连番号为:" + strconv.Itoa(maxSeq) + ", 该连番号为:" + strconv.Itoa(callOffData.CheckSequence),
ErrorInfo: "连番号不连续,当前需要解析连番号为:" + strconv.Itoa(needParseSeq) + ", 该连番号为:" + strconv.Itoa(callOffData.CheckSequence),
ErrorStatus: model.ERROR_STATUS_ON,
}
err = callOffErrDao.InsertOne(&callOffError)
@ -639,10 +645,9 @@ func (impl *ToyotaCalloffServiceImplement) ParseCallOffData(user *global.User, p
}
break
}
} else {
maxSeq = callOffData.CheckSequence - 1
}
needParseSeq = callOffData.CheckSequence + 1
productFamily, exist := productFamilyMap[callOffData.ProductFamilyId]
if !exist {
productFamily, err = productFamilyDao.SelectOne(callOffData.ProductFamilyId)
@ -771,7 +776,6 @@ func (impl *ToyotaCalloffServiceImplement) ParseCallOffData(user *global.User, p
}
break
}
maxSeq++
callOffData.Parsed = model.CALLOFF_STATUS_PARSED
err = callOffDao.UpdateOne(&callOffData)
if err != nil {
@ -781,7 +785,7 @@ func (impl *ToyotaCalloffServiceImplement) ParseCallOffData(user *global.User, p
}
}
_ = session.Commit()
log.Info("解析CallOff数据任务执行完成,当前项目:"+project.ProjectId+", 最大MaxSeq:", strconv.Itoa(maxSeq-1))
log.Info("解析CallOff数据任务执行完成,当前项目:"+project.ProjectId+", 最大MaxSeq:", strconv.Itoa(needParseSeq-1))
return
}
@ -854,13 +858,17 @@ func (impl *ToyotaCalloffServiceImplement) AnalysisAgain(user *global.User, dema
if len(errorLi) != 0 {
return grmi.NewBusinessError("存在未修复的数据项错误")
}
doneCallOff, err := callOffDao.SelectMaxSeqCallOff(callOff.ProjectId)
doneCallOff, err := callOffDao.SelectMaxSeqCallOff()
if err != nil {
return grmi.NewBusinessError("查询已解析最大连番号CallOff数据失败, 错误:" + err.Error())
}
if doneCallOff != nil {
if callOff.CheckSequence != doneCallOff.CheckSequence+1 {
return grmi.NewBusinessError("当前连番号大于需要解析的连番号,需要解析连番号为:" + strconv.Itoa(doneCallOff.CheckSequence+1))
var needParseSequence int
if doneCallOff.CheckSequence != 999 {
needParseSequence = doneCallOff.CheckSequence + 1
}
if callOff.CheckSequence != needParseSequence {
return grmi.NewBusinessError("当前连番号大于需要解析的连番号,需要解析连番号为:" + strconv.Itoa(needParseSequence))
}
}
err = callOffErrDao.DeleteWhere([]grmi.Predicate{meta.ToyotaCallOffErrorLst_DemandId.NewPredicate(grmi.Equal, demandId)})


Loading…
Cancel
Save