Ver código fonte

调整成本和分摊参数导出模板

ljx 4 anos atrás
pai
commit
115fdde030

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

@@ -107,7 +107,6 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
             pageUtils.setTotalAmount(new BigDecimal(0.0000));
             return pageUtils;
         }
-
         // 进行金额合并
         List<Long> idList = costIncomeGroupBeforeVOList.stream().map(CostIncomeGroupBeforeVO::getId).collect(Collectors.toList());
         List<CostIncomeGroupAllAmountVO> costIncomeGroupAllAmountVoS = baseMapper.countMoney(idList);
@@ -339,8 +338,8 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
             boolean checkOne = "0".equals(data.get(15).toString());
             // TODO 为0的时候这一行是否可以输入空的
             if (checkNull) {
-                // 不为空要求这一行全部输入
-                for (int j = 0; j < data.size(); j++) {
+                // 不为空要求这一行全部输入  前6列数据不能为空
+                for (int j = 0; j < NumberConstant.SIX; j++) {
                     if (StrUtil.isBlank(data.get(j).toString())) {
                         IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
                         incomeErrorMessage.setTotal(i);

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

@@ -1,8 +1,6 @@
 package com.imed.costaccount.web;
 
 import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.IoUtil;
 import cn.hutool.poi.excel.ExcelReader;
@@ -317,28 +315,35 @@ public class ExcelController {
 
         ExcelWriter writer = new ExcelWriter(url);
         // 样式
+        // 所有科室里面对应存在责任中心对应的科室
+        List<Department> departmentLinkedList = getDepartments(hospId);
+        // 设置科室的代码集合
+        List<String> departmentCodeList = departmentLinkedList.stream().map(Department::getDepartmentCode).collect(Collectors.toList());
+        List<String> departmentNameList = departmentLinkedList.stream().map(Department::getDepartmentName).collect(Collectors.toList());
         Sheet sheet = writer.getSheet();
         writer.merge(0, 1, 0, 6, "为了保证成功导入,请勿修改模板格式", false);
         writer.passCurrentRow();
         writer.passCurrentRow();
         writer.merge(2, 2, 0, 6, "医院成本数据批量导入", false);
         writer.passCurrentRow();
-        // 所有科室里面对应存在责任中心对应的科室
-        List<Department> departmentLinkedList = getDepartments(hospId);
-        // 设置科室的代码集合
-        List<String> departmentCodeList = departmentLinkedList.stream().map(Department::getDepartmentCode).collect(Collectors.toList());
-        List<String> departmentNameList = departmentLinkedList.stream().map(Department::getDepartmentName).collect(Collectors.toList());
+        writer.merge(3,3,2,departmentCodeList.size(),"科室",false);
+        writer.passCurrentRow();
         departmentCodeList.add(0, null);
         departmentCodeList.add(1, null);
+        departmentCodeList.add(2, null);
+        departmentCodeList.add("-1");
         writer.writeRow(departmentCodeList);
-        departmentNameList.add(0, "成本项目代码");
-        departmentNameList.add(1, "成本项目名称");
+        departmentNameList.add(0, null);
+        departmentNameList.add(1, "成本项目代码");
+        departmentNameList.add(2, "成本项目名称");
+        departmentNameList.add("总计");
         writer.writeRow(departmentNameList);
         // 设置科室名称的集合
         writer.setFreezePane(5);
         int accountType = NumberConstant.TWO;
         int column = NumberConstant.FIVE;
-        getProductByAccountType(hospId, writer, accountType, column);
+        List<Product> productList = getProductByAccountType(hospId, writer, accountType, column);
+        writer.merge(6,productList.size(),0,0,"成本项目",false);
         writer.setColumnWidth(0, 15);
         writer.setColumnWidth(1, 15);
         response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
@@ -358,7 +363,7 @@ public class ExcelController {
      * @param accountType 会计科目类型 1 收入  2支出(成本)
      * @param column      控制第几列
      */
-    private void getProductByAccountType(Long hospId, ExcelWriter writer, Integer accountType, Integer column) {
+    private List<Product> getProductByAccountType(Long hospId, ExcelWriter writer, Integer accountType, Integer column) {
         // 所有的成本项目
         List<Product> productList = productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId));
         // 所有成本会计对照数据
@@ -381,9 +386,10 @@ public class ExcelController {
         });
         // 写入响应第一列 第二列的数据
         for (int j = 0; j < products.size(); j++) {
-            writer.writeCellValue(0, j + column, productList.get(j).getProductCode());
-            writer.writeCellValue(1, j + column, productList.get(j).getProductName());
+            writer.writeCellValue(1, j + column, productList.get(j).getProductCode());
+            writer.writeCellValue(2, j + column, productList.get(j).getProductName());
         }
+        return productList;
     }
 
     /**
@@ -399,27 +405,33 @@ public class ExcelController {
 
         ExcelWriter writer = new ExcelWriter(url);
         // 样式
+        // 所有科室里面对应存在责任中心对应的科室进行显示
+        List<Department> departmentLinkedList = getDepartments(hospId);
+        // 设置科室的代码集合
+        List<String> departmentCodeList = departmentLinkedList.stream().map(Department::getDepartmentCode).collect(Collectors.toList());
+        List<String> departmentNameList = departmentLinkedList.stream().map(Department::getDepartmentName).collect(Collectors.toList());
+        List<CostShareParam> costShareParamList = costShareParamService.list(new QueryWrapper<CostShareParam>().lambda().eq(CostShareParam::getHospId, hospId));
         Sheet sheet = writer.getSheet();
         writer.merge(0, 1, 0, 6, "为了保证成功导入,请勿修改模板格式", false);
         writer.passCurrentRow();
         writer.passCurrentRow();
         writer.merge(2, 2, 0, 6, "医院成本分摊参数数据批量导入", false);
         writer.passCurrentRow();
-        // 所有科室里面对应存在责任中心对应的科室进行显示
-        List<Department> departmentLinkedList = getDepartments(hospId);
-        // 设置科室的代码集合
-        List<String> departmentCodeList = departmentLinkedList.stream().map(Department::getDepartmentCode).collect(Collectors.toList());
-        List<String> departmentNameList = departmentLinkedList.stream().map(Department::getDepartmentName).collect(Collectors.toList());
+        writer.merge(3,3,3,departmentCodeList.size(),"科室",false);
+        writer.passCurrentRow();
+        writer.merge(6,costShareParamList.size(),0,0,"成本分摊参数",false);
         departmentCodeList.add(0, null);
         departmentCodeList.add(1, null);
+        departmentCodeList.add(2, null);
         writer.writeRow(departmentCodeList);
-        departmentNameList.add(0, "成本分摊参数代码");
-        departmentNameList.add(1, "成本分摊参数名称");
+        departmentNameList.add(0, null);
+        departmentNameList.add(1, "成本分摊参数代码");
+        departmentNameList.add(2, "成本分摊参数名称");
         writer.writeRow(departmentNameList);
         // 设置科室名称的集合
         writer.setFreezePane(5);
         // 为第一列和第二列设置成本分摊参数的列表数据
-        List<CostShareParam> costShareParamList = costShareParamService.list(new QueryWrapper<CostShareParam>().lambda().eq(CostShareParam::getHospId, hospId));
+
         for (int j = 0; j < costShareParamList.size(); j++) {
             writer.writeCellValue(0, j + 5, costShareParamList.get(j).getShareParamCode());
             writer.writeCellValue(1, j + 5, costShareParamList.get(j).getShareParamName());
@@ -458,12 +470,11 @@ public class ExcelController {
      * @param
      */
     @PostMapping("/importDataByFileType")
-    @ApiOperation("批量导入指定类型数据信息")
+    @ApiOperation("收入数据导入")
     public Result importProductAccount(@RequestParam("file") MultipartFile file ,Integer fileType,String dateTime) {
         if (Objects.isNull(file)) {
             throw new CostException(500, "请选择文件");
         }
-
         InputStream in;
         // 导入的是收入数据
         try {
@@ -480,34 +491,26 @@ public class ExcelController {
             throw new CostException(500, "导入失败");
         }
     }
-
-//    @ApiOperation("excel导入收入数据")
-//    @PostMapping("/importDataByIncomeData")
-//    public Result importDataByIncomeData(@RequestParam("file") MultipartFile file, Integer year, Integer month) {
-//        if (Objects.isNull(year) || Objects.isNull(month)) {
-//            DateTime dateTime = DateUtil.lastMonth();
-//            year = DateUtil.year(dateTime);
-//            month = DateUtil.month(dateTime);
-//        }
-//        if (Objects.isNull(file)) {
-//            throw new CostException(500, "请选择文件");
-//        }
-//        InputStream in;
-//        // 导入的是收入数据
-//        try {
-//            in = file.getInputStream();
-//            ExcelReader reader = ExcelUtil.getReader(in);
-//            List<List<Object>> read = reader.read();
-//            log.info("最开始:read={}", read);
-//            log.info("-------------------------------------------------------------------");
-//            User user = UserContext.getCurrentUser();
-//            return costIncomeGroupService.importDataByIncomeData(read, user, file, year, month);
-//        } catch (IOException e) {
-//            e.printStackTrace();
-//            ;
-//            throw new CostException(500, "导入失败");
-//        }
-//
-//    }
-
+    @PostMapping("/importCostingGroup")
+    @ApiOperation("成本数据导入")
+    public Result importCostingGroup(@RequestParam("file") MultipartFile file ,Integer fileType,String dateTime) {
+        if (Objects.isNull(file)) {
+            throw new CostException(500, "请选择文件");
+        }
+        InputStream in;
+        // 导入的是收入数据
+        try {
+            in = file.getInputStream();
+            ExcelReader reader = ExcelUtil.getReader(in);
+            List<List<Object>> read = reader.read();
+            log.info("最开始:read={}", read);
+            log.info("-------------------------------------------------------------------");
+            User user = UserContext.getCurrentUser();
+            return costIncomeGroupService.importIncomeGroup(read, user, file, dateTime,fileType);
+        } catch (IOException e) {
+            e.printStackTrace();
+            ;
+            throw new CostException(500, "导入失败");
+        }
+    }
 }

+ 2 - 2
src/main/resources/application-dev.yml

@@ -9,7 +9,7 @@ spring:
       driver-class-name: com.mysql.jdbc.Driver
       url: jdbc:mysql://112.124.59.133:3306/cost_account?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
       username: root
-      password: zjxy!@#2021
+      password: xywl2021#@!
       initial-size: 10
       max-active: 100
       min-idle: 10
@@ -27,7 +27,7 @@ spring:
   redis:
     port: 6379
     host: 112.124.59.133
-    password: xywl!@#2021
+    password: xywl2021!
     jedis:
       pool:
         max-active: 30

+ 1 - 2
src/main/resources/mapper/CostIncomeGroupMapper.xml

@@ -48,8 +48,7 @@
 
     <select id="countMoney" resultType="com.imed.costaccount.model.vo.CostIncomeGroupAllAmountVO">
         select
-        <include refid="Base_Column_List"/>
-        ,group_concat(amount) as allMoney
+        <include refid="Base_Column_List"/>,group_concat(amount) as allMoney
         from cost_income_group
         where id IN
         <foreach close=")" collection="idList" item="item" open="(" separator=",">