作者 tangxvhui

更新

... ... @@ -628,20 +628,29 @@ func (srv TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]i
LeaderId: param.LeaderId,
}
taskDato := dao.NewTaskDao(map[string]interface{}{
taskDao := dao.NewTaskDao(map[string]interface{}{
"transactionContext": transactionContext,
})
tasklistData, err := taskDato.ListTaskStageNotHrbp(condition)
tasklistData, err := taskDao.ListTaskStageNotHrbp(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
}
taskCount, err := taskDato.CountTaskStageNotHrbp(condition)
taskCount, err := taskDao.CountTaskStageNotHrbp(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
}
taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyNotHrbp(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
}
taskAnomalyCnt, err := taskDao.CountTaskAnomalyNotHrbp(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
taskResult := []*adapter.TaskItem{}
taskMapResult := map[int]*adapter.TaskItem{}
for _, val := range tasklistData {
... ... @@ -690,6 +699,8 @@ func (srv TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]i
}
}
result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
result["taskStageAnomaly"] = taskStageAnomalyCnt
result["taskAnomalyCnt"] = taskAnomalyCnt
return result, nil
}
... ... @@ -723,17 +734,25 @@ func (srv TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[s
defer func() {
_ = transactionContext.RollbackTransaction()
}()
taskDato := dao.NewTaskDao(map[string]interface{}{
taskDao := dao.NewTaskDao(map[string]interface{}{
"transactionContext": transactionContext,
})
tasklistData, err := taskDato.ListTaskStageByHrbp(condition)
tasklistData, err := taskDao.ListTaskStageByHrbp(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
}
taskCount, err := taskDato.CountTaskStageByHrbp(condition)
taskCount, err := taskDao.CountTaskStageByHrbp(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
}
taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyByHrbp(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
}
taskAnomalyCnt, err := taskDao.CountTaskAnomalyByHrbp(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -785,6 +804,8 @@ func (srv TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[s
}
}
result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
result["taskStageAnomaly"] = taskStageAnomalyCnt
result["taskAnomalyCnt"] = taskAnomalyCnt
return result, nil
}
... ...
... ... @@ -276,7 +276,7 @@ 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{}{}
condition := []interface{}{param.UserId}
whereSql := ``
if param.OnlyMy {
condition = append(condition, param.UserId)
... ... @@ -310,7 +310,7 @@ func (d *TaskDao) CountTaskStageByHrbp(param ListTaskCondition) (int, error) {
)select count(*) from task
left join t_task_ignore on t_task_ignore.task_id=task.id
where 1=1 `
condition := []interface{}{}
condition := []interface{}{param.UserId}
whereSql := ``
if param.OnlyMy {
condition = append(condition, param.UserId)
... ... @@ -386,7 +386,7 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err
or
(task_stage.real_completed_at=0 and task_stage.plan_completed_at<extract(epoch from now()))
) `
condition := []interface{}{}
condition := []interface{}{param.UserId}
whereSql := ``
if param.OnlyMy {
condition = append(condition, param.UserId)
... ... @@ -456,3 +456,68 @@ func (d *TaskDao) TaskAnomaly(leaderId []string, anomaly int) ([]TaskStageData,
_, err := tx.Query(&result, sqlStr, anomaly, pg.In(leaderId))
return result, err
}
// 统计任务异常的数量,以非hrbp角色统计
func (d *TaskDao) CountTaskAnomalyNotHrbp(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.anomaly>1 `
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) CountTaskAnomalyByHrbp(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.anomaly>1 `
condition := []interface{}{param.UserId}
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
}
... ...