|
@@ -5,16 +5,12 @@ import cn.cslg.pas.common.model.vo.PathStructureNameVO;
|
|
|
import cn.cslg.pas.common.model.vo.StructurePictureVO;
|
|
|
import cn.cslg.pas.common.model.vo.StructureVO;
|
|
|
import cn.cslg.pas.common.utils.FileUtils;
|
|
|
-import cn.cslg.pas.domain.Project;
|
|
|
import cn.cslg.pas.domain.Structure;
|
|
|
import cn.cslg.pas.domain.asso.AssoStructurePicture;
|
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
|
import cn.cslg.pas.mapper.AssoStructurePictureMapper;
|
|
|
-import cn.cslg.pas.mapper.ProjectMapper;
|
|
|
import cn.cslg.pas.mapper.StructureMapper;
|
|
|
import cn.cslg.pas.service.IStructureService;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -22,9 +18,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 架构的Service层接口实现类
|
|
@@ -35,7 +29,7 @@ import java.util.stream.Collectors;
|
|
|
@RequiredArgsConstructor
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
-public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure> implements IStructureService {
|
|
|
+public class StructureServiceImpl implements IStructureService {
|
|
|
private final StructureMapper structureMapper;
|
|
|
private final AssoStructurePictureMapper assoStructurePictureMapper;
|
|
|
private final FileUtils fileUtils;
|
|
@@ -259,32 +253,13 @@ public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure
|
|
|
@Override
|
|
|
public StructureVO query(StructureQueryPageDTO structureQueryPageDTO) {
|
|
|
log.info("开始处理【查询架构树】的业务,参数为:{}", structureQueryPageDTO);
|
|
|
- StructureVO structureVO = new StructureVO();
|
|
|
- //从DTO中取出产品id、架构id
|
|
|
- Integer productId = structureQueryPageDTO.getProductId();
|
|
|
|
|
|
+ //从DTO中取出产品id、架构id、架构名称
|
|
|
+ Integer productId = structureQueryPageDTO.getProductId();
|
|
|
Integer structureId = structureQueryPageDTO.getStructureId();
|
|
|
- LambdaQueryWrapper<Structure> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.like(Structure::getStructureName, structureQueryPageDTO.getStructureName());
|
|
|
- List<Structure> structures = this.list(wrapper);
|
|
|
- List<Integer> ids = structures.stream().map(Structure::getId).collect(Collectors.toList());
|
|
|
- List<String> paths = structures.stream().map(Structure::getPath).collect(Collectors.toList());
|
|
|
- paths.forEach(
|
|
|
- item -> {
|
|
|
- String[] pathStrs = item.split(",");
|
|
|
- List<String> pathStr = new ArrayList<>(Arrays.asList(pathStrs));
|
|
|
- pathStr.forEach(
|
|
|
- tem -> {
|
|
|
- Integer paId = Integer.parseInt(tem);
|
|
|
- if (!ids.contains(paId)) {
|
|
|
- ids.add(paId);
|
|
|
- }
|
|
|
- }
|
|
|
- );
|
|
|
- }
|
|
|
- );
|
|
|
|
|
|
- diGui(structureVO, structureId, productId, ids);
|
|
|
+ StructureVO structureVO = new StructureVO();
|
|
|
+ diGui(structureVO, structureId, productId);
|
|
|
return structureVO;
|
|
|
}
|
|
|
|
|
@@ -294,9 +269,15 @@ public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure
|
|
|
* @return 返回查询到的数据
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<PathStructureNameVO> queryPathStructureName() {
|
|
|
+ public List<PathStructureNameVO> queryPathStructureName(Integer productId) {
|
|
|
log.info("开始处理【查询所有架构路径和路径架构名称】的业务");
|
|
|
|
|
|
+ List<StructureVO> structures = structureMapper.selectAllByProductId(productId);
|
|
|
+ for (StructureVO structure : structures) {
|
|
|
+ Integer structureId = structure.getId();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
return null;
|
|
|
}
|
|
@@ -304,41 +285,70 @@ public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure
|
|
|
/**
|
|
|
* 删除架构
|
|
|
*
|
|
|
- * @param structureId 架构id
|
|
|
+ * @param id 架构id
|
|
|
*/
|
|
|
@Override
|
|
|
- public void delete(Integer structureId) {
|
|
|
- log.info("开始处理【删除架构】的业务,参数为:{}", structureId);
|
|
|
+ public void delete(Integer id) {
|
|
|
+ log.info("开始处理【删除架构】的业务,参数为:{}", id);
|
|
|
|
|
|
//检查尝试删除的数据是否存在
|
|
|
- Structure queryResult = structureMapper.getStandardById(structureId);
|
|
|
+ Structure queryResult = structureMapper.getStandardById(id);
|
|
|
if (queryResult == null) {
|
|
|
String message = "删除架构失败,尝试访问的数据已不存在";
|
|
|
log.info("{}", message);
|
|
|
throw new XiaoShiException(message);
|
|
|
}
|
|
|
|
|
|
- //架构和专利关联表删除数据
|
|
|
+ //根据架构id查询其所有子级架构
|
|
|
ArrayList<Integer> structureIds = new ArrayList<>();
|
|
|
- structureIds.add(structureId);
|
|
|
- int rows = assoStructurePictureMapper.deleteByIds(structureIds);
|
|
|
+ structureIds.add(id);
|
|
|
+ String path = queryResult.getPath();
|
|
|
+ log.info("根据架构id查询其所有子级架构");
|
|
|
+ List<StructureVO> structures = structureMapper.selectByFindInSetPath(path);
|
|
|
+ for (StructureVO structure : structures) {
|
|
|
+ Integer childStructureId = structure.getId();
|
|
|
+ structureIds.add(childStructureId);
|
|
|
+ }
|
|
|
+
|
|
|
+ //架构和专利关联表删除数据
|
|
|
+ log.info("架构和专利关联表删除数据");
|
|
|
+ assoStructurePictureMapper.deleteByIds(structureIds);
|
|
|
+// if (rows != structureIds.size()) {
|
|
|
+// String message = "删除架构失败,架构和专利关联表删除数据失败,服务器忙请稍后再次尝试";
|
|
|
+// log.info("{}", message);
|
|
|
+// throw new XiaoShiException(message);
|
|
|
+// }
|
|
|
+
|
|
|
+ //架构和图片关联表删除数据
|
|
|
+ log.info("架构和图片关联表删除数据");
|
|
|
+ assoStructurePictureMapper.deleteByStructureIds(structureIds);
|
|
|
+// if (rows != structureIds.size()) {
|
|
|
+// String message = "删除架构失败,架构和图片关联表删除数据失败,服务器忙请稍后再次尝试";
|
|
|
+// log.info("{}", message);
|
|
|
+// throw new XiaoShiException(message);
|
|
|
+// }
|
|
|
+
|
|
|
+ //架构表删除数据
|
|
|
+ log.info("架构表删除数据");
|
|
|
+ int rows = structureMapper.deleteByIds(structureIds);
|
|
|
if (rows != structureIds.size()) {
|
|
|
- String message = "删除架构失败,服务器忙请稍后再次尝试";
|
|
|
+ String message = "删除架构失败,架构表删除数据失败,服务器忙请稍后再次尝试";
|
|
|
log.info("{}", message);
|
|
|
throw new XiaoShiException(message);
|
|
|
}
|
|
|
|
|
|
+ log.info("删除架构完成");
|
|
|
|
|
|
}
|
|
|
|
|
|
//递归组装架构树集合
|
|
|
- private void diGui(StructureVO structureVO, Integer structureId, Integer productId, List<Integer> ids) {
|
|
|
- List<StructureVO> structureVOs = structureMapper.selectByParentIdAndProductId(structureId, productId, ids);
|
|
|
+ private void diGui(StructureVO structureVO, Integer structureId, Integer productId) {
|
|
|
+ List<StructureVO> structureVOs = structureMapper.selectByParentIdAndProductId(structureId, productId);
|
|
|
if (structureVOs != null) {
|
|
|
structureVO.setChildren(structureVOs);
|
|
|
for (StructureVO n : structureVOs) {
|
|
|
structureId = n.getId();
|
|
|
- diGui(n, structureId, productId, ids);
|
|
|
+ diGui(n, structureId, productId);
|
|
|
}
|
|
|
}
|
|
|
}
|