|
@@ -121,13 +121,6 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
|
|
|
Long hospId = user.getHospId();
|
|
|
// 检验输入的数据的合理性
|
|
|
checkAccountShare(costAccountShareSaveDto, hospId);
|
|
|
- // 检验输入的责任中心是否存在
|
|
|
- List<CostAccountShare> costAccountShareList = baseMapper.selectList(new QueryWrapper<CostAccountShare>().lambda()
|
|
|
- .eq(CostAccountShare::getHospId, hospId));
|
|
|
- Map<Long, CostAccountShare> map = costAccountShareList.stream().collect(Collectors.toMap(CostAccountShare::getResponsibilityId,synOe->synOe));
|
|
|
- if (Objects.nonNull(map.get(costAccountShareSaveDto.getResponsibilityId()))){
|
|
|
- throw new CostException(500,"添加的责任中心已存在");
|
|
|
- }
|
|
|
CostAccountShare costAccountShareRequest = BeanUtil.convertObj(costAccountShareSaveDto, CostAccountShare.class);
|
|
|
costAccountShareRequest.setHospId(hospId);
|
|
|
costAccountShareRequest.setCreateTime(System.currentTimeMillis());
|
|
@@ -149,6 +142,7 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
|
|
|
costAccountShareSaveDto.setResponsibilityCode(responsibility.getResponsibilityCode());
|
|
|
costAccountShareSaveDto.setResponsibilityName(responsibility.getResponsibilityName());
|
|
|
costAccountShareSaveDto.setShareLevel(responsibility.getShareLevel());
|
|
|
+ List<CostAccountShare> costAccountShareList = baseMapper.selectList(new QueryWrapper<CostAccountShare>().lambda().eq(CostAccountShare::getHospId,hospId).eq(CostAccountShare::getResponsibilityId,costAccountShareSaveDto.getResponsibilityId()));
|
|
|
if (!StringUtils.isEmpty(costAccountShareSaveDto.getAccountingIds())){
|
|
|
// 这个责任中心允许输入会计科目
|
|
|
List<Long> accountIdList = Arrays.stream(costAccountShareSaveDto.getAccountingIds().split(StrUtil.COMMA)).map(Long::valueOf).collect(Collectors.toList());
|
|
@@ -163,17 +157,28 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
|
|
|
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 accountingIds = list.get(0).getAccountingIds();
|
|
|
- List<Long> accountIdListRequest = Arrays.stream(accountingIds.split(StrUtil.COMMA)).map(Long::valueOf).collect(Collectors.toList());
|
|
|
- if (!Collections.disjoint(accountIdListRequest,accountIdList)){
|
|
|
- throw new CostException(500,"存在重复的数据");
|
|
|
- }
|
|
|
-
|
|
|
+// Map<String, List<CostAccountShare>> costAccountMap = costAccountShareList.stream().collect(Collectors.groupingBy(CostAccountShare::getResponsibilityCode));
|
|
|
+// List<CostAccountShare> list = costAccountMap.get(costAccountShareSaveDto.getResponsibilityCode());
|
|
|
+ if (!CollectionUtils.isEmpty(costAccountShareList)){
|
|
|
+ costAccountShareList.forEach(i->{
|
|
|
+ String accountingIds = i.getAccountingIds();
|
|
|
+ Integer isShareCost = i.getIsShareCost();
|
|
|
+ List<Long> accountIdListRequest = Arrays.stream(accountingIds.split(StrUtil.COMMA)).map(Long::valueOf).collect(Collectors.toList());
|
|
|
+ if (!Collections.disjoint(accountIdListRequest,accountIdList)){
|
|
|
+ throw new CostException(500,"存在重复的数据");
|
|
|
+ }if (NumberConstant.ONE.equals(isShareCost) && NumberConstant.ONE.equals(costAccountShareSaveDto.getIsShareCost())){
|
|
|
+ throw new CostException(500,"责任中心已包含分摊成本");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ // 此时是
|
|
|
+ // 责任中心只允许出现一次
|
|
|
+ if (!CollectionUtils.isEmpty(costAccountShareList)){
|
|
|
+ throw new CostException(500,"该责任中心合并计算已存在");
|
|
|
+ }
|
|
|
+ if (NumberConstant.ONE.equals(costAccountShareSaveDto.getIsShareCost())){
|
|
|
+ throw new CostException(500,"合并计算责任中心必须要设置包含分摊参数");
|
|
|
}
|
|
|
}
|
|
|
// 检验输入的这个责任中心是否允许输入会计科目
|
|
@@ -205,7 +210,7 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
|
|
|
Long id = costAccountShareEditDto.getId();
|
|
|
CostAccountShare costAccountShare = baseMapper.selectById(id);
|
|
|
if (Objects.isNull(costAccountShare)){
|
|
|
- throw new CostException(500,"责任中心成本数据不存在");
|
|
|
+ throw new CostException(500,"成本分摊参数对应数据不存在");
|
|
|
}
|
|
|
baseMapper.deleteById(id);
|
|
|
// 新增责任中心成本对照数据
|
|
@@ -379,10 +384,11 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
|
|
|
Long shareId = responsibility.getShareId();
|
|
|
CostShareLevel costShareLevel = costShareLevelService.getById(shareId);
|
|
|
Integer calcType = costShareLevel.getCalcType();
|
|
|
+ // 分摊参数设置对饮的责任中心的id集合
|
|
|
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))
|
|
|
+ .eq(CostShareLevel::getHospId,hospId).eq(CostShareLevel::getCalcType, calcType))
|
|
|
.stream().map(CostShareLevel::getId).collect(Collectors.toList());
|
|
|
// 筛选责任中心里面符合指定类型的责任中心
|
|
|
// 筛选指定类型的责任中心 并且当前没有设置的责任中心
|