|
@@ -63,11 +63,12 @@ func (d *TaskDao) catchTaskIdByPermission(userId int) string { |
|
@@ -63,11 +63,12 @@ func (d *TaskDao) catchTaskIdByPermission(userId int) string { |
63
|
}
|
63
|
}
|
64
|
|
64
|
|
65
|
type ListTaskCondition struct {
|
65
|
type ListTaskCondition struct {
|
66
|
- Limit int //分页
|
|
|
67
|
- Offset int //分页
|
|
|
68
|
- CompanyId int //公司id
|
|
|
69
|
- UserId int //谁要查看任务数据
|
|
|
70
|
- OnlyMy bool //只查看我负责的任务
|
66
|
+ Limit int //分页
|
|
|
67
|
+ Offset int //分页
|
|
|
68
|
+ CompanyId int //公司id
|
|
|
69
|
+ UserId int //谁要查看任务数据
|
|
|
70
|
+ OnlyMy bool //只查看我负责的任务
|
|
|
71
|
+ LevelName string //任务类型名称
|
71
|
SearchWord string
|
72
|
SearchWord string
|
72
|
}
|
73
|
}
|
73
|
|
74
|
|
|
@@ -108,7 +109,10 @@ func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) { |
|
@@ -108,7 +109,10 @@ func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) { |
108
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
109
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
109
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
110
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
110
|
}
|
111
|
}
|
111
|
-
|
112
|
+ if len(param.LevelName) > 0 {
|
|
|
113
|
+ condition = append(condition, param.LevelName)
|
|
|
114
|
+ whereSql += ` and task.level_name = ? `
|
|
|
115
|
+ }
|
112
|
sqlStr := withSql + whereSql
|
116
|
sqlStr := withSql + whereSql
|
113
|
tx := d.transactionContext.PgTx
|
117
|
tx := d.transactionContext.PgTx
|
114
|
var cnt int
|
118
|
var cnt int
|
|
@@ -135,6 +139,10 @@ func (d *TaskDao) CountTaskByHrbp(param ListTaskCondition) (int, error) { |
|
@@ -135,6 +139,10 @@ func (d *TaskDao) CountTaskByHrbp(param ListTaskCondition) (int, error) { |
135
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
139
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
136
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
140
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
137
|
}
|
141
|
}
|
|
|
142
|
+ if len(param.LevelName) > 0 {
|
|
|
143
|
+ condition = append(condition, param.LevelName)
|
|
|
144
|
+ whereSql += ` and task.level_name = ? `
|
|
|
145
|
+ }
|
138
|
sqlStr := withSql + whereSql
|
146
|
sqlStr := withSql + whereSql
|
139
|
tx := d.transactionContext.PgTx
|
147
|
tx := d.transactionContext.PgTx
|
140
|
var cnt int
|
148
|
var cnt int
|
|
@@ -167,6 +175,10 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er |
|
@@ -167,6 +175,10 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er |
167
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
175
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
168
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
176
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
169
|
}
|
177
|
}
|
|
|
178
|
+ if len(param.LevelName) > 0 {
|
|
|
179
|
+ condition = append(condition, param.LevelName)
|
|
|
180
|
+ whereSql += ` and task.level_name = ? `
|
|
|
181
|
+ }
|
170
|
sqlStr := withSql + whereSql
|
182
|
sqlStr := withSql + whereSql
|
171
|
tx := d.transactionContext.PgTx
|
183
|
tx := d.transactionContext.PgTx
|
172
|
var cnt int
|
184
|
var cnt int
|
|
@@ -201,6 +213,10 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err |
|
@@ -201,6 +213,10 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err |
201
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
213
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
202
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
214
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
203
|
}
|
215
|
}
|
|
|
216
|
+ if len(param.LevelName) > 0 {
|
|
|
217
|
+ condition = append(condition, param.LevelName)
|
|
|
218
|
+ whereSql += ` and task.level_name = ? `
|
|
|
219
|
+ }
|
204
|
|
220
|
|
205
|
sqlStr := withSql + whereSql
|
221
|
sqlStr := withSql + whereSql
|
206
|
tx := d.transactionContext.PgTx
|
222
|
tx := d.transactionContext.PgTx
|
|
@@ -302,6 +318,10 @@ func (d *TaskDao) CountTaskAnomalyNotHrbp(param ListTaskCondition) (int, error) |
|
@@ -302,6 +318,10 @@ func (d *TaskDao) CountTaskAnomalyNotHrbp(param ListTaskCondition) (int, error) |
302
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
318
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
303
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
319
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
304
|
}
|
320
|
}
|
|
|
321
|
+ if len(param.LevelName) > 0 {
|
|
|
322
|
+ condition = append(condition, param.LevelName)
|
|
|
323
|
+ whereSql += ` and task.level_name = ? `
|
|
|
324
|
+ }
|
305
|
sqlStr := withSql + whereSql
|
325
|
sqlStr := withSql + whereSql
|
306
|
tx := d.transactionContext.PgTx
|
326
|
tx := d.transactionContext.PgTx
|
307
|
var cnt int
|
327
|
var cnt int
|
|
@@ -326,7 +346,11 @@ func (d *TaskDao) CountTaskAnomalyByHrbp(param ListTaskCondition) (int, error) { |
|
@@ -326,7 +346,11 @@ func (d *TaskDao) CountTaskAnomalyByHrbp(param ListTaskCondition) (int, error) { |
326
|
}
|
346
|
}
|
327
|
if param.SearchWord != "" {
|
347
|
if param.SearchWord != "" {
|
328
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
348
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
329
|
- whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
349
|
+ whereSql += ` and (task.leader->>'name' like ? or task.alias like ?) `
|
|
|
350
|
+ }
|
|
|
351
|
+ if len(param.LevelName) > 0 {
|
|
|
352
|
+ condition = append(condition, param.LevelName)
|
|
|
353
|
+ whereSql += ` and task.level_name = ? `
|
330
|
}
|
354
|
}
|
331
|
sqlStr := withSql + whereSql
|
355
|
sqlStr := withSql + whereSql
|
332
|
tx := d.transactionContext.PgTx
|
356
|
tx := d.transactionContext.PgTx
|
|
@@ -453,6 +477,8 @@ type ListTask struct { |
|
@@ -453,6 +477,8 @@ type ListTask struct { |
453
|
CreatedAt time.Time `pg:"created_at"`
|
477
|
CreatedAt time.Time `pg:"created_at"`
|
454
|
CurrentStage domain.TaskStage `pg:"current_stage"` // 当前执行的里程碑
|
478
|
CurrentStage domain.TaskStage `pg:"current_stage"` // 当前执行的里程碑
|
455
|
LastStage domain.TaskStage `pg:"last_stage"` // 上一个完成的里程碑
|
479
|
LastStage domain.TaskStage `pg:"last_stage"` // 上一个完成的里程碑
|
|
|
480
|
+ SortBy int `pg:"sort_by"`
|
|
|
481
|
+ EndTime int `pg:"end_time"`
|
456
|
}
|
482
|
}
|
457
|
|
483
|
|
458
|
// (新)获取任务,用于页面展示; 无过滤查看权限
|
484
|
// (新)获取任务,用于页面展示; 无过滤查看权限
|
|
@@ -481,6 +507,8 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
@@ -481,6 +507,8 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
481
|
task.updated_at,
|
507
|
task.updated_at,
|
482
|
task.current_stage,
|
508
|
task.current_stage,
|
483
|
task.last_stage,
|
509
|
task.last_stage,
|
|
|
510
|
+ task.sort_by,
|
|
|
511
|
+ task.end_time,
|
484
|
task.created_at
|
512
|
task.created_at
|
485
|
from task
|
513
|
from task
|
486
|
left join t_task_ignore on t_task_ignore.task_id=task.id
|
514
|
left join t_task_ignore on t_task_ignore.task_id=task.id
|
|
@@ -511,14 +539,16 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
@@ -511,14 +539,16 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
511
|
t_task.updated_at ,
|
539
|
t_task.updated_at ,
|
512
|
t_task.current_stage,
|
540
|
t_task.current_stage,
|
513
|
t_task.last_stage,
|
541
|
t_task.last_stage,
|
|
|
542
|
+ t_task.sort_by,
|
|
|
543
|
+ t_task.end_time,
|
514
|
t_task.created_at
|
544
|
t_task.created_at
|
515
|
from t_task
|
545
|
from t_task
|
516
|
where 1=1
|
546
|
where 1=1
|
517
|
)select *
|
547
|
)select *
|
518
|
from t_task_1
|
548
|
from t_task_1
|
519
|
- order by t_task_1.sort_by_1,
|
549
|
+ order by t_task_1.status, t_task_1.sort_by_1,
|
520
|
t_task_1.sort_by_2,t_task_1.anomaly desc,
|
550
|
t_task_1.sort_by_2,t_task_1.anomaly desc,
|
521
|
- t_task_1."level",t_task_1."created_at"
|
551
|
+ t_task_1.sort_by,t_task_1."created_at"
|
522
|
limit ? offset ?
|
552
|
limit ? offset ?
|
523
|
`
|
553
|
`
|
524
|
condition := []interface{}{param.UserId, param.CompanyId}
|
554
|
condition := []interface{}{param.UserId, param.CompanyId}
|
|
@@ -531,6 +561,10 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
@@ -531,6 +561,10 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
531
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
561
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
532
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
562
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
533
|
}
|
563
|
}
|
|
|
564
|
+ if len(param.LevelName) > 0 {
|
|
|
565
|
+ condition = append(condition, param.LevelName)
|
|
|
566
|
+ whereSql += ` and task.level_name = ? `
|
|
|
567
|
+ }
|
534
|
strSql2 := fmt.Sprintf(sqlStr, whereSql)
|
568
|
strSql2 := fmt.Sprintf(sqlStr, whereSql)
|
535
|
condition = append(condition, param.Limit, param.Offset)
|
569
|
condition = append(condition, param.Limit, param.Offset)
|
536
|
result := []ListTask{}
|
570
|
result := []ListTask{}
|
|
@@ -558,6 +592,8 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
@@ -558,6 +592,8 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
558
|
task.last_stage,
|
592
|
task.last_stage,
|
559
|
task.status ,
|
593
|
task.status ,
|
560
|
task.updated_at,
|
594
|
task.updated_at,
|
|
|
595
|
+ task.sort_by,
|
|
|
596
|
+ task.end_time,
|
561
|
task.created_at
|
597
|
task.created_at
|
562
|
from task
|
598
|
from task
|
563
|
join t_task_1 on t_task_1.id=task.id
|
599
|
join t_task_1 on t_task_1.id=task.id
|
|
@@ -587,14 +623,16 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
@@ -587,14 +623,16 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
587
|
t_task.last_stage,
|
623
|
t_task.last_stage,
|
588
|
t_task.status ,
|
624
|
t_task.status ,
|
589
|
t_task.updated_at ,
|
625
|
t_task.updated_at ,
|
|
|
626
|
+ t_task.sort_by,
|
|
|
627
|
+ t_task.end_time,
|
590
|
t_task.created_at
|
628
|
t_task.created_at
|
591
|
from t_task
|
629
|
from t_task
|
592
|
where 1=1
|
630
|
where 1=1
|
593
|
)select *
|
631
|
)select *
|
594
|
from tt_task_1
|
632
|
from tt_task_1
|
595
|
- order by tt_task_1.sort_by_1,
|
633
|
+ order by tt_task_1.status,tt_task_1.sort_by_1,
|
596
|
tt_task_1.sort_by_2,tt_task_1.anomaly desc,
|
634
|
tt_task_1.sort_by_2,tt_task_1.anomaly desc,
|
597
|
- tt_task_1."level",tt_task_1."created_at"
|
635
|
+ tt_task_1.sort_by,tt_task_1."created_at"
|
598
|
limit ? offset ?
|
636
|
limit ? offset ?
|
599
|
`
|
637
|
`
|
600
|
condition := []interface{}{param.CompanyId}
|
638
|
condition := []interface{}{param.CompanyId}
|
|
@@ -607,6 +645,10 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
@@ -607,6 +645,10 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
607
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
645
|
condition = append(condition, param.SearchWord, param.SearchWord)
|
608
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
646
|
whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
609
|
}
|
647
|
}
|
|
|
648
|
+ if len(param.LevelName) > 0 {
|
|
|
649
|
+ condition = append(condition, param.LevelName)
|
|
|
650
|
+ whereSql += ` and task.level_name = ? `
|
|
|
651
|
+ }
|
610
|
strSql2 := fmt.Sprintf(strSql, whereSql)
|
652
|
strSql2 := fmt.Sprintf(strSql, whereSql)
|
611
|
condition = append(condition, param.Limit, param.Offset)
|
653
|
condition = append(condition, param.Limit, param.Offset)
|
612
|
result := []ListTask{}
|
654
|
result := []ListTask{}
|
|
@@ -614,3 +656,84 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
@@ -614,3 +656,84 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
614
|
_, err := tx.Query(&result, strSql2, condition...)
|
656
|
_, err := tx.Query(&result, strSql2, condition...)
|
615
|
return result, err
|
657
|
return result, err
|
616
|
}
|
658
|
}
|
|
|
659
|
+
|
|
|
660
|
+// 获取已取消关注的任务列表
|
|
|
661
|
+func (d *TaskDao) ListTaskIgnore(param ListTaskCondition) ([]ListTask, error) {
|
|
|
662
|
+ sqlStr := `with
|
|
|
663
|
+ t_task_ignore as(
|
|
|
664
|
+ select task_ignore.task_id
|
|
|
665
|
+ from task_ignore
|
|
|
666
|
+ where user_id =3252522494124032
|
|
|
667
|
+ )select
|
|
|
668
|
+ task.id as task_id ,
|
|
|
669
|
+ task.alias ,
|
|
|
670
|
+ task.leader ->>'name' as leader_name,
|
|
|
671
|
+ task."level" ,
|
|
|
672
|
+ task.level_name ,
|
|
|
673
|
+ task.anomaly ,
|
|
|
674
|
+ task.status ,
|
|
|
675
|
+ task.updated_at ,
|
|
|
676
|
+ task.created_at ,
|
|
|
677
|
+ task.current_stage ,
|
|
|
678
|
+ task.last_stage ,
|
|
|
679
|
+ task.sort_by ,
|
|
|
680
|
+ task.end_time
|
|
|
681
|
+ from task
|
|
|
682
|
+ join t_task_ignore on t_task_ignore.task_id=task.id
|
|
|
683
|
+ where 1=1 and task.company_id=? and task.deleted_at isnull `
|
|
|
684
|
+ condition := []interface{}{param.CompanyId}
|
|
|
685
|
+ whereSql := ``
|
|
|
686
|
+ if param.OnlyMy {
|
|
|
687
|
+ condition = append(condition, param.UserId)
|
|
|
688
|
+ whereSql += ` and task.leader ->>'id' = '?' `
|
|
|
689
|
+ }
|
|
|
690
|
+ if param.SearchWord != "" {
|
|
|
691
|
+ condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
692
|
+ whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
693
|
+ }
|
|
|
694
|
+ if len(param.LevelName) > 0 {
|
|
|
695
|
+ condition = append(condition, param.LevelName)
|
|
|
696
|
+ whereSql += ` and task.level_name = ? `
|
|
|
697
|
+ }
|
|
|
698
|
+ condition = append(condition, param.Limit, param.Offset)
|
|
|
699
|
+ sqlStr = sqlStr + whereSql + ` limit ? offset ? `
|
|
|
700
|
+
|
|
|
701
|
+ result := []ListTask{}
|
|
|
702
|
+ tx := d.transactionContext.PgTx
|
|
|
703
|
+ _, err := tx.Query(&result, sqlStr, condition...)
|
|
|
704
|
+ return result, err
|
|
|
705
|
+}
|
|
|
706
|
+
|
|
|
707
|
+func (d *TaskDao) CountTaskIgnore(param ListTaskCondition) (int, error) {
|
|
|
708
|
+ sqlStr := `with
|
|
|
709
|
+ t_task_ignore as(
|
|
|
710
|
+ select task_ignore.task_id
|
|
|
711
|
+ from task_ignore
|
|
|
712
|
+ where user_id =3252522494124032
|
|
|
713
|
+ )select
|
|
|
714
|
+ count(*) as cnt
|
|
|
715
|
+ from task
|
|
|
716
|
+ join t_task_ignore on t_task_ignore.task_id=task.id
|
|
|
717
|
+ where 1=1 and task.company_id=? and task.deleted_at isnull `
|
|
|
718
|
+ condition := []interface{}{param.CompanyId}
|
|
|
719
|
+ whereSql := ``
|
|
|
720
|
+ if param.OnlyMy {
|
|
|
721
|
+ condition = append(condition, param.UserId)
|
|
|
722
|
+ whereSql += ` and task.leader ->>'id' = '?' `
|
|
|
723
|
+ }
|
|
|
724
|
+ if param.SearchWord != "" {
|
|
|
725
|
+ condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
726
|
+ whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
727
|
+ }
|
|
|
728
|
+ if len(param.LevelName) > 0 {
|
|
|
729
|
+ condition = append(condition, param.LevelName)
|
|
|
730
|
+ whereSql += ` and task.level_name = ? `
|
|
|
731
|
+ }
|
|
|
732
|
+ condition = append(condition, param.Limit, param.Offset)
|
|
|
733
|
+ sqlStr = sqlStr + whereSql + ` limit ? offset ? `
|
|
|
734
|
+
|
|
|
735
|
+ result := 0
|
|
|
736
|
+ tx := d.transactionContext.PgTx
|
|
|
737
|
+ _, err := tx.Query(pg.Scan(&result), sqlStr, condition...)
|
|
|
738
|
+ return result, err
|
|
|
739
|
+} |