|
|
@@ -163,31 +163,47 @@ public class UStandardInfoServiceImpl extends ServiceImpl<StandardInfoMapper, St
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Boolean setCondition(List<StandardInfoJoinDTO> standardInfoJoins) {
|
|
|
+ public Boolean setCondition(List<StandardInfoVO> standardInfoJoins) {
|
|
|
BladeUser user = SecureUtil.getUser();
|
|
|
+ //先删除,在添加
|
|
|
+ List<Long> leftIds = new ArrayList<>();
|
|
|
+ //获取参宿
|
|
|
+ List<StandardInfoJoinDTO> list = new ArrayList<>();
|
|
|
+ //新增数据
|
|
|
List<StandardInfoJoin> saveData = new ArrayList<>();
|
|
|
- try {
|
|
|
- for (StandardInfoJoinDTO standardInfoJoin : standardInfoJoins) {
|
|
|
- Long leftId = standardInfoJoin.getLeftId();
|
|
|
- List<Long> rightIds = standardInfoJoin.getRightIds();
|
|
|
- for (Long rightId : rightIds) {
|
|
|
- StandardInfoJoin uStandardInfoJoin = new StandardInfoJoin();
|
|
|
- uStandardInfoJoin.setId(SnowFlakeUtil.getId());
|
|
|
- uStandardInfoJoin.setStandardInfoLeftId(leftId);
|
|
|
- uStandardInfoJoin.setStandardInfoRightId(rightId);
|
|
|
- uStandardInfoJoin.setCreateUser(user.getUserId());
|
|
|
- saveData.add(uStandardInfoJoin);
|
|
|
- }
|
|
|
- //先删除之前的关联关系
|
|
|
- standardInfoJoinService.remove(Wrappers.<StandardInfoJoin>lambdaQuery()
|
|
|
- .eq(StandardInfoJoin::getStandardInfoLeftId, leftId));
|
|
|
+ //解析参数
|
|
|
+ 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);
|
|
|
}
|
|
|
- //新增
|
|
|
- return standardInfoJoinService.saveBatch(saveData);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- throw new ServiceException("条件设置失败");
|
|
|
+ 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);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -210,7 +226,7 @@ public class UStandardInfoServiceImpl extends ServiceImpl<StandardInfoMapper, St
|
|
|
standardInfoPrivateJoinService.remove(Wrappers.<StandardInfoPrivateJoin>lambdaQuery()
|
|
|
.eq(StandardInfoPrivateJoin::getStandardInfoId, leftId));
|
|
|
}
|
|
|
- return standardInfoPrivateJoinService.saveBatch(saveData);
|
|
|
+ return standardInfoPrivateJoinService.saveOrUpdateBatch(saveData);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
throw new ServiceException("元素关联失败");
|
|
|
@@ -279,6 +295,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);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|