作者 tangxvhui

更新

... ... @@ -145,7 +145,9 @@ func (d *StaffAssessDao) AllAssessCycleList(companyId int) ([]AssessCycle, error
staff_assess_task.company_id ,
staff_assess_task.cycle_name
from staff_assess_task
where staff_assess_task.company_id = ?`
where staff_assess_task.company_id = ?
and staff_assess_task.deleted_at isnull
`
tx := d.transactionContext.PgTx
condition := []interface{}{
... ... @@ -172,7 +174,8 @@ func (d *StaffAssessDao) AllAssessCycleDayList(companyId int, cycleId int) ([]As
staff_assess_task.company_id
from staff_assess_task
where staff_assess_task.cycle_id = ?
and company_id =? `
and company_id =?
and staff_assess_task.deleted_at isnull `
tx := d.transactionContext.PgTx
condition := []interface{}{
... ... @@ -292,10 +295,11 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
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
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
),
-- 部门主管
t_user_1 as (
... ... @@ -308,6 +312,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
from evaluation_project
where evaluation_project.cycle_id =%d
and evaluation_project.hr_bp = %d
and evaluation_project.deleted_at isnull
),
-- 如果的项目管理员
t_project_2 as(
... ... @@ -316,6 +321,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
where evaluation_project.cycle_id =%d
and evaluation_project.pmp =1
and evaluation_project.pmp_ids @>'["%d"]'
and evaluation_project.deleted_at isnull
),
-- 合并数据
t_project_3 as (
... ... @@ -331,6 +337,8 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
to_char(staff_assess.begin_time,'YYYY-MM-DD') as begin_day,
staff_assess.evaluation_project_id
from staff_assess
join staff_assess_task on staff_assess.staff_assess_task_id = staff_assess_task.id
and staff_assess_task.deleted_at isnull
where staff_assess.cycle_id = %d
and to_char(staff_assess.begin_time,'YYYY-MM-DD')='%s'
and staff_assess."types" ='self'
... ...
... ... @@ -117,9 +117,10 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
tx := repo.transactionContext.PgTx
var m []*models.StaffAssess
query := tx.Model(&m).
Where("deleted_at isnull")
Where("staff_assess.deleted_at isnull").
Join(`JOIN staff_assess_task ON staff_assess_task."id" = staff_assess."staff_assess_task_id" and staff_assess_task."deleted_at" isnull`)
if companyId, ok := queryOptions["companyId"]; ok {
query.Where("company_id = ?", companyId)
query.Where("staff_assess.company_id = ?", companyId)
}
if v, ok := queryOptions["limit"].(int); ok {
query.Limit(v)
... ... @@ -128,34 +129,34 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
query.Offset(v)
}
if v, ok := queryOptions["targetUserId"]; ok {
query.Where(`target_user->>'userId'='?'`, v)
query.Where(`staff_assess.target_user->>'userId'='?'`, v)
}
if v, ok := queryOptions["targetUserName"].(string); ok {
query.Where(`target_user->>'userName' like ?`, fmt.Sprintf("%%%v%%", v))
query.Where(`staff_assess.target_user->>'userName' like ?`, fmt.Sprintf("%%%v%%", v))
}
if v, ok := queryOptions["executorId"]; ok {
query.Where(`executor->>'userId'='?'`, v)
query.Where(`staff_assess.executor->>'userId'='?'`, v)
}
if v, ok := queryOptions["cycleId"]; ok {
query.Where(`cycle_id=?`, v)
query.Where(`staff_assess.cycle_id=?`, v)
}
if v, ok := queryOptions["staffAssessTaskId"]; ok {
query.Where(`staff_assess_task_id=?`, v)
query.Where(`staff_assess.staff_assess_task_id=?`, v)
}
if v, ok := queryOptions["id"]; ok {
query.Where("id=?", v)
query.Where("staff_assess.id=?", v)
}
if v, ok := queryOptions["typesList"].([]string); ok {
query.Where("types in(?)", pg.In(v))
query.Where("staff_assess.types in(?)", pg.In(v))
}
if v, ok := queryOptions["status"]; ok {
query.Where("status=?", v)
query.Where("staff_assess.status=?", v)
}
if v, ok := queryOptions["endTime"]; ok {
query.Where("end_time<=?", v)
query.Where("staff_assess.end_time<=?", v)
}
if v, ok := queryOptions["beginDay"]; ok {
query.Where("to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD')= ? ", v)
... ...