...
|
...
|
@@ -91,6 +91,7 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
|
}
|
|
|
leaderData := leaderList[0]
|
|
|
nowTime := time.Now()
|
|
|
nowEndTime := dayEndTime(nowTime)
|
|
|
newTask := domain.Task{
|
|
|
Id: 0,
|
|
|
CreatedAt: time.Time{},
|
...
|
...
|
@@ -116,7 +117,6 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error())
|
|
|
}
|
|
|
nowEndTime := dayEndTime(nowTime)
|
|
|
newTaskStage := []*domain.TaskStage{
|
|
|
{
|
|
|
Id: 0,
|
...
|
...
|
@@ -143,11 +143,15 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
|
RealCompletedAt: 0,
|
|
|
},
|
|
|
}
|
|
|
|
|
|
err = taskStageRepo.Save(newTaskStage)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error())
|
|
|
}
|
|
|
newTask.CurrentStage = *newTaskStage[0]
|
|
|
err = taskRepo.Save(&newTask)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务失败:"+err.Error())
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
...
|
...
|
@@ -282,11 +286,17 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//更新当前 执行的里程碑
|
|
|
err = taskStageRepo.Save(stageList)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
for _, val := range stageList {
|
|
|
if val.RealCompletedAt == 0 {
|
|
|
taskData.CurrentStage = *val
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
err = taskRepo.Save(taskData)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -770,6 +780,7 @@ func (srv TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]i |
|
|
case 5:
|
|
|
taskData.StageE = stage
|
|
|
}
|
|
|
|
|
|
}
|
|
|
result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
|
|
|
result["taskStageAnomaly"] = taskStageAnomalyCnt
|
...
|
...
|
@@ -896,38 +907,43 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction |
|
|
taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
var taskList []*domain.Task
|
|
|
var taskStages []*domain.TaskStage
|
|
|
for _, val := range param {
|
|
|
taskData, err := taskRepo.FindOne(map[string]interface{}{"id": val.TaskId})
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "找不到任务数据"+err.Error())
|
|
|
}
|
|
|
_, stageList, err := taskStageRepo.Find(map[string]interface{}{"ids": []int{val.TaskStageCheck.Id}})
|
|
|
_, stageList, err := taskStageRepo.Find(map[string]interface{}{"taskId": []int{val.TaskId}})
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "找不到任务里程碑数据"+err.Error())
|
|
|
}
|
|
|
if val.AnomalyState == domain.AnomalyState1 {
|
|
|
taskData.Anomaly = 0
|
|
|
}
|
|
|
if len(stageList) > 0 {
|
|
|
stageList[0].RealCompletedAt = val.TaskStageCheck.RealCompletedAt
|
|
|
taskStages = append(taskStages, stageList[0])
|
|
|
if stageList[0].PlanCompletedAt < stageList[0].RealCompletedAt {
|
|
|
for _, val2 := range stageList {
|
|
|
if val2.Id == val.TaskStageCheck.Id {
|
|
|
continue
|
|
|
}
|
|
|
val2.RealCompletedAt = val.TaskStageCheck.RealCompletedAt
|
|
|
if val2.PlanCompletedAt < val2.RealCompletedAt {
|
|
|
taskData.WarnFlag = domain.TaskWarn
|
|
|
} else {
|
|
|
taskData.WarnFlag = domain.TaskWarnNull
|
|
|
}
|
|
|
break
|
|
|
}
|
|
|
|
|
|
taskList = append(taskList, taskData)
|
|
|
}
|
|
|
err := taskStageRepo.Save(taskStages)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务里程碑数据"+err.Error())
|
|
|
}
|
|
|
for _, val := range taskList {
|
|
|
err = taskRepo.Save(val)
|
|
|
taskData.CurrentStage = domain.TaskStage{}
|
|
|
//设置下一个 待执行的里程碑
|
|
|
for _, val2 := range stageList {
|
|
|
if val2.RealCompletedAt == 0 {
|
|
|
taskData.CurrentStage = *val2
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
err = taskStageRepo.Save(stageList)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务里程碑数据"+err.Error())
|
|
|
}
|
|
|
err = taskRepo.Save(taskData)
|
|
|
if err != nil {
|
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存任务数据"+err.Error())
|
|
|
}
|
...
|
...
|
|