|
@@ -164,49 +164,61 @@ public class UStandardInfoServiceImpl extends ServiceImpl<StandardInfoMapper, St
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
- 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<>();
|
|
|
|
- //解析参数
|
|
|
|
- for (StandardInfoVO standardInfoJoin : standardInfoJoins) {
|
|
|
|
- StandardInfoJoinDTO standardInfoJoinDTO = new StandardInfoJoinDTO();
|
|
|
|
|
|
+ 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));
|
|
|
|
|
|
- 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);
|
|
|
|
|
|
+
|
|
|
|
+ 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);
|
|
}
|
|
}
|
|
- 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);
|
|
|
|
|
|
+ //封装参数
|
|
|
|
+ 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);
|
|
|
|
|
|
+ return standardInfoJoinService.saveOrUpdateBatch(saveData);
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|