作者 郑周

1. 状态增加初始值

2. 判断是否首次提交记录
... ... @@ -477,7 +477,7 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess)
TaskLeader: taskList[0].Leader,
AssistLevel: 0,
AssistContent: "",
AnomalyState: domain.AnomalyState,
AnomalyState: domain.AnomalyStateInit,
TaskStages: []domain.TaskStage{},
TaskStageCheck: domain.TaskStage{},
}
... ...
... ... @@ -1262,12 +1262,19 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取里程碑数据:"+err.Error())
}
// 首次提交任务记录(未过期前可以多次编辑提交)
var isFirstSubmit = false
for i := range taskRecords {
it := taskRecords[i]
if v, ok := recordMap[it.Id]; ok {
it.AssistLevel = v.AssistLevel // 更新上级辅导情况
it.AssistContent = v.AssistContent // 更新上级辅导内容
if !isFirstSubmit && it.AnomalyState == domain.AnomalyStateInit {
isFirstSubmit = true
}
var anomalyState = domain.AnomalyState0
key := fmt.Sprintf("%s-%s", v.Category, v.Name)
if item, ok := contentCategoryMap[key]; ok {
... ... @@ -1317,7 +1324,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
}
if len(taskRecords) > 0 {
err := taskService.NewTaskService().ReplyTaskStage(transactionContext, taskRecords)
err := taskService.NewTaskService().ReplyTaskStage(transactionContext, taskRecords, isFirstSubmit)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "更新里程碑数据:"+err.Error())
}
... ...
... ... @@ -903,7 +903,7 @@ func (srv TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[s
}
// ReplyTaskStage 根据每日的任务反馈 ,更新任务里程碑
func (srv TaskService) ReplyTaskStage(transactionContext application.TransactionContext, param []*domain.TaskRecord) error {
func (srv TaskService) ReplyTaskStage(transactionContext application.TransactionContext, param []*domain.TaskRecord, isFirstSubmit bool) error {
taskRepo := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
... ... @@ -927,7 +927,8 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction
continue
}
if val.AnomalyState == domain.AnomalyState0 {
// 避免当天多次编辑提交,数量递增
if isFirstSubmit && val.AnomalyState == domain.AnomalyState0 {
taskData.Anomaly += 1
}
trimSpace := strings.TrimLeft(val.AssistContent, "\n") // 去掉前换行符
... ...
... ... @@ -10,9 +10,9 @@ const (
)
const (
AnomalyState int = -1 // 初始值
AnomalyState0 int = 0 // 异常
AnomalyState1 int = 1 // 正常
AnomalyStateInit int = -1 // 初始值
AnomalyState0 int = 0 // 异常
AnomalyState1 int = 1 // 正常
)
// TaskRecord 任务反馈情况记录
... ... @@ -27,7 +27,7 @@ type TaskRecord struct {
TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"`
AssistLevel int `json:"assistLevel" comment:"上级辅导情况"`
AssistContent string `json:"assistContent" comment:"上级辅导内容"`
AnomalyState int `json:"anomalyState" comment:"异常是否反馈状态(0异常、1正常)"`
AnomalyState int `json:"anomalyState" comment:"异常是否反馈状态(-1初始状态、0异常、1正常)"`
TaskStages []TaskStage `json:"taskStages" comment:"里程碑列表"`
TaskStageCheck TaskStage `json:"taskStageCheck" comment:"提交的里程碑"`
CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
... ...