فهرست منبع

08 25 01 分摊后查询

hr 4 سال پیش
والد
کامیت
00cce196f4

+ 1 - 0
.gitignore

@@ -19,6 +19,7 @@ target/
 *.iml
 *.ipr
 logs/*
+Demo*.java
 
 ### NetBeans ###
 /nbproject/private/

+ 19 - 1
src/main/java/com/imed/costaccount/mapper/AllocationQueryMapper.java

@@ -2,7 +2,13 @@ package com.imed.costaccount.mapper;
 
 import com.imed.costaccount.model.AllocationQuery;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.imed.costaccount.model.vo.CodeAndNameVO;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.List;
 
 /**
  * 
@@ -12,5 +18,17 @@ import org.apache.ibatis.annotations.Mapper;
  */
 @Mapper
 public interface AllocationQueryMapper extends BaseMapper<AllocationQuery> {
-	
+
+    BigDecimal getTotalMoney(@Param("dateYear") int dateYear, @Param("month") int month, @Param("hospId") Long hospId);
+
+    List<CodeAndNameVO> getRespCodeAndName(@Param("hospId") Long hospId, @Param("dateYear") int dateYear, @Param("month") int month);
+
+    List<CodeAndNameVO> getAccountCodeAndName(@Param("hospId") Long hospId, @Param("dateYear") int dateYear, @Param("month") int month);
+
+    BigDecimal getCountByRespAndAccounts(@Param("hospId") Long hospId, @Param("dateYear") int dateYear, @Param("month") int month, @Param("code") String code, @Param("accountCodes") List<String> accountCodes);
+
+    BigDecimal getTotalByAccountAndResps(@Param("hospId") Long hospId, @Param("dateYear") int dateYear, @Param("month") int month, @Param("code") String code, @Param("respCodes") List<String> respCodes);
+
+    BigDecimal getTotalByAccountAndRespCode(@Param("hospId") Long hospId, @Param("dateYear") int dateYear, @Param("month") int month, @Param("accountCode") String accountCode, @Param("responsibilityCode") String responsibilityCode);
+
 }

+ 2 - 0
src/main/java/com/imed/costaccount/model/AllocationQuery.java

@@ -1,6 +1,7 @@
 package com.imed.costaccount.model;
 
 import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
 
 import java.math.BigDecimal;
@@ -87,6 +88,7 @@ public class AllocationQuery implements Serializable {
 	/**
 	 * 删除时间
 	 */
+	@TableLogic(value = "0",delval = "TIME_STAMP(NOW()) * 1000")
 	private Long deleteTime;
 
 }

+ 22 - 0
src/main/java/com/imed/costaccount/service/AllocationQueryService.java

@@ -2,6 +2,10 @@ package com.imed.costaccount.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.imed.costaccount.model.AllocationQuery;
+import com.imed.costaccount.model.vo.CodeAndNameVO;
+
+import java.math.BigDecimal;
+import java.util.List;
 
 
 /**
@@ -13,5 +17,23 @@ import com.imed.costaccount.model.AllocationQuery;
  */
 public interface AllocationQueryService extends IService<AllocationQuery> {
 
+    /**
+     * 这个月总金额
+     * @param dateYear
+     * @param month
+     * @param hospId
+     * @return
+     */
+    BigDecimal getTotalMoney(int dateYear, int month, Long hospId);
+
+    List<CodeAndNameVO> getRespCodeAndName(Long hospId, int dateYear, int month);
+
+    List<CodeAndNameVO> getAccountCodeAndName(Long hospId, int dateYear, int month);
+
+    BigDecimal getCountByRespAndAccounts(Long hospId, int dateYear, int month, String code, List<String> accountCodes);
+
+    BigDecimal getTotalByAccountAndResps(Long hospId, int dateYear, int month, String code, List<String> respCodes);
+
+    BigDecimal getTotalByAccountAndRespCode(Long hospId, int dateYear, int month, String accountCode, String responsibilityCode);
 }
 

+ 2 - 1
src/main/java/com/imed/costaccount/service/AllocationService.java

@@ -42,9 +42,10 @@ public interface AllocationService extends IService<Allocation> {
      * 分摊后报表
      * @param year 年月(yyyy-MM-dd)
      * @param responsibilityCode 责任中心代码
+     * @param hospId
      * @return List
      */
-    List<CollectDataFormVO> queryAfterAllocationForm(String year, String responsibilityCode);
+    CollectDataFormVO queryAfterAllocationForm(String year, String responsibilityCode, Long hospId);
 
 
 

+ 46 - 0
src/main/java/com/imed/costaccount/service/impl/AllocationQueryServiceImpl.java

@@ -1,5 +1,7 @@
 package com.imed.costaccount.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.imed.costaccount.model.vo.CodeAndNameVO;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -8,9 +10,53 @@ import com.imed.costaccount.mapper.AllocationQueryMapper;
 import com.imed.costaccount.model.AllocationQuery;
 import com.imed.costaccount.service.AllocationQueryService;
 
+import java.math.BigDecimal;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
 
 @Service("allocationQueryService")
 public class AllocationQueryServiceImpl extends ServiceImpl<AllocationQueryMapper, AllocationQuery> implements AllocationQueryService {
 
 
+    /**
+     * 这个月总金额
+     *
+     * @param dateYear
+     * @param month
+     * @param hospId
+     * @return
+     */
+    @Override
+    public BigDecimal getTotalMoney(int dateYear, int month, Long hospId) {
+        return baseMapper.getTotalMoney(dateYear, month, hospId);
+    }
+
+    @Override
+    public List<CodeAndNameVO> getRespCodeAndName(Long hospId, int dateYear, int month) {
+        List<CodeAndNameVO> respCodeAndName = baseMapper.getRespCodeAndName(hospId, dateYear, month);
+        return respCodeAndName.stream().distinct().collect(Collectors.toList());
+    }
+
+    @Override
+    public List<CodeAndNameVO> getAccountCodeAndName(Long hospId, int dateYear, int month) {
+        List<CodeAndNameVO> respCodeAndName = baseMapper.getAccountCodeAndName(hospId, dateYear, month);
+        return respCodeAndName.stream().distinct().collect(Collectors.toList());
+    }
+
+    @Override
+    public BigDecimal getCountByRespAndAccounts(Long hospId, int dateYear, int month, String code, List<String> accountCodes) {
+        return baseMapper.getCountByRespAndAccounts(hospId, dateYear, month, code, accountCodes);
+    }
+
+    @Override
+    public BigDecimal getTotalByAccountAndResps(Long hospId, int dateYear, int month, String code, List<String> respCodes) {
+        return baseMapper.getTotalByAccountAndResps(hospId, dateYear, month, code, respCodes);
+    }
+
+    @Override
+    public BigDecimal getTotalByAccountAndRespCode(Long hospId, int dateYear, int month, String accountCode, String responsibilityCode) {
+        return baseMapper.getTotalByAccountAndRespCode(hospId, dateYear, month, accountCode, responsibilityCode);
+    }
 }

+ 116 - 39
src/main/java/com/imed/costaccount/service/impl/AllocationServiceImpl.java

@@ -21,7 +21,6 @@ import com.imed.costaccount.model.vo.*;
 import com.imed.costaccount.service.*;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.xmlbeans.impl.xb.xsdschema.All;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
@@ -80,12 +79,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
         }
         Map<String, List<ShareParamValue>> paramValueRespCodeMap = shareParamValues.stream().collect(Collectors.groupingBy(ShareParamValue::getResponsibilityCode));
         // 删除该年月已经分摊过的数据
-        this.remove(
-                new LambdaQueryWrapper<Allocation>()
-                        .eq(Allocation::getDateYear, startDTO.getYear())
-                        .eq(Allocation::getDateMonth, startDTO.getMonth())
-                        .eq(Allocation::getHospId, hospId)
-        );
+        removeData(startDTO, hospId);
         // 得到这个医院所有的分摊层级列表排序
         List<CostShareLevelVO> shareLevelVOs = shareLevelService.getAll(hospId);
         if (CollUtil.isEmpty(shareLevelVOs)) {
@@ -206,7 +200,22 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
         this.saveAllocationQuery(list, costingGroups, hospId);
     }
 
-    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Throwable.class)
+    private void removeData(StartDTO startDTO, Long hospId) {
+        this.remove(
+                new LambdaQueryWrapper<Allocation>()
+                        .eq(Allocation::getDateYear, startDTO.getYear())
+                        .eq(Allocation::getDateMonth, startDTO.getMonth())
+                        .eq(Allocation::getHospId, hospId)
+        );
+        allocationQueryService.remove(
+                new LambdaQueryWrapper<AllocationQuery>()
+                        .eq(AllocationQuery::getDateYear, startDTO.getYear())
+                        .eq(AllocationQuery::getDateMonth, startDTO.getMonth())
+                        .eq(AllocationQuery::getHospId, hospId)
+        );
+    }
+
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
     public void saveAllocationQuery(List<Allocation> list, List<CostCostingGroup> costingGroups, Long hospId) {
         List<AllocationQuery> saveList = new ArrayList<>();
         list.forEach(i -> {
@@ -370,7 +379,6 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
     }
 
 
-
     /**
      * 分摊报表导出
      *
@@ -388,8 +396,8 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
         // 设置导出
         Map<String, List<AllocationReportVO>> responsibilityMap = allocationReportVOList.stream().collect(Collectors.groupingBy(AllocationReportVO::getResponsibilityCode));
         Map<String, List<AllocationReportVO>> targetResponsibilityMap = allocationReportVOList.stream().collect(Collectors.groupingBy(AllocationReportVO::getTargetResponsibilityCode));
-        Map<String, AllocationReportVO> allAccMap = allocationReportVOList.stream().collect(Collectors.toMap(k -> k.getResponsibilityName()+k.getAccountName()+k.getTargetResponsibilityName()+k.getShareParamName(), synOne -> synOne));
-        Map<String, AllocationReportVO> allAliMap = allocationReportVOList.stream().collect(Collectors.toMap(k -> k.getResponsibilityName()+k.getAlias()+k.getTargetResponsibilityName()+k.getShareParamName(), synOne -> synOne));
+        Map<String, AllocationReportVO> allAccMap = allocationReportVOList.stream().collect(Collectors.toMap(k -> k.getResponsibilityName() + k.getAccountName() + k.getTargetResponsibilityName() + k.getShareParamName(), synOne -> synOne));
+        Map<String, AllocationReportVO> allAliMap = allocationReportVOList.stream().collect(Collectors.toMap(k -> k.getResponsibilityName() + k.getAlias() + k.getTargetResponsibilityName() + k.getShareParamName(), synOne -> synOne));
         // 当前责任中心下面有几个会计科目  后面进行合并使用
         int numResponsibility;
 //        // 从第几列开始编写数据
@@ -410,23 +418,23 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
                 for (String s : strings) {
                     AllocationReportVO allocationReportVO = linkedHashMap.get(s);
                     if (StrUtil.isBlank(allocationReportVO.getAlias())) {
-                        writer.writeCellValue(column,0,allocationReportVO.getResponsibilityName());
+                        writer.writeCellValue(column, 0, allocationReportVO.getResponsibilityName());
                         // 别名不存在
                         writer.writeCellValue(column, 1, allocationReportVO.getAccountName());
                     } else {
                         // 不为空 设置别名
-                        writer.writeCellValue(column,0,allocationReportVO.getResponsibilityName());
+                        writer.writeCellValue(column, 0, allocationReportVO.getResponsibilityName());
                         writer.writeCellValue(column, 1, allocationReportVO.getAlias());
                     }
                     writer.writeCellValue(column, 2, allocationReportVO.getTotalAmounts());
                     column++;
                 }
-            }else {
+            } else {
                 // 不需要合并单元格
                 writer.writeCellValue(column, 0, allocationReportVOS.get(0).getResponsibilityName());
-                if (StrUtil.isNotBlank(allocationReportVOS.get(0).getAlias())){
+                if (StrUtil.isNotBlank(allocationReportVOS.get(0).getAlias())) {
                     writer.writeCellValue(column, 1, allocationReportVOS.get(0).getAlias());
-                }else {
+                } else {
                     writer.writeCellValue(column, 1, allocationReportVOS.get(0).getAccountName());
                 }
                 writer.writeCellValue(column, 2, allocationReportVOS.get(0).getTotalAmounts());
@@ -456,18 +464,18 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
                 // 责任中心
                 AllocationReportVO costCostingVO = allocationReportVOS.get(0);
                 // 设置第几次分摊的值
-                for (int k = 0; k < levelSort-1; k++) {
+                for (int k = 0; k < levelSort - 1; k++) {
                     writer.merge(num, num + shareParamSize - 1, k + 1, k + 1, costCostingVO.getTargetShareMoneys().get(k), false);
                 }
                 // 设置对应的分摊参数值
                 Set<String> strings = linkedHashMap.keySet();
                 for (String s : strings) {
                     AllocationReportVO allocationReportVO = linkedHashMap.get(s);
-                    writer.writeCellValue(0,num,allocationReportVO.getTargetResponsibilityName());
+                    writer.writeCellValue(0, num, allocationReportVO.getTargetResponsibilityName());
                     writer.writeCellValue(levelSort, num, allocationReportVO.getShareParamName());
-                    writer.writeCellValue(levelSort +1, num, allocationReportVO.getShareParamValueNums());
+                    writer.writeCellValue(levelSort + 1, num, allocationReportVO.getShareParamValueNums());
                     writer.writeCellValue(levelSort + 2, num, allocationReportVO.getShareParamRates());
-                    for (int m=levelSort+3;m<column;m++){
+                    for (int m = levelSort + 3; m < column; m++) {
                         // x是m y是num
                         // 获取当前这一列对应的责任中心 以及会计科目
                         // 第一行责任中心
@@ -478,17 +486,17 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
                         String otherResponsibilityName = sheet.getRow(num).getCell(0).getStringCellValue();
                         // 分摊参数
                         String shareName = sheet.getRow(num).getCell(levelSort).getStringCellValue();
-                        String sss= responsibilityName + accountNameOrAlias + otherResponsibilityName + shareName;
+                        String sss = responsibilityName + accountNameOrAlias + otherResponsibilityName + shareName;
                         AllocationReportVO vo = allAliMap.get(sss);
                         AllocationReportVO allocationReportVO2 = allAccMap.get(responsibilityName + accountNameOrAlias + otherResponsibilityName + shareName);
                         AllocationReportVO allocationReportVO3 = allAliMap.get(responsibilityName + accountNameOrAlias + otherResponsibilityName + shareName);
 
-                        if (Objects.nonNull(allocationReportVO2)){
-                            writer.writeCellValue(m,num,allocationReportVO2.getAmounts());
-                        }else if (Objects.nonNull(allocationReportVO3)){
-                            writer.writeCellValue(m,num,allocationReportVO3.getAmounts());
-                        }else {
-                            writer.writeCellValue(m,num,0);
+                        if (Objects.nonNull(allocationReportVO2)) {
+                            writer.writeCellValue(m, num, allocationReportVO2.getAmounts());
+                        } else if (Objects.nonNull(allocationReportVO3)) {
+                            writer.writeCellValue(m, num, allocationReportVO3.getAmounts());
+                        } else {
+                            writer.writeCellValue(m, num, 0);
                         }
                     }
                     num++;
@@ -496,13 +504,13 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
             }
             if (shareParamSize < NumberConstant.TWO) {
                 writer.writeCellValue(0, num, allocationReportVOS.get(0).getTargetResponsibilityName());
-                for (int k = 0; k < levelSort-1; k++) {
+                for (int k = 0; k < levelSort - 1; k++) {
                     writer.writeCellValue(k + 1, num, allocationReportVOS.get(0).getTargetShareMoneys().get(k));
                 }
-                writer.writeCellValue(levelSort , num, allocationReportVOS.get(0).getShareParamName());
+                writer.writeCellValue(levelSort, num, allocationReportVOS.get(0).getShareParamName());
                 writer.writeCellValue(levelSort + 1, num, allocationReportVOS.get(0).getShareParamValueNums());
                 writer.writeCellValue(levelSort + 2, num, allocationReportVOS.get(0).getShareParamRates());
-                for (int m=levelSort+4;m<column;m++){
+                for (int m = levelSort + 4; m < column; m++) {
                     // x是m y是num
                     // 获取当前这一列对应的责任中心 以及会计科目
                     // 第一行责任中心
@@ -515,12 +523,12 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
                     String shareName = sheet.getRow(num).getCell(levelSort).getStringCellValue();
                     AllocationReportVO allocationReportVO2 = allAccMap.get(responsibilityName + accountNameOrAlias + otherResponsibilityName + shareName);
                     AllocationReportVO allocationReportVO3 = allAliMap.get(responsibilityName + accountNameOrAlias + otherResponsibilityName + shareName);
-                    if (Objects.nonNull(allocationReportVO2)){
-                        writer.writeCellValue(m,num,allocationReportVO2.getAmounts());
-                    }else if (Objects.nonNull(allocationReportVO3)){
-                        writer.writeCellValue(m,num,allocationReportVO3.getAmounts());
-                    }else {
-                        writer.writeCellValue(m,num,0);
+                    if (Objects.nonNull(allocationReportVO2)) {
+                        writer.writeCellValue(m, num, allocationReportVO2.getAmounts());
+                    } else if (Objects.nonNull(allocationReportVO3)) {
+                        writer.writeCellValue(m, num, allocationReportVO3.getAmounts());
+                    } else {
+                        writer.writeCellValue(m, num, 0);
                     }
                 }
                 num++;
@@ -537,6 +545,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
 
     /**
      * 查询数据
+     *
      * @param levelSort
      * @param year
      * @param month
@@ -579,7 +588,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
                             money.updateAndGet(v -> v.add(m.getAmount()));
                             shareMoney.add(month.toString());
                         });
-                    }else {
+                    } else {
                         // TODO 封装测试数据
                         shareMoney.add("1000");
                     }
@@ -601,10 +610,78 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
      *
      * @param year               年月(yyyy-MM-dd)
      * @param responsibilityCode 责任中心代码
+     * @param hospId             医院id
      * @return List
      */
     @Override
-    public List<CollectDataFormVO> queryAfterAllocationForm(String year, String responsibilityCode) {
-        return null;
+    public CollectDataFormVO queryAfterAllocationForm(String year, String responsibilityCode, Long hospId) {
+        DateTime dateTime = DateUtil.parseDate(year);
+        int dateYear = DateUtil.year(dateTime);
+        int month = DateUtil.month(dateTime) + 1;
+        List<CodeAndNameVO> responsibilityCodeAndNames = allocationQueryService.getRespCodeAndName(hospId, dateYear, month);
+        List<CodeAndNameVO> accountCodeAndNames = allocationQueryService.getAccountCodeAndName(hospId, dateYear, month);
+        // todo 校验两个List是否为空
+        // 填充
+        responsibilityCodeAndNames.add(0, new CodeAndNameVO("#", "#"));
+        responsibilityCodeAndNames.add(responsibilityCodeAndNames.size(), new CodeAndNameVO("合计", "合计"));
+
+        List<String> titleData = responsibilityCodeAndNames.stream().map(CodeAndNameVO::getName).collect(Collectors.toList());
+        List<String> respCodes = responsibilityCodeAndNames.stream().map(CodeAndNameVO::getCode).collect(Collectors.toList());
+        Map<Integer, String> titleMap = new HashMap<>();
+        for (int i = 0; i < titleData.size(); i++) {
+            titleMap.put(i + 1, titleData.get(i));
+        }
+
+        List<Map<Integer, Object>> realDatas = new ArrayList<>();
+        List<String> accountCodes = accountCodeAndNames.stream().map(CodeAndNameVO::getCode).collect(Collectors.toList());
+        for (CodeAndNameVO account : accountCodeAndNames) {
+            Map<Integer, Object> map = new HashMap<>();
+            for (int i = 0; i < responsibilityCodeAndNames.size(); i++) {
+                if (i == 0) {
+                    map.put(i + 1, account.getName());
+                    continue;
+                } else if (i == responsibilityCodeAndNames.size() - 1) {
+                    // todo 计算最右侧合计的钱
+                    BigDecimal amount = allocationQueryService.getTotalByAccountAndResps(hospId, dateYear, month, account.getCode(), respCodes);
+                    map.put(i + 1, amount);
+                    continue;
+                }
+                // TODO: 2021/8/26 计算 中间的钱
+                BigDecimal amount = allocationQueryService.getTotalByAccountAndRespCode(hospId, dateYear, month,  account.getCode(), respCodes.get(i));
+                map.put(i + 1, amount);
+
+            }
+            realDatas.add(map);
+        }
+
+        // 尾栏计算
+        Map<Integer, Object> map = new HashMap<>();
+        for (int i = 0; i < titleData.size(); i++) {
+            if (i == 0) {
+                map.put(i + 1, "合计");
+                continue;
+            } else if (i == titleData.size() - 1) {
+                // TODO: 2021/8/26 计算
+                BigDecimal bigDecimal = allocationQueryService.getTotalMoney(dateYear, month, hospId);
+                map.put(i + 1, bigDecimal);
+                continue;
+            }
+            BigDecimal bigDecimal = allocationQueryService.getCountByRespAndAccounts(hospId, dateYear, month, responsibilityCodeAndNames.get(i).getCode(), accountCodes);
+            map.put(i + 1, bigDecimal);
+        }
+        return new CollectDataFormVO(titleMap, realDatas, map);
+    }
+
+    /**
+     * 这年月的数据
+     */
+    private List<AllocationQuery> getAllocationQueriesByYear(Long hospId, int dateYear, int month) {
+        List<AllocationQuery> list = allocationQueryService.list(
+                new LambdaQueryWrapper<AllocationQuery>()
+                        .eq(AllocationQuery::getDateYear, dateYear)
+                        .eq(AllocationQuery::getDateMonth, month)
+                        .eq(AllocationQuery::getHospId, hospId)
+        );
+        return list;
     }
 }

+ 1 - 2
src/main/java/com/imed/costaccount/web/CostCostingGroupController.java

@@ -104,7 +104,6 @@ public class CostCostingGroupController extends AbstractController {
     })
     public Result queryAfterAllocationForm(@RequestParam(value = "year", required = false) String year,
                                            @RequestParam(value = "responsibilityCode", required = false) String responsibilityCode) {
-        List<CollectDataFormVO> list = allocationService.queryAfterAllocationForm(year, responsibilityCode);
-        return Result.ok(list);
+        return Result.ok(allocationService.queryAfterAllocationForm(year, responsibilityCode,getHospId()));
     }
 }

+ 58 - 1
src/main/resources/mapper/AllocationQueryMapper.xml

@@ -3,7 +3,7 @@
 
 <mapper namespace="com.imed.costaccount.mapper.AllocationQueryMapper">
 
-	<!-- 可根据自己的需求,是否要使用 -->
+    <!-- 可根据自己的需求,是否要使用 -->
     <resultMap type="com.imed.costaccount.model.AllocationQuery" id="allocationQueryMap">
         <result property="id" column="id"/>
         <result property="dateYear" column="date_year"/>
@@ -21,4 +21,61 @@
     </resultMap>
 
 
+    <select id="getTotalMoney" resultType="java.math.BigDecimal">
+        select sum(amount)
+        from cost_allocation_query
+        where date_year = #{dateYear}
+          and date_month = #{month}
+          and hosp_id = #{hospId}
+    </select>
+    <select id="getRespCodeAndName" resultType="com.imed.costaccount.model.vo.CodeAndNameVO">
+        select responsibility_code as code, responsibility_name as name
+        from cost_allocation_query
+        where date_year = #{dateYear}
+          and date_month = #{month}
+          and hosp_id = #{hospId}
+    </select>
+    <select id="getAccountCodeAndName" resultType="com.imed.costaccount.model.vo.CodeAndNameVO">
+        select accounting_code as code, accounting_name as name
+        from cost_allocation_query
+        where date_year = #{dateYear}
+          and date_month = #{month}
+          and hosp_id = #{hospId}
+    </select>
+    <select id="getCountByRespAndAccounts" resultType="java.math.BigDecimal">
+        select IFNULL(sum(amount), 0)
+        from cost_allocation_query
+        where date_year = 2021
+        and date_month = 1
+        and hosp_id = 11
+        and responsibility_code = #{code}
+        and accounting_code in
+        <foreach collection="accountCodes" item="item" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+
+    </select>
+    <select id="getTotalByAccountAndResps" resultType="java.math.BigDecimal">
+        select IFNULL(sum(amount), 0)
+        from cost_allocation_query
+        where date_year = 2021
+        and date_month = 1
+        and hosp_id = 11
+        and accounting_code = #{code}
+        and responsibility_code in
+        <foreach collection="respCodes" item="item" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </select>
+    <select id="getTotalByAccountAndRespCode" resultType="java.math.BigDecimal">
+        select IFNULL(sum(amount), 0)
+        from cost_allocation_query
+        where date_year = 2021
+        and date_month = 1
+        and hosp_id = 11
+        and accounting_code =  #{accountCode}
+        and responsibility_code = #{responsibilityCode}
+    </select>
+
+
 </mapper>