...
|
...
|
@@ -209,7 +209,6 @@ type UserAssessContent struct { |
|
|
|
|
|
type SearchConditin1 struct {
|
|
|
CompanyId int //公司id
|
|
|
AssessId int //评估任务id
|
|
|
CycleId int //周期id
|
|
|
BeginDay string //评估的日期
|
|
|
TargetUserName string //被评估人的名称
|
...
|
...
|
@@ -289,14 +288,14 @@ func (d *StaffAssessDao) CountUserAssess(param SearchConditin1) (int, error) { |
|
|
}
|
|
|
|
|
|
// 生成的sql 根据用户的查看权限 ,获取可查看的评估任务,
|
|
|
// companyId int 公司id
|
|
|
// cycleId int, 评估周期id
|
|
|
// userId int, 用户id,谁要查看数据
|
|
|
// beginDay string, 周期中执行项目的时间
|
|
|
// hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否
|
|
|
// limit int, 分页条数
|
|
|
// offset int 分页偏移
|
|
|
// assessType string 评估的类型
|
|
|
// companyId int 公司id (必填)
|
|
|
// cycleId int, 评估周期id (必填)
|
|
|
// userId int, 用户id,谁要查看数据 (必填)
|
|
|
// beginDay string, 周期中执行项目的时间 (选填)
|
|
|
// hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否 (必填)
|
|
|
// limit int, 分页条数 (必填)
|
|
|
// offset int 分页偏移 (必填)
|
|
|
// assessType string 评估的类型 (选填)
|
|
|
func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, beginDay string, hrbp int, limit int, offset int, assessType string) string {
|
|
|
sqlstr := `
|
|
|
set time zone 'PRC';
|
...
|
...
|
@@ -340,6 +339,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
|
|
t_staff_assess_0 as (
|
|
|
select staff_assess.id as assess_id,
|
|
|
staff_assess.cycle_id,
|
|
|
staff_assess.cycle_name,
|
|
|
staff_assess.target_user->>'userId' as target_user_id,
|
|
|
staff_assess.target_user->>'userName' as target_user_name,
|
|
|
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, |
|
|
join staff_assess_task on staff_assess.staff_assess_task_id = staff_assess_task.id
|
|
|
and staff_assess_task.deleted_at isnull
|
|
|
where staff_assess.cycle_id = %d
|
|
|
and to_char(staff_assess.begin_time,'YYYY-MM-DD')='%s'
|
|
|
and staff_assess."types" ='%s'
|
|
|
%s
|
|
|
-- 根据条件拼接查询条件
|
|
|
),
|
|
|
-- 根据查看权限过滤合并数据
|
|
|
t_staff_assess_1 as (
|
...
|
...
|
@@ -357,6 +357,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, |
|
|
t_staff_assess_0.target_user_id,
|
|
|
t_staff_assess_0.target_user_name,
|
|
|
t_staff_assess_0.begin_day,
|
|
|
t_staff_assess_0.cycle_name,
|
|
|
t_staff_assess_0.cycle_id
|
|
|
from t_staff_assess_0
|
|
|
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, |
|
|
t_staff_assess_0.target_user_id,
|
|
|
t_staff_assess_0.target_user_name,
|
|
|
t_staff_assess_0.begin_day,
|
|
|
t_staff_assess_0.cycle_name,
|
|
|
t_staff_assess_0.cycle_id
|
|
|
from t_staff_assess_0
|
|
|
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, |
|
|
limit %d offset %d
|
|
|
)
|
|
|
`
|
|
|
//根据条件拼接查询条件
|
|
|
staffAssessWhere := map[string]string{
|
|
|
"beginDay": ` and to_char(staff_assess.begin_time,'YYYY-MM-DD') like '%s' `,
|
|
|
"assessType": ` and staff_assess."types" ='%s' `,
|
|
|
}
|
|
|
params := []interface{}{
|
|
|
companyId, userId, cycleId, hrbp, cycleId, userId, cycleId, beginDay, assessType, limit, offset,
|
|
|
companyId, userId, cycleId, hrbp, cycleId, userId, cycleId,
|
|
|
}
|
|
|
|
|
|
if len(beginDay) > 0 {
|
|
|
str := fmt.Sprintf(staffAssessWhere["beginDay"]+"\n", beginDay)
|
|
|
params = append(params, str)
|
|
|
}
|
|
|
|
|
|
if len(assessType) > 0 {
|
|
|
str := fmt.Sprintf(staffAssessWhere["assessType"]+"\n", assessType)
|
|
|
params = append(params, str)
|
|
|
}
|
|
|
params = append(params, limit, offset)
|
|
|
sqlstr = fmt.Sprintf(sqlstr, params...)
|
|
|
return sqlstr
|
|
|
}
|
...
|
...
|
@@ -505,6 +522,8 @@ func (d *StaffAssessDao) SummaryAssess(companyId int, operatorId int, cycleId in |
|
|
type ExportData1 struct {
|
|
|
AssessId string
|
|
|
ContentId int
|
|
|
CycleId string //周期id
|
|
|
CycleName string //周期名称
|
|
|
TargetUserId string //被评估人的id
|
|
|
TargetUserName string //被评估人的名称
|
|
|
BeginDay string //评估的日期
|
...
|
...
|
@@ -527,11 +546,20 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa |
|
|
param.Limit = 5000
|
|
|
}
|
|
|
sqlStr := ` select
|
|
|
t_staff_assess_1.target_user_id,t_staff_assess_1.target_user_name,t_staff_assess_1.begin_day,
|
|
|
t_staff_assess_1.assess_id,staff_assess_content.id as content_id,
|
|
|
staff_assess_content.value ,staff_assess_content.sort_by ,
|
|
|
staff_assess_content.category ,staff_assess_content."name" as content_name ,
|
|
|
staff_assess_content.weight,staff_assess_content.prompt_text ,staff_assess_content.remark
|
|
|
t_staff_assess_1.target_user_id,
|
|
|
t_staff_assess_1.target_user_name,
|
|
|
t_staff_assess_1.begin_day,
|
|
|
t_staff_assess_1.assess_id,
|
|
|
t_staff_assess_1.cycle_id,
|
|
|
t_staff_assess_1.cycle_name,
|
|
|
staff_assess_content.id as content_id,
|
|
|
staff_assess_content.value ,
|
|
|
staff_assess_content.sort_by ,
|
|
|
staff_assess_content.category ,
|
|
|
staff_assess_content."name" as content_name ,
|
|
|
staff_assess_content.weight,
|
|
|
staff_assess_content.prompt_text ,
|
|
|
staff_assess_content.remark
|
|
|
from t_staff_assess_1
|
|
|
left join staff_assess_content on t_staff_assess_1.assess_id = staff_assess_content.staff_assess_id
|
|
|
where 1=1
|
...
|
...
|
@@ -614,3 +642,99 @@ func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int, |
|
|
_, err := tx.QueryOne(pg.Scan(&result), sqlStr, condition...)
|
|
|
return result, err
|
|
|
}
|
|
|
|
|
|
// 评估的指标
|
|
|
type ContentCategoryName struct {
|
|
|
Category string //指标分类
|
|
|
Name string //指标名称
|
|
|
Weight string //指标权重
|
|
|
CycleId string //周期id
|
|
|
CycleName string //周期名称
|
|
|
TargetUserId string //评估的目标员工id
|
|
|
TargetUserName string //评估的目标员工名称
|
|
|
Cnt int //排序
|
|
|
}
|
|
|
|
|
|
// 员工绩效-综合管理-导出绩效指标
|
|
|
// 抽取出评估的指标
|
|
|
func (d *StaffAssessDao) SearchContentCategoryName(companyId int, cycleId int, userId int, hrbp int) ([]ContentCategoryName, error) {
|
|
|
sqlStr := `
|
|
|
select
|
|
|
staff_assess_content.category,
|
|
|
staff_assess_content."name" ,
|
|
|
staff_assess_content.weight ,
|
|
|
staff_assess.cycle_id ,
|
|
|
staff_assess.cycle_name,
|
|
|
t_staff_assess_1.target_user_id,
|
|
|
t_staff_assess_1.target_user_name,
|
|
|
sum(
|
|
|
case
|
|
|
when staff_assess_content.value isnull then 0
|
|
|
when staff_assess_content.value='' then 0
|
|
|
ELSE 1
|
|
|
END) as cnt
|
|
|
from staff_assess_content
|
|
|
join t_staff_assess_1 on staff_assess_content.staff_assess_id = t_staff_assess_1.id
|
|
|
group by staff_assess_content.category,
|
|
|
staff_assess_content."name" ,
|
|
|
staff_assess.cycle_id ,
|
|
|
staff_assess.cycle_name,
|
|
|
staff_assess_content.weight ,
|
|
|
target_user_id,target_user_name
|
|
|
order by cnt desc,user_id
|
|
|
`
|
|
|
sqlStr0 := d.useTStaffAssess(companyId, cycleId, userId, "", hrbp, 0, 5000, string(domain.AssessSelf))
|
|
|
sqlStr = sqlStr0 + sqlStr
|
|
|
tx := d.transactionContext.PgTx
|
|
|
result := []ContentCategoryName{}
|
|
|
_, err := tx.Query(&result, sqlStr)
|
|
|
return result, err
|
|
|
}
|
|
|
|
|
|
type ExportData2 struct {
|
|
|
CycleId string `pg:"cycle_id"` //周期id
|
|
|
CycleName string `pg:"cycle_name"` //周期名称
|
|
|
TargetUserId string `pg:"target_user_id"` //被评估人的id
|
|
|
TargetUserName string `pg:"target_user_name"` //被评估人的名称
|
|
|
BeginDay string `pg:"begin_day"` //评估的日期
|
|
|
Value string `pg:"value"` //评估填写的值
|
|
|
Category string `pg:"category"` //评估项分类
|
|
|
ContentName string `pg:"content_name"` //评估项名称
|
|
|
Weight float64 `pg:"weight"` //权重
|
|
|
PromptText string `pg:"prompt_text"` //评估标准
|
|
|
Remark []domain.AssessContemtRemark `pg:"remark"`
|
|
|
}
|
|
|
|
|
|
// 员工绩效-综合管理-导出绩效指标
|
|
|
// companyId int 公司id
|
|
|
// cycleId int, 评估周期id
|
|
|
// userId int, 用户id,谁要查看数据
|
|
|
// hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否
|
|
|
func (d *StaffAssessDao) ExportDataUserAssess2(companyId int, cycleId int, operaterId int, hrbp int) ([]ExportData1, error) {
|
|
|
sqlStr := ` select
|
|
|
t_staff_assess_1.target_user_id,
|
|
|
t_staff_assess_1.target_user_name,
|
|
|
t_staff_assess_1.begin_day,
|
|
|
t_staff_assess_1.cycle_id,
|
|
|
t_staff_assess_1.cycle_name,
|
|
|
staff_assess_content.value ,
|
|
|
staff_assess_content.category ,
|
|
|
staff_assess_content."name" as content_name ,
|
|
|
staff_assess_content.weight,
|
|
|
staff_assess_content.prompt_text ,
|
|
|
staff_assess_content.remark
|
|
|
from t_staff_assess_1
|
|
|
left join staff_assess_content on t_staff_assess_1.assess_id = staff_assess_content.staff_assess_id
|
|
|
where 1=1
|
|
|
`
|
|
|
condition := []interface{}{}
|
|
|
//加入排序
|
|
|
sqlStr += ` order by t_staff_assess_1.begin_day`
|
|
|
//获取前置sql语句
|
|
|
sqlStr0 := d.useTStaffAssess(companyId, cycleId, operaterId, "", hrbp, 5000, 0, string(domain.AssessSelf))
|
|
|
sqlStr = sqlStr0 + sqlStr
|
|
|
tx := d.transactionContext.PgTx
|
|
|
var result []ExportData1
|
|
|
_, err := tx.Query(&result, sqlStr, condition...)
|
|
|
return result, err
|
|
|
} |
...
|
...
|
|