正在显示
5 个修改的文件
包含
152 行增加
和
13 行删除
1 | package command | 1 | package command |
2 | 2 | ||
3 | type QueryEvaluationList struct { | 3 | type QueryEvaluationList struct { |
4 | - PageNumber int `json:"pageNumber"` | ||
5 | - PageSize int `json:"pageSize"` | ||
6 | - CycleId int `json:"cycleId,string"` | ||
7 | - CompanyId int `json:"companyId"` | ||
8 | - ExecutorId int `json:"executorId"` | ||
9 | - TargetUsrName string `json:"targetUsrName"` | 4 | + PageNumber int `json:"pageNumber"` |
5 | + PageSize int `json:"pageSize"` | ||
6 | + CycleId int `json:"cycleId,string"` | ||
7 | + CompanyId int `json:"-"` | ||
8 | + ExecutorId int `json:"-"` | ||
9 | + TargetUserName string `json:"targetUserName"` | ||
10 | } | 10 | } |
@@ -994,10 +994,40 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva | @@ -994,10 +994,40 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva | ||
994 | userRepo := factory.CreateUserRepository(map[string]interface{}{ | 994 | userRepo := factory.CreateUserRepository(map[string]interface{}{ |
995 | "transactionContext": transactionContext, | 995 | "transactionContext": transactionContext, |
996 | }) | 996 | }) |
997 | - cnt, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | 997 | + positionRepo := factory.CreatePositionRepository(map[string]interface{}{ |
998 | + "transactionContext": transactionContext, | ||
999 | + }) | ||
1000 | + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{ | ||
1001 | + "transactionContext": transactionContext, | ||
1002 | + }) | ||
1003 | + limit := param.PageSize | ||
1004 | + offset := (param.PageNumber - 1) * param.PageSize | ||
1005 | + | ||
1006 | + //获取评估列表信息 | ||
1007 | + condition1 := map[string]interface{}{ | ||
1008 | + "cycleId": param.CycleId, | ||
1009 | + "executorId": param.ExecutorId, | ||
1010 | + "types": int(domain.EvaluationSuper), | ||
1011 | + "limit": limit, | ||
1012 | + } | ||
1013 | + if offset > 0 { | ||
1014 | + condition1["offset"] = offset | ||
1015 | + } | ||
1016 | + if len(param.TargetUserName) == 0 { | ||
1017 | + condition1["targetUserName"] = "%" + param.TargetUserName + "%" | ||
1018 | + } | ||
1019 | + //获取评估列表信息 | ||
1020 | + cnt, evaluationList, err := evaluationRepo.Find(condition1) | ||
1021 | + if err != nil { | ||
1022 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1023 | + } | ||
1024 | + //获取未完成上级评估的数量 | ||
1025 | + cntUn, _, err := evaluationRepo.Find(map[string]interface{}{ | ||
998 | "cycleId": param.CycleId, | 1026 | "cycleId": param.CycleId, |
999 | "executorId": param.ExecutorId, | 1027 | "executorId": param.ExecutorId, |
1000 | "types": int(domain.EvaluationSuper), | 1028 | "types": int(domain.EvaluationSuper), |
1029 | + "status": domain.EvaluationUncompleted, | ||
1030 | + "limit": 1, | ||
1001 | }) | 1031 | }) |
1002 | if err != nil { | 1032 | if err != nil { |
1003 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1033 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -1006,21 +1036,109 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva | @@ -1006,21 +1036,109 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva | ||
1006 | for _, v := range evaluationList { | 1036 | for _, v := range evaluationList { |
1007 | targetUserIds = append(targetUserIds, v.TargetUser.UserId) | 1037 | targetUserIds = append(targetUserIds, v.TargetUser.UserId) |
1008 | } | 1038 | } |
1009 | - var userList []*domain.User | 1039 | + //获取员工的综合自评 |
1040 | + evaluationSelfMap := map[int]*domain.SummaryEvaluation{} | ||
1041 | + for _, v := range evaluationList { | ||
1042 | + _, evaluationSelfList, err := evaluationRepo.Find(map[string]interface{}{ | ||
1043 | + "cycleId": param.CycleId, | ||
1044 | + "executorId": v.TargetUser.UserId, | ||
1045 | + "types": int(domain.EvaluationSelf), | ||
1046 | + "limit": 1, | ||
1047 | + }) | ||
1048 | + if err != nil { | ||
1049 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取综合自评"+err.Error()) | ||
1050 | + } | ||
1051 | + if len(evaluationSelfList) > 0 { | ||
1052 | + evaluationSelfMap[v.TargetUser.UserId] = evaluationSelfList[0] | ||
1053 | + } | ||
1054 | + } | ||
1055 | + | ||
1056 | + //获取员工信息 | ||
1057 | + userMap := map[int64]*domain.User{} | ||
1010 | if len(targetUserIds) > 0 { | 1058 | if len(targetUserIds) > 0 { |
1011 | - _, userList, err = userRepo.Find(map[string]interface{}{ | 1059 | + _, userList, err := userRepo.Find(map[string]interface{}{ |
1012 | "ids": targetUserIds, | 1060 | "ids": targetUserIds, |
1013 | }) | 1061 | }) |
1014 | if err != nil { | 1062 | if err != nil { |
1015 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1063 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1016 | } | 1064 | } |
1065 | + for _, v := range userList { | ||
1066 | + userMap[v.Id] = v | ||
1067 | + } | ||
1068 | + } | ||
1069 | + var departmentIds []int | ||
1070 | + //获取部门 | ||
1071 | + departmentMap := map[int64]*domain.Department{} | ||
1072 | + var positionIds []int | ||
1073 | + //获取职位列表 | ||
1074 | + positionMap := map[int64]*domain.Position{} | ||
1075 | + for _, v := range userMap { | ||
1076 | + departmentIds = append(departmentIds, v.DepartmentId...) | ||
1077 | + positionIds = append(positionIds, v.PositionId...) | ||
1078 | + } | ||
1079 | + if len(departmentIds) > 0 { | ||
1080 | + _, departmentList, err := departmentRepo.Find(map[string]interface{}{"ids": departmentIds}) | ||
1081 | + if err != nil { | ||
1082 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error()) | ||
1083 | + } | ||
1084 | + for _, v := range departmentList { | ||
1085 | + departmentMap[v.Id] = v | ||
1086 | + } | ||
1017 | } | 1087 | } |
1018 | 1088 | ||
1019 | - _ = userList | ||
1020 | - _ = evaluationList | ||
1021 | - _ = cnt | 1089 | + if len(positionIds) > 0 { |
1090 | + _, positionList, err := positionRepo.Find(map[string]interface{}{"ids": departmentIds}) | ||
1091 | + if err != nil { | ||
1092 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error()) | ||
1093 | + } | ||
1094 | + for _, v := range positionList { | ||
1095 | + positionMap[v.Id] = v | ||
1096 | + } | ||
1097 | + } | ||
1022 | if err := transactionContext.CommitTransaction(); err != nil { | 1098 | if err := transactionContext.CommitTransaction(); err != nil { |
1023 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1099 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1024 | } | 1100 | } |
1025 | - return nil, nil | 1101 | + evaluationListAdapter := []*adapter.EvaluationSuperListAdapter{} |
1102 | + for _, v := range evaluationList { | ||
1103 | + item := adapter.EvaluationSuperListAdapter{ | ||
1104 | + SummaryEvaluationId: v.Id, | ||
1105 | + TargetUserName: v.TargetUser.UserName, | ||
1106 | + EvaluationStatus: string(v.Status), | ||
1107 | + EndTime: v.EndTime.Format("2006-01-02 15:04:05"), | ||
1108 | + TotalScoreSelf: "", | ||
1109 | + Department: "", | ||
1110 | + Position: "", | ||
1111 | + EntryTime: "", | ||
1112 | + } | ||
1113 | + //填充员工信息 | ||
1114 | + if targetUser, ok := userMap[int64(v.TargetUser.UserId)]; ok { | ||
1115 | + //填充部门信息 | ||
1116 | + for _, departId := range targetUser.DepartmentId { | ||
1117 | + if depart, ok := departmentMap[int64(departId)]; ok { | ||
1118 | + item.Department += depart.Name + " " | ||
1119 | + } | ||
1120 | + } | ||
1121 | + //填充职位信息 | ||
1122 | + for _, positionId := range targetUser.PositionId { | ||
1123 | + if position, ok := positionMap[int64(positionId)]; ok { | ||
1124 | + item.Position += position.Name + " " | ||
1125 | + } | ||
1126 | + } | ||
1127 | + //填充入职时间 | ||
1128 | + item.EntryTime = targetUser.EntryTime | ||
1129 | + } | ||
1130 | + //填充自评总分 | ||
1131 | + if evaluationSelf, ok := evaluationSelfMap[v.TargetUser.UserId]; ok { | ||
1132 | + item.TotalScoreSelf = evaluationSelf.TotalScore | ||
1133 | + } | ||
1134 | + evaluationListAdapter = append(evaluationListAdapter, &item) | ||
1135 | + } | ||
1136 | + result := tool_funs.SimpleWrapGridMap(int64(cnt), evaluationListAdapter) | ||
1137 | + result["endTime"] = "" | ||
1138 | + result["uncompleted_number"] = 0 | ||
1139 | + if len(evaluationList) > 0 { | ||
1140 | + result["endTime"] = evaluationList[0].EndTime.Format("2006-01-02 15:04:05") | ||
1141 | + result["uncompleted_number"] = cntUn | ||
1142 | + } | ||
1143 | + return result, nil | ||
1026 | } | 1144 | } |
@@ -144,6 +144,10 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{ | @@ -144,6 +144,10 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{ | ||
144 | query.Where(`summary_evaluation.target_user->>'userId'='?'`, v) | 144 | query.Where(`summary_evaluation.target_user->>'userId'='?'`, v) |
145 | } | 145 | } |
146 | 146 | ||
147 | + if v, ok := queryOptions["targetUserName"]; ok { | ||
148 | + query.Where(`summary_evaluation.target_user->>'userName' like ?`, v) | ||
149 | + } | ||
150 | + | ||
147 | if v, ok := queryOptions["executorId"]; ok { | 151 | if v, ok := queryOptions["executorId"]; ok { |
148 | query.Where(`summary_evaluation.executor->>'userId'='?'`, v) | 152 | query.Where(`summary_evaluation.executor->>'userId'='?'`, v) |
149 | } | 153 | } |
@@ -205,3 +205,19 @@ func (c *SummaryEvaluationController) EditEvaluationSuper() { | @@ -205,3 +205,19 @@ func (c *SummaryEvaluationController) EditEvaluationSuper() { | ||
205 | data, err := srv.EditEvaluationSuper(param) | 205 | data, err := srv.EditEvaluationSuper(param) |
206 | c.Response(data, err) | 206 | c.Response(data, err) |
207 | } | 207 | } |
208 | + | ||
209 | +func (c *SummaryEvaluationController) ListEvaluationSuper() { | ||
210 | + srv := service.NewSummaryEvaluationService() | ||
211 | + param := &command.QueryEvaluationList{} | ||
212 | + err := c.BindJSON(param) | ||
213 | + if err != nil { | ||
214 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
215 | + c.Response(nil, e) | ||
216 | + return | ||
217 | + } | ||
218 | + userReq := middlewares.GetUser(c.Ctx) | ||
219 | + param.CompanyId = int(userReq.CompanyId) | ||
220 | + param.ExecutorId = int(userReq.UserId) | ||
221 | + data, err := srv.ListEvaluationSuper(param) | ||
222 | + c.Response(data, err) | ||
223 | +} |
@@ -22,6 +22,7 @@ func init() { | @@ -22,6 +22,7 @@ func init() { | ||
22 | web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevel), | 22 | web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevel), |
23 | web.NSCtrlPost("/evaluation-super", (*controllers.SummaryEvaluationController).GetEvaluationSuper), | 23 | web.NSCtrlPost("/evaluation-super", (*controllers.SummaryEvaluationController).GetEvaluationSuper), |
24 | web.NSCtrlPost("/evaluation-super/edit", (*controllers.SummaryEvaluationController).EditEvaluationSuper), | 24 | web.NSCtrlPost("/evaluation-super/edit", (*controllers.SummaryEvaluationController).EditEvaluationSuper), |
25 | + web.NSCtrlPost("/evaluation-super/list", (*controllers.SummaryEvaluationController).ListEvaluationSuper), | ||
25 | ) | 26 | ) |
26 | web.AddNamespace(summaryNS) | 27 | web.AddNamespace(summaryNS) |
27 | } | 28 | } |
-
请 注册 或 登录 后发表评论