正在显示
6 个修改的文件
包含
280 行增加
和
15 行删除
@@ -8,3 +8,15 @@ type MemberSummaryAdapter struct { | @@ -8,3 +8,15 @@ type MemberSummaryAdapter struct { | ||
8 | DepartmentNames []string `json:"departmentNames"` // 被评估人部门列表 | 8 | DepartmentNames []string `json:"departmentNames"` // 被评估人部门列表 |
9 | PositionNames []string `json:"positionNames"` // 被评估人职位列表 | 9 | PositionNames []string `json:"positionNames"` // 被评估人职位列表 |
10 | } | 10 | } |
11 | + | ||
12 | +// PerformanceIndicatorAdapter 综合管理-成员列表-绩效导出指标 | ||
13 | +type PerformanceIndicatorAdapter struct { | ||
14 | + TargetUserId string `json:"targetUserId"` // 被评估人的id | ||
15 | + TargetUserName string `json:"targetUserName"` // 被评估人的名称 | ||
16 | + PIContents []PIContent `json:"piContents"` // 被评估人的内容 | ||
17 | +} | ||
18 | + | ||
19 | +type PIContent struct { | ||
20 | + Category string `json:"category"` // 评估内容分类 | ||
21 | + Names []string `json:"names"` // 评估内容名称 | ||
22 | +} |
@@ -9,3 +9,12 @@ type MemberSummaryListCommand struct { | @@ -9,3 +9,12 @@ type MemberSummaryListCommand struct { | ||
9 | CompanyId int `cname:"公司ID" json:"companyId"` | 9 | CompanyId int `cname:"公司ID" json:"companyId"` |
10 | OperatorId int `cname:"操作人ID" json:"operatorId"` | 10 | OperatorId int `cname:"操作人ID" json:"operatorId"` |
11 | } | 11 | } |
12 | + | ||
13 | +// MemberPerformanceIndicatorCommand 成员绩效导出-指标 | ||
14 | +type MemberPerformanceIndicatorCommand struct { | ||
15 | + CycleId int `cname:"周期ID" json:"cycleId,string"` | ||
16 | + UserName string `cname:"用户名称" json:"userName"` | ||
17 | + UserIds []string `cname:"用户ID" json:"userIds"` | ||
18 | + CompanyId int `cname:"公司ID" json:"companyId"` | ||
19 | + OperatorId int `cname:"操作人ID" json:"operatorId"` | ||
20 | +} |
@@ -217,3 +217,112 @@ func (srv StaffAssessServeice) QueryMemberSummary(in *query.MemberSummaryListCom | @@ -217,3 +217,112 @@ func (srv StaffAssessServeice) QueryMemberSummary(in *query.MemberSummaryListCom | ||
217 | 217 | ||
218 | return tool_funs.SimpleWrapGridMap(int64(total), adapters), nil | 218 | return tool_funs.SimpleWrapGridMap(int64(total), adapters), nil |
219 | } | 219 | } |
220 | + | ||
221 | +func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberPerformanceIndicatorCommand) (map[string]interface{}, error) { | ||
222 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
223 | + if err != nil { | ||
224 | + return nil, err | ||
225 | + } | ||
226 | + defer func() { | ||
227 | + transactionContext.RollbackTransaction() | ||
228 | + }() | ||
229 | + | ||
230 | + hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId) | ||
231 | + if err != nil { | ||
232 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
233 | + } | ||
234 | + assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext}) | ||
235 | + list, err := assessDao.MemberPerformanceIndicator( | ||
236 | + in.UserName, | ||
237 | + in.CompanyId, | ||
238 | + in.OperatorId, | ||
239 | + in.CycleId, | ||
240 | + hrbp, | ||
241 | + string(domain.AssessSelf), | ||
242 | + in.UserIds) | ||
243 | + if err != nil { | ||
244 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
245 | + } | ||
246 | + | ||
247 | + // (全部周期数据)筛选出第一个周期的数据,减少后续数据遍历 | ||
248 | + dupleMap := map[string]string{} | ||
249 | + dupleList := make([]dao.PerformanceIndicatorAssess, 0) | ||
250 | + for i := range list { | ||
251 | + it := list[i] | ||
252 | + if v, ok := dupleMap[it.TargetUserId]; ok { | ||
253 | + if v == it.BeginDay { | ||
254 | + dupleList = append(dupleList, it) | ||
255 | + } | ||
256 | + } else { | ||
257 | + dupleMap[it.TargetUserId] = it.BeginDay | ||
258 | + dupleList = append(dupleList, it) | ||
259 | + } | ||
260 | + } | ||
261 | + | ||
262 | + piaMap := map[string]*adapter.PerformanceIndicatorAdapter{} | ||
263 | + categoryMap := map[string]int{} // 内容分类 | ||
264 | + //categoryNameMap := map[string]int{} // 内容分类下的名称 | ||
265 | + | ||
266 | + adapterList := make([]*adapter.PerformanceIndicatorAdapter, 0) | ||
267 | + for i := range dupleList { | ||
268 | + it := dupleList[i] | ||
269 | + | ||
270 | + var pia *adapter.PerformanceIndicatorAdapter | ||
271 | + if v, ok := piaMap[it.TargetUserId]; ok { | ||
272 | + pia = v | ||
273 | + } else { | ||
274 | + pia = &adapter.PerformanceIndicatorAdapter{ | ||
275 | + TargetUserId: it.TargetUserId, | ||
276 | + TargetUserName: it.TargetUserName, | ||
277 | + PIContents: make([]adapter.PIContent, 0), | ||
278 | + } | ||
279 | + piaMap[it.TargetUserId] = pia | ||
280 | + adapterList = append(adapterList, pia) | ||
281 | + } | ||
282 | + | ||
283 | + // 分类名称有值才能合并分类数组 | ||
284 | + if len(it.ContentCategory) > 0 { | ||
285 | + onlyKey1 := it.TargetUserId + it.ContentCategory | ||
286 | + if _, ok := categoryMap[onlyKey1]; !ok { | ||
287 | + categoryMap[onlyKey1] = 0 | ||
288 | + | ||
289 | + // 不存在分类时,创建分类内容 | ||
290 | + pia.PIContents = append(pia.PIContents, adapter.PIContent{ | ||
291 | + Category: it.ContentCategory, | ||
292 | + Names: make([]string, 0), | ||
293 | + }) | ||
294 | + } | ||
295 | + | ||
296 | + // 内容名称有值合并到数组 | ||
297 | + if len(it.ContentName) > 0 { | ||
298 | + // 周期筛选过的,不再需要唯一值验证判断,直接添加到对应的分类下 | ||
299 | + for index := range pia.PIContents { | ||
300 | + piContent := &pia.PIContents[index] | ||
301 | + if piContent.Category == it.ContentCategory { | ||
302 | + piContent.Names = append(piContent.Names, it.ContentName) | ||
303 | + break | ||
304 | + } | ||
305 | + } | ||
306 | + //onlyKey2 := it.TargetUserId + it.ContentCategory + it.ContentName | ||
307 | + //if _, ok := categoryNameMap[onlyKey2]; !ok { | ||
308 | + // categoryNameMap[onlyKey2] = 0 | ||
309 | + // | ||
310 | + // for index := range pia.PIContents { | ||
311 | + // piContent := pia.PIContents[index] | ||
312 | + // if piContent.Category == it.ContentCategory { | ||
313 | + // piContent.Names = append(piContent.Names, it.ContentName) | ||
314 | + // break | ||
315 | + // } | ||
316 | + // } | ||
317 | + //} | ||
318 | + } | ||
319 | + } | ||
320 | + | ||
321 | + } | ||
322 | + | ||
323 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
324 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
325 | + } | ||
326 | + | ||
327 | + return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil | ||
328 | +} |
@@ -652,6 +652,132 @@ func (d *StaffAssessDao) MemberSummaryList(likeUserName string, companyId int, o | @@ -652,6 +652,132 @@ func (d *StaffAssessDao) MemberSummaryList(likeUserName string, companyId int, o | ||
652 | return total, result, err | 652 | return total, result, err |
653 | } | 653 | } |
654 | 654 | ||
655 | +type PerformanceIndicatorAssess struct { | ||
656 | + AssessId int `json:"assessId"` // ID | ||
657 | + TargetUserId string `json:"targetUserId"` // 被评估人的id | ||
658 | + TargetUserName string `json:"targetUserName"` // 被评估人的名称 | ||
659 | + BeginDay string `json:"beginDay"` // 评估的开始日期 | ||
660 | + CycleId int `json:"cycleId"` // 周期ID | ||
661 | + ContentId int `json:"contentId"` // 评估内容ID | ||
662 | + ContentCategory string `json:"contentCategory"` // 评估内容分类 | ||
663 | + ContentName string `json:"contentName"` // 评估内容名称 | ||
664 | + SortBy int `json:"sort_by"` // 评估内容排序 | ||
665 | +} | ||
666 | + | ||
667 | +func (d *StaffAssessDao) MemberPerformanceIndicator(likeUserName string, companyId int, operatorId int, cycleId int, hrbp int, assessType string, userIds []string) ([]PerformanceIndicatorAssess, error) { | ||
668 | + sqlString := ` | ||
669 | + set time zone 'PRC'; | ||
670 | + with t_user_department as ( | ||
671 | + select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user" | ||
672 | + where "user".company_id= %d and "user".deleted_at isnull | ||
673 | + ), | ||
674 | + t_department as ( | ||
675 | + select department.id::text as depart_id from department where charge_user_ids @>'[%d]' | ||
676 | + and "department".deleted_at isnull | ||
677 | + ), | ||
678 | + -- 部门主管(所有下级用户ID) | ||
679 | + t_user_1 as ( | ||
680 | + select t_user_department.user_id::text from t_user_department | ||
681 | + join t_department on t_user_department.depart_id = t_department.depart_id | ||
682 | + ), | ||
683 | + -- 如果是HRBP | ||
684 | + t_project_1 as( | ||
685 | + select evaluation_project.id as project_id | ||
686 | + from evaluation_project | ||
687 | + where evaluation_project.cycle_id =%d | ||
688 | + and evaluation_project.hr_bp = %d | ||
689 | + and evaluation_project.deleted_at isnull | ||
690 | + ), | ||
691 | + -- 如果的项目管理员 | ||
692 | + t_project_2 as( | ||
693 | + select evaluation_project.id as project_id | ||
694 | + from evaluation_project | ||
695 | + where evaluation_project.cycle_id =%d | ||
696 | + and evaluation_project.pmp =1 | ||
697 | + and evaluation_project.pmp_ids @>'["%d"]' | ||
698 | + and evaluation_project.deleted_at isnull | ||
699 | + ), | ||
700 | + -- 合并数据 | ||
701 | + t_project_3 as ( | ||
702 | + select t_project_2.project_id from t_project_2 | ||
703 | + union | ||
704 | + select t_project_1.project_id from t_project_1 | ||
705 | + ), | ||
706 | + -- 初步过滤数据 | ||
707 | + t_staff_assess_0 as ( | ||
708 | + select | ||
709 | + staff_assess.id as assess_id, | ||
710 | + staff_assess.cycle_id, | ||
711 | + staff_assess.target_user->>'userId' as target_user_id, | ||
712 | + staff_assess.target_user->>'userName' as target_user_name, | ||
713 | + to_char(staff_assess.begin_time,'YYYY-MM-DD') as begin_day, | ||
714 | + staff_assess.evaluation_project_id | ||
715 | + from staff_assess | ||
716 | + join staff_assess_task on staff_assess.staff_assess_task_id = staff_assess_task.id | ||
717 | + and staff_assess_task.deleted_at isnull | ||
718 | + where | ||
719 | + staff_assess.cycle_id = %d | ||
720 | + and staff_assess.types ='%s' | ||
721 | + ), | ||
722 | + -- 根据查看权限过滤合并数据 | ||
723 | + t_staff_assess_1 as ( | ||
724 | + ( select | ||
725 | + t_staff_assess_0.assess_id, | ||
726 | + t_staff_assess_0.target_user_id, | ||
727 | + t_staff_assess_0.target_user_name, | ||
728 | + t_staff_assess_0.begin_day, | ||
729 | + t_staff_assess_0.cycle_id | ||
730 | + from t_staff_assess_0 | ||
731 | + join t_project_3 on t_staff_assess_0.evaluation_project_id = t_project_3.project_id | ||
732 | + ) union ( | ||
733 | + select | ||
734 | + t_staff_assess_0.assess_id, | ||
735 | + t_staff_assess_0.target_user_id, | ||
736 | + t_staff_assess_0.target_user_name, | ||
737 | + t_staff_assess_0.begin_day, | ||
738 | + t_staff_assess_0.cycle_id | ||
739 | + from t_staff_assess_0 | ||
740 | + join t_user_1 on t_staff_assess_0.target_user_id = t_user_1.user_id | ||
741 | + ) | ||
742 | + ) | ||
743 | + ` | ||
744 | + params := []interface{}{companyId, operatorId, cycleId, hrbp, cycleId, operatorId, cycleId, assessType} | ||
745 | + sqlString = fmt.Sprintf(sqlString, params...) | ||
746 | + | ||
747 | + sqlString += ` select | ||
748 | + t_staff_assess_1.target_user_id, | ||
749 | + t_staff_assess_1.target_user_name, | ||
750 | + t_staff_assess_1.begin_day, | ||
751 | + t_staff_assess_1.cycle_id, | ||
752 | + t_staff_assess_1.assess_id, | ||
753 | + staff_assess_content.id as content_id, | ||
754 | + staff_assess_content.name as content_name, | ||
755 | + staff_assess_content.category as content_category, | ||
756 | + staff_assess_content.sort_by | ||
757 | + from t_staff_assess_1 | ||
758 | + left join staff_assess_content on t_staff_assess_1.assess_id = staff_assess_content.staff_assess_id | ||
759 | + where 1=1 | ||
760 | + -- AND staff_assess_content.id NOTNULL 部分脏数据 | ||
761 | + ` | ||
762 | + condition := make([]interface{}, 0) | ||
763 | + if len(likeUserName) > 0 { | ||
764 | + sqlString += ` and t_staff_assess_1.target_user_name like ? ` | ||
765 | + condition = append(condition, "%"+likeUserName+"%") | ||
766 | + } | ||
767 | + if len(userIds) > 0 { | ||
768 | + sqlString += ` and t_staff_assess_1.target_user_id in (?) ` | ||
769 | + condition = append(condition, pg.In(userIds)) | ||
770 | + } | ||
771 | + sqlString += ` order by convert_to(t_staff_assess_1.target_user_name,'GBK'), staff_assess_content.sort_by` | ||
772 | + | ||
773 | + tx := d.transactionContext.PgTx | ||
774 | + var result = make([]PerformanceIndicatorAssess, 0) | ||
775 | + _, err := tx.Query(&result, sqlString, condition...) | ||
776 | + | ||
777 | + return result, err | ||
778 | + | ||
779 | +} | ||
780 | + | ||
655 | type ExportData1 struct { | 781 | type ExportData1 struct { |
656 | AssessId string | 782 | AssessId string |
657 | ContentId int | 783 | ContentId int |
@@ -389,6 +389,21 @@ func (c *StaffAssessController) QueryMemberSummary() { | @@ -389,6 +389,21 @@ func (c *StaffAssessController) QueryMemberSummary() { | ||
389 | } | 389 | } |
390 | } | 390 | } |
391 | 391 | ||
392 | +// QueryMemberPerformanceIndicator 员工绩效-综合管理-绩效导出指标 | ||
393 | +func (c *StaffAssessController) QueryMemberPerformanceIndicator() { | ||
394 | + srv := service.NewStaffAssessServeice() | ||
395 | + in := &query.MemberPerformanceIndicatorCommand{} | ||
396 | + if err := c.Unmarshal(in); err != nil { | ||
397 | + c.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
398 | + } else { | ||
399 | + if user := middlewares.GetUser(c.Ctx); user != nil { | ||
400 | + in.CompanyId = int(user.CompanyId) | ||
401 | + in.OperatorId = int(user.UserId) | ||
402 | + } | ||
403 | + c.Response(srv.QueryMemberPerformanceIndicator(in)) | ||
404 | + } | ||
405 | +} | ||
406 | + | ||
392 | // 员工绩效-项目管理-矩阵分析 | 407 | // 员工绩效-项目管理-矩阵分析 |
393 | func (c *StaffAssessController) AnalysisData() { | 408 | func (c *StaffAssessController) AnalysisData() { |
394 | srv := service.NewStaffAssessServeice() | 409 | srv := service.NewStaffAssessServeice() |
@@ -22,21 +22,15 @@ func init() { | @@ -22,21 +22,15 @@ func init() { | ||
22 | 22 | ||
23 | assessNS := web.NewNamespace("/v1/staff-assess", | 23 | assessNS := web.NewNamespace("/v1/staff-assess", |
24 | web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()), | 24 | web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()), |
25 | - web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表 | ||
26 | - //web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfMeInfo), //获取我的自评反馈详情 | ||
27 | - // web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessMeInviteUser), //获取邀请的员工 | ||
28 | - web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessMeInviteUser), //保存我邀请的员工 | ||
29 | - web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工 | ||
30 | - //web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessController).ListMeInviteUserAssess), //我要执行的360评估的用户列表 | ||
31 | - //web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessController).ListMeSupperAssess), //我要执行的360评估的用户列表 | ||
32 | - web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情 | ||
33 | - web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情 | ||
34 | - web.NSCtrlPut("/info-cache", (*controllers.StaffAssessController).SaveAssessCache), //通用保存员工评估的详情(缓存) | ||
35 | - web.NSCtrlPost("/summary", (*controllers.StaffAssessController).QuerySummary), //员工绩效-项目管理-总览 | ||
36 | - web.NSCtrlPost("/summary/users", (*controllers.StaffAssessController).QueryMemberSummary), //员工绩效-综合管理-成员列表 | ||
37 | - // web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工360评估的列表 | ||
38 | - //web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessController).ListTargetUserMeSupperAssess), //获取我被上级评估的列表 | ||
39 | - // web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情 | 25 | + web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表 |
26 | + web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessMeInviteUser), //保存我邀请的员工 | ||
27 | + web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工 | ||
28 | + web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情 | ||
29 | + web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情 | ||
30 | + web.NSCtrlPut("/info-cache", (*controllers.StaffAssessController).SaveAssessCache), //通用保存员工评估的详情(缓存) | ||
31 | + web.NSCtrlPost("/summary", (*controllers.StaffAssessController).QuerySummary), //员工绩效-项目管理-总览 | ||
32 | + web.NSCtrlPost("/summary/users", (*controllers.StaffAssessController).QueryMemberSummary), //员工绩效-综合管理-成员列表 | ||
33 | + web.NSCtrlPost("/summary/users-indicator", (*controllers.StaffAssessController).QueryMemberPerformanceIndicator), //员工绩效-综合管理-绩效导出指标 | ||
40 | ) | 34 | ) |
41 | //v2 改版 | 35 | //v2 改版 |
42 | assessTaskV2NS := web.NewNamespace("/v2/staff-assess-task", | 36 | assessTaskV2NS := web.NewNamespace("/v2/staff-assess-task", |
-
请 注册 或 登录 后发表评论