|
@@ -1,9 +1,11 @@
|
|
|
package com.imed.costaccount.service.impl;
|
|
|
|
|
|
+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;
|
|
|
import com.imed.costaccount.common.exception.CostException;
|
|
|
+import com.imed.costaccount.common.util.BeanUtil;
|
|
|
import com.imed.costaccount.common.util.PageUtils;
|
|
|
import com.imed.costaccount.mapper.CostShareLevelMapper;
|
|
|
import com.imed.costaccount.model.CostShareLevel;
|
|
@@ -12,15 +14,16 @@ import com.imed.costaccount.model.dto.CostShareLevelEditDto;
|
|
|
import com.imed.costaccount.model.dto.CostShareLevelSaveDto;
|
|
|
import com.imed.costaccount.model.vo.CostShareLevelVO;
|
|
|
import com.imed.costaccount.service.CostShareLevelService;
|
|
|
-import com.imed.costaccount.common.util.BeanUtil;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@Service("costShareLevelService")
|
|
@@ -64,12 +67,18 @@ public class CostShareLevelServiceImpl extends ServiceImpl<CostShareLevelMapper,
|
|
|
public void addCostShareLevel(CostShareLevelSaveDto costShareLevelSaveDto) {
|
|
|
User user = (User) SecurityUtils.getSubject().getPrincipal();
|
|
|
Long hospId = user.getHospId();
|
|
|
+ // 检验目标层级必须大于等于当前层级
|
|
|
+ String targetLevel = costShareLevelSaveDto.getTargetLevel();
|
|
|
+ Integer leverSort = costShareLevelSaveDto.getLeverSort();
|
|
|
+ checkTargetLevel(targetLevel, leverSort);
|
|
|
CostShareLevel costShareLevel = BeanUtil.convertObj(costShareLevelSaveDto, CostShareLevel.class);
|
|
|
costShareLevel.setCreateTime(System.currentTimeMillis());
|
|
|
costShareLevel.setHospId(hospId);
|
|
|
baseMapper.insert(costShareLevel);
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 查询层级级别大于等于当前
|
|
|
+ */
|
|
|
/**
|
|
|
* 修改分摊层级数据
|
|
|
*
|
|
@@ -85,6 +94,9 @@ public class CostShareLevelServiceImpl extends ServiceImpl<CostShareLevelMapper,
|
|
|
if (Objects.isNull(costShareLevel)){
|
|
|
throw new CostException("分摊层级数据不存在");
|
|
|
}
|
|
|
+ String targetLevel = costShareLevelEditDto.getTargetLevel();
|
|
|
+ Integer leverSort = costShareLevelEditDto.getLeverSort();
|
|
|
+ checkTargetLevel(targetLevel, leverSort);
|
|
|
baseMapper.deleteById(id);
|
|
|
CostShareLevel costShareLevelRequest = BeanUtil.convertObj(costShareLevelEditDto, CostShareLevel.class);
|
|
|
costShareLevelRequest.setId(null);
|
|
@@ -93,6 +105,20 @@ public class CostShareLevelServiceImpl extends ServiceImpl<CostShareLevelMapper,
|
|
|
baseMapper.insert(costShareLevelRequest);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 目标层级不能小于当前层级
|
|
|
+ * @param targetLevel 目标层级
|
|
|
+ * @param leverSort 当前层级
|
|
|
+ */
|
|
|
+ private void checkTargetLevel(String targetLevel, Integer leverSort) {
|
|
|
+ List<Integer> targetLevelList = Arrays.stream(targetLevel.split(StrUtil.COMMA)).map(Integer::valueOf).collect(Collectors.toList());
|
|
|
+ targetLevelList.forEach(i -> {
|
|
|
+ if (i < leverSort) {
|
|
|
+ throw new CostException(500, "目标层级不能小于当前层级");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取所有的分摊层级数据
|
|
|
*
|