任务列表修改

Former-commit-id: 653b972fac7e26ba710770419b13ee883257e313
This commit is contained in:
zhangwei 2023-06-13 08:35:26 +08:00
parent b33442951d
commit 531406600d
2 changed files with 13 additions and 9 deletions

View File

@ -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 {

View File

@ -7,7 +7,7 @@ NacosConfig:
- IpAddr: 10.101.15.7
Port: 8848
ClientConfig:
NamespaceId: test
NamespaceId: zhangwei
TimeoutMs: 5000
NotLoadCacheAtStart: true
LogDir: