|
@@ -91,6 +91,7 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
@@ -91,6 +91,7 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
91
|
}
|
91
|
}
|
92
|
leaderData := leaderList[0]
|
92
|
leaderData := leaderList[0]
|
93
|
nowTime := time.Now()
|
93
|
nowTime := time.Now()
|
|
|
94
|
+ nowEndTime := dayEndTime(nowTime)
|
94
|
newTask := domain.Task{
|
95
|
newTask := domain.Task{
|
95
|
Id: 0,
|
96
|
Id: 0,
|
96
|
CreatedAt: time.Time{},
|
97
|
CreatedAt: time.Time{},
|
|
@@ -116,7 +117,6 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
@@ -116,7 +117,6 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
116
|
if err != nil {
|
117
|
if err != nil {
|
117
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error())
|
118
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error())
|
118
|
}
|
119
|
}
|
119
|
- nowEndTime := dayEndTime(nowTime)
|
|
|
120
|
newTaskStage := []*domain.TaskStage{
|
120
|
newTaskStage := []*domain.TaskStage{
|
121
|
{
|
121
|
{
|
122
|
Id: 0,
|
122
|
Id: 0,
|
|
@@ -143,11 +143,15 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
@@ -143,11 +143,15 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
143
|
RealCompletedAt: 0,
|
143
|
RealCompletedAt: 0,
|
144
|
},
|
144
|
},
|
145
|
}
|
145
|
}
|
146
|
-
|
|
|
147
|
err = taskStageRepo.Save(newTaskStage)
|
146
|
err = taskStageRepo.Save(newTaskStage)
|
148
|
if err != nil {
|
147
|
if err != nil {
|
149
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error())
|
148
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error())
|
150
|
}
|
149
|
}
|
|
|
150
|
+ newTask.CurrentStage = *newTaskStage[0]
|
|
|
151
|
+ err = taskRepo.Save(&newTask)
|
|
|
152
|
+ if err != nil {
|
|
|
153
|
+ return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务失败:"+err.Error())
|
|
|
154
|
+ }
|
151
|
return nil
|
155
|
return nil
|
152
|
}
|
156
|
}
|
153
|
|
157
|
|
|
@@ -282,11 +286,17 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
@@ -282,11 +286,17 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
282
|
}
|
286
|
}
|
283
|
}
|
287
|
}
|
284
|
}
|
288
|
}
|
285
|
-
|
289
|
+ //更新当前 执行的里程碑
|
286
|
err = taskStageRepo.Save(stageList)
|
290
|
err = taskStageRepo.Save(stageList)
|
287
|
if err != nil {
|
291
|
if err != nil {
|
288
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
292
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
289
|
}
|
293
|
}
|
|
|
294
|
+ for _, val := range stageList {
|
|
|
295
|
+ if val.RealCompletedAt == 0 {
|
|
|
296
|
+ taskData.CurrentStage = *val
|
|
|
297
|
+ break
|
|
|
298
|
+ }
|
|
|
299
|
+ }
|
290
|
err = taskRepo.Save(taskData)
|
300
|
err = taskRepo.Save(taskData)
|
291
|
if err != nil {
|
301
|
if err != nil {
|
292
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
302
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -770,6 +780,7 @@ func (srv TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]i |
|
@@ -770,6 +780,7 @@ func (srv TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]i |
770
|
case 5:
|
780
|
case 5:
|
771
|
taskData.StageE = stage
|
781
|
taskData.StageE = stage
|
772
|
}
|
782
|
}
|
|
|
783
|
+
|
773
|
}
|
784
|
}
|
774
|
result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
|
785
|
result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
|
775
|
result["taskStageAnomaly"] = taskStageAnomalyCnt
|
786
|
result["taskStageAnomaly"] = taskStageAnomalyCnt
|
|
@@ -896,38 +907,43 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction |
|
@@ -896,38 +907,43 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction |
896
|
taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
|
907
|
taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
|
897
|
"transactionContext": transactionContext,
|
908
|
"transactionContext": transactionContext,
|
898
|
})
|
909
|
})
|
899
|
- var taskList []*domain.Task
|
|
|
900
|
- var taskStages []*domain.TaskStage
|
|
|
901
|
for _, val := range param {
|
910
|
for _, val := range param {
|
902
|
taskData, err := taskRepo.FindOne(map[string]interface{}{"id": val.TaskId})
|
911
|
taskData, err := taskRepo.FindOne(map[string]interface{}{"id": val.TaskId})
|
903
|
if err != nil {
|
912
|
if err != nil {
|
904
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "找不到任务数据"+err.Error())
|
913
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "找不到任务数据"+err.Error())
|
905
|
}
|
914
|
}
|
906
|
- _, stageList, err := taskStageRepo.Find(map[string]interface{}{"ids": []int{val.TaskStageCheck.Id}})
|
915
|
+ _, stageList, err := taskStageRepo.Find(map[string]interface{}{"taskId": []int{val.TaskId}})
|
907
|
if err != nil {
|
916
|
if err != nil {
|
908
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "找不到任务里程碑数据"+err.Error())
|
917
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "找不到任务里程碑数据"+err.Error())
|
909
|
}
|
918
|
}
|
910
|
if val.AnomalyState == domain.AnomalyState1 {
|
919
|
if val.AnomalyState == domain.AnomalyState1 {
|
911
|
taskData.Anomaly = 0
|
920
|
taskData.Anomaly = 0
|
912
|
}
|
921
|
}
|
913
|
- if len(stageList) > 0 {
|
|
|
914
|
- stageList[0].RealCompletedAt = val.TaskStageCheck.RealCompletedAt
|
|
|
915
|
- taskStages = append(taskStages, stageList[0])
|
|
|
916
|
- if stageList[0].PlanCompletedAt < stageList[0].RealCompletedAt {
|
922
|
+ for _, val2 := range stageList {
|
|
|
923
|
+ if val2.Id == val.TaskStageCheck.Id {
|
|
|
924
|
+ continue
|
|
|
925
|
+ }
|
|
|
926
|
+ val2.RealCompletedAt = val.TaskStageCheck.RealCompletedAt
|
|
|
927
|
+ if val2.PlanCompletedAt < val2.RealCompletedAt {
|
917
|
taskData.WarnFlag = domain.TaskWarn
|
928
|
taskData.WarnFlag = domain.TaskWarn
|
918
|
} else {
|
929
|
} else {
|
919
|
taskData.WarnFlag = domain.TaskWarnNull
|
930
|
taskData.WarnFlag = domain.TaskWarnNull
|
920
|
}
|
931
|
}
|
|
|
932
|
+ break
|
921
|
}
|
933
|
}
|
922
|
-
|
|
|
923
|
- taskList = append(taskList, taskData)
|
934
|
+ taskData.CurrentStage = domain.TaskStage{}
|
|
|
935
|
+ //设置下一个 待执行的里程碑
|
|
|
936
|
+ for _, val2 := range stageList {
|
|
|
937
|
+ if val2.RealCompletedAt == 0 {
|
|
|
938
|
+ taskData.CurrentStage = *val2
|
|
|
939
|
+ break
|
924
|
}
|
940
|
}
|
925
|
- err := taskStageRepo.Save(taskStages)
|
941
|
+ }
|
|
|
942
|
+ err = taskStageRepo.Save(stageList)
|
926
|
if err != nil {
|
943
|
if err != nil {
|
927
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务里程碑数据"+err.Error())
|
944
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务里程碑数据"+err.Error())
|
928
|
}
|
945
|
}
|
929
|
- for _, val := range taskList {
|
|
|
930
|
- err = taskRepo.Save(val)
|
946
|
+ err = taskRepo.Save(taskData)
|
931
|
if err != nil {
|
947
|
if err != nil {
|
932
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务数据"+err.Error())
|
948
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务数据"+err.Error())
|
933
|
}
|
949
|
}
|