hr 4 gadi atpakaļ
vecāks
revīzija
cba7e6a29b

+ 5 - 2
src/main/java/com/imed/costaccount/model/AfterIncomegroup.java

@@ -3,6 +3,7 @@ package com.imed.costaccount.model;
 import io.swagger.annotations.ApiModel;
 import lombok.Data;
 
+import java.io.Serializable;
 import java.math.BigDecimal;
 
 /**
@@ -12,7 +13,9 @@ import java.math.BigDecimal;
  */
 @Data
 @ApiModel("归集数据标记")
-public class AfterIncomegroup {
+public class AfterIncomegroup implements Serializable {
+
+    private static final long serialVersionUID = 1L;
 
     /**
      * 开单科室状态 1 收益中心 2 执行中心
@@ -52,5 +55,5 @@ public class AfterIncomegroup {
     /**
      * 是直接还是间接 1直接 2 间接
      */
-    private Integer directStatus=1;
+    private Integer directStatus = 1;
 }

+ 0 - 132
src/main/java/com/imed/costaccount/model/GetCheckData.java

@@ -1,132 +0,0 @@
-package com.imed.costaccount.model;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.imed.costaccount.common.exception.CostException;
-import com.imed.costaccount.service.*;
-import io.swagger.annotations.ApiModel;
-import lombok.Data;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.CollectionUtils;
-
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-/**
- * @author 李加喜
- * @Package com.imed.costaccount.model
- * @date 2021-08-10 17:15
- */
-@Data
-@ApiModel("获取数据")
-public class GetCheckData {
-    @Autowired
-    private DepartmentService departmentService;
-
-    @Autowired
-    private ResponsibilityService responsibilityService;
-
-    @Autowired
-    private ProductService productService;
-
-    @Autowired
-    private  AccountingService accountingService;
-
-    @Autowired
-    private ResponsibilityDepartmentService responsibilityDepartmentService;
-
-    @Autowired
-    private CostIncomeGroupSetService costIncomeGroupSetService;
-
-    @Autowired
-    private AccountingProductService accountingProductService;
-    private Long hospId;
-    private Map<String, Department> departmentMap;
-    private Map<String, Product> productMap;
-    private Map<Long, Responsibility> responsibilityMap;
-    private Map<Long, Accounting> accountingMap;
-    private Map<Long, Long> responsibilityDepMap;
-    private Map<Long, Long> accountProMap;
-    private Map<Integer, CostIncomeGroupSet> incomeGroupSetMap;
-
-    public GetCheckData(Long hospId) {
-        this.hospId = hospId;
-    }
-
-    /**
-     * 根据科室Code+Name获取指定科室
-     * @return
-     */
-    public Map<String, Department> getDepartmentMap() {
-        return departmentMap;
-    }
-
-    /**
-     * 根据Product的Code+name 获取product
-     * @return
-     */
-    public Map<String, Product> getProductMap() {
-        return productMap;
-    }
-
-    /**
-     * 根据id获取责任中心
-     * @return
-     */
-    public Map<Long, Responsibility> getResponsibilityMap() {
-        return responsibilityMap;
-    }
-
-    /**
-     * 根据id后去会计科目
-     * @return
-     */
-    public Map<Long, Accounting> getAccountingMap() {
-        return accountingMap;
-    }
-
-    /**
-     * 根据科室的id获取责任中心的Id
-     * @return
-     */
-    public Map<Long, Long> getResponsibilityDepMap() {
-        return responsibilityDepMap;
-    }
-
-    /**
-     * 根据成本项目id获取会计科目Id
-     * @return
-     */
-    public Map<Long, Long> getAccountProMap() {
-        return accountProMap;
-    }
-    public Map<Integer, CostIncomeGroupSet> getIncomeGroupSetMap() {
-        return incomeGroupSetMap;
-    }
-
-    /**
-     * 根据开单科室状态科执行科室状态返回设置数据
-     * @return
-     */
-
-    public GetCheckData invoke() {
-        departmentMap = departmentService.list(new QueryWrapper<Department>().lambda().eq(Department::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getDepartmentCode() + k.getDepartmentName(), synOe -> synOe));
-        productMap = productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getProductCode() + k.getProductName(), synOe -> synOe));
-        responsibilityMap = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId)).stream().collect(Collectors.toMap(Responsibility::getId, synOe -> synOe));
-        accountingMap = accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId)).stream().collect(Collectors.toMap(Accounting::getId, synOe -> synOe));
-        incomeGroupSetMap = costIncomeGroupSetService.list(new QueryWrapper<CostIncomeGroupSet>().lambda().eq(CostIncomeGroupSet::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getOpenDepartmentStatus() + k.getStartDepartmentStatus(), synOe -> synOe));
-        List<ResponsibilityDepartment> responsibilityDepartmentList = responsibilityDepartmentService.list(new QueryWrapper<ResponsibilityDepartment>().lambda()
-                .eq(ResponsibilityDepartment::getHospId, hospId));
-        if (CollectionUtils.isEmpty(responsibilityDepartmentList)) {
-            throw new CostException(500, "没有科室责任中心对照数据");
-        }
-        List<AccountingProduct> accountingProductList = accountingProductService.list(new QueryWrapper<AccountingProduct>().lambda().eq(AccountingProduct::getHospId, hospId));
-        if (CollectionUtils.isEmpty(accountingProductList)) {
-            throw new CostException(500, "没有成本会计对照数据");
-        }
-        responsibilityDepMap = responsibilityDepartmentList.stream().collect(Collectors.toMap(ResponsibilityDepartment::getDepartmentId, ResponsibilityDepartment::getResponsibilityId));
-        accountProMap = accountingProductList.stream().collect(Collectors.toMap(AccountingProduct::getProductId, AccountingProduct::getAccountingId));
-
-        return this;
-    }
-}

+ 13 - 5
src/main/java/com/imed/costaccount/service/impl/CostIncomeGroupServiceImpl.java

@@ -150,11 +150,7 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
             throw new CostException(500, year + "年" + month + "月数据已存在");
         }
         // 移除前几行的抬头内容  list的大小对应的就是行数的大小
-        for (int i = list.size() - 1; i >= 0; i--) {
-            if (i == NumberConstant.ZERO || i == NumberConstant.ONE || i == NumberConstant.TWO || i == NumberConstant.THREE) {
-                list.remove(list.get(i));
-            }
-        }
+        removeTitle(list);
         log.info("读取的数据为:{}", list);
         List<IncomeErrorMessage> incomeErrorMessageList = new ArrayList<>();
         //获取所有的科室 成本项目 责任中心 会计科目
@@ -198,6 +194,14 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
         }
     }
 
+    private void removeTitle(List<List<Object>> list) {
+        for (int i = list.size() - 1; i >= 0; i--) {
+            if (i == NumberConstant.ZERO || i == NumberConstant.ONE || i == NumberConstant.TWO || i == NumberConstant.THREE) {
+                list.remove(list.get(i));
+            }
+        }
+    }
+
     /**
      * 返回成本会计对照数据  Key 成本项目Id   Value 会计科目Id
      *
@@ -282,6 +286,10 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
      */
     @Override
     public Result importDataByIncomeData(List<List<Object>> read, User user, MultipartFile file, Integer year, Integer month) {
+        // 去头
+        this.removeTitle(read);
+
+
         return null;
     }
 

+ 20 - 8
src/main/java/com/imed/costaccount/service/impl/IncomeCollectionServiceImpl.java

@@ -1,13 +1,16 @@
 package com.imed.costaccount.service.impl;
 
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.template.TemplateUtil;
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.imed.costaccount.common.constants.Constant;
 import com.imed.costaccount.common.exception.CostException;
 import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.mapper.CostIncomeGroupMapper;
+import com.imed.costaccount.model.AfterIncomegroup;
 import com.imed.costaccount.model.CostIncomeGroup;
 import com.imed.costaccount.model.dto.CollectDTO;
 import com.imed.costaccount.model.vo.CollectedVO;
@@ -112,24 +115,33 @@ public class IncomeCollectionServiceImpl
             incomeCollection.setAccountingName(costIncomeGroup.getAccountName());
             incomeCollection.setProductName(costIncomeGroup.getProductName());
             incomeCollection.setProductCode(costIncomeGroup.getProductCode());
+            incomeCollection.setAmount(costIncomeGroup.getAmount());
             incomeCollection.setHospId(hospId);
             // todo 来源id暂时不确定
             incomeCollection.setFileId(costIncomeGroup.getFileId());
             incomeCollection.setCreateTime(System.currentTimeMillis());
-            // TODO: 2021/8/10 待确认是否收入中心
+            String afterIncomeGroupStr = costIncomeGroup.getAfterIncomeGroup();
+            AfterIncomegroup afterIncomegroup = JSONUtil.toBean(afterIncomeGroupStr, AfterIncomegroup.class);
+            if (Objects.isNull(afterIncomegroup)) {
+                throw new CostException("未能正确归集对应的....");
+            }
             // 开单中心的数据
-            incomeCollection.setDepartmentCode(costIncomeGroup.getOpenDepartmentCode());
-            incomeCollection.setResponsibilityCode(costIncomeGroup.getOpenResponsibilityCode());
-            incomeCollection.setAmount(costIncomeGroup.getOpenDepartmentAmount());
+            incomeCollection.setDepartmentCode(afterIncomegroup.getOpenDepartmentCode());
+            incomeCollection.setDepartmentName(afterIncomegroup.getOpenDepartmentName());
+            incomeCollection.setResponsibilityCode(afterIncomegroup.getResponsibilityCode());
+            incomeCollection.setResponsibilityName(afterIncomegroup.getResponsibilityName());
+
             list.add(incomeCollection);
             // 执行科室数据
-            incomeCollection.setDepartmentCode(costIncomeGroup.getStartDepartmentCode());
-            incomeCollection.setResponsibilityCode(costIncomeGroup.getStartResponsibilityCode());
-            incomeCollection.setAmount(costIncomeGroup.getStartDepartmentAmount());
+            incomeCollection.setDepartmentCode(afterIncomegroup.getStartDepartmentCode());
+            incomeCollection.setDepartmentName(afterIncomegroup.getStartDepartmentName());
+            incomeCollection.setResponsibilityCode(afterIncomegroup.getResponsibilityCode());
+            incomeCollection.setResponsibilityName(afterIncomegroup.getResponsibilityName());
             list.add(incomeCollection);
         });
 
-        // TODO: 2021/8/10 几十万条数据如何处理
+
+        // TODO: 2021/8/10 几十万条数据如何处理 待测试处理
         this.saveBatch(list);
     }
 

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

@@ -481,33 +481,33 @@ public class ExcelController {
         }
     }
 
-    @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, "导入失败");
-        }
-
-    }
+//    @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, "导入失败");
+//        }
+//
+//    }
 
 }

+ 22 - 0
src/main/resources/mapper/CostIncomeGroupMapper.xml

@@ -53,4 +53,26 @@
         from cost_income_group
         group by open_department_code , start_department_code , product_code;
     </select>
+
+    <select id="getCollections" resultType="com.imed.costaccount.model.vo.CollectionVO">
+        select file_id, date_year, date_month, sum(amount) as amount
+        from cost_income_group
+        where hosp_id = #{hospId}
+        <if test="date != null and date != ''">
+            date_year = YEAR(concat(#{date},'01')) and date_month = MONTH(concat(#{date},'01'))
+        </if>
+        group by date_month, date_year
+        limit #{startIndex},#{pageSize}
+    </select>
+
+    <select id="getCollectionCount" resultType="java.lang.Integer">
+        select count(*)
+        from cost_income_group
+        where hosp_id = #{hospId}
+        <if test="date != null and date != ''">
+            date_year = YEAR(concat(#{date},'01')) and date_month = MONTH(concat(#{date},'01'))
+        </if>
+    </select>
+
+
 </mapper>