|
@@ -1,13 +1,12 @@
|
|
|
package com.kcim.service.impl;
|
|
package com.kcim.service.impl;
|
|
|
|
|
|
|
|
-import cn.hutool.core.date.DateTime;
|
|
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import com.kcim.common.constants.Constant;
|
|
import com.kcim.common.constants.Constant;
|
|
|
import com.kcim.common.constants.NumberConstant;
|
|
import com.kcim.common.constants.NumberConstant;
|
|
|
import com.kcim.common.constants.ParameterConstant;
|
|
import com.kcim.common.constants.ParameterConstant;
|
|
|
import com.kcim.common.constants.SplitConstant;
|
|
import com.kcim.common.constants.SplitConstant;
|
|
|
import com.kcim.common.exception.CostException;
|
|
import com.kcim.common.exception.CostException;
|
|
|
import com.kcim.common.util.BeanUtil;
|
|
import com.kcim.common.util.BeanUtil;
|
|
|
|
|
+import com.kcim.common.util.ComputeDateUtils;
|
|
|
import com.kcim.common.util.UserContext;
|
|
import com.kcim.common.util.UserContext;
|
|
|
import com.kcim.dao.model.*;
|
|
import com.kcim.dao.model.*;
|
|
|
import com.kcim.dao.repository.AccountingRepository;
|
|
import com.kcim.dao.repository.AccountingRepository;
|
|
@@ -18,7 +17,6 @@ import com.kcim.service.CenterService;
|
|
|
import com.kcim.service.IncomeCollectionService;
|
|
import com.kcim.service.IncomeCollectionService;
|
|
|
import com.kcim.service.StandardReportService;
|
|
import com.kcim.service.StandardReportService;
|
|
|
import com.kcim.vo.*;
|
|
import com.kcim.vo.*;
|
|
|
-import com.kcim.vo.HospitalDeptCostAllocationVO;
|
|
|
|
|
import com.kcim.web.reponse.ComputeProfitCollectResponse;
|
|
import com.kcim.web.reponse.ComputeProfitCollectResponse;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -64,9 +62,8 @@ public class StandardReportServiceImpl implements StandardReportService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public List<DeptDirectMedicalCostVO> getDeptDirectMedicalCost(String computeDate) {
|
|
public List<DeptDirectMedicalCostVO> getDeptDirectMedicalCost(String computeDate) {
|
|
|
- DateTime parse = DateUtil.parse(computeDate);
|
|
|
|
|
- int year = DateUtil.year(parse);
|
|
|
|
|
- int month = DateUtil.month(parse) + 1;
|
|
|
|
|
|
|
+ Integer year = ComputeDateUtils.getComputeYear(computeDate);
|
|
|
|
|
+ Integer month = ComputeDateUtils.getComputeMonth(computeDate);
|
|
|
//获取科室直接成本
|
|
//获取科室直接成本
|
|
|
List<AllocationQuery> allocationQueryList = allocationQueryService.getCostByDate(UserContext.getCurrentLoginHospId(), year, month, NumberConstant.ONE);
|
|
List<AllocationQuery> allocationQueryList = allocationQueryService.getCostByDate(UserContext.getCurrentLoginHospId(), year, month, NumberConstant.ONE);
|
|
|
if(CollectionUtils.isEmpty(allocationQueryList)){
|
|
if(CollectionUtils.isEmpty(allocationQueryList)){
|
|
@@ -132,9 +129,8 @@ public class StandardReportServiceImpl implements StandardReportService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public List<DeptFullDirectCostVO> getDeptFullDirectCost(String computeDate) {
|
|
public List<DeptFullDirectCostVO> getDeptFullDirectCost(String computeDate) {
|
|
|
- DateTime parse = DateUtil.parse(computeDate);
|
|
|
|
|
- int year = DateUtil.year(parse);
|
|
|
|
|
- int month = DateUtil.month(parse) + 1;
|
|
|
|
|
|
|
+ Integer year = ComputeDateUtils.getComputeYear(computeDate);
|
|
|
|
|
+ Integer month = ComputeDateUtils.getComputeMonth(computeDate);
|
|
|
|
|
|
|
|
// 获取科室直接成本
|
|
// 获取科室直接成本
|
|
|
List<AllocationQuery> allocationQueryList = allocationQueryService.getCostByDate(UserContext.getCurrentLoginHospId(), year, month, NumberConstant.ONE);
|
|
List<AllocationQuery> allocationQueryList = allocationQueryService.getCostByDate(UserContext.getCurrentLoginHospId(), year, month, NumberConstant.ONE);
|
|
@@ -200,9 +196,8 @@ public class StandardReportServiceImpl implements StandardReportService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public List<ClinicalDeptMedicalCostVO> getClinicalDeptMedicalCost(String computeDate) {
|
|
public List<ClinicalDeptMedicalCostVO> getClinicalDeptMedicalCost(String computeDate) {
|
|
|
- DateTime parse = DateUtil.parse(computeDate);
|
|
|
|
|
- int year = DateUtil.year(parse);
|
|
|
|
|
- int month = DateUtil.month(parse) + 1;
|
|
|
|
|
|
|
+ Integer year = ComputeDateUtils.getComputeYear(computeDate);
|
|
|
|
|
+ Integer month = ComputeDateUtils.getComputeMonth(computeDate);
|
|
|
// 获取科室直接成本
|
|
// 获取科室直接成本
|
|
|
List<AllocationQuery> allocationQueryList = allocationQueryService.getAllByDate(UserContext.getCurrentLoginHospId(), year, month);
|
|
List<AllocationQuery> allocationQueryList = allocationQueryService.getAllByDate(UserContext.getCurrentLoginHospId(), year, month);
|
|
|
if (CollectionUtils.isEmpty(allocationQueryList)) {
|
|
if (CollectionUtils.isEmpty(allocationQueryList)) {
|
|
@@ -234,9 +229,8 @@ public class StandardReportServiceImpl implements StandardReportService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public List<ClinicalDeptFullCostVO> getClinicalDeptFullCost(String computeDate) {
|
|
public List<ClinicalDeptFullCostVO> getClinicalDeptFullCost(String computeDate) {
|
|
|
- DateTime parse = DateUtil.parse(computeDate);
|
|
|
|
|
- int year = DateUtil.year(parse);
|
|
|
|
|
- int month = DateUtil.month(parse) + 1;
|
|
|
|
|
|
|
+ Integer year = ComputeDateUtils.getComputeYear(computeDate);
|
|
|
|
|
+ Integer month = ComputeDateUtils.getComputeMonth(computeDate);
|
|
|
|
|
|
|
|
// 获取科室直接成本
|
|
// 获取科室直接成本
|
|
|
List<AllocationQuery> allocationQueryList = allocationQueryService.getAllByDate(UserContext.getCurrentLoginHospId(), year, month);
|
|
List<AllocationQuery> allocationQueryList = allocationQueryService.getAllByDate(UserContext.getCurrentLoginHospId(), year, month);
|
|
@@ -277,9 +271,8 @@ public class StandardReportServiceImpl implements StandardReportService {
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public ComputeProfitCollectResponse getClinicalDeptFullCostAnalysis(String computeDate) {
|
|
public ComputeProfitCollectResponse getClinicalDeptFullCostAnalysis(String computeDate) {
|
|
|
- DateTime parse = DateUtil.parse(computeDate);
|
|
|
|
|
- int year = DateUtil.year(parse);
|
|
|
|
|
- int month = DateUtil.month(parse) + 1;
|
|
|
|
|
|
|
+ Integer year = ComputeDateUtils.getComputeYear(computeDate);
|
|
|
|
|
+ Integer month = ComputeDateUtils.getComputeMonth(computeDate);
|
|
|
|
|
|
|
|
// 获取科室成本
|
|
// 获取科室成本
|
|
|
List<AllocationQuery> allocationQueryList = allocationQueryService.getAllByDate(UserContext.getCurrentLoginHospId(), year, month);
|
|
List<AllocationQuery> allocationQueryList = allocationQueryService.getAllByDate(UserContext.getCurrentLoginHospId(), year, month);
|
|
@@ -386,6 +379,246 @@ public class StandardReportServiceImpl implements StandardReportService {
|
|
|
return response;
|
|
return response;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取医院科室成本分摊汇总表数据
|
|
|
|
|
+ * @param computeDate 核算年月
|
|
|
|
|
+ * @return 报表数据
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<HospitalDeptCostAllocationVO> getHospitalDeptCostAllocation(String computeDate) {
|
|
|
|
|
+ Integer year = ComputeDateUtils.getComputeYear(computeDate);
|
|
|
|
|
+ Integer month = ComputeDateUtils.getComputeMonth(computeDate);
|
|
|
|
|
+
|
|
|
|
|
+ // 获取科室成本
|
|
|
|
|
+ List<AllocationQuery> allocationQueryList = allocationQueryService.getAllByDate(UserContext.getCurrentLoginHospId(), year, month);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(allocationQueryList)) {
|
|
|
|
|
+ throw new CostException("医院未分摊本月数据");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取所有的标准字典数据
|
|
|
|
|
+ StandCostDictMapVO standCostDictMaps = getStandCostDictMaps();
|
|
|
|
|
+
|
|
|
|
|
+ // 处理 allocationQueryList 数据
|
|
|
|
|
+ Map<String, HospitalDeptCostAllocationVO> deptCostAllocationMap = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ // 转换为HospitalDeptCostAllocationVO(一个责任中心只一条记录)
|
|
|
|
|
+ for (AllocationQuery allocationQuery : allocationQueryList) {
|
|
|
|
|
+ addHospitalDeptCostAllocationVO(deptCostAllocationMap, allocationQuery, standCostDictMaps);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 转成List便于处理
|
|
|
|
|
+ List<HospitalDeptCostAllocationVO> reportList = new ArrayList<>(deptCostAllocationMap.values());
|
|
|
|
|
+ //创建总计
|
|
|
|
|
+ HospitalDeptCostAllocationVO grandTotal = createSubtotalVo(reportList.get(NumberConstant.ZERO), "总计", HospitalDeptCostAllocationVO.class);
|
|
|
|
|
+ // 按responsibilitySort正序排序
|
|
|
|
|
+ reportList.sort(Comparator.comparing(HospitalDeptCostAllocationVO::getResponsibilitySort,
|
|
|
|
|
+ Comparator.nullsLast(Comparator.naturalOrder())));
|
|
|
|
|
+
|
|
|
|
|
+ // 按标准分级分组
|
|
|
|
|
+ Map<String, List<HospitalDeptCostAllocationVO>> shareLevelGroup = reportList.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(HospitalDeptCostAllocationVO::getStandardShareLevel));
|
|
|
|
|
+
|
|
|
|
|
+ // 科室标准分级按顺序号倒序排序
|
|
|
|
|
+ List<DictDataVo> standardShareLevelList = standCostDictMaps.getStandardShareLevelDict();
|
|
|
|
|
+ standardShareLevelList.sort(Comparator.comparing(DictDataVo::getSort, Comparator.nullsLast(Comparator.reverseOrder())));
|
|
|
|
|
+
|
|
|
|
|
+ // 创建各层级小计并按正确顺序插入
|
|
|
|
|
+ List<HospitalDeptCostAllocationVO> result = new ArrayList<>();
|
|
|
|
|
+ for (DictDataVo shareLevel : standardShareLevelList) {
|
|
|
|
|
+ List<HospitalDeptCostAllocationVO> deptCostAllocationVOS = shareLevelGroup.get(shareLevel.getCode());
|
|
|
|
|
+ if (CollectionUtils.isEmpty(deptCostAllocationVOS)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 添加该分类下的所有记录
|
|
|
|
|
+ result.addAll(deptCostAllocationVOS);
|
|
|
|
|
+ // 创建小计对象
|
|
|
|
|
+ HospitalDeptCostAllocationVO subtotalVo = createSubtotalVo(deptCostAllocationVOS.get(NumberConstant.ZERO), String.format("%s小计", shareLevel.getName()), HospitalDeptCostAllocationVO.class);
|
|
|
|
|
+ //将科室的金额加到小计对象中
|
|
|
|
|
+ deptCostAllocationVOS.forEach(item -> addBigDecimalFields(item, subtotalVo));
|
|
|
|
|
+ // 小计的金额加到总计
|
|
|
|
|
+ addBigDecimalFields(subtotalVo, grandTotal);
|
|
|
|
|
+ // 添加小计行
|
|
|
|
|
+ result.add(subtotalVo);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 总计加到列表最后面
|
|
|
|
|
+ result.add(grandTotal);
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取医院诊次成本构成表数据
|
|
|
|
|
+ * @param computeDate 核算年月
|
|
|
|
|
+ * @return 报表数据
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<HospitalVisitCostCompositionVO> getHospitalVisitCostComposition(String computeDate) {
|
|
|
|
|
+ Integer year = ComputeDateUtils.getComputeYear(computeDate);
|
|
|
|
|
+ Integer month = ComputeDateUtils.getComputeMonth(computeDate);
|
|
|
|
|
+
|
|
|
|
|
+ // 获取科室成本
|
|
|
|
|
+ List<AllocationQuery> allocationQueryList = allocationQueryService.getAcountAccounts(UserContext.getCurrentLoginHospId(), year, month);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(allocationQueryList)) {
|
|
|
|
|
+ throw new CostException("医院未分摊本月数据");
|
|
|
|
|
+ }
|
|
|
|
|
+ //获取分摊参数
|
|
|
|
|
+ List<ShareParamValue> shareParamValueList = shareParamValueRepository.getList(computeDate);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(shareParamValueList)) {
|
|
|
|
|
+ throw new CostException("未获取医院本月分摊参数数据");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 获取所有的标准字典数据
|
|
|
|
|
+ StandCostDictMapVO standCostDictMaps = getStandCostDictMaps();
|
|
|
|
|
+ //获取成本会计科目字典
|
|
|
|
|
+ List<DictDataVo> accountingTypeDict = standCostDictMaps.getAccountingTypeDict();
|
|
|
|
|
+ List<DictDataVo> costAccountingTypeDict = accountingTypeDict.stream().filter(dictDataVo -> NumberConstant.TWO_S.equals(dictDataVo.getValue())).collect(Collectors.toList());
|
|
|
|
|
+ // 初始化成本项目映射
|
|
|
|
|
+ Map<String, HospitalVisitCostCompositionVO> costItemMap =createHospitalVisitCostCompositionVO(costAccountingTypeDict);
|
|
|
|
|
+ // 处理分配查询数据
|
|
|
|
|
+ for (AllocationQuery allocationQuery : allocationQueryList) {
|
|
|
|
|
+ String accountingCode = allocationQuery.getAccountingCode();
|
|
|
|
|
+ Accounting account = standCostDictMaps.getAccountingMap().get(accountingCode);
|
|
|
|
|
+ if (account == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ DictDataVo costType = standCostDictMaps.getCostTypeMap().get(account.getCostType());
|
|
|
|
|
+ HospitalVisitCostCompositionVO vo = costItemMap.get(account.getType());
|
|
|
|
|
+ // 医疗成本
|
|
|
|
|
+ if ("1".equals(costType.getExpandOne())) {
|
|
|
|
|
+ vo.setMedicalCost(vo.getMedicalCost().add(allocationQuery.getAmount()));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 医疗全成本
|
|
|
|
|
+ if (!"3".equals(costType.getExpandOne())) {
|
|
|
|
|
+ vo.setMedicalFullCost(vo.getMedicalFullCost().add(allocationQuery.getAmount()));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 医院全成本
|
|
|
|
|
+ vo.setHospitalFullCost(vo.getHospitalFullCost().add(allocationQuery.getAmount()));
|
|
|
|
|
+ }
|
|
|
|
|
+ //获取诊次床日分摊参数代码
|
|
|
|
|
+ String[] visitsBedDaysParamCode = getVisitsBedDaysParamCode();
|
|
|
|
|
+
|
|
|
|
|
+ // 诊次分摊参数值
|
|
|
|
|
+ BigDecimal visitParamValue = getParamValue(shareParamValueList, visitsBedDaysParamCode[NumberConstant.ZERO]);
|
|
|
|
|
+// // 床日分摊参数值
|
|
|
|
|
+// BigDecimal bedDaysParamValue = getParamValue(shareParamValueList, visitsBedDaysParamCode[NumberConstant.ONE]);
|
|
|
|
|
+
|
|
|
|
|
+ //处理总计和药品小计
|
|
|
|
|
+ HospitalVisitCostCompositionVO totalVo = new HospitalVisitCostCompositionVO();
|
|
|
|
|
+ totalVo.setCostItem("总计");
|
|
|
|
|
+ HospitalVisitCostCompositionVO drugTotalVo = new HospitalVisitCostCompositionVO();
|
|
|
|
|
+ totalVo.setCostItem("药品费");
|
|
|
|
|
+ // 转成List便于处理
|
|
|
|
|
+ List<HospitalVisitCostCompositionVO> reportList = costItemMap.values().stream().collect(Collectors.toList());
|
|
|
|
|
+ for (HospitalVisitCostCompositionVO item : reportList) {
|
|
|
|
|
+ //计算每诊次的医疗全成本
|
|
|
|
|
+ item.setHospitalFullCost(getPercent(visitParamValue,totalVo.getHospitalFullCost()));
|
|
|
|
|
+ //计算每诊次的医疗成本
|
|
|
|
|
+ item.setMedicalCost(getPercent(visitParamValue,totalVo.getMedicalCost()));
|
|
|
|
|
+ //计算每诊次的医院全成本
|
|
|
|
|
+ item.setHospitalFullCost(getPercent(visitParamValue,totalVo.getMedicalFullCost()));
|
|
|
|
|
+ // 将金额加到总计对象中
|
|
|
|
|
+ addBigDecimalFields(item, totalVo);
|
|
|
|
|
+ /// 将金额加到药品对象中
|
|
|
|
|
+ if(NumberConstant.THREE_S.equals(item.getCostType())){
|
|
|
|
|
+ addBigDecimalFields(item, drugTotalVo);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //添加到列表的指定位置
|
|
|
|
|
+ reportList.add(NumberConstant.TWO,drugTotalVo);
|
|
|
|
|
+ reportList.add(NumberConstant.ZERO,totalVo);
|
|
|
|
|
+ return reportList;
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取医院科室诊次成本表数据
|
|
|
|
|
+ * @param computeDate 核算年月
|
|
|
|
|
+ * @return 报表数据
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<DeptFullDirectCostVO> getHospitalDeptVisitCost(String computeDate) {
|
|
|
|
|
+ Integer year = ComputeDateUtils.getComputeYear(computeDate);
|
|
|
|
|
+ Integer month = ComputeDateUtils.getComputeMonth(computeDate);
|
|
|
|
|
+
|
|
|
|
|
+ // 获取科室成本
|
|
|
|
|
+ List<AllocationQuery> allocationQueryList = allocationQueryService.getRespAcountAccounts(UserContext.getCurrentLoginHospId(), year, month);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(allocationQueryList)) {
|
|
|
|
|
+ throw new CostException("医院未分摊本月数据");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 获取所有的标准字典数据
|
|
|
|
|
+ StandCostDictMapVO standCostDictMaps = getStandCostDictMaps();
|
|
|
|
|
+
|
|
|
|
|
+ // 获取分摊参数
|
|
|
|
|
+ List<ShareParamValue> shareParamValueList = shareParamValueRepository.getList(computeDate);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(shareParamValueList)) {
|
|
|
|
|
+ throw new CostException("未获取医院本月分摊参数数据");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 获取诊次床日分摊参数代码
|
|
|
|
|
+ String[] visitsBedDaysParamCode = getVisitsBedDaysParamCode();
|
|
|
|
|
+ BigDecimal visitParamValue = getParamValue(shareParamValueList, visitsBedDaysParamCode[NumberConstant.ZERO]);
|
|
|
|
|
+
|
|
|
|
|
+ // 处理 allocationQueryList 数据
|
|
|
|
|
+ Map<String, DeptFullDirectCostVO> deptVisitCostMap = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ for (AllocationQuery allocationQuery : allocationQueryList) {
|
|
|
|
|
+ String responsibilityCode = allocationQuery.getTargetResponsibilityCode();
|
|
|
|
|
+ Responsibility responsibility = standCostDictMaps.getResponsibilityMap().get(responsibilityCode);
|
|
|
|
|
+ if (responsibility == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ String accountingCode = allocationQuery.getAccountingCode();
|
|
|
|
|
+ Accounting account = standCostDictMaps.getAccountingMap().get(accountingCode);
|
|
|
|
|
+ if (account == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ //只处理临床科室
|
|
|
|
|
+ if(NumberConstant.FOUR.equals(responsibility.getStandardShareLevel())){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ DeptFullDirectCostVO vo = new DeptFullDirectCostVO();
|
|
|
|
|
+ if (deptVisitCostMap.containsKey(responsibilityCode)) {
|
|
|
|
|
+ vo = deptVisitCostMap.get(responsibilityCode);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 初始化科室信息
|
|
|
|
|
+ vo.setResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
|
|
+ vo.setResponsibilityName(responsibility.getResponsibilityName());
|
|
|
|
|
+ vo.setResponsibilitySort(responsibility.getSort());
|
|
|
|
|
+ // 初始化所有费用字段为0
|
|
|
|
|
+ BeanUtil.initBigDecimalFieldsToZero(vo);
|
|
|
|
|
+ }
|
|
|
|
|
+ DictDataVo costType = standCostDictMaps.getCostTypeMap().get(account.getCostType());
|
|
|
|
|
+ // 医疗成本
|
|
|
|
|
+ if ("1".equals(costType.getExpandOne())) {
|
|
|
|
|
+ vo.setMedicalCostTotal(vo.getMedicalCostTotal().add(allocationQuery.getAmount()));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 医疗全成本
|
|
|
|
|
+ if (!"3".equals(costType.getExpandOne())) {
|
|
|
|
|
+ vo.setMedicalTotalCost(vo.getMedicalTotalCost().add(allocationQuery.getAmount()));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 医院全成本
|
|
|
|
|
+ vo.setHospitalTotalCost(vo.getHospitalTotalCost().add(allocationQuery.getAmount()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 转成List便于处理
|
|
|
|
|
+ List<DeptFullDirectCostVO> reportList = new ArrayList<>(deptVisitCostMap.values());
|
|
|
|
|
+ // 创建总计对象
|
|
|
|
|
+ DeptFullDirectCostVO grandTotal = createSubtotalVo(reportList.get(NumberConstant.ZERO), "总计", DeptFullDirectCostVO.class);
|
|
|
|
|
+ // 计算每诊次成本
|
|
|
|
|
+ for (DeptFullDirectCostVO vo : reportList) {
|
|
|
|
|
+ // 计算每诊次医疗成本
|
|
|
|
|
+ vo.setMedicalCostTotal(getPercent(vo.getMedicalCostTotal(), visitParamValue));
|
|
|
|
|
+ // 计算每诊次医疗全成本
|
|
|
|
|
+ vo.setMedicalTotalCost(getPercent(vo.getMedicalTotalCost(), visitParamValue));
|
|
|
|
|
+ // 计算每诊次医院全成本
|
|
|
|
|
+ vo.setHospitalTotalCost(getPercent(vo.getHospitalTotalCost(), visitParamValue));
|
|
|
|
|
+ // 将各科室金额累加到总计对象
|
|
|
|
|
+ reportList.forEach(item -> addBigDecimalFields(item, grandTotal));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 按responsibilitySort正序排序
|
|
|
|
|
+ reportList.sort(Comparator.comparing(DeptFullDirectCostVO::getResponsibilitySort,
|
|
|
|
|
+ Comparator.nullsLast(Comparator.naturalOrder())));
|
|
|
|
|
+ // 添加总计行
|
|
|
|
|
+ reportList.add(NumberConstant.ZERO,grandTotal);
|
|
|
|
|
+ return reportList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取可是指定项目的金额
|
|
* 获取可是指定项目的金额
|
|
|
* @param dept
|
|
* @param dept
|
|
@@ -1045,156 +1278,6 @@ public class StandardReportServiceImpl implements StandardReportService {
|
|
|
return split;
|
|
return split;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 获取医院科室成本分摊汇总表数据
|
|
|
|
|
- * @param computeDate 核算年月
|
|
|
|
|
- * @return 报表数据
|
|
|
|
|
- */
|
|
|
|
|
- @Override
|
|
|
|
|
- public List<HospitalDeptCostAllocationVO> getHospitalDeptCostAllocation(String computeDate) {
|
|
|
|
|
- DateTime parse = DateUtil.parse(computeDate);
|
|
|
|
|
- int year = DateUtil.year(parse);
|
|
|
|
|
- int month = DateUtil.month(parse) + 1;
|
|
|
|
|
-
|
|
|
|
|
- // 获取科室成本
|
|
|
|
|
- List<AllocationQuery> allocationQueryList = allocationQueryService.getAllByDate(UserContext.getCurrentLoginHospId(), year, month);
|
|
|
|
|
- if (CollectionUtils.isEmpty(allocationQueryList)) {
|
|
|
|
|
- throw new CostException("医院未分摊本月数据");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 获取所有的标准字典数据
|
|
|
|
|
- StandCostDictMapVO standCostDictMaps = getStandCostDictMaps();
|
|
|
|
|
-
|
|
|
|
|
- // 处理 allocationQueryList 数据
|
|
|
|
|
- Map<String, HospitalDeptCostAllocationVO> deptCostAllocationMap = new HashMap<>();
|
|
|
|
|
-
|
|
|
|
|
- // 转换为HospitalDeptCostAllocationVO(一个责任中心只一条记录)
|
|
|
|
|
- for (AllocationQuery allocationQuery : allocationQueryList) {
|
|
|
|
|
- addHospitalDeptCostAllocationVO(deptCostAllocationMap, allocationQuery, standCostDictMaps);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 转成List便于处理
|
|
|
|
|
- List<HospitalDeptCostAllocationVO> reportList = new ArrayList<>(deptCostAllocationMap.values());
|
|
|
|
|
- //创建总计
|
|
|
|
|
- HospitalDeptCostAllocationVO grandTotal = createSubtotalVo(reportList.get(NumberConstant.ZERO), "总计", HospitalDeptCostAllocationVO.class);
|
|
|
|
|
- // 按responsibilitySort正序排序
|
|
|
|
|
- reportList.sort(Comparator.comparing(HospitalDeptCostAllocationVO::getResponsibilitySort,
|
|
|
|
|
- Comparator.nullsLast(Comparator.naturalOrder())));
|
|
|
|
|
-
|
|
|
|
|
- // 按标准分级分组
|
|
|
|
|
- Map<String, List<HospitalDeptCostAllocationVO>> shareLevelGroup = reportList.stream()
|
|
|
|
|
- .collect(Collectors.groupingBy(HospitalDeptCostAllocationVO::getStandardShareLevel));
|
|
|
|
|
-
|
|
|
|
|
- // 科室标准分级按顺序号倒序排序
|
|
|
|
|
- List<DictDataVo> standardShareLevelList = standCostDictMaps.getStandardShareLevelDict();
|
|
|
|
|
- standardShareLevelList.sort(Comparator.comparing(DictDataVo::getSort, Comparator.nullsLast(Comparator.reverseOrder())));
|
|
|
|
|
-
|
|
|
|
|
- // 创建各层级小计并按正确顺序插入
|
|
|
|
|
- List<HospitalDeptCostAllocationVO> result = new ArrayList<>();
|
|
|
|
|
- for (DictDataVo shareLevel : standardShareLevelList) {
|
|
|
|
|
- List<HospitalDeptCostAllocationVO> deptCostAllocationVOS = shareLevelGroup.get(shareLevel.getCode());
|
|
|
|
|
- if (CollectionUtils.isEmpty(deptCostAllocationVOS)) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- // 添加该分类下的所有记录
|
|
|
|
|
- result.addAll(deptCostAllocationVOS);
|
|
|
|
|
- // 创建小计对象
|
|
|
|
|
- HospitalDeptCostAllocationVO subtotalVo = createSubtotalVo(deptCostAllocationVOS.get(NumberConstant.ZERO), String.format("%s小计", shareLevel.getName()), HospitalDeptCostAllocationVO.class);
|
|
|
|
|
- //将科室的金额加到小计对象中
|
|
|
|
|
- deptCostAllocationVOS.forEach(item -> addBigDecimalFields(item, subtotalVo));
|
|
|
|
|
- // 小计的金额加到总计
|
|
|
|
|
- addBigDecimalFields(subtotalVo, grandTotal);
|
|
|
|
|
- // 添加小计行
|
|
|
|
|
- result.add(subtotalVo);
|
|
|
|
|
- }
|
|
|
|
|
- // 总计加到列表最后面
|
|
|
|
|
- result.add(grandTotal);
|
|
|
|
|
- return result;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 获取医院诊次成本构成表数据
|
|
|
|
|
- * @param computeDate 核算年月
|
|
|
|
|
- * @return 报表数据
|
|
|
|
|
- */
|
|
|
|
|
- @Override
|
|
|
|
|
- public List<HospitalVisitCostCompositionVO> getHospitalVisitCostComposition(String computeDate) {
|
|
|
|
|
- DateTime parse = DateUtil.parse(computeDate);
|
|
|
|
|
- int year = DateUtil.year(parse);
|
|
|
|
|
- int month = DateUtil.month(parse) + 1;
|
|
|
|
|
-
|
|
|
|
|
- // 获取科室成本
|
|
|
|
|
- List<AllocationQuery> allocationQueryList = allocationQueryService.getAcountAccounts(UserContext.getCurrentLoginHospId(), year, month);
|
|
|
|
|
- if (CollectionUtils.isEmpty(allocationQueryList)) {
|
|
|
|
|
- throw new CostException("医院未分摊本月数据");
|
|
|
|
|
- }
|
|
|
|
|
- //获取分摊参数
|
|
|
|
|
- List<ShareParamValue> shareParamValueList = shareParamValueRepository.getList(computeDate);
|
|
|
|
|
- if (CollectionUtils.isEmpty(shareParamValueList)) {
|
|
|
|
|
- throw new CostException("未获取医院本月分摊参数数据");
|
|
|
|
|
- }
|
|
|
|
|
- // 获取所有的标准字典数据
|
|
|
|
|
- StandCostDictMapVO standCostDictMaps = getStandCostDictMaps();
|
|
|
|
|
- //获取成本会计科目字典
|
|
|
|
|
- List<DictDataVo> accountingTypeDict = standCostDictMaps.getAccountingTypeDict();
|
|
|
|
|
- List<DictDataVo> costAccountingTypeDict = accountingTypeDict.stream().filter(dictDataVo -> NumberConstant.TWO_S.equals(dictDataVo.getValue())).collect(Collectors.toList());
|
|
|
|
|
- // 初始化成本项目映射
|
|
|
|
|
- Map<String, HospitalVisitCostCompositionVO> costItemMap =createHospitalVisitCostCompositionVO(costAccountingTypeDict);
|
|
|
|
|
- // 处理分配查询数据
|
|
|
|
|
- for (AllocationQuery allocationQuery : allocationQueryList) {
|
|
|
|
|
- String accountingCode = allocationQuery.getAccountingCode();
|
|
|
|
|
- Accounting account = standCostDictMaps.getAccountingMap().get(accountingCode);
|
|
|
|
|
- if (account == null) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- DictDataVo costType = standCostDictMaps.getCostTypeMap().get(account.getCostType());
|
|
|
|
|
- HospitalVisitCostCompositionVO vo = costItemMap.get(account.getType());
|
|
|
|
|
- // 医疗成本
|
|
|
|
|
- if ("1".equals(costType.getExpandOne())) {
|
|
|
|
|
- vo.setMedicalCost(vo.getMedicalCost().add(allocationQuery.getAmount()));
|
|
|
|
|
- }
|
|
|
|
|
- // 医疗全成本
|
|
|
|
|
- if (!"3".equals(costType.getExpandOne())) {
|
|
|
|
|
- vo.setMedicalFullCost(vo.getMedicalFullCost().add(allocationQuery.getAmount()));
|
|
|
|
|
- }
|
|
|
|
|
- // 医院全成本
|
|
|
|
|
- vo.setHospitalFullCost(vo.getHospitalFullCost().add(allocationQuery.getAmount()));
|
|
|
|
|
- }
|
|
|
|
|
- //获取诊次床日分摊参数代码
|
|
|
|
|
- String[] visitsBedDaysParamCode = getVisitsBedDaysParamCode();
|
|
|
|
|
-
|
|
|
|
|
- // 诊次分摊参数值
|
|
|
|
|
- BigDecimal visitParamValue = getParamValue(shareParamValueList, visitsBedDaysParamCode[NumberConstant.ZERO]);
|
|
|
|
|
-// // 床日分摊参数值
|
|
|
|
|
-// BigDecimal bedDaysParamValue = getParamValue(shareParamValueList, visitsBedDaysParamCode[NumberConstant.ONE]);
|
|
|
|
|
-
|
|
|
|
|
- //处理总计和药品小计
|
|
|
|
|
- HospitalVisitCostCompositionVO totalVo = new HospitalVisitCostCompositionVO();
|
|
|
|
|
- totalVo.setCostItem("总计");
|
|
|
|
|
- HospitalVisitCostCompositionVO drugTotalVo = new HospitalVisitCostCompositionVO();
|
|
|
|
|
- totalVo.setCostItem("药品费");
|
|
|
|
|
- // 转成List便于处理
|
|
|
|
|
- List<HospitalVisitCostCompositionVO> reportList = costItemMap.values().stream().collect(Collectors.toList());
|
|
|
|
|
- for (HospitalVisitCostCompositionVO item : reportList) {
|
|
|
|
|
- //计算每诊次的医疗全成本
|
|
|
|
|
- item.setHospitalFullCost(getPercent(visitParamValue,totalVo.getHospitalFullCost()));
|
|
|
|
|
- //计算每诊次的医疗成本
|
|
|
|
|
- item.setMedicalCost(getPercent(visitParamValue,totalVo.getMedicalCost()));
|
|
|
|
|
- //计算每诊次的医院全成本
|
|
|
|
|
- item.setHospitalFullCost(getPercent(visitParamValue,totalVo.getMedicalFullCost()));
|
|
|
|
|
- // 将金额加到总计对象中
|
|
|
|
|
- addBigDecimalFields(item, totalVo);
|
|
|
|
|
- /// 将金额加到药品对象中
|
|
|
|
|
- if(NumberConstant.THREE_S.equals(item.getCostType())){
|
|
|
|
|
- addBigDecimalFields(item, drugTotalVo);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- //添加到列表的指定位置
|
|
|
|
|
- reportList.add(NumberConstant.TWO,drugTotalVo);
|
|
|
|
|
- reportList.add(NumberConstant.ZERO,totalVo);
|
|
|
|
|
- return reportList;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 添加医院科室成本分摊数据
|
|
* 添加医院科室成本分摊数据
|
|
|
* @param deptCostAllocationMap 科室成本分摊Map
|
|
* @param deptCostAllocationMap 科室成本分摊Map
|