作者 Your Name

新增 获取评估指标的接口

@@ -10,20 +10,20 @@ import ( @@ -10,20 +10,20 @@ import (
10 // 员工绩效-综合管理-导出绩效指标 10 // 员工绩效-综合管理-导出绩效指标
11 11
12 // excel表头部字段 12 // excel表头部字段
13 -type headerLevel struct { 13 +type HeaderLevel struct {
14 Name string 14 Name string
15 Filter map[string]int 15 Filter map[string]int
16 - Child []headerLevel 16 + Child []HeaderLevel
17 } 17 }
18 18
19 // 添加下一层级的字段 19 // 添加下一层级的字段
20 -func (h *headerLevel) addChild(name string) (child *headerLevel) { 20 +func (h *HeaderLevel) addChild(name string) (child *HeaderLevel) {
21 cIndex, ok := h.Filter[name] 21 cIndex, ok := h.Filter[name]
22 if !ok { 22 if !ok {
23 - h.Child = append(h.Child, headerLevel{ 23 + h.Child = append(h.Child, HeaderLevel{
24 Name: name, 24 Name: name,
25 Filter: map[string]int{}, 25 Filter: map[string]int{},
26 - Child: []headerLevel{}, 26 + Child: []HeaderLevel{},
27 }) 27 })
28 h.Filter[name] = len(h.Child) - 1 28 h.Filter[name] = len(h.Child) - 1
29 cIndex = h.Filter[name] 29 cIndex = h.Filter[name]
@@ -32,13 +32,13 @@ func (h *headerLevel) addChild(name string) (child *headerLevel) { @@ -32,13 +32,13 @@ func (h *headerLevel) addChild(name string) (child *headerLevel) {
32 } 32 }
33 33
34 // 获取表头的所有列表名 34 // 获取表头的所有列表名
35 -func (h *headerLevel) collectAllColumn(all *[][]string) { 35 +func (h *HeaderLevel) collectAllColumn(all *[][]string) {
36 for _, v := range h.Child { 36 for _, v := range h.Child {
37 v.collectColumn(&v, all, nil) 37 v.collectColumn(&v, all, nil)
38 } 38 }
39 } 39 }
40 40
41 -func (h *headerLevel) collectColumn(child *headerLevel, columns *[][]string, column *[]string) { 41 +func (h *HeaderLevel) collectColumn(child *HeaderLevel, columns *[][]string, column *[]string) {
42 if column == nil { 42 if column == nil {
43 column = &[]string{} 43 column = &[]string{}
44 } 44 }
@@ -60,7 +60,7 @@ type exportData struct { @@ -60,7 +60,7 @@ type exportData struct {
60 userName []string //员工的名称列表 ,对应excel文件的多个sheet 60 userName []string //员工的名称列表 ,对应excel文件的多个sheet
61 usrIdMap map[string]string 61 usrIdMap map[string]string
62 userDayMap map[string][]string //每个员工对应的日期列表 key=员工名称 value= 日期列表 62 userDayMap map[string][]string //每个员工对应的日期列表 key=员工名称 value= 日期列表
63 - tableHeader map[string]*headerLevel //每个员工数据表格对应表头 key=员工名称 63 + tableHeader map[string]*HeaderLevel //每个员工数据表格对应表头 key=员工名称
64 data map[string]*strings.Builder //每个员工表头对应的评估填写的数据 key=员工名称+日期+表头 64 data map[string]*strings.Builder //每个员工表头对应的评估填写的数据 key=员工名称+日期+表头
65 data2 map[string]string //每个员工评估项的标准描述 65 data2 map[string]string //每个员工评估项的标准描述
66 data3 map[string]string //每个员工评估项的标准权重 66 data3 map[string]string //每个员工评估项的标准权重
@@ -71,7 +71,7 @@ func newExportData() *exportData { @@ -71,7 +71,7 @@ func newExportData() *exportData {
71 userName: nil, 71 userName: nil,
72 usrIdMap: map[string]string{}, 72 usrIdMap: map[string]string{},
73 userDayMap: map[string][]string{}, 73 userDayMap: map[string][]string{},
74 - tableHeader: map[string]*headerLevel{}, 74 + tableHeader: map[string]*HeaderLevel{},
75 data: map[string]*strings.Builder{}, 75 data: map[string]*strings.Builder{},
76 data2: map[string]string{}, 76 data2: map[string]string{},
77 data3: map[string]string{}, 77 data3: map[string]string{},
@@ -93,10 +93,10 @@ func (e *exportData) setCategoryNameList(param []dao.ContentCategoryName) { @@ -93,10 +93,10 @@ func (e *exportData) setCategoryNameList(param []dao.ContentCategoryName) {
93 } 93 }
94 userName := e.usrIdMap[v.TargetUserId] 94 userName := e.usrIdMap[v.TargetUserId]
95 if _, ok := e.tableHeader[userName]; !ok { 95 if _, ok := e.tableHeader[userName]; !ok {
96 - e.tableHeader[userName] = &headerLevel{ 96 + e.tableHeader[userName] = &HeaderLevel{
97 Name: "个人绩效评估等级统计表", 97 Name: "个人绩效评估等级统计表",
98 Filter: map[string]int{}, 98 Filter: map[string]int{},
99 - Child: []headerLevel{}, 99 + Child: []HeaderLevel{},
100 } 100 }
101 } 101 }
102 child := e.tableHeader[userName].addChild(v.Category) //第一级,"分类" 102 child := e.tableHeader[userName].addChild(v.Category) //第一级,"分类"
@@ -553,7 +553,7 @@ func (srv StaffAssessServeice) AnalysisData(param *query.ListAssessContentCycleD @@ -553,7 +553,7 @@ func (srv StaffAssessServeice) AnalysisData(param *query.ListAssessContentCycleD
553 return &result, nil 553 return &result, nil
554 } 554 }
555 555
556 -// 员工绩效-综合管理-导出绩效指标 556 +// 员工绩效-综合管理-导出绩效-个人
557 func (srv StaffAssessServeice) ExportUserAssess2(param *query.SummaryCommand) (*excelize.File, error) { 557 func (srv StaffAssessServeice) ExportUserAssess2(param *query.SummaryCommand) (*excelize.File, error) {
558 transactionContext, err := factory.CreateTransactionContext(nil) 558 transactionContext, err := factory.CreateTransactionContext(nil)
559 if err != nil { 559 if err != nil {
@@ -661,3 +661,49 @@ func (srv StaffAssessServeice) ExportUserAssess2(param *query.SummaryCommand) (* @@ -661,3 +661,49 @@ func (srv StaffAssessServeice) ExportUserAssess2(param *query.SummaryCommand) (*
661 xlsxFile.DeleteSheet(firstSheetName) 661 xlsxFile.DeleteSheet(firstSheetName)
662 return xlsxFile, nil 662 return xlsxFile, nil
663 } 663 }
  664 +
  665 +// 获取所有的评估的指标
  666 +func (srv StaffAssessServeice) QueryPerformanceIndicator(param *query.ListAssessContentCycleDay) (map[string]interface{}, error) {
  667 + transactionContext, err := factory.CreateTransactionContext(nil)
  668 + if err != nil {
  669 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  670 + }
  671 + if err := transactionContext.StartTransaction(); err != nil {
  672 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  673 + }
  674 + defer func() {
  675 + _ = transactionContext.RollbackTransaction()
  676 + }()
  677 +
  678 + hrbp, err := srv.getHRBP(transactionContext, param.CompanyId, param.OperaterId)
  679 + if err != nil {
  680 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  681 + }
  682 + assessDao := dao.NewStaffAssessDao(map[string]interface{}{
  683 + "transactionContext": transactionContext,
  684 + })
  685 +
  686 + contentItems, err := assessDao.SearchUserAssessContentItem(dao.SearchConditin1{
  687 + CompanyId: param.CompanyId,
  688 + CycleId: param.CycleId,
  689 + BeginDay: param.BeginDay,
  690 + OperaterId: param.OperaterId,
  691 + Hrbp: hrbp,
  692 + })
  693 + if err != nil {
  694 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计总数"+err.Error())
  695 + }
  696 + if err := transactionContext.CommitTransaction(); err != nil {
  697 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  698 + }
  699 +
  700 + headerList := HeaderLevel{}
  701 + for _, v := range contentItems {
  702 + child := headerList.addChild(v.Category)
  703 + child.addChild(v.Name)
  704 + }
  705 + result := map[string]interface{}{
  706 + "headerList": headerList.Child,
  707 + }
  708 + return result, nil
  709 +}
@@ -260,6 +260,40 @@ func (d *StaffAssessDao) SearchUserAssessContent(param SearchConditin1) ([]UserA @@ -260,6 +260,40 @@ func (d *StaffAssessDao) SearchUserAssessContent(param SearchConditin1) ([]UserA
260 return result, err 260 return result, err
261 } 261 }
262 262
  263 +type UserAssessContentItem struct {
  264 + Category string `pg:"category"` //指标分类
  265 + Name string `pg:"name"` //指标名称
  266 +}
  267 +
  268 +// 项目管理-成员列表 根据周期的id和日期获取员工的评估指标
  269 +// companyId int 公司id
  270 +// cycleId int, 评估周期id
  271 +// userId int, 用户id,谁要查看数据
  272 +// beginDay string, 周期中执行项目的时间
  273 +// hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否
  274 +// limit int, 分页条数 不需要
  275 +// offset int 分页偏移 不需要
  276 +func (d *StaffAssessDao) SearchUserAssessContentItem(param SearchConditin1) ([]UserAssessContentItem, error) {
  277 + param.Offset = 0
  278 + param.Limit = 10000
  279 +
  280 + sqlStr := `select
  281 + staff_assess_content.category,
  282 + staff_assess_content."name"
  283 + from staff_assess_content
  284 + join t_staff_assess_1 on staff_assess_content.staff_assess_id = t_staff_assess_1.assess_id
  285 + group by staff_assess_content.category,
  286 + staff_assess_content."name"
  287 + `
  288 + //获取前置sql语句
  289 + sqlStr0 := d.useTStaffAssess(param.CompanyId, param.CycleId, param.OperaterId, param.BeginDay, param.Hrbp, param.Limit, param.Offset, string(domain.AssessSelf))
  290 + sqlStr = sqlStr0 + sqlStr
  291 + tx := d.transactionContext.PgTx
  292 + result := []UserAssessContentItem{}
  293 + _, err := tx.Query(&result, sqlStr)
  294 + return result, err
  295 +}
  296 +
263 // 项目管理-成员列表 根据周期的id和日期获取员工填写的评估内容,数量统计 297 // 项目管理-成员列表 根据周期的id和日期获取员工填写的评估内容,数量统计
264 // companyId int 公司id 298 // companyId int 公司id
265 // cycleId int, 评估周期id 299 // cycleId int, 评估周期id
@@ -1068,8 +1102,8 @@ func (d *StaffAssessDao) SearchContentCategoryName(companyId int, cycleId int, u @@ -1068,8 +1102,8 @@ func (d *StaffAssessDao) SearchContentCategoryName(companyId int, cycleId int, u
1068 staff_assess_content.category, 1102 staff_assess_content.category,
1069 staff_assess_content."name" , 1103 staff_assess_content."name" ,
1070 staff_assess_content.weight , 1104 staff_assess_content.weight ,
1071 - staff_assess.cycle_id ,  
1072 - staff_assess.cycle_name, 1105 + t_staff_assess_1.cycle_id ,
  1106 + t_staff_assess_1.cycle_name,
1073 t_staff_assess_1.target_user_id, 1107 t_staff_assess_1.target_user_id,
1074 t_staff_assess_1.target_user_name, 1108 t_staff_assess_1.target_user_name,
1075 sum( 1109 sum(
@@ -1079,14 +1113,14 @@ func (d *StaffAssessDao) SearchContentCategoryName(companyId int, cycleId int, u @@ -1079,14 +1113,14 @@ func (d *StaffAssessDao) SearchContentCategoryName(companyId int, cycleId int, u
1079 ELSE 1 1113 ELSE 1
1080 END) as cnt 1114 END) as cnt
1081 from staff_assess_content 1115 from staff_assess_content
1082 - join t_staff_assess_1 on staff_assess_content.staff_assess_id = t_staff_assess_1.id 1116 + join t_staff_assess_1 on staff_assess_content.staff_assess_id = t_staff_assess_1.assess_id
1083 group by staff_assess_content.category, 1117 group by staff_assess_content.category,
1084 staff_assess_content."name" , 1118 staff_assess_content."name" ,
1085 - staff_assess.cycle_id ,  
1086 - staff_assess.cycle_name, 1119 + t_staff_assess_1.cycle_id ,
  1120 + t_staff_assess_1.cycle_name,
1087 staff_assess_content.weight , 1121 staff_assess_content.weight ,
1088 target_user_id,target_user_name 1122 target_user_id,target_user_name
1089 - order by cnt desc,user_id 1123 + order by cnt desc,target_user_id
1090 ` 1124 `
1091 sqlStr0 := d.useTStaffAssess(companyId, cycleId, userId, "", hrbp, 0, 5000, string(domain.AssessSelf)) 1125 sqlStr0 := d.useTStaffAssess(companyId, cycleId, userId, "", hrbp, 0, 5000, string(domain.AssessSelf))
1092 sqlStr = sqlStr0 + sqlStr 1126 sqlStr = sqlStr0 + sqlStr
@@ -322,6 +322,23 @@ func (c *StaffAssessController) ListAssessContentCycleDay() { @@ -322,6 +322,23 @@ func (c *StaffAssessController) ListAssessContentCycleDay() {
322 c.Response(data, err) 322 c.Response(data, err)
323 } 323 }
324 324
  325 +// 根据周期里的考核日期,获取员工填写评估内容列表的评估项
  326 +func (c *StaffAssessController) ListAssessContentIndicator() {
  327 + srv := service.NewStaffAssessServeice()
  328 + paramReq := &query.ListAssessContentCycleDay{}
  329 + err := c.BindJSON(paramReq)
  330 + if err != nil {
  331 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  332 + c.Response(nil, e)
  333 + return
  334 + }
  335 + userReq := middlewares.GetUser(c.Ctx)
  336 + paramReq.CompanyId = int(userReq.CompanyId)
  337 + paramReq.OperaterId = int(userReq.UserId)
  338 + data, err := srv.QueryPerformanceIndicator(paramReq)
  339 + c.Response(data, err)
  340 +}
  341 +
325 // 根据周期里的考核日期,获取员工填写评估内容列表,导出为xlsx文件 342 // 根据周期里的考核日期,获取员工填写评估内容列表,导出为xlsx文件
326 func (c *StaffAssessController) ExportAssessContentCycleDay() { 343 func (c *StaffAssessController) ExportAssessContentCycleDay() {
327 srv := service.NewStaffAssessServeice() 344 srv := service.NewStaffAssessServeice()
@@ -13,12 +13,14 @@ func init() { @@ -13,12 +13,14 @@ func init() {
13 //web.NSCtrlPost("/search/me", (*controllers.StaffAssessController).SearchAssessTaskMe), //获取我参与过的评估项目列表 13 //web.NSCtrlPost("/search/me", (*controllers.StaffAssessController).SearchAssessTaskMe), //获取我参与过的评估项目列表
14 //web.NSCtrlPost("/desc/me", (*controllers.StaffAssessController).AssessTaskMeDesc), //获取我的项目评估进度描述 14 //web.NSCtrlPost("/desc/me", (*controllers.StaffAssessController).AssessTaskMeDesc), //获取我的项目评估进度描述
15 //web.NSCtrlPost("/", (*controllers.StaffAssessController).CreateStaffAssessTask), //创建员工的评估任务 15 //web.NSCtrlPost("/", (*controllers.StaffAssessController).CreateStaffAssessTask), //创建员工的评估任务
16 - web.NSCtrlGet("/cycle", (*controllers.StaffAssessController).ListAssessCycle), //获取周期列表  
17 - web.NSCtrlPost("/cycle/day", (*controllers.StaffAssessController).ListAssessCycleDay), //获取周期中的考核日期  
18 - web.NSCtrlPost("/cycle/day/content", (*controllers.StaffAssessController).ListAssessContentCycleDay), //根据周期里的考核日期,获取员工填写评估内容列表  
19 - web.NSCtrlPost("/cycle/day/content/export", (*controllers.StaffAssessController).ExportAssessContentCycleDay), //根据周期里的考核日期,导出员工填写评估内容列表  
20 - web.NSCtrlPost("/cycle/day/analysis", (*controllers.StaffAssessController).AnalysisData), //员工绩效-项目管理-矩阵分析  
21 - web.NSCtrlPost("/cycle/day/content/export2", (*controllers.StaffAssessController).ExportUserAssess2), //员工绩效-综合管理-导出绩效-个人 16 + web.NSCtrlGet("/cycle", (*controllers.StaffAssessController).ListAssessCycle), //获取周期列表
  17 + web.NSCtrlPost("/cycle/day", (*controllers.StaffAssessController).ListAssessCycleDay), //获取周期中的考核日期
  18 + web.NSCtrlPost("/cycle/day/content", (*controllers.StaffAssessController).ListAssessContentCycleDay), //根据周期里的考核日期,获取员工填写评估内容列表
  19 + web.NSCtrlPost("/cycle/day/content/indicator", (*controllers.StaffAssessController).ListAssessContentIndicator), //根据周期里的考核日期,获取员工填写评估的指标项
  20 + web.NSCtrlPost("/cycle/day/content/export", (*controllers.StaffAssessController).ExportAssessContentCycleDay), //根据周期里的考核日期,导出员工填写评估内容列表
  21 + web.NSCtrlPost("/cycle/day/analysis", (*controllers.StaffAssessController).AnalysisData), //员工绩效-项目管理-矩阵分析
  22 + web.NSCtrlPost("/cycle/day/content/export2", (*controllers.StaffAssessController).ExportUserAssess2), //员工绩效-综合管理-导出绩效-个人
  23 +
22 ) 24 )
23 25
24 assessNS := web.NewNamespace("/v1/staff-assess", 26 assessNS := web.NewNamespace("/v1/staff-assess",