diff --git a/evo-admin/src/main/java/com/evo/common/annotation/Excel.java b/evo-admin/src/main/java/com/evo/common/annotation/Excel.java index b147861..116e2e7 100644 --- a/evo-admin/src/main/java/com/evo/common/annotation/Excel.java +++ b/evo-admin/src/main/java/com/evo/common/annotation/Excel.java @@ -30,6 +30,16 @@ public @interface Excel */ public String name() default ""; + /** + * 是否在全部表展示, 默认true + */ + public boolean showAllSheet() default true; + /** + * 是否在第一页显示, 默认false + */ + public boolean showViewHome() default true; + + /** * 日期格式, 如: yyyy-MM-dd */ diff --git a/evo-admin/src/main/java/com/evo/common/utils/poi/ExcelUtilSs.java b/evo-admin/src/main/java/com/evo/common/utils/poi/ExcelUtilSs.java index f38b9c9..178f931 100644 --- a/evo-admin/src/main/java/com/evo/common/utils/poi/ExcelUtilSs.java +++ b/evo-admin/src/main/java/com/evo/common/utils/poi/ExcelUtilSs.java @@ -334,7 +334,10 @@ public class ExcelUtilSs{ for (int i = 0; i < fields2.size();i++){ Object[] os = fields2.get(i); Excel excel = (Excel) os[1]; - this.createCell(excel, row, column++,index); + Boolean show = excel.showAllSheet() ? true : (index == 0 && excel.showViewHome()) || (index != 0 && !excel.showViewHome()); + if(show){ + this.createCell(excel, row, column++,index); + } } // 产生一行 Integer lastIndex = (index == 0 ? list.size() :this.lists.get(index-1).size())+5; @@ -411,9 +414,12 @@ public class ExcelUtilSs{ for (Object[] os : fields2){ Field field = (Field) os[0]; Excel excel = (Excel) os[1]; - // 设置实体类私有属性可访问 - field.setAccessible(true); - this.addCell(excel, row, vo, field, column++,index); + Boolean show = excel.showAllSheet() ? true : (index == 0 && excel.showViewHome()) || (index != 0 && !excel.showViewHome()); + if(show){ + // 设置实体类私有属性可访问 + field.setAccessible(true); + this.addCell(excel, row, vo, field, column++,index); + } } } } diff --git a/evo-admin/src/main/java/com/evo/finance/domain/vo/SalaryVo.java b/evo-admin/src/main/java/com/evo/finance/domain/vo/SalaryVo.java index 31229a9..5e8ccc3 100644 --- a/evo-admin/src/main/java/com/evo/finance/domain/vo/SalaryVo.java +++ b/evo-admin/src/main/java/com/evo/finance/domain/vo/SalaryVo.java @@ -10,32 +10,25 @@ public class SalaryVo { @Excel(name = "部门名称") private String deptName; + + @Excel(name = "人数", showAllSheet = false) + private Integer peopleNum; + /** 员工姓名 */ - @Excel(name = "员工姓名") + @Excel(name = "员工姓名", showAllSheet = false, showViewHome = false) private String name; /** 员工姓名 */ - @Excel(name = "公司名称") + @Excel(name = "公司名称", showAllSheet = false,showViewHome = false) private String companyName; -// @Excel(name = "工资月份") -// private String month; /** 基本工资 */ @Excel(name = "月工资") private BigDecimal monthSalary; /** 应出勤(小时) */ - @Excel(name = "应出勤(小时)") + @Excel(name = "应出勤(小时)", showAllSheet = false, showViewHome = false) private BigDecimal shouldAttendance; /** 实出勤(小时) */ - @Excel(name = "实出勤(小时)") + @Excel(name = "实出勤(小时)", showAllSheet = false, showViewHome = false) private BigDecimal realAttendance; -// /** 基本工资 */ -// @Excel(name = "基本工资") -// private BigDecimal basicSalary; -// /** 岗位工资 */ -// @Excel(name = "岗位工资") -// private BigDecimal jobSalary; -// /** 加班工资 */ -// @Excel(name = "加班工资") -// private BigDecimal overtimeSalary; /** 学历补助 */ @Excel(name = "学历补助") private BigDecimal levelSubsidies; diff --git a/evo-admin/src/main/java/com/evo/finance/service/impl/RzSalaryDetailServiceImpl.java b/evo-admin/src/main/java/com/evo/finance/service/impl/RzSalaryDetailServiceImpl.java index 2398d59..fd02254 100644 --- a/evo-admin/src/main/java/com/evo/finance/service/impl/RzSalaryDetailServiceImpl.java +++ b/evo-admin/src/main/java/com/evo/finance/service/impl/RzSalaryDetailServiceImpl.java @@ -243,7 +243,9 @@ public class RzSalaryDetailServiceImpl extends ServiceImpl sheetCompanyNames = Collections.asList(companyDataList.keySet()).stream().sorted((x,y) -> { if(x.equals("河北伊特")){ return -1; - }else{ + }else if(y.equals("河北伊特")){ + return 1; + }else { return x.compareTo(y); } }).collect(Collectors.toList()); @@ -265,6 +267,7 @@ public class RzSalaryDetailServiceImpl extends ServiceImpl depts = deptDataList.get(sheetDeptName); SalaryVo result = sumSalaryVo(depts); result.setDeptName(sheetDeptName); + result.setPeopleNum(depts.size()); allList.add(result); SalaryVo hjResult = new SalaryVo(); BeanUtils.copyProperties(result,hjResult); @@ -274,17 +277,29 @@ public class RzSalaryDetailServiceImpl extends ServiceImpl sortList = dataList.stream().sorted((x,y) -> {return x.getDeptName().compareTo(y.getDeptName()); }).collect(Collectors.toList()); + sortList.add(hjResult); + companyLists.add(sortList); + }else{ + SalaryVo result = sumSalaryVo(dataList); + result.setDeptName(sheetCompanyName+"总计"); + result.setPeopleNum(dataList.size()); + allList.add(result); + + SalaryVo hjResult = new SalaryVo(); + BeanUtils.copyProperties(result,hjResult); + //处理公司的合计 + hjResult.setDeptName("合计"); + hjResult.setPeopleNum(dataList.size()); dataList.add(hjResult); companyLists.add(dataList); } @@ -293,7 +308,7 @@ public class RzSalaryDetailServiceImpl extends ServiceImpl!d.getDeptName().equals("小计")).collect(Collectors.toList())); result.setDeptName("总计"); allList.add(result); - allSheetNames.remove("河北伊特"); +// allSheetNames.remove("河北伊特"); companyLists.addAll(deptLists); return util.exportExcel(allList,companyLists,"总表", allSheetNames, new SimpleDateFormat("yyyy-MM").format(rzSalaryDetail.getMonth())+"月工资汇总表", "制表: "+"审核: "+"经理签字: "+"总经理签字:");