职工福利-选择福利统计-新增: 导出选择福利统计表(补充最后一行的合计数据);
This commit is contained in:
+44
-8
@@ -7,6 +7,7 @@ import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
|||||||
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||||||
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||||
import cn.afterturn.easypoi.excel.export.ExcelExportService;
|
import cn.afterturn.easypoi.excel.export.ExcelExportService;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import io.v.nutz.base.annontation.ViReturn;
|
import io.v.nutz.base.annontation.ViReturn;
|
||||||
import io.v.nutz.base.utils.MsgApi;
|
import io.v.nutz.base.utils.MsgApi;
|
||||||
@@ -863,26 +864,61 @@ public class WelfareSingleController {
|
|||||||
|
|
||||||
NutMap nutMap = welfareSingleService.pageData(projectId, "", "", "", "");
|
NutMap nutMap = welfareSingleService.pageData(projectId, "", "", "", "");
|
||||||
List<NutMap> tableList = nutMap.getAsList("tableList", NutMap.class);
|
List<NutMap> tableList = nutMap.getAsList("tableList", NutMap.class);
|
||||||
// Json.fromJsonAsList()
|
List<NutMap> labelList = nutMap.getAsList("tableColumn", NutMap.class);
|
||||||
|
|
||||||
|
int xh = 0;
|
||||||
|
int isAuditCount = 0;
|
||||||
|
ArrayList<Integer> countList = new ArrayList<>();
|
||||||
for (NutMap map : tableList) {
|
for (NutMap map : tableList) {
|
||||||
boolean isAudit = (boolean) map.get("isAudit");
|
map.setv("xh", ++xh);
|
||||||
|
boolean isAudit = map.getBoolean("isAudit");
|
||||||
map.setv("isAudit", isAudit ? "已核对" : "未核对");
|
map.setv("isAudit", isAudit ? "已核对" : "未核对");
|
||||||
|
if (isAudit) {
|
||||||
|
isAuditCount++;
|
||||||
|
}
|
||||||
|
/*if (CollectionUtil.isNotEmpty(labelList)) {
|
||||||
|
for (int i = 0; i < labelList.size(); i++) {
|
||||||
|
String prop = labelList.get(i).getString("prop");
|
||||||
|
if (countList.size() < labelList.size()) {
|
||||||
|
countList.add(0);
|
||||||
|
}
|
||||||
|
Integer integer = countList.get(i) == null ? 0 : countList.get(i);
|
||||||
|
countList.set(i, integer += map.getInt(prop));
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
//放入静态列的统计数据
|
||||||
|
NutMap countMap = NutMap.NEW();
|
||||||
|
if (CollectionUtil.isNotEmpty(tableList)) {
|
||||||
|
tableList.add(
|
||||||
|
countMap.addv("xh", "合计")
|
||||||
|
.addv("isAudit", isAuditCount)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//放入动态列的统计数据
|
||||||
|
if (CollectionUtil.isNotEmpty(labelList)) {
|
||||||
|
for (int i = 0; i < labelList.size(); i++) {
|
||||||
|
String prop = labelList.get(i).getString("prop");
|
||||||
|
// Integer sum = countList.get(i);
|
||||||
|
int sum = tableList.stream()
|
||||||
|
.filter(t -> t.get(prop) != null)
|
||||||
|
.mapToInt(t -> t.getInt(prop))
|
||||||
|
.sum();
|
||||||
|
countMap.addv(prop, sum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ExcelExportEntity> exportEntities = new ArrayList<>();
|
List<ExcelExportEntity> exportEntities = new ArrayList<>();
|
||||||
|
exportEntities.add(new ExcelExportEntity("", "xh", 20));
|
||||||
exportEntities.add(new ExcelExportEntity("所属工会", "welfareUnitName", 50));
|
exportEntities.add(new ExcelExportEntity("所属工会", "welfareUnitName", 50));
|
||||||
exportEntities.add(new ExcelExportEntity("本次福利会员人数", "teacherSum", 20));
|
|
||||||
//传入动态列 tableColumn
|
//传入动态列 tableColumn
|
||||||
List<NutMap> labelList = nutMap.getAsList("tableColumn", NutMap.class);
|
|
||||||
for (NutMap labeMap : labelList) {
|
for (NutMap labeMap : labelList) {
|
||||||
exportEntities.add(new ExcelExportEntity(labeMap.getString("label"), labeMap.get("prop"), 20));
|
exportEntities.add(new ExcelExportEntity(labeMap.getString("label"), labeMap.get("prop"), 20));
|
||||||
}
|
}
|
||||||
exportEntities.add(new ExcelExportEntity("参加人数", "totalCount", 20));
|
|
||||||
exportEntities.add(new ExcelExportEntity("未选人数", "unselectedTeacherSum", 20));
|
|
||||||
exportEntities.add(new ExcelExportEntity("是否核对", "isAudit", 20));
|
exportEntities.add(new ExcelExportEntity("是否核对", "isAudit", 20));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Workbook workbook = new XSSFWorkbook();
|
Workbook workbook = new XSSFWorkbook();
|
||||||
ExcelExportService service = new ExcelExportService();
|
ExcelExportService service = new ExcelExportService();
|
||||||
ExportParams exportParams = new ExportParams();
|
ExportParams exportParams = new ExportParams();
|
||||||
|
|||||||
Reference in New Issue
Block a user