|
@@ -829,7 +829,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv |
|
@@ -829,7 +829,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv |
829
|
}
|
829
|
}
|
830
|
|
830
|
|
831
|
// 获取员工自评的评估内容详情
|
831
|
// 获取员工自评的评估内容详情
|
832
|
-func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
|
832
|
+func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuery) (*adapter.AssessInfoResp, error) {
|
833
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
833
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
834
|
if err != nil {
|
834
|
if err != nil {
|
835
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
835
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -971,3 +971,271 @@ func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext a |
|
@@ -971,3 +971,271 @@ func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext a |
971
|
}
|
971
|
}
|
972
|
return contentList, nil
|
972
|
return contentList, nil
|
973
|
}
|
973
|
}
|
|
|
974
|
+
|
|
|
975
|
+// 选择员工评估可邀请的用户
|
|
|
976
|
+func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessInviteUser) (map[string]interface{}, error) {
|
|
|
977
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
978
|
+ if err != nil {
|
|
|
979
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
980
|
+ }
|
|
|
981
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
982
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
983
|
+ }
|
|
|
984
|
+ defer func() {
|
|
|
985
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
986
|
+ }()
|
|
|
987
|
+ //获取被评估的目标用户
|
|
|
988
|
+ userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
989
|
+ "transactionContext": transactionContext,
|
|
|
990
|
+ })
|
|
|
991
|
+ targetUser, err := userRepo.FindOne(map[string]interface{}{
|
|
|
992
|
+ "id": param.TargetUserId,
|
|
|
993
|
+ })
|
|
|
994
|
+ if err != nil {
|
|
|
995
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error())
|
|
|
996
|
+ }
|
|
|
997
|
+ //获取被评估的目标用户的部门
|
|
|
998
|
+ departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
999
|
+ "transactionContext": transactionContext,
|
|
|
1000
|
+ })
|
|
|
1001
|
+
|
|
|
1002
|
+ _, targetUserDepartment, err := departmentRepo.Find(map[string]interface{}{
|
|
|
1003
|
+ "ids": targetUser.DepartmentId,
|
|
|
1004
|
+ })
|
|
|
1005
|
+
|
|
|
1006
|
+ if err != nil {
|
|
|
1007
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
|
|
|
1008
|
+ }
|
|
|
1009
|
+ //获取部门主管的id
|
|
|
1010
|
+ targetUserCharge := map[int64]struct{}{}
|
|
|
1011
|
+ for _, v := range targetUserDepartment {
|
|
|
1012
|
+ for _, vv := range v.ChargeUserIds {
|
|
|
1013
|
+ targetUserCharge[vv] = struct{}{}
|
|
|
1014
|
+ }
|
|
|
1015
|
+ }
|
|
|
1016
|
+ //
|
|
|
1017
|
+ targetUserDepartmentMap := map[int64]struct{}{}
|
|
|
1018
|
+ for _, v := range targetUserDepartment {
|
|
|
1019
|
+ targetUserDepartmentMap[v.Id] = struct{}{}
|
|
|
1020
|
+ }
|
|
|
1021
|
+ //查询员工数据
|
|
|
1022
|
+ condition := map[string]interface{}{
|
|
|
1023
|
+ "companyId": param.CompanyId,
|
|
|
1024
|
+ "name": param.InviteUserName,
|
|
|
1025
|
+ "limit": 20,
|
|
|
1026
|
+ }
|
|
|
1027
|
+ if param.PageSize > 0 {
|
|
|
1028
|
+ condition["limit"] = param.PageSize
|
|
|
1029
|
+ }
|
|
|
1030
|
+ offset := (param.PageNumber - 1) * param.PageSize
|
|
|
1031
|
+ if offset > 0 {
|
|
|
1032
|
+ condition["offset"] = offset
|
|
|
1033
|
+ }
|
|
|
1034
|
+ cnt, userList, err := userRepo.Find(condition)
|
|
|
1035
|
+ if err != nil {
|
|
|
1036
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工列表信息"+err.Error())
|
|
|
1037
|
+ }
|
|
|
1038
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
1039
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1040
|
+ }
|
|
|
1041
|
+ listData := []adapter.SelectInviteUser{}
|
|
|
1042
|
+ for _, v := range userList {
|
|
|
1043
|
+ item := adapter.SelectInviteUser{
|
|
|
1044
|
+ UserId: int(v.Id),
|
|
|
1045
|
+ UserName: v.Name,
|
|
|
1046
|
+ IsSupper: false,
|
|
|
1047
|
+ Types: 2, //默认是不同上级
|
|
|
1048
|
+ }
|
|
|
1049
|
+ if _, ok := targetUserCharge[v.Id]; ok {
|
|
|
1050
|
+ item.IsSupper = true
|
|
|
1051
|
+ }
|
|
|
1052
|
+ for _, vv := range v.DepartmentId {
|
|
|
1053
|
+ if _, ok := targetUserDepartmentMap[int64(vv)]; ok {
|
|
|
1054
|
+ item.Types = 1 //设为相同上级
|
|
|
1055
|
+ break
|
|
|
1056
|
+ }
|
|
|
1057
|
+ }
|
|
|
1058
|
+ listData = append(listData, item)
|
|
|
1059
|
+ }
|
|
|
1060
|
+ return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
|
|
|
1061
|
+}
|
|
|
1062
|
+
|
|
|
1063
|
+// 获取我的360评估,用户列表和评估填写的值
|
|
|
1064
|
+func (srv StaffAssessServeice) ListInviteUserAssess(param *query.ListInviteUserAssessQuery) (
|
|
|
1065
|
+ *adapter.ListInviteUserAssessResp, error) {
|
|
|
1066
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
1067
|
+ if err != nil {
|
|
|
1068
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1069
|
+ }
|
|
|
1070
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
1071
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1072
|
+ }
|
|
|
1073
|
+ defer func() {
|
|
|
1074
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
1075
|
+ }()
|
|
|
1076
|
+ //获取对应的评估任务
|
|
|
1077
|
+ assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
1078
|
+ "transactionContext": transactionContext,
|
|
|
1079
|
+ })
|
|
|
1080
|
+ //获取 executorId 对应的360评估任务 用户
|
|
|
1081
|
+ cnt, assessList, err := assessRepo.Find(map[string]interface{}{
|
|
|
1082
|
+ "staffAssessTaskId": param.AssessTaskkId,
|
|
|
1083
|
+ "executorId": param.ExecutorId,
|
|
|
1084
|
+ "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
|
|
|
1085
|
+ })
|
|
|
1086
|
+ if err != nil {
|
|
|
1087
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1088
|
+ }
|
|
|
1089
|
+ // 获取已经填报的内容
|
|
|
1090
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
1091
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1092
|
+ }
|
|
|
1093
|
+
|
|
|
1094
|
+ //TODO 评估填写数据行转列
|
|
|
1095
|
+ tableHeader := []adapter.ListTableHeader{
|
|
|
1096
|
+ {Key: "userName", Name: "姓名"},
|
|
|
1097
|
+ {Key: "status", Name: "状态"},
|
|
|
1098
|
+ {Key: "types", Name: "360°评估关系"},
|
|
|
1099
|
+ {Key: "endTime", Name: "360°评估截止日期"},
|
|
|
1100
|
+ }
|
|
|
1101
|
+ listData := []map[string]string{}
|
|
|
1102
|
+ for _, v := range assessList {
|
|
|
1103
|
+ m := map[string]string{
|
|
|
1104
|
+ "userName": v.TargetUser.UserName,
|
|
|
1105
|
+ "status": string(v.Status),
|
|
|
1106
|
+ "types": string(v.Types),
|
|
|
1107
|
+ "endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
1108
|
+ }
|
|
|
1109
|
+ listData = append(listData, m)
|
|
|
1110
|
+ }
|
|
|
1111
|
+ _ = tableHeader
|
|
|
1112
|
+
|
|
|
1113
|
+ result := adapter.ListInviteUserAssessResp{
|
|
|
1114
|
+ TableHeader: tableHeader,
|
|
|
1115
|
+ List: listData,
|
|
|
1116
|
+ Total: cnt,
|
|
|
1117
|
+ }
|
|
|
1118
|
+ return &result, nil
|
|
|
1119
|
+}
|
|
|
1120
|
+
|
|
|
1121
|
+// 获取上级评估成员列表
|
|
|
1122
|
+func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQuery) (map[string]interface{}, error) {
|
|
|
1123
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
1124
|
+ if err != nil {
|
|
|
1125
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1126
|
+ }
|
|
|
1127
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
1128
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1129
|
+ }
|
|
|
1130
|
+ defer func() {
|
|
|
1131
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
1132
|
+ }()
|
|
|
1133
|
+ //获取对应的评估任务
|
|
|
1134
|
+ assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
1135
|
+ "transactionContext": transactionContext,
|
|
|
1136
|
+ })
|
|
|
1137
|
+ //获取 executorId 对应的上级评估列表
|
|
|
1138
|
+ cnt, assessList, err := assessRepo.Find(map[string]interface{}{
|
|
|
1139
|
+ "staffAssessTaskId": param.AssessTaskkId,
|
|
|
1140
|
+ "executorId": param.ExecutorId,
|
|
|
1141
|
+ "typesList": []string{string(domain.AssessSuper)},
|
|
|
1142
|
+ })
|
|
|
1143
|
+ if err != nil {
|
|
|
1144
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1145
|
+ }
|
|
|
1146
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
1147
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1148
|
+ }
|
|
|
1149
|
+
|
|
|
1150
|
+ resultList := []adapter.ListSupperAssessResp{}
|
|
|
1151
|
+ for _, v := range assessList {
|
|
|
1152
|
+ item := adapter.ListSupperAssessResp{
|
|
|
1153
|
+ AssessId: v.Id,
|
|
|
1154
|
+ UserName: v.TargetUser.UserName,
|
|
|
1155
|
+ EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
1156
|
+ InviteUncompleted: 0,
|
|
|
1157
|
+ InviteTotal: 5,
|
|
|
1158
|
+ Department: "",
|
|
|
1159
|
+ Position: "",
|
|
|
1160
|
+ DutyTime: "",
|
|
|
1161
|
+ }
|
|
|
1162
|
+
|
|
|
1163
|
+ for _, vv := range v.TargetDepartment {
|
|
|
1164
|
+ item.Department += vv.DepartmentName + " "
|
|
|
1165
|
+ }
|
|
|
1166
|
+ resultList = append(resultList, item)
|
|
|
1167
|
+ }
|
|
|
1168
|
+ return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil
|
|
|
1169
|
+}
|
|
|
1170
|
+
|
|
|
1171
|
+// 根据staffAssessId 获取评估的填写信息
|
|
|
1172
|
+func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
|
|
|
1173
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
1174
|
+ if err != nil {
|
|
|
1175
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1176
|
+ }
|
|
|
1177
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
1178
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1179
|
+ }
|
|
|
1180
|
+ defer func() {
|
|
|
1181
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
1182
|
+ }()
|
|
|
1183
|
+ assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
1184
|
+ "transactionContext": transactionContext,
|
|
|
1185
|
+ })
|
|
|
1186
|
+ //获取员工的评估
|
|
|
1187
|
+ _, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
1188
|
+ "companyId": param.CompanyId,
|
|
|
1189
|
+ "id": param.AssessId,
|
|
|
1190
|
+ })
|
|
|
1191
|
+ if err != nil {
|
|
|
1192
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
|
|
|
1193
|
+ }
|
|
|
1194
|
+ if len(assessList) == 0 {
|
|
|
1195
|
+ return &adapter.AssessInfoResp{}, nil
|
|
|
1196
|
+ }
|
|
|
1197
|
+ assessData := assessList[0]
|
|
|
1198
|
+ assessContentList := []*domain.StaffAssessContent{}
|
|
|
1199
|
+ if assessData.Status == domain.StaffAssessCompleted {
|
|
|
1200
|
+ //已完成
|
|
|
1201
|
+ assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
|
|
|
1202
|
+ "transactionContext": transactionContext,
|
|
|
1203
|
+ })
|
|
|
1204
|
+ _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
|
|
|
1205
|
+ "staffAssessId": assessData.Id,
|
|
|
1206
|
+ })
|
|
|
1207
|
+ if err != nil {
|
|
|
1208
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
|
|
|
1209
|
+ }
|
|
|
1210
|
+ } else if assessData.Status == domain.StaffAssessUncompleted {
|
|
|
1211
|
+ //未完成
|
|
|
1212
|
+ assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData)
|
|
|
1213
|
+ if err != nil {
|
|
|
1214
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
|
|
|
1215
|
+ }
|
|
|
1216
|
+ }
|
|
|
1217
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
1218
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1219
|
+ }
|
|
|
1220
|
+
|
|
|
1221
|
+ result := adapter.AssessInfoResp{
|
|
|
1222
|
+ AssessId: assessData.Id,
|
|
|
1223
|
+ CycleId: assessData.CycleId,
|
|
|
1224
|
+ CycleName: assessData.CycleName,
|
|
|
1225
|
+ EvaluationProjectId: assessData.EvaluationProjectId,
|
|
|
1226
|
+ EvaluationProjectName: assessData.EvaluationProjectName,
|
|
|
1227
|
+ BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
1228
|
+ EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
1229
|
+ Status: string(assessData.Status),
|
|
|
1230
|
+ TargetUserId: assessData.TargetUser.UserId,
|
|
|
1231
|
+ TargetUserName: assessData.TargetUser.UserName,
|
|
|
1232
|
+ AssessContent: assessContentList,
|
|
|
1233
|
+ }
|
|
|
1234
|
+ return &result, nil
|
|
|
1235
|
+}
|
|
|
1236
|
+
|
|
|
1237
|
+// 获取员工的某次评估任务的360评估记录录
|
|
|
1238
|
+// assessTaskId targetUserId
|
|
|
1239
|
+func (srv StaffAssessServeice) AssessInviteList() error {
|
|
|
1240
|
+ return nil
|
|
|
1241
|
+} |