push notice when new hpc job submitted

Former-commit-id: 459845bff6477ce1a0b43cba3eac68aa2c7d1223
This commit is contained in:
Jake 2024-05-09 19:05:16 +08:00
parent 4849b93853
commit 8d8d6a9822
1 changed files with 17 additions and 0 deletions

View File

@ -2,10 +2,12 @@ package hpc
import (
"context"
clientCore "gitlink.org.cn/JointCloud/pcm-coordinator/api/client"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"k8s.io/apimachinery/pkg/util/json"
"math/rand"
"strconv"
"time"
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
@ -88,6 +90,21 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t
if tx.Error != nil {
return nil, tx.Error
}
adapterId, _ := strconv.ParseUint(req.AdapterId, 10, 64)
adapterName := ""
tx.Table("t_adapter").Select("name").Where("id=?", adapterId).Find(&adapterName)
noticeInfo := clientCore.NoticeInfo{
AdapterId: int64(adapterId),
AdapterName: adapterName,
NoticeType: "create",
TaskName: req.Name,
Incident: "任务创建中",
CreatedTime: time.Now(),
}
result := l.svcCtx.DbEngin.Table("t_notice").Create(&noticeInfo)
if result.Error != nil {
logx.Errorf("Task creation failure, err: %v", result.Error)
}
// todo mq task manage
//reqMessage, err := json.Marshal(mqInfo)
//if err != nil {