作者 tangxvhui

添加 周期综合评估下,周期评估列表

@@ -10,3 +10,13 @@ type EvaluationSuperListAdapter struct { @@ -10,3 +10,13 @@ type EvaluationSuperListAdapter struct {
10 Position string `json:"position"` //职位 10 Position string `json:"position"` //职位
11 EntryTime string `json:"entryTime"` //入职时间 11 EntryTime string `json:"entryTime"` //入职时间
12 } 12 }
  13 +
  14 +type EvaluationSuperItemAdapter struct {
  15 + SummaryEvaluationId int `json:"summaryEvaluationId,string"` //评估任务id
  16 + TargetUserName string `json:"targetUserName"` //目标用户,被评估的员工
  17 + TargetUserId int `json:"targetUserId,string"` //目标用户,被评估的员工
  18 + CycleId int64 `json:"cycleId,string"` //周期id
  19 + TotalScore string `json:"totalScore"` //得分
  20 + Department string `json:"department"` //部门
  21 + Position string `json:"position"` //职位
  22 +}
1 package command 1 package command
2 2
3 -type QueryEvaluationList struct { 3 +// 查询执行人的上级评估列表
  4 +type QueryExecutorEvaluationList struct {
4 PageNumber int `json:"pageNumber"` 5 PageNumber int `json:"pageNumber"`
5 PageSize int `json:"pageSize"` 6 PageSize int `json:"pageSize"`
6 CycleId int `json:"cycleId,string"` 7 CycleId int `json:"cycleId,string"`
@@ -8,3 +9,12 @@ type QueryEvaluationList struct { @@ -8,3 +9,12 @@ type QueryEvaluationList struct {
8 ExecutorId int `json:"-"` 9 ExecutorId int `json:"-"`
9 TargetUserName string `json:"targetUserName"` 10 TargetUserName string `json:"targetUserName"`
10 } 11 }
  12 +
  13 +// 查询上级评估列表
  14 +type QueryEvaluationList struct {
  15 + PageNumber int `json:"pageNumber"`
  16 + PageSize int `json:"pageSize"`
  17 + CycleId int `json:"cycleId,string"`
  18 + CompanyId int `json:"-"`
  19 + TargetUserName string `json:"targetUserName"`
  20 +}
@@ -990,8 +990,8 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC @@ -990,8 +990,8 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC
990 return result, nil 990 return result, nil
991 } 991 }
992 992
993 -// 获取上级评估的列表  
994 -func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEvaluationList) (map[string]interface{}, error) { 993 +// 获取执行人的上级评估的列表
  994 +func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command.QueryExecutorEvaluationList) (map[string]interface{}, error) {
995 transactionContext, err := factory.CreateTransactionContext(nil) 995 transactionContext, err := factory.CreateTransactionContext(nil)
996 if err != nil { 996 if err != nil {
997 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 997 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -1011,9 +1011,6 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva @@ -1011,9 +1011,6 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva
1011 positionRepo := factory.CreatePositionRepository(map[string]interface{}{ 1011 positionRepo := factory.CreatePositionRepository(map[string]interface{}{
1012 "transactionContext": transactionContext, 1012 "transactionContext": transactionContext,
1013 }) 1013 })
1014 - departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{  
1015 - "transactionContext": transactionContext,  
1016 - })  
1017 limit := param.PageSize 1014 limit := param.PageSize
1018 offset := (param.PageNumber - 1) * param.PageSize 1015 offset := (param.PageNumber - 1) * param.PageSize
1019 1016
@@ -1080,28 +1077,15 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva @@ -1080,28 +1077,15 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva
1080 userMap[v.Id] = v 1077 userMap[v.Id] = v
1081 } 1078 }
1082 } 1079 }
1083 - var departmentIds []int  
1084 - //获取部门  
1085 - departmentMap := map[int64]*domain.Department{}  
1086 var positionIds []int 1080 var positionIds []int
1087 //获取职位列表 1081 //获取职位列表
1088 positionMap := map[int64]*domain.Position{} 1082 positionMap := map[int64]*domain.Position{}
1089 for _, v := range userMap { 1083 for _, v := range userMap {
1090 - departmentIds = append(departmentIds, v.DepartmentId...)  
1091 positionIds = append(positionIds, v.PositionId...) 1084 positionIds = append(positionIds, v.PositionId...)
1092 } 1085 }
1093 - if len(departmentIds) > 0 {  
1094 - _, departmentList, err := departmentRepo.Find(map[string]interface{}{"ids": departmentIds})  
1095 - if err != nil {  
1096 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())  
1097 - }  
1098 - for _, v := range departmentList {  
1099 - departmentMap[v.Id] = v  
1100 - }  
1101 - }  
1102 1086
1103 if len(positionIds) > 0 { 1087 if len(positionIds) > 0 {
1104 - _, positionList, err := positionRepo.Find(map[string]interface{}{"ids": departmentIds}) 1088 + _, positionList, err := positionRepo.Find(map[string]interface{}{"ids": positionIds})
1105 if err != nil { 1089 if err != nil {
1106 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error()) 1090 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
1107 } 1091 }
@@ -1124,14 +1108,11 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva @@ -1124,14 +1108,11 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva
1124 Position: "", 1108 Position: "",
1125 EntryTime: "", 1109 EntryTime: "",
1126 } 1110 }
  1111 + for _, dep := range v.TargetDepartment {
  1112 + item.Department += dep.DepartmentName + " "
  1113 + }
1127 //填充员工信息 1114 //填充员工信息
1128 if targetUser, ok := userMap[int64(v.TargetUser.UserId)]; ok { 1115 if targetUser, ok := userMap[int64(v.TargetUser.UserId)]; ok {
1129 - //填充部门信息  
1130 - for _, departId := range targetUser.DepartmentId {  
1131 - if depart, ok := departmentMap[int64(departId)]; ok {  
1132 - item.Department += depart.Name + " "  
1133 - }  
1134 - }  
1135 //填充职位信息 1116 //填充职位信息
1136 for _, positionId := range targetUser.PositionId { 1117 for _, positionId := range targetUser.PositionId {
1137 if position, ok := positionMap[int64(positionId)]; ok { 1118 if position, ok := positionMap[int64(positionId)]; ok {
@@ -1310,7 +1291,107 @@ func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command @@ -1310,7 +1291,107 @@ func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command
1310 } 1291 }
1311 1292
1312 // 获取周期综合评估下,周期评估列表 1293 // 获取周期综合评估下,周期评估列表
1313 -func (srv *SummaryEvaluationService) ListEvalationSuper() (map[int]interface{}, error) { 1294 +func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.QueryEvaluationList) (map[string]interface{}, error) {
  1295 + transactionContext, err := factory.CreateTransactionContext(nil)
  1296 + if err != nil {
  1297 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1298 + }
  1299 + if err := transactionContext.StartTransaction(); err != nil {
  1300 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1301 + }
  1302 + defer func() {
  1303 + _ = transactionContext.RollbackTransaction()
  1304 + }()
  1305 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
  1306 + "transactionContext": transactionContext,
  1307 + })
  1308 + userRepo := factory.CreateUserRepository(map[string]interface{}{
  1309 + "transactionContext": transactionContext,
  1310 + })
  1311 + positionRepo := factory.CreatePositionRepository(map[string]interface{}{
  1312 + "transactionContext": transactionContext,
  1313 + })
  1314 + limit := param.PageSize
  1315 + offset := (param.PageNumber - 1) * param.PageSize
  1316 +
  1317 + //获取评估列表信息
  1318 + condition1 := map[string]interface{}{
  1319 + "cycleId": param.CycleId,
  1320 + "types": int(domain.EvaluationSuper),
  1321 + "limit": limit,
  1322 + }
  1323 + if offset > 0 {
  1324 + condition1["offset"] = offset
  1325 + }
  1326 + if len(param.TargetUserName) == 0 {
  1327 + condition1["targetUserName"] = "%" + param.TargetUserName + "%"
  1328 + }
  1329 + //获取评估列表信息
  1330 + cnt, evaluationList, err := evaluationRepo.Find(condition1)
  1331 + if err != nil {
  1332 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1333 + }
  1334 + targetUserIds := []int{}
  1335 + for _, v := range evaluationList {
  1336 + targetUserIds = append(targetUserIds, v.TargetUser.UserId)
  1337 + }
1314 1338
1315 - return nil, nil 1339 + //获取员工信息
  1340 + userMap := map[int64]*domain.User{}
  1341 + if len(targetUserIds) > 0 {
  1342 + _, userList, err := userRepo.Find(map[string]interface{}{
  1343 + "ids": targetUserIds,
  1344 + })
  1345 + if err != nil {
  1346 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1347 + }
  1348 + for _, v := range userList {
  1349 + userMap[v.Id] = v
  1350 + }
  1351 + }
  1352 + var positionIds []int
  1353 + //获取职位列表
  1354 + positionMap := map[int64]*domain.Position{}
  1355 + for _, v := range userMap {
  1356 + positionIds = append(positionIds, v.PositionId...)
  1357 + }
  1358 + if len(positionIds) > 0 {
  1359 + _, positionList, err := positionRepo.Find(map[string]interface{}{"ids": positionIds})
  1360 + if err != nil {
  1361 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
  1362 + }
  1363 + for _, v := range positionList {
  1364 + positionMap[v.Id] = v
  1365 + }
  1366 + }
  1367 + if err := transactionContext.CommitTransaction(); err != nil {
  1368 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1369 + }
  1370 + evaluationListAdapter := []*adapter.EvaluationSuperItemAdapter{}
  1371 + for _, v := range evaluationList {
  1372 + item := adapter.EvaluationSuperItemAdapter{
  1373 + SummaryEvaluationId: v.Id,
  1374 + TargetUserName: v.TargetUser.UserName,
  1375 + TargetUserId: v.TargetUser.UserId,
  1376 + CycleId: v.CycleId,
  1377 + TotalScore: v.TotalScore,
  1378 + Department: "",
  1379 + Position: "",
  1380 + }
  1381 + for _, dep := range v.TargetDepartment {
  1382 + item.Department += dep.DepartmentName + " "
  1383 + }
  1384 + //填充员工信息
  1385 + if targetUser, ok := userMap[int64(v.TargetUser.UserId)]; ok {
  1386 + //填充职位信息
  1387 + for _, positionId := range targetUser.PositionId {
  1388 + if position, ok := positionMap[int64(positionId)]; ok {
  1389 + item.Position += position.Name + " "
  1390 + }
  1391 + }
  1392 + }
  1393 + evaluationListAdapter = append(evaluationListAdapter, &item)
  1394 + }
  1395 + result := tool_funs.SimpleWrapGridMap(int64(cnt), evaluationListAdapter)
  1396 + return result, nil
1316 } 1397 }
@@ -259,10 +259,10 @@ func (c *SummaryEvaluationController) EditEvaluationSuper() { @@ -259,10 +259,10 @@ func (c *SummaryEvaluationController) EditEvaluationSuper() {
259 c.Response(data, err) 259 c.Response(data, err)
260 } 260 }
261 261
262 -// 上级评估列表  
263 -func (c *SummaryEvaluationController) ListEvaluationSuper() { 262 +// 执行人的上级评估列表
  263 +func (c *SummaryEvaluationController) ListExecutorEvaluationSuper() {
264 srv := service.NewSummaryEvaluationService() 264 srv := service.NewSummaryEvaluationService()
265 - param := &command.QueryEvaluationList{} 265 + param := &command.QueryExecutorEvaluationList{}
266 err := c.BindJSON(param) 266 err := c.BindJSON(param)
267 if err != nil { 267 if err != nil {
268 e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) 268 e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
@@ -272,7 +272,7 @@ func (c *SummaryEvaluationController) ListEvaluationSuper() { @@ -272,7 +272,7 @@ func (c *SummaryEvaluationController) ListEvaluationSuper() {
272 userReq := middlewares.GetUser(c.Ctx) 272 userReq := middlewares.GetUser(c.Ctx)
273 param.CompanyId = int(userReq.CompanyId) 273 param.CompanyId = int(userReq.CompanyId)
274 param.ExecutorId = int(userReq.UserId) 274 param.ExecutorId = int(userReq.UserId)
275 - data, err := srv.ListEvaluationSuper(param) 275 + data, err := srv.ListExecutorEvaluationSuper(param)
276 c.Response(data, err) 276 c.Response(data, err)
277 } 277 }
278 278
@@ -307,3 +307,19 @@ func (c *SummaryEvaluationController) GetTargetUserEvaluationSuper() { @@ -307,3 +307,19 @@ func (c *SummaryEvaluationController) GetTargetUserEvaluationSuper() {
307 data, err := srv.GetTargetUserEvaluationSuper(paramReq) 307 data, err := srv.GetTargetUserEvaluationSuper(paramReq)
308 c.Response(data, err) 308 c.Response(data, err)
309 } 309 }
  310 +
  311 +// 按周期获取上级评估列表
  312 +func (c *SummaryEvaluationController) ListAllEvaluationSuper() {
  313 + srv := service.NewSummaryEvaluationService()
  314 + param := &command.QueryEvaluationList{}
  315 + err := c.BindJSON(param)
  316 + if err != nil {
  317 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  318 + c.Response(nil, e)
  319 + return
  320 + }
  321 + userReq := middlewares.GetUser(c.Ctx)
  322 + param.CompanyId = int(userReq.CompanyId)
  323 + data, err := srv.ListAllEvaluationSuper(param)
  324 + c.Response(data, err)
  325 +}
@@ -25,9 +25,10 @@ func init() { @@ -25,9 +25,10 @@ func init() {
25 web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevel), 25 web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevel),
26 web.NSCtrlPost("/evaluation-super", (*controllers.SummaryEvaluationController).GetEvaluationSuper), 26 web.NSCtrlPost("/evaluation-super", (*controllers.SummaryEvaluationController).GetEvaluationSuper),
27 web.NSCtrlPost("/evaluation-super/edit", (*controllers.SummaryEvaluationController).EditEvaluationSuper), 27 web.NSCtrlPost("/evaluation-super/edit", (*controllers.SummaryEvaluationController).EditEvaluationSuper),
28 - web.NSCtrlPost("/evaluation-super/list", (*controllers.SummaryEvaluationController).ListEvaluationSuper), 28 + web.NSCtrlPost("/evaluation-super/list", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSuper),
29 web.NSCtrlPost("/evaluation-super/confirm", (*controllers.SummaryEvaluationController).ConfirmScoreSuperEvaluation), 29 web.NSCtrlPost("/evaluation-super/confirm", (*controllers.SummaryEvaluationController).ConfirmScoreSuperEvaluation),
30 web.NSCtrlPost("/target_user/evaluation-super", (*controllers.SummaryEvaluationController).GetTargetUserEvaluationSuper), 30 web.NSCtrlPost("/target_user/evaluation-super", (*controllers.SummaryEvaluationController).GetTargetUserEvaluationSuper),
  31 + web.NSCtrlPost("/evaluation-super/all", (*controllers.SummaryEvaluationController).ListAllEvaluationSuper),
31 // 32 //
32 ) 33 )
33 web.AddNamespace(summaryNS) 34 web.AddNamespace(summaryNS)