Prechádzať zdrojové kódy

08 25 01 分摊后查询

hr 4 rokov pred
rodič
commit
c0544f0d6b

+ 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.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.imed.costaccount.model.vo.AfterAllocationVO;
 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
 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);
 }

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

@@ -77,12 +77,35 @@ public class Allocation implements Serializable {
 	 */
 	private Long createTime;
 
+	/**
+	 * 目标责任中心
+	 */
 	private String targetResponsibilityCode;
+
+	/**
+	 * 目标责任中心名称
+	 */
 	private String targetResponsibilityName;
+
+	/**
+	 * 分摊参数代码
+	 */
 	private String shareParamCode;
+	/**
+	 * 分摊参数名称
+	 */
 	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;
 
 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.Allocation;
 
-import java.util.Map;
-
 /**
  * 成本分摊后表
  *
@@ -21,5 +20,18 @@ public interface AllocationService extends IService<Allocation> {
      * @param hospId 医院id
      */
     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);
+
 }
 

+ 31 - 0
src/main/java/com/imed/costaccount/service/impl/AllocationServiceImpl.java

@@ -1,15 +1,19 @@
 package com.imed.costaccount.service.impl;
 
 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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.imed.costaccount.common.exception.CostException;
 import com.imed.costaccount.common.util.JacksonUtil;
+import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.mapper.AllocationMapper;
 import com.imed.costaccount.model.*;
 import com.imed.costaccount.model.dto.StartDTO;
 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.service.*;
 import org.springframework.stereotype.Service;
@@ -274,4 +278,31 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
         List<Long> shareLevelIds = shareLevels.stream().map(CostShareLevel::getId).collect(Collectors.toList());
         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);
+    }
 }

+ 6 - 4
src/main/java/com/imed/costaccount/web/CostCostingGroupController.java

@@ -82,14 +82,16 @@ public class CostCostingGroupController extends AbstractController {
     @GetMapping("/queryAfterAllocation")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "year",value = "年月日(yyyy-MM-dd)"),
-            @ApiImplicitParam(name = "responsibilityCode",value = "年月日(yyyy-MM-dd)"),
-            @ApiImplicitParam(name = "year",value = "年月日(yyyy-MM-dd)"),
-            @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) {
-        return null;
+        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">
 
-	<!-- 可根据自己的需求,是否要使用 -->
+    <!-- 可根据自己的需求,是否要使用 -->
     <resultMap type="com.imed.costaccount.model.Allocation" id="allocationMap">
         <result property="id" column="id"/>
         <result property="dateYear" column="date_year"/>
@@ -19,10 +19,41 @@
         <result property="targetResponsibilityName" column="target_responsibility_name"/>
         <result property="shareParamCode" column="share_param_code"/>
         <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="createTime" column="create_time"/>
         <result property="deleteTime" column="delete_time"/>
     </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>

+ 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);
+    }
+
+}