ljx 4 anni fa
parent
commit
d53474db6d

+ 8 - 8
src/main/java/com/imed/costaccount/common/config/CorsConfig.java

@@ -17,8 +17,8 @@ public class CorsConfig implements WebMvcConfigurer {
 
 
 
-//    @Value("${file.filelocal}")
-//    private String fileLocal;
+    @Value("${file.filelocal}")
+    private String fileLocal;
 
     @Bean
     public CorsFilter corsFilter() {
@@ -43,12 +43,12 @@ public class CorsConfig implements WebMvcConfigurer {
      * 对于解决其他目录的需要重新修改
      * @param registry
      */
-//    @Override
-//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
-//        registry.addResourceHandler("/**")
-//                .addResourceLocations("classpath:/static/**")
-//                .addResourceLocations(fileLocal);//映射本地静态资源
-//    }
+    @Override
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
+        registry.addResourceHandler("/**")
+                .addResourceLocations("classpath:/static/**")
+                .addResourceLocations(fileLocal);//映射本地静态资源
+    }
 
 
 

+ 108 - 76
src/main/java/com/imed/costaccount/service/impl/CostIncomeGroupServiceImpl.java

@@ -65,29 +65,29 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
     @Override
     public PageUtils queryList(Integer current, Integer pageSize, String dateTime, String responsibilityCode, String accountCode, Long hospId) {
         int year = 0;
-        int month=0;
-        if (StrUtil.isNotBlank(dateTime)){
+        int month = 0;
+        if (StrUtil.isNotBlank(dateTime)) {
             year = DateUtils.getYear(dateTime);
-            month=DateUtils.getMonth(dateTime);
+            month = DateUtils.getMonth(dateTime);
         }
         Page<CostIncomeGroup> costIncomeGroupPage = new Page<>(current, pageSize);
-        Page<CostIncomeGroup> pages= this.page(costIncomeGroupPage,new QueryWrapper<CostIncomeGroup>().lambda()
-                .eq(Objects.nonNull(hospId),CostIncomeGroup::getHospId,hospId)
-                .eq(!NumberConstant.ZERO.equals(year),CostIncomeGroup::getDateYear,year)
-                .eq(!NumberConstant.ONE.equals(month),CostIncomeGroup::getDateMonth,month)
-                .and(StrUtil.isNotBlank(responsibilityCode),i->i.like(CostIncomeGroup::getOpenResponsibilityCode,responsibilityCode)
-                .or().like(CostIncomeGroup::getStartResponsibilityCode, responsibilityCode))
-                .like(StrUtil.isNotBlank(accountCode),CostIncomeGroup::getAccountCode,accountCode));
+        Page<CostIncomeGroup> pages = this.page(costIncomeGroupPage, new QueryWrapper<CostIncomeGroup>().lambda()
+                .eq(Objects.nonNull(hospId), CostIncomeGroup::getHospId, hospId)
+                .eq(!NumberConstant.ZERO.equals(year), CostIncomeGroup::getDateYear, year)
+                .eq(!NumberConstant.ONE.equals(month), CostIncomeGroup::getDateMonth, month)
+                .and(StrUtil.isNotBlank(responsibilityCode), i -> i.like(CostIncomeGroup::getOpenResponsibilityCode, responsibilityCode)
+                        .or().like(CostIncomeGroup::getStartResponsibilityCode, responsibilityCode))
+                .like(StrUtil.isNotBlank(accountCode), CostIncomeGroup::getAccountCode, accountCode));
         List<CostIncomeGroup> records = pages.getRecords();
         List<CostIncomeGroupBeforeVO> costIncomeGroupBeforeVOList = BeanUtil.convertList(records, CostIncomeGroupBeforeVO.class);
         // 查询所有的责任中心 科室 会计科目  成本项目的数据  处理名字
         setCodeName(hospId, costIncomeGroupBeforeVOList);
         // 进行金额合并
-        List<CostIncomeGroupAllAmountVO> costIncomeGroupAllAmountVoS =baseMapper.countMoney(costIncomeGroupBeforeVOList);
+        List<CostIncomeGroupAllAmountVO> costIncomeGroupAllAmountVoS = baseMapper.countMoney(costIncomeGroupBeforeVOList);
         //  对,的金额进行合并
-        costIncomeGroupAllAmountVoS.forEach(i->{
+        costIncomeGroupAllAmountVoS.forEach(i -> {
             String allMoney = i.getAllMoney();
-            if (allMoney.contains(StrUtil.COMMA)){
+            if (allMoney.contains(StrUtil.COMMA)) {
                 // 存在,在进行求和
                 long sum;
                 List<Long> list = Arrays.stream(allMoney.split(StrUtil.COMMA)).map(Long::valueOf).collect(Collectors.toList());
@@ -103,12 +103,12 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
     /**
      * 批量导入收入数据
      *
-     * @param list 输入的文件
+     * @param list   输入的文件
      * @param hospId 医院Id
      * @return
      */
     @Override
-    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public Result importIncomeGroup(List<List<Object>> list, Long hospId) {
         // 移除前几行的抬头内容  list的大小对应的就是行数的大小
         for (int i = list.size() - 1; i >= 0; i--) {
@@ -121,142 +121,174 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
         List<IncomeErrorMessage> incomeErrorMessageList = new ArrayList<>();
         //获取所有的科室 成本项目 责任中心 会计科目
         Map<String, Department> departmentMap = departmentService.list(new QueryWrapper<Department>().lambda().eq(Department::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getDepartmentCode() + k.getDepartmentName(), synOe -> synOe));
-        Map<String,Product> productMap= productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getProductCode() + k.getProductName(), synOe -> synOe));
-        Map<Long, Responsibility> responsibilityMap = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId)).stream().collect(Collectors.toMap(Responsibility::getId,synOe->synOe));
+        Map<String, Product> productMap = productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getProductCode() + k.getProductName(), synOe -> synOe));
+        Map<Long, Responsibility> responsibilityMap = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId)).stream().collect(Collectors.toMap(Responsibility::getId, synOe -> synOe));
         Map<Long, Accounting> accountingMap = accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId)).stream().collect(Collectors.toMap(Accounting::getId, synOe -> synOe));
         List<ResponsibilityDepartment> responsibilityDepartmentList = responsibilityDepartmentService.list(new QueryWrapper<ResponsibilityDepartment>().lambda()
                 .eq(ResponsibilityDepartment::getHospId, hospId));
-        if (CollectionUtils.isEmpty(responsibilityDepartmentList)){
-            throw new CostException(500,"没有科室责任中心对照数据");
+        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,"没有成本会计对照数据");
+        if (CollectionUtils.isEmpty(accountingProductList)) {
+            throw new CostException(500, "没有成本会计对照数据");
         }
         Map<Long, Long> responsibilityDepMap = responsibilityDepartmentList.stream().collect(Collectors.toMap(ResponsibilityDepartment::getDepartmentId, ResponsibilityDepartment::getResponsibilityId));
         Map<Long, Long> accountProMap = accountingProductList.stream().collect(Collectors.toMap(AccountingProduct::getProductId, AccountingProduct::getAccountingId));
-        checkImportData(list, incomeErrorMessageList, departmentMap, productMap, responsibilityMap, accountingMap, responsibilityDepMap, accountProMap);
-        if (!CollectionUtils.isEmpty(incomeErrorMessageList)){
+        List<CostIncomeGroup> costIncomeGroupArrayList = new ArrayList<>();
+        checkImportData(list, incomeErrorMessageList,costIncomeGroupArrayList, departmentMap, productMap, responsibilityMap, accountingMap, responsibilityDepMap, accountProMap);
+
+        if (!CollectionUtils.isEmpty(incomeErrorMessageList)) {
             // 说明存在错误数据
             // TODO 不讲数据保存在收入归集表里面  直将信息保存在提交记录里面
-        }else {
-            // 实现厨具的存储
-
+        } else {
+            // 实现数据的存储
+            for (int i = 0; i < list.size(); i++) {
+                CostIncomeGroup costIncomeGroup = new CostIncomeGroup();
+                List<Object> data = list.get(i);
+                // 成本项目的代码和名称
+                String productCode = data.get(0).toString();
+                // 开单科室 执行科室的代码和名称
+                String openDepartmentCode = data.get(3).toString();
+                String startDepartmentCode = data.get(5).toString();
+                String beforeMoney = data.get(6).toString();
+//                if ()
+            }
         }
         return Result.ok();
     }
 
     /**
-     *检验数据
-     * @param list 表单数据
+     * 检验数据
+     *  @param list                   表单数据
      * @param incomeErrorMessageList 存储错误信息的集合
-     * @param departmentMap 科室Map
-     * @param productMap 成本项目map
-     * @param responsibilityMap 责任中心Map
-     * @param accountingMap 会计科目Map
-     * @param responsibilityDepMap 责任中心科室对照Map
-     * @param accountProMap 责任中心Map
+     * @param costIncomeGroupArrayList
+     * @param departmentMap          科室Map
+     * @param productMap             成本项目map
+     * @param responsibilityMap      责任中心Map
+     * @param accountingMap          会计科目Map
+     * @param responsibilityDepMap   责任中心科室对照Map
+     * @param accountProMap          责任中心Map
      */
-    private void checkImportData(List<List<Object>> list, List<IncomeErrorMessage> incomeErrorMessageList, Map<String, Department> departmentMap, Map<String, Product> productMap, Map<Long, Responsibility> responsibilityMap, Map<Long, Accounting> accountingMap, Map<Long, Long> responsibilityDepMap, Map<Long, Long> accountProMap) {
+    private void checkImportData(List<List<Object>> list, List<IncomeErrorMessage> incomeErrorMessageList, List<CostIncomeGroup> costIncomeGroupArrayList, Map<String, Department> departmentMap, Map<String, Product> productMap, Map<Long, Responsibility> responsibilityMap, Map<Long, Accounting> accountingMap, Map<Long, Long> responsibilityDepMap, Map<Long, Long> accountProMap) {
         for (int i = 0; i < list.size(); i++) {
+            CostIncomeGroup costIncomeGroup = new CostIncomeGroup();
             // 用来检验数据合理性的循环
             IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
             List<Object> data = list.get(i);
-            log.info("用户输入的数据是{}",data);
+            log.info("用户输入的数据是{}", data);
             Object money = data.get(data.size() - 1);
-            if (!Objects.isNull(money) && !NumberConstant.ZERO.equals(Integer.parseInt(money.toString()))){
+            // 成本项目的代码和名称
+            String productCode = data.get(0).toString();
+            String productName = data.get(1).toString();
+            // 开单科室 执行科室的代码和名称
+            String openDepartmentName = data.get(2).toString();
+            String openDepartmentCode = data.get(3).toString();
+            String startDepartmentName = data.get(4).toString();
+            String startDepartmentCode = data.get(5).toString();
+            BigDecimal beforeMoney = (BigDecimal)data.get(6);
+            if (!Objects.isNull(money) && !NumberConstant.ZERO.equals(Integer.parseInt(money.toString()))) {
                 // 要求这一行的数据必须全部填写
-                for (int j=0;j<data.size();j++){
-                    if (Objects.isNull(data.get(j))){
+                for (int j = 0; j < data.size(); j++) {
+                    if (Objects.isNull(data.get(j))) {
                         incomeErrorMessage.setTotal(i);
-                        int row=i+1;
-                        int column=j+1;
-                        incomeErrorMessage.setErrMessage("第{"+row+"}行第{"+column+"}列数据为空");
+                        int row = i + 1;
+                        int column = j + 1;
+                        incomeErrorMessage.setErrMessage("第{" + row + "}行第{" + column + "}列数据为空");
                         incomeErrorMessageList.add(incomeErrorMessage);
                     }
                 }
                 // TODO 暂时不走循环  直接获取数据的处理
-                // 成本项目的代码和名称
-                String productCode = data.get(0).toString();
-                String productName = data.get(1).toString();
-                // 开单科室 执行科室的代码和名称
-                String openDepartmentName = data.get(2).toString();
-                String openDepartmentCode = data.get(3).toString();
-                String startDepartmentName = data.get(4).toString();
-                String startDepartmentCode = data.get(5).toString();
                 // 检验数据是否存在
                 Product product = productMap.get(productCode + productName);
                 Department department = departmentMap.get(openDepartmentCode + openDepartmentName);
                 Department department1 = departmentMap.get(startDepartmentCode + startDepartmentName);
-                if (Objects.isNull(product)){
+                if (Objects.isNull(product)) {
                     incomeErrorMessage.setTotal(i);
-                    incomeErrorMessage.setErrMessage("代码:"+productCode+" 名称:"+productName+"成本项目不存在");
+                    incomeErrorMessage.setErrMessage("代码:" + productCode + " 名称:" + productName + "成本项目不存在");
                     incomeErrorMessageList.add(incomeErrorMessage);
-                }else {
+                } else {
                     // 检验对应的会计科目是否存在
                     Long id = product.getId();
                     Long accountId = accountProMap.get(id);
-                    if (Objects.isNull(accountingMap.get(accountId))){
+                    if (Objects.isNull(accountingMap.get(accountId))) {
                         incomeErrorMessage.setTotal(i);
-                        incomeErrorMessage.setErrMessage("代码:"+productCode+" 名称:"+productName+"成本项目对应的会计科目不存在");
+                        incomeErrorMessage.setErrMessage("代码:" + productCode + " 名称:" + productName + "成本项目对应的会计科目不存在");
                         incomeErrorMessageList.add(incomeErrorMessage);
+                    }else{
+                        costIncomeGroup.setProductCode(productCode);
+                        costIncomeGroup.setAccountCode(accountingMap.get(accountId).getAccountingCode());
                     }
                 }
                 // 开单科室
-                if (Objects.isNull(department)){
+                if (Objects.isNull(department)) {
                     incomeErrorMessage.setTotal(i);
-                    incomeErrorMessage.setErrMessage("代码:"+productCode+" 名称:"+productName+"开单科室不存在");
+                    incomeErrorMessage.setErrMessage("代码:" + productCode + " 名称:" + productName + "开单科室不存在");
                     incomeErrorMessageList.add(incomeErrorMessage);
-                }else{
+                } else {
                     Long id = department.getId();
                     Long responsibilityId = responsibilityDepMap.get(id);
-                    if (Objects.isNull(responsibilityMap.get(responsibilityId))){
+                    if (Objects.isNull(responsibilityMap.get(responsibilityId))) {
                         incomeErrorMessage.setTotal(i);
-                        incomeErrorMessage.setErrMessage("代码:"+openDepartmentCode+" 名称:"+openDepartmentName+"科室对应的责任中心不存在");
+                        incomeErrorMessage.setErrMessage("代码:" + openDepartmentCode + " 名称:" + openDepartmentName + "科室对应的责任中心不存在");
                         incomeErrorMessageList.add(incomeErrorMessage);
+                    }else {
+                        costIncomeGroup.setOpenDepartmentCode(openDepartmentCode);
+                        costIncomeGroup.setOpenResponsibilityCode(responsibilityMap.get(responsibilityId).getResponsibilityCode());
                     }
                 }
                 //执行科室
-                if (Objects.isNull(department1)){
+                if (Objects.isNull(department1)) {
                     incomeErrorMessage.setTotal(i);
-                    incomeErrorMessage.setErrMessage("代码:"+productCode+" 名称:"+productName+"执行科室不存在");
+                    incomeErrorMessage.setErrMessage("代码:" + productCode + " 名称:" + productName + "执行科室不存在");
                     incomeErrorMessageList.add(incomeErrorMessage);
-                }else{
+                } else {
                     Long id = department1.getId();
                     Long responsibilityId = responsibilityDepMap.get(id);
-                    if (Objects.isNull(responsibilityMap.get(responsibilityId))){
+                    if (Objects.isNull(responsibilityMap.get(responsibilityId))) {
                         incomeErrorMessage.setTotal(i);
-                        incomeErrorMessage.setErrMessage("代码:"+openDepartmentCode+" 名称:"+openDepartmentName+"科室对应的责任中心不存在");
+                        incomeErrorMessage.setErrMessage("代码:" + openDepartmentCode + " 名称:" + openDepartmentName + "科室对应的责任中心不存在");
                         incomeErrorMessageList.add(incomeErrorMessage);
+                    }else {
+                        costIncomeGroup.setStartDepartmentCode(startDepartmentCode);
+                        costIncomeGroup.setStartResponsibilityCode(responsibilityMap.get(responsibilityId).getResponsibilityCode());
                     }
                 }
+                costIncomeGroup.setAmount(beforeMoney);
+            }else {
+                // 最后一位是0 或者是null的情况
+                if (StrUtil.isNotBlank(productCode)){
+                    costIncomeGroup.setProductCode(productCode);
+//                    costIncomeGroup.setAccountCode(accountingMap.get(accountId))
+                }
             }
         }
     }
 
     /**
      * 设置相关名称
+     *
      * @param hospId
      * @param costIncomeGroupBeforeVOList
      */
     private void setCodeName(Long hospId, List<CostIncomeGroupBeforeVO> costIncomeGroupBeforeVOList) {
         List<Responsibility> responsibilityList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId));
-        Map<String, String> responsibilityMap = responsibilityList.stream().collect(Collectors.toMap(Responsibility::getResponsibilityCode,Responsibility::getResponsibilityName));
+        Map<String, String> responsibilityMap = responsibilityList.stream().collect(Collectors.toMap(Responsibility::getResponsibilityCode, Responsibility::getResponsibilityName));
         List<Department> departmentList = departmentService.list(new QueryWrapper<Department>().lambda().eq(Department::getHospId, hospId));
-        Map<String, String> departmentMap = departmentList.stream().collect(Collectors.toMap(Department::getDepartmentCode,Department::getDepartmentName));
+        Map<String, String> departmentMap = departmentList.stream().collect(Collectors.toMap(Department::getDepartmentCode, Department::getDepartmentName));
         List<Product> productList = productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId));
-        Map<String, String> productMap = productList.stream().collect(Collectors.toMap(Product::getProductCode,Product::getProductName));
+        Map<String, String> productMap = productList.stream().collect(Collectors.toMap(Product::getProductCode, Product::getProductName));
         List<Accounting> accountingList = accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId));
-        Map<String, String> accountMap = accountingList.stream().collect(Collectors.toMap(Accounting::getAccountingCode,Accounting::getAccountingName));
-        costIncomeGroupBeforeVOList.forEach(i->{
+        Map<String, String> accountMap = accountingList.stream().collect(Collectors.toMap(Accounting::getAccountingCode, Accounting::getAccountingName));
+        costIncomeGroupBeforeVOList.forEach(i -> {
             // 以为这里的数据导入的  在导入的时候进行数据校验
             // 设置开单科室名称 执行科室名称  开单责任中心名称  执行责任中心名称 成本项目的名称 会计科目名称
-            i.setOpenDepartmentCodeName("["+i.getOpenDepartmentCode()+"]"+departmentMap.get(i.getOpenDepartmentCode()));
-            i.setOpenResponsibilityCodeName("["+i.getOpenResponsibilityCode()+"]"+responsibilityMap.get(i.getOpenResponsibilityCode()));
-            i.setStartDepartmentCodeName("["+i.getStartDepartmentCode()+"]"+departmentMap.get(i.getStartDepartmentCode()));
-            i.setStartResponsibilityCodeName("["+i.getStartResponsibilityCode()+"]"+responsibilityMap.get(i.getStartResponsibilityCode()));
-            i.setProductCodeName("["+i.getProductCode()+"]"+productMap.get(i.getProductCode()));
-            i.setAccountCodeName("["+i.getAccountCode()+"]"+accountMap.get(i.getAccountCode()));
+            i.setOpenDepartmentCodeName("[" + i.getOpenDepartmentCode() + "]" + departmentMap.get(i.getOpenDepartmentCode()));
+            i.setOpenResponsibilityCodeName("[" + i.getOpenResponsibilityCode() + "]" + responsibilityMap.get(i.getOpenResponsibilityCode()));
+            i.setStartDepartmentCodeName("[" + i.getStartDepartmentCode() + "]" + departmentMap.get(i.getStartDepartmentCode()));
+            i.setStartResponsibilityCodeName("[" + i.getStartResponsibilityCode() + "]" + responsibilityMap.get(i.getStartResponsibilityCode()));
+            i.setProductCodeName("[" + i.getProductCode() + "]" + productMap.get(i.getProductCode()));
+            i.setAccountCodeName("[" + i.getAccountCode() + "]" + accountMap.get(i.getAccountCode()));
         });
     }
     /**

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

@@ -53,4 +53,6 @@ logging:
   config: classpath:log4j2.xml
   level:
     io.swagger.models.parameters.AbstractSerializableParameter: error
+file:
+  filelocal: