You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

taskdetailslogic.go 1.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package core
  2. import (
  3. "context"
  4. "github.com/pkg/errors"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
  8. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
  9. "gorm.io/gorm"
  10. "github.com/zeromicro/go-zero/core/logx"
  11. )
  12. type TaskDetailsLogic struct {
  13. logx.Logger
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. }
  17. func NewTaskDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TaskDetailsLogic {
  18. return &TaskDetailsLogic{
  19. Logger: logx.WithContext(ctx),
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. }
  23. }
  24. func (l *TaskDetailsLogic) TaskDetails(req *types.FId) (resp *types.TaskDetailsResp, err error) {
  25. resp = &types.TaskDetailsResp{}
  26. task := &models.Task{}
  27. if errors.Is(l.svcCtx.DbEngin.Where("id", req.Id).First(&task).Error, gorm.ErrRecordNotFound) {
  28. return nil, errors.New("记录不存在")
  29. }
  30. clusterIds := make([]string, 0)
  31. var cList []*types.ClusterInfo
  32. var subList []*types.SubTaskInfo
  33. switch task.AdapterTypeDict {
  34. case "0":
  35. l.svcCtx.DbEngin.Table("task_cloud").Where("task_id", task.Id).Scan(&subList)
  36. if len(subList) <= 0 {
  37. l.svcCtx.DbEngin.Table("task_vm").Where("task_id", task.Id).Find(&subList)
  38. }
  39. case "1":
  40. l.svcCtx.DbEngin.Table("task_ai").Where("task_id", task.Id).Scan(&subList)
  41. case "2":
  42. l.svcCtx.DbEngin.Table("task_hpc").Where("task_id", task.Id).Scan(&subList)
  43. }
  44. for _, sub := range subList {
  45. clusterIds = append(clusterIds, sub.ClusterId)
  46. }
  47. err = l.svcCtx.DbEngin.Table("t_cluster").Where("id in ?", clusterIds).Scan(&cList).Error
  48. if err != nil {
  49. return resp, err
  50. }
  51. utils.Convert(&task, &resp)
  52. resp.ClusterInfos = cList
  53. resp.SubTaskInfos = subList
  54. return
  55. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.