Przeglądaj źródła

Merge branch 'master' of huangrui/CostAccount into dev

lijiaxi 4 lat temu
rodzic
commit
02dfdb5168

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

@@ -110,6 +110,8 @@ public class Allocation implements Serializable {
 
 	private Long shareLevelId;
 
+	private Long targetShareLevelId;
+
 	/**
 	 * 
 	 */

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

@@ -91,7 +91,7 @@ public interface ResponsibilityService extends IService<Responsibility> {
      * @param hospId 医院id
      * @return 责任中心 可能存在null
      */
-    List<Responsibility> getByLevelId(Long levelId, Long hospId);
+    List<Responsibility> getLevelIdByCode(Long levelId, Long hospId);
 
     /**
      * 通过code得到名字
@@ -101,6 +101,6 @@ public interface ResponsibilityService extends IService<Responsibility> {
      */
     String getByCode(String valueResponsibilityCode, Long hospId);
 
-    Long getByLevelId(String responsibilityCode, Long hospId);
+    Long getLevelIdByCode(String responsibilityCode, Long hospId);
 }
 

+ 21 - 14
src/main/java/com/imed/costaccount/service/impl/AllocationServiceImpl.java

@@ -107,7 +107,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
             // 计算方式 0是合并计算  1是分开计算
             Integer calcType = shareLevelVO.getCalcType();
             // 得到该分摊层级下责任中心列表,如果不存在,下一个
-            List<Responsibility> responsibilities = responsibilityService.getByLevelId(levelId, hospId);
+            List<Responsibility> responsibilities = responsibilityService.getLevelIdByCode(levelId, hospId);
             if (responsibilities.isEmpty()) {
                 continue;
             }
@@ -173,13 +173,17 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
                             Allocation targetAllocation = new Allocation();
                             String valueResponsibilityCode = paramValue.getResponsibilityCode();
                             String targetRespName = responsibilityService.getByCode(valueResponsibilityCode, hospId);
+                            Long targetShareLevelId = responsibilityService.getLevelIdByCode(valueResponsibilityCode, hospId);
+                            if (Objects.isNull(targetShareLevelId)) {
+                                throw new CostException("目标责任中心分摊层级异常");
+                            }
                             String shareParamName = shareParamService.getByCode(paramValue.getShareParamCode(), hospId);
                             targetAllocation.setDateMonth(startDTO.getMonth()).setDateYear(startDTO.getYear()).setLevelSort(shareLevelVO.getLeverSort())
                                     .setLevelName(shareLevelVO.getShareName()).setHospId(hospId).setResponsibilityCode(responsibility.getResponsibilityCode())
                                     .setResponsibilityName(responsibility.getResponsibilityName()).setAccountShareId(accountShareId).setAmount(targetAmount)
                                     .setCreateTime(timeMillis).setTargetResponsibilityCode(valueResponsibilityCode).setTargetResponsibilityName(targetRespName)
                                     .setShareParamCode(paramValue.getShareParamCode()).setShareParamName(shareParamName).setTotalAmount(totalAmount).setShareParamValueNum(paramValue.getValueNum())
-                                    .setShareParamRate(numerator.divide(reduce, 4)).setShareLevelId(levelId)
+                                    .setShareParamRate(numerator.divide(reduce, 4)).setShareLevelId(levelId).setTargetShareLevelId(targetShareLevelId)
                             ;
 
                             // todo 目标分摊层级责任中心 就是当前列个表中的责任中心
@@ -224,6 +228,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
     @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 -> {
             Long accountShareId = i.getAccountShareId();
             CostAccountShare byId = accountShareService.getById(accountShareId);
@@ -241,8 +246,9 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
             }
             AllocationQuery allocationQuery = new AllocationQuery();
             allocationQuery.setDateYear(i.getDateYear()).setDateMonth(i.getDateMonth())
-                    .setHospId(hospId).setResponsibilityCode(i.getResponsibilityCode()).setResponsibilityName(i.getResponsibilityName())
-                    .setOriginId(i.getId()).setOriginType(2L).setAmount(i.getAmount())
+                    .setHospId(hospId).setResponsibilityCode(i.getResponsibilityCode())
+                    .setResponsibilityName(i.getResponsibilityName())
+                    .setOriginId(i.getId()).setOriginType(1L).setAmount(i.getAmount())
                     .setAccountingCode(accountingCodes).setAccountingName(accountingNames)
                     .setCreateTime(System.currentTimeMillis())
                     .setLevelSort(i.getLevelSort()).setLevelName(i.getLevelName())
@@ -253,7 +259,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
         costingGroups.forEach(i -> {
             AllocationQuery allocationQuery = new AllocationQuery();
             String responsibilityCode = i.getResponsibilityCode();
-            Long levelId = responsibilityService.getByLevelId(responsibilityCode, hospId);
+            Long levelId = responsibilityService.getLevelIdByCode(responsibilityCode, hospId);
             if (Objects.isNull(levelId)) {
                 throw new CostException("责任中心" + i.getResponsibilityName() + "数据异常");
             }
@@ -263,7 +269,8 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
             }
             allocationQuery.setDateYear(i.getDateYear()).setDateMonth(i.getDateMonth())
                     .setHospId(hospId).setResponsibilityCode(responsibilityCode).setResponsibilityName(i.getResponsibilityName())
-                    .setOriginId(i.getId()).setOriginType(2L).setAmount(i.getAmount()).setAccountingCode(i.getAccountCode()).setAccountingName(i.getAccountName())
+                    .setOriginId(i.getId()).setOriginType(2L).setAmount(i.getAmount())
+                    .setAccountingCode(i.getAccountCode()).setAccountingName(i.getAccountName())
                     .setCreateTime(System.currentTimeMillis())
                     .setLevelSort(byId.getLeverSort()).setLevelName(byId.getShareName())
             ;
@@ -396,18 +403,18 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
     /**
      * 分摊报表导出
      *
-     * @param writer    {@link ExcelWriter}
-     * @param levelSort 分摊层级  就是第几次分摊
-     * @param sheet     报表
-     * @param year      年
-     * @param month     月
+     * @param writer       {@link ExcelWriter}
+     * @param levelSort    分摊层级  就是第几次分摊
+     * @param sheet        报表
+     * @param year         
+     * @param month        
      * @param shareLevelId
      * @return
      */
     @Override
     public ExcelWriter getShareReportTemplate(ExcelWriter writer, Integer levelSort, Sheet sheet, Integer year, Integer month, Long shareLevelId) {
         // 获取数据
-        List<AllocationReportVO> allocationReportVOList = getAllocationReportVOS(levelSort, year, month,shareLevelId);
+        List<AllocationReportVO> allocationReportVOList = getAllocationReportVOS(levelSort, year, month, shareLevelId);
         // 设置导出
         Map<String, List<AllocationReportVO>> responsibilityMap = allocationReportVOList.stream().collect(Collectors.groupingBy(AllocationReportVO::getResponsibilityCode));
         Map<String, List<AllocationReportVO>> targetResponsibilityMap = allocationReportVOList.stream().collect(Collectors.groupingBy(AllocationReportVO::getTargetResponsibilityCode));
@@ -606,14 +613,14 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
      * @param month
      * @return
      */
-    private List<AllocationReportVO> getAllocationReportVOS(Integer levelSort, Integer year, Integer month,Long shareLevelId) {
+    private List<AllocationReportVO> getAllocationReportVOS(Integer levelSort, Integer year, Integer month, Long shareLevelId) {
         Long hospId = UserContext.getHospId();
         if (Objects.isNull(levelSort) || Objects.isNull(year) || Objects.isNull(month)) {
             throw new CostException(500, "参数异常");
         }
         // 处理第几次分摊计算值
         List<Allocation> allocationList = baseMapper.selectList(new QueryWrapper<Allocation>().lambda()
-                .eq(Allocation::getHospId, hospId).eq(Allocation::getLevelSort, levelSort).eq(Allocation::getShareLevelId,shareLevelId).eq(Allocation::getDateYear, year)
+                .eq(Allocation::getHospId, hospId).eq(Allocation::getLevelSort, levelSort).eq(Allocation::getShareLevelId, shareLevelId).eq(Allocation::getDateYear, year)
                 .eq(Allocation::getDateMonth, month));
         // 找会计科室的时候使用的
         List<Allocation> allocations = baseMapper.selectList(new QueryWrapper<Allocation>().lambda()

+ 2 - 2
src/main/java/com/imed/costaccount/service/impl/ResponsibilityServiceImpl.java

@@ -491,7 +491,7 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
      * @return 责任中心 可能存在null
      */
     @Override
-    public List<Responsibility> getByLevelId(Long levelId, Long hospId) {
+    public List<Responsibility> getLevelIdByCode(Long levelId, Long hospId) {
         return this.list(
                 new LambdaQueryWrapper<Responsibility>()
                         .in(Responsibility::getShareId, levelId)
@@ -522,7 +522,7 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
     }
 
     @Override
-    public Long getByLevelId(String responsibilityCode, Long hospId) {
+    public Long getLevelIdByCode(String responsibilityCode, Long hospId) {
         Responsibility one = this.getOne(
                 new LambdaQueryWrapper<Responsibility>()
                         .eq(Responsibility::getResponsibilityCode, responsibilityCode)

+ 1 - 0
src/main/resources/mapper/AllocationMapper.xml

@@ -26,6 +26,7 @@
         <result property="levelSort" column="level_sort"/>
         <result property="levelName" column="level_name"/>
         <result property="shareLevelId" column="share_level_id"/>
+        <result property="targetShareLevelId" column="target_share_level_id"/>
         <result property="createTime" column="create_time"/>
         <result property="deleteTime" column="delete_time"/>
     </resultMap>