Merge branch 'dev-zhengzhou' into test
正在显示
4 个修改的文件
包含
195 行增加
和
13 行删除
@@ -13,7 +13,7 @@ type MemberSummaryListCommand struct { | @@ -13,7 +13,7 @@ type MemberSummaryListCommand struct { | ||
13 | // MemberPerformanceIndicatorCommand 成员绩效导出-指标 | 13 | // MemberPerformanceIndicatorCommand 成员绩效导出-指标 |
14 | type MemberPerformanceIndicatorCommand struct { | 14 | type MemberPerformanceIndicatorCommand struct { |
15 | CycleId int `cname:"周期ID" json:"cycleId,string"` | 15 | CycleId int `cname:"周期ID" json:"cycleId,string"` |
16 | - UserName string `cname:"用户名称" json:"userName"` | 16 | + UserName string `cname:"搜索用户名称" json:"userName"` |
17 | UserIds []string `cname:"用户ID" json:"userIds"` | 17 | UserIds []string `cname:"用户ID" json:"userIds"` |
18 | CompanyId int `cname:"公司ID" json:"companyId"` | 18 | CompanyId int `cname:"公司ID" json:"companyId"` |
19 | OperatorId int `cname:"操作人ID" json:"operatorId"` | 19 | OperatorId int `cname:"操作人ID" json:"operatorId"` |
@@ -231,11 +231,156 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP | @@ -231,11 +231,156 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP | ||
231 | transactionContext.RollbackTransaction() | 231 | transactionContext.RollbackTransaction() |
232 | }() | 232 | }() |
233 | 233 | ||
234 | + var projectItemUsed = map[int][]*domain.EvaluationItemUsed{} // 项目ID-> 评估内容项 | ||
235 | + var userProjectMap = map[int][]*dao.IndicatorUserProject{} // 用户ID-> 用户评估的项目(用户在周期内可能有多个项目模板,激活状态只能是1个) | ||
236 | + var projectIds = make([]int, 0) | ||
237 | + | ||
238 | + if len(in.UserIds) > 0 { | ||
239 | + staffAssessRepository := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
240 | + _, assessList, err := staffAssessRepository.Find(map[string]interface{}{ | ||
241 | + "cycleId": in.CycleId, | ||
242 | + "targetUserIds": in.UserIds, | ||
243 | + "types": domain.AssessSelf, | ||
244 | + }) | ||
245 | + if err != nil { | ||
246 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
247 | + } | ||
248 | + | ||
249 | + projectIdsMap := map[int]int{} | ||
250 | + for i := range assessList { | ||
251 | + it := assessList[i] | ||
252 | + projectIdsMap[it.EvaluationProjectId] = it.EvaluationProjectId | ||
253 | + | ||
254 | + // 用户存在多个项目模板 | ||
255 | + array, ok := userProjectMap[it.TargetUser.UserId] | ||
256 | + if !ok { | ||
257 | + array = make([]*dao.IndicatorUserProject, 0) | ||
258 | + } | ||
259 | + userProjectMap[it.TargetUser.UserId] = append(array, &dao.IndicatorUserProject{ | ||
260 | + AssessId: it.Id, | ||
261 | + EvaluationProjectId: it.EvaluationProjectId, | ||
262 | + TargetUserId: it.TargetUser.UserId, | ||
263 | + TargetUserName: it.TargetUser.UserName, | ||
264 | + }) | ||
265 | + } | ||
266 | + for k, _ := range projectIdsMap { | ||
267 | + projectIds = append(projectIds, k) | ||
268 | + } | ||
269 | + | ||
270 | + } else { | ||
234 | hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId) | 271 | hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId) |
235 | if err != nil { | 272 | if err != nil { |
236 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 273 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
237 | } | 274 | } |
238 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext}) | 275 | assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext}) |
276 | + list, err := assessDao.MemberAllProjectId( | ||
277 | + in.CompanyId, | ||
278 | + in.UserName, | ||
279 | + in.OperatorId, | ||
280 | + in.CycleId, | ||
281 | + hrbp) | ||
282 | + if err != nil { | ||
283 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
284 | + } | ||
285 | + | ||
286 | + projectIdsMap := map[int]int{} | ||
287 | + for i := range list { | ||
288 | + it := list[i] | ||
289 | + projectIdsMap[it.EvaluationProjectId] = it.EvaluationProjectId | ||
290 | + | ||
291 | + // 用户存在多个项目模板 | ||
292 | + array, ok := userProjectMap[it.TargetUserId] | ||
293 | + if !ok { | ||
294 | + array = make([]*dao.IndicatorUserProject, 0) | ||
295 | + } | ||
296 | + userProjectMap[it.TargetUserId] = append(array, &it) | ||
297 | + } | ||
298 | + | ||
299 | + for k, _ := range projectIdsMap { | ||
300 | + projectIds = append(projectIds, k) | ||
301 | + } | ||
302 | + } | ||
303 | + | ||
304 | + // 项目ID->查询所有评估项 | ||
305 | + if len(projectIds) > 0 { | ||
306 | + itemUsedRepository := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
307 | + _, itemList, err := itemUsedRepository.Find(map[string]interface{}{"evaluationProjectIds": projectIds, "nodeType": domain.LinkNodeSelfAssessment}) | ||
308 | + if err != nil { | ||
309 | + return nil, err | ||
310 | + } | ||
311 | + for i := range itemList { | ||
312 | + it := itemList[i] | ||
313 | + array, ok := projectItemUsed[it.EvaluationProjectId] | ||
314 | + if !ok { | ||
315 | + array = make([]*domain.EvaluationItemUsed, 0) | ||
316 | + } | ||
317 | + projectItemUsed[it.EvaluationProjectId] = append(array, it) | ||
318 | + } | ||
319 | + } | ||
320 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
321 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
322 | + } | ||
323 | + | ||
324 | + adapterList := make([]*adapter.PerformanceIndicatorAdapter, 0) | ||
325 | + categoryMap := map[string]int{} // 内容分类 | ||
326 | + for i := range in.UserIds { | ||
327 | + userId := in.UserIds[i] | ||
328 | + userIdInt, err := strconv.Atoi(userId) | ||
329 | + if err != nil { | ||
330 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
331 | + } | ||
332 | + | ||
333 | + iupArray, ok := userProjectMap[userIdInt] | ||
334 | + if !ok { | ||
335 | + continue | ||
336 | + } | ||
337 | + var pia = &adapter.PerformanceIndicatorAdapter{ | ||
338 | + TargetUserId: userId, | ||
339 | + TargetUserName: iupArray[0].TargetUserName, | ||
340 | + PIContents: make([]adapter.PIContent, 0), | ||
341 | + } | ||
342 | + adapterList = append(adapterList, pia) | ||
343 | + for _, assess := range iupArray { | ||
344 | + items, ok := projectItemUsed[assess.EvaluationProjectId] | ||
345 | + if !ok { | ||
346 | + continue | ||
347 | + } | ||
348 | + for _, item := range items { | ||
349 | + if len(item.Category) == 0 { | ||
350 | + continue | ||
351 | + } | ||
352 | + onlyKey1 := userId + item.Category | ||
353 | + if _, ok := categoryMap[onlyKey1]; !ok { | ||
354 | + categoryMap[onlyKey1] = 0 | ||
355 | + // 不存在分类时,创建分类内容 | ||
356 | + pia.PIContents = append(pia.PIContents, adapter.PIContent{ | ||
357 | + Category: item.Category, | ||
358 | + Names: make([]string, 0), | ||
359 | + }) | ||
360 | + } | ||
361 | + | ||
362 | + // 内容名称有值合并到数组 | ||
363 | + if len(item.Name) > 0 { | ||
364 | + for index := range pia.PIContents { | ||
365 | + piContent := &pia.PIContents[index] | ||
366 | + if piContent.Category == item.Category { | ||
367 | + piContent.Names = append(piContent.Names, item.Name) | ||
368 | + break | ||
369 | + } | ||
370 | + } | ||
371 | + } | ||
372 | + } | ||
373 | + } | ||
374 | + } | ||
375 | + | ||
376 | + /* | ||
377 | + // 旧版(如果未填写自评会出现数据评估项丢失的BUG) | ||
378 | + hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId) | ||
379 | + if err != nil { | ||
380 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
381 | + } | ||
382 | + | ||
383 | + assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext}) | ||
239 | list, err := assessDao.MemberPerformanceIndicator( | 384 | list, err := assessDao.MemberPerformanceIndicator( |
240 | in.UserName, | 385 | in.UserName, |
241 | in.CompanyId, | 386 | in.CompanyId, |
@@ -326,10 +471,10 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP | @@ -326,10 +471,10 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP | ||
326 | } | 471 | } |
327 | 472 | ||
328 | } | 473 | } |
329 | - | ||
330 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
331 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
332 | - } | 474 | + */ |
475 | + //if err := transactionContext.CommitTransaction(); err != nil { | ||
476 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
477 | + //} | ||
333 | 478 | ||
334 | return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil | 479 | return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil |
335 | } | 480 | } |
@@ -374,8 +519,7 @@ func (srv StaffAssessServeice) ExportPerformanceIndicator(in *query.ExportPerfor | @@ -374,8 +519,7 @@ func (srv StaffAssessServeice) ExportPerformanceIndicator(in *query.ExportPerfor | ||
374 | for i := range list { | 519 | for i := range list { |
375 | it := list[i] | 520 | it := list[i] |
376 | if v, ok := selectedMap[it.TargetUserId]; ok { | 521 | if v, ok := selectedMap[it.TargetUserId]; ok { |
377 | - v.UserName = it.TargetUserName | ||
378 | - | 522 | + //v.UserName = it.TargetUserName |
379 | if v.Category == it.ContentCategory && v.Name == it.ContentName { | 523 | if v.Category == it.ContentCategory && v.Name == it.ContentName { |
380 | conditionList = append(conditionList, it) | 524 | conditionList = append(conditionList, it) |
381 | conditionMap[it.TargetUserId+it.BeginDay] = it | 525 | conditionMap[it.TargetUserId+it.BeginDay] = it |
@@ -383,7 +383,8 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, | @@ -383,7 +383,8 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, | ||
383 | t_staff_assess_0.target_user_name, | 383 | t_staff_assess_0.target_user_name, |
384 | t_staff_assess_0.begin_day, | 384 | t_staff_assess_0.begin_day, |
385 | t_staff_assess_0.cycle_name, | 385 | t_staff_assess_0.cycle_name, |
386 | - t_staff_assess_0.cycle_id | 386 | + t_staff_assess_0.cycle_id, |
387 | + t_staff_assess_0.evaluation_project_id | ||
387 | from t_staff_assess_0 | 388 | from t_staff_assess_0 |
388 | join t_project_3 on t_staff_assess_0.evaluation_project_id = t_project_3.project_id | 389 | join t_project_3 on t_staff_assess_0.evaluation_project_id = t_project_3.project_id |
389 | ) union (select t_staff_assess_0.assess_id, | 390 | ) union (select t_staff_assess_0.assess_id, |
@@ -391,7 +392,8 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, | @@ -391,7 +392,8 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, | ||
391 | t_staff_assess_0.target_user_name, | 392 | t_staff_assess_0.target_user_name, |
392 | t_staff_assess_0.begin_day, | 393 | t_staff_assess_0.begin_day, |
393 | t_staff_assess_0.cycle_name, | 394 | t_staff_assess_0.cycle_name, |
394 | - t_staff_assess_0.cycle_id | 395 | + t_staff_assess_0.cycle_id, |
396 | + t_staff_assess_0.evaluation_project_id | ||
395 | from t_staff_assess_0 | 397 | from t_staff_assess_0 |
396 | join t_user_1 on t_staff_assess_0.target_user_id=t_user_1.user_id | 398 | join t_user_1 on t_staff_assess_0.target_user_id=t_user_1.user_id |
397 | ) | 399 | ) |
@@ -804,6 +806,38 @@ func (d *StaffAssessDao) MemberPerformanceIndicator(likeUserName string, company | @@ -804,6 +806,38 @@ func (d *StaffAssessDao) MemberPerformanceIndicator(likeUserName string, company | ||
804 | 806 | ||
805 | } | 807 | } |
806 | 808 | ||
809 | +type IndicatorUserProject struct { | ||
810 | + AssessId int `json:"assessId"` // ID | ||
811 | + TargetUserId int `json:"targetUserId"` // 目标用户ID | ||
812 | + TargetUserName string `json:"targetUserName"` // 目标用户名称 | ||
813 | + EvaluationProjectId int `json:"evaluationProjectId"` // 项目ID | ||
814 | + | ||
815 | +} | ||
816 | + | ||
817 | +func (d *StaffAssessDao) MemberAllProjectId(companyId int, likeUserName string, operatorId int, cycleId int, hrbp int) ([]IndicatorUserProject, error) { | ||
818 | + sqlStr := ` select | ||
819 | + t_staff_assess_1.evaluation_project_id, | ||
820 | + t_staff_assess_1.target_user_id, | ||
821 | + t_staff_assess_1.target_user_name, | ||
822 | + t_staff_assess_1.assess_id | ||
823 | + from t_staff_assess_1 | ||
824 | + where 1=1 | ||
825 | + ` | ||
826 | + var condition []interface{} | ||
827 | + if len(likeUserName) > 0 { | ||
828 | + sqlStr += ` and t_staff_assess_1.target_user_name like ? ` | ||
829 | + condition = append(condition, "%"+likeUserName+"%") | ||
830 | + } | ||
831 | + // 获取前置sql语句 | ||
832 | + sqlStr0 := d.useTStaffAssess(companyId, cycleId, operatorId, "", hrbp, 0, 5000, string(domain.AssessSelf)) | ||
833 | + sqlStr = sqlStr0 + sqlStr | ||
834 | + tx := d.transactionContext.PgTx | ||
835 | + var result []IndicatorUserProject | ||
836 | + _, err := tx.Query(&result, sqlStr, condition...) | ||
837 | + return result, err | ||
838 | + | ||
839 | +} | ||
840 | + | ||
807 | type ExportPerformanceIndicator struct { | 841 | type ExportPerformanceIndicator struct { |
808 | AssessId int `json:"assessId"` // ID | 842 | AssessId int `json:"assessId"` // ID |
809 | TargetUserId string `json:"targetUserId"` // 被评估人的id | 843 | TargetUserId string `json:"targetUserId"` // 被评估人的id |
@@ -128,9 +128,15 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in | @@ -128,9 +128,15 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in | ||
128 | if v, ok := queryOptions["offset"].(int); ok { | 128 | if v, ok := queryOptions["offset"].(int); ok { |
129 | query.Offset(v) | 129 | query.Offset(v) |
130 | } | 130 | } |
131 | + if v, ok := queryOptions["id"]; ok { | ||
132 | + query.Where("staff_assess.id=?", v) | ||
133 | + } | ||
131 | if v, ok := queryOptions["targetUserId"]; ok { | 134 | if v, ok := queryOptions["targetUserId"]; ok { |
132 | query.Where(`staff_assess.target_user->>'userId'='?'`, v) | 135 | query.Where(`staff_assess.target_user->>'userId'='?'`, v) |
133 | } | 136 | } |
137 | + if v, ok := queryOptions["targetUserIds"]; ok { | ||
138 | + query.Where(`staff_assess.target_user->>'userId' in(?)`, pg.In(v)) | ||
139 | + } | ||
134 | 140 | ||
135 | if v, ok := queryOptions["targetUserName"].(string); ok { | 141 | if v, ok := queryOptions["targetUserName"].(string); ok { |
136 | query.Where(`staff_assess.target_user->>'userName' like ?`, fmt.Sprintf("%%%v%%", v)) | 142 | query.Where(`staff_assess.target_user->>'userName' like ?`, fmt.Sprintf("%%%v%%", v)) |
@@ -138,16 +144,14 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in | @@ -138,16 +144,14 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in | ||
138 | if v, ok := queryOptions["executorId"]; ok { | 144 | if v, ok := queryOptions["executorId"]; ok { |
139 | query.Where(`staff_assess.executor->>'userId'='?'`, v) | 145 | query.Where(`staff_assess.executor->>'userId'='?'`, v) |
140 | } | 146 | } |
141 | - | ||
142 | if v, ok := queryOptions["cycleId"]; ok { | 147 | if v, ok := queryOptions["cycleId"]; ok { |
143 | query.Where(`staff_assess.cycle_id=?`, v) | 148 | query.Where(`staff_assess.cycle_id=?`, v) |
144 | } | 149 | } |
145 | if v, ok := queryOptions["staffAssessTaskId"]; ok { | 150 | if v, ok := queryOptions["staffAssessTaskId"]; ok { |
146 | query.Where(`staff_assess.staff_assess_task_id=?`, v) | 151 | query.Where(`staff_assess.staff_assess_task_id=?`, v) |
147 | } | 152 | } |
148 | - | ||
149 | - if v, ok := queryOptions["id"]; ok { | ||
150 | - query.Where("staff_assess.id=?", v) | 153 | + if v, ok := queryOptions["types"]; ok { |
154 | + query.Where(`staff_assess.types=?`, v) | ||
151 | } | 155 | } |
152 | if v, ok := queryOptions["typesList"].([]string); ok { | 156 | if v, ok := queryOptions["typesList"].([]string); ok { |
153 | query.Where("staff_assess.types in(?)", pg.In(v)) | 157 | query.Where("staff_assess.types in(?)", pg.In(v)) |
-
请 注册 或 登录 后发表评论