...
|
...
|
@@ -2,6 +2,7 @@ package service |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
|
|
|
"github.com/linmadan/egglib-go/core/application"
|
...
|
...
|
@@ -206,7 +207,7 @@ type excelTableHeader struct { |
|
|
Level4 string
|
|
|
}
|
|
|
|
|
|
func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCycleDay) ([]byte, error) {
|
|
|
func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCycleDay) (*excelize.File, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -382,7 +383,7 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy |
|
|
xlsxFile := excelize.NewFile()
|
|
|
sheetIndex := xlsxFile.GetActiveSheetIndex()
|
|
|
sheetName := xlsxFile.GetSheetName(sheetIndex)
|
|
|
// 写入第一行
|
|
|
//写入第一行
|
|
|
xlsxFile.SetCellStr(sheetName, "A1", "每日绩效汇总")
|
|
|
//写入二到五行
|
|
|
for k, v := range headerList {
|
...
|
...
|
@@ -393,5 +394,39 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy |
|
|
xlsxFile.SetCellStr(sheetName, colName+"5", v.Level4)
|
|
|
}
|
|
|
//从第六行开始写入用户填写的评估数据
|
|
|
return nil, nil
|
|
|
for k, v := range tableRowSort {
|
|
|
rowNum := strconv.Itoa(k + 6)
|
|
|
row := tableRows[v]
|
|
|
for k2, v2 := range headerList {
|
|
|
if k2 == 0 {
|
|
|
xlsxFile.SetCellStr(sheetName, "A"+rowNum, row["BeginDay"])
|
|
|
continue
|
|
|
}
|
|
|
if k2 == 1 {
|
|
|
xlsxFile.SetCellStr(sheetName, "B"+rowNum, row["TargetUserName"])
|
|
|
continue
|
|
|
}
|
|
|
colName, _ := excelize.ColumnNumberToName(k2 + 1)
|
|
|
key := v2.Level1 + "+" + v2.Level3
|
|
|
if mVal, ok := row[key]; ok {
|
|
|
xlsxFile.SetCellStr(sheetName, colName+rowNum, mVal)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//TODO 调整样式
|
|
|
xlsxFile.MergeCell(sheetName, "A2", "A4")
|
|
|
xlsxFile.MergeCell(sheetName, "B2", "B4")
|
|
|
xlsxFile.MergeCell(sheetName, "B5", "B5")
|
|
|
//设置行高
|
|
|
for i := range tableRowSort {
|
|
|
xlsxFile.SetRowHeight(sheetName, i+6, 50)
|
|
|
}
|
|
|
//设置列宽
|
|
|
for i := range headerList {
|
|
|
colName, _ := excelize.ColumnNumberToName(i + 1)
|
|
|
if i == 0 {
|
|
|
xlsxFile.SetColWidth(sheetName, colName, colName, 70)
|
|
|
}
|
|
|
}
|
|
|
return xlsxFile, nil
|
|
|
} |
...
|
...
|
|