by Robin at 20240104; fix

This commit is contained in:
Leufolium 2024-01-04 21:55:00 +08:00
parent bb8a2acd6a
commit 710f5f01a3
8 changed files with 97 additions and 0 deletions

View File

@ -2409,6 +2409,31 @@ func (m *Mongo) UpdateImageAuditTaskByIds(ctx *gin.Context, imageaudittask *dbst
return err
}
func (m *Mongo) UpdateOverdueImageAuditTasksStatus(ctx *gin.Context, imageaudittask *dbstruct.ImageAuditTask, batchId string) (*qmgo.UpdateResult, error) {
col := m.getColImageAuditTask()
set := qmgo.M{
"status": consts.ImageAudit_Expired,
"remarks": "已有新批次任务处理该字段,该审核任务已过期",
}
up := qmgo.M{
"$set": set,
}
filter := qmgo.M{
"associative_database": util.DerefString(imageaudittask.AssociativeDatabase),
"associative_table_name": util.DerefString(imageaudittask.AssociativeTableName),
"associative_table_id": util.DerefInt64(imageaudittask.AssociativeTableId),
"associative_table_column": util.DerefString(imageaudittask.AssociativeTableColumn),
"batch_id": qmgo.M{
"$ne": batchId,
},
"status": qmgo.M{
"$in": []int64{consts.ImageAudit_Rollbacked, consts.ImageAudit_ServiceFailed},
},
}
result, err := col.UpdateAll(ctx, filter, up)
return result, err
}
// 文字审核相关
func (m *Mongo) CreateTextAudit(ctx *gin.Context, textaudit *dbstruct.TextAudit) error {
col := m.getColTextAudit()
@ -2594,6 +2619,31 @@ func (m *Mongo) UpdateTextAuditTaskByIds(ctx *gin.Context, textaudittask *dbstru
return err
}
func (m *Mongo) UpdateOverdueTextAuditTasksStatus(ctx *gin.Context, textaudittask *dbstruct.TextAuditTask, batchId string) (*qmgo.UpdateResult, error) {
col := m.getColTextAuditTask()
set := qmgo.M{
"status": consts.TextAudit_Expired,
"remarks": "已有新批次任务处理该字段,该审核任务已过期",
}
up := qmgo.M{
"$set": set,
}
filter := qmgo.M{
"associative_database": util.DerefString(textaudittask.AssociativeDatabase),
"associative_table_name": util.DerefString(textaudittask.AssociativeTableName),
"associative_table_id": util.DerefInt64(textaudittask.AssociativeTableId),
"associative_table_column": util.DerefString(textaudittask.AssociativeTableColumn),
"batch_id": qmgo.M{
"$ne": batchId,
},
"status": qmgo.M{
"$in": []int64{consts.TextAudit_Rollbacked, consts.TextAudit_ServiceFailed},
},
}
result, err := col.UpdateAll(ctx, filter, up)
return result, err
}
// 联系客服对话表相关
func (m *Mongo) CreateContactCustomerServiceSession(ctx *gin.Context, contact_customer_service_session *dbstruct.ContactCustomerServiceSession) error {
col := m.getColContactCustomerServiceSession()

View File

@ -655,6 +655,8 @@ func (s *Service) ApiGetFollowAccountRelationList(ctx *gin.Context, req *account
list, err := _DefaultAccountRelation.OpListBySubMidAndPredicate(ctx, &accountrelationproto.OpListBySubMidAndPredicateReq{
SubMid: req.Mid,
Predicate: goproto.Int64(consts.Follow),
Offset: req.Offset,
Limit: req.Limit,
})
if err != nil {
logger.Error("OpListBySubMidAndPredicate fail, req: %v, err: %v", util.ToJson(req), err)
@ -676,6 +678,8 @@ func (s *Service) ApiGetIsFollowedAccountRelationList(ctx *gin.Context, req *acc
list, err := _DefaultAccountRelation.OpListBySubMidAndPredicate(ctx, &accountrelationproto.OpListBySubMidAndPredicateReq{
SubMid: req.Mid,
Predicate: goproto.Int64(consts.IsFollowed),
Offset: req.Offset,
Limit: req.Limit,
})
if err != nil {
logger.Error("OpListBySubMidAndPredicate fail, req: %v, err: %v", util.ToJson(req), err)
@ -717,6 +721,8 @@ func (s *Service) ApiGetIgnoreAccountRelationList(ctx *gin.Context, req *account
list, err := _DefaultAccountRelation.OpListBySubMidAndPredicate(ctx, &accountrelationproto.OpListBySubMidAndPredicateReq{
SubMid: req.Mid,
Predicate: goproto.Int64(consts.Ignore),
Offset: req.Offset,
Limit: req.Limit,
})
if err != nil {
logger.Error("OpListBySubMidAndPredicate fail, req: %v, err: %v", util.ToJson(req), err)
@ -737,6 +743,8 @@ func (s *Service) ApiGetAbleToAccessWeixinOfAccountRelationList(ctx *gin.Context
list, err := _DefaultAccountRelation.OpListBySubMidAndPredicate(ctx, &accountrelationproto.OpListBySubMidAndPredicateReq{
SubMid: req.Mid,
Predicate: goproto.Int64(consts.AbleToAccessWeixinOf),
Offset: req.Offset,
Limit: req.Limit,
})
if err != nil {
logger.Error("OpListBySubMidAndPredicate fail, req: %v, err: %v", util.ToJson(req), err)

View File

@ -81,3 +81,16 @@ func (p *ImageAuditTask) OpUpdateByIds(ctx *gin.Context, req *imageaudittaskprot
}
return nil
}
// 处理批次号早于参数提供的批次号的审核任务,全部置为已失效
func (p *ImageAuditTask) OpHandleOverdue(ctx *gin.Context, task *dbstruct.ImageAuditTask, batchId string) error {
result, err := p.store.UpdateOverdueImageAuditTasksStatus(ctx, task, batchId)
if err != nil {
logger.Error("UpdateOverdueImageAuditTasksStatus fail, err: %v", err)
return err
}
if result.ModifiedCount > 0 {
logger.Info("Set %v tasks overdued", result.ModifiedCount)
}
return nil
}

View File

@ -81,3 +81,16 @@ func (p *TextAuditTask) OpUpdateByIds(ctx *gin.Context, req *textaudittaskproto.
}
return nil
}
// 处理批次号早于参数提供的批次号的审核任务,全部置为已失效
func (p *TextAuditTask) OpHandleOverdue(ctx *gin.Context, task *dbstruct.TextAuditTask, batchId string) error {
result, err := p.store.UpdateOverdueTextAuditTasksStatus(ctx, task, batchId)
if err != nil {
logger.Error("UpdateOverdueTextAuditTasksStatus fail, err: %v", err)
return err
}
if result.ModifiedCount > 0 {
logger.Info("Set %v tasks overdued", result.ModifiedCount)
}
return nil
}

View File

@ -35,6 +35,7 @@ type ImageAuditTaskService interface {
OpList(ctx *gin.Context, req *imageaudittaskproto.OpListReq) ([]*dbstruct.ImageAuditTask, error)
OpUpdateByIds(ctx *gin.Context, req *imageaudittaskproto.OpUpdateByIdsReq) error
OpUpdateByBatchId(ctx *gin.Context, batchId string, imageaudittask *dbstruct.ImageAuditTask) error
OpHandleOverdue(ctx *gin.Context, task *dbstruct.ImageAuditTask, batchId string) error
}
var defaultImageAuditClient *imageaudit.Client

View File

@ -73,6 +73,11 @@ func createScanImageAdvanceRequest(tasks []*ImageAuditTaskControlBlock, batchId
// 写map记录
if actionMap[task.ActionId] == nil { // 写入actionMap
actionMap[task.ActionId] = NewImageAuditAction()
// 将此前批次对该元素未成功,待处理的审核全部置为已失效
if err := _DefaultImageAuditTask.OpHandleOverdue(ctx, task.ImageAuditTask, batchId); err != nil {
logger.Error("_DefaultImageAuditTask OpHandleOverdue fail :%v", err)
}
}
actionMap[task.ActionId].Record(task)

View File

@ -30,6 +30,7 @@ type TextAuditTaskService interface {
OpList(ctx *gin.Context, req *textaudittaskproto.OpListReq) ([]*dbstruct.TextAuditTask, error)
OpUpdateByIds(ctx *gin.Context, req *textaudittaskproto.OpUpdateByIdsReq) error
OpUpdateByBatchId(ctx *gin.Context, batchId string, textaudittask *dbstruct.TextAuditTask) error
OpHandleOverdue(ctx *gin.Context, task *dbstruct.TextAuditTask, batchId string) error
}
var defaultTextAuditClient *textaudit.Client

View File

@ -53,6 +53,8 @@ func executeTextAuditTasks(tasks []*TextAuditTaskControlBlock, batchId string) (
func createScanTextRequest(tasks []*TextAuditTaskControlBlock, batchId string) (request *textaudit.ScanTextRequest, actionMap map[string]*TextAuditAction, err error) {
ctx := &gin.Context{}
actionMap = make(map[string]*TextAuditAction) // 动作Id号-action的map
// 1.打包文字转成ScanTextRequest
@ -62,6 +64,10 @@ func createScanTextRequest(tasks []*TextAuditTaskControlBlock, batchId string) (
// 写map
if actionMap[task.ActionId] == nil { // 写入actionMap
actionMap[task.ActionId] = NewTextAuditAction()
// 将此前批次对该元素未成功,待处理的审核全部置为已失效
if err := _DefaultTextAuditTask.OpHandleOverdue(ctx, task.TextAuditTask, batchId); err != nil {
logger.Error("_DefaultTextAuditTask OpHandleOverdue fail :%v", err)
}
}
actionMap[task.ActionId].Record(task)