|
@@ -1,6 +1,8 @@
|
|
package com.kcim.service.impl;
|
|
package com.kcim.service.impl;
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
|
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
|
|
|
+import cn.afterturn.easypoi.util.PoiCellUtil;
|
|
|
|
+import cn.afterturn.easypoi.util.PoiMergeCellUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
@@ -32,6 +34,10 @@ import org.apache.commons.fileupload.FileItemFactory;
|
|
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
|
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -49,6 +55,7 @@ import java.text.DecimalFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
+import java.util.stream.IntStream;
|
|
|
|
|
|
import static com.kcim.common.constants.Constant.PROFIT_REPORT_TYPE;
|
|
import static com.kcim.common.constants.Constant.PROFIT_REPORT_TYPE;
|
|
import static com.kcim.common.constants.ParameterConstant.MEDICAL_TECHNIQUES_SHARE_LEVEL_ID;
|
|
import static com.kcim.common.constants.ParameterConstant.MEDICAL_TECHNIQUES_SHARE_LEVEL_ID;
|
|
@@ -92,6 +99,9 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
|
|
|
private final String PERCENT = "占比";
|
|
private final String PERCENT = "占比";
|
|
|
|
|
|
|
|
+ private final String AMOUNT_FIELD = "amount";
|
|
|
|
+
|
|
|
|
+ private final String PERCENT_FIELD = "percent";
|
|
|
|
|
|
public CostDepartmentProfitServiceImpl(ReportFormService reportFormService, IncomeCollectionService incomeCollectionService, CostShareLevelService costShareLevelService, ResponsibilityService responsibilityService, ReportRelationService reportRelationService, AllocationService allocationService, AllocationQueryService allocationQueryService, FileRecordService fileRecordService, MinioConfig minioConfig, MinioFileUtil minioFileUtil, CenterService centerService, CostDepartmentProfitRepository costDepartmentProfitRepository) {
|
|
public CostDepartmentProfitServiceImpl(ReportFormService reportFormService, IncomeCollectionService incomeCollectionService, CostShareLevelService costShareLevelService, ResponsibilityService responsibilityService, ReportRelationService reportRelationService, AllocationService allocationService, AllocationQueryService allocationQueryService, FileRecordService fileRecordService, MinioConfig minioConfig, MinioFileUtil minioFileUtil, CenterService centerService, CostDepartmentProfitRepository costDepartmentProfitRepository) {
|
|
this.reportFormService = reportFormService;
|
|
this.reportFormService = reportFormService;
|
|
@@ -627,6 +637,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
Map<String, List<CostDepartmentProfit>> doctorParentMap = departmentProfits.stream().collect(Collectors.groupingBy(CostDepartmentProfit::getParentResponsibilityCode));
|
|
Map<String, List<CostDepartmentProfit>> doctorParentMap = departmentProfits.stream().collect(Collectors.groupingBy(CostDepartmentProfit::getParentResponsibilityCode));
|
|
// Map<String, List<CostDepartmentProfit>> yiParentMap = costDepartmentProfits.stream().collect(Collectors.groupingBy(CostDepartmentProfit::getParentResponsibilityCode));
|
|
// Map<String, List<CostDepartmentProfit>> yiParentMap = costDepartmentProfits.stream().collect(Collectors.groupingBy(CostDepartmentProfit::getParentResponsibilityCode));
|
|
|
|
|
|
|
|
+
|
|
//列
|
|
//列
|
|
List<TitleEntity> titleEntities = titleList.stream().filter(TitleEntity::isLast).collect(Collectors.toList());
|
|
List<TitleEntity> titleEntities = titleList.stream().filter(TitleEntity::isLast).collect(Collectors.toList());
|
|
List<Map<String, String>> rowList = new ArrayList<>();
|
|
List<Map<String, String>> rowList = new ArrayList<>();
|
|
@@ -673,6 +684,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
for (int i = 0; i < 2; i++) {
|
|
for (int i = 0; i < 2; i++) {
|
|
Map<String, String> m = new HashMap<String, String>();
|
|
Map<String, String> m = new HashMap<String, String>();
|
|
for (TitleEntity titleEntity : titleEntities) {
|
|
for (TitleEntity titleEntity : titleEntities) {
|
|
|
|
+
|
|
if (titleEntity.getId().equals("parentResponsibility")) {
|
|
if (titleEntity.getId().equals("parentResponsibility")) {
|
|
m.put("parent", v1.get(0).getParentResponsibilityName());
|
|
m.put("parent", v1.get(0).getParentResponsibilityName());
|
|
} else if (titleEntity.getId().equals("childResponsibility")) {
|
|
} else if (titleEntity.getId().equals("childResponsibility")) {
|
|
@@ -761,20 +773,73 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
} else {
|
|
} else {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
-// else {
|
|
|
|
-// TitleEntity entity = new TitleEntity();
|
|
|
|
-// entity.setId("amount"+reportForm.getId());
|
|
|
|
-// entity.setPid(String.valueOf(reportForm.getId()));
|
|
|
|
-// entity.setContent("金额");
|
|
|
|
-// entity.setFieldName("amount"+reportForm.getId());
|
|
|
|
-// titleList.add(entity);
|
|
|
|
-// TitleEntity entity1 = new TitleEntity();
|
|
|
|
-// entity1.setId("percent"+reportForm.getId());
|
|
|
|
-// entity1.setPid(String.valueOf(reportForm.getId()));
|
|
|
|
-// entity1.setContent("占比");
|
|
|
|
-// entity1.setFieldName("percent"+reportForm.getId());
|
|
|
|
-// titleList.add(entity1);
|
|
|
|
-// }
|
|
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ private boolean getChild(List<TitleEntity> titleList, String parentResponsibilityCode,
|
|
|
|
+ Map<String, List<ResponsibilityVo>> collect, Map<String, Long> responseCodeIdMap, String pid) {
|
|
|
|
+ List<ResponsibilityVo> forms = collect.get(parentResponsibilityCode);
|
|
|
|
+ if (!CollectionUtils.isEmpty(forms)) {
|
|
|
|
+ for (ResponsibilityVo form : forms) {
|
|
|
|
+ TitleEntity entity = new TitleEntity();
|
|
|
|
+ entity.setPid(pid);
|
|
|
|
+ entity.setContent(form.getResponsibilityName());
|
|
|
|
+ entity.setFieldName(form.getResponsibilityName());
|
|
|
|
+ entity.setWidth(10);
|
|
|
|
+ entity.setSort(1);
|
|
|
|
+ if(form.getResponsibilityCode().equals(parentResponsibilityCode)){
|
|
|
|
+ entity.setId(responseCodeIdMap.get(form.getResponsibilityCode())+"child");
|
|
|
|
+ entity.setLast(false);
|
|
|
|
+ titleList.add(entity);
|
|
|
|
+ //添加固定两列金额 占比
|
|
|
|
+ TitleEntity amountEntity = new TitleEntity();
|
|
|
|
+ amountEntity.setId(parentResponsibilityCode+"|"+AMOUNT_FIELD);
|
|
|
|
+ amountEntity.setPid(responseCodeIdMap.get(form.getResponsibilityCode())+"child");
|
|
|
|
+ amountEntity.setContent("金额");
|
|
|
|
+ amountEntity.setFieldName(parentResponsibilityCode+"|"+AMOUNT_FIELD);
|
|
|
|
+ amountEntity.setWidth(15);
|
|
|
|
+ amountEntity.setSort(2);
|
|
|
|
+ amountEntity.setLast(true);
|
|
|
|
+ titleList.add(amountEntity);
|
|
|
|
+ TitleEntity percentEntity = new TitleEntity();
|
|
|
|
+ percentEntity.setId(parentResponsibilityCode+"|"+PERCENT_FIELD);
|
|
|
|
+ percentEntity.setPid(responseCodeIdMap.get(form.getResponsibilityCode())+"child");
|
|
|
|
+ percentEntity.setContent("占比");
|
|
|
|
+ percentEntity.setFieldName(parentResponsibilityCode+"|"+PERCENT_FIELD);
|
|
|
|
+ percentEntity.setWidth(10);
|
|
|
|
+ percentEntity.setSort(2);
|
|
|
|
+ percentEntity.setLast(true);
|
|
|
|
+ titleList.add(percentEntity);
|
|
|
|
+ }else {
|
|
|
|
+ entity.setId(String.valueOf(responseCodeIdMap.get(form.getResponsibilityCode())));
|
|
|
|
+
|
|
|
|
+ boolean last = getChild(titleList, form.getResponsibilityCode(), collect, responseCodeIdMap, String.valueOf(responseCodeIdMap.get(form.getResponsibilityCode())));
|
|
|
|
+ entity.setLast(last);
|
|
|
|
+ titleList.add(entity);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //添加固定两列金额 占比
|
|
|
|
+ TitleEntity amountEntity = new TitleEntity();
|
|
|
|
+ amountEntity.setId(parentResponsibilityCode+"|"+AMOUNT_FIELD);
|
|
|
|
+ amountEntity.setPid(pid);
|
|
|
|
+ amountEntity.setContent("金额");
|
|
|
|
+ amountEntity.setFieldName(parentResponsibilityCode+"|"+AMOUNT_FIELD);
|
|
|
|
+ amountEntity.setWidth(15);
|
|
|
|
+ amountEntity.setSort(2);
|
|
|
|
+ amountEntity.setLast(true);
|
|
|
|
+ titleList.add(amountEntity);
|
|
|
|
+ TitleEntity percentEntity = new TitleEntity();
|
|
|
|
+ percentEntity.setId(parentResponsibilityCode+"|"+PERCENT_FIELD);
|
|
|
|
+ percentEntity.setPid(pid);
|
|
|
|
+ percentEntity.setContent("占比");
|
|
|
|
+ percentEntity.setFieldName(parentResponsibilityCode+"|"+PERCENT_FIELD);
|
|
|
|
+ percentEntity.setWidth(10);
|
|
|
|
+ percentEntity.setSort(2);
|
|
|
|
+ percentEntity.setLast(true);
|
|
|
|
+ titleList.add(percentEntity);
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -819,49 +884,40 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
if (CollectionUtils.isEmpty(dataVoList)) {
|
|
if (CollectionUtils.isEmpty(dataVoList)) {
|
|
throw new CostException("未找到损益报表类型字典");
|
|
throw new CostException("未找到损益报表类型字典");
|
|
}
|
|
}
|
|
- Map<String, DictDataVo> dictMap = dataVoList.stream().collect(Collectors.toMap(DictDataVo::getCode, vo -> vo, (a, b) -> b));
|
|
|
|
|
|
+// Map<String, DictDataVo> dictMap = dataVoList.stream().collect(Collectors.toMap(DictDataVo::getCode, vo -> vo, (a, b) -> b));
|
|
//去除全院损益字典
|
|
//去除全院损益字典
|
|
List<DictDataVo> collect = dataVoList.stream().filter(f -> f.getValue().equals(NumberConstant.ONE_S)).collect(Collectors.toList());
|
|
List<DictDataVo> collect = dataVoList.stream().filter(f -> f.getValue().equals(NumberConstant.ONE_S)).collect(Collectors.toList());
|
|
if(CollectionUtils.isEmpty(collect)){
|
|
if(CollectionUtils.isEmpty(collect)){
|
|
throw new CostException("未找到科室损益报表类型字典");
|
|
throw new CostException("未找到科室损益报表类型字典");
|
|
}
|
|
}
|
|
-// ExecutorService pool = Executors.newFixedThreadPool(5);
|
|
|
|
|
|
+// FileItemFactory factory = new DiskFileItemFactory(5242880, null);
|
|
|
|
+
|
|
|
|
+// FileItem fileItem = factory.createItem("file", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8", true, "测试用.xls");
|
|
|
|
+//// try {
|
|
|
|
+// OutputStream outputStream = fileItem.getOutputStream();
|
|
|
|
|
|
for (DictDataVo vo : collect) {
|
|
for (DictDataVo vo : collect) {
|
|
-// pool.execute(new Runnable() {
|
|
|
|
-// /**
|
|
|
|
-// * When an object implementing interface <code>Runnable</code> is used
|
|
|
|
-// * to create a thread, starting the thread causes the object's
|
|
|
|
-// * <code>run</code> method to be called in that separately executing
|
|
|
|
-// * thread.
|
|
|
|
-// * <p>
|
|
|
|
-// * The general contract of the method <code>run</code> is that it may
|
|
|
|
-// * take any action whatsoever.
|
|
|
|
-// *
|
|
|
|
-// * @see Thread#run()
|
|
|
|
-// */
|
|
|
|
-// @Override
|
|
|
|
-// public void run() {
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
-// });
|
|
|
|
|
|
+
|
|
Integer reportDictType = Integer.valueOf(vo.getCode());
|
|
Integer reportDictType = Integer.valueOf(vo.getCode());
|
|
|
|
|
|
String time = DateUtil.format(DateUtil.date(), "yyyy年MM月dd日HH时mm分ss秒");
|
|
String time = DateUtil.format(DateUtil.date(), "yyyy年MM月dd日HH时mm分ss秒");
|
|
|
|
|
|
FileItemFactory factory = new DiskFileItemFactory(5242880, null);
|
|
FileItemFactory factory = new DiskFileItemFactory(5242880, null);
|
|
|
|
|
|
- FileItem fileItem = factory.createItem("file", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8", true, vo.getName() + time + ".xls");
|
|
|
|
|
|
+ FileItem fileItem = factory.createItem("file", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8", true, vo.getName() + time + ".xlsx");
|
|
// try {
|
|
// try {
|
|
- OutputStream outputStream = fileItem.getOutputStream();
|
|
|
|
- getDepartmentProfit(date, outputStream, reportDictType,vo.getName());
|
|
|
|
|
|
+ OutputStream outputStream = fileItem.getOutputStream();
|
|
|
|
+// getDepartmentProfit(date, outputStream, reportDictType,vo.getName());
|
|
|
|
+ exportDepartmentProfit(date, outputStream, reportDictType,vo.getName());
|
|
|
|
+
|
|
|
|
+
|
|
// } catch (Exception e) {
|
|
// } catch (Exception e) {
|
|
// throw new RuntimeException(e);
|
|
// throw new RuntimeException(e);
|
|
// }
|
|
// }
|
|
MultipartFile multipartFile = new CommonsMultipartFile(fileItem);
|
|
MultipartFile multipartFile = new CommonsMultipartFile(fileItem);
|
|
String file = uploadFile(multipartFile);
|
|
String file = uploadFile(multipartFile);
|
|
FileRecord fileRecord = new FileRecord();
|
|
FileRecord fileRecord = new FileRecord();
|
|
- fileRecord.setFileName(vo.getName() + time + ".xls")
|
|
|
|
|
|
+ fileRecord.setFileName(vo.getName() + time + ".xlsx")
|
|
.setFileSource(reportType)
|
|
.setFileSource(reportType)
|
|
.setFileType(vo.getName())
|
|
.setFileType(vo.getName())
|
|
.setFileUrl(file)
|
|
.setFileUrl(file)
|
|
@@ -891,152 +947,6 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- private void handleDepartmentProfit(String date, OutputStream outputStream, Integer reportType, String name) throws Exception {
|
|
|
|
-
|
|
|
|
- Long hospId = UserContext.getHospId();
|
|
|
|
- DateTime dateTime = DateUtil.parse(date);
|
|
|
|
- int year = DateUtil.year(dateTime);
|
|
|
|
- int month = DateUtil.month(dateTime) + 1;
|
|
|
|
-
|
|
|
|
- Map<String,List<ColEntity>> heads = new HashMap<>();// 最终导出的多个sheet的表头
|
|
|
|
- Map<String,List<Map<String, String>>> datas = new HashMap<>();// 最终导出的多个sheet的内容
|
|
|
|
- Map<String,Integer> types = new HashMap<>();// 最终导出的每个sheet的样式类型
|
|
|
|
- Map<String,List<Integer>> autoRowHeights = new HashMap<>();// 最终导出的每个sheet的需要自适应行高的行号
|
|
|
|
- Map<String,List<Integer>> mergeIndexs = new HashMap<>();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // 查询所有的节点
|
|
|
|
- List<Responsibility> responsibilityList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId));
|
|
|
|
- if (CollUtil.isEmpty(responsibilityList)) {
|
|
|
|
- throw new CostException(500, "责任中心不存在");
|
|
|
|
- }
|
|
|
|
- Map<String, Long> responseCodeParentIdMap = responsibilityList.stream().collect(Collectors.toMap(Responsibility::getResponsibilityCode, Responsibility::getParentId, (a, b) -> b));
|
|
|
|
-
|
|
|
|
- Map<Long, Responsibility> responsibilityIdMap = responsibilityList.stream().collect(Collectors.toMap(Responsibility::getId, responsibility -> responsibility, (a, b) -> b));
|
|
|
|
-
|
|
|
|
- Map<String, Responsibility> responsibilityCodeMap = responsibilityList.stream().collect(Collectors.toMap(Responsibility::getResponsibilityCode, responsibility -> responsibility, (a, b) -> b));
|
|
|
|
-
|
|
|
|
- // 表头
|
|
|
|
- List<CostDepartmentProfit> departmentProfits = this.list(new QueryWrapper<CostDepartmentProfit>().lambda()
|
|
|
|
- .eq(CostDepartmentProfit::getHospId, hospId)
|
|
|
|
- .eq(CostDepartmentProfit::getYear, year).eq(CostDepartmentProfit::getMonth, month).eq(CostDepartmentProfit::getShareType, reportType));
|
|
|
|
- if (CollectionUtils.isEmpty(departmentProfits)) {
|
|
|
|
- throw new CostException(500, name+"未进行科室损益计算");
|
|
|
|
- }
|
|
|
|
- //损益报表数据没有 上级责任中心所以需要拼回去
|
|
|
|
- for (CostDepartmentProfit departmentProfit : departmentProfits) {
|
|
|
|
- Long aLong = responseCodeParentIdMap.get(departmentProfit.getResponsibilityCode());
|
|
|
|
- if (aLong != null) {
|
|
|
|
- if (aLong.equals(NumberConstant.ZERO_L)) {
|
|
|
|
- Responsibility responsibility = responsibilityCodeMap.get(departmentProfit.getResponsibilityCode());
|
|
|
|
- departmentProfit.setParentResponsibilityCode(departmentProfit.getResponsibilityCode());
|
|
|
|
- departmentProfit.setParentResponsibilityName(departmentProfit.getResponsibilityName());
|
|
|
|
- departmentProfit.setParentResponsibilityId(responsibility.getId());
|
|
|
|
- departmentProfit.setResponsibilityId(responsibility.getId());
|
|
|
|
- } else {
|
|
|
|
- Responsibility responsibility = responsibilityIdMap.get(aLong);
|
|
|
|
- Responsibility currentResponsibility = responsibilityCodeMap.get(departmentProfit.getResponsibilityCode());
|
|
|
|
- if (Objects.nonNull(responsibility)) {
|
|
|
|
- departmentProfit.setParentResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
|
- departmentProfit.setParentResponsibilityName(responsibility.getResponsibilityName());
|
|
|
|
- departmentProfit.setParentResponsibilityId(aLong);
|
|
|
|
- departmentProfit.setResponsibilityId(currentResponsibility.getId());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //损益表设置 行树层级
|
|
|
|
- List<ReportForm> reportFormList = reportFormService.list(new QueryWrapper<ReportForm>().lambda()
|
|
|
|
- .eq(ReportForm::getHospId, hospId)
|
|
|
|
- .eq(ReportForm::getReportType, reportType));
|
|
|
|
- if (CollUtil.isEmpty(reportFormList)) {
|
|
|
|
- throw new CostException(500, "损益表未找到");
|
|
|
|
- }
|
|
|
|
- Map<Long, List<ReportForm>> collect = reportFormList.stream().collect(Collectors.groupingBy(ReportForm::getParentId));
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //第一层
|
|
|
|
- List<TitleEntity> titleList = new ArrayList<>();
|
|
|
|
- titleList.add(new TitleEntity("0", null, name, false, NumberConstant.ZERO));
|
|
|
|
- //添加默认三列责任中心
|
|
|
|
-// setDefaultColumn(titleList);
|
|
|
|
- //行
|
|
|
|
- ArrayList<CostDepartmentProfit> headerDepartmentProfits = new ArrayList<>(departmentProfits.stream()
|
|
|
|
- .collect(Collectors.toMap(
|
|
|
|
- CostDepartmentProfit::getResponsibilityCode, // 以 responsibilityCode 作为 key
|
|
|
|
- profit -> profit, // 保留 profit 对象
|
|
|
|
- (existing, replacement) -> existing // 如果有重复的 responsibilityCode,保留已有的对象
|
|
|
|
- )).values());
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- Map<String, List<CostDepartmentProfit>> doctorParentMap = headerDepartmentProfits.stream().collect(Collectors.groupingBy(CostDepartmentProfit::getParentResponsibilityCode));
|
|
|
|
- AtomicReference<Integer> patentPid = new AtomicReference<>(1);
|
|
|
|
- doctorParentMap.forEach((parentResponsibilityCde,responseList)->{
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- Responsibility responsibility = responsibilityCodeMap.get(parentResponsibilityCde);
|
|
|
|
- TitleEntity entity = new TitleEntity();
|
|
|
|
- entity.setId(String.valueOf(responsibility.getId()));
|
|
|
|
- entity.setPid(String.valueOf(patentPid));
|
|
|
|
- entity.setContent(responsibility.getResponsibilityName());
|
|
|
|
- entity.setFieldName(String.valueOf(responsibility.getId()));
|
|
|
|
- entity.setWidth(20);
|
|
|
|
- responseList.forEach(f->{
|
|
|
|
- TitleEntity childEntity = new TitleEntity();
|
|
|
|
- childEntity.setId(String.valueOf(f.getResponsibilityId()));
|
|
|
|
- childEntity.setPid(f.getParentResponsibilityCode());
|
|
|
|
- childEntity.setContent(f.getResponsibilityName());
|
|
|
|
- childEntity.setFieldName(String.valueOf(f.getResponsibilityId()));
|
|
|
|
- childEntity.setWidth(20);
|
|
|
|
- childEntity.setLast(false);
|
|
|
|
- titleList.add(childEntity);
|
|
|
|
- getLastDefaultHeader(titleList,String.valueOf(f.getResponsibilityId()));
|
|
|
|
- });
|
|
|
|
- entity.setLast(false);
|
|
|
|
- titleList.add(entity);
|
|
|
|
- patentPid.getAndSet(patentPid.get() + 1);
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- //列
|
|
|
|
- List<TitleEntity> titleEntities = titleList.stream().filter(TitleEntity::isLast).collect(Collectors.toList());
|
|
|
|
- List<Map<String, String>> rowList = new ArrayList<>();
|
|
|
|
-
|
|
|
|
-// setRowList(doctorParentMap, titleEntities, rowList);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- ExcelPoiUtil excelTool = new ExcelPoiUtil(name);
|
|
|
|
- Map<String, String> param = ImmutableMap.<String, String>builder().put("id", "id").put("pid", "pid")
|
|
|
|
- .put("content", "content").put("fieldName", "fieldName").put("width", "width").build();
|
|
|
|
- List<ColEntity> titleData = excelTool.colEntityTransformer(titleList, param, "0");
|
|
|
|
-
|
|
|
|
- heads.put(name, titleData);// 每个sheet的表头,sheet名称为key
|
|
|
|
- datas.put(name, rowList);// 每个sheet的内容,sheet名称为key
|
|
|
|
-
|
|
|
|
- types.put(name, 0);// 每个sheet的样式类型,sheet名称为key
|
|
|
|
-// mergeIndexs.put(name, Arrays.asList(0, 1));// 每个sheet的默认行高,sheet名称为key
|
|
|
|
- autoRowHeights.put(name, Arrays.asList( 2, 3));
|
|
|
|
-
|
|
|
|
- // 多个sheet导出
|
|
|
|
- HSSFWorkbook workbook = excelTool.exportWorkbook(heads, datas, types, autoRowHeights, mergeIndexs);
|
|
|
|
- excelTool.save(workbook, "D:\\测试用.xls");
|
|
|
|
- workbook.write(outputStream);
|
|
|
|
- workbook.close();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
|
|
private void getLastDefaultHeader( List<TitleEntity> titleList,String responsibilityId){
|
|
private void getLastDefaultHeader( List<TitleEntity> titleList,String responsibilityId){
|
|
TitleEntity amountEntity = new TitleEntity();
|
|
TitleEntity amountEntity = new TitleEntity();
|
|
@@ -1861,4 +1771,304 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
}
|
|
}
|
|
return bigDecimal;
|
|
return bigDecimal;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void exportDepartmentProfit(String date, OutputStream outputStream, Integer reportType, String name) throws Exception {
|
|
|
|
+
|
|
|
|
+ Long hospId = UserContext.getHospId();
|
|
|
|
+ DateTime dateTime = DateUtil.parse(date);
|
|
|
|
+ int year = DateUtil.year(dateTime);
|
|
|
|
+ int month = DateUtil.month(dateTime) + 1;
|
|
|
|
+ // 查询所有的节点
|
|
|
|
+ List<Responsibility> responsibilityList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId));
|
|
|
|
+ if (CollUtil.isEmpty(responsibilityList)) {
|
|
|
|
+ throw new CostException(500, "责任中心不存在");
|
|
|
|
+ }
|
|
|
|
+ Map<String, Long> responseCodeParentIdMap = responsibilityList.stream().collect(Collectors.toMap(Responsibility::getResponsibilityCode, Responsibility::getParentId, (a, b) -> b));
|
|
|
|
+ Map<Long, Responsibility> responsibilityIdMap = responsibilityList.stream().collect(Collectors.toMap(Responsibility::getId, responsibility -> responsibility, (a, b) -> b));
|
|
|
|
+ Map<String, String> responseCodeNameMap = responsibilityList.stream().collect(Collectors.toMap(Responsibility::getResponsibilityCode, Responsibility::getResponsibilityName, (a, b) -> b));
|
|
|
|
+ Map<String, Long> responseCodeIdMap = responsibilityList.stream().collect(Collectors.toMap(Responsibility::getResponsibilityCode, Responsibility::getId, (a, b) -> b));
|
|
|
|
+
|
|
|
|
+ // 损益表数据
|
|
|
|
+ List<CostDepartmentProfit> departmentProfits = this.list(new QueryWrapper<CostDepartmentProfit>().lambda()
|
|
|
|
+ .eq(CostDepartmentProfit::getHospId, hospId)
|
|
|
|
+ .eq(CostDepartmentProfit::getYear, year).eq(CostDepartmentProfit::getMonth, month)
|
|
|
|
+ .eq(CostDepartmentProfit::getShareType, reportType));
|
|
|
|
+ if (CollectionUtils.isEmpty(departmentProfits)) {
|
|
|
|
+ throw new CostException(500, name+"未进行科室损益计算");
|
|
|
|
+ }
|
|
|
|
+ for (CostDepartmentProfit departmentProfit : departmentProfits) {
|
|
|
|
+ Long aLong = responseCodeParentIdMap.get(departmentProfit.getResponsibilityCode());
|
|
|
|
+ if (aLong != null) {
|
|
|
|
+ if (aLong.equals(NumberConstant.ZERO_L)) {
|
|
|
|
+ departmentProfit.setParentResponsibilityCode(departmentProfit.getResponsibilityCode());
|
|
|
|
+ departmentProfit.setParentResponsibilityName(departmentProfit.getResponsibilityName());
|
|
|
|
+ } else {
|
|
|
|
+ Responsibility responsibility = responsibilityIdMap.get(aLong);
|
|
|
|
+ if (Objects.nonNull(responsibility)) {
|
|
|
|
+ departmentProfit.setParentResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
|
+ departmentProfit.setParentResponsibilityName(responsibility.getResponsibilityName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<CostDepartmentProfit> profitList = departmentProfits.stream().filter(f -> StringUtils.isEmpty(f.getParentResponsibilityCode())).collect(Collectors.toList());
|
|
|
|
+ if(!CollectionUtils.isEmpty(profitList)){
|
|
|
|
+ log.info("{}报表类型存在无上级责任中心的数据,请核实配置数据",reportType);
|
|
|
|
+ }
|
|
|
|
+ Map<Long, List<CostDepartmentProfit>> profitReportIdGroup = departmentProfits.stream().collect(Collectors.groupingBy(CostDepartmentProfit::getReportId));
|
|
|
|
+ Map<Long, Map<String, CostDepartmentProfit>> profitReportResponsibilityGroup = new HashMap<>();
|
|
|
|
+ profitReportIdGroup.forEach((k,v)->{
|
|
|
|
+ profitReportResponsibilityGroup.put(k,v.stream().collect(Collectors.toMap(CostDepartmentProfit::getResponsibilityCode, costDepartmentProfit -> costDepartmentProfit, (a, b) -> b)));
|
|
|
|
+ });
|
|
|
|
+// Map<String, List<CostDepartmentProfit>> doctorParentMap = departmentProfits.stream().collect(Collectors.groupingBy(CostDepartmentProfit::getParentResponsibilityCode));
|
|
|
|
+ //损益表设置
|
|
|
|
+ List<ReportForm> reportFormList = reportFormService.list(new QueryWrapper<ReportForm>().lambda()
|
|
|
|
+ .eq(ReportForm::getHospId, hospId)
|
|
|
|
+ .eq(ReportForm::getReportType, reportType));
|
|
|
|
+ if (CollUtil.isEmpty(reportFormList)) {
|
|
|
|
+ throw new CostException(500, "损益表未找到");
|
|
|
|
+ }
|
|
|
|
+ //第一层
|
|
|
|
+ List<TitleEntity> titleList = new ArrayList<>();
|
|
|
|
+ titleList.add(new TitleEntity("0", null, name, false, NumberConstant.ZERO));
|
|
|
|
+ //从损益数据中提取出所有责任中心组装成树
|
|
|
|
+ List<ResponsibilityVo> responsibilityVos = new ArrayList<>();
|
|
|
|
+ for (CostDepartmentProfit departmentProfit : departmentProfits) {
|
|
|
|
+ ResponsibilityVo responsibilityVo = new ResponsibilityVo();
|
|
|
|
+ responsibilityVo.setParentResponsibilityCode(departmentProfit.getParentResponsibilityCode());
|
|
|
|
+ responsibilityVo.setParentResponsibilityName(departmentProfit.getParentResponsibilityName());
|
|
|
|
+ responsibilityVo.setResponsibilityCode(departmentProfit.getResponsibilityCode());
|
|
|
|
+ responsibilityVo.setResponsibilityName(departmentProfit.getResponsibilityName());
|
|
|
|
+ responsibilityVos.add(responsibilityVo);
|
|
|
|
+ }
|
|
|
|
+ ListUtils.sort(responsibilityVos,ResponsibilityVo::getParentResponsibilityName);
|
|
|
|
+ Map<String, List<ResponsibilityVo>> responsibilityMap = responsibilityVos.stream().distinct().collect(Collectors.groupingBy(ResponsibilityVo::getParentResponsibilityCode));
|
|
|
|
+ responsibilityMap.forEach((k,v)->{
|
|
|
|
+ TitleEntity entity = new TitleEntity();
|
|
|
|
+ entity.setId(String.valueOf(responseCodeIdMap.get(k)));
|
|
|
|
+ entity.setPid("0");
|
|
|
|
+ entity.setContent(responseCodeNameMap.get(k));
|
|
|
|
+ entity.setFieldName(responseCodeNameMap.get(k));
|
|
|
|
+ entity.setWidth(15);
|
|
|
|
+ entity.setSort(1);
|
|
|
|
+ boolean child = getChild(titleList, k, responsibilityMap,responseCodeIdMap,String.valueOf(responseCodeIdMap.get(k)));
|
|
|
|
+ entity.setLast(child);
|
|
|
|
+ titleList.add(entity);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ final List<ReportForm> finalReportFormList = reportFormList;
|
|
|
|
+ List<ReportForm> reportForms = reportFormList.stream().filter(i -> i.getParentId() == 0)
|
|
|
|
+ .peek(i -> i.setChild(this.getReportFormChild(i, finalReportFormList)))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ //列
|
|
|
|
+ List<TitleEntity> titleEntities = titleList.stream().filter(TitleEntity::isLast).collect(Collectors.toList());
|
|
|
|
+ List<Map<String, String>> rowList = new ArrayList<>();
|
|
|
|
+ List<Integer> depthList = new ArrayList<>();
|
|
|
|
+ for (ReportForm reportForm : reportForms) {
|
|
|
|
+ int child = TreeDepthUtil.getTreeDepthByDfsWithRecursion(reportForm, "child");
|
|
|
|
+ depthList.add(child);
|
|
|
|
+ }
|
|
|
|
+ OptionalInt max = depthList.stream().mapToInt(Integer::intValue).max();
|
|
|
|
+ //根据报表设置最深深度添加 默认列
|
|
|
|
+ int asInt = max.getAsInt();
|
|
|
|
+ for (int i = 1; i<= asInt; i++){
|
|
|
|
+ TitleEntity parentResponsibility = new TitleEntity();
|
|
|
|
+ parentResponsibility.setId(String.valueOf(i));
|
|
|
|
+ parentResponsibility.setPid("0");
|
|
|
|
+ parentResponsibility.setContent("");
|
|
|
|
+ parentResponsibility.setFieldName(String.valueOf(i));
|
|
|
|
+ parentResponsibility.setWidth(15);
|
|
|
|
+ parentResponsibility.setSort(NumberConstant.ZERO);
|
|
|
|
+ parentResponsibility.setLast(true);
|
|
|
|
+ titleList.add(parentResponsibility);
|
|
|
|
+ }
|
|
|
|
+ titleList.sort(Comparator.comparing(TitleEntity::getSort));
|
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00%");
|
|
|
|
+ //递归排序
|
|
|
|
+ formSort(reportForms);
|
|
|
|
+ //配置单元格数据
|
|
|
|
+ for (ReportForm reportForm : reportForms) {
|
|
|
|
+ int fieldId = 1;
|
|
|
|
+ Map<String, String> m = new HashMap<String, String>();
|
|
|
|
+ if(!CollectionUtils.isEmpty(reportForm.getChild())){
|
|
|
|
+ m.put(Integer.toString(fieldId),reportForm.getReportName());
|
|
|
|
+ setRowList(fieldId,reportForm.getChild(),profitReportResponsibilityGroup,rowList,df,titleEntities,m,asInt);
|
|
|
|
+ }else {
|
|
|
|
+ for (int i = 1; i<= asInt; i++){
|
|
|
|
+ m.put(Integer.toString(i),reportForm.getReportName());
|
|
|
|
+ }
|
|
|
|
+ Map<String, CostDepartmentProfit> map = profitReportResponsibilityGroup.get(reportForm.getId());
|
|
|
|
+ for (TitleEntity titleEntity : titleEntities) {
|
|
|
|
+ String fieldName = titleEntity.getFieldName();
|
|
|
|
+ if(fieldName.contains(AMOUNT_FIELD)){
|
|
|
|
+ String[] split1 = StringUtils.split(fieldName, "|");
|
|
|
|
+ if (split1 != null) {
|
|
|
|
+ CostDepartmentProfit costDepartmentProfit = map.get(split1[0]);
|
|
|
|
+ m.put(fieldName, costDepartmentProfit.getAmount().setScale(2, RoundingMode.HALF_UP).toString());
|
|
|
|
+
|
|
|
|
+ }else {
|
|
|
|
+ m.put(fieldName,"");
|
|
|
|
+ }
|
|
|
|
+ } else if (fieldName.contains(PERCENT_FIELD)) {
|
|
|
|
+ String[] split1 = StringUtils.split(fieldName, "|");
|
|
|
|
+ if (split1 != null) {
|
|
|
|
+ CostDepartmentProfit costDepartmentProfit = map.get(split1[0]);
|
|
|
|
+ if (costDepartmentProfit.getPercent() != null) {
|
|
|
|
+ m.put(fieldName, df.format(costDepartmentProfit.getPercent()));
|
|
|
|
+ } else {
|
|
|
|
+ m.put(fieldName, "");
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ m.put(fieldName,"");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ rowList.add(m);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //表头树进行excel 元素转换
|
|
|
|
+ ExcelPoiUtil excelTool = new ExcelPoiUtil(name);
|
|
|
|
+ Map<String, String> param = ImmutableMap.<String, String>builder().put("id", "id").put("pid", "pid")
|
|
|
|
+ .put("content", "content").put("fieldName", "fieldName").put("width", "width").build();
|
|
|
|
+ List<ColEntity> titleData = excelTool.colEntityTransformer(titleList, param, "0");
|
|
|
|
+
|
|
|
|
+ List<Integer> mergeList = IntStream.range(0, asInt).boxed().collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ // 多个sheet导出
|
|
|
|
+ XSSFWorkbook workbook = excelTool.exportXssfWorkbook(titleData, rowList, null);
|
|
|
|
+// CellRangeAddress cellAddresses = new CellRangeAddress(4,7,0,4);
|
|
|
|
+// workbook.getSheetAt(0).addMergedRegion(cellAddresses);
|
|
|
|
+
|
|
|
|
+ //表头占的行数
|
|
|
|
+ int totalRow = titleData.get(0).getTotalRow();
|
|
|
|
+ int[] relationColl = new int[mergeList.size()];
|
|
|
|
+ Map<Integer,int[]> mergeMap = IntStream.range(0, mergeList.size()).boxed().collect(Collectors.toMap(i -> i, i -> relationColl, (a, b) -> b));
|
|
|
|
+ //手动横向合并
|
|
|
|
+ addMergeCells(workbook, mergeMap, asInt);
|
|
|
|
+ //纵向合并
|
|
|
|
+ PoiMergeCellUtil.mergeCells(workbook.getSheetAt(0),mergeMap,totalRow);
|
|
|
|
+// int[] relationTitleColl = new int[totalRow];
|
|
|
|
+//
|
|
|
|
+// Map<Integer,int[]> mergeTitleMap = IntStream.range(asInt-1, titleData.get(0).getTotalCol()).boxed().collect(Collectors.toMap(i -> i, i -> relationTitleColl, (a, b) -> b));
|
|
|
|
+// PoiMergeCellUtil.mergeCells(workbook.getSheetAt(0),mergeTitleMap,1,totalRow-1);
|
|
|
|
+
|
|
|
|
+// excelTool.save(workbook, "D:\\测试用.xls");
|
|
|
|
+ workbook.write(outputStream);
|
|
|
|
+ workbook.close();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static void addMergeCells(XSSFWorkbook workbook, Map<Integer, int[]> mergeMap, int asInt) {
|
|
|
|
+ XSSFSheet sheet = workbook.getSheetAt(0);
|
|
|
|
+ //最后一行
|
|
|
|
+ Set<Integer> colKeyList = mergeMap.keySet();
|
|
|
|
+ int endRow = sheet.getLastRowNum();
|
|
|
|
+ for(int i = 4; i <= endRow; i++) {
|
|
|
|
+ //mergeMap
|
|
|
|
+ List<String> cellText = new ArrayList<>();
|
|
|
|
+ for (Integer integer : colKeyList) {
|
|
|
|
+ XSSFRow row = sheet.getRow(i);
|
|
|
|
+ String text = PoiCellUtil.getCellValue(row.getCell(integer));
|
|
|
|
+ cellText.add(text);
|
|
|
|
+ }
|
|
|
|
+ // 过滤出元素出现次数大于 1 (重复元素)的 entry
|
|
|
|
+ List<Integer> collect = cellText.stream().filter(j -> !Objects.equals(j, "")) // list 对应的 Stream 并过滤""
|
|
|
|
+ .collect(Collectors.toMap(e -> e, e -> 1, Integer::sum)) // 获得元素出现频率的 Map,键为元素,值为元素出现的次数
|
|
|
|
+ .values()
|
|
|
|
+ .stream() // 所有 entry 对应的 Stream
|
|
|
|
+ .filter(integer -> integer > 1) // 获得 entry 的键(重复元素)对应的 Stream
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ if(!CollectionUtils.isEmpty(collect)){
|
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(i,i, mergeMap.size()-collect.get(0), asInt -1));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void setRowList(int fieldId, List<ReportForm> child, Map<Long, Map<String, CostDepartmentProfit>> profitReportResponsibilityGroup,
|
|
|
|
+ List<Map<String, String>> rowList, DecimalFormat df, List<TitleEntity> titleEntities,
|
|
|
|
+ Map<String, String> parentFieldMap, int maxDepth) {
|
|
|
|
+ fieldId++;
|
|
|
|
+ for (ReportForm reportForm:child){
|
|
|
|
+ Map<String, String> m = new HashMap<String, String>(parentFieldMap);
|
|
|
|
+ m.put(Integer.toString(fieldId),reportForm.getReportName());
|
|
|
|
+ if(!CollectionUtils.isEmpty(reportForm.getChild())){
|
|
|
|
+ setRowList(fieldId,reportForm.getChild(),profitReportResponsibilityGroup,rowList, df, titleEntities, m, maxDepth);
|
|
|
|
+ }else {
|
|
|
|
+ if(fieldId<maxDepth){
|
|
|
|
+ for(int i=1;i<=maxDepth - fieldId;i++){
|
|
|
|
+ m.put(Integer.toString(fieldId + i),reportForm.getReportName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Map<String, CostDepartmentProfit> map = profitReportResponsibilityGroup.get(reportForm.getId());
|
|
|
|
+ for (TitleEntity titleEntity : titleEntities) {
|
|
|
|
+ String fieldName = titleEntity.getFieldName();
|
|
|
|
+ if(fieldName.contains(AMOUNT_FIELD)){
|
|
|
|
+ String[] split1 = StringUtils.split(fieldName, "|");
|
|
|
|
+ if (split1 != null) {
|
|
|
|
+ if(map !=null){
|
|
|
|
+ CostDepartmentProfit costDepartmentProfit = map.get(split1[0]);
|
|
|
|
+ if(Objects.nonNull(costDepartmentProfit)){
|
|
|
|
+ m.put(fieldName, costDepartmentProfit.getAmount().setScale(2, RoundingMode.HALF_UP).toString());
|
|
|
|
+ }else {
|
|
|
|
+ m.put(fieldName,"");
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ m.put(fieldName,"");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }else {
|
|
|
|
+ m.put(fieldName,"");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ } else if (fieldName.contains(PERCENT_FIELD)) {
|
|
|
|
+ String[] split1 = StringUtils.split(fieldName, "|");
|
|
|
|
+ if (split1 != null) {
|
|
|
|
+ if(map !=null){
|
|
|
|
+ CostDepartmentProfit costDepartmentProfit = map.get(split1[0]);
|
|
|
|
+ if (costDepartmentProfit.getPercent() != null) {
|
|
|
|
+ m.put(fieldName, df.format(costDepartmentProfit.getPercent()));
|
|
|
|
+ } else {
|
|
|
|
+ m.put(fieldName, "");
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ m.put(fieldName, "");
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ m.put(fieldName,"");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ rowList.add(m);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<ReportForm> getReportFormChild(ReportForm parent, List<ReportForm> reportFormList) {
|
|
|
|
+ return reportFormList.stream().filter(o -> o.getParentId().equals(parent.getId()))
|
|
|
|
+ .peek(o -> o.setChild(this.getReportFormChild(o, reportFormList)))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+//
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void formSort(List<ReportForm> reportFormList){
|
|
|
|
+ for (ReportForm reportForm :reportFormList){
|
|
|
|
+ if(!CollectionUtils.isEmpty(reportForm.getChild())){
|
|
|
|
+ formSort(reportForm.getChild());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ reportFormList.sort(Comparator.comparing(ReportForm::getSort));
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|