作者 Your Name

更新

1 package adapter 1 package adapter
2 2
3 type ListSupperAssessResp struct { 3 type ListSupperAssessResp struct {
4 - AssessId int `json:"assessId"` //  
5 - UserName string `json:"userName"` //用户名称  
6 - EndTime string `json:"endTime"` //截止时间  
7 - InviteTotal int `json:"inviteCompleted"` //邀请总数  
8 - InviteUncompleted int `json:"inviteUncompleted"` //邀请未完成  
9 - Department string `json:"department"` //部门  
10 - Position string `json:"position"` //职位  
11 - DutyTime string `json:"dutyTime"` //入职时间 4 + AssessId int `json:"assessId"` //
  5 + UserName string `json:"userName"` //用户名称
  6 + EndTime string `json:"endTime"` //截止时间
  7 + InviteTotal int `json:"inviteTota"` //邀请总数
  8 + InviteCompleted int `json:"inviteCompleted"` //邀请未完成
  9 + Department string `json:"department"` //部门
  10 + Position string `json:"position"` //职位
  11 + DutyTime string `json:"dutyTime"` //入职时间
12 } 12 }
  1 +package command
  2 +
  3 +//保存员工填写评估内容
  4 +type SaveAssessInfoCommand struct {
  5 + AssessId int `json:"assessId"`
  6 + AssessContent []AssesssContent `json:"assessContent"`
  7 +}
  8 +
  9 +type AssesssContent struct {
  10 + Category string `json:"category"`
  11 + Name string `json:"name"`
  12 + Value string `json:"value"`
  13 + Remark []RemarkText `json:"remark"`
  14 +}
  15 +
  16 +type RemarkText struct {
  17 + Title string `json:"title"`
  18 + RemarkText string `json:"remarkText"`
  19 +}
  1 +package query
  2 +
  3 +type ListSupperAssessQuery struct {
  4 + PageNumber int `json:"pageNumber"`
  5 + PageSize int `json:"pageSize"`
  6 + UserName string `json:"userName"` //查询条件 员工的名称
  7 + CompanyId int `json:"companyId"` //
  8 + ExecutorId int `json:"executorId"` //评估的执行人
  9 + AssessTaskId int `json:"assessTaskId"` //评估任务id
  10 +}
@@ -2,7 +2,7 @@ package query @@ -2,7 +2,7 @@ package query
2 2
3 //获取员工自评填写详情 3 //获取员工自评填写详情
4 type AssessSelfInfoQuery struct { 4 type AssessSelfInfoQuery struct {
5 - AssessTaskId int `json:"assessTaskId"` //StaffAssess 的id 5 + AssessTaskId int `json:"assessTaskId"` //assessTaskId 的id
6 TargetUserId int `json:"targetUserId"` //被评估的人id 6 TargetUserId int `json:"targetUserId"` //被评估的人id
7 CompanyId int `json:"companyId"` //公司id 7 CompanyId int `json:"companyId"` //公司id
8 8
1 -package query  
2 -  
3 -type ListSupperAssessQuery struct {  
4 - PageNumber int `json:"pageNumber"`  
5 - PageSize int `json:"pageSize"`  
6 - UserName string `json:"userName"` //查询条件 员工的名称  
7 - CompanyId int `json:"companyId"` //  
8 - ExecutorId int `json:"executorId"` //评估的执行人  
9 - AssessTaskkId int `json:"assessTaskId"` //评估任务id  
10 -}  
@@ -5,6 +5,6 @@ type ListInviteUserAssessQuery struct { @@ -5,6 +5,6 @@ type ListInviteUserAssessQuery struct {
5 PageSize int `json:"pageSize"` 5 PageSize int `json:"pageSize"`
6 UserName string `json:"userName"` //查询条件 员工的名称 6 UserName string `json:"userName"` //查询条件 员工的名称
7 CompanyId int `json:"companyId"` // 7 CompanyId int `json:"companyId"` //
8 - ExecutorId int `json:"executorId"` //评估的执行人  
9 - AssessTaskkId int `json:"assessTaskId"` //评估任务id 8 + ExecutorId int `json:"executorId"` //评估的执行人,必填
  9 + AssessTaskkId int `json:"assessTaskId"` //评估任务id 必填
10 } 10 }
  1 +package query
  2 +
  3 +//获取员工 被评估的列表
  4 +type ListTargetUserAssessQuery struct {
  5 + AssessTaskId int `json:"assessTaskId"`
  6 + TargetUserId int `json:"targetUserId"`
  7 + CompanyId int `json:"companyId"`
  8 + Types []string `json:"tyspes"`
  9 +}
@@ -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 +}
@@ -20,4 +20,5 @@ type PositionRepository interface { @@ -20,4 +20,5 @@ type PositionRepository interface {
20 Update(position *Position) (*Position, error) 20 Update(position *Position) (*Position, error)
21 Remove(ids []int64) error 21 Remove(ids []int64) error
22 FindOne(queryOption map[string]interface{}) (*Position, error) 22 FindOne(queryOption map[string]interface{}) (*Position, error)
  23 + Find(queryOptions map[string]interface{}) (int, []*Position, error)
23 } 24 }
@@ -12,3 +12,8 @@ type StaffDepartment struct { @@ -12,3 +12,8 @@ type StaffDepartment struct {
12 DepartmentId int `json:"departmentId"` //部门id 12 DepartmentId int `json:"departmentId"` //部门id
13 DepartmentName string `json:"departmentName"` //部门名称 13 DepartmentName string `json:"departmentName"` //部门名称
14 } 14 }
  15 +
  16 +type StaffPosition struct {
  17 + PositionId int `json:"positionId"`
  18 + PositionName string `json:"positionName"`
  19 +}
  1 +package dao
  2 +
  3 +import (
  4 + "strconv"
  5 +
  6 + "github.com/go-pg/pg/v10"
  7 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  8 +)
  9 +
  10 +type StaffAssessDao struct {
  11 + transactionContext *pgTransaction.TransactionContext
  12 +}
  13 +
  14 +func NewStaffAssessDao(options map[string]interface{}) *StaffAssessDao {
  15 + var transactionContext *pgTransaction.TransactionContext
  16 + if value, ok := options["transactionContext"]; ok {
  17 + transactionContext = value.(*pgTransaction.TransactionContext)
  18 + }
  19 + return &StaffAssessDao{
  20 + transactionContext: transactionContext,
  21 + }
  22 +}
  23 +
  24 +type CountData struct {
  25 + TargetUserId int
  26 + InviteTotal int
  27 + InviteCompleted int
  28 +}
  29 +
  30 +// 获取员工邀请的人完成360评估的数量
  31 +func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTaskId int) ([]CountData, error) {
  32 + sqlStr := `SELECT staff_assess.target_user->>'userId' as target_user_id,
  33 + count(staff_assess."id") AS invite_total,
  34 + sum(
  35 + case WHEN staff_assess.status='completed' THEN 1
  36 + ELSE 0 END
  37 + ) as invite_completed
  38 + FROM staff_assess
  39 + WHERE staff_assess.target_user->>'userId' IN(?)
  40 + AND staff_assess.types IN ('invite_same_super','invite_diff_super')
  41 + AND staff_assess.staff_assess_task_id = ?
  42 + GROUP BY userId`
  43 +
  44 + userIdList := []string{}
  45 + for _, v := range userIds {
  46 + uid := strconv.Itoa(v)
  47 + userIdList = append(userIdList, uid)
  48 + }
  49 + condition := []interface{}{
  50 + pg.In(userIdList), assessTaskId,
  51 + }
  52 + tx := d.transactionContext.PgTx
  53 + result := []CountData{}
  54 + _, err := tx.Query(&result, sqlStr, condition...)
  55 + return result, err
  56 +}
1 package repository 1 package repository
2 2
3 import ( 3 import (
  4 + "time"
  5 +
4 "github.com/go-pg/pg/v10" 6 "github.com/go-pg/pg/v10"
5 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" 9 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
8 - "time"  
9 ) 10 )
10 11
11 type PositionRepository struct { 12 type PositionRepository struct {
@@ -66,6 +67,37 @@ func (repository *PositionRepository) FindOne(queryOption map[string]interface{} @@ -66,6 +67,37 @@ func (repository *PositionRepository) FindOne(queryOption map[string]interface{}
66 return repository.transferToDomain(position), nil 67 return repository.transferToDomain(position), nil
67 } 68 }
68 69
  70 +func (repo *PositionRepository) Find(queryOptions map[string]interface{}) (int, []*domain.Position, error) {
  71 + tx := repo.transactionContext.PgTx
  72 + positionModel := []models.Position{}
  73 + query := tx.Model(&positionModel)
  74 + if v, ok := queryOptions["id"]; ok {
  75 + query.Where("id=?", v)
  76 + }
  77 + if v, ok := queryOptions["ids"]; ok {
  78 + query.Where("id in(?)", pg.In(v))
  79 + }
  80 + if v, ok := queryOptions["companyId"]; ok {
  81 + query.Where("company_id=?", v)
  82 + }
  83 + if v, ok := queryOptions["offset"]; ok {
  84 + query.Offset(v.(int))
  85 + }
  86 + if v, ok := queryOptions["limit"]; ok {
  87 + query.Limit(v.(int))
  88 + }
  89 + cnt, err := query.SelectAndCount()
  90 + if err != nil {
  91 + return 0, nil, err
  92 + }
  93 + var resultList []*domain.Position
  94 + for i := range positionModel {
  95 + result := repo.transferToDomain(&positionModel[i])
  96 + resultList = append(resultList, result)
  97 + }
  98 + return cnt, resultList, nil
  99 +}
  100 +
69 func (repository *PositionRepository) transferToDomain(model *models.Position) *domain.Position { 101 func (repository *PositionRepository) transferToDomain(model *models.Position) *domain.Position {
70 return &domain.Position{ 102 return &domain.Position{
71 Id: model.Id, 103 Id: model.Id,
@@ -130,6 +130,10 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in @@ -130,6 +130,10 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
130 if v, ok := queryOptions["targetUserId"].(int); ok && v > 0 { 130 if v, ok := queryOptions["targetUserId"].(int); ok && v > 0 {
131 query.Where(`target_user->>'userId'='?'`, v) 131 query.Where(`target_user->>'userId'='?'`, v)
132 } 132 }
  133 +
  134 + if v, ok := queryOptions["targetUserName"].(int); ok && v > 0 {
  135 + query.Where(`target_user->>'userName' like ?`, fmt.Sprintf("%%%v%%", v))
  136 + }
133 if v, ok := queryOptions["executorId"].(int); ok && v > 0 { 137 if v, ok := queryOptions["executorId"].(int); ok && v > 0 {
134 query.Where(`executor->>'userId'='?'`, v) 138 query.Where(`executor->>'userId'='?'`, v)
135 } 139 }
@@ -149,7 +149,7 @@ func (c *StaffAssessController) SelectAssessInviteUser() { @@ -149,7 +149,7 @@ func (c *StaffAssessController) SelectAssessInviteUser() {
149 } 149 }
150 150
151 // 获取我要执行360评估,用户列表和评估填写的值 151 // 获取我要执行360评估,用户列表和评估填写的值
152 -func (c *StaffAssessController) ListInviteUserAssess() { 152 +func (c *StaffAssessController) ListMeInviteUserAssess() {
153 srv := service.NewStaffAssessServeice() 153 srv := service.NewStaffAssessServeice()
154 paramReq := &query.ListInviteUserAssessQuery{} 154 paramReq := &query.ListInviteUserAssessQuery{}
155 err := c.BindJSON(paramReq) 155 err := c.BindJSON(paramReq)
@@ -161,12 +161,12 @@ func (c *StaffAssessController) ListInviteUserAssess() { @@ -161,12 +161,12 @@ func (c *StaffAssessController) ListInviteUserAssess() {
161 //TODO 获取当前用户信息 161 //TODO 获取当前用户信息
162 paramReq.CompanyId = 1 162 paramReq.CompanyId = 1
163 paramReq.ExecutorId = 1 163 paramReq.ExecutorId = 1
164 - data, err := srv.ListInviteUserAssess(paramReq) 164 + data, err := srv.ListExecutorInviteAssess(paramReq)
165 c.Response(data, err) 165 c.Response(data, err)
166 } 166 }
167 167
168 -// 获取上级评估成员列表  
169 -func (c *StaffAssessController) ListSupperAssess() { 168 +// 获取我要执行的上级评估成员列表
  169 +func (c *StaffAssessController) ListMeSupperAssess() {
170 srv := service.NewStaffAssessServeice() 170 srv := service.NewStaffAssessServeice()
171 paramReq := &query.ListSupperAssessQuery{} 171 paramReq := &query.ListSupperAssessQuery{}
172 err := c.BindJSON(paramReq) 172 err := c.BindJSON(paramReq)
@@ -178,7 +178,7 @@ func (c *StaffAssessController) ListSupperAssess() { @@ -178,7 +178,7 @@ func (c *StaffAssessController) ListSupperAssess() {
178 //TODO 获取当前用户信息 178 //TODO 获取当前用户信息
179 paramReq.CompanyId = 1 179 paramReq.CompanyId = 1
180 paramReq.ExecutorId = 1 180 paramReq.ExecutorId = 1
181 - data, err := srv.ListSupperAssess(paramReq) 181 + data, err := srv.ListExecutorSupperAssess(paramReq)
182 c.Response(data, err) 182 c.Response(data, err)
183 } 183 }
184 184
@@ -211,3 +211,17 @@ func (c *StaffAssessController) GetAssessInfo() { @@ -211,3 +211,17 @@ func (c *StaffAssessController) GetAssessInfo() {
211 data, err := srv.GetAssessInfo(paramReq) 211 data, err := srv.GetAssessInfo(paramReq)
212 c.Response(data, err) 212 c.Response(data, err)
213 } 213 }
  214 +
  215 +// 保存评估内容详情
  216 +func (c *StaffAssessController) SaveAssessInfo() {
  217 + srv := service.NewStaffAssessServeice()
  218 + paramReq := &command.SaveAssessInfoCommand{}
  219 + err := c.BindJSON(paramReq)
  220 + if err != nil {
  221 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  222 + c.Response(nil, e)
  223 + return
  224 + }
  225 + data, err := srv.SaveAssessInfo(paramReq)
  226 + c.Response(data, err)
  227 +}
@@ -15,13 +15,17 @@ func init() { @@ -15,13 +15,17 @@ func init() {
15 // /v1/staff-assess/self/me/list 15 // /v1/staff-assess/self/me/list
16 assessNS := web.NewNamespace("/v1/staff-assess", 16 assessNS := web.NewNamespace("/v1/staff-assess",
17 // web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), 17 // web.NSBefore(filters.AllowCors(), middlewares.CheckToken()),
18 - web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表  
19 - web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfMeInfo), //获取我的自评反馈详情  
20 - web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessInviteUser), //获取邀请的员工  
21 - web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessInviteUser), //保存我邀请的员工  
22 - web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工  
23 - web.NSCtrlPost("/self/info", (*controllers.StaffAssessController).GetAssessSelfInfo), //获取我的自评反馈详情  
24 - web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //获取我的自评反馈详情 18 + web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表
  19 + web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfMeInfo), //获取我的自评反馈详情
  20 + web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessInviteUser), //获取邀请的员工
  21 + web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessInviteUser), //保存我邀请的员工
  22 + web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工
  23 + web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessController).ListMeInviteUserAssess), //我要执行的360评估的用户列表
  24 + web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessController).ListMeSupperAssess), //我要执行的360评估的用户列表
  25 + web.NSCtrlPost("/self/info", (*controllers.StaffAssessController).GetAssessSelfInfo), //获取员工的自评反馈详情
  26 + web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //获取员工评估的详情
  27 + web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //保存员工评估的详情
  28 +
25 ) 29 )
26 web.AddNamespace(assessTaskNS) 30 web.AddNamespace(assessTaskNS)
27 web.AddNamespace(assessNS) 31 web.AddNamespace(assessNS)