作者 tangxvhui

geng xi

... ... @@ -115,9 +115,7 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "创建任务失败:"+err.Error())
}
nowEndTime := dayZeroTime(nowTime)
nowEndTime := dayEndTime(nowTime)
newTaskStage := []*domain.TaskStage{
{
Id: 0,
... ... @@ -144,6 +142,7 @@ 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())
... ... @@ -240,7 +239,6 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "请填写里程碑完成时间")
}
t = dayEndTime(t)
if i > 0 {
if lastPlanCompletedAt.After(t) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "里程碑["+val2.Name+"]完成时间填写错误")
... ... @@ -253,9 +251,10 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]
TaskId: taskData.Id,
Name: val2.Name,
SortBy: i + 1,
PlanCompletedAt: t.Unix(),
PlanCompletedAt: 0,
RealCompletedAt: 0,
}
newStage.SetPlanCompleted(t)
newStageList = append(newStageList, &newStage)
continue
}
... ... @@ -266,7 +265,7 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]
oldStage.DeletedAt = nil
oldStage.SortBy = i + 1
oldStage.Name = val2.Name
if ok := oldStage.PlanCompleted(t); ok {
if ok := oldStage.SetPlanCompleted(t); ok {
markStage = append(markStage, *oldStage)
}
}
... ...
... ... @@ -52,8 +52,8 @@ func (t TaskStage) StatusDescription() string {
return str
}
// 计划完成是否变更
func (t *TaskStage) PlanCompleted(now time.Time) bool {
// 计划完成时间是否变更
func (t *TaskStage) SetPlanCompleted(now time.Time) bool {
if t.RealCompletedAt != 0 {
return false
}
... ... @@ -65,6 +65,11 @@ func (t *TaskStage) PlanCompleted(now time.Time) bool {
return true
}
func (t *TaskStage) SetRealCompleted(now time.Time) {
nowDay := t.dayEndTime(now)
t.RealCompletedAt = nowDay.Unix()
}
func (t TaskStage) dayEndTime(now time.Time) time.Time {
yyyy, m, d := now.Local().Date()
endTime := time.Date(yyyy, m, d, 23, 59, 59, 0, time.Local)
... ...