新增同步商品库错误返回(测试)
This commit is contained in:
@@ -632,23 +632,7 @@ func (v *VendorSync) LoopStoresMap2(ctx *jxcontext.Context, parentTask tasksch.I
|
||||
}
|
||||
task = tasksch.NewParallelTask(taskName, tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx, handler, loopInfoList)
|
||||
if isAsync {
|
||||
task.SetFinishHook(func(task tasksch.ITask) {
|
||||
var noticeMsg string
|
||||
if ctx.GetUserName() != "jxadmin" {
|
||||
if len(task.GetFailedList()) > 10 {
|
||||
downloadURL, _, _ := WirteToExcelBySyncFailed(task)
|
||||
noticeMsg = "您此次的同步任务错误详情返回如下: "
|
||||
noticeMsg += fmt.Sprintf("[详情点我]%s/billshow/?normal=true&path=%s \n", globals.BackstageHost, downloadURL)
|
||||
} else if len(task.GetFailedList()) > 0 && len(task.GetFailedList()) <= 10 {
|
||||
if task.GetErr() != nil {
|
||||
noticeMsg = utils.Format4Output(buildErrMsgJson(task), true)
|
||||
}
|
||||
}
|
||||
if authInfo, err := ctx.GetV2AuthInfo(); err == nil {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "同步错误返回", noticeMsg)
|
||||
}
|
||||
}
|
||||
})
|
||||
buildSetFinishHook(task, ctx)
|
||||
}
|
||||
tasksch.HandleTask(task, parentTask, isManageIt).Run()
|
||||
if !isAsync {
|
||||
@@ -669,6 +653,26 @@ func (v *VendorSync) LoopStoresMap2(ctx *jxcontext.Context, parentTask tasksch.I
|
||||
return task, hint, err
|
||||
}
|
||||
|
||||
func buildSetFinishHook(task tasksch.ITask, ctx *jxcontext.Context) {
|
||||
task.SetFinishHook(func(task tasksch.ITask) {
|
||||
var noticeMsg string
|
||||
if ctx.GetUserName() != "jxadmin" {
|
||||
if len(task.GetFailedList()) > 10 {
|
||||
downloadURL, _, _ := WirteToExcelBySyncFailed(task)
|
||||
noticeMsg = "您此次的同步任务错误详情返回如下: "
|
||||
noticeMsg += fmt.Sprintf("[详情点我]%s/billshow/?normal=true&path=%s \n", globals.BackstageHost, downloadURL)
|
||||
} else if len(task.GetFailedList()) > 0 && len(task.GetFailedList()) <= 10 {
|
||||
if task.GetErr() != nil {
|
||||
noticeMsg = utils.Format4Output(buildErrMsgJson(task), true)
|
||||
}
|
||||
}
|
||||
if authInfo, err := ctx.GetV2AuthInfo(); err == nil {
|
||||
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "同步错误返回", noticeMsg)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func buildErrMsg(task tasksch.ITask) (err error) {
|
||||
err = fmt.Errorf(utils.Format4Output(buildErrMsgJson(task), true))
|
||||
return makeSpecSyncError(err)
|
||||
|
||||
Reference in New Issue
Block a user