|
@@ -1140,181 +1140,108 @@ func (srv *SummaryEvaluationService) GetEvaluationSuperForAdmin(param *command.Q |
|
@@ -1140,181 +1140,108 @@ func (srv *SummaryEvaluationService) GetEvaluationSuperForAdmin(param *command.Q |
1140
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
1140
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
1141
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
1141
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
1142
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
1142
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
1143
|
- _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{"id": []int{param.SummaryEvaluationId}})
|
|
|
1144
|
- if err != nil {
|
|
|
1145
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1146
|
- }
|
|
|
1147
|
- if len(evaluationList) == 0 {
|
|
|
1148
|
- return &adapter.EvaluationInfoSuperAdapter{}, nil
|
1143
|
+ result, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
|
|
|
1144
|
+ if err != nil || result == nil {
|
|
|
1145
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估"+err.Error())
|
1149
|
}
|
1146
|
}
|
1150
|
- evaluationData := evaluationList[0]
|
|
|
1151
|
-
|
|
|
1152
|
- if evaluationData.CompanyId != param.CompanyId {
|
1147
|
+ if result.CompanyId != param.CompanyId {
|
1153
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
|
1148
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
|
1154
|
}
|
1149
|
}
|
1155
|
- _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": evaluationData.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
|
1150
|
+ if result.Types != domain.EvaluationFinish {
|
|
|
1151
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "考核结果类型错误")
|
|
|
1152
|
+ }
|
|
|
1153
|
+
|
|
|
1154
|
+ _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
|
1156
|
if err != nil {
|
1155
|
if err != nil {
|
1157
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1156
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1158
|
}
|
1157
|
}
|
|
|
1158
|
+
|
1159
|
// 获取已填写的评估内容
|
1159
|
// 获取已填写的评估内容
|
1160
|
- _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": evaluationData.Id})
|
1160
|
+ _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": result.Id})
|
1161
|
if err != nil {
|
1161
|
if err != nil {
|
1162
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1162
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1163
|
}
|
1163
|
}
|
1164
|
-
|
|
|
1165
|
- // 上级评估未填写或未填写完成,获取360/人资评估的填写值
|
|
|
1166
|
- if len(itemValues) == 0 || evaluationData.Status == domain.EvaluationUncompleted {
|
|
|
1167
|
- _, evaluationListOther, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
1168
|
- "typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},
|
|
|
1169
|
- "targetUserId": evaluationData.TargetUser.UserId,
|
|
|
1170
|
- "cycleId": evaluationData.CycleId,
|
|
|
1171
|
- })
|
1164
|
+ // 考核结果不存在 -> 获取上级考核 -> 获取360+HRBP+自评
|
|
|
1165
|
+ if len(itemValues) == 0 {
|
|
|
1166
|
+ itemValues, evaluationList, err := srv.findCycleItemValueByType(transactionContext, result.CycleId, result.TargetUser.UserId, []int{int(domain.EvaluationSuper)})
|
1172
|
if err != nil {
|
1167
|
if err != nil {
|
1173
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1168
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1174
|
}
|
1169
|
}
|
1175
|
- var evaluationIds []int
|
|
|
1176
|
- for _, v := range evaluationListOther {
|
|
|
1177
|
- evaluationIds = append(evaluationIds, v.Id)
|
|
|
1178
|
- }
|
|
|
1179
|
- if len(evaluationIds) > 0 {
|
|
|
1180
|
- _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds})
|
1170
|
+ // 没有上级评估时(有上级考核类型时,不管分数有没有填写都算,没填写当作零)
|
|
|
1171
|
+ if len(evaluationList) == 0 {
|
|
|
1172
|
+ itemValues, _, err = srv.findCycleItemValueByType(transactionContext, result.CycleId, result.TargetUser.UserId, []int{int(domain.EvaluationSelf)})
|
|
|
1173
|
+ if err != nil {
|
|
|
1174
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1175
|
+ }
|
|
|
1176
|
+ hrItemValues, _, err := srv.findCycleItemValueByType(transactionContext, result.CycleId, result.TargetUser.UserId, []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)})
|
1181
|
if err != nil {
|
1177
|
if err != nil {
|
1182
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1178
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1183
|
}
|
1179
|
}
|
|
|
1180
|
+ // 自评分数
|
|
|
1181
|
+ if len(itemValues) == 0 {
|
|
|
1182
|
+ itemValues = hrItemValues
|
|
|
1183
|
+ } else {
|
|
|
1184
|
+ // HR360分数 替换 自评分数
|
|
|
1185
|
+ hrItemMap := map[int]*domain.SummaryEvaluationValue{}
|
|
|
1186
|
+ for i := range hrItemValues {
|
|
|
1187
|
+ hrItemMap[hrItemValues[i].EvaluationItemId] = hrItemValues[i]
|
|
|
1188
|
+ }
|
|
|
1189
|
+ for i := range itemValues {
|
|
|
1190
|
+ it := itemValues[i]
|
|
|
1191
|
+ if v, ok := hrItemMap[it.EvaluationItemId]; ok {
|
|
|
1192
|
+ itemValues[i] = v
|
|
|
1193
|
+ }
|
|
|
1194
|
+ }
|
|
|
1195
|
+ }
|
1184
|
}
|
1196
|
}
|
1185
|
}
|
1197
|
}
|
1186
|
- evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationData)
|
1198
|
+
|
|
|
1199
|
+ evaluationBase := srv.getSummaryEvaluation(transactionContext, result)
|
1187
|
if err := transactionContext.CommitTransaction(); err != nil {
|
1200
|
if err := transactionContext.CommitTransaction(); err != nil {
|
1188
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1201
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1189
|
}
|
1202
|
}
|
1190
|
//组合 评估填写的值和评估项
|
1203
|
//组合 评估填写的值和评估项
|
1191
|
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
|
1204
|
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
|
1192
|
|
1205
|
|
1193
|
- result := adapter.EvaluationInfoSuperAdapter{
|
1206
|
+ ra := adapter.EvaluationInfoSuperAdapter{
|
1194
|
EvaluationBaseAdapter: evaluationBase,
|
1207
|
EvaluationBaseAdapter: evaluationBase,
|
1195
|
EvaluationItems: itemValuesAdapter,
|
1208
|
EvaluationItems: itemValuesAdapter,
|
1196
|
}
|
1209
|
}
|
1197
|
- return &result, nil
|
1210
|
+ return &ra, nil
|
1198
|
}
|
1211
|
}
|
1199
|
|
1212
|
|
1200
|
-// // EditEvaluationSuper 更新上级评估内容
|
|
|
1201
|
-// func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEvaluationValue) (interface{}, error) {
|
|
|
1202
|
-// lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)
|
|
|
1203
|
-// err := lock.Lock()
|
|
|
1204
|
-// if err != nil {
|
|
|
1205
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
1206
|
-// }
|
|
|
1207
|
-// defer func() {
|
|
|
1208
|
-// lock.UnLock()
|
|
|
1209
|
-// }()
|
|
|
1210
|
-// transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
1211
|
-// if err != nil {
|
|
|
1212
|
-// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1213
|
-// }
|
|
|
1214
|
-// if err := transactionContext.StartTransaction(); err != nil {
|
|
|
1215
|
-// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1216
|
-// }
|
|
|
1217
|
-// defer func() {
|
|
|
1218
|
-// _ = transactionContext.RollbackTransaction()
|
|
|
1219
|
-// }()
|
|
|
1220
|
-// evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
1221
|
-// "transactionContext": transactionContext,
|
|
|
1222
|
-// })
|
|
|
1223
|
-// itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
1224
|
-// "transactionContext": transactionContext,
|
|
|
1225
|
-// })
|
|
|
1226
|
-
|
|
|
1227
|
-// itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
|
|
|
1228
|
-// "transactionContext": transactionContext,
|
|
|
1229
|
-// })
|
|
|
1230
|
-// evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
|
|
|
1231
|
-// "id": param.SummaryEvaluationId,
|
|
|
1232
|
-// })
|
|
|
1233
|
-// if err != nil {
|
|
|
1234
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1235
|
-// }
|
|
|
1236
|
-// if evaluationData.Types != domain.EvaluationSuper {
|
|
|
1237
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
1238
|
-// }
|
1213
|
+func (srv *SummaryEvaluationService) findCycleItemValueByType(
|
|
|
1214
|
+ tc application.TransactionContext,
|
|
|
1215
|
+ cycleId int64,
|
|
|
1216
|
+ targetUserId int,
|
|
|
1217
|
+ typesList []int,
|
|
|
1218
|
+) ([]*domain.SummaryEvaluationValue, []*domain.SummaryEvaluation, error) {
|
|
|
1219
|
+ evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": tc})
|
|
|
1220
|
+ itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": tc})
|
1239
|
|
1221
|
|
1240
|
-// if evaluationData.Executor.UserId != param.ExecutorId {
|
|
|
1241
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
1242
|
-// }
|
|
|
1243
|
-
|
|
|
1244
|
-// if evaluationData.CompanyId != param.CompanyId {
|
|
|
1245
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
1246
|
-// }
|
|
|
1247
|
-
|
|
|
1248
|
-// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
1249
|
-// "targetUserId": evaluationData.TargetUser.UserId,
|
|
|
1250
|
-// "typesList": []int{int(domain.EvaluationFinish)},
|
|
|
1251
|
-// "cycleId": evaluationData.CycleId,
|
|
|
1252
|
-// "limit": 1,
|
|
|
1253
|
-// })
|
|
|
1254
|
-// if err != nil {
|
|
|
1255
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1256
|
-// }
|
|
|
1257
|
-// // 如果目标员工已经确认考核结果,就不能在进行评估编辑
|
|
|
1258
|
-// if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted {
|
|
|
1259
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能再编辑!")
|
|
|
1260
|
-// }
|
|
|
1261
|
-
|
|
|
1262
|
-// _, itemList, err := itemUsedRepo.Find(map[string]interface{}{
|
|
|
1263
|
-// "evaluationProjectId": evaluationData.EvaluationProjectId,
|
|
|
1264
|
-// "nodeType": domain.LinkNodeSelfAssessment,
|
|
|
1265
|
-// })
|
|
|
1266
|
-// if err != nil {
|
|
|
1267
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1268
|
-// }
|
|
|
1269
|
-// //获取已填写的评估内容
|
|
|
1270
|
-// _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
1271
|
-// "summaryEvaluationId": evaluationData.Id,
|
|
|
1272
|
-// })
|
|
|
1273
|
-// if err != nil {
|
|
|
1274
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1275
|
-// }
|
|
|
1276
|
-// //记录人资评估或者360评估的 填写项id
|
|
|
1277
|
-// hrbpOr360ItemValue, err := srv.getEvaluationSuperDefaultValue(transactionContext, evaluationData)
|
|
|
1278
|
-// if err != nil {
|
|
|
1279
|
-// return nil, err
|
|
|
1280
|
-// }
|
|
|
1281
|
-
|
|
|
1282
|
-// err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, hrbpOr360ItemValue, param.IsTemporary)
|
|
|
1283
|
-// if err != nil {
|
|
|
1284
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1285
|
-// }
|
|
|
1286
|
-// if !param.IsTemporary {
|
|
|
1287
|
-// //变更评估状态为已填写
|
|
|
1288
|
-// evaluationData.Status = domain.EvaluationCompleted
|
|
|
1289
|
-// }
|
|
|
1290
|
-// for _, v := range itemValueList {
|
|
|
1291
|
-// //保存填写值
|
|
|
1292
|
-// err = itemValueRepo.Save(v)
|
|
|
1293
|
-// if err != nil {
|
|
|
1294
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1295
|
-// }
|
|
|
1296
|
-// }
|
|
|
1297
|
-// //保存填写值
|
|
|
1298
|
-// err = evaluationRepo.Save(evaluationData)
|
|
|
1299
|
-// if err != nil {
|
|
|
1300
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1301
|
-// }
|
|
|
1302
|
-// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
1303
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1304
|
-// }
|
|
|
1305
|
-
|
|
|
1306
|
-// if !param.IsTemporary {
|
|
|
1307
|
-// err = srv.AfterCompletedEvaluationSuper(evaluationData)
|
|
|
1308
|
-// if err != nil {
|
|
|
1309
|
-// return nil, err
|
|
|
1310
|
-// }
|
|
|
1311
|
-// }
|
|
|
1312
|
-
|
|
|
1313
|
-// itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
|
|
|
1314
|
-// return map[string][]adapter.EvaluationItemAdapter{
|
|
|
1315
|
-// "EvaluationItems": itemValueAdapter,
|
|
|
1316
|
-// }, nil
|
|
|
1317
|
-// }
|
1222
|
+ _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
1223
|
+ "typesList": typesList,
|
|
|
1224
|
+ "limit": len(typesList),
|
|
|
1225
|
+ "targetUserId": targetUserId,
|
|
|
1226
|
+ "cycleId": cycleId,
|
|
|
1227
|
+ })
|
|
|
1228
|
+ if err != nil {
|
|
|
1229
|
+ return nil, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1230
|
+ }
|
|
|
1231
|
+ var eIds []int // 评估类型的ID列表
|
|
|
1232
|
+ for _, v := range evaluationList {
|
|
|
1233
|
+ eIds = append(eIds, v.Id)
|
|
|
1234
|
+ }
|
|
|
1235
|
+ if len(eIds) > 0 {
|
|
|
1236
|
+ _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": eIds})
|
|
|
1237
|
+ if err != nil {
|
|
|
1238
|
+ return nil, evaluationList, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1239
|
+ } else {
|
|
|
1240
|
+ return itemValues, evaluationList, nil
|
|
|
1241
|
+ }
|
|
|
1242
|
+ }
|
|
|
1243
|
+ return make([]*domain.SummaryEvaluationValue, 0), evaluationList, nil
|
|
|
1244
|
+}
|
1318
|
|
1245
|
|
1319
|
// EditEvaluationSuperForAdmin 更新上级评估内容(超级管理员)
|
1246
|
// EditEvaluationSuperForAdmin 更新上级评估内容(超级管理员)
|
1320
|
func (srv *SummaryEvaluationService) EditEvaluationSuperForAdmin(param *command.EditEvaluationValue) (interface{}, error) {
|
1247
|
func (srv *SummaryEvaluationService) EditEvaluationSuperForAdmin(param *command.EditEvaluationValue) (interface{}, error) {
|