|
@@ -67,7 +67,6 @@ import java.util.stream.Collectors;
|
|
|
@RequiredArgsConstructor
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
-
|
|
|
public class PatentStarApiService {
|
|
|
@Autowired
|
|
|
private RetrieveRecordService retrieveRecordService;
|
|
@@ -114,8 +113,7 @@ public class PatentStarApiService {
|
|
|
|
|
|
Map<String, Object> map = this.patentStarSearchApi(patentStarListDTO);
|
|
|
if (map == null) {
|
|
|
- ThrowException.throwXiaoShiException("检索失败,请检查检索式");
|
|
|
-// throw new XiaoShiException("检索失败,请检查检索式");
|
|
|
+ throw new XiaoShiException("检索失败,请检查检索式");
|
|
|
}
|
|
|
|
|
|
//记录检索历史
|
|
@@ -150,111 +148,12 @@ public class PatentStarApiService {
|
|
|
return records;
|
|
|
}
|
|
|
|
|
|
- private List<PatentColumnDTO> loadPatentList(List<PatentColumnDTO> columnDTOS, List<String> list, String dbType) {
|
|
|
- if (CollectionUtils.isEmpty(list) || CollectionUtils.isEmpty(columnDTOS)) {
|
|
|
- // 如果任一列表为空,直接返回原始columnDTOS或根据list生成新的DTO列表
|
|
|
- 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) {
|
|
|
- return dto.getAppNo().contains(number) || dto.getPublicNo().contains(number)
|
|
|
- || dto.getGrantNo().contains(number) || dto.getRowApplicationNo().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;
|
|
|
- }
|
|
|
-
|
|
|
- /*private List<PatentColumnDTO> loadPatentList(List<PatentColumnDTO> columnDTOS, List<String> list, String dbType) {
|
|
|
- List<String> noList = new ArrayList<>(list);
|
|
|
- if (CollectionUtils.isEmpty(list)) {
|
|
|
- return columnDTOS;
|
|
|
- }
|
|
|
- List<PatentColumnDTO> patentColumnDTOS = new ArrayList<>();
|
|
|
- if (CollectionUtils.isEmpty(columnDTOS)) {
|
|
|
- list.forEach(i -> {
|
|
|
- PatentColumnDTO columnDTO = new PatentColumnDTO();
|
|
|
- columnDTO.setPatentNo(i);
|
|
|
- columnDTO.setSearchNo(i);
|
|
|
- columnDTO.setIfSearch(false);
|
|
|
- patentColumnDTOS.add(columnDTO);
|
|
|
- });
|
|
|
- return patentColumnDTOS;
|
|
|
- }
|
|
|
- list.forEach(i -> {
|
|
|
- for (PatentColumnDTO columnDTO : columnDTOS) {
|
|
|
- if (dbType.equals("CN")) {
|
|
|
- String no = PatentNoUtil.formatApNo(i);
|
|
|
- if (columnDTO.getAppNo().contains(no) || columnDTO.getPublicNo().contains(no)
|
|
|
- || columnDTO.getGrantNo().contains(no) || columnDTO.getRowApplicationNo().contains(no)) {
|
|
|
- columnDTO.setSearchNo(i);
|
|
|
- patentColumnDTOS.add(columnDTO);
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (columnDTO.getAppNo().contains(i) || columnDTO.getPublicNo().contains(i)
|
|
|
- || columnDTO.getGrantNo().contains(i) || columnDTO.getRowApplicationNo().contains(i)) {
|
|
|
- columnDTO.setSearchNo(i);
|
|
|
- patentColumnDTOS.add(columnDTO);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- List<String> collect = patentColumnDTOS.stream().map(PatentColumnDTO::getSearchNo).collect(Collectors.toList());
|
|
|
- for (String key : collect) {
|
|
|
- noList.removeIf(j -> j.equals(key));
|
|
|
- }
|
|
|
- if (!CollectionUtils.isEmpty(noList)) {
|
|
|
- for (String s : noList) {
|
|
|
- PatentColumnDTO columnDTO = new PatentColumnDTO();
|
|
|
- columnDTO.setPatentNo(s);
|
|
|
- columnDTO.setSearchNo(s);
|
|
|
- columnDTO.setIfSearch(false);
|
|
|
- patentColumnDTOS.add(columnDTO);
|
|
|
- }
|
|
|
- }
|
|
|
- return patentColumnDTOS;
|
|
|
- }*/
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 格式化条件后并请求外部接口
|
|
|
+ * @param PatentStarListDTO
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
public Map<String, Object> patentStarSearchApi(PatentStarListDTO PatentStarListDTO) throws IOException {
|
|
|
try {
|
|
|
if (PatentStarListDTO.getFormed() == null || PatentStarListDTO.getFormed() == false) {
|
|
@@ -317,25 +216,66 @@ public class PatentStarApiService {
|
|
|
return reMap;
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- return null;
|
|
|
-// throw new XiaoShiException("外部接口检索超时");
|
|
|
+// e.printStackTrace();
|
|
|
+// return null;
|
|
|
+ throw new XiaoShiException("外部接口检索超时");
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- private String formatCondition(String[] valueStrs, Integer pageNum, Integer pageSize) {
|
|
|
- StringBuilder builder = new StringBuilder();
|
|
|
- builder.append("NO").append("=").append("(");
|
|
|
- for (int i = (pageNum - 1) * pageSize; i < (pageNum * pageSize); i++) {
|
|
|
- String valueStr = valueStrs[i];
|
|
|
- if (i != (pageNum * pageSize) - 1) {
|
|
|
- builder.append(valueStr).append(",");
|
|
|
- } else {
|
|
|
- builder.append(valueStr);
|
|
|
+ //封装patent column数据返回
|
|
|
+ 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 builder.append(")").toString();
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean containsNumber(PatentColumnDTO dto, String number) {
|
|
|
+ return dto.getAppNo().contains(number) || dto.getPublicNo().contains(number)
|
|
|
+ || dto.getGrantNo().contains(number) || dto.getRowApplicationNo().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 List<PatentStarListDTO> getSplitedConditions(PatentStarListDTO patentStarListDTO, int patentNum) throws IOException {
|