作者 tangxvhui
@@ -434,20 +434,24 @@ type SummaryAssess struct { @@ -434,20 +434,24 @@ type SummaryAssess struct {
434 } 434 }
435 435
436 func (d *StaffAssessDao) SummaryAssess(companyId int, operatorId int, cycleId int, beginDay string, hrbp int) ([]SummaryAssess, error) { 436 func (d *StaffAssessDao) SummaryAssess(companyId int, operatorId int, cycleId int, beginDay string, hrbp int) ([]SummaryAssess, error) {
  437 + //`
  438 + //with t_user_department as (
  439 + // select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"
  440 + // where "user".company_id= %d and "user".deleted_at isnull
  441 + //),
  442 + //t_department as (
  443 + // select department.id::text as depart_id from department where charge_user_ids @>'[%d]'
  444 + // and "department".deleted_at isnull
  445 + //),
  446 + //-- 部门主管(所有下级用户ID)
  447 + //t_user_1 as (
  448 + // select t_user_department.user_id::text from t_user_department
  449 + // join t_department on t_user_department.depart_id = t_department.depart_id
  450 + //),`
437 sqlString := ` 451 sqlString := `
438 set time zone 'PRC'; 452 set time zone 'PRC';
439 - with t_user_department as (  
440 - select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"  
441 - where "user".company_id= %d and "user".deleted_at isnull  
442 - ),  
443 - t_department as (  
444 - select department.id::text as depart_id from department where charge_user_ids @>'[%d]'  
445 - and "department".deleted_at isnull  
446 - ),  
447 - -- 部门主管(所有下级用户ID)  
448 - t_user_1 as (  
449 - select t_user_department.user_id::text from t_user_department  
450 - join t_department on t_user_department.depart_id = t_department.depart_id 453 + with t_user_1 as (
  454 + select "user".id::text as user_id from "user" where "user".parent_id =%d
451 ), 455 ),
452 -- 如果是HRBP 456 -- 如果是HRBP
453 t_project_1 as( 457 t_project_1 as(
@@ -520,7 +524,8 @@ func (d *StaffAssessDao) SummaryAssess(companyId int, operatorId int, cycleId in @@ -520,7 +524,8 @@ func (d *StaffAssessDao) SummaryAssess(companyId int, operatorId int, cycleId in
520 ) 524 )
521 ) 525 )
522 ` 526 `
523 - params := []interface{}{companyId, operatorId, cycleId, hrbp, cycleId, operatorId, cycleId, beginDay} 527 + params := []interface{}{operatorId, cycleId, hrbp, cycleId, operatorId, cycleId, beginDay}
  528 + //params := []interface{}{companyId, operatorId, cycleId, hrbp, cycleId, operatorId, cycleId, beginDay}
524 529
525 sqlString = fmt.Sprintf(sqlString, params...) 530 sqlString = fmt.Sprintf(sqlString, params...)
526 531
@@ -562,21 +567,10 @@ func (d *StaffAssessDao) MemberSummaryList(likeUserName string, companyId int, o @@ -562,21 +567,10 @@ func (d *StaffAssessDao) MemberSummaryList(likeUserName string, companyId int, o
562 if offset < 0 { 567 if offset < 0 {
563 offset = 0 568 offset = 0
564 } 569 }
565 -  
566 sqlString := ` 570 sqlString := `
567 set time zone 'PRC'; 571 set time zone 'PRC';
568 - with t_user_department as (  
569 - select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"  
570 - where "user".company_id= %d and "user".deleted_at isnull  
571 - ),  
572 - t_department as (  
573 - select department.id::text as depart_id from department where charge_user_ids @>'[%d]'  
574 - and "department".deleted_at isnull  
575 - ),  
576 - -- 部门主管(所有下级用户ID)  
577 - t_user_1 as (  
578 - select t_user_department.user_id::text from t_user_department  
579 - join t_department on t_user_department.depart_id = t_department.depart_id 572 + with t_user_1 as (
  573 + select "user".id::text as user_id from "user" where "user".parent_id =%d
580 ), 574 ),
581 -- 如果是HRBP 575 -- 如果是HRBP
582 t_project_1 as( 576 t_project_1 as(
@@ -642,7 +636,7 @@ func (d *StaffAssessDao) MemberSummaryList(likeUserName string, companyId int, o @@ -642,7 +636,7 @@ func (d *StaffAssessDao) MemberSummaryList(likeUserName string, companyId int, o
642 ) 636 )
643 ) 637 )
644 ` 638 `
645 - params := []interface{}{companyId, operatorId, cycleId, hrbp, cycleId, operatorId, cycleId} 639 + params := []interface{}{operatorId, cycleId, hrbp, cycleId, operatorId, cycleId}
646 // 筛选结果的所有评估数据 640 // 筛选结果的所有评估数据
647 sqlString = fmt.Sprintf(sqlString, params...) 641 sqlString = fmt.Sprintf(sqlString, params...)
648 642
@@ -709,18 +703,8 @@ type PerformanceIndicatorAssess struct { @@ -709,18 +703,8 @@ type PerformanceIndicatorAssess struct {
709 func (d *StaffAssessDao) MemberPerformanceIndicator(likeUserName string, companyId int, operatorId int, cycleId int, hrbp int, assessType string, userIds []string) ([]PerformanceIndicatorAssess, error) { 703 func (d *StaffAssessDao) MemberPerformanceIndicator(likeUserName string, companyId int, operatorId int, cycleId int, hrbp int, assessType string, userIds []string) ([]PerformanceIndicatorAssess, error) {
710 sqlString := ` 704 sqlString := `
711 set time zone 'PRC'; 705 set time zone 'PRC';
712 - with t_user_department as (  
713 - select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"  
714 - where "user".company_id= %d and "user".deleted_at isnull  
715 - ),  
716 - t_department as (  
717 - select department.id::text as depart_id from department where charge_user_ids @>'[%d]'  
718 - and "department".deleted_at isnull  
719 - ),  
720 - -- 部门主管(所有下级用户ID)  
721 - t_user_1 as (  
722 - select t_user_department.user_id::text from t_user_department  
723 - join t_department on t_user_department.depart_id = t_department.depart_id 706 + with t_user_1 as (
  707 + select "user".id::text as user_id from "user" where "user".parent_id =%d
724 ), 708 ),
725 -- 如果是HRBP 709 -- 如果是HRBP
726 t_project_1 as( 710 t_project_1 as(
@@ -783,7 +767,7 @@ func (d *StaffAssessDao) MemberPerformanceIndicator(likeUserName string, company @@ -783,7 +767,7 @@ func (d *StaffAssessDao) MemberPerformanceIndicator(likeUserName string, company
783 ) 767 )
784 ) 768 )
785 ` 769 `
786 - params := []interface{}{companyId, operatorId, cycleId, hrbp, cycleId, operatorId, cycleId, assessType} 770 + params := []interface{}{operatorId, cycleId, hrbp, cycleId, operatorId, cycleId, assessType}
787 sqlString = fmt.Sprintf(sqlString, params...) 771 sqlString = fmt.Sprintf(sqlString, params...)
788 772
789 sqlString += ` select 773 sqlString += ` select
@@ -843,18 +827,8 @@ func (d *StaffAssessDao) ExportPerformanceIndicator( @@ -843,18 +827,8 @@ func (d *StaffAssessDao) ExportPerformanceIndicator(
843 userIds []string) ([]ExportPerformanceIndicator, error) { 827 userIds []string) ([]ExportPerformanceIndicator, error) {
844 sqlString := ` 828 sqlString := `
845 set time zone 'PRC'; 829 set time zone 'PRC';
846 - with t_user_department as (  
847 - select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"  
848 - where "user".company_id= %d and "user".deleted_at isnull  
849 - ),  
850 - t_department as (  
851 - select department.id::text as depart_id from department where charge_user_ids @>'[%d]'  
852 - and "department".deleted_at isnull  
853 - ),  
854 - -- 部门主管(所有下级用户ID)  
855 - t_user_1 as (  
856 - select t_user_department.user_id::text from t_user_department  
857 - join t_department on t_user_department.depart_id = t_department.depart_id 830 + with t_user_1 as (
  831 + select "user".id::text as user_id from "user" where "user".parent_id =%d
858 ), 832 ),
859 -- 如果是HRBP 833 -- 如果是HRBP
860 t_project_1 as( 834 t_project_1 as(
@@ -917,7 +891,7 @@ func (d *StaffAssessDao) ExportPerformanceIndicator( @@ -917,7 +891,7 @@ func (d *StaffAssessDao) ExportPerformanceIndicator(
917 ) 891 )
918 ) 892 )
919 ` 893 `
920 - params := []interface{}{companyId, operatorId, cycleId, hrbp, cycleId, operatorId, cycleId, assessType} 894 + params := []interface{}{operatorId, cycleId, hrbp, cycleId, operatorId, cycleId, assessType}
921 sqlString = fmt.Sprintf(sqlString, params...) 895 sqlString = fmt.Sprintf(sqlString, params...)
922 896
923 sqlString += ` select 897 sqlString += ` select