...
|
...
|
@@ -39,9 +39,6 @@ func (rs *NodeTaskService) SendEvaluationNode() error { |
|
|
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
|
|
//ttaffAssessRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
//
|
|
|
|
|
|
projectIdsMap := map[int64]*domain.EvaluationProject{}
|
|
|
cycleIdsMap := map[int64]*domain.EvaluationCycle{}
|
|
|
for i := range tasks {
|
...
|
...
|
@@ -74,7 +71,7 @@ func (rs *NodeTaskService) SendEvaluationNode() error { |
|
|
cycleIdsMap[cycles[i].Id] = cycles[i]
|
|
|
}
|
|
|
|
|
|
staffAssessTaskMap := map[int64]*command.CreateStaffAssessTask{}
|
|
|
staffAssessService := service.NewStaffAssessServeice()
|
|
|
for i := range tasks {
|
|
|
task := tasks[i]
|
|
|
// 项目
|
...
|
...
|
@@ -108,47 +105,44 @@ func (rs *NodeTaskService) SendEvaluationNode() error { |
|
|
fmCycleStartTime := cycleTimeStart.Format("2006-1-2 15:04:05")
|
|
|
fmCycleTimeEnd := cycleTimeEnd.Format("2006-1-2 15:04:05")
|
|
|
|
|
|
var csat, staffOk = staffAssessTaskMap[task.ProjectId]
|
|
|
if !staffOk {
|
|
|
csat = &command.CreateStaffAssessTask{
|
|
|
CompanyId: int(project.CompanyId),
|
|
|
EvaluationProjectId: int(project.Id),
|
|
|
EvaluationProjectName: project.Name,
|
|
|
CycleId: project.CycleId,
|
|
|
}
|
|
|
|
|
|
// 周期名称
|
|
|
if cycle, ok := cycleIdsMap[project.CycleId]; ok {
|
|
|
csat.CycleName = cycle.Name
|
|
|
}
|
|
|
|
|
|
// 接收人
|
|
|
csat.ExecutorId = make([]int, 0)
|
|
|
for rIndex := range project.Recipients {
|
|
|
vInt, _ := strconv.Atoi(project.Recipients[rIndex])
|
|
|
csat.ExecutorId = append(csat.ExecutorId, vInt)
|
|
|
}
|
|
|
|
|
|
// FIXME 这里设置时间可能会有歧义,目前原型设计时间均一致,所以直接选取第一个获取到的周期时间,作为本周期的起止和截止时间
|
|
|
csat.BeginTime = fmCycleStartTime
|
|
|
csat.EndTime = fmCycleTimeEnd
|
|
|
|
|
|
staffAssessTaskMap[task.ProjectId] = csat
|
|
|
csat := &command.CreateStaffAssessTask{
|
|
|
CompanyId: int(project.CompanyId),
|
|
|
EvaluationProjectId: int(project.Id),
|
|
|
EvaluationProjectName: project.Name,
|
|
|
CycleId: project.CycleId,
|
|
|
StepList: make([]command.AssessTaskStep, 0),
|
|
|
}
|
|
|
|
|
|
// 周期名称
|
|
|
if cycle, ok := cycleIdsMap[project.CycleId]; ok {
|
|
|
csat.CycleName = cycle.Name
|
|
|
}
|
|
|
|
|
|
if csat.StepList == nil {
|
|
|
csat.StepList = make([]command.AssessTaskStep, 0)
|
|
|
// 接收人
|
|
|
csat.ExecutorId = make([]int, 0)
|
|
|
for rIndex := range project.Recipients {
|
|
|
vInt, _ := strconv.Atoi(project.Recipients[rIndex])
|
|
|
csat.ExecutorId = append(csat.ExecutorId, vInt)
|
|
|
}
|
|
|
|
|
|
csat.BeginTime = fmCycleStartTime
|
|
|
csat.EndTime = fmCycleTimeEnd
|
|
|
csat.StepList = append(csat.StepList, command.AssessTaskStep{
|
|
|
SortBy: i,
|
|
|
SortBy: task.NodeSort,
|
|
|
LinkNodeId: int(task.NodeId),
|
|
|
LinkNodeName: task.NodeName,
|
|
|
LinkNodeType: task.NodeType,
|
|
|
BeginTime: fmCycleStartTime,
|
|
|
EndTime: fmCycleTimeEnd,
|
|
|
})
|
|
|
|
|
|
// 创建发送任务
|
|
|
_, err := staffAssessService.CreateStaffAssessTask(transactionContext, csat)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
} else {
|
|
|
task.NextSentAt = nil
|
|
|
task.NextSentAt = nil // 项目不存在,取消周期任务发送
|
|
|
}
|
|
|
|
|
|
task, err := taskRepository.Insert(task)
|
...
|
...
|
@@ -157,15 +151,6 @@ func (rs *NodeTaskService) SendEvaluationNode() error { |
|
|
}
|
|
|
}
|
|
|
|
|
|
staffAssessService := service.NewStaffAssessServeice()
|
|
|
for i := range staffAssessTaskMap {
|
|
|
staffAssessTask := staffAssessTaskMap[i]
|
|
|
_, err := staffAssessService.CreateStaffAssessTask(transactionContext, staffAssessTask)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
|