From 531406600d5b31f432a6b2a81b9d1b6ce23d3eb8 Mon Sep 17 00:00:00 2001 From: zhangwei <894646498@qq.com> Date: Tue, 13 Jun 2023 08:35:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=88=97=E8=A1=A8=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 653b972fac7e26ba710770419b13ee883257e313 --- .../api/internal/logic/core/tasklistlogic.go | 20 +++++++++++-------- adaptor/PCM-CORE/rpc/etc/pcmcore.yaml | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/adaptor/PCM-CORE/api/internal/logic/core/tasklistlogic.go b/adaptor/PCM-CORE/api/internal/logic/core/tasklistlogic.go index dbc1ae1a..13518ed1 100644 --- a/adaptor/PCM-CORE/api/internal/logic/core/tasklistlogic.go +++ b/adaptor/PCM-CORE/api/internal/logic/core/tasklistlogic.go @@ -28,18 +28,16 @@ func NewTaskListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TaskList func (l *TaskListLogic) TaskList() (resp *types.TaskListResp, err error) { resp = &types.TaskListResp{} - // 查询总运行时长 - tx := l.svcCtx.DbEngin.Raw("select sum(running_time)/3600 as total_run_time from (select sum(running_time) as running_time from hpc union all select sum(running_time) as running_time from cloud union all select sum(running_time) as running_time from ai) runtime").Scan(&resp.TotalRunTime) + + // 查询任务数据 + var tasks []model.Task + tx := l.svcCtx.DbEngin.Find(&tasks) if tx.Error != nil { logx.Error(err) return nil, tx.Error } - // 查询任务数据 - var tasks []model.Task - tx = l.svcCtx.DbEngin.Find(&tasks) - if tx.Error != nil { - logx.Error(err) - return nil, tx.Error + if len(tasks) == 0 { + return nil, nil } for _, task := range tasks { tx := l.svcCtx.DbEngin.Raw("SELECT CONCAT_WS(',',GROUP_CONCAT(DISTINCT h.service_name) ,GROUP_CONCAT(DISTINCT a.service_name) ,GROUP_CONCAT(DISTINCT c.service_name))as service_name from task t left join hpc h on t.id = h.task_id left join cloud c on t.id = c.task_id left join ai a on t.id = a.task_id where t.id = ?", task.Id).Scan(&task.ServiceName) @@ -65,6 +63,12 @@ func (l *TaskListLogic) TaskList() (resp *types.TaskListResp, err error) { }) } + // 查询总运行时长 + tx = l.svcCtx.DbEngin.Raw("select sum(running_time)/3600 as total_run_time from (select sum(running_time) as running_time from hpc union all select sum(running_time) as running_time from cloud union all select sum(running_time) as running_time from ai) runtime").Scan(&resp.TotalRunTime) + if tx.Error != nil { + logx.Error(err) + return nil, tx.Error + } // 运行卡时数 tx = l.svcCtx.DbEngin.Model(&model.Hpc{}).Select("(CASE WHEN SUM(running_time * card_count)/3600 IS NULL THEN 0 ELSE SUM(running_time * card_count)/3600 END )as cardTime").Find(&resp.CardTime) if tx.Error != nil { diff --git a/adaptor/PCM-CORE/rpc/etc/pcmcore.yaml b/adaptor/PCM-CORE/rpc/etc/pcmcore.yaml index 5f1389af..33b07b37 100644 --- a/adaptor/PCM-CORE/rpc/etc/pcmcore.yaml +++ b/adaptor/PCM-CORE/rpc/etc/pcmcore.yaml @@ -7,7 +7,7 @@ NacosConfig: - IpAddr: 10.101.15.7 Port: 8848 ClientConfig: - NamespaceId: test + NamespaceId: zhangwei TimeoutMs: 5000 NotLoadCacheAtStart: true LogDir: