Bläddra i källkod

收入数据导入导出 成本分摊参数导入导出

ljx 4 år sedan
förälder
incheckning
6ccef14eb4
20 ändrade filer med 964 tillägg och 48 borttagningar
  1. 1 1
      pom.xml
  2. 16 0
      src/main/java/com/imed/costaccount/mapper/CostCostingGroupMapper.java
  3. 16 0
      src/main/java/com/imed/costaccount/mapper/CostShareParamGroupMapper.java
  4. 106 0
      src/main/java/com/imed/costaccount/model/CostCostingGroup.java
  5. 82 0
      src/main/java/com/imed/costaccount/model/CostShareParamGroup.java
  6. 30 0
      src/main/java/com/imed/costaccount/service/CostCostingGroupService.java
  7. 30 0
      src/main/java/com/imed/costaccount/service/CostShareParamGroupService.java
  8. 0 2
      src/main/java/com/imed/costaccount/service/CostShareParamService.java
  9. 235 0
      src/main/java/com/imed/costaccount/service/impl/CostCostingGroupServiceImpl.java
  10. 2 6
      src/main/java/com/imed/costaccount/service/impl/CostIncomeGroupServiceImpl.java
  11. 173 0
      src/main/java/com/imed/costaccount/service/impl/CostShareParamGroupServiceImpl.java
  12. 4 5
      src/main/java/com/imed/costaccount/service/impl/CostShareParamServiceImpl.java
  13. 74 0
      src/main/java/com/imed/costaccount/web/CostCostingGroupController.java
  14. 1 1
      src/main/java/com/imed/costaccount/web/CostIncomeFileController.java
  15. 74 0
      src/main/java/com/imed/costaccount/web/CostShareParamGroupController.java
  16. 63 32
      src/main/java/com/imed/costaccount/web/ExcelController.java
  17. 1 0
      src/main/resources/application-dev.yml
  18. 30 0
      src/main/resources/mapper/CostCostingGroupMapper.xml
  19. 2 1
      src/main/resources/mapper/CostIncomeGroupMapper.xml
  20. 24 0
      src/main/resources/mapper/CostShareParamGroupMapper.xml

+ 1 - 1
pom.xml

@@ -103,7 +103,7 @@
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
             <!--最好指定版本,不同环境版本可能不同-->
-            <version>5.1.17</version>
+            <version>8.0.25</version>
         </dependency>
 
         <dependency>

+ 16 - 0
src/main/java/com/imed/costaccount/mapper/CostCostingGroupMapper.java

@@ -0,0 +1,16 @@
+package com.imed.costaccount.mapper;
+
+import com.imed.costaccount.model.CostCostingGroup;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 成本归集
+ * 
+ * @author KCYG
+ * @date 2021-08-12 11:00:23
+ */
+@Mapper
+public interface CostCostingGroupMapper extends BaseMapper<CostCostingGroup> {
+	
+}

+ 16 - 0
src/main/java/com/imed/costaccount/mapper/CostShareParamGroupMapper.java

@@ -0,0 +1,16 @@
+package com.imed.costaccount.mapper;
+
+import com.imed.costaccount.model.CostShareParamGroup;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 成本分摊参数归集
+ * 
+ * @author KCYG
+ * @date 2021-08-12 16:32:47
+ */
+@Mapper
+public interface CostShareParamGroupMapper extends BaseMapper<CostShareParamGroup> {
+	
+}

+ 106 - 0
src/main/java/com/imed/costaccount/model/CostCostingGroup.java

@@ -0,0 +1,106 @@
+package com.imed.costaccount.model;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 成本归集
+ * 
+ * @author KCYG
+ * @email KCYG@xinxicom
+ * @date 2021-08-12 11:00:23
+ */
+@Data
+@Accessors(chain = true)
+@AllArgsConstructor
+@NoArgsConstructor
+@TableName("cost_costing_group")
+public class CostCostingGroup implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 成本归集的Id
+	 */
+	@TableId
+	private Long id;
+	/**
+	 * 科室的Code
+	 */
+	private String departmentCode;
+	/**
+	 * 科室名称
+	 */
+	private String departmentName;
+	/**
+	 * 责任中心的Code
+	 */
+	private String responsibilityCode;
+	/**
+	 * 责任中心名称
+	 */
+	private String responsibilityName;
+	/**
+	 * 其他责任中心Code
+	 */
+	private String otherResponsibilityCode;
+	/**
+	 * 其他责任中心名称
+	 */
+	private String otherResponsibilityName;
+	/**
+	 * 成本项目的Code
+	 */
+	private String productCode;
+	/**
+	 * 成本项目的名称
+	 */
+	private String productName;
+	/**
+	 * 会计科目Code
+	 */
+	private String accountCode;
+	/**
+	 * 会计科目名称
+	 */
+	private String accountName;
+	/**
+	 * 金额
+	 */
+	private BigDecimal amount;
+	/**
+	 * 归属医院id
+	 */
+	private Long hospId;
+	/**
+	 * 文件id
+	 */
+	private Long fileId;
+	/**
+	 * 统计数据
+	 */
+	private String afterIncomeGroup;
+	/**
+	 * 年份
+	 */
+	private Integer dateYear;
+	/**
+	 * 月份
+	 */
+	private Integer dateMonth;
+	/**
+	 * 创建时间13位时间戳
+	 */
+	private Long createTime;
+	/**
+	 * 删除时间,如果存在表示已删除13位时间戳
+	 */
+	private Long deleteTime;
+
+}

+ 82 - 0
src/main/java/com/imed/costaccount/model/CostShareParamGroup.java

@@ -0,0 +1,82 @@
+package com.imed.costaccount.model;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 成本分摊参数归集
+ * 
+ * @author KCYG
+ * @email KCYG@xinxicom
+ * @date 2021-08-12 16:32:47
+ */
+@Data
+@Accessors(chain = true)
+@AllArgsConstructor
+@NoArgsConstructor
+@TableName("cost_share_param_group")
+public class CostShareParamGroup implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 成本分摊参数归集的Id
+	 */
+	@TableId
+	private Long id;
+	/**
+	 * 成本分摊参数代码
+	 */
+	private String shareParamCode;
+	/**
+	 * 成本分摊参数名称
+	 */
+	private String shareParamName;
+	/**
+	 * 责任中心的Code
+	 */
+	private String responsibilityCode;
+	/**
+	 * 责任中心名称
+	 */
+	private String responsibilityName;
+	/**
+	 * 金额
+	 */
+	private BigDecimal amount;
+	/**
+	 * 归属医院id
+	 */
+	private Long hospId;
+	/**
+	 * 文件id
+	 */
+	private Long fileId;
+	/**
+	 * 统计数据
+	 */
+	private String afterIncomeGroup;
+	/**
+	 * 年份
+	 */
+	private Integer dateYear;
+	/**
+	 * 月份
+	 */
+	private Integer dateMonth;
+	/**
+	 * 创建时间13位时间戳
+	 */
+	private Long createTime;
+	/**
+	 * 删除时间,如果存在表示已删除13位时间戳
+	 */
+	private Long deleteTime;
+
+}

+ 30 - 0
src/main/java/com/imed/costaccount/service/CostCostingGroupService.java

@@ -0,0 +1,30 @@
+package com.imed.costaccount.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.imed.costaccount.common.util.Result;
+import com.imed.costaccount.model.CostCostingGroup;
+import com.imed.costaccount.model.User;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+/**
+ * 成本归集
+ *
+ * @author KCYG
+ * @email KCYG@xinxicom
+ * @date 2021-08-12 11:00:23
+ */
+public interface CostCostingGroupService extends IService<CostCostingGroup> {
+    /**
+     * 批量导入成本数据
+     * @param read
+     * @param user
+     * @param file
+     * @param dateTime
+     * @param fileType
+     * @return
+     */
+    Result importCostingGroup(List<List<Object>> read, User user, MultipartFile file, String dateTime, Integer fileType);
+}
+

+ 30 - 0
src/main/java/com/imed/costaccount/service/CostShareParamGroupService.java

@@ -0,0 +1,30 @@
+package com.imed.costaccount.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.imed.costaccount.common.util.Result;
+import com.imed.costaccount.model.CostShareParamGroup;
+import com.imed.costaccount.model.User;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+/**
+ * 成本分摊参数归集
+ *
+ * @author KCYG
+ * @email KCYG@xinxicom
+ * @date 2021-08-12 16:32:47
+ */
+public interface CostShareParamGroupService extends IService<CostShareParamGroup> {
+    /**
+     * 成本分摊参数导入
+     * @param read
+     * @param user
+     * @param file
+     * @param dateTime
+     * @param fileType
+     * @return
+     */
+    Result importShareParamGroup(List<List<Object>> read, User user, MultipartFile file, String dateTime, Integer fileType);
+}
+

+ 0 - 2
src/main/java/com/imed/costaccount/service/CostShareParamService.java

@@ -62,7 +62,5 @@ public interface CostShareParamService extends IService<CostShareParam> {
     CostShareParamVO getByHospIdAndAPramId(Integer id, Long hospId);
 
     List<Integer> selectIsSelect(Integer shareParamId);
-
-
 }
 

+ 235 - 0
src/main/java/com/imed/costaccount/service/impl/CostCostingGroupServiceImpl.java

@@ -0,0 +1,235 @@
+package com.imed.costaccount.service.impl;
+
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.imed.costaccount.common.exception.CostException;
+import com.imed.costaccount.common.util.DateUtils;
+import com.imed.costaccount.common.util.Result;
+import com.imed.costaccount.common.util.UserContext;
+import com.imed.costaccount.constants.NumberConstant;
+import com.imed.costaccount.enums.DateStyleEnum;
+import com.imed.costaccount.mapper.CostCostingGroupMapper;
+import com.imed.costaccount.model.*;
+import com.imed.costaccount.model.vo.IncomeErrorMessage;
+import com.imed.costaccount.service.AccountingProductService;
+import com.imed.costaccount.service.CostCostingGroupService;
+import com.imed.costaccount.service.CostIncomeFileService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.math.BigDecimal;
+import java.util.*;
+
+
+@Service("costCostingGroupService")
+@Slf4j
+public class CostCostingGroupServiceImpl extends ServiceImpl<CostCostingGroupMapper, CostCostingGroup> implements CostCostingGroupService {
+
+    private final CostIncomeGroupServiceImpl costIncomeGroupService;
+
+    private final AccountingProductService accountingProductService;
+
+    private final CostIncomeFileService costIncomeFileService;
+
+    public CostCostingGroupServiceImpl(CostIncomeGroupServiceImpl costIncomeGroupService, AccountingProductService accountingProductService, CostIncomeFileService costIncomeFileService) {
+        this.costIncomeGroupService = costIncomeGroupService;
+        this.accountingProductService = accountingProductService;
+        this.costIncomeFileService = costIncomeFileService;
+    }
+
+
+    /**
+     * 批量导入成本数据
+     *
+     * @param list
+     * @param user
+     * @param file
+     * @param dateTime
+     * @param fileType
+     * @return
+     */
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
+    public Result importCostingGroup(List<List<Object>> list, User user, MultipartFile file, String dateTime, Integer fileType) {
+        // 先检验当前年月是否存在数据
+        int year = 0;
+        int month = 0;
+        Date date = DateUtils.StringToDate(dateTime, DateStyleEnum.YYYY_MM);
+        if (StrUtil.isNotBlank(dateTime)) {
+            year = DateUtil.year(date);
+            month = DateUtil.month(date) + 1;
+        }
+        Long hospId = user.getHospId();
+        List<CostCostingGroup> groups = this.list(new QueryWrapper<CostCostingGroup>().lambda().eq(CostCostingGroup::getHospId, hospId)
+                .eq(CostCostingGroup::getDateYear, year).eq(CostCostingGroup::getDateMonth, month));
+        if (!CollectionUtils.isEmpty(groups)) {
+            throw new CostException(500, year + "年" + month + "月数据已存在");
+        }
+        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));
+            }
+        }
+        List<IncomeErrorMessage> incomeErrorMessageList = new ArrayList<>();
+        //获取所有的科室 成本项目 责任中心 会计科目
+        Map<String, Department> departmentMap = costIncomeGroupService.getDepartmentByCodeNameMap(hospId);
+        Map<String, Product> productMap = costIncomeGroupService.getProductByCodeNameMap(hospId);
+        Map<Long, Responsibility> responsibilityMap = costIncomeGroupService.getResponsibilityIdResponsibilityMap(hospId);
+        Map<Long, Accounting> accountingMap = costIncomeGroupService.getAccountIdAccountingMap(hospId);
+        List<ResponsibilityDepartment> responsibilityDepartmentList = costIncomeGroupService.getResponsibilityDepartments(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 = costIncomeGroupService.getDepartmentIdResponsibilityIdMap(responsibilityDepartmentList);
+        Map<Long, Long> accountProMap = costIncomeGroupService.getProductIdAccountIdMap(accountingProductList);
+
+        String endStatus = list.get(0).get(list.get(0).size() - 1).toString();
+        // 要保存的数据
+        List<CostCostingGroup> costCostingGroupArrayList = new LinkedList<>();
+        // 判断最后科室代码的最后一个字符是否是-1
+        if (!"-1".equals(endStatus)) {
+            // 如果没有-1说明终结符
+            IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
+            incomeErrorMessage.setTotal(5);
+            incomeErrorMessage.setErrMessage("科室代码末尾没有-1终结符");
+            incomeErrorMessageList.add(incomeErrorMessage);
+            // 文件上传
+            String uploadFile = costIncomeGroupService.uploadFile(file, UserContext.getCurrentUser());
+            // 上传记录保存
+            if (StrUtil.isBlank(uploadFile)) {
+                throw new CostException(500, "文件上传异常");
+            }
+            // 记录文件上传记录
+            CostIncomeFile costIncomeFile = costIncomeFileService.saveCostIncomeFile(list, user, file, hospId, incomeErrorMessageList, uploadFile, fileType);
+            return Result.build(500, "数据未成功导入", null);
+        }
+        // 检验收入数据
+        checkCostData(list, incomeErrorMessageList, departmentMap, productMap, responsibilityMap, accountingMap, responsibilityDepMap, accountProMap, costCostingGroupArrayList,year,month);
+        // 文件上传
+        String uploadFile = costIncomeGroupService.uploadFile(file, UserContext.getCurrentUser());
+        // 上传记录保存
+        if (StrUtil.isBlank(uploadFile)) {
+            throw new CostException(500, "文件上传异常");
+        }
+        // 记录文件上传记录
+        CostIncomeFile costIncomeFile = costIncomeFileService.saveCostIncomeFile(list, user, file, hospId, incomeErrorMessageList, uploadFile, fileType);
+        Long id = costIncomeFile.getId();
+        costCostingGroupArrayList.forEach(i -> {
+            // 设置文件Id
+            i.setFileId(id);
+        });
+        if (CollectionUtils.isEmpty(incomeErrorMessageList)) {
+            this.saveBatch(costCostingGroupArrayList);
+            return Result.build(200,"数据导入成功",null);
+        }else {
+            return Result.build(500, "数据未成功导入", null);
+        }
+    }
+
+    /**
+     * 检验成本数据
+     * @param list
+     * @param incomeErrorMessageList
+     * @param departmentMap
+     * @param productMap
+     * @param responsibilityMap
+     * @param accountingMap
+     * @param responsibilityDepMap
+     * @param accountProMap
+     * @param costCostingGroupArrayList
+     */
+    private void checkCostData(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, List<CostCostingGroup> costCostingGroupArrayList,Integer year,Integer month) {
+        List<Object> departmentCodes = list.get(0);
+        List<Object> departmentNames = list.get(1);
+        //检验数据是否准确
+        for (int i = 2; i < list.size(); i++) {
+            List<Object> data = list.get(i);
+            // 检验成本项目是否正确
+            CostCostingGroup costCostingGroupRequest = new CostCostingGroup();
+            String productCode = data.get(0).toString();
+            String productName = data.get(1).toString();
+            Product product = productMap.get(productCode + productName);
+            if (Objects.nonNull(product)) {
+                Long id = product.getId();
+                Long accountTingId = accountProMap.get(id);
+                if (Objects.nonNull(accountTingId)) {
+                    Accounting accounting = accountingMap.get(accountTingId);
+                    if (Objects.nonNull(accounting)) {
+                        costCostingGroupRequest.setProductCode(productCode);
+                        costCostingGroupRequest.setProductName(productName);
+                        costCostingGroupRequest.setAccountCode(accounting.getAccountingCode());
+                        costCostingGroupRequest.setAccountName(accounting.getAccountingName());
+                    } else {
+                        IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
+                        incomeErrorMessage.setTotal(1);
+                        incomeErrorMessage.setErrMessage("成本代码" + productCode + " 成本名称" + productName + " 不存在对应的会计科目不存在");
+                        incomeErrorMessageList.add(incomeErrorMessage);
+                    }
+                } else {
+                    IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
+                    incomeErrorMessage.setTotal(1);
+                    incomeErrorMessage.setErrMessage("成本代码" + productCode + " 成本名称" + productName + " 不存在对应的会计科目不存在");
+                    incomeErrorMessageList.add(incomeErrorMessage);
+                }
+            } else {
+                IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
+                incomeErrorMessage.setTotal(1);
+                incomeErrorMessage.setErrMessage("成本代码" + productCode + " 成本名称" + productName + "不存在");
+                incomeErrorMessageList.add(incomeErrorMessage);
+            }
+            for (int j = 2; j < data.size()-1 ; j++) {
+                CostCostingGroup costCostingGroup=costCostingGroupRequest;
+                // 检验科室信息是否准确
+                String departmentCode = departmentCodes.get(j).toString();
+                String departmentName = departmentNames.get(j).toString();
+                Department department = departmentMap.get(departmentCode + departmentName);
+                if (Objects.nonNull(department)) {
+                    // 检测责任中心是否存在
+                    Long id = department.getId();
+                    Long responsibilityId = responsibilityDepMap.get(id);
+                    if (Objects.nonNull(responsibilityId)) {
+                        Responsibility responsibility = responsibilityMap.get(responsibilityId);
+                        if (Objects.nonNull(responsibility)) {
+                            costCostingGroup.setDepartmentCode(departmentCode);
+                            costCostingGroup.setDepartmentName(departmentName);
+                            costCostingGroup.setResponsibilityCode(responsibility.getResponsibilityCode());
+                            costCostingGroup.setResponsibilityName(responsibility.getResponsibilityName());
+
+                        } else {
+                            IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
+                            incomeErrorMessage.setTotal(j);
+                            incomeErrorMessage.setErrMessage("第" + j + "列科室信息对应的责任中心不存在");
+                            incomeErrorMessageList.add(incomeErrorMessage);
+                        }
+                    } else {
+                        IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
+                        incomeErrorMessage.setTotal(j);
+                        incomeErrorMessage.setErrMessage("第" + j + "列科室信息不存在对应的责任中心");
+                        incomeErrorMessageList.add(incomeErrorMessage);
+                    }
+                } else {
+                    IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
+                    incomeErrorMessage.setTotal(j);
+                    incomeErrorMessage.setErrMessage("第" + j + "列科室信息不存在");
+                    incomeErrorMessageList.add(incomeErrorMessage);
+                }
+                costCostingGroup.setAmount(BigDecimal.valueOf(Double.parseDouble(("0".equals(data.get(j).toString()) || StrUtil.isBlank(data.get(j).toString())) ?"0.00":data.get(j).toString())));
+                costCostingGroup.setHospId(UserContext.getHospId());
+                costCostingGroup.setCreateTime(System.currentTimeMillis());
+                costCostingGroup.setDateYear(year);
+                costCostingGroup.setDateMonth(month);
+                costCostingGroupArrayList.add(costCostingGroup);
+            }
+        }
+    }
+}

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

@@ -18,7 +18,6 @@ import com.imed.costaccount.model.vo.CostIncomeGroupBeforeVO;
 import com.imed.costaccount.model.vo.IncomeErrorMessage;
 import com.imed.costaccount.service.*;
 import lombok.extern.slf4j.Slf4j;
-import org.jetbrains.annotations.NotNull;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
@@ -146,7 +145,7 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
         // 先检验当前年月是否存在数据
         int year = 0;
         int month = 0;
-        Date date = DateUtils.StringToDate(dateTime, DateStyleEnum.YYYY_MM_DD);
+        Date date = DateUtils.StringToDate(dateTime, DateStyleEnum.YYYY_MM);
         if (StrUtil.isNotBlank(dateTime)) {
             year = DateUtil.year(date);
             month = DateUtil.month(date) + 1;
@@ -216,8 +215,7 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
      * @param accountingProductList
      * @return
      */
-    @NotNull
-    private Map<Long, Long> getProductIdAccountIdMap(List<AccountingProduct> accountingProductList) {
+    public Map<Long, Long> getProductIdAccountIdMap(List<AccountingProduct> accountingProductList) {
         return accountingProductList.stream().collect(Collectors.toMap(AccountingProduct::getProductId, AccountingProduct::getAccountingId));
     }
 
@@ -296,8 +294,6 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
     public Result importDataByIncomeData(List<List<Object>> read, User user, MultipartFile file, Integer year, Integer month) {
         // 去头
         this.removeTitle(read);
-
-
         return null;
     }
 

+ 173 - 0
src/main/java/com/imed/costaccount/service/impl/CostShareParamGroupServiceImpl.java

@@ -0,0 +1,173 @@
+package com.imed.costaccount.service.impl;
+
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.imed.costaccount.common.exception.CostException;
+import com.imed.costaccount.common.util.DateUtils;
+import com.imed.costaccount.common.util.Result;
+import com.imed.costaccount.common.util.UserContext;
+import com.imed.costaccount.constants.NumberConstant;
+import com.imed.costaccount.enums.DateStyleEnum;
+import com.imed.costaccount.mapper.CostShareParamGroupMapper;
+import com.imed.costaccount.model.*;
+import com.imed.costaccount.model.vo.IncomeErrorMessage;
+import com.imed.costaccount.service.CostIncomeFileService;
+import com.imed.costaccount.service.CostShareParamGroupService;
+import com.imed.costaccount.service.CostShareParamService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+
+
+@Service("costShareParamGroupService")
+public class CostShareParamGroupServiceImpl extends ServiceImpl<CostShareParamGroupMapper, CostShareParamGroup> implements CostShareParamGroupService {
+
+    private final CostIncomeGroupServiceImpl costIncomeGroupService;
+
+    private final CostShareParamService costShareParamService;
+
+    private final CostIncomeFileService costIncomeFileService;
+
+    public CostShareParamGroupServiceImpl(CostIncomeGroupServiceImpl costIncomeGroupService, CostShareParamService costShareParamService, CostIncomeFileService costIncomeFileService) {
+        this.costIncomeGroupService = costIncomeGroupService;
+        this.costShareParamService = costShareParamService;
+        this.costIncomeFileService = costIncomeFileService;
+    }
+
+    /**
+     * 成本分摊参数导入
+     *
+     * @param list
+     * @param user
+     * @param file
+     * @param dateTime
+     * @param fileType
+     * @return
+     */
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
+    public Result importShareParamGroup(List<List<Object>> list, User user, MultipartFile file, String dateTime, Integer fileType) {
+        // 先检验当前年月是否存在数据
+        int year = 0;
+        int month = 0;
+        Date date = DateUtils.StringToDate(dateTime, DateStyleEnum.YYYY_MM);
+        if (StrUtil.isNotBlank(dateTime)) {
+            year = DateUtil.year(date);
+            month = DateUtil.month(date) + 1;
+        }
+        Long hospId = user.getHospId();
+        List<CostShareParamGroup> groups = this.list(new QueryWrapper<CostShareParamGroup>().lambda().eq(CostShareParamGroup::getHospId, hospId)
+                .eq(CostShareParamGroup::getDateYear, year).eq(CostShareParamGroup::getDateMonth, month));
+        if (!CollectionUtils.isEmpty(groups)) {
+            throw new CostException(500, year + "年" + month + "月数据已存在");
+        }
+        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));
+            }
+        }
+        List<IncomeErrorMessage> incomeErrorMessageList = new ArrayList<>();
+        Map<String, Department> departmentMap = costIncomeGroupService.getDepartmentByCodeNameMap(hospId);
+        Map<Long, Responsibility> responsibilityMap = costIncomeGroupService.getResponsibilityIdResponsibilityMap(hospId);
+        List<ResponsibilityDepartment> responsibilityDepartmentList = costIncomeGroupService.getResponsibilityDepartments(hospId);
+        if (CollectionUtils.isEmpty(responsibilityDepartmentList)) {
+            throw new CostException(500, "没有科室责任中心对照数据");
+        }
+        Map<Long, Long> responsibilityDepMap = costIncomeGroupService.getDepartmentIdResponsibilityIdMap(responsibilityDepartmentList);
+        Map<String, CostShareParam> shareParamMap = costShareParamService.list(new QueryWrapper<CostShareParam>().lambda().eq(CostShareParam::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getShareParamCode() + k.getShareParamName(), synOe -> synOe));
+        // 要保存的数据
+        List<CostShareParamGroup> costShareParamGroupList = new LinkedList<>();
+        List<Object> departmentCodes = list.get(0);
+        List<Object> departmentNames = list.get(1);
+
+        //检验数据是否准确  list包含了科室Code行与Name行 所以要从list的第三行开始
+        checkShareParamGroupData(list, year, month, incomeErrorMessageList, departmentMap, responsibilityMap, responsibilityDepMap, shareParamMap, costShareParamGroupList, departmentCodes, departmentNames);
+        // 文件上传
+        String uploadFile = costIncomeGroupService.uploadFile(file, UserContext.getCurrentUser());
+        // 上传记录保存
+        if (StrUtil.isBlank(uploadFile)) {
+            throw new CostException(500, "文件上传异常");
+        }
+        // 记录文件上传记录
+        CostIncomeFile costIncomeFile = costIncomeFileService.saveCostIncomeFile(list, user, file, hospId, incomeErrorMessageList, uploadFile, fileType);
+        Long id = costIncomeFile.getId();
+        costShareParamGroupList.forEach(i -> {
+            // 设置文件Id
+            i.setFileId(id);
+        });
+        if (CollectionUtils.isEmpty(incomeErrorMessageList)) {
+            this.saveBatch(costShareParamGroupList);
+            return Result.build(200,"数据导入成功",null);
+        }else {
+            return Result.build(500, "数据未成功导入", null);
+        }
+    }
+
+    private void checkShareParamGroupData(List<List<Object>> list, int year, int month, List<IncomeErrorMessage> incomeErrorMessageList, Map<String, Department> departmentMap, Map<Long, Responsibility> responsibilityMap, Map<Long, Long> responsibilityDepMap, Map<String, CostShareParam> shareParamMap, List<CostShareParamGroup> costShareParamGroupList, List<Object> departmentCodes, List<Object> departmentNames) {
+        for (int i = 2; i < list.size(); i++) {
+            List<Object> data = list.get(i);
+            // 检验成本分摊参数是否正确
+            CostShareParamGroup costShareParamGroupRequest = new CostShareParamGroup();
+            String shareParamCode = data.get(0).toString();
+            String shareParamName = data.get(1).toString();
+            CostShareParam costShareParam = shareParamMap.get(shareParamCode + shareParamName);
+            if (Objects.nonNull(costShareParam)){
+                costShareParamGroupRequest.setShareParamCode(shareParamCode);
+                costShareParamGroupRequest.setShareParamName(shareParamName);
+            }else {
+                IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
+                incomeErrorMessage.setTotal(1);
+                incomeErrorMessage.setErrMessage("成本分摊代码:"+shareParamCode+" 名称"+shareParamName+"不存在");
+            }
+            for (int j = 2; j < data.size() ; j++) {
+                CostShareParamGroup costShareParamGroup=costShareParamGroupRequest;
+                // 检验科室信息是否准确
+                String departmentCode = departmentCodes.get(j).toString();
+                String departmentName = departmentNames.get(j).toString();
+                Department department = departmentMap.get(departmentCode + departmentName);
+                if (Objects.nonNull(department)) {
+                    // 检测责任中心是否存在
+                    Long id = department.getId();
+                    Long responsibilityId = responsibilityDepMap.get(id);
+                    if (Objects.nonNull(responsibilityId)) {
+                        Responsibility responsibility = responsibilityMap.get(responsibilityId);
+                        if (Objects.nonNull(responsibility)) {
+                            costShareParamGroup.setResponsibilityCode(responsibility.getResponsibilityCode());
+                            costShareParamGroup.setResponsibilityName(responsibility.getResponsibilityName());
+
+                        } else {
+                            IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
+                            incomeErrorMessage.setTotal(j);
+                            incomeErrorMessage.setErrMessage("第" + j + "列科室信息对应的责任中心不存在");
+                            incomeErrorMessageList.add(incomeErrorMessage);
+                        }
+                    } else {
+                        IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
+                        incomeErrorMessage.setTotal(j);
+                        incomeErrorMessage.setErrMessage("第" + j + "列科室信息不存在对应的责任中心");
+                        incomeErrorMessageList.add(incomeErrorMessage);
+                    }
+                } else {
+                    IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
+                    incomeErrorMessage.setTotal(j);
+                    incomeErrorMessage.setErrMessage("第" + j + "列科室信息不存在");
+                    incomeErrorMessageList.add(incomeErrorMessage);
+                }
+                costShareParamGroup.setAmount(BigDecimal.valueOf(Double.parseDouble(("0".equals(data.get(j).toString()) || StrUtil.isBlank(data.get(j).toString())) ?"0.00":data.get(j).toString())));
+                costShareParamGroup.setHospId(UserContext.getHospId());
+                costShareParamGroup.setCreateTime(System.currentTimeMillis());
+                costShareParamGroup.setDateYear(year);
+                costShareParamGroup.setDateMonth(month);
+                costShareParamGroupList.add(costShareParamGroup);
+            }
+        }
+    }
+}

+ 4 - 5
src/main/java/com/imed/costaccount/service/impl/CostShareParamServiceImpl.java

@@ -8,18 +8,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.imed.costaccount.common.exception.CostException;
 import com.imed.costaccount.common.util.BeanUtil;
 import com.imed.costaccount.common.util.PageUtils;
-import com.imed.costaccount.common.util.UserContext;
+import com.imed.costaccount.common.util.Result;
 import com.imed.costaccount.constants.NumberConstant;
 import com.imed.costaccount.mapper.CostShareParamMapper;
-import com.imed.costaccount.model.CostNumberBedSet;
 import com.imed.costaccount.model.CostShareParam;
-import com.imed.costaccount.model.dto.CheckShareParamStatusDto;
+import com.imed.costaccount.model.User;
 import com.imed.costaccount.model.dto.CostShareParamAccountDto;
 import com.imed.costaccount.model.dto.CostShareParamEditDto;
 import com.imed.costaccount.model.dto.CostShareParamSaveDto;
-import com.imed.costaccount.model.vo.CheckShareParamStatusVO;
 import com.imed.costaccount.model.vo.CostShareParamVO;
-import com.imed.costaccount.service.CostNumberBedSetService;
 import com.imed.costaccount.service.CostShareParamService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.stereotype.Service;
@@ -27,6 +24,7 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.*;
 import java.util.stream.Collectors;
@@ -192,4 +190,5 @@ public class CostShareParamServiceImpl extends ServiceImpl<CostShareParamMapper,
 
     }
 
+
 }

+ 74 - 0
src/main/java/com/imed/costaccount/web/CostCostingGroupController.java

@@ -0,0 +1,74 @@
+package com.imed.costaccount.web;
+
+import com.imed.costaccount.common.util.Result;
+import com.imed.costaccount.model.CostCostingGroup;
+import com.imed.costaccount.model.User;
+import com.imed.costaccount.service.CostCostingGroupService;
+import org.apache.shiro.SecurityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Arrays;
+
+
+/**
+ * 成本归集
+ *
+ * @author KCYG
+ * @date 2021-08-12 11:00:23
+ */
+@RestController
+@RequestMapping("/costAccount/costcostinggroup")
+public class CostCostingGroupController {
+    @Autowired
+    private CostCostingGroupService costCostingGroupService;
+
+    /**
+     * 分页查询列表
+     * 查询的是
+     */
+    @RequestMapping("/list")
+    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();
+    }
+
+
+    /**
+     * 信息
+     */
+    @RequestMapping("/info/{id}")
+    public Result info(@PathVariable("id") Long id){
+		CostCostingGroup costCostingGroup = costCostingGroupService.getById(id);
+        return Result.ok(costCostingGroup);
+    }
+
+    /**
+     * 保存
+     */
+    @RequestMapping("/save")
+    public Result save(@RequestBody CostCostingGroup costCostingGroup){
+		costCostingGroupService.save(costCostingGroup);
+        return Result.ok();
+    }
+
+    /**
+     * 修改
+     */
+    @RequestMapping("/update")
+    public Result update(@RequestBody CostCostingGroup costCostingGroup){
+		costCostingGroupService.updateById(costCostingGroup);
+        return Result.ok();
+    }
+
+    /**
+     * 删除
+     */
+    @RequestMapping("/delete")
+    public Result delete(@RequestBody Long[] ids){
+		costCostingGroupService.removeByIds(Arrays.asList(ids));
+        return Result.ok();
+    }
+
+}

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

@@ -22,7 +22,7 @@ import java.util.List;
  * @date 2021-08-10 14:42:20
  */
 @RestController
-@RequestMapping("/costAccount//costincomefile")
+@RequestMapping("/costAccount/costincomefile")
 @Api(tags = "文件记录")
 public class CostIncomeFileController {
     @Autowired

+ 74 - 0
src/main/java/com/imed/costaccount/web/CostShareParamGroupController.java

@@ -0,0 +1,74 @@
+package com.imed.costaccount.web;
+
+import com.imed.costaccount.common.util.Result;
+import com.imed.costaccount.model.CostShareParamGroup;
+import com.imed.costaccount.model.User;
+import com.imed.costaccount.service.CostShareParamGroupService;
+import org.apache.shiro.SecurityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Arrays;
+
+
+/**
+ * 成本分摊参数归集
+ *
+ * @author KCYG
+ * @date 2021-08-12 16:32:47
+ */
+@RestController
+@RequestMapping("/costAccount/costshareparamgroup")
+public class CostShareParamGroupController {
+    @Autowired
+    private CostShareParamGroupService costShareParamGroupService;
+
+    /**
+     * 分页查询列表
+     * 查询的是
+     */
+    @RequestMapping("/list")
+    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();
+    }
+
+
+    /**
+     * 信息
+     */
+    @RequestMapping("/info/{id}")
+    public Result info(@PathVariable("id") Long id){
+		CostShareParamGroup costShareParamGroup = costShareParamGroupService.getById(id);
+        return Result.ok(costShareParamGroup);
+    }
+
+    /**
+     * 保存
+     */
+    @RequestMapping("/save")
+    public Result save(@RequestBody CostShareParamGroup costShareParamGroup){
+		costShareParamGroupService.save(costShareParamGroup);
+        return Result.ok();
+    }
+
+    /**
+     * 修改
+     */
+    @RequestMapping("/update")
+    public Result update(@RequestBody CostShareParamGroup costShareParamGroup){
+		costShareParamGroupService.updateById(costShareParamGroup);
+        return Result.ok();
+    }
+
+    /**
+     * 删除
+     */
+    @RequestMapping("/delete")
+    public Result delete(@RequestBody Long[] ids){
+		costShareParamGroupService.removeByIds(Arrays.asList(ids));
+        return Result.ok();
+    }
+
+}

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

@@ -60,8 +60,11 @@ public class ExcelController {
 
     private final CostIncomeGroupService costIncomeGroupService;
 
+    private final CostCostingGroupService costCostingGroupService;
 
-    public ExcelController(UserService userService, DepartmentServiceImpl departmentService, ProductServiceImpl productService, AccountingService accountingService, AccountingProductService accountingProductService, ResponsibilityDepartmentService responsibilityDepartmentService, CostShareParamService costShareParamService, CostIncomeGroupService costIncomeGroupService, RedisUtil redisUtil, JwtUtil jwtUtil) {
+    private final CostShareParamGroupService costShareParamGroupService;
+
+    public ExcelController(UserService userService, DepartmentServiceImpl departmentService, ProductServiceImpl productService, AccountingService accountingService, AccountingProductService accountingProductService, ResponsibilityDepartmentService responsibilityDepartmentService, CostShareParamService costShareParamService, CostIncomeGroupService costIncomeGroupService, RedisUtil redisUtil, JwtUtil jwtUtil, CostCostingGroupService costCostingGroupService, CostShareParamGroupService costShareParamGroupService) {
         this.userService = userService;
         this.departmentService = departmentService;
         this.productService = productService;
@@ -71,6 +74,8 @@ public class ExcelController {
         this.costShareParamService = costShareParamService;
         this.costIncomeGroupService = costIncomeGroupService;
         this.jwtUtil = jwtUtil;
+        this.costCostingGroupService = costCostingGroupService;
+        this.costShareParamGroupService = costShareParamGroupService;
     }
 
     @ApiOperation("用户导出模板设置")
@@ -307,8 +312,13 @@ public class ExcelController {
      */
     @GetMapping("/getImportCostProductAccountTemplate")
     @ApiOperation("成本数据导出模板设置")
-    public void getImportCostProductAccountTemplate(HttpServletResponse response) throws IOException {
-        Long hospId = UserContext.getHospId();
+    public void getImportCostProductAccountTemplate(HttpServletResponse response,String token) throws IOException {
+        int userId = jwtUtil.getUserId(token);
+        User user = userService.getById(userId);
+        if (Objects.isNull(user)){
+            throw new CostException(500,"用户不存在");
+        }
+        Long hospId = user.getHospId();
         String uuid = UUID.randomUUID().toString();
         String url = System.getProperty("java.io.tmpdir") + File.separator + uuid + File.separator + uuid + ".xls";
         FileUtil.del(FileUtil.file(url));
@@ -321,29 +331,26 @@ public class ExcelController {
         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.merge(0, 1, 0, departmentCodeList.size()==0?3:departmentCodeList.size()+2, "为了保证成功导入,请勿修改模板格式", false);
         writer.passCurrentRow();
         writer.passCurrentRow();
-        writer.merge(2, 2, 0, 6, "医院成本数据批量导入", false);
+        writer.merge(2, 2, 0, departmentCodeList.size()==0?3:departmentCodeList.size()+2, "医院成本数据批量导入", false);
         writer.passCurrentRow();
-        writer.merge(3,3,2,departmentCodeList.size(),"科室",false);
+        writer.merge(3,3,2,departmentCodeList.size()==0?3:departmentCodeList.size()+2,"科室",false);
         writer.passCurrentRow();
         departmentCodeList.add(0, null);
         departmentCodeList.add(1, null);
-        departmentCodeList.add(2, null);
         departmentCodeList.add("-1");
         writer.writeRow(departmentCodeList);
-        departmentNameList.add(0, null);
-        departmentNameList.add(1, "成本项目代码");
-        departmentNameList.add(2, "成本项目名称");
+        departmentNameList.add(0, "成本项目代码");
+        departmentNameList.add(1, "成本项目名称");
         departmentNameList.add("总计");
         writer.writeRow(departmentNameList);
         // 设置科室名称的集合
         writer.setFreezePane(5);
         int accountType = NumberConstant.TWO;
-        int column = NumberConstant.FIVE;
-        List<Product> productList = getProductByAccountType(hospId, writer, accountType, column);
-        writer.merge(6,productList.size(),0,0,"成本项目",false);
+        int column = NumberConstant.SIX;
+        getProductByAccountType(hospId, writer, accountType, column);
         writer.setColumnWidth(0, 15);
         writer.setColumnWidth(1, 15);
         response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
@@ -363,7 +370,7 @@ public class ExcelController {
      * @param accountType 会计科目类型 1 收入  2支出(成本)
      * @param column      控制第几列
      */
-    private List<Product> getProductByAccountType(Long hospId, ExcelWriter writer, Integer accountType, Integer column) {
+    private void getProductByAccountType(Long hospId, ExcelWriter writer, Integer accountType, Integer column) {
         // 所有的成本项目
         List<Product> productList = productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId));
         // 所有成本会计对照数据
@@ -384,12 +391,11 @@ public class ExcelController {
                 }
             }
         });
-        // 写入响应第一列 第二列的数据
+        // 写入响应第二列 第三列的数据
         for (int j = 0; j < products.size(); j++) {
-            writer.writeCellValue(1, j + column, productList.get(j).getProductCode());
-            writer.writeCellValue(2, j + column, productList.get(j).getProductName());
+            writer.writeCellValue(0, j + column, products.get(j).getProductCode());
+            writer.writeCellValue(1, j + column, products.get(j).getProductName());
         }
-        return productList;
     }
 
     /**
@@ -397,8 +403,13 @@ public class ExcelController {
      */
     @GetMapping("/getShareParamTemplate")
     @ApiOperation("成本分摊参数导出模板")
-    public void getShareParamTemplate(HttpServletResponse response) throws IOException {
-        Long hospId = UserContext.getHospId();
+    public void getShareParamTemplate(HttpServletResponse response,String token) throws IOException {
+        int userId = jwtUtil.getUserId(token);
+        User user = userService.getById(userId);
+        if (Objects.isNull(user)){
+            throw new CostException(500,"用户不存在");
+        }
+        Long hospId = user.getHospId();
         String uuid = UUID.randomUUID().toString();
         String url = System.getProperty("java.io.tmpdir") + File.separator + uuid + File.separator + uuid + ".xls";
         FileUtil.del(FileUtil.file(url));
@@ -412,32 +423,29 @@ public class ExcelController {
         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.merge(0, 1, 0, departmentCodeList.size()==0?3:departmentCodeList.size()+1, "为了保证成功导入,请勿修改模板格式", false);
         writer.passCurrentRow();
         writer.passCurrentRow();
-        writer.merge(2, 2, 0, 6, "医院成本分摊参数数据批量导入", false);
+        writer.merge(2, 2, 0, departmentCodeList.size()==0?3:departmentCodeList.size()+1, "医院成本分摊参数数据批量导入", false);
         writer.passCurrentRow();
-        writer.merge(3,3,3,departmentCodeList.size(),"科室",false);
+        writer.merge(3,3,2,departmentCodeList.size()==0?3:departmentCodeList.size()+1,"科室",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, null);
-        departmentNameList.add(1, "成本分摊参数代码");
-        departmentNameList.add(2, "成本分摊参数名称");
+        departmentNameList.add(0, "成本分摊参数代码");
+        departmentNameList.add(1, "成本分摊参数名称");
         writer.writeRow(departmentNameList);
         // 设置科室名称的集合
         writer.setFreezePane(5);
         // 为第一列和第二列设置成本分摊参数的列表数据
 
         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());
+            writer.writeCellValue(0, j + 6, costShareParamList.get(j).getShareParamCode());
+            writer.writeCellValue(1, j + 6, costShareParamList.get(j).getShareParamName());
         }
         writer.setColumnWidth(0, 15);
-        writer.setColumnWidth(1, 15);
+        writer.setColumnWidth(1, 22);
         response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
         response.setHeader("Content-Disposition", "attachment;filename=" + uuid + ".xls");
         ServletOutputStream out = null;
@@ -506,11 +514,34 @@ public class ExcelController {
             log.info("最开始:read={}", read);
             log.info("-------------------------------------------------------------------");
             User user = UserContext.getCurrentUser();
-            return costIncomeGroupService.importIncomeGroup(read, user, file, dateTime,fileType);
+            return costCostingGroupService.importCostingGroup(read, user, file, dateTime,fileType);
         } catch (IOException e) {
             e.printStackTrace();
             ;
             throw new CostException(500, "导入失败");
         }
     }
+    @PostMapping("/importShareParamGroup")
+    @ApiOperation("成本分摊参数导入")
+    public Result importShareParamGroup(@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 costShareParamGroupService.importShareParamGroup(read, user, file, dateTime,fileType);
+        } catch (IOException e) {
+            e.printStackTrace();
+            ;
+            throw new CostException(500, "导入失败");
+        }
+    }
+
 }

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

@@ -8,6 +8,7 @@ spring:
     druid:
       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
+#      url: jdbc:mysql://127.0.0.1:3306/cost_account?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
       username: root
       password: xywl2021#@!
       initial-size: 10

+ 30 - 0
src/main/resources/mapper/CostCostingGroupMapper.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.imed.costaccount.mapper.CostCostingGroupMapper">
+
+	<!-- 可根据自己的需求,是否要使用 -->
+    <resultMap type="com.imed.costaccount.model.CostCostingGroup" id="costCostingGroupMap">
+        <result property="id" column="id"/>
+        <result property="departmentCode" column="department_code"/>
+        <result property="departmentName" column="department_name"/>
+        <result property="responsibilityCode" column="responsibility_code"/>
+        <result property="responsibilityName" column="responsibility_name"/>
+        <result property="otherResponsibilityCode" column="other_responsibility_code"/>
+        <result property="otherResponsibilityName" column="other_responsibility_name"/>
+        <result property="productCode" column="product_code"/>
+        <result property="productName" column="product_name"/>
+        <result property="accountCode" column="account_code"/>
+        <result property="accountName" column="account_name"/>
+        <result property="amount" column="amount"/>
+        <result property="hospId" column="hosp_id"/>
+        <result property="fileId" column="file_id"/>
+        <result property="afterIncomeGroup" column="after_income_group"/>
+        <result property="dateYear" column="date_year"/>
+        <result property="dateMonth" column="date_month"/>
+        <result property="createTime" column="create_time"/>
+        <result property="deleteTime" column="delete_time"/>
+    </resultMap>
+
+
+</mapper>

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

@@ -48,7 +48,8 @@
 
     <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=",">

+ 24 - 0
src/main/resources/mapper/CostShareParamGroupMapper.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.imed.costaccount.mapper.CostShareParamGroupMapper">
+
+	<!-- 可根据自己的需求,是否要使用 -->
+    <resultMap type="com.imed.costaccount.model.CostShareParamGroup" id="costShareParamGroupMap">
+        <result property="id" column="id"/>
+        <result property="shareParamCode" column="share_param_code"/>
+        <result property="shareParamName" column="share_param_name"/>
+        <result property="responsibilityCode" column="responsibility_code"/>
+        <result property="responsibilityName" column="responsibility_name"/>
+        <result property="amount" column="amount"/>
+        <result property="hospId" column="hosp_id"/>
+        <result property="fileId" column="file_id"/>
+        <result property="afterIncomeGroup" column="after_income_group"/>
+        <result property="dateYear" column="date_year"/>
+        <result property="dateMonth" column="date_month"/>
+        <result property="createTime" column="create_time"/>
+        <result property="deleteTime" column="delete_time"/>
+    </resultMap>
+
+
+</mapper>