chendayu 2 anos atrás
pai
commit
2217aa354d

+ 1 - 2
PAS/src/main/java/cn/cslg/pas/controller/ProjectController.java

@@ -36,8 +36,7 @@ import java.util.List;
 @RestController
 @RequestMapping(Constants.API_VERSION_V2 + "/project")
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
-public class
-ProjectController {
+public class ProjectController {
     private final ProjectService projectService;
     private final ProjectPatentLinkService projectPatentLinkService;
 

+ 24 - 2
PAS/src/main/java/cn/cslg/pas/service/impl/ProductServiceImpl.java

@@ -8,6 +8,8 @@ import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.FileUtils;
 import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
 import cn.cslg.pas.domain.Product;
+import cn.cslg.pas.domain.ProductMarketData;
+import cn.cslg.pas.domain.Structure;
 import cn.cslg.pas.domain.asso.AssoProductPatent;
 import cn.cslg.pas.domain.asso.AssoProductPicture;
 import cn.cslg.pas.domain.asso.AssoStructurePatent;
@@ -17,7 +19,10 @@ import cn.cslg.pas.mapper.asso.AssoProductPictureMapper;
 import cn.cslg.pas.mapper.ProductMapper;
 import cn.cslg.pas.mapper.asso.AssoProductPatentMapper;
 import cn.cslg.pas.mapper.asso.AssoStructurePatentMapper;
+import cn.cslg.pas.service.IProductMarketDataService;
 import cn.cslg.pas.service.IProductService;
+import cn.cslg.pas.service.IStructureService;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -48,6 +53,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
     private final AssoProductPatentMapper assoProductPatentMapper;
     private final AssoStructurePatentMapper assoStructurePatentMapper;
     private final ProjectMapper projectMapper;
+    private final IStructureService structureService;
+    private final IProductMarketDataService productMarketDataService;
     private final CacheUtils cacheUtils;
     private final LoginUtils loginUtils;
     private final FileUtils fileUtils;
@@ -279,6 +286,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
         }
 
         //检查专题库表中是否有该产品数据,若有则不允许删除
+        log.info("检查专题库表中是否有该产品数据,若有则不允许删除");
         count = projectMapper.countByProductId(id);
         if (count > 0) {
             String message = "删除产品失败,该产品已被专题库使用,请尝试先修改专题库";
@@ -286,8 +294,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
             throw new XiaoShiException(message);
         }
 
-        //删除产品架构专利专题库关联表数据
-        log.info("产品架构专利专题库关联表删除数据");
+        //删除产品架构专利专题库关联表数据
+        log.info("产品架构专利专题库关联表删除数据");
         AssoStructurePatent assoStructurePatent = new AssoStructurePatent()
                 .setProductId(id);
         assoStructurePatentMapper.delete(assoStructurePatent);
@@ -300,6 +308,20 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
         log.info("产品专利关联表删除数据");
         assoProductPatentMapper.deleteByProductId(id);
 
+        //删除产品的所有架构的架构关联表数据和架构表数据
+
+
+        LambdaQueryWrapper<Structure> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(Structure::getProductId, id);
+        log.info("产品的架构表删除数据");
+        structureService.remove(wrapper);
+
+        //删除产品营销数据
+        LambdaQueryWrapper<ProductMarketData> wrapper2 = new LambdaQueryWrapper<>();
+        wrapper2.eq(ProductMarketData::getProductId, id);
+        log.info("产品的营销数据表删除数据");
+        productMarketDataService.remove(wrapper2);
+
         //删除产品数据
         log.info("产品表删除数据");
         int rows = productMapper.deleteById(id);

+ 22 - 6
PAS/src/main/java/cn/cslg/pas/service/impl/StructureServiceImpl.java

@@ -8,6 +8,8 @@ import cn.cslg.pas.common.model.vo.StructureVO;
 import cn.cslg.pas.common.utils.CacheUtils;
 import cn.cslg.pas.common.utils.FileUtils;
 import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
+import cn.cslg.pas.common.utils.ThrowException;
+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;
@@ -15,6 +17,7 @@ import cn.cslg.pas.mapper.asso.AssoStructurePatentMapper;
 import cn.cslg.pas.mapper.asso.AssoStructurePictureMapper;
 import cn.cslg.pas.mapper.StructureMapper;
 import cn.cslg.pas.service.IStructureService;
+import cn.cslg.pas.service.ProjectService;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
@@ -42,6 +45,7 @@ public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure
     private final StructureMapper structureMapper;
     private final AssoStructurePictureMapper assoStructurePictureMapper;
     private final AssoStructurePatentMapper assoStructurePatentMapper;
+    private final ProjectService projectService;
     private final CacheUtils cacheUtils;
     private final LoginUtils loginUtils;
     private final FileUtils fileUtils;
@@ -387,15 +391,27 @@ public class StructureServiceImpl extends ServiceImpl<StructureMapper, Structure
             structureIds.add(structureId);
         }
 
-        //检查产品架构专利号专题库表是否有该架构和其所有子级架构数据,若有则不允许删除
-        log.info("检查产品架构专利号专题库表是否有该架构和其所有子级架构数据,若有则不允许删除");
-        int count = assoStructurePatentMapper.countByStructureIds(structureIds);
+        //检查专题库表中是否有该架构数据,若有则不允许删除
+        LambdaQueryWrapper<Project> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(Project::getStructureId, structureIds);
+        long count = projectService.count(wrapper);
         if (count > 0) {
-            String message = "删除架构失败,该架构或其子级架构正在被专题库标引使用,请尝试先删除其关联数据";
-            log.info("{}", message);
-            throw new XiaoShiException(message);
+            ThrowException.throwXiaoShiException("删除架构失败,该架构或其子级架构正在被专题库使用,请尝试先删除其他关联数据");
         }
 
+        //架构专利产品专题库标引表删除数据
+        log.info("架构专利产品专题库标引表删除数据");
+        assoStructurePatentMapper.deleteByStructureIds(structureIds);
+
+        //检查产品架构专利号专题库表是否有该架构和其所有子级架构数据,若有则不允许删除
+//        log.info("检查产品架构专利号专题库表是否有该架构和其所有子级架构数据,若有则不允许删除");
+//        int count = assoStructurePatentMapper.countByStructureIds(structureIds);
+//        if (count > 0) {
+//            String message = "删除架构失败,该架构或其子级架构正在被专题库标引使用,请尝试先删除其关联数据";
+//            log.info("{}", message);
+//            throw new XiaoShiException(message);
+//        }
+
         //架构和专利关联表删除数据
         //log.info("架构和专利关联表删除数据");
         //assoStructurePatentMapper.deleteByStructureIds(structureIds);