|
@@ -5,7 +5,6 @@ import ( |
|
@@ -5,7 +5,6 @@ import ( |
5
|
|
5
|
|
6
|
"github.com/go-pg/pg/v10"
|
6
|
"github.com/go-pg/pg/v10"
|
7
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
7
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
8
|
- "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
9
|
)
|
8
|
)
|
10
|
|
9
|
|
11
|
type SummaryEvaluationDao struct {
|
10
|
type SummaryEvaluationDao struct {
|
|
@@ -31,7 +30,7 @@ type ExecutorCycle struct { |
|
@@ -31,7 +30,7 @@ type ExecutorCycle struct { |
31
|
// GetExecutorCycleList 获取执行人拥有的周期列表
|
30
|
// GetExecutorCycleList 获取执行人拥有的周期列表
|
32
|
// executorId 执行人id
|
31
|
// executorId 执行人id
|
33
|
// offset,limit 分页
|
32
|
// offset,limit 分页
|
34
|
-func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, limit int, isHrbp bool) ([]ExecutorCycle, error) {
|
33
|
+func (d *SummaryEvaluationDao) GetExecutorCycleList(companyId int, executorId int, offset int, limit int, isHrbp bool) ([]ExecutorCycle, error) {
|
35
|
sqlStr := `select
|
34
|
sqlStr := `select
|
36
|
distinct on(
|
35
|
distinct on(
|
37
|
summary_evaluation.cycle_id ,
|
36
|
summary_evaluation.cycle_id ,
|
|
@@ -40,14 +39,16 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, |
|
@@ -40,14 +39,16 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, |
40
|
summary_evaluation.cycle_id ,
|
39
|
summary_evaluation.cycle_id ,
|
41
|
summary_evaluation.cycle_name
|
40
|
summary_evaluation.cycle_name
|
42
|
from summary_evaluation
|
41
|
from summary_evaluation
|
43
|
- where summary_evaluation.executor ->>'userId'='?'
|
42
|
+ where summary_evaluation.company_id=?
|
44
|
`
|
43
|
`
|
45
|
tx := d.transactionContext.PgTx
|
44
|
tx := d.transactionContext.PgTx
|
46
|
condition := []interface{}{
|
45
|
condition := []interface{}{
|
47
|
- executorId,
|
46
|
+ companyId, executorId,
|
48
|
}
|
47
|
}
|
49
|
if isHrbp {
|
48
|
if isHrbp {
|
50
|
- sqlStr += ` or summary_evaluation."types"=4 `
|
49
|
+ sqlStr += ` and (summary_evaluation.executor ->>'userId'='?' or summary_evaluation."types"=4 ) `
|
|
|
50
|
+ } else {
|
|
|
51
|
+ sqlStr += ` and (summary_evaluation.executor ->>'userId'='?') `
|
51
|
}
|
52
|
}
|
52
|
condition = append(condition, offset, limit)
|
53
|
condition = append(condition, offset, limit)
|
53
|
|
54
|
|
|
@@ -58,22 +59,22 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, |
|
@@ -58,22 +59,22 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, |
58
|
}
|
59
|
}
|
59
|
|
60
|
|
60
|
// CountExecutorCycleList 统计执行人拥有的周期列表
|
61
|
// CountExecutorCycleList 统计执行人拥有的周期列表
|
61
|
-func (d *SummaryEvaluationDao) CountExecutorCycleList(executorId int, evaluationType domain.EvaluationType) (int, error) {
|
62
|
+func (d *SummaryEvaluationDao) CountExecutorCycleList(companyId int, executorId int, isHrbp bool) (int, error) {
|
62
|
sqlStr := `select count(
|
63
|
sqlStr := `select count(
|
63
|
distinct summary_evaluation.cycle_id
|
64
|
distinct summary_evaluation.cycle_id
|
64
|
) as cnt
|
65
|
) as cnt
|
65
|
from summary_evaluation
|
66
|
from summary_evaluation
|
66
|
- where summary_evaluation.executor ->>'userId'='?' `
|
67
|
+ where summary_evaluation.company_id=? `
|
67
|
|
68
|
|
68
|
tx := d.transactionContext.PgTx
|
69
|
tx := d.transactionContext.PgTx
|
69
|
condition := []interface{}{
|
70
|
condition := []interface{}{
|
70
|
- executorId,
|
71
|
+ companyId, executorId,
|
71
|
}
|
72
|
}
|
72
|
- if evaluationType > 0 {
|
|
|
73
|
- sqlStr += ` and summary_evaluation."types"=? `
|
|
|
74
|
- condition = append(condition, int(evaluationType))
|
73
|
+ if isHrbp {
|
|
|
74
|
+ sqlStr += ` and (summary_evaluation.executor ->>'userId'='?' or summary_evaluation."types"=4 ) `
|
|
|
75
|
+ } else {
|
|
|
76
|
+ sqlStr += ` and (summary_evaluation.executor ->>'userId'='?') `
|
75
|
}
|
77
|
}
|
76
|
-
|
|
|
77
|
var cnt int
|
78
|
var cnt int
|
78
|
_, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
|
79
|
_, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
|
79
|
return cnt, err
|
80
|
return cnt, err
|