作者 tangxvhui

更新

@@ -145,7 +145,9 @@ func (d *StaffAssessDao) AllAssessCycleList(companyId int) ([]AssessCycle, error @@ -145,7 +145,9 @@ func (d *StaffAssessDao) AllAssessCycleList(companyId int) ([]AssessCycle, error
145 staff_assess_task.company_id , 145 staff_assess_task.company_id ,
146 staff_assess_task.cycle_name 146 staff_assess_task.cycle_name
147 from staff_assess_task 147 from staff_assess_task
148 - where staff_assess_task.company_id = ?` 148 + where staff_assess_task.company_id = ?
  149 + and staff_assess_task.deleted_at isnull
  150 + `
149 151
150 tx := d.transactionContext.PgTx 152 tx := d.transactionContext.PgTx
151 condition := []interface{}{ 153 condition := []interface{}{
@@ -172,7 +174,8 @@ func (d *StaffAssessDao) AllAssessCycleDayList(companyId int, cycleId int) ([]As @@ -172,7 +174,8 @@ func (d *StaffAssessDao) AllAssessCycleDayList(companyId int, cycleId int) ([]As
172 staff_assess_task.company_id 174 staff_assess_task.company_id
173 from staff_assess_task 175 from staff_assess_task
174 where staff_assess_task.cycle_id = ? 176 where staff_assess_task.cycle_id = ?
175 - and company_id =? ` 177 + and company_id =?
  178 + and staff_assess_task.deleted_at isnull `
176 179
177 tx := d.transactionContext.PgTx 180 tx := d.transactionContext.PgTx
178 condition := []interface{}{ 181 condition := []interface{}{
@@ -292,10 +295,11 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, @@ -292,10 +295,11 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
292 set time zone 'PRC'; 295 set time zone 'PRC';
293 with t_user_department as ( 296 with t_user_department as (
294 select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user" 297 select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"
295 - where "user".company_id= %d 298 + where "user".company_id= %d and "user".deleted_at isnull
296 ), 299 ),
297 t_department as ( 300 t_department as (
298 - select department.id::text as depart_id from department where charge_user_ids @>'[%d]' 301 + select department.id::text as depart_id from department where charge_user_ids @>'[%d]'
  302 + and "department".deleted_at isnull
299 ), 303 ),
300 -- 部门主管 304 -- 部门主管
301 t_user_1 as ( 305 t_user_1 as (
@@ -308,6 +312,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, @@ -308,6 +312,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
308 from evaluation_project 312 from evaluation_project
309 where evaluation_project.cycle_id =%d 313 where evaluation_project.cycle_id =%d
310 and evaluation_project.hr_bp = %d 314 and evaluation_project.hr_bp = %d
  315 + and evaluation_project.deleted_at isnull
311 ), 316 ),
312 -- 如果的项目管理员 317 -- 如果的项目管理员
313 t_project_2 as( 318 t_project_2 as(
@@ -316,6 +321,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, @@ -316,6 +321,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
316 where evaluation_project.cycle_id =%d 321 where evaluation_project.cycle_id =%d
317 and evaluation_project.pmp =1 322 and evaluation_project.pmp =1
318 and evaluation_project.pmp_ids @>'["%d"]' 323 and evaluation_project.pmp_ids @>'["%d"]'
  324 + and evaluation_project.deleted_at isnull
319 ), 325 ),
320 -- 合并数据 326 -- 合并数据
321 t_project_3 as ( 327 t_project_3 as (
@@ -331,6 +337,8 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, @@ -331,6 +337,8 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
331 to_char(staff_assess.begin_time,'YYYY-MM-DD') as begin_day, 337 to_char(staff_assess.begin_time,'YYYY-MM-DD') as begin_day,
332 staff_assess.evaluation_project_id 338 staff_assess.evaluation_project_id
333 from staff_assess 339 from staff_assess
  340 + join staff_assess_task on staff_assess.staff_assess_task_id = staff_assess_task.id
  341 + and staff_assess_task.deleted_at isnull
334 where staff_assess.cycle_id = %d 342 where staff_assess.cycle_id = %d
335 and to_char(staff_assess.begin_time,'YYYY-MM-DD')='%s' 343 and to_char(staff_assess.begin_time,'YYYY-MM-DD')='%s'
336 and staff_assess."types" ='self' 344 and staff_assess."types" ='self'
@@ -117,9 +117,10 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in @@ -117,9 +117,10 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
117 tx := repo.transactionContext.PgTx 117 tx := repo.transactionContext.PgTx
118 var m []*models.StaffAssess 118 var m []*models.StaffAssess
119 query := tx.Model(&m). 119 query := tx.Model(&m).
120 - Where("deleted_at isnull") 120 + Where("staff_assess.deleted_at isnull").
  121 + Join(`JOIN staff_assess_task ON staff_assess_task."id" = staff_assess."staff_assess_task_id" and staff_assess_task."deleted_at" isnull`)
121 if companyId, ok := queryOptions["companyId"]; ok { 122 if companyId, ok := queryOptions["companyId"]; ok {
122 - query.Where("company_id = ?", companyId) 123 + query.Where("staff_assess.company_id = ?", companyId)
123 } 124 }
124 if v, ok := queryOptions["limit"].(int); ok { 125 if v, ok := queryOptions["limit"].(int); ok {
125 query.Limit(v) 126 query.Limit(v)
@@ -128,34 +129,34 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in @@ -128,34 +129,34 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
128 query.Offset(v) 129 query.Offset(v)
129 } 130 }
130 if v, ok := queryOptions["targetUserId"]; ok { 131 if v, ok := queryOptions["targetUserId"]; ok {
131 - query.Where(`target_user->>'userId'='?'`, v) 132 + query.Where(`staff_assess.target_user->>'userId'='?'`, v)
132 } 133 }
133 134
134 if v, ok := queryOptions["targetUserName"].(string); ok { 135 if v, ok := queryOptions["targetUserName"].(string); ok {
135 - query.Where(`target_user->>'userName' like ?`, fmt.Sprintf("%%%v%%", v)) 136 + query.Where(`staff_assess.target_user->>'userName' like ?`, fmt.Sprintf("%%%v%%", v))
136 } 137 }
137 if v, ok := queryOptions["executorId"]; ok { 138 if v, ok := queryOptions["executorId"]; ok {
138 - query.Where(`executor->>'userId'='?'`, v) 139 + query.Where(`staff_assess.executor->>'userId'='?'`, v)
139 } 140 }
140 141
141 if v, ok := queryOptions["cycleId"]; ok { 142 if v, ok := queryOptions["cycleId"]; ok {
142 - query.Where(`cycle_id=?`, v) 143 + query.Where(`staff_assess.cycle_id=?`, v)
143 } 144 }
144 if v, ok := queryOptions["staffAssessTaskId"]; ok { 145 if v, ok := queryOptions["staffAssessTaskId"]; ok {
145 - query.Where(`staff_assess_task_id=?`, v) 146 + query.Where(`staff_assess.staff_assess_task_id=?`, v)
146 } 147 }
147 148
148 if v, ok := queryOptions["id"]; ok { 149 if v, ok := queryOptions["id"]; ok {
149 - query.Where("id=?", v) 150 + query.Where("staff_assess.id=?", v)
150 } 151 }
151 if v, ok := queryOptions["typesList"].([]string); ok { 152 if v, ok := queryOptions["typesList"].([]string); ok {
152 - query.Where("types in(?)", pg.In(v)) 153 + query.Where("staff_assess.types in(?)", pg.In(v))
153 } 154 }
154 if v, ok := queryOptions["status"]; ok { 155 if v, ok := queryOptions["status"]; ok {
155 - query.Where("status=?", v) 156 + query.Where("staff_assess.status=?", v)
156 } 157 }
157 if v, ok := queryOptions["endTime"]; ok { 158 if v, ok := queryOptions["endTime"]; ok {
158 - query.Where("end_time<=?", v) 159 + query.Where("staff_assess.end_time<=?", v)
159 } 160 }
160 if v, ok := queryOptions["beginDay"]; ok { 161 if v, ok := queryOptions["beginDay"]; ok {
161 query.Where("to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD')= ? ", v) 162 query.Where("to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD')= ? ", v)