From 0dea973bf92f274581ac081fca9ffd8eeb9c0aae Mon Sep 17 00:00:00 2001 From: zhouqunjie Date: Thu, 18 May 2023 10:08:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=B6=85=E7=AE=97=E6=A6=82=E8=A7=88=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=AD=A3=E5=9C=A8=E8=BF=90=E8=A1=8C=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=95=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 66b2b2b936df959f338e9b718998b068b8fdfd76 --- adaptor/PCM-CORE/api/desc/core/pcm-core.api | 4 ++-- .../api/internal/logic/core/getregionlogic.go | 2 +- .../api/internal/logic/core/listregionlogic.go | 18 ++++++++++++++++-- .../api/internal/logic/hpc/listjoblogic.go | 2 +- adaptor/PCM-CORE/api/internal/types/types.go | 4 ++-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/adaptor/PCM-CORE/api/desc/core/pcm-core.api b/adaptor/PCM-CORE/api/desc/core/pcm-core.api index 0e656b76..47c268f3 100644 --- a/adaptor/PCM-CORE/api/desc/core/pcm-core.api +++ b/adaptor/PCM-CORE/api/desc/core/pcm-core.api @@ -145,7 +145,7 @@ type ( type ( getRegionResp { - Code string `json:"code"` + Code int32 `json:"code"` Msg string `json:"msg"` Data RegionNum `json:"data"` } @@ -157,7 +157,7 @@ type ( type ( listRegionResp { - Code string `json:"code"` + Code int32 `json:"code"` Msg string `json:"msg"` Data []Region `json:"data"` } diff --git a/adaptor/PCM-CORE/api/internal/logic/core/getregionlogic.go b/adaptor/PCM-CORE/api/internal/logic/core/getregionlogic.go index ca524df9..d27a4133 100644 --- a/adaptor/PCM-CORE/api/internal/logic/core/getregionlogic.go +++ b/adaptor/PCM-CORE/api/internal/logic/core/getregionlogic.go @@ -30,7 +30,7 @@ func (l *GetRegionLogic) GetRegion() (resp *types.GetRegionResp, err error) { regionNameDb := l.svcCtx.DbEngin.Find(®ionSlurmArray).Not("RegionName = ?", "") softStackDb := l.svcCtx.DbEngin.Find(®ionSlurmArray).Not("SoftStack = ?", "") resp = &types.GetRegionResp{ - Code: "200", + Code: 200, Msg: "Success", Data: types.RegionNum{ RegionSum: regionNameDb.RowsAffected, diff --git a/adaptor/PCM-CORE/api/internal/logic/core/listregionlogic.go b/adaptor/PCM-CORE/api/internal/logic/core/listregionlogic.go index 47f77fc6..32f8481d 100644 --- a/adaptor/PCM-CORE/api/internal/logic/core/listregionlogic.go +++ b/adaptor/PCM-CORE/api/internal/logic/core/listregionlogic.go @@ -29,14 +29,28 @@ func (l *ListRegionLogic) ListRegion() (resp *types.ListRegionResp, err error) { // todo: add your logic here and delete this line var regionSlurmArray []model.RegionSlurm var regions []types.Region + var jobCount int64 + var regionResult []types.Region l.svcCtx.DbEngin.Find(®ionSlurmArray) tool.Convert(regionSlurmArray, ®ions) // 查询超算上的job todo + for _, region := range regions { + if region.RegionName == "Changsha HPC Center" { + l.svcCtx.DbEngin.Raw("select count(*) from task t join hpc h on t.id = h.task_id and t.status != 'Completed' and h.service_name = 'th'").Scan(&jobCount) + region.RunningJobs = jobCount + } + if region.RegionName == "Zhijiang HPC Center" { + l.svcCtx.DbEngin.Raw("select count(*) from task t join hpc h on t.id = h.task_id and t.status != 'Completed' and h.service_name = 'ac'").Scan(&jobCount) + region.RunningJobs = jobCount + } + regionResult = append(regionResult, region) + + } resp = &types.ListRegionResp{ - Code: "200", + Code: 200, Msg: "Success", - Data: regions, + Data: regionResult, } return } diff --git a/adaptor/PCM-CORE/api/internal/logic/hpc/listjoblogic.go b/adaptor/PCM-CORE/api/internal/logic/hpc/listjoblogic.go index c5a6e3d0..8f7b8672 100644 --- a/adaptor/PCM-CORE/api/internal/logic/hpc/listjoblogic.go +++ b/adaptor/PCM-CORE/api/internal/logic/hpc/listjoblogic.go @@ -51,7 +51,7 @@ func (l *ListJobLogic) ListJob(req *types.ListJobReq) (resp *types.ListJobResp, SlurmVersion: task.SlurmVersion, Name: task.Name, JobStartTime: task.JobStartTime, - JobRunTime: task.JobRunTime, + JobRunTime: task.JobRunTime + "s", StateofJob: task.StateofJob, }) diff --git a/adaptor/PCM-CORE/api/internal/types/types.go b/adaptor/PCM-CORE/api/internal/types/types.go index 0469939b..557d67e6 100644 --- a/adaptor/PCM-CORE/api/internal/types/types.go +++ b/adaptor/PCM-CORE/api/internal/types/types.go @@ -128,7 +128,7 @@ type Environment struct { } type GetRegionResp struct { - Code string `json:"code"` + Code int32 `json:"code"` Msg string `json:"msg"` Data RegionNum `json:"data"` } @@ -139,7 +139,7 @@ type RegionNum struct { } type ListRegionResp struct { - Code string `json:"code"` + Code int32 `json:"code"` Msg string `json:"msg"` Data []Region `json:"data"` }