2
0
hr 4 лет назад
Родитель
Сommit
92615a54e4

+ 27 - 12
src/main/java/com/imed/costaccount/mapper/AllocationMapper.java

@@ -13,7 +13,7 @@ import java.util.List;
 
 /**
  * 成本分摊后表
- * 
+ *
  * @author huangrui
  * @date 2021-08-25 08:45:06
  */
@@ -22,12 +22,13 @@ public interface AllocationMapper extends BaseMapper<Allocation> {
 
     /**
      * 分摊后查询列表
-     * @param dateYear 年
-     * @param dateMonth 月
+     *
+     * @param dateYear           年
+     * @param dateMonth          月
      * @param responsibilityCode 责任中心
-     * @param startIndex 开始索引
-     * @param pageSize 页数
-     * @param hospId 医院id
+     * @param startIndex         开始索引
+     * @param pageSize           页数
+     * @param hospId             医院id
      * @return List
      */
     List<AfterAllocationVO> queryAfterAllocationList(@Param("dateYear") Integer dateYear,
@@ -38,10 +39,11 @@ public interface AllocationMapper extends BaseMapper<Allocation> {
 
     /**
      * 总数
-     * @param dateYear 年
-     * @param dateMonth 月
+     *
+     * @param dateYear           年
+     * @param dateMonth          月
      * @param responsibilityCode 责任中心
-     * @param hospId 医院id
+     * @param hospId             医院id
      * @return 总数
      */
     int queryAfterAllocationListCount(@Param("dateYear") Integer dateYear,
@@ -51,14 +53,27 @@ public interface AllocationMapper extends BaseMapper<Allocation> {
 
     /**
      * 总金额
-     * @param dateYear 年
-     * @param dateMonth 月
+     *
+     * @param dateYear           年
+     * @param dateMonth          月
      * @param responsibilityCode 责任中心
-     * @param hospId 医院id
+     * @param hospId             医院id
      * @return 总数
      */
     BigDecimal queryAfterAllocationListSum(@Param("dateYear") Integer dateYear,
                                            @Param("dateMonth") Integer dateMonth,
                                            @Param("responsibilityCode") String responsibilityCode,
                                            @Param("hospId") Long hospId);
+
+    /**
+     * 得到这个月的分摊过的分摊层级
+     *
+     * @param hospId 医院id
+     * @param year   年
+     * @param month  月
+     * @return
+     */
+    List<Allocation> getAllSortLevel(@Param("hospId") Long hospId,
+                                     @Param("year") int year,
+                                     @Param("month") int month);
 }

+ 0 - 28
src/main/java/com/imed/costaccount/mapper/AllocationMapper.xml

@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<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"/>
-        <result property="dateMonth" column="date_month"/>
-        <result property="levelSort" column="level_sort"/>
-        <result property="levelName" column="level_name"/>
-        <result property="hospId" column="hosp_id"/>
-        <result property="responsibilityCode" column="responsibility_code"/>
-        <result property="responsibilityName" column="responsibility_name"/>
-        <result property="accountShareId" column="account_share_id"/>
-        <result property="isBaseCost" column="is_base_cost"/>
-        <result property="amount" column="amount"/>
-        <result property="targetResponsibilityCode" column="target_responsibility_code"/>
-        <result property="targetResponsibilityName" column="target_responsibility_name"/>
-        <result property="shareParamCode" column="share_param_code"/>
-        <result property="shareParamName" column="share_param_name"/>
-        <result property="createTime" column="create_time"/>
-        <result property="deleteTime" column="delete_time"/>
-    </resultMap>
-
-
-</mapper>

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

@@ -88,7 +88,7 @@ public class AllocationQuery implements Serializable {
 	/**
 	 * 删除时间
 	 */
-	@TableLogic(value = "0",delval = "TIME_STAMP(NOW()) * 1000")
+	@TableLogic(value = "0",delval = "UNIX_TIMESTAMP(NOW()) * 1000")
 	private Long deleteTime;
 
 }

+ 21 - 0
src/main/java/com/imed/costaccount/model/vo/AfterAllocationFormVO.java

@@ -0,0 +1,21 @@
+package com.imed.costaccount.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class AfterAllocationFormVO {
+
+    private Integer year;
+
+    private Integer month;
+
+    private String shareReportName;
+
+    private Integer shareLevel;
+
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date shareTime;
+}

+ 1 - 1
src/main/java/com/imed/costaccount/model/vo/MenuVO.java

@@ -14,7 +14,7 @@ public class MenuVO {
 
     private Long menuId;
 
-    @JsonIgnore
+//    @JsonIgnore
     private Long parentId;
 
     private String name;

+ 10 - 0
src/main/java/com/imed/costaccount/service/AllocationService.java

@@ -5,6 +5,8 @@ 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 com.imed.costaccount.model.vo.AfterAllocationFormVO;
+import com.imed.costaccount.model.vo.AfterAllocationVO;
 import com.imed.costaccount.model.vo.CollectDataFormVO;
 import org.apache.poi.ss.usermodel.Sheet;
 
@@ -59,5 +61,13 @@ public interface AllocationService extends IService<Allocation> {
      * @return
      */
     ExcelWriter getShareReportTemplate(ExcelWriter writer, Integer levelSort, Sheet sheet, Integer year, Integer month);
+
+    /**
+     * 分摊后报表输出
+     * @param date yyyy-MM-dd
+     * @param hospId 医院id
+     * @return List
+     */
+    List<AfterAllocationFormVO> afterAllocationFormList(String date, Long hospId);
 }
 

+ 27 - 11
src/main/java/com/imed/costaccount/service/impl/AllocationServiceImpl.java

@@ -65,6 +65,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
     @Override
     @Transactional(rollbackFor = Throwable.class, propagation = Propagation.REQUIRED)
     public void startAllocation(StartDTO startDTO, Long hospId) {
+        long timeMillis = System.currentTimeMillis();
         // 得到这个月的所有导入的成本数据
         List<CostCostingGroup> costingGroups = costCostingGroupService.getByYearAndDate(startDTO.getYear(), startDTO.getMonth(), hospId);
         // 没有重新导入
@@ -171,7 +172,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
                             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(System.currentTimeMillis()).setTargetResponsibilityCode(valueResponsibilityCode).setTargetResponsibilityName(targetRespName)
+                                    .setCreateTime(timeMillis).setTargetResponsibilityCode(valueResponsibilityCode).setTargetResponsibilityName(targetRespName)
                                     .setShareParamCode(paramValue.getShareParamCode()).setShareParamName(shareParamName).setTotalAmount(totalAmount).setShareParamValueNum(paramValue.getValueNum())
                                     .setShareParamRate(numerator.divide(reduce, 4))
                             ;
@@ -647,7 +648,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
                     continue;
                 }
                 // TODO: 2021/8/26 计算 中间的钱
-                BigDecimal amount = allocationQueryService.getTotalByAccountAndRespCode(hospId, dateYear, month,  account.getCode(), respCodes.get(i));
+                BigDecimal amount = allocationQueryService.getTotalByAccountAndRespCode(hospId, dateYear, month, account.getCode(), respCodes.get(i));
                 map.put(i + 1, amount);
 
             }
@@ -673,15 +674,30 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
     }
 
     /**
-     * 这年月的数据
+     * 分摊后报表输出
+     *
+     * @param date   yyyy-MM-dd
+     * @param hospId 医院id
+     * @return List
      */
-    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;
+    @Override
+    public List<AfterAllocationFormVO> afterAllocationFormList(String date, Long hospId) {
+
+        DateTime parse = DateUtil.parse(date);
+        int year = DateUtil.year(parse);
+        int month = DateUtil.month(parse) + 1;
+        // 得到这个月的分摊过的分摊层级
+        List<Allocation> list = baseMapper.getAllSortLevel(hospId, year, month);
+//        list.
+        List<AfterAllocationFormVO> vos = list.stream().map(i -> {
+            AfterAllocationFormVO vo = new AfterAllocationFormVO();
+            vo.setYear(i.getDateYear());
+            vo.setMonth(i.getDateMonth());
+            vo.setShareLevel(i.getLevelSort());
+            vo.setShareReportName(i.getShareParamName() + "分摊");
+            vo.setShareTime(DateUtil.date(i.getCreateTime()));
+            return vo;
+        }).collect(Collectors.toList());
+        return vos;
     }
 }

+ 13 - 5
src/main/java/com/imed/costaccount/web/CostCostingGroupController.java

@@ -4,13 +4,11 @@ import com.imed.costaccount.common.exception.CostException;
 import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.common.util.Result;
 import com.imed.costaccount.model.dto.StartDTO;
+import com.imed.costaccount.model.vo.AfterAllocationFormVO;
 import com.imed.costaccount.model.vo.CollectDataFormVO;
 import com.imed.costaccount.service.AllocationService;
 import com.imed.costaccount.service.CostCostingGroupService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.*;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
@@ -104,6 +102,16 @@ public class CostCostingGroupController extends AbstractController {
     })
     public Result queryAfterAllocationForm(@RequestParam(value = "year", required = false) String year,
                                            @RequestParam(value = "responsibilityCode", required = false) String responsibilityCode) {
-        return Result.ok(allocationService.queryAfterAllocationForm(year, responsibilityCode,getHospId()));
+        return Result.ok(allocationService.queryAfterAllocationForm(year, responsibilityCode, getHospId()));
     }
+
+    @ApiOperation("分摊后报表输出")
+    @GetMapping("/afterAllocationFormList")
+    public Result afterAllocationFormList(@RequestParam(value = "date", required = false)
+                                          @ApiParam(name = "date", value = "年月日(yyyy-MM-dd)") String date) {
+        List<AfterAllocationFormVO> list = allocationService.afterAllocationFormList(date, getHospId());
+        PageUtils pageUtils = new PageUtils(list, 0, 0, 0);
+        return Result.ok(pageUtils);
+    }
+
 }

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

@@ -55,5 +55,14 @@
         </if>
     </select>
 
+    <select id="getAllSortLevel" resultType="com.imed.costaccount.model.Allocation">
+        select distinct date_year,date_month,level_sort, share_param_code, share_param_name, create_time
+        from cost_allocation
+        where date_year = #{year}
+          and date_month = #{month}
+          and hosp_id = #{hospId}
+    </select>
+
+
 
 </mapper>