|
@@ -1582,9 +1582,7 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
for (Map.Entry<String, List<HospProfitAndLoss>> entry : groupedByYearMonth.entrySet()){
|
|
for (Map.Entry<String, List<HospProfitAndLoss>> entry : groupedByYearMonth.entrySet()){
|
|
|
List<HospProfitAndLoss> hospProfitAndLossList = entry.getValue();
|
|
List<HospProfitAndLoss> hospProfitAndLossList = entry.getValue();
|
|
|
//转换成成本损益数据
|
|
//转换成成本损益数据
|
|
|
- List<CostProfitVo> costProfitVos = convertToCostProfitVoList(hospProfitAndLossList, reportFormList);
|
|
|
|
|
- //记录所有月份的损益数据
|
|
|
|
|
- allCostProfitVo.addAll(costProfitVos);
|
|
|
|
|
|
|
+ List<CostProfitVo> costProfitVos = convertToCostProfitVoList(hospProfitAndLossList, reportFormList,allCostProfitVo);
|
|
|
//生成出参样式
|
|
//生成出参样式
|
|
|
BatchCostProfitResponse response = new BatchCostProfitResponse();
|
|
BatchCostProfitResponse response = new BatchCostProfitResponse();
|
|
|
//第13月为审计月份
|
|
//第13月为审计月份
|
|
@@ -1606,6 +1604,8 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
if(!beginComputeDate.equals(endComputeDate)){
|
|
if(!beginComputeDate.equals(endComputeDate)){
|
|
|
//获取月度汇总数据
|
|
//获取月度汇总数据
|
|
|
List<CostProfitVo> costProfitVos = generateSummaryForMultipleMonths(allCostProfitVo);
|
|
List<CostProfitVo> costProfitVos = generateSummaryForMultipleMonths(allCostProfitVo);
|
|
|
|
|
+ //填充全院其他收支
|
|
|
|
|
+ fillHopsOhterProfit(costProfitVos,responses);
|
|
|
if(!CollectionUtils.isEmpty(costProfitVos)){
|
|
if(!CollectionUtils.isEmpty(costProfitVos)){
|
|
|
BatchCostProfitResponse response = new BatchCostProfitResponse();
|
|
BatchCostProfitResponse response = new BatchCostProfitResponse();
|
|
|
response.setComputeDate(String.format("%s至%s", beginComputeDate, endComputeDate));
|
|
response.setComputeDate(String.format("%s至%s", beginComputeDate, endComputeDate));
|
|
@@ -1620,6 +1620,48 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
return responses;
|
|
return responses;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 填充全院其他收支
|
|
|
|
|
+ * @param multipleMonthsProfitVos
|
|
|
|
|
+ * @param responses
|
|
|
|
|
+ */
|
|
|
|
|
+ public void fillHopsOhterProfit(List<CostProfitVo> multipleMonthsProfitVos,List<BatchCostProfitResponse> responses) {
|
|
|
|
|
+ //获取累计月全院其他收支节点
|
|
|
|
|
+ Optional<CostProfitVo> firstHopsOhterProfit = multipleMonthsProfitVos.stream().filter(costProfitVo -> costProfitVo.getReportId().equals(-1L)).findFirst();
|
|
|
|
|
+ if(!firstHopsOhterProfit.isPresent()||CollectionUtils.isEmpty(firstHopsOhterProfit.get().getChildren())){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ CostProfitVo standCostProfitVo = firstHopsOhterProfit.get();
|
|
|
|
|
+ for (BatchCostProfitResponse response : responses) {
|
|
|
|
|
+ //获取月度的全院其他收支节点
|
|
|
|
|
+ Optional<CostProfitVo> firstOhterProfit = response.getProfitVoList().stream().filter(costProfitVo -> costProfitVo.getReportId().equals(-1L)).findFirst();
|
|
|
|
|
+ //没有全院其他收支的添加一个空数据的全院其他收支
|
|
|
|
|
+ if(!firstOhterProfit.isPresent()||CollectionUtils.isEmpty(firstOhterProfit.get().getChildren())){
|
|
|
|
|
+ CostProfitVo costProfitVo = BeanUtil.convertObj(standCostProfitVo, CostProfitVo.class);
|
|
|
|
|
+ costProfitVo.setChildren(new ArrayList<>());
|
|
|
|
|
+ //添加缺失的全院其他收支项目到月度数据中
|
|
|
|
|
+ for (CostProfitVo missChildCostProfitVo : standCostProfitVo.getChildren()) {
|
|
|
|
|
+ CostProfitVo newCostProfitVo = BeanUtil.convertObj(missChildCostProfitVo, CostProfitVo.class);
|
|
|
|
|
+ combineReportAndProfitAmount(newCostProfitVo,null);
|
|
|
|
|
+ costProfitVo.getChildren().add(newCostProfitVo);
|
|
|
|
|
+ }
|
|
|
|
|
+ response.getProfitVoList().add(costProfitVo);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ //找出月度缺失的全院其他收支
|
|
|
|
|
+ List<CostProfitVo> missChilds = standCostProfitVo.getChildren().stream().filter(standChildCostProfitVo -> !firstOhterProfit.get().getChildren().stream().anyMatch(childCostProfitVo -> standChildCostProfitVo.getReportId().equals(childCostProfitVo.getReportId()))).collect(Collectors.toList());
|
|
|
|
|
+ if(CollectionUtils.isEmpty(missChilds)){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ //添加缺失的全院其他收支项目到月度数据中
|
|
|
|
|
+ for (CostProfitVo missChildCostProfitVo : missChilds) {
|
|
|
|
|
+ CostProfitVo costProfitVo = BeanUtil.convertObj(missChildCostProfitVo, CostProfitVo.class);
|
|
|
|
|
+ combineReportAndProfitAmount(costProfitVo,null);
|
|
|
|
|
+ firstOhterProfit.get().getChildren().add(costProfitVo);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 生成多月份汇总的科室损益数据
|
|
* 生成多月份汇总的科室损益数据
|
|
|
*
|
|
*
|
|
@@ -1648,6 +1690,7 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
BigDecimal totalSamePeriodAmount = profitVos.stream().map(vo -> Optional.ofNullable(vo.getSamePeriodAmount()).orElse(BigDecimal.ZERO))
|
|
BigDecimal totalSamePeriodAmount = profitVos.stream().map(vo -> Optional.ofNullable(vo.getSamePeriodAmount()).orElse(BigDecimal.ZERO))
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
+ costProfitVo.setChildren(null);
|
|
|
costProfitVo.setAmount(totalAmount);
|
|
costProfitVo.setAmount(totalAmount);
|
|
|
costProfitVo.setBudgetAmount(totalBudgetAmount);
|
|
costProfitVo.setBudgetAmount(totalBudgetAmount);
|
|
|
costProfitVo.setPrevPeriodAmount(totalPrevPeriodAmount);
|
|
costProfitVo.setPrevPeriodAmount(totalPrevPeriodAmount);
|
|
@@ -1668,7 +1711,7 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
* @param reportFormList
|
|
* @param reportFormList
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public List<CostProfitVo> convertToCostProfitVoList(List<HospProfitAndLoss> hospProfitAndLossList,List<ReportForm> reportFormList ){
|
|
|
|
|
|
|
+ public List<CostProfitVo> convertToCostProfitVoList(List<HospProfitAndLoss> hospProfitAndLossList,List<ReportForm> reportFormList,List<CostProfitVo> allCostProfitVo ){
|
|
|
//全院其他收支项目
|
|
//全院其他收支项目
|
|
|
List<HospProfitAndLoss> otherHospProfitAndLoss = hospProfitAndLossList.stream().filter(i -> NumberConstant.ONE.equals(i.getOriginType())).collect(Collectors.toList());
|
|
List<HospProfitAndLoss> otherHospProfitAndLoss = hospProfitAndLossList.stream().filter(i -> NumberConstant.ONE.equals(i.getOriginType())).collect(Collectors.toList());
|
|
|
//按报表项目编号map
|
|
//按报表项目编号map
|
|
@@ -1709,12 +1752,18 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
costProfitVo.setMonth(hospProfitAndLoss.getDateMonth());
|
|
costProfitVo.setMonth(hospProfitAndLoss.getDateMonth());
|
|
|
//全院其他收支项目放在虚拟的全院其他收支下
|
|
//全院其他收支项目放在虚拟的全院其他收支下
|
|
|
costProfitVo.setSort(i);
|
|
costProfitVo.setSort(i);
|
|
|
- costProfitVo.setReportNum(hospProfitAndLoss.getReportNum());
|
|
|
|
|
- costProfitVo.setReportId(hospProfitAndLoss.getReportNum().longValue());
|
|
|
|
|
|
|
+ //添加一个负数作为虚拟的报表项目编号
|
|
|
|
|
+ Integer reportNum =hospProfitAndLoss.getReportNum();
|
|
|
|
|
+ costProfitVo.setReportNum(reportNum);
|
|
|
|
|
+ costProfitVo.setId(reportNum.longValue());
|
|
|
|
|
+ costProfitVo.setReportId(reportNum.longValue());
|
|
|
|
|
+ costProfitVo.setReportName(hospProfitAndLoss.getReportName());
|
|
|
costProfitVo.setReportParentId(otherProfit.getReportId());
|
|
costProfitVo.setReportParentId(otherProfit.getReportId());
|
|
|
costProfitVos.add(costProfitVo);
|
|
costProfitVos.add(costProfitVo);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ //记录所有月份的损益数据
|
|
|
|
|
+ allCostProfitVo.addAll(costProfitVos);
|
|
|
//转成树状结构的损益数据
|
|
//转成树状结构的损益数据
|
|
|
List<CostProfitVo> costProfitVoTree = converToCostProfitVoTree(costProfitVos);
|
|
List<CostProfitVo> costProfitVoTree = converToCostProfitVoTree(costProfitVos);
|
|
|
return costProfitVoTree;
|
|
return costProfitVoTree;
|
|
@@ -1744,6 +1793,7 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
|
|
|
*/
|
|
*/
|
|
|
public CostProfitVo reportFormToProfitVo(ReportForm reportForm){
|
|
public CostProfitVo reportFormToProfitVo(ReportForm reportForm){
|
|
|
CostProfitVo profitVo = new CostProfitVo();
|
|
CostProfitVo profitVo = new CostProfitVo();
|
|
|
|
|
+ profitVo.setId(reportForm.getId());
|
|
|
profitVo.setReportId(reportForm.getId());
|
|
profitVo.setReportId(reportForm.getId());
|
|
|
profitVo.setReportName(reportForm.getReportName());
|
|
profitVo.setReportName(reportForm.getReportName());
|
|
|
profitVo.setReportParentId(reportForm.getParentId());
|
|
profitVo.setReportParentId(reportForm.getParentId());
|