作者 tangxvhui

调整 每日任务评估 的异常状态

@@ -3,7 +3,6 @@ package service @@ -3,7 +3,6 @@ package service
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "strconv" 5 "strconv"
6 - "strings"  
7 "time" 6 "time"
8 7
9 service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role" 8 service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
@@ -1296,7 +1295,6 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1296,7 +1295,6 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1296 it.AssistContent = v.AssistContent // 更新上级辅导内容 1295 it.AssistContent = v.AssistContent // 更新上级辅导内容
1297 it.RemarkContent = make([]domain.RemarkText, 0) // 更新填写反馈内容 1296 it.RemarkContent = make([]domain.RemarkText, 0) // 更新填写反馈内容
1298 1297
1299 - var anomalyState = domain.AnomalyState0 // 反馈异常  
1300 key := fmt.Sprintf("%s-%s", v.Category, v.Name) 1298 key := fmt.Sprintf("%s-%s", v.Category, v.Name)
1301 // 反馈内容填写(区分:一、模板分类中的反馈内容 二、模板的反馈内容 1299 // 反馈内容填写(区分:一、模板分类中的反馈内容 二、模板的反馈内容
1302 if item, ok := contentCategoryMap[key]; ok { 1300 if item, ok := contentCategoryMap[key]; ok {
@@ -1304,27 +1302,34 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1304,27 +1302,34 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1304 } else { 1302 } else {
1305 it.RemarkContent = append(it.RemarkContent, v.RemarkContent...) 1303 it.RemarkContent = append(it.RemarkContent, v.RemarkContent...)
1306 } 1304 }
1307 - for _, remark := range it.RemarkContent {  
1308 - trimSpace := strings.TrimLeft(remark.RemarkText, "\n") // 去掉前换行符  
1309 - trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符  
1310 - trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符  
1311 - if !(len(trimSpace) == 0 || trimSpace == "无") { // 有一个填写项就恢复正常状态  
1312 - anomalyState = domain.AnomalyState1  
1313 - break  
1314 - } 1305 + var anomalyState = domain.AnomalyState1 // 反馈异常
  1306 + if it.IsRemarkAnomaly() {
  1307 + anomalyState = domain.AnomalyState0
1315 } 1308 }
  1309 + // for _, remark := range it.RemarkContent {
  1310 + // trimSpace := strings.TrimLeft(remark.RemarkText, "\n") // 去掉前换行符
  1311 + // trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
  1312 + // trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符
  1313 + // if !(len(trimSpace) == 0 || trimSpace == "无") { // 有一个填写项就恢复正常状态
  1314 + // anomalyState = domain.AnomalyState1
  1315 + // break
  1316 + // }
  1317 + // }
1316 it.AnomalyState = anomalyState 1318 it.AnomalyState = anomalyState
1317 1319
1318 - var assistState = domain.AssistState0 // 辅导异常  
1319 - if it.AssistLevel > domain.AssistLevel1 {  
1320 - trimSpace := strings.TrimLeft(it.AssistContent, "\n") // 去掉前换行符  
1321 - trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符  
1322 - trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符  
1323 - // 辅导情况是已辅导且有填写内容,变为正常  
1324 - if !(len(trimSpace) == 0 || trimSpace == "无") {  
1325 - assistState = domain.AssistState1  
1326 - } 1320 + var assistState = domain.AssistState1 // 辅导异常
  1321 + if it.IsAssistAnomaly() {
  1322 + assistState = domain.AssistState0
1327 } 1323 }
  1324 + // if it.AssistLevel > domain.AssistLevel1 {
  1325 + // trimSpace := strings.TrimLeft(it.AssistContent, "\n") // 去掉前换行符
  1326 + // trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
  1327 + // trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符
  1328 + // // 辅导情况是已辅导且有填写内容,变为正常
  1329 + // if !(len(trimSpace) == 0 || trimSpace == "无") {
  1330 + // assistState = domain.AssistState1
  1331 + // }
  1332 + // }
1328 it.AssistState = assistState 1333 it.AssistState = assistState
1329 1334
1330 // 更新里程碑状态 1335 // 更新里程碑状态
@@ -215,7 +215,8 @@ func (t *Task) CheckAndRecordAnomaly(taskRecordData *TaskRecord) { @@ -215,7 +215,8 @@ func (t *Task) CheckAndRecordAnomaly(taskRecordData *TaskRecord) {
215 //里程碑和反馈 其中一个不正常,记录一次辅导异常 215 //里程碑和反馈 其中一个不正常,记录一次辅导异常
216 t.AssistFlag += 1 216 t.AssistFlag += 1
217 } 217 }
218 - if taskRecordData.AssistLevel != AssistLevel1 && !(taskRecordData.AssistContent == "无" || len(taskRecordData.AssistContent) == 0) { 218 + if taskRecordData.AssistLevel != AssistLevel1 &&
  219 + !(taskRecordData.AssistContent == "无" || len(taskRecordData.AssistContent) == 0) {
219 //只要正常填写的辅导都设定为已辅导 220 //只要正常填写的辅导都设定为已辅导
220 t.AssistFlag = 0 221 t.AssistFlag = 0
221 } 222 }
1 package domain 1 package domain
2 2
3 import ( 3 import (
  4 + "strings"
4 "time" 5 "time"
5 ) 6 )
6 7
@@ -54,16 +55,35 @@ type TaskRecordRepository interface { @@ -54,16 +55,35 @@ type TaskRecordRepository interface {
54 } 55 }
55 56
56 // 是否是辅导异常 57 // 是否是辅导异常
57 -// func (r *TaskRecord) IsAssistAnomaly() bool {  
58 -// //TODO 判断是否辅导异常 58 +func (r *TaskRecord) IsAssistAnomaly() bool {
  59 + // 判断是否辅导异常
  60 + taskStageAnomaly := true
  61 + if r.TaskStageCheck.RealCompletedAt > 0 {
  62 + taskStageAnomaly = false
  63 + }
59 64
60 -// r.AssistContent = strings.TrimSpace(r.AssistContent)  
61 -// if r.AssistLevel == AssistLevel1 || r.AssistContent == "无" || len(r.AssistContent) == 0 {  
62 -// return true  
63 -// } 65 + remarkAnomaly := true
  66 + for _, val := range r.RemarkContent {
  67 + txt := strings.TrimSpace(val.RemarkText)
  68 + if len(txt) == 0 || txt == "无" {
  69 + continue
  70 + }
  71 + remarkAnomaly = false
  72 + break
  73 + }
64 74
65 -// return false  
66 -// } 75 + assistAnomaly := false
  76 + if taskStageAnomaly || remarkAnomaly {
  77 + assistAnomaly = true
  78 + }
  79 + r.AssistContent = strings.TrimSpace(r.AssistContent)
  80 + if r.AssistLevel == AssistLevel1 || r.AssistContent == "无" || len(r.AssistContent) == 0 {
  81 +
  82 + } else {
  83 + assistAnomaly = false
  84 + }
  85 + return assistAnomaly
  86 +}
67 87
68 // 是否是里程碑异常 88 // 是否是里程碑异常
69 // func (r *TaskRecord) IsTaskStageAnomaly() bool { 89 // func (r *TaskRecord) IsTaskStageAnomaly() bool {
@@ -84,14 +104,16 @@ type TaskRecordRepository interface { @@ -84,14 +104,16 @@ type TaskRecordRepository interface {
84 // } 104 // }
85 105
86 // 是否是反馈异常 106 // 是否是反馈异常
87 -// func (r *TaskRecord) IsRemarkAnomaly() bool {  
88 -// all := ""  
89 -// for _, val := range r.RemarkContent {  
90 -// txt := strings.TrimSpace(val.RemarkText)  
91 -// all += txt  
92 -// }  
93 -// if len(all) == 0 || all == "无" {  
94 -// return true  
95 -// }  
96 -// return false  
97 -// } 107 +func (r *TaskRecord) IsRemarkAnomaly() bool {
  108 + isAnomaly := true
  109 + for _, val := range r.RemarkContent {
  110 + txt := strings.TrimSpace(val.RemarkText)
  111 + if len(txt) == 0 || txt == "无" {
  112 + continue
  113 + }
  114 + isAnomaly = false
  115 + break
  116 + }
  117 +
  118 + return isAnomaly
  119 +}