浏览代码

Merge branch 'master' of huangrui/CostAccount into dev

lijiaxi 4 年之前
父节点
当前提交
7ec16adfb8

+ 47 - 1
src/main/java/com/imed/costaccount/mapper/AllocationMapper.java

@@ -2,7 +2,12 @@ package com.imed.costaccount.mapper;
 
 
 import com.imed.costaccount.model.Allocation;
 import com.imed.costaccount.model.Allocation;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.imed.costaccount.model.vo.AfterAllocationVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
+import java.util.List;
 
 
 /**
 /**
  * 成本分摊后表
  * 成本分摊后表
@@ -12,5 +17,46 @@ import org.apache.ibatis.annotations.Mapper;
  */
  */
 @Mapper
 @Mapper
 public interface AllocationMapper extends BaseMapper<Allocation> {
 public interface AllocationMapper extends BaseMapper<Allocation> {
-	
+
+    /**
+     * 分摊后查询列表
+     * @param dateYear 年
+     * @param dateMonth 月
+     * @param responsibilityCode 责任中心
+     * @param startIndex 开始索引
+     * @param pageSize 页数
+     * @param hospId 医院id
+     * @return List
+     */
+    List<AfterAllocationVO> queryAfterAllocationList(@Param("dateYear") Integer dateYear,
+                                                     @Param("dateMonth") Integer dateMonth,
+                                                     @Param("responsibilityCode") String responsibilityCode,
+                                                     @Param("startIndex") Integer startIndex,
+                                                     @Param("pageSize") Integer pageSize, Long hospId);
+
+    /**
+     * 总数
+     * @param dateYear 年
+     * @param dateMonth 月
+     * @param responsibilityCode 责任中心
+     * @param hospId 医院id
+     * @return 总数
+     */
+    int queryAfterAllocationListCount(@Param("dateYear") Integer dateYear,
+                                      @Param("dateMonth") Integer dateMonth,
+                                      @Param("responsibilityCode") String responsibilityCode,
+                                      @Param("hospId") Long hospId);
+
+    /**
+     * 总金额
+     * @param dateYear 年
+     * @param dateMonth 月
+     * @param responsibilityCode 责任中心
+     * @param hospId 医院id
+     * @return 总数
+     */
+    BigDecimal queryAfterAllocationListSum(@Param("dateYear") Integer dateYear,
+                                           @Param("dateMonth") Integer dateMonth,
+                                           @Param("responsibilityCode") String responsibilityCode,
+                                           @Param("hospId") Long hospId);
 }
 }

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

@@ -77,10 +77,37 @@ public class Allocation implements Serializable {
 	 */
 	 */
 	private Long createTime;
 	private Long createTime;
 
 
+	/**
+	 * 目标责任中心
+	 */
 	private String targetResponsibilityCode;
 	private String targetResponsibilityCode;
+
+	/**
+	 * 目标责任中心名称
+	 */
 	private String targetResponsibilityName;
 	private String targetResponsibilityName;
+
+	/**
+	 * 分摊参数代码
+	 */
 	private String shareParamCode;
 	private String shareParamCode;
+	/**
+	 * 分摊参数名称
+	 */
 	private String shareParamName;
 	private String shareParamName;
+	/**
+	 * 分摊参数数值
+	 */
+	private BigDecimal shareParamValueNum;
+	/**
+	 * 成本金额
+	 */
+	private BigDecimal totalAmount;
+	/**
+	 * 分摊参数比例
+	 */
+	private BigDecimal shareParamRate;
+
 	/**
 	/**
 	 * 
 	 * 
 	 */
 	 */

+ 80 - 0
src/main/java/com/imed/costaccount/model/vo/AfterAllocationVO.java

@@ -0,0 +1,80 @@
+package com.imed.costaccount.model.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+@ApiModel("分摊后查询对象")
+public class AfterAllocationVO {
+
+     @ApiModelProperty(name = "",value = "")
+     private Long id;
+
+     @ApiModelProperty(name = "dateYear",value = "年")
+     private Integer dateYear;
+     /**
+      * 月
+      */
+     @ApiModelProperty(name = "dateMonth",value = "月")
+     private Integer dateMonth;
+
+     @ApiModelProperty(name = "levelSort",value = "分摊层级序号")
+     private Integer levelSort;
+
+     @ApiModelProperty(name = "levelName",value = "分摊层级数名称")
+     private String levelName;
+     /**
+      * 责任中心代码
+      */
+     @ApiModelProperty(name = "responsibilityCode",value = "责任中心代码")
+     private String responsibilityCode;
+     /**
+      * 责任中心名称
+      */
+     @ApiModelProperty(name = "responsibilityName",value = "责任中心名称")
+     private String responsibilityName;
+
+
+     /**
+      * 分摊得到的钱
+      */
+     @ApiModelProperty(name = "amount",value = "分摊得到的钱")
+     private BigDecimal amount;
+
+     /**
+      * 目标责任中心
+      */
+     @ApiModelProperty(name = "targetResponsibilityCode",value = "目标责任中心")
+     private String targetResponsibilityCode;
+
+     /**
+      * 目标责任中心名称
+      */
+     @ApiModelProperty(name = "targetResponsibilityName",value = "目标责任中心名称")
+     private String targetResponsibilityName;
+
+     /**
+      * 分摊参数代码
+      */
+     @ApiModelProperty(name = "shareParamCode",value = "分摊参数代码")
+     private String shareParamCode;
+     /**
+      * 分摊参数名称
+      */
+     @ApiModelProperty(name = "shareParamName",value = "分摊参数名称")
+     private String shareParamName;
+     /**
+      * 分摊参数数值
+      */
+     @ApiModelProperty(name = "shareParamValueNum",value = "分摊参数数值")
+     private BigDecimal shareParamValueNum;
+     /**
+      * 分摊参数比例
+      */
+     @ApiModelProperty(name = "分摊参数比例",value = "shareParamRate")
+     private BigDecimal shareParamRate;
+
+}

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

@@ -1,11 +1,10 @@
 package com.imed.costaccount.service;
 package com.imed.costaccount.service;
 
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.model.dto.StartDTO;
 import com.imed.costaccount.model.dto.StartDTO;
 import com.imed.costaccount.model.Allocation;
 import com.imed.costaccount.model.Allocation;
 
 
-import java.util.Map;
-
 /**
 /**
  * 成本分摊后表
  * 成本分摊后表
  *
  *
@@ -21,5 +20,18 @@ public interface AllocationService extends IService<Allocation> {
      * @param hospId 医院id
      * @param hospId 医院id
      */
      */
     void startAllocation(StartDTO startDTO, Long hospId);
     void startAllocation(StartDTO startDTO, Long hospId);
+
+
+    /**
+     * 分摊后查询列表
+     * @param year 年月 (yyyy-MM-dd)
+     * @param responsibilityCode 责任中心代码
+     * @param current 当前页
+     * @param pageSize 当前页展示的数据大小
+     * @param hospId 医院id
+     * @return PageUtils
+     */
+    PageUtils queryAfterAllocation(String year, String responsibilityCode, Integer current, Integer pageSize, Long hospId);
+
 }
 }
 
 

+ 1 - 6
src/main/java/com/imed/costaccount/service/CostCostingGroupService.java

@@ -52,12 +52,7 @@ public interface CostCostingGroupService extends IService<CostCostingGroup> {
      */
      */
     PageUtils queryAllocation(Integer current, Integer pageSize, String date, Long hospId);
     PageUtils queryAllocation(Integer current, Integer pageSize, String date, Long hospId);
 
 
-    /**
-     * 开始归集代码
-     * @param startDTO {@link StartDTO}
-     * @param hospId 医院id
-     */
-    void startAllocation(StartDTO startDTO, Long hospId);
+
 
 
     /**
     /**
      * 得到这个月的所有导入的成本数据
      * 得到这个月的所有导入的成本数据

+ 35 - 9
src/main/java/com/imed/costaccount/service/impl/AllocationServiceImpl.java

@@ -1,15 +1,19 @@
 package com.imed.costaccount.service.impl;
 package com.imed.costaccount.service.impl;
 
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.imed.costaccount.common.exception.CostException;
 import com.imed.costaccount.common.exception.CostException;
 import com.imed.costaccount.common.util.JacksonUtil;
 import com.imed.costaccount.common.util.JacksonUtil;
+import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.mapper.AllocationMapper;
 import com.imed.costaccount.mapper.AllocationMapper;
 import com.imed.costaccount.model.*;
 import com.imed.costaccount.model.*;
 import com.imed.costaccount.model.dto.StartDTO;
 import com.imed.costaccount.model.dto.StartDTO;
 import com.imed.costaccount.model.vo.AccountShareVO;
 import com.imed.costaccount.model.vo.AccountShareVO;
+import com.imed.costaccount.model.vo.AfterAllocationVO;
 import com.imed.costaccount.model.vo.CostShareLevelVO;
 import com.imed.costaccount.model.vo.CostShareLevelVO;
 import com.imed.costaccount.service.*;
 import com.imed.costaccount.service.*;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -19,7 +23,6 @@ import org.springframework.transaction.annotation.Transactional;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 
 
 
 @Service("allocationService")
 @Service("allocationService")
@@ -137,11 +140,6 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
                         // 本次的分摊比例计算
                         // 本次的分摊比例计算
                         BigDecimal thisAmount = rate.multiply(totalAmount);
                         BigDecimal thisAmount = rate.multiply(totalAmount);
 
 
-//                        Allocation allocation = new Allocation();
-//                        allocation.setDateMonth(startDTO.getMonth()).setDateYear(startDTO.getYear()).setLevelSort(shareLevelVO.getLeverSort())
-//                                .setLevelName(shareLevelVO.getShareName()).setHospId(hospId).setResponsibilityCode(responsibilityCode).setResponsibilityName(responsibility.getResponsibilityName())
-//                                .setAccountShareId(accountShareId).setAmount(thisAmount).setCreateTime(System.currentTimeMillis());
-//                        allocations.add(allocation);
 
 
                         // 得到目标层级责任中心列表
                         // 得到目标层级责任中心列表
                         List<Responsibility> targetResponsibilities = this.getTargetResponsibility(targetLevel, hospId, shareLevelVO.getLeverSort());
                         List<Responsibility> targetResponsibilities = this.getTargetResponsibility(targetLevel, hospId, shareLevelVO.getLeverSort());
@@ -168,7 +166,8 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
                                     .setLevelName(shareLevelVO.getShareName()).setHospId(hospId).setResponsibilityCode(responsibility.getResponsibilityCode())
                                     .setLevelName(shareLevelVO.getShareName()).setHospId(hospId).setResponsibilityCode(responsibility.getResponsibilityCode())
                                     .setResponsibilityName(responsibility.getResponsibilityName()).setAccountShareId(accountShareId).setAmount(targetAmount)
                                     .setResponsibilityName(responsibility.getResponsibilityName()).setAccountShareId(accountShareId).setAmount(targetAmount)
                                     .setCreateTime(System.currentTimeMillis()).setTargetResponsibilityCode(valueResponsibilityCode).setTargetResponsibilityName(targetRespName)
                                     .setCreateTime(System.currentTimeMillis()).setTargetResponsibilityCode(valueResponsibilityCode).setTargetResponsibilityName(targetRespName)
-                                    .setShareParamCode(paramValue.getShareParamCode()).setShareParamName(shareParamName)
+                                    .setShareParamCode(paramValue.getShareParamCode()).setShareParamName(shareParamName).setTotalAmount(totalAmount).setShareParamValueNum(paramValue.getValueNum())
+                                    .setShareParamRate(numerator.divide(reduce, 4))
                             ;
                             ;
                             // todo 目标分摊层级责任中心 就是当前列个表中的责任中心
                             // todo 目标分摊层级责任中心 就是当前列个表中的责任中心
                             allocations.add(targetAllocation);
                             allocations.add(targetAllocation);
@@ -203,7 +202,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
      *
      *
      * @return
      * @return
      */
      */
-    private BigDecimal getCostAmount(CostAccountShare accountShare, Integer calcType, Map<String, List<CostCostingGroup>> map,List<Allocation> costList) {
+    private BigDecimal getCostAmount(CostAccountShare accountShare, Integer calcType, Map<String, List<CostCostingGroup>> map, List<Allocation> costList) {
         // 是否包含分摊成本 0不包含 1 包含
         // 是否包含分摊成本 0不包含 1 包含
         Integer isShareCost = accountShare.getIsShareCost();
         Integer isShareCost = accountShare.getIsShareCost();
         String accountingCodes = accountShare.getAccountingCodes();
         String accountingCodes = accountShare.getAccountingCodes();
@@ -214,7 +213,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
         }
         }
         // 计算方式 0是合并计算  1是分开计算
         // 计算方式 0是合并计算  1是分开计算
         BigDecimal costAmount = BigDecimal.ZERO;
         BigDecimal costAmount = BigDecimal.ZERO;
-        List<Allocation> all=new ArrayList<>();
+        List<Allocation> all = new ArrayList<>();
         if (!costList.isEmpty()) {
         if (!costList.isEmpty()) {
             all = costList.stream().filter(i -> i.getTargetResponsibilityCode().equals(responsibilityCode)).collect(Collectors.toList());
             all = costList.stream().filter(i -> i.getTargetResponsibilityCode().equals(responsibilityCode)).collect(Collectors.toList());
 //            Stream<Allocation> allocationStream = costList.stream().filter(i -> i.getTargetResponsibilityCode().equals(responsibilityCode));
 //            Stream<Allocation> allocationStream = costList.stream().filter(i -> i.getTargetResponsibilityCode().equals(responsibilityCode));
@@ -279,4 +278,31 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
         List<Long> shareLevelIds = shareLevels.stream().map(CostShareLevel::getId).collect(Collectors.toList());
         List<Long> shareLevelIds = shareLevels.stream().map(CostShareLevel::getId).collect(Collectors.toList());
         return responsibilityService.getByLevelIds(shareLevelIds, hospId);
         return responsibilityService.getByLevelIds(shareLevelIds, hospId);
     }
     }
+
+
+    /**
+     * 分摊后查询列表
+     *
+     * @param year               年月 (yyyy-MM-dd)
+     * @param responsibilityCode 责任中心代码
+     * @param current            当前页
+     * @param pageSize           当前页展示的数据大小
+     * @param hospId             医院id
+     * @return PageUtils
+     */
+    @Override
+    public PageUtils queryAfterAllocation(String year, String responsibilityCode, Integer current, Integer pageSize, Long hospId) {
+        Integer dateYear = null;
+        Integer dateMonth = null;
+        if (StrUtil.isNotBlank(year)) {
+            DateTime dateTime = DateUtil.parseDate(year);
+            dateYear = DateUtil.year(dateTime);
+            dateMonth = DateUtil.month(dateTime) + 1;
+        }
+        Integer startIndex = (current - 1) * pageSize;
+        List<AfterAllocationVO> list = baseMapper.queryAfterAllocationList(dateYear, dateMonth, responsibilityCode, startIndex, pageSize, hospId);
+        int totalCount = baseMapper.queryAfterAllocationListCount(dateYear, dateMonth, responsibilityCode, hospId);
+        BigDecimal sum = baseMapper.queryAfterAllocationListSum(dateYear, dateMonth, responsibilityCode, hospId);
+        return new PageUtils(list, totalCount, pageSize, current, sum);
+    }
 }
 }

+ 7 - 201
src/main/java/com/imed/costaccount/service/impl/CostCostingGroupServiceImpl.java

@@ -1,6 +1,5 @@
 package com.imed.costaccount.service.impl;
 package com.imed.costaccount.service.impl;
 
 
-import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
@@ -12,9 +11,9 @@ import com.imed.costaccount.common.exception.CostException;
 import com.imed.costaccount.common.util.*;
 import com.imed.costaccount.common.util.*;
 import com.imed.costaccount.constants.NumberConstant;
 import com.imed.costaccount.constants.NumberConstant;
 import com.imed.costaccount.enums.DateStyleEnum;
 import com.imed.costaccount.enums.DateStyleEnum;
+import com.imed.costaccount.mapper.AllocationMapper;
 import com.imed.costaccount.mapper.CostCostingGroupMapper;
 import com.imed.costaccount.mapper.CostCostingGroupMapper;
 import com.imed.costaccount.model.*;
 import com.imed.costaccount.model.*;
-import com.imed.costaccount.model.dto.StartDTO;
 import com.imed.costaccount.model.vo.*;
 import com.imed.costaccount.model.vo.*;
 import com.imed.costaccount.service.*;
 import com.imed.costaccount.service.*;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
@@ -26,7 +25,6 @@ import org.springframework.web.multipart.MultipartFile;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.*;
-import java.util.stream.Collectors;
 
 
 
 
 @Service("costCostingGroupService")
 @Service("costCostingGroupService")
@@ -43,36 +41,20 @@ public class CostCostingGroupServiceImpl extends ServiceImpl<CostCostingGroupMap
 
 
     private final ResponsibilityService responsibilityService;
     private final ResponsibilityService responsibilityService;
 
 
-    private final CostCostingCollectionService costingCollectionService;
+    private final AllocationMapper allocationMapper;
 
 
-    private final CostShareLevelService shareLevelService;
-
-    private final CostAccountShareService accountShareService;
-
-    private final ShareParamValueService shareParamValueService;
-
-    private final CostShareParamService shareParamService;
 
 
     public CostCostingGroupServiceImpl(CostIncomeGroupServiceImpl costIncomeGroupService,
     public CostCostingGroupServiceImpl(CostIncomeGroupServiceImpl costIncomeGroupService,
                                        AccountingService accountingService,
                                        AccountingService accountingService,
                                        AccountingProductService accountingProductService,
                                        AccountingProductService accountingProductService,
                                        CostIncomeFileService costIncomeFileService,
                                        CostIncomeFileService costIncomeFileService,
-                                       ResponsibilityService responsibilityService,
-                                       CostCostingCollectionService costingCollectionService,
-                                       CostShareLevelService shareLevelService,
-                                       CostAccountShareService accountShareService,
-                                       ShareParamValueService shareParamValueService,
-                                       CostShareParamService shareParamService) {
+                                       ResponsibilityService responsibilityService, AllocationMapper allocationMapper) {
         this.costIncomeGroupService = costIncomeGroupService;
         this.costIncomeGroupService = costIncomeGroupService;
         this.accountingService = accountingService;
         this.accountingService = accountingService;
         this.accountingProductService = accountingProductService;
         this.accountingProductService = accountingProductService;
         this.costIncomeFileService = costIncomeFileService;
         this.costIncomeFileService = costIncomeFileService;
         this.responsibilityService = responsibilityService;
         this.responsibilityService = responsibilityService;
-        this.costingCollectionService = costingCollectionService;
-        this.shareLevelService = shareLevelService;
-        this.accountShareService = accountShareService;
-        this.shareParamValueService = shareParamValueService;
-        this.shareParamService = shareParamService;
+        this.allocationMapper = allocationMapper;
     }
     }
 
 
     /**
     /**
@@ -130,9 +112,9 @@ public class CostCostingGroupServiceImpl extends ServiceImpl<CostCostingGroupMap
 
 
         List<AllocationVO> list = baseMapper.queryAllocation(startIndex, pageSize, year, month, hospId);
         List<AllocationVO> list = baseMapper.queryAllocation(startIndex, pageSize, year, month, hospId);
         list.forEach(i -> {
         list.forEach(i -> {
-            List<CostCostingCollection> collections = costingCollectionService.list(new LambdaQueryWrapper<CostCostingCollection>().eq(CostCostingCollection::getYear, i.getYear())
-                    .eq(CostCostingCollection::getMonth, i.getMonth())
-                    .eq(CostCostingCollection::getHospId, hospId)
+            List<Allocation> collections = allocationMapper.selectList(new LambdaQueryWrapper<Allocation>().eq(Allocation::getDateYear, i.getYear())
+                    .eq(Allocation::getDateMonth, i.getMonth())
+                    .eq(Allocation::getHospId, hospId)
             );
             );
             if (!collections.isEmpty()) {
             if (!collections.isEmpty()) {
                 i.setIsAllocation(true);
                 i.setIsAllocation(true);
@@ -142,182 +124,6 @@ public class CostCostingGroupServiceImpl extends ServiceImpl<CostCostingGroupMap
         return new PageUtils(list, count, pageSize, current);
         return new PageUtils(list, count, pageSize, current);
     }
     }
 
 
-    /**
-     * 开始成本分摊
-     *
-     * @param startDTO {@link StartDTO}
-     * @param hospId   医院id
-     */
-    @Override
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
-    public void startAllocation(StartDTO startDTO, Long hospId) {
-        // 这个月成本数据数据
-        List<CostCostingGroup> list = this.list(
-                new LambdaQueryWrapper<CostCostingGroup>()
-                        .eq(CostCostingGroup::getDateYear, startDTO.getYear())
-                        .eq(CostCostingGroup::getDateMonth, startDTO.getMonth())
-                        .eq(CostCostingGroup::getHospId, hospId)
-        );
-        // 没有重新导入
-        if (list.isEmpty()) {
-            throw new CostException("本月成本数据暂未导入");
-        }
-
-        Map<String, List<CostCostingGroup>> responsibilityCodeMap = list.stream().collect(Collectors.groupingBy(CostCostingGroup::getResponsibilityCode));
-        Set<String> responsibilityCodes = responsibilityCodeMap.keySet();
-        for (String responsibilityCode : responsibilityCodes) {
-
-        }
-
-
-//        // 得到这个月导入的成本分摊参数值数据
-//        List<ShareParamValue> shareParamValues = shareParamValueService.list(
-//                new LambdaQueryWrapper<ShareParamValue>()
-//                        .eq(ShareParamValue::getHospId, hospId)
-//                        .eq(ShareParamValue::getDateYear, startDTO.getYear())
-//                        .eq(ShareParamValue::getDateMonth, startDTO.getMonth())
-//        );
-//        // 没有重新导入
-//        if (shareParamValues.isEmpty()) {
-//            throw new CostException("本月分摊参数值数据未导入");
-//        }
-//        // 通过会计科目聚合月成本数据
-//        Map<String, List<CostCostingGroup>> accountMap = list.stream().collect(Collectors.groupingBy(CostCostingGroup::getAccountCode));
-//
-//        // 删除该年月已经过的数据
-//        costingCollectionService.remove(
-//                new LambdaQueryWrapper<CostCostingCollection>()
-//                        .eq(CostCostingCollection::getYear, startDTO.getYear())
-//                        .eq(CostCostingCollection::getMonth, startDTO.getMonth())
-//                        .eq(CostCostingCollection::getHospId, hospId)
-//        );
-//        // 得到这个医院所有的分摊层级(通过sort_level正序排序的数据)
-//        List<CostShareLevelVO> shareLevelVOs = shareLevelService.getAll(hospId);
-//        if (CollUtil.isEmpty(shareLevelVOs)) {
-//            throw new CostException("请先设置医院分摊层级");
-//        }
-//        List<CostCostingCollection> costingCollections = new ArrayList<>();
-//        // 遍历这个医院的分摊层级
-//        for (int i = 0; i < shareLevelVOs.size(); i++) {
-//            // 最后一层不分摊
-//            if (i == shareLevelVOs.size() - 1) {
-//                break;
-//            }
-//            // 通过分摊层级id 得到对应的责任中心
-//            CostShareLevelVO shareLevelVO = shareLevelVOs.get(i);
-//            Responsibility responsibility = responsibilityService.getByLevelId(shareLevelVO.getId(), hospId);
-//            // 如果这个分摊层级没有责任中心那么不分摊
-//            if (Objects.isNull(responsibility)) {
-//                continue;
-//            }
-//            // 通过责任中心code去得到分摊参数对应信息 并得到对应的会计科目和对应的分摊参数比例等信息
-//            List<CostAccountShare> accountShares = accountShareService.getByResponsibility(responsibility.getResponsibilityCode(), hospId);
-//            if (accountShares.isEmpty()) {
-//                continue;
-//            }
-//            // 遍历分摊参数对应信息
-//            for (CostAccountShare accountShare : accountShares) {
-//                // 得到对应的会计中心code
-//                String accountingCodes = accountShare.getAccountingCodes();
-//                // 没有会计中心,合并计算未设置好分摊参数比例
-//                if (StrUtil.isBlank(accountingCodes) && shareLevelVO.getCalcType().equals(1)) {
-//                    throw new CostException("责任中心:" + accountShare.getResponsibilityName() + ";会计中心为:" + accountShare.getAccountingNames() + ";未设置分摊参数比例");
-//                }
-//                // 会计科目不存在且是合并计算,这种情况直接分摊下去
-//                String paramList = accountShare.getParamList();
-//                if (StrUtil.isBlank(paramList)) {
-//                    throw new CostException("责任中心:" + accountShare.getResponsibilityName() + ";会计中心为:" + accountShare.getAccountingNames() + (";未设置分摊参数比例值"));
-//                }
-//                // 分摊参数以及比例集合
-//                List<AccountShareVO> accountShareVOs = JacksonUtil.str2ObjList(paramList, List.class, AccountShareVO.class);
-//                // 没有会计中心直接分摊的情况
-//                if (StrUtil.isBlank(accountingCodes) && shareLevelVO.getCalcType().equals(0)) {
-//                    // 直接分摊到责任中心去 这情况只有一个分摊计划
-//                    AccountShareVO accountShareVO = accountShareVOs.get(0);
-//                    Long shareParamId = accountShareVO.getId();
-//                    CostShareParam shareParam = shareParamService.getByIdAndCalcType(shareParamId);
-//                    if (Objects.isNull(shareParam)) {
-//                        continue;
-//                    }
-//                    String accountCodeStr = shareParam.getAccountingCodes();
-//                    if (StrUtil.isBlank(accountCodeStr)) {
-//                        throw new CostException("成本分摊参数:" + shareParam.getShareParamName() + ";设置会计科目不存在");
-//                    }
-//                    ArrayList<String> accountCodes = CollUtil.newArrayList(accountCodeStr.split(StrUtil.COMMA));
-//                    String shareParamPout = accountShareVO.getShareParamPopout();
-//                    BigDecimal rate = new BigDecimal("1");
-//                    if (!"100".equals(shareParamPout)) {
-//                        rate = new BigDecimal("0." + shareParamPout);
-//                    }
-//                    // 计算分摊数值
-//                    BigDecimal valueNum = shareParamValues.stream().map(ShareParamValue::getValueNum).reduce(BigDecimal.ZERO, BigDecimal::add);
-//                    for (String accountCode : accountCodes) {
-//                        Accounting account = this.getAccountByCode(accountCode, hospId);
-//                        List<CostCostingGroup> costCostingGroups = accountMap.get(accountCode);
-//                        if (CollUtil.isEmpty(costCostingGroups)) {
-//                            continue;
-//                        }
-//                        BigDecimal accountCodeAmount = costCostingGroups.stream().map(CostCostingGroup::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
-//                        CostCostingCollection collection = new CostCostingCollection();
-//                        collection.setYear(startDTO.getYear()).setMonth(startDTO.getMonth()).setResponsibilityCode(accountShare.getResponsibilityCode())
-//                                .setResponsibilityName(accountShare.getResponsibilityName()).setLeverSort(shareLevelVO.getLeverSort())
-//                                .setShareLevelName(shareLevelVO.getShareName()).setAccountCode(accountCode).setAccountName(account.getAccountingName())
-//                                .setIsBaseCost(account.getIsBaseCost()).setAmount(accountCodeAmount).setCreateTime(System.currentTimeMillis())
-//                                .setHospId(hospId).setShareParam(accountShareVO.getShareParamName()).setShareParamProportion(rate.toString())
-//                                .setShareValue(valueNum)
-//                                // 目标分摊层级暂不处理
-//                                //.setTargetResponsibilityCode().setTargetResponsibilityName()
-//                                .setShareAmount(rate.multiply(accountCodeAmount));
-//                        costingCollections.add(collection);
-//                    }
-//                    continue;
-//                }
-//                // 责任中心对应的会计科目代码列表
-//                ArrayList<String> accountCodeList = CollUtil.newArrayList(accountingCodes.split(StrUtil.COMMA));
-//                for (String accountCode : accountCodeList) {
-//                    // 分摊前数据 通过会计科目得到
-//                    List<CostCostingGroup> costCostingGroups = accountMap.get(accountCode);
-//
-//                    if (CollUtil.isEmpty(costCostingGroups)) {
-//                        continue;
-//                    }
-//                    BigDecimal accountCodeAmount = costCostingGroups.stream().map(CostCostingGroup::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
-//                    Accounting accounting = this.getAccountByCode(accountCode, hospId);
-//                    if (StrUtil.isBlank(paramList)) {
-//                        throw new CostException("未设置分摊参数比例值");
-//                    }
-//                    // 分摊比例相关数据
-//                    if (CollUtil.isEmpty(accountShareVOs)) {
-//                        throw new CostException("分摊参数对应比例错误");
-//                    }
-//                    for (AccountShareVO accountShareVO : accountShareVOs) {
-//                        CostCostingCollection collection = new CostCostingCollection();
-//                        String shareParamPout = accountShareVO.getShareParamPopout();
-//                        BigDecimal rate = new BigDecimal("1");
-//                        if (!"100".equals(shareParamPout)) {
-//                            rate = new BigDecimal("0." + shareParamPout);
-//                        }
-//                        // 计算分摊数值
-//                        BigDecimal valueNum = shareParamValues.stream().map(ShareParamValue::getValueNum).reduce(BigDecimal.ZERO, BigDecimal::add);
-//                        collection.setYear(startDTO.getYear()).setMonth(startDTO.getMonth()).setResponsibilityCode(accountShare.getResponsibilityCode())
-//                                .setResponsibilityName(accountShare.getResponsibilityName()).setLeverSort(shareLevelVO.getLeverSort())
-//                                .setShareLevelName(shareLevelVO.getShareName()).setAccountCode(accountCode).setAccountName(accounting.getAccountingName())
-//                                .setIsBaseCost(accounting.getIsBaseCost()).setAmount(accountCodeAmount).setCreateTime(System.currentTimeMillis())
-//                                .setHospId(hospId).setShareParam(accountShareVO.getShareParamName()).setShareParamProportion(rate.toString())
-//                                .setShareValue(valueNum)
-//                                // 目标分摊层级暂不处理
-//                                //.setTargetResponsibilityCode().setTargetResponsibilityName()
-//                                .setShareAmount(rate.multiply(accountCodeAmount));
-//                        costingCollections.add(collection);
-////                        costingCollectionService.save(collection);
-//                    }
-//
-//                }
-//            }
-//        }
-//        log.info("list:{}", costingCollections);
-//        costingCollectionService.saveBatch(costingCollections);
-    }
 
 
     /**
     /**
      * 通过code获取名称
      * 通过code获取名称

+ 1 - 1
src/main/java/com/imed/costaccount/service/impl/ReportFormServiceImpl.java

@@ -64,7 +64,7 @@ public class ReportFormServiceImpl extends ServiceImpl<ReportFormMapper, ReportF
                 reportFormVO.setShowAddRelation(1);
                 reportFormVO.setShowAddRelation(1);
             } else if (i.getCalcType() == 2) {
             } else if (i.getCalcType() == 2) {
                 reportFormVO.setShowAddRelation(2);
                 reportFormVO.setShowAddRelation(2);
-            } else if (i.getCalcType() == 3) {
+            } else if (i.getCalcType() == 5) {
                 reportFormVO.setShowAddRelation(3);
                 reportFormVO.setShowAddRelation(3);
             }
             }
             return reportFormVO;
             return reportFormVO;

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

@@ -70,11 +70,28 @@ public class CostCostingGroupController extends AbstractController {
         return Result.ok(pageUtils);
         return Result.ok(pageUtils);
     }
     }
 
 
-    @ApiOperation("开始归集")
+    @ApiOperation("开始分摊")
     @PostMapping("/startAllocation")
     @PostMapping("/startAllocation")
     public Result startAllocation(@RequestBody @Valid StartDTO startDTO) {
     public Result startAllocation(@RequestBody @Valid StartDTO startDTO) {
 //        costCostingGroupService.startAllocation(startDTO, getHospId());
 //        costCostingGroupService.startAllocation(startDTO, getHospId());
         allocationService.startAllocation(startDTO,getHospId());
         allocationService.startAllocation(startDTO,getHospId());
         return Result.ok();
         return Result.ok();
     }
     }
+
+    @ApiOperation("分摊后列表")
+    @GetMapping("/queryAfterAllocation")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "year",value = "年月日(yyyy-MM-dd)"),
+            @ApiImplicitParam(name = "responsibilityCode",value = "责任中心代码"),
+            @ApiImplicitParam(name = "current",value = "每页数据大小"),
+            @ApiImplicitParam(name = "pageSize",value = "每页数据大小")
+    })
+    public Result queryAfterAllocation(@RequestParam(value = "year", required = false) String year,
+                                       @RequestParam(value = "responsibilityCode", required = false) String responsibilityCode,
+                                       @RequestParam(value = "current", defaultValue = "1", required = false) Integer current,
+                                       @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize) {
+        PageUtils pageUtils = allocationService.queryAfterAllocation(year, responsibilityCode, current, pageSize,getHospId());
+        return Result.ok(pageUtils);
+    }
+
 }
 }

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

@@ -3,7 +3,7 @@
 
 
 <mapper namespace="com.imed.costaccount.mapper.AllocationMapper">
 <mapper namespace="com.imed.costaccount.mapper.AllocationMapper">
 
 
-	<!-- 可根据自己的需求,是否要使用 -->
+    <!-- 可根据自己的需求,是否要使用 -->
     <resultMap type="com.imed.costaccount.model.Allocation" id="allocationMap">
     <resultMap type="com.imed.costaccount.model.Allocation" id="allocationMap">
         <result property="id" column="id"/>
         <result property="id" column="id"/>
         <result property="dateYear" column="date_year"/>
         <result property="dateYear" column="date_year"/>
@@ -19,10 +19,41 @@
         <result property="targetResponsibilityName" column="target_responsibility_name"/>
         <result property="targetResponsibilityName" column="target_responsibility_name"/>
         <result property="shareParamCode" column="share_param_code"/>
         <result property="shareParamCode" column="share_param_code"/>
         <result property="shareParamName" column="share_param_name"/>
         <result property="shareParamName" column="share_param_name"/>
+        <result property="totalAmount" column="total_amount"/>
+        <result property="shareParamValueNum" column="share_param_value_num"/>
+        <result property="shareParamRate" column="share_param_rate"/>
         <result property="isBaseCost" column="is_base_cost"/>
         <result property="isBaseCost" column="is_base_cost"/>
         <result property="createTime" column="create_time"/>
         <result property="createTime" column="create_time"/>
         <result property="deleteTime" column="delete_time"/>
         <result property="deleteTime" column="delete_time"/>
     </resultMap>
     </resultMap>
+    <select id="queryAfterAllocationList" resultType="com.imed.costaccount.model.vo.AfterAllocationVO">
+        select * from cost_allocation where delete_time = 0 and hosp_id = #{hospId}
+        <if test="dateYear != null">
+            and date_year = #{dateYear} and date_month = #{dateMonth}
+        </if>
+        <if test="responsibilityCode != null and responsibilityCode != ''">
+            and responsibility_code =  #{responsibilityCode}
+        </if>
+        limit #{startIndex},#{pageSize}
+    </select>
+    <select id="queryAfterAllocationListCount" resultType="java.lang.Integer">
+        select count(*) from cost_allocation where delete_time = 0 and hosp_id = #{hospId}
+        <if test="dateYear != null">
+            and date_year = #{dateYear} and date_month = #{dateMonth}
+        </if>
+        <if test="responsibilityCode != null and responsibilityCode != ''">
+            and responsibility_code = #{responsibilityCode}
+        </if>
+    </select>
+    <select id="queryAfterAllocationListSum" resultType="java.math.BigDecimal">
+        select sum(amount) from cost_allocation where delete_time = 0 and hosp_id = #{hospId}
+        <if test="dateYear != null">
+            and date_year = #{dateYear} and date_month = #{dateMonth}
+        </if>
+        <if test="responsibilityCode != null and responsibilityCode != ''">
+            and responsibility_code = #{responsibilityCode}
+        </if>
+    </select>
 
 
 
 
 </mapper>
 </mapper>

+ 34 - 0
src/test/java/com/imed/costaccount/service/impl/AllocationServiceImplTest.java

@@ -0,0 +1,34 @@
+package com.imed.costaccount.service.impl;
+
+import com.imed.costaccount.common.util.PageUtils;
+import com.imed.costaccount.service.AccountingService;
+import com.imed.costaccount.service.AllocationService;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+@Slf4j
+public class AllocationServiceImplTest {
+
+    @Autowired
+    private AllocationService allocationService;
+
+    @Test
+    public void testShareAfterQueryTest() {
+        String year = "2021-01-01";
+        String responsibilityCode = "";
+        int current = 1;
+        int pageSize = 10;
+        long hospId = 11L;
+        PageUtils pageUtils = allocationService.queryAfterAllocation(year, responsibilityCode, current, pageSize, hospId);
+        Assert.assertNotNull(pageUtils);
+        log.info("pageUtils={}",pageUtils);
+    }
+
+}