...
|
...
|
@@ -63,11 +63,12 @@ func (d *TaskDao) catchTaskIdByPermission(userId int) string { |
|
|
}
|
|
|
|
|
|
type ListTaskCondition struct {
|
|
|
Limit int //分页
|
|
|
Offset int //分页
|
|
|
CompanyId int //公司id
|
|
|
UserId int //谁要查看任务数据
|
|
|
OnlyMy bool //只查看我负责的任务
|
|
|
Limit int //分页
|
|
|
Offset int //分页
|
|
|
CompanyId int //公司id
|
|
|
UserId int //谁要查看任务数据
|
|
|
OnlyMy bool //只查看我负责的任务
|
|
|
LevelName string //任务类型名称
|
|
|
SearchWord string
|
|
|
}
|
|
|
|
...
|
...
|
@@ -108,7 +109,10 @@ func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) { |
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
}
|
|
|
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name = ? `
|
|
|
}
|
|
|
sqlStr := withSql + whereSql
|
|
|
tx := d.transactionContext.PgTx
|
|
|
var cnt int
|
...
|
...
|
@@ -135,6 +139,10 @@ func (d *TaskDao) CountTaskByHrbp(param ListTaskCondition) (int, error) { |
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name = ? `
|
|
|
}
|
|
|
sqlStr := withSql + whereSql
|
|
|
tx := d.transactionContext.PgTx
|
|
|
var cnt int
|
...
|
...
|
@@ -167,6 +175,10 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er |
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name = ? `
|
|
|
}
|
|
|
sqlStr := withSql + whereSql
|
|
|
tx := d.transactionContext.PgTx
|
|
|
var cnt int
|
...
|
...
|
@@ -201,6 +213,10 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err |
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name = ? `
|
|
|
}
|
|
|
|
|
|
sqlStr := withSql + whereSql
|
|
|
tx := d.transactionContext.PgTx
|
...
|
...
|
@@ -302,6 +318,10 @@ func (d *TaskDao) CountTaskAnomalyNotHrbp(param ListTaskCondition) (int, error) |
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name = ? `
|
|
|
}
|
|
|
sqlStr := withSql + whereSql
|
|
|
tx := d.transactionContext.PgTx
|
|
|
var cnt int
|
...
|
...
|
@@ -326,7 +346,11 @@ func (d *TaskDao) CountTaskAnomalyByHrbp(param ListTaskCondition) (int, error) { |
|
|
}
|
|
|
if param.SearchWord != "" {
|
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?) `
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name = ? `
|
|
|
}
|
|
|
sqlStr := withSql + whereSql
|
|
|
tx := d.transactionContext.PgTx
|
...
|
...
|
@@ -453,6 +477,8 @@ type ListTask struct { |
|
|
CreatedAt time.Time `pg:"created_at"`
|
|
|
CurrentStage domain.TaskStage `pg:"current_stage"` // 当前执行的里程碑
|
|
|
LastStage domain.TaskStage `pg:"last_stage"` // 上一个完成的里程碑
|
|
|
SortBy int `pg:"sort_by"`
|
|
|
EndTime int `pg:"end_time"`
|
|
|
}
|
|
|
|
|
|
// (新)获取任务,用于页面展示; 无过滤查看权限
|
...
|
...
|
@@ -481,6 +507,8 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
|
task.updated_at,
|
|
|
task.current_stage,
|
|
|
task.last_stage,
|
|
|
task.sort_by,
|
|
|
task.end_time,
|
|
|
task.created_at
|
|
|
from task
|
|
|
left join t_task_ignore on t_task_ignore.task_id=task.id
|
...
|
...
|
@@ -511,14 +539,16 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
|
t_task.updated_at ,
|
|
|
t_task.current_stage,
|
|
|
t_task.last_stage,
|
|
|
t_task.sort_by,
|
|
|
t_task.end_time,
|
|
|
t_task.created_at
|
|
|
from t_task
|
|
|
where 1=1
|
|
|
)select *
|
|
|
from t_task_1
|
|
|
order by t_task_1.sort_by_1,
|
|
|
order by t_task_1.status, t_task_1.sort_by_1,
|
|
|
t_task_1.sort_by_2,t_task_1.anomaly desc,
|
|
|
t_task_1."level",t_task_1."created_at"
|
|
|
t_task_1.sort_by,t_task_1."created_at"
|
|
|
limit ? offset ?
|
|
|
`
|
|
|
condition := []interface{}{param.UserId, param.CompanyId}
|
...
|
...
|
@@ -531,6 +561,10 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name = ? `
|
|
|
}
|
|
|
strSql2 := fmt.Sprintf(sqlStr, whereSql)
|
|
|
condition = append(condition, param.Limit, param.Offset)
|
|
|
result := []ListTask{}
|
...
|
...
|
@@ -558,6 +592,8 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
|
task.last_stage,
|
|
|
task.status ,
|
|
|
task.updated_at,
|
|
|
task.sort_by,
|
|
|
task.end_time,
|
|
|
task.created_at
|
|
|
from task
|
|
|
join t_task_1 on t_task_1.id=task.id
|
...
|
...
|
@@ -587,14 +623,16 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
|
t_task.last_stage,
|
|
|
t_task.status ,
|
|
|
t_task.updated_at ,
|
|
|
t_task.sort_by,
|
|
|
t_task.end_time,
|
|
|
t_task.created_at
|
|
|
from t_task
|
|
|
where 1=1
|
|
|
)select *
|
|
|
from tt_task_1
|
|
|
order by tt_task_1.sort_by_1,
|
|
|
order by tt_task_1.status,tt_task_1.sort_by_1,
|
|
|
tt_task_1.sort_by_2,tt_task_1.anomaly desc,
|
|
|
tt_task_1."level",tt_task_1."created_at"
|
|
|
tt_task_1.sort_by,tt_task_1."created_at"
|
|
|
limit ? offset ?
|
|
|
`
|
|
|
condition := []interface{}{param.CompanyId}
|
...
|
...
|
@@ -607,6 +645,10 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name = ? `
|
|
|
}
|
|
|
strSql2 := fmt.Sprintf(strSql, whereSql)
|
|
|
condition = append(condition, param.Limit, param.Offset)
|
|
|
result := []ListTask{}
|
...
|
...
|
@@ -614,3 +656,84 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
|
_, err := tx.Query(&result, strSql2, condition...)
|
|
|
return result, err
|
|
|
}
|
|
|
|
|
|
// 获取已取消关注的任务列表
|
|
|
func (d *TaskDao) ListTaskIgnore(param ListTaskCondition) ([]ListTask, error) {
|
|
|
sqlStr := `with
|
|
|
t_task_ignore as(
|
|
|
select task_ignore.task_id
|
|
|
from task_ignore
|
|
|
where user_id =3252522494124032
|
|
|
)select
|
|
|
task.id as task_id ,
|
|
|
task.alias ,
|
|
|
task.leader ->>'name' as leader_name,
|
|
|
task."level" ,
|
|
|
task.level_name ,
|
|
|
task.anomaly ,
|
|
|
task.status ,
|
|
|
task.updated_at ,
|
|
|
task.created_at ,
|
|
|
task.current_stage ,
|
|
|
task.last_stage ,
|
|
|
task.sort_by ,
|
|
|
task.end_time
|
|
|
from task
|
|
|
join t_task_ignore on t_task_ignore.task_id=task.id
|
|
|
where 1=1 and task.company_id=? and task.deleted_at isnull `
|
|
|
condition := []interface{}{param.CompanyId}
|
|
|
whereSql := ``
|
|
|
if param.OnlyMy {
|
|
|
condition = append(condition, param.UserId)
|
|
|
whereSql += ` and task.leader ->>'id' = '?' `
|
|
|
}
|
|
|
if param.SearchWord != "" {
|
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name = ? `
|
|
|
}
|
|
|
condition = append(condition, param.Limit, param.Offset)
|
|
|
sqlStr = sqlStr + whereSql + ` limit ? offset ? `
|
|
|
|
|
|
result := []ListTask{}
|
|
|
tx := d.transactionContext.PgTx
|
|
|
_, err := tx.Query(&result, sqlStr, condition...)
|
|
|
return result, err
|
|
|
}
|
|
|
|
|
|
func (d *TaskDao) CountTaskIgnore(param ListTaskCondition) (int, error) {
|
|
|
sqlStr := `with
|
|
|
t_task_ignore as(
|
|
|
select task_ignore.task_id
|
|
|
from task_ignore
|
|
|
where user_id =3252522494124032
|
|
|
)select
|
|
|
count(*) as cnt
|
|
|
from task
|
|
|
join t_task_ignore on t_task_ignore.task_id=task.id
|
|
|
where 1=1 and task.company_id=? and task.deleted_at isnull `
|
|
|
condition := []interface{}{param.CompanyId}
|
|
|
whereSql := ``
|
|
|
if param.OnlyMy {
|
|
|
condition = append(condition, param.UserId)
|
|
|
whereSql += ` and task.leader ->>'id' = '?' `
|
|
|
}
|
|
|
if param.SearchWord != "" {
|
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name = ? `
|
|
|
}
|
|
|
condition = append(condition, param.Limit, param.Offset)
|
|
|
sqlStr = sqlStr + whereSql + ` limit ? offset ? `
|
|
|
|
|
|
result := 0
|
|
|
tx := d.transactionContext.PgTx
|
|
|
_, err := tx.Query(pg.Scan(&result), sqlStr, condition...)
|
|
|
return result, err
|
|
|
} |
...
|
...
|
|