|
@@ -209,7 +209,6 @@ type UserAssessContent struct { |
|
@@ -209,7 +209,6 @@ type UserAssessContent struct { |
209
|
|
209
|
|
210
|
type SearchConditin1 struct {
|
210
|
type SearchConditin1 struct {
|
211
|
CompanyId int //公司id
|
211
|
CompanyId int //公司id
|
212
|
- AssessId int //评估任务id
|
|
|
213
|
CycleId int //周期id
|
212
|
CycleId int //周期id
|
214
|
BeginDay string //评估的日期
|
213
|
BeginDay string //评估的日期
|
215
|
TargetUserName string //被评估人的名称
|
214
|
TargetUserName string //被评估人的名称
|
|
@@ -289,14 +288,14 @@ func (d *StaffAssessDao) CountUserAssess(param SearchConditin1) (int, error) { |
|
@@ -289,14 +288,14 @@ func (d *StaffAssessDao) CountUserAssess(param SearchConditin1) (int, error) { |
289
|
}
|
288
|
}
|
290
|
|
289
|
|
291
|
// 生成的sql 根据用户的查看权限 ,获取可查看的评估任务,
|
290
|
// 生成的sql 根据用户的查看权限 ,获取可查看的评估任务,
|
292
|
-// companyId int 公司id
|
|
|
293
|
-// cycleId int, 评估周期id
|
|
|
294
|
-// userId int, 用户id,谁要查看数据
|
|
|
295
|
-// beginDay string, 周期中执行项目的时间
|
|
|
296
|
-// hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否
|
|
|
297
|
-// limit int, 分页条数
|
|
|
298
|
-// offset int 分页偏移
|
|
|
299
|
-// assessType string 评估的类型
|
291
|
+// companyId int 公司id (必填)
|
|
|
292
|
+// cycleId int, 评估周期id (必填)
|
|
|
293
|
+// userId int, 用户id,谁要查看数据 (必填)
|
|
|
294
|
+// beginDay string, 周期中执行项目的时间 (选填)
|
|
|
295
|
+// hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否 (必填)
|
|
|
296
|
+// limit int, 分页条数 (必填)
|
|
|
297
|
+// offset int 分页偏移 (必填)
|
|
|
298
|
+// assessType string 评估的类型 (选填)
|
300
|
func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, beginDay string, hrbp int, limit int, offset int, assessType string) string {
|
299
|
func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, beginDay string, hrbp int, limit int, offset int, assessType string) string {
|
301
|
sqlstr := `
|
300
|
sqlstr := `
|
302
|
set time zone 'PRC';
|
301
|
set time zone 'PRC';
|
|
@@ -340,6 +339,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
|
@@ -340,6 +339,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
340
|
t_staff_assess_0 as (
|
339
|
t_staff_assess_0 as (
|
341
|
select staff_assess.id as assess_id,
|
340
|
select staff_assess.id as assess_id,
|
342
|
staff_assess.cycle_id,
|
341
|
staff_assess.cycle_id,
|
|
|
342
|
+ staff_assess.cycle_name,
|
343
|
staff_assess.target_user->>'userId' as target_user_id,
|
343
|
staff_assess.target_user->>'userId' as target_user_id,
|
344
|
staff_assess.target_user->>'userName' as target_user_name,
|
344
|
staff_assess.target_user->>'userName' as target_user_name,
|
345
|
to_char(staff_assess.begin_time,'YYYY-MM-DD') as begin_day,
|
345
|
to_char(staff_assess.begin_time,'YYYY-MM-DD') as begin_day,
|
|
@@ -348,8 +348,8 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
|
@@ -348,8 +348,8 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
348
|
join staff_assess_task on staff_assess.staff_assess_task_id = staff_assess_task.id
|
348
|
join staff_assess_task on staff_assess.staff_assess_task_id = staff_assess_task.id
|
349
|
and staff_assess_task.deleted_at isnull
|
349
|
and staff_assess_task.deleted_at isnull
|
350
|
where staff_assess.cycle_id = %d
|
350
|
where staff_assess.cycle_id = %d
|
351
|
- and to_char(staff_assess.begin_time,'YYYY-MM-DD')='%s'
|
|
|
352
|
- and staff_assess."types" ='%s'
|
351
|
+ %s
|
|
|
352
|
+ -- 根据条件拼接查询条件
|
353
|
),
|
353
|
),
|
354
|
-- 根据查看权限过滤合并数据
|
354
|
-- 根据查看权限过滤合并数据
|
355
|
t_staff_assess_1 as (
|
355
|
t_staff_assess_1 as (
|
|
@@ -357,6 +357,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
|
@@ -357,6 +357,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
357
|
t_staff_assess_0.target_user_id,
|
357
|
t_staff_assess_0.target_user_id,
|
358
|
t_staff_assess_0.target_user_name,
|
358
|
t_staff_assess_0.target_user_name,
|
359
|
t_staff_assess_0.begin_day,
|
359
|
t_staff_assess_0.begin_day,
|
|
|
360
|
+ t_staff_assess_0.cycle_name,
|
360
|
t_staff_assess_0.cycle_id
|
361
|
t_staff_assess_0.cycle_id
|
361
|
from t_staff_assess_0
|
362
|
from t_staff_assess_0
|
362
|
join t_project_3 on t_staff_assess_0.evaluation_project_id = t_project_3.project_id
|
363
|
join t_project_3 on t_staff_assess_0.evaluation_project_id = t_project_3.project_id
|
|
@@ -364,6 +365,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
|
@@ -364,6 +365,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
364
|
t_staff_assess_0.target_user_id,
|
365
|
t_staff_assess_0.target_user_id,
|
365
|
t_staff_assess_0.target_user_name,
|
366
|
t_staff_assess_0.target_user_name,
|
366
|
t_staff_assess_0.begin_day,
|
367
|
t_staff_assess_0.begin_day,
|
|
|
368
|
+ t_staff_assess_0.cycle_name,
|
367
|
t_staff_assess_0.cycle_id
|
369
|
t_staff_assess_0.cycle_id
|
368
|
from t_staff_assess_0
|
370
|
from t_staff_assess_0
|
369
|
join t_user_1 on t_staff_assess_0.target_user_id=t_user_1.user_id
|
371
|
join t_user_1 on t_staff_assess_0.target_user_id=t_user_1.user_id
|
|
@@ -371,10 +373,25 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
|
@@ -371,10 +373,25 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
371
|
limit %d offset %d
|
373
|
limit %d offset %d
|
372
|
)
|
374
|
)
|
373
|
`
|
375
|
`
|
|
|
376
|
+ //根据条件拼接查询条件
|
|
|
377
|
+ staffAssessWhere := map[string]string{
|
|
|
378
|
+ "beginDay": ` and to_char(staff_assess.begin_time,'YYYY-MM-DD') like '%s' `,
|
|
|
379
|
+ "assessType": ` and staff_assess."types" ='%s' `,
|
|
|
380
|
+ }
|
374
|
params := []interface{}{
|
381
|
params := []interface{}{
|
375
|
- companyId, userId, cycleId, hrbp, cycleId, userId, cycleId, beginDay, assessType, limit, offset,
|
382
|
+ companyId, userId, cycleId, hrbp, cycleId, userId, cycleId,
|
376
|
}
|
383
|
}
|
377
|
|
384
|
|
|
|
385
|
+ if len(beginDay) > 0 {
|
|
|
386
|
+ str := fmt.Sprintf(staffAssessWhere["beginDay"]+"\n", beginDay)
|
|
|
387
|
+ params = append(params, str)
|
|
|
388
|
+ }
|
|
|
389
|
+
|
|
|
390
|
+ if len(assessType) > 0 {
|
|
|
391
|
+ str := fmt.Sprintf(staffAssessWhere["assessType"]+"\n", assessType)
|
|
|
392
|
+ params = append(params, str)
|
|
|
393
|
+ }
|
|
|
394
|
+ params = append(params, limit, offset)
|
378
|
sqlstr = fmt.Sprintf(sqlstr, params...)
|
395
|
sqlstr = fmt.Sprintf(sqlstr, params...)
|
379
|
return sqlstr
|
396
|
return sqlstr
|
380
|
}
|
397
|
}
|
|
@@ -505,6 +522,8 @@ func (d *StaffAssessDao) SummaryAssess(companyId int, operatorId int, cycleId in |
|
@@ -505,6 +522,8 @@ func (d *StaffAssessDao) SummaryAssess(companyId int, operatorId int, cycleId in |
505
|
type ExportData1 struct {
|
522
|
type ExportData1 struct {
|
506
|
AssessId string
|
523
|
AssessId string
|
507
|
ContentId int
|
524
|
ContentId int
|
|
|
525
|
+ CycleId string //周期id
|
|
|
526
|
+ CycleName string //周期名称
|
508
|
TargetUserId string //被评估人的id
|
527
|
TargetUserId string //被评估人的id
|
509
|
TargetUserName string //被评估人的名称
|
528
|
TargetUserName string //被评估人的名称
|
510
|
BeginDay string //评估的日期
|
529
|
BeginDay string //评估的日期
|
|
@@ -527,11 +546,20 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa |
|
@@ -527,11 +546,20 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa |
527
|
param.Limit = 5000
|
546
|
param.Limit = 5000
|
528
|
}
|
547
|
}
|
529
|
sqlStr := ` select
|
548
|
sqlStr := ` select
|
530
|
- t_staff_assess_1.target_user_id,t_staff_assess_1.target_user_name,t_staff_assess_1.begin_day,
|
|
|
531
|
- t_staff_assess_1.assess_id,staff_assess_content.id as content_id,
|
|
|
532
|
- staff_assess_content.value ,staff_assess_content.sort_by ,
|
|
|
533
|
- staff_assess_content.category ,staff_assess_content."name" as content_name ,
|
|
|
534
|
- staff_assess_content.weight,staff_assess_content.prompt_text ,staff_assess_content.remark
|
549
|
+ t_staff_assess_1.target_user_id,
|
|
|
550
|
+ t_staff_assess_1.target_user_name,
|
|
|
551
|
+ t_staff_assess_1.begin_day,
|
|
|
552
|
+ t_staff_assess_1.assess_id,
|
|
|
553
|
+ t_staff_assess_1.cycle_id,
|
|
|
554
|
+ t_staff_assess_1.cycle_name,
|
|
|
555
|
+ staff_assess_content.id as content_id,
|
|
|
556
|
+ staff_assess_content.value ,
|
|
|
557
|
+ staff_assess_content.sort_by ,
|
|
|
558
|
+ staff_assess_content.category ,
|
|
|
559
|
+ staff_assess_content."name" as content_name ,
|
|
|
560
|
+ staff_assess_content.weight,
|
|
|
561
|
+ staff_assess_content.prompt_text ,
|
|
|
562
|
+ staff_assess_content.remark
|
535
|
from t_staff_assess_1
|
563
|
from t_staff_assess_1
|
536
|
left join staff_assess_content on t_staff_assess_1.assess_id = staff_assess_content.staff_assess_id
|
564
|
left join staff_assess_content on t_staff_assess_1.assess_id = staff_assess_content.staff_assess_id
|
537
|
where 1=1
|
565
|
where 1=1
|
|
@@ -614,3 +642,99 @@ func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int, |
|
@@ -614,3 +642,99 @@ func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int, |
614
|
_, err := tx.QueryOne(pg.Scan(&result), sqlStr, condition...)
|
642
|
_, err := tx.QueryOne(pg.Scan(&result), sqlStr, condition...)
|
615
|
return result, err
|
643
|
return result, err
|
616
|
}
|
644
|
}
|
|
|
645
|
+
|
|
|
646
|
+// 评估的指标
|
|
|
647
|
+type ContentCategoryName struct {
|
|
|
648
|
+ Category string //指标分类
|
|
|
649
|
+ Name string //指标名称
|
|
|
650
|
+ Weight string //指标权重
|
|
|
651
|
+ CycleId string //周期id
|
|
|
652
|
+ CycleName string //周期名称
|
|
|
653
|
+ TargetUserId string //评估的目标员工id
|
|
|
654
|
+ TargetUserName string //评估的目标员工名称
|
|
|
655
|
+ Cnt int //排序
|
|
|
656
|
+}
|
|
|
657
|
+
|
|
|
658
|
+// 员工绩效-综合管理-导出绩效指标
|
|
|
659
|
+// 抽取出评估的指标
|
|
|
660
|
+func (d *StaffAssessDao) SearchContentCategoryName(companyId int, cycleId int, userId int, hrbp int) ([]ContentCategoryName, error) {
|
|
|
661
|
+ sqlStr := `
|
|
|
662
|
+ select
|
|
|
663
|
+ staff_assess_content.category,
|
|
|
664
|
+ staff_assess_content."name" ,
|
|
|
665
|
+ staff_assess_content.weight ,
|
|
|
666
|
+ staff_assess.cycle_id ,
|
|
|
667
|
+ staff_assess.cycle_name,
|
|
|
668
|
+ t_staff_assess_1.target_user_id,
|
|
|
669
|
+ t_staff_assess_1.target_user_name,
|
|
|
670
|
+ sum(
|
|
|
671
|
+ case
|
|
|
672
|
+ when staff_assess_content.value isnull then 0
|
|
|
673
|
+ when staff_assess_content.value='' then 0
|
|
|
674
|
+ ELSE 1
|
|
|
675
|
+ END) as cnt
|
|
|
676
|
+ from staff_assess_content
|
|
|
677
|
+ join t_staff_assess_1 on staff_assess_content.staff_assess_id = t_staff_assess_1.id
|
|
|
678
|
+ group by staff_assess_content.category,
|
|
|
679
|
+ staff_assess_content."name" ,
|
|
|
680
|
+ staff_assess.cycle_id ,
|
|
|
681
|
+ staff_assess.cycle_name,
|
|
|
682
|
+ staff_assess_content.weight ,
|
|
|
683
|
+ target_user_id,target_user_name
|
|
|
684
|
+ order by cnt desc,user_id
|
|
|
685
|
+ `
|
|
|
686
|
+ sqlStr0 := d.useTStaffAssess(companyId, cycleId, userId, "", hrbp, 0, 5000, string(domain.AssessSelf))
|
|
|
687
|
+ sqlStr = sqlStr0 + sqlStr
|
|
|
688
|
+ tx := d.transactionContext.PgTx
|
|
|
689
|
+ result := []ContentCategoryName{}
|
|
|
690
|
+ _, err := tx.Query(&result, sqlStr)
|
|
|
691
|
+ return result, err
|
|
|
692
|
+}
|
|
|
693
|
+
|
|
|
694
|
+type ExportData2 struct {
|
|
|
695
|
+ CycleId string `pg:"cycle_id"` //周期id
|
|
|
696
|
+ CycleName string `pg:"cycle_name"` //周期名称
|
|
|
697
|
+ TargetUserId string `pg:"target_user_id"` //被评估人的id
|
|
|
698
|
+ TargetUserName string `pg:"target_user_name"` //被评估人的名称
|
|
|
699
|
+ BeginDay string `pg:"begin_day"` //评估的日期
|
|
|
700
|
+ Value string `pg:"value"` //评估填写的值
|
|
|
701
|
+ Category string `pg:"category"` //评估项分类
|
|
|
702
|
+ ContentName string `pg:"content_name"` //评估项名称
|
|
|
703
|
+ Weight float64 `pg:"weight"` //权重
|
|
|
704
|
+ PromptText string `pg:"prompt_text"` //评估标准
|
|
|
705
|
+ Remark []domain.AssessContemtRemark `pg:"remark"`
|
|
|
706
|
+}
|
|
|
707
|
+
|
|
|
708
|
+// 员工绩效-综合管理-导出绩效指标
|
|
|
709
|
+// companyId int 公司id
|
|
|
710
|
+// cycleId int, 评估周期id
|
|
|
711
|
+// userId int, 用户id,谁要查看数据
|
|
|
712
|
+// hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否
|
|
|
713
|
+func (d *StaffAssessDao) ExportDataUserAssess2(companyId int, cycleId int, operaterId int, hrbp int) ([]ExportData1, error) {
|
|
|
714
|
+ sqlStr := ` select
|
|
|
715
|
+ t_staff_assess_1.target_user_id,
|
|
|
716
|
+ t_staff_assess_1.target_user_name,
|
|
|
717
|
+ t_staff_assess_1.begin_day,
|
|
|
718
|
+ t_staff_assess_1.cycle_id,
|
|
|
719
|
+ t_staff_assess_1.cycle_name,
|
|
|
720
|
+ staff_assess_content.value ,
|
|
|
721
|
+ staff_assess_content.category ,
|
|
|
722
|
+ staff_assess_content."name" as content_name ,
|
|
|
723
|
+ staff_assess_content.weight,
|
|
|
724
|
+ staff_assess_content.prompt_text ,
|
|
|
725
|
+ staff_assess_content.remark
|
|
|
726
|
+ from t_staff_assess_1
|
|
|
727
|
+ left join staff_assess_content on t_staff_assess_1.assess_id = staff_assess_content.staff_assess_id
|
|
|
728
|
+ where 1=1
|
|
|
729
|
+ `
|
|
|
730
|
+ condition := []interface{}{}
|
|
|
731
|
+ //加入排序
|
|
|
732
|
+ sqlStr += ` order by t_staff_assess_1.begin_day`
|
|
|
733
|
+ //获取前置sql语句
|
|
|
734
|
+ sqlStr0 := d.useTStaffAssess(companyId, cycleId, operaterId, "", hrbp, 5000, 0, string(domain.AssessSelf))
|
|
|
735
|
+ sqlStr = sqlStr0 + sqlStr
|
|
|
736
|
+ tx := d.transactionContext.PgTx
|
|
|
737
|
+ var result []ExportData1
|
|
|
738
|
+ _, err := tx.Query(&result, sqlStr, condition...)
|
|
|
739
|
+ return result, err
|
|
|
740
|
+} |