...
|
...
|
@@ -317,7 +317,23 @@ func (d *TaskAnomalyDao) List2(userId int, companyId int, taskName string, categ |
|
|
// pageSize 分页大小
|
|
|
// pageNumber 分页页码
|
|
|
func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, category int, dayTime string, leaderId []string, limit int, offset int) (int, []ListTaskAnomaly, error) {
|
|
|
sqlStr1 := ` with t_task_ignore as (
|
|
|
sqlStr1 := ` with
|
|
|
recursive t_user as (
|
|
|
(
|
|
|
select "user".id,"user".parent_id ,"user".account,"user".name, 1 as "level"
|
|
|
from "user"
|
|
|
where "user".id=? and "user".deleted_at isnull
|
|
|
)
|
|
|
union
|
|
|
(
|
|
|
select "child_user".id,"child_user".parent_id,"child_user".account,"child_user".name,
|
|
|
"parent_user"."level"+1 as "level"
|
|
|
from "user" as "child_user"
|
|
|
join t_user as "parent_user" on "parent_user".id="child_user".parent_id
|
|
|
where "child_user".deleted_at isnull
|
|
|
)
|
|
|
),
|
|
|
t_task_ignore as (
|
|
|
select task_ignore.id ,task_ignore.task_id
|
|
|
from task_ignore
|
|
|
where user_id = ?
|
...
|
...
|
@@ -349,11 +365,27 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ |
|
|
where t_task_ignore.id isnull and task.deleted_at isnull
|
|
|
and task_anomaly.company_id = ?
|
|
|
and task.related_user@> ?
|
|
|
and task.leader->>'id' <> ?
|
|
|
and task.leader->>'id' not in (select id::text from t_user where t_user."level" <3)
|
|
|
and task_anomaly.is_last=1
|
|
|
`
|
|
|
|
|
|
sqlStr2 := ` with t_task_ignore as (
|
|
|
sqlStr2 := ` with
|
|
|
recursive t_user as (
|
|
|
(
|
|
|
select "user".id,"user".parent_id ,"user".account,"user".name, 1 as "level"
|
|
|
from "user"
|
|
|
where "user".id=? and "user".deleted_at isnull
|
|
|
)
|
|
|
union
|
|
|
(
|
|
|
select "child_user".id,"child_user".parent_id,"child_user".account,"child_user".name,
|
|
|
"parent_user"."level"+1 as "level"
|
|
|
from "user" as "child_user"
|
|
|
join t_user as "parent_user" on "parent_user".id="child_user".parent_id
|
|
|
where "child_user".deleted_at isnull
|
|
|
)
|
|
|
),
|
|
|
t_task_ignore as (
|
|
|
select task_ignore.id ,task_ignore.task_id
|
|
|
from task_ignore
|
|
|
where user_id = ?
|
...
|
...
|
@@ -364,11 +396,11 @@ func (d *TaskAnomalyDao) List3(userId int, companyId int, taskName string, categ |
|
|
where t_task_ignore.id isnull and task.deleted_at isnull
|
|
|
and task_anomaly.company_id = ?
|
|
|
and task.related_user@> ?
|
|
|
and task.leader->>'id' <> ?
|
|
|
and task.leader->>'id' not in (select id::text from t_user where t_user."level" <3)
|
|
|
and task_anomaly.is_last=1
|
|
|
`
|
|
|
|
|
|
condition := []interface{}{userId, companyId, fmt.Sprintf("[%d]", userId), strconv.Itoa(userId)}
|
|
|
condition := []interface{}{userId, userId, companyId, fmt.Sprintf("[%d]", userId), strconv.Itoa(userId)}
|
|
|
if len(dayTime) > 0 {
|
|
|
condition = append(condition, dayTime)
|
|
|
sqlStr2 += ` and to_char(task_anomaly.created_at,'yyyy-MM-dd') =? `
|
...
|
...
|
|