service/app/mix/service/xxljob_tasks.go

554 lines
23 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package service
import (
"context"
"fmt"
"service/api/consts"
accountproto "service/api/proto/account/proto"
account_cancellationproto "service/api/proto/account_cancellation/proto"
contact_customer_service_proto "service/api/proto/contact_customer_service/proto"
daily_statementproto "service/api/proto/daily_statement/proto"
daily_statement_zone_infoproto "service/api/proto/daily_statement_zone_info/proto"
momentproto "service/api/proto/moment/proto"
vasproto "service/api/proto/vas/proto"
vericodeproto "service/api/proto/vericode/proto"
"service/apollostruct"
"service/bizcommon/util"
"service/dbstruct"
"service/library/apollo"
"service/library/contentaudit/imageaudit"
"service/library/contentaudit/textaudit"
videomoderation "service/library/contentaudit/video_moderation"
"service/library/dingtalk"
"service/library/logger"
"service/library/mycrypto"
"service/library/redis"
"strings"
"time"
"github.com/gin-gonic/gin"
xxl "github.com/xxl-job/xxl-job-executor-go"
goproto "google.golang.org/protobuf/proto"
)
func (s *CronService) ReloadRecommList(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))
logger.Info("Refreshing recommendation list cached in redis...")
nt := util.GetHourHalfTimeStamp(time.Now())
err := DefaultStreamerRecommService.RunBatch(nt)
if err != nil {
logger.Error("RunBatch fail, err: %v", err)
return fmt.Sprintf("RunBatch fail, err: %v", err)
}
logger.Info("Refresh recommendation list cached in redis accomplished...")
return "Refresh recommendation list cached in redis accomplished"
}
func (s *CronService) ClearVeriCodeSendTimes(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))
logger.Info("Clearing vericode_send_times collection...")
if err := _DefaultVeriCodeSendTimes.OpClear(&gin.Context{}); err != nil {
logger.Error("Clear vericode_send_times collection fail: %v", err)
return fmt.Sprintf("Clear vericode_send_times collection fail: %v", err)
}
logger.Info("vericode_send_times collection has been cleared")
return "vericode_send_times collection has been cleared"
}
func (s *CronService) ClearMomentCreateTimes(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))
logger.Info("Clearing moment_create_times collection...")
if err := _DefaultMomentCreateTimes.OpClear(&gin.Context{}); err != nil {
logger.Error("Clear moment_create_times collection fail: %v", err)
return fmt.Sprintf("Clear moment_create_times collection fail: %v", err)
}
logger.Info("moment_create_times collection has been cleared")
return "moment_create_times collection has been cleared"
}
// 统计每日报表
func (s *CronService) CreateDailyStatement(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))
//拿到现在的时间戳
nowTimeStamp := util.GetHourStartTimeStamp(time.Now())
//获取上个小时时间段
startTimeStamp := nowTimeStamp - int64(60*60)
endTimeStamp := nowTimeStamp - int64(1)
starttime := time.Unix(startTimeStamp, 0)
endtime := time.Unix(endTimeStamp, 0)
//获取H5接口访问量
logpath := fmt.Sprintf("%v_%02d%02d%02d.Global", s.fileAbsPath, starttime.Year(), starttime.Month(), starttime.Day())
count, err := DefaultScriptsService.QueryCallCount(consts.H5CallUrl, logpath)
if err != nil {
logger.Error("query h5 call count fail : %v", err)
//return fmt.Sprintf("query h5 call count fail : %v", err)
}
//获取站外user_id访问zone访问量
zoneListFromOusideCount, err := DefaultScriptsService.QueryCallCount(consts.ZoneListFromOutsideCountCallUrl, logpath)
if err != nil {
logger.Error("query list_by_user_id_from_outside call count fail : %v", err)
//return fmt.Sprintf("query list_by_user_id_from_outside call count fail : %v", err)
}
//获取用户总量
accountCount, err := _DefaultAccount.OpCount(&gin.Context{}, &accountproto.OpCountReq{
CtLowerBound: goproto.Int64(int64(consts.AppEnterProductionTime)),
})
if err != nil {
logger.Error("_DefaultAccount OpCount fail : %v", err)
//return fmt.Sprintf("_DefaultAccount OpCount fail : %v", err)
}
//获取订单总量
orderCounts, err := _DefaultVas.GetOrderCountGroupByStatus(&gin.Context{}, &vasproto.GetOrderByStatusReq{
CtStart: goproto.Int64(consts.AppEnterProductionTime),
CtEnd: nil,
})
if err != nil {
logger.Error("_DefaultVas GetOrderCountByStatus fail : %v", err)
//return fmt.Sprintf("_DefaultVas GetOrderCountByStatus fail : %v", err)
}
//获取用户注册来源
androidCount, iosCount, h5Count, err := _DefaultAccount.OpCountLastHourNewUserSource(&gin.Context{}, &accountproto.OpCountReq{
CtLowerBound: goproto.Int64(startTimeStamp),
CtUpperBound: goproto.Int64(endTimeStamp),
})
if err != nil {
logger.Error("_DefaultAccount OpCountLastHourNewUserSource fail : %v", err)
//return fmt.Sprintf("_DefaultAccount OpCountLastHourNewUserSource fail : %v", err)
}
//获取订单完成量
finishedOrderCount := int32(0)
allOrderCount := int32(0)
for _, orderCount := range orderCounts {
if util.DerefInt32(orderCount.OrderStatus) != 0 {
finishedOrderCount += util.DerefInt32(orderCount.Count)
}
allOrderCount += util.DerefInt32(orderCount.Count)
}
dailyStatement := &dbstruct.DailyStatement{
H5CallCount: goproto.Int64(int64(count)),
RegisteredUserCount: goproto.Int64(accountCount),
OrderCreatedCount: goproto.Int64(int64(allOrderCount)),
OrderFinishedCount: goproto.Int64(int64(finishedOrderCount)),
LastHourNewUserCountFromAndroid: goproto.Int64(androidCount),
LastHourNewUserCountFromIos: goproto.Int64(iosCount),
LastHourNewUserCountFromH5: goproto.Int64(h5Count),
ZoneListFromOutsideCount: goproto.Int64(int64(zoneListFromOusideCount)),
StartTime: goproto.Int64(startTimeStamp),
EndTime: goproto.Int64(endTimeStamp),
}
err = _DefaultDailyStatement.OpCreate(&gin.Context{}, &daily_statementproto.OpCreateReq{
DailyStatement: dailyStatement,
})
if err != nil {
logger.Error("_DefaultDailyStatement OpCreate fail : %v", err)
return fmt.Sprintf("_DefaultDailyStatement OpCreate fail : %v", err)
}
//获取空间相关信息
zoneprofits, zonerefunds, err := _DefaultVas.GetLastHourZoneProfit(&gin.Context{}, startTimeStamp, endTimeStamp)
if err != nil {
logger.Error("_DefaultVas GetLastHourZoneProfit fail : %v", err)
return fmt.Sprintf("_DefaultDailyStatementZoneInfo OpCreateBatch fail : %v", err)
}
dailyStatementZoneInfos := DefaultService.utilAssembleDailyStatementZoneInfo(zoneprofits, zonerefunds, startTimeStamp, endTimeStamp)
for _, dailyStatementZoneInfo := range dailyStatementZoneInfos {
dailyStatementZoneInfo.Fill()
}
err = _DefaultDailyStatementZoneInfo.OpCreateBatch(&gin.Context{}, &daily_statement_zone_infoproto.OpCreateBatchReq{
DailyStatementZoneInfos: dailyStatementZoneInfos,
})
if err != nil {
logger.Error("_DefaultDailyStatementZoneInfo OpCreateBatch fail : %v", err)
return fmt.Sprintf("_DefaultDailyStatementZoneInfo OpCreateBatch fail : %v", err)
}
logger.Info("%v - %v statement data has created...", starttime, endtime)
return fmt.Sprintf("%v - %v statement data has created...", starttime, endtime)
}
// 图像审核作业
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{}
// 刷新批次号
batchId, err := imageaudit.RefreshBatchId()
if err != nil {
return fmt.Sprintf("Refresh batchId failed, err: %v", err)
}
// 执行图像审核
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))
}
logger.Info("Image audit batch ends...")
return handleMsg.String()
}
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{}
// 刷新批次号
batchId := param.ExecutorParams
// 执行图像审核
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))
}
logger.Info("Image audit batch ends...")
return handleMsg.String()
}
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{}
// 刷新批次号
batchId, err := textaudit.RefreshBatchId()
if err != nil {
return fmt.Sprintf("Refresh batchId failed, err: %v", err)
}
// 执
// 执行文字审核
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))
}
logger.Info("Text audit batch ends...")
return handleMsg.String()
}
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{}
// 刷新批次号
batchId := param.ExecutorParams
// 执行文字审核
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))
}
logger.Info("Text audit batch ends...")
return handleMsg.String()
}
// 每天0点定时清空图像和文字审核作业的日志
func (s *CronService) ClearContentAuditBatchExecutionLogs(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))
inParams := strings.Split(param.ExecutorParams, "|")
if len(inParams) < 2 {
return "Wrong executor params format!"
}
jobIdsStr := inParams[0]
errorPrefix := inParams[1]
err := _DefaultXxlJob.ClearSuccXxlJobLogs(&gin.Context{}, jobIdsStr, errorPrefix)
if err != nil {
return err.Error()
}
return "clear content audit batch execution logs finished..."
}
// 每分钟查询反馈信息发送到钉钉机器人
func (s *CronService) SendContactCustomerServicesOfLastMinute(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))
//拿到现在的时间戳
nowTimeStamp := util.GetMinuteStartTimeStamp(time.Now())
//获取上分钟时间段
startTimeStamp := nowTimeStamp - int64(60)
endTimeStamp := nowTimeStamp - int64(1)
list, err := _DefaultContactCustomerService.OpList(&gin.Context{}, &contact_customer_service_proto.OpListReq{
CtLowerBound: goproto.Int64(startTimeStamp),
CtUpperBound: goproto.Int64(endTimeStamp),
})
if err != nil {
return err.Error()
}
if len(list) == 0 {
return "No new contact customer service created"
}
msg, err = DefaultService.utilStringifyContactCustomerServices(&gin.Context{}, list)
if err != nil {
return err.Error()
}
err = dingtalk.SendMsg(msg)
if err != nil {
return err.Error()
}
return "Message send success"
}
// 每天0点定时清空图像和文字审核作业的日志
func (s *CronService) CreateVeriCode(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))
mobilePhone := param.ExecutorParams
if mobilePhone == "" {
return "null mobile phone"
}
phoneHash := mycrypto.CryptoServiceInstance().SHA256.Encrypt([]byte(mobilePhone))
err := _DefaultVeriCode.OpCreate(&gin.Context{}, &vericodeproto.OpCreateReq{
VeriCode: &dbstruct.VeriCode{
PhoneHash: phoneHash,
VeriCode: "123456",
RegionCode: "86",
},
})
if err != nil {
return "create veri_code fail!"
}
return "verification code created: 123456"
}
// 每天0点对应当执行注销的账户执行注销操作
func (s *CronService) CancelAccountsAtDueTime(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))
// 拿到当日起始时间戳
dayStartTimeStamp := util.GetDayStartTimeStamp(time.Now())
ctxt := &gin.Context{}
// 首先锁表,将所有账户注销表中待执行的记录,状态全部更改为注销执行中,防止注销中用户再取消注销造成同步问题
err := _DefaultAccountCancellation.OpUpdateByDuetimeAndStatus(ctxt, &account_cancellationproto.OpUpdateReq{
AccountCancellation: &dbstruct.AccountCancellation{
Status: goproto.Int64(consts.AccountCancellationStatus_CancellationExecuting),
},
}, dayStartTimeStamp, consts.AccountCancellationStatus_Cancelling)
if err != nil {
logger.Error("_DefaultAccountCancellation OpUpdateByDuetimeAndStatus err: %v", err)
return fmt.Sprintf("_DefaultAccountCancellation OpUpdateByDuetimeAndStatus err: %v", err)
}
// 查询出所有注销执行中的记录
list, err := _DefaultAccountCancellation.OpList(ctxt, &account_cancellationproto.OpListReq{
Duetime: goproto.Int64(dayStartTimeStamp),
Status: goproto.Int64(consts.AccountCancellationStatus_CancellationExecuting),
})
if err != nil {
logger.Error("_DefaultAccountCancellation OpList err: %v", err)
return fmt.Sprintf("_DefaultAccountCancellation OpList err: %v", err)
}
if len(list) == 0 {
logger.Info("There is no account cancellation due to executing now")
return "There is no account cancellation due to executing now"
}
// 提取出所有的mid和id
midList := make([]int64, 0)
idList := make([]int64, 0)
for _, account_cancellation := range list {
midList = append(midList, util.DerefInt64(account_cancellation.Mid))
idList = append(idList, util.DerefInt64(account_cancellation.Id))
}
// 对所有mid对应的账号执行注销
err = DefaultService.utilCancelAccountByMids(ctxt, midList)
if err != nil {
logger.Error("DefaultService utilCancelAccountByMids err: %v", err)
return fmt.Sprintf("DefaultService utilCancelAccountByMids err: %v", err)
}
// 解锁表,更新状态
err = _DefaultAccountCancellation.OpUpdateByIds(ctxt, &account_cancellationproto.OpUpdateReq{
AccountCancellation: &dbstruct.AccountCancellation{
Status: goproto.Int64(consts.AccountCancellationStatus_Cancelled),
},
}, idList)
if err != nil {
logger.Error("_DefaultAccountCancellation OpUpdateByIds err: %v", err)
return fmt.Sprintf("_DefaultAccountCancellation OpUpdateByIds err: %v", err)
}
return "Account cancellation execution finished..."
}
func (s *CronService) ReloadMomentRecommList(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))
logger.Info("Refreshing recommendation list cached in redis...")
list, err := _DefaultMoment.OpList(&gin.Context{}, &momentproto.OpListReq{
CtLowerBound: goproto.Int64(0),
})
if err != nil {
logger.Error("OpGetMomentList fail, err: %v", err)
return fmt.Sprintf("OpGetMomentList fail, err: %v", err)
}
// 取apollo配置
cfg := &apollostruct.RestrictedVisitorMomentCfg{}
err = apollo.GetJson(consts.RestrictedVisitorMomentKey, &cfg, apollo.ApolloOpts().SetNamespace("application"))
if err != nil {
logger.Error("Apollo read failed : %v", err)
return "Apollo read failedl"
}
// 查询限制访问动态
restrictedlist, err := _DefaultMoment.OpListByMids(&gin.Context{}, &momentproto.OpListByMidsReq{
Mids: cfg.RestrictedVisitorVisibleMids,
CtLowerBound: goproto.Int64(0),
})
if err != nil {
logger.Error("OpGetMomentListByMids fail, err: %v", err)
return fmt.Sprintf("OpGetMomentListByMids fail, err: %v", err)
}
// 清缓存
if err := redis.GetRedisClient().Del(consts.RedisMomentPrefix + "recomm_list"); err != nil {
logger.Error("Del redis cache fail, err: %v", err)
return fmt.Sprintf("Del redis cache fail, err: %v", err)
}
if err := redis.GetRedisClient().Del(consts.RedisMomentPrefix + "restricted_recomm_list"); err != nil {
logger.Error("Del redis cache fail, err: %v", err)
return fmt.Sprintf("Del redis cache fail, err: %v", err)
}
if err := redis.GetRedisClient().Del(consts.RedisMomentPrefix + "recent_list_offset"); err != nil {
logger.Error("Del redis cache fail, err: %v", err)
return fmt.Sprintf("Del redis cache fail, err: %v", err)
}
// 加载缓存
for _, moment := range list {
id := util.DerefInt64(moment.Id)
err := redis.GetRedisClient().RPush(consts.RedisMomentPrefix+"recomm_list", id)
if err != nil {
logger.Error("Redis cache fail, err: %v", err)
return fmt.Sprintf("Redis cache fail, err: %v", err)
}
}
for _, moment := range restrictedlist {
id := util.DerefInt64(moment.Id)
err := redis.GetRedisClient().RPush(consts.RedisMomentPrefix+"restricted_recomm_list", id)
if err != nil {
logger.Error("Redis cache fail, err: %v", err)
return fmt.Sprintf("Redis cache fail, err: %v", err)
}
}
logger.Info("Refresh moment recommendation list cached in redis accomplished...")
return "Refresh moment recommendation list cached in redis accomplished"
}
func (s *CronService) ClearZoneMomentCreateTimes(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))
logger.Info("Clearing zone_moment_create_times collection...")
if err := _DefaultZoneMomentCreateTimes.OpClear(&gin.Context{}); err != nil {
logger.Error("Clear zone_moment_create_times collection fail: %v", err)
return fmt.Sprintf("Clear zone_moment_create_times collection fail: %v", err)
}
logger.Info("zone_moment_create_times collection has been cleared")
return "zone_moment_create_times collection has been cleared"
}
func (s *CronService) ClearWrongPswdTimes(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))
logger.Info("Clearing wrong_pswd_times...")
if err := _DefaultLogin.OpClearWrongPswdTimes(&gin.Context{}); err != nil {
logger.Error("Clear wrong_pswd_times fail: %v", err)
return fmt.Sprintf("Clear wrong_pswd_times fail: %v", err)
}
logger.Info("wrong_pswd_times has been cleared")
return "wrong_pswd_times has been cleared"
}
// 视频审核作业
func (s *CronService) VideoModerationBatch(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{}
// 刷新批次号
batchId, err := videomoderation.RefreshBatchId()
if err != nil {
return fmt.Sprintf("Refresh batchId failed, err: %v", err)
}
// 执行视频审核
successNum, failNum, err := videomoderation.Run(batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, video moderation tasks of this batchId have failed, successNum: %v, failNum: %v, err :%v ; ", batchId, successNum, failNum, err))
} else {
handleMsg.WriteString(fmt.Sprintf("batchId : %v, video moderation tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
}
logger.Info("Video moderation batch ends...")
return handleMsg.String()
}
func (s *CronService) VideoModerationBatchHis(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{}
// 刷新批次号
batchId := param.ExecutorParams
// 执行图像审核
successNum, failNum, err := videomoderation.Run(batchId)
if err != nil {
handleMsg.WriteString(fmt.Sprintf("ERROR : batchId : %v, video moderation tasks of this batchId have failed, successNum: %v, failNum: %v, err :%v ; ", batchId, successNum, failNum, err))
} else {
handleMsg.WriteString(fmt.Sprintf("batchId : %v, video moderation tasks of this batchId have finished, successNum: %v, failNum: %v", batchId, successNum, failNum))
}
logger.Info("Video moderation batch ends...")
return handleMsg.String()
}
func (s *CronService) ClearExpiredBtcb(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))
videomoderation.ClearExpiredBtcb()
logger.Info("Clear expired btcb ends...")
return "Clear expired btcb ends..."
}