作者 郑周

1. 项目启动时,生成指标任务

... ... @@ -2,17 +2,18 @@ package service
import (
"fmt"
"strconv"
"strings"
"time"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
taskCommand "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/task/command"
taskService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/task/service"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
"strconv"
"strings"
"time"
)
type EvaluationProjectService struct {
... ... @@ -577,10 +578,17 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 项目中指标任务负责人
var principalId = 0
var projectTaskService = taskService.NewTaskService()
if len(project.PrincipalId) > 0 {
intId, _ := strconv.Atoi(project.PrincipalId)
principalId = intId
}
now := time.Now().Local()
year, month, day := now.Date()
nowO := time.Date(year, month, day, 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻
for i := range project.Template.LinkNodes {
node := project.Template.LinkNodes[i]
task := &domain.NodeTask{
... ... @@ -620,6 +628,23 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 任务指标生成任务
for j := range node.NodeContents {
content := node.NodeContents[j]
if content.IndicatorType == domain.IndicatorTypeTask {
if principalId == 0 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "请选择任务负责人")
}
err := projectTaskService.CreateTask(transactionContext, &taskCommand.CreateTaskCommand{
Name: content.Name,
LeaderId: principalId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
}
}
err = rs.generateEvaluationItemUsed(transactionContext, project)
... ...
... ... @@ -14,6 +14,11 @@ import (
type TaskService struct{}
func NewTaskService() *TaskService {
s := &TaskService{}
return s
}
func dayEndTime(t time.Time) time.Time {
y, m, d := t.Local().Date()
t2 := time.Date(y, m, d, 23, 59, 59, 0, time.Local)
... ...