Browse Source

Merge branch 'master' of huangrui/CostAccount into dev

lijiaxi 4 years ago
parent
commit
f755699bbe
24 changed files with 374 additions and 214 deletions
  1. 1 1
      src/main/java/com/imed/costaccount/CostAccountApplication.java
  2. 6 6
      src/main/java/com/imed/costaccount/model/CostAccountShare.java
  3. 5 4
      src/main/java/com/imed/costaccount/model/Responsibility.java
  4. 25 0
      src/main/java/com/imed/costaccount/model/dto/AccountShareCopyDto.java
  5. 3 3
      src/main/java/com/imed/costaccount/model/dto/CostAccountShareEditDto.java
  6. 6 6
      src/main/java/com/imed/costaccount/model/dto/CostAccountShareSaveDto.java
  7. 4 0
      src/main/java/com/imed/costaccount/model/dto/ResponsibilityEditDTO.java
  8. 13 13
      src/main/java/com/imed/costaccount/model/dto/ResponsibilitySaveDTO.java
  9. 6 6
      src/main/java/com/imed/costaccount/model/vo/CostAccountShareVO.java
  10. 2 0
      src/main/java/com/imed/costaccount/model/vo/CostIncomeGroupAllAmountBO.java
  11. 3 0
      src/main/java/com/imed/costaccount/model/vo/CostResponsibilityVO.java
  12. 18 0
      src/main/java/com/imed/costaccount/service/CostAccountShareService.java
  13. 1 1
      src/main/java/com/imed/costaccount/service/CostShareParamService.java
  14. 1 1
      src/main/java/com/imed/costaccount/service/impl/AccountingServiceImpl.java
  15. 120 50
      src/main/java/com/imed/costaccount/service/impl/CostAccountShareServiceImpl.java
  16. 36 14
      src/main/java/com/imed/costaccount/service/impl/CostIncomeFileServiceImpl.java
  17. 3 6
      src/main/java/com/imed/costaccount/service/impl/CostShareParamServiceImpl.java
  18. 75 87
      src/main/java/com/imed/costaccount/service/impl/ResponsibilityServiceImpl.java
  19. 3 0
      src/main/java/com/imed/costaccount/test.json
  20. 31 4
      src/main/java/com/imed/costaccount/web/CostAccountShareController.java
  21. 1 1
      src/main/java/com/imed/costaccount/web/CostShareParamController.java
  22. 7 7
      src/main/java/com/imed/costaccount/web/ResponsibilityController.java
  23. 3 3
      src/main/resources/mapper/CostAccountShareMapper.xml
  24. 1 1
      src/main/resources/mapper/ResponsibilityMapper.xml

+ 1 - 1
src/main/java/com/imed/costaccount/CostAccountApplication.java

@@ -10,6 +10,6 @@ public class CostAccountApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(CostAccountApplication.class, args);
-        System.out.println("启动成功");
+        System.out.println("============================启动成功==========================================");
     }
 }

+ 6 - 6
src/main/java/com/imed/costaccount/model/CostAccountShare.java

@@ -49,18 +49,18 @@ public class CostAccountShare implements Serializable {
 	 */
 	private Long hospId;
 	/**
-	 * 成本项目Id
+	 * 会计科目Id
 	 *
 	 */
-	private Long accountingId;
+	private String accountingIds;
 	/**
-	 * 成本项目名称
+	 * 会计科目名称
 	 */
-	private String accountingName;
+	private String accountingNames;
 	/**
-	 * 成本项目代码
+	 * 会计科目代码
 	 */
-	private String accountingCode;
+	private String accountingCodes;
 	/**
 	 * 分摊参数集合
 	 */

+ 5 - 4
src/main/java/com/imed/costaccount/model/Responsibility.java

@@ -38,10 +38,6 @@ public class Responsibility implements Serializable {
 	 * 责任中心代码
 	 */
 	private String responsibilityCode;
-	/**
-	 * 责任级别(第一级为1,以此类推)
-	 */
-	private Integer responsibilityLevel;
 	/**
 	 * 上级id
 	 */
@@ -58,6 +54,11 @@ public class Responsibility implements Serializable {
 	 * 责任类型 1. 收费中心,2.成本(费用)中心
 	 */
 	private Integer responsibilityType;
+
+	/**
+	 * 是否默认 0.不是,1.是
+	 */
+	private Integer isDefault;
 	/**
 	 * 分摊级别的Id
 	 */

+ 25 - 0
src/main/java/com/imed/costaccount/model/dto/AccountShareCopyDto.java

@@ -0,0 +1,25 @@
+package com.imed.costaccount.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ * @author 李加喜
+ * @Package com.imed.costaccount.model.dto
+ * @date 2021-08-16 9:58
+ */
+@Data
+@ApiModel("成本分摊参数对应设置功能")
+public class AccountShareCopyDto {
+    @ApiModelProperty(name="id",value = "成本分摊参数设置对应Id不能为空")
+    @NotNull(message = "成本分摊参数设置对应Id不能为空")
+    private Long id;
+
+    @ApiModelProperty(name="responsibilityId",value = "成本分摊参数设置对应Id不能为空")
+   @NotNull(message = "成本分摊参数设置对应Id不能为空")
+    private List<Long> responsibilityIds;
+}

+ 3 - 3
src/main/java/com/imed/costaccount/model/dto/CostAccountShareEditDto.java

@@ -32,13 +32,13 @@ public class CostAccountShareEditDto {
     private String responsibilityName;
 
     @ApiModelProperty(name = "accountingId",value = "成本项目的Id")
-    private Long accountingId;
+    private String accountingIds;
 
     @ApiModelProperty(name = "accountingName",value = "成本项目名称")
-    private String accountingName;
+    private String accountingNames;
 
     @ApiModelProperty(name = "accountingCode",value = "成本项目代码")
-    private String accountingCode;
+    private String accountingCodes;
 
     @ApiModelProperty(name = "costNode",value = "备注")
     private String costNode;

+ 6 - 6
src/main/java/com/imed/costaccount/model/dto/CostAccountShareSaveDto.java

@@ -28,14 +28,14 @@ public class CostAccountShareSaveDto {
     @ApiModelProperty(name = "responsibilityCode",value = "责任中心名称")
     private String responsibilityName;
 
-    @ApiModelProperty(name = "accountingId",value = "成本项目的Id")
-    private Long accountingId=0L;
+    @ApiModelProperty(name = "accountingId",value = "会计科目的Id")
+    private String accountingIds;
 
-    @ApiModelProperty(name = "accountingName",value = "成本项目名称")
-    private String accountingName;
+    @ApiModelProperty(name = "accountingName",value = "会计科目名称")
+    private String accountingNames;
 
-    @ApiModelProperty(name = "accountingCode",value = "成本项目代码")
-    private String accountingCode;
+    @ApiModelProperty(name = "accountingCode",value = "会计科目的代码")
+    private String accountingCodes;
 
     @ApiModelProperty(name = "costNode",value = "备注")
     private String costNode;

+ 4 - 0
src/main/java/com/imed/costaccount/model/dto/ResponsibilityEditDTO.java

@@ -47,5 +47,9 @@ public class ResponsibilityEditDTO {
     @ApiModelProperty(name = "shareName",value = "分摊级别名称(分摊接口中获取,暂时可写死)")
     private String shareName;
 
+    @NotNull(message = "是否默认字段不为空")
+    @ApiModelProperty(value = "0.不是,1.是", name = "deptStatus")
+    private Integer isDefault;
+
 
 }

+ 13 - 13
src/main/java/com/imed/costaccount/model/dto/ResponsibilitySaveDTO.java

@@ -12,37 +12,37 @@ import javax.validation.constraints.NotNull;
 @ApiModel("责任中心新增实体类")
 public class ResponsibilitySaveDTO {
 
-    @ApiModelProperty(name = "ApiModelProperty",value = "责任级别id,新增一级不传,如果是添加二级责任中心,那么必传")
+    @ApiModelProperty(name = "ApiModelProperty", value = "责任级别id,新增一级不传,如果是添加二级责任中心,那么必传")
     private Long id;
 
-    @ApiModelProperty(name = "responsibilityCode",value = "责任中心代码(后台校验唯一性)")
+    @ApiModelProperty(name = "responsibilityCode", value = "责任中心代码(后台校验唯一性)")
     @NotBlank(message = "责任中心代码不能为空")
     private String responsibilityCode;
 
     @NotBlank(message = "责任中心名称不能为空")
-    @ApiModelProperty(name = "responsibilityName",value = "责任中心名称")
+    @ApiModelProperty(name = "responsibilityName", value = "责任中心名称")
     private String responsibilityName;
 
     @NotNull(message = "是否汇总中心不能为空")
-    @ApiModelProperty(name = "isGatherCenter",value = "是否汇总中心")
+    @ApiModelProperty(name = "isGatherCenter", value = "是否汇总中心")
     private Integer isGatherCenter;
 
     @NotNull(message = "收益类型 1. 收费中心,2.成本(费用)中心")
-    @ApiModelProperty(name = "responsibilityType",value = "收益类型 1. 收费中心,2.成本(费用)中心")
+    @ApiModelProperty(name = "responsibilityType", value = "收益类型 1. 收费中心,2.成本(费用)中心")
     private Integer responsibilityType;
 
-    @ApiModelProperty(name = "shareId",value = "分摊级别的Id")
+    @ApiModelProperty(name = "shareId", value = "分摊级别的Id")
     private Long shareId;
 
-//    @NotNull(message = "分摊级别不能为空")
-    @ApiModelProperty(name = "shareLevel",value = "分摊级别(分摊接口中获取,暂时可写死)")
+    //    @NotNull(message = "分摊级别不能为空")
+    @ApiModelProperty(name = "shareLevel", value = "分摊级别(分摊接口中获取,暂时可写死)")
     private Integer shareLevel;
 
-//    @NotNull(message = "分摊级别名称不能为空")
-    @ApiModelProperty(name = "shareName",value = "分摊级别名称(分摊接口中获取,暂时可写死)")
+    //    @NotNull(message = "分摊级别名称不能为空")
+    @ApiModelProperty(name = "shareName", value = "分摊级别名称(分摊接口中获取,暂时可写死)")
     private String shareName;
 
-
-
-
+    @NotNull(message = "是否默认字段不为空")
+    @ApiModelProperty(value = "0.不是,1.是", name = "isDefault")
+    private Integer isDefault;
 }

+ 6 - 6
src/main/java/com/imed/costaccount/model/vo/CostAccountShareVO.java

@@ -28,14 +28,14 @@ public class CostAccountShareVO {
     @ApiModelProperty(name = "responsibilityCode",value = "责任中心名称")
     private String responsibilityName;
 
-    @ApiModelProperty(name = "accountingId",value = "成本项目的Id")
-    private Long accountingId;
+    @ApiModelProperty(name = "accountingId",value = "会计科目的Id")
+    private String accountingIds;
 
-    @ApiModelProperty(name = "accountingName",value = "成本项目名称")
-    private String accountingName;
+    @ApiModelProperty(name = "accountingName",value = "会计科目名称")
+    private String accountingNames;
 
-    @ApiModelProperty(name = "accountingCode",value = "成本项目代码")
-    private String accountingCode;
+    @ApiModelProperty(name = "accountingCode",value = "会计科目代码")
+    private String accountingCodes;
 
     @ApiModelProperty(name = "shareparamId",value = "关联的分摊参数的Id集合")
     private String shareparamId;

+ 2 - 0
src/main/java/com/imed/costaccount/model/vo/CostIncomeGroupAllAmountBO.java

@@ -1,9 +1,11 @@
 package com.imed.costaccount.model.vo;
 
 import com.imed.costaccount.model.CostIncomeGroup;
+import io.swagger.annotations.ApiModel;
 import lombok.Data;
 
 @Data
+@ApiModel("收入数据归集前的查询")
 public class CostIncomeGroupAllAmountBO extends CostIncomeGroup {
     private String allMoney;
 }

+ 3 - 0
src/main/java/com/imed/costaccount/model/vo/CostResponsibilityVO.java

@@ -39,6 +39,9 @@ public class CostResponsibilityVO{
     @ApiModelProperty(name = "shareName",value = "分摊级别名称")
     private String shareName;
 
+    @ApiModelProperty(name = "deptStatus",value = "责任中心状态,0.门诊,1.住院")
+    private Integer deptStatus;
+
     private Long parentId;
 
     /**

+ 18 - 0
src/main/java/com/imed/costaccount/service/CostAccountShareService.java

@@ -3,6 +3,8 @@ package com.imed.costaccount.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.model.CostAccountShare;
+import com.imed.costaccount.model.Responsibility;
+import com.imed.costaccount.model.dto.AccountShareCopyDto;
 import com.imed.costaccount.model.dto.CostAccountShareEditDto;
 import com.imed.costaccount.model.dto.CostAccountShareSaveDto;
 import com.imed.costaccount.model.dto.ShareParamEditDto;
@@ -61,5 +63,21 @@ public interface CostAccountShareService extends IService<CostAccountShare> {
      * @return
      */
     List<CostShareParamStatusVO> getAllShareParamStatusById(Integer id, Long hospId);
+
+    /**
+     * 拷贝
+     * @param accountShareCopyDto
+     * @param hospId
+     */
+    void copyAccountShareData(AccountShareCopyDto accountShareCopyDto, Long hospId);
+
+    /**
+     * 获取指定类型的责任中心集合 分开计算还是合并计算
+     *
+     * @param accountShareId 分摊参数设置对应的Id
+     * @param hospId 医院的Id
+     * @return
+     */
+    List<Responsibility> getResponsibilityCalType(Long accountShareId, Long hospId);
 }
 

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

@@ -61,6 +61,6 @@ public interface CostShareParamService extends IService<CostShareParam> {
      */
     CostShareParamVO getByHospIdAndAPramId(Integer id, Long hospId);
 
-    List<Integer> selectIsSelect(Integer shareParamId);
+    List<Long> selectIsSelect(Integer shareParamId);
 }
 

+ 1 - 1
src/main/java/com/imed/costaccount/service/impl/AccountingServiceImpl.java

@@ -59,7 +59,7 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
         List<AccountVO> all = BeanUtil.convertList(list, AccountVO.class);
         // 查询所有的已绑定的分摊参数
         if (Objects.nonNull(shareParamId)) {
-            List<Integer> ids = shareParamService.selectIsSelect(shareParamId);
+            List<Long> ids = shareParamService.selectIsSelect(shareParamId);
             if (CollUtil.isNotEmpty(ids)) {
                 all.forEach(i -> {
                     if (ids.contains(i.getId())) {

+ 120 - 50
src/main/java/com/imed/costaccount/service/impl/CostAccountShareServiceImpl.java

@@ -1,14 +1,17 @@
 package com.imed.costaccount.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 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.exception.CostException;
+import com.imed.costaccount.common.util.BeanUtil;
 import com.imed.costaccount.common.util.JsonUtil;
 import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.constants.NumberConstant;
 import com.imed.costaccount.mapper.CostAccountShareMapper;
 import com.imed.costaccount.model.*;
+import com.imed.costaccount.model.dto.AccountShareCopyDto;
 import com.imed.costaccount.model.dto.CostAccountShareEditDto;
 import com.imed.costaccount.model.dto.CostAccountShareSaveDto;
 import com.imed.costaccount.model.dto.ShareParamEditDto;
@@ -17,7 +20,6 @@ import com.imed.costaccount.model.vo.CostShareParamStatusVO;
 import com.imed.costaccount.model.vo.CostShareParamVO;
 import com.imed.costaccount.model.vo.ShareParamProportionVO;
 import com.imed.costaccount.service.*;
-import com.imed.costaccount.common.util.BeanUtil;
 import org.apache.shiro.SecurityUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
@@ -25,10 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
@@ -69,40 +68,39 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
         List<CostAccountShare> costAccountShareList = pages.getRecords();
 
         List<CostAccountShareVO> costAccountShareVOList = BeanUtil.convertList(costAccountShareList, CostAccountShareVO.class);
-        getMessage(hospId, costAccountShareVOList);
-        //
+//        getMessage(hospId, costAccountShareVOList);
         PageUtils pageUtils = new PageUtils(pages);
         pageUtils.setList(costAccountShareVOList);
         return pageUtils;
     }
 
-    private void getMessage(Long hospId, List<CostAccountShareVO> costAccountShareList) {
-        // 设置责任中心的数据 与 会计科目的数据从对应的id里面获取
-        List<Responsibility> list = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId));
-        List<Accounting> accountingList = accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId));
-        Map<Long, List<Responsibility>> resMap = list.stream().collect(Collectors.groupingBy(Responsibility::getId));
-        Map<Long, List<Accounting>> accountMap = accountingList.stream().collect(Collectors.groupingBy(Accounting::getId));
-        costAccountShareList.forEach(i->{
-            Long id = i.getResponsibilityId();
-            List<Responsibility> responsibilities = resMap.get(id);
-            if (!CollectionUtils.isEmpty(responsibilities)){
-                i.setResponsibilityId(id);
-                i.setResponsibilityName(responsibilities.get(0).getResponsibilityName());
-                i.setResponsibilityCode(responsibilities.get(0).getResponsibilityCode());
-
-            }
-            Long accountingId = i.getAccountingId();
-            if (accountingId>0){
-                List<Accounting> accountingList1 = accountMap.get(accountingId);
-                if (!CollectionUtils.isEmpty(accountingList1)){
-                    i.setAccountingId(accountingId);
-                    i.setAccountingName(accountingList1.get(0).getAccountingName());
-                    i.setAccountingCode(accountingList1.get(0).getAccountingCode());
-                    i.setAllParentIds(accountingList1.get(0).getAllParentIds());
-                }
-            }
-        });
-    }
+//    private void getMessage(Long hospId, List<CostAccountShareVO> costAccountShareList) {
+//        // 设置责任中心的数据 与 会计科目的数据从对应的id里面获取
+//        List<Responsibility> list = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId));
+//        List<Accounting> accountingList = accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId));
+//        Map<Long, List<Responsibility>> resMap = list.stream().collect(Collectors.groupingBy(Responsibility::getId));
+//        Map<Long, List<Accounting>> accountMap = accountingList.stream().collect(Collectors.groupingBy(Accounting::getId));
+//        costAccountShareList.forEach(i->{
+//            Long id = i.getResponsibilityId();
+//            List<Responsibility> responsibilities = resMap.get(id);
+//            if (!CollectionUtils.isEmpty(responsibilities)){
+//                i.setResponsibilityId(id);
+//                i.setResponsibilityName(responsibilities.get(0).getResponsibilityName());
+//                i.setResponsibilityCode(responsibilities.get(0).getResponsibilityCode());
+//
+//            }
+//            Long accountingId = i.getAccountingId();
+//            if (accountingId>0){
+//                List<Accounting> accountingList1 = accountMap.get(accountingId);
+//                if (!CollectionUtils.isEmpty(accountingList1)){
+//                    i.setAccountingId(accountingId);
+//                    i.setAccountingName(accountingList1.get(0).getAccountingName());
+//                    i.setAccountingCode(accountingList1.get(0).getAccountingCode());
+//                    i.setAllParentIds(accountingList1.get(0).getAllParentIds());
+//                }
+//            }
+//        });
+//    }
 
     /**
      * 保存成本参数对应成本对照表
@@ -144,37 +142,43 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
         costAccountShareSaveDto.setResponsibilityCode(responsibility.getResponsibilityCode());
         costAccountShareSaveDto.setResponsibilityName(responsibility.getResponsibilityName());
         costAccountShareSaveDto.setShareLevel(responsibility.getShareLevel());
-        if (!StringUtils.isEmpty(costAccountShareSaveDto.getAccountingId()) && costAccountShareSaveDto.getAccountingId() > 0){
-            // 如果输入成本科目的情况下
-            Accounting accounting = accountingService.getOne(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId).eq(Accounting::getId, costAccountShareSaveDto.getAccountingId()));
-            if (Objects.isNull(accounting)){
-                throw new CostException(500,"输入的成本科目不存在");
+        if (!StringUtils.isEmpty(costAccountShareSaveDto.getAccountingIds())){
+            // 这个责任中心允许输入会计科目
+            List<String> accountIdList = Arrays.asList(costAccountShareSaveDto.getAccountingIds().split(StrUtil.COMMA));
+            List<Accounting> accountingList = accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId).in(Accounting::getId, accountIdList).orderByDesc(Accounting::getCreateTime));
+            if (CollectionUtils.isEmpty(accountingList)){
+                throw new CostException(500,"输入的会计科目不存在");
             }else {
-                costAccountShareSaveDto.setAccountingId(accounting.getId());
-                costAccountShareSaveDto.setAccountingName(accounting.getAccountingName());
-                costAccountShareSaveDto.setAccountingCode(accounting.getAccountingCode());
+                String accountIds = accountingList.stream().map(Accounting::getId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.joining(StrUtil.COMMA));
+                costAccountShareSaveDto.setAccountingIds(accountIds);
+                String accountNames = accountingList.stream().map(Accounting::getAccountingName).map(String::valueOf).collect(Collectors.joining(StrUtil.COMMA));
+                costAccountShareSaveDto.setAccountingNames(accountNames);
+                String accountCodes = accountingList.stream().map(Accounting::getAccountingCode).map(String::valueOf).collect(Collectors.joining(StrUtil.COMMA));
+                costAccountShareSaveDto.setAccountingCodes(accountCodes);
             }
             // 检验输入的责任中心与匹配的成本科目是否存在
             List<CostAccountShare> costAccountShareList = baseMapper.selectList(new QueryWrapper<CostAccountShare>().lambda().eq(CostAccountShare::getHospId,hospId));
             Map<String, List<CostAccountShare>> costAccountMap = costAccountShareList.stream().collect(Collectors.groupingBy(CostAccountShare::getResponsibilityCode));
             List<CostAccountShare> list = costAccountMap.get(costAccountShareSaveDto.getResponsibilityCode());
             if (!CollectionUtils.isEmpty(list)){
-                String accountingCode = list.get(0).getAccountingCode();
-                if (accountingCode.equals(costAccountShareSaveDto.getAccountingCode())){
-                    throw new CostException(500,"输入的责任中心对应的成本科目已存在");
+                String accountingIds = list.get(0).getAccountingIds();
+                List<String> accountIdListRequest = Arrays.asList(accountingIds.split(StrUtil.COMMA));
+                if (!Collections.disjoint(accountIdListRequest,accountIdList)){
+                    throw new CostException(500,"存在重复的数据");
                 }
+
             }
         }
-        // 检验输入的这个责任中心是否允许输入成本科目
+        // 检验输入的这个责任中心是否允许输入会计科目
         Long shareId = responsibility.getShareId();
         CostShareLevel costShareLevel = costShareLevelService.getOne(new QueryWrapper<CostShareLevel>().lambda()
                 .eq(CostShareLevel::getHospId, hospId).eq(CostShareLevel::getId, shareId));
         if (Objects.nonNull(costShareLevel)){
-            if ((!StringUtils.isEmpty(costAccountShareSaveDto.getAccountingId()) && costAccountShareSaveDto.getAccountingId() > 0) && NumberConstant.ZERO.equals(costShareLevel.getCalcType())){
-                throw new CostException(500,"合并计算不允许选择成本科目");
+            if ((!StringUtils.isEmpty(costAccountShareSaveDto.getAccountingIds())) && NumberConstant.ZERO.equals(costShareLevel.getCalcType())){
+                throw new CostException(500,"合并计算不允许选择会计科目");
             }
-            if ((!StringUtils.isEmpty(costAccountShareSaveDto.getAccountingId()) && costAccountShareSaveDto.getAccountingId() <= 0) && NumberConstant.ONE.equals(costShareLevel.getCalcType())){
-                throw new CostException(500,"分开计算的责任中心需要选择成本科目");
+            if ((StringUtils.isEmpty(costAccountShareSaveDto.getAccountingIds())) && NumberConstant.ONE.equals(costShareLevel.getCalcType())){
+                throw new CostException(500,"分开计算的责任中心需要选择会计科目");
             }
         }else {
             throw new CostException(500,"对不起该责任中心没有对应分摊层级");
@@ -315,4 +319,70 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
         return costShareParamStatusVOList;
     }
 
+    /**
+     * 拷贝
+     *
+     * @param accountShareCopyDto 赋值数据
+     * @param hospId 医院Id
+     */
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
+    public void copyAccountShareData(AccountShareCopyDto accountShareCopyDto, Long hospId) {
+        Long id = accountShareCopyDto.getId();
+        CostAccountShare costAccountShare = this.getById(id);
+        if (Objects.isNull(costAccountShare)){
+            throw new CostException(500,"成本分摊参数设置对应数据不存在");
+        }
+        List<CostAccountShare> accountShareList = new ArrayList<>();
+        List<Long> responsibilityIds = accountShareCopyDto.getResponsibilityIds();
+        Map<Long, Responsibility> responsibilityMap = responsibilityService.list(new QueryWrapper<Responsibility>().lambda()
+                .eq(Responsibility::getHospId, hospId)).stream().collect(Collectors.toMap(Responsibility::getId, synOne->synOne));
+        long millis = System.currentTimeMillis();
+        responsibilityIds.forEach(i->{
+            CostAccountShare accountShareRequest = BeanUtil.convertObj(costAccountShare, CostAccountShare.class);
+            accountShareRequest.setId(null);
+            accountShareRequest.setCreateTime(millis);
+            Responsibility responsibility = responsibilityMap.get(i);
+            accountShareRequest.setResponsibilityId(i);
+            accountShareRequest.setResponsibilityCode(responsibility.getResponsibilityCode());
+            accountShareRequest.setResponsibilityName(responsibility.getResponsibilityName());
+            accountShareRequest.setShareLevel(responsibility.getShareLevel());
+            accountShareList.add(accountShareRequest);
+        });
+        this.saveBatch(accountShareList);
+
+    }
+
+    /**
+     * 获取指定类型的责任中心集合 分开计算还是合并计算
+     *
+     *
+     * @param accountShareId
+     * @param hospId
+     * @return
+     */
+    @Override
+    public List<Responsibility> getResponsibilityCalType(Long accountShareId, Long hospId) {
+        CostAccountShare costAccountShare = this.getById(accountShareId);
+        if (Objects.isNull(costAccountShare)){
+            throw new CostException(500,"成本分摊参数设置对应数据不存在");
+        }
+        Long responsibilityId = costAccountShare.getResponsibilityId();
+        Responsibility responsibility = responsibilityService.getById(responsibilityId);
+        Long shareId = responsibility.getShareId();
+        CostShareLevel costShareLevel = costShareLevelService.getById(shareId);
+        Integer calcType = costShareLevel.getCalcType();
+        List<Long> responsibilityIds = this.list(new QueryWrapper<CostAccountShare>().lambda().eq(CostAccountShare::getHospId, hospId)).stream().map(CostAccountShare::getResponsibilityId).collect(Collectors.toList());
+        // 执行类型的分摊级别的Id的集合
+        List<Long> costShareIds = costShareLevelService.list(new QueryWrapper<CostShareLevel>().lambda()
+                .eq(CostShareLevel::getCalcType, calcType))
+                .stream().map(CostShareLevel::getId).collect(Collectors.toList());
+        // 筛选责任中心里面符合指定类型的责任中心
+        // 筛选指定类型的责任中心 并且当前没有设置的责任中心
+        List<Responsibility> responsibilityList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda()
+                .eq(Responsibility::getHospId, hospId)).stream()
+                .filter(i -> costShareIds.contains(i.getShareId()) && !responsibilityIds.contains(i.getId())).collect(Collectors.toList());
+        return responsibilityList;
+    }
+
 }

+ 36 - 14
src/main/java/com/imed/costaccount/service/impl/CostIncomeFileServiceImpl.java

@@ -15,9 +15,7 @@ import com.imed.costaccount.mapper.CostCostingGroupMapper;
 import com.imed.costaccount.mapper.CostIncomeFileMapper;
 import com.imed.costaccount.mapper.CostIncomeGroupMapper;
 import com.imed.costaccount.mapper.CostShareParamGroupMapper;
-import com.imed.costaccount.model.CostIncomeFile;
-import com.imed.costaccount.model.CostIncomeGroup;
-import com.imed.costaccount.model.User;
+import com.imed.costaccount.model.*;
 import com.imed.costaccount.model.vo.CostIncomeFileVO;
 import com.imed.costaccount.model.vo.IncomeErrorMessage;
 import com.imed.costaccount.service.CostIncomeFileService;
@@ -36,6 +34,9 @@ import java.util.stream.Collectors;
 @Service("costIncomeFileService")
 public class CostIncomeFileServiceImpl extends ServiceImpl<CostIncomeFileMapper, CostIncomeFile> implements CostIncomeFileService {
 
+    private static final String INCOME_FILETYPE="收入数据";
+    private static final String COST_FILETYPE="成本数据";
+    private static final String SHAREPARAM_FILETYPE="成本分摊参数数据";
     @Autowired
     private CostIncomeGroupMapper costIncomeGroupMapper;
     @Autowired
@@ -68,11 +69,11 @@ public class CostIncomeFileServiceImpl extends ServiceImpl<CostIncomeFileMapper,
             costIncomeFile.setSuccessAmount(list.size());
         }
         if (NumberConstant.ONE.equals(fileType)){
-            costIncomeFile.setFileType("成本分摊参数值");
+            costIncomeFile.setFileType(INCOME_FILETYPE);
         }else if (NumberConstant.TWO.equals(fileType)){
-            costIncomeFile.setFileType("收入数据");
+            costIncomeFile.setFileType(COST_FILETYPE);
         }else if (NumberConstant.THREE.equals(fileType)){
-            costIncomeFile.setFileType("成本数据");
+            costIncomeFile.setFileType(SHAREPARAM_FILETYPE);
         }else {
             costIncomeFile.setFileType(file.getContentType());
         }
@@ -127,14 +128,35 @@ public class CostIncomeFileServiceImpl extends ServiceImpl<CostIncomeFileMapper,
         if (Objects.isNull(costIncomeFile)){
             throw new CostException(500,"文件记录不存在");
         }
-//        // 根据文件的Id 和 医院Id获取数据
-        List<CostIncomeGroup> costIncomeGroupList = costIncomeGroupMapper.selectList(new QueryWrapper<CostIncomeGroup>().lambda()
-                .eq(CostIncomeGroup::getHospId, hospId).eq(CostIncomeGroup::getFileId, id));
-//        if (CollectionUtils.isEmpty(costIncomeGroupList)){
-//            throw new CostException(410,"数据已撤销");
-//        }
-        List<Long> list = costIncomeGroupList.stream().map(CostIncomeGroup::getId).collect(Collectors.toList());
-        costIncomeGroupMapper.deleteBatchIds(list);
+        String fileType = costIncomeFile.getFileType();
+        if (INCOME_FILETYPE.equals(fileType)){
+            // 根据文件的Id 和 医院Id获取数据
+            List<CostIncomeGroup> costIncomeGroupList = costIncomeGroupMapper.selectList(new QueryWrapper<CostIncomeGroup>().lambda()
+                    .eq(CostIncomeGroup::getHospId, hospId).eq(CostIncomeGroup::getFileId, id));
+            if (CollectionUtils.isEmpty(costIncomeGroupList)){
+                throw new CostException(410,"数据已撤销");
+            }
+            List<Long> list = costIncomeGroupList.stream().map(CostIncomeGroup::getId).collect(Collectors.toList());
+            costIncomeGroupMapper.deleteBatchIds(list);
+        }else if (COST_FILETYPE.equals(fileType)){
+            // 根据文件的Id 和 医院Id获取数据
+            List<CostCostingGroup> costIncomeGroupList = costCostingGroupMapper.selectList(new QueryWrapper<CostCostingGroup>().lambda()
+                    .eq(CostCostingGroup::getHospId, hospId).eq(CostCostingGroup::getFileId, id));
+            if (CollectionUtils.isEmpty(costIncomeGroupList)){
+                throw new CostException(410,"数据已撤销");
+            }
+            List<Long> list = costIncomeGroupList.stream().map(CostCostingGroup::getId).collect(Collectors.toList());
+            costCostingGroupMapper.deleteBatchIds(list);
+        }if (SHAREPARAM_FILETYPE.equals(fileType)){
+            // 根据文件的Id 和 医院Id获取数据
+            List<CostShareParamGroup> costIncomeGroupList = costShareParamGroupMapper.selectList(new QueryWrapper<CostShareParamGroup>().lambda()
+                    .eq(CostShareParamGroup::getHospId, hospId).eq(CostShareParamGroup::getFileId, id));
+            if (CollectionUtils.isEmpty(costIncomeGroupList)){
+                throw new CostException(410,"数据已撤销");
+            }
+            List<Long> list = costIncomeGroupList.stream().map(CostShareParamGroup::getId).collect(Collectors.toList());
+            costShareParamGroupMapper.deleteBatchIds(list);
+        }
         costIncomeFile.setRollbackStatus(NumberConstant.ONE);
         this.updateById(costIncomeFile);
     }

+ 3 - 6
src/main/java/com/imed/costaccount/service/impl/CostShareParamServiceImpl.java

@@ -8,11 +8,9 @@ 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.Result;
 import com.imed.costaccount.constants.NumberConstant;
 import com.imed.costaccount.mapper.CostShareParamMapper;
 import com.imed.costaccount.model.CostShareParam;
-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;
@@ -24,7 +22,6 @@ 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;
@@ -129,7 +126,7 @@ public class CostShareParamServiceImpl extends ServiceImpl<CostShareParamMapper,
             String[] accountIds = costShareParamAccountDto.getAccountIds();
             List<String> accountList = Arrays.asList(accountIds);
             if (!CollectionUtil.isEmpty(accountList)){
-                String accounds = accountList.stream().map(String::valueOf).collect(Collectors.joining(","));
+                String accounds = accountList.stream().map(String::valueOf).collect(Collectors.joining(StrUtil.COMMA));
                 costShareParam.setAccountingId(accounds);
             }else {
                 costShareParam.setAccountingId(null);
@@ -173,7 +170,7 @@ public class CostShareParamServiceImpl extends ServiceImpl<CostShareParamMapper,
     }
 
     @Override
-    public List<Integer> selectIsSelect(Integer shareParamId) {
+    public List<Long> selectIsSelect(Integer shareParamId) {
         CostShareParam byId = this.getById(shareParamId);
         if (Objects.isNull(byId)) {
             return Collections.emptyList();
@@ -181,7 +178,7 @@ public class CostShareParamServiceImpl extends ServiceImpl<CostShareParamMapper,
         String accountingId = byId.getAccountingId();
         if (!StringUtils.isEmpty(accountingId)){
             String[] split = accountingId.split(StrUtil.COMMA);
-            List<Integer> collect = Arrays.stream(split).map(Integer::valueOf).collect(Collectors.toList());
+            List<Long> collect = Arrays.stream(split).map(Long::valueOf).collect(Collectors.toList());
             return collect;
         }else {
             return Collections.emptyList();

+ 75 - 87
src/main/java/com/imed/costaccount/service/impl/ResponsibilityServiceImpl.java

@@ -24,6 +24,8 @@ import org.springframework.util.CollectionUtils;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static com.imed.costaccount.common.constants.Constant.LIMIT;
+
 @Slf4j
 @Service("responsibilityService")
 public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper, Responsibility> implements ResponsibilityService {
@@ -44,6 +46,20 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
     @Override
     public List<CostResponsibilityVO> getList(User user) {
         // 1. 获取所有的列表然后组装
+        List<CostResponsibilityVO> costResponsibilityVOS = this.getCostResponsibilityVO(user);
+        List<CostResponsibilityVO> parentCostResponsibility = costResponsibilityVOS.stream()
+                .filter(i -> i.getParentId() == 0).collect(Collectors.toList());
+        // 多层结构
+        List<CostResponsibilityVO> all = new ArrayList<>();
+        // todo 试试多线程实现方式
+        for (CostResponsibilityVO parent : parentCostResponsibility) {
+            List<CostResponsibilityVO> children = this.getResponsibilityChildren(parent, costResponsibilityVOS);
+            all.addAll(children);
+        }
+        return all;
+    }
+
+    private List<CostResponsibilityVO> getCostResponsibilityVO(User user) {
         List<Responsibility> list = this.list(
                 new LambdaQueryWrapper<Responsibility>()
                         .eq(Responsibility::getHospId, user.getHospId())
@@ -54,23 +70,31 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
         }
         // 拷贝组合
         List<CostResponsibilityVO> costResponsibilityVOS = BeanUtil.convertList(list, CostResponsibilityVO.class);
-        List<CostResponsibilityVO> parentCostResponsibility = costResponsibilityVOS.stream()
-                .filter(i -> i.getResponsibilityLevel().equals(1)).collect(Collectors.toList());
+        return costResponsibilityVOS;
+    }
 
-        parentCostResponsibility.forEach(i -> costResponsibilityVOS.forEach(j -> {
-            if (j.getParentId().equals(i.getId())) {
-                if (i.getResponsibilityLevel() == 1) {
-                    i.setShareLevel(null);
-                }
-                List<CostResponsibilityVO> child = i.getChild();
+    /**
+     * 获取子层级
+     *
+     * @param parent                当前的
+     * @param costResponsibilityVOS 所有的
+     * @return
+     */
+    private List<CostResponsibilityVO> getResponsibilityChildren(CostResponsibilityVO parent, List<CostResponsibilityVO> costResponsibilityVOS) {
+        List<CostResponsibilityVO> list = new LinkedList<>();
+        list.add(parent);
+        for (CostResponsibilityVO costResponsibilityVO : costResponsibilityVOS) {
+            if (parent.getId().equals(costResponsibilityVO.getParentId())) {
+                List<CostResponsibilityVO> child = parent.getChild();
                 if (CollUtil.isEmpty(child)) {
                     child = new ArrayList<>();
                 }
-                child.add(j);
-                i.setChild(child);
+                child.add(costResponsibilityVO);
+                parent.setChild(child);
+                this.getResponsibilityChildren(costResponsibilityVO, costResponsibilityVOS);
             }
-        }));
-        return parentCostResponsibility;
+        }
+        return list;
     }
 
 
@@ -88,13 +112,11 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
         if (Objects.isNull(id)) {
             id = 0L;
         }
+        // 校验责任中心代码code是否唯一
         checkCode(responsibilitySaveDTO.getResponsibilityCode(), user.getHospId());
 
         Responsibility center = BeanUtil.convertObj(responsibilitySaveDTO, Responsibility.class);
-        center.setCreateTime(System.currentTimeMillis()).setId(null).setParentId(id).setHospId(user.getHospId()).setResponsibilityLevel(2);
-        if (id == 0) {
-            center.setResponsibilityLevel(1);
-        }
+        center.setCreateTime(System.currentTimeMillis()).setId(null).setParentId(id).setHospId(user.getHospId());
 
         // 如果是汇总中心,那么不存在分摊级别
         Integer isGatherCenter = responsibilitySaveDTO.getIsGatherCenter();
@@ -105,15 +127,32 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
         // 父节点不允许为非汇总中心
         Responsibility byId = this.getById(id);
         if (Objects.nonNull(byId) && (byId.getIsGatherCenter() == 2)) {
-            throw new CostException(500, "非汇总中心不允许添加");
+            throw new CostException(500, "非汇总中心不允许添加下属层级");
         }
 
         if (responsibilitySaveDTO.getIsGatherCenter() == 1) {
             throw new CostException(500, "子层级暂不允许为非汇总中心");
         }
+
+        // 只允许存在一个汇总中心
+        if (responsibilitySaveDTO.getIsDefault() == 1) {
+            this.checkIsDefault(user.getHospId());
+        }
         this.save(center);
     }
 
+    private void checkIsDefault(Long hospId) {
+        Responsibility one = this.getOne(
+                new LambdaQueryWrapper<Responsibility>()
+                        .eq(Responsibility::getHospId, hospId)
+                        .eq(Responsibility::getIsDefault, 1)
+                        .last(LIMIT)
+        );
+        if (Objects.nonNull(one)) {
+            throw new CostException("责任中心只能拥有一个默认责任中心");
+        }
+    }
+
     private void checkCode(String code, Long hospId) {
         // 校验责任代码唯一性
         Responsibility one = this.getOne(
@@ -151,55 +190,14 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
         // 如果不存在子节点 ,修改它本身
         if (list.isEmpty()) {
             this.updateCurResp(center, responsibilityEditDTO, user);
-            return ;
+            return;
         }
 
         this.updateParent(responsibilityEditDTO, center, user.getHospId());
-//        // 不管是哪个绑定到父级目录下
-////        if (responsibilityEditDTO.getParentId() == 0) {
-////
-////        }
-////
-////
-////        // 如果修改父节点节点(只有两层的情况)
-//        if (center.getResponsibilityLevel() == 1) {
-//            this.updateParent(responsibilityEditDTO, center, user.getHospId());
-//            return;
-//        }
-
-//        this.updateCurrent(responsibilityEditDTO, center, user.getHospId());
     }
 
-    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
-    public void updateAllResp(Responsibility center, ResponsibilityEditDTO dto, User user, List<Responsibility> list) {
-        // 删除原有的父节点数据
-        Long id = dto.getId();
-        this.removeById(id);
-        this.checkCode(dto.getResponsibilityCode(), user.getHospId());
-        // 新增父节点数据
-        Responsibility newResponsibility = BeanUtil.convertObj(dto, Responsibility.class);
-        newResponsibility.setId(null).setHospId(user.getHospId()).setCreateTime(new Date().getTime()).setResponsibilityLevel(2);
-        // 相关校验
-        if (dto.getParentId() == 0) {
-            newResponsibility.setResponsibilityLevel(1);
-        }
-
-        // 如果是汇总中心,那么不存在分摊级别
-        Integer isGatherCenter = newResponsibility.getIsGatherCenter();
-        if (isGatherCenter == 1) {
-            newResponsibility.setShareId(null);
-            newResponsibility.setShareLevel(0);
-            newResponsibility.setShareName("");
-        }
-
-        if (Objects.nonNull(center) && (center.getIsGatherCenter() == 2)) {
-            throw new CostException(500, "非汇总中心不允许添加");
-        }
-
 
-    }
-
-    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
+    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
     public void updateCurResp(Responsibility center, ResponsibilityEditDTO dto, User user) {
         // 删除
         Long id = dto.getId();
@@ -211,21 +209,23 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
         newResponsibility.setId(null)
                 .setHospId(user.getHospId())
                 .setCreateTime(System.currentTimeMillis())
-                .setParentId(dto.getParentId())
-                .setResponsibilityLevel(2);
+                .setParentId(dto.getParentId());
         // 如果变成了汇总中心,那么变成第一层
         if (dto.getIsGatherCenter() == 1) {
             newResponsibility.setShareId(null)
                     .setShareLevel(0)
                     .setShareName(null)
-                    .setParentId(0L)
-                    .setResponsibilityLevel(1);
+                    .setParentId(0L);
         }
         if (dto.getParentId() == 0) {
-            newResponsibility.setResponsibilityLevel(1);
             // 永远为2的情况
             newResponsibility.setIsGatherCenter(2);
         }
+        // 校验默认
+        if (dto.getIsDefault() == 1) {
+            this.checkIsDefault(user.getHospId());
+        }
+
         this.save(newResponsibility);
     }
 
@@ -252,11 +252,7 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
         this.checkCode(dto.getResponsibilityCode(), hospId);
         // 新增父节点数据
         Responsibility newResponsibility = BeanUtil.convertObj(dto, Responsibility.class);
-        newResponsibility.setId(null).setHospId(responsibility.getHospId()).setCreateTime(new Date().getTime()).setResponsibilityLevel(2);
-        // 相关校验
-        if (dto.getParentId() == 0) {
-            newResponsibility.setResponsibilityLevel(1);
-        }
+        newResponsibility.setId(null).setHospId(responsibility.getHospId()).setCreateTime(new Date().getTime());
 
         // 如果是汇总中心,那么不存在分摊级别
         Integer isGatherCenter = newResponsibility.getIsGatherCenter();
@@ -270,6 +266,9 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
         if (Objects.nonNull(byId) && (byId.getIsGatherCenter() == 2)) {
             throw new CostException(500, "非汇总中心不允许添加");
         }
+        if (dto.getIsDefault() == 1) {
+            this.checkIsDefault(hospId);
+        }
 
         this.save(newResponsibility);
 
@@ -301,15 +300,13 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
         newResponsibility.setId(null)
                 .setHospId(responsibility.getHospId())
                 .setCreateTime(System.currentTimeMillis())
-                .setParentId(dto.getParentId())
-                .setResponsibilityLevel(2);
+                .setParentId(dto.getParentId());
         // 暂时先这样处理
         if (dto.getIsGatherCenter() == 1) {
             newResponsibility.setShareId(null)
                     .setShareLevel(0)
                     .setShareName(null)
-                    .setParentId(0L)
-                    .setResponsibilityLevel(1);
+                    .setParentId(0L);
         }
         this.save(newResponsibility);
     }
@@ -359,7 +356,7 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
                 new LambdaQueryWrapper<Responsibility>()
                         .eq(Responsibility::getHospId, user.getHospId())
                         .eq(Responsibility::getParentId, 0)
-                .orderByDesc(Responsibility::getCreateTime)
+                        .orderByDesc(Responsibility::getCreateTime)
         );
         if (CollUtil.isEmpty(parentList)) {
             return Collections.emptyList();
@@ -402,7 +399,7 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
     public List<CommonVO> getParentList(User user) {
         List<Responsibility> list = this.list(
                 new LambdaQueryWrapper<Responsibility>().select(Responsibility::getId, Responsibility::getResponsibilityName)
-                        .eq(Responsibility::getResponsibilityLevel, 1)
+                        .eq(Responsibility::getParentId, 0)
                         .eq(Responsibility::getHospId, user.getHospId())
         );
         return list.stream().map(i -> {
@@ -448,16 +445,7 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
     @Override
     public List<CostResponsibilityVO> responsibilityList(User user) {
         // 1. 获取所有的列表然后组装
-        List<Responsibility> list = this.list(
-                new LambdaQueryWrapper<Responsibility>()
-                        .eq(Responsibility::getHospId, user.getHospId())
-                        .orderByDesc(Responsibility::getCreateTime)
-        );
-        if (CollUtil.isEmpty(list)) {
-            return Collections.emptyList();
-        }
-        // 拷贝组合
-        List<CostResponsibilityVO> costResponsibilityVOS = BeanUtil.convertList(list, CostResponsibilityVO.class);
+        List<CostResponsibilityVO> costResponsibilityVOS = this.getCostResponsibilityVO(user);
         List<CostResponsibilityVO> parentCostResponsibility = costResponsibilityVOS.stream()
                 .filter(i -> i.getResponsibilityLevel().equals(1)).collect(Collectors.toList());
 
@@ -470,7 +458,7 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
                 if (CollUtil.isEmpty(child)) {
                     child = new ArrayList<>();
                 }
-                j.setResponsibilityName(i.getResponsibilityName()+"/"+j.getResponsibilityName());
+                j.setResponsibilityName(i.getResponsibilityName() + "/" + j.getResponsibilityName());
                 child.add(j);
                 i.setChild(child);
             }

+ 3 - 0
src/main/java/com/imed/costaccount/test.json

@@ -0,0 +1,3 @@
+{
+  ""
+}

+ 31 - 4
src/main/java/com/imed/costaccount/web/CostAccountShareController.java

@@ -3,8 +3,11 @@ package com.imed.costaccount.web;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 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.CostAccountShare;
+import com.imed.costaccount.model.Responsibility;
 import com.imed.costaccount.model.User;
+import com.imed.costaccount.model.dto.AccountShareCopyDto;
 import com.imed.costaccount.model.dto.CostAccountShareEditDto;
 import com.imed.costaccount.model.dto.CostAccountShareSaveDto;
 import com.imed.costaccount.model.dto.ShareParamEditDto;
@@ -54,7 +57,7 @@ public class CostAccountShareController {
      * 获取相关的责任中心成本对照表数据
      */
     @GetMapping("/getCostAccountShare")
-    @ApiOperation("根据责任中心成本对照表的Id获取")
+    @ApiOperation("根据成本分摊参数对应表的Id获取")
     public Result getCostAccountShare(Integer id){
 		CostAccountShare costAccountShare = costAccountShareService.getById(id);
         return Result.ok(costAccountShare);
@@ -64,7 +67,7 @@ public class CostAccountShareController {
      * 保存
      */
     @PostMapping("/save")
-    @ApiOperation("保存责任中心成本对照数据")
+    @ApiOperation("保存成本分摊参数对应数据")
     public Result save(@RequestBody @Valid CostAccountShareSaveDto costAccountShareSaveDto){
 		costAccountShareService.addCostAccountShare(costAccountShareSaveDto);
         return Result.ok();
@@ -74,11 +77,14 @@ public class CostAccountShareController {
      * 修改
      */
     @PostMapping("/update")
-    @ApiOperation("修改责任中心成本数据")
+    @ApiOperation("修改成本分摊参数对应数据")
     public Result update(@RequestBody @Valid CostAccountShareEditDto costAccountShareEditDto){
 		costAccountShareService.updateByCostAccountShare(costAccountShareEditDto);
         return Result.ok();
     }
+    /**
+     * 显示会计科目里面
+     */
     /**
      * 在全部分摊参数里面显示当前责任中心已经存在的分摊参数
      */
@@ -125,9 +131,30 @@ public class CostAccountShareController {
      */
     @PostMapping("/delete")
     @ApiOperation("删除责任中心成本数据")
-    public Result delete(@RequestBody Integer[] ids){
+    public Result delete(@RequestBody Long[] ids){
 		costAccountShareService.removeByIds(Arrays.asList(ids));
         return Result.ok();
     }
 
+    /**
+     * 成本分摊参数设置对应复制
+     */
+    @PostMapping("/copyAccountShareData")
+    @ApiOperation("复制成本分摊参数设置功能")
+    public Result copyAccountShareData(@RequestBody @Valid AccountShareCopyDto accountShareCopyDto){
+        Long hospId = UserContext.getHospId();
+        costAccountShareService.copyAccountShareData(accountShareCopyDto,hospId);
+        return Result.ok();
+    }
+    /**
+     * 获取指定类型的责任中心集合 分开计算还是合并计算
+     * @param accountShareId 分摊参数设置的Id
+     */
+    @GetMapping("/getResponsibilityCalType")
+    @ApiOperation("获取指定类型的责任中心集合")
+    public Result getResponsibilityCalType(Long accountShareId){
+        Long hospId = UserContext.getHospId();
+        List<Responsibility> responsibilityList= costAccountShareService.getResponsibilityCalType(accountShareId,hospId);
+        return Result.ok(responsibilityList);
+    }
 }

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

@@ -72,7 +72,7 @@ public class CostShareParamController {
      * 接受传递过来的数组集合
      */
     @PostMapping("/updateCostShareParamByAccountId")
-    @ApiOperation("为成本参数添加对应科目信息")
+    @ApiOperation("为成本参数添加对应会计科目信息")
     public Result updateCostShareParamByAccountId(@RequestBody CostShareParamAccountDto costShareParamAccountDto){
         User user = (User) SecurityUtils.getSubject().getPrincipal();
         Long hospId = user.getHospId();

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

@@ -22,7 +22,7 @@ import java.util.List;
 @Slf4j
 @RestController
 @RequestMapping("/costAccount/responsibility")
-public class ResponsibilityController {
+public class ResponsibilityController extends AbstractController{
 
     private final ResponsibilityService responsibilityService;
 
@@ -33,7 +33,7 @@ public class ResponsibilityController {
     @ApiOperation("责任中心列表")
     @GetMapping("/list")
     public Result list() {
-        User user = (User) SecurityUtils.getSubject().getPrincipal();
+        User user = getUser();
         List<CostResponsibilityVO> list = responsibilityService.getList(user);
         PageUtils pageUtils = new PageUtils(list,0,0,0);
         return Result.ok(pageUtils);
@@ -42,7 +42,7 @@ public class ResponsibilityController {
     @ApiOperation("收入归集设置需要的责任中心列表")
     @GetMapping("/responsibilityList")
     public Result responsibilityList() {
-        User user = (User) SecurityUtils.getSubject().getPrincipal();
+        User user = getUser();
         List<CostResponsibilityVO> list = responsibilityService.responsibilityList(user);
         PageUtils pageUtils = new PageUtils(list,0,0,0);
         return Result.ok(pageUtils);
@@ -51,7 +51,7 @@ public class ResponsibilityController {
     @GetMapping("/getLevelTwo")
     @ApiOperation("获取可不是汇总中心列表")
     public Result getLevelTwo(){
-        User user = (User) SecurityUtils.getSubject().getPrincipal();
+        User user = getUser();
         Long hospId = user.getHospId();
         List<CostResponsibilityLevelVO> costResponsibilityLevelVOList= responsibilityService.getLevelTwo(hospId);
         return Result.ok(costResponsibilityLevelVOList);
@@ -62,7 +62,7 @@ public class ResponsibilityController {
     @ApiOperation("新增责任中心")
     @PostMapping("/save")
     public Result save(@RequestBody @Valid ResponsibilitySaveDTO responsibilitySaveDTO) {
-        User user = (User) SecurityUtils.getSubject().getPrincipal();
+        User user = getUser();
         responsibilityService.addResponsibilityCenter(responsibilitySaveDTO, user);
         return Result.ok();
     }
@@ -70,7 +70,7 @@ public class ResponsibilityController {
     @ApiOperation("编辑责任中心")
     @PostMapping("/edit")
     public Result edit(@RequestBody @Valid ResponsibilityEditDTO responsibilityEditDTO) {
-        User user = (User) SecurityUtils.getSubject().getPrincipal();
+        User user = getUser();
         responsibilityService.editResponsibility(responsibilityEditDTO, user);
         return Result.ok();
     }
@@ -86,7 +86,7 @@ public class ResponsibilityController {
     @ApiOperation("所有第一层父节点")
     @GetMapping("/getParentList")
     public Result getParentList() {
-        User user = (User) SecurityUtils.getSubject().getPrincipal();
+        User user = getUser();
         List<CommonVO> list = responsibilityService.getParentList(user);
         return Result.ok(list);
     }

+ 3 - 3
src/main/resources/mapper/CostAccountShareMapper.xml

@@ -11,9 +11,9 @@
         <result property="responsibilityCode" column="responsibility_code"/>
         <result property="responsibilityName" column="responsibility_name"/>
         <result property="hospId" column="hosp_id"/>
-        <result property="accountingId" column="accounting_id"/>
-        <result property="accountingName" column="accounting_name"/>
-        <result property="accountingCode" column="accounting_code"/>
+        <result property="accountingIds" column="accounting_ids"/>
+        <result property="accountingNames" column="accounting_names"/>
+        <result property="accountingCodes" column="accounting_codes"/>
         <result property="paramList" column="param_list"/>
         <result property="costNode" column="cost_node"/>
         <result property="createTime" column="create_time"/>

+ 1 - 1
src/main/resources/mapper/ResponsibilityMapper.xml

@@ -8,12 +8,12 @@
         <result property="id" column="id"/>
         <result property="responsibilityName" column="responsibility_name"/>
         <result property="responsibilityCode" column="responsibility_code"/>
-        <result property="responsibilityLevel" column="responsibility_level"/>
         <result property="parentId" column="parent_id"/>
         <result property="hospId" column="hosp_id"/>
         <result property="isGatherCenter" column="is_gather_center"/>
         <result property="responsibilityType" column="responsibility_type"/>
         <result property="shareId" column="share_id"/>
+        <result property="isDefault" column="is_default" />
         <result property="shareLevel" column="share_level"/>
         <result property="shareName" column="share_name"/>
         <result property="createTime" column="create_time"/>