ljx 4 anni fa
parent
commit
a40bd4a98f

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

@@ -22,15 +22,22 @@ import java.util.stream.Collectors;
 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;
@@ -40,6 +47,7 @@ public class GetCheckData {
     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;
@@ -92,12 +100,21 @@ public class GetCheckData {
     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)) {
@@ -109,6 +126,7 @@ public class GetCheckData {
         }
         responsibilityDepMap = responsibilityDepartmentList.stream().collect(Collectors.toMap(ResponsibilityDepartment::getDepartmentId, ResponsibilityDepartment::getResponsibilityId));
         accountProMap = accountingProductList.stream().collect(Collectors.toMap(AccountingProduct::getProductId, AccountingProduct::getAccountingId));
+
         return this;
     }
 }

+ 40 - 0
src/main/java/com/imed/costaccount/model/vo/CostIncomeFileVO.java

@@ -0,0 +1,40 @@
+package com.imed.costaccount.model.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author 李加喜
+ * @Package com.imed.costaccount.model.vo
+ * @date 2021-08-10 18:18
+ */
+@Data
+@ApiModel("分页查询文件列表数据")
+public class CostIncomeFileVO {
+    /**
+     * 主键 文件编号
+     */
+    @ApiModelProperty(name = "id",value = "文件编号")
+    private Long id;
+
+    @ApiModelProperty(name = "fileType",value = "文件类型")
+    private String fileType;
+    @ApiModelProperty(name = "fileName",value = "文件名称")
+    private String fileName;
+
+    @ApiModelProperty(name = "successAmount",value = "导入成功记录数")
+    private Integer successAmount;
+    @ApiModelProperty(name = "totalAmount",value = "总记录数")
+    private Integer totalAmount;
+    @ApiModelProperty(name = "userName",value = "导入人员")
+    private String userName;
+    /**
+     * 错误详情
+     */
+    private String errorList;
+    /**
+     * 是否显示错误详情按钮
+     */
+    private Integer errStatus=0;
+}

+ 11 - 0
src/main/java/com/imed/costaccount/service/CostIncomeFileService.java

@@ -1,6 +1,7 @@
 package com.imed.costaccount.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.model.CostIncomeFile;
 import com.imed.costaccount.model.User;
 import com.imed.costaccount.model.vo.IncomeErrorMessage;
@@ -28,5 +29,15 @@ public interface CostIncomeFileService extends IService<CostIncomeFile> {
      * @return
      */
     CostIncomeFile saveCostIncomeFile(List<List<Object>> list, User user, MultipartFile file, Long hospId, List<IncomeErrorMessage> incomeErrorMessageList, String uploadFile);
+
+    /**
+     * 分页查询查询记录数据
+     * @param current
+     * @param pageSize
+     * @param name
+     * @param hospId
+     * @return
+     */
+    PageUtils queryList(Integer current, Integer pageSize, String name, Long hospId);
 }
 

+ 33 - 0
src/main/java/com/imed/costaccount/service/impl/CostIncomeFileServiceImpl.java

@@ -1,11 +1,17 @@
 package com.imed.costaccount.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.imed.costaccount.common.util.BeanUtil;
+import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.constants.NumberConstant;
 import com.imed.costaccount.mapper.CostIncomeFileMapper;
 import com.imed.costaccount.model.CostIncomeFile;
 import com.imed.costaccount.model.User;
+import com.imed.costaccount.model.vo.CostIncomeFileVO;
 import com.imed.costaccount.model.vo.IncomeErrorMessage;
 import com.imed.costaccount.service.CostIncomeFileService;
 import org.springframework.stereotype.Service;
@@ -49,4 +55,31 @@ public class CostIncomeFileServiceImpl extends ServiceImpl<CostIncomeFileMapper,
         this.save(costIncomeFile);
         return costIncomeFile;
     }
+
+    /**
+     * 分页查询查询记录数据
+     *
+     * @param current
+     * @param pageSize
+     * @param name
+     * @param hospId
+     * @return
+     */
+    @Override
+    public PageUtils queryList(Integer current, Integer pageSize, String name, Long hospId) {
+        Page<CostIncomeFile> costIncomeFilePage = new Page<>(current, pageSize);
+        Page<CostIncomeFile> page = this.page(costIncomeFilePage, new QueryWrapper<CostIncomeFile>().lambda()
+                .eq(CostIncomeFile::getHospId, hospId).like(StrUtil.isNotBlank(name), CostIncomeFile::getFileName, name));
+        List<CostIncomeFile> records = page.getRecords();
+        List<CostIncomeFileVO> costIncomeFileVOList = BeanUtil.convertList(records, CostIncomeFileVO.class);
+        costIncomeFileVOList.forEach(i->{
+            String errorList = i.getErrorList();
+            if (StrUtil.isNotBlank(errorList)){
+                i.setErrStatus(NumberConstant.ONE);
+            }
+        });
+        PageUtils pageUtils = new PageUtils(page);
+        pageUtils.setList(costIncomeFileVOList);
+        return pageUtils;
+    }
 }

+ 21 - 8
src/main/java/com/imed/costaccount/service/impl/CostIncomeGroupServiceImpl.java

@@ -129,7 +129,13 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
     @Override
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public Result importIncomeGroup(List<List<Object>> list, User user, MultipartFile file,Integer year,Integer month) {
+        // 先检验当前年月是否存在数据
         Long hospId = user.getHospId();
+        List<CostIncomeGroup> groups = this.list(new QueryWrapper<CostIncomeGroup>().lambda().eq(CostIncomeGroup::getHospId, hospId)
+                .eq(CostIncomeGroup::getDateYear, year).eq(CostIncomeGroup::getDateMonth, month));
+        if (!CollectionUtils.isEmpty(groups)){
+            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) {
@@ -139,13 +145,21 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
         log.info("读取的数据为:{}", list);
         List<IncomeErrorMessage> incomeErrorMessageList = new ArrayList<>();
         //获取所有的科室 成本项目 责任中心 会计科目
-        GetCheckData getCheckData = new GetCheckData(hospId).invoke();
-        Map<String, Department> departmentMap = getCheckData.getDepartmentMap();
-        Map<String, Product> productMap = getCheckData.getProductMap();
-        Map<Long, Responsibility> responsibilityMap = getCheckData.getResponsibilityMap();
-        Map<Long, Accounting> accountingMap = getCheckData.getAccountingMap();
-        Map<Long, Long> responsibilityDepMap = getCheckData.getResponsibilityDepMap();
-        Map<Long, Long> accountProMap = getCheckData.getAccountProMap();
+        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<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, "没有科室责任中心对照数据");
+        }
+        List<AccountingProduct> accountingProductList = accountingProductService.list(new QueryWrapper<AccountingProduct>().lambda().eq(AccountingProduct::getHospId, hospId));
+        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));
         List<CostIncomeGroup> costIncomeGroupArrayList = new ArrayList<>();
         // 检验数据
         checkImportData(list, incomeErrorMessageList, costIncomeGroupArrayList, departmentMap, productMap, responsibilityMap, accountingMap, responsibilityDepMap, accountProMap,hospId,year,month);
@@ -205,7 +219,6 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
             IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
             List<Object> data = list.get(i);
             log.info("用户输入的数据是{}", data);
-            // TODO 暂时不走循环  直接获取数据的处理
             // 成本项目的代码和名称
             String productCode = data.get(0).toString();
             String productName = data.get(1).toString();

+ 13 - 7
src/main/java/com/imed/costaccount/web/CostIncomeFileController.java

@@ -1,10 +1,12 @@
 package com.imed.costaccount.web;
 
+import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.common.util.Result;
+import com.imed.costaccount.common.util.UserContext;
 import com.imed.costaccount.model.CostIncomeFile;
-import com.imed.costaccount.model.User;
 import com.imed.costaccount.service.CostIncomeFileService;
-import org.apache.shiro.SecurityUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -18,7 +20,8 @@ import java.util.Arrays;
  * @date 2021-08-10 14:42:20
  */
 @RestController
-@RequestMapping("/costincomefile")
+@RequestMapping("/costAccount//costincomefile")
+@Api(tags = "文件记录")
 public class CostIncomeFileController {
     @Autowired
     private CostIncomeFileService costIncomeFileService;
@@ -27,11 +30,14 @@ public class CostIncomeFileController {
      * 分页查询列表
      * 查询的是
      */
-    @RequestMapping("/list")
+    @GetMapping("/list")
+    @ApiOperation("分页查询记录数据")
     public Result list(@RequestParam(value = "current", defaultValue = "1") Integer current,
-                       @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){
-        User user = (User) SecurityUtils.getSubject().getPrincipal();
-        return Result.ok();
+                       @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
+                       @RequestParam(value = "name",required = false) String name){
+        Long hospId = UserContext.getHospId();
+        PageUtils pageUtils = costIncomeFileService.queryList(current,pageSize,name,hospId);
+        return Result.ok(pageUtils);
     }