作者 tangxvhui
... ... @@ -483,6 +483,7 @@ func (srv StaffAssessServeice) buildTaskRecord(staffAssess *domain.StaffAssess)
AssistLevel: 0,
AssistContent: "",
AnomalyState: domain.AnomalyStateInit,
AssistState: domain.AssistStateInit,
TaskStages: []domain.TaskStage{},
TaskStageCheck: domain.TaskStage{},
TaskCreatedBy: taskList[0].CreatedBy,
... ...
... ... @@ -1277,34 +1277,37 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
it.AssistContent = v.AssistContent // 更新上级辅导内容
it.RemarkContent = make([]domain.RemarkText, 0) // 更新填写反馈内容
var anomalyState = domain.AnomalyState0
var anomalyState = domain.AnomalyState0 // 反馈异常
key := fmt.Sprintf("%s-%s", v.Category, v.Name)
// 反馈内容填写
// 反馈内容填写(区分:一、模板分类中的反馈内容 二、模板的反馈内容
if item, ok := contentCategoryMap[key]; ok {
it.RemarkContent = append(it.RemarkContent, item.Remark...)
for _, remark := range item.Remark {
trimSpace := strings.TrimLeft(remark.RemarkText, "\n") // 去掉前换行符
trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符
if !(len(trimSpace) == 0 || trimSpace == "无") { // 有一个填写项就恢复正常状态
anomalyState = domain.AnomalyState1
break
}
}
} else {
it.RemarkContent = append(it.RemarkContent, v.RemarkContent...)
}
//if anomalyState == domain.AnomalyState0 {
// trimSpace := strings.TrimLeft(it.AssistContent, "\n") // 去掉前换行符
// trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
// trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符
// // 上级填写内容有值,选项是已辅导,变为正常
// if !(len(trimSpace) == 0 || trimSpace == "无") && it.AssistLevel >= domain.AssistLevel2 {
// anomalyState = domain.AnomalyState1
// }
//}
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
}
}
it.AssistState = assistState
// 更新里程碑状态
if v.TaskStageId == it.TaskStageCheck.Id {
if v.Check == domain.TaskStageUncompleted {
... ...
... ... @@ -13,9 +13,15 @@ const (
)
const (
AnomalyStateInit int = -1 // 初始值
AnomalyState0 int = 0 // 异常
AnomalyState1 int = 1 // 正常
AnomalyStateInit int = -1 // 反馈初始值
AnomalyState0 int = 0 // 反馈异常
AnomalyState1 int = 1 // 反馈正常
)
const (
AssistStateInit int = -1 // 辅导初始值
AssistState0 int = 0 // 辅导异常
AssistState1 int = 1 // 辅导正常
)
// TaskRecord 任务反馈情况记录
... ... @@ -31,7 +37,8 @@ type TaskRecord struct {
RemarkContent []RemarkText `json:"remarkContent" comment:"反馈填写"`
AssistLevel int `json:"assistLevel" comment:"上级辅导情况"`
AssistContent string `json:"assistContent" comment:"上级辅导内容"`
AnomalyState int `json:"anomalyState" comment:"异常是否反馈状态(-1初始状态、0异常、1正常)"`
AnomalyState int `json:"anomalyState" comment:"反馈异常状态(-1初始状态、0异常、1正常)"`
AssistState int `json:"assistState" comment:"辅导异常状态(-1初始状态、0异常、1正常)"`
TaskStages []TaskStage `json:"taskStages" comment:"里程碑列表"`
TaskStageCheck TaskStage `json:"taskStageCheck" comment:"提交的里程碑"`
CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
... ...
... ... @@ -20,6 +20,7 @@ type TaskRecord struct {
AssistContent string `comment:"上级辅导内容"`
RemarkContent []domain.RemarkText `comment:"填写反馈进度"`
AnomalyState int `comment:"异常反馈状态" pg:",use_zero"`
AssistState int `comment:"辅导反馈状态" pg:",use_zero"`
TaskStages []domain.TaskStage `comment:"里程碑列表"`
TaskStageCheck domain.TaskStage `comment:"提交的里程碑"`
CreatedAt time.Time `comment:"创建时间"`
... ...
... ... @@ -34,6 +34,7 @@ func (repo *TaskRecordRepository) TransformToDomain(m *models.TaskRecord) domain
AssistContent: m.AssistContent,
RemarkContent: m.RemarkContent,
AnomalyState: m.AnomalyState,
AssistState: m.AssistState,
TaskStages: m.TaskStages,
TaskStageCheck: m.TaskStageCheck,
CreatedAt: m.CreatedAt.Local(),
... ... @@ -57,6 +58,7 @@ func (repo *TaskRecordRepository) TransformToModel(d *domain.TaskRecord) models.
AssistContent: d.AssistContent,
RemarkContent: d.RemarkContent,
AnomalyState: d.AnomalyState,
AssistState: d.AssistState,
TaskStages: d.TaskStages,
TaskStageCheck: d.TaskStageCheck,
CreatedAt: d.CreatedAt,
... ...
... ... @@ -12,3 +12,9 @@ ALTER TABLE public.task_record
ADD task_created_by int NOT NULL DEFAULT 0;
COMMENT ON COLUMN public.task_record.task_created_by IS '任务的创建来源';
-- 增加任务记录字段
ALTER TABLE public.task_record
ADD assist_state int NOT NULL DEFAULT 1;
COMMENT ON COLUMN public.task_record.assist_state IS '辅导异常状态';
... ...