|
@@ -217,47 +217,53 @@ public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMap
|
|
|
@Override
|
|
|
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
|
|
|
public void updateShareParam(ShareParamEditDto shareParamEditDto) {
|
|
|
- User user = (User) SecurityUtils.getSubject().getPrincipal();
|
|
|
- Integer hospId = user.getHospId();
|
|
|
- Integer id = shareParamEditDto.getId();
|
|
|
- CostAccountShare costAccountShare = baseMapper.selectOne(new QueryWrapper<CostAccountShare>().lambda()
|
|
|
- .eq(CostAccountShare::getHospId, hospId)
|
|
|
- .eq(CostAccountShare::getId, id));
|
|
|
- if (Objects.isNull(costAccountShare)){
|
|
|
- throw new CostException(500,"责任中心成本数据不存在");
|
|
|
- }
|
|
|
- List<ShareParamProportionVO> shareParamProportionVOList = shareParamEditDto.getShareParamProportionVOList();
|
|
|
- // 检验输入的成本分摊参数是否存在
|
|
|
- List<CostShareParamVO> costShareParamServiceAll = costShareParamService.getAll(hospId);
|
|
|
- Map<Integer, List<CostShareParamVO>> listMap = costShareParamServiceAll.stream().collect(Collectors.groupingBy(CostShareParamVO::getId));
|
|
|
- shareParamProportionVOList.forEach(i->{
|
|
|
- if (CollectionUtils.isEmpty(listMap.get(i.getId()))){
|
|
|
- throw new CostException(500,"分摊名称:"+i.getShareParamName()+"未找到");
|
|
|
- }
|
|
|
- });
|
|
|
- // 检验输入的数据的和是否是100
|
|
|
- AtomicReference<Integer> sum= new AtomicReference<>(0);
|
|
|
- shareParamProportionVOList.forEach(i->{
|
|
|
- sum.updateAndGet(v -> v + i.getShareParamPopout());
|
|
|
- });
|
|
|
- int max = Integer.parseInt(sum.toString());
|
|
|
- if (!NumberConstant.ONE_HUNDRED.equals(max)){
|
|
|
- throw new CostException(500,"分摊比例的和不是100");
|
|
|
- }
|
|
|
+ List<ShareParamProportionVO> shareParamProportionVOList1 = shareParamEditDto.getShareParamProportionVOList();
|
|
|
|
|
|
- // 判断添加的分摊是否存在一样的
|
|
|
- HashMap<Integer, ShareParamProportionVO> hashMap = new HashMap<>();
|
|
|
- shareParamProportionVOList.forEach(i->{
|
|
|
- Integer paramId = i.getId();
|
|
|
- if (hashMap.containsKey(paramId)){
|
|
|
- throw new CostException(500,"不可以添加相同的分摊参数");
|
|
|
+ User user = (User) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ Integer hospId = user.getHospId();
|
|
|
+ Integer id = shareParamEditDto.getId();
|
|
|
+ CostAccountShare costAccountShare = baseMapper.selectOne(new QueryWrapper<CostAccountShare>().lambda()
|
|
|
+ .eq(CostAccountShare::getHospId, hospId)
|
|
|
+ .eq(CostAccountShare::getId, id));
|
|
|
+ if (Objects.isNull(costAccountShare)){
|
|
|
+ throw new CostException(500,"分摊参数对应数据不存在");
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(shareParamProportionVOList1)){
|
|
|
+ List<ShareParamProportionVO> shareParamProportionVOList = shareParamEditDto.getShareParamProportionVOList();
|
|
|
+ // 检验输入的成本分摊参数是否存在
|
|
|
+ List<CostShareParamVO> costShareParamServiceAll = costShareParamService.getAll(hospId);
|
|
|
+ Map<Integer, List<CostShareParamVO>> listMap = costShareParamServiceAll.stream().collect(Collectors.groupingBy(CostShareParamVO::getId));
|
|
|
+ shareParamProportionVOList.forEach(i->{
|
|
|
+ if (CollectionUtils.isEmpty(listMap.get(i.getId()))){
|
|
|
+ throw new CostException(500,"分摊名称:"+i.getShareParamName()+"未找到");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 检验输入的数据的和是否是100
|
|
|
+ AtomicReference<Integer> sum= new AtomicReference<>(0);
|
|
|
+ shareParamProportionVOList.forEach(i->{
|
|
|
+ sum.updateAndGet(v -> v + i.getShareParamPopout());
|
|
|
+ });
|
|
|
+ int max = Integer.parseInt(sum.toString());
|
|
|
+ if (!NumberConstant.ONE_HUNDRED.equals(max)){
|
|
|
+ throw new CostException(500,"分摊比例的和不是100");
|
|
|
}
|
|
|
- hashMap.put(paramId,i);
|
|
|
- });
|
|
|
|
|
|
- //
|
|
|
- String paramList = JsonUtil.toJSONString(shareParamProportionVOList);
|
|
|
- costAccountShare.setParamList(paramList);
|
|
|
+ // 判断添加的分摊是否存在一样的
|
|
|
+ HashMap<Integer, ShareParamProportionVO> hashMap = new HashMap<>();
|
|
|
+ shareParamProportionVOList.forEach(i->{
|
|
|
+ Integer paramId = i.getId();
|
|
|
+ if (hashMap.containsKey(paramId)){
|
|
|
+ throw new CostException(500,"不可以添加相同的分摊参数");
|
|
|
+ }
|
|
|
+ hashMap.put(paramId,i);
|
|
|
+ });
|
|
|
+ //
|
|
|
+ String paramList = JsonUtil.toJSONString(shareParamProportionVOList);
|
|
|
+ costAccountShare.setParamList(paramList);
|
|
|
+ }else{
|
|
|
+ costAccountShare.setParamList(null);
|
|
|
+ }
|
|
|
+
|
|
|
baseMapper.updateById(costAccountShare);
|
|
|
}
|
|
|
|