...
|
...
|
@@ -510,7 +510,60 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess) |
|
|
}
|
|
|
}
|
|
|
//TODO 设置手动创建的task
|
|
|
_, taskList, err := taskRepo.Find(map[string]interface{}{
|
|
|
"leaderId": projectData.PrincipalId,
|
|
|
"status": domain.TaskRunning,
|
|
|
"createdBy": 1,
|
|
|
"gtEndTime": time.Now().Unix(),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取评估项指标任务task信息"+err.Error())
|
|
|
}
|
|
|
for index := range taskList {
|
|
|
//获取里程碑数据
|
|
|
_, taskStageList, err := taskStageRepo.Find(map[string]interface{}{
|
|
|
"taskId": taskList[index].Id,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, "获取评估项指标任务里程碑TaskStage信息"+err.Error())
|
|
|
}
|
|
|
newTaskRecord := domain.TaskRecord{
|
|
|
Id: 0,
|
|
|
CompanyId: staffAssess.CompanyId,
|
|
|
StaffAssessId: staffAssess.Id,
|
|
|
TaskId: taskList[index].Id,
|
|
|
TaskCategory: "",
|
|
|
TaskName: taskList[index].Name,
|
|
|
TaskAlias: taskList[index].Alias,
|
|
|
TaskLeader: taskList[index].Leader,
|
|
|
AssistLevel: 0,
|
|
|
AssistContent: "",
|
|
|
AnomalyState: domain.AnomalyStateInit,
|
|
|
AssistState: domain.AssistStateInit,
|
|
|
TaskStages: []domain.TaskStage{},
|
|
|
TaskStageCheck: domain.TaskStage{},
|
|
|
TaskCreatedBy: taskList[index].CreatedBy,
|
|
|
}
|
|
|
sort.Slice(taskStageList, func(i, j int) bool {
|
|
|
return taskStageList[i].SortBy < taskStageList[j].SortBy
|
|
|
})
|
|
|
for i2, val2 := range taskStageList {
|
|
|
newTaskRecord.TaskStages = append(newTaskRecord.TaskStages, *taskStageList[i2])
|
|
|
if newTaskRecord.TaskStageCheck.Id == 0 {
|
|
|
//按顺序第一个未完成的里程碑
|
|
|
if val2.RealCompletedAt <= 0 {
|
|
|
newTaskRecord.TaskStageCheck = *taskStageList[i2]
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 没有里程碑也下发任务
|
|
|
if len(newTaskRecord.TaskStages) > 0 && newTaskRecord.TaskStageCheck.Id == 0 {
|
|
|
// 里程碑已全部完成,不发任务
|
|
|
} else {
|
|
|
taskRecordList = append(taskRecordList, &newTaskRecord)
|
|
|
}
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
|