|
@@ -153,20 +153,29 @@ func (d *TaskDao) CountTaskByHrbp(param ListTaskCondition) (int, error) { |
|
@@ -153,20 +153,29 @@ func (d *TaskDao) CountTaskByHrbp(param ListTaskCondition) (int, error) { |
153
|
// 统计里程碑异常的数量,以非hrbp角色统计
|
153
|
// 统计里程碑异常的数量,以非hrbp角色统计
|
154
|
func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, error) {
|
154
|
func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, error) {
|
155
|
task1 := d.catchTaskIdByPermission(param.UserId)
|
155
|
task1 := d.catchTaskIdByPermission(param.UserId)
|
|
|
156
|
+ // withSql := task1 + ` select count(*)
|
|
|
157
|
+ // from task
|
|
|
158
|
+ // join t_task_1 on task.id =t_task_1.id
|
|
|
159
|
+ // where 1=1
|
|
|
160
|
+ // and task.company_id =?
|
|
|
161
|
+ // and task.deleted_at isnull
|
|
|
162
|
+ // and (
|
|
|
163
|
+ // (
|
|
|
164
|
+ // cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)>0 and
|
|
|
165
|
+ // cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)<floor(extract(epoch from now()))
|
|
|
166
|
+ // )
|
|
|
167
|
+ // or
|
|
|
168
|
+ // task.warn_flag = 1
|
|
|
169
|
+ // )
|
|
|
170
|
+ // `
|
156
|
withSql := task1 + ` select count(*)
|
171
|
withSql := task1 + ` select count(*)
|
157
|
from task
|
172
|
from task
|
158
|
join t_task_1 on task.id =t_task_1.id
|
173
|
join t_task_1 on task.id =t_task_1.id
|
159
|
where 1=1
|
174
|
where 1=1
|
160
|
and task.company_id =?
|
175
|
and task.company_id =?
|
161
|
and task.deleted_at isnull
|
176
|
and task.deleted_at isnull
|
162
|
- and (
|
|
|
163
|
- (
|
|
|
164
|
- cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)>0 and
|
|
|
165
|
- cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)<floor(extract(epoch from now()))
|
|
|
166
|
- )
|
|
|
167
|
- or
|
|
|
168
|
- task.warn_flag = 1
|
|
|
169
|
- )
|
177
|
+ and task.warn_flag >0
|
|
|
178
|
+
|
170
|
`
|
179
|
`
|
171
|
condition := []interface{}{param.CompanyId}
|
180
|
condition := []interface{}{param.CompanyId}
|
172
|
whereSql := ``
|
181
|
whereSql := ``
|
|
@@ -191,6 +200,24 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er |
|
@@ -191,6 +200,24 @@ func (d *TaskDao) CountTaskStageAnomalyNotHrbp(param ListTaskCondition) (int, er |
191
|
|
200
|
|
192
|
// 统计里程碑异常的数量,以hrbp角色统计
|
201
|
// 统计里程碑异常的数量,以hrbp角色统计
|
193
|
func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, error) {
|
202
|
func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, error) {
|
|
|
203
|
+ // withSql := `with
|
|
|
204
|
+ // t_task_ignore as (
|
|
|
205
|
+ // select task_ignore.task_id,task_ignore.id from task_ignore where task_ignore.user_id =?
|
|
|
206
|
+ // )select count(*)
|
|
|
207
|
+ // from task
|
|
|
208
|
+ // left join t_task_ignore on t_task_ignore.task_id=task.id
|
|
|
209
|
+ // where 1=1
|
|
|
210
|
+ // and task.company_id =?
|
|
|
211
|
+ // and task.deleted_at isnull
|
|
|
212
|
+ // and t_task_ignore.id isnull
|
|
|
213
|
+ // and (
|
|
|
214
|
+ // (
|
|
|
215
|
+ // cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)>0 and
|
|
|
216
|
+ // cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)<floor(extract(epoch from now()))
|
|
|
217
|
+ // )
|
|
|
218
|
+ // or
|
|
|
219
|
+ // task.warn_flag = 1
|
|
|
220
|
+ // )`
|
194
|
withSql := `with
|
221
|
withSql := `with
|
195
|
t_task_ignore as (
|
222
|
t_task_ignore as (
|
196
|
select task_ignore.task_id,task_ignore.id from task_ignore where task_ignore.user_id =?
|
223
|
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 |
|
@@ -201,14 +228,7 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err |
201
|
and task.company_id =?
|
228
|
and task.company_id =?
|
202
|
and task.deleted_at isnull
|
229
|
and task.deleted_at isnull
|
203
|
and t_task_ignore.id isnull
|
230
|
and t_task_ignore.id isnull
|
204
|
- and (
|
|
|
205
|
- (
|
|
|
206
|
- cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)>0 and
|
|
|
207
|
- cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int)<floor(extract(epoch from now()))
|
|
|
208
|
- )
|
|
|
209
|
- or
|
|
|
210
|
- task.warn_flag = 1
|
|
|
211
|
- )`
|
231
|
+ and task.warn_flag > 0 `
|
212
|
condition := []interface{}{param.UserId, param.CompanyId}
|
232
|
condition := []interface{}{param.UserId, param.CompanyId}
|
213
|
whereSql := ``
|
233
|
whereSql := ``
|
214
|
if param.OnlyMy {
|
234
|
if param.OnlyMy {
|
|
@@ -471,7 +491,6 @@ and task.anomaly>0 ` |
|
@@ -471,7 +491,6 @@ and task.anomaly>0 ` |
471
|
type ListTask struct {
|
491
|
type ListTask struct {
|
472
|
SortBy1 int `pg:"sort_by_1"`
|
492
|
SortBy1 int `pg:"sort_by_1"`
|
473
|
CPlanCompletedAt int `pg:"c_plan_completed_at"`
|
493
|
CPlanCompletedAt int `pg:"c_plan_completed_at"`
|
474
|
- SortBy2 int `pg:"sort_by_2"`
|
|
|
475
|
TaskId int `pg:"task_id"`
|
494
|
TaskId int `pg:"task_id"`
|
476
|
Alias string `pg:"alias"`
|
495
|
Alias string `pg:"alias"`
|
477
|
LeaderName string `pg:"leader_name"`
|
496
|
LeaderName string `pg:"leader_name"`
|
|
@@ -479,6 +498,7 @@ type ListTask struct { |
|
@@ -479,6 +498,7 @@ type ListTask struct { |
479
|
Level int `pg:"level"`
|
498
|
Level int `pg:"level"`
|
480
|
LevelName string `pg:"level_name"`
|
499
|
LevelName string `pg:"level_name"`
|
481
|
Anomaly int `pg:"anomaly"`
|
500
|
Anomaly int `pg:"anomaly"`
|
|
|
501
|
+ WarnFlag int `pg:"warn_flag"`
|
482
|
Status int `pg:"status"`
|
502
|
Status int `pg:"status"`
|
483
|
UpdatedAt time.Time `pg:"updated_at"`
|
503
|
UpdatedAt time.Time `pg:"updated_at"`
|
484
|
CreatedAt time.Time `pg:"created_at"`
|
504
|
CreatedAt time.Time `pg:"created_at"`
|
|
@@ -511,6 +531,7 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
@@ -511,6 +531,7 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
511
|
task."level",
|
531
|
task."level",
|
512
|
task.level_name ,
|
532
|
task.level_name ,
|
513
|
task.anomaly ,
|
533
|
task.anomaly ,
|
|
|
534
|
+ task.warn_flag ,
|
514
|
task.status ,
|
535
|
task.status ,
|
515
|
task.updated_at,
|
536
|
task.updated_at,
|
516
|
task.current_stage,
|
537
|
task.current_stage,
|
|
@@ -531,11 +552,6 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
@@ -531,11 +552,6 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
531
|
when t_task.c_plan_completed_at-now_time>0 then 0
|
552
|
when t_task.c_plan_completed_at-now_time>0 then 0
|
532
|
else t_task.c_plan_completed_at-now_time
|
553
|
else t_task.c_plan_completed_at-now_time
|
533
|
end) as sort_by_1,
|
554
|
end) as sort_by_1,
|
534
|
- (case
|
|
|
535
|
- when t_task.l_plan_completed_at=0 then 0
|
|
|
536
|
- when t_task.l_plan_completed_at-t_task.l_real_completed_at>0 then 0
|
|
|
537
|
- else t_task.l_plan_completed_at-t_task.l_real_completed_at
|
|
|
538
|
- end) as sort_by_2,
|
|
|
539
|
t_task.c_plan_completed_at ,
|
555
|
t_task.c_plan_completed_at ,
|
540
|
t_task.id as task_id,
|
556
|
t_task.id as task_id,
|
541
|
t_task.alias ,
|
557
|
t_task.alias ,
|
|
@@ -544,6 +560,7 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
@@ -544,6 +560,7 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
544
|
t_task."level",
|
560
|
t_task."level",
|
545
|
t_task.level_name ,
|
561
|
t_task.level_name ,
|
546
|
t_task.anomaly ,
|
562
|
t_task.anomaly ,
|
|
|
563
|
+ t_task.warn_flag ,
|
547
|
t_task.status ,
|
564
|
t_task.status ,
|
548
|
t_task.updated_at ,
|
565
|
t_task.updated_at ,
|
549
|
t_task.current_stage,
|
566
|
t_task.current_stage,
|
|
@@ -556,7 +573,7 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
@@ -556,7 +573,7 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) |
556
|
)select *
|
573
|
)select *
|
557
|
from t_task_1
|
574
|
from t_task_1
|
558
|
order by t_task_1.status, t_task_1.sort_by_1,
|
575
|
order by t_task_1.status, t_task_1.sort_by_1,
|
559
|
- t_task_1.sort_by_2,t_task_1.anomaly desc,
|
576
|
+ t_task_1.anomaly desc,
|
560
|
t_task_1.sort_by,t_task_1."created_at"
|
577
|
t_task_1.sort_by,t_task_1."created_at"
|
561
|
limit ? offset ?
|
578
|
limit ? offset ?
|
562
|
`
|
579
|
`
|
|
@@ -598,6 +615,7 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
@@ -598,6 +615,7 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
598
|
task."level",
|
615
|
task."level",
|
599
|
task.level_name ,
|
616
|
task.level_name ,
|
600
|
task.anomaly ,
|
617
|
task.anomaly ,
|
|
|
618
|
+ task.warn_flag ,
|
601
|
task.current_stage,
|
619
|
task.current_stage,
|
602
|
task.last_stage,
|
620
|
task.last_stage,
|
603
|
task.status ,
|
621
|
task.status ,
|
|
@@ -617,11 +635,6 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
@@ -617,11 +635,6 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
617
|
when t_task.c_plan_completed_at-now_time>0 then 0
|
635
|
when t_task.c_plan_completed_at-now_time>0 then 0
|
618
|
else t_task.c_plan_completed_at-now_time
|
636
|
else t_task.c_plan_completed_at-now_time
|
619
|
end) as sort_by_1,
|
637
|
end) as sort_by_1,
|
620
|
- (case
|
|
|
621
|
- when t_task.l_plan_completed_at=0 then 0
|
|
|
622
|
- when t_task.l_plan_completed_at-t_task.l_real_completed_at>0 then 0
|
|
|
623
|
- else t_task.l_plan_completed_at-t_task.l_real_completed_at
|
|
|
624
|
- end) as sort_by_2,
|
|
|
625
|
t_task.c_plan_completed_at ,
|
638
|
t_task.c_plan_completed_at ,
|
626
|
t_task.id as task_id,
|
639
|
t_task.id as task_id,
|
627
|
t_task.alias ,
|
640
|
t_task.alias ,
|
|
@@ -630,6 +643,7 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
@@ -630,6 +643,7 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
630
|
t_task."level",
|
643
|
t_task."level",
|
631
|
t_task.level_name ,
|
644
|
t_task.level_name ,
|
632
|
t_task.anomaly ,
|
645
|
t_task.anomaly ,
|
|
|
646
|
+ t_task.warn_flag ,
|
633
|
t_task.current_stage,
|
647
|
t_task.current_stage,
|
634
|
t_task.last_stage,
|
648
|
t_task.last_stage,
|
635
|
t_task.status ,
|
649
|
t_task.status ,
|
|
@@ -642,7 +656,7 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
|
@@ -642,7 +656,7 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) |
642
|
)select *
|
656
|
)select *
|
643
|
from tt_task_1
|
657
|
from tt_task_1
|
644
|
order by tt_task_1.status,tt_task_1.sort_by_1,
|
658
|
order by tt_task_1.status,tt_task_1.sort_by_1,
|
645
|
- tt_task_1.sort_by_2,tt_task_1.anomaly desc,
|
659
|
+ tt_task_1.anomaly desc,
|
646
|
tt_task_1.sort_by,tt_task_1."created_at"
|
660
|
tt_task_1.sort_by,tt_task_1."created_at"
|
647
|
limit ? offset ?
|
661
|
limit ? offset ?
|
648
|
`
|
662
|
`
|
|
@@ -789,27 +803,92 @@ and (task.leader ->>'id' in(?) or task.related_user @>?) |
|
@@ -789,27 +803,92 @@ and (task.leader ->>'id' in(?) or task.related_user @>?) |
789
|
return result, err
|
803
|
return result, err
|
790
|
}
|
804
|
}
|
791
|
|
805
|
|
792
|
-// 按照 任务的相关人员(related_user),排除 既是相关人员,又是任务负责人的情况, 获取出现异常的任务
|
|
|
793
|
-// func (d *TaskDao) TaskIsAnomalyByRelatedUser(relatedUserId int) ([]TaskData6, error) {
|
|
|
794
|
-// sqlStr := `select
|
|
|
795
|
-// task.id as task_id,
|
|
|
796
|
-// task."name" as task_name ,
|
|
|
797
|
-// task.alias as task_alias,
|
|
|
798
|
-// task.leader ->>'id' as leader_id,
|
|
|
799
|
-// task.leader ->>'name' as leader_name,
|
|
|
800
|
-// task.assist_flag ,
|
|
|
801
|
-// task.warn_flag ,
|
|
|
802
|
-// task.anomaly
|
|
|
803
|
-// from task where 1=1
|
|
|
804
|
-// and task.deleted_at isnull
|
|
|
805
|
-// and (task.assist_flag+task.warn_flag +task.anomaly)>0
|
|
|
806
|
-// and task.related_user @>?
|
|
|
807
|
-// and task.leader ->>'id' <> ?
|
|
|
808
|
-// `
|
|
|
809
|
-// relatedUser := fmt.Sprintf("[%d]", relatedUserId)
|
|
|
810
|
-// condition := []interface{}{relatedUser, strconv.Itoa(relatedUserId)}
|
|
|
811
|
-// result := []TaskData6{}
|
|
|
812
|
-// tx := d.transactionContext.PgTx
|
|
|
813
|
-// _, err := tx.Query(&result, sqlStr, condition...)
|
|
|
814
|
-// return result, err
|
|
|
815
|
-// } |
806
|
+// 员工绩效-任务列表 查询任务列表
|
|
|
807
|
+// userid 谁要查看任务数据
|
|
|
808
|
+// limit 分页
|
|
|
809
|
+// offset 分页
|
|
|
810
|
+func (d *TaskDao) ListTaskByHrbpV3(param ListTaskCondition) ([]ListTask, error) {
|
|
|
811
|
+ sqlStr := `
|
|
|
812
|
+ with
|
|
|
813
|
+ t_task_ignore as (
|
|
|
814
|
+ select task_ignore.task_id,task_ignore.id from task_ignore where task_ignore.user_id =?
|
|
|
815
|
+ ),
|
|
|
816
|
+ t_task as (
|
|
|
817
|
+ select
|
|
|
818
|
+ cast(COALESCE(task.current_stage ->>'planCompletedAt','0') as int) as c_plan_completed_at,
|
|
|
819
|
+ cast(COALESCE(task.current_stage ->>'realCompletedAt','0') as int) as c_real_completed_at,
|
|
|
820
|
+ floor(extract(epoch from now())) as now_time,
|
|
|
821
|
+ task.id ,
|
|
|
822
|
+ task.alias ,
|
|
|
823
|
+ task.leader ->>'name' as leader_name,
|
|
|
824
|
+ task.leader ->>'id' as leader_id,
|
|
|
825
|
+ task."level",
|
|
|
826
|
+ task.level_name ,
|
|
|
827
|
+ task.anomaly ,
|
|
|
828
|
+ task.warn_flag ,
|
|
|
829
|
+ task.status ,
|
|
|
830
|
+ task.updated_at,
|
|
|
831
|
+ task.current_stage,
|
|
|
832
|
+ task.last_stage,
|
|
|
833
|
+ task.sort_by,
|
|
|
834
|
+ task.end_time,
|
|
|
835
|
+ task.created_at
|
|
|
836
|
+ from task
|
|
|
837
|
+ left join t_task_ignore on t_task_ignore.task_id=task.id
|
|
|
838
|
+ where 1=1 and t_task_ignore.id isnull and task.company_id=?
|
|
|
839
|
+ and task.deleted_at isnull
|
|
|
840
|
+ %s
|
|
|
841
|
+ ),
|
|
|
842
|
+ t_task_1 as (
|
|
|
843
|
+ select
|
|
|
844
|
+ (case
|
|
|
845
|
+ when t_task.c_plan_completed_at=0 then 0
|
|
|
846
|
+ when t_task.c_plan_completed_at-now_time>0 then 0
|
|
|
847
|
+ else t_task.c_plan_completed_at-now_time
|
|
|
848
|
+ end) as sort_by_1,
|
|
|
849
|
+ t_task.c_plan_completed_at ,
|
|
|
850
|
+ t_task.id as task_id,
|
|
|
851
|
+ t_task.alias ,
|
|
|
852
|
+ t_task.leader_name,
|
|
|
853
|
+ t_task.leader_id,
|
|
|
854
|
+ t_task."level",
|
|
|
855
|
+ t_task.level_name ,
|
|
|
856
|
+ t_task.anomaly ,
|
|
|
857
|
+ t_task.warn_flag ,
|
|
|
858
|
+ t_task.status ,
|
|
|
859
|
+ t_task.updated_at ,
|
|
|
860
|
+ t_task.current_stage,
|
|
|
861
|
+ t_task.last_stage,
|
|
|
862
|
+ t_task.sort_by,
|
|
|
863
|
+ t_task.end_time,
|
|
|
864
|
+ t_task.created_at
|
|
|
865
|
+ from t_task
|
|
|
866
|
+ where 1=1
|
|
|
867
|
+ )select *
|
|
|
868
|
+ from t_task_1
|
|
|
869
|
+ order by t_task_1.status, t_task_1.sort_by_1,
|
|
|
870
|
+ t_task_1.anomaly desc,
|
|
|
871
|
+ t_task_1.sort_by,t_task_1."created_at"
|
|
|
872
|
+ limit ? offset ?
|
|
|
873
|
+ `
|
|
|
874
|
+ condition := []interface{}{param.UserId, param.CompanyId}
|
|
|
875
|
+ whereSql := ``
|
|
|
876
|
+ if param.OnlyMy {
|
|
|
877
|
+ condition = append(condition, param.UserId)
|
|
|
878
|
+ whereSql += ` and task.leader ->>'id' = '?' `
|
|
|
879
|
+ }
|
|
|
880
|
+ if param.SearchWord != "" {
|
|
|
881
|
+ condition = append(condition, param.SearchWord, param.SearchWord)
|
|
|
882
|
+ whereSql += ` and (task.leader->>'name' like ? or task.alias like ?)`
|
|
|
883
|
+ }
|
|
|
884
|
+ if len(param.LevelName) > 0 {
|
|
|
885
|
+ condition = append(condition, param.LevelName)
|
|
|
886
|
+ whereSql += ` and task.level_name = ? `
|
|
|
887
|
+ }
|
|
|
888
|
+ strSql2 := fmt.Sprintf(sqlStr, whereSql)
|
|
|
889
|
+ condition = append(condition, param.Limit, param.Offset)
|
|
|
890
|
+ result := []ListTask{}
|
|
|
891
|
+ tx := d.transactionContext.PgTx
|
|
|
892
|
+ _, err := tx.Query(&result, strSql2, condition...)
|
|
|
893
|
+ return result, err
|
|
|
894
|
+} |