作者 郑周

1. 里程碑记录优化

@@ -1146,16 +1146,13 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1146,16 +1146,13 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1146 } 1146 }
1147 assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{"transactionContext": transactionContext}) 1147 assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{"transactionContext": transactionContext})
1148 1148
1149 - //待更新的评估填写信息  
1150 var assessContentList []*domain.StaffAssessContent 1149 var assessContentList []*domain.StaffAssessContent
1151 - // 已完成 1150 + // 已完成会有评估内容数据
1152 _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{"staffAssessId": assessData.Id}) 1151 _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{"staffAssessId": assessData.Id})
1153 if err != nil { 1152 if err != nil {
1154 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) 1153 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
1155 } 1154 }
1156 -  
1157 - if len(assessContentList) == 0 {  
1158 - // 未完成获取评估内容 1155 + if len(assessContentList) == 0 { // 未完成获取评估内容
1159 assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData) 1156 assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
1160 if err != nil { 1157 if err != nil {
1161 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) 1158 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
@@ -1168,7 +1165,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1168,7 +1165,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1168 key := fmt.Sprintf("%s-%s", v.Category, v.Name) 1165 key := fmt.Sprintf("%s-%s", v.Category, v.Name)
1169 paramContentMap[key] = in.AssessContent[i] 1166 paramContentMap[key] = in.AssessContent[i]
1170 } 1167 }
1171 - //更新的评估填写信息 1168 + // 更新的评估填写信息
1172 for _, v := range assessContentList { 1169 for _, v := range assessContentList {
1173 key := fmt.Sprintf("%s-%s", v.Category, v.Name) 1170 key := fmt.Sprintf("%s-%s", v.Category, v.Name)
1174 item, ok := paramContentMap[key] 1171 item, ok := paramContentMap[key]
@@ -1184,8 +1181,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1184,8 +1181,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1184 1181
1185 v.Value = item.Value 1182 v.Value = item.Value
1186 if len(item.Value) > 0 { 1183 if len(item.Value) > 0 {
1187 - // 转换填入的评估值  
1188 - err = v.TransformValue() 1184 + err = v.TransformValue() // 转换评分评级填入的评估值
1189 if err != nil { 1185 if err != nil {
1190 return nil, application.ThrowError(application.BUSINESS_ERROR, v.Category+"-"+v.Name+":"+err.Error()) 1186 return nil, application.ThrowError(application.BUSINESS_ERROR, v.Category+"-"+v.Name+":"+err.Error())
1191 } 1187 }
@@ -1226,19 +1222,53 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1226,19 +1222,53 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1226 } 1222 }
1227 } 1223 }
1228 1224
  1225 + // TODO 还差调用绪旭辉接口,更新里程碑状态
1229 if len(in.AssessTaskStages) > 0 { 1226 if len(in.AssessTaskStages) > 0 {
1230 - tsIds := make([]int, 0)  
1231 - for i := range in.AssessTaskStages {  
1232 - tsId := in.AssessTaskStages[i].TaskStageId  
1233 - if tsId > 0 {  
1234 - tsIds = append(tsIds, tsId) 1227 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  1228 + project, err := projectRepository.FindOne(map[string]interface{}{"id": assessData.EvaluationProjectId})
  1229 + if err != nil {
  1230 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目错误:"+err.Error())
1235 } 1231 }
  1232 + // 任务负责人才能提交里程碑数据
  1233 + if project.PrincipalId != strconv.Itoa(in.ExecutorId) {
  1234 + return nil, application.ThrowError(application.BUSINESS_ERROR, "当前用户不能提交里程碑完成情况")
1236 } 1235 }
1237 1236
  1237 + recordMap := map[int]domain.AssessTaskStage{}
  1238 + recordIds := make([]int, 0)
  1239 + for i := range in.AssessTaskStages {
  1240 + it := in.AssessTaskStages[i]
  1241 + recordIds = append(recordIds, it.TaskRecordId)
  1242 + recordMap[it.TaskRecordId] = it
1238 } 1243 }
1239 // 里程碑记录 1244 // 里程碑记录
1240 - //taskRecordRepository := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})  
1241 - //taskRecordRepository.Find() 1245 + if len(recordIds) > 0 {
  1246 + taskRecordRepository := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
  1247 + _, taskRecords, err := taskRecordRepository.Find(map[string]interface{}{"ids": recordIds})
  1248 + if err != nil {
  1249 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取里程碑数据:"+err.Error())
  1250 + }
  1251 + for i := range taskRecords {
  1252 + it := taskRecords[i]
  1253 + if v, ok := recordMap[it.Id]; ok {
  1254 + it.AssistLevel = v.AssistLevel // 更新上级辅导情况
  1255 + it.AssistContent = v.AssistContent // 更新上级辅导内容
  1256 + if v.TaskStageId == it.TaskStageCheck.Id { // 更新里程碑状态
  1257 + it.TaskStageCheck.Status = v.Status
  1258 + }
  1259 + for j := range it.TaskStages {
  1260 + if v.TaskStageId == it.TaskStages[j].Id { // 更新里程碑状态
  1261 + it.TaskStages[j].Status = v.Status
  1262 + }
  1263 + }
  1264 + _, err := taskRecordRepository.Insert(it)
  1265 + if err != nil {
  1266 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "更新里程碑数据:"+err.Error())
  1267 + }
  1268 + }
  1269 + }
  1270 + }
  1271 + }
1242 1272
1243 if err := transactionContext.CommitTransaction(); err != nil { 1273 if err := transactionContext.CommitTransaction(); err != nil {
1244 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1274 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -28,6 +28,7 @@ type RemarkText struct { @@ -28,6 +28,7 @@ type RemarkText struct {
28 type AssessTaskStage struct { 28 type AssessTaskStage struct {
29 Category string `json:"category"` 29 Category string `json:"category"`
30 Name string `json:"name"` 30 Name string `json:"name"`
  31 + TaskRecordId int `json:"taskRecordId" comment:"任务记录ID"`
31 TaskStageId int `json:"taskStageId" comment:"里程碑ID"` 32 TaskStageId int `json:"taskStageId" comment:"里程碑ID"`
32 Status TaskStageState `json:"status" comment:"里程碑完成情况"` 33 Status TaskStageState `json:"status" comment:"里程碑完成情况"`
33 AssistLevel int `json:"assistLevel" comment:"上级辅导情况"` 34 AssistLevel int `json:"assistLevel" comment:"上级辅导情况"`
@@ -14,7 +14,7 @@ type TaskRecord struct { @@ -14,7 +14,7 @@ type TaskRecord struct {
14 Id int `json:"id,string" comment:"ID"` 14 Id int `json:"id,string" comment:"ID"`
15 CompanyId int `json:"companyId,string" comment:"公司ID"` 15 CompanyId int `json:"companyId,string" comment:"公司ID"`
16 StaffAssessId int `json:"staffAssessId,string" comment:"每日评估的ID"` 16 StaffAssessId int `json:"staffAssessId,string" comment:"每日评估的ID"`
17 - TaskId int `json:"taskId,string" comment:"里程碑任务的ID"` 17 + TaskId int `json:"taskId,string" comment:"任务ID"`
18 TaskName string `json:"taskName" comment:"任务名称"` 18 TaskName string `json:"taskName" comment:"任务名称"`
19 TaskAlias string `json:"taskAlias" comment:"任务别名"` 19 TaskAlias string `json:"taskAlias" comment:"任务别名"`
20 TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"` 20 TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"`
@@ -11,7 +11,7 @@ type TaskRecord struct { @@ -11,7 +11,7 @@ type TaskRecord struct {
11 Id int `comment:"ID" pg:"pk:id"` 11 Id int `comment:"ID" pg:"pk:id"`
12 CompanyId int `comment:"公司ID"` 12 CompanyId int `comment:"公司ID"`
13 StaffAssessId int `comment:"每日评估的ID"` 13 StaffAssessId int `comment:"每日评估的ID"`
14 - TaskId int `comment:"里程碑任务的ID"` 14 + TaskId int `comment:"任务ID"`
15 TaskName string `comment:"任务名称"` 15 TaskName string `comment:"任务名称"`
16 TaskAlias string `comment:"任务别名"` 16 TaskAlias string `comment:"任务别名"`
17 TaskLeader domain.TaskLeader `comment:"任务负责人"` 17 TaskLeader domain.TaskLeader `comment:"任务负责人"`