by Robin at 20240226;

This commit is contained in:
Leufolium 2024-02-26 08:26:21 +08:00
parent 6fb4fe002e
commit d0017528b0
1 changed files with 55 additions and 108 deletions

View File

@ -140,34 +140,21 @@ func (s *CronService) CreateDailyStatement(ctx context.Context, param *xxl.RunRe
func (s *CronService) ImageAuditBatch(ctx context.Context, param *xxl.RunReq) (msg string) {
logger.Info("task %v param: %v log_id: %v", param.ExecutorHandler, param.ExecutorParams, xxl.Int64ToStr(param.LogID))
handleMsg := &strings.Builder{}
xxlJobLog := &dbstruct.XxlJobLog{
Id: goproto.Int64(param.LogID),
// 刷新批次号
batchId := imageaudit.RefreshBatchId()
// 执行图像审核
successNum, failNum, err := imageaudit.Run(batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, image audit tasks of this batchId have failed, successNum: %v, failNum: %v, err :%v ; ", batchId, successNum, failNum, err))
} else {
handleMsg.WriteString(fmt.Sprintf("batchId : %v, image audit tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
}
// 同步图像审核结果
err = DefaultService.utilSyncImageAuditTaskResultByBatchId(&gin.Context{}, batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, image audit tasks of this batchId have failed to syncronize, err :%v", batchId, err))
}
go func() {
// 刷新批次号
batchId := imageaudit.RefreshBatchId()
// 执行图像审核
successNum, failNum, err := imageaudit.Run(batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, image audit tasks of this batchId have failed, successNum: %v, failNum: %v, err :%v ; ", batchId, successNum, failNum, err))
} else {
handleMsg.WriteString(fmt.Sprintf("batchId : %v, image audit tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
}
// 同步图像审核结果
err = DefaultService.utilSyncImageAuditTaskResultByBatchId(&gin.Context{}, batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, image audit tasks of this batchId have failed to syncronize, err :%v", batchId, err))
}
if handleMsg.Cap() > 0 {
xxlJobLog.HandleMsg = goproto.String(handleMsg.String())
err1 := _DefaultXxlJob.UpdateXxlJobLog(&gin.Context{}, xxlJobLog)
if err1 != nil {
logger.Error("UpdateXxlJobLog fail, err: %v", err1)
}
}
}()
logger.Info("Image audit batch ends...")
return handleMsg.String()
@ -176,34 +163,20 @@ func (s *CronService) ImageAuditBatch(ctx context.Context, param *xxl.RunReq) (m
func (s *CronService) ImageAuditBatchHis(ctx context.Context, param *xxl.RunReq) (msg string) {
logger.Info("task %v param: %v log_id: %v", param.ExecutorHandler, param.ExecutorParams, xxl.Int64ToStr(param.LogID))
handleMsg := &strings.Builder{}
xxlJobLog := &dbstruct.XxlJobLog{
Id: goproto.Int64(param.LogID),
// 刷新批次号
batchId := imageaudit.RefreshBatchId()
// 执行图像审核
successNum, failNum, err := imageaudit.Run(batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, image audit tasks of this batchId have failed, successNum: %v, failNum: %v, err :%v ; ", batchId, successNum, failNum, err))
} else {
handleMsg.WriteString(fmt.Sprintf("batchId : %v, image audit tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
}
// 同步图像审核结果
err = DefaultService.utilSyncImageAuditTaskResultByBatchId(&gin.Context{}, batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, image audit tasks of this batchId have failed to syncronize, err :%v", batchId, err))
}
go func() {
// 刷新批次号
batchId := imageaudit.RefreshBatchId()
// 执行图像审核
successNum, failNum, err := imageaudit.Run(batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, image audit tasks of this batchId have failed, successNum: %v, failNum: %v, err :%v ; ", batchId, successNum, failNum, err))
} else {
handleMsg.WriteString(fmt.Sprintf("batchId : %v, image audit tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
}
// 同步图像审核结果
err = DefaultService.utilSyncImageAuditTaskResultByBatchId(&gin.Context{}, batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, image audit tasks of this batchId have failed to syncronize, err :%v", batchId, err))
}
if handleMsg.Cap() > 0 {
xxlJobLog.HandleMsg = goproto.String(handleMsg.String())
err1 := _DefaultXxlJob.UpdateXxlJobLog(&gin.Context{}, xxlJobLog)
if err1 != nil {
logger.Error("UpdateXxlJobLog fail, err: %v", err1)
}
}
}()
logger.Info("Image audit batch ends...")
return handleMsg.String()
@ -212,34 +185,21 @@ func (s *CronService) ImageAuditBatchHis(ctx context.Context, param *xxl.RunReq)
func (s *CronService) TextAuditBatch(ctx context.Context, param *xxl.RunReq) (msg string) {
logger.Info("task %v param: %v log_id: %v", param.ExecutorHandler, param.ExecutorParams, xxl.Int64ToStr(param.LogID))
handleMsg := &strings.Builder{}
xxlJobLog := &dbstruct.XxlJobLog{
Id: goproto.Int64(param.LogID),
// 刷新批次号
batchId := textaudit.RefreshBatchId()
// 执行文字审核
successNum, failNum, err := textaudit.Run(batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, text audit tasks of this batchId have failed, successNum: %v, failNum: %v, err :%v", batchId, successNum, failNum, err))
} else {
handleMsg.WriteString(fmt.Sprintf("batchId : %v, text audit tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
}
// 同步文字审核结果
err = DefaultService.utilSyncTextAuditTaskResultByBatchId(&gin.Context{}, batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, text audit tasks of this batchId have failed to syncronize, err :%v", batchId, err))
}
go func() {
// 刷新批次号
batchId := textaudit.RefreshBatchId()
// 执行文字审核
successNum, failNum, err := textaudit.Run(batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, text audit tasks of this batchId have failed, successNum: %v, failNum: %v, err :%v", batchId, successNum, failNum, err))
} else {
handleMsg.WriteString(fmt.Sprintf("batchId : %v, text audit tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
}
// 同步文字审核结果
err = DefaultService.utilSyncTextAuditTaskResultByBatchId(&gin.Context{}, batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, text audit tasks of this batchId have failed to syncronize, err :%v", batchId, err))
}
if handleMsg.Cap() > 0 {
xxlJobLog.HandleMsg = goproto.String(handleMsg.String())
err1 := _DefaultXxlJob.UpdateXxlJobLog(&gin.Context{}, xxlJobLog)
if err1 != nil {
logger.Error("UpdateXxlJobLog fail, err: %v", err1)
}
}
}()
logger.Info("Text audit batch ends...")
return handleMsg.String()
@ -248,34 +208,21 @@ func (s *CronService) TextAuditBatch(ctx context.Context, param *xxl.RunReq) (ms
func (s *CronService) TextAuditBatchHis(ctx context.Context, param *xxl.RunReq) (msg string) {
logger.Info("task %v param: %v log_id: %v", param.ExecutorHandler, param.ExecutorParams, xxl.Int64ToStr(param.LogID))
handleMsg := &strings.Builder{}
xxlJobLog := &dbstruct.XxlJobLog{
Id: goproto.Int64(param.LogID),
// 刷新批次号
batchId := textaudit.RefreshBatchId()
// 执行文字审核
successNum, failNum, err := textaudit.Run(batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, text audit tasks of this batchId have failed, successNum: %v, failNum: %v, err :%v", batchId, successNum, failNum, err))
}
// 同步文字审核结果
err = DefaultService.utilSyncTextAuditTaskResultByBatchId(&gin.Context{}, batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, text audit tasks of this batchId have failed to syncronize, err :%v", batchId, err))
} else {
handleMsg.WriteString(fmt.Sprintf("batchId : %v, text audit tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
}
go func() {
// 刷新批次号
batchId := textaudit.RefreshBatchId()
// 执行文字审核
successNum, failNum, err := textaudit.Run(batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, text audit tasks of this batchId have failed, successNum: %v, failNum: %v, err :%v", batchId, successNum, failNum, err))
}
// 同步文字审核结果
err = DefaultService.utilSyncTextAuditTaskResultByBatchId(&gin.Context{}, batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, text audit tasks of this batchId have failed to syncronize, err :%v", batchId, err))
} else {
handleMsg.WriteString(fmt.Sprintf("batchId : %v, text audit tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
}
if handleMsg.Cap() > 0 {
xxlJobLog.HandleMsg = goproto.String(handleMsg.String())
err1 := _DefaultXxlJob.UpdateXxlJobLog(&gin.Context{}, xxlJobLog)
if err1 != nil {
logger.Error("UpdateXxlJobLog fail, err: %v", err1)
}
}
}()
logger.Info("Text audit batch ends...")
return handleMsg.String()