|
@@ -1,6 +1,7 @@
|
|
|
package org.springblade.business.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -14,15 +15,15 @@ import org.springblade.business.mapper.StandardInfoMapper;
|
|
|
import org.springblade.business.service.StandardInfoJoinService;
|
|
|
import org.springblade.business.service.StandardInfoPrivateJoinService;
|
|
|
import org.springblade.business.service.StandardInfoService;
|
|
|
-import org.springblade.business.vo.StandardInfoDtoVo;
|
|
|
-import org.springblade.business.vo.StandardInfoPrivateJoinVO;
|
|
|
-import org.springblade.business.vo.StandardInfoVO;
|
|
|
+import org.springblade.business.vo.*;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
+import org.springblade.core.tool.utils.CollectionUtil;
|
|
|
+import org.springblade.core.tool.utils.StringUtil;
|
|
|
import org.springframework.beans.BeansException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -163,54 +164,99 @@ public class UStandardInfoServiceImpl extends ServiceImpl<StandardInfoMapper, St
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Boolean setCondition(List<StandardInfoJoinDTO> standardInfoJoins) {
|
|
|
- BladeUser user = SecureUtil.getUser();
|
|
|
- List<StandardInfoJoin> saveData = new ArrayList<>();
|
|
|
- try {
|
|
|
- for (StandardInfoJoinDTO standardInfoJoin : standardInfoJoins) {
|
|
|
- Long leftId = standardInfoJoin.getLeftId();
|
|
|
+ public Boolean setCondition(List<StandardInfoVO> standardInfoJoins, Long id) {
|
|
|
+ List<StandardInfo> standardInfoIds = baseMapper.selectList(Wrappers.<StandardInfo>lambdaQuery()
|
|
|
+ .eq(StandardInfo::getStandardId, id)
|
|
|
+ .eq(StandardInfo::getIsDeleted, 0));
|
|
|
+ if(CollectionUtil.isEmpty(standardInfoIds)){
|
|
|
+ throw new ServiceException("未查询到规范文件的信息");
|
|
|
+ }
|
|
|
+ List<Long> collect = standardInfoIds.stream().map(StandardInfo::getId).collect(Collectors.toList());
|
|
|
+ //删除当前规范文件下的条件设置
|
|
|
+ standardInfoJoinService.remove(Wrappers.<StandardInfoJoin>lambdaQuery()
|
|
|
+ .in(StandardInfoJoin::getStandardInfoLeftId, collect));
|
|
|
+
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(standardInfoJoins)) {
|
|
|
+ BladeUser user = SecureUtil.getUser();
|
|
|
+ //先删除,在添加
|
|
|
+ List<Long> leftIds = new ArrayList<>();
|
|
|
+ //获取参宿
|
|
|
+ List<StandardInfoJoinDTO> list = new ArrayList<>();
|
|
|
+ //新增数据
|
|
|
+ List<StandardInfoJoin> saveData = new ArrayList<>();
|
|
|
+ //解析参数
|
|
|
+ for (StandardInfoVO standardInfoJoin : standardInfoJoins) {
|
|
|
+ StandardInfoJoinDTO standardInfoJoinDTO = new StandardInfoJoinDTO();
|
|
|
+
|
|
|
+ Long leftId = standardInfoJoin.getId();
|
|
|
+ standardInfoJoinDTO.setLeftId(leftId);
|
|
|
+ leftIds.add(leftId);
|
|
|
+ List<StandardInfoConditionVo> standardInfos = standardInfoJoin.getStandardInfos();
|
|
|
+ if (CollectionUtil.isNotEmpty(standardInfos)) {
|
|
|
+ for (StandardInfoConditionVo standardInfo : standardInfos) {
|
|
|
+ StandardInfoGroupNameVO standardInfoGroupNameVO = standardInfo.getStandardInfoGroupNameVO();
|
|
|
+ List<Long> ids = standardInfoGroupNameVO.getIds();
|
|
|
+ standardInfoJoinDTO.getRightIds().addAll(ids);
|
|
|
+ }
|
|
|
+ list.add(standardInfoJoinDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //封装参数
|
|
|
+ for (StandardInfoJoinDTO standardInfoJoin : list) {
|
|
|
List<Long> rightIds = standardInfoJoin.getRightIds();
|
|
|
for (Long rightId : rightIds) {
|
|
|
StandardInfoJoin uStandardInfoJoin = new StandardInfoJoin();
|
|
|
uStandardInfoJoin.setId(SnowFlakeUtil.getId());
|
|
|
- uStandardInfoJoin.setStandardInfoLeftId(leftId);
|
|
|
+ uStandardInfoJoin.setStandardInfoLeftId(standardInfoJoin.getLeftId());
|
|
|
uStandardInfoJoin.setStandardInfoRightId(rightId);
|
|
|
uStandardInfoJoin.setCreateUser(user.getUserId());
|
|
|
saveData.add(uStandardInfoJoin);
|
|
|
}
|
|
|
- //先删除之前的关联关系
|
|
|
- standardInfoJoinService.remove(Wrappers.<StandardInfoJoin>lambdaQuery()
|
|
|
- .eq(StandardInfoJoin::getStandardInfoLeftId,leftId));
|
|
|
}
|
|
|
- //新增
|
|
|
- return standardInfoJoinService.saveBatch(saveData);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- throw new ServiceException("条件设置失败");
|
|
|
+
|
|
|
+ return standardInfoJoinService.saveOrUpdateBatch(saveData);
|
|
|
}
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Boolean setElementJoin(List<StandardInfoPrivateJoinDTO> standardInfoPrivateJoins) {
|
|
|
+ public Boolean setElementJoin(List<StandardInfoPrivateJoinVO> standardInfoPrivateJoins) {
|
|
|
BladeUser user = SecureUtil.getUser();
|
|
|
List<StandardInfoPrivateJoin> saveData = new ArrayList<>();
|
|
|
+ List<Long> leftIds = new ArrayList<>();
|
|
|
|
|
|
try {
|
|
|
- for (StandardInfoPrivateJoinDTO standardInfoPrivateJoin : standardInfoPrivateJoins) {
|
|
|
- Long leftId = standardInfoPrivateJoin.getLeftId();
|
|
|
- List<StandardInfoPrivateJoin> rightIds = standardInfoPrivateJoin.getRightIds();
|
|
|
- rightIds.forEach(f -> {
|
|
|
- f.setId(SnowFlakeUtil.getId());
|
|
|
- f.setStandardInfoId(leftId);
|
|
|
- f.setCreateUser(user.getUserId());
|
|
|
- });
|
|
|
- saveData.addAll(rightIds);
|
|
|
- //删除之前的关联关系
|
|
|
- standardInfoPrivateJoinService.remove(Wrappers.<StandardInfoPrivateJoin>lambdaQuery()
|
|
|
- .eq(StandardInfoPrivateJoin::getStandardInfoId,leftId));
|
|
|
+
|
|
|
+ for (StandardInfoPrivateJoinVO standardInfoPrivateJoin : standardInfoPrivateJoins) {
|
|
|
+ Long leftId = standardInfoPrivateJoin.getId();
|
|
|
+ leftIds.add(leftId);
|
|
|
+ List<StandardInfoPrivateJoinGroupVO> group = standardInfoPrivateJoin.getGroup();
|
|
|
+ //项目组
|
|
|
+ for (StandardInfoPrivateJoinGroupVO standardInfoPrivateJoinGroupVO : group) {
|
|
|
+ //项目id
|
|
|
+ Long privateId = standardInfoPrivateJoinGroupVO.getPrivateId();
|
|
|
+ List<StandardElementVo> keys = standardInfoPrivateJoinGroupVO.getKeys();
|
|
|
+
|
|
|
+ for (StandardElementVo key : keys) {
|
|
|
+ StandardInfoPrivateJoin join = new StandardInfoPrivateJoin();
|
|
|
+ join.setStandardInfoId(leftId);
|
|
|
+ join.setId(SnowFlakeUtil.getId());
|
|
|
+ join.setPrivateId(privateId);
|
|
|
+ join.setColKey(key.getColKey());
|
|
|
+ join.setColName(key.getColName());
|
|
|
+ join.setCreateUser(user.getUserId());
|
|
|
+ saveData.add(join);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- return standardInfoPrivateJoinService.saveBatch(saveData);
|
|
|
+ //删除之前的关联关系
|
|
|
+ standardInfoPrivateJoinService.remove(Wrappers.<StandardInfoPrivateJoin>lambdaQuery()
|
|
|
+ .in(StandardInfoPrivateJoin::getStandardInfoId, leftIds));
|
|
|
+
|
|
|
+ return standardInfoPrivateJoinService.saveOrUpdateBatch(saveData);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
throw new ServiceException("元素关联失败");
|
|
@@ -248,13 +294,29 @@ public class UStandardInfoServiceImpl extends ServiceImpl<StandardInfoMapper, St
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<StandardInfoVO> getConditionSet(Long id) {
|
|
|
- return baseMapper.getConditionSet(id);
|
|
|
+ public List<StandardInfoVO> getConditionSet(Long id, Long leftId) {
|
|
|
+ List<StandardInfoVO> conditionSet = baseMapper.getConditionSet(id, leftId);
|
|
|
+ for (StandardInfoVO standardInfoVO : conditionSet) {
|
|
|
+ List<StandardInfoConditionVo> standardInfos = standardInfoVO.getStandardInfos();
|
|
|
+ for (StandardInfoConditionVo standardInfo : standardInfos) {
|
|
|
+ //重新组装数据
|
|
|
+ List<String> name = standardInfo.getRightStandardInfos().stream().map(StandardInfo::getName).collect(Collectors.toList());
|
|
|
+ List<Long> ids = standardInfo.getRightStandardInfos().stream().map(StandardInfo::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ StandardInfoGroupNameVO standardInfoGroupNameVO = new StandardInfoGroupNameVO();
|
|
|
+ standardInfoGroupNameVO.setName(StringUtil.join(name, ","));
|
|
|
+ standardInfoGroupNameVO.setIds(ids);
|
|
|
+
|
|
|
+ standardInfo.setStandardInfoGroupNameVO(standardInfoGroupNameVO);
|
|
|
+ standardInfo.setRightStandardInfos(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return conditionSet;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<StandardInfoPrivateJoinVO> getElementJoin(Long id) {
|
|
|
- return baseMapper.getElementJoin(id);
|
|
|
+ public List<StandardInfoPrivateJoinVO> getElementJoin(Long id, Long leftId) {
|
|
|
+ return baseMapper.getElementJoin(id, leftId);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -263,6 +325,52 @@ public class UStandardInfoServiceImpl extends ServiceImpl<StandardInfoMapper, St
|
|
|
List<Long> collect = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList());
|
|
|
return baseMapper.effectPreview(collect);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Boolean editConditionSet(List<StandardInfoVO> standardInfoJoins) {
|
|
|
+ BladeUser user = SecureUtil.getUser();
|
|
|
+ //先删除,在添加
|
|
|
+ List<Long> leftIds = new ArrayList<>();
|
|
|
+ //获取参宿
|
|
|
+ List<StandardInfoJoinDTO> list = new ArrayList<>();
|
|
|
+ //新增数据
|
|
|
+ List<StandardInfoJoin> saveData = new ArrayList<>();
|
|
|
+ //解析参数
|
|
|
+ for (StandardInfoVO standardInfoJoin : standardInfoJoins) {
|
|
|
+ StandardInfoJoinDTO standardInfoJoinDTO = new StandardInfoJoinDTO();
|
|
|
+
|
|
|
+ Long leftId = standardInfoJoin.getId();
|
|
|
+ standardInfoJoinDTO.setLeftId(leftId);
|
|
|
+ leftIds.add(leftId);
|
|
|
+ List<StandardInfoConditionVo> standardInfos = standardInfoJoin.getStandardInfos();
|
|
|
+ for (StandardInfoConditionVo standardInfo : standardInfos) {
|
|
|
+ StandardInfoGroupNameVO standardInfoGroupNameVO = standardInfo.getStandardInfoGroupNameVO();
|
|
|
+ List<Long> ids = standardInfoGroupNameVO.getIds();
|
|
|
+ standardInfoJoinDTO.getRightIds().addAll(ids);
|
|
|
+ }
|
|
|
+ list.add(standardInfoJoinDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (StandardInfoJoinDTO standardInfoJoin : list) {
|
|
|
+
|
|
|
+ List<Long> rightIds = standardInfoJoin.getRightIds();
|
|
|
+ for (Long rightId : rightIds) {
|
|
|
+ StandardInfoJoin uStandardInfoJoin = new StandardInfoJoin();
|
|
|
+ uStandardInfoJoin.setId(SnowFlakeUtil.getId());
|
|
|
+ uStandardInfoJoin.setStandardInfoLeftId(standardInfoJoin.getLeftId());
|
|
|
+ uStandardInfoJoin.setStandardInfoRightId(rightId);
|
|
|
+ uStandardInfoJoin.setCreateUser(user.getUserId());
|
|
|
+ saveData.add(uStandardInfoJoin);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean remove = standardInfoJoinService.remove(Wrappers.<StandardInfoJoin>lambdaQuery()
|
|
|
+ .in(StandardInfoJoin::getStandardInfoLeftId, leftIds));
|
|
|
+
|
|
|
+ return standardInfoJoinService.saveOrUpdateBatch(saveData);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|