作者 郑周

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

package adapter
type AssessAnalysisResp struct {
GroupList []string //评估指标项列表
Uncomplete []string // 未完成填写评估的员工
Complete map[string]AssessComplete //已完成填写的评估内容
UserCount map[string]int //各项员工数量
GroupList []string `json:"groupList"` //评估指标项列表
Uncomplete []string `json:"uncomplete"` // 未完成填写评估的员工
Complete map[string]AssessComplete `json:"complete"` //已完成填写的评估内容
UserCount map[string]int `json:"userCount"` //各项员工数量
}
type AssessComplete struct {
GroupKey string //评估指标项
Items []string //评估指标所有的评级
UserItem map[string][]string //每个评级下的员工名称
PercentItem map[string]string ///每个评级下的员工占比
CountItem map[string]int //每个评级下的员工数量
TotalUser int //填写该指标的员工数量
GroupKey string `json:"groupKey"` //评估指标项
Items []string `json:"items"` //评估指标所有的评级
UserItem map[string][]string `json:"userItem"` //每个评级下的员工名称
PercentItem map[string]string `json:"percentItem"` ///每个评级下的员工占比
CountItem map[string]int `json:"countItem"` //每个评级下的员工数量
TotalUser int `json:"totalUser"` //填写该指标的员工数量
}
... ...
package query
//根据周期id和日期获取 员工填写评估内容
// 根据周期id和日期获取 员工填写评估内容
type ListAssessContentCycleDay struct {
CompanyId int `json:"companyId"`
OperaterId int `json:"operaterId"`
... ... @@ -11,3 +11,16 @@ type ListAssessContentCycleDay struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
}
type ExportAssessContentCycleDay struct {
CompanyId int `json:"companyId"`
OperaterId int `json:"operaterId"`
CycleId int `json:"cycleId,string"` //周期id
BeginDay string `json:"beginDay"` //评估开始的时间
TargetUserName string `json:"targetUserName"`
TargetUserId []string `json:"targetUserId"`
ExportItems []struct {
Category string `json:"category"` //指标类别
Name string `json:"name"` //指标名称
} `json:"exportItems"`
}
... ...
... ... @@ -7,7 +7,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
)
// 员工绩效-综合管理-导出绩效指标
// 员工绩效-综合管理-导出绩效-个人
// excel表头部字段
type HeaderLevel struct {
... ... @@ -133,7 +133,7 @@ func (e *exportData) setData(param []*dao.ExportData2) {
if v.Weight == 0 {
e.data3[key23] = ""
} else {
e.data3[key23] = fmt.Sprintf("%.2f %%", v.Weight)
e.data3[key23] = fmt.Sprintf("%.2f%%", v.Weight)
}
}
}
... ...
... ... @@ -211,7 +211,7 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs
return &result, nil
}
func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCycleDay) (*excelize.File, error) {
func (srv StaffAssessServeice) ExportUserAssess(param *query.ExportAssessContentCycleDay) (*excelize.File, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -249,6 +249,11 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//选择导出的评估项
includeCol := map[string]struct{}{}
for _, v := range param.ExportItems {
includeCol[v.Category+"+"+v.Name] = struct{}{}
}
//处理查询到的数据
//汇总 Excel表格的表头描述
... ... @@ -259,6 +264,11 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy
if v.ContentId == 0 {
continue
}
if len(includeCol) > 0 {
if _, ok := includeCol[v.Category+"+"+v.ContentName]; !ok {
continue
}
}
level1Item := ""
for _, v1 := range level1 {
if v.Category == v1 {
... ... @@ -354,6 +364,11 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy
tableRows[v.TargetUserId]["TargetUserName"] = v.TargetUserName
tableRows[v.TargetUserId]["BeginDay"] = v.BeginDay
if v.ContentId > 0 {
if len(includeCol) > 0 {
if _, ok := includeCol[v.Category+"+"+v.ContentName]; !ok {
continue
}
}
value := []string{v.Value}
for _, v2 := range v.Remark {
value = append(value, v2.RemarkText)
... ... @@ -611,29 +626,36 @@ func (srv StaffAssessServeice) ExportUserAssess2(param *query.SummaryCommand) (*
continue
}
xlsxFile.SetCellStr(v, "B2", v)
xlsxFile.MergeCell(v, "B2", "B4")
//填充第一列数据
xlsxFile.SetCellStr(v, "A2", cycleName)
xlsxFile.SetCellStr(v, "A1", tableHeader.Name)
xlsxFile.SetCellStr(v, "A2", cycleName)
xlsxFile.MergeCell(v, "A2", "A4")
xlsxFile.SetCellStr(v, "A5", "权重")
xlsxFile.MergeCell(v, "A5", "B5")
xlsxFile.SetCellStr(v, "A6", "评估标准")
xlsxFile.MergeCell(v, "A6", "B6")
//日期
dayList := eData.userDayMap[v]
for ii, vv := range dayList {
if ii == 0 {
axis := fmt.Sprintf("A%d", ii+7)
xlsxFile.SetCellStr(v, axis, vv)
} else {
axis := fmt.Sprintf("A%d", 7+3*(ii+1))
//填写在第几行
axisNum := 7 + 3*ii
axis := fmt.Sprintf("A%d", axisNum)
xlsxFile.SetCellStr(v, axis, vv)
axisEnd := fmt.Sprintf("B%d", axisNum+2)
xlsxFile.MergeCell(v, axis, axisEnd) //单元格高度按三个单元格合并
}
}
allColNum := 0 //计算总共有多少列
//第一行
for _, v2 := range tableHeader.Child {
//第二行
for _, v3 := range v2.Child {
//第三行
for i4, v4 := range v3.Child {
for _, v4 := range v3.Child {
allColNum++
//按列填充数据
colName, _ := excelize.ColumnNumberToName(i4 + 3) //第3列开始
colName, _ := excelize.ColumnNumberToName(allColNum + 2) //第3列开始
xlsxFile.SetCellStr(v, colName+"2", v2.Name) //分类
xlsxFile.SetCellStr(v, colName+"3", v3.Name) //加分项 得分项
xlsxFile.SetCellStr(v, colName+"4", v4.Name) // 评估项名称
... ... @@ -645,17 +667,22 @@ func (srv StaffAssessServeice) ExportUserAssess2(param *query.SummaryCommand) (*
//按日期填充评估的填写的值
for i5, v5 := range dayList {
k1 := eData.dataKey(v, v5, v2.Name, v3.Name, v4.Name)
if i5 > 0 {
axis := fmt.Sprintf("%s%d", colName, 7+3*(i5+1)) //单元格高度按三个单元格合并
xlsxFile.SetCellStr(v, axis, eData.data[k1].String())
} else {
axis := fmt.Sprintf("%s%d", colName, i5+7)
xlsxFile.SetCellStr(v, axis, eData.data[k1].String())
//填写在第几行
axisNum := 7 + 3*i5
axis := fmt.Sprintf("%s%d", colName, axisNum)
if d, ok := eData.data[k1]; ok {
xlsxFile.SetCellStr(v, axis, d.String())
}
//单元格高度按三个单元格合并
axisEnd := fmt.Sprintf("%s%d", colName, axisNum+2)
xlsxFile.MergeCell(v, axis, axisEnd)
}
}
}
}
//
colName, _ := excelize.ColumnNumberToName(allColNum + 2)
xlsxFile.MergeCell(v, "A1", fmt.Sprintf("%s1", colName))
}
//删除默认的第一个sheet
xlsxFile.DeleteSheet(firstSheetName)
... ... @@ -697,7 +724,11 @@ func (srv StaffAssessServeice) QueryPerformanceIndicator(param *query.ListAssess
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
headerList := HeaderLevel{}
headerList := HeaderLevel{
Name: "",
Filter: map[string]int{},
Child: []HeaderLevel{},
}
for _, v := range contentItems {
child := headerList.addChild(v.Category)
child.addChild(v.Name)
... ...
... ... @@ -1134,7 +1134,7 @@ func (d *StaffAssessDao) SearchContentCategoryName(companyId int, cycleId int, u
target_user_id,target_user_name
order by cnt desc,target_user_id
`
sqlStr0 := d.useTStaffAssess(companyId, cycleId, userId, "", hrbp, 0, 5000, string(domain.AssessSelf))
sqlStr0 := d.useTStaffAssess(companyId, cycleId, userId, "", hrbp, 5000, 0, string(domain.AssessSelf))
sqlStr = sqlStr0 + sqlStr
tx := d.transactionContext.PgTx
result := []ContentCategoryName{}
... ...
... ... @@ -342,7 +342,7 @@ func (c *StaffAssessController) ListAssessContentIndicator() {
// 根据周期里的考核日期,获取员工填写评估内容列表,导出为xlsx文件
func (c *StaffAssessController) ExportAssessContentCycleDay() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListAssessContentCycleDay{}
paramReq := &query.ExportAssessContentCycleDay{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
... ...