2
0
Эх сурвалжийг харах

Merge branch 'master' of huangrui/CostAccount into dev

lijiaxi 4 жил өмнө
parent
commit
4c56050d1c

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

@@ -108,6 +108,8 @@ public class Allocation implements Serializable {
 	 */
 	 */
 	private BigDecimal shareParamRate;
 	private BigDecimal shareParamRate;
 
 
+	private Long shareLevelId;
+
 	/**
 	/**
 	 * 
 	 * 
 	 */
 	 */

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

@@ -18,6 +18,8 @@ public class AfterAllocationFormVO {
 
 
     private Integer shareLevel;
     private Integer shareLevel;
 
 
+    private Long shareLevelId;
+
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private Date shareTime;
     private Date shareTime;
 }
 }

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

@@ -57,9 +57,10 @@ public interface AllocationService extends IService<Allocation> {
      * @param sheet 报表
      * @param sheet 报表
      * @param year 年
      * @param year 年
      * @param month 月
      * @param month 月
+     * @param shareLevelId
      * @return
      * @return
      */
      */
-    ExcelWriter getShareReportTemplate(ExcelWriter writer, Integer levelSort, Sheet sheet, Integer year, Integer month);
+    ExcelWriter getShareReportTemplate(ExcelWriter writer, Integer levelSort, Sheet sheet, Integer year, Integer month, Long shareLevelId);
 
 
     /**
     /**
      * 分摊后报表输出
      * 分摊后报表输出

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

@@ -179,7 +179,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
                                     .setResponsibilityName(responsibility.getResponsibilityName()).setAccountShareId(accountShareId).setAmount(targetAmount)
                                     .setResponsibilityName(responsibility.getResponsibilityName()).setAccountShareId(accountShareId).setAmount(targetAmount)
                                     .setCreateTime(timeMillis).setTargetResponsibilityCode(valueResponsibilityCode).setTargetResponsibilityName(targetRespName)
                                     .setCreateTime(timeMillis).setTargetResponsibilityCode(valueResponsibilityCode).setTargetResponsibilityName(targetRespName)
                                     .setShareParamCode(paramValue.getShareParamCode()).setShareParamName(shareParamName).setTotalAmount(totalAmount).setShareParamValueNum(paramValue.getValueNum())
                                     .setShareParamCode(paramValue.getShareParamCode()).setShareParamName(shareParamName).setTotalAmount(totalAmount).setShareParamValueNum(paramValue.getValueNum())
-                                    .setShareParamRate(numerator.divide(reduce, 4))
+                                    .setShareParamRate(numerator.divide(reduce, 4)).setShareLevelId(levelId)
                             ;
                             ;
 
 
                             // todo 目标分摊层级责任中心 就是当前列个表中的责任中心
                             // todo 目标分摊层级责任中心 就是当前列个表中的责任中心
@@ -401,12 +401,13 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
      * @param sheet     报表
      * @param sheet     报表
      * @param year      年
      * @param year      年
      * @param month     月
      * @param month     月
+     * @param shareLevelId
      * @return
      * @return
      */
      */
     @Override
     @Override
-    public ExcelWriter getShareReportTemplate(ExcelWriter writer, Integer levelSort, Sheet sheet, Integer year, Integer month) {
+    public ExcelWriter getShareReportTemplate(ExcelWriter writer, Integer levelSort, Sheet sheet, Integer year, Integer month, Long shareLevelId) {
         // 获取数据
         // 获取数据
-        List<AllocationReportVO> allocationReportVOList = getAllocationReportVOS(levelSort, year, month);
+        List<AllocationReportVO> allocationReportVOList = getAllocationReportVOS(levelSort, year, month,shareLevelId);
         // 设置导出
         // 设置导出
         Map<String, List<AllocationReportVO>> responsibilityMap = allocationReportVOList.stream().collect(Collectors.groupingBy(AllocationReportVO::getResponsibilityCode));
         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, List<AllocationReportVO>> targetResponsibilityMap = allocationReportVOList.stream().collect(Collectors.groupingBy(AllocationReportVO::getTargetResponsibilityCode));
@@ -552,10 +553,10 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
             }
             }
         }
         }
         Map<String, Integer> rowMap = new HashMap<>();
         Map<String, Integer> rowMap = new HashMap<>();
-        int cc=levelSort+3;
+        int cc = levelSort + 3;
         // 合并行
         // 合并行
-        boolean otherData=false;
-        for (int m = levelSort + 3; m < column-1; m++) {
+        boolean otherData = false;
+        for (int m = levelSort + 3; m < column - 1; m++) {
 //            String cellValue = sheet.getRow(0).getCell(m).getStringCellValue();
 //            String cellValue = sheet.getRow(0).getCell(m).getStringCellValue();
 //            if (!rowMap.containsKey(cellValue)){
 //            if (!rowMap.containsKey(cellValue)){
 //                rowMap.put(cellValue,m);
 //                rowMap.put(cellValue,m);
@@ -563,28 +564,29 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
 //                String value = sheet.getRow(0).getCell(m ).getStringCellValue();
 //                String value = sheet.getRow(0).getCell(m ).getStringCellValue();
 //                writer.merge(0, 0, rowMap.get(sheet.getRow(0).getCell(m-1).getStringCellValue()), m-1, sheet.getRow(0).getCell(m-1).getStringCellValue(), false);
 //                writer.merge(0, 0, rowMap.get(sheet.getRow(0).getCell(m-1).getStringCellValue()), m-1, sheet.getRow(0).getCell(m-1).getStringCellValue(), false);
 //            }
 //            }
-            String cellValue1=sheet.getRow(0).getCell(m).getStringCellValue();
-            String cellValue2=sheet.getRow(0).getCell(m+1).getStringCellValue();
-            if(!cellValue1.equals(cellValue2)){
-                otherData=true;
-                writer.merge(0, 0, cc,m,cellValue1,false);
-                cc=m+1;
-            }if (m==column-2){
-                writer.merge(0, 0, cc,m+1,sheet.getRow(0).getCell(m+1).getStringCellValue(),false);
+            String cellValue1 = sheet.getRow(0).getCell(m).getStringCellValue();
+            String cellValue2 = sheet.getRow(0).getCell(m + 1).getStringCellValue();
+            if (!cellValue1.equals(cellValue2)) {
+                otherData = true;
+                writer.merge(0, 0, cc, m, cellValue1, false);
+                cc = m + 1;
+            }
+            if (m == column - 2) {
+                writer.merge(0, 0, cc, m + 1, sheet.getRow(0).getCell(m + 1).getStringCellValue(), false);
             }
             }
         }
         }
         // 合并列
         // 合并列
-        int jj=3;
-
-        for (int i=3;i<num-1;i++){
-            String cellValue1=sheet.getRow(i).getCell(0).getStringCellValue();
-            String cellValue2=sheet.getRow(i+1).getCell(0).getStringCellValue();
-            if(!cellValue1.equals(cellValue2)){
-                otherData=true;
-                writer.merge(jj, i, 0,0,cellValue1,false);
-                jj=i+1;
-            }else if (i==num-2){
-                writer.merge(jj, i+1, 0,0,cellValue1,false);
+        int jj = 3;
+
+        for (int i = 3; i < num - 1; i++) {
+            String cellValue1 = sheet.getRow(i).getCell(0).getStringCellValue();
+            String cellValue2 = sheet.getRow(i + 1).getCell(0).getStringCellValue();
+            if (!cellValue1.equals(cellValue2)) {
+                otherData = true;
+                writer.merge(jj, i, 0, 0, cellValue1, false);
+                jj = i + 1;
+            } else if (i == num - 2) {
+                writer.merge(jj, i + 1, 0, 0, cellValue1, false);
             }
             }
         }
         }
         for (int i = 0; i < 30; i++) {
         for (int i = 0; i < 30; i++) {
@@ -604,16 +606,16 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
      * @param month
      * @param month
      * @return
      * @return
      */
      */
-    private List<AllocationReportVO> getAllocationReportVOS(Integer levelSort, Integer year, Integer month) {
+    private List<AllocationReportVO> getAllocationReportVOS(Integer levelSort, Integer year, Integer month,Long shareLevelId) {
         Long hospId = UserContext.getHospId();
         Long hospId = UserContext.getHospId();
         if (Objects.isNull(levelSort) || Objects.isNull(year) || Objects.isNull(month)) {
         if (Objects.isNull(levelSort) || Objects.isNull(year) || Objects.isNull(month)) {
             throw new CostException(500, "参数异常");
             throw new CostException(500, "参数异常");
         }
         }
         // 处理第几次分摊计算值
         // 处理第几次分摊计算值
         List<Allocation> allocationList = baseMapper.selectList(new QueryWrapper<Allocation>().lambda()
         List<Allocation> allocationList = baseMapper.selectList(new QueryWrapper<Allocation>().lambda()
-                .eq(Allocation::getHospId, hospId).eq(Allocation::getLevelSort, levelSort).eq(Allocation::getDateYear, year)
+                .eq(Allocation::getHospId, hospId).eq(Allocation::getLevelSort, levelSort).eq(Allocation::getShareLevelId,shareLevelId).eq(Allocation::getDateYear, year)
                 .eq(Allocation::getDateMonth, month));
                 .eq(Allocation::getDateMonth, month));
-
+        // 找会计科室的时候使用的
         List<Allocation> allocations = baseMapper.selectList(new QueryWrapper<Allocation>().lambda()
         List<Allocation> allocations = baseMapper.selectList(new QueryWrapper<Allocation>().lambda()
                 .eq(Allocation::getHospId, hospId).eq(Allocation::getDateYear, year)
                 .eq(Allocation::getHospId, hospId).eq(Allocation::getDateYear, year)
                 .eq(Allocation::getDateMonth, month));
                 .eq(Allocation::getDateMonth, month));
@@ -751,6 +753,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
             vo.setShareLevel(i.getLevelSort());
             vo.setShareLevel(i.getLevelSort());
             vo.setShareReportName(i.getShareParamName() + "分摊");
             vo.setShareReportName(i.getShareParamName() + "分摊");
             vo.setShareTime(DateUtil.date(i.getCreateTime()));
             vo.setShareTime(DateUtil.date(i.getCreateTime()));
+            vo.setShareLevelId(i.getShareLevelId());
             return vo;
             return vo;
         }).collect(Collectors.toList());
         }).collect(Collectors.toList());
         return vos;
         return vos;

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

@@ -400,7 +400,7 @@ public class ExcelController extends AbstractController{
 //    }
 //    }
     @ApiOperation("分摊报表输出2.0")
     @ApiOperation("分摊报表输出2.0")
     @GetMapping("/getShareReportTemplate")
     @GetMapping("/getShareReportTemplate")
-    public void getTemplate(HttpServletResponse response,Integer levelSort,String token,Integer year,Integer month) throws IOException {
+    public void getTemplate(HttpServletResponse response,Integer levelSort,String token,Integer year,Integer month,Long shareLevelId) throws IOException {
         int userId = jwtUtil.getUserId(token);
         int userId = jwtUtil.getUserId(token);
         User user = userService.getById(userId);
         User user = userService.getById(userId);
         if (Objects.isNull(user)){
         if (Objects.isNull(user)){
@@ -413,7 +413,7 @@ public class ExcelController extends AbstractController{
         ExcelWriter writer = new ExcelWriter(url);
         ExcelWriter writer = new ExcelWriter(url);
         Sheet sheet = writer.getSheet();
         Sheet sheet = writer.getSheet();
         // 第几次分摊
         // 第几次分摊
-        writer= allocationServicel.getShareReportTemplate(writer,levelSort,sheet,year,month);
+        writer= allocationServicel.getShareReportTemplate(writer,levelSort,sheet,year,month,shareLevelId);
         response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
         response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
         response.setHeader("Content-Disposition", "attachment;filename=" + uuid + ".xls");
         response.setHeader("Content-Disposition", "attachment;filename=" + uuid + ".xls");
         ServletOutputStream out = null;
         ServletOutputStream out = null;

+ 13 - 5
src/main/resources/mapper/AllocationMapper.xml

@@ -23,8 +23,9 @@
         <result property="shareParamValueNum" column="share_param_value_num"/>
         <result property="shareParamValueNum" column="share_param_value_num"/>
         <result property="shareParamRate" column="share_param_rate"/>
         <result property="shareParamRate" column="share_param_rate"/>
         <result property="isBaseCost" column="is_base_cost"/>
         <result property="isBaseCost" column="is_base_cost"/>
-        <result property="levelSort" column="level_sort" />
-        <result property="levelName" column="level_name" />
+        <result property="levelSort" column="level_sort"/>
+        <result property="levelName" column="level_name"/>
+        <result property="shareLevelId" column="share_level_id"/>
         <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>
@@ -34,7 +35,7 @@
             and date_year = #{dateYear} and date_month = #{dateMonth}
             and date_year = #{dateYear} and date_month = #{dateMonth}
         </if>
         </if>
         <if test="responsibilityCode != null and responsibilityCode != ''">
         <if test="responsibilityCode != null and responsibilityCode != ''">
-            and responsibility_code =  #{responsibilityCode}
+            and responsibility_code = #{responsibilityCode}
         </if>
         </if>
         limit #{startIndex},#{pageSize}
         limit #{startIndex},#{pageSize}
     </select>
     </select>
@@ -58,13 +59,20 @@
     </select>
     </select>
 
 
     <select id="getAllSortLevel" resultType="com.imed.costaccount.model.Allocation">
     <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,id
+        select distinct date_year,
+                        date_month,
+                        level_sort,
+                        share_param_code,
+                        share_param_name,
+                        create_time,
+                        id,
+                        share_level_id
         from cost_allocation
         from cost_allocation
         where date_year = #{year}
         where date_year = #{year}
           and date_month = #{month}
           and date_month = #{month}
           and hosp_id = #{hospId}
           and hosp_id = #{hospId}
+        group by share_level_id
     </select>
     </select>
 
 
 
 
-
 </mapper>
 </mapper>