...
|
...
|
@@ -434,20 +434,24 @@ type SummaryAssess struct { |
|
|
}
|
|
|
|
|
|
func (d *StaffAssessDao) SummaryAssess(companyId int, operatorId int, cycleId int, beginDay string, hrbp int) ([]SummaryAssess, error) {
|
|
|
//`
|
|
|
//with t_user_department as (
|
|
|
// select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"
|
|
|
// where "user".company_id= %d and "user".deleted_at isnull
|
|
|
//),
|
|
|
//t_department as (
|
|
|
// select department.id::text as depart_id from department where charge_user_ids @>'[%d]'
|
|
|
// and "department".deleted_at isnull
|
|
|
//),
|
|
|
//-- 部门主管(所有下级用户ID)
|
|
|
//t_user_1 as (
|
|
|
// select t_user_department.user_id::text from t_user_department
|
|
|
// join t_department on t_user_department.depart_id = t_department.depart_id
|
|
|
//),`
|
|
|
sqlString := `
|
|
|
set time zone 'PRC';
|
|
|
with t_user_department as (
|
|
|
select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"
|
|
|
where "user".company_id= %d and "user".deleted_at isnull
|
|
|
),
|
|
|
t_department as (
|
|
|
select department.id::text as depart_id from department where charge_user_ids @>'[%d]'
|
|
|
and "department".deleted_at isnull
|
|
|
),
|
|
|
-- 部门主管(所有下级用户ID)
|
|
|
t_user_1 as (
|
|
|
select t_user_department.user_id::text from t_user_department
|
|
|
join t_department on t_user_department.depart_id = t_department.depart_id
|
|
|
with t_user_1 as (
|
|
|
select "user".id::text as user_id from "user" where "user".parent_id =%d
|
|
|
),
|
|
|
-- 如果是HRBP
|
|
|
t_project_1 as(
|
...
|
...
|
@@ -520,7 +524,8 @@ func (d *StaffAssessDao) SummaryAssess(companyId int, operatorId int, cycleId in |
|
|
)
|
|
|
)
|
|
|
`
|
|
|
params := []interface{}{companyId, operatorId, cycleId, hrbp, cycleId, operatorId, cycleId, beginDay}
|
|
|
params := []interface{}{operatorId, cycleId, hrbp, cycleId, operatorId, cycleId, beginDay}
|
|
|
//params := []interface{}{companyId, operatorId, cycleId, hrbp, cycleId, operatorId, cycleId, beginDay}
|
|
|
|
|
|
sqlString = fmt.Sprintf(sqlString, params...)
|
|
|
|
...
|
...
|
@@ -562,21 +567,10 @@ func (d *StaffAssessDao) MemberSummaryList(likeUserName string, companyId int, o |
|
|
if offset < 0 {
|
|
|
offset = 0
|
|
|
}
|
|
|
|
|
|
sqlString := `
|
|
|
set time zone 'PRC';
|
|
|
with t_user_department as (
|
|
|
select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"
|
|
|
where "user".company_id= %d and "user".deleted_at isnull
|
|
|
),
|
|
|
t_department as (
|
|
|
select department.id::text as depart_id from department where charge_user_ids @>'[%d]'
|
|
|
and "department".deleted_at isnull
|
|
|
),
|
|
|
-- 部门主管(所有下级用户ID)
|
|
|
t_user_1 as (
|
|
|
select t_user_department.user_id::text from t_user_department
|
|
|
join t_department on t_user_department.depart_id = t_department.depart_id
|
|
|
with t_user_1 as (
|
|
|
select "user".id::text as user_id from "user" where "user".parent_id =%d
|
|
|
),
|
|
|
-- 如果是HRBP
|
|
|
t_project_1 as(
|
...
|
...
|
@@ -642,7 +636,7 @@ func (d *StaffAssessDao) MemberSummaryList(likeUserName string, companyId int, o |
|
|
)
|
|
|
)
|
|
|
`
|
|
|
params := []interface{}{companyId, operatorId, cycleId, hrbp, cycleId, operatorId, cycleId}
|
|
|
params := []interface{}{operatorId, cycleId, hrbp, cycleId, operatorId, cycleId}
|
|
|
// 筛选结果的所有评估数据
|
|
|
sqlString = fmt.Sprintf(sqlString, params...)
|
|
|
|
...
|
...
|
@@ -709,18 +703,8 @@ type PerformanceIndicatorAssess struct { |
|
|
func (d *StaffAssessDao) MemberPerformanceIndicator(likeUserName string, companyId int, operatorId int, cycleId int, hrbp int, assessType string, userIds []string) ([]PerformanceIndicatorAssess, error) {
|
|
|
sqlString := `
|
|
|
set time zone 'PRC';
|
|
|
with t_user_department as (
|
|
|
select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"
|
|
|
where "user".company_id= %d and "user".deleted_at isnull
|
|
|
),
|
|
|
t_department as (
|
|
|
select department.id::text as depart_id from department where charge_user_ids @>'[%d]'
|
|
|
and "department".deleted_at isnull
|
|
|
),
|
|
|
-- 部门主管(所有下级用户ID)
|
|
|
t_user_1 as (
|
|
|
select t_user_department.user_id::text from t_user_department
|
|
|
join t_department on t_user_department.depart_id = t_department.depart_id
|
|
|
with t_user_1 as (
|
|
|
select "user".id::text as user_id from "user" where "user".parent_id =%d
|
|
|
),
|
|
|
-- 如果是HRBP
|
|
|
t_project_1 as(
|
...
|
...
|
@@ -783,7 +767,7 @@ func (d *StaffAssessDao) MemberPerformanceIndicator(likeUserName string, company |
|
|
)
|
|
|
)
|
|
|
`
|
|
|
params := []interface{}{companyId, operatorId, cycleId, hrbp, cycleId, operatorId, cycleId, assessType}
|
|
|
params := []interface{}{operatorId, cycleId, hrbp, cycleId, operatorId, cycleId, assessType}
|
|
|
sqlString = fmt.Sprintf(sqlString, params...)
|
|
|
|
|
|
sqlString += ` select
|
...
|
...
|
@@ -843,18 +827,8 @@ func (d *StaffAssessDao) ExportPerformanceIndicator( |
|
|
userIds []string) ([]ExportPerformanceIndicator, error) {
|
|
|
sqlString := `
|
|
|
set time zone 'PRC';
|
|
|
with t_user_department as (
|
|
|
select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"
|
|
|
where "user".company_id= %d and "user".deleted_at isnull
|
|
|
),
|
|
|
t_department as (
|
|
|
select department.id::text as depart_id from department where charge_user_ids @>'[%d]'
|
|
|
and "department".deleted_at isnull
|
|
|
),
|
|
|
-- 部门主管(所有下级用户ID)
|
|
|
t_user_1 as (
|
|
|
select t_user_department.user_id::text from t_user_department
|
|
|
join t_department on t_user_department.depart_id = t_department.depart_id
|
|
|
with t_user_1 as (
|
|
|
select "user".id::text as user_id from "user" where "user".parent_id =%d
|
|
|
),
|
|
|
-- 如果是HRBP
|
|
|
t_project_1 as(
|
...
|
...
|
@@ -917,7 +891,7 @@ func (d *StaffAssessDao) ExportPerformanceIndicator( |
|
|
)
|
|
|
)
|
|
|
`
|
|
|
params := []interface{}{companyId, operatorId, cycleId, hrbp, cycleId, operatorId, cycleId, assessType}
|
|
|
params := []interface{}{operatorId, cycleId, hrbp, cycleId, operatorId, cycleId, assessType}
|
|
|
sqlString = fmt.Sprintf(sqlString, params...)
|
|
|
|
|
|
sqlString += ` select
|
...
|
...
|
|