瀏覽代碼

2023/6/20 专利之星接口导入

lwhhszx 2 年之前
父節點
當前提交
5ac8cbc2a6

+ 75 - 75
PAS/src/main/java/cn/cslg/pas/common/core/CreateTaskThread.java

@@ -31,81 +31,81 @@ public class CreateTaskThread implements InitializingBean {
 
     @Override
     public void afterPropertiesSet() throws Exception {
-        //初始化任务队列
-        //查找任务状态为0(队列中)和1(进行中)的任务
-        List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().in(Task::getStatus, new ArrayList<>(Arrays.asList(0, 1))));
-        if (tasks.size() > 0) {
-            //过滤出任务ids
-            List<Integer> taskIds = tasks.stream().map(Task::getId).collect(Collectors.toList());
-            //过滤出进行中的任务的id
-            List<Task> doingTasks = tasks.stream().filter(item -> item.getStatus() == 1).collect(Collectors.toList());
-            List<Integer> doingTaskIds = doingTasks.stream().map(Task::getId).collect(Collectors.toList());
-            if (doingTaskIds.size() > 0) {
-                //先将进行中的任务(项目重启后进行中的任务仅会有1个)的id先存入任务队列,再将其余存入
-                pantentQueueService.queueAddTask(Arrays.asList(doingTaskIds.get(0)));
-                taskIds.removeAll(doingTaskIds);
-            }
-            pantentQueueService.queueAddTask(taskIds);
-        }
-
-        //生产者线程
-        Thread threadProducer = new Thread(pantentQueueService::addPatnetToQueue);
-        threadProducer.start();
-
-
-        //消费者1线程(摘要附图)
-        Thread threadConsumer1 = new Thread(() -> {
-            try {
-                pantentQueueService.pushPatentImageToDB();
-            } catch (InterruptedException | IOException e) {
-                e.printStackTrace();
-            }
-        });
-        threadConsumer1.start();
-
-
-        //消费者2线程(著录项目)
-        Thread threadConsumer2 = new Thread(() -> {
-            try {
-                pantentQueueService.pushPatentZhuLuToDB();
-            } catch (InterruptedException | IOException e) {
-                e.printStackTrace();
-            }
-        });
-        threadConsumer2.start();
-
-
-        //消费者3线程(权利要求)
-        Thread threadConsumer3 = new Thread(() -> {
-            try {
-                pantentQueueService.pushPatentRightToDB();
-            } catch (InterruptedException | IOException e) {
-                e.printStackTrace();
-            }
-        });
-        threadConsumer3.start();
-
-
-        //消费者4线程(说明书文本消费者)
-        Thread threadConsumer4 = new Thread(() -> {
-            try {
-                pantentQueueService.pushPatentInstructionTextToDB();
-            } catch (InterruptedException | IOException e) {
-                e.printStackTrace();
-            }
-        });
-        threadConsumer4.start();
-
-
-        //消费者5线程(与专利关联数据消费者)
-        Thread threadConsumer5 = new Thread(() -> {
-            try {
-                pantentQueueService.pushPatentAssoToDB();
-            } catch (InterruptedException | IOException e) {
-                e.printStackTrace();
-            }
-        });
-        threadConsumer5.start();
+//        //初始化任务队列
+//        //查找任务状态为0(队列中)和1(进行中)的任务
+//        List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().in(Task::getStatus, new ArrayList<>(Arrays.asList(0, 1))));
+//        if (tasks.size() > 0) {
+//            //过滤出任务ids
+//            List<Integer> taskIds = tasks.stream().map(Task::getId).collect(Collectors.toList());
+//            //过滤出进行中的任务的id
+//            List<Task> doingTasks = tasks.stream().filter(item -> item.getStatus() == 1).collect(Collectors.toList());
+//            List<Integer> doingTaskIds = doingTasks.stream().map(Task::getId).collect(Collectors.toList());
+//            if (doingTaskIds.size() > 0) {
+//                //先将进行中的任务(项目重启后进行中的任务仅会有1个)的id先存入任务队列,再将其余存入
+//                pantentQueueService.queueAddTask(Arrays.asList(doingTaskIds.get(0)));
+//                taskIds.removeAll(doingTaskIds);
+//            }
+//            pantentQueueService.queueAddTask(taskIds);
+//        }
+//
+//        //生产者线程
+//        Thread threadProducer = new Thread(pantentQueueService::addPatnetToQueue);
+//        threadProducer.start();
+//
+//
+//        //消费者1线程(摘要附图)
+//        Thread threadConsumer1 = new Thread(() -> {
+//            try {
+//                pantentQueueService.pushPatentImageToDB();
+//            } catch (InterruptedException | IOException e) {
+//                e.printStackTrace();
+//            }
+//        });
+//        threadConsumer1.start();
+//
+//
+//        //消费者2线程(著录项目)
+//        Thread threadConsumer2 = new Thread(() -> {
+//            try {
+//                pantentQueueService.pushPatentZhuLuToDB();
+//            } catch (InterruptedException | IOException e) {
+//                e.printStackTrace();
+//            }
+//        });
+//        threadConsumer2.start();
+//
+//
+//        //消费者3线程(权利要求)
+//        Thread threadConsumer3 = new Thread(() -> {
+//            try {
+//                pantentQueueService.pushPatentRightToDB();
+//            } catch (InterruptedException | IOException e) {
+//                e.printStackTrace();
+//            }
+//        });
+//        threadConsumer3.start();
+//
+//
+//        //消费者4线程(说明书文本消费者)
+//        Thread threadConsumer4 = new Thread(() -> {
+//            try {
+//                pantentQueueService.pushPatentInstructionTextToDB();
+//            } catch (InterruptedException | IOException e) {
+//                e.printStackTrace();
+//            }
+//        });
+//        threadConsumer4.start();
+//
+//
+//        //消费者5线程(与专利关联数据消费者)
+//        Thread threadConsumer5 = new Thread(() -> {
+//            try {
+//                pantentQueueService.pushPatentAssoToDB();
+//            } catch (InterruptedException | IOException e) {
+//                e.printStackTrace();
+//            }
+//        });
+//        threadConsumer5.start();
 
     }
 

+ 0 - 4
PAS/src/main/java/cn/cslg/pas/controller/ProjectController.java

@@ -48,14 +48,12 @@ public class ProjectController {
         return Response.success(projectService.getPageList(params));
     }
 
-
     @GetMapping("getProjectById")
     @Operation(summary = "根据Id获得专题库")
     public String getProject(Integer id) throws IOException {
         return Response.success(projectService.getProjectByIds(Arrays.asList(id)));
     }
 
-
     @checkAuth(FunId = "/workspace/project/add")
     @PostMapping("add")
     @Operation(summary = "新增专题库")
@@ -69,7 +67,6 @@ public class ProjectController {
         return Response.success(projectId);
     }
 
-
     @Permission(roles = {2})
     @checkAuth(FunId = "/workspace/project/modify")
     @PostMapping("edit")
@@ -83,7 +80,6 @@ public class ProjectController {
         return Response.success();
     }
 
-
     @Permission(roles = {2})
     @PostMapping("delete")
     @checkAuth(FunId = "/workspace/project/delete")

+ 1 - 1
PAS/src/main/java/cn/cslg/pas/controller/outApi/PatentStarController.java

@@ -25,7 +25,7 @@ public class PatentStarController {
     @PostMapping("/select")
     @Operation(summary = "检索接口")
     public String getAreaList(@RequestBody PatentStarListDto patentStarListDto) throws IOException {
-        return patentStarApiService.patentStarSearchApi(patentStarListDto);
+        return Response.success(patentStarApiService.patentStarSearchApi(patentStarListDto)) ;
     }
     @GetMapping("/getCnBib")
     @Operation(summary = "获得中国专利著录")

+ 7 - 0
PAS/src/main/java/cn/cslg/pas/service/PatentRightService.java

@@ -438,6 +438,12 @@ public class PatentRightService extends ServiceImpl<PatentRightMapper, PatentRig
             List<PatentRight> patentRights = PatentRightUtils.formatPatentRight(params);
 
             if (patentRights.size() > 0) {
+                PatentRight patentRight = new PatentRight()
+                        .setPatentId(params.getPatentId())
+                        .setType(1)
+                        .setContent(params.getContent())
+                        .setSort(0)
+                        .setParentSort("-1");
                 //TODO 先根据专利id查询库中原权要,与当前权要比对,若不同则更新,若相同则不更新
 
                 //删除库表中原有该权要
@@ -453,6 +459,7 @@ public class PatentRightService extends ServiceImpl<PatentRightMapper, PatentRig
     }
 
 
+
 }
 
 

+ 65 - 7
PAS/src/main/java/cn/cslg/pas/service/outApi/PatentStarApiService.java

@@ -24,9 +24,10 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.io.IOException;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * 调用外部接口的Service类 PCS:权限系统
@@ -46,7 +47,51 @@ public class PatentStarApiService {
     @Value("${PASUrl}")
     private String PASUrl;
 
-    public String patentStarSearchApi(PatentStarListDto patentStarListDto) throws IOException {
+    public static String formatQuery(String query){
+        String str = "((abc=13+ac=232)+ad=33+(ad=2))";
+        StringBuilder sb =new StringBuilder(str);
+        String regex = "(?<=[\\(\\)\\+\\-=])[\\w\\W]+?(?=[\\(\\+\\-=\\)])";
+        Pattern pattern = Pattern.compile(regex);
+        Matcher matcher = pattern.matcher(str);
+        Map<Integer,Integer> map =new LinkedHashMap<>();
+        while (matcher.find()) {
+            String  a=   matcher.group();
+            String regex2 = "[^\\(^\\)^\\+^-^=^*]";
+            Pattern pattern2 = Pattern.compile(regex2);
+            Matcher matcher2 = pattern2.matcher(a);
+            System.out.println(matcher.start() + "->" + matcher.end()+matcher.group());
+            Integer start =matcher.start();
+            if(matcher2.find()){
+                start +=matcher2.start();
+            }
+            map.put(start,matcher.end());
+        }
+        List <Integer> list = new ArrayList<Integer>(map.keySet());
+for(int i=0;i<list.size();i+=2){
+ int start1 = list.get(i);
+ int end1 = map.get(list.get(i));
+ int len1 =end1-start1;
+ int start2 = list.get(i+1);
+ int end2 = map.get(list.get(i+1));
+    int len2 =end2-start2;
+ int diff =len2 -len1;
+ if(diff>0){
+     sb.replace(start1,end1,str.substring(start2,end2));
+     sb.replace(start2+diff,end2+diff,str.substring(start1,end1));
+ }
+ else {
+     sb.replace(start2,end2,str.substring(start1,end1));
+     sb.replace(start1,end1,str.substring(start2,end2));
+ }
+    System.out.println(sb);
+}
+String aa =sb.toString();
+aa.replace("\\","=");
+        System.out.println(aa);
+return "";
+    }
+    public Map<String,Object> patentStarSearchApi(PatentStarListDto patentStarListDto) throws IOException {
+        String formQuery=patentStarListDto.getCurrentQuery();
         String json = JSONObject.toJSONString(patentStarListDto);
         String url = "http://s.patentstar.com.cn/SearchAPI/PatentSearch/ResultGet";
         Long currentTimeMillis = System.currentTimeMillis() / 1000;
@@ -68,15 +113,22 @@ public class PatentStarApiService {
             Response response = okHttpClient.newCall(request).execute();
             // 判断请求是否成功
             if (response.isSuccessful()) {
-//                JSONObject jsonObject  =JSONObject.parseObject(Objects.requireNonNull(response.body()).string());
-//                JSONObject jsonObject1= (JSONObject)jsonObject.get("Data");
+                JSONObject jsonObject  =JSONObject.parseObject(Objects.requireNonNull(response.body()).string());
+                JSONObject Data= (JSONObject)jsonObject.get("Data");
                 // 打印服务端返回结果
-                return Objects.requireNonNull(response.body()).string();
+              //  return Objects.requireNonNull(response.body()).string();
+
+                Map<String,Object> reMap =new HashMap<>();
+                reMap.put("size",patentStarListDto.getRowCount());
+                reMap.put("current",patentStarListDto.getPageNum());
+                reMap.put("records",Data.get("List"));
+                reMap.put("total",Data.get("HitCount"));
+                return reMap;
             }
         } catch (IOException e) {
             e.printStackTrace();
         }
-        return "{}";
+        return null;
     }
     /**
      * @param appNo
@@ -449,4 +501,10 @@ public class PatentStarApiService {
         }
         return "{}";
     }
+
+    public static void main(String[] args) {
+        String str ="D=ABC";
+    String aa=   PatentStarApiService.formatQuery(str);
+    System.out.println(aa);
+    }
 }