作者 tangxvhui

更新 ,项目管理-成员列表导出

@@ -16,7 +16,6 @@ type ExportAssessContentCycleDay struct { @@ -16,7 +16,6 @@ type ExportAssessContentCycleDay struct {
16 CompanyId int `json:"companyId"` 16 CompanyId int `json:"companyId"`
17 OperaterId int `json:"operaterId"` 17 OperaterId int `json:"operaterId"`
18 CycleId int `json:"cycleId,string"` //周期id 18 CycleId int `json:"cycleId,string"` //周期id
19 - BeginDay string `json:"beginDay"` //评估开始的时间  
20 BeginDayList []string `json:"beginDayList"` //评估开始的时间 19 BeginDayList []string `json:"beginDayList"` //评估开始的时间
21 TargetUserName string `json:"targetUserName"` 20 TargetUserName string `json:"targetUserName"`
22 TargetUserId []string `json:"targetUserId"` 21 TargetUserId []string `json:"targetUserId"`
@@ -2,8 +2,6 @@ package service @@ -2,8 +2,6 @@ package service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 - "strconv"  
6 - "strings"  
7 5
8 "github.com/linmadan/egglib-go/core/application" 6 "github.com/linmadan/egglib-go/core/application"
9 "github.com/xuri/excelize/v2" 7 "github.com/xuri/excelize/v2"
@@ -211,223 +209,223 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs @@ -211,223 +209,223 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs
211 return &result, nil 209 return &result, nil
212 } 210 }
213 211
214 -func (srv StaffAssessServeice) ExportUserAssess(param *query.ExportAssessContentCycleDay) (*excelize.File, error) {  
215 - transactionContext, err := factory.CreateTransactionContext(nil)  
216 - if err != nil {  
217 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
218 - }  
219 - if err := transactionContext.StartTransaction(); err != nil {  
220 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
221 - }  
222 - defer func() {  
223 - _ = transactionContext.RollbackTransaction()  
224 - }()  
225 -  
226 - hrbp, err := srv.getHRBP(transactionContext, param.CompanyId, param.OperaterId)  
227 - if err != nil {  
228 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
229 - }  
230 -  
231 - assessDao := dao.NewStaffAssessDao(map[string]interface{}{  
232 - "transactionContext": transactionContext,  
233 - })  
234 - contentList, err := assessDao.ExportDataUserAssess(dao.SearchConditin1{  
235 - CompanyId: param.CompanyId,  
236 - CycleId: param.CycleId,  
237 - BeginDay: param.BeginDay,  
238 - TargetUserName: param.TargetUserName,  
239 - TargetUserId: param.TargetUserId,  
240 - Limit: 5000,  
241 - Offset: 0,  
242 - OperaterId: param.OperaterId,  
243 - Hrbp: hrbp,  
244 - })  
245 - if err != nil {  
246 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取数据列表"+err.Error())  
247 - }  
248 -  
249 - if err := transactionContext.CommitTransaction(); err != nil {  
250 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
251 - }  
252 - //选择导出的评估项  
253 - includeCol := map[string]struct{}{}  
254 - for _, v := range param.ExportItems {  
255 - includeCol[v.Category+"+"+v.Name] = struct{}{}  
256 - }  
257 -  
258 - //处理查询到的数据  
259 - //汇总 Excel表格的表头描述  
260 - level1 := []string{} //分类  
261 - level3 := map[string][]string{} //key=分类+得分项类型 val=名称  
262 - level4 := map[string]string{} //key=分类+名称 val=评估标准  
263 - for _, v := range contentList {  
264 - if v.ContentId == 0 {  
265 - continue  
266 - }  
267 - if len(includeCol) > 0 {  
268 - if _, ok := includeCol[v.Category+"+"+v.ContentName]; !ok {  
269 - continue  
270 - }  
271 - }  
272 - level1Item := ""  
273 - for _, v1 := range level1 {  
274 - if v.Category == v1 {  
275 - level1Item = v1  
276 - }  
277 - }  
278 - if len(level1Item) == 0 {  
279 - level1 = append(level1, v.Category)  
280 - }  
281 - if v.Weight == 0 {  
282 - level3Key := v.Category + "-加分项"  
283 - if _, ok := level3[level3Key]; !ok {  
284 - level3[level3Key] = []string{}  
285 - }  
286 - level3Item := ""  
287 - for _, v3 := range level3[level3Key] {  
288 - if v3 == v.ContentName {  
289 - level3Item = v.ContentName  
290 - }  
291 - }  
292 - if len(level3Item) == 0 {  
293 - level3[level3Key] = append(level3[level3Key], v.ContentName)  
294 - }  
295 - }  
296 - if v.Weight > 0 {  
297 - level3Key := v.Category + "-得分项"  
298 - if _, ok := level3[level3Key]; !ok {  
299 - level3[level3Key] = []string{}  
300 - }  
301 - level3Item := ""  
302 - for _, v3 := range level3[level3Key] {  
303 - if v3 == v.ContentName {  
304 - level3Item = v.ContentName  
305 - }  
306 - }  
307 - if len(level3Item) == 0 {  
308 - level3[level3Key] = append(level3[level3Key], v.ContentName)  
309 - }  
310 - }  
311 -  
312 - level4Key := v.Category + "+" + v.ContentName  
313 - if _, ok := level4[level4Key]; !ok {  
314 - level4[level4Key] = v.PromptText  
315 - }  
316 - }  
317 - //汇总表头,按列  
318 - headerList := []excelTableHeader{  
319 - {  
320 - Level1: "日期",  
321 - Level2: "",  
322 - Level3: "",  
323 - Level4: "评估标准",  
324 - }, {  
325 - Level1: "姓名",  
326 - Level2: "",  
327 - Level3: "",  
328 - Level4: "",  
329 - },  
330 - }  
331 - for _, v := range level1 {  
332 - item := excelTableHeader{  
333 - Level1: v,  
334 - }  
335 - level3Key := v + "-加分项"  
336 - if _, ok := level3[level3Key]; ok {  
337 - for _, v2 := range level3[level3Key] {  
338 - item.Level2 = "加分项"  
339 - item.Level3 = v2  
340 - level4Key := v + "+" + v2  
341 - item.Level4 = level4[level4Key]  
342 - headerList = append(headerList, item)  
343 - }  
344 - }  
345 - level3Key = v + "-得分项"  
346 - if _, ok := level3[level3Key]; ok {  
347 - for _, v2 := range level3[level3Key] {  
348 - item.Level2 = "得分项"  
349 - item.Level3 = v2  
350 - level4Key := v + "+" + v2  
351 - item.Level4 = level4[level4Key]  
352 - headerList = append(headerList, item)  
353 - }  
354 - }  
355 - }  
356 - //数据形式 进行 行列转换  
357 - tableRows := map[string]map[string]string{}  
358 - tableRowSort := []string{}  
359 - for _, v := range contentList {  
360 - if _, ok := tableRows[v.TargetUserId]; !ok {  
361 - tableRows[v.TargetUserId] = map[string]string{}  
362 - tableRowSort = append(tableRowSort, v.TargetUserId)  
363 - }  
364 - tableRows[v.TargetUserId]["TargetUserName"] = v.TargetUserName  
365 - tableRows[v.TargetUserId]["BeginDay"] = v.BeginDay  
366 - if v.ContentId > 0 {  
367 - if len(includeCol) > 0 {  
368 - if _, ok := includeCol[v.Category+"+"+v.ContentName]; !ok {  
369 - continue  
370 - }  
371 - }  
372 - value := []string{v.Value}  
373 - for _, v2 := range v.Remark {  
374 - value = append(value, v2.RemarkText)  
375 - }  
376 - key := v.Category + "+" + v.ContentName  
377 - tableRows[v.TargetUserId][key] = strings.Join(value, "\n")  
378 - }  
379 - }  
380 - //将数据写入xlsx  
381 - xlsxFile := excelize.NewFile()  
382 - sheetIndex := xlsxFile.GetActiveSheetIndex()  
383 - sheetName := xlsxFile.GetSheetName(sheetIndex)  
384 - //写入第一行  
385 - xlsxFile.SetCellStr(sheetName, "A1", "每日绩效汇总")  
386 - //写入二到五行  
387 - for k, v := range headerList {  
388 - colName, _ := excelize.ColumnNumberToName(k + 1)  
389 - xlsxFile.SetCellStr(sheetName, colName+"2", v.Level1)  
390 - xlsxFile.SetCellStr(sheetName, colName+"3", v.Level2)  
391 - xlsxFile.SetCellStr(sheetName, colName+"4", v.Level3)  
392 - xlsxFile.SetCellStr(sheetName, colName+"5", v.Level4)  
393 - }  
394 - //从第六行开始写入用户填写的评估数据  
395 - for k, v := range tableRowSort {  
396 - rowNum := strconv.Itoa(k + 6)  
397 - row := tableRows[v]  
398 - for k2, v2 := range headerList {  
399 - if k2 == 0 {  
400 - xlsxFile.SetCellStr(sheetName, "A"+rowNum, row["BeginDay"])  
401 - continue  
402 - }  
403 - if k2 == 1 {  
404 - xlsxFile.SetCellStr(sheetName, "B"+rowNum, row["TargetUserName"])  
405 - continue  
406 - }  
407 - colName, _ := excelize.ColumnNumberToName(k2 + 1)  
408 - key := v2.Level1 + "+" + v2.Level3  
409 - if mVal, ok := row[key]; ok {  
410 - xlsxFile.SetCellStr(sheetName, colName+rowNum, mVal)  
411 - }  
412 - }  
413 - }  
414 - //TODO 调整样式  
415 - xlsxFile.MergeCell(sheetName, "A2", "A4")  
416 - xlsxFile.MergeCell(sheetName, "B2", "B4")  
417 - xlsxFile.MergeCell(sheetName, "B5", "B5")  
418 - //设置行高  
419 - for i := range tableRowSort {  
420 - xlsxFile.SetRowHeight(sheetName, i+5, 50)  
421 - }  
422 - //设置列宽  
423 - for i := range headerList {  
424 - colName, _ := excelize.ColumnNumberToName(i + 1)  
425 - if i == 0 {  
426 - xlsxFile.SetColWidth(sheetName, colName, colName, 30)  
427 - }  
428 - }  
429 - return xlsxFile, nil  
430 -} 212 +// func (srv StaffAssessServeice) ExportUserAssess(param *query.ExportAssessContentCycleDay) (*excelize.File, error) {
  213 +// transactionContext, err := factory.CreateTransactionContext(nil)
  214 +// if err != nil {
  215 +// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  216 +// }
  217 +// if err := transactionContext.StartTransaction(); err != nil {
  218 +// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  219 +// }
  220 +// defer func() {
  221 +// _ = transactionContext.RollbackTransaction()
  222 +// }()
  223 +
  224 +// hrbp, err := srv.getHRBP(transactionContext, param.CompanyId, param.OperaterId)
  225 +// if err != nil {
  226 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  227 +// }
  228 +
  229 +// assessDao := dao.NewStaffAssessDao(map[string]interface{}{
  230 +// "transactionContext": transactionContext,
  231 +// })
  232 +// contentList, err := assessDao.ExportDataUserAssess(dao.SearchConditin1{
  233 +// CompanyId: param.CompanyId,
  234 +// CycleId: param.CycleId,
  235 +// BeginDay: param.BeginDay,
  236 +// TargetUserName: param.TargetUserName,
  237 +// TargetUserId: param.TargetUserId,
  238 +// Limit: 5000,
  239 +// Offset: 0,
  240 +// OperaterId: param.OperaterId,
  241 +// Hrbp: hrbp,
  242 +// })
  243 +// if err != nil {
  244 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取数据列表"+err.Error())
  245 +// }
  246 +
  247 +// if err := transactionContext.CommitTransaction(); err != nil {
  248 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  249 +// }
  250 +// //选择导出的评估项
  251 +// includeCol := map[string]struct{}{}
  252 +// for _, v := range param.ExportItems {
  253 +// includeCol[v.Category+"+"+v.Name] = struct{}{}
  254 +// }
  255 +
  256 +// //处理查询到的数据
  257 +// //汇总 Excel表格的表头描述
  258 +// level1 := []string{} //分类
  259 +// level3 := map[string][]string{} //key=分类+得分项类型 val=名称
  260 +// level4 := map[string]string{} //key=分类+名称 val=评估标准
  261 +// for _, v := range contentList {
  262 +// if v.ContentId == 0 {
  263 +// continue
  264 +// }
  265 +// if len(includeCol) > 0 {
  266 +// if _, ok := includeCol[v.Category+"+"+v.ContentName]; !ok {
  267 +// continue
  268 +// }
  269 +// }
  270 +// level1Item := ""
  271 +// for _, v1 := range level1 {
  272 +// if v.Category == v1 {
  273 +// level1Item = v1
  274 +// }
  275 +// }
  276 +// if len(level1Item) == 0 {
  277 +// level1 = append(level1, v.Category)
  278 +// }
  279 +// if v.Weight == 0 {
  280 +// level3Key := v.Category + "-加分项"
  281 +// if _, ok := level3[level3Key]; !ok {
  282 +// level3[level3Key] = []string{}
  283 +// }
  284 +// level3Item := ""
  285 +// for _, v3 := range level3[level3Key] {
  286 +// if v3 == v.ContentName {
  287 +// level3Item = v.ContentName
  288 +// }
  289 +// }
  290 +// if len(level3Item) == 0 {
  291 +// level3[level3Key] = append(level3[level3Key], v.ContentName)
  292 +// }
  293 +// }
  294 +// if v.Weight > 0 {
  295 +// level3Key := v.Category + "-得分项"
  296 +// if _, ok := level3[level3Key]; !ok {
  297 +// level3[level3Key] = []string{}
  298 +// }
  299 +// level3Item := ""
  300 +// for _, v3 := range level3[level3Key] {
  301 +// if v3 == v.ContentName {
  302 +// level3Item = v.ContentName
  303 +// }
  304 +// }
  305 +// if len(level3Item) == 0 {
  306 +// level3[level3Key] = append(level3[level3Key], v.ContentName)
  307 +// }
  308 +// }
  309 +
  310 +// level4Key := v.Category + "+" + v.ContentName
  311 +// if _, ok := level4[level4Key]; !ok {
  312 +// level4[level4Key] = v.PromptText
  313 +// }
  314 +// }
  315 +// //汇总表头,按列
  316 +// headerList := []excelTableHeader{
  317 +// {
  318 +// Level1: "日期",
  319 +// Level2: "",
  320 +// Level3: "",
  321 +// Level4: "评估标准",
  322 +// }, {
  323 +// Level1: "姓名",
  324 +// Level2: "",
  325 +// Level3: "",
  326 +// Level4: "",
  327 +// },
  328 +// }
  329 +// for _, v := range level1 {
  330 +// item := excelTableHeader{
  331 +// Level1: v,
  332 +// }
  333 +// level3Key := v + "-加分项"
  334 +// if _, ok := level3[level3Key]; ok {
  335 +// for _, v2 := range level3[level3Key] {
  336 +// item.Level2 = "加分项"
  337 +// item.Level3 = v2
  338 +// level4Key := v + "+" + v2
  339 +// item.Level4 = level4[level4Key]
  340 +// headerList = append(headerList, item)
  341 +// }
  342 +// }
  343 +// level3Key = v + "-得分项"
  344 +// if _, ok := level3[level3Key]; ok {
  345 +// for _, v2 := range level3[level3Key] {
  346 +// item.Level2 = "得分项"
  347 +// item.Level3 = v2
  348 +// level4Key := v + "+" + v2
  349 +// item.Level4 = level4[level4Key]
  350 +// headerList = append(headerList, item)
  351 +// }
  352 +// }
  353 +// }
  354 +// //数据形式 进行 行列转换
  355 +// tableRows := map[string]map[string]string{}
  356 +// tableRowSort := []string{}
  357 +// for _, v := range contentList {
  358 +// if _, ok := tableRows[v.TargetUserId]; !ok {
  359 +// tableRows[v.TargetUserId] = map[string]string{}
  360 +// tableRowSort = append(tableRowSort, v.TargetUserId)
  361 +// }
  362 +// tableRows[v.TargetUserId]["TargetUserName"] = v.TargetUserName
  363 +// tableRows[v.TargetUserId]["BeginDay"] = v.BeginDay
  364 +// if v.ContentId > 0 {
  365 +// if len(includeCol) > 0 {
  366 +// if _, ok := includeCol[v.Category+"+"+v.ContentName]; !ok {
  367 +// continue
  368 +// }
  369 +// }
  370 +// value := []string{v.Value}
  371 +// for _, v2 := range v.Remark {
  372 +// value = append(value, v2.RemarkText)
  373 +// }
  374 +// key := v.Category + "+" + v.ContentName
  375 +// tableRows[v.TargetUserId][key] = strings.Join(value, "\n")
  376 +// }
  377 +// }
  378 +// //将数据写入xlsx
  379 +// xlsxFile := excelize.NewFile()
  380 +// sheetIndex := xlsxFile.GetActiveSheetIndex()
  381 +// sheetName := xlsxFile.GetSheetName(sheetIndex)
  382 +// //写入第一行
  383 +// xlsxFile.SetCellStr(sheetName, "A1", "每日绩效汇总")
  384 +// //写入二到五行
  385 +// for k, v := range headerList {
  386 +// colName, _ := excelize.ColumnNumberToName(k + 1)
  387 +// xlsxFile.SetCellStr(sheetName, colName+"2", v.Level1)
  388 +// xlsxFile.SetCellStr(sheetName, colName+"3", v.Level2)
  389 +// xlsxFile.SetCellStr(sheetName, colName+"4", v.Level3)
  390 +// xlsxFile.SetCellStr(sheetName, colName+"5", v.Level4)
  391 +// }
  392 +// //从第六行开始写入用户填写的评估数据
  393 +// for k, v := range tableRowSort {
  394 +// rowNum := strconv.Itoa(k + 6)
  395 +// row := tableRows[v]
  396 +// for k2, v2 := range headerList {
  397 +// if k2 == 0 {
  398 +// xlsxFile.SetCellStr(sheetName, "A"+rowNum, row["BeginDay"])
  399 +// continue
  400 +// }
  401 +// if k2 == 1 {
  402 +// xlsxFile.SetCellStr(sheetName, "B"+rowNum, row["TargetUserName"])
  403 +// continue
  404 +// }
  405 +// colName, _ := excelize.ColumnNumberToName(k2 + 1)
  406 +// key := v2.Level1 + "+" + v2.Level3
  407 +// if mVal, ok := row[key]; ok {
  408 +// xlsxFile.SetCellStr(sheetName, colName+rowNum, mVal)
  409 +// }
  410 +// }
  411 +// }
  412 +// //TODO 调整样式
  413 +// xlsxFile.MergeCell(sheetName, "A2", "A4")
  414 +// xlsxFile.MergeCell(sheetName, "B2", "B4")
  415 +// xlsxFile.MergeCell(sheetName, "B5", "B5")
  416 +// //设置行高
  417 +// for i := range tableRowSort {
  418 +// xlsxFile.SetRowHeight(sheetName, i+5, 50)
  419 +// }
  420 +// //设置列宽
  421 +// for i := range headerList {
  422 +// colName, _ := excelize.ColumnNumberToName(i + 1)
  423 +// if i == 0 {
  424 +// xlsxFile.SetColWidth(sheetName, colName, colName, 30)
  425 +// }
  426 +// }
  427 +// return xlsxFile, nil
  428 +// }
431 429
432 //员工绩效-项目管理-矩阵分析 430 //员工绩效-项目管理-矩阵分析
433 431
@@ -710,7 +708,7 @@ func (srv StaffAssessServeice) QueryPerformanceIndicator(param *query.ListAssess @@ -710,7 +708,7 @@ func (srv StaffAssessServeice) QueryPerformanceIndicator(param *query.ListAssess
710 708
711 // 员工绩效-项目管理-成员列表导出 709 // 员工绩效-项目管理-成员列表导出
712 710
713 -func (srv StaffAssessServeice) ExportUserAssess3(param *query.ExportAssessContentCycleDay) (*excelize.File, error) { 711 +func (srv StaffAssessServeice) ExportUserAssess(param *query.ExportAssessContentCycleDay) (*excelize.File, error) {
714 transactionContext, err := factory.CreateTransactionContext(nil) 712 transactionContext, err := factory.CreateTransactionContext(nil)
715 if err != nil { 713 if err != nil {
716 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 714 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -733,7 +731,7 @@ func (srv StaffAssessServeice) ExportUserAssess3(param *query.ExportAssessConten @@ -733,7 +731,7 @@ func (srv StaffAssessServeice) ExportUserAssess3(param *query.ExportAssessConten
733 contentList, err := assessDao.ExportDataUserAssess(dao.SearchConditin1{ 731 contentList, err := assessDao.ExportDataUserAssess(dao.SearchConditin1{
734 CompanyId: param.CompanyId, 732 CompanyId: param.CompanyId,
735 CycleId: param.CycleId, 733 CycleId: param.CycleId,
736 - BeginDay: param.BeginDay, 734 + BeginDay: "",
737 TargetUserName: param.TargetUserName, 735 TargetUserName: param.TargetUserName,
738 TargetUserId: param.TargetUserId, 736 TargetUserId: param.TargetUserId,
739 Limit: 5000, 737 Limit: 5000,
@@ -753,6 +751,10 @@ func (srv StaffAssessServeice) ExportUserAssess3(param *query.ExportAssessConten @@ -753,6 +751,10 @@ func (srv StaffAssessServeice) ExportUserAssess3(param *query.ExportAssessConten
753 for _, v := range param.ExportItems { 751 for _, v := range param.ExportItems {
754 includeCol[v.Category+"+"+v.Name] = struct{}{} 752 includeCol[v.Category+"+"+v.Name] = struct{}{}
755 } 753 }
  754 + includeBeginDay := map[string]struct{}{}
  755 + for _, v := range param.BeginDayList {
  756 + includeBeginDay[v] = struct{}{}
  757 + }
756 758
757 eData := newExportData2() 759 eData := newExportData2()
758 eData.setData(contentList) 760 eData.setData(contentList)
@@ -768,65 +770,74 @@ func (srv StaffAssessServeice) ExportUserAssess3(param *query.ExportAssessConten @@ -768,65 +770,74 @@ func (srv StaffAssessServeice) ExportUserAssess3(param *query.ExportAssessConten
768 xlsxFile.MergeCell(sheetName, "B2", "B4") 770 xlsxFile.MergeCell(sheetName, "B2", "B4")
769 xlsxFile.SetCellStr(sheetName, "A5", "评估标准") 771 xlsxFile.SetCellStr(sheetName, "A5", "评估标准")
770 772
771 - //填充1,2 列 773 + //行数量
772 rowNum := 0 774 rowNum := 0
773 for _, v := range eData.rowSort.Child { 775 for _, v := range eData.rowSort.Child {
  776 + //纵向-索引-第一列-日期
  777 + if len(includeBeginDay) > 0 {
  778 + if _, ok := includeBeginDay[v.Name]; !ok {
  779 + continue
  780 + }
  781 + }
774 for _, v2 := range v.Child { 782 for _, v2 := range v.Child {
  783 + //纵向-索引-第二列-员工id
  784 + //填充1,2 列
775 rowNum++ 785 rowNum++
776 axisNum := fmt.Sprintf("%d", rowNum+5) 786 axisNum := fmt.Sprintf("%d", rowNum+5)
  787 + userName := eData.userIdMap[v2.Name]
777 xlsxFile.SetCellStr(sheetName, "A"+axisNum, v.Name) 788 xlsxFile.SetCellStr(sheetName, "A"+axisNum, v.Name)
778 - xlsxFile.SetCellStr(sheetName, "B"+axisNum, v2.Name) 789 + xlsxFile.SetCellStr(sheetName, "B"+axisNum, userName)
779 } 790 }
780 } 791 }
  792 + //列数量
  793 + colNum := 0
781 for _, v := range eData.tableHeader.Child { 794 for _, v := range eData.tableHeader.Child {
  795 + //横向-评估指标-分类
782 for _, v2 := range v.Child { 796 for _, v2 := range v.Child {
  797 + //横向-评估指标-加分项、得分项
783 for _, v3 := range v2.Child { 798 for _, v3 := range v2.Child {
784 - _ = v3 799 + // 横向-评估指标-名称
  800 + //检查是否在指定的导出选项中
  801 + if len(includeCol) > 0 {
  802 + if _, ok := includeCol[v.Name+"+"+v3.Name]; !ok {
  803 + continue
  804 + }
  805 + }
  806 + colNum++
  807 + //第几列
  808 + colName, _ := excelize.ColumnNumberToName(colNum + 2)
  809 + //填充 分类
  810 + xlsxFile.SetCellStr(sheetName, colName+"2", v.Name)
  811 + // 填充 加分项、得分项
  812 + xlsxFile.SetCellStr(sheetName, colName+"3", v2.Name)
  813 + // 填充 名称
  814 + xlsxFile.SetCellStr(sheetName, colName+"4", v3.Name)
  815 + if len(v3.Child) > 0 {
  816 + //填充, 评估标准
  817 + xlsxFile.SetCellStr(sheetName, colName+"5", v3.Child[0].Name)
  818 + }
  819 + xlsxFile.SetColWidth(sheetName, colName, colName, 30)
  820 + rowNum = 0
  821 + for _, v4 := range eData.rowSort.Child {
  822 + //纵向-索引-第一列-日期
  823 + if len(includeBeginDay) > 0 {
  824 + if _, ok := includeBeginDay[v.Name]; !ok {
  825 + continue
  826 + }
  827 + }
  828 + for _, v5 := range v4.Child {
  829 + //纵向-索引-第二列-员工id
  830 + rowNum++
  831 + axis := fmt.Sprintf("%s%d", colName, rowNum+5)
  832 + key := eData.dataKey(v5.Name, v4.Name, v.Name, v3.Name)
  833 + if d, ok := eData.data[key]; ok {
  834 + xlsxFile.SetCellStr(sheetName, axis, d.String())
  835 + }
  836 + xlsxFile.SetRowHeight(sheetName, rowNum+5, 50)
  837 + }
  838 + }
785 } 839 }
786 } 840 }
787 } 841 }
788 - //写入二到五行  
789 - // for k, v := range headerList {  
790 - // colName, _ := excelize.ColumnNumberToName(k + 1)  
791 - // xlsxFile.SetCellStr(sheetName, colName+"2", v.Level1)  
792 - // xlsxFile.SetCellStr(sheetName, colName+"3", v.Level2)  
793 - // xlsxFile.SetCellStr(sheetName, colName+"4", v.Level3)  
794 - // xlsxFile.SetCellStr(sheetName, colName+"5", v.Level4)  
795 - // }  
796 - //从第六行开始写入用户填写的评估数据  
797 - // for k, v := range tableRowSort {  
798 - // rowNum := strconv.Itoa(k + 6)  
799 - // row := tableRows[v]  
800 - // for k2, v2 := range headerList {  
801 - // if k2 == 0 {  
802 - // xlsxFile.SetCellStr(sheetName, "A"+rowNum, row["BeginDay"])  
803 - // continue  
804 - // }  
805 - // if k2 == 1 {  
806 - // xlsxFile.SetCellStr(sheetName, "B"+rowNum, row["TargetUserName"])  
807 - // continue  
808 - // }  
809 - // colName, _ := excelize.ColumnNumberToName(k2 + 1)  
810 - // key := v2.Level1 + "+" + v2.Level3  
811 - // if mVal, ok := row[key]; ok {  
812 - // xlsxFile.SetCellStr(sheetName, colName+rowNum, mVal)  
813 - // }  
814 - // }  
815 - // }  
816 - //TODO 调整样式  
817 - xlsxFile.MergeCell(sheetName, "A2", "A4")  
818 - xlsxFile.MergeCell(sheetName, "B2", "B4")  
819 - xlsxFile.MergeCell(sheetName, "B5", "B5")  
820 - // //设置行高  
821 - // for i := range tableRowSort {  
822 - // xlsxFile.SetRowHeight(sheetName, i+5, 50)  
823 - // }  
824 - // //设置列宽  
825 - // for i := range headerList {  
826 - // colName, _ := excelize.ColumnNumberToName(i + 1)  
827 - // if i == 0 {  
828 - // xlsxFile.SetColWidth(sheetName, colName, colName, 30)  
829 - // }  
830 - // }  
831 return xlsxFile, nil 842 return xlsxFile, nil
832 } 843 }
1 package controllers 1 package controllers
2 2
3 import ( 3 import (
4 - "fmt"  
5 -  
6 "github.com/linmadan/egglib-go/core/application" 4 "github.com/linmadan/egglib-go/core/application"
7 "github.com/linmadan/egglib-go/web/beego" 5 "github.com/linmadan/egglib-go/web/beego"
8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" 6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
@@ -356,8 +354,7 @@ func (c *StaffAssessController) ExportAssessContentCycleDay() { @@ -356,8 +354,7 @@ func (c *StaffAssessController) ExportAssessContentCycleDay() {
356 if err != nil { 354 if err != nil {
357 c.Response(nil, err) 355 c.Response(nil, err)
358 } 356 }
359 - fileName := fmt.Sprintf("每日绩效汇总%s", paramReq.BeginDay)  
360 - c.Ctx.Output.Header("Content-Disposition", "attachment;filename="+fileName) 357 + c.Ctx.Output.Header("Content-Disposition", "attachment;filename=每日绩效汇总")
361 c.Ctx.Output.Header("Content-Description", "FileTransfer") 358 c.Ctx.Output.Header("Content-Description", "FileTransfer")
362 c.Ctx.Output.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") 359 c.Ctx.Output.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
363 c.Ctx.Output.Header("Content-Transfer-Encoding", "binary") 360 c.Ctx.Output.Header("Content-Transfer-Encoding", "binary")