...
|
...
|
@@ -196,3 +196,158 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs |
|
|
}
|
|
|
return &result, nil
|
|
|
}
|
|
|
|
|
|
type excelTableHeader struct {
|
|
|
Level1 string
|
|
|
Level2 string
|
|
|
Level3 string
|
|
|
Level4 string
|
|
|
}
|
|
|
|
|
|
func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCycleDay) ([]byte, 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()
|
|
|
}()
|
|
|
|
|
|
roleRepo := factory.CreateRoleRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
_, roleList, err := roleRepo.Find(map[string]interface{}{
|
|
|
"type": domain.RoleTypeSystem,
|
|
|
"companyId": param.CompanyId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error())
|
|
|
}
|
|
|
_, userRoleList, err := roleUserRepo.Find(map[string]interface{}{
|
|
|
"companyId": param.CompanyId,
|
|
|
"userId": param.OperaterId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())
|
|
|
}
|
|
|
hrbp := -1
|
|
|
for _, v := range userRoleList {
|
|
|
for _, v2 := range roleList {
|
|
|
if v.RoleId == v2.Id {
|
|
|
hrbp = 1
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
if hrbp == 1 {
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
assessDao := dao.NewStaffAssessDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
contentList, err := assessDao.ExportDataUserAssess(dao.SearchConditin1{
|
|
|
CompanyId: param.CompanyId,
|
|
|
CycleId: param.CycleId,
|
|
|
BeginDay: param.BeginDay,
|
|
|
TargetUserName: param.TargetUserName,
|
|
|
Limit: 5000,
|
|
|
Offset: 0,
|
|
|
OperaterId: param.OperaterId,
|
|
|
Hrbp: hrbp,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取数据列表"+err.Error())
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
//处理查询到的数据
|
|
|
//汇总 Excel表格的表头描述
|
|
|
level1 := []string{} //分类
|
|
|
level3 := map[string][]string{} // key=分类+得分项类型 val=名称
|
|
|
level4 := map[string]string{} //key=分类+名称 val=评估标准
|
|
|
for _, v := range contentList {
|
|
|
level1Item := ""
|
|
|
for _, v1 := range level1 {
|
|
|
if v.Category == v1 {
|
|
|
level1Item = v1
|
|
|
}
|
|
|
}
|
|
|
if len(level1Item) == 0 {
|
|
|
level1 = append(level1, v.Category)
|
|
|
}
|
|
|
if v.Weight == 0 {
|
|
|
level3Key := v.Category + "-加分项"
|
|
|
if _, ok := level3[level3Key]; !ok {
|
|
|
level3[level3Key] = []string{}
|
|
|
}
|
|
|
level3Item := ""
|
|
|
for _, v3 := range level3[level3Key] {
|
|
|
if v3 == v.ContentName {
|
|
|
level3Item = v.ContentName
|
|
|
}
|
|
|
}
|
|
|
if len(level3Item) == 0 {
|
|
|
level3[level3Key] = append(level3[level3Key], v.ContentName)
|
|
|
}
|
|
|
}
|
|
|
if v.Weight > 0 {
|
|
|
level3Key := v.Category + "-得分项"
|
|
|
if _, ok := level3[level3Key]; !ok {
|
|
|
level3[level3Key] = []string{}
|
|
|
}
|
|
|
level3Item := ""
|
|
|
for _, v3 := range level3[level3Key] {
|
|
|
if v3 == v.ContentName {
|
|
|
level3Item = v.ContentName
|
|
|
}
|
|
|
}
|
|
|
if len(level3Item) == 0 {
|
|
|
level3[level3Key] = append(level3[level3Key], v.ContentName)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
level4Key := v.Category + "+" + v.ContentName
|
|
|
if _, ok := level4[level4Key]; !ok {
|
|
|
level4[level4Key] = v.PromptText
|
|
|
}
|
|
|
}
|
|
|
//汇总表头
|
|
|
headerList := []excelTableHeader{}
|
|
|
for _, v := range level1 {
|
|
|
item := excelTableHeader{
|
|
|
Level1: v,
|
|
|
}
|
|
|
level3Key := v + "-加分项"
|
|
|
if _, ok := level3[level3Key]; ok {
|
|
|
for _, v2 := range level3[level3Key] {
|
|
|
item.Level2 = "加分项"
|
|
|
item.Level3 = v2
|
|
|
level4Key := v + "+" + v2
|
|
|
item.Level4 = level4[level4Key]
|
|
|
headerList = append(headerList, item)
|
|
|
}
|
|
|
}
|
|
|
level3Key = v + "-得分项"
|
|
|
if _, ok := level3[level3Key]; ok {
|
|
|
for _, v2 := range level3[level3Key] {
|
|
|
item.Level2 = "得分项"
|
|
|
item.Level3 = v2
|
|
|
level4Key := v + "+" + v2
|
|
|
item.Level4 = level4[level4Key]
|
|
|
headerList = append(headerList, item)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
// tab
|
|
|
return nil, nil
|
|
|
} |
...
|
...
|
|