作者 tangxvhui

调整 task 任务的更新内容

... ... @@ -13,6 +13,7 @@ type TaskInfoAdapter struct {
EndTime int64 `json:"endTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间
UseEndtime int `json:"useEndTime"` // 是否应用任务截止的时间;默认值0:不应用,1:应用
AssistFlagMax int `json:"assist_flag_max"` // 辅导异常标记最大值
CreatedBy int `json:"createdBy"` // 任务数据的来源
RelatedUserId []string `json:"relatedUserId"` // 相关的员工id
RelatedUser []UserData `json:"relatedUser"` // 相关的员工id
StageList []TaskStage `json:"stageList"`
... ...
... ... @@ -3,9 +3,10 @@ package command
type UpdateTaskCommand struct {
CompanyId int `json:"-"`
Id int `json:"id,string"`
Alias string `json:"alias"` //任务名称
LevelName string `json:"levelName"` //优先级
RelatedUserId []string `json:"relatedUserId"` //相关人员id
Alias string `json:"alias"` // 任务名称
LeaderId string `json:"leaderId"` // 负责人id
LevelName string `json:"levelName"` // 优先级
RelatedUserId []string `json:"relatedUserId"` // 相关人员id
SortBy int `json:"sortBy"` // 优先级排序;值越小优先级越高
EndTime int64 `json:"endTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间
UseEndtime int `json:"useEndTime"` // 是否应用任务截止的时间;默认值0:不应用,1:应用
... ...
... ... @@ -307,6 +307,19 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//检查leaderid
_, leaderList, err := userRepo.Find(map[string]interface{}{"id": param.LeaderId, "limit": 1})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(leaderList) == 0 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "负责人数据验证不通过")
}
if leaderList[0].CompanyId != int64(param.CompanyId) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "负责人数据验证不通过")
}
//更新任务的相关人员
relatedUserIds := []int{}
for _, val := range param.RelatedUserId {
... ... @@ -374,17 +387,12 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]
oldStage.SortBy = i + 1
oldStage.Name = val2.Name
oldStage.SetPlanCompleted(t)
//if ok := oldStage.SetPlanCompleted(t); ok {
//markStage = append(markStage, *oldStage)
// }
}
stageList = append(stageList, newStageList...)
//查询是否已经有每日评估
taskRecordRepo := factory.CreateTaskRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
for _, v := range stageList {
if v.DeletedAt != nil {
cnt, _, err := taskRecordRepo.Find(map[string]interface{}{
... ... @@ -405,6 +413,13 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if taskData.CreatedBy == 1 {
taskData.Leader = domain.TaskLeader{
Id: leaderList[0].Id,
Account: leaderList[0].Account,
Name: leaderList[0].Name,
}
}
taskData.SetCurrentStage(stageList)
taskData.SetSortBy(param.SortBy)
//处理endTime
... ... @@ -413,7 +428,6 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string]
} else {
taskData.EndTime = dayEndTime(time.Unix(param.EndTime, 10)).Unix()
}
taskData.UseEndTime = param.UseEndtime
taskData.AssistFlagMax = param.AssistFlagMax
err = taskRepo.Save(taskData)
... ... @@ -575,7 +589,6 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task
},
Status: int(taskData.Status),
StatusDescription: taskData.Status.Named(),
// Level: taskData.Level,
LevelName: taskData.LevelName,
SortBy: int(taskData.SortBy),
EndTime: taskData.EndTime,
... ... @@ -584,6 +597,7 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task
RelatedUser: []adapter.UserData{},
StageList: []adapter.TaskStage{},
AssistFlagMax: taskData.AssistFlagMax,
CreatedBy: taskData.CreatedBy,
}
for _, val := range relatedUserList {
idStr := strconv.Itoa(int(val.Id))
... ...