Prechádzať zdrojové kódy

编写收入归集设置的基本操作

ljx 4 rokov pred
rodič
commit
d99026bab2

+ 2 - 3
src/main/java/com/imed/costaccount/model/CostIncomeGroupSet.java

@@ -1,8 +1,6 @@
 package com.imed.costaccount.model;
 
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableLogic;
-import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.*;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -57,6 +55,7 @@ public class CostIncomeGroupSet implements Serializable {
 	/**
 	 * 排除的成本科目的Id ,拼接
 	 */
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
 	private String accountCode;
 	/**
 	 * 创建时间13位时间戳

+ 4 - 1
src/main/java/com/imed/costaccount/model/dto/CostIncomeGroupSetEditDto.java

@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import javax.validation.constraints.Max;
 import javax.validation.constraints.NotNull;
 
 /**
@@ -25,14 +26,16 @@ public class CostIncomeGroupSetEditDto {
 
     @ApiModelProperty(name = "openDepartmentProportion", value = "开单科室的比例")
     @NotNull(message = "开单科室比例不能为空")
+    @Max(100L)
     private Integer openDepartmentProportion;
 
     @ApiModelProperty(name = "startDepartmentStatus", value = "执行科室状态 1 收入中心 2 成本中心")
     @NotNull(message = "执行科室状态不能为空")
-
     private Integer startDepartmentStatus;
 
     @ApiModelProperty(name = "startDepartmentStatus", value = "执行科室的比例")
+    @NotNull(message = "执行科室状态不能为空")
+    @Max(100L)
     private Integer startDepartmentProportion;
 
     @ApiModelProperty(name = "responsibilityCode", value = "责任中心的代码")

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

@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
 import lombok.Data;
 
+import javax.validation.constraints.Max;
 import javax.validation.constraints.NotNull;
 
 /**
@@ -14,13 +15,16 @@ import javax.validation.constraints.NotNull;
 @Data
 @ApiOperation("收入归集设置的保存对象")
 public class CostIncomeGroupSetSaveDto {
-    public static final Integer ONE_HUNDRED=100;
+
+    public  Long ONE_HUNDRED=100L;
+
     @ApiModelProperty(name = "openDepartmentStatus", value = "开单科室的状态 1 收入中心  2 成本中心")
     @NotNull(message = "开单科室状态不能为空")
     private Integer openDepartmentStatus;
 
     @ApiModelProperty(name = "openDepartmentProportion", value = "开单科室的比例")
     @NotNull(message = "开单科室比例不能为空")
+    @Max(100L)
     private Integer openDepartmentProportion;
 
     @ApiModelProperty(name = "startDepartmentStatus", value = "执行科室状态 1 收入中心 2 成本中心")
@@ -29,6 +33,7 @@ public class CostIncomeGroupSetSaveDto {
     private Integer startDepartmentStatus;
 
     @ApiModelProperty(name = "startDepartmentStatus", value = "执行科室的比例")
+    @Max(100L)
     private Integer startDepartmentProportion;
 
     @ApiModelProperty(name = "responsibilityCode", value = "责任中心的代码")

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

@@ -1,7 +1,5 @@
 package com.imed.costaccount.model.dto;
 
-import com.baomidou.mybatisplus.annotation.FieldStrategy;
-import com.baomidou.mybatisplus.annotation.TableField;
 import lombok.Data;
 
 /**
@@ -19,7 +17,6 @@ public class CostShareParamAccountDto {
     /**
      * 要修改的成本参数
      */
-    @TableField(updateStrategy = FieldStrategy.IGNORED)
     private Long costShareParamId;
     /**
      * 关联的医院的Id

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

@@ -24,9 +24,12 @@ public class AccountVO {
     private List<AccountVO> children;
 
     /**
-     * true表示选中
+     * true表示选中  是否被分摊参数选中
      */
-    private Boolean isSelect = false;
-
+    private Boolean isShareParamSelect = false;
 
+    /**
+     * true表示选中  是否被收入归集设置选中
+     */
+    private Boolean isIncomeGroutSetSelect = false;
 }

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

@@ -28,12 +28,6 @@ public class CostResponsibilityTreeVO {
     @ApiModelProperty(name = "responsibilityLevel",value = "责任级别(第一级为1,以此类推)")
     private Integer responsibilityLevel;
 
-    @ApiModelProperty(name = "shareLevel",value = "分摊级别 如果是顶层默认为0")
-    private Integer shareLevel;
-
-    @ApiModelProperty(name = "shareName",value = "分摊级别名称")
-    private String shareName;
-
     private Long parentId;
 
     /**

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

@@ -26,7 +26,7 @@ public interface AccountingService extends IService<Accounting> {
      * @param shareParamId
      * @return
      */
-    List<AccountVO> getListByAccountType(Integer accountType, User user, Integer shareParamId);
+    List<AccountVO> getListByAccountType(Integer accountType, User user, Integer shareParamId,Integer incomeGroutSetId);
 
     /**
      * 保存会计科目

+ 15 - 0
src/main/java/com/imed/costaccount/service/CostIncomeGroupSetService.java

@@ -7,6 +7,8 @@ import com.imed.costaccount.model.dto.CostIncomeGroupSetEditDto;
 import com.imed.costaccount.model.dto.CostIncomeGroupSetSaveDto;
 import com.imed.costaccount.model.vo.CostIncomeGroupSetVO;
 
+import java.util.List;
+
 /**
  * 收入归集设置
  *
@@ -43,5 +45,18 @@ public interface CostIncomeGroupSetService extends IService<CostIncomeGroupSet>
      * @param hospId
      */
     void updateByIncomeGroup(CostIncomeGroupSetEditDto costIncomeGroupSetEditDto, Long hospId);
+
+    /**
+     * 查询当前收入归集设置里面对应的会计科目的Id集合
+     * @param incomeGroutSetId
+     * @return
+     */
+    List<String> selectIsSelect(Integer incomeGroutSetId);
+
+    /**
+     * 设置对应的排除成本科目
+     * @param accountList
+     */
+    void updateAccountCode(Integer id,List<String> accountList);
 }
 

+ 19 - 5
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.CostIncomeGroupSetService;
 import com.imed.costaccount.service.CostShareParamService;
 import com.imed.costaccount.utils.BeanUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -29,8 +30,11 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
 
     private final CostShareParamService shareParamService;
 
-    public AccountingServiceImpl(CostShareParamService shareParamService) {
+    private final CostIncomeGroupSetService costIncomeGroupSetService;
+
+    public AccountingServiceImpl(CostShareParamService shareParamService, CostIncomeGroupSetService costIncomeGroupSetService) {
         this.shareParamService = shareParamService;
+        this.costIncomeGroupSetService = costIncomeGroupSetService;
     }
 
     /**
@@ -42,7 +46,7 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
      * @return
      */
     @Override
-    public List<AccountVO> getListByAccountType(Integer accountType, User user, Integer shareParamId) {
+    public List<AccountVO> getListByAccountType(Integer accountType, User user, Integer shareParamId, Integer incomeGroutSetId) {
         // 1. 得到所有的会计科目
         List<Accounting> list = this.list(
                 new LambdaQueryWrapper<Accounting>()
@@ -56,18 +60,28 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
         // 所有的
 //        List<AccountVO> all = list.stream().map(i -> BeanUtil.con(i, AccountVO.class)).collect(Collectors.toList());
         List<AccountVO> all = BeanUtil.convertList(list, AccountVO.class);
-        // 查询所有的已绑定的
+        // 查询所有的已绑定的分摊参数
         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);
+                        i.setIsShareParamSelect(true);
+                    }
+                });
+            }
+        }
+        // 查询所有已绑定的 收入归集设置
+        if (Objects.nonNull(incomeGroutSetId)){
+            List<String> codes= costIncomeGroupSetService.selectIsSelect(incomeGroutSetId);
+            if (CollUtil.isNotEmpty(codes)){
+                all.forEach(i->{
+                    if (codes.contains(i.getAccountingCode())){
+                        i.setIsShareParamSelect(true);
                     }
                 });
             }
         }
-
         // 顶层的
         List<AccountVO> parents = all.stream().filter(i -> i.getParentId() == 0).collect(Collectors.toList());
         List<AccountVO> accountVOS = new ArrayList<>();

+ 44 - 3
src/main/java/com/imed/costaccount/service/impl/CostIncomeGroupSetServiceImpl.java

@@ -1,5 +1,7 @@
 package com.imed.costaccount.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
+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;
@@ -21,9 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 
@@ -179,4 +179,45 @@ public class CostIncomeGroupSetServiceImpl extends ServiceImpl<CostIncomeGroupSe
         baseMapper.insert(incomeGroupSet);
     }
 
+    /**
+     * 查询当前收入归集设置里面对应的会计科目的Id集合
+     *
+     * @param incomeGroutSetId
+     * @return
+     */
+    @Override
+    public List<String> selectIsSelect(Integer incomeGroutSetId) {
+        CostIncomeGroupSet incomeGroupSet = this.getById(incomeGroutSetId);
+        if (Objects.isNull(incomeGroupSet)) {
+            return Collections.emptyList();
+        }
+        String accountCode = incomeGroupSet.getAccountCode();
+        if (!StringUtils.isEmpty(accountCode)){
+            List<String> collect = Arrays.stream(accountCode.split(StrUtil.COMMA)).map(String::valueOf).collect(Collectors.toList());
+            return collect;
+        }else {
+            return Collections.emptyList();
+        }
+    }
+
+    /**
+     * 设置对应的排除成本科目
+     * @param id  收入归集设置的Id
+     * @param accountList 对应科目的Code集合
+     */
+    @Override
+    public void updateAccountCode(Integer id,List<String> accountList) {
+        CostIncomeGroupSet incomeGroupSet = this.getById(id);
+        if (Objects.isNull(incomeGroupSet)){
+            throw new CostException(500,"收入归集设置不存在");
+        }
+        if(CollUtil.isNotEmpty(accountList)){
+            String accountCodes = accountList.stream().map(String::valueOf).collect(Collectors.joining(StrUtil.COMMA));
+            incomeGroupSet.setAccountCode(accountCodes);
+        }else{
+            incomeGroupSet.setAccountCode(null);
+        }
+        baseMapper.updateById(incomeGroupSet);
+    }
+
 }

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

@@ -438,5 +438,8 @@ public class ResponsibilityServiceImpl extends ServiceImpl<ResponsibilityMapper,
         });
         return costResponsibilityLevelVOS;
     }
+    /**
+     * 树形结构返回责任中心列表数据
+     */
 
 }

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

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

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

@@ -7,11 +7,14 @@ import com.imed.costaccount.model.dto.CostIncomeGroupSetEditDto;
 import com.imed.costaccount.model.dto.CostIncomeGroupSetSaveDto;
 import com.imed.costaccount.model.vo.CostIncomeGroupSetVO;
 import com.imed.costaccount.service.CostIncomeGroupSetService;
+import com.imed.costaccount.service.impl.AccountingServiceImpl;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
 import java.util.Arrays;
+import java.util.List;
 
 
 /**
@@ -26,10 +29,14 @@ public class CostIncomeGroupSetController{
     @Autowired
     private CostIncomeGroupSetService costIncomeGroupSetService;
 
+    @Autowired
+    private AccountingServiceImpl accountingService;
+
     /**
      * 分页查询列表
      */
     @GetMapping("/list")
+    @ApiOperation("分页获取收入归集设置数据数据")
     public Result list(@RequestParam(defaultValue = "1", value = "current") Integer current,
                        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){
         Long hospId = UserContext.getHospId();
@@ -42,6 +49,7 @@ public class CostIncomeGroupSetController{
      * 根据Id获取收入归集设置数据
      */
     @GetMapping("/info/{id}")
+    @ApiOperation("根据Id获取收入归集设置数据")
     public Result info(@PathVariable("id") Long id){
         Long hospId = UserContext.getHospId();
         CostIncomeGroupSetVO costIncomeGroupSetVO = costIncomeGroupSetService.getByIncomeGroupId(id,hospId);
@@ -52,6 +60,7 @@ public class CostIncomeGroupSetController{
      * 保存
      */
     @PostMapping("/addCostIncomeGroupSet")
+    @ApiOperation("添加收入归集设置数据")
     public Result save(@RequestBody @Valid CostIncomeGroupSetSaveDto costIncomeGroupSetSaveDto){
         Long hospId = UserContext.getHospId();
         costIncomeGroupSetService.addCostIncomeGroupSet(costIncomeGroupSetSaveDto,hospId);
@@ -62,7 +71,8 @@ public class CostIncomeGroupSetController{
      * 修改
      */
     @PostMapping("/update")
-    public Result update(@RequestBody CostIncomeGroupSetEditDto costIncomeGroupSetEditDto){
+    @ApiOperation("修改收入归集设置数据")
+    public Result update(@RequestBody @Valid CostIncomeGroupSetEditDto costIncomeGroupSetEditDto){
         Long hospId = UserContext.getHospId();
         costIncomeGroupSetService.updateByIncomeGroup(costIncomeGroupSetEditDto,hospId);
         return Result.ok();
@@ -72,9 +82,21 @@ public class CostIncomeGroupSetController{
      * 删除
      */
     @PostMapping("/delete")
+    @ApiOperation("分删除收入归集设置数据")
     public Result delete(@RequestBody Long[] ids){
 		costIncomeGroupSetService.removeByIds(Arrays.asList(ids));
         return Result.ok();
     }
 
+    /**
+     *  添加排除成本科目
+     */
+    @PostMapping("/addIncomeAccount")
+    @ApiOperation("添加需要排除的成本科目")
+    public Result addIncomeAccount(Integer id,String[] accountCode){
+        List<String> accountList = Arrays.asList(accountCode);
+        costIncomeGroupSetService.updateAccountCode(id,accountList);
+        return Result.ok();
+    }
+
 }