|
@@ -217,7 +217,7 @@ func (d *StaffAssessDao) SearchUserAssessContent(param SearchConditin1) ([]UserA |
|
@@ -217,7 +217,7 @@ func (d *StaffAssessDao) SearchUserAssessContent(param SearchConditin1) ([]UserA |
217
|
sqlStr0 := d.useTStaffAssess(param.CompanyId, param.CycleId, param.OperaterId, param.BeginDay, param.Hrbp, param.Limit, param.Offset)
|
217
|
sqlStr0 := d.useTStaffAssess(param.CompanyId, param.CycleId, param.OperaterId, param.BeginDay, param.Hrbp, param.Limit, param.Offset)
|
218
|
sqlStr = sqlStr0 + sqlStr
|
218
|
sqlStr = sqlStr0 + sqlStr
|
219
|
tx := d.transactionContext.PgTx
|
219
|
tx := d.transactionContext.PgTx
|
220
|
- var result []UserAssessContent
|
220
|
+ result := []UserAssessContent{}
|
221
|
_, err := tx.Query(&result, sqlStr, condition...)
|
221
|
_, err := tx.Query(&result, sqlStr, condition...)
|
222
|
return result, err
|
222
|
return result, err
|
223
|
}
|
223
|
}
|
|
@@ -259,6 +259,7 @@ func (d *StaffAssessDao) CountUserAssess(param SearchConditin1) (int, error) { |
|
@@ -259,6 +259,7 @@ func (d *StaffAssessDao) CountUserAssess(param SearchConditin1) (int, error) { |
259
|
//offset int 分页偏移
|
259
|
//offset int 分页偏移
|
260
|
func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, beginDay string, hrbp int, limit int, offset int) string {
|
260
|
func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, beginDay string, hrbp int, limit int, offset int) string {
|
261
|
sqlstr := `
|
261
|
sqlstr := `
|
|
|
262
|
+ set time zone 'PRC';
|
262
|
with t_user_department as (
|
263
|
with t_user_department as (
|
263
|
select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"
|
264
|
select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"
|
264
|
where "user".company_id= %d
|
265
|
where "user".company_id= %d
|
|
@@ -266,19 +267,16 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
|
@@ -266,19 +267,16 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
266
|
t_department as (
|
267
|
t_department as (
|
267
|
select department.id::text as depart_id from department where charge_user_ids @>'[%d]'
|
268
|
select department.id::text as depart_id from department where charge_user_ids @>'[%d]'
|
268
|
),
|
269
|
),
|
269
|
- -- 如果是部门管理员 获取用户列表
|
|
|
270
|
t_user_1 as (
|
270
|
t_user_1 as (
|
271
|
select t_user_department.user_id::text from t_user_department
|
271
|
select t_user_department.user_id::text from t_user_department
|
272
|
join t_department on t_user_department.depart_id = t_department.depart_id
|
272
|
join t_department on t_user_department.depart_id = t_department.depart_id
|
273
|
),
|
273
|
),
|
274
|
- -- 如果是hrbp
|
|
|
275
|
t_project_1 as(
|
274
|
t_project_1 as(
|
276
|
select evaluation_project.id as project_id
|
275
|
select evaluation_project.id as project_id
|
277
|
from evaluation_project
|
276
|
from evaluation_project
|
278
|
where evaluation_project.cycle_id =%d
|
277
|
where evaluation_project.cycle_id =%d
|
279
|
and evaluation_project.hr_bp = %d
|
278
|
and evaluation_project.hr_bp = %d
|
280
|
),
|
279
|
),
|
281
|
- -- 如果是项目管理员
|
|
|
282
|
t_project_2 as(
|
280
|
t_project_2 as(
|
283
|
select evaluation_project.id as project_id
|
281
|
select evaluation_project.id as project_id
|
284
|
from evaluation_project
|
282
|
from evaluation_project
|
|
@@ -286,13 +284,11 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
|
@@ -286,13 +284,11 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
286
|
and evaluation_project.pmp =1
|
284
|
and evaluation_project.pmp =1
|
287
|
and evaluation_project.pmp_ids @>'["%d"]'
|
285
|
and evaluation_project.pmp_ids @>'["%d"]'
|
288
|
),
|
286
|
),
|
289
|
- -- 合并数据
|
|
|
290
|
t_project_3 as (
|
287
|
t_project_3 as (
|
291
|
select t_project_2.project_id from t_project_2
|
288
|
select t_project_2.project_id from t_project_2
|
292
|
union
|
289
|
union
|
293
|
select t_project_1.project_id from t_project_1
|
290
|
select t_project_1.project_id from t_project_1
|
294
|
),
|
291
|
),
|
295
|
- -- 初步过滤评估列表数据
|
|
|
296
|
t_staff_assess_0 as (
|
292
|
t_staff_assess_0 as (
|
297
|
select staff_assess.id as assess_id,
|
293
|
select staff_assess.id as assess_id,
|
298
|
staff_assess.target_user->>'userId' as target_user_id,
|
294
|
staff_assess.target_user->>'userId' as target_user_id,
|
|
@@ -304,7 +300,6 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
|
@@ -304,7 +300,6 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
304
|
and to_char(staff_assess.begin_time,'YYYY-MM-DD')='%s'
|
300
|
and to_char(staff_assess.begin_time,'YYYY-MM-DD')='%s'
|
305
|
and staff_assess."types" ='self'
|
301
|
and staff_assess."types" ='self'
|
306
|
),
|
302
|
),
|
307
|
- -- 合并根据权限过滤后的数据
|
|
|
308
|
t_staff_assess_1 as (
|
303
|
t_staff_assess_1 as (
|
309
|
(select t_staff_assess_0.assess_id,
|
304
|
(select t_staff_assess_0.assess_id,
|
310
|
t_staff_assess_0.target_user_id,
|
305
|
t_staff_assess_0.target_user_id,
|