Bladeren bron

添加标准报表-科室直接成本相关代码

JammeyJiang 3 maanden geleden
bovenliggende
commit
10a49b767c

+ 4 - 0
src/main/java/com/kcim/common/constants/Constant.java

@@ -191,6 +191,10 @@ public interface Constant {
      * 会计科目类别
      */
     String ACCOUNTING_TYPE = "ACCOUNTING_TYPE";
+    /**
+     * 标准成本类别
+     */
+    String STANDARD_COST_CATEGORIES = "STANDARD_COST_CATEGORIES";
     /**
      * 标准分摊层级
      */

+ 13 - 5
src/main/java/com/kcim/dao/model/AllocationQuery.java

@@ -3,16 +3,14 @@ package com.kcim.dao.model;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
-
-import java.math.BigDecimal;
-import java.io.Serializable;
-import java.util.Date;
-
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
 
+import java.io.Serializable;
+import java.math.BigDecimal;
+
 /**
  * 
  * 
@@ -99,4 +97,14 @@ public class AllocationQuery implements Serializable {
 
 	private Integer shareType;
 
+	/**
+	 * 标准科室分类(来自责任中心)
+	 */
+	private String standardShareLevel;
+
+	/**
+	 * 费用类型(来自会计科目字典)
+	 */
+	private String expandOne;
+
 }

+ 2 - 1
src/main/java/com/kcim/dao/model/Responsibility.java

@@ -70,6 +70,7 @@ public class Responsibility implements Serializable {
 	 * 分摊级别 如果是顶层默认为0
 	 */
 	private Integer shareLevel;
+
 	/**
 	 * 分摊级别名称
 	 */
@@ -95,7 +96,7 @@ public class Responsibility implements Serializable {
 	}
 
 	/**
-	 * 标准分摊层级
+	 * 标准分摊层级 标准分摊层级代码 1.行政后勤类,2.医疗辅助类,3.医疗技术类,4.临床服务类
 	 */
 	private String standardShareLevel;
 	@TableField(exist = false)

+ 7 - 0
src/main/java/com/kcim/dao/repository/AccountingRepository.java

@@ -41,6 +41,13 @@ public class AccountingRepository extends ServiceImpl<AccountingMapper, Accounti
         return this.list(queryWrapper);
     }
 
+    public List<Accounting> getAllCostAccounting() {
+        LambdaQueryWrapper<Accounting> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(Accounting::getHospId, UserContext.getHospId());
+        queryWrapper.eq(Accounting::getAccountingType, NumberConstant.TWO);
+        return this.list(queryWrapper);
+    }
+
     public List<Accounting> getList(Integer accountType) {
         LambdaQueryWrapper<Accounting> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(Accounting::getHospId, UserContext.getHospId());

+ 2 - 0
src/main/java/com/kcim/service/AllocationQueryService.java

@@ -45,6 +45,8 @@ public interface AllocationQueryService extends IService<AllocationQuery> {
      */
     List<AllocationQuery> getAllByDate(Long hospId, int year, int month);
 
+    List<AllocationQuery> getCostByDate(Long hospId, int year, int month,int originType);
+
     List<AllocationQuery> getByDate(int year, int month, Long hospId, List<Long> levelSorts);
 
     List<AllocationQuery> getByDateAndResp(int year, int month, Long hospId, String responsibilityCode);

+ 21 - 0
src/main/java/com/kcim/service/StandardReportService.java

@@ -0,0 +1,21 @@
+package com.kcim.service;
+
+import com.kcim.vo.DeptAllDirectCostVO;
+import com.kcim.vo.DeptDirectMedicalCostVO;
+
+import java.util.List;
+
+public interface StandardReportService {
+
+    /**
+     * 科室直接成本表(医疗成本)
+     * @param computeDate
+     */
+    List<DeptDirectMedicalCostVO> getDeptDirectMedicalCost(String computeDate);
+    /**
+     * 科室直接成本表(全成本)
+     * @param computeDate 核算年月
+     * @return 报表数据
+     */
+    List<DeptAllDirectCostVO> getDeptAllDirectCost(String computeDate);
+}

+ 20 - 0
src/main/java/com/kcim/service/impl/AllocationQueryServiceImpl.java

@@ -77,6 +77,26 @@ public class AllocationQueryServiceImpl extends ServiceImpl<AllocationQueryMappe
         return list;
     }
 
+    /**
+     * 获取指定类型的成本数据
+     * @param hospId
+     * @param year
+     * @param month
+     * @param originType 来源类型:1.分摊前,2.分摊后
+     * @return
+     */
+    @Override
+    public List<AllocationQuery> getCostByDate(Long hospId, int year, int month, int originType) {
+        List<AllocationQuery> list = this.list(
+                new LambdaQueryWrapper<AllocationQuery>()
+                        .eq(AllocationQuery::getDateYear, year)
+                        .eq(AllocationQuery::getDateMonth, month)
+                        .eq(AllocationQuery::getHospId, hospId)
+                        .eq(AllocationQuery::getOriginType, originType)
+        );
+        return list;
+    }
+
     @Override
     public List<AllocationQuery> getByDate(int year, int month, Long hospId, List<Long> levelSorts) {
         return this.list(

+ 554 - 0
src/main/java/com/kcim/service/impl/StandardReportServiceImpl.java

@@ -0,0 +1,554 @@
+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.NumberConstant;
+import com.kcim.common.util.BeanUtil;
+import com.kcim.common.util.UserContext;
+import com.kcim.dao.model.Accounting;
+import com.kcim.dao.model.AllocationQuery;
+import com.kcim.dao.model.Responsibility;
+import com.kcim.dao.repository.AccountingRepository;
+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 lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @program: CostAccount
+ * @description:
+ * @author: Wang.YS
+ * @create: 2024-03-19 11:10
+ **/
+@Service("StandardReportService")
+@Slf4j
+@AllArgsConstructor
+public class StandardReportServiceImpl implements StandardReportService {
+    ResponsibilityRepository responsibilityRepository;
+
+    AllocationQueryService allocationQueryService;
+
+    CenterService centerService;
+
+    AccountingRepository accountingRepository;
+    
+    /**
+     * 科室直接成本表(医疗成本)
+     * @param computeDate 核算年月
+     * @return
+     */
+    @Override
+    public List<DeptDirectMedicalCostVO> getDeptDirectMedicalCost(String computeDate) {
+        DateTime parse = DateUtil.parse(computeDate);
+        int year = DateUtil.year(parse);
+        int month = DateUtil.month(parse) + 1;
+        //获取科室直接成本
+        List<AllocationQuery> allocationQueryList = allocationQueryService.getCostByDate(UserContext.getCurrentLoginHospId(), year, month, NumberConstant.ONE);
+        if(CollectionUtils.isEmpty(allocationQueryList)){
+            return new ArrayList<>();
+        }
+        //获取所有的标准字典数据
+        StandCostDictMapVO standCostDictMaps = getStandCostDictMaps();
+        // 处理 allocationQueryList 数据
+        Map<String ,DeptDirectMedicalCostVO> deptDirectMedicalCostMap = new HashMap<>();
+        //转换为DeptDirectMedicalCostVO(一个责任中心只一条记录)
+        for (AllocationQuery allocationQuery : allocationQueryList) {
+            addDeptDirectMedicalCostVO(deptDirectMedicalCostMap,allocationQuery, standCostDictMaps);
+        }
+        // 转成List便于处理
+        List<DeptDirectMedicalCostVO> deptDirectMedicalCostList = deptDirectMedicalCostMap.values().stream().collect(Collectors.toList());
+        //创建医疗业务成本合计
+        DeptDirectMedicalCostVO medicalBusinessTotal = createSubTotalVo(deptDirectMedicalCostList.get(NumberConstant.ZERO), "医疗业务成本合计");
+        //创建总计
+        DeptDirectMedicalCostVO grandTotal = createSubTotalVo(deptDirectMedicalCostList.get(NumberConstant.ZERO), "总计");
+        //按responsibilitySort正序排序
+        deptDirectMedicalCostList.sort(Comparator.comparing(DeptDirectMedicalCostVO::getResponsibilitySort,
+                Comparator.nullsLast(Comparator.naturalOrder())));
+        // 按标准分级分组
+        Map<String, List<DeptDirectMedicalCostVO>> shareLevelGroup = deptDirectMedicalCostList.stream().collect(Collectors.groupingBy(DeptDirectMedicalCostVO::getStandardShareLevel));
+        // 科室标准分级按顺序号倒序排序
+        List<DictDataVo> standardShareLevelList = standCostDictMaps.getStandardShareLevelDict();
+        standardShareLevelList.sort(Comparator.comparing(DictDataVo::getSort,Comparator.nullsLast(Comparator.reverseOrder())));
+        // 创建各层级小计并按正确顺序插入
+        List<DeptDirectMedicalCostVO> result = new ArrayList<>();
+        for (DictDataVo shareLevel : standardShareLevelList) {
+            List<DeptDirectMedicalCostVO> deptDirectMedicalCostVOS = shareLevelGroup.get(shareLevel.getCode());
+            if(CollectionUtils.isEmpty(deptDirectMedicalCostVOS)){
+                continue;
+            }
+            // 添加该分类下的所有记录
+            result.addAll(deptDirectMedicalCostVOS);
+            // 创建小计对象
+            DeptDirectMedicalCostVO subtotalVo = createSubTotalVo(deptDirectMedicalCostVOS.get(NumberConstant.ZERO),String.format("%s小计", shareLevel.getName()));
+            //将科室的金额加到小计对象中
+            deptDirectMedicalCostVOS.forEach(item -> addDeptDirectMedicalCost(item, subtotalVo));
+            // 如果属于医疗业务成本的科室,则小计的金额加到医疗业务成本
+            if(NumberConstant.ONE_S.equals(shareLevel.getValue())){
+                addDeptDirectMedicalCost(subtotalVo, medicalBusinessTotal);
+            }
+            // 小计的金额加到总计
+            addDeptDirectMedicalCost(subtotalVo, grandTotal);
+            // 添加小计行
+            result.add(subtotalVo);
+            // 医疗业务成本加入到医疗辅助类小计后面
+            if(NumberConstant.TWO_S.equals(shareLevel.getCode())){
+                result.add(medicalBusinessTotal);
+            }
+        }
+        // 总计加到列表最后面
+        result.add(grandTotal);
+        return result;
+    }
+
+    /**
+     * 科室直接成本表(全成本)
+     * @param computeDate 核算年月
+     * @return 报表数据
+     */
+    @Override
+    public List<DeptAllDirectCostVO> getDeptAllDirectCost(String computeDate) {
+        DateTime parse = DateUtil.parse(computeDate);
+        int year = DateUtil.year(parse);
+        int month = DateUtil.month(parse) + 1;
+        
+        // 获取科室直接成本
+        List<AllocationQuery> allocationQueryList = allocationQueryService.getCostByDate(UserContext.getCurrentLoginHospId(), year, month, NumberConstant.ONE);
+        if (CollectionUtils.isEmpty(allocationQueryList)) {
+            return new ArrayList<>();
+        }
+        // 获取所有的标准字典数据
+        StandCostDictMapVO standCostDictMaps = getStandCostDictMaps();
+        // 处理 allocationQueryList 数据
+        Map<String, DeptAllDirectCostVO> reportMap = new HashMap<>();
+        // 转换为DeptDirectAllCostVO(一个责任中心只一条记录)
+        for (AllocationQuery allocationQuery : allocationQueryList) {
+            addDeptDirectAllCostVO(reportMap, allocationQuery, standCostDictMaps);
+        }
+        // 转成List便于处理
+        List<DeptAllDirectCostVO> reportList = reportMap.values().stream().collect(Collectors.toList());
+        // 按responsibilitySort正序排序
+        reportList.sort(Comparator.comparing(DeptAllDirectCostVO::getResponsibilitySort, Comparator.nullsLast(Comparator.naturalOrder())));
+        // 按标准分级分组
+        Map<String, List<DeptAllDirectCostVO>> shareLevelGroup = reportList.stream().collect(Collectors.groupingBy(DeptAllDirectCostVO::getStandardShareLevel));
+        // 科室标准分级按顺序号倒序排序
+        List<DictDataVo> standardShareLevelList = standCostDictMaps.getStandardShareLevelDict();
+        standardShareLevelList.sort(Comparator.comparing(DictDataVo::getSort, Comparator.nullsLast(Comparator.reverseOrder())));
+        //创建医疗业务成本合计
+        DeptAllDirectCostVO medicalBusinessTotal = createAllDirectCostSubTotalVo(reportList.get(NumberConstant.ZERO), "医疗业务成本合计");
+        //创建总计
+        DeptAllDirectCostVO grandTotal = createAllDirectCostSubTotalVo(reportList.get(NumberConstant.ZERO), "总计");
+        // 创建各层级小计并按正确顺序插入
+        List<DeptAllDirectCostVO> result = new ArrayList<>();
+        for (DictDataVo shareLevel : standardShareLevelList) {
+            List<DeptAllDirectCostVO> 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()));
+            //将科室的金额加到小计对象中
+            reportVOS.forEach(item -> addDeptAllDirectCost(item, subtotalVo));
+            // 如果属于医疗业务成本的科室,则小计的金额加到医疗业务成本
+            if(NumberConstant.ONE_S.equals(shareLevel.getValue())){
+                addDeptAllDirectCost(subtotalVo, medicalBusinessTotal);
+            }
+            // 小计的金额加到总计
+            addDeptAllDirectCost(subtotalVo, grandTotal);
+            // 添加小计行
+            result.add(subtotalVo);
+            // 医疗业务成本加入到医疗辅助类小计后面
+            if(NumberConstant.TWO_S.equals(shareLevel.getCode())){
+                result.add(medicalBusinessTotal);
+            }
+        }
+        // 总计加到列表最后面
+        result.add(grandTotal);
+        return result;
+    }
+
+    /**
+     * 获取所有的标准字典数据并转换所有需要的映射数据
+     * @return 包含所有映射数据的DTO对象
+     */
+    private StandCostDictMapVO getStandCostDictMaps() {
+        StandCostDictMapVO dataMaps = new StandCostDictMapVO();
+        List<Responsibility> responsibilityList = responsibilityRepository.getList(UserContext.getCurrentLoginHospId());
+        DictDataVo accountingTypeDict = centerService.getDict(Constant.ACCOUNTING_TYPE);
+        DictDataVo costTypeDict = centerService.getDict(Constant.STANDARD_COST_CATEGORIES);
+        DictDataVo standardShareLevelDict = centerService.getDict(Constant.STANDARD_SHARE_LEVEL);
+        List<Accounting> allCostAccounting = accountingRepository.getAllCostAccounting();
+
+        // 添加 null 检查
+        if (responsibilityList == null) {
+            responsibilityList = new ArrayList<>();
+        }
+        if (allCostAccounting == null) {
+            allCostAccounting = new ArrayList<>();
+        }
+
+        // 创建一个映射,用于快速查找责任中心的科室类型
+        Map<String, Responsibility> responsibilityMap = responsibilityList.stream()
+                .filter(Objects::nonNull) // 过滤掉 null 对象
+                .filter(r -> r.getResponsibilityCode() != null) // 过滤掉 responsibilityCode 为 null 的对象
+                .collect(Collectors.toMap(Responsibility::getResponsibilityCode, o -> o));
+
+        // 创建一个映射,用于快速查找会计科目的类型
+        Map<String, Accounting> accountingMap = allCostAccounting.stream()
+                .filter(Objects::nonNull) // 过滤掉 null 对象
+                .filter(a -> a.getAccountingCode() != null) // 过滤掉 accountingCode 为 null 的对象
+                .collect(Collectors.toMap(Accounting::getAccountingCode, o -> o));
+
+        // 添加 null 检查并创建映射
+        List<DictDataVo> accountingTypeDictList = (accountingTypeDict != null && accountingTypeDict.getDataVoList() != null)
+                ? accountingTypeDict.getDataVoList() : new ArrayList<>();
+
+        List<DictDataVo> costTypeDictList = (costTypeDict != null && costTypeDict.getDataVoList() != null)
+                ? costTypeDict.getDataVoList() : new ArrayList<>();
+
+        List<DictDataVo> standardShareLevelDictList = (standardShareLevelDict != null && standardShareLevelDict.getDataVoList() != null)
+                ? standardShareLevelDict.getDataVoList() : new ArrayList<>();
+
+        // 创建一个映射,用于快速查找会计科目类型的扩展字段
+        Map<String, DictDataVo> accountingTypeMap = accountingTypeDictList.stream()
+                .filter(Objects::nonNull) // 过滤掉 null 对象
+                .filter(d -> d.getCode() != null) // 过滤掉 code 为 null 的对象
+                .collect(Collectors.toMap(DictDataVo::getCode, o -> o));
+
+        // 创建一个映射,用于快速查找会计科目类型的扩展字段
+        Map<String, DictDataVo> costTypeMap = costTypeDictList.stream()
+                .filter(Objects::nonNull) // 过滤掉 null 对象
+                .filter(d -> d.getCode() != null) // 过滤掉 code 为 null 的对象
+                .collect(Collectors.toMap(DictDataVo::getCode, o -> o));
+
+        // 创建一个映射,用于快速查找会计科目类型的扩展字段
+        Map<String, DictDataVo> standardShareLevelMap = standardShareLevelDictList.stream()
+                .filter(Objects::nonNull) // 过滤掉 null 对象
+                .filter(d -> d.getCode() != null) // 过滤掉 code 为 null 的对象
+                .collect(Collectors.toMap(DictDataVo::getCode, o -> o));
+
+        dataMaps.setResponsibilityDict(responsibilityList);
+        dataMaps.setCostAccountingDict(allCostAccounting);
+        dataMaps.setCostTypeDict(costTypeDictList);
+        dataMaps.setAccountingTypeDict(accountingTypeDictList);
+        dataMaps.setStandardShareLevelDict(standardShareLevelDictList);
+        dataMaps.setAccountingMap(accountingMap);
+        dataMaps.setCostTypeMap(costTypeMap);
+        dataMaps.setResponsibilityMap(responsibilityMap);
+        dataMaps.setStandardShareLevelMap(standardShareLevelMap);
+        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()));
+    }
+
+    /**
+     * 创建小计对象
+     * @param directMedicalCostVO
+     * @param totalName
+     * @return
+     */
+    public DeptDirectMedicalCostVO createSubTotalVo(DeptDirectMedicalCostVO directMedicalCostVO, String totalName ){
+        if (directMedicalCostVO == null) {
+            return null;
+        }
+        DeptDirectMedicalCostVO deptDirectMedicalCostVO = BeanUtil.convertObj(directMedicalCostVO, DeptDirectMedicalCostVO.class);
+        deptDirectMedicalCostVO.setResponsibilityCode(totalName);
+        deptDirectMedicalCostVO.setResponsibilityName(totalName);
+        // 初始化所有费用字段为0
+        initDeptDirectMedicalCostAmount(deptDirectMedicalCostVO);
+        return deptDirectMedicalCostVO;
+    }
+
+    /**
+     *  转换为DeptDirectMedicalCostVO(一个责任中心只一条记录)
+     * @param allocationQuery
+     * @param standCostDictMaps
+     * @return
+     */
+    public void addDeptDirectMedicalCostVO(Map<String ,DeptDirectMedicalCostVO> deptDirectMedicalCostMap,
+                                           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 检查
+        }
+        //只处理医疗成本
+        if(!NumberConstant.ONE_S.equals(accountType.getExpandOne()) ){
+            return;
+        }
+        DictDataVo costType = standCostDictMaps.getCostTypeMap().get(account.getCostType());
+        DictDataVo standardShareLevel = standCostDictMaps.getStandardShareLevelMap().get(responsibility.getStandardShareLevel());
+        DeptDirectMedicalCostVO deptDirectMedicalCostVO= new DeptDirectMedicalCostVO();
+        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());
+            // 初始化所有费用字段为0
+            initDeptDirectMedicalCostAmount(deptDirectMedicalCostVO);
+        }
+        // 根据费用类型累加到对应字段
+        switch (accountType.getExpandOne()) {
+            case "1":
+                deptDirectMedicalCostVO.setPersonnelExpense(deptDirectMedicalCostVO.getPersonnelExpense().add((allocationQuery.getAmount())));
+                break;
+            case "2":
+                deptDirectMedicalCostVO.setHealthMaterialFee(deptDirectMedicalCostVO.getHealthMaterialFee().add((allocationQuery.getAmount())));
+                break;
+            case "3":
+                deptDirectMedicalCostVO.setDrugFee(deptDirectMedicalCostVO.getDrugFee().add((allocationQuery.getAmount())));
+                break;
+            case "4":
+                deptDirectMedicalCostVO.setFixedAssetDepreciation(deptDirectMedicalCostVO.getFixedAssetDepreciation().add((allocationQuery.getAmount())));
+                break;
+            case "5":
+                deptDirectMedicalCostVO.setIntangibleAssetAmortization(deptDirectMedicalCostVO.getIntangibleAssetAmortization().add((allocationQuery.getAmount())));
+                break;
+            case "6":
+                deptDirectMedicalCostVO.setMedicalRiskFundExtraction(deptDirectMedicalCostVO.getMedicalRiskFundExtraction().add((allocationQuery.getAmount())));
+                break;
+            case "7":
+                deptDirectMedicalCostVO.setOtherMedicalExpenses(deptDirectMedicalCostVO.getOtherMedicalExpenses().add((allocationQuery.getAmount())));
+                break;
+            default:
+                break;
+        }
+        // 更新总计
+        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(一个责任中心只一条记录)
+     * @param reportMap
+     * @param allocationQuery
+     * @param standCostDictMaps
+     */
+    private void addDeptDirectAllCostVO(Map<String, DeptAllDirectCostVO> 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());
+
+        DeptAllDirectCostVO reportVO = new DeptAllDirectCostVO();
+        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());
+            // 初始化所有费用字段为0
+            initAllDirectCostAmount(reportVO);
+        }
+
+        // 根据费用类型累加到对应字段
+        switch (costType.getValue()) {
+            case "1":
+                reportVO.setMedicalCostTotal(reportVO.getMedicalCostTotal().add(allocationQuery.getAmount()));
+                break;
+            case "2":
+                reportVO.setFinancialProjectFunds(reportVO.getFinancialProjectFunds().add(allocationQuery.getAmount()));
+                break;
+            case "3":
+                reportVO.setNonPeerFinancialFunds(reportVO.getNonPeerFinancialFunds().add(allocationQuery.getAmount()));
+                break;
+            case "4":
+                reportVO.setEducationalExpenses(reportVO.getEducationalExpenses().add(allocationQuery.getAmount()));
+                break;
+            case "5":
+                reportVO.setAssetDisposalFees(reportVO.getAssetDisposalFees().add(allocationQuery.getAmount()));
+                break;
+            default:
+                break;
+        }
+        //不是医院全成本的都是医疗全成本
+        if(!NumberConstant.THREE_S.equals(costType.getExpandOne())){
+            // 医疗全成本合计
+            reportVO.setMedicalTotalCost(reportVO.getMedicalTotalCost().add(allocationQuery.getAmount()));
+        }
+        // 医院全成本合计
+        reportVO.setHospitalTotalCost(reportVO.getHospitalTotalCost().add(allocationQuery.getAmount()));
+    }
+
+    /**
+     * 创建小计对象
+     * @param directMedicalCostVO
+     * @param totalName
+     * @return
+     */
+    public DeptAllDirectCostVO createAllDirectCostSubTotalVo(DeptAllDirectCostVO directMedicalCostVO, String totalName ){
+        if (directMedicalCostVO == null) {
+            return null;
+        }
+        DeptAllDirectCostVO deptDirectMedicalCostVO = BeanUtil.convertObj(directMedicalCostVO, DeptAllDirectCostVO.class);
+        deptDirectMedicalCostVO.setResponsibilityCode(totalName);
+        deptDirectMedicalCostVO.setResponsibilityName(totalName);
+        // 初始化所有费用字段为0
+        initAllDirectCostAmount(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
+     */
+    public void addDeptAllDirectCost(DeptAllDirectCostVO sourceDept, DeptAllDirectCostVO targetDept) {
+        if (sourceDept == null || targetDept == 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()));
+    }
+
+
+}

+ 92 - 0
src/main/java/com/kcim/vo/DeptAllDirectCostVO.java

@@ -0,0 +1,92 @@
+package com.kcim.vo;
+
+import lombok.Data;
+
+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;
+
+    /**
+     * 医疗成本合计
+     */
+    private BigDecimal medicalCostTotal;
+
+    /**
+     * 财政项目拨款经费形成的各项费用
+     */
+    private BigDecimal financialProjectFunds;
+
+    /**
+     * 非同级财政拨款项目经费形成的各项费用
+     */
+    private BigDecimal nonPeerFinancialFunds;
+
+    /**
+     * 医疗全成本合计
+     */
+    private BigDecimal medicalTotalCost;
+
+    /**
+     * 科教经费形成的各项费用
+     */
+    private BigDecimal educationalExpenses;
+
+    /**
+     * 资产处置费用、上缴上级费用、对附属单位补助费用、其他费用等
+     */
+    private BigDecimal assetDisposalFees;
+
+    /**
+     * 医院全成本合计
+     */
+    private BigDecimal hospitalTotalCost;
+}

+ 94 - 0
src/main/java/com/kcim/vo/DeptDirectMedicalCostVO.java

@@ -0,0 +1,94 @@
+package com.kcim.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 科室直接成本表(医疗成本)
+ * @author Administrator
+ */
+@Data
+public class DeptDirectMedicalCostVO {
+    /**
+     * 科室标准分级
+     */
+    private String standardShareLevel;
+    /**
+     * 科室代码
+     */
+    private String responsibilityCode;
+    /**
+     * 科室名称
+     */
+    private String responsibilityName;
+    /**
+     * 人员经费
+     */
+    private BigDecimal personnelExpense;
+
+    /**
+     * 卫生材料费
+     */
+    private BigDecimal healthMaterialFee;
+
+    /**
+     * 药品费
+     */
+    private BigDecimal drugFee;
+
+    /**
+     * 固定资产折旧费
+     */
+    private BigDecimal fixedAssetDepreciation;
+
+    /**
+     * 无形资产摊销费
+     */
+    private BigDecimal intangibleAssetAmortization;
+
+    /**
+     * 提取医疗风险基金
+     */
+    private BigDecimal medicalRiskFundExtraction;
+
+    /**
+     * 其他医疗费用
+     */
+    private BigDecimal otherMedicalExpenses;
+
+    /**
+     * 合计
+     */
+    private BigDecimal total;
+
+    /**
+     * 标准会计科目类别(来自会计科目字典)
+     */
+    private String standAccountType;
+
+    /**
+     * 会计科目类别(来自会计科目字典)
+     */
+    private String accountType;
+
+    /**
+     * 成本类别(来自成本类别字典)
+     */
+    private String costType;
+
+    /**
+     * 标准成本类别(来自成本类别字典)
+     */
+    private String standCostType;
+
+    /**
+     * 责任中心序号
+     */
+    private int responsibilitySort;
+
+    /**
+     * 标准分级序号
+     */
+    private int shareLevelSort;
+}

+ 30 - 0
src/main/java/com/kcim/vo/StandCostDictMapVO.java

@@ -0,0 +1,30 @@
+package com.kcim.vo;
+
+import com.kcim.dao.model.Accounting;
+import com.kcim.dao.model.Responsibility;
+import lombok.Data;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @program: CostAccount
+ * @description:
+ * @author: Wang.YS
+ * @create: 2023-09-20 10:16
+ **/
+@Data
+public class StandCostDictMapVO {
+
+    private List<Responsibility> responsibilityDict;
+    private List<Accounting> costAccountingDict ;
+    private List<DictDataVo> accountingTypeDict;
+    private List<DictDataVo> costTypeDict;
+    private List<DictDataVo> standardShareLevelDict;
+
+    private Map<String, Responsibility> responsibilityMap;
+    private Map<String, Accounting> accountingMap;
+    private Map<String, DictDataVo> accountingTypeMap;
+    private Map<String, DictDataVo> costTypeMap;
+    private Map<String, DictDataVo> standardShareLevelMap;
+}

+ 38 - 0
src/main/java/com/kcim/web/StandardReportController.java

@@ -0,0 +1,38 @@
+package com.kcim.web;
+
+import com.kcim.common.util.Result;
+import com.kcim.service.StandardReportService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 相关导入导出操作
+ */
+@Slf4j
+@Api(tags = "标准成本报表")
+@RestController
+@RequestMapping("standardReport")
+@AllArgsConstructor
+public class StandardReportController extends AbstractController {
+
+    private StandardReportService standardReportService;
+
+    @ApiOperation("医院科室直接成本表(医疗成本)")
+    @GetMapping("/getDeptDirectMedicalCost")
+    public Result getDeptDirectMedicalCost(@RequestParam String computeDate){
+        return Result.ok(standardReportService.getDeptDirectMedicalCost(computeDate));
+    }
+    @ApiOperation("医院科室直接成本表(全成本)")
+    @GetMapping("/getDeptAllDirectCost")
+    public Result getDeptAllDirectCost(@RequestParam String computeDate){
+        return Result.ok(standardReportService.getDeptAllDirectCost(computeDate));
+    }
+
+
+}