|
@@ -87,6 +87,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
private final CenterService centerService;
|
|
|
|
|
|
private final 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.incomeCollectionService = incomeCollectionService;
|
|
@@ -133,7 +134,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
List<CostDepartmentProfitVO> costDepartmentProfitVOList = BeanUtil.convertList(records, CostDepartmentProfitVO.class);
|
|
|
DecimalFormat df = new DecimalFormat("0.00%");
|
|
|
for (CostDepartmentProfitVO costDepartmentProfitVO : costDepartmentProfitVOList) {
|
|
|
- if(costDepartmentProfitVO.getPercent()!= null){
|
|
|
+ if (costDepartmentProfitVO.getPercent() != null) {
|
|
|
costDepartmentProfitVO.setPercentName(df.format(costDepartmentProfitVO.getPercent()));
|
|
|
}
|
|
|
}
|
|
@@ -524,7 +525,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void getDepartmentProfit(String date, OutputStream outputStream) throws Exception {
|
|
|
+ private void getDepartmentProfit(String date, OutputStream outputStream, Integer reportType) throws Exception {
|
|
|
|
|
|
Long hospId = UserContext.getHospId();
|
|
|
DateTime dateTime = DateUtil.parse(date);
|
|
@@ -548,7 +549,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
// 表头
|
|
|
List<CostDepartmentProfit> departmentProfits = this.list(new QueryWrapper<CostDepartmentProfit>().lambda()
|
|
|
.eq(CostDepartmentProfit::getHospId, hospId)
|
|
|
- .eq(CostDepartmentProfit::getYear, year).eq(CostDepartmentProfit::getMonth, month));
|
|
|
+ .eq(CostDepartmentProfit::getYear, year).eq(CostDepartmentProfit::getMonth, month).eq(CostDepartmentProfit::getShareType, reportType));
|
|
|
if (CollectionUtils.isEmpty(departmentProfits)) {
|
|
|
throw new CostException(500, "未进行科室损益计算");
|
|
|
}
|
|
@@ -559,7 +560,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
// Long aLong1 = responseCodeIdMap.get(departmentProfit.getResponsibilityCode());
|
|
|
departmentProfit.setParentResponsibilityCode(departmentProfit.getResponsibilityCode());
|
|
|
departmentProfit.setParentResponsibilityName(departmentProfit.getResponsibilityName());
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
Responsibility responsibility = responsibilityIdMap.get(aLong);
|
|
|
if (Objects.nonNull(responsibility)) {
|
|
|
departmentProfit.setParentResponsibilityCode(responsibility.getResponsibilityCode());
|
|
@@ -572,7 +573,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
//损益表设置
|
|
|
List<ReportForm> reportFormList = reportFormService.list(new QueryWrapper<ReportForm>().lambda()
|
|
|
.eq(ReportForm::getHospId, hospId)
|
|
|
- .eq(ReportForm::getReportType, NumberConstant.ZERO));
|
|
|
+ .eq(ReportForm::getReportType, reportType));
|
|
|
if (CollUtil.isEmpty(reportFormList)) {
|
|
|
throw new CostException(500, "损益表未找到");
|
|
|
}
|
|
@@ -607,20 +608,20 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
}
|
|
|
titleList.sort(Comparator.comparing(TitleEntity::getSort));
|
|
|
|
|
|
- List<CostDepartmentProfit> costDepartmentProfitsDoctor = departmentProfits.stream().filter(f -> f.getShareType().equals(NumberConstant.ONE)).collect(Collectors.toList());
|
|
|
- List<CostDepartmentProfit> costDepartmentProfits = departmentProfits.stream().filter(f -> f.getShareType().equals(NumberConstant.TWO)).collect(Collectors.toList());
|
|
|
+// List<CostDepartmentProfit> costDepartmentProfitsDoctor = departmentProfits.stream().filter(f -> f.getShareType().equals(NumberConstant.ONE)).collect(Collectors.toList());
|
|
|
+// List<CostDepartmentProfit> costDepartmentProfits = departmentProfits.stream().filter(f -> f.getShareType().equals(NumberConstant.TWO)).collect(Collectors.toList());
|
|
|
|
|
|
//行
|
|
|
- Map<String, List<CostDepartmentProfit>> doctorParentMap = costDepartmentProfitsDoctor.stream().collect(Collectors.groupingBy(CostDepartmentProfit::getParentResponsibilityCode));
|
|
|
- Map<String, List<CostDepartmentProfit>> yiParentMap = costDepartmentProfits.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));
|
|
|
|
|
|
//列
|
|
|
List<TitleEntity> titleEntities = titleList.stream().filter(TitleEntity::isLast).collect(Collectors.toList());
|
|
|
List<Map<String, String>> rowList = new ArrayList<>();
|
|
|
- List<Map<String, String>> rowList1 = new ArrayList<>();
|
|
|
+// List<Map<String, String>> rowList1 = new ArrayList<>();
|
|
|
|
|
|
setRowList(doctorParentMap, titleEntities, rowList);
|
|
|
- setRowList(yiParentMap, titleEntities, rowList1);
|
|
|
+// setRowList(yiParentMap, titleEntities, rowList1);
|
|
|
|
|
|
|
|
|
ExcelPoiUtil excelTool = new ExcelPoiUtil("科室损益");
|
|
@@ -635,11 +636,11 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
mergeindexs.put("科室损益-医师", Arrays.asList(0, 1));// 每个sheet的默认行高,sheet名称为key
|
|
|
autoRowHeights.put("科室损益-医师", Arrays.asList(1, 2, 3, 4, 5));
|
|
|
|
|
|
- heads.put("科室损益-医技", titleData);// 每个sheet的表头,sheet名称为key
|
|
|
- datas.put("科室损益-医技", rowList1);// 每个sheet的内容,sheet名称为key
|
|
|
- types.put("科室损益-医技", 0);// 每个sheet的样式类型,sheet名称为key
|
|
|
- mergeindexs.put("科室损益-医技", Arrays.asList(0, 1));// 每个sheet的默认行高,sheet名称为key
|
|
|
- autoRowHeights.put("科室损益-医技", Arrays.asList(1, 2, 3, 4, 5));
|
|
|
+// heads.put("科室损益-医技", titleData);// 每个sheet的表头,sheet名称为key
|
|
|
+// datas.put("科室损益-医技", rowList1);// 每个sheet的内容,sheet名称为key
|
|
|
+// types.put("科室损益-医技", 0);// 每个sheet的样式类型,sheet名称为key
|
|
|
+// mergeindexs.put("科室损益-医技", Arrays.asList(0, 1));// 每个sheet的默认行高,sheet名称为key
|
|
|
+// autoRowHeights.put("科室损益-医技", Arrays.asList(1, 2, 3, 4, 5));
|
|
|
|
|
|
|
|
|
// 多个sheet导出
|
|
@@ -676,9 +677,9 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
if (i == 0) {
|
|
|
m.put(titleEntity.getFieldName(), profit.getAmount().setScale(2, RoundingMode.HALF_UP).toString());
|
|
|
} else {
|
|
|
- if(profit.getPercent() != null){
|
|
|
+ if (profit.getPercent() != null) {
|
|
|
m.put(titleEntity.getFieldName(), df.format(profit.getPercent()));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
m.put(titleEntity.getFieldName(), "");
|
|
|
}
|
|
|
}
|
|
@@ -805,7 +806,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
|
|
|
// Sheet sheet = writer.getSheet();
|
|
|
// getDepartmentProfit(writer,sheet,date);
|
|
|
- getDepartmentProfit(date, outputStream);
|
|
|
+ getDepartmentProfit(date, outputStream, reportType);
|
|
|
// hssfWorkbook.write(outputStream);
|
|
|
// writer.flush(outputStream,true);
|
|
|
|
|
@@ -873,7 +874,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
// int year = DateUtil.year(parse);
|
|
|
// int month = DateUtil.month(parse) + 1;
|
|
|
Integer year = ComputeDateUtils.getComputeYear(computeDate);
|
|
|
- Integer month = ComputeDateUtils.getComputeMonth(computeDate) ;
|
|
|
+ Integer month = ComputeDateUtils.getComputeMonth(computeDate);
|
|
|
// 先查询指定条件的报表数据 查询损益表的数据
|
|
|
List<ReportForm> reportFormList = reportFormService.list(new QueryWrapper<ReportForm>().lambda()
|
|
|
.eq(ReportForm::getHospId, hospId)
|
|
@@ -917,9 +918,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
// 分摊后的数据说明是分摊后的数据 这里原有为收益中心数据 同步添加医技分摊后数据
|
|
|
List<AllocationQuery> allocationQueryList = allocationQueryService.list(new QueryWrapper<AllocationQuery>().lambda().eq(AllocationQuery::getHospId, hospId)
|
|
|
.eq(year > 0, AllocationQuery::getDateYear, year)
|
|
|
- .eq(month > 0, AllocationQuery::getDateMonth, month)
|
|
|
- .eq(AllocationQuery::getShareType, NumberConstant.ONE)
|
|
|
- );
|
|
|
+ .eq(month > 0, AllocationQuery::getDateMonth, month));
|
|
|
if (CollUtil.isEmpty(allocationQueryList)) {
|
|
|
throw new CostException(500, "分摊后数据不存在");
|
|
|
}
|
|
@@ -946,7 +945,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
|
|
|
// 删除这个年月的数据
|
|
|
this.remove(new QueryWrapper<CostDepartmentProfit>().lambda().eq(CostDepartmentProfit::getHospId, hospId)
|
|
|
- .eq(CostDepartmentProfit::getYear, year).eq(CostDepartmentProfit::getMonth, month));
|
|
|
+ .eq(CostDepartmentProfit::getYear, year).eq(CostDepartmentProfit::getMonth, month).eq(CostDepartmentProfit::getShareType, Integer.valueOf(reportType)));
|
|
|
// 添加数据
|
|
|
List<CostDepartmentProfit> costDepartmentProfits = BeanUtil.convertList(list, CostDepartmentProfit.class);
|
|
|
|
|
@@ -960,29 +959,26 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
|
|
|
private DictDataVo getDictDataVo(String reportType) {
|
|
|
DictDataVo dict = centerService.getDict(PROFIT_REPORT_TYPE);
|
|
|
- if(Objects.isNull(dict)){
|
|
|
+ if (Objects.isNull(dict)) {
|
|
|
throw new CostException("未找到损益报表类型字典");
|
|
|
}
|
|
|
List<DictDataVo> dataVoList = dict.getDataVoList();
|
|
|
- if(CollectionUtils.isEmpty(dataVoList)){
|
|
|
+ if (CollectionUtils.isEmpty(dataVoList)) {
|
|
|
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));
|
|
|
DictDataVo dataVo = dictMap.get(reportType);
|
|
|
- if(Objects.isNull(dataVo)){
|
|
|
- throw new CostException("未找到损益报表类型为【"+ reportType +"】的字典");
|
|
|
+ if (Objects.isNull(dataVo)) {
|
|
|
+ throw new CostException("未找到损益报表类型为【" + reportType + "】的字典");
|
|
|
}
|
|
|
return dataVo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Object computeProfitReport(String computeDate, Long hospId, String reportType) {
|
|
|
-// report
|
|
|
-// DateTime dateTime = DateUtil.parse(computeDate);
|
|
|
-// int year = DateUtil.year(dateTime);
|
|
|
-// int month = DateUtil.month(dateTime) + 1;
|
|
|
+
|
|
|
Integer year = ComputeDateUtils.getComputeYear(computeDate);
|
|
|
- Integer month = ComputeDateUtils.getComputeMonth(computeDate) ;
|
|
|
+ Integer month = ComputeDateUtils.getComputeMonth(computeDate);
|
|
|
Integer integerReportType = Integer.valueOf(reportType);
|
|
|
|
|
|
List<ReportForm> reportFormList = reportFormService.list(new QueryWrapper<ReportForm>().lambda()
|
|
@@ -997,8 +993,8 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
List<CommonTitleReportVo> titleReportVoList = collect.get(NumberConstant.ZERO_L);
|
|
|
for (CommonTitleReportVo reportVo : titleReportVoList) {
|
|
|
List<CommonTitleReportVo> childList = collect.get(reportVo.getReportId());
|
|
|
- if(!CollectionUtils.isEmpty(childList)){
|
|
|
- reportVo.setChildTitle(setReportChildren(childList,collect));
|
|
|
+ if (!CollectionUtils.isEmpty(childList)) {
|
|
|
+ reportVo.setChildTitle(setReportChildren(childList, collect));
|
|
|
}
|
|
|
}
|
|
|
ProfitReportResponse response = new ProfitReportResponse();
|
|
@@ -1008,7 +1004,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
.eq(CostDepartmentProfit::getHospId, hospId)
|
|
|
.eq(CostDepartmentProfit::getYear, year)
|
|
|
.eq(CostDepartmentProfit::getMonth, month)
|
|
|
- .eq(CostDepartmentProfit::getShareType,integerReportType));
|
|
|
+ .eq(CostDepartmentProfit::getShareType, integerReportType));
|
|
|
if (CollectionUtils.isEmpty(departmentProfits)) {
|
|
|
response.setData(new ArrayList<>());
|
|
|
return response;
|
|
@@ -1028,25 +1024,73 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
List<Responsibility> responsibilityList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda()
|
|
|
.eq(Responsibility::getHospId, hospId)
|
|
|
.eq(Responsibility::getShareId, id));
|
|
|
- if(CollectionUtils.isEmpty(responsibilityList)){
|
|
|
+ if (CollectionUtils.isEmpty(responsibilityList)) {
|
|
|
throw new CostException("未找到对应分摊层级责任中心");
|
|
|
}
|
|
|
//获取当前院区所有的责任中心
|
|
|
List<Responsibility> responsibilityAllList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda()
|
|
|
.eq(Responsibility::getHospId, hospId));
|
|
|
- Map<Long,Responsibility> map = responsibilityAllList.stream().collect(Collectors.toMap(Responsibility::getId, responsibility -> responsibility, (a, b) -> b));
|
|
|
+ Map<Long, Responsibility> map = responsibilityAllList.stream().collect(Collectors.toMap(Responsibility::getId, responsibility -> responsibility, (a, b) -> b));
|
|
|
+ Map<String, Long> responseCodeParentIdMap = responsibilityAllList.stream().collect(Collectors.toMap(Responsibility::getResponsibilityCode, Responsibility::getParentId, (a, b) -> b));
|
|
|
+ Map<String, String> responseNameMap = responsibilityAllList.stream().collect(Collectors.toMap(Responsibility::getResponsibilityCode, Responsibility::getResponsibilityName, (a, b) -> b));
|
|
|
+
|
|
|
+
|
|
|
+ //通过查询的最下层责任中心 找到其所有父类责任中心
|
|
|
List<Responsibility> parentResponseList = new ArrayList<>();
|
|
|
for (Responsibility responsibility : responsibilityList) {
|
|
|
Responsibility responsibility1 = map.get(responsibility.getParentId());
|
|
|
- if(Objects.nonNull(responsibility1)){
|
|
|
+ if (Objects.nonNull(responsibility1)) {
|
|
|
parentResponseList.add(responsibility1);
|
|
|
- if(!responsibility1.getParentId().equals(NumberConstant.ZERO_L)){
|
|
|
- getResponsibilityParent(responsibility1,map,parentResponseList);
|
|
|
+ if (!responsibility1.getParentId().equals(NumberConstant.ZERO_L)) {
|
|
|
+ getResponsibilityParent(responsibility1, map, parentResponseList);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //去除重复组装数据
|
|
|
+ List<Responsibility> parentResponsibility = parentResponseList.stream().distinct().collect(Collectors.toList());
|
|
|
+ //找出最外层用于出参循环
|
|
|
+ List<Responsibility> responseParent = parentResponsibility.stream().filter(f -> f.getParentId().equals(NumberConstant.ZERO_L)).collect(Collectors.toList());
|
|
|
+ //只留下中间责任中心
|
|
|
+ parentResponsibility.removeAll(responseParent);
|
|
|
+
|
|
|
+ //最上级添加模版
|
|
|
+ List<CostProfitVo> parentReportVos = new ArrayList<>();
|
|
|
+ for (Responsibility responsibility : responseParent) {
|
|
|
+ List<CostProfitVo> profitVos = BeanUtil.convertList(parentModel, CostProfitVo.class);
|
|
|
+ for (CostProfitVo costProfitVo : profitVos) {
|
|
|
+ costProfitVo.setResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
+ costProfitVo.setResponsibilityName(responsibility.getResponsibilityName());
|
|
|
+ costProfitVo.setAmount(BigDecimal.ZERO);
|
|
|
+ costProfitVo.setPercent(BigDecimal.ZERO);
|
|
|
+ parentReportVos.add(costProfitVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //中间责任中心 添加模版 添加父类责任中心
|
|
|
+ List<CostProfitVo> middleReportVos = new ArrayList<>();
|
|
|
+ for (Responsibility responsibility : parentResponsibility) {
|
|
|
+ List<CostProfitVo> profitVos = BeanUtil.convertList(parentModel, CostProfitVo.class);
|
|
|
+ Long aLong = responseCodeParentIdMap.get(responsibility.getResponsibilityCode());
|
|
|
+ for (CostProfitVo costProfitVo : profitVos) {
|
|
|
+ costProfitVo.setResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
+ costProfitVo.setResponsibilityName(responsibility.getResponsibilityName());
|
|
|
+ costProfitVo.setAmount(BigDecimal.ZERO);
|
|
|
+ costProfitVo.setPercent(BigDecimal.ZERO);
|
|
|
+ if (aLong.equals(NumberConstant.ZERO_L)) {
|
|
|
+ costProfitVo.setParentResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
+ costProfitVo.setParentResponsibilityName(responsibility.getResponsibilityName());
|
|
|
+ } else {
|
|
|
+ Responsibility responsibility1 = map.get(aLong);
|
|
|
+ if (Objects.nonNull(responsibility1)) {
|
|
|
+ costProfitVo.setParentResponsibilityCode(responsibility1.getResponsibilityCode());
|
|
|
+ costProfitVo.setParentResponsibilityName(responsibility1.getResponsibilityName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ middleReportVos.add(costProfitVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
//添加父类责任中心
|
|
|
- Map<String, Long> responseCodeParentIdMap = responsibilityAllList.stream().collect(Collectors.toMap(Responsibility::getResponsibilityCode, Responsibility::getParentId, (a, b) -> b));
|
|
|
+ //已计算过的数据添加上级责任中心
|
|
|
for (CostProfitVo departmentProfit : costProfitVos) {
|
|
|
Long aLong = responseCodeParentIdMap.get(departmentProfit.getResponsibilityCode());
|
|
|
if (aLong != null) {
|
|
@@ -1054,7 +1098,7 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
// Long aLong1 = responseCodeIdMap.get(departmentProfit.getResponsibilityCode());
|
|
|
departmentProfit.setParentResponsibilityCode(departmentProfit.getResponsibilityCode());
|
|
|
departmentProfit.setParentResponsibilityName(departmentProfit.getResponsibilityName());
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
Responsibility responsibility = map.get(aLong);
|
|
|
if (Objects.nonNull(responsibility)) {
|
|
|
departmentProfit.setParentResponsibilityCode(responsibility.getResponsibilityCode());
|
|
@@ -1063,98 +1107,197 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- Map<String,Map<Long,List<CostProfitVo>>> sumGroup = new HashMap<>();
|
|
|
- //上级
|
|
|
+ //已计算过的 按责任中心-报表id 分组
|
|
|
+ Map<String, Map<Long, List<CostProfitVo>>> sumGroup = new HashMap<>();
|
|
|
+ //已计算过的 按父类责任中心分组
|
|
|
Map<String, List<CostProfitVo>> collect1 = costProfitVos.stream().collect(Collectors.groupingBy(CostProfitVo::getParentResponsibilityCode));
|
|
|
-
|
|
|
for (String s : collect1.keySet()) {
|
|
|
List<CostProfitVo> costProfitVos1 = collect1.get(s);
|
|
|
Map<Long, List<CostProfitVo>> collect2 = costProfitVos1.stream().collect(Collectors.groupingBy(CostProfitVo::getReportId));
|
|
|
- sumGroup.put(s,collect2);
|
|
|
+ sumGroup.put(s, collect2);
|
|
|
}
|
|
|
- List<CostProfitVo> parentReportVos = new ArrayList<>();
|
|
|
-// for (Responsibility responsibility : parentResponseList) {
|
|
|
-// if(responsibility.getParentId().equals(NumberConstant.ZERO_L)){
|
|
|
-// for (CostProfitVo costProfitVo : parentModel) {
|
|
|
-// costProfitVo.setResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
-// costProfitVo.setResponsibilityName(responsibility.getResponsibilityName());
|
|
|
-// costProfitVo.setAmount(BigDecimal.ZERO);
|
|
|
-// costProfitVo.setPercent(BigDecimal.ZERO);
|
|
|
-// costProfitVo.setParent(true);
|
|
|
-// parentReportVos.add(costProfitVo);
|
|
|
-// }
|
|
|
-// }else {
|
|
|
-// for (CostProfitVo costProfitVo : parentModel) {
|
|
|
-// costProfitVo.setResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
-// costProfitVo.setResponsibilityName(responsibility.getResponsibilityName());
|
|
|
-// costProfitVo.setAmount(BigDecimal.ZERO);
|
|
|
-// costProfitVo.setPercent(BigDecimal.ZERO);
|
|
|
-// costProfitVo.setParent(false);
|
|
|
-// parentReportVos.add(costProfitVo);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
- for (Responsibility responsibility : parentResponseList) {
|
|
|
- Map<Long, List<CostProfitVo>> longListMap = sumGroup.get(responsibility.getResponsibilityCode());
|
|
|
- AtomicReference<BigDecimal> sum = new AtomicReference<>(new BigDecimal("0.0000"));
|
|
|
- AtomicReference<BigDecimal> percentSum = new AtomicReference<>(new BigDecimal("0.0000"));
|
|
|
- for (CostProfitVo costProfitVo : parentModel) {
|
|
|
- costProfitVo.setResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
- costProfitVo.setResponsibilityName(responsibility.getResponsibilityName());
|
|
|
- if(!CollectionUtils.isEmpty(longListMap)){
|
|
|
- List<CostProfitVo> costProfitVos1 = longListMap.get(costProfitVo.getReportId());
|
|
|
- for (CostProfitVo profitVo : costProfitVos1) {
|
|
|
- sum.updateAndGet(v -> v.add(profitVo.getAmount()));
|
|
|
- percentSum.updateAndGet(v -> v.add(profitVo.getPercent()));
|
|
|
- }
|
|
|
- costProfitVo.setAmount(sum.get());
|
|
|
- costProfitVo.setPercent(percentSum.get());
|
|
|
- costProfitVo.setSumFlag(true);
|
|
|
-
|
|
|
- }else {
|
|
|
- costProfitVo.setAmount(BigDecimal.ZERO);
|
|
|
- costProfitVo.setPercent(BigDecimal.ZERO);
|
|
|
- costProfitVo.setSumFlag(false);
|
|
|
+ //计算所有中间层
|
|
|
+ List<CostProfitVo> middleFilterReportVos = new ArrayList<>();
|
|
|
+ for (CostProfitVo middleReportVo : middleReportVos) {
|
|
|
+ String responsibilityCode = middleReportVo.getResponsibilityCode();
|
|
|
+ Map<Long, List<CostProfitVo>> longListMap = sumGroup.get(responsibilityCode);
|
|
|
+ if (!CollectionUtils.isEmpty(longListMap)) {
|
|
|
+ List<CostProfitVo> profitVos = longListMap.get(middleReportVo.getReportId());
|
|
|
+ AtomicReference<BigDecimal> sum = new AtomicReference<>(new BigDecimal("0.0000"));
|
|
|
+ if (!CollectionUtils.isEmpty(profitVos)) {
|
|
|
+ profitVos.forEach(m -> {
|
|
|
+ sum.updateAndGet(v -> v.add(m.getAmount()));
|
|
|
+ });
|
|
|
+
|
|
|
+ middleReportVo.setAmount(sum.get());
|
|
|
}
|
|
|
- parentReportVos.add(costProfitVo);
|
|
|
+ } else {
|
|
|
+ //未在最下层找到数据的可能还是一个分类 提取出来
|
|
|
+ middleFilterReportVos.add(middleReportVo);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- for (CostProfitVo departmentProfit : parentReportVos) {
|
|
|
- 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 = map.get(aLong);
|
|
|
- if (Objects.nonNull(responsibility)) {
|
|
|
- departmentProfit.setParentResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
- departmentProfit.setParentResponsibilityName(responsibility.getResponsibilityName());
|
|
|
+ //用于处理多层级中 有两层中间层的数据
|
|
|
+ if (!CollectionUtils.isEmpty(middleFilterReportVos)) {
|
|
|
+ handleMiddleFilterReport(middleReportVos, middleFilterReportVos);
|
|
|
+ }
|
|
|
+ Map<String, Map<Long, List<CostProfitVo>>> sumMiddleGroup = new HashMap<>();
|
|
|
+ Map<String, List<CostProfitVo>> collect2 = middleReportVos.stream().collect(Collectors.groupingBy(CostProfitVo::getParentResponsibilityCode));
|
|
|
+ for (String s : collect2.keySet()) {
|
|
|
+ List<CostProfitVo> costProfitVos1 = collect2.get(s);
|
|
|
+ Map<Long, List<CostProfitVo>> collect3 = costProfitVos1.stream().collect(Collectors.groupingBy(CostProfitVo::getReportId));
|
|
|
+ sumMiddleGroup.put(s, collect3);
|
|
|
+ }
|
|
|
+ // 最上层的需要执行两次分组 两层时取最后一层计算 多层时取 中间层计算合计
|
|
|
+ for (CostProfitVo parentReportVo : parentReportVos) {
|
|
|
+ String responsibilityCode = parentReportVo.getResponsibilityCode();
|
|
|
+ Map<Long, List<CostProfitVo>> longListMap = sumGroup.get(responsibilityCode);
|
|
|
+ //在最下层找到的 说明是两层
|
|
|
+ if (!CollectionUtils.isEmpty(longListMap)) {
|
|
|
+ List<CostProfitVo> profitVos = longListMap.get(parentReportVo.getReportId());
|
|
|
+ AtomicReference<BigDecimal> sum = new AtomicReference<>(new BigDecimal("0.0000"));
|
|
|
+ if (!CollectionUtils.isEmpty(profitVos)) {
|
|
|
+ profitVos.forEach(m -> {
|
|
|
+ sum.updateAndGet(v -> v.add(m.getAmount()));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //再找中间层是否存在子类
|
|
|
+ Map<Long, List<CostProfitVo>> longListMap1 = sumMiddleGroup.get(responsibilityCode);
|
|
|
+ if (!CollectionUtils.isEmpty(longListMap1)) {
|
|
|
+ List<CostProfitVo> profitVos1 = longListMap1.get(parentReportVo.getReportId());
|
|
|
+ if (!CollectionUtils.isEmpty(profitVos1)) {
|
|
|
+ profitVos1.forEach(m -> {
|
|
|
+ sum.updateAndGet(v -> v.add(m.getAmount()));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ parentReportVo.setAmount(sum.get());
|
|
|
+ } else {
|
|
|
+ //未在最下层找到从中间层找进行计算
|
|
|
+ Map<Long, List<CostProfitVo>> longListMap1 = sumMiddleGroup.get(responsibilityCode);
|
|
|
+ if (!CollectionUtils.isEmpty(longListMap1)) {
|
|
|
+ List<CostProfitVo> profitVos = longListMap1.get(parentReportVo.getReportId());
|
|
|
+ AtomicReference<BigDecimal> sum = new AtomicReference<>(new BigDecimal("0.0000"));
|
|
|
+ if (!CollectionUtils.isEmpty(profitVos)) {
|
|
|
+ profitVos.forEach(m -> {
|
|
|
+ sum.updateAndGet(v -> v.add(m.getAmount()));
|
|
|
+ });
|
|
|
}
|
|
|
+ parentReportVo.setAmount(sum.get());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //把最上层 中间层 最下层组装成一个list 进行分组
|
|
|
+
|
|
|
+ //组装数据
|
|
|
+ Map<String, List<CostProfitVo>> collect3 = parentReportVos.stream().collect(Collectors.groupingBy(CostProfitVo::getResponsibilityCode));
|
|
|
+ List<CostResponsibilityProfitVo> list = new ArrayList<>();
|
|
|
+
|
|
|
+ for (String s : collect3.keySet()) {
|
|
|
+ CostResponsibilityProfitVo vo = new CostResponsibilityProfitVo();
|
|
|
+ List<CostProfitVo> costProfitVos1 = collect3.get(s);
|
|
|
+ vo.setResponsibilityCode(s);
|
|
|
+ vo.setResponsibilityName(responseNameMap.get(s));
|
|
|
+ if (!CollectionUtils.isEmpty(costProfitVos1)) {
|
|
|
+ List<CommonDataReportVo> dataReportVos = new ArrayList<>();
|
|
|
+ for (CostProfitVo costProfitVo : costProfitVos1) {
|
|
|
+ CommonDataReportVo vo1 = new CommonDataReportVo();
|
|
|
+ vo1.setReportId(costProfitVo.getReportId());
|
|
|
+ vo1.setValue(costProfitVo.getAmount());
|
|
|
+ dataReportVos.add(vo1);
|
|
|
}
|
|
|
+ vo.setProfitList(dataReportVos);
|
|
|
+ } else {
|
|
|
+ vo.setProfitList(new ArrayList<>());
|
|
|
}
|
|
|
+ list.add(vo);
|
|
|
}
|
|
|
|
|
|
+ middleReportVos.addAll(costProfitVos);
|
|
|
+ Map<String, List<CostProfitVo>> collect5 = middleReportVos.stream().collect(Collectors.groupingBy(CostProfitVo::getResponsibilityCode));
|
|
|
+ List<CostResponsibilityProfitVo> list1 = new ArrayList<>();
|
|
|
+ for (String s : collect5.keySet()) {
|
|
|
+ CostResponsibilityProfitVo vo = new CostResponsibilityProfitVo();
|
|
|
+ List<CostProfitVo> costProfitVos2 = collect5.get(s);
|
|
|
+ vo.setResponsibilityCode(s);
|
|
|
+ vo.setResponsibilityName(responseNameMap.get(s));
|
|
|
+ if (!CollectionUtils.isEmpty(costProfitVos2)) {
|
|
|
+ vo.setParentResponsibilityCode(costProfitVos2.get(0).getParentResponsibilityCode());
|
|
|
+
|
|
|
+ List<CommonDataReportVo> dataReportVos = new ArrayList<>();
|
|
|
+ for (CostProfitVo costProfitVo : costProfitVos2) {
|
|
|
+ CommonDataReportVo vo1 = new CommonDataReportVo();
|
|
|
+ vo1.setReportId(costProfitVo.getReportId());
|
|
|
+ vo1.setValue(costProfitVo.getAmount());
|
|
|
+ dataReportVos.add(vo1);
|
|
|
+ }
|
|
|
+ vo.setProfitList(dataReportVos);
|
|
|
+ } else {
|
|
|
+ vo.setProfitList(new ArrayList<>());
|
|
|
+ }
|
|
|
+ list1.add(vo);
|
|
|
+ }
|
|
|
+ Map<String, List<CostResponsibilityProfitVo>> collect4 = list1.stream().collect(Collectors.groupingBy(CostResponsibilityProfitVo::getParentResponsibilityCode));
|
|
|
+ for (CostResponsibilityProfitVo vo : list) {
|
|
|
+ List<CostResponsibilityProfitVo> list2 = collect4.get(vo.getResponsibilityCode());
|
|
|
+ vo.setChild(setProfitChildren(list2,collect4));
|
|
|
+ }
|
|
|
+ response.setData(list);
|
|
|
|
|
|
+ //提取出最上层
|
|
|
|
|
|
|
|
|
- for (CostProfitVo parentReportVo : parentReportVos) {
|
|
|
+ return response;
|
|
|
+ }
|
|
|
|
|
|
+ private static void handleMiddleFilterReport(List<CostProfitVo> middleReportVos, List<CostProfitVo> middleFilterReportVos) {
|
|
|
+ //去除没计算完的
|
|
|
+ middleReportVos.removeAll(middleFilterReportVos);
|
|
|
+ //说明有没计算完的
|
|
|
+ Map<String, Map<Long, List<CostProfitVo>>> sumFilterGroup = new HashMap<>();
|
|
|
+ //已计算过的 按父类责任中心分组
|
|
|
+ Map<String, List<CostProfitVo>> collect2 = middleReportVos.stream().collect(Collectors.groupingBy(CostProfitVo::getParentResponsibilityCode));
|
|
|
+ for (String s : collect2.keySet()) {
|
|
|
+ List<CostProfitVo> costProfitVos1 = collect2.get(s);
|
|
|
+ Map<Long, List<CostProfitVo>> collect3 = costProfitVos1.stream().collect(Collectors.groupingBy(CostProfitVo::getReportId));
|
|
|
+ sumFilterGroup.put(s, collect3);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- return response;
|
|
|
+ for (CostProfitVo middleReportVo : middleFilterReportVos) {
|
|
|
+ String responsibilityCode = middleReportVo.getResponsibilityCode();
|
|
|
+ Map<Long, List<CostProfitVo>> longListMap = sumFilterGroup.get(responsibilityCode);
|
|
|
+ if (!CollectionUtils.isEmpty(longListMap)) {
|
|
|
+ List<CostProfitVo> profitVos = longListMap.get(middleReportVo.getReportId());
|
|
|
+ AtomicReference<BigDecimal> sum = new AtomicReference<>(new BigDecimal("0.0000"));
|
|
|
+ if (!CollectionUtils.isEmpty(profitVos)) {
|
|
|
+ profitVos.forEach(m -> {
|
|
|
+ sum.updateAndGet(v -> v.add(m.getAmount()));
|
|
|
+ });
|
|
|
+
|
|
|
+ middleReportVo.setAmount(sum.get());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //todo:先处理到四层
|
|
|
+ }
|
|
|
+ //添加回去
|
|
|
+ middleReportVos.addAll(middleFilterReportVos);
|
|
|
}
|
|
|
|
|
|
- private List<CommonTitleReportVo> setReportChildren(List<CommonTitleReportVo> child,Map<Long, List<CommonTitleReportVo>> collect){
|
|
|
- for(CommonTitleReportVo reportVo:child){
|
|
|
- if(!CollectionUtils.isEmpty(collect.get(reportVo.getReportId()))){
|
|
|
- reportVo.setChildTitle(setReportChildren(collect.get(reportVo.getReportId()),collect));
|
|
|
+ private List<CostResponsibilityProfitVo> setProfitChildren(List<CostResponsibilityProfitVo> child, Map<String, List<CostResponsibilityProfitVo>> collect) {
|
|
|
+ for (CostResponsibilityProfitVo reportVo : child) {
|
|
|
+ if (!CollectionUtils.isEmpty(collect.get(reportVo.getResponsibilityCode()))) {
|
|
|
+ reportVo.setChild(setProfitChildren(collect.get(reportVo.getResponsibilityCode()), collect));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return child;
|
|
|
+ }
|
|
|
+ private List<CommonTitleReportVo> setReportChildren(List<CommonTitleReportVo> child, Map<Long, List<CommonTitleReportVo>> collect) {
|
|
|
+ for (CommonTitleReportVo reportVo : child) {
|
|
|
+ if (!CollectionUtils.isEmpty(collect.get(reportVo.getReportId()))) {
|
|
|
+ reportVo.setChildTitle(setReportChildren(collect.get(reportVo.getReportId()), collect));
|
|
|
}
|
|
|
}
|
|
|
return child;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @param reportType
|
|
|
* @param responsibilityName
|
|
@@ -1168,24 +1311,24 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
Long id = Long.valueOf(dataVo.getExpandOne());
|
|
|
List<Responsibility> responsibilityList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda()
|
|
|
.eq(Responsibility::getHospId, hospId)
|
|
|
- .eq(Responsibility::getShareId, id).like(StrUtil.isNotBlank(responsibilityName),Responsibility::getResponsibilityName,responsibilityName));
|
|
|
- if(CollectionUtils.isEmpty(responsibilityList)){
|
|
|
+ .eq(Responsibility::getShareId, id).like(StrUtil.isNotBlank(responsibilityName), Responsibility::getResponsibilityName, responsibilityName));
|
|
|
+ if (CollectionUtils.isEmpty(responsibilityList)) {
|
|
|
throw new CostException("未找到对应分摊层级责任中心");
|
|
|
}
|
|
|
List<Responsibility> responsibilityAllList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda()
|
|
|
.eq(Responsibility::getHospId, hospId));
|
|
|
- Map<Long,Responsibility> map = responsibilityAllList.stream().collect(Collectors.toMap(Responsibility::getId, responsibility -> responsibility, (a, b) -> b));
|
|
|
+ Map<Long, Responsibility> map = responsibilityAllList.stream().collect(Collectors.toMap(Responsibility::getId, responsibility -> responsibility, (a, b) -> b));
|
|
|
List<Responsibility> addList = new ArrayList<>();
|
|
|
for (Responsibility responsibility : responsibilityList) {
|
|
|
Responsibility responsibility1 = map.get(responsibility.getParentId());
|
|
|
- if(Objects.nonNull(responsibility1)){
|
|
|
+ if (Objects.nonNull(responsibility1)) {
|
|
|
addList.add(responsibility1);
|
|
|
- if(!responsibility1.getParentId().equals(NumberConstant.ZERO_L)){
|
|
|
- getResponsibilityParent(responsibility1,map,addList);
|
|
|
+ if (!responsibility1.getParentId().equals(NumberConstant.ZERO_L)) {
|
|
|
+ getResponsibilityParent(responsibility1, map, addList);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(!CollectionUtils.isEmpty(addList)){
|
|
|
+ if (!CollectionUtils.isEmpty(addList)) {
|
|
|
//去重
|
|
|
List<Responsibility> collect = addList.stream().distinct().collect(Collectors.toList());
|
|
|
responsibilityList.addAll(collect);
|
|
@@ -1197,38 +1340,35 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
collect.remove(NumberConstant.ZERO_L);
|
|
|
for (Responsibility responsibility : responsibilities) {
|
|
|
List<Responsibility> responsibilities1 = collect.get(responsibility.getId());
|
|
|
- if(!CollectionUtils.isEmpty(responsibilities1)){
|
|
|
- responsibility.setChildren(setResponsibilityChildren(responsibilities1,collect));
|
|
|
+ if (!CollectionUtils.isEmpty(responsibilities1)) {
|
|
|
+ responsibility.setChildren(setResponsibilityChildren(responsibilities1, collect));
|
|
|
}
|
|
|
}
|
|
|
return responsibilities;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- private void getResponsibilityParent(Responsibility responsibility,Map<Long,Responsibility> collect,List<Responsibility> addList){
|
|
|
+ private void getResponsibilityParent(Responsibility responsibility, Map<Long, Responsibility> collect, List<Responsibility> addList) {
|
|
|
Responsibility responsibility1 = collect.get(responsibility.getParentId());
|
|
|
- if(Objects.nonNull(responsibility1)){
|
|
|
+ if (Objects.nonNull(responsibility1)) {
|
|
|
addList.add(responsibility1);
|
|
|
- if(!responsibility1.getParentId().equals(NumberConstant.ZERO_L)){
|
|
|
- getResponsibilityParent(responsibility1,collect,addList);
|
|
|
+ if (!responsibility1.getParentId().equals(NumberConstant.ZERO_L)) {
|
|
|
+ getResponsibilityParent(responsibility1, collect, addList);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- private List<Responsibility> setResponsibilityChildren(List<Responsibility> child,Map<Long, List<Responsibility>> collect){
|
|
|
- for(Responsibility responsibility:child){
|
|
|
- if(!CollectionUtils.isEmpty(collect.get(responsibility.getId()))){
|
|
|
- responsibility.setChildren(setResponsibilityChildren(collect.get(responsibility.getId()),collect));
|
|
|
+ private List<Responsibility> setResponsibilityChildren(List<Responsibility> child, Map<Long, List<Responsibility>> collect) {
|
|
|
+ for (Responsibility responsibility : child) {
|
|
|
+ if (!CollectionUtils.isEmpty(collect.get(responsibility.getId()))) {
|
|
|
+ responsibility.setChildren(setResponsibilityChildren(collect.get(responsibility.getId()), collect));
|
|
|
}
|
|
|
}
|
|
|
return child;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* @param computeDate
|
|
|
* @param hospId
|
|
@@ -1238,35 +1378,47 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
*/
|
|
|
@Override
|
|
|
public Object getComputeProfitList(String computeDate, Long hospId, String reportType, String responsibilityCode) {
|
|
|
-
|
|
|
Integer year = ComputeDateUtils.getComputeYear(computeDate);
|
|
|
- Integer month = ComputeDateUtils.getComputeMonth(computeDate) ;
|
|
|
+ Integer month = ComputeDateUtils.getComputeMonth(computeDate);
|
|
|
//取出计算当前月计算过的科室损益
|
|
|
- List<CostDepartmentProfit> departmentProfits = costDepartmentProfitRepository.getCurrentByReportType(year,month,hospId,reportType,responsibilityCode);
|
|
|
+ List<CostDepartmentProfit> departmentProfits = costDepartmentProfitRepository.getCurrentByReportType(year, month, hospId, reportType, responsibilityCode);
|
|
|
if (CollectionUtils.isEmpty(departmentProfits)) {
|
|
|
throw new CostException(500, "未进行科室损益计算");
|
|
|
}
|
|
|
+ Integer integerReportType = Integer.valueOf(reportType);
|
|
|
+ List<ReportForm> reportFormList = reportFormService.list(new QueryWrapper<ReportForm>().lambda()
|
|
|
+ .eq(ReportForm::getHospId, hospId)
|
|
|
+ .eq(ReportForm::getReportType, integerReportType));
|
|
|
+ if (CollUtil.isEmpty(reportFormList)) {
|
|
|
+ throw new CostException(500, "损益表未找到");
|
|
|
+ }
|
|
|
+ Map<Long, Integer> sortMap = reportFormList.stream().collect(Collectors.toMap(ReportForm::getId, ReportForm::getSort, (a, b) -> b));
|
|
|
List<CostProfitVo> costProfitVos = BeanUtil.convertList(departmentProfits, CostProfitVo.class);
|
|
|
+ costProfitVos.forEach(costProfitVo -> costProfitVo.setSort(sortMap.get(costProfitVo.getReportId())));
|
|
|
Map<Long, List<CostProfitVo>> collect = costProfitVos.stream().collect(Collectors.groupingBy(CostProfitVo::getReportParentId));
|
|
|
-
|
|
|
List<CostProfitVo> costProfitParentVos = collect.get(NumberConstant.ZERO_L);
|
|
|
-
|
|
|
collect.remove(NumberConstant.ZERO_L);
|
|
|
for (CostProfitVo costProfitVo : costProfitParentVos) {
|
|
|
List<CostProfitVo> costProfitVo1 = collect.get(costProfitVo.getReportId());
|
|
|
- if(!CollectionUtils.isEmpty(costProfitVo1)){
|
|
|
- costProfitVo.setChildren(setChildren(costProfitVo1,collect));
|
|
|
+ if (!CollectionUtils.isEmpty(costProfitVo1)) {
|
|
|
+ costProfitVo.setChildren(setChildren(costProfitVo1, collect));
|
|
|
}
|
|
|
}
|
|
|
+ if (!CollectionUtils.isEmpty(costProfitParentVos)) {
|
|
|
+ costProfitParentVos.sort(Comparator.comparing(CostProfitVo::getSort, Comparator.nullsLast(Integer::compareTo)));
|
|
|
+ }
|
|
|
return costProfitParentVos;
|
|
|
}
|
|
|
|
|
|
- private List<CostProfitVo> setChildren(List<CostProfitVo> child,Map<Long, List<CostProfitVo>> collect){
|
|
|
- for(CostProfitVo costProfitVo:child){
|
|
|
- if(!CollectionUtils.isEmpty(collect.get(costProfitVo.getReportId()))){
|
|
|
- costProfitVo.setChildren(setChildren(collect.get(costProfitVo.getReportId()),collect));
|
|
|
+ private List<CostProfitVo> setChildren(List<CostProfitVo> child, Map<Long, List<CostProfitVo>> collect) {
|
|
|
+ for (CostProfitVo costProfitVo : child) {
|
|
|
+ if (!CollectionUtils.isEmpty(collect.get(costProfitVo.getReportId()))) {
|
|
|
+ costProfitVo.setChildren(setChildren(collect.get(costProfitVo.getReportId()), collect));
|
|
|
}
|
|
|
}
|
|
|
+ if (!CollectionUtils.isEmpty(child)) {
|
|
|
+ child.sort(Comparator.comparing(CostProfitVo::getSort, Comparator.nullsLast(Integer::compareTo)));
|
|
|
+ }
|
|
|
return child;
|
|
|
}
|
|
|
|
|
@@ -1288,7 +1440,6 @@ public class CostDepartmentProfitServiceImpl extends ServiceImpl<CostDepartmentP
|
|
|
List<IncomeCollection> incomeCollectionList = list.stream().filter(income -> income.getResponsibilityCode().equals(i.getResponsibilityCode()) && accountList.contains(income.getAccountingCode())).collect(Collectors.toList());
|
|
|
// 需要查询分摊后的表
|
|
|
List<AllocationQueryReportVO> reportVOList = allocationQueryReportVOList.stream().filter(m -> m.getTargetResponsibilityCode().equals(i.getResponsibilityCode()) && accountList.contains(m.getAccountingCode())).collect(Collectors.toList());
|
|
|
-
|
|
|
if (CollUtil.isNotEmpty(incomeCollectionList)) {
|
|
|
incomeCollectionList.forEach(m -> {
|
|
|
sum.updateAndGet(v -> v.add(m.getAmount()));
|