commit for zw

Former-commit-id: 37456dca050bf7b1f0321b8490a5c358e13b065f
This commit is contained in:
zhouqunjie 2023-05-29 00:28:59 -07:00
parent d0bfea9fd4
commit 9eb9f871cf
1 changed files with 12 additions and 9 deletions

View File

@ -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])
}
}
}
}