export.go
2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package service
import (
"github.com/linmadan/egglib-go/core/application"
"github.com/xuri/excelize/v2"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
)
// 数据导出
func (srv *StaffAssessServeice) ExportUserAssess2V2(param *query.ExportUserAssess2Commad) (*excelize.File, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
hrbp, err := srv.getHRBP(transactionContext, param.CompanyId, param.OperatorId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
assessDao := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
// 按照cycleId获取项目的指标项
evaluationItemList, err := assessDao.SearchEvaluationItemUsed2(param.CompanyId,
param.CycleId, param.OperatorId, hrbp, param.ExportUserId)
// 按照项目获取填写的内容
assessContentList, err := assessDao.SearchEvaluationItemUsed2(param.CompanyId,
param.CycleId, param.OperatorId, hrbp, param.ExportUserId)
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil, nil
}
// 处理原始数据,方便进行 excel导出
type exportData3 struct {
sheetList []string //excel的sheet列表
tableHeader map[string]*HeaderLevel //表头数据
}
func (e *exportData3) FormatTableHead(param []dao.DataEvaluationItemUsed2) {
userNameMap := map[string]struct{}{} //员工名字过滤
userProjcetMap := map[string]map[string]string{}
userIdName := map[string]string{} //员工id=> 员工名称
sheetMap := HeaderLevel{}
for _, val := range param {
// child := sheetMap.addChild(val.TargetUserId)
// _ = child.addChild(val.EvaluationProjectId)
if _, ok := userNameMap[val.TargetUserId]; !ok {
userProjcetMap[val.TargetUserId] = map[string]string{}
}
userProjcetMap[val.TargetUserId][val.EvaluationProjectId] = ""
if _, ok := userIdName[val.TargetUserId]; !ok {
userIdName[val.TargetUserId] = val.TargetUserName
userNameMap[val.TargetUserName] = struct{}{}
}
}
for _, val := range sheetMap.Child {
}
}
func (e *exportData3) FormatListValue(param []dao.DataStaffAssessContent2) {
}
func (e *exportData3) DataKey(userName string, projectId string, beginDay string, category string, weight string, contentName string) string {
return ""
}