|
@@ -510,7 +510,60 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess) |
|
@@ -510,7 +510,60 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess) |
510
|
}
|
510
|
}
|
511
|
}
|
511
|
}
|
512
|
//TODO 设置手动创建的task
|
512
|
//TODO 设置手动创建的task
|
|
|
513
|
+ _, taskList, err := taskRepo.Find(map[string]interface{}{
|
|
|
514
|
+ "leaderId": projectData.PrincipalId,
|
|
|
515
|
+ "status": domain.TaskRunning,
|
|
|
516
|
+ "createdBy": 1,
|
|
|
517
|
+ "gtEndTime": time.Now().Unix(),
|
|
|
518
|
+ })
|
|
|
519
|
+ if err != nil {
|
|
|
520
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取评估项指标任务task信息"+err.Error())
|
|
|
521
|
+ }
|
|
|
522
|
+ for index := range taskList {
|
|
|
523
|
+ //获取里程碑数据
|
|
|
524
|
+ _, taskStageList, err := taskStageRepo.Find(map[string]interface{}{
|
|
|
525
|
+ "taskId": taskList[index].Id,
|
|
|
526
|
+ })
|
|
|
527
|
+ if err != nil {
|
|
|
528
|
+ return nil, application.ThrowError(application.ARG_ERROR, "获取评估项指标任务里程碑TaskStage信息"+err.Error())
|
|
|
529
|
+ }
|
|
|
530
|
+ newTaskRecord := domain.TaskRecord{
|
|
|
531
|
+ Id: 0,
|
|
|
532
|
+ CompanyId: staffAssess.CompanyId,
|
|
|
533
|
+ StaffAssessId: staffAssess.Id,
|
|
|
534
|
+ TaskId: taskList[index].Id,
|
|
|
535
|
+ TaskCategory: "",
|
|
|
536
|
+ TaskName: taskList[index].Name,
|
|
|
537
|
+ TaskAlias: taskList[index].Alias,
|
|
|
538
|
+ TaskLeader: taskList[index].Leader,
|
|
|
539
|
+ AssistLevel: 0,
|
|
|
540
|
+ AssistContent: "",
|
|
|
541
|
+ AnomalyState: domain.AnomalyStateInit,
|
|
|
542
|
+ AssistState: domain.AssistStateInit,
|
|
|
543
|
+ TaskStages: []domain.TaskStage{},
|
|
|
544
|
+ TaskStageCheck: domain.TaskStage{},
|
|
|
545
|
+ TaskCreatedBy: taskList[index].CreatedBy,
|
|
|
546
|
+ }
|
|
|
547
|
+ sort.Slice(taskStageList, func(i, j int) bool {
|
|
|
548
|
+ return taskStageList[i].SortBy < taskStageList[j].SortBy
|
|
|
549
|
+ })
|
|
|
550
|
+ for i2, val2 := range taskStageList {
|
|
|
551
|
+ newTaskRecord.TaskStages = append(newTaskRecord.TaskStages, *taskStageList[i2])
|
|
|
552
|
+ if newTaskRecord.TaskStageCheck.Id == 0 {
|
|
|
553
|
+ //按顺序第一个未完成的里程碑
|
|
|
554
|
+ if val2.RealCompletedAt <= 0 {
|
|
|
555
|
+ newTaskRecord.TaskStageCheck = *taskStageList[i2]
|
|
|
556
|
+ }
|
|
|
557
|
+ }
|
|
|
558
|
+ }
|
513
|
|
559
|
|
|
|
560
|
+ // 没有里程碑也下发任务
|
|
|
561
|
+ if len(newTaskRecord.TaskStages) > 0 && newTaskRecord.TaskStageCheck.Id == 0 {
|
|
|
562
|
+ // 里程碑已全部完成,不发任务
|
|
|
563
|
+ } else {
|
|
|
564
|
+ taskRecordList = append(taskRecordList, &newTaskRecord)
|
|
|
565
|
+ }
|
|
|
566
|
+ }
|
514
|
if err := transactionContext.CommitTransaction(); err != nil {
|
567
|
if err := transactionContext.CommitTransaction(); err != nil {
|
515
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
568
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
516
|
}
|
569
|
}
|