|
@@ -10,6 +10,7 @@ import cn.cslg.pas.common.model.cronModel.Records;
|
|
|
import cn.cslg.pas.common.model.importTaskModel.PatentApplicant;
|
|
|
import cn.cslg.pas.common.utils.*;
|
|
|
import cn.cslg.pas.common.vo.ContentVO;
|
|
|
+import cn.cslg.pas.common.vo.NoCacheVO;
|
|
|
import cn.cslg.pas.common.vo.QueryExternalFamilyVO;
|
|
|
import cn.cslg.pas.common.vo.StarPatentVO;
|
|
|
import cn.cslg.pas.common.vo.business.PatentNoVO;
|
|
@@ -84,9 +85,30 @@ public class PatentStarApiService {
|
|
|
private WebVOTransformService webVOTransformService;
|
|
|
@Autowired
|
|
|
private AssoRetrieveRecordProjectService assoRetrieveRecordProjectService;
|
|
|
+ @Autowired
|
|
|
+ private NOSCacheService cacheService;
|
|
|
|
|
|
public Records patentStarSearchLocal(PatentStarListDTO patentStarListDTO) throws IOException {
|
|
|
RetrieveRecord retrieveRecord = retrieveRecordService.setRetrieveRecord(patentStarListDTO);
|
|
|
+ String redisKey = patentStarListDTO.getRedisKey();
|
|
|
+ List<String> nos = new ArrayList<>();
|
|
|
+ Long total = 0L;
|
|
|
+ if (StringUtils.isNotEmpty(patentStarListDTO.getNumberQuery())) {
|
|
|
+ NoCacheVO cacheVO = cacheService.savaByList(patentStarListDTO);
|
|
|
+ retrieveRecord.setConditions(patentStarListDTO.getNumberQuery());
|
|
|
+ retrieveRecord.setSearchType(1);
|
|
|
+ redisKey = cacheVO.getKey();
|
|
|
+ total = cacheVO.getTotal();
|
|
|
+ nos.addAll(cacheVO.getList());
|
|
|
+ }
|
|
|
+ if (Boolean.TRUE.equals(StringUtils.isEmpty(patentStarListDTO.getNumberQuery())) && StringUtils.isNotEmpty(redisKey)) {
|
|
|
+ NoCacheVO cacheVO = cacheService.getByList(patentStarListDTO);
|
|
|
+ retrieveRecord.setConditions(patentStarListDTO.getNumberQuery());
|
|
|
+ retrieveRecord.setSearchType(1);
|
|
|
+ nos.addAll(cacheVO.getList());
|
|
|
+ total = cacheVO.getTotal();
|
|
|
+ redisKey = cacheVO.getKey();
|
|
|
+ }
|
|
|
long start = System.currentTimeMillis();
|
|
|
Map<String, Object> map = this.patentStarSearchApi(patentStarListDTO);
|
|
|
long end = System.currentTimeMillis();
|
|
@@ -113,12 +135,26 @@ public class PatentStarApiService {
|
|
|
records.setRetrieveRecordId(retrieveRecord.getId());
|
|
|
records.setCurrent(Long.parseLong(map.get("current").toString()));
|
|
|
records.setSize(Long.parseLong(map.get("size").toString()));
|
|
|
- records.setData(this.loadPatent(starPatentVOS, patentStarListDTO.getDBType()));
|
|
|
- records.setTotal(Long.parseLong(map.get("total").toString()));
|
|
|
+// records.setData(this.loadPatent(starPatentVOS, patentStarListDTO.getDBType()));
|
|
|
+// records.setTotal(Long.parseLong(map.get("total").toString()));
|
|
|
+ List<PatentColumnDTO> columnDTOS = this.loadPatent(starPatentVOS, patentStarListDTO.getDBType());
|
|
|
+ records.setData(this.loadPatentList(columnDTOS, nos, patentStarListDTO.getDBType()));
|
|
|
+ if (total != 0) {
|
|
|
+ records.setTotal(total);
|
|
|
+ } else {
|
|
|
+ records.setTotal(Long.parseLong(map.get("total").toString()));
|
|
|
+ }
|
|
|
+ records.setRedisKey(redisKey);
|
|
|
return records;
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 格式化条件后并请求外部接口
|
|
|
+ * @param PatentStarListDTO
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
public Map<String, Object> patentStarSearchApi(PatentStarListDTO PatentStarListDTO) throws IOException {
|
|
|
try {
|
|
|
if (PatentStarListDTO.getFormed() == null || PatentStarListDTO.getFormed() == false) {
|
|
@@ -197,6 +233,60 @@ public class PatentStarApiService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ private List<PatentColumnDTO> loadPatentList(List<PatentColumnDTO> columnDTOS, List<String> list, String dbType) {
|
|
|
+ if (CollectionUtils.isEmpty(list) || CollectionUtils.isEmpty(columnDTOS)) {
|
|
|
+ return list.isEmpty() ? columnDTOS : createNewDTOs(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<PatentColumnDTO> result = new ArrayList<>(columnDTOS.size());
|
|
|
+ Set<String> searchedNumbers = new HashSet<>(); // 用于跟踪已搜索的专利号
|
|
|
+ for (String patentNo : list) {
|
|
|
+ boolean found = false;
|
|
|
+ String formattedNo = dbType.equals("CN") ? PatentNoUtil.formatApNo(patentNo) : patentNo;
|
|
|
+ for (PatentColumnDTO columnDTO : columnDTOS) {
|
|
|
+ if (containsNumber(columnDTO, formattedNo)) {
|
|
|
+ PatentColumnDTO dto = new PatentColumnDTO();
|
|
|
+ BeanUtils.copyProperties(columnDTO,dto);
|
|
|
+ dto.setSearchNo(patentNo);
|
|
|
+ result.add(dto);
|
|
|
+ searchedNumbers.add(patentNo); // 标记为已搜索
|
|
|
+ found = true;
|
|
|
+ break; // 找到匹配项后跳出内层循环
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!found) {
|
|
|
+ // 如果没有在columnDTOS中找到匹配项,则创建一个新的DTO
|
|
|
+ PatentColumnDTO newDTO = new PatentColumnDTO();
|
|
|
+ newDTO.setPatentNo(patentNo);
|
|
|
+ newDTO.setSearchNo(patentNo);
|
|
|
+ newDTO.setIfSearch(false);
|
|
|
+ result.add(newDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean containsNumber(PatentColumnDTO dto, String number) {
|
|
|
+ String appNo = StringUtils.isNotEmpty(dto.getAppNo()) ? dto.getAppNo() : "";
|
|
|
+ String publicNo = StringUtils.isNotEmpty(dto.getPublicNo()) ? dto.getPublicNo() : "";
|
|
|
+ String grantNo = StringUtils.isNotEmpty(dto.getGrantNo()) ? dto.getGrantNo() : "";
|
|
|
+ String rowAppNo = StringUtils.isNotEmpty(dto.getRowApplicationNo()) ? dto.getRowApplicationNo() : "";
|
|
|
+ return appNo.contains(number) || publicNo.contains(number)
|
|
|
+ || grantNo.contains(number) || rowAppNo.contains(number);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<PatentColumnDTO> createNewDTOs(List<String> list) {
|
|
|
+ List<PatentColumnDTO> newDTOs = new ArrayList<>();
|
|
|
+ for (String s : list) {
|
|
|
+ PatentColumnDTO dto = new PatentColumnDTO();
|
|
|
+ dto.setPatentNo(s);
|
|
|
+ dto.setSearchNo(s);
|
|
|
+ dto.setIfSearch(false);
|
|
|
+ newDTOs.add(dto);
|
|
|
+ }
|
|
|
+ return newDTOs;
|
|
|
+ }
|
|
|
+
|
|
|
public String getFormatCondition(String condition) {
|
|
|
String s = condition.substring(condition.indexOf("=") + 1);
|
|
|
String s1 = s.replaceAll("[()]", "");
|