作者 tangxvhui

日常保存

@@ -9,4 +9,5 @@ type ListTaskAnomalyCommand struct { @@ -9,4 +9,5 @@ type ListTaskAnomalyCommand struct {
9 DayTime string `json:"dayTime"` //发生异常的日期 9 DayTime string `json:"dayTime"` //发生异常的日期
10 Category int `json:"category"` //异常分类 10 Category int `json:"category"` //异常分类
11 LeaderId string `json:"leaderId"` //任务负责人id 11 LeaderId string `json:"leaderId"` //任务负责人id
  12 + SubLevel int `json:"subLevel"` //userId 的下级 ,向下查询多少级
12 } 13 }
@@ -156,7 +156,10 @@ func (srv TaskService) ListTaskAnomaly2(param *command.ListTaskAnomalyCommand) ( @@ -156,7 +156,10 @@ func (srv TaskService) ListTaskAnomaly2(param *command.ListTaskAnomalyCommand) (
156 }) 156 })
157 limit := 500 157 limit := 500
158 offset := 0 158 offset := 0
159 - cnt, anomalyList, err := taskAnomalyDao.List2(param.UserId, param.CompanyId, param.TaskName, param.Category, param.DayTime, param.LeaderId, limit, offset) 159 + if param.SubLevel < 1 {
  160 + param.SubLevel = 2
  161 + }
  162 + cnt, anomalyList, err := taskAnomalyDao.List2(param.UserId, param.CompanyId, param.TaskName, param.Category, param.DayTime, param.LeaderId, param.SubLevel, limit, offset)
160 if err != nil { 163 if err != nil {
161 return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 164 return map[string]interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
162 } 165 }
@@ -132,9 +132,12 @@ func (d *TaskAnomalyDao) List1(userId int, companyId int, taskName string, categ @@ -132,9 +132,12 @@ func (d *TaskAnomalyDao) List1(userId int, companyId int, taskName string, categ
132 // userId 谁要查看数据 132 // userId 谁要查看数据
133 // companyId 公司id 133 // companyId 公司id
134 // dayTime 搜索条件日期 ,例:"2006-01-02" 134 // dayTime 搜索条件日期 ,例:"2006-01-02"
  135 +// taskName 任务名称
  136 +// category 异常分类
135 // pageSize 分页大小 137 // pageSize 分页大小
136 // pageNumber 分页页码 138 // pageNumber 分页页码
137 -func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, category int, leaderId string, dayTime string, limit int, offset int) (int, []ListTaskAnomaly, error) { 139 +// subLevel 我的下级的层级
  140 +func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, category int, leaderId string, dayTime string, subLevel int, limit int, offset int) (int, []ListTaskAnomaly, error) {
138 sqlStr1 := `with 141 sqlStr1 := `with
139 -- 人员自身以及全下级 142 -- 人员自身以及全下级
140 recursive t_user as ( 143 recursive t_user as (
@@ -172,7 +175,7 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ @@ -172,7 +175,7 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ
172 and t_task_ignore.id isnull 175 and t_task_ignore.id isnull
173 and task.deleted_at isnull 176 and task.deleted_at isnull
174 and task.leader ->>'id' in ( 177 and task.leader ->>'id' in (
175 - select t_user.id::text from t_user where t_user."level">0 178 + select t_user.id::text from t_user where t_user."level"=?
176 ) 179 )
177 ) 180 )
178 select 181 select
@@ -232,7 +235,7 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ @@ -232,7 +235,7 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ
232 and t_task_ignore.id isnull 235 and t_task_ignore.id isnull
233 and task.deleted_at isnull 236 and task.deleted_at isnull
234 and task.leader ->>'id' in ( 237 and task.leader ->>'id' in (
235 - select t_user.id::text from t_user where t_user."level">0 238 + select t_user.id::text from t_user where t_user."level"=?
236 ) 239 )
237 ) 240 )
238 select count(*) as cnt 241 select count(*) as cnt