From 9eb9f871cf99336feee5e323dabf5edb8b486c50 Mon Sep 17 00:00:00 2001 From: zhouqunjie Date: Mon, 29 May 2023 00:28:59 -0700 Subject: [PATCH] commit for zw Former-commit-id: 37456dca050bf7b1f0321b8490a5c358e13b065f --- .../PCM-TH/rpc/internal/logic/cronlogic.go | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/adaptor/PCM-HPC/PCM-TH/rpc/internal/logic/cronlogic.go b/adaptor/PCM-HPC/PCM-TH/rpc/internal/logic/cronlogic.go index 3da27087..c8a16483 100644 --- a/adaptor/PCM-HPC/PCM-TH/rpc/internal/logic/cronlogic.go +++ b/adaptor/PCM-HPC/PCM-TH/rpc/internal/logic/cronlogic.go @@ -7,6 +7,7 @@ import ( "PCM/common/enum" "PCM/common/tool" "context" + "github.com/jinzhu/copier" "github.com/zeromicro/go-zero/core/logx" "strconv" "time" @@ -41,7 +42,7 @@ func InitCron(svc *svc.ServiceContext) { for index, _ := range infoList.HpcInfoList { for _, job := range listJob.Jobs { if job.Name == infoList.HpcInfoList[index].Name { - tool.Convert(job, infoList.HpcInfoList[index]) + copier.CopyWithOption(infoList.HpcInfoList[index], job, copier.Option{Converters: tool.Converters}) infoList.HpcInfoList[index].JobId = strconv.Itoa(int(job.JobId)) infoList.HpcInfoList[index].StartTime = time.Unix(job.StartTime, 0).String() infoList.HpcInfoList[index].RunningTime = int64(time.Now().Sub(time.Unix(job.StartTime, 0)).Seconds()) @@ -72,17 +73,19 @@ func submitJob(infoList *pcmcoreclient.InfoListResp, submitJobLogic *SubmitJobLo } jobResult, _ := submitJobLogic.SubmitJob(&submitReq) // 任务失败 - if string(jobResult.SubmitResponseMsg[0].ErrorCode) != "" { + if jobResult.SubmitResponseMsg[0].ErrorCode != 0 { infoList.HpcInfoList[index].Status = "Failed" infoList.HpcInfoList[index].ExitCode = jobResult.SubmitResponseMsg[0].ErrorCode // 查询失败的任务信息同步到core端 - historyResult, err := historyListLogic.ListHistoryJob(&hpcTH.ListHistoryJobReq{}) - if err != nil { - return - } - for _, historyJob := range historyResult.HistoryJobs { - if infoList.HpcInfoList[index].Name == historyJob.Jobname { - tool.Convert(historyJob, infoList.HpcInfoList[index]) + for index, _ := range infoList.HpcInfoList { + historyResult, err := historyListLogic.ListHistoryJob(&hpcTH.ListHistoryJobReq{}) + if err != nil { + return + } + for _, historyJob := range historyResult.HistoryJobs { + if infoList.HpcInfoList[index].JobId == string(historyJob.Jobid) { + tool.Convert(historyJob, infoList.HpcInfoList[index]) + } } } }