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.

jobtotallogic.go 3.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. Copyright (c) [2023] [pcm]
  3. [pcm-coordinator] is licensed under Mulan PSL v2.
  4. You can use this software according to the terms and conditions of the Mulan PSL v2.
  5. You may obtain a copy of Mulan PSL v2 at:
  6. http://license.coscl.org.cn/MulanPSL2
  7. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  8. EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  9. MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  10. See the Mulan PSL v2 for more details.
  11. */
  12. package core
  13. import (
  14. "context"
  15. "github.com/zeromicro/go-zero/core/logx"
  16. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  17. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  18. )
  19. type JobTotalLogic struct {
  20. logx.Logger
  21. ctx context.Context
  22. svcCtx *svc.ServiceContext
  23. }
  24. type Job struct {
  25. TotalSize int `json:"totalSize"`
  26. OtJobs []OtJob `json:"otJobs"`
  27. }
  28. type OtJob struct {
  29. Name string `json:"name"`
  30. Status string `json:"status"`
  31. Tasks []Task `json:"tasks"`
  32. }
  33. type Task struct {
  34. CenterName []string `json:"centerName"`
  35. }
  36. func NewJobTotalLogic(ctx context.Context, svcCtx *svc.ServiceContext) *JobTotalLogic {
  37. return &JobTotalLogic{
  38. Logger: logx.WithContext(ctx),
  39. ctx: ctx,
  40. svcCtx: svcCtx,
  41. }
  42. }
  43. func (l *JobTotalLogic) JobTotal() (resp *types.JobTotalResp, err error) {
  44. //// 获取任务时间信息
  45. //resp = &types.JobTotalResp{}
  46. //bytes, err := httputils.HttpGet("http://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/alljobinfo")
  47. //if err != nil {
  48. // return nil, err
  49. //}
  50. //json.Unmarshal(bytes, resp)
  51. //
  52. //// 获取其他任务信息
  53. //jobs := &Job{}
  54. //jobBytes, err := httputils.HttpGet("http://grampus.openi.org.cn/openapi/v1/sharescreen/trainjob?pageIndex=1&pageSize=10")
  55. //if err != nil {
  56. // return nil, err
  57. //}
  58. //json.Unmarshal(jobBytes, jobs)
  59. //
  60. //for _, job := range jobs.OtJobs {
  61. // trainJob := types.TrainJob{
  62. // Name: job.Name,
  63. // Status: enum.ExternalStatus(job.Status).String(),
  64. // Strategy: 0,
  65. // SynergyStatus: "未协同",
  66. // }
  67. // if job.Tasks[0].CenterName != nil {
  68. // trainJob.ParticipantName = job.Tasks[0].CenterName[0]
  69. // }
  70. // resp.TrainJobs = append(resp.TrainJobs, trainJob)
  71. //}
  72. //
  73. //var tasks []models.Task
  74. //tx := l.svcCtx.DbEngin.Find(&tasks)
  75. //if tx.Error != nil {
  76. // logx.Error(err)
  77. // return nil, tx.Error
  78. //}
  79. //if len(tasks) == 0 {
  80. // return nil, nil
  81. //}
  82. //for _, task := range tasks {
  83. // var participantName string
  84. // tx := l.svcCtx.DbEngin.Raw("SELECT name from sc_participant_phy_info where id in (SELECT CONCAT_WS(',',GROUP_CONCAT(DISTINCT h.participant_id) ,GROUP_CONCAT(DISTINCT a.participant_id) ,GROUP_CONCAT(DISTINCT c.participant_id))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(&participantName)
  85. // if tx.Error != nil {
  86. // logx.Error(err)
  87. // return nil, tx.Error
  88. // }
  89. // // 承接方转义
  90. // resp.TrainJobs = append(resp.TrainJobs, types.TrainJob{
  91. // ParticipantName: participantName,
  92. // Name: task.Name,
  93. // Strategy: int(task.Strategy),
  94. // SynergyStatus: enum.SynergyStatus(task.SynergyStatus).String(),
  95. // Status: task.Status,
  96. // })
  97. //
  98. //}
  99. return resp, nil
  100. }

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.