作者 郑周

1. 状态增加初始值

2. 判断是否首次提交记录
@@ -477,7 +477,7 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess) @@ -477,7 +477,7 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess)
477 TaskLeader: taskList[0].Leader, 477 TaskLeader: taskList[0].Leader,
478 AssistLevel: 0, 478 AssistLevel: 0,
479 AssistContent: "", 479 AssistContent: "",
480 - AnomalyState: domain.AnomalyState, 480 + AnomalyState: domain.AnomalyStateInit,
481 TaskStages: []domain.TaskStage{}, 481 TaskStages: []domain.TaskStage{},
482 TaskStageCheck: domain.TaskStage{}, 482 TaskStageCheck: domain.TaskStage{},
483 } 483 }
@@ -1262,12 +1262,19 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1262,12 +1262,19 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1262 if err != nil { 1262 if err != nil {
1263 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取里程碑数据:"+err.Error()) 1263 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取里程碑数据:"+err.Error())
1264 } 1264 }
  1265 +
  1266 + // 首次提交任务记录(未过期前可以多次编辑提交)
  1267 + var isFirstSubmit = false
1265 for i := range taskRecords { 1268 for i := range taskRecords {
1266 it := taskRecords[i] 1269 it := taskRecords[i]
1267 if v, ok := recordMap[it.Id]; ok { 1270 if v, ok := recordMap[it.Id]; ok {
1268 it.AssistLevel = v.AssistLevel // 更新上级辅导情况 1271 it.AssistLevel = v.AssistLevel // 更新上级辅导情况
1269 it.AssistContent = v.AssistContent // 更新上级辅导内容 1272 it.AssistContent = v.AssistContent // 更新上级辅导内容
1270 1273
  1274 + if !isFirstSubmit && it.AnomalyState == domain.AnomalyStateInit {
  1275 + isFirstSubmit = true
  1276 + }
  1277 +
1271 var anomalyState = domain.AnomalyState0 1278 var anomalyState = domain.AnomalyState0
1272 key := fmt.Sprintf("%s-%s", v.Category, v.Name) 1279 key := fmt.Sprintf("%s-%s", v.Category, v.Name)
1273 if item, ok := contentCategoryMap[key]; ok { 1280 if item, ok := contentCategoryMap[key]; ok {
@@ -1317,7 +1324,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1317,7 +1324,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1317 } 1324 }
1318 1325
1319 if len(taskRecords) > 0 { 1326 if len(taskRecords) > 0 {
1320 - err := taskService.NewTaskService().ReplyTaskStage(transactionContext, taskRecords) 1327 + err := taskService.NewTaskService().ReplyTaskStage(transactionContext, taskRecords, isFirstSubmit)
1321 if err != nil { 1328 if err != nil {
1322 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "更新里程碑数据:"+err.Error()) 1329 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "更新里程碑数据:"+err.Error())
1323 } 1330 }
@@ -903,7 +903,7 @@ func (srv TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[s @@ -903,7 +903,7 @@ func (srv TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[s
903 } 903 }
904 904
905 // ReplyTaskStage 根据每日的任务反馈 ,更新任务里程碑 905 // ReplyTaskStage 根据每日的任务反馈 ,更新任务里程碑
906 -func (srv TaskService) ReplyTaskStage(transactionContext application.TransactionContext, param []*domain.TaskRecord) error { 906 +func (srv TaskService) ReplyTaskStage(transactionContext application.TransactionContext, param []*domain.TaskRecord, isFirstSubmit bool) error {
907 taskRepo := factory.CreateTaskRepository(map[string]interface{}{ 907 taskRepo := factory.CreateTaskRepository(map[string]interface{}{
908 "transactionContext": transactionContext, 908 "transactionContext": transactionContext,
909 }) 909 })
@@ -927,7 +927,8 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction @@ -927,7 +927,8 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction
927 continue 927 continue
928 } 928 }
929 929
930 - if val.AnomalyState == domain.AnomalyState0 { 930 + // 避免当天多次编辑提交,数量递增
  931 + if isFirstSubmit && val.AnomalyState == domain.AnomalyState0 {
931 taskData.Anomaly += 1 932 taskData.Anomaly += 1
932 } 933 }
933 trimSpace := strings.TrimLeft(val.AssistContent, "\n") // 去掉前换行符 934 trimSpace := strings.TrimLeft(val.AssistContent, "\n") // 去掉前换行符
@@ -10,7 +10,7 @@ const ( @@ -10,7 +10,7 @@ const (
10 ) 10 )
11 11
12 const ( 12 const (
13 - AnomalyState int = -1 // 初始值 13 + AnomalyStateInit int = -1 // 初始值
14 AnomalyState0 int = 0 // 异常 14 AnomalyState0 int = 0 // 异常
15 AnomalyState1 int = 1 // 正常 15 AnomalyState1 int = 1 // 正常
16 ) 16 )
@@ -27,7 +27,7 @@ type TaskRecord struct { @@ -27,7 +27,7 @@ type TaskRecord struct {
27 TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"` 27 TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"`
28 AssistLevel int `json:"assistLevel" comment:"上级辅导情况"` 28 AssistLevel int `json:"assistLevel" comment:"上级辅导情况"`
29 AssistContent string `json:"assistContent" comment:"上级辅导内容"` 29 AssistContent string `json:"assistContent" comment:"上级辅导内容"`
30 - AnomalyState int `json:"anomalyState" comment:"异常是否反馈状态(0异常、1正常)"` 30 + AnomalyState int `json:"anomalyState" comment:"异常是否反馈状态(-1初始状态、0异常、1正常)"`
31 TaskStages []TaskStage `json:"taskStages" comment:"里程碑列表"` 31 TaskStages []TaskStage `json:"taskStages" comment:"里程碑列表"`
32 TaskStageCheck TaskStage `json:"taskStageCheck" comment:"提交的里程碑"` 32 TaskStageCheck TaskStage `json:"taskStageCheck" comment:"提交的里程碑"`
33 CreatedAt time.Time `json:"createdAt" comment:"创建时间"` 33 CreatedAt time.Time `json:"createdAt" comment:"创建时间"`