浏览代码

Merge remote-tracking branch 'origin/master'

xiexiang 1 年之前
父节点
当前提交
3305e22d41

+ 20 - 0
src/main/java/cn/cslg/pas/common/config/ThreadPoolConfig.java

@@ -0,0 +1,20 @@
+package cn.cslg.pas.common.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;  
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;  
+  
+@Configuration  
+public class ThreadPoolConfig {  
+  
+    @Bean  
+    public ThreadPoolTaskExecutor threadPoolTaskExecutor() {  
+        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();  
+        executor.setCorePoolSize(5); // 设置核心线程数  
+        executor.setMaxPoolSize(5); // 设置最大线程数
+        executor.setQueueCapacity(25); // 设置队列容量  
+        executor.setThreadNamePrefix("my-thread-pool-"); // 设置线程名称前缀  
+        executor.initialize(); // 初始化线程池  
+        return executor;  
+    }  
+}

+ 12 - 2
src/main/java/cn/cslg/pas/factorys/EsBuilderFactory/WildcardQueryBuilder.java

@@ -5,6 +5,9 @@ import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
 import org.springframework.stereotype.Component;
 
 import java.text.ParseException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
 
 @Component
 public class WildcardQueryBuilder implements IQueryBuilder{
@@ -15,9 +18,16 @@ public class WildcardQueryBuilder implements IQueryBuilder{
 
     @Override
     public Query creteQuery() throws ParseException {
+        List<String> list = Arrays.asList("patent_no.keyword", "app_no.keyword", "public_no.keyword", "grant_no.keyword");
         String str = "*";
-        String s = str.concat(value).concat("*");
-        return QueryBuilders.wildcard(i -> i.field(field).value(s));
+        String s = "";
+        if (list.contains(field)) {
+            s = str.concat(value.toUpperCase(Locale.ROOT)).concat("*");
+        } else {
+            s = str.concat(value).concat("*");
+        }
+        String result = s;
+        return QueryBuilders.wildcard(i -> i.field(field).value(result));
     }
 
     public String getField() {

+ 55 - 24
src/main/java/cn/cslg/pas/service/business/EventService.java

@@ -97,12 +97,6 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Integer addMessage(Object object, List<MultipartFile> files) {
-        EventDTO eventDTO = (EventDTO) object;
-        //检查事件格式
-        if (eventDTO.getScenarioId() == null) {
-            throw new XiaoShiException("参数错误");
-        }
-
         //获取登录人信息
         PersonnelVO personnelVO = new PersonnelVO();
         try {
@@ -110,16 +104,11 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
         } catch (Exception e) {
             throw new UnLoginException("未登录");
         }
+        this.checkParameter(object);
+        EventDTO eventDTO = (EventDTO) object;
 
         //根据名称查询是否重复
         eventDTO.setName(eventDTO.getName().trim());
-        String name = eventDTO.getName();
-        LambdaQueryWrapper<Event> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(Event::getName, name);
-        List<Event> events = this.list(queryWrapper);
-        if (events != null && events.size() != 0) {
-            throw new XiaoShiException("名称重复");
-        }
 
         //事件入库
         Event event = new Event();
@@ -184,16 +173,10 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
             throw new XiaoShiException("参数错误");
 
         }
+        this.checkParameter(object);
         Event event = this.getById(updateEventDTO.getId());
         //根据名称查询是否重复
         updateEventDTO.setName(updateEventDTO.getName().trim());
-        String name = updateEventDTO.getName();
-        LambdaQueryWrapper<Event> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(Event::getName, name);
-        List<Event> events = this.list(queryWrapper);
-        if (!updateEventDTO.getName().equals(event.getName()) && events.size() != 0) {
-            throw new XiaoShiException("名称重复");
-        }
         BeanUtils.copyProperties(updateEventDTO, event);
         event.updateById();
 
@@ -271,8 +254,8 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
 
         //返回分组数据
         QueryGroupImp queryGroupImp = queryGroupFactory.getClass(groupConfig.getGroupClass());
-        String countFiled ="id";
-        ReGroupDataVO reGroupDataVO = queryGroupImp.getGroup(sqls, tableName, groupConfig.getSqlField(),countFiled);
+        String countFiled = "id";
+        ReGroupDataVO reGroupDataVO = queryGroupImp.getGroup(sqls, tableName, groupConfig.getSqlField(), countFiled);
 
         //装载数据
         GroupVO groupVO = new GroupVO();
@@ -460,9 +443,9 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
             rootSql = "(tenant_id =" + tenant_id + ")";
         }
 
-        if (sqls.get(0) != null && !sqls.get(0).equals("")&&!rootSql.equals("")) {
+        if (sqls.get(0) != null && !sqls.get(0).equals("") && !rootSql.equals("")) {
             sqls.set(0, rootSql + " and" + "(" + sqls.get(0) + ")");
-        } else if((sqls.get(0) == null ||sqls.get(0).equals(""))&&!rootSql.equals("")){
+        } else if ((sqls.get(0) == null || sqls.get(0).equals("")) && !rootSql.equals("")) {
             sqls.set(0, rootSql);
         }
 
@@ -470,4 +453,52 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
 
     }
 
+    /**
+     * 参数检查
+     *
+     * @param object
+     */
+    public void checkParameter(Object object) {
+      PersonnelVO  personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+
+        String name = null;
+        Integer id = null;
+        Integer scenarioId = null;
+        if (object instanceof EventDTO) {
+            EventDTO eventDTO = (EventDTO) object;
+            eventDTO.getScenarioId();
+            name = eventDTO.getName();
+            scenarioId = eventDTO.getScenarioId();
+        } else if (object instanceof UpdateEventDTO) {
+            UpdateEventDTO eventDTO = (UpdateEventDTO) object;
+            eventDTO.getScenarioId();
+            name = eventDTO.getName();
+            scenarioId = eventDTO.getScenarioId();
+            id = eventDTO.getId();
+        }
+
+        //检验名称是否为空
+        if (name == null || name.trim().equals("")) {
+            throw new XiaoShiException("请输入名称");
+        }
+
+        //检验是否传入应用场景
+        if(scenarioId==null){
+            throw new XiaoShiException("请选择应用场景");
+        }
+
+        //检验名称是否重复
+        LambdaQueryWrapper<Event> queryWrapper =new LambdaQueryWrapper<>();
+        queryWrapper.eq(Event::getName,name)
+                .eq(Event::getTenantId,personnelVO.getTenantId());
+        if(id!=null){
+            queryWrapper.ne(Event::getId,id);
+        }
+        Event event =this.getOne(queryWrapper,false);
+        if(event!=null){
+            throw  new XiaoShiException("名称重复");
+        }
+
+
+    }
 }

+ 6 - 6
src/main/java/cn/cslg/pas/service/business/es/EsService.java

@@ -284,7 +284,7 @@ public class EsService {
                         BeanUtils.copyProperties(patent1, columnDTO);
                         if (projectId != null) {
                             try {
-                                columnDTO.setMergeApplicant(esPatentService.getMergeApp(projectId,id));
+                                columnDTO.setMergeApplicant(esPatentService.getMergeApp(projectId, id));
                             } catch (IOException e) {
                                 columnDTO.setMergeApplicant(new ArrayList<>());
                             }
@@ -317,7 +317,7 @@ public class EsService {
                 BeanUtils.copyProperties(esMess, columnDTO);
                 if (projectId != null) {
                     try {
-                        columnDTO.setMergeApplicant(esPatentService.getMergeApp(projectId,id));
+                        columnDTO.setMergeApplicant(esPatentService.getMergeApp(projectId, id));
                     } catch (IOException e) {
                         columnDTO.setMergeApplicant(new ArrayList<>());
                     }
@@ -493,6 +493,7 @@ public class EsService {
             return -1;
         }
     }
+
     //更新patent
     public Integer updatePatentById(Patent patent, String id) {
         UpdateRequest<Patent, Patent> req;
@@ -827,7 +828,7 @@ public class EsService {
         req = UpdateRequest.of(
                 b -> b.index("legal_event")
                         .id(id)
-                        .doc(legalEvent)
+                        .doc(legalEvent).refresh(Refresh.True).waitForActiveShards(WaitForActiveShards.of(i -> i.count(1)))
         );
         try {
             client.update(req, LegalEvent.class);
@@ -847,7 +848,7 @@ public class EsService {
     public String addLegalEvent(LegalEvent legalEvent) throws Exception {
         IndexResponse indexResponse = client.index(i -> i
                 .index("legal_event")
-                .document(legalEvent)
+                .document(legalEvent).refresh(Refresh.True).waitForActiveShards(WaitForActiveShards.of(t -> t.count(1)))
         );
         return indexResponse.id();
 
@@ -1038,8 +1039,7 @@ public class EsService {
                     legalEvent1.setDescription(item.getLegalStatusInfo());
                     legalEvent1.setName(item.getLegalStatus());
                     try {
-                   String reId =this.addLegalEvent(legalEvent1);
-                   System.out.println(reId);
+                        String reId = this.addLegalEvent(legalEvent1);
                     } catch (Exception e) {
                         throw new XiaoShiException(e.getMessage());
                     }

+ 5 - 3
src/main/java/cn/cslg/pas/service/importPatent/ImportFromWebToEsService.java

@@ -301,9 +301,11 @@ public class ImportFromWebToEsService implements PatentImportImp {
 
 
     public void setPatentToEsProductAll() {
-        importTaskAMVO.setMessageThreadDoneCounter(importTaskAMVO.getThreadDoneCounter() + 1);
-        if (importTaskAMVO.getMessageThreadCounter().equals(importTaskAMVO.getMessageThreadDoneCounter())) {
-            savePatentToEsThread.setIfProductAll(true);
+        synchronized ("装载专利信息") {
+            importTaskAMVO.setMessageThreadDoneCounter(importTaskAMVO.getMessageThreadDoneCounter() + 1);
+            if (importTaskAMVO.getMessageThreadCounter().equals(importTaskAMVO.getMessageThreadDoneCounter())) {
+                savePatentToEsThread.setIfProductAll(true);
+            }
         }
     }
 

+ 5 - 0
src/main/java/cn/cslg/pas/service/importPatent/ImportSinglePatentService.java

@@ -743,6 +743,10 @@ public class ImportSinglePatentService {
         if (contents.contains(5)) {
             this.getPDFFromWeb(starPatentVO);
         }
+        //添加法律事务
+        if(contents.contains(6)){
+            esService.addEsLegalEvent(patentNo);
+        }
 
         if (!ObjectUtils.isEmpty(patent)) {
             esService.updatePatentShouldWait(patent, patentWithIdVO.getId());
@@ -750,4 +754,5 @@ public class ImportSinglePatentService {
         }
         return true;
     }
+
 }

+ 3 - 0
src/main/java/cn/cslg/pas/service/importPatent/SavePatentToEsThread.java

@@ -129,6 +129,7 @@ public class SavePatentToEsThread extends Thread {
             }
         }
         taskThread.awakeTaskThread();
+        System.out.println("专利信息装载完毕");
     }
 
     public SavePatentToEsThread(TaskThread taskThread, ApplicationContext applicationContext) {
@@ -150,7 +151,9 @@ public class SavePatentToEsThread extends Thread {
     public void setIfProductAll(Boolean ifProductAll) {
 
         this.ifProductAll = ifProductAll;
+        System.out.println("专利导入全部结束"+ this.ifProductAll);
         if (taskLock.tryLock()) {
+            System.out.println("专利导入到es解锁");
             taskCondition.signalAll();
             taskLock.unlock();
         }

+ 15 - 10
src/main/java/cn/cslg/pas/service/importPatent/SchedulingTaskService.java

@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
@@ -29,8 +30,8 @@ public class SchedulingTaskService {
 
     @Autowired
     private ApplicationContext applicationContext;
-    private ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(Constants.MAX_IMPORT_TASK_COUNT);
-
+    @Autowired
+    private ThreadPoolTaskExecutor threadPoolTaskExecutor;
     @Autowired
     private ImportTaskConditionService importTaskConditionService;
 
@@ -39,8 +40,10 @@ public class SchedulingTaskService {
     private List<ImportTaskAMVO> importTaskAMVOS;
 
     public void startTask() {
-        Integer freeCount = Constants.MAX_IMPORT_TASK_COUNT - executor.getActiveCount();
-
+        Integer freeCount = Constants.MAX_IMPORT_TASK_COUNT - threadPoolTaskExecutor.getActiveCount();
+       if(importTaskAMVOS==null){
+           importTaskAMVOS=new ArrayList<>();
+       }
         // 当正在活跃的线程数小于最大线程数时
         if (freeCount > 0) {
             //查找任务
@@ -55,17 +58,19 @@ public class SchedulingTaskService {
 
             if (importTaskList.size() > 0) {
                 // 装载任务信息
-                importTaskAMVOS = this.loadTaskAMVOS(importTaskList);
+             List<ImportTaskAMVO>   importTaskAMVOFromDbs = this.loadTaskAMVOS(importTaskList);
 
-                for (int i = 0; i < importTaskAMVOS.size(); i++) {
+                for (int i = 0; i < importTaskAMVOFromDbs.size(); i++) {
                     importTaskList.get(i).setState(1);
                     importTaskList.get(i).updateById();
-                    importTaskAMVOS.get(i).setState(1);
-                    importTaskAMVOS.get(i).setThreadCounter(0);
-                    TaskThread taskThread = new TaskThread(importTaskAMVOS.get(i), applicationContext);
-                    executor.execute(taskThread);
+                    importTaskAMVOFromDbs.get(i).setState(1);
+                    importTaskAMVOFromDbs.get(i).setThreadCounter(0);
+                    TaskThread taskThread = new TaskThread(importTaskAMVOFromDbs.get(i), applicationContext);
+                    threadPoolTaskExecutor.execute(taskThread);
+                    importTaskAMVOS.add(importTaskAMVOFromDbs.get(i));
                 }
 
+
             }
 
         }

+ 15 - 0
src/main/java/cn/cslg/pas/service/importPatent/TaskExecutor.java

@@ -0,0 +1,15 @@
+package cn.cslg.pas.service.importPatent;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;  
+import org.springframework.stereotype.Component;  
+  
+@Component  
+public class TaskExecutor {  
+
+    private ThreadPoolTaskExecutor threadPoolTaskExecutor;  
+  
+    public void executeTask(Runnable task) {  
+        threadPoolTaskExecutor.execute(task);  
+    }  
+}

+ 2 - 1
src/main/java/cn/cslg/pas/service/importPatent/TaskThread.java

@@ -98,7 +98,7 @@ public class TaskThread extends Thread {
         importTaskAMVO.setThreadCounter(threadCount);
         this.applicationContext = applicationContext;
         this.patentProcess.setPatentDoneNum(importTaskAMVO.getDoneNum());
-        this.patentProcess.setPatentDefaultNum(0);
+        this.patentProcess.setPatentDefaultNum(importTaskAMVO.getDefaultNum());
 
     }
 
@@ -144,6 +144,7 @@ public class TaskThread extends Thread {
     public void awakeTaskThread() {
         synchronized ("导入任务是否完成") {
             importTaskAMVO.setThreadDoneCounter(importTaskAMVO.getThreadDoneCounter() + 1);
+            System.out.println("任务已经完成第"+importTaskAMVO.getThreadDoneCounter());
             if (importTaskAMVO.getThreadCounter().equals(importTaskAMVO.getThreadDoneCounter())) {
 
                 System.out.println("任务已经完成");

+ 16 - 16
src/main/resources/jsons/esCountAnalysis.json

@@ -1,6 +1,6 @@
 [
   {
-    "name": "IPC分类号一级",
+    "name": "IPC分类号",
     "type": "String",
     "value": "ipcLevel1",
     "field": "IC",
@@ -12,7 +12,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "IPC分类号二级",
+    "name": "IPC分类号大类",
     "type": "String",
     "value": "ipcLevel2",
     "field": "IC2",
@@ -24,7 +24,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "IPC分类号三级",
+    "name": "IPC分类号小类",
     "type": "String",
     "value": "ipcLevel3",
     "field": "IC3",
@@ -36,7 +36,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "IPC分类号四级",
+    "name": "IPC分类号大组",
     "type": "String",
     "value": "ipcLevel4",
     "field": "IC4",
@@ -48,7 +48,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "IPC分类号五级",
+    "name": "IPC分类号小组",
     "type": "String",
     "value": "ipcLevel5",
     "field": "IC5",
@@ -60,7 +60,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "CPC分类号一级",
+    "name": "CPC分类号",
     "type": "String",
     "value": "cpcLevel1",
     "field": "CPC",
@@ -72,7 +72,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "CPC分类号二级",
+    "name": "CPC分类号大类",
     "type": "String",
     "value": "cpcLevel2",
     "field": "CPC2",
@@ -84,7 +84,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "CPC分类号三级",
+    "name": "CPC分类号小类",
     "type": "String",
     "value": "cpcLevel3",
     "field": "CPC3",
@@ -96,7 +96,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "CPC分类号四级",
+    "name": "CPC分类号大组",
     "type": "String",
     "value": "cpcLevel4",
     "field": "CPC4",
@@ -108,7 +108,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "CPC分类号五级",
+    "name": "CPC分类号小组",
     "type": "String",
     "value": "cpcLevel5",
     "field": "CPC5",
@@ -120,7 +120,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "UPC分类号一级",
+    "name": "UPC分类号",
     "type": "String",
     "value": "upcLevel1",
     "field": "UPC",
@@ -132,7 +132,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "UPC分类号二级",
+    "name": "UPC分类号大类",
     "type": "String",
     "value": "upcLevel2",
     "field": "UPC2",
@@ -144,7 +144,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "UPC分类号三级",
+    "name": "UPC分类号小类",
     "type": "String",
     "value": "upcLevel3",
     "field": "UPC3",
@@ -156,7 +156,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "LOC分类号一级",
+    "name": "LOC分类号",
     "type": "String",
     "value": "locLevel1",
     "field": "LOC",
@@ -168,7 +168,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "LOC分类号二级",
+    "name": "LOC分类号大类",
     "type": "String",
     "value": "locLevel2",
     "field": "LOC2",
@@ -180,7 +180,7 @@
     "ifAsCondition": "true"
   },
   {
-    "name": "LOC分类号三级",
+    "name": "LOC分类号小类",
     "type": "String",
     "value": "locLevel3",
     "field": "LOC3",

+ 0 - 13
src/main/resources/jsons/event.json

@@ -50,19 +50,6 @@
     "ifShow": "true"
   },
   {
-    "name": "客户",
-    "type": "String",
-    "value": "clientName",
-    "field": "clientName",
-    "sqlField": "client_id",
-    "sqlClass": "getClientNameSql",
-    "orderClass": "getClientNameOrder",
-    "ifSearch": "true",
-    "ifGroup": "false",
-    "ifShow": "true",
-    "ifAsCondition": "true"
-  },
-  {
     "name": "发生时间",
     "type": "DateTime",
     "value": "eventDate",

+ 3 - 5
src/test/java/cn/cslg/pas/service/CommonServiceTests.java

@@ -137,10 +137,8 @@ public class CommonServiceTests {
 //李仁杰<2232723707@qq.com>"
     @Test
     public void testEmail() throws Exception{
- Map<String,List<String>> map =new HashMap<>();
- map.put("a",new ArrayList<>());
- List<String> aa =map.get("a");
- aa.add("111");
- System.out.println(aa);
+        String te = "201100 上海市闵行区园美路58号1幢2层203、204室";
+        te+="aaaa";
+ System.out.println(te);
     }
     }

+ 8 - 7
src/test/java/cn/cslg/pas/service/EventServiceTests.java

@@ -69,8 +69,9 @@ public class EventServiceTests {
 
     @Autowired
     private ProductMarketDataService productMarketDataService;
-@Autowired
-private AssoProjectEventMapper assoProjectEventMapper;
+    @Autowired
+    private AssoProjectEventMapper assoProjectEventMapper;
+
     @Test
     void test() throws Exception {
         StringRequest queryRequest = new StringRequest();
@@ -383,9 +384,9 @@ private AssoProjectEventMapper assoProjectEventMapper;
             for (int i = 0; i < list.size(); i++) {
                 String s = list.get(i);
                 if (i == list.size() - 1) {
-                    str = str + "\"" +s + "\""  ;
+                    str = str + "\"" + s + "\"";
                 } else {
-                    str = str + "\"" +s + "\"" + "," ;
+                    str = str + "\"" + s + "\"" + ",";
                 }
             }
         } else {
@@ -470,9 +471,9 @@ private AssoProjectEventMapper assoProjectEventMapper;
 
     @Test
     public void test101() {
-        String a =" DESC";
-  List<Integer> ids = assoProjectEventMapper.getEventProjectNumOrder(0,a);
-  System.out.println(ids);
+        String a = " DESC";
+        List<Integer> ids = assoProjectEventMapper.getEventProjectNumOrder(0, a);
+        System.out.println(ids);
     }
 
 }