|
@@ -115,21 +115,21 @@ func (d *StaffAssessDao) CountTargetUserInviteAssess1(userIds []int, cycleId int |
|
@@ -115,21 +115,21 @@ func (d *StaffAssessDao) CountTargetUserInviteAssess1(userIds []int, cycleId int |
115
|
// }
|
115
|
// }
|
116
|
|
116
|
|
117
|
// 搜索 executorId 参与的评估任务
|
117
|
// 搜索 executorId 参与的评估任务
|
118
|
-func (d *StaffAssessDao) CountAssessTaskMe(executorId int, companyId int) (int, error) {
|
|
|
119
|
- sqlStr := `SELECT count( DISTINCT staff_assess_task."id") FROM staff_assess_task
|
|
|
120
|
- JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"
|
|
|
121
|
- WHERE staff_assess.company_id=?
|
|
|
122
|
- and staff_assess_task.deleted_at isnull
|
|
|
123
|
- and staff_assess.executor->>'userId'='?'
|
|
|
124
|
- `
|
|
|
125
|
- tx := d.transactionContext.PgTx
|
|
|
126
|
- condition := []interface{}{
|
|
|
127
|
- companyId, executorId,
|
|
|
128
|
- }
|
|
|
129
|
- result := 0
|
|
|
130
|
- _, err := tx.QueryOne(pg.Scan(&result), sqlStr, condition...)
|
|
|
131
|
- return result, err
|
|
|
132
|
-}
|
118
|
+// func (d *StaffAssessDao) CountAssessTaskMe(executorId int, companyId int) (int, error) {
|
|
|
119
|
+// sqlStr := `SELECT count( DISTINCT staff_assess_task."id") FROM staff_assess_task
|
|
|
120
|
+// JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"
|
|
|
121
|
+// WHERE staff_assess.company_id=?
|
|
|
122
|
+// and staff_assess_task.deleted_at isnull
|
|
|
123
|
+// and staff_assess.executor->>'userId'='?'
|
|
|
124
|
+// `
|
|
|
125
|
+// tx := d.transactionContext.PgTx
|
|
|
126
|
+// condition := []interface{}{
|
|
|
127
|
+// companyId, executorId,
|
|
|
128
|
+// }
|
|
|
129
|
+// result := 0
|
|
|
130
|
+// _, err := tx.QueryOne(pg.Scan(&result), sqlStr, condition...)
|
|
|
131
|
+// return result, err
|
|
|
132
|
+// }
|
133
|
|
133
|
|
134
|
// 获取所以已经执行的评估周期
|
134
|
// 获取所以已经执行的评估周期
|
135
|
type AssessCycle struct {
|
135
|
type AssessCycle struct {
|
|
@@ -1000,45 +1000,45 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa |
|
@@ -1000,45 +1000,45 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa |
1000
|
return result, err
|
1000
|
return result, err
|
1001
|
}
|
1001
|
}
|
1002
|
|
1002
|
|
1003
|
-type AssessCycleDayMe struct {
|
|
|
1004
|
- BeginDay string
|
|
|
1005
|
- CycleId string
|
|
|
1006
|
- CycleName string
|
|
|
1007
|
- EndTime string
|
|
|
1008
|
- BeginTime string
|
1003
|
+type AssessCycleDayExecutor struct {
|
|
|
1004
|
+ BeginDay string `pg:"begin_day"`
|
|
|
1005
|
+ CycleId string `pg:"cycle_id"`
|
|
|
1006
|
+ CycleName string `pg:"cycle_name"`
|
|
|
1007
|
+ EndTime string `pg:"end_time"`
|
|
|
1008
|
+ BeginTime string `pg:"begin_time"`
|
1009
|
}
|
1009
|
}
|
1010
|
|
1010
|
|
1011
|
// 根据评估的人执行人id,搜索 executorId参与的评估周期
|
1011
|
// 根据评估的人执行人id,搜索 executorId参与的评估周期
|
1012
|
-func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limit int, offset int) ([]AssessCycleDayMe, error) {
|
|
|
1013
|
- if limit < 0 {
|
|
|
1014
|
- limit = 20
|
|
|
1015
|
- }
|
|
|
1016
|
- if offset < 0 {
|
|
|
1017
|
- offset = 0
|
|
|
1018
|
- }
|
|
|
1019
|
- sqlStr := `
|
|
|
1020
|
- SELECT
|
|
|
1021
|
- distinct on(staff_assess_task.cycle_id,staff_assess_task.begin_day)
|
|
|
1022
|
- staff_assess_task.cycle_id,staff_assess_task.cycle_name ,
|
|
|
1023
|
- staff_assess_task.begin_day,
|
|
|
1024
|
- to_char(staff_assess_task.end_time at time zone 'PRC','YYYY-MM-DD HH24:MI:SS') as end_time,
|
|
|
1025
|
- to_char(staff_assess_task.begin_time at time zone 'PRC','YYYY-MM-DD HH24:MI:SS') as begin_time
|
|
|
1026
|
- FROM staff_assess_task
|
|
|
1027
|
- JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"
|
|
|
1028
|
- WHERE staff_assess.company_id=?
|
|
|
1029
|
- and staff_assess_task.deleted_at isnull
|
|
|
1030
|
- and staff_assess.executor->>'userId'='?'
|
|
|
1031
|
- order by staff_assess_task.begin_day desc
|
|
|
1032
|
- limit ? offset ?
|
|
|
1033
|
- `
|
|
|
1034
|
- tx := d.transactionContext.PgTx
|
|
|
1035
|
- condition := []interface{}{
|
|
|
1036
|
- companyId, executorId, limit, offset,
|
|
|
1037
|
- }
|
|
|
1038
|
- result := []AssessCycleDayMe{}
|
|
|
1039
|
- _, err := tx.Query(&result, sqlStr, condition...)
|
|
|
1040
|
- return result, err
|
|
|
1041
|
-}
|
1012
|
+// func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limit int, offset int) ([]AssessCycleDayExecutor, error) {
|
|
|
1013
|
+// if limit < 0 {
|
|
|
1014
|
+// limit = 20
|
|
|
1015
|
+// }
|
|
|
1016
|
+// if offset < 0 {
|
|
|
1017
|
+// offset = 0
|
|
|
1018
|
+// }
|
|
|
1019
|
+// sqlStr := `
|
|
|
1020
|
+// SELECT
|
|
|
1021
|
+// distinct on(staff_assess_task.cycle_id,staff_assess_task.begin_day)
|
|
|
1022
|
+// staff_assess_task.cycle_id,staff_assess_task.cycle_name ,
|
|
|
1023
|
+// staff_assess_task.begin_day,
|
|
|
1024
|
+// to_char(staff_assess_task.end_time at time zone 'PRC','YYYY-MM-DD HH24:MI:SS') as end_time,
|
|
|
1025
|
+// to_char(staff_assess_task.begin_time at time zone 'PRC','YYYY-MM-DD HH24:MI:SS') as begin_time
|
|
|
1026
|
+// FROM staff_assess_task
|
|
|
1027
|
+// JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"
|
|
|
1028
|
+// WHERE staff_assess.company_id=?
|
|
|
1029
|
+// and staff_assess_task.deleted_at isnull
|
|
|
1030
|
+// and staff_assess.executor->>'userId'='?'
|
|
|
1031
|
+// order by staff_assess_task.begin_day desc
|
|
|
1032
|
+// limit ? offset ?
|
|
|
1033
|
+// `
|
|
|
1034
|
+// tx := d.transactionContext.PgTx
|
|
|
1035
|
+// condition := []interface{}{
|
|
|
1036
|
+// companyId, executorId, limit, offset,
|
|
|
1037
|
+// }
|
|
|
1038
|
+// result := []AssessCycleDayExecutor{}
|
|
|
1039
|
+// _, err := tx.Query(&result, sqlStr, condition...)
|
|
|
1040
|
+// return result, err
|
|
|
1041
|
+// }
|
1042
|
|
1042
|
|
1043
|
// 根据评估的人执行人id,统计executorId参与的评估周期
|
1043
|
// 根据评估的人执行人id,统计executorId参与的评估周期
|
1044
|
func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int, error) {
|
1044
|
func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int, error) {
|
|
@@ -1254,8 +1254,8 @@ func (d *StaffAssessDao) CountUncompletedSelfAssess(companyId int, projectIds [] |
|
@@ -1254,8 +1254,8 @@ func (d *StaffAssessDao) CountUncompletedSelfAssess(companyId int, projectIds [] |
1254
|
return result, err
|
1254
|
return result, err
|
1255
|
}
|
1255
|
}
|
1256
|
|
1256
|
|
1257
|
-// SearchAssesBeforeNow
|
|
|
1258
|
-func (d *StaffAssessDao) SearchAssesBeforeNow(executorId int, companyId int, limit int, offset int) ([]AssessCycleDayMe, int, error) {
|
1257
|
+// SearchExecutorAssesBeforeNow
|
|
|
1258
|
+func (d *StaffAssessDao) SearchExecutorAssessBeforeNow(executorId int, companyId int, limit int, offset int) ([]AssessCycleDayExecutor, int, error) {
|
1259
|
sqlStr1 := `select
|
1259
|
sqlStr1 := `select
|
1260
|
distinct on(cycle_id ,begin_day)
|
1260
|
distinct on(cycle_id ,begin_day)
|
1261
|
staff_assess.cycle_id ,
|
1261
|
staff_assess.cycle_id ,
|
|
@@ -1269,20 +1269,66 @@ func (d *StaffAssessDao) SearchAssesBeforeNow(executorId int, companyId int, lim |
|
@@ -1269,20 +1269,66 @@ func (d *StaffAssessDao) SearchAssesBeforeNow(executorId int, companyId int, lim |
1269
|
and (
|
1269
|
and (
|
1270
|
staff_assess.end_time < now() or staff_assess.status ='completed'
|
1270
|
staff_assess.end_time < now() or staff_assess.status ='completed'
|
1271
|
)
|
1271
|
)
|
1272
|
- and staff_assess.executor ->> 'userId'=''
|
1272
|
+ and staff_assess.executor ->> 'userId'='?'
|
1273
|
order by begin_day desc
|
1273
|
order by begin_day desc
|
1274
|
limit ? offset ?`
|
1274
|
limit ? offset ?`
|
1275
|
|
1275
|
|
1276
|
- // sqlStr2 := ``
|
|
|
1277
|
-
|
|
|
1278
|
condition1 := []interface{}{
|
1276
|
condition1 := []interface{}{
|
1279
|
companyId, executorId, limit, offset,
|
1277
|
companyId, executorId, limit, offset,
|
1280
|
}
|
1278
|
}
|
1281
|
|
1279
|
|
1282
|
- _ = sqlStr1
|
|
|
1283
|
- _ = condition1
|
|
|
1284
|
- return nil, 0, nil
|
1280
|
+ sqlStr2 := `select
|
|
|
1281
|
+ count(
|
|
|
1282
|
+ distinct (staff_assess.cycle_id ,to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD'))
|
|
|
1283
|
+ ) as cnt
|
|
|
1284
|
+ from staff_assess
|
|
|
1285
|
+ WHERE staff_assess.company_id=?
|
|
|
1286
|
+ and staff_assess.deleted_at isnull
|
|
|
1287
|
+ and (
|
|
|
1288
|
+ staff_assess.end_time < now() or staff_assess.status ='completed'
|
|
|
1289
|
+ )
|
|
|
1290
|
+ and staff_assess.executor ->> 'userId'='?'
|
|
|
1291
|
+ `
|
|
|
1292
|
+ condition2 := []interface{}{
|
|
|
1293
|
+ companyId, executorId,
|
|
|
1294
|
+ }
|
|
|
1295
|
+ tx := d.transactionContext.PgTx
|
|
|
1296
|
+ result := []AssessCycleDayExecutor{}
|
|
|
1297
|
+ _, err := tx.Query(&result, sqlStr1, condition1...)
|
|
|
1298
|
+ if err != nil {
|
|
|
1299
|
+ return nil, 0, err
|
|
|
1300
|
+ }
|
|
|
1301
|
+ var cnt int
|
|
|
1302
|
+ _, err = tx.QueryOne(pg.Scan(&cnt), sqlStr2, condition2...)
|
|
|
1303
|
+ if err != nil {
|
|
|
1304
|
+ return nil, 0, err
|
|
|
1305
|
+ }
|
|
|
1306
|
+ return result, cnt, nil
|
1285
|
|
1307
|
|
1286
|
}
|
1308
|
}
|
1287
|
|
1309
|
|
1288
|
-func (d *StaffAssessDao) SearchAssessAfterNow(executorId int, companyId int) {} |
1310
|
+// SearchExecutorAssessAfterNow SearchExecutorAssesAfterNow
|
|
|
1311
|
+func (d *StaffAssessDao) SearchExecutorAssessAfterNow(executorId int, companyId int) ([]AssessCycleDayExecutor, error) {
|
|
|
1312
|
+ sqlStr := `select
|
|
|
1313
|
+ distinct on(cycle_id ,begin_day)
|
|
|
1314
|
+ staff_assess.cycle_id ,
|
|
|
1315
|
+ staff_assess.cycle_name ,
|
|
|
1316
|
+ to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD') as begin_day,
|
|
|
1317
|
+ to_char(staff_assess.end_time at time zone 'PRC','YYYY-MM-DD HH24:MI:SS') as end_time,
|
|
|
1318
|
+ to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD HH24:MI:SS') as begin_time
|
|
|
1319
|
+ from staff_assess
|
|
|
1320
|
+ WHERE staff_assess.company_id=?
|
|
|
1321
|
+ and staff_assess.deleted_at isnull
|
|
|
1322
|
+ and (
|
|
|
1323
|
+ staff_assess.end_time >= now() and staff_assess.status ='uncompleted'
|
|
|
1324
|
+ )
|
|
|
1325
|
+ and staff_assess.executor ->> 'userId'='?'
|
|
|
1326
|
+ order by begin_day`
|
|
|
1327
|
+ condition1 := []interface{}{
|
|
|
1328
|
+ companyId, executorId,
|
|
|
1329
|
+ }
|
|
|
1330
|
+ tx := d.transactionContext.PgTx
|
|
|
1331
|
+ result := []AssessCycleDayExecutor{}
|
|
|
1332
|
+ _, err := tx.Query(&result, sqlStr, condition1...)
|
|
|
1333
|
+ return result, err
|
|
|
1334
|
+} |