hr преди 4 години
родител
ревизия
a51d9cd3e6

+ 5 - 0
src/main/java/com/imed/costaccount/model/vo/AccountVO.java

@@ -23,5 +23,10 @@ public class AccountVO {
 
     private List<AccountVO> children;
 
+    /**
+     * true表示选中
+     */
+    private Boolean isSelect = false;
+
 
 }

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

@@ -23,9 +23,10 @@ public interface AccountingService extends IService<Accounting> {
      * 获取会计科目列表按收入支出类型
      * @param accountType  会计科目类型1.收入,2.支出
      * @param user
+     * @param shareParamId
      * @return
      */
-    List<AccountVO> getListByAccountType(Integer accountType, User user);
+    List<AccountVO> getListByAccountType(Integer accountType, User user, Integer shareParamId);
 
     /**
      * 保存会计科目

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

@@ -60,5 +60,8 @@ public interface CostShareParamService extends IService<CostShareParam> {
      * @return
      */
     CostShareParamVO getByHospIdAndAPramId(Integer id, Integer hospId);
+
+    List<Integer> selectIsSelect(Integer shareParamId);
+
 }
 

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

@@ -13,6 +13,7 @@ import com.imed.costaccount.model.dto.AccountingSaveDTO;
 import com.imed.costaccount.model.vo.AccountVO;
 import com.imed.costaccount.model.vo.SelectAccountingVO;
 import com.imed.costaccount.service.AccountingService;
+import com.imed.costaccount.service.CostShareParamService;
 import com.imed.costaccount.utils.BeanUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -26,16 +27,22 @@ import java.util.stream.Collectors;
 @Service("accountingService")
 public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Accounting> implements AccountingService {
 
+    private final CostShareParamService shareParamService;
+
+    public AccountingServiceImpl(CostShareParamService shareParamService) {
+        this.shareParamService = shareParamService;
+    }
 
     /**
      * 获取会计科目列表按收入支出类型
      *
-     * @param accountType 会计科目类型1.收入,2.支出
+     * @param accountType  会计科目类型1.收入,2.支出
      * @param user
+     * @param shareParamId
      * @return
      */
     @Override
-    public List<AccountVO> getListByAccountType(Integer accountType, User user) {
+    public List<AccountVO> getListByAccountType(Integer accountType, User user, Integer shareParamId) {
         // 1. 得到所有的会计科目
         List<Accounting> list = this.list(
                 new LambdaQueryWrapper<Accounting>()
@@ -48,6 +55,18 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
         }
         // 所有的
         List<AccountVO> all = list.stream().map(i -> BeanUtil.convertObj(i, AccountVO.class)).collect(Collectors.toList());
+        // 查询所有的已绑定的
+        if (Objects.nonNull(shareParamId)) {
+            List<Integer> ids = shareParamService.selectIsSelect(shareParamId);
+            if (CollUtil.isNotEmpty(ids)) {
+                all.forEach(i -> {
+                    if (ids.contains(i.getId())) {
+                        i.setIsSelect(true);
+                    }
+                });
+            }
+        }
+
         // 顶层的
         List<AccountVO> parents = all.stream().filter(i -> i.getParentId() == 0).collect(Collectors.toList());
         List<AccountVO> accountVOS = new ArrayList<>();

+ 14 - 0
src/main/java/com/imed/costaccount/service/impl/CostShareParamServiceImpl.java

@@ -1,6 +1,7 @@
 package com.imed.costaccount.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
+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;
@@ -170,4 +171,17 @@ public class CostShareParamServiceImpl extends ServiceImpl<CostShareParamMapper,
         CostShareParamVO costShareParamVO = BeanUtil.convertObj(costShareParam, CostShareParamVO.class);
         return costShareParamVO;
     }
+
+    @Override
+    public List<Integer> selectIsSelect(Integer shareParamId) {
+        CostShareParam byId = this.getById(shareParamId);
+        if (Objects.isNull(byId)) {
+            throw new CostException(500, "当前分摊参数已被移除或不存在");
+        }
+        String accountingId = byId.getAccountingId();
+        String[] split = accountingId.split(StrUtil.COMMA);
+        List<Integer> collect = Arrays.stream(split).map(Integer::valueOf).collect(Collectors.toList());
+        return collect;
+
+    }
 }

+ 2 - 2
src/main/java/com/imed/costaccount/web/AccountingController.java

@@ -39,9 +39,9 @@ public class AccountingController {
     @ApiOperation("获取会计科目列表按收入支出类型")
     @GetMapping("/list")
     @ApiImplicitParam(name = "accountType",value = "会计科目类型1.收入,2.支出")
-    public Result list(@RequestParam Integer accountType){
+    public Result list(@RequestParam Integer accountType,Integer shareParamId){
         User user = (User) SecurityUtils.getSubject().getPrincipal();
-        List<AccountVO> list = accountingService.getListByAccountType(accountType, user);
+        List<AccountVO> list = accountingService.getListByAccountType(accountType, user,shareParamId);
         PageUtils pageUtils = new PageUtils(list, 0, 0, 0);
         return Result.ok(pageUtils);
     }