|
@@ -1,18 +1,22 @@
|
|
|
package cn.cslg.pas.service.impl;
|
|
|
|
|
|
+import cn.cslg.pas.common.model.dto.AssoStructurePatentAddNewBatchDTO;
|
|
|
import cn.cslg.pas.common.model.dto.AssoStructurePatentQueryDTO;
|
|
|
import cn.cslg.pas.common.model.dto.AssoStructurePatentUpdateDTO;
|
|
|
+import cn.cslg.pas.common.model.dto.StructureAndProductIds;
|
|
|
import cn.cslg.pas.common.model.vo.AssoStructurePatentVO;
|
|
|
import cn.cslg.pas.domain.asso.AssoStructurePatent;
|
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
|
import cn.cslg.pas.mapper.asso.AssoStructurePatentMapper;
|
|
|
import cn.cslg.pas.service.IStructurePatentService;
|
|
|
+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;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -65,6 +69,57 @@ public class StructurePatentServiceImpl extends ServiceImpl<AssoStructurePatentM
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 批量新增标引
|
|
|
+ *
|
|
|
+ * @param assoStructurePatentAddNewBatchDTO 专题库批量新增标引(一个专题库给多个专利选择同样的多个产品架构)的DTO类
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void addNewBatch(AssoStructurePatentAddNewBatchDTO assoStructurePatentAddNewBatchDTO) {
|
|
|
+ log.info("开始处理【批量新增标引】的业务,参数为:{}", assoStructurePatentAddNewBatchDTO);
|
|
|
+
|
|
|
+ //专题库id
|
|
|
+ Integer projectId = assoStructurePatentAddNewBatchDTO.getProjectId();
|
|
|
+ //多件专利
|
|
|
+ List<String> patentNos = assoStructurePatentAddNewBatchDTO.getPatentNos();
|
|
|
+ //多件专利共用的架构id和架构所属产品id
|
|
|
+ List<StructureAndProductIds> structureAndProductIds = assoStructurePatentAddNewBatchDTO.getStructureAndProductIds();
|
|
|
+
|
|
|
+ //DTO赋值给实体类
|
|
|
+ ArrayList<AssoStructurePatent> assoStructurePatents = new ArrayList<>();
|
|
|
+ for (String patentNo : patentNos) {
|
|
|
+ for (StructureAndProductIds structureAndProductId : structureAndProductIds) {
|
|
|
+ AssoStructurePatent assoStructurePatent = new AssoStructurePatent()
|
|
|
+ .setProjectId(projectId)
|
|
|
+ .setPatentNo(patentNo)
|
|
|
+ .setStructureId(structureAndProductId.getStructureId())
|
|
|
+ .setProductId(structureAndProductId.getProductId());
|
|
|
+ assoStructurePatents.add(assoStructurePatent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据专题库id从库中查询数据
|
|
|
+ LambdaQueryWrapper<AssoStructurePatent> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(AssoStructurePatent::getProjectId, projectId);
|
|
|
+ List<AssoStructurePatent> assoStructurePatents2 = this.list(wrapper);
|
|
|
+ if (assoStructurePatents2 != null && assoStructurePatents2.size() > 0) {
|
|
|
+ //遍历查询出来的所有数据,将id改为Null
|
|
|
+ for (AssoStructurePatent assoStructurePatent2 : assoStructurePatents2) {
|
|
|
+ assoStructurePatent2.setId(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //集合去重,去重后留下来的数据即为新增的标引就可以直接入库了
|
|
|
+ boolean flag = assoStructurePatents.removeAll(assoStructurePatents2);
|
|
|
+ //若有新增的标引则入库
|
|
|
+ if (flag) {
|
|
|
+ //数据批量插入架构和专利关联表
|
|
|
+ log.info("数据批量插入架构和专利关联表");
|
|
|
+ this.saveBatch(assoStructurePatents);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 查询标引
|
|
|
*
|
|
|
* @param assoStructurePatentQueryDTO 专题库产品架构专利号标引的查询DTO类
|