作者 郑周

1.任务记录 新增反馈内容字段

@@ -1283,12 +1283,15 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1283,12 +1283,15 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1283 for i := range taskRecords { 1283 for i := range taskRecords {
1284 it := taskRecords[i] 1284 it := taskRecords[i]
1285 if v, ok := recordMap[it.Id]; ok { 1285 if v, ok := recordMap[it.Id]; ok {
1286 - it.AssistLevel = v.AssistLevel // 更新上级辅导情况  
1287 - it.AssistContent = v.AssistContent // 更新上级辅导内容 1286 + it.AssistLevel = v.AssistLevel // 更新上级辅导情况
  1287 + it.AssistContent = v.AssistContent // 更新上级辅导内容
  1288 + it.RemarkContent = make([]domain.RemarkText, 0) // 更新填写反馈内容
1288 1289
1289 var anomalyState = domain.AnomalyState0 1290 var anomalyState = domain.AnomalyState0
1290 key := fmt.Sprintf("%s-%s", v.Category, v.Name) 1291 key := fmt.Sprintf("%s-%s", v.Category, v.Name)
1291 if item, ok := contentCategoryMap[key]; ok { 1292 if item, ok := contentCategoryMap[key]; ok {
  1293 + it.RemarkContent = append(it.RemarkContent, item.Remark...)
  1294 +
1292 for _, remark := range item.Remark { 1295 for _, remark := range item.Remark {
1293 trimSpace := strings.TrimLeft(remark.RemarkText, "\n") // 去掉前换行符 1296 trimSpace := strings.TrimLeft(remark.RemarkText, "\n") // 去掉前换行符
1294 trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符 1297 trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
1 package adapter 1 package adapter
2 2
  3 +import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  4 +
3 type TaskRecordAdapter struct { 5 type TaskRecordAdapter struct {
4 - Id int `json:"id,string" ` //comment:"记录ID"  
5 - StaffAssessId int `json:"staffAssessId,string" ` //comment:"每日评估的ID"  
6 - TaskId int `json:"taskId,string" ` //comment:"任务ID"  
7 - TaskCategory string `json:"taskCategory" ` //comment:"任务类别"  
8 - TaskName string `json:"taskName" ` //comment:"任务名称"  
9 - TaskAlias string `json:"taskAlias" ` //comment:"任务别名"  
10 - TaskLeader string `json:"taskLeader"` //comment:"任务负责人"  
11 - AssistContent string `json:"assistContent" ` //comment:"反馈内容"  
12 - TaskStageCheck TaskStage `json:"taskStageCheck" ` //comment:"提交的里程碑"  
13 - CreatedAt string `json:"createdAt" ` //格式2006-01-02comment:"创建时间"  
14 - AnomalyState int `json:"anomalyState"` // 6 + Id int `json:"id,string" ` //comment:"记录ID"
  7 + StaffAssessId int `json:"staffAssessId,string" ` //comment:"每日评估的ID"
  8 + TaskId int `json:"taskId,string" ` //comment:"任务ID"
  9 + TaskCategory string `json:"taskCategory" ` //comment:"任务类别"
  10 + TaskName string `json:"taskName" ` //comment:"任务名称"
  11 + TaskAlias string `json:"taskAlias" ` //comment:"任务别名"
  12 + TaskLeader string `json:"taskLeader"` //comment:"任务负责人"
  13 + RemarkContent []domain.RemarkText `json:"remarkContent" ` //comment:"任务填写反馈"
  14 + AssistLevel int `json:"assistLevel"` //comment:"上级辅导情况"
  15 + AssistContent string `json:"assistContent" ` //comment:"上级辅导内容"
  16 + TaskStageCheck TaskStage `json:"taskStageCheck" ` //comment:"提交的里程碑"
  17 + CreatedAt string `json:"createdAt" ` //格式2006-01-02comment:"创建时间"
  18 + AnomalyState int `json:"anomalyState"` //
15 } 19 }
@@ -801,12 +801,10 @@ func (srv TaskService) ListTaskRecord(param *command.ListTaskRecordCommand) (map @@ -801,12 +801,10 @@ func (srv TaskService) ListTaskRecord(param *command.ListTaskRecordCommand) (map
801 defer func() { 801 defer func() {
802 _ = transactionContext.RollbackTransaction() 802 _ = transactionContext.RollbackTransaction()
803 }() 803 }()
804 - taskRecordRepo := factory.CreateTaskRecordRepository(map[string]interface{}{  
805 - "transactionContext": transactionContext,  
806 - })  
807 - assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{  
808 - "transactionContext": transactionContext,  
809 - }) 804 + taskRecordRepo := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
  805 + //assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
  806 + // "transactionContext": transactionContext,
  807 + //})
810 cnt, taskRecordList, err := taskRecordRepo.Find(map[string]interface{}{ 808 cnt, taskRecordList, err := taskRecordRepo.Find(map[string]interface{}{
811 "companyId": param.CompanyId, 809 "companyId": param.CompanyId,
812 "taskId": param.TaskId, 810 "taskId": param.TaskId,
@@ -814,6 +812,9 @@ func (srv TaskService) ListTaskRecord(param *command.ListTaskRecordCommand) (map @@ -814,6 +812,9 @@ func (srv TaskService) ListTaskRecord(param *command.ListTaskRecordCommand) (map
814 if err != nil { 812 if err != nil {
815 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务反馈数据"+err.Error()) 813 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务反馈数据"+err.Error())
816 } 814 }
  815 + if err := transactionContext.CommitTransaction(); err != nil {
  816 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  817 + }
817 818
818 resultList := []adapter.TaskRecordAdapter{} 819 resultList := []adapter.TaskRecordAdapter{}
819 nowDay := time.Now().Format("2006-01-02") 820 nowDay := time.Now().Format("2006-01-02")
@@ -831,7 +832,9 @@ func (srv TaskService) ListTaskRecord(param *command.ListTaskRecordCommand) (map @@ -831,7 +832,9 @@ func (srv TaskService) ListTaskRecord(param *command.ListTaskRecordCommand) (map
831 TaskName: val.TaskName, 832 TaskName: val.TaskName,
832 TaskAlias: val.TaskAlias, 833 TaskAlias: val.TaskAlias,
833 TaskLeader: val.TaskLeader.Name, 834 TaskLeader: val.TaskLeader.Name,
834 - AssistContent: "", 835 + RemarkContent: val.RemarkContent, // 填写反馈内容
  836 + AssistLevel: val.AssistLevel, // 上级辅助等级
  837 + AssistContent: val.AssistContent, // 上级辅助内容
835 AnomalyState: val.AnomalyState, 838 AnomalyState: val.AnomalyState,
836 TaskStageCheck: adapter.TaskStage{ 839 TaskStageCheck: adapter.TaskStage{
837 Id: val.Id, 840 Id: val.Id,
@@ -852,24 +855,24 @@ func (srv TaskService) ListTaskRecord(param *command.ListTaskRecordCommand) (map @@ -852,24 +855,24 @@ func (srv TaskService) ListTaskRecord(param *command.ListTaskRecordCommand) (map
852 t2 := time.Unix(val.TaskStageCheck.RealCompletedAt, 0).Local().Format("2006-01-02") 855 t2 := time.Unix(val.TaskStageCheck.RealCompletedAt, 0).Local().Format("2006-01-02")
853 item.TaskStageCheck.RealCompletedAt = t2 856 item.TaskStageCheck.RealCompletedAt = t2
854 } 857 }
855 - _, contentList, err := assessContentRepo.Find(map[string]interface{}{  
856 - "staffAssessId": val.StaffAssessId,  
857 - "category": val.TaskCategory,  
858 - "name": val.TaskName,  
859 - })  
860 - if err != nil {  
861 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估反馈数据"+err.Error())  
862 - }  
863 - if len(contentList) > 0 {  
864 - for _, val2 := range contentList[0].Remark {  
865 - item.AssistContent += val2.RemarkText + "\n"  
866 - }  
867 - } 858 + //_, contentList, err := assessContentRepo.Find(map[string]interface{}{
  859 + // "staffAssessId": val.StaffAssessId,
  860 + // "category": val.TaskCategory,
  861 + // "name": val.TaskName,
  862 + //})
  863 + //if err != nil {
  864 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估反馈数据"+err.Error())
  865 + //}
  866 + //if len(contentList) > 0 {
  867 + // for _, val2 := range contentList[0].Remark {
  868 + // item.AssistContent += val2.RemarkText + "\n"
  869 + // }
  870 + //}
868 resultList = append(resultList, item) 871 resultList = append(resultList, item)
869 } 872 }
870 - if err := transactionContext.CommitTransaction(); err != nil {  
871 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
872 - } 873 + //if err := transactionContext.CommitTransaction(); err != nil {
  874 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  875 + //}
873 result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList) 876 result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList)
874 return result, nil 877 return result, nil
875 } 878 }
@@ -19,22 +19,23 @@ const ( @@ -19,22 +19,23 @@ const (
19 19
20 // TaskRecord 任务反馈情况记录 20 // TaskRecord 任务反馈情况记录
21 type TaskRecord struct { 21 type TaskRecord struct {
22 - Id int `json:"id,string" comment:"记录ID"`  
23 - CompanyId int `json:"companyId,string" comment:"公司ID"`  
24 - StaffAssessId int `json:"staffAssessId,string" comment:"每日评估的ID"`  
25 - TaskId int `json:"taskId,string" comment:"任务ID"`  
26 - TaskCategory string `json:"taskCategory" comment:"任务类别"`  
27 - TaskName string `json:"taskName" comment:"任务名称"`  
28 - TaskAlias string `json:"taskAlias" comment:"任务别名"`  
29 - TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"`  
30 - AssistLevel int `json:"assistLevel" comment:"上级辅导情况"`  
31 - AssistContent string `json:"assistContent" comment:"上级辅导内容"`  
32 - AnomalyState int `json:"anomalyState" comment:"异常是否反馈状态(-1初始状态、0异常、1正常)"`  
33 - TaskStages []TaskStage `json:"taskStages" comment:"里程碑列表"`  
34 - TaskStageCheck TaskStage `json:"taskStageCheck" comment:"提交的里程碑"`  
35 - CreatedAt time.Time `json:"createdAt" comment:"创建时间"`  
36 - UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`  
37 - DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` 22 + Id int `json:"id,string" comment:"记录ID"`
  23 + CompanyId int `json:"companyId,string" comment:"公司ID"`
  24 + StaffAssessId int `json:"staffAssessId,string" comment:"每日评估的ID"`
  25 + TaskId int `json:"taskId,string" comment:"任务ID"`
  26 + TaskCategory string `json:"taskCategory" comment:"任务类别"`
  27 + TaskName string `json:"taskName" comment:"任务名称"`
  28 + TaskAlias string `json:"taskAlias" comment:"任务别名"`
  29 + TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"`
  30 + AssistLevel int `json:"assistLevel" comment:"上级辅导情况"`
  31 + AssistContent string `json:"assistContent" comment:"上级辅导内容"`
  32 + RemarkContent []RemarkText `json:"remarkContent" comment:"填写反馈"`
  33 + AnomalyState int `json:"anomalyState" comment:"异常是否反馈状态(-1初始状态、0异常、1正常)"`
  34 + TaskStages []TaskStage `json:"taskStages" comment:"里程碑列表"`
  35 + TaskStageCheck TaskStage `json:"taskStageCheck" comment:"提交的里程碑"`
  36 + CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
  37 + UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`
  38 + DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
38 } 39 }
39 40
40 type TaskRecordRepository interface { 41 type TaskRecordRepository interface {
@@ -7,21 +7,22 @@ import ( @@ -7,21 +7,22 @@ import (
7 7
8 // 任务阶段 8 // 任务阶段
9 type TaskRecord struct { 9 type TaskRecord struct {
10 - tableName struct{} `comment:"评估项目" pg:"task_record"`  
11 - Id int `comment:"ID" pg:"pk:id"`  
12 - CompanyId int `comment:"公司ID"`  
13 - StaffAssessId int `comment:"每日评估的ID"`  
14 - TaskId int `comment:"任务ID"`  
15 - TaskCategory string `comment:"任务类别"`  
16 - TaskName string `comment:"任务名称"`  
17 - TaskAlias string `comment:"任务别名"`  
18 - TaskLeader domain.TaskLeader `comment:"任务负责人"`  
19 - AssistLevel int `comment:"上级辅导情况" pg:",use_zero"`  
20 - AssistContent string `comment:"上级辅导内容"`  
21 - AnomalyState int `comment:"异常反馈状态" pg:",use_zero"`  
22 - TaskStages []domain.TaskStage `comment:"里程碑列表"`  
23 - TaskStageCheck domain.TaskStage `comment:"提交的里程碑"`  
24 - CreatedAt time.Time `comment:"创建时间"`  
25 - UpdatedAt time.Time `comment:"更新时间"`  
26 - DeletedAt *time.Time `comment:"删除时间"` 10 + tableName struct{} `comment:"评估项目" pg:"task_record"`
  11 + Id int `comment:"ID" pg:"pk:id"`
  12 + CompanyId int `comment:"公司ID"`
  13 + StaffAssessId int `comment:"每日评估的ID"`
  14 + TaskId int `comment:"任务ID"`
  15 + TaskCategory string `comment:"任务类别"`
  16 + TaskName string `comment:"任务名称"`
  17 + TaskAlias string `comment:"任务别名"`
  18 + TaskLeader domain.TaskLeader `comment:"任务负责人"`
  19 + AssistLevel int `comment:"上级辅导情况" pg:",use_zero"`
  20 + AssistContent string `comment:"上级辅导内容"`
  21 + RemarkContent []domain.RemarkText `comment:"填写反馈进度"`
  22 + AnomalyState int `comment:"异常反馈状态" pg:",use_zero"`
  23 + TaskStages []domain.TaskStage `comment:"里程碑列表"`
  24 + TaskStageCheck domain.TaskStage `comment:"提交的里程碑"`
  25 + CreatedAt time.Time `comment:"创建时间"`
  26 + UpdatedAt time.Time `comment:"更新时间"`
  27 + DeletedAt *time.Time `comment:"删除时间"`
27 } 28 }
@@ -32,6 +32,7 @@ func (repo *TaskRecordRepository) TransformToDomain(m *models.TaskRecord) domain @@ -32,6 +32,7 @@ func (repo *TaskRecordRepository) TransformToDomain(m *models.TaskRecord) domain
32 TaskLeader: m.TaskLeader, 32 TaskLeader: m.TaskLeader,
33 AssistLevel: m.AssistLevel, 33 AssistLevel: m.AssistLevel,
34 AssistContent: m.AssistContent, 34 AssistContent: m.AssistContent,
  35 + RemarkContent: m.RemarkContent,
35 AnomalyState: m.AnomalyState, 36 AnomalyState: m.AnomalyState,
36 TaskStages: m.TaskStages, 37 TaskStages: m.TaskStages,
37 TaskStageCheck: m.TaskStageCheck, 38 TaskStageCheck: m.TaskStageCheck,
@@ -53,6 +54,7 @@ func (repo *TaskRecordRepository) TransformToModel(d *domain.TaskRecord) models. @@ -53,6 +54,7 @@ func (repo *TaskRecordRepository) TransformToModel(d *domain.TaskRecord) models.
53 TaskLeader: d.TaskLeader, 54 TaskLeader: d.TaskLeader,
54 AssistLevel: d.AssistLevel, 55 AssistLevel: d.AssistLevel,
55 AssistContent: d.AssistContent, 56 AssistContent: d.AssistContent,
  57 + RemarkContent: d.RemarkContent,
56 AnomalyState: d.AnomalyState, 58 AnomalyState: d.AnomalyState,
57 TaskStages: d.TaskStages, 59 TaskStages: d.TaskStages,
58 TaskStageCheck: d.TaskStageCheck, 60 TaskStageCheck: d.TaskStageCheck,
  1 +
  2 +
  3 +-- 增加任务记录字段-填写反馈进度
  4 +ALTER TABLE public.task_record
  5 + ADD remark_content jsonb NULL;
  6 +
  7 +COMMENT ON COLUMN public.task_record.remark_content IS '填写反馈进度';
  8 +