作者 郑周

Merge remote-tracking branch 'origin/test' into test

1 package adapter 1 package adapter
2 2
3 type AssessAnalysisResp struct { 3 type AssessAnalysisResp struct {
4 - GroupList []string //评估指标项列表  
5 - Uncomplete []string // 未完成填写评估的员工  
6 - Complete map[string]AssessComplete //已完成填写的评估内容  
7 - UserCount map[string]int //各项员工数量 4 + GroupList []string `json:"groupList"` //评估指标项列表
  5 + Uncomplete []string `json:"uncomplete"` // 未完成填写评估的员工
  6 + Complete map[string]AssessComplete `json:"complete"` //已完成填写的评估内容
  7 + UserCount map[string]int `json:"userCount"` //各项员工数量
8 } 8 }
9 9
10 type AssessComplete struct { 10 type AssessComplete struct {
11 - GroupKey string //评估指标项  
12 - Items []string //评估指标所有的评级  
13 - UserItem map[string][]string //每个评级下的员工名称  
14 - PercentItem map[string]string ///每个评级下的员工占比  
15 - CountItem map[string]int //每个评级下的员工数量  
16 - TotalUser int //填写该指标的员工数量 11 + GroupKey string `json:"groupKey"` //评估指标项
  12 + Items []string `json:"items"` //评估指标所有的评级
  13 + UserItem map[string][]string `json:"userItem"` //每个评级下的员工名称
  14 + PercentItem map[string]string `json:"percentItem"` ///每个评级下的员工占比
  15 + CountItem map[string]int `json:"countItem"` //每个评级下的员工数量
  16 + TotalUser int `json:"totalUser"` //填写该指标的员工数量
17 } 17 }
1 package query 1 package query
2 2
3 -//根据周期id和日期获取 员工填写评估内容 3 +// 根据周期id和日期获取 员工填写评估内容
4 type ListAssessContentCycleDay struct { 4 type ListAssessContentCycleDay struct {
5 CompanyId int `json:"companyId"` 5 CompanyId int `json:"companyId"`
6 OperaterId int `json:"operaterId"` 6 OperaterId int `json:"operaterId"`
@@ -11,3 +11,16 @@ type ListAssessContentCycleDay struct { @@ -11,3 +11,16 @@ type ListAssessContentCycleDay struct {
11 PageNumber int `json:"pageNumber"` 11 PageNumber int `json:"pageNumber"`
12 PageSize int `json:"pageSize"` 12 PageSize int `json:"pageSize"`
13 } 13 }
  14 +
  15 +type ExportAssessContentCycleDay struct {
  16 + CompanyId int `json:"companyId"`
  17 + OperaterId int `json:"operaterId"`
  18 + CycleId int `json:"cycleId,string"` //周期id
  19 + BeginDay string `json:"beginDay"` //评估开始的时间
  20 + TargetUserName string `json:"targetUserName"`
  21 + TargetUserId []string `json:"targetUserId"`
  22 + ExportItems []struct {
  23 + Category string `json:"category"` //指标类别
  24 + Name string `json:"name"` //指标名称
  25 + } `json:"exportItems"`
  26 +}
@@ -7,7 +7,7 @@ import ( @@ -7,7 +7,7 @@ import (
7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" 7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
8 ) 8 )
9 9
10 -// 员工绩效-综合管理-导出绩效指标 10 +// 员工绩效-综合管理-导出绩效-个人
11 11
12 // excel表头部字段 12 // excel表头部字段
13 type HeaderLevel struct { 13 type HeaderLevel struct {
@@ -133,7 +133,7 @@ func (e *exportData) setData(param []*dao.ExportData2) { @@ -133,7 +133,7 @@ func (e *exportData) setData(param []*dao.ExportData2) {
133 if v.Weight == 0 { 133 if v.Weight == 0 {
134 e.data3[key23] = "" 134 e.data3[key23] = ""
135 } else { 135 } else {
136 - e.data3[key23] = fmt.Sprintf("%.2f %%", v.Weight) 136 + e.data3[key23] = fmt.Sprintf("%.2f%%", v.Weight)
137 } 137 }
138 } 138 }
139 } 139 }
@@ -211,7 +211,7 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs @@ -211,7 +211,7 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs
211 return &result, nil 211 return &result, nil
212 } 212 }
213 213
214 -func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCycleDay) (*excelize.File, error) { 214 +func (srv StaffAssessServeice) ExportUserAssess(param *query.ExportAssessContentCycleDay) (*excelize.File, error) {
215 transactionContext, err := factory.CreateTransactionContext(nil) 215 transactionContext, err := factory.CreateTransactionContext(nil)
216 if err != nil { 216 if err != nil {
217 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 217 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -249,6 +249,11 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy @@ -249,6 +249,11 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy
249 if err := transactionContext.CommitTransaction(); err != nil { 249 if err := transactionContext.CommitTransaction(); err != nil {
250 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 250 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
251 } 251 }
  252 + //选择导出的评估项
  253 + includeCol := map[string]struct{}{}
  254 + for _, v := range param.ExportItems {
  255 + includeCol[v.Category+"+"+v.Name] = struct{}{}
  256 + }
252 257
253 //处理查询到的数据 258 //处理查询到的数据
254 //汇总 Excel表格的表头描述 259 //汇总 Excel表格的表头描述
@@ -259,6 +264,11 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy @@ -259,6 +264,11 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy
259 if v.ContentId == 0 { 264 if v.ContentId == 0 {
260 continue 265 continue
261 } 266 }
  267 + if len(includeCol) > 0 {
  268 + if _, ok := includeCol[v.Category+"+"+v.ContentName]; !ok {
  269 + continue
  270 + }
  271 + }
262 level1Item := "" 272 level1Item := ""
263 for _, v1 := range level1 { 273 for _, v1 := range level1 {
264 if v.Category == v1 { 274 if v.Category == v1 {
@@ -354,6 +364,11 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy @@ -354,6 +364,11 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy
354 tableRows[v.TargetUserId]["TargetUserName"] = v.TargetUserName 364 tableRows[v.TargetUserId]["TargetUserName"] = v.TargetUserName
355 tableRows[v.TargetUserId]["BeginDay"] = v.BeginDay 365 tableRows[v.TargetUserId]["BeginDay"] = v.BeginDay
356 if v.ContentId > 0 { 366 if v.ContentId > 0 {
  367 + if len(includeCol) > 0 {
  368 + if _, ok := includeCol[v.Category+"+"+v.ContentName]; !ok {
  369 + continue
  370 + }
  371 + }
357 value := []string{v.Value} 372 value := []string{v.Value}
358 for _, v2 := range v.Remark { 373 for _, v2 := range v.Remark {
359 value = append(value, v2.RemarkText) 374 value = append(value, v2.RemarkText)
@@ -611,29 +626,36 @@ func (srv StaffAssessServeice) ExportUserAssess2(param *query.SummaryCommand) (* @@ -611,29 +626,36 @@ func (srv StaffAssessServeice) ExportUserAssess2(param *query.SummaryCommand) (*
611 continue 626 continue
612 } 627 }
613 xlsxFile.SetCellStr(v, "B2", v) 628 xlsxFile.SetCellStr(v, "B2", v)
  629 + xlsxFile.MergeCell(v, "B2", "B4")
614 //填充第一列数据 630 //填充第一列数据
615 - xlsxFile.SetCellStr(v, "A2", cycleName)  
616 xlsxFile.SetCellStr(v, "A1", tableHeader.Name) 631 xlsxFile.SetCellStr(v, "A1", tableHeader.Name)
  632 + xlsxFile.SetCellStr(v, "A2", cycleName)
  633 + xlsxFile.MergeCell(v, "A2", "A4")
617 xlsxFile.SetCellStr(v, "A5", "权重") 634 xlsxFile.SetCellStr(v, "A5", "权重")
  635 + xlsxFile.MergeCell(v, "A5", "B5")
618 xlsxFile.SetCellStr(v, "A6", "评估标准") 636 xlsxFile.SetCellStr(v, "A6", "评估标准")
  637 + xlsxFile.MergeCell(v, "A6", "B6")
619 //日期 638 //日期
620 dayList := eData.userDayMap[v] 639 dayList := eData.userDayMap[v]
621 for ii, vv := range dayList { 640 for ii, vv := range dayList {
622 - if ii == 0 {  
623 - axis := fmt.Sprintf("A%d", ii+7)  
624 - xlsxFile.SetCellStr(v, axis, vv)  
625 - } else {  
626 - axis := fmt.Sprintf("A%d", 7+3*(ii+1)) 641 + //填写在第几行
  642 + axisNum := 7 + 3*ii
  643 + axis := fmt.Sprintf("A%d", axisNum)
627 xlsxFile.SetCellStr(v, axis, vv) 644 xlsxFile.SetCellStr(v, axis, vv)
  645 + axisEnd := fmt.Sprintf("B%d", axisNum+2)
  646 + xlsxFile.MergeCell(v, axis, axisEnd) //单元格高度按三个单元格合并
628 } 647 }
629 - } 648 + allColNum := 0 //计算总共有多少列
  649 + //第一行
630 for _, v2 := range tableHeader.Child { 650 for _, v2 := range tableHeader.Child {
  651 +
631 //第二行 652 //第二行
632 for _, v3 := range v2.Child { 653 for _, v3 := range v2.Child {
633 //第三行 654 //第三行
634 - for i4, v4 := range v3.Child { 655 + for _, v4 := range v3.Child {
  656 + allColNum++
635 //按列填充数据 657 //按列填充数据
636 - colName, _ := excelize.ColumnNumberToName(i4 + 3) //第3列开始 658 + colName, _ := excelize.ColumnNumberToName(allColNum + 2) //第3列开始
637 xlsxFile.SetCellStr(v, colName+"2", v2.Name) //分类 659 xlsxFile.SetCellStr(v, colName+"2", v2.Name) //分类
638 xlsxFile.SetCellStr(v, colName+"3", v3.Name) //加分项 得分项 660 xlsxFile.SetCellStr(v, colName+"3", v3.Name) //加分项 得分项
639 xlsxFile.SetCellStr(v, colName+"4", v4.Name) // 评估项名称 661 xlsxFile.SetCellStr(v, colName+"4", v4.Name) // 评估项名称
@@ -645,17 +667,22 @@ func (srv StaffAssessServeice) ExportUserAssess2(param *query.SummaryCommand) (* @@ -645,17 +667,22 @@ func (srv StaffAssessServeice) ExportUserAssess2(param *query.SummaryCommand) (*
645 //按日期填充评估的填写的值 667 //按日期填充评估的填写的值
646 for i5, v5 := range dayList { 668 for i5, v5 := range dayList {
647 k1 := eData.dataKey(v, v5, v2.Name, v3.Name, v4.Name) 669 k1 := eData.dataKey(v, v5, v2.Name, v3.Name, v4.Name)
648 - if i5 > 0 {  
649 - axis := fmt.Sprintf("%s%d", colName, 7+3*(i5+1)) //单元格高度按三个单元格合并  
650 - xlsxFile.SetCellStr(v, axis, eData.data[k1].String())  
651 - } else {  
652 - axis := fmt.Sprintf("%s%d", colName, i5+7)  
653 - xlsxFile.SetCellStr(v, axis, eData.data[k1].String()) 670 + //填写在第几行
  671 + axisNum := 7 + 3*i5
  672 + axis := fmt.Sprintf("%s%d", colName, axisNum)
  673 + if d, ok := eData.data[k1]; ok {
  674 + xlsxFile.SetCellStr(v, axis, d.String())
654 } 675 }
  676 + //单元格高度按三个单元格合并
  677 + axisEnd := fmt.Sprintf("%s%d", colName, axisNum+2)
  678 + xlsxFile.MergeCell(v, axis, axisEnd)
655 } 679 }
656 } 680 }
657 } 681 }
658 } 682 }
  683 + //
  684 + colName, _ := excelize.ColumnNumberToName(allColNum + 2)
  685 + xlsxFile.MergeCell(v, "A1", fmt.Sprintf("%s1", colName))
659 } 686 }
660 //删除默认的第一个sheet 687 //删除默认的第一个sheet
661 xlsxFile.DeleteSheet(firstSheetName) 688 xlsxFile.DeleteSheet(firstSheetName)
@@ -697,7 +724,11 @@ func (srv StaffAssessServeice) QueryPerformanceIndicator(param *query.ListAssess @@ -697,7 +724,11 @@ func (srv StaffAssessServeice) QueryPerformanceIndicator(param *query.ListAssess
697 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 724 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
698 } 725 }
699 726
700 - headerList := HeaderLevel{} 727 + headerList := HeaderLevel{
  728 + Name: "",
  729 + Filter: map[string]int{},
  730 + Child: []HeaderLevel{},
  731 + }
701 for _, v := range contentItems { 732 for _, v := range contentItems {
702 child := headerList.addChild(v.Category) 733 child := headerList.addChild(v.Category)
703 child.addChild(v.Name) 734 child.addChild(v.Name)
@@ -1134,7 +1134,7 @@ func (d *StaffAssessDao) SearchContentCategoryName(companyId int, cycleId int, u @@ -1134,7 +1134,7 @@ func (d *StaffAssessDao) SearchContentCategoryName(companyId int, cycleId int, u
1134 target_user_id,target_user_name 1134 target_user_id,target_user_name
1135 order by cnt desc,target_user_id 1135 order by cnt desc,target_user_id
1136 ` 1136 `
1137 - sqlStr0 := d.useTStaffAssess(companyId, cycleId, userId, "", hrbp, 0, 5000, string(domain.AssessSelf)) 1137 + sqlStr0 := d.useTStaffAssess(companyId, cycleId, userId, "", hrbp, 5000, 0, string(domain.AssessSelf))
1138 sqlStr = sqlStr0 + sqlStr 1138 sqlStr = sqlStr0 + sqlStr
1139 tx := d.transactionContext.PgTx 1139 tx := d.transactionContext.PgTx
1140 result := []ContentCategoryName{} 1140 result := []ContentCategoryName{}
@@ -342,7 +342,7 @@ func (c *StaffAssessController) ListAssessContentIndicator() { @@ -342,7 +342,7 @@ func (c *StaffAssessController) ListAssessContentIndicator() {
342 // 根据周期里的考核日期,获取员工填写评估内容列表,导出为xlsx文件 342 // 根据周期里的考核日期,获取员工填写评估内容列表,导出为xlsx文件
343 func (c *StaffAssessController) ExportAssessContentCycleDay() { 343 func (c *StaffAssessController) ExportAssessContentCycleDay() {
344 srv := service.NewStaffAssessServeice() 344 srv := service.NewStaffAssessServeice()
345 - paramReq := &query.ListAssessContentCycleDay{} 345 + paramReq := &query.ExportAssessContentCycleDay{}
346 err := c.BindJSON(paramReq) 346 err := c.BindJSON(paramReq)
347 if err != nil { 347 if err != nil {
348 e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) 348 e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())