...
|
...
|
@@ -37,6 +37,7 @@ func (d *TaskDao) catchTaskIdByPermission(userId int) string { |
|
|
select "child_user".id,"child_user".parent_id
|
|
|
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
|
|
|
)
|
|
|
),
|
|
|
-- 根据任务负责人和相关人员查询
|
...
|
...
|
@@ -379,16 +380,16 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err |
|
|
return cnt, err
|
|
|
}
|
|
|
|
|
|
func (d *TaskDao) IncreaseAnomaly(id []int, incr int) error {
|
|
|
if len(id) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
sqlStr := `update task set anomaly=task.anomaly+?
|
|
|
where id in(?)`
|
|
|
tx := d.transactionContext.PgTx
|
|
|
_, err := tx.Exec(sqlStr, incr, pg.In(id))
|
|
|
return err
|
|
|
}
|
|
|
// func (d *TaskDao) IncreaseAnomaly(id []int, incr int) error {
|
|
|
// if len(id) == 0 {
|
|
|
// return nil
|
|
|
// }
|
|
|
// sqlStr := `update task set anomaly=task.anomaly+?
|
|
|
// where id in(?)`
|
|
|
// tx := d.transactionContext.PgTx
|
|
|
// _, err := tx.Exec(sqlStr, incr, pg.In(id))
|
|
|
// return err
|
|
|
// }
|
|
|
|
|
|
// TaskStageData
|
|
|
// type TaskStageData struct {
|
...
|
...
|
@@ -470,7 +471,7 @@ func (d *TaskDao) TaskAnomalyByLeader(leaderId []string, anomaly int) ([]TaskDat |
|
|
task.leader ->>'name' as leader_name,
|
|
|
task.anomaly
|
|
|
from task
|
|
|
where task.anomaly >=? and task.leader ->>'id' in(?) `
|
|
|
where task.anomaly >=? and task.leader ->>'id' in(?) and task.deleted_at isnull `
|
|
|
result := []TaskData2{}
|
|
|
tx := d.transactionContext.PgTx
|
|
|
_, err := tx.Query(&result, sqlStr, anomaly, pg.In(leaderId))
|
...
|
...
|
@@ -484,7 +485,7 @@ func (d *TaskDao) CountTaskAnomalyNotHrbp(param ListTaskCondition) (int, error) |
|
|
from task
|
|
|
join t_task_1 on task.id =t_task_1.id
|
|
|
where 1=1
|
|
|
and task.anomaly>1 `
|
|
|
and task.anomaly>1 and task.deleted_at isnull `
|
|
|
condition := []interface{}{}
|
|
|
whereSql := ``
|
|
|
if param.OnlyMy {
|
...
|
...
|
@@ -546,6 +547,7 @@ func (d *TaskDao) ListTask2(userId int) ([]TaskData1, error) { |
|
|
task.level_name
|
|
|
from task
|
|
|
join t_task_1 on task.id =t_task_1.id
|
|
|
where task.deleted_at isnull
|
|
|
`
|
|
|
result := []TaskData1{}
|
|
|
tx := d.transactionContext.PgTx
|
...
|
...
|
@@ -564,7 +566,7 @@ func (d *TaskDao) ListTask2ForHrbp(userId int, companyId int) ([]TaskData1, erro |
|
|
task.level_name
|
|
|
from task
|
|
|
left join t_task_ignore on t_task_ignore.task_id=task.id
|
|
|
where 1=1 and task.company_id=? `
|
|
|
where 1=1 and task.company_id=? and task.deleted_at isnull`
|
|
|
result := []TaskData1{}
|
|
|
tx := d.transactionContext.PgTx
|
|
|
_, err := tx.Query(&result, sqlStr, userId, companyId)
|
...
|
...
|
@@ -573,26 +575,26 @@ func (d *TaskDao) ListTask2ForHrbp(userId int, companyId int) ([]TaskData1, erro |
|
|
}
|
|
|
|
|
|
// 获取异常任务对应的公司
|
|
|
func (d *TaskDao) TaskStageAnomalyForCompany() ([]int, error) {
|
|
|
var companyIds []struct {
|
|
|
CompanyId int `pg:"company_id"`
|
|
|
}
|
|
|
sqlStr := `select distinct company_id
|
|
|
from task
|
|
|
where 1=1
|
|
|
and (task.warn_flag >0)`
|
|
|
result := []TaskData1{}
|
|
|
tx := d.transactionContext.PgTx
|
|
|
_, err := tx.Query(&result, sqlStr)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
var ids []int
|
|
|
for _, v := range companyIds {
|
|
|
ids = append(ids, v.CompanyId)
|
|
|
}
|
|
|
return ids, nil
|
|
|
}
|
|
|
// func (d *TaskDao) TaskStageAnomalyForCompany() ([]int, error) {
|
|
|
// var companyIds []struct {
|
|
|
// CompanyId int `pg:"company_id"`
|
|
|
// }
|
|
|
// sqlStr := `select distinct company_id
|
|
|
// from task
|
|
|
// where 1=1
|
|
|
// and (task.warn_flag >0)`
|
|
|
// result := []TaskData1{}
|
|
|
// tx := d.transactionContext.PgTx
|
|
|
// _, err := tx.Query(&result, sqlStr)
|
|
|
// if err != nil {
|
|
|
// return nil, err
|
|
|
// }
|
|
|
// var ids []int
|
|
|
// for _, v := range companyIds {
|
|
|
// ids = append(ids, v.CompanyId)
|
|
|
// }
|
|
|
// return ids, nil
|
|
|
// }
|
|
|
|
|
|
type TaskData4 struct {
|
|
|
TaskId int `pg:"task_id"`
|
...
|
...
|
|