Переглянути джерело

添加临床科室医疗成本表相关代码

JammeyJiang 3 місяців тому
батько
коміт
65ed2d7ac3

+ 31 - 1
src/main/java/com/kcim/common/util/BeanUtil.java

@@ -5,6 +5,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.util.CollectionUtils;
 
 import java.lang.reflect.Field;
+import java.math.BigDecimal;
 import java.util.*;
 
 @Slf4j
@@ -111,6 +112,35 @@ public final class BeanUtil {
         return target;
     }
 
+    /**
+     * 将对象中所有BigDecimal类型的字段设置为0
+     *
+     * @param target 目标对象
+     * @param <T>    对象类型
+     * @return 设置后的对象
+     */
+    public static <T> T initBigDecimalFieldsToZero(T target) {
+        if (target == null) {
+            return null;
+        }
+
+        Class<?> clazz = target.getClass();
+        for (; clazz != Object.class; clazz = clazz.getSuperclass()) {
+            Field[] fields = clazz.getDeclaredFields();
+            for (Field field : fields) {
+                if (field.getType().equals(BigDecimal.class)) {
+                    field.setAccessible(true);
+                    try {
+                        field.set(target, BigDecimal.ZERO);
+                    } catch (IllegalAccessException e) {
+                        log.error("设置BigDecimal字段默认值异常", e);
+                    }
+                }
+            }
+        }
+        return target;
+    }
+
     private static class CacheFieldMap {
         private static Map<String, Map<String, Field>> cacheMap = new HashMap<>();
 
@@ -147,4 +177,4 @@ public final class BeanUtil {
         BeanUtils.copyProperties(source, result);
         return result;
     }
-}
+}

+ 10 - 2
src/main/java/com/kcim/service/StandardReportService.java

@@ -1,6 +1,7 @@
 package com.kcim.service;
 
-import com.kcim.vo.DeptAllDirectCostVO;
+import com.kcim.vo.DeptFullDirectCostVO;
+import com.kcim.vo.ClinicalDeptMedicalCostVO;
 import com.kcim.vo.DeptDirectMedicalCostVO;
 
 import java.util.List;
@@ -17,5 +18,12 @@ public interface StandardReportService {
      * @param computeDate 核算年月
      * @return 报表数据
      */
-    List<DeptAllDirectCostVO> getDeptAllDirectCost(String computeDate);
+    List<DeptFullDirectCostVO> getDeptFullDirectCost(String computeDate);
+
+    /**
+     * 科室成本明细表
+     * @param computeDate 核算年月
+     * @return 报表数据
+     */
+    List<ClinicalDeptMedicalCostVO> getClinicalDeptMedicalCost(String computeDate);
 }

+ 228 - 168
src/main/java/com/kcim/service/impl/StandardReportServiceImpl.java

@@ -14,15 +14,13 @@ import com.kcim.dao.repository.ResponsibilityRepository;
 import com.kcim.service.AllocationQueryService;
 import com.kcim.service.CenterService;
 import com.kcim.service.StandardReportService;
-import com.kcim.vo.DeptAllDirectCostVO;
-import com.kcim.vo.DeptDirectMedicalCostVO;
-import com.kcim.vo.DictDataVo;
-import com.kcim.vo.StandCostDictMapVO;
+import com.kcim.vo.*;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -94,13 +92,13 @@ public class StandardReportServiceImpl implements StandardReportService {
             // 创建小计对象
             DeptDirectMedicalCostVO subtotalVo = createSubTotalVo(deptDirectMedicalCostVOS.get(NumberConstant.ZERO),String.format("%s小计", shareLevel.getName()));
             //将科室的金额加到小计对象中
-            deptDirectMedicalCostVOS.forEach(item -> addDeptDirectMedicalCost(item, subtotalVo));
+            deptDirectMedicalCostVOS.forEach(item -> addBigDecimalFields(item, subtotalVo));
             // 如果属于医疗业务成本的科室,则小计的金额加到医疗业务成本
             if(NumberConstant.ONE_S.equals(shareLevel.getValue())){
-                addDeptDirectMedicalCost(subtotalVo, medicalBusinessTotal);
+                addBigDecimalFields(subtotalVo, medicalBusinessTotal);
             }
             // 小计的金额加到总计
-            addDeptDirectMedicalCost(subtotalVo, grandTotal);
+            addBigDecimalFields(subtotalVo, grandTotal);
             // 添加小计行
             result.add(subtotalVo);
             // 医疗业务成本加入到医疗辅助类小计后面
@@ -119,7 +117,7 @@ public class StandardReportServiceImpl implements StandardReportService {
      * @return 报表数据
      */
     @Override
-    public List<DeptAllDirectCostVO> getDeptAllDirectCost(String computeDate) {
+    public List<DeptFullDirectCostVO> getDeptFullDirectCost(String computeDate) {
         DateTime parse = DateUtil.parse(computeDate);
         int year = DateUtil.year(parse);
         int month = DateUtil.month(parse) + 1;
@@ -132,43 +130,43 @@ public class StandardReportServiceImpl implements StandardReportService {
         // 获取所有的标准字典数据
         StandCostDictMapVO standCostDictMaps = getStandCostDictMaps();
         // 处理 allocationQueryList 数据
-        Map<String, DeptAllDirectCostVO> reportMap = new HashMap<>();
+        Map<String, DeptFullDirectCostVO> reportMap = new HashMap<>();
         // 转换为DeptDirectAllCostVO(一个责任中心只一条记录)
         for (AllocationQuery allocationQuery : allocationQueryList) {
             addDeptDirectAllCostVO(reportMap, allocationQuery, standCostDictMaps);
         }
         // 转成List便于处理
-        List<DeptAllDirectCostVO> reportList = reportMap.values().stream().collect(Collectors.toList());
+        List<DeptFullDirectCostVO> reportList = reportMap.values().stream().collect(Collectors.toList());
         // 按responsibilitySort正序排序
-        reportList.sort(Comparator.comparing(DeptAllDirectCostVO::getResponsibilitySort, Comparator.nullsLast(Comparator.naturalOrder())));
+        reportList.sort(Comparator.comparing(DeptFullDirectCostVO::getResponsibilitySort, Comparator.nullsLast(Comparator.naturalOrder())));
         // 按标准分级分组
-        Map<String, List<DeptAllDirectCostVO>> shareLevelGroup = reportList.stream().collect(Collectors.groupingBy(DeptAllDirectCostVO::getStandardShareLevel));
+        Map<String, List<DeptFullDirectCostVO>> shareLevelGroup = reportList.stream().collect(Collectors.groupingBy(DeptFullDirectCostVO::getStandardShareLevel));
         // 科室标准分级按顺序号倒序排序
         List<DictDataVo> standardShareLevelList = standCostDictMaps.getStandardShareLevelDict();
         standardShareLevelList.sort(Comparator.comparing(DictDataVo::getSort, Comparator.nullsLast(Comparator.reverseOrder())));
         //创建医疗业务成本合计
-        DeptAllDirectCostVO medicalBusinessTotal = createAllDirectCostSubTotalVo(reportList.get(NumberConstant.ZERO), "医疗业务成本合计");
+        DeptFullDirectCostVO medicalBusinessTotal = createAllDirectCostSubTotalVo(reportList.get(NumberConstant.ZERO), "医疗业务成本合计");
         //创建总计
-        DeptAllDirectCostVO grandTotal = createAllDirectCostSubTotalVo(reportList.get(NumberConstant.ZERO), "总计");
+        DeptFullDirectCostVO grandTotal = createAllDirectCostSubTotalVo(reportList.get(NumberConstant.ZERO), "总计");
         // 创建各层级小计并按正确顺序插入
-        List<DeptAllDirectCostVO> result = new ArrayList<>();
+        List<DeptFullDirectCostVO> result = new ArrayList<>();
         for (DictDataVo shareLevel : standardShareLevelList) {
-            List<DeptAllDirectCostVO> reportVOS = shareLevelGroup.get(shareLevel.getCode());
+            List<DeptFullDirectCostVO> reportVOS = shareLevelGroup.get(shareLevel.getCode());
             if (CollectionUtils.isEmpty(reportVOS)) {
                 continue;
             }
             // 添加该分类下的所有记录
             result.addAll(reportVOS);
             // 创建小计对象
-            DeptAllDirectCostVO subtotalVo = createAllDirectCostSubTotalVo(reportVOS.get(NumberConstant.ZERO),String.format("%s小计", shareLevel.getName()));
+            DeptFullDirectCostVO subtotalVo = createAllDirectCostSubTotalVo(reportVOS.get(NumberConstant.ZERO),String.format("%s小计", shareLevel.getName()));
             //将科室的金额加到小计对象中
-            reportVOS.forEach(item -> addDeptAllDirectCost(item, subtotalVo));
+            reportVOS.forEach(item -> addBigDecimalFields(item, subtotalVo));
             // 如果属于医疗业务成本的科室,则小计的金额加到医疗业务成本
             if(NumberConstant.ONE_S.equals(shareLevel.getValue())){
-                addDeptAllDirectCost(subtotalVo, medicalBusinessTotal);
+                addBigDecimalFields(subtotalVo, medicalBusinessTotal);
             }
             // 小计的金额加到总计
-            addDeptAllDirectCost(subtotalVo, grandTotal);
+            addBigDecimalFields(subtotalVo, grandTotal);
             // 添加小计行
             result.add(subtotalVo);
             // 医疗业务成本加入到医疗辅助类小计后面
@@ -181,6 +179,162 @@ public class StandardReportServiceImpl implements StandardReportService {
         return result;
     }
 
+    /**
+     * 获取科室成本明细数据
+     * @param computeDate 核算年月
+     * @return
+     */
+    @Override
+    public List<ClinicalDeptMedicalCostVO> getClinicalDeptMedicalCost(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)) {
+            return new ArrayList<>();
+        }
+        // 获取所有的标准字典数据
+        StandCostDictMapVO standCostDictMaps = getStandCostDictMaps();
+        // 处理 allocationQueryList 数据
+        Map<String, ClinicalDeptMedicalCostVO> reportMap = new HashMap<>();
+        // 添加科室成本明细(一个责任中心只一条记录)
+        for (AllocationQuery allocationQuery : allocationQueryList) {
+            addDeptCostDetailVO(reportMap, allocationQuery, standCostDictMaps);
+        }
+        return null;
+    }
+
+    /**
+     * 添加科室成本明细
+     * @param reportMap 
+     * @param allocationQuery
+     * @param standCostDictMaps
+     */
+    private void addDeptCostDetailVO(Map<String, ClinicalDeptMedicalCostVO> reportMap, AllocationQuery allocationQuery, StandCostDictMapVO standCostDictMaps) {
+        String responsibilityCode = allocationQuery.getResponsibilityCode();
+        Responsibility responsibility = standCostDictMaps.getResponsibilityMap().get(responsibilityCode);
+        if (responsibility == null) {
+            return; // 添加 null 检查
+        }
+
+        String accountingCode = allocationQuery.getAccountingCode();
+        Accounting account = standCostDictMaps.getAccountingMap().get(accountingCode);
+        if (account == null) {
+            return; // 添加 null 检查
+        }
+
+        DictDataVo accountType = standCostDictMaps.getAccountingTypeMap().get(account.getType());
+        if (accountType == null) {
+            return; // 添加 null 检查
+        }
+        DictDataVo costType = standCostDictMaps.getCostTypeMap().get(account.getCostType());
+        DictDataVo standardShareLevel = standCostDictMaps.getStandardShareLevelMap().get(responsibility.getStandardShareLevel());
+
+        ClinicalDeptMedicalCostVO reportVO = new ClinicalDeptMedicalCostVO();
+        if (reportMap.containsKey(allocationQuery.getResponsibilityCode())) {
+            reportVO = reportMap.get(allocationQuery.getResponsibilityCode());
+        } else {
+            //生成科室成本报表信息
+            initDeptCostReport(reportVO, responsibility, accountType, costType, standardShareLevel);
+            // 初始化所有费用字段为0
+            BeanUtil.initBigDecimalFieldsToZero(reportVO);
+        }
+
+        // 根据费用类型累加到对应字段
+        switch (accountType.getExpandOne())  {
+            case "1":
+                if(NumberConstant.ONE.equals(allocationQuery.getOriginType().intValue())){
+                    reportVO.setPersonnelDirectCost(reportVO.getPersonnelDirectCost().add(allocationQuery.getAmount()));
+                }else{
+                    reportVO.setPersonnelIndirectCost(reportVO.getPersonnelIndirectCost().add(allocationQuery.getAmount()));
+                }
+                reportVO.setPersonnelTotalCost(reportVO.getPersonnelTotalCost().add(allocationQuery.getAmount()));
+                break;
+            case "2":
+                if(NumberConstant.ONE.equals(allocationQuery.getOriginType().intValue())){
+                    reportVO.setHealthMaterialDirectCost(reportVO.getHealthMaterialDirectCost().add(allocationQuery.getAmount()));
+                }else{
+                    reportVO.setHealthMaterialIndirectCost(reportVO.getHealthMaterialIndirectCost().add(allocationQuery.getAmount()));
+                }
+                reportVO.setHealthMaterialTotalCost(reportVO.getHealthMaterialTotalCost().add(allocationQuery.getAmount()));
+                break;
+            case "3":
+                if(NumberConstant.ONE.equals(allocationQuery.getOriginType().intValue())){
+                    reportVO.setMedicineDirectCost(reportVO.getMedicineDirectCost().add(allocationQuery.getAmount()));
+                }else{
+                    reportVO.setMedicineIndirectCost(reportVO.getMedicineIndirectCost().add(allocationQuery.getAmount()));
+                }
+                reportVO.setMedicineTotalCost(reportVO.getMedicineTotalCost().add(allocationQuery.getAmount()));
+                break;
+            case "4":
+                if(NumberConstant.ONE.equals(allocationQuery.getOriginType().intValue())){
+                    reportVO.setFixedAssetDepreciationDirectCost(reportVO.getFixedAssetDepreciationDirectCost().add(allocationQuery.getAmount()));
+                }else{
+                    reportVO.setFixedAssetDepreciationIndirectCost(reportVO.getFixedAssetDepreciationIndirectCost().add(allocationQuery.getAmount()));
+                }
+                reportVO.setFixedAssetDepreciationTotalCost(reportVO.getFixedAssetDepreciationTotalCost().add(allocationQuery.getAmount()));
+                break;
+            case "5":
+                if(NumberConstant.ONE.equals(allocationQuery.getOriginType().intValue())){
+                    reportVO.setIntangibleAssetAmortizationDirectCost(reportVO.getIntangibleAssetAmortizationDirectCost().add(allocationQuery.getAmount()));
+                }else{
+                    reportVO.setIntangibleAssetAmortizationIndirectCost(reportVO.getIntangibleAssetAmortizationIndirectCost().add(allocationQuery.getAmount()));
+                }
+                reportVO.setIntangibleAssetAmortizationTotalCost(reportVO.getIntangibleAssetAmortizationTotalCost().add(allocationQuery.getAmount()));
+                break;
+            case "6":
+                if(NumberConstant.ONE.equals(allocationQuery.getOriginType().intValue())){
+                    reportVO.setMedicalRiskReserveDirectCost(reportVO.getMedicalRiskReserveDirectCost().add(allocationQuery.getAmount()));
+                }else{
+                    reportVO.setMedicalRiskReserveIndirectCost(reportVO.getMedicalRiskReserveIndirectCost().add(allocationQuery.getAmount()));
+                }
+                reportVO.setMedicalRiskReserveTotalCost(reportVO.getMedicalRiskReserveTotalCost().add(allocationQuery.getAmount()));
+                break;
+            case "7":
+                if(NumberConstant.ONE.equals(allocationQuery.getOriginType().intValue())){
+                    reportVO.setOtherMedicalExpensesDirectCost(reportVO.getOtherMedicalExpensesDirectCost().add(allocationQuery.getAmount()));
+                }else{
+                    reportVO.setOtherMedicalExpensesIndirectCost(reportVO.getOtherMedicalExpensesIndirectCost().add(allocationQuery.getAmount()));
+                }
+                reportVO.setOtherMedicalExpensesTotalCost(reportVO.getOtherMedicalExpensesTotalCost().add(allocationQuery.getAmount()));
+                break;
+            default:
+                break;
+        }
+        //添加合计
+        if(NumberConstant.ONE.equals(allocationQuery.getOriginType().intValue())){
+            reportVO.setTotalDirectCost(reportVO.getTotalDirectCost().add(allocationQuery.getAmount()));
+        }else{
+            reportVO.setTotalIndirectCost(reportVO.getTotalIndirectCost().add(allocationQuery.getAmount()));
+        }
+        reportVO.setTotalCost(reportVO.getTotalCost().add(allocationQuery.getAmount()));
+    }
+
+    /**
+     * 生成科室成本报表信息
+     * @param reportVO
+     * @param responsibility
+     * @param accountType
+     * @param costType
+     * @param standardShareLevel
+     */
+    private void initDeptCostReport(BaseDeptCostReportVO reportVO,
+                                    Responsibility responsibility,
+                                    DictDataVo accountType,
+                                    DictDataVo costType,
+                                    DictDataVo standardShareLevel) {
+        reportVO.setStandardShareLevel(responsibility.getStandardShareLevel());
+        reportVO.setResponsibilityName(responsibility.getResponsibilityName());
+        reportVO.setResponsibilityCode(responsibility.getResponsibilityCode());
+        reportVO.setResponsibilitySort(responsibility.getSort());
+        reportVO.setCostType(costType.getCode());
+        reportVO.setStandCostType(costType.getExpandOne());
+        reportVO.setAccountType(accountType.getCode());
+        reportVO.setStandAccountType(accountType.getExpandOne());
+        reportVO.setShareLevelSort(standardShareLevel.getSort());
+    }
+
     /**
      * 获取所有的标准字典数据并转换所有需要的映射数据
      * @return 包含所有映射数据的DTO对象
@@ -201,16 +355,16 @@ public class StandardReportServiceImpl implements StandardReportService {
             allCostAccounting = new ArrayList<>();
         }
 
-        // 创建一个映射,用于快速查找责任中心的科室类型
+        // 创建一个映射,用于快速查找责任中心的科室类型,过滤掉 null 对象,过滤掉 responsibilityCode 为 null 的对象
         Map<String, Responsibility> responsibilityMap = responsibilityList.stream()
-                .filter(Objects::nonNull) // 过滤掉 null 对象
-                .filter(r -> r.getResponsibilityCode() != null) // 过滤掉 responsibilityCode 为 null 的对象
+                .filter(Objects::nonNull)
+                .filter(r -> r.getResponsibilityCode() != null)
                 .collect(Collectors.toMap(Responsibility::getResponsibilityCode, o -> o));
 
-        // 创建一个映射,用于快速查找会计科目的类型
+        // 创建一个映射,用于快速查找会计科目的类型,过滤掉 null 对象,过滤掉 accountingCode 为 null 的对象
         Map<String, Accounting> accountingMap = allCostAccounting.stream()
-                .filter(Objects::nonNull) // 过滤掉 null 对象
-                .filter(a -> a.getAccountingCode() != null) // 过滤掉 accountingCode 为 null 的对象
+                .filter(Objects::nonNull)
+                .filter(a -> a.getAccountingCode() != null)
                 .collect(Collectors.toMap(Accounting::getAccountingCode, o -> o));
 
         // 添加 null 检查并创建映射
@@ -223,22 +377,22 @@ public class StandardReportServiceImpl implements StandardReportService {
         List<DictDataVo> standardShareLevelDictList = (standardShareLevelDict != null && standardShareLevelDict.getDataVoList() != null)
                 ? standardShareLevelDict.getDataVoList() : new ArrayList<>();
 
-        // 创建一个映射,用于快速查找会计科目类型的扩展字段
+        // 创建一个映射,用于快速查找会计科目类型的扩展字段,过滤掉 null 对象,过滤掉 code 为 null 的对象
         Map<String, DictDataVo> accountingTypeMap = accountingTypeDictList.stream()
-                .filter(Objects::nonNull) // 过滤掉 null 对象
-                .filter(d -> d.getCode() != null) // 过滤掉 code 为 null 的对象
+                .filter(Objects::nonNull)
+                .filter(d -> d.getCode() != null)
                 .collect(Collectors.toMap(DictDataVo::getCode, o -> o));
 
-        // 创建一个映射,用于快速查找会计科目类型的扩展字段
+        // 创建一个映射,用于快速查找会计科目类型的扩展字段,过滤掉 null 对象,过滤掉 code 为 null 的对象
         Map<String, DictDataVo> costTypeMap = costTypeDictList.stream()
-                .filter(Objects::nonNull) // 过滤掉 null 对象
-                .filter(d -> d.getCode() != null) // 过滤掉 code 为 null 的对象
+                .filter(Objects::nonNull)
+                .filter(d -> d.getCode() != null)
                 .collect(Collectors.toMap(DictDataVo::getCode, o -> o));
 
-        // 创建一个映射,用于快速查找会计科目类型的扩展字段
+        // 创建一个映射,用于快速查找会计科目类型的扩展字段,过滤掉 null 对象,过滤掉 code 为 null 的对象
         Map<String, DictDataVo> standardShareLevelMap = standardShareLevelDictList.stream()
-                .filter(Objects::nonNull) // 过滤掉 null 对象
-                .filter(d -> d.getCode() != null) // 过滤掉 code 为 null 的对象
+                .filter(Objects::nonNull)
+                .filter(d -> d.getCode() != null)
                 .collect(Collectors.toMap(DictDataVo::getCode, o -> o));
 
         dataMaps.setResponsibilityDict(responsibilityList);
@@ -253,49 +407,7 @@ public class StandardReportServiceImpl implements StandardReportService {
         dataMaps.setAccountingTypeMap(accountingTypeMap);
         return dataMaps;
     }
-
-    /**
-     * 累计两个科室的金额,将sourceDept的金额加到targetDept中
-     * @param sourceDept
-     * @param targetDept
-     */
-    public void addDeptDirectMedicalCost(DeptDirectMedicalCostVO sourceDept, DeptDirectMedicalCostVO targetDept){
-        if (sourceDept == null || targetDept == null) {
-            return;
-        }
-
-        targetDept.setPersonnelExpense(
-                (targetDept.getPersonnelExpense() == null ? BigDecimal.ZERO : targetDept.getPersonnelExpense())
-                        .add(sourceDept.getPersonnelExpense() == null ? BigDecimal.ZERO : sourceDept.getPersonnelExpense()));
-
-        targetDept.setHealthMaterialFee(
-                (targetDept.getHealthMaterialFee() == null ? BigDecimal.ZERO : targetDept.getHealthMaterialFee())
-                        .add(sourceDept.getHealthMaterialFee() == null ? BigDecimal.ZERO : sourceDept.getHealthMaterialFee()));
-
-        targetDept.setDrugFee(
-                (targetDept.getDrugFee() == null ? BigDecimal.ZERO : targetDept.getDrugFee())
-                        .add(sourceDept.getDrugFee() == null ? BigDecimal.ZERO : sourceDept.getDrugFee()));
-
-        targetDept.setFixedAssetDepreciation(
-                (targetDept.getFixedAssetDepreciation() == null ? BigDecimal.ZERO : targetDept.getFixedAssetDepreciation())
-                        .add(sourceDept.getFixedAssetDepreciation() == null ? BigDecimal.ZERO : sourceDept.getFixedAssetDepreciation()));
-
-        targetDept.setIntangibleAssetAmortization(
-                (targetDept.getIntangibleAssetAmortization() == null ? BigDecimal.ZERO : targetDept.getIntangibleAssetAmortization())
-                        .add(sourceDept.getIntangibleAssetAmortization() == null ? BigDecimal.ZERO : sourceDept.getIntangibleAssetAmortization()));
-
-        targetDept.setMedicalRiskFundExtraction(
-                (targetDept.getMedicalRiskFundExtraction() == null ? BigDecimal.ZERO : targetDept.getMedicalRiskFundExtraction())
-                        .add(sourceDept.getMedicalRiskFundExtraction() == null ? BigDecimal.ZERO : sourceDept.getMedicalRiskFundExtraction()));
-
-        targetDept.setOtherMedicalExpenses(
-                (targetDept.getOtherMedicalExpenses() == null ? BigDecimal.ZERO : targetDept.getOtherMedicalExpenses())
-                        .add(sourceDept.getOtherMedicalExpenses() == null ? BigDecimal.ZERO : sourceDept.getOtherMedicalExpenses()));
-
-        targetDept.setTotal(
-                (targetDept.getTotal() == null ? BigDecimal.ZERO : targetDept.getTotal())
-                        .add(sourceDept.getTotal() == null ? BigDecimal.ZERO : sourceDept.getTotal()));
-    }
+   
 
     /**
      * 创建小计对象
@@ -311,7 +423,7 @@ public class StandardReportServiceImpl implements StandardReportService {
         deptDirectMedicalCostVO.setResponsibilityCode(totalName);
         deptDirectMedicalCostVO.setResponsibilityName(totalName);
         // 初始化所有费用字段为0
-        initDeptDirectMedicalCostAmount(deptDirectMedicalCostVO);
+        BeanUtil.initBigDecimalFieldsToZero(deptDirectMedicalCostVO);
         return deptDirectMedicalCostVO;
     }
 
@@ -348,17 +460,9 @@ public class StandardReportServiceImpl implements StandardReportService {
         if(deptDirectMedicalCostMap.containsKey(allocationQuery.getResponsibilityCode())){
             deptDirectMedicalCostVO=deptDirectMedicalCostMap.get(allocationQuery.getResponsibilityCode());
         }else{
-            deptDirectMedicalCostVO.setStandardShareLevel(responsibility.getStandardShareLevel());
-            deptDirectMedicalCostVO.setResponsibilityName(responsibility.getResponsibilityName());
-            deptDirectMedicalCostVO.setResponsibilityCode(responsibility.getResponsibilityCode());
-            deptDirectMedicalCostVO.setResponsibilitySort(responsibility.getSort());
-            deptDirectMedicalCostVO.setCostType(costType.getCode());
-            deptDirectMedicalCostVO.setStandCostType(costType.getExpandOne());
-            deptDirectMedicalCostVO.setAccountType(accountType.getCode());
-            deptDirectMedicalCostVO.setStandAccountType(accountType.getExpandOne());
-            deptDirectMedicalCostVO.setShareLevelSort(standardShareLevel.getSort());
+            initDeptCostReport(deptDirectMedicalCostVO, responsibility,accountType, costType,standardShareLevel);
             // 初始化所有费用字段为0
-            initDeptDirectMedicalCostAmount(deptDirectMedicalCostVO);
+            BeanUtil.initBigDecimalFieldsToZero(deptDirectMedicalCostVO);
         }
         // 根据费用类型累加到对应字段
         switch (accountType.getExpandOne()) {
@@ -390,21 +494,7 @@ public class StandardReportServiceImpl implements StandardReportService {
         deptDirectMedicalCostVO.setTotal(deptDirectMedicalCostVO.getTotal().add(allocationQuery.getAmount()));
     }
 
-    /**
-     * 初始化直接成本的金额
-     * @param deptDirectMedicalCostVO
-     */
-    public void initDeptDirectMedicalCostAmount(DeptDirectMedicalCostVO deptDirectMedicalCostVO){
-        // 初始化所有费用字段为0
-        deptDirectMedicalCostVO.setPersonnelExpense(BigDecimal.ZERO);
-        deptDirectMedicalCostVO.setHealthMaterialFee(BigDecimal.ZERO);
-        deptDirectMedicalCostVO.setDrugFee(BigDecimal.ZERO);
-        deptDirectMedicalCostVO.setFixedAssetDepreciation(BigDecimal.ZERO);
-        deptDirectMedicalCostVO.setIntangibleAssetAmortization(BigDecimal.ZERO);
-        deptDirectMedicalCostVO.setMedicalRiskFundExtraction(BigDecimal.ZERO);
-        deptDirectMedicalCostVO.setOtherMedicalExpenses(BigDecimal.ZERO);
-        deptDirectMedicalCostVO.setTotal(BigDecimal.ZERO);
-    }
+
 
     /**
      * 转换为DeptDirectAllCostVO(一个责任中心只一条记录)
@@ -412,7 +502,7 @@ public class StandardReportServiceImpl implements StandardReportService {
      * @param allocationQuery
      * @param standCostDictMaps
      */
-    private void addDeptDirectAllCostVO(Map<String, DeptAllDirectCostVO> reportMap, AllocationQuery allocationQuery, StandCostDictMapVO standCostDictMaps) {
+    private void addDeptDirectAllCostVO(Map<String, DeptFullDirectCostVO> reportMap, AllocationQuery allocationQuery, StandCostDictMapVO standCostDictMaps) {
         String responsibilityCode = allocationQuery.getResponsibilityCode();
         Responsibility responsibility = standCostDictMaps.getResponsibilityMap().get(responsibilityCode);
         if (responsibility == null) {
@@ -432,21 +522,13 @@ public class StandardReportServiceImpl implements StandardReportService {
         DictDataVo costType = standCostDictMaps.getCostTypeMap().get(account.getCostType());
         DictDataVo standardShareLevel = standCostDictMaps.getStandardShareLevelMap().get(responsibility.getStandardShareLevel());
 
-        DeptAllDirectCostVO reportVO = new DeptAllDirectCostVO();
+        DeptFullDirectCostVO reportVO = new DeptFullDirectCostVO();
         if (reportMap.containsKey(allocationQuery.getResponsibilityCode())) {
             reportVO = reportMap.get(allocationQuery.getResponsibilityCode());
         } else {
-            reportVO.setStandardShareLevel(responsibility.getStandardShareLevel());
-            reportVO.setResponsibilityName(responsibility.getResponsibilityName());
-            reportVO.setResponsibilityCode(responsibility.getResponsibilityCode());
-            reportVO.setResponsibilitySort(responsibility.getSort());
-            reportVO.setCostType(costType.getCode());
-            reportVO.setStandCostType(costType.getExpandOne());
-            reportVO.setAccountType(accountType.getCode());
-            reportVO.setStandAccountType(accountType.getExpandOne());
-            reportVO.setShareLevelSort(standardShareLevel.getSort());
+            initDeptCostReport(reportVO, responsibility,accountType, costType,standardShareLevel);
             // 初始化所有费用字段为0
-            initAllDirectCostAmount(reportVO);
+            BeanUtil.initBigDecimalFieldsToZero(reportVO);
         }
 
         // 根据费用类型累加到对应字段
@@ -484,71 +566,49 @@ public class StandardReportServiceImpl implements StandardReportService {
      * @param totalName
      * @return
      */
-    public DeptAllDirectCostVO createAllDirectCostSubTotalVo(DeptAllDirectCostVO directMedicalCostVO, String totalName ){
+    public DeptFullDirectCostVO createAllDirectCostSubTotalVo(DeptFullDirectCostVO directMedicalCostVO, String totalName ){
         if (directMedicalCostVO == null) {
             return null;
         }
-        DeptAllDirectCostVO deptDirectMedicalCostVO = BeanUtil.convertObj(directMedicalCostVO, DeptAllDirectCostVO.class);
+        DeptFullDirectCostVO deptDirectMedicalCostVO = BeanUtil.convertObj(directMedicalCostVO, DeptFullDirectCostVO.class);
         deptDirectMedicalCostVO.setResponsibilityCode(totalName);
         deptDirectMedicalCostVO.setResponsibilityName(totalName);
         // 初始化所有费用字段为0
-        initAllDirectCostAmount(deptDirectMedicalCostVO);
+        BeanUtil.initBigDecimalFieldsToZero(deptDirectMedicalCostVO);
         return deptDirectMedicalCostVO;
-    }
-
-    /**
-     * 初始化ScreenshotReport的金额
-     * @param reportVO
-     */
-    private void initAllDirectCostAmount(DeptAllDirectCostVO reportVO) {
-        // 初始化所有费用字段为0
-        reportVO.setMedicalCostTotal(BigDecimal.ZERO);
-        reportVO.setFinancialProjectFunds(BigDecimal.ZERO);
-        reportVO.setNonPeerFinancialFunds(BigDecimal.ZERO);
-        reportVO.setEducationalExpenses(BigDecimal.ZERO);
-        reportVO.setAssetDisposalFees(BigDecimal.ZERO);
-        reportVO.setMedicalTotalCost(BigDecimal.ZERO);
-        reportVO.setHospitalTotalCost(BigDecimal.ZERO);
-    }
+    }    
+    
 
     /**
-     * 合并两个科室直接成本(全成本)
-     * @param sourceDept
-     * @param targetDept
+     * 合并两个科室成本
+     * @param source 源对象
+     * @param target 目标对象
      */
-    public void addDeptAllDirectCost(DeptAllDirectCostVO sourceDept, DeptAllDirectCostVO targetDept) {
-        if (sourceDept == null || targetDept == null) {
+    public <T> void addBigDecimalFields(T source, T target) {
+        if (source == null || target == null) {
             return;
         }
-
-        targetDept.setMedicalCostTotal(
-                (targetDept.getMedicalCostTotal() == null ? BigDecimal.ZERO : targetDept.getMedicalCostTotal())
-                        .add(sourceDept.getMedicalCostTotal() == null ? BigDecimal.ZERO : sourceDept.getMedicalCostTotal()));
-
-        targetDept.setFinancialProjectFunds(
-                (targetDept.getFinancialProjectFunds() == null ? BigDecimal.ZERO : targetDept.getFinancialProjectFunds())
-                        .add(sourceDept.getFinancialProjectFunds() == null ? BigDecimal.ZERO : sourceDept.getFinancialProjectFunds()));
-
-        targetDept.setNonPeerFinancialFunds(
-                (targetDept.getNonPeerFinancialFunds() == null ? BigDecimal.ZERO : targetDept.getNonPeerFinancialFunds())
-                        .add(sourceDept.getNonPeerFinancialFunds() == null ? BigDecimal.ZERO : sourceDept.getNonPeerFinancialFunds()));
-
-        targetDept.setMedicalTotalCost(
-                (targetDept.getMedicalTotalCost() == null ? BigDecimal.ZERO : targetDept.getMedicalTotalCost())
-                        .add(sourceDept.getMedicalTotalCost() == null ? BigDecimal.ZERO : sourceDept.getMedicalTotalCost()));
-
-        targetDept.setEducationalExpenses(
-                (targetDept.getEducationalExpenses() == null ? BigDecimal.ZERO : targetDept.getEducationalExpenses())
-                        .add(sourceDept.getEducationalExpenses() == null ? BigDecimal.ZERO : sourceDept.getEducationalExpenses()));
-
-        targetDept.setAssetDisposalFees(
-                (targetDept.getAssetDisposalFees() == null ? BigDecimal.ZERO : targetDept.getAssetDisposalFees())
-                        .add(sourceDept.getAssetDisposalFees() == null ? BigDecimal.ZERO : sourceDept.getAssetDisposalFees()));
-
-        targetDept.setHospitalTotalCost(
-                (targetDept.getHospitalTotalCost() == null ? BigDecimal.ZERO : targetDept.getHospitalTotalCost())
-                        .add(sourceDept.getHospitalTotalCost() == null ? BigDecimal.ZERO : sourceDept.getHospitalTotalCost()));
+        Class<?> clazz = target.getClass();
+        Field[] fields = clazz.getDeclaredFields();
+
+        for (Field field : fields) {
+            if (field.getType().equals(BigDecimal.class)) {
+                field.setAccessible(true);
+                try {
+                    BigDecimal sourceValue = (BigDecimal) field.get(source);
+                    BigDecimal targetValue = (BigDecimal) field.get(target);
+
+                    BigDecimal result = (targetValue == null ? BigDecimal.ZERO : targetValue)
+                            .add(sourceValue == null ? BigDecimal.ZERO : sourceValue);
+
+                    field.set(target, result);
+                } catch (IllegalAccessException e) {
+                    log.error("合并科室成本时发生错误", e);
+                }
+            }
+        }
     }
 
 
+
 }

+ 60 - 0
src/main/java/com/kcim/vo/BaseDeptCostReportVO.java

@@ -0,0 +1,60 @@
+package com.kcim.vo;
+
+import lombok.Data;
+
+/**
+ * 科室成本明细视图对象
+ */
+@Data
+public class BaseDeptCostReportVO {
+    /**
+     * 科室标准分级
+     */
+    private String standardShareLevel;
+
+    /**
+     * 科室名称
+     */
+    private String responsibilityName;
+
+    /**
+     * 科室代码
+     */
+    private String responsibilityCode;
+
+    /**
+     * 科室排序
+     */
+    private Integer responsibilitySort;
+
+    /**
+     * 成本类型代码
+     */
+    private String costType;
+
+    /**
+     * 标准成本类型
+     */
+    private String standCostType;
+
+    /**
+     * 会计类型代码
+     */
+    private String accountType;
+
+    /**
+     * 标准会计类型
+     */
+    private String standAccountType;
+
+    /**
+     * 标准分级排序
+     */
+    private Integer shareLevelSort;
+
+    /**
+     * 来源类型:1.分摊前,2.分摊后
+     */
+    private Long originType;
+
+}

+ 133 - 0
src/main/java/com/kcim/vo/ClinicalDeptMedicalCostVO.java

@@ -0,0 +1,133 @@
+package com.kcim.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 科室成本明细视图对象
+ */
+@Data
+public class ClinicalDeptMedicalCostVO extends BaseDeptCostReportVO{
+
+    /**
+     * 人员经费(直接成本)
+     */
+    private BigDecimal personnelDirectCost;
+
+    /**
+     * 人员经费(间接成本)
+     */
+    private BigDecimal personnelIndirectCost;
+
+    /**
+     * 人员经费(全成本)
+     */
+    private BigDecimal personnelTotalCost;
+
+    /**
+     * 卫生材料费(直接成本)
+     */
+    private BigDecimal healthMaterialDirectCost;
+
+    /**
+     * 卫生材料费(间接成本)
+     */
+    private BigDecimal healthMaterialIndirectCost;
+
+    /**
+     * 卫生材料费(全成本)
+     */
+    private BigDecimal healthMaterialTotalCost;
+
+    /**
+     * 药品费(直接成本)
+     */
+    private BigDecimal medicineDirectCost;
+
+    /**
+     * 药品费(间接成本)
+     */
+    private BigDecimal medicineIndirectCost;
+
+    /**
+     * 药品费(全成本)
+     */
+    private BigDecimal medicineTotalCost;
+
+    /**
+     * 固定资产折旧费(直接成本)
+     */
+    private BigDecimal fixedAssetDepreciationDirectCost;
+
+    /**
+     * 固定资产折旧费(间接成本)
+     */
+    private BigDecimal fixedAssetDepreciationIndirectCost;
+
+    /**
+     * 固定资产折旧费(全成本)
+     */
+    private BigDecimal fixedAssetDepreciationTotalCost;
+
+    /**
+     * 无形资产摊销费(直接成本)
+     */
+    private BigDecimal intangibleAssetAmortizationDirectCost;
+
+    /**
+     * 无形资产摊销费(间接成本)
+     */
+    private BigDecimal intangibleAssetAmortizationIndirectCost;
+
+    /**
+     * 无形资产摊销费(全成本)
+     */
+    private BigDecimal intangibleAssetAmortizationTotalCost;
+
+    /**
+     * 提取医疗风险基金(直接成本)
+     */
+    private BigDecimal medicalRiskReserveDirectCost;
+
+    /**
+     * 提取医疗风险基金(间接成本)
+     */
+    private BigDecimal medicalRiskReserveIndirectCost;
+
+    /**
+     * 提取医疗风险基金(全成本)
+     */
+    private BigDecimal medicalRiskReserveTotalCost;
+
+    /**
+     * 其他医疗费用(直接成本)
+     */
+    private BigDecimal otherMedicalExpensesDirectCost;
+
+    /**
+     * 其他医疗费用(间接成本)
+     */
+    private BigDecimal otherMedicalExpensesIndirectCost;
+
+    /**
+     * 其他医疗费用(全成本)
+     */
+    private BigDecimal otherMedicalExpensesTotalCost;
+
+    /**
+     * 合计(直接成本)
+     */
+    private BigDecimal totalDirectCost;
+
+    /**
+     * 合计(间接成本)
+     */
+    private BigDecimal totalIndirectCost;
+
+    /**
+     * 合计(全成本)
+     */
+    private BigDecimal totalCost;
+
+}

+ 2 - 42
src/main/java/com/kcim/vo/DeptDirectMedicalCostVO.java

@@ -9,19 +9,8 @@ import java.math.BigDecimal;
  * @author Administrator
  */
 @Data
-public class DeptDirectMedicalCostVO {
-    /**
-     * 科室标准分级
-     */
-    private String standardShareLevel;
-    /**
-     * 科室代码
-     */
-    private String responsibilityCode;
-    /**
-     * 科室名称
-     */
-    private String responsibilityName;
+public class DeptDirectMedicalCostVO extends BaseDeptCostReportVO{
+
     /**
      * 人员经费
      */
@@ -62,33 +51,4 @@ public class DeptDirectMedicalCostVO {
      */
     private BigDecimal total;
 
-    /**
-     * 标准会计科目类别(来自会计科目字典)
-     */
-    private String standAccountType;
-
-    /**
-     * 会计科目类别(来自会计科目字典)
-     */
-    private String accountType;
-
-    /**
-     * 成本类别(来自成本类别字典)
-     */
-    private String costType;
-
-    /**
-     * 标准成本类别(来自成本类别字典)
-     */
-    private String standCostType;
-
-    /**
-     * 责任中心序号
-     */
-    private int responsibilitySort;
-
-    /**
-     * 标准分级序号
-     */
-    private int shareLevelSort;
 }

+ 1 - 46
src/main/java/com/kcim/vo/DeptAllDirectCostVO.java → src/main/java/com/kcim/vo/DeptFullDirectCostVO.java

@@ -8,52 +8,7 @@ import java.math.BigDecimal;
  * 截图报表数据封装类
  */
 @Data
-public class DeptAllDirectCostVO {
-
-    /**
-     * 科室标准分级
-     */
-    private String standardShareLevel;
-
-    /**
-     * 科室名称
-     */
-    private String responsibilityName;
-
-    /**
-     * 科室代码
-     */
-    private String responsibilityCode;
-
-    /**
-     * 科室排序
-     */
-    private Integer responsibilitySort;
-
-    /**
-     * 成本类型代码
-     */
-    private String costType;
-
-    /**
-     * 标准成本类型
-     */
-    private String standCostType;
-
-    /**
-     * 会计类型代码
-     */
-    private String accountType;
-
-    /**
-     * 标准会计类型
-     */
-    private String standAccountType;
-
-    /**
-     * 标准分级排序
-     */
-    private Integer shareLevelSort;
+public class DeptFullDirectCostVO extends BaseDeptCostReportVO {
 
     /**
      * 医疗成本合计

+ 12 - 4
src/main/java/com/kcim/web/StandardReportController.java

@@ -29,10 +29,18 @@ public class StandardReportController extends AbstractController {
         return Result.ok(standardReportService.getDeptDirectMedicalCost(computeDate));
     }
     @ApiOperation("医院科室直接成本表(全成本)")
-    @GetMapping("/getDeptAllDirectCost")
-    public Result getDeptAllDirectCost(@RequestParam String computeDate){
-        return Result.ok(standardReportService.getDeptAllDirectCost(computeDate));
+    @GetMapping("/getDeptFullDirectCost")
+    public Result getDeptFullDirectCost(@RequestParam String computeDate){
+        return Result.ok(standardReportService.getDeptFullDirectCost(computeDate));
     }
 
-
+    /**
+     * 获取科室成本明细数据
+     *
+     * @return 科室成本明细数据列表
+     */
+    @GetMapping("/getClinicalDeptMedicalCost")
+    public Result getClinicalDeptMedicalCost(@RequestParam String computeDate) {
+        return Result.ok(standardReportService.getClinicalDeptMedicalCost(computeDate));
+    }
 }