Prechádzať zdrojové kódy

添加指定目标责任中心分摊的相关功能

JammeyJiang 4 mesiacov pred
rodič
commit
d63c6835b9

+ 16 - 0
src/main/java/com/kcim/dao/mapper/CostAccountShareTargetMapper.java

@@ -0,0 +1,16 @@
+package com.kcim.dao.mapper;
+
+import com.kcim.dao.model.CostAccountShareTarget;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 成本分摊对应的分摊目标责任中心
+ * 
+ * @author Wang.YS
+ * @date 2025-04-03 11:13:36
+ */
+@Mapper
+public interface CostAccountShareTargetMapper extends BaseMapper<CostAccountShareTarget> {
+	
+}

+ 74 - 0
src/main/java/com/kcim/dao/model/CostAccountShareTarget.java

@@ -0,0 +1,74 @@
+package com.kcim.dao.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.util.Date;
+
+/**
+ * 成本分摊对应的分摊目标责任中心
+ * 
+ * @author Wang.YS
+
+ * @date 2025-04-03 11:13:36
+ */
+@Data
+@Accessors(chain = true)
+@AllArgsConstructor
+@NoArgsConstructor
+@TableName("cost_account_share_target")
+public class CostAccountShareTarget implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 主键
+	 */
+	@TableId
+	private Long id;
+	/**
+	 * 医院id
+	 */
+	private Long hospId;
+	/**
+	 * 成本分摊参数对应表的ID
+	 */
+	private Long accountShareId;
+	/**
+	 * 目标责任中心代码
+	 */
+	private String targetResponsibilityCode;
+	/**
+	 * 创建人
+	 */
+	private String createUser;
+	/**
+	 * 创建时间
+	 */
+	private Date createTime;
+	/**
+	 * 更新人
+	 */
+	private String updateUser;
+	/**
+	 * 更新时间
+	 */
+	private Date updateTime;
+	/**
+	 * 删除人
+	 */
+	private String deleteUser;
+	/**
+	 * 删除时间
+	 */
+	private Date deleteTime;
+	/**
+	 * 删除标志  0正常 1作废
+	 */
+	private Integer delFlag;
+
+}

+ 2 - 2
src/main/java/com/kcim/dao/repository/CostAccountShareParamRepository.java

@@ -42,7 +42,7 @@ public class CostAccountShareParamRepository extends ServiceImpl<CostAccountShar
      * @param accountShareId
      * @return
      */
-    public boolean delCostAccountShareDetail(Long accountShareId) {
+    public boolean delCostAccountParamDetail(Long accountShareId) {
         LambdaUpdateWrapper<CostAccountShareParam> updateWrapper = new LambdaUpdateWrapper<>();
         updateWrapper.set(CostAccountShareParam::getDelFlag,NumberConstant.ONE);
         updateWrapper.set(CostAccountShareParam::getDeleteUser,UserContext.getCurrentUser().getId());
@@ -61,7 +61,7 @@ public class CostAccountShareParamRepository extends ServiceImpl<CostAccountShar
      * @param accountShareIdList
      * @return
      */
-    public boolean delCostAccountShareDetailList(List<Long> accountShareIdList) {
+    public boolean delCostAccountShareParamList(List<Long> accountShareIdList) {
         LambdaUpdateWrapper<CostAccountShareParam> updateWrapper = new LambdaUpdateWrapper<>();
         updateWrapper.set(CostAccountShareParam::getDelFlag,NumberConstant.ONE);
         updateWrapper.set(CostAccountShareParam::getDeleteUser,UserContext.getCurrentUser().getId());

+ 77 - 0
src/main/java/com/kcim/dao/repository/CostAccountShareTargetRepository.java

@@ -0,0 +1,77 @@
+package com.kcim.dao.repository;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.kcim.common.constants.NumberConstant;
+import com.kcim.common.util.UserContext;
+import com.kcim.dao.mapper.CostAccountShareTargetMapper;
+import com.kcim.dao.model.CostAccountShareTarget;
+import org.springframework.stereotype.Repository;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.ObjectUtils;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @program: CostAccount
+ * @description:
+ * @author: Wang.YS
+ * @create: 2024-04-03 14:49
+ **/
+@Repository
+public class CostAccountShareTargetRepository extends ServiceImpl<CostAccountShareTargetMapper, CostAccountShareTarget> {
+    /**
+     * 获取指定分摊设置对应的目标责任中心
+     * @param accountShareId
+     * @return
+     */
+    public List<CostAccountShareTarget> getCostAccountShareTarget(Long accountShareId) {
+        LambdaQueryWrapper<CostAccountShareTarget> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(CostAccountShareTarget::getHospId, UserContext.getHospId());
+        queryWrapper.eq(CostAccountShareTarget::getDelFlag, NumberConstant.ZERO);
+        if(!ObjectUtils.isEmpty(accountShareId)) {
+            queryWrapper.eq(CostAccountShareTarget::getAccountShareId, accountShareId);
+        }
+        return this.list(queryWrapper);
+    }
+
+    /**
+     * 作废指定分摊设置对应的目标责任中心
+     * @param accountShareId
+     * @return
+     */
+    public boolean delCostAccountShareTarget(Long accountShareId) {
+        LambdaUpdateWrapper<CostAccountShareTarget> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.set(CostAccountShareTarget::getDelFlag,NumberConstant.ONE);
+        updateWrapper.set(CostAccountShareTarget::getDeleteUser,UserContext.getCurrentUser().getId());
+        updateWrapper.set(CostAccountShareTarget::getDeleteTime,new Date());
+
+        updateWrapper.eq(CostAccountShareTarget::getHospId, UserContext.getHospId());
+        updateWrapper.eq(CostAccountShareTarget::getDelFlag, NumberConstant.ZERO);
+        if(!ObjectUtils.isEmpty(accountShareId)) {
+            updateWrapper.eq(CostAccountShareTarget::getAccountShareId, accountShareId);
+        }
+        return this.update(updateWrapper);
+    }
+
+    /**
+     * 批量删除指定分摊设置对应的目标责任中心
+     * @param accountShareIdList
+     * @return
+     */
+    public boolean delCostAccountShareTargetList(List<Long> accountShareIdList) {
+        LambdaUpdateWrapper<CostAccountShareTarget> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.set(CostAccountShareTarget::getDelFlag,NumberConstant.ONE);
+        updateWrapper.set(CostAccountShareTarget::getDeleteUser,UserContext.getCurrentUser().getId());
+        updateWrapper.set(CostAccountShareTarget::getDeleteTime,new Date());
+
+        updateWrapper.eq(CostAccountShareTarget::getHospId, UserContext.getHospId());
+        updateWrapper.eq(CostAccountShareTarget::getDelFlag, NumberConstant.ZERO);
+        if(!CollectionUtils.isEmpty(accountShareIdList)) {
+            updateWrapper.in(CostAccountShareTarget::getAccountShareId, accountShareIdList);
+        }
+        return this.update(updateWrapper);
+    }
+}

+ 8 - 0
src/main/java/com/kcim/service/CostAccountShareService.java

@@ -10,6 +10,7 @@ import com.kcim.dao.model.dto.CostAccountShareSaveDto;
 import com.kcim.dao.model.dto.ShareParamEditDto;
 import com.kcim.vo.CostShareParamStatusVO;
 import com.kcim.vo.ShareParamProportionVO;
+import com.kcim.vo.ShareTargetMapVo;
 
 import java.util.List;
 
@@ -104,5 +105,12 @@ public interface CostAccountShareService extends IService<CostAccountShare> {
      * @return
      */
     void synCostAccountShare(Integer direction, Long accountShareId);
+
+
+    /**
+     * 添加分摊设置对应的目标责任中心
+     * @param shareTargetMapVo
+     */
+    void applyAccountShareTarget(ShareTargetMapVo shareTargetMapVo);
 }
 

+ 15 - 0
src/main/java/com/kcim/service/CostAccountShareTargetService.java

@@ -0,0 +1,15 @@
+package com.kcim.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.kcim.dao.model.CostAccountShareTarget;
+
+/**
+ * 成本分摊对应的分摊目标责任中心
+ *
+ * @author Wang.YS
+ * @date 2025-04-03 11:13:36
+ */
+public interface CostAccountShareTargetService extends IService<CostAccountShareTarget> {
+
+}
+

+ 44 - 5
src/main/java/com/kcim/service/impl/AllocationServiceImpl.java

@@ -22,6 +22,7 @@ import com.kcim.dao.model.*;
 import com.kcim.dao.model.dto.StartDTO;
 import com.kcim.dao.repository.CostAccountShareDetailRepository;
 import com.kcim.dao.repository.CostAccountShareParamRepository;
+import com.kcim.dao.repository.CostAccountShareTargetRepository;
 import com.kcim.dao.repository.ResponsibilityRepository;
 import com.kcim.service.*;
 import com.kcim.vo.*;
@@ -62,6 +63,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
 
     private final CostAccountShareDetailRepository costAccountShareDetailRepository;
     private final CostAccountShareParamRepository costAccountShareParamRepository;
+    private final CostAccountShareTargetRepository costAccountShareTargetRepository;
 
 //    public AllocationServiceImpl(CostCostingGroupService costCostingGroupService, CostShareLevelService shareLevelService, ResponsibilityService responsibilityService, CostAccountShareService accountShareService, ShareParamValueService shareParamValueService, CostShareParamService shareParamService, AllocationQueryService allocationQueryService, ResponsibilityRepository responsibilityRepository, CenterService centerService, SqlService sqlService) {
 //        this.costCostingGroupService = costCostingGroupService;
@@ -163,12 +165,20 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
         if(!CollectionUtils.isEmpty(costAccountShareDetailList)) {
             costAccountShareDetailMap=costAccountShareDetailList.stream().collect(Collectors.groupingBy(CostAccountShareDetail::getAccountShareId));
         }
+
+        //分摊设置对应的目标责任中心
+        List<CostAccountShareTarget> costAccountShareTargetList = costAccountShareTargetRepository.getCostAccountShareTarget(null);
+        Map<Long, List<CostAccountShareTarget>> costAccountShareTargetMap =new HashMap<>();
+        //全部没有指定分摊时会有目标责任中心为空的情况
+        if(!CollectionUtils.isEmpty(costAccountShareTargetList)) {
+            costAccountShareTargetMap=costAccountShareTargetList.stream().collect(Collectors.groupingBy(CostAccountShareTarget::getAccountShareId));
+        }
         //分摊成本列表
         List<Allocation> allocationCostList=new ArrayList<>();
         //逐级分摊
         for (CostShareLevelVO shareLevelVO : shareLevelVOs) {
             List<Allocation> shareLevelAllocationList = allocationShareLevelCost(startDTO, shareLevelVO, responsibilityList, responsibilityShareIdMap, respDirectCostMap, respParamValueList,
-                    accountShareResponsibilityMap, costAccountShareParamMap, costAccountShareDetailMap, allocationCostList, timeMillis);
+                    accountShareResponsibilityMap, costAccountShareParamMap, costAccountShareDetailMap, costAccountShareTargetMap,allocationCostList, timeMillis);
             allocationCostList.addAll(shareLevelAllocationList);
         }
         //没有任何分摊数据
@@ -207,6 +217,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
                                                      Map<String,List<CostAccountShare>> accountShareResponsibilityMap,
                                                      Map<Long, List<CostAccountShareParam>> costAccountShareParamMap,
                                                      Map<Long, List<CostAccountShareDetail>> costAccountShareDetailMap,
+                                                     Map<Long, List<CostAccountShareTarget>> costAccountShareTargetMap,
                                                      List<Allocation> allocationCostList,
                                                      long timeMillis){
         //分摊成本列表
@@ -229,6 +240,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
         if (CollectionUtils.isEmpty(responsibilities)) {
             return allocationList;
         }
+
         //目标责任中心列表
         List<Responsibility> targetResponsibilityList = responsibilityList.stream().filter(responsibility -> targetLevelList.contains(String.valueOf(responsibility.getShareLevel()))).collect(Collectors.toList());
         if (CollectionUtils.isEmpty(targetResponsibilityList)) {
@@ -238,7 +250,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
         for (Responsibility responsibility : responsibilities) {
             //分摊一个责任中心的成本
             List<Allocation> allocationRespCosts = allocationResponsibilityCost(startDTO, shareLevelVO, responsibility, targetResponsibilityList, respDirectCostMap, respParamValueList,
-                    accountShareResponsibilityMap, costAccountShareParamMap, costAccountShareDetailMap, allocationCostList, timeMillis);
+                    accountShareResponsibilityMap, costAccountShareParamMap, costAccountShareDetailMap,costAccountShareTargetMap, allocationCostList, timeMillis);
             allocationList.addAll(allocationRespCosts);
         }
         return allocationList;
@@ -267,6 +279,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
                                              Map<String,List<CostAccountShare>> accountShareResponsibilityMap,
                                              Map<Long, List<CostAccountShareParam>> costAccountShareParamMap,
                                              Map<Long, List<CostAccountShareDetail>> costAccountShareDetailMap,
+                                             Map<Long, List<CostAccountShareTarget>> costAccountShareTargetMap,
                                              List<Allocation> allocationCostList,
                                              long timeMillis){
         //分摊结果列表
@@ -282,8 +295,6 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
         if(NumberConstant.ZERO.equals(calcType) &&NumberConstant.ONE!=accountShares.size()){
             throw new CostException(String.format("[%s-%s]的分摊设置有问题,合并计算的责任中心只允许设置一个分摊配置",responsibility.getResponsibilityCode(),responsibility.getResponsibilityName()));
         }
-        //所有目标责任中心的责任中心代码列表
-        List<String> targetResponsibilityCodeList = targetResponsibilityList.stream().map(Responsibility::getResponsibilityCode).collect(Collectors.toList());
         //间接成本
         List<Allocation> respIndirectCostList = allocationCostList.stream().filter(allocationCost -> allocationCost.getTargetResponsibilityCode().equals(responsibility.getResponsibilityCode())).collect(Collectors.toList());
         //直接成本
@@ -294,6 +305,10 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
             List<CostCostingGroup> paramDirectCostList=new ArrayList<>();
             //分摊设置对应的间接成本
             List<Allocation> paramIndirectCostList=new ArrayList<>();
+            //获取分摊设置对应的目标责任中心
+            List<Responsibility> shareTargetRespCodeList = getShareTargetResponsibility(accountShare, targetResponsibilityList, costAccountShareTargetMap);
+            //所有目标责任中心的责任中心代码列表
+            List<String> targetResponsibilityCodeList = shareTargetRespCodeList.stream().map(Responsibility::getResponsibilityCode).collect(Collectors.toList());
             //合并计算
             if(NumberConstant.ZERO.equals(calcType)){
                 //合并计算时分摊参数的成本=责任中心的成本
@@ -322,7 +337,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
                     throw new CostException(String.format("[%s-%s]的目标责任中心找不到对应的参数数值,无法继续分摊",responsibility.getResponsibilityName(),shareParam.getShareParamName()));
                 }
                 //按分摊参数计算每个会计科目分摊到的金额
-                List<Allocation> allocationParamCosts = allocationParamCostCalc(startDTO, shareLevelVO, responsibility, targetResponsibilityList, paramDirectCostList,
+                List<Allocation> allocationParamCosts = allocationParamCostCalc(startDTO, shareLevelVO, responsibility, shareTargetRespCodeList, paramDirectCostList,
                         paramIndirectCostList, accountShares.get(NumberConstant.ZERO), shareParam, targetResponsibilityParamList, timeMillis);
                 allocationList.addAll(allocationParamCosts);
             }
@@ -330,6 +345,30 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
         return allocationList;
     }
 
+    /**
+     * 获取分摊设置的目标责任中心
+     * @param accountShare
+     * @param levelTargetResponsibility
+     * @param costAccountShareTargetMap
+     * @return
+     */
+    public List<Responsibility> getShareTargetResponsibility(CostAccountShare accountShare,
+                                                             List<Responsibility> levelTargetResponsibility,
+                                                             Map<Long, List<CostAccountShareTarget>> costAccountShareTargetMap){
+        //获取分摊设置对应的目标责任中心
+        List<CostAccountShareTarget> shareTargetResponsibilityList=costAccountShareTargetMap.get(accountShare.getId());
+        if(CollectionUtils.isEmpty(shareTargetResponsibilityList)){
+            return levelTargetResponsibility;
+        }
+        //筛选出指定的目标责任中心
+        List<String> shareTargetRespCodeList = shareTargetResponsibilityList.stream().map(CostAccountShareTarget::getTargetResponsibilityCode).collect(Collectors.toList());
+        List<Responsibility> shareTargetRespList = levelTargetResponsibility.stream().filter(responsibility -> shareTargetRespCodeList.contains(responsibility.getResponsibilityCode())).collect(Collectors.toList());
+        if(CollectionUtils.isEmpty(shareTargetRespList)){
+            throw new CostException(String.format("[%s-%s]找不到对应的目标责任中心,无法继续分摊",accountShare.getResponsibilityName(),accountShare.getAlias()));
+        }
+        return shareTargetRespList;
+    }
+
 
     /**
      * 按分摊参数计算每个会计科目分摊到的金额

+ 72 - 3
src/main/java/com/kcim/service/impl/CostAccountShareServiceImpl.java

@@ -20,6 +20,7 @@ import com.kcim.dao.model.dto.CostAccountShareSaveDto;
 import com.kcim.dao.model.dto.ShareParamEditDto;
 import com.kcim.dao.repository.CostAccountShareDetailRepository;
 import com.kcim.dao.repository.CostAccountShareParamRepository;
+import com.kcim.dao.repository.CostAccountShareTargetRepository;
 import com.kcim.service.*;
 import com.kcim.vo.*;
 import lombok.AllArgsConstructor;
@@ -51,6 +52,7 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
 
     private final CostAccountShareDetailRepository costAccountShareDetailRepository;
     private final CostAccountShareParamRepository costAccountShareParamRepository;
+    private final CostAccountShareTargetRepository costAccountShareTargetRepository;
 
 
 //    public CostAccountShareServiceImpl(CostAccountShareParamService costAccountShareParamService,CostAccountShareDetailService costAccountShareDetailService,ResponsibilityService responsibilityService, AccountingService accountingService, CostShareLevelService costShareLevelService, CostShareParamService costShareParamService) {
@@ -386,7 +388,7 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
      */
     public void applyShareParamProportion(ShareParamEditDto shareParamEditDto){
         //先作废上次的数据
-        costAccountShareParamRepository.delCostAccountShareDetail(shareParamEditDto.getId());
+        costAccountShareParamRepository.delCostAccountParamDetail(shareParamEditDto.getId());
         //保存新的分摊参数
         List<ShareParamProportionVO> newShareParamList = shareParamEditDto.getShareParamProportionVOList();
         List<CostAccountShareParam> costAccountShareParamList = newShareParamList.stream().map(newShareParam ->
@@ -480,6 +482,8 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
         this.saveBatch(accountShareList);
         //主表向明细表同步
         synMainCostAccountShare(accountShareList);
+        //复制目标责任中心设置
+        copyCostAccountShareTarget(accountShareCopyDto,accountShareList);
     }
 
     /**
@@ -558,7 +562,7 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
     public void deleteByIds(List<Long> idList) {
         this.removeByIds(idList);
         costAccountShareDetailRepository.delCostAccountShareDetailList(idList);
-        costAccountShareParamRepository.delCostAccountShareDetailList(idList);
+        costAccountShareParamRepository.delCostAccountShareParamList(idList);
     }
 
     @Override
@@ -629,7 +633,7 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
         //作废原来的数据
         List<Long> accountShareIdList = costAccountShareList.stream().map(CostAccountShare::getId).collect(Collectors.toList());
         costAccountShareDetailRepository.delCostAccountShareDetailList(accountShareIdList);
-        costAccountShareParamRepository.delCostAccountShareDetailList(accountShareIdList);
+        costAccountShareParamRepository.delCostAccountShareParamList(accountShareIdList);
         //保存会计科目对象
         if (!CollectionUtils.isEmpty(fullCostAccountShareDetailList)) {
             costAccountShareDetailRepository.saveBatch(fullCostAccountShareDetailList,NumberConstant.ONE_HUNDRED);
@@ -688,4 +692,69 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
         return baseMapper.selectList(queryWrapper);
     }
 
+    /**
+     * 复制目标责任中心设置
+     * @param accountShareCopyDto
+     * @param accountShareList
+     */
+    public void copyCostAccountShareTarget(AccountShareCopyDto accountShareCopyDto,List<CostAccountShare> accountShareList){
+        //没有指定的复制目标
+        if(CollectionUtils.isEmpty(accountShareList)){
+            return;
+        }
+        List<CostAccountShareTarget> costAccountShareTargetList = costAccountShareTargetRepository.getCostAccountShareTarget(accountShareCopyDto.getId());
+        //没有设置指定的分摊目标责任中心
+        if(CollectionUtils.isEmpty(costAccountShareTargetList)){
+            return;
+        }
+        //逐个分摊设置复制目标责任中心
+        List<CostAccountShareTarget> copyCostAccountShareTargetList=new ArrayList<>();
+        for (CostAccountShare costAccountShare : accountShareList) {
+            List<CostAccountShareTarget> copyTargetList = costAccountShareTargetList.stream().map(target -> createCostAccountShareTarget(costAccountShare.getId(), target.getTargetResponsibilityCode())).collect(Collectors.toList());
+            copyCostAccountShareTargetList.addAll(copyTargetList);
+        }
+        //保存复制的数据
+        if(CollectionUtils.isEmpty(copyCostAccountShareTargetList)) {
+            costAccountShareTargetRepository.saveBatch(copyCostAccountShareTargetList);
+        }
+    }
+
+    @Override
+    public void applyAccountShareTarget(ShareTargetMapVo shareTargetMapVo) {
+        applyAccountShareTarget(shareTargetMapVo.getAccountShareId(),shareTargetMapVo.getTargetRespCodeList());
+    }
+    /**
+     * 提交分摊设置对应的目标责任中心
+     * @param accountShareId
+     * @param respCodeList
+     */
+    public void applyAccountShareTarget(Long accountShareId , List<String> respCodeList){
+        //先作废上次的数据
+        costAccountShareTargetRepository.delCostAccountShareTarget(accountShareId);
+        //没有新的目标责任中心时不用处理
+        if(CollectionUtils.isEmpty(respCodeList)){
+            return;
+        }
+        //保存新的目标责任中心
+        List<CostAccountShareTarget> costAccountShareTargetList = respCodeList.stream().map(respCode ->
+                createCostAccountShareTarget(accountShareId, respCode)).collect(Collectors.toList());
+        costAccountShareTargetRepository.saveBatch(costAccountShareTargetList);
+    }
+
+    /**
+     * 生成分摊设置对应的目标责任中心对象
+     * @param accountShareId
+     * @param targetResponsibilityCode
+     * @return
+     */
+    public CostAccountShareTarget createCostAccountShareTarget(Long accountShareId,String targetResponsibilityCode) {
+        CostAccountShareTarget costAccountShareTarget = new CostAccountShareTarget();
+        costAccountShareTarget.setHospId(UserContext.getHospId());
+        costAccountShareTarget.setAccountShareId(accountShareId);
+        costAccountShareTarget.setTargetResponsibilityCode(targetResponsibilityCode);
+        costAccountShareTarget.setCreateUser(String.valueOf(UserContext.getCurrentUser().getId()));
+        costAccountShareTarget.setCreateTime(new Date());
+        return costAccountShareTarget;
+    }
+
 }

+ 15 - 0
src/main/java/com/kcim/service/impl/CostAccountShareTargetService.java

@@ -0,0 +1,15 @@
+package com.kcim.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.kcim.dao.model.CostAccountShareTarget;
+
+/**
+ * 成本分摊对应的分摊目标责任中心
+ *
+ * @author Wang.YS
+ * @date 2025-04-03 11:13:36
+ */
+public interface CostAccountShareTargetService extends IService<CostAccountShareTarget> {
+
+}
+

+ 23 - 0
src/main/java/com/kcim/vo/ShareTargetMapVo.java

@@ -0,0 +1,23 @@
+package com.kcim.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 分摊目标责任中心绑定对象
+ * @program:
+ * @description:
+ * @author: Wang.YS
+ * @create: 2023-11-01 21:25
+ **/
+@Data
+public class ShareTargetMapVo {
+
+    @ApiModelProperty(name = "accountShareId",value = "分摊参数对应ID")
+    private Long accountShareId;
+
+    @ApiModelProperty(name = "targetRespCodeList",value = "目标责任中心代码")
+    private List<String> targetRespCodeList;
+}

+ 12 - 1
src/main/java/com/kcim/web/CostAccountShareController.java

@@ -10,9 +10,10 @@ import com.kcim.dao.model.dto.AccountShareCopyDto;
 import com.kcim.dao.model.dto.CostAccountShareEditDto;
 import com.kcim.dao.model.dto.CostAccountShareSaveDto;
 import com.kcim.dao.model.dto.ShareParamEditDto;
+import com.kcim.service.CostAccountShareService;
 import com.kcim.vo.CostShareParamStatusVO;
 import com.kcim.vo.ShareParamProportionVO;
-import com.kcim.service.CostAccountShareService;
+import com.kcim.vo.ShareTargetMapVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -165,4 +166,14 @@ public class CostAccountShareController {
         costAccountShareService.synCostAccountShare(direction,accountShareId);
         return Result.ok();
     }
+
+    /**
+     * 进行分摊参数设置
+     */
+    @PostMapping("/applyAccountShareTarget")
+    @ApiOperation("添加分摊参数设置对应的目标责任中心")
+    public Result applyAccountShareTarget(@RequestBody ShareTargetMapVo shareTargetMapVo){
+        costAccountShareService.applyAccountShareTarget(shareTargetMapVo);
+        return Result.ok();
+    }
 }