...
|
...
|
@@ -153,20 +153,29 @@ func (d *TaskDao) CountTaskByHrbp(param ListTaskCondition) (int, error) { |
|
|
// 统计里程碑异常的数量,以非hrbp角色统计
|
|
|
func (d *TaskDao) CountTaskStageAnomalyNotHrbp(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
|
|
|
// and task.company_id =?
|
|
|
// and task.deleted_at isnull
|
|
|
// and (
|
|
|
// (
|
|
|
// cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)>0 and
|
|
|
// cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)<floor(extract(epoch from now()))
|
|
|
// )
|
|
|
// or
|
|
|
// task.warn_flag = 1
|
|
|
// )
|
|
|
// `
|
|
|
withSql := task1 + ` select count(*)
|
|
|
from task
|
|
|
join t_task_1 on task.id =t_task_1.id
|
|
|
where 1=1
|
|
|
and task.company_id =?
|
|
|
and task.deleted_at isnull
|
|
|
and (
|
|
|
(
|
|
|
cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)>0 and
|
|
|
cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)<floor(extract(epoch from now()))
|
|
|
)
|
|
|
or
|
|
|
task.warn_flag = 1
|
|
|
)
|
|
|
and task.warn_flag >0
|
|
|
|
|
|
`
|
|
|
condition := []interface{}{param.CompanyId}
|
|
|
whereSql := ``
|
...
|
...
|
@@ -191,6 +200,24 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er |
|
|
|
|
|
// 统计里程碑异常的数量,以hrbp角色统计
|
|
|
func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, error) {
|
|
|
// withSql := `with
|
|
|
// t_task_ignore as (
|
|
|
// 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
|
|
|
// and task.company_id =?
|
|
|
// and task.deleted_at isnull
|
|
|
// and t_task_ignore.id isnull
|
|
|
// and (
|
|
|
// (
|
|
|
// cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)>0 and
|
|
|
// cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)<floor(extract(epoch from now()))
|
|
|
// )
|
|
|
// or
|
|
|
// task.warn_flag = 1
|
|
|
// )`
|
|
|
withSql := `with
|
|
|
t_task_ignore as (
|
|
|
select task_ignore.task_id,task_ignore.id from task_ignore where task_ignore.user_id =?
|
...
|
...
|
@@ -201,14 +228,7 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err |
|
|
and task.company_id =?
|
|
|
and task.deleted_at isnull
|
|
|
and t_task_ignore.id isnull
|
|
|
and (
|
|
|
(
|
|
|
cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)>0 and
|
|
|
cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)<floor(extract(epoch from now()))
|
|
|
)
|
|
|
or
|
|
|
task.warn_flag = 1
|
|
|
)`
|
|
|
and task.warn_flag > 0 `
|
|
|
condition := []interface{}{param.UserId, param.CompanyId}
|
|
|
whereSql := ``
|
|
|
if param.OnlyMy {
|
...
|
...
|
@@ -471,7 +491,6 @@ and task.anomaly>0 ` |
|
|
type ListTask struct {
|
|
|
SortBy1 int `pg:"sort_by_1"`
|
|
|
CPlanCompletedAt int `pg:"c_plan_completed_at"`
|
|
|
SortBy2 int `pg:"sort_by_2"`
|
|
|
TaskId int `pg:"task_id"`
|
|
|
Alias string `pg:"alias"`
|
|
|
LeaderName string `pg:"leader_name"`
|
...
|
...
|
@@ -479,6 +498,7 @@ type ListTask struct { |
|
|
Level int `pg:"level"`
|
|
|
LevelName string `pg:"level_name"`
|
|
|
Anomaly int `pg:"anomaly"`
|
|
|
WarnFlag int `pg:"warn_flag"`
|
|
|
Status int `pg:"status"`
|
|
|
UpdatedAt time.Time `pg:"updated_at"`
|
|
|
CreatedAt time.Time `pg:"created_at"`
|
...
|
...
|
@@ -511,6 +531,7 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
|
task."level",
|
|
|
task.level_name ,
|
|
|
task.anomaly ,
|
|
|
task.warn_flag ,
|
|
|
task.status ,
|
|
|
task.updated_at,
|
|
|
task.current_stage,
|
...
|
...
|
@@ -531,11 +552,6 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
|
when t_task.c_plan_completed_at-now_time>0 then 0
|
|
|
else t_task.c_plan_completed_at-now_time
|
|
|
end) as sort_by_1,
|
|
|
(case
|
|
|
when t_task.l_plan_completed_at=0 then 0
|
|
|
when t_task.l_plan_completed_at-t_task.l_real_completed_at>0 then 0
|
|
|
else t_task.l_plan_completed_at-t_task.l_real_completed_at
|
|
|
end) as sort_by_2,
|
|
|
t_task.c_plan_completed_at ,
|
|
|
t_task.id as task_id,
|
|
|
t_task.alias ,
|
...
|
...
|
@@ -544,6 +560,7 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
|
t_task."level",
|
|
|
t_task.level_name ,
|
|
|
t_task.anomaly ,
|
|
|
t_task.warn_flag ,
|
|
|
t_task.status ,
|
|
|
t_task.updated_at ,
|
|
|
t_task.current_stage,
|
...
|
...
|
@@ -556,7 +573,7 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
|
)select *
|
|
|
from t_task_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.anomaly desc,
|
|
|
t_task_1.sort_by,t_task_1."created_at"
|
|
|
limit ? offset ?
|
|
|
`
|
...
|
...
|
@@ -598,6 +615,7 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
|
task."level",
|
|
|
task.level_name ,
|
|
|
task.anomaly ,
|
|
|
task.warn_flag ,
|
|
|
task.current_stage,
|
|
|
task.last_stage,
|
|
|
task.status ,
|
...
|
...
|
@@ -617,11 +635,6 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
|
when t_task.c_plan_completed_at-now_time>0 then 0
|
|
|
else t_task.c_plan_completed_at-now_time
|
|
|
end) as sort_by_1,
|
|
|
(case
|
|
|
when t_task.l_plan_completed_at=0 then 0
|
|
|
when t_task.l_plan_completed_at-t_task.l_real_completed_at>0 then 0
|
|
|
else t_task.l_plan_completed_at-t_task.l_real_completed_at
|
|
|
end) as sort_by_2,
|
|
|
t_task.c_plan_completed_at ,
|
|
|
t_task.id as task_id,
|
|
|
t_task.alias ,
|
...
|
...
|
@@ -630,6 +643,7 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
|
t_task."level",
|
|
|
t_task.level_name ,
|
|
|
t_task.anomaly ,
|
|
|
t_task.warn_flag ,
|
|
|
t_task.current_stage,
|
|
|
t_task.last_stage,
|
|
|
t_task.status ,
|
...
|
...
|
@@ -642,7 +656,7 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
|
)select *
|
|
|
from tt_task_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.anomaly desc,
|
|
|
tt_task_1.sort_by,tt_task_1."created_at"
|
|
|
limit ? offset ?
|
|
|
`
|
...
|
...
|
@@ -789,27 +803,92 @@ and (task.leader ->>'id' in(?) or task.related_user @>?) |
|
|
return result, err
|
|
|
}
|
|
|
|
|
|
// 按照 任务的相关人员(related_user),排除 既是相关人员,又是任务负责人的情况, 获取出现异常的任务
|
|
|
// func (d *TaskDao) TaskIsAnomalyByRelatedUser(relatedUserId int) ([]TaskData6, error) {
|
|
|
// sqlStr := `select
|
|
|
// task.id as task_id,
|
|
|
// task."name" as task_name ,
|
|
|
// task.alias as task_alias,
|
|
|
// task.leader ->>'id' as leader_id,
|
|
|
// task.leader ->>'name' as leader_name,
|
|
|
// task.assist_flag ,
|
|
|
// task.warn_flag ,
|
|
|
// task.anomaly
|
|
|
// from task where 1=1
|
|
|
// and task.deleted_at isnull
|
|
|
// and (task.assist_flag+task.warn_flag +task.anomaly)>0
|
|
|
// and task.related_user @>?
|
|
|
// and task.leader ->>'id' <> ?
|
|
|
// `
|
|
|
// relatedUser := fmt.Sprintf("[%d]", relatedUserId)
|
|
|
// condition := []interface{}{relatedUser, strconv.Itoa(relatedUserId)}
|
|
|
// result := []TaskData6{}
|
|
|
// tx := d.transactionContext.PgTx
|
|
|
// _, err := tx.Query(&result, sqlStr, condition...)
|
|
|
// return result, err
|
|
|
// } |
|
|
// 员工绩效-任务列表 查询任务列表
|
|
|
// userid 谁要查看任务数据
|
|
|
// limit 分页
|
|
|
// offset 分页
|
|
|
func (d *TaskDao) ListTaskByHrbpV3(param ListTaskCondition) ([]ListTask, error) {
|
|
|
sqlStr := `
|
|
|
with
|
|
|
t_task_ignore as (
|
|
|
select task_ignore.task_id,task_ignore.id from task_ignore where task_ignore.user_id =?
|
|
|
),
|
|
|
t_task as (
|
|
|
select
|
|
|
cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int) as c_plan_completed_at,
|
|
|
cast(COALESCE(task.current_stage ->>'realCompletedAt','0') as int) as c_real_completed_at,
|
|
|
floor(extract(epoch from now())) as now_time,
|
|
|
task.id ,
|
|
|
task.alias ,
|
|
|
task.leader ->>'name' as leader_name,
|
|
|
task.leader ->>'id' as leader_id,
|
|
|
task."level",
|
|
|
task.level_name ,
|
|
|
task.anomaly ,
|
|
|
task.warn_flag ,
|
|
|
task.status ,
|
|
|
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
|
|
|
where 1=1 and t_task_ignore.id isnull and task.company_id=?
|
|
|
and task.deleted_at isnull
|
|
|
%s
|
|
|
),
|
|
|
t_task_1 as (
|
|
|
select
|
|
|
(case
|
|
|
when t_task.c_plan_completed_at=0 then 0
|
|
|
when t_task.c_plan_completed_at-now_time>0 then 0
|
|
|
else t_task.c_plan_completed_at-now_time
|
|
|
end) as sort_by_1,
|
|
|
t_task.c_plan_completed_at ,
|
|
|
t_task.id as task_id,
|
|
|
t_task.alias ,
|
|
|
t_task.leader_name,
|
|
|
t_task.leader_id,
|
|
|
t_task."level",
|
|
|
t_task.level_name ,
|
|
|
t_task.anomaly ,
|
|
|
t_task.warn_flag ,
|
|
|
t_task.status ,
|
|
|
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.status, t_task_1.sort_by_1,
|
|
|
t_task_1.anomaly desc,
|
|
|
t_task_1.sort_by,t_task_1."created_at"
|
|
|
limit ? offset ?
|
|
|
`
|
|
|
condition := []interface{}{param.UserId, 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 = ? `
|
|
|
}
|
|
|
strSql2 := fmt.Sprintf(sqlStr, whereSql)
|
|
|
condition = append(condition, param.Limit, param.Offset)
|
|
|
result := []ListTask{}
|
|
|
tx := d.transactionContext.PgTx
|
|
|
_, err := tx.Query(&result, strSql2, condition...)
|
|
|
return result, err
|
|
|
} |
...
|
...
|
|