作者 tangxvhui

日常保存

... ... @@ -694,6 +694,7 @@ func (srv TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]i
}
// 以hrbp角色权限获取任务列表
// TODO 统计里程碑异常数,反馈异常数
func (srv TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[string]interface{}, error) {
var limit = 20
var offset = 0
... ...
... ... @@ -333,3 +333,79 @@ func (d *TaskDao) CountTaskStageByHrbp(param ListTaskCondition) (int, error) {
_, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
return cnt, err
}
// 统计里程碑异常的数量,以非hrbp角色统计
func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, error) {
task1 := d.catchTaskIdByPermission(param.UserId)
withSql := task1 + ` select count(*)
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
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{}{}
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 ? `
}
sqlStr := withSql + whereSql
tx := d.transactionContext.PgTx
var cnt int
_, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
return cnt, err
}
// 统计里程碑异常的数量,以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_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
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{}{}
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 ? `
}
sqlStr := withSql + whereSql
tx := d.transactionContext.PgTx
var cnt int
_, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
return cnt, err
}
... ...