|
@@ -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
|
}
|
|
@@ -781,6 +798,8 @@ func (d *StaffAssessDao) MemberPerformanceIndicator(likeUserName string, company |
|
@@ -781,6 +798,8 @@ func (d *StaffAssessDao) MemberPerformanceIndicator(likeUserName string, company |
781
|
type ExportData1 struct {
|
798
|
type ExportData1 struct {
|
782
|
AssessId string
|
799
|
AssessId string
|
783
|
ContentId int
|
800
|
ContentId int
|
|
|
801
|
+ CycleId string //周期id
|
|
|
802
|
+ CycleName string //周期名称
|
784
|
TargetUserId string //被评估人的id
|
803
|
TargetUserId string //被评估人的id
|
785
|
TargetUserName string //被评估人的名称
|
804
|
TargetUserName string //被评估人的名称
|
786
|
BeginDay string //评估的日期
|
805
|
BeginDay string //评估的日期
|
|
@@ -803,11 +822,20 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa |
|
@@ -803,11 +822,20 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa |
803
|
param.Limit = 5000
|
822
|
param.Limit = 5000
|
804
|
}
|
823
|
}
|
805
|
sqlStr := ` select
|
824
|
sqlStr := ` select
|
806
|
- t_staff_assess_1.target_user_id,t_staff_assess_1.target_user_name,t_staff_assess_1.begin_day,
|
|
|
807
|
- t_staff_assess_1.assess_id,staff_assess_content.id as content_id,
|
|
|
808
|
- staff_assess_content.value ,staff_assess_content.sort_by ,
|
|
|
809
|
- staff_assess_content.category ,staff_assess_content."name" as content_name ,
|
|
|
810
|
- staff_assess_content.weight,staff_assess_content.prompt_text ,staff_assess_content.remark
|
825
|
+ t_staff_assess_1.target_user_id,
|
|
|
826
|
+ t_staff_assess_1.target_user_name,
|
|
|
827
|
+ t_staff_assess_1.begin_day,
|
|
|
828
|
+ t_staff_assess_1.assess_id,
|
|
|
829
|
+ t_staff_assess_1.cycle_id,
|
|
|
830
|
+ t_staff_assess_1.cycle_name,
|
|
|
831
|
+ staff_assess_content.id as content_id,
|
|
|
832
|
+ staff_assess_content.value ,
|
|
|
833
|
+ staff_assess_content.sort_by ,
|
|
|
834
|
+ staff_assess_content.category ,
|
|
|
835
|
+ staff_assess_content."name" as content_name ,
|
|
|
836
|
+ staff_assess_content.weight,
|
|
|
837
|
+ staff_assess_content.prompt_text ,
|
|
|
838
|
+ staff_assess_content.remark
|
811
|
from t_staff_assess_1
|
839
|
from t_staff_assess_1
|
812
|
left join staff_assess_content on t_staff_assess_1.assess_id = staff_assess_content.staff_assess_id
|
840
|
left join staff_assess_content on t_staff_assess_1.assess_id = staff_assess_content.staff_assess_id
|
813
|
where 1=1
|
841
|
where 1=1
|
|
@@ -890,3 +918,99 @@ func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int, |
|
@@ -890,3 +918,99 @@ func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int, |
890
|
_, err := tx.QueryOne(pg.Scan(&result), sqlStr, condition...)
|
918
|
_, err := tx.QueryOne(pg.Scan(&result), sqlStr, condition...)
|
891
|
return result, err
|
919
|
return result, err
|
892
|
}
|
920
|
}
|
|
|
921
|
+
|
|
|
922
|
+// 评估的指标
|
|
|
923
|
+type ContentCategoryName struct {
|
|
|
924
|
+ Category string //指标分类
|
|
|
925
|
+ Name string //指标名称
|
|
|
926
|
+ Weight float64 //指标权重
|
|
|
927
|
+ CycleId string //周期id
|
|
|
928
|
+ CycleName string //周期名称
|
|
|
929
|
+ TargetUserId string //评估的目标员工id
|
|
|
930
|
+ TargetUserName string //评估的目标员工名称
|
|
|
931
|
+ Cnt int //排序
|
|
|
932
|
+}
|
|
|
933
|
+
|
|
|
934
|
+// 员工绩效-综合管理-导出绩效指标
|
|
|
935
|
+// 抽取出评估的指标
|
|
|
936
|
+func (d *StaffAssessDao) SearchContentCategoryName(companyId int, cycleId int, userId int, hrbp int) ([]ContentCategoryName, error) {
|
|
|
937
|
+ sqlStr := `
|
|
|
938
|
+ select
|
|
|
939
|
+ staff_assess_content.category,
|
|
|
940
|
+ staff_assess_content."name" ,
|
|
|
941
|
+ staff_assess_content.weight ,
|
|
|
942
|
+ staff_assess.cycle_id ,
|
|
|
943
|
+ staff_assess.cycle_name,
|
|
|
944
|
+ t_staff_assess_1.target_user_id,
|
|
|
945
|
+ t_staff_assess_1.target_user_name,
|
|
|
946
|
+ sum(
|
|
|
947
|
+ case
|
|
|
948
|
+ when staff_assess_content.value isnull then 0
|
|
|
949
|
+ when staff_assess_content.value='' then 0
|
|
|
950
|
+ ELSE 1
|
|
|
951
|
+ END) as cnt
|
|
|
952
|
+ from staff_assess_content
|
|
|
953
|
+ join t_staff_assess_1 on staff_assess_content.staff_assess_id = t_staff_assess_1.id
|
|
|
954
|
+ group by staff_assess_content.category,
|
|
|
955
|
+ staff_assess_content."name" ,
|
|
|
956
|
+ staff_assess.cycle_id ,
|
|
|
957
|
+ staff_assess.cycle_name,
|
|
|
958
|
+ staff_assess_content.weight ,
|
|
|
959
|
+ target_user_id,target_user_name
|
|
|
960
|
+ order by cnt desc,user_id
|
|
|
961
|
+ `
|
|
|
962
|
+ sqlStr0 := d.useTStaffAssess(companyId, cycleId, userId, "", hrbp, 0, 5000, string(domain.AssessSelf))
|
|
|
963
|
+ sqlStr = sqlStr0 + sqlStr
|
|
|
964
|
+ tx := d.transactionContext.PgTx
|
|
|
965
|
+ result := []ContentCategoryName{}
|
|
|
966
|
+ _, err := tx.Query(&result, sqlStr)
|
|
|
967
|
+ return result, err
|
|
|
968
|
+}
|
|
|
969
|
+
|
|
|
970
|
+type ExportData2 struct {
|
|
|
971
|
+ CycleId string `pg:"cycle_id"` //周期id
|
|
|
972
|
+ CycleName string `pg:"cycle_name"` //周期名称
|
|
|
973
|
+ TargetUserId string `pg:"target_user_id"` //被评估人的id
|
|
|
974
|
+ TargetUserName string `pg:"target_user_name"` //被评估人的名称
|
|
|
975
|
+ BeginDay string `pg:"begin_day"` //评估的日期
|
|
|
976
|
+ Value string `pg:"value"` //评估填写的值
|
|
|
977
|
+ Category string `pg:"category"` //评估项分类
|
|
|
978
|
+ ContentName string `pg:"content_name"` //评估项名称
|
|
|
979
|
+ Weight float64 `pg:"weight"` //权重
|
|
|
980
|
+ PromptText string `pg:"prompt_text"` //评估标准
|
|
|
981
|
+ Remark []domain.AssessContemtRemark `pg:"remark"`
|
|
|
982
|
+}
|
|
|
983
|
+
|
|
|
984
|
+// 员工绩效-综合管理-导出绩效指标
|
|
|
985
|
+// companyId int 公司id
|
|
|
986
|
+// cycleId int, 评估周期id
|
|
|
987
|
+// userId int, 用户id,谁要查看数据
|
|
|
988
|
+// hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否
|
|
|
989
|
+func (d *StaffAssessDao) ExportDataUserAssess2(companyId int, cycleId int, operaterId int, hrbp int) ([]*ExportData2, error) {
|
|
|
990
|
+ sqlStr := ` select
|
|
|
991
|
+ t_staff_assess_1.target_user_id,
|
|
|
992
|
+ t_staff_assess_1.target_user_name,
|
|
|
993
|
+ t_staff_assess_1.begin_day,
|
|
|
994
|
+ t_staff_assess_1.cycle_id,
|
|
|
995
|
+ t_staff_assess_1.cycle_name,
|
|
|
996
|
+ staff_assess_content.value ,
|
|
|
997
|
+ staff_assess_content.category ,
|
|
|
998
|
+ staff_assess_content."name" as content_name ,
|
|
|
999
|
+ staff_assess_content.weight,
|
|
|
1000
|
+ staff_assess_content.prompt_text ,
|
|
|
1001
|
+ staff_assess_content.remark
|
|
|
1002
|
+ from t_staff_assess_1
|
|
|
1003
|
+ left join staff_assess_content on t_staff_assess_1.assess_id = staff_assess_content.staff_assess_id
|
|
|
1004
|
+ where 1=1
|
|
|
1005
|
+ `
|
|
|
1006
|
+ condition := []interface{}{}
|
|
|
1007
|
+ //加入排序
|
|
|
1008
|
+ sqlStr += ` order by t_staff_assess_1.begin_day`
|
|
|
1009
|
+ //获取前置sql语句
|
|
|
1010
|
+ sqlStr0 := d.useTStaffAssess(companyId, cycleId, operaterId, "", hrbp, 5000, 0, string(domain.AssessSelf))
|
|
|
1011
|
+ sqlStr = sqlStr0 + sqlStr
|
|
|
1012
|
+ tx := d.transactionContext.PgTx
|
|
|
1013
|
+ result := []*ExportData2{}
|
|
|
1014
|
+ _, err := tx.Query(&result, sqlStr, condition...)
|
|
|
1015
|
+ return result, err
|
|
|
1016
|
+} |