|
@@ -11,12 +11,15 @@ 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.Project;
|
|
|
+import cn.cslg.pas.domain.asso.AssoProductPatent;
|
|
|
import cn.cslg.pas.domain.asso.AssoProductPicture;
|
|
|
+import cn.cslg.pas.domain.asso.AssoStructurePatent;
|
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
|
-import cn.cslg.pas.mapper.AssoProductPictureMapper;
|
|
|
-import cn.cslg.pas.mapper.ProductMapper;
|
|
|
import cn.cslg.pas.mapper.ProjectMapper;
|
|
|
+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.IProductService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
@@ -43,6 +46,9 @@ import java.util.List;
|
|
|
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {
|
|
|
private final ProductMapper productMapper;
|
|
|
private final AssoProductPictureMapper assoProductPictureMapper;
|
|
|
+ private final AssoProductPatentMapper assoProductPatentMapper;
|
|
|
+ private final AssoStructurePatentMapper assoStructurePatentMapper;
|
|
|
+ private final ProjectMapper projectMapper;
|
|
|
private final CacheUtils cacheUtils;
|
|
|
private final LoginUtils loginUtils;
|
|
|
private final FileUtils fileUtils;
|
|
@@ -92,7 +98,15 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
throw new XiaoShiException(message);
|
|
|
}
|
|
|
|
|
|
+ //数据入产品专利关联表(若有专利)
|
|
|
String patentNo = productAddNewDTO.getPatentNo();
|
|
|
+ if (patentNo != null) {
|
|
|
+ AssoProductPatent assoProductPatent = new AssoProductPatent()
|
|
|
+ .setPatentNo(patentNo)
|
|
|
+ .setProductId(product.getId());
|
|
|
+ log.info("数据入产品专利关联表");
|
|
|
+ assoProductPatentMapper.insert(assoProductPatent);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
//如果有图片,图片文件上传至服务器,后获取图片文件的名称、后缀名、url地址,赋值给产品类别图片关联表实体类
|
|
@@ -213,15 +227,18 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
for (ProductVO productVO : productVOs) {
|
|
|
List<ProductPatentVO> productPatents = productVO.getProductPatents();
|
|
|
List<StructurePatentVO> structurePatents = productVO.getStructurePatents();
|
|
|
- //ArrayList<String> patentNos = new ArrayList<>();
|
|
|
HashSet<String> patentNos = new HashSet<>();
|
|
|
for (ProductPatentVO productPatent : productPatents) {
|
|
|
String patentNo = productPatent.getPatentNo();
|
|
|
- patentNos.add(patentNo);
|
|
|
+ if (patentNo != null) {
|
|
|
+ patentNos.add(patentNo);
|
|
|
+ }
|
|
|
}
|
|
|
for (StructurePatentVO structurePatent : structurePatents) {
|
|
|
String patentNo = structurePatent.getPatentNo();
|
|
|
- patentNos.add(patentNo);
|
|
|
+ if (patentNo != null) {
|
|
|
+ patentNos.add(patentNo);
|
|
|
+ }
|
|
|
}
|
|
|
//相关专利数量赋值给patentNum
|
|
|
productVO.setPatentNum(patentNos.size());
|
|
@@ -241,10 +258,28 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
throw new XiaoShiException(message);
|
|
|
}
|
|
|
|
|
|
- //删除产品图片数据
|
|
|
+ //检查专题库表中是否有该产品数据,若有则不允许删除
|
|
|
+ count = projectMapper.countByProductId(id);
|
|
|
+ if (count > 0) {
|
|
|
+ String message = "删除产品失败,该产品已被专题库使用,请尝试先修改专题库";
|
|
|
+ log.info("{}", message);
|
|
|
+ throw new XiaoShiException(message);
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除产品架构专利号专题库关联表数据
|
|
|
+ log.info("产品架构专利号专题库关联表删除数据");
|
|
|
+ AssoStructurePatent assoStructurePatent = new AssoStructurePatent()
|
|
|
+ .setProductId(id);
|
|
|
+ assoStructurePatentMapper.delete(assoStructurePatent);
|
|
|
+
|
|
|
+ //删除产品图片关联表数据
|
|
|
log.info("产品图片关联表删除数据");
|
|
|
assoProductPictureMapper.deleteByProductId(id);
|
|
|
|
|
|
+ //删除产品专利关联表数据
|
|
|
+ log.info("产品专利关联表删除数据");
|
|
|
+ assoProductPatentMapper.deleteByProductId(id);
|
|
|
+
|
|
|
//删除产品数据
|
|
|
log.info("产品表删除数据");
|
|
|
int rows = productMapper.deleteById(id);
|