作者 tangxvhui

Merge branch 'test' into dev-tangxvhui

  1 +package service
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
  6 + roleService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
  8 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
  9 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis"
  11 +)
  12 +
  13 +// GetEvaluationFinish 超级管理员获取考核详情
  14 +func (srv *SummaryEvaluationService) GetEvaluationFinish(param *command.QueryEvaluationSuper) (*adapter.EvaluationInfoSuperAdapter, error) {
  15 + transactionContext, err := factory.StartTransaction()
  16 + if err != nil {
  17 + return nil, err
  18 + }
  19 + defer func() {
  20 + _ = transactionContext.RollbackTransaction()
  21 + }()
  22 +
  23 + // 只有超级管理员可以使用的功能
  24 + superAdmin, err := roleService.GetSuperAdmin(transactionContext, param.CompanyId, param.UserId)
  25 + if err != nil {
  26 + return nil, err
  27 + }
  28 + if superAdmin != domain.RoleTypeSuperAdmin {
  29 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
  30 + }
  31 +
  32 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
  33 + evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
  34 + itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
  35 +
  36 + result, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
  37 + if err != nil || result == nil {
  38 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估"+err.Error())
  39 + }
  40 + if result.CompanyId != param.CompanyId {
  41 + return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
  42 + }
  43 + if result.Types != domain.EvaluationFinish {
  44 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "考核类型错误")
  45 + }
  46 +
  47 + _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
  48 + if err != nil {
  49 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  50 + }
  51 +
  52 + // 获取已填写的评估内容
  53 + _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": result.Id})
  54 + if err != nil {
  55 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  56 + }
  57 + // 考核结果不存在 -> 获取上级考核 -> 获取360+HRBP+自评
  58 + if len(itemValues) == 0 {
  59 + itemValues, evaluationList, err := srv.findCycleItemValueByType(transactionContext, result.CycleId, result.TargetUser.UserId, []int{int(domain.EvaluationSuper)})
  60 + if err != nil {
  61 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  62 + }
  63 + // 上级评估不存在(有上级考核类型时,不管分数有没有填写都算,没填写当作零)
  64 + if len(evaluationList) == 0 {
  65 + itemValues, _, err = srv.findCycleItemValueByType(transactionContext, result.CycleId, result.TargetUser.UserId, []int{int(domain.EvaluationSelf)})
  66 + if err != nil {
  67 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  68 + }
  69 + hrItemValues, _, err := srv.findCycleItemValueByType(transactionContext, result.CycleId, result.TargetUser.UserId, []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)})
  70 + if err != nil {
  71 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  72 + }
  73 + // 自评分数
  74 + if len(itemValues) == 0 {
  75 + itemValues = hrItemValues
  76 + } else {
  77 + // HR360分数 替换 自评分数
  78 + hrItemMap := map[int]*domain.SummaryEvaluationValue{}
  79 + for i := range hrItemValues {
  80 + hrItemMap[hrItemValues[i].EvaluationItemId] = hrItemValues[i]
  81 + }
  82 + for i := range itemValues {
  83 + it := itemValues[i]
  84 + if v, ok := hrItemMap[it.EvaluationItemId]; ok {
  85 + itemValues[i] = v
  86 + }
  87 + }
  88 + }
  89 + }
  90 + }
  91 +
  92 + evaluationBase := srv.getSummaryEvaluation(transactionContext, result)
  93 + if err := transactionContext.CommitTransaction(); err != nil {
  94 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  95 + }
  96 + //组合 评估填写的值和评估项
  97 + itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
  98 +
  99 + ra := adapter.EvaluationInfoSuperAdapter{
  100 + EvaluationBaseAdapter: evaluationBase,
  101 + EvaluationItems: itemValuesAdapter,
  102 + }
  103 + return &ra, nil
  104 +}
  105 +
  106 +func (srv *SummaryEvaluationService) findCycleItemValueByType(
  107 + tc application.TransactionContext,
  108 + cycleId int64,
  109 + targetUserId int,
  110 + typesList []int,
  111 +) ([]*domain.SummaryEvaluationValue, []*domain.SummaryEvaluation, error) {
  112 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": tc})
  113 + itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": tc})
  114 +
  115 + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
  116 + "typesList": typesList,
  117 + "limit": len(typesList),
  118 + "targetUserId": targetUserId,
  119 + "cycleId": cycleId,
  120 + })
  121 + if err != nil {
  122 + return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  123 + }
  124 + var eIds []int // 评估类型的ID列表
  125 + for _, v := range evaluationList {
  126 + eIds = append(eIds, v.Id)
  127 + }
  128 + if len(eIds) > 0 {
  129 + _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": eIds})
  130 + if err != nil {
  131 + return nil, evaluationList, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  132 + } else {
  133 + return itemValues, evaluationList, nil
  134 + }
  135 + }
  136 + return make([]*domain.SummaryEvaluationValue, 0), evaluationList, nil
  137 +}
  138 +
  139 +// EditEvaluationFinish 超级管理员编辑考核结果
  140 +func (srv *SummaryEvaluationService) EditEvaluationFinish(param *command.EditEvaluationValue) (interface{}, error) {
  141 + // 超管不接收临时数据提交
  142 + if param.IsTemporary {
  143 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "不能提交临时数据")
  144 + }
  145 +
  146 + lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)
  147 + err := lock.Lock()
  148 + if err != nil {
  149 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
  150 + }
  151 + defer func() {
  152 + lock.UnLock()
  153 + }()
  154 +
  155 + transactionContext, err := factory.StartTransaction()
  156 + if err != nil {
  157 + return nil, err
  158 + }
  159 + defer func() {
  160 + _ = transactionContext.RollbackTransaction()
  161 + }()
  162 +
  163 + // 只有超级管理员可以使用的功能
  164 + superAdmin, err := roleService.GetSuperAdmin(transactionContext, param.CompanyId, param.ExecutorId)
  165 + if err != nil {
  166 + return nil, err
  167 + }
  168 + if superAdmin != domain.RoleTypeSuperAdmin {
  169 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
  170 + }
  171 +
  172 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
  173 + itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
  174 + itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
  175 + result, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
  176 + if err != nil {
  177 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  178 + }
  179 + if result.CompanyId != param.CompanyId {
  180 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
  181 + }
  182 + if result.Types != domain.EvaluationFinish {
  183 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "考核类型错误")
  184 + }
  185 +
  186 + _, itemList, err := itemUsedRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
  187 + if err != nil {
  188 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  189 + }
  190 + // 获取已填写的评估内容
  191 + _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": result.Id})
  192 + if err != nil {
  193 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  194 + }
  195 + // 超级管理员编辑不限制截止时间、不校验填写项
  196 + err = srv.editEvaluationValueUnlimited(result, &itemValueList, itemList, param.EvaluationItems, nil, true)
  197 + if err != nil {
  198 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  199 + }
  200 + for _, v := range itemValueList {
  201 + err = itemValueRepo.Save(v) // 保存填写值
  202 + if err != nil {
  203 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  204 + }
  205 + }
  206 + result.Status = domain.EvaluationCompleted
  207 + result.CheckResult = domain.EvaluationCheckUncompleted
  208 + err = evaluationRepo.Save(result)
  209 + if err != nil {
  210 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  211 + }
  212 + if err := transactionContext.CommitTransaction(); err != nil {
  213 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  214 + }
  215 +
  216 + itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
  217 + return map[string][]adapter.EvaluationItemAdapter{"EvaluationItems": itemValueAdapter}, nil
  218 +}
@@ -1117,299 +1117,6 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval @@ -1117,299 +1117,6 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval
1117 return &result, nil 1117 return &result, nil
1118 } 1118 }
1119 1119
1120 -// GetEvaluationSuperForAdmin 根据执行人获取上级评估详情(超级管理员特殊处理)  
1121 -func (srv *SummaryEvaluationService) GetEvaluationSuperForAdmin(param *command.QueryEvaluationSuper) (*adapter.EvaluationInfoSuperAdapter, error) {  
1122 - transactionContext, err := factory.StartTransaction()  
1123 - if err != nil {  
1124 - return nil, err  
1125 - }  
1126 - defer func() {  
1127 - _ = transactionContext.RollbackTransaction()  
1128 - }()  
1129 -  
1130 - // 只有超级管理员可以使用的功能  
1131 - superAdmin, err := roleService.GetSuperAdmin(transactionContext, param.CompanyId, param.UserId)  
1132 - if err != nil {  
1133 - return nil, err  
1134 - }  
1135 - if superAdmin != domain.RoleTypeSuperAdmin {  
1136 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")  
1137 - }  
1138 -  
1139 - evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})  
1140 - evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})  
1141 - itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})  
1142 - _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{"id": []int{param.SummaryEvaluationId}})  
1143 - if err != nil {  
1144 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1145 - }  
1146 - if len(evaluationList) == 0 {  
1147 - return &adapter.EvaluationInfoSuperAdapter{}, nil  
1148 - }  
1149 - evaluationData := evaluationList[0]  
1150 -  
1151 - if evaluationData.CompanyId != param.CompanyId {  
1152 - return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")  
1153 - }  
1154 - _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": evaluationData.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})  
1155 - if err != nil {  
1156 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1157 - }  
1158 - // 获取已填写的评估内容  
1159 - _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": evaluationData.Id})  
1160 - if err != nil {  
1161 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1162 - }  
1163 -  
1164 - // 上级评估未填写或未填写完成,获取360/人资评估的填写值  
1165 - if len(itemValues) == 0 || evaluationData.Status == domain.EvaluationUncompleted {  
1166 - _, evaluationListOther, err := evaluationRepo.Find(map[string]interface{}{  
1167 - "typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},  
1168 - "targetUserId": evaluationData.TargetUser.UserId,  
1169 - "cycleId": evaluationData.CycleId,  
1170 - })  
1171 - if err != nil {  
1172 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1173 - }  
1174 - var evaluationIds []int  
1175 - for _, v := range evaluationListOther {  
1176 - evaluationIds = append(evaluationIds, v.Id)  
1177 - }  
1178 - if len(evaluationIds) > 0 {  
1179 - _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds})  
1180 - if err != nil {  
1181 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1182 - }  
1183 - }  
1184 - }  
1185 - evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationData)  
1186 - if err := transactionContext.CommitTransaction(); err != nil {  
1187 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1188 - }  
1189 - //组合 评估填写的值和评估项  
1190 - itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)  
1191 -  
1192 - result := adapter.EvaluationInfoSuperAdapter{  
1193 - EvaluationBaseAdapter: evaluationBase,  
1194 - EvaluationItems: itemValuesAdapter,  
1195 - }  
1196 - return &result, nil  
1197 -}  
1198 -  
1199 -// // EditEvaluationSuper 更新上级评估内容  
1200 -// func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEvaluationValue) (interface{}, error) {  
1201 -// lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)  
1202 -// err := lock.Lock()  
1203 -// if err != nil {  
1204 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")  
1205 -// }  
1206 -// defer func() {  
1207 -// lock.UnLock()  
1208 -// }()  
1209 -// transactionContext, err := factory.CreateTransactionContext(nil)  
1210 -// if err != nil {  
1211 -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
1212 -// }  
1213 -// if err := transactionContext.StartTransaction(); err != nil {  
1214 -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
1215 -// }  
1216 -// defer func() {  
1217 -// _ = transactionContext.RollbackTransaction()  
1218 -// }()  
1219 -// evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{  
1220 -// "transactionContext": transactionContext,  
1221 -// })  
1222 -// itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{  
1223 -// "transactionContext": transactionContext,  
1224 -// })  
1225 -  
1226 -// itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{  
1227 -// "transactionContext": transactionContext,  
1228 -// })  
1229 -// evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{  
1230 -// "id": param.SummaryEvaluationId,  
1231 -// })  
1232 -// if err != nil {  
1233 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1234 -// }  
1235 -// if evaluationData.Types != domain.EvaluationSuper {  
1236 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")  
1237 -// }  
1238 -  
1239 -// if evaluationData.Executor.UserId != param.ExecutorId {  
1240 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")  
1241 -// }  
1242 -  
1243 -// if evaluationData.CompanyId != param.CompanyId {  
1244 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")  
1245 -// }  
1246 -  
1247 -// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{  
1248 -// "targetUserId": evaluationData.TargetUser.UserId,  
1249 -// "typesList": []int{int(domain.EvaluationFinish)},  
1250 -// "cycleId": evaluationData.CycleId,  
1251 -// "limit": 1,  
1252 -// })  
1253 -// if err != nil {  
1254 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1255 -// }  
1256 -// // 如果目标员工已经确认考核结果,就不能在进行评估编辑  
1257 -// if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted {  
1258 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能再编辑!")  
1259 -// }  
1260 -  
1261 -// _, itemList, err := itemUsedRepo.Find(map[string]interface{}{  
1262 -// "evaluationProjectId": evaluationData.EvaluationProjectId,  
1263 -// "nodeType": domain.LinkNodeSelfAssessment,  
1264 -// })  
1265 -// if err != nil {  
1266 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1267 -// }  
1268 -// //获取已填写的评估内容  
1269 -// _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{  
1270 -// "summaryEvaluationId": evaluationData.Id,  
1271 -// })  
1272 -// if err != nil {  
1273 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1274 -// }  
1275 -// //记录人资评估或者360评估的 填写项id  
1276 -// hrbpOr360ItemValue, err := srv.getEvaluationSuperDefaultValue(transactionContext, evaluationData)  
1277 -// if err != nil {  
1278 -// return nil, err  
1279 -// }  
1280 -  
1281 -// err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, hrbpOr360ItemValue, param.IsTemporary)  
1282 -// if err != nil {  
1283 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1284 -// }  
1285 -// if !param.IsTemporary {  
1286 -// //变更评估状态为已填写  
1287 -// evaluationData.Status = domain.EvaluationCompleted  
1288 -// }  
1289 -// for _, v := range itemValueList {  
1290 -// //保存填写值  
1291 -// err = itemValueRepo.Save(v)  
1292 -// if err != nil {  
1293 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1294 -// }  
1295 -// }  
1296 -// //保存填写值  
1297 -// err = evaluationRepo.Save(evaluationData)  
1298 -// if err != nil {  
1299 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1300 -// }  
1301 -// if err := transactionContext.CommitTransaction(); err != nil {  
1302 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1303 -// }  
1304 -  
1305 -// if !param.IsTemporary {  
1306 -// err = srv.AfterCompletedEvaluationSuper(evaluationData)  
1307 -// if err != nil {  
1308 -// return nil, err  
1309 -// }  
1310 -// }  
1311 -  
1312 -// itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)  
1313 -// return map[string][]adapter.EvaluationItemAdapter{  
1314 -// "EvaluationItems": itemValueAdapter,  
1315 -// }, nil  
1316 -// }  
1317 -  
1318 -// EditEvaluationSuperForAdmin 更新上级评估内容(超级管理员)  
1319 -func (srv *SummaryEvaluationService) EditEvaluationSuperForAdmin(param *command.EditEvaluationValue) (interface{}, error) {  
1320 - // 超管不接收临时数据提交  
1321 - if param.IsTemporary {  
1322 - return nil, nil  
1323 - }  
1324 -  
1325 - lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)  
1326 - err := lock.Lock()  
1327 - if err != nil {  
1328 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")  
1329 - }  
1330 - defer func() {  
1331 - lock.UnLock()  
1332 - }()  
1333 -  
1334 - transactionContext, err := factory.StartTransaction()  
1335 - if err != nil {  
1336 - return nil, err  
1337 - }  
1338 - defer func() {  
1339 - _ = transactionContext.RollbackTransaction()  
1340 - }()  
1341 -  
1342 - // 只有超级管理员可以使用的功能  
1343 - superAdmin, err := roleService.GetSuperAdmin(transactionContext, param.CompanyId, param.ExecutorId)  
1344 - if err != nil {  
1345 - return nil, err  
1346 - }  
1347 - if superAdmin != domain.RoleTypeSuperAdmin {  
1348 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")  
1349 - }  
1350 -  
1351 - evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})  
1352 - itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})  
1353 - itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})  
1354 - evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})  
1355 - if err != nil {  
1356 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1357 - }  
1358 - if evaluationData.CompanyId != param.CompanyId {  
1359 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")  
1360 - }  
1361 - _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{  
1362 - "targetUserId": evaluationData.TargetUser.UserId,  
1363 - "typesList": []int{int(domain.EvaluationFinish)},  
1364 - "cycleId": evaluationData.CycleId,  
1365 - "limit": 1,  
1366 - })  
1367 - if err != nil {  
1368 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1369 - }  
1370 - // 如果目标员工已经确认考核结果,就不能在进行评估编辑  
1371 - if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted {  
1372 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能再编辑!")  
1373 - }  
1374 -  
1375 - _, itemList, err := itemUsedRepo.Find(map[string]interface{}{"evaluationProjectId": evaluationData.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})  
1376 - if err != nil {  
1377 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1378 - }  
1379 - // 获取已填写的评估内容  
1380 - _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": evaluationData.Id})  
1381 - if err != nil {  
1382 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1383 - }  
1384 - // 超级管理员编辑不限制截止时间、不校验填写项  
1385 - err = srv.editEvaluationValueUnlimited(evaluationData, &itemValueList, itemList, param.EvaluationItems, nil, true)  
1386 - if err != nil {  
1387 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1388 - }  
1389 - for _, v := range itemValueList {  
1390 - err = itemValueRepo.Save(v) // 保存填写值  
1391 - if err != nil {  
1392 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1393 - }  
1394 - }  
1395 - evaluationData.Status = domain.EvaluationCompleted  
1396 - err = evaluationRepo.Save(evaluationData)  
1397 - if err != nil {  
1398 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1399 - }  
1400 - if err := transactionContext.CommitTransaction(); err != nil {  
1401 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1402 - }  
1403 -  
1404 - // err = srv.AfterCompletedEvaluationSuper(evaluationData)  
1405 - // if err != nil {  
1406 - // return nil, err  
1407 - // }  
1408 -  
1409 - itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)  
1410 - return map[string][]adapter.EvaluationItemAdapter{"EvaluationItems": itemValueAdapter}, nil  
1411 -}  
1412 -  
1413 // getEvaluationSuperDefaultValue 1120 // getEvaluationSuperDefaultValue
1414 // 按照权限设置,是否获取上级评估内容的默认值 1121 // 按照权限设置,是否获取上级评估内容的默认值
1415 func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionContext application.TransactionContext, evaluationData *domain.SummaryEvaluation) ( 1122 func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionContext application.TransactionContext, evaluationData *domain.SummaryEvaluation) (
@@ -258,7 +258,7 @@ func (c *SummaryEvaluationController) EditEvaluationHRBP() { @@ -258,7 +258,7 @@ func (c *SummaryEvaluationController) EditEvaluationHRBP() {
258 c.Response(data, err) 258 c.Response(data, err)
259 } 259 }
260 260
261 -// 获取上级评估 261 +// GetEvaluationSuper 获取上级评估、或考核结果
262 func (c *SummaryEvaluationController) GetEvaluationSuper() { 262 func (c *SummaryEvaluationController) GetEvaluationSuper() {
263 srv := service.NewSummaryEvaluationService() 263 srv := service.NewSummaryEvaluationService()
264 param := &command.QueryEvaluationSuper{} 264 param := &command.QueryEvaluationSuper{}
@@ -272,9 +272,9 @@ func (c *SummaryEvaluationController) GetEvaluationSuper() { @@ -272,9 +272,9 @@ func (c *SummaryEvaluationController) GetEvaluationSuper() {
272 param.CompanyId = int(userReq.CompanyId) 272 param.CompanyId = int(userReq.CompanyId)
273 param.UserId = int(userReq.UserId) 273 param.UserId = int(userReq.UserId)
274 274
275 - // 超级管理员可以修改上级评估数据 275 + // 超级管理员获取考核结果
276 if param.Advanced == 1 { 276 if param.Advanced == 1 {
277 - data, err := srv.GetEvaluationSuperForAdmin(param) 277 + data, err := srv.GetEvaluationFinish(param)
278 c.Response(data, err) 278 c.Response(data, err)
279 } else { 279 } else {
280 data, err := srv.GetEvaluationSuper(param) 280 data, err := srv.GetEvaluationSuper(param)
@@ -282,7 +282,7 @@ func (c *SummaryEvaluationController) GetEvaluationSuper() { @@ -282,7 +282,7 @@ func (c *SummaryEvaluationController) GetEvaluationSuper() {
282 } 282 }
283 } 283 }
284 284
285 -// 编辑上级评估 285 +// EditEvaluationSuper 编辑上级评估、编辑考核结果
286 func (c *SummaryEvaluationController) EditEvaluationSuper() { 286 func (c *SummaryEvaluationController) EditEvaluationSuper() {
287 srv := service.NewSummaryEvaluationService() 287 srv := service.NewSummaryEvaluationService()
288 param := &command.EditEvaluationValue{} 288 param := &command.EditEvaluationValue{}
@@ -296,9 +296,9 @@ func (c *SummaryEvaluationController) EditEvaluationSuper() { @@ -296,9 +296,9 @@ func (c *SummaryEvaluationController) EditEvaluationSuper() {
296 param.CompanyId = int(userReq.CompanyId) 296 param.CompanyId = int(userReq.CompanyId)
297 param.ExecutorId = int(userReq.UserId) 297 param.ExecutorId = int(userReq.UserId)
298 298
299 - // 超级管理员重新修改上级评估数据 299 + // 超级管理员获取评估考核结果
300 if param.Advanced == 1 { 300 if param.Advanced == 1 {
301 - data, err := srv.EditEvaluationSuperForAdmin(param) 301 + data, err := srv.EditEvaluationFinish(param)
302 c.Response(data, err) 302 c.Response(data, err)
303 } else { 303 } else {
304 data, err := srv.EditEvaluationSuper(param) 304 data, err := srv.EditEvaluationSuper(param)