作者 Your Name

新增 获取评估指标的接口

... ... @@ -10,20 +10,20 @@ import (
// 员工绩效-综合管理-导出绩效指标
// excel表头部字段
type headerLevel struct {
type HeaderLevel struct {
Name string
Filter map[string]int
Child []headerLevel
Child []HeaderLevel
}
// 添加下一层级的字段
func (h *headerLevel) addChild(name string) (child *headerLevel) {
func (h *HeaderLevel) addChild(name string) (child *HeaderLevel) {
cIndex, ok := h.Filter[name]
if !ok {
h.Child = append(h.Child, headerLevel{
h.Child = append(h.Child, HeaderLevel{
Name: name,
Filter: map[string]int{},
Child: []headerLevel{},
Child: []HeaderLevel{},
})
h.Filter[name] = len(h.Child) - 1
cIndex = h.Filter[name]
... ... @@ -32,13 +32,13 @@ func (h *headerLevel) addChild(name string) (child *headerLevel) {
}
// 获取表头的所有列表名
func (h *headerLevel) collectAllColumn(all *[][]string) {
func (h *HeaderLevel) collectAllColumn(all *[][]string) {
for _, v := range h.Child {
v.collectColumn(&v, all, nil)
}
}
func (h *headerLevel) collectColumn(child *headerLevel, columns *[][]string, column *[]string) {
func (h *HeaderLevel) collectColumn(child *HeaderLevel, columns *[][]string, column *[]string) {
if column == nil {
column = &[]string{}
}
... ... @@ -60,7 +60,7 @@ type exportData struct {
userName []string //员工的名称列表 ,对应excel文件的多个sheet
usrIdMap map[string]string
userDayMap map[string][]string //每个员工对应的日期列表 key=员工名称 value= 日期列表
tableHeader map[string]*headerLevel //每个员工数据表格对应表头 key=员工名称
tableHeader map[string]*HeaderLevel //每个员工数据表格对应表头 key=员工名称
data map[string]*strings.Builder //每个员工表头对应的评估填写的数据 key=员工名称+日期+表头
data2 map[string]string //每个员工评估项的标准描述
data3 map[string]string //每个员工评估项的标准权重
... ... @@ -71,7 +71,7 @@ func newExportData() *exportData {
userName: nil,
usrIdMap: map[string]string{},
userDayMap: map[string][]string{},
tableHeader: map[string]*headerLevel{},
tableHeader: map[string]*HeaderLevel{},
data: map[string]*strings.Builder{},
data2: map[string]string{},
data3: map[string]string{},
... ... @@ -93,10 +93,10 @@ func (e *exportData) setCategoryNameList(param []dao.ContentCategoryName) {
}
userName := e.usrIdMap[v.TargetUserId]
if _, ok := e.tableHeader[userName]; !ok {
e.tableHeader[userName] = &headerLevel{
e.tableHeader[userName] = &HeaderLevel{
Name: "个人绩效评估等级统计表",
Filter: map[string]int{},
Child: []headerLevel{},
Child: []HeaderLevel{},
}
}
child := e.tableHeader[userName].addChild(v.Category) //第一级,"分类"
... ...
... ... @@ -553,7 +553,7 @@ func (srv StaffAssessServeice) AnalysisData(param *query.ListAssessContentCycleD
return &result, nil
}
// 员工绩效-综合管理-导出绩效指标
// 员工绩效-综合管理-导出绩效-个人
func (srv StaffAssessServeice) ExportUserAssess2(param *query.SummaryCommand) (*excelize.File, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -661,3 +661,49 @@ func (srv StaffAssessServeice) ExportUserAssess2(param *query.SummaryCommand) (*
xlsxFile.DeleteSheet(firstSheetName)
return xlsxFile, nil
}
// 获取所有的评估的指标
func (srv StaffAssessServeice) QueryPerformanceIndicator(param *query.ListAssessContentCycleDay) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
hrbp, err := srv.getHRBP(transactionContext, param.CompanyId, param.OperaterId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
assessDao := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
contentItems, err := assessDao.SearchUserAssessContentItem(dao.SearchConditin1{
CompanyId: param.CompanyId,
CycleId: param.CycleId,
BeginDay: param.BeginDay,
OperaterId: param.OperaterId,
Hrbp: hrbp,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计总数"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
headerList := HeaderLevel{}
for _, v := range contentItems {
child := headerList.addChild(v.Category)
child.addChild(v.Name)
}
result := map[string]interface{}{
"headerList": headerList.Child,
}
return result, nil
}
... ...
... ... @@ -260,6 +260,40 @@ func (d *StaffAssessDao) SearchUserAssessContent(param SearchConditin1) ([]UserA
return result, err
}
type UserAssessContentItem struct {
Category string `pg:"category"` //指标分类
Name string `pg:"name"` //指标名称
}
// 项目管理-成员列表 根据周期的id和日期获取员工的评估指标
// companyId int 公司id
// cycleId int, 评估周期id
// userId int, 用户id,谁要查看数据
// beginDay string, 周期中执行项目的时间
// hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否
// limit int, 分页条数 不需要
// offset int 分页偏移 不需要
func (d *StaffAssessDao) SearchUserAssessContentItem(param SearchConditin1) ([]UserAssessContentItem, error) {
param.Offset = 0
param.Limit = 10000
sqlStr := `select
staff_assess_content.category,
staff_assess_content."name"
from staff_assess_content
join t_staff_assess_1 on staff_assess_content.staff_assess_id = t_staff_assess_1.assess_id
group by staff_assess_content.category,
staff_assess_content."name"
`
//获取前置sql语句
sqlStr0 := d.useTStaffAssess(param.CompanyId, param.CycleId, param.OperaterId, param.BeginDay, param.Hrbp, param.Limit, param.Offset, string(domain.AssessSelf))
sqlStr = sqlStr0 + sqlStr
tx := d.transactionContext.PgTx
result := []UserAssessContentItem{}
_, err := tx.Query(&result, sqlStr)
return result, err
}
// 项目管理-成员列表 根据周期的id和日期获取员工填写的评估内容,数量统计
// companyId int 公司id
// cycleId int, 评估周期id
... ... @@ -1068,8 +1102,8 @@ func (d *StaffAssessDao) SearchContentCategoryName(companyId int, cycleId int, u
staff_assess_content.category,
staff_assess_content."name" ,
staff_assess_content.weight ,
staff_assess.cycle_id ,
staff_assess.cycle_name,
t_staff_assess_1.cycle_id ,
t_staff_assess_1.cycle_name,
t_staff_assess_1.target_user_id,
t_staff_assess_1.target_user_name,
sum(
... ... @@ -1079,14 +1113,14 @@ func (d *StaffAssessDao) SearchContentCategoryName(companyId int, cycleId int, u
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
join t_staff_assess_1 on staff_assess_content.staff_assess_id = t_staff_assess_1.assess_id
group by staff_assess_content.category,
staff_assess_content."name" ,
staff_assess.cycle_id ,
staff_assess.cycle_name,
t_staff_assess_1.cycle_id ,
t_staff_assess_1.cycle_name,
staff_assess_content.weight ,
target_user_id,target_user_name
order by cnt desc,user_id
order by cnt desc,target_user_id
`
sqlStr0 := d.useTStaffAssess(companyId, cycleId, userId, "", hrbp, 0, 5000, string(domain.AssessSelf))
sqlStr = sqlStr0 + sqlStr
... ...
... ... @@ -322,6 +322,23 @@ func (c *StaffAssessController) ListAssessContentCycleDay() {
c.Response(data, err)
}
// 根据周期里的考核日期,获取员工填写评估内容列表的评估项
func (c *StaffAssessController) ListAssessContentIndicator() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListAssessContentCycleDay{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.OperaterId = int(userReq.UserId)
data, err := srv.QueryPerformanceIndicator(paramReq)
c.Response(data, err)
}
// 根据周期里的考核日期,获取员工填写评估内容列表,导出为xlsx文件
func (c *StaffAssessController) ExportAssessContentCycleDay() {
srv := service.NewStaffAssessServeice()
... ...
... ... @@ -13,12 +13,14 @@ func init() {
//web.NSCtrlPost("/search/me", (*controllers.StaffAssessController).SearchAssessTaskMe), //获取我参与过的评估项目列表
//web.NSCtrlPost("/desc/me", (*controllers.StaffAssessController).AssessTaskMeDesc), //获取我的项目评估进度描述
//web.NSCtrlPost("/", (*controllers.StaffAssessController).CreateStaffAssessTask), //创建员工的评估任务
web.NSCtrlGet("/cycle", (*controllers.StaffAssessController).ListAssessCycle), //获取周期列表
web.NSCtrlPost("/cycle/day", (*controllers.StaffAssessController).ListAssessCycleDay), //获取周期中的考核日期
web.NSCtrlPost("/cycle/day/content", (*controllers.StaffAssessController).ListAssessContentCycleDay), //根据周期里的考核日期,获取员工填写评估内容列表
web.NSCtrlPost("/cycle/day/content/export", (*controllers.StaffAssessController).ExportAssessContentCycleDay), //根据周期里的考核日期,导出员工填写评估内容列表
web.NSCtrlPost("/cycle/day/analysis", (*controllers.StaffAssessController).AnalysisData), //员工绩效-项目管理-矩阵分析
web.NSCtrlPost("/cycle/day/content/export2", (*controllers.StaffAssessController).ExportUserAssess2), //员工绩效-综合管理-导出绩效-个人
web.NSCtrlGet("/cycle", (*controllers.StaffAssessController).ListAssessCycle), //获取周期列表
web.NSCtrlPost("/cycle/day", (*controllers.StaffAssessController).ListAssessCycleDay), //获取周期中的考核日期
web.NSCtrlPost("/cycle/day/content", (*controllers.StaffAssessController).ListAssessContentCycleDay), //根据周期里的考核日期,获取员工填写评估内容列表
web.NSCtrlPost("/cycle/day/content/indicator", (*controllers.StaffAssessController).ListAssessContentIndicator), //根据周期里的考核日期,获取员工填写评估的指标项
web.NSCtrlPost("/cycle/day/content/export", (*controllers.StaffAssessController).ExportAssessContentCycleDay), //根据周期里的考核日期,导出员工填写评估内容列表
web.NSCtrlPost("/cycle/day/analysis", (*controllers.StaffAssessController).AnalysisData), //员工绩效-项目管理-矩阵分析
web.NSCtrlPost("/cycle/day/content/export2", (*controllers.StaffAssessController).ExportUserAssess2), //员工绩效-综合管理-导出绩效-个人
)
assessNS := web.NewNamespace("/v1/staff-assess",
... ...