...
|
...
|
@@ -60,13 +60,12 @@ func (d *TaskDao) catchTaskIdByPermission(userId int) string { |
|
|
}
|
|
|
|
|
|
type ListTaskCondition struct {
|
|
|
Limit int //分页
|
|
|
Offset int //分页
|
|
|
UserId int //谁要查看任务数据
|
|
|
TaskName string //任务名称
|
|
|
LevelName string //优先级
|
|
|
OnlyMy bool //只查看我负责的任务
|
|
|
LeaderId string //任务负责人id
|
|
|
Limit int //分页
|
|
|
Offset int //分页
|
|
|
CompanyId int //公司id
|
|
|
UserId int //谁要查看任务数据
|
|
|
OnlyMy bool //只查看我负责的任务
|
|
|
SearchWord string
|
|
|
}
|
|
|
|
|
|
// 任务和里程碑列表
|
...
|
...
|
@@ -125,7 +124,7 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage |
|
|
from task
|
|
|
join t_task_1 on task.id=t_task_1.id
|
|
|
join task_stage on task.id =task_stage.task_id
|
|
|
where 1=1
|
|
|
where 1=1 and task.company_id=?
|
|
|
order by diff_time,task."level",task.created_at
|
|
|
),
|
|
|
-- 按任务数据分页获取
|
...
|
...
|
@@ -156,22 +155,15 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage |
|
|
where t_task_tage_1.task_id in(
|
|
|
select t_task_page.task_id from t_task_page
|
|
|
)`
|
|
|
condition := []interface{}{}
|
|
|
condition := []interface{}{param.CompanyId}
|
|
|
whereSql := ``
|
|
|
if param.OnlyMy {
|
|
|
condition = append(condition, param.UserId)
|
|
|
whereSql += ` and t_task_tage_1.leader_id = '?' `
|
|
|
} else if param.LeaderId != "" && param.LeaderId != "0" {
|
|
|
condition = append(condition, param.LeaderId)
|
|
|
whereSql += ` and t_task_tage_1.leader_id = ? `
|
|
|
}
|
|
|
if len(param.TaskName) > 0 {
|
|
|
condition = append(condition, param.TaskName)
|
|
|
whereSql += ` and t_task_tage_1.task_name like ? `
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and t_task_tage_1.level_name like ? `
|
|
|
if param.SearchWord != "" {
|
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (t_task_tage_1.leader_name like ? or t_task_tage_1.task_alias_name like ?)`
|
|
|
}
|
|
|
condition = append(condition, param.Limit, param.Offset)
|
|
|
sqlStr := fmt.Sprintf(withSql, whereSql)
|
...
|
...
|
@@ -186,24 +178,18 @@ func (d *TaskDao) CountTaskStageNotHrbp(param ListTaskCondition) (int, error) { |
|
|
task1 := d.catchTaskIdByPermission(param.UserId)
|
|
|
withSql := task1 + `select count(*) from task
|
|
|
join t_task_1 on task.id =t_task_1.id
|
|
|
where 1=1 `
|
|
|
condition := []interface{}{}
|
|
|
where 1=1 and task.company_id=?`
|
|
|
condition := []interface{}{param.CompanyId}
|
|
|
whereSql := ``
|
|
|
if param.OnlyMy {
|
|
|
condition = append(condition, param.UserId)
|
|
|
whereSql += ` and task.leader ->>'id' = '?' `
|
|
|
} else if param.LeaderId != "" && param.LeaderId != "0" {
|
|
|
condition = append(condition, param.LeaderId)
|
|
|
whereSql += ` and task.leader ->>'id' = ? `
|
|
|
}
|
|
|
if len(param.TaskName) > 0 {
|
|
|
condition = append(condition, param.TaskName)
|
|
|
whereSql += ` and task.name like ? `
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name like ? `
|
|
|
if param.SearchWord != "" {
|
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
}
|
|
|
|
|
|
sqlStr := withSql + whereSql
|
|
|
tx := d.transactionContext.PgTx
|
|
|
var cnt int
|
...
|
...
|
@@ -247,7 +233,7 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage, |
|
|
end) as diff_time
|
|
|
from task
|
|
|
join task_stage on task.id =task_stage.task_id
|
|
|
where 1=1
|
|
|
where 1=1 and task.company_id=?
|
|
|
order by diff_time,task."level",task.created_at
|
|
|
),
|
|
|
-- 按任务数据分页获取
|
...
|
...
|
@@ -280,22 +266,15 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage, |
|
|
where t_task_tage_1.task_id in(
|
|
|
select t_task_page.task_id from t_task_page
|
|
|
)`
|
|
|
condition := []interface{}{param.UserId}
|
|
|
condition := []interface{}{param.UserId, param.CompanyId}
|
|
|
whereSql := ``
|
|
|
if param.OnlyMy {
|
|
|
condition = append(condition, param.UserId)
|
|
|
whereSql += ` and t_task_tage_1.leader_id = '?' `
|
|
|
} else if param.LeaderId != "" && param.LeaderId != "0" {
|
|
|
condition = append(condition, param.LeaderId)
|
|
|
whereSql += ` and t_task_tage_1.leader_id = ? `
|
|
|
}
|
|
|
if len(param.TaskName) > 0 {
|
|
|
condition = append(condition, param.TaskName)
|
|
|
whereSql += ` and t_task_tage_1.task_name like ? `
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and t_task_tage_1.level_name like ? `
|
|
|
if param.SearchWord != "" {
|
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (t_task_tage_1.leader_name like ? or t_task_tage_1.task_alias_name like ?)`
|
|
|
}
|
|
|
condition = append(condition, param.Limit, param.Offset)
|
|
|
sqlStr := fmt.Sprintf(withSql, whereSql)
|
...
|
...
|
@@ -313,23 +292,16 @@ func (d *TaskDao) CountTaskStageByHrbp(param ListTaskCondition) (int, error) { |
|
|
select task_ignore.task_id,task_ignore.id from task_ignore where task_ignore.user_id =?
|
|
|
)select count(*) from task
|
|
|
left join t_task_ignore on t_task_ignore.task_id=task.id
|
|
|
where 1=1 `
|
|
|
condition := []interface{}{param.UserId}
|
|
|
where 1=1 and task.company_id=?`
|
|
|
condition := []interface{}{param.UserId, param.CompanyId}
|
|
|
whereSql := ``
|
|
|
if param.OnlyMy {
|
|
|
condition = append(condition, param.UserId)
|
|
|
whereSql += ` and task.leader ->>'id' = '?' `
|
|
|
} else if param.LeaderId != "" && param.LeaderId != "0" {
|
|
|
condition = append(condition, param.LeaderId)
|
|
|
whereSql += ` and task.leader ->>'id' = ? `
|
|
|
}
|
|
|
if len(param.TaskName) > 0 {
|
|
|
condition = append(condition, param.TaskName)
|
|
|
whereSql += ` and task.name like ? `
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name like ? `
|
|
|
if param.SearchWord != "" {
|
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
}
|
|
|
sqlStr := withSql + whereSql
|
|
|
tx := d.transactionContext.PgTx
|
...
|
...
|
@@ -345,28 +317,21 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er |
|
|
from task_stage
|
|
|
join task on task_stage.task_id =task.id
|
|
|
join t_task_1 on task.id =t_task_1.id
|
|
|
where 1=1
|
|
|
where 1=1 and task.company_id=?
|
|
|
and(
|
|
|
(task_stage.plan_completed_at <task_stage.real_completed_at)
|
|
|
or
|
|
|
(task_stage.real_completed_at=0 and task_stage.plan_completed_at<extract(epoch from now()))
|
|
|
) `
|
|
|
condition := []interface{}{}
|
|
|
condition := []interface{}{param.CompanyId}
|
|
|
whereSql := ``
|
|
|
if param.OnlyMy {
|
|
|
condition = append(condition, param.UserId)
|
|
|
whereSql += ` and task.leader ->>'id' = '?' `
|
|
|
} else if param.LeaderId != "" && param.LeaderId != "0" {
|
|
|
condition = append(condition, param.LeaderId)
|
|
|
whereSql += ` and task.leader ->>'id' = ? `
|
|
|
}
|
|
|
if len(param.TaskName) > 0 {
|
|
|
condition = append(condition, param.TaskName)
|
|
|
whereSql += ` and task.name like ? `
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name like ? `
|
|
|
if param.SearchWord != "" {
|
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
}
|
|
|
sqlStr := withSql + whereSql
|
|
|
tx := d.transactionContext.PgTx
|
...
|
...
|
@@ -384,29 +349,23 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err |
|
|
from task_stage
|
|
|
join task on task_stage.task_id =task.id
|
|
|
left join t_task_ignore on t_task_ignore.task_id=task.id
|
|
|
where 1=1
|
|
|
where 1=1 and task.company_id=?
|
|
|
and(
|
|
|
(task_stage.plan_completed_at <task_stage.real_completed_at)
|
|
|
or
|
|
|
(task_stage.real_completed_at=0 and task_stage.plan_completed_at<extract(epoch from now()))
|
|
|
) `
|
|
|
condition := []interface{}{param.UserId}
|
|
|
condition := []interface{}{param.UserId, param.CompanyId}
|
|
|
whereSql := ``
|
|
|
if param.OnlyMy {
|
|
|
condition = append(condition, param.UserId)
|
|
|
whereSql += ` and task.leader ->>'id' = '?' `
|
|
|
} else if param.LeaderId != "" && param.LeaderId != "0" {
|
|
|
condition = append(condition, param.LeaderId)
|
|
|
whereSql += ` and task.leader ->>'id' = ? `
|
|
|
}
|
|
|
if len(param.TaskName) > 0 {
|
|
|
condition = append(condition, param.TaskName)
|
|
|
whereSql += ` and task.name like ? `
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name like ? `
|
|
|
if param.SearchWord != "" {
|
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
}
|
|
|
|
|
|
sqlStr := withSql + whereSql
|
|
|
tx := d.transactionContext.PgTx
|
|
|
var cnt int
|
...
|
...
|
@@ -446,16 +405,25 @@ func (d *TaskDao) TaskStageAnomaly(leaderId []string) ([]TaskStageData, error) { |
|
|
return result, err
|
|
|
}
|
|
|
|
|
|
// 异常的里程碑任务
|
|
|
func (d *TaskDao) TaskAnomaly(leaderId []string, anomaly int) ([]TaskStageData, error) {
|
|
|
type TaskData2 struct {
|
|
|
Id int `pg:"id"`
|
|
|
Name string `pg:"name"`
|
|
|
Alias string `pg:"alias"`
|
|
|
LeaderName string `pg:"leader_name"`
|
|
|
Anomaly string `pg:"anomaly"`
|
|
|
}
|
|
|
|
|
|
// 异常的任务
|
|
|
func (d *TaskDao) TaskAnomaly(leaderId []string, anomaly int) ([]TaskData2, error) {
|
|
|
sqlStr := `select
|
|
|
task."id",
|
|
|
task."name" ,
|
|
|
task.alias ,
|
|
|
task.leader ->>'name' as leader_name,
|
|
|
task.anomaly
|
|
|
from task
|
|
|
where task.anomaly >=? and task.leader ->'id' in(?) `
|
|
|
result := []TaskStageData{}
|
|
|
where task.anomaly >=? and task.leader ->>'id' in(?) `
|
|
|
result := []TaskData2{}
|
|
|
tx := d.transactionContext.PgTx
|
|
|
_, err := tx.Query(&result, sqlStr, anomaly, pg.In(leaderId))
|
|
|
return result, err
|
...
|
...
|
@@ -474,17 +442,10 @@ func (d *TaskDao) CountTaskAnomalyNotHrbp(param ListTaskCondition) (int, error) |
|
|
if param.OnlyMy {
|
|
|
condition = append(condition, param.UserId)
|
|
|
whereSql += ` and task.leader ->>'id' = '?' `
|
|
|
} else if param.LeaderId != "" {
|
|
|
condition = append(condition, param.LeaderId)
|
|
|
whereSql += ` and task.leader ->>'id' = ? `
|
|
|
}
|
|
|
if len(param.TaskName) > 0 {
|
|
|
condition = append(condition, param.TaskName)
|
|
|
whereSql += ` and task.name like ? `
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name like ? `
|
|
|
if param.SearchWord != "" {
|
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
}
|
|
|
sqlStr := withSql + whereSql
|
|
|
tx := d.transactionContext.PgTx
|
...
|
...
|
@@ -501,23 +462,16 @@ func (d *TaskDao) CountTaskAnomalyByHrbp(param ListTaskCondition) (int, error) { |
|
|
)select count(*)
|
|
|
from task
|
|
|
left join t_task_ignore on t_task_ignore.task_id=task.id
|
|
|
where 1=1 and task.anomaly>1 `
|
|
|
condition := []interface{}{param.UserId}
|
|
|
where 1=1 and task.anomaly>1 and task.company_id=?`
|
|
|
condition := []interface{}{param.UserId, param.CompanyId}
|
|
|
whereSql := ``
|
|
|
if param.OnlyMy {
|
|
|
condition = append(condition, param.UserId)
|
|
|
whereSql += ` and task.leader ->>'id' = '?' `
|
|
|
} else if param.LeaderId != "" {
|
|
|
condition = append(condition, param.LeaderId)
|
|
|
whereSql += ` and task.leader ->>'id' = ? `
|
|
|
}
|
|
|
if len(param.TaskName) > 0 {
|
|
|
condition = append(condition, param.TaskName)
|
|
|
whereSql += ` and task.name like ? `
|
|
|
}
|
|
|
if len(param.LevelName) > 0 {
|
|
|
condition = append(condition, param.LevelName)
|
|
|
whereSql += ` and task.level_name like ? `
|
|
|
if param.SearchWord != "" {
|
|
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
}
|
|
|
sqlStr := withSql + whereSql
|
|
|
tx := d.transactionContext.PgTx
|
...
|
...
|
@@ -525,3 +479,47 @@ func (d *TaskDao) CountTaskAnomalyByHrbp(param ListTaskCondition) (int, error) { |
|
|
_, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
|
|
|
return cnt, err
|
|
|
}
|
|
|
|
|
|
// 任务数据
|
|
|
type TaskData1 struct {
|
|
|
Name string `pg:"name"`
|
|
|
Alias string `pg:"alias"`
|
|
|
LeaderId string `pg:"leader_id"`
|
|
|
LeaderName string `pg:"leader_name"`
|
|
|
LevelName string `pg:"level_name"`
|
|
|
}
|
|
|
|
|
|
// 获取任务列表
|
|
|
func (d *TaskDao) ListTask2(userId int) ([]TaskData1, error) {
|
|
|
task1 := d.catchTaskIdByPermission(userId)
|
|
|
sqlStr := task1 + ` select task."name" ,task.alias ,
|
|
|
task.leader ->>'id' as leader_id,
|
|
|
task.leader ->>'name' as leader_name,
|
|
|
task.level_name
|
|
|
from task
|
|
|
join t_task_1 on task.id =t_task_1.id
|
|
|
`
|
|
|
result := []TaskData1{}
|
|
|
tx := d.transactionContext.PgTx
|
|
|
_, err := tx.Query(&result, sqlStr)
|
|
|
return result, err
|
|
|
}
|
|
|
|
|
|
// 获取任务列表
|
|
|
func (d *TaskDao) ListTask2ForHrbp(userId int, companyId int) ([]TaskData1, error) {
|
|
|
sqlStr := `with
|
|
|
t_task_ignore as (
|
|
|
select task_ignore.task_id,task_ignore.id from task_ignore where task_ignore.user_id =?
|
|
|
)select task."name" ,task.alias ,
|
|
|
task.leader ->>'id' as leader_id,
|
|
|
task.leader ->>'name' as leader_name,
|
|
|
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=? `
|
|
|
result := []TaskData1{}
|
|
|
tx := d.transactionContext.PgTx
|
|
|
_, err := tx.Query(&result, sqlStr, userId, companyId)
|
|
|
return result, err
|
|
|
|
|
|
} |
...
|
...
|
|