会员-按分工会/单位导出

This commit is contained in:
=
2025-11-27 16:04:56 +08:00
parent 4b12f3d5a5
commit 075af05eb6
3 changed files with 60 additions and 1 deletions
@@ -1,8 +1,16 @@
package com.budwk.app.zhgh.staffmanage.member.controller.statistics;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.date.DateUtil;
import com.budwk.app.base.result.Result;
import com.budwk.app.base.utils.CommonDownloadUtil;
import com.budwk.app.zhgh.staffmanage.member.service.MemberStatisticsService;
import com.budwk.app.zhgh.user.singleTeacher.param.SingleTeacherPageForm;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.Workbook;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
@@ -80,4 +88,44 @@ public class MemberSummaryController {
e.printStackTrace();
}
}
@At
@Ok("void")
@SaCheckPermission("member.statistics.summary")
@ApiOperation("导出Excel")
public void exportExcel(@Param("queryId") String queryId, @Param("queryType") String queryType,
@Param("currentYear") Integer currentYear, HttpServletResponse response) {
if (currentYear == null) {
currentYear = DateUtil.thisYear();
}
List<NutMap> list = new ArrayList<>();
if ("fgh".equals(queryType)) {
list = memberStatisticsService.getUnionStatisticsData(queryId, currentYear);
} else {
list = memberStatisticsService.getUnitStatisticsData(queryId, currentYear);
}
NutMap totalMap = NutMap.NEW();
totalMap.put("单位名称", "合计");
totalMap.put("总人数", list.stream().mapToInt(v -> v.getInt("totalNumber", 0)).sum());
list.add(totalMap);
List<ExcelExportEntity> entities = new ArrayList<>();
if ("fgh".equals(queryType)) {
entities.add(new ExcelExportEntity("分工会", "unionName", 20));
} else {
entities.add(new ExcelExportEntity("单位", "unitName", 20));
entities.add(new ExcelExportEntity("分工会", "unionName", 20));
}
entities.add(new ExcelExportEntity("总人数", "totalNumber", 15));
try {
ExportParams exportParams = new ExportParams();
exportParams.setType(ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entities, list);
CommonDownloadUtil.download("会员人数统计.xlsx", workbook, response);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -362,6 +362,7 @@ public class MemberStatisticsServiceImpl extends BaseServiceImpl<Sys_user> imple
un.id,
un.unitcode AS unitCode,
un.`name` AS unitName,
uni.`name`AS unionName,
SUM(CASE WHEN TIMESTAMPDIFF(YEAR, u.birthday, CURDATE()) <= 40 $personCnd $yearCnd THEN 1 ELSE 0 END) AS smallForty,
SUM(CASE WHEN TIMESTAMPDIFF(YEAR, u.birthday, CURDATE()) >= 41 AND TIMESTAMPDIFF(YEAR, u.birthday, CURDATE()) <= 50 $personCnd $yearCnd THEN 1 ELSE 0 END) AS smallFifty,
SUM(CASE WHEN TIMESTAMPDIFF(YEAR, u.birthday, CURDATE()) >= 51 AND TIMESTAMPDIFF(YEAR, u.birthday, CURDATE()) <= 55 $personCnd $yearCnd THEN 1 ELSE 0 END) AS smallFiftyFive,
@@ -371,6 +372,7 @@ public class MemberStatisticsServiceImpl extends BaseServiceImpl<Sys_user> imple
SUM(CASE WHEN sex = '女' $personCnd $yearCnd THEN 1 ELSE 0 END) AS femaleMember
FROM
sys_unit un
LEFT JOIN sys_union uni ON uni.id = un.unionId
JOIN $table u ON u.unitId = un.id AND u.member = 1
$condition
""");
@@ -42,7 +42,9 @@ layout("/layouts/platform.html"){
</el-card>
<el-card shadow="never" class="mt10">
<table-tool label="会员统计"></table-tool>
<table-tool label="会员统计">
<el-button size="mini" type="primary" icon="el-icon-download" @click="exportExcel">导出</el-button>
</table-tool>
<el-table :data="tableData" show-summary>
<el-table-column
align="center"
@@ -90,6 +92,13 @@ layout("/layouts/platform.html"){
}
},
methods: {
exportExcel() {
this.$downLoad("/platform/member/statistics/summary/exportExcel", {
queryId: this.pageForm.queryId,
queryType: this.pageForm.queryType,
currentYear: this.pageForm.currentYear
})
},
doExport() {},
initData() {
if (this.$auth.hasRoleOr(["SYSADMIN", "SCHOOL_UNION_ADMIN"])) {