作者 tangxvhui
@@ -483,6 +483,7 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess) @@ -483,6 +483,7 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess)
483 AssistLevel: 0, 483 AssistLevel: 0,
484 AssistContent: "", 484 AssistContent: "",
485 AnomalyState: domain.AnomalyStateInit, 485 AnomalyState: domain.AnomalyStateInit,
  486 + AssistState: domain.AssistStateInit,
486 TaskStages: []domain.TaskStage{}, 487 TaskStages: []domain.TaskStage{},
487 TaskStageCheck: domain.TaskStage{}, 488 TaskStageCheck: domain.TaskStage{},
488 TaskCreatedBy: taskList[0].CreatedBy, 489 TaskCreatedBy: taskList[0].CreatedBy,
@@ -1277,34 +1277,37 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1277,34 +1277,37 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1277 it.AssistContent = v.AssistContent // 更新上级辅导内容 1277 it.AssistContent = v.AssistContent // 更新上级辅导内容
1278 it.RemarkContent = make([]domain.RemarkText, 0) // 更新填写反馈内容 1278 it.RemarkContent = make([]domain.RemarkText, 0) // 更新填写反馈内容
1279 1279
1280 - var anomalyState = domain.AnomalyState0 1280 + var anomalyState = domain.AnomalyState0 // 反馈异常
1281 key := fmt.Sprintf("%s-%s", v.Category, v.Name) 1281 key := fmt.Sprintf("%s-%s", v.Category, v.Name)
1282 - // 反馈内容填写 1282 + // 反馈内容填写(区分:一、模板分类中的反馈内容 二、模板的反馈内容
1283 if item, ok := contentCategoryMap[key]; ok { 1283 if item, ok := contentCategoryMap[key]; ok {
1284 it.RemarkContent = append(it.RemarkContent, item.Remark...) 1284 it.RemarkContent = append(it.RemarkContent, item.Remark...)
1285 - for _, remark := range item.Remark {  
1286 - trimSpace := strings.TrimLeft(remark.RemarkText, "\n") // 去掉前换行符  
1287 - trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符  
1288 - trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符  
1289 - if !(len(trimSpace) == 0 || trimSpace == "无") { // 有一个填写项就恢复正常状态  
1290 - anomalyState = domain.AnomalyState1  
1291 - break  
1292 - }  
1293 - }  
1294 } else { 1285 } else {
1295 it.RemarkContent = append(it.RemarkContent, v.RemarkContent...) 1286 it.RemarkContent = append(it.RemarkContent, v.RemarkContent...)
1296 } 1287 }
1297 - //if anomalyState == domain.AnomalyState0 {  
1298 - // trimSpace := strings.TrimLeft(it.AssistContent, "\n") // 去掉前换行符  
1299 - // trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符  
1300 - // trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符  
1301 - // // 上级填写内容有值,选项是已辅导,变为正常  
1302 - // if !(len(trimSpace) == 0 || trimSpace == "无") && it.AssistLevel >= domain.AssistLevel2 {  
1303 - // anomalyState = domain.AnomalyState1  
1304 - // }  
1305 - //} 1288 + for _, remark := range it.RemarkContent {
  1289 + trimSpace := strings.TrimLeft(remark.RemarkText, "\n") // 去掉前换行符
  1290 + trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
  1291 + trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符
  1292 + if !(len(trimSpace) == 0 || trimSpace == "无") { // 有一个填写项就恢复正常状态
  1293 + anomalyState = domain.AnomalyState1
  1294 + break
  1295 + }
  1296 + }
1306 it.AnomalyState = anomalyState 1297 it.AnomalyState = anomalyState
1307 1298
  1299 + var assistState = domain.AssistState0 // 辅导异常
  1300 + if it.AssistLevel > domain.AssistLevel1 {
  1301 + trimSpace := strings.TrimLeft(it.AssistContent, "\n") // 去掉前换行符
  1302 + trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
  1303 + trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符
  1304 + // 辅导情况是已辅导且有填写内容,变为正常
  1305 + if !(len(trimSpace) == 0 || trimSpace == "无") {
  1306 + assistState = domain.AssistState1
  1307 + }
  1308 + }
  1309 + it.AssistState = assistState
  1310 +
1308 // 更新里程碑状态 1311 // 更新里程碑状态
1309 if v.TaskStageId == it.TaskStageCheck.Id { 1312 if v.TaskStageId == it.TaskStageCheck.Id {
1310 if v.Check == domain.TaskStageUncompleted { 1313 if v.Check == domain.TaskStageUncompleted {
@@ -13,9 +13,15 @@ const ( @@ -13,9 +13,15 @@ const (
13 ) 13 )
14 14
15 const ( 15 const (
16 - AnomalyStateInit int = -1 // 初始值  
17 - AnomalyState0 int = 0 // 异常  
18 - AnomalyState1 int = 1 // 正常 16 + AnomalyStateInit int = -1 // 反馈初始值
  17 + AnomalyState0 int = 0 // 反馈异常
  18 + AnomalyState1 int = 1 // 反馈正常
  19 +)
  20 +
  21 +const (
  22 + AssistStateInit int = -1 // 辅导初始值
  23 + AssistState0 int = 0 // 辅导异常
  24 + AssistState1 int = 1 // 辅导正常
19 ) 25 )
20 26
21 // TaskRecord 任务反馈情况记录 27 // TaskRecord 任务反馈情况记录
@@ -31,7 +37,8 @@ type TaskRecord struct { @@ -31,7 +37,8 @@ type TaskRecord struct {
31 RemarkContent []RemarkText `json:"remarkContent" comment:"反馈填写"` 37 RemarkContent []RemarkText `json:"remarkContent" comment:"反馈填写"`
32 AssistLevel int `json:"assistLevel" comment:"上级辅导情况"` 38 AssistLevel int `json:"assistLevel" comment:"上级辅导情况"`
33 AssistContent string `json:"assistContent" comment:"上级辅导内容"` 39 AssistContent string `json:"assistContent" comment:"上级辅导内容"`
34 - AnomalyState int `json:"anomalyState" comment:"异常是否反馈状态(-1初始状态、0异常、1正常)"` 40 + AnomalyState int `json:"anomalyState" comment:"反馈异常状态(-1初始状态、0异常、1正常)"`
  41 + AssistState int `json:"assistState" comment:"辅导异常状态(-1初始状态、0异常、1正常)"`
35 TaskStages []TaskStage `json:"taskStages" comment:"里程碑列表"` 42 TaskStages []TaskStage `json:"taskStages" comment:"里程碑列表"`
36 TaskStageCheck TaskStage `json:"taskStageCheck" comment:"提交的里程碑"` 43 TaskStageCheck TaskStage `json:"taskStageCheck" comment:"提交的里程碑"`
37 CreatedAt time.Time `json:"createdAt" comment:"创建时间"` 44 CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
@@ -20,6 +20,7 @@ type TaskRecord struct { @@ -20,6 +20,7 @@ type TaskRecord struct {
20 AssistContent string `comment:"上级辅导内容"` 20 AssistContent string `comment:"上级辅导内容"`
21 RemarkContent []domain.RemarkText `comment:"填写反馈进度"` 21 RemarkContent []domain.RemarkText `comment:"填写反馈进度"`
22 AnomalyState int `comment:"异常反馈状态" pg:",use_zero"` 22 AnomalyState int `comment:"异常反馈状态" pg:",use_zero"`
  23 + AssistState int `comment:"辅导反馈状态" pg:",use_zero"`
23 TaskStages []domain.TaskStage `comment:"里程碑列表"` 24 TaskStages []domain.TaskStage `comment:"里程碑列表"`
24 TaskStageCheck domain.TaskStage `comment:"提交的里程碑"` 25 TaskStageCheck domain.TaskStage `comment:"提交的里程碑"`
25 CreatedAt time.Time `comment:"创建时间"` 26 CreatedAt time.Time `comment:"创建时间"`
@@ -34,6 +34,7 @@ func (repo *TaskRecordRepository) TransformToDomain(m *models.TaskRecord) domain @@ -34,6 +34,7 @@ func (repo *TaskRecordRepository) TransformToDomain(m *models.TaskRecord) domain
34 AssistContent: m.AssistContent, 34 AssistContent: m.AssistContent,
35 RemarkContent: m.RemarkContent, 35 RemarkContent: m.RemarkContent,
36 AnomalyState: m.AnomalyState, 36 AnomalyState: m.AnomalyState,
  37 + AssistState: m.AssistState,
37 TaskStages: m.TaskStages, 38 TaskStages: m.TaskStages,
38 TaskStageCheck: m.TaskStageCheck, 39 TaskStageCheck: m.TaskStageCheck,
39 CreatedAt: m.CreatedAt.Local(), 40 CreatedAt: m.CreatedAt.Local(),
@@ -57,6 +58,7 @@ func (repo *TaskRecordRepository) TransformToModel(d *domain.TaskRecord) models. @@ -57,6 +58,7 @@ func (repo *TaskRecordRepository) TransformToModel(d *domain.TaskRecord) models.
57 AssistContent: d.AssistContent, 58 AssistContent: d.AssistContent,
58 RemarkContent: d.RemarkContent, 59 RemarkContent: d.RemarkContent,
59 AnomalyState: d.AnomalyState, 60 AnomalyState: d.AnomalyState,
  61 + AssistState: d.AssistState,
60 TaskStages: d.TaskStages, 62 TaskStages: d.TaskStages,
61 TaskStageCheck: d.TaskStageCheck, 63 TaskStageCheck: d.TaskStageCheck,
62 CreatedAt: d.CreatedAt, 64 CreatedAt: d.CreatedAt,
@@ -12,3 +12,9 @@ ALTER TABLE public.task_record @@ -12,3 +12,9 @@ ALTER TABLE public.task_record
12 ADD task_created_by int NOT NULL DEFAULT 0; 12 ADD task_created_by int NOT NULL DEFAULT 0;
13 13
14 COMMENT ON COLUMN public.task_record.task_created_by IS '任务的创建来源'; 14 COMMENT ON COLUMN public.task_record.task_created_by IS '任务的创建来源';
  15 +
  16 +-- 增加任务记录字段
  17 +ALTER TABLE public.task_record
  18 + ADD assist_state int NOT NULL DEFAULT 1;
  19 +
  20 +COMMENT ON COLUMN public.task_record.assist_state IS '辅导异常状态';