|
@@ -333,3 +333,79 @@ func (d *TaskDao) CountTaskStageByHrbp(param ListTaskCondition) (int, error) { |
|
@@ -333,3 +333,79 @@ func (d *TaskDao) CountTaskStageByHrbp(param ListTaskCondition) (int, error) { |
333
|
_, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
|
333
|
_, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
|
334
|
return cnt, err
|
334
|
return cnt, err
|
335
|
}
|
335
|
}
|
|
|
336
|
+
|
|
|
337
|
+// 统计里程碑异常的数量,以非hrbp角色统计
|
|
|
338
|
+func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, error) {
|
|
|
339
|
+ task1 := d.catchTaskIdByPermission(param.UserId)
|
|
|
340
|
+ withSql := task1 + ` select count(*)
|
|
|
341
|
+ from task_stage
|
|
|
342
|
+ join task on task_stage.task_id =task.id
|
|
|
343
|
+ join t_task_1 on task.id =t_task_1.id
|
|
|
344
|
+ where 1=1
|
|
|
345
|
+ and(
|
|
|
346
|
+ (task_stage.plan_completed_at <task_stage.real_completed_at)
|
|
|
347
|
+ or
|
|
|
348
|
+ (task_stage.real_completed_at=0 and task_stage.plan_completed_at<extract(epoch from now()))
|
|
|
349
|
+ ) `
|
|
|
350
|
+ condition := []interface{}{}
|
|
|
351
|
+ whereSql := ``
|
|
|
352
|
+ if param.OnlyMy {
|
|
|
353
|
+ condition = append(condition, param.UserId)
|
|
|
354
|
+ whereSql += ` and task.leader ->>'id' = '?' `
|
|
|
355
|
+ } else if param.LeaderId != "" {
|
|
|
356
|
+ condition = append(condition, param.LeaderId)
|
|
|
357
|
+ whereSql += ` and task.leader ->>'id' = ? `
|
|
|
358
|
+ }
|
|
|
359
|
+ if len(param.TaskName) > 0 {
|
|
|
360
|
+ condition = append(condition, param.TaskName)
|
|
|
361
|
+ whereSql += ` and task.name like ? `
|
|
|
362
|
+ }
|
|
|
363
|
+ if len(param.LevelName) > 0 {
|
|
|
364
|
+ condition = append(condition, param.LevelName)
|
|
|
365
|
+ whereSql += ` and task.level_name like ? `
|
|
|
366
|
+ }
|
|
|
367
|
+ sqlStr := withSql + whereSql
|
|
|
368
|
+ tx := d.transactionContext.PgTx
|
|
|
369
|
+ var cnt int
|
|
|
370
|
+ _, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
|
|
|
371
|
+ return cnt, err
|
|
|
372
|
+}
|
|
|
373
|
+
|
|
|
374
|
+// 统计里程碑异常的数量,以hrbp角色统计
|
|
|
375
|
+func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, error) {
|
|
|
376
|
+ withSql := `with
|
|
|
377
|
+ t_task_ignore as (
|
|
|
378
|
+ select task_ignore.task_id,task_ignore.id from task_ignore where task_ignore.user_id =?
|
|
|
379
|
+ )select count(*)
|
|
|
380
|
+ from task_stage
|
|
|
381
|
+ join task on task_stage.task_id =task.id
|
|
|
382
|
+ left join t_task_ignore on t_task_ignore.task_id=task.id
|
|
|
383
|
+ where 1=1
|
|
|
384
|
+ and(
|
|
|
385
|
+ (task_stage.plan_completed_at <task_stage.real_completed_at)
|
|
|
386
|
+ or
|
|
|
387
|
+ (task_stage.real_completed_at=0 and task_stage.plan_completed_at<extract(epoch from now()))
|
|
|
388
|
+ ) `
|
|
|
389
|
+ condition := []interface{}{}
|
|
|
390
|
+ whereSql := ``
|
|
|
391
|
+ if param.OnlyMy {
|
|
|
392
|
+ condition = append(condition, param.UserId)
|
|
|
393
|
+ whereSql += ` and task.leader ->>'id' = '?' `
|
|
|
394
|
+ } else if param.LeaderId != "" {
|
|
|
395
|
+ condition = append(condition, param.LeaderId)
|
|
|
396
|
+ whereSql += ` and task.leader ->>'id' = ? `
|
|
|
397
|
+ }
|
|
|
398
|
+ if len(param.TaskName) > 0 {
|
|
|
399
|
+ condition = append(condition, param.TaskName)
|
|
|
400
|
+ whereSql += ` and task.name like ? `
|
|
|
401
|
+ }
|
|
|
402
|
+ if len(param.LevelName) > 0 {
|
|
|
403
|
+ condition = append(condition, param.LevelName)
|
|
|
404
|
+ whereSql += ` and task.level_name like ? `
|
|
|
405
|
+ }
|
|
|
406
|
+ sqlStr := withSql + whereSql
|
|
|
407
|
+ tx := d.transactionContext.PgTx
|
|
|
408
|
+ var cnt int
|
|
|
409
|
+ _, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
|
|
|
410
|
+ return cnt, err
|
|
|
411
|
+} |