...
|
...
|
@@ -227,38 +227,7 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
//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,
|
|
|
})
|
...
|
...
|
@@ -595,56 +564,99 @@ func (srv StaffAssessServeice) ExportUserAssess2(param *query.SummaryCommand) (* |
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
roleRepo := factory.CreateRoleRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{
|
|
|
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,
|
|
|
})
|
|
|
_, roleList, err := roleRepo.Find(map[string]interface{}{
|
|
|
"type": domain.RoleTypeSystem,
|
|
|
"companyId": param.CompanyId,
|
|
|
})
|
|
|
// 获取所有的评估项
|
|
|
categoryNameList, err := assessDao.SearchContentCategoryName(param.CompanyId, param.CycleId, param.OperatorId, hrbp)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
_, userRoleList, err := roleUserRepo.Find(map[string]interface{}{
|
|
|
"companyId": param.CompanyId,
|
|
|
"userId": param.OperatorId,
|
|
|
})
|
|
|
//获取员工填写的评估
|
|
|
userAssessList, err := assessDao.ExportDataUserAssess2(
|
|
|
param.CompanyId,
|
|
|
param.CycleId,
|
|
|
param.OperatorId,
|
|
|
hrbp,
|
|
|
)
|
|
|
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
|
|
|
}
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
// assessDao := dao.NewStaffAssessDao(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// })
|
|
|
// 获取所有的评估项
|
|
|
// categoryNameList, err := assessDao.SearchContentCategoryName(param.CompanyId, param.CycleId, param.OperatorId, hrbp)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// categoryNameTree := map[string]headerLevel{}
|
|
|
// userNameMap := map[string]struct{}{} //处理员工重名
|
|
|
// userIdMap := map[string]string{} //映射员工id和员工名称
|
|
|
// userNameList := []string{} //员工名称列表
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// tableHeader := excelTableHeader{}
|
|
|
|
|
|
return nil, nil
|
|
|
eData := newExportData()
|
|
|
eData.setCategoryNameList(categoryNameList)
|
|
|
eData.setData(userAssessList)
|
|
|
xlsxFile := excelize.NewFile()
|
|
|
//设置默认的第一个sheet
|
|
|
sheetIndex := xlsxFile.GetActiveSheetIndex()
|
|
|
firstSheetName := xlsxFile.GetSheetName(sheetIndex)
|
|
|
cycleName := ""
|
|
|
if len(userAssessList) > 0 {
|
|
|
cycleName = userAssessList[0].CycleName
|
|
|
}
|
|
|
//填入excel 文件
|
|
|
for _, v := range eData.userName {
|
|
|
// 根据员工名称 添加一个sheet
|
|
|
xlsxFile.NewSheet(v)
|
|
|
//填写前4行数据
|
|
|
tableHeader, ok := eData.tableHeader[v]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
xlsxFile.SetCellStr(v, "B2", v)
|
|
|
//填充第一列数据
|
|
|
xlsxFile.SetCellStr(v, "A2", cycleName)
|
|
|
xlsxFile.SetCellStr(v, "A1", tableHeader.Name)
|
|
|
xlsxFile.SetCellStr(v, "A5", "权重")
|
|
|
xlsxFile.SetCellStr(v, "A6", "评估标准")
|
|
|
//日期
|
|
|
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", ii+7+2)
|
|
|
xlsxFile.SetCellStr(v, axis, vv)
|
|
|
}
|
|
|
}
|
|
|
for _, v2 := range tableHeader.Child {
|
|
|
//第二行
|
|
|
for _, v3 := range v2.Child {
|
|
|
//第三行
|
|
|
for i4, v4 := range v3.Child {
|
|
|
//按列填充数据
|
|
|
colName, _ := excelize.ColumnNumberToName(i4 + 3) //第3列开始
|
|
|
xlsxFile.SetCellStr(v, colName+"2", v2.Name) //分类
|
|
|
xlsxFile.SetCellStr(v, colName+"3", v3.Name) //加分项 得分项
|
|
|
xlsxFile.SetCellStr(v, colName+"4", v4.Name) // 评估项名称
|
|
|
//权重 填写第5行数据
|
|
|
k23 := eData.data23Key(v, v2.Name, v3.Name, v4.Name)
|
|
|
xlsxFile.SetCellStr(v, colName+"5", eData.data3[k23])
|
|
|
//评估标准 填写第6行数据
|
|
|
xlsxFile.SetCellStr(v, colName+"6", eData.data2[k23])
|
|
|
//按日期填充评估的填写的值
|
|
|
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, i5+7+2) //单元格高度按三个单元格合并
|
|
|
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())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//删除默认的第一个sheet
|
|
|
xlsxFile.DeleteSheet(firstSheetName)
|
|
|
return xlsxFile, nil
|
|
|
} |
...
|
...
|
|