|
@@ -12,6 +12,7 @@ import ( |
|
@@ -12,6 +12,7 @@ import ( |
12
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
|
12
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
|
13
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
|
13
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
|
14
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
14
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
15
|
+ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
|
15
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
|
16
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
|
16
|
)
|
17
|
)
|
17
|
|
18
|
|
|
@@ -321,16 +322,15 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) |
|
@@ -321,16 +322,15 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) |
321
|
DutyTime: userData.CreatedAt.Local().Format("2006-01-02 15:04:05"),
|
322
|
DutyTime: userData.CreatedAt.Local().Format("2006-01-02 15:04:05"),
|
322
|
}
|
323
|
}
|
323
|
for _, v := range supperUserList {
|
324
|
for _, v := range supperUserList {
|
324
|
- userInfo.SupperUserName = userInfo.SupperUserName + v.Name + ";"
|
325
|
+ userInfo.SupperUserName = userInfo.SupperUserName + v.Name + " "
|
325
|
}
|
326
|
}
|
326
|
result := tool_funs.SimpleWrapGridMap(int64(cnt), listData)
|
327
|
result := tool_funs.SimpleWrapGridMap(int64(cnt), listData)
|
327
|
result["userInfo"] = userInfo
|
328
|
result["userInfo"] = userInfo
|
328
|
return result, nil
|
329
|
return result, nil
|
329
|
}
|
330
|
}
|
330
|
|
331
|
|
331
|
-// 更具项目评估的配置,创建员工的评估任务
|
332
|
+// 根据项目评估的配置,创建员工的评估任务
|
332
|
func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) {
|
333
|
func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) {
|
333
|
-
|
|
|
334
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
334
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
335
|
if err != nil {
|
335
|
if err != nil {
|
336
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
336
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -546,7 +546,7 @@ func (srv StaffAssessServeice) createStaffAssessSupper( |
|
@@ -546,7 +546,7 @@ func (srv StaffAssessServeice) createStaffAssessSupper( |
546
|
return nil, nil
|
546
|
return nil, nil
|
547
|
}
|
547
|
}
|
548
|
|
548
|
|
549
|
-// 获取某个员工360邀请的人员
|
549
|
+// 获取某个员工360评估邀请的人员
|
550
|
func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) {
|
550
|
func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) {
|
551
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
551
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
552
|
if err != nil {
|
552
|
if err != nil {
|
|
@@ -877,10 +877,12 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuer |
|
@@ -877,10 +877,12 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuer |
877
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
|
877
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
|
878
|
}
|
878
|
}
|
879
|
}
|
879
|
}
|
|
|
880
|
+
|
|
|
881
|
+ //获取员工描述
|
|
|
882
|
+ staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId))
|
880
|
if err := transactionContext.CommitTransaction(); err != nil {
|
883
|
if err := transactionContext.CommitTransaction(); err != nil {
|
881
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
884
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
882
|
}
|
885
|
}
|
883
|
-
|
|
|
884
|
result := adapter.AssessInfoResp{
|
886
|
result := adapter.AssessInfoResp{
|
885
|
AssessId: assessData.Id,
|
887
|
AssessId: assessData.Id,
|
886
|
CycleId: assessData.CycleId,
|
888
|
CycleId: assessData.CycleId,
|
|
@@ -892,8 +894,17 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuer |
|
@@ -892,8 +894,17 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuer |
892
|
Status: string(assessData.Status),
|
894
|
Status: string(assessData.Status),
|
893
|
TargetUserId: assessData.TargetUser.UserId,
|
895
|
TargetUserId: assessData.TargetUser.UserId,
|
894
|
TargetUserName: assessData.TargetUser.UserName,
|
896
|
TargetUserName: assessData.TargetUser.UserName,
|
|
|
897
|
+ CompanyId: assessData.CompanyId,
|
|
|
898
|
+ CompanyName: "",
|
|
|
899
|
+ SupperUser: "",
|
|
|
900
|
+ DutyTime: "",
|
895
|
AssessContent: assessContentList,
|
901
|
AssessContent: assessContentList,
|
896
|
}
|
902
|
}
|
|
|
903
|
+ if staffDesc != nil {
|
|
|
904
|
+ result.CompanyName = staffDesc.CompanyName
|
|
|
905
|
+ result.SupperUser = staffDesc.SupperUserName
|
|
|
906
|
+ result.DutyTime = staffDesc.DutyTime
|
|
|
907
|
+ }
|
897
|
return &result, nil
|
908
|
return &result, nil
|
898
|
}
|
909
|
}
|
899
|
|
910
|
|
|
@@ -998,13 +1009,14 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI |
|
@@ -998,13 +1009,14 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI |
998
|
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
1009
|
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
999
|
"transactionContext": transactionContext,
|
1010
|
"transactionContext": transactionContext,
|
1000
|
})
|
1011
|
})
|
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())
|
1012
|
+ var targetUserDepartment []*domain.Department
|
|
|
1013
|
+ if len(targetUser.DepartmentId) > 0 {
|
|
|
1014
|
+ _, targetUserDepartment, err = departmentRepo.Find(map[string]interface{}{
|
|
|
1015
|
+ "ids": targetUser.DepartmentId,
|
|
|
1016
|
+ })
|
|
|
1017
|
+ if err != nil {
|
|
|
1018
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
|
|
|
1019
|
+ }
|
1008
|
}
|
1020
|
}
|
1009
|
//获取部门主管的id
|
1021
|
//获取部门主管的id
|
1010
|
targetUserCharge := map[int64]struct{}{}
|
1022
|
targetUserCharge := map[int64]struct{}{}
|
|
@@ -1060,8 +1072,8 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI |
|
@@ -1060,8 +1072,8 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI |
1060
|
return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
|
1072
|
return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
|
1061
|
}
|
1073
|
}
|
1062
|
|
1074
|
|
1063
|
-// 获取我的360评估,用户列表和评估填写的值
|
|
|
1064
|
-func (srv StaffAssessServeice) ListInviteUserAssess(param *query.ListInviteUserAssessQuery) (
|
1075
|
+// 获取我要执行的的360评估,用户列表和评估填写的值
|
|
|
1076
|
+func (srv StaffAssessServeice) ListExecutorInviteAssess(param *query.ListInviteUserAssessQuery) (
|
1065
|
*adapter.ListInviteUserAssessResp, error) {
|
1077
|
*adapter.ListInviteUserAssessResp, error) {
|
1066
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
1078
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
1067
|
if err != nil {
|
1079
|
if err != nil {
|
|
@@ -1118,8 +1130,8 @@ func (srv StaffAssessServeice) ListInviteUserAssess(param *query.ListInviteUserA |
|
@@ -1118,8 +1130,8 @@ func (srv StaffAssessServeice) ListInviteUserAssess(param *query.ListInviteUserA |
1118
|
return &result, nil
|
1130
|
return &result, nil
|
1119
|
}
|
1131
|
}
|
1120
|
|
1132
|
|
1121
|
-// 获取上级评估成员列表
|
|
|
1122
|
-func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQuery) (map[string]interface{}, error) {
|
1133
|
+// 获取我需要执行的上级评估成员列表
|
|
|
1134
|
+func (srv StaffAssessServeice) ListExecutorSupperAssess(param *query.ListSupperAssessQuery) (map[string]interface{}, error) {
|
1123
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
1135
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
1124
|
if err != nil {
|
1136
|
if err != nil {
|
1125
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
1137
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
@@ -1134,15 +1146,70 @@ func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQue |
|
@@ -1134,15 +1146,70 @@ func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQue |
1134
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
1146
|
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
|
1135
|
"transactionContext": transactionContext,
|
1147
|
"transactionContext": transactionContext,
|
1136
|
})
|
1148
|
})
|
1137
|
- //获取 executorId 对应的上级评估列表
|
|
|
1138
|
- cnt, assessList, err := assessRepo.Find(map[string]interface{}{
|
|
|
1139
|
- "staffAssessTaskId": param.AssessTaskkId,
|
1149
|
+
|
|
|
1150
|
+ limit := 20
|
|
|
1151
|
+ if param.PageSize > 0 {
|
|
|
1152
|
+ limit = param.PageSize
|
|
|
1153
|
+ }
|
|
|
1154
|
+ condition := map[string]interface{}{
|
|
|
1155
|
+ "staffAssessTaskId": param.AssessTaskId,
|
1140
|
"executorId": param.ExecutorId,
|
1156
|
"executorId": param.ExecutorId,
|
1141
|
"typesList": []string{string(domain.AssessSuper)},
|
1157
|
"typesList": []string{string(domain.AssessSuper)},
|
1142
|
- })
|
1158
|
+ "limit": limit,
|
|
|
1159
|
+ "targetUserName": param.UserName,
|
|
|
1160
|
+ }
|
|
|
1161
|
+ offset := (param.PageNumber - 1) * param.PageSize
|
|
|
1162
|
+ if offset > 0 {
|
|
|
1163
|
+ condition["offset"] = offset
|
|
|
1164
|
+ }
|
|
|
1165
|
+ //获取 executorId 对应的上级评估列表
|
|
|
1166
|
+ cnt, assessList, err := assessRepo.Find(condition)
|
1143
|
if err != nil {
|
1167
|
if err != nil {
|
1144
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1168
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1145
|
}
|
1169
|
}
|
|
|
1170
|
+
|
|
|
1171
|
+ userIds := []int{}
|
|
|
1172
|
+ for _, v := range assessList {
|
|
|
1173
|
+ userIds = append(userIds, v.TargetUser.UserId)
|
|
|
1174
|
+ }
|
|
|
1175
|
+ //获取员工信息
|
|
|
1176
|
+ userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
1177
|
+ "transactionContext": transactionContext,
|
|
|
1178
|
+ })
|
|
|
1179
|
+ var targetUserList []*domain.User
|
|
|
1180
|
+ if len(userIds) > 0 {
|
|
|
1181
|
+ _, targetUserList, _ = userRepo.Find(map[string]interface{}{
|
|
|
1182
|
+ "ids": userIds,
|
|
|
1183
|
+ })
|
|
|
1184
|
+ }
|
|
|
1185
|
+ //获取职位信息
|
|
|
1186
|
+ positionRepo := factory.CreatePositionRepository(map[string]interface{}{
|
|
|
1187
|
+ "transactionContext": transactionContext,
|
|
|
1188
|
+ })
|
|
|
1189
|
+ //获取员工的职位
|
|
|
1190
|
+ userPositionMap := map[int64][]*domain.Position{}
|
|
|
1191
|
+ for _, v := range targetUserList {
|
|
|
1192
|
+ if len(v.PositionId) == 0 {
|
|
|
1193
|
+ continue
|
|
|
1194
|
+ }
|
|
|
1195
|
+ _, positionList, _ := positionRepo.Find(map[string]interface{}{
|
|
|
1196
|
+ "ids": v.PositionId,
|
|
|
1197
|
+ })
|
|
|
1198
|
+ userPositionMap[v.Id] = positionList
|
|
|
1199
|
+ }
|
|
|
1200
|
+
|
|
|
1201
|
+ //获取员工邀请的人完成360评估的数量
|
|
|
1202
|
+ var inviteCompletedCount []dao.CountData
|
|
|
1203
|
+ if len(userIds) > 0 {
|
|
|
1204
|
+ d := dao.NewStaffAssessDao(map[string]interface{}{
|
|
|
1205
|
+ "transactionContext": transactionContext,
|
|
|
1206
|
+ })
|
|
|
1207
|
+ inviteCompletedCount, err = d.CountInviteAssessByTargetUser(userIds, param.AssessTaskId)
|
|
|
1208
|
+ if err != nil {
|
|
|
1209
|
+ log.Logger.Error("获取员工邀请的人完成情况" + err.Error())
|
|
|
1210
|
+ }
|
|
|
1211
|
+ }
|
|
|
1212
|
+
|
1146
|
if err := transactionContext.CommitTransaction(); err != nil {
|
1213
|
if err := transactionContext.CommitTransaction(); err != nil {
|
1147
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1214
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1148
|
}
|
1215
|
}
|
|
@@ -1150,19 +1217,39 @@ func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQue |
|
@@ -1150,19 +1217,39 @@ func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQue |
1150
|
resultList := []adapter.ListSupperAssessResp{}
|
1217
|
resultList := []adapter.ListSupperAssessResp{}
|
1151
|
for _, v := range assessList {
|
1218
|
for _, v := range assessList {
|
1152
|
item := adapter.ListSupperAssessResp{
|
1219
|
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: "",
|
1220
|
+ AssessId: v.Id,
|
|
|
1221
|
+ UserName: v.TargetUser.UserName,
|
|
|
1222
|
+ EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
1223
|
+ InviteCompleted: 0,
|
|
|
1224
|
+ InviteTotal: 5,
|
|
|
1225
|
+ Department: "",
|
|
|
1226
|
+ Position: "",
|
|
|
1227
|
+ DutyTime: "",
|
1161
|
}
|
1228
|
}
|
1162
|
-
|
1229
|
+ //填入部门
|
1163
|
for _, vv := range v.TargetDepartment {
|
1230
|
for _, vv := range v.TargetDepartment {
|
1164
|
item.Department += vv.DepartmentName + " "
|
1231
|
item.Department += vv.DepartmentName + " "
|
1165
|
}
|
1232
|
}
|
|
|
1233
|
+ for _, vv := range targetUserList {
|
|
|
1234
|
+ if vv.Id != int64(v.TargetUser.UserId) {
|
|
|
1235
|
+ continue
|
|
|
1236
|
+ }
|
|
|
1237
|
+ //填入入职时间
|
|
|
1238
|
+ item.DutyTime = vv.CreatedAt.Local().Format("2006-01-02 15:04:05")
|
|
|
1239
|
+ //填入职位
|
|
|
1240
|
+ for _, vvv := range userPositionMap[vv.Id] {
|
|
|
1241
|
+ item.Position += vvv.Name + " "
|
|
|
1242
|
+ }
|
|
|
1243
|
+ break
|
|
|
1244
|
+ }
|
|
|
1245
|
+ //
|
|
|
1246
|
+ for _, vv := range inviteCompletedCount {
|
|
|
1247
|
+ if v.TargetUser.UserId == vv.TargetUserId {
|
|
|
1248
|
+ item.InviteCompleted = vv.InviteCompleted
|
|
|
1249
|
+ item.InviteTotal = vv.InviteTotal
|
|
|
1250
|
+ break
|
|
|
1251
|
+ }
|
|
|
1252
|
+ }
|
1166
|
resultList = append(resultList, item)
|
1253
|
resultList = append(resultList, item)
|
1167
|
}
|
1254
|
}
|
1168
|
return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil
|
1255
|
return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil
|
|
@@ -1214,6 +1301,11 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada |
|
@@ -1214,6 +1301,11 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada |
1214
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
|
1301
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
|
1215
|
}
|
1302
|
}
|
1216
|
}
|
1303
|
}
|
|
|
1304
|
+
|
|
|
1305
|
+ targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(assessData.TargetUser.UserId))
|
|
|
1306
|
+ if err != nil {
|
|
|
1307
|
+ log.Logger.Error("获取员工描述" + err.Error())
|
|
|
1308
|
+ }
|
1217
|
if err := transactionContext.CommitTransaction(); err != nil {
|
1309
|
if err := transactionContext.CommitTransaction(); err != nil {
|
1218
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1310
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1219
|
}
|
1311
|
}
|
|
@@ -1229,8 +1321,17 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada |
|
@@ -1229,8 +1321,17 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada |
1229
|
Status: string(assessData.Status),
|
1321
|
Status: string(assessData.Status),
|
1230
|
TargetUserId: assessData.TargetUser.UserId,
|
1322
|
TargetUserId: assessData.TargetUser.UserId,
|
1231
|
TargetUserName: assessData.TargetUser.UserName,
|
1323
|
TargetUserName: assessData.TargetUser.UserName,
|
|
|
1324
|
+ CompanyId: assessData.CompanyId,
|
|
|
1325
|
+ CompanyName: "",
|
|
|
1326
|
+ SupperUser: "",
|
|
|
1327
|
+ DutyTime: "",
|
1232
|
AssessContent: assessContentList,
|
1328
|
AssessContent: assessContentList,
|
1233
|
}
|
1329
|
}
|
|
|
1330
|
+ if targetUserDesc != nil {
|
|
|
1331
|
+ result.CompanyName = targetUserDesc.CompanyName
|
|
|
1332
|
+ result.SupperUser = targetUserDesc.SupperUserName
|
|
|
1333
|
+ result.DutyTime = targetUserDesc.DutyTime
|
|
|
1334
|
+ }
|
1234
|
return &result, nil
|
1335
|
return &result, nil
|
1235
|
}
|
1336
|
}
|
1236
|
|
1337
|
|
|
@@ -1239,3 +1340,175 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada |
|
@@ -1239,3 +1340,175 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada |
1239
|
func (srv StaffAssessServeice) AssessInviteList() error {
|
1340
|
func (srv StaffAssessServeice) AssessInviteList() error {
|
1240
|
return nil
|
1341
|
return nil
|
1241
|
}
|
1342
|
}
|
|
|
1343
|
+
|
|
|
1344
|
+// 获取员工信息描述
|
|
|
1345
|
+func (srv *StaffAssessServeice) getStaffDescrip(transactionContext application.TransactionContext, userid int64) (*adapter.StaffInfo, error) {
|
|
|
1346
|
+ //获取用户数据
|
|
|
1347
|
+ userRepo := factory.CreateUserRepository(map[string]interface{}{
|
|
|
1348
|
+ "transactionContext": transactionContext,
|
|
|
1349
|
+ })
|
|
|
1350
|
+ userData, err := userRepo.FindOne(map[string]interface{}{
|
|
|
1351
|
+ "id": userid,
|
|
|
1352
|
+ })
|
|
|
1353
|
+ if err != nil {
|
|
|
1354
|
+ log.Logger.Error("获取用户信息," + err.Error())
|
|
|
1355
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取用户信息,"+err.Error())
|
|
|
1356
|
+ }
|
|
|
1357
|
+
|
|
|
1358
|
+ //获取公司数据
|
|
|
1359
|
+ companyRep := factory.CreateCompanyRepository(map[string]interface{}{
|
|
|
1360
|
+ "transactionContext": transactionContext,
|
|
|
1361
|
+ })
|
|
|
1362
|
+ companyData, err := companyRep.FindOne(map[string]interface{}{
|
|
|
1363
|
+ "id": userData.CompanyId,
|
|
|
1364
|
+ })
|
|
|
1365
|
+ if err != nil {
|
|
|
1366
|
+ log.Logger.Error("获取公司信息," + err.Error())
|
|
|
1367
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取公司信息,"+err.Error())
|
|
|
1368
|
+ }
|
|
|
1369
|
+ departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
|
|
|
1370
|
+ "transactionContext": transactionContext,
|
|
|
1371
|
+ })
|
|
|
1372
|
+ var supperUserList []*domain.User
|
|
|
1373
|
+ if len(userData.DepartmentId) > 0 {
|
|
|
1374
|
+ _, departmentList, err := departmentRepo.Find(map[string]interface{}{
|
|
|
1375
|
+ "ids": userData.DepartmentId,
|
|
|
1376
|
+ })
|
|
|
1377
|
+ if err != nil {
|
|
|
1378
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取部门信息,"+err.Error())
|
|
|
1379
|
+ }
|
|
|
1380
|
+ var chargeUserIds []int64
|
|
|
1381
|
+ for _, v := range departmentList {
|
|
|
1382
|
+ chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
|
|
|
1383
|
+ }
|
|
|
1384
|
+ if len(chargeUserIds) > 0 {
|
|
|
1385
|
+ _, supperUserList, err = userRepo.Find(map[string]interface{}{
|
|
|
1386
|
+ "ids": chargeUserIds,
|
|
|
1387
|
+ })
|
|
|
1388
|
+ if err != nil {
|
|
|
1389
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取员工上级信息,"+err.Error())
|
|
|
1390
|
+ }
|
|
|
1391
|
+ }
|
|
|
1392
|
+ }
|
|
|
1393
|
+ userInfo := adapter.StaffInfo{
|
|
|
1394
|
+ UserName: userData.Name,
|
|
|
1395
|
+ CompanyName: companyData.Name,
|
|
|
1396
|
+ SupperUserName: "",
|
|
|
1397
|
+ DutyTime: userData.CreatedAt.Local().Format("2006-01-02 15:04:05"),
|
|
|
1398
|
+ }
|
|
|
1399
|
+ for _, v := range supperUserList {
|
|
|
1400
|
+ userInfo.SupperUserName = userInfo.SupperUserName + v.Name + " "
|
|
|
1401
|
+ }
|
|
|
1402
|
+ return &userInfo, nil
|
|
|
1403
|
+}
|
|
|
1404
|
+
|
|
|
1405
|
+// 提交评估数据
|
|
|
1406
|
+func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoCommand) (map[string]interface{}, error) {
|
|
|
1407
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
1408
|
+ if err != nil {
|
|
|
1409
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1410
|
+ }
|
|
|
1411
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
1412
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1413
|
+ }
|
|
|
1414
|
+ defer func() {
|
|
|
1415
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
1416
|
+ }()
|
|
|
1417
|
+ assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
1418
|
+ "transactionContext": transactionContext,
|
|
|
1419
|
+ })
|
|
|
1420
|
+ //获取员工的评估
|
|
|
1421
|
+ assessData, err := assessReps.FindOne(map[string]interface{}{
|
|
|
1422
|
+ "id": param.AssessId,
|
|
|
1423
|
+ })
|
|
|
1424
|
+ if err != nil {
|
|
|
1425
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
|
|
|
1426
|
+ }
|
|
|
1427
|
+ assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
|
|
|
1428
|
+ "transactionContext": transactionContext,
|
|
|
1429
|
+ })
|
|
|
1430
|
+ //待更新的评估填写信息
|
|
|
1431
|
+ assessContentList := []*domain.StaffAssessContent{}
|
|
|
1432
|
+ if assessData.Status == domain.StaffAssessCompleted {
|
|
|
1433
|
+ //已完成
|
|
|
1434
|
+
|
|
|
1435
|
+ _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
|
|
|
1436
|
+ "staffAssessId": assessData.Id,
|
|
|
1437
|
+ })
|
|
|
1438
|
+ if err != nil {
|
|
|
1439
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
|
|
|
1440
|
+ }
|
|
|
1441
|
+ } else if assessData.Status == domain.StaffAssessUncompleted {
|
|
|
1442
|
+ //未完成
|
|
|
1443
|
+ assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData)
|
|
|
1444
|
+ if err != nil {
|
|
|
1445
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
|
|
|
1446
|
+ }
|
|
|
1447
|
+ }
|
|
|
1448
|
+ //处理提交上来的数据
|
|
|
1449
|
+ paramContentMap := map[string]command.AssesssContent{}
|
|
|
1450
|
+ for i, v := range param.AssessContent {
|
|
|
1451
|
+ key := fmt.Sprintf("%s-%s", v.Category, v.Name)
|
|
|
1452
|
+ paramContentMap[key] = param.AssessContent[i]
|
|
|
1453
|
+ }
|
|
|
1454
|
+ //更新的评估填写信息
|
|
|
1455
|
+ for _, v := range assessContentList {
|
|
|
1456
|
+ key := fmt.Sprintf("%s-%s", v.Category, v.Name)
|
|
|
1457
|
+ item, ok := paramContentMap[key]
|
|
|
1458
|
+ if !ok {
|
|
|
1459
|
+ continue
|
|
|
1460
|
+ }
|
|
|
1461
|
+ v.Value = item.Value
|
|
|
1462
|
+ for ii := range v.Remark {
|
|
|
1463
|
+ for _, vvv := range item.Remark {
|
|
|
1464
|
+ if v.Remark[ii].Title == vvv.Title {
|
|
|
1465
|
+ v.Remark[ii].RemarkText = vvv.RemarkText
|
|
|
1466
|
+ break
|
|
|
1467
|
+ }
|
|
|
1468
|
+ }
|
|
|
1469
|
+ }
|
|
|
1470
|
+ }
|
|
|
1471
|
+ //保存信息
|
|
|
1472
|
+ for i := range assessContentList {
|
|
|
1473
|
+ _, err = assessContentRepo.Save(assessContentList[i])
|
|
|
1474
|
+ if err != nil {
|
|
|
1475
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估填写内容"+err.Error())
|
|
|
1476
|
+ }
|
|
|
1477
|
+ }
|
|
|
1478
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
1479
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1480
|
+ }
|
|
|
1481
|
+ return map[string]interface{}{
|
|
|
1482
|
+ "assessId": assessData.Id,
|
|
|
1483
|
+ }, nil
|
|
|
1484
|
+}
|
|
|
1485
|
+
|
|
|
1486
|
+// 获取员工被评估的列表 ,类型是360邀请的
|
|
|
1487
|
+func (srv StaffAssessServeice) ListTargetUserAssess(param *query.ListTargetUserAssessQuery) (map[string]interface{}, error) {
|
|
|
1488
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
1489
|
+ if err != nil {
|
|
|
1490
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1491
|
+ }
|
|
|
1492
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
1493
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1494
|
+ }
|
|
|
1495
|
+ defer func() {
|
|
|
1496
|
+ _ = transactionContext.RollbackTransaction()
|
|
|
1497
|
+ }()
|
|
|
1498
|
+ assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
|
|
|
1499
|
+ "transactionContext": transactionContext,
|
|
|
1500
|
+ })
|
|
|
1501
|
+ //获取员工的评估
|
|
|
1502
|
+ cnt, assessList, err := assessReps.Find(map[string]interface{}{
|
|
|
1503
|
+ "assessTaskId": param.AssessTaskId,
|
|
|
1504
|
+ "companyId": param.CompanyId,
|
|
|
1505
|
+ "targetUserId": param.TargetUserId,
|
|
|
1506
|
+ })
|
|
|
1507
|
+ if err != nil {
|
|
|
1508
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
|
|
|
1509
|
+ }
|
|
|
1510
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
1511
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1512
|
+ }
|
|
|
1513
|
+ return tool_funs.SimpleWrapGridMap(int64(cnt), assessList), nil
|
|
|
1514
|
+} |