作者 tangxvhui

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

... ... @@ -3,7 +3,6 @@ package service
import (
"fmt"
"strconv"
"strings"
"time"
service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
... ... @@ -1296,7 +1295,6 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
it.AssistContent = v.AssistContent // 更新上级辅导内容
it.RemarkContent = make([]domain.RemarkText, 0) // 更新填写反馈内容
var anomalyState = domain.AnomalyState0 // 反馈异常
key := fmt.Sprintf("%s-%s", v.Category, v.Name)
// 反馈内容填写(区分:一、模板分类中的反馈内容 二、模板的反馈内容
if item, ok := contentCategoryMap[key]; ok {
... ... @@ -1304,27 +1302,34 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
} else {
it.RemarkContent = append(it.RemarkContent, v.RemarkContent...)
}
for _, remark := range it.RemarkContent {
trimSpace := strings.TrimLeft(remark.RemarkText, "\n") // 去掉前换行符
trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符
if !(len(trimSpace) == 0 || trimSpace == "无") { // 有一个填写项就恢复正常状态
anomalyState = domain.AnomalyState1
break
}
var anomalyState = domain.AnomalyState1 // 反馈异常
if it.IsRemarkAnomaly() {
anomalyState = domain.AnomalyState0
}
// for _, remark := range it.RemarkContent {
// trimSpace := strings.TrimLeft(remark.RemarkText, "\n") // 去掉前换行符
// trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
// trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符
// if !(len(trimSpace) == 0 || trimSpace == "无") { // 有一个填写项就恢复正常状态
// anomalyState = domain.AnomalyState1
// break
// }
// }
it.AnomalyState = anomalyState
var assistState = domain.AssistState0 // 辅导异常
if it.AssistLevel > domain.AssistLevel1 {
trimSpace := strings.TrimLeft(it.AssistContent, "\n") // 去掉前换行符
trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符
// 辅导情况是已辅导且有填写内容,变为正常
if !(len(trimSpace) == 0 || trimSpace == "无") {
assistState = domain.AssistState1
}
var assistState = domain.AssistState1 // 辅导异常
if it.IsAssistAnomaly() {
assistState = domain.AssistState0
}
// if it.AssistLevel > domain.AssistLevel1 {
// trimSpace := strings.TrimLeft(it.AssistContent, "\n") // 去掉前换行符
// trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
// trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符
// // 辅导情况是已辅导且有填写内容,变为正常
// if !(len(trimSpace) == 0 || trimSpace == "无") {
// assistState = domain.AssistState1
// }
// }
it.AssistState = assistState
// 更新里程碑状态
... ...
... ... @@ -215,7 +215,8 @@ func (t *Task) CheckAndRecordAnomaly(taskRecordData *TaskRecord) {
//里程碑和反馈 其中一个不正常,记录一次辅导异常
t.AssistFlag += 1
}
if taskRecordData.AssistLevel != AssistLevel1 && !(taskRecordData.AssistContent == "无" || len(taskRecordData.AssistContent) == 0) {
if taskRecordData.AssistLevel != AssistLevel1 &&
!(taskRecordData.AssistContent == "无" || len(taskRecordData.AssistContent) == 0) {
//只要正常填写的辅导都设定为已辅导
t.AssistFlag = 0
}
... ...
package domain
import (
"strings"
"time"
)
... ... @@ -54,16 +55,35 @@ type TaskRecordRepository interface {
}
// 是否是辅导异常
// func (r *TaskRecord) IsAssistAnomaly() bool {
// //TODO 判断是否辅导异常
func (r *TaskRecord) IsAssistAnomaly() bool {
// 判断是否辅导异常
taskStageAnomaly := true
if r.TaskStageCheck.RealCompletedAt > 0 {
taskStageAnomaly = false
}
// r.AssistContent = strings.TrimSpace(r.AssistContent)
// if r.AssistLevel == AssistLevel1 || r.AssistContent == "无" || len(r.AssistContent) == 0 {
// return true
// }
remarkAnomaly := true
for _, val := range r.RemarkContent {
txt := strings.TrimSpace(val.RemarkText)
if len(txt) == 0 || txt == "无" {
continue
}
remarkAnomaly = false
break
}
// return false
// }
assistAnomaly := false
if taskStageAnomaly || remarkAnomaly {
assistAnomaly = true
}
r.AssistContent = strings.TrimSpace(r.AssistContent)
if r.AssistLevel == AssistLevel1 || r.AssistContent == "无" || len(r.AssistContent) == 0 {
} else {
assistAnomaly = false
}
return assistAnomaly
}
// 是否是里程碑异常
// func (r *TaskRecord) IsTaskStageAnomaly() bool {
... ... @@ -84,14 +104,16 @@ type TaskRecordRepository interface {
// }
// 是否是反馈异常
// func (r *TaskRecord) IsRemarkAnomaly() bool {
// all := ""
// for _, val := range r.RemarkContent {
// txt := strings.TrimSpace(val.RemarkText)
// all += txt
// }
// if len(all) == 0 || all == "无" {
// return true
// }
// return false
// }
func (r *TaskRecord) IsRemarkAnomaly() bool {
isAnomaly := true
for _, val := range r.RemarkContent {
txt := strings.TrimSpace(val.RemarkText)
if len(txt) == 0 || txt == "无" {
continue
}
isAnomaly = false
break
}
return isAnomaly
}
... ...