Ver código fonte

Merge remote-tracking branch 'origin/master' into prod_test

lrj 8 meses atrás
pai
commit
fedd412afb
55 arquivos alterados com 1086 adições e 393 exclusões
  1. 47 0
      src/main/java/cn/cslg/pas/common/core/GlobalException.java
  2. 1 1
      src/main/java/cn/cslg/pas/common/utils/CacheUtils.java
  3. 1 1
      src/main/java/cn/cslg/pas/common/utils/CronUtil.java
  4. 1 1
      src/main/java/cn/cslg/pas/common/utils/ResponseEnum.java
  5. 3 0
      src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/expressManager.java
  6. 15 50
      src/main/java/cn/cslg/pas/controller/AssoGroupFeatureController.java
  7. 0 2
      src/main/java/cn/cslg/pas/controller/AvoidDesignController.java
  8. 0 2
      src/main/java/cn/cslg/pas/controller/ClaimsManageController.java
  9. 0 4
      src/main/java/cn/cslg/pas/controller/CustomFieldController.java
  10. 0 2
      src/main/java/cn/cslg/pas/controller/CustomOptionController.java
  11. 0 2
      src/main/java/cn/cslg/pas/controller/EventController.java
  12. 0 2
      src/main/java/cn/cslg/pas/controller/FTOController.java
  13. 9 41
      src/main/java/cn/cslg/pas/controller/PatentController.java
  14. 0 2
      src/main/java/cn/cslg/pas/controller/PatentDigProjectController.java
  15. 0 2
      src/main/java/cn/cslg/pas/controller/PatentDigProjectFilesController.java
  16. 0 4
      src/main/java/cn/cslg/pas/controller/PatentProjectController.java
  17. 0 2
      src/main/java/cn/cslg/pas/controller/ProductCategoryController.java
  18. 0 2
      src/main/java/cn/cslg/pas/controller/ProductController.java
  19. 0 2
      src/main/java/cn/cslg/pas/controller/ProductMarketDataController.java
  20. 0 2
      src/main/java/cn/cslg/pas/controller/ReportProjectController.java
  21. 0 2
      src/main/java/cn/cslg/pas/controller/TortController.java
  22. 0 2
      src/main/java/cn/cslg/pas/controller/TreeNodeController.java
  23. 5 5
      src/main/java/cn/cslg/pas/factorys/EsBuilderFactory/LGKeyWordQueryBuilder.java
  24. 2 1
      src/main/java/cn/cslg/pas/service/MailSendService.java
  25. 45 8
      src/main/java/cn/cslg/pas/service/ReportExportService.java
  26. 1 1
      src/main/java/cn/cslg/pas/service/business/ImportTaskConditionService.java
  27. 12 1
      src/main/java/cn/cslg/pas/service/business/ImportTaskService.java
  28. 38 15
      src/main/java/cn/cslg/pas/service/business/MergePersonService.java
  29. 5 4
      src/main/java/cn/cslg/pas/service/business/PDFExportFirstPageService.java
  30. 114 17
      src/main/java/cn/cslg/pas/service/business/PatentExportService.java
  31. 4 4
      src/main/java/cn/cslg/pas/service/business/ProductService.java
  32. 45 7
      src/main/java/cn/cslg/pas/service/business/es/EsCountService.java
  33. 64 11
      src/main/java/cn/cslg/pas/service/business/es/EsCustomFieldService.java
  34. 85 41
      src/main/java/cn/cslg/pas/service/business/es/EsExportService.java
  35. 9 5
      src/main/java/cn/cslg/pas/service/business/es/EsFamilyService.java
  36. 9 7
      src/main/java/cn/cslg/pas/service/business/es/EsLegalEventService.java
  37. 166 41
      src/main/java/cn/cslg/pas/service/business/es/EsPatentService.java
  38. 9 1
      src/main/java/cn/cslg/pas/service/business/es/EsPatentVectorService.java
  39. 21 4
      src/main/java/cn/cslg/pas/service/business/es/EsProductPatentService.java
  40. 16 2
      src/main/java/cn/cslg/pas/service/business/es/EsQuotePatentService.java
  41. 46 10
      src/main/java/cn/cslg/pas/service/business/es/EsScratchWordsService.java
  42. 135 29
      src/main/java/cn/cslg/pas/service/business/es/EsService.java
  43. 8 1
      src/main/java/cn/cslg/pas/service/business/es/EsValueCurveService.java
  44. 5 4
      src/main/java/cn/cslg/pas/service/business/invalidReport/AssoGroupFeatureService.java
  45. 1 0
      src/main/java/cn/cslg/pas/service/common/PersonFieldService.java
  46. 8 1
      src/main/java/cn/cslg/pas/service/common/TranslateService.java
  47. 4 4
      src/main/java/cn/cslg/pas/service/importPatent/ImportSinglePatentService.java
  48. 58 5
      src/main/java/cn/cslg/pas/service/importPatent/SavePatentToEsThread.java
  49. 3 1
      src/main/java/cn/cslg/pas/service/quartzService/SysImportPatentJobService.java
  50. 2 1
      src/main/java/cn/cslg/pas/service/query/FormatQueryService.java
  51. BIN
      src/main/resources/file/reportTemple/FTOTemplate1-chinese.docx
  52. 8 2
      src/main/resources/jsons/patent.json
  53. 2 2
      src/main/resources/mapper/PatentProjectMapper.xml
  54. 40 30
      src/test/java/cn/cslg/pas/service/EventServiceTests.java
  55. 39 0
      src/test/java/cn/cslg/pas/test/QuartzTaskTests.java

+ 47 - 0
src/main/java/cn/cslg/pas/common/core/GlobalException.java

@@ -0,0 +1,47 @@
+package cn.cslg.pas.common.core;
+
+import cn.cslg.pas.common.core.exception.PermissionException;
+import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.common.utils.ResponseEnum;
+import cn.cslg.pas.exception.XiaoShiException;
+import cn.dev33.satoken.exception.NotLoginException;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+
+/**
+ * 全局异常处理
+ */
+@Slf4j
+@RestControllerAdvice // 可指定包前缀,比如:(basePackages = "com.pj.admin")
+public class GlobalException {
+
+    // 全局异常拦截(拦截项目中的所有异常)
+    @ExceptionHandler
+    public String handlerException(Exception e, HttpServletRequest request, HttpServletResponse response) throws Exception {
+        // 打印堆栈,以供调试
+        e.printStackTrace();
+        if (e instanceof NotLoginException) {
+            return Response.error(ResponseEnum.UNAUTHORIZED);
+        } else if (e instanceof PermissionException) {
+            return Response.error(ResponseEnum.NOT_PERMISSION);
+        } else {
+            return Response.error(ResponseEnum.SYSTEM_ERROR);
+        }
+    }
+
+    //小世异常
+    @ExceptionHandler
+    public Response handlerXiaoShiException(XiaoShiException e) {
+        log.info("全局异常处理机制捕获到XiaoShiException,异常信息提示为:{}", e.getErrorCode() + "--" + e.getMessage());
+        if (StringUtils.isNotEmpty(e.getErrorCode())) {
+            return Response.error(e.getErrorCode(), e.getErrorMessage());
+        } else {
+            return Response.error(e.getMessage());
+        }
+    }
+}

+ 1 - 1
src/main/java/cn/cslg/pas/common/utils/CacheUtils.java

@@ -29,7 +29,7 @@ public class CacheUtils {
 
     public PersonnelVO getLoginUser(Object userId) {
         String json = redisUtil.get(RedisConf.LOGIN_USER + RedisConf.SYMBOL_COLON + userId);
-        if (StringUtils.isEmpty(json)) {
+        if (Boolean.TRUE.equals(StringUtils.isEmpty(json))) {
             throw new XiaoShiException(ExceptionEnum.LOGIN_NO_LOGIN,"未登录");
         } else {
             return com.alibaba.fastjson2.JSONObject.parseObject(json, PersonnelVO.class);

+ 1 - 1
src/main/java/cn/cslg/pas/common/utils/CronUtil.java

@@ -33,7 +33,7 @@ public class CronUtil {
                 cron = "0 0 0 1 1 ? *";
                 break;
             default:
-                throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK,"周期非法输入");
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR,"周期非法输入");
         }
         return cron;
 

+ 1 - 1
src/main/java/cn/cslg/pas/common/utils/ResponseEnum.java

@@ -7,7 +7,7 @@ public enum ResponseEnum {
     NOT_PERMISSION(402, "无操作权限"),
     SYSTEM_ERROR(500, "系统异常"),
     SUCCESSBUT(200, "请求成功"),
-    ERROR(0, "请求失败"),
+    ERROR(708, "请求失败"),
     NO_PERMISSION(201,"无权限"),
     PARAMS_ERROR(202,"参数错误"),
     CONDITION_ERROR(203, "检索式错误"),

+ 3 - 0
src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/expressManager.java

@@ -422,6 +422,9 @@ public class expressManager {
                     case '>':
                     case '<':
                     case '<':
+                        if (isFindingEndYinHao) {
+                            continue;
+                        }
                         strTemToken = strTem.substring(step + 1, i);
 
                         if (strTemToken != null && strTemToken != "") {

+ 15 - 50
src/main/java/cn/cslg/pas/controller/AssoGroupFeatureController.java

@@ -33,64 +33,39 @@ public class AssoGroupFeatureController {
     @Operation(summary = "修改特征")
     @PostMapping("/updateGroupFeature")
     public Response updateGroupFeature(@RequestBody UpdateGroupFeatureDTO updateGroupFeatureDTO) throws Exception {
-        try {
-            Records records = new Records();
-            records.setData(assoGroupFeatureService.updateGroupFeature(updateGroupFeatureDTO));
-            return Response.success(records);
-
-        } catch (Exception e) {
-            return Response.error(e.getMessage());
-        }
+        Records records = new Records();
+        records.setData(assoGroupFeatureService.updateGroupFeature(updateGroupFeatureDTO));
+        return Response.success(records);
     }
 
     @Operation(summary = "删除特征")
     @PostMapping("/removeGroupFeature")
     public Response removeGroupFeature(@RequestBody RemoveGroupFeatureDTO removeGroupFeatureDTO) throws Exception {
-        try {
-            Records records = new Records();
-            records.setData(assoGroupFeatureService.removeGroupFeature(removeGroupFeatureDTO));
-            return Response.success(records);
-
-        } catch (Exception e) {
-            return Response.error(e.getMessage());
-        }
+        Records records = new Records();
+        records.setData(assoGroupFeatureService.removeGroupFeature(removeGroupFeatureDTO));
+        return Response.success(records);
     }
 
 
     @Operation(summary = "查询特征修改历史")
     @PostMapping("/queryFeatureHistory")
     public Response queryFeatureHistory(@RequestBody QueryFeatureHistoryDTO queryFeatureHistoryDTO) throws Exception {
-        try {
-            Records records = new Records();
-            records.setData(assoGroupFeatureService.queryFeatureHistory(queryFeatureHistoryDTO));
-            return Response.success(records);
-
-        } catch (Exception e) {
-            return Response.error(e.getMessage());
-        }
+        Records records = new Records();
+        records.setData(assoGroupFeatureService.queryFeatureHistory(queryFeatureHistoryDTO));
+        return Response.success(records);
     }
 
     @Operation(summary = "更新特征")
     @PostMapping("/updateFeature")
     public Response updateFeature(@RequestBody UpdateGroupFeatureDTO updateGroupFeatureDTO) throws Exception {
-        try {
-           assoGroupFeatureService.updateFeature(updateGroupFeatureDTO);
-            return Response.success("更新成功");
-
-        } catch (Exception e) {
-            return Response.error(e.getMessage());
-        }
+        assoGroupFeatureService.updateFeature(updateGroupFeatureDTO);
+        return Response.success("更新成功");
     }
 
     @Operation(summary = "更新信息")
     @PostMapping("/updateMessage")
     public Response updateMessage(@RequestBody UpdateMessageDTO updateMessageDTO) {
-        try {
-            assoGroupFeatureService.updateMessage(updateMessageDTO);
-        }
-        catch (Exception e){
-            return  Response.error(e.getMessage());
-        }
+        assoGroupFeatureService.updateMessage(updateMessageDTO);
         return Response.success("更新成功");
     }
 
@@ -98,12 +73,7 @@ public class AssoGroupFeatureController {
     @Operation(summary = "批量给证据组合添加特征")
     @PostMapping("/addFeatureGroupBatch")
     public Response addFeatureGroupBatch(@RequestBody AddFeatureGroupBatchDTO addFeatureGroupBatchDTO) {
-        try {
-            assoGroupFeatureService.addFeatureGroupBatch(addFeatureGroupBatchDTO);
-        }
-        catch (Exception e){
-            return  Response.error(e.getMessage());
-        }
+        assoGroupFeatureService.addFeatureGroupBatch(addFeatureGroupBatchDTO);
         return Response.success("添加成功");
     }
 
@@ -111,13 +81,8 @@ public class AssoGroupFeatureController {
     @GetMapping("/cancelRemoveFeature")
     public Response cancelRemoveFeature( Integer featureId ) {
         Records records =new Records();
-        try {
-           List<Integer> ids = assoGroupFeatureService.cancelRemoveFeature(featureId);
-           records.setData(ids);
-        }
-        catch (Exception e){
-            return  Response.error(e.getMessage());
-        }
+        List<Integer> ids = assoGroupFeatureService.cancelRemoveFeature(featureId);
+        records.setData(ids);
         return Response.success(records);
     }
 }

+ 0 - 2
src/main/java/cn/cslg/pas/controller/AvoidDesignController.java

@@ -44,8 +44,6 @@ public class AvoidDesignController {
                     return Response.error(e.getMessage());
                 } else if (e instanceof UnLoginException) {
                     return Response.unLogin(e.getMessage());
-                } else if (e instanceof ConditionException) {
-                    return Response.conditionError(e.getMessage());
                 }
             }
             return Response.success(ids);

+ 0 - 2
src/main/java/cn/cslg/pas/controller/ClaimsManageController.java

@@ -69,8 +69,6 @@ public class ClaimsManageController {
                     return Response.error(e.getMessage());
                 } else if (e instanceof UnLoginException) {
                     return Response.unLogin(e.getMessage());
-                } else if (e instanceof ConditionException) {
-                    return Response.conditionError(e.getMessage());
                 }
             }
             Records records = new Records();

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

@@ -68,8 +68,6 @@ public class CustomFieldController {
                     return Response.error(e.getMessage());
                 } else if (e instanceof UnLoginException) {
                     return Response.unLogin(e.getMessage());
-                } else if (e instanceof ConditionException) {
-                    return Response.conditionError(e.getMessage());
                 }
             }
             return Response.success(id);
@@ -91,8 +89,6 @@ public class CustomFieldController {
                     return Response.error(e.getMessage());
                 } else if (e instanceof UnLoginException) {
                     return Response.unLogin(e.getMessage());
-                } else if (e instanceof ConditionException) {
-                    return Response.conditionError(e.getMessage());
                 }
             }
             return Response.success(id);

+ 0 - 2
src/main/java/cn/cslg/pas/controller/CustomOptionController.java

@@ -49,8 +49,6 @@ public class CustomOptionController {
                     return Response.error(e.getMessage());
                 } else if (e instanceof UnLoginException) {
                     return Response.unLogin(e.getMessage());
-                } else if (e instanceof ConditionException) {
-                    return Response.conditionError(e.getMessage());
                 }
             }
             return Response.success(id);

+ 0 - 2
src/main/java/cn/cslg/pas/controller/EventController.java

@@ -60,8 +60,6 @@ public class EventController {
                     return Response.error(e.getMessage());
                 } else if (e instanceof UnLoginException) {
                     return Response.unLogin(e.getMessage());
-                } else if (e instanceof ConditionException) {
-                    return Response.conditionError(e.getMessage());
                 }
             }
             return Response.success(id);

+ 0 - 2
src/main/java/cn/cslg/pas/controller/FTOController.java

@@ -62,8 +62,6 @@ public class FTOController {
                     return Response.error(e.getMessage());
                 } else if (e instanceof UnLoginException) {
                     return Response.unLogin(e.getMessage());
-                } else if (e instanceof ConditionException) {
-                    return Response.conditionError(e.getMessage());
                 }
             }
             Records records = new Records();

+ 9 - 41
src/main/java/cn/cslg/pas/controller/PatentController.java

@@ -103,12 +103,7 @@ public class PatentController {
     @PostMapping("/queryPatent")
     public Response queryPatent(@RequestBody StringRequest stringRequest) throws Exception {
         Business business = businessFactory.getClass("patentService");
-        Records records = null;
-        try {
-            records = (Records) business.queryMessage(stringRequest);
-        } catch (Exception e) {
-            return Response.error(e.getMessage());
-        }
+        Records records = (Records) business.queryMessage(stringRequest);
         return Response.success(records);
     }
 
@@ -180,12 +175,7 @@ public class PatentController {
     @Operation(summary = "专利的聚合统计")
     @PostMapping("/esCountAnalysis")
     public Response esCountAnalysis(@RequestBody EsAllCountVO countVO) throws Exception {
-        EsCountDTO dto = null;
-        try {
-            dto = esCountService.esCountAnalysis(countVO);
-        } catch (Exception e) {
-            return Response.error(e.getMessage());
-        }
+        EsCountDTO dto = esCountService.esCountAnalysis(countVO);
         return Response.success(dto);
     }
 
@@ -200,12 +190,7 @@ public class PatentController {
     @Operation(summary = "专利列表上新增或编辑发明人/权利人/申请人合并共享接口")
     @PostMapping("/commonMerge")
     public Response commonMerge(@RequestBody MergePersonCommonVO commonVO) throws Exception {
-        Integer personId = null;
-        try {
-            personId = mergePersonService.commonMerge(commonVO);
-        } catch (Exception e) {
-            return Response.error(e.getMessage());
-        }
+        Integer personId = mergePersonService.commonMerge(commonVO);
         return Response.success(personId);
     }
 
@@ -226,12 +211,7 @@ public class PatentController {
     @Operation(summary = "发明人/权利人/申请人合并记录删除")
     @PostMapping("/delMergePerson")
     public Response delMergePerson(@RequestBody MergePersonIdVO vo) throws Exception {
-        Integer id = null;
-        try {
-            id = mergePersonService.delMergePerson(vo);
-        } catch (Exception e) {
-            return Response.error(e.getMessage());
-        }
+        Integer id = mergePersonService.delMergePerson(vo);
         return Response.success(id);
     }
 
@@ -263,11 +243,7 @@ public class PatentController {
         Integer taskId = importTaskService.addExportTask(exportTaskDTO);
         exportTaskDTO.setEsVO(EsVO);
         exportTaskDTO.setTaskId(taskId);
-        try {
-            pdfExportFirstPageService.mergePdfFirstPage(exportTaskDTO);
-        } catch (Exception e) {
-            return Response.error(e.getMessage());
-        }
+        pdfExportFirstPageService.mergePdfFirstPage(exportTaskDTO);
         Records records = new Records();
         records.setData("正在导出PDF首页");
         return Response.success(records);
@@ -324,23 +300,15 @@ public class PatentController {
     }
 
     @PostMapping("/refreshPatent")
-    public Response refreshPatent(@RequestBody RefreshPatentDTO refreshPatentDTO) {
-        try {
-            importSinglePatentService.refreshPatent(refreshPatentDTO);
-        } catch (Exception e) {
-            return Response.error(e.getMessage());
-        }
+    public Response refreshPatent(@RequestBody RefreshPatentDTO refreshPatentDTO) throws Exception {
+        importSinglePatentService.refreshPatent(refreshPatentDTO);
           return Response.success("刷新成功");
     }
 
     @Operation(summary = "批量删除专利")
     @PostMapping("/deletePatents")
     public Response deletePatents(@RequestBody EsCustomFieldBatchVO vo) throws Exception {
-        try {
-            esService.deletePatents(vo);
-            return Response.success("删除成功");
-        } catch (Exception e) {
-            return Response.error("删除失败");
-        }
+        esService.deletePatents(vo);
+        return Response.success("删除成功");
     }
 }

+ 0 - 2
src/main/java/cn/cslg/pas/controller/PatentDigProjectController.java

@@ -62,8 +62,6 @@ public class PatentDigProjectController {
                     return Response.error(e.getMessage());
                 } else if (e instanceof UnLoginException) {
                     return Response.unLogin(e.getMessage());
-                } else if (e instanceof ConditionException) {
-                    return Response.conditionError(e.getMessage());
                 }
             }
             return Response.success(id);

+ 0 - 2
src/main/java/cn/cslg/pas/controller/PatentDigProjectFilesController.java

@@ -57,8 +57,6 @@ public class PatentDigProjectFilesController {
                 return Response.error(e.getMessage());
             } else if (e instanceof UnLoginException) {
                 return Response.unLogin(e.getMessage());
-            } else if (e instanceof ConditionException) {
-                return Response.conditionError(e.getMessage());
             }
         }
         return Response.success(id);

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

@@ -69,8 +69,6 @@ public class PatentProjectController {
                     return Response.error(e.getMessage());
                 } else if (e instanceof UnLoginException) {
                     return Response.unLogin(e.getMessage());
-                } else if (e instanceof ConditionException) {
-                    return Response.conditionError(e.getMessage());
                 } else {
                     return Response.error(e.getMessage());
                 }
@@ -95,8 +93,6 @@ public class PatentProjectController {
                     return Response.error(e.getMessage());
                 } else if (e instanceof UnLoginException) {
                     return Response.unLogin(e.getMessage());
-                } else if (e instanceof ConditionException) {
-                    return Response.conditionError(e.getMessage());
                 }
             }
             return Response.success(id);

+ 0 - 2
src/main/java/cn/cslg/pas/controller/ProductCategoryController.java

@@ -60,8 +60,6 @@ public class ProductCategoryController {
                     return Response.error(e.getMessage());
                 } else if (e instanceof UnLoginException) {
                     return Response.unLogin(e.getMessage());
-                } else if (e instanceof ConditionException) {
-                    return Response.conditionError(e.getMessage());
                 }
             }
             return Response.success(id);

+ 0 - 2
src/main/java/cn/cslg/pas/controller/ProductController.java

@@ -63,8 +63,6 @@ public class ProductController {
                     return Response.error(e.getMessage());
                 } else if (e instanceof UnLoginException) {
                     return Response.unLogin(e.getMessage());
-                } else if (e instanceof ConditionException) {
-                    return Response.conditionError(e.getMessage());
                 }
             }
             return Response.success(id);

+ 0 - 2
src/main/java/cn/cslg/pas/controller/ProductMarketDataController.java

@@ -59,8 +59,6 @@ public class ProductMarketDataController {
                 return Response.error(e.getMessage());
             } else if (e instanceof UnLoginException) {
                 return Response.unLogin(e.getMessage());
-            } else if (e instanceof ConditionException) {
-                return Response.conditionError(e.getMessage());
             }
         }
         return Response.success(id);

+ 0 - 2
src/main/java/cn/cslg/pas/controller/ReportProjectController.java

@@ -67,8 +67,6 @@ public class ReportProjectController {
                     return Response.error(e.getMessage());
                 } else if (e instanceof UnLoginException) {
                     return Response.unLogin(e.getMessage());
-                } else if (e instanceof ConditionException) {
-                    return Response.conditionError(e.getMessage());
                 }
             }
             return Response.success(id);

+ 0 - 2
src/main/java/cn/cslg/pas/controller/TortController.java

@@ -66,8 +66,6 @@ public class TortController {
                     return Response.error(e.getMessage());
                 } else if (e instanceof UnLoginException) {
                     return Response.unLogin(e.getMessage());
-                } else if (e instanceof ConditionException) {
-                    return Response.conditionError(e.getMessage());
                 }
             }
             Records records = new Records();

+ 0 - 2
src/main/java/cn/cslg/pas/controller/TreeNodeController.java

@@ -73,8 +73,6 @@ public class TreeNodeController {
                     return Response.error(e.getMessage());
                 } else if (e instanceof UnLoginException) {
                     return Response.unLogin(e.getMessage());
-                } else if (e instanceof ConditionException) {
-                    return Response.conditionError(e.getMessage());
                 }
             }
             return Response.success(id);

+ 5 - 5
src/main/java/cn/cslg/pas/factorys/EsBuilderFactory/LGKeyWordQueryBuilder.java

@@ -15,11 +15,11 @@ public class LGKeyWordQueryBuilder implements IQueryBuilder {
 
     @Override
     public Query creteQuery() {
-        if (value.equals("3")) {
-            value = "1";
-        } else if (value.equals("1")) {
-            value = "3";
-        }
+//        if (value.equals("3")) {
+//            value = "1";
+//        } else if (value.equals("1")) {
+//            value = "3";
+//        }
 //        QueryBuilders.matchQueryAsQuery(field, value, null, null);
         return QueryBuilders.term(i -> i.field(field).value(value));
     }

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

@@ -235,7 +235,7 @@ public class MailSendService {
         }
     }
 
-    public void sendSysCycleStartEmail() {
+    public void sendSysCycleStartEmail(String value) {
         LambdaQueryWrapper<SystemDict> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.in(SystemDict::getType, "ADMIN");
         List<SystemDict> systemDictList = systemDictService.list(queryWrapper);
@@ -246,6 +246,7 @@ public class MailSendService {
         map.put("title", "监控通知");
         map.put("template", "mail/sysCycleStart.html");
         map.put("img", "/logo.png");
+        map.put("value1", value);
         if (systemDictList != null && systemDictList.size() > 0) {
             SystemDict systemDict = systemDictList.remove(0);
             map.put("email", systemDict.getValue());

+ 45 - 8
src/main/java/cn/cslg/pas/service/ReportExportService.java

@@ -18,8 +18,10 @@ import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.PatentPerson;
 import cn.cslg.pas.domain.es.Priorities;
 import cn.cslg.pas.domain.es.Text;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.mapper.AvoidDesignMapper;
+import cn.cslg.pas.mapper.ProjectMapper;
 import cn.cslg.pas.service.business.*;
 import cn.cslg.pas.service.business.es.*;
 import cn.cslg.pas.service.business.invalidReport.AssoReasonLiteratureService;
@@ -38,6 +40,7 @@ import com.deepoove.poi.data.Pictures;
 import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.ddr.poi.html.HtmlRenderPolicy;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -104,6 +107,8 @@ public class ReportExportService {
     private EvidenceReasonService evidenceReasonService;
     @Autowired
     private TortCompareRecordService tortCompareRecordService;
+    @Autowired
+    private ProjectMapper projectMapper;
 
     /**
      * @param projectId
@@ -117,9 +122,16 @@ public class ReportExportService {
         ReportTemple reportTemplate = templeService.getById(templeId);
         //获得模板路径
         String templateFilePath = fileUtils.getPath(reportTemplate.getTemplatePath());
-
+        //获取项目名称
+        String name = "";
+        Project project = projectMapper.selectById(projectId);
+        if (ObjectUtils.isNotEmpty(project) && StringUtils.isNotEmpty(project.getName())) {
+            name = project.getName();
+        } else {
+            name = IdUtil.simpleUUID();
+        }
         //读取模板后保存生成word的地址
-        String fileName = IdUtil.simpleUUID() + ".docx";
+        String fileName = name + ".docx";
         String directoryName = fileUtils.createDirectory();
         String outPath = fileUtils.getSavePath(directoryName) + fileName;
 
@@ -317,7 +329,12 @@ public class ReportExportService {
         HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy();
         // 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析
         Configure configure = Configure.builder().bind("cM", policy).bind("targetDescription", htmlRenderPolicy).bind("compareDescription",htmlRenderPolicy).build();
-        XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map1);
+        XWPFTemplate template = null;
+        try {
+            template = XWPFTemplate.compile(filePath, configure).render(map1);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR,"未匹配到模版文件");
+        }
         return template;
     }
 
@@ -355,7 +372,12 @@ public class ReportExportService {
                 .bind("littleDirection", htmlRenderPolicy)
                 .bind("wholeDirection", htmlRenderPolicy)
                 .build();
-        XWPFTemplate template = XWPFTemplate.compile(path, configure).render(new HashMap<>());
+        XWPFTemplate template = null;
+        try {
+            template = XWPFTemplate.compile(path, configure).render(new HashMap<>());
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR,"未匹配到模版文件");
+        }
         return template;
     }
 
@@ -591,7 +613,12 @@ public class ReportExportService {
         HtmlRenderPolicy htmlRenderPolicy = new HtmlRenderPolicy();
         // 将bz设置为行循环绑定的数据源的key,即key是bz的value会在模板中的{{bz}}处进行解析
         Configure configure = Configure.builder().bind("cM", policy).bind("targetDescription", htmlRenderPolicy).build();
-        XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map);
+        XWPFTemplate template = null;
+        try {
+            template = XWPFTemplate.compile(filePath, configure).render(map);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR,"未匹配到模版文件");
+        }
         return template;
 
     }
@@ -988,7 +1015,12 @@ public class ReportExportService {
                 .bind("remark", htmlRenderPolicy)
                 .build();
         // 读取模板、数据并渲染
-        XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map);
+        XWPFTemplate template = null;
+        try {
+            template = XWPFTemplate.compile(filePath, configure).render(map);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR,"未匹配到模版文件");
+        }
         return template;
     }
 
@@ -1002,7 +1034,7 @@ public class ReportExportService {
                 patent = patentList.get(0);
             }
         } catch (Exception e) {
-            throw new IOException();
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "获取标的专利信息失败");
         }
 
         //装载单个专利的信息
@@ -1378,7 +1410,12 @@ public class ReportExportService {
                 .bind("remark", htmlRenderPolicy)
                 .build();
         // 读取模板、数据并渲染
-        XWPFTemplate template = XWPFTemplate.compile(filePath, configure).render(map);
+        XWPFTemplate template = null;
+        try {
+            template = XWPFTemplate.compile(filePath, configure).render(map);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR,"未匹配到模版文件");
+        }
         return template;
     }
 }

+ 1 - 1
src/main/java/cn/cslg/pas/service/business/ImportTaskConditionService.java

@@ -268,7 +268,7 @@ public class ImportTaskConditionService extends ServiceImpl<ImportTaskConditionM
     public Boolean removeQuartzCondition(QuartzConditionRemoveDTO quartzConditionRemoveDTO) {
         List<Integer> ids = quartzConditionRemoveDTO.getIds();
         if (ids == null || ids.size() == 0) {
-            throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK, "请选择至少一个条件");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "请选择至少一个条件");
         }
         this.removeBatchByIds(ids);
         return true;

+ 12 - 1
src/main/java/cn/cslg/pas/service/business/ImportTaskService.java

@@ -4,6 +4,7 @@ import cn.cslg.pas.common.core.base.Cycle;
 import cn.cslg.pas.common.dto.ExportTaskDTO;
 import cn.cslg.pas.common.dto.ImportTaskDTO;
 import cn.cslg.pas.common.dto.PatentStarListDTO;
+import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
 import cn.cslg.pas.common.importTask.QuartzConditionDTO;
 import cn.cslg.pas.common.model.cronModel.Personnel;
 import cn.cslg.pas.common.model.cronModel.PersonnelVO;
@@ -25,6 +26,7 @@ import cn.cslg.pas.service.MailSendService;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.common.PatentStarApiService;
 import cn.cslg.pas.service.importPatent.SchedulingTaskService;
+import cn.cslg.pas.service.importPatent.WebVOTransformService;
 import cn.cslg.pas.service.permissions.PermissionService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import com.alibaba.fastjson.JSONArray;
@@ -89,6 +91,8 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
     private MailSendService mailSendService;
     @Autowired
     private ReportProjectService reportProjectService;
+    @Autowired
+    private WebVOTransformService webVOTransformService;
 
     @Override
     public Object queryMessage(QueryRequest queryRequest) throws Exception {
@@ -663,12 +667,19 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
         importTask.setIfCreateBySys(true);
         if (importTask.getAllNum() != null && importTask.getAllNum() <= 0) {
             importTask.setState(2);
-            mailSendService.sendCycleImportTaskDoneEmail(importTask);
+            if (importTask.getAllNum() < 0) {
+                mailSendService.sendSysCycleStartEmail("任务查询专利报错,请管理员手动更正");
+            }
             importTask.insert();
         } else {
             importTask.insert();
             schedulingTaskService.startTask();
         }
+        ImportTaskAMVO importTaskAMVO = new ImportTaskAMVO();
+        importTaskAMVO.setUpdateToDate(importTask.getUpdateToDate());
+        importTaskAMVO.setUpdateCycle(updateCycle);
+        importTaskAMVO.setProjectId(project.getProjectId());
+        List<EsCustomFieldDTO> dtoList = webVOTransformService.getEsCustomFieldDTOList(importTaskAMVO);
     }
 
     public String getImportContentStr(Integer importContent, Integer taskType) {

+ 38 - 15
src/main/java/cn/cslg/pas/service/business/MergePersonService.java

@@ -19,6 +19,7 @@ import cn.cslg.pas.domain.business.FollowUp;
 import cn.cslg.pas.domain.business.MergePerson;
 import cn.cslg.pas.domain.business.SystemDict;
 import cn.cslg.pas.domain.es.*;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.UnLoginException;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.mapper.MergePersonMapper;
@@ -29,10 +30,7 @@ import cn.cslg.pas.service.query.FormatQueryService;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.PageUtil;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
-import co.elastic.clients.elasticsearch._types.FieldValue;
-import co.elastic.clients.elasticsearch._types.InlineScript;
-import co.elastic.clients.elasticsearch._types.Refresh;
-import co.elastic.clients.elasticsearch._types.Script;
+import co.elastic.clients.elasticsearch._types.*;
 import co.elastic.clients.elasticsearch._types.aggregations.*;
 import co.elastic.clients.elasticsearch._types.query_dsl.IdsQuery;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
@@ -235,7 +233,7 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
             createPatent(patent, type, list, name, num);
             Integer count = updateChild(patent, id, hit.routing());
             if (count < 0) {
-                throw new XiaoShiException("合并失败");
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "合并失败");
             }
         }
     }
@@ -267,7 +265,7 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
             createPatent(patent, type, list, name, num);
             Integer count = updateChild(patent, id, hit.routing());
             if (count < 0) {
-                throw new XiaoShiException("合并失败");
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "合并失败");
             }
         }
         return mergeId;
@@ -302,7 +300,7 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
                 .eq(MergePerson::getName, vo.getName());
         List<MergePerson> list = mergePersonMapper.selectList(wrapper);
         if (!list.isEmpty()) {
-            throw new XiaoShiException("合并名称不可重复");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "合并名称不可重复");
         }
         MergePerson person = new MergePerson();
         BeanUtils.copyProperties(vo, person);
@@ -417,7 +415,12 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
         builder.query(query);
         builder.size(1000);
         builder.trackTotalHits(TrackHits.of(i -> i.enabled(true)));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         return response.hits().hits();
     }
 
@@ -458,7 +461,12 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
         builder.query(query);
         builder.size(1000);
         builder.trackTotalHits(TrackHits.of(i -> i.enabled(true)));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         return response.hits().hits();
     }
 
@@ -527,7 +535,12 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
         }
 
         builder.trackTotalHits(i -> i.enabled(true));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         Aggregate totalAgg = response.aggregations().get("totalAgg");
         Aggregate totalAggregate = totalAgg.nested().aggregations().get("statsBucket");
         long total = totalAggregate.statsBucket().count();
@@ -877,7 +890,7 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
         // 通用添加逻辑
         String child = addChildCommon(id, joinName, mergePersonList, setter);
         if (StringUtils.isEmpty(child)) {
-            throw new XiaoShiException("添加子文档失败");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "添加子文档失败");
         }
 
         // 如果type为0,还需要额外添加一个字段
@@ -885,7 +898,7 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
             setter = setterMap.get(1); // 假设第二个字段是mergeRightHolder
             String child1 = addChildCommon(id, joinName, mergePersonList, setter);
             if (StringUtils.isEmpty(child1)) {
-                throw new XiaoShiException("添加子文档失败");
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "添加子文档失败");
             }
         }
     }
@@ -941,7 +954,12 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
         builder.query(bool);
         builder.size(1000);
         builder.trackTotalHits(TrackHits.of(i -> i.enabled(true)));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> idList = new ArrayList<>();
         for (Hit<Patent> hit : hits) {
@@ -961,7 +979,12 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
         builder.query(query);
         builder.size(1000);
         builder.trackTotalHits(TrackHits.of(i -> i.enabled(true)));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             String id = hit.id();
@@ -1061,7 +1084,7 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
             client.deleteByQuery(request);
             return 1;
         } catch (IOException e) {
-            throw new XiaoShiException("删除失败");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "删除失败");
         }
     }
 

+ 5 - 4
src/main/java/cn/cslg/pas/service/business/PDFExportFirstPageService.java

@@ -10,6 +10,7 @@ import cn.cslg.pas.common.utils.ParseByteToFileUtils;
 import cn.cslg.pas.common.vo.WebSocketMessageVO;
 import cn.cslg.pas.common.vo.business.PatentNoVO;
 import cn.cslg.pas.common.vo.es.EsCustomFieldBatchVO;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.business.es.EsCustomFieldService;
 import cn.cslg.pas.service.business.es.EsPatentService;
@@ -187,7 +188,7 @@ public class PDFExportFirstPageService {
         exportTask.setDoneNum(total - defaultNum);
         Integer taskId = importTaskService.updateExportTask(exportTask);
         if (taskId == null) {
-            throw new XiaoShiException("导出记录失败");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "导出记录失败");
         }
     }
 
@@ -244,13 +245,13 @@ public class PDFExportFirstPageService {
                     patentNos = esCustomFieldService.getPatentNos(EsVO);
                     return patentNos;
                 } catch (Exception e) {
-                    throw new XiaoShiException("");
+                    throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "");
                 }
             } else {
-                throw new XiaoShiException("入参错误");
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "入参错误");
             }
         } catch (Exception e) {
-            throw new XiaoShiException("获取专利号错误");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "获取专利号错误");
         }
     }
 

+ 114 - 17
src/main/java/cn/cslg/pas/service/business/PatentExportService.java

@@ -30,6 +30,7 @@ import cn.cslg.pas.service.business.es.EsPatentService;
 import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.common.MessageService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.aggregations.Aggregate;
 import co.elastic.clients.elasticsearch.core.SearchRequest;
 import co.elastic.clients.elasticsearch.core.SearchResponse;
@@ -160,7 +161,7 @@ public class PatentExportService {
             //根据projectId查询专利信息
             List<String> patentNos = pdfExportFirstPageService.getPatentNo(EsVO);
             if (patentNos.isEmpty()) {
-                throw new XiaoShiException("未获取到专利信息");
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "未获取到专利信息");
             }
             Integer total = patentNos.size();
             Integer defaultNum = 0;
@@ -270,7 +271,7 @@ public class PatentExportService {
             exportTask.setState(2);
             Integer taskId = importTaskService.updateExportTask(exportTask);
             if (taskId == null) {
-                throw new XiaoShiException("导出记录失败");
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "导出记录失败");
             }
             WebSocketMessageVO webSocketMessageVO = new WebSocketMessageVO();
             webSocketMessageVO.setProjectId(EsVO.getProjectId());
@@ -335,7 +336,12 @@ public class PatentExportService {
         List<Patent> patentList = new ArrayList<>();
         Records records = new Records();
         SearchRequest.Builder builder = esService.getCommonPatent(esPatentCommonVO);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         Long total = 0L;
         if (org.apache.commons.lang3.StringUtils.isNotEmpty(esPatentCommonVO.getEsField())) {
@@ -352,6 +358,35 @@ public class PatentExportService {
         return records;
     }
 
+    public Records queryPatents1(EsPatentCommonVO esPatentCommonVO) throws Exception {
+        List<PatentColumnDTO> patentList = new ArrayList<>();
+        Records records = new Records();
+        SearchRequest.Builder builder = esService.getCommonPatent(esPatentCommonVO);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
+        List<Hit<Patent>> hits = response.hits().hits();
+        Long total = 0L;
+        if (org.apache.commons.lang3.StringUtils.isNotEmpty(esPatentCommonVO.getEsField())) {
+            Aggregate aggregate = response.aggregations().get("count");
+            total = aggregate.cardinality().value();
+        } else {
+            total = response.hits().total().value();
+        }
+        records.setTotal(total);
+        for (Hit<Patent> hit : hits) {
+            String id = hit.id();
+            Patent patent = hit.source();
+            PatentColumnDTO columnDTO = esService.getPatentColumnDTO(patent, esPatentCommonVO.getProjectId(), id, "1");
+            patentList.add(columnDTO);
+        }
+        records.setData(patentList);
+        return records;
+    }
+
     @Async
     public void exportPatent2(ExportTaskDTO exportTask, ImportTaskAMVO importTaskAMVO) throws Exception {
 
@@ -362,10 +397,10 @@ public class PatentExportService {
         Integer projectId = exportTask.getProjectId();
         String createId = exportTask.getCreateId();
         if (taskId == null) {
-            throw new XiaoShiException(ExceptionEnum.BUSINESS_CHECK, "任务id不可为空");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "任务id不可为空");
         }
         if (CollectionUtils.isEmpty(selectedFields)) {
-            throw new IllegalArgumentException("没有选择要导出的字段数据");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "没有选择要导出的字段数据");
         }
 
 
@@ -418,7 +453,7 @@ public class PatentExportService {
         EsPatentCommonVO esPatentCommonVO = esService.tranPatentRequestToComVO(queryRequest);
         esPatentCommonVO.setStartNum(startNum);
         esPatentCommonVO.setEndNum(toNum);
-        Records firstRecords = this.queryPatents(esPatentCommonVO);
+        Records firstRecords = this.queryPatents1(esPatentCommonVO);
 
         Long total = 0l;
         if (startNum != null && endNum != null) {
@@ -436,14 +471,14 @@ public class PatentExportService {
         }
 
         this.updateTaskStateToDoing(taskId,total);
-        List<Patent> firstPatentList = (List<Patent>) firstRecords.getData();
-        List<String> firstPatentNos = firstPatentList.stream().map(Patent::getPatentNo).collect(Collectors.toList());
+        List<PatentColumnDTO> firstPatentList = (List<PatentColumnDTO>) firstRecords.getData();
+        List<String> firstPatentNos = firstPatentList.stream().map(PatentColumnDTO::getPatentNo).collect(Collectors.toList());
 
         //查询自定义字段
         esQueryPatentFieldsDTO.setPatentNos(firstPatentNos);
         List<EsPatentFieldsVO> firstEsPatentFieldsVOS = esCustomFieldService.getPatentFields(esQueryPatentFieldsDTO);
         for (int i = 0; i < firstPatentList.size(); i++) {
-            Patent patent = firstPatentList.get(i);
+            PatentColumnDTO patent = firstPatentList.get(i);
             if (notInNos != null && notInNos.contains(patent.getPatentNo())) {
                 continue;
             }
@@ -470,16 +505,15 @@ public class PatentExportService {
 
             esPatentCommonVO.setStartNum(startNum);
             esPatentCommonVO.setEndNum(toNum);
-            Records records = this.queryPatents(esPatentCommonVO);
+            Records records = this.queryPatents1(esPatentCommonVO);
 
-            List<Patent> patentList = (List<Patent>) records.getData();
-            List<String> patentNos = patentList.stream().map(Patent::getPatentNo).collect(Collectors.toList());
-            ;
+            List<PatentColumnDTO> patentList = (List<PatentColumnDTO>) records.getData();
+            List<String> patentNos = patentList.stream().map(PatentColumnDTO::getPatentNo).collect(Collectors.toList());
             //查询自定义字段
             esQueryPatentFieldsDTO.setPatentNos(patentNos);
             List<EsPatentFieldsVO> esPatentFieldsVOS = esCustomFieldService.getPatentFields(esQueryPatentFieldsDTO);
             for (int i = 0; i < patentList.size(); i++) {
-                Patent patent = patentList.get(i);
+                PatentColumnDTO patent = patentList.get(i);
                 if (notInNos != null && notInNos.contains(patent.getPatentNo())) {
                     continue;
                 }
@@ -497,10 +531,11 @@ public class PatentExportService {
 
         esQueryPatentFieldsDTO.setPatentNos(inNos);
         List<EsPatentFieldsVO> esPatentFieldsVOS = esCustomFieldService.getPatentFields(esQueryPatentFieldsDTO);
-        List<Patent> patentList = esPatentService.getPatentsByNo(inNos, true, null, null);
+//        List<Patent> patentList = esPatentService.getPatentsByNo(inNos, true, null, null);
+        List<PatentColumnDTO> patentList = esPatentService.getPatentsByNo1(inNos, true, null, null,projectId);
         for (int i = 0; i < patentList.size(); i++) {
 
-            Patent patent = patentList.get(i);
+            PatentColumnDTO patent = patentList.get(i);
             if (notInNos != null && notInNos.contains(patent.getPatentNo())) {
                 continue;
             }
@@ -528,7 +563,7 @@ public class PatentExportService {
             Integer reTaskId = importTaskService.updateExportTask(exportTask);
             this.sendWebSocketMessage(projectId, taskId, createId, total.intValue(), index, true);
             if (reTaskId == null) {
-                throw new XiaoShiException("导出记录失败");
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "导出记录失败");
             }
 
         }
@@ -569,6 +604,67 @@ e.printStackTrace();
         return commonCellStyle;
     }
 
+    public void loadPatentCell(PatentColumnDTO patent, List<PatentExportVO> patentExportVOS, List<PatentConfigVO> patentConfigVOS, List<EsPatentFieldsVO> esPatentFieldsVOs, HSSFSheet sheet, HSSFCellStyle commonCellStyle, Integer index) {
+
+        HSSFRow row = sheet.createRow(index + 1);
+        row.setHeight((short) 800);
+        for (int j = 0; j < patentExportVOS.size(); j++) {
+            String column = patentExportVOS.get(j).getValue();
+            String name = patentExportVOS.get(j).getName();
+            String type = patentExportVOS.get(j).getType();
+
+            List<String> types = Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
+
+            if (types.contains(type)) {
+                EsPatentFieldsVO esPatentFieldsVO = esPatentFieldsVOs.stream()
+                        .filter(item -> item.getPatentNo().equals(patent.getPatentNo()))
+                        .findFirst()
+                        .orElse(null);
+                if (esPatentFieldsVO != null) {
+                    List<InnerPatentFieldsVO> innerClassFields = esPatentFieldsVO.getInnerClassFields();
+                    if (!innerClassFields.isEmpty()) {
+                        InnerPatentFieldsVO innerPatentFieldsVO = innerClassFields.stream()
+                                .filter(item -> item.getField().equals(column) && item.getFieldType().equals(Integer.parseInt(type)))
+                                .findFirst()
+                                .orElse(null);
+                        if (innerPatentFieldsVO != null) {
+                            List<FieldValueVO> fieldValueVOS = innerPatentFieldsVO.getFieldValueVOS();
+                            if (!fieldValueVOS.isEmpty()) {
+                                StringBuffer sb = new StringBuffer();
+                                for (FieldValueVO fieldValueVO : fieldValueVOS) {
+                                    String valueStr = fieldValueVO.getValue();
+                                    sb.append(valueStr);
+                                }
+                                HSSFCell cell = row.createCell(j);
+                                ExcelUtils.setExcelCellStyle(commonCellStyle);
+                                commonCellStyle.setVerticalAlignment(VerticalAlignment.TOP);
+                                commonCellStyle.setWrapText(true);
+                                cell.setCellStyle(commonCellStyle);
+                                cell.setCellValue(sb.toString());
+
+
+                            }
+                        }
+                    }
+                }
+            } else {
+                // 使用反射获取属性值
+                Object value = GenerateObjectUtil.getPropertyValue(patent, column);
+                if (value != null) {
+                    PatentConfigVO patentConfigVO = patentConfigVOS.stream().filter(item -> item.getValue().equals(column)).findFirst().orElse(null);
+                    String exportClass = patentConfigVO.getExportClass();
+                    GetValueImp getValueImp = patentExportFactory.getClass(exportClass);
+                    if (getValueImp != null) {
+                        String reValue = getValueImp.getValue(value);
+                        HSSFCell cell = row.createCell(j);
+                        cell.setCellStyle(commonCellStyle);
+                        cell.setCellValue(reValue);
+                    }
+                }
+            }
+        }
+    }
+
     public void loadPatentCell(Patent patent, List<PatentExportVO> patentExportVOS, List<PatentConfigVO> patentConfigVOS, List<EsPatentFieldsVO> esPatentFieldsVOs, HSSFSheet sheet, HSSFCellStyle commonCellStyle, Integer index) {
 
         HSSFRow row = sheet.createRow(index + 1);
@@ -629,4 +725,5 @@ e.printStackTrace();
             }
         }
     }
+
 }

+ 4 - 4
src/main/java/cn/cslg/pas/service/business/ProductService.java

@@ -463,10 +463,8 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
         for (ProductVO productVO : productVOS) {
             //装载人员信息
             Personnel personnel = personnels.stream().filter(item -> item.getId().toString().equals(productVO.getCreateId())).findFirst().orElse(null);
-            if (personnel != null) {
+            if (ObjectUtils.isNotEmpty(personnel)) {
                 productVO.setCreateName(personnel.getPersonnelName());
-            } else {
-                throw new XiaoShiException("未获取到当前登陆人信息");
             }
             //装载文件信息
             List<AssoProductFile> assoProductFilesTemp = assoProductFiles.stream().filter(item -> item.getProductId().equals(productVO.getId())).collect(Collectors.toList());
@@ -517,7 +515,9 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
             adminWrapper.eq(AssoProductPerson::getRole, 0);
             List<AssoProductPerson> assoProductPeople = assoProductPersonService.list(adminWrapper);
             List<String> adminIds = assoProductPeople.stream().map(AssoProductPerson::getPersonId).collect(Collectors.toList());
-            adminIds.remove(personnel.getId().toString());
+            if (ObjectUtils.isNotEmpty(personnel)) {
+                adminIds.remove(personnel.getId());
+            }
             //根据管理员人员ids查询名称
             String res = permissionService.getPersonnelByIdsFromPCS(adminIds);
             JSONObject jsonObject = JSONObject.parseObject(res);

+ 45 - 7
src/main/java/cn/cslg/pas/service/business/es/EsCountService.java

@@ -14,11 +14,14 @@ import cn.cslg.pas.common.vo.business.EsAllCountVO;
 import cn.cslg.pas.common.vo.business.EsCountVO;
 import cn.cslg.pas.common.vo.es.EsDateRangeVO;
 import cn.cslg.pas.domain.es.Patent;
+import cn.cslg.pas.exception.ExceptionEnum;
+import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.EsCountAnalyseBuilderFactory.EsCountAnalysisBuilderFactory;
 import cn.cslg.pas.factorys.EsCountAnalyseBuilderFactory.IEsCountAnalysisBuilder;
 import cn.cslg.pas.service.business.CommonService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.SortOptions;
 import co.elastic.clients.elasticsearch._types.SortOrder;
 import co.elastic.clients.elasticsearch._types.aggregations.*;
@@ -174,7 +177,12 @@ public class EsCountService {
                 builder.aggregations("Agg", aggregation);
                 //解除最大条数限制
                 builder.trackTotalHits(i -> i.enabled(true));
-                SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+                SearchResponse<Patent> response = null;
+                try {
+                    response = client.search(builder.build(), Patent.class);
+                } catch (Exception e) {
+                    throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+                }
                 Aggregate agg = response.aggregations().get("Agg");
 
                 if (StringUtils.isNotEmpty(field)) {
@@ -288,7 +296,12 @@ public class EsCountService {
 
             builder.aggregations("minAgg", filtersAgg);
             builder.aggregations("maxAgg", maxFilters);
-            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+            SearchResponse<Patent> response = null;
+            try {
+                response = client.search(builder.build(), Patent.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             Aggregate minAgg = response.aggregations().get("minAgg");
             if (minAgg != null) {
                 List<FiltersBucket> list = minAgg.filters().buckets().array();
@@ -795,7 +808,12 @@ public class EsCountService {
         }
         builder.from(pageNum).size(pageSize);
         builder.trackTotalHits(i -> i.enabled(true));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         return hits.stream().map(Hit::id).collect(Collectors.toList());
     }
@@ -806,7 +824,12 @@ public class EsCountService {
         //设置查询索引
         builder.index("patent");
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         final long childCount = this.ifExistChild1(projectId, fieldId,query);
         return total - childCount;
@@ -829,7 +852,12 @@ public class EsCountService {
         } else {
             builder.query(childQ);
         }
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         return response.hits().total().value();
     }
 
@@ -846,7 +874,12 @@ public class EsCountService {
         builder.query(q);
         builder.from(pageNum).size(pageSize);
         builder.trackTotalHits(i -> i.enabled(true));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> list = new ArrayList<>();
         for (Hit<Patent> hit : hits) {
@@ -885,7 +918,12 @@ public class EsCountService {
         builder.query(bool);
         builder.from(0).size(10000);
         builder.trackTotalHits(i -> i.enabled(true));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> collect = hits.stream().map(Hit::routing).collect(Collectors.toList());
         long total = response.hits().total().value();

+ 64 - 11
src/main/java/cn/cslg/pas/service/business/es/EsCustomFieldService.java

@@ -11,11 +11,13 @@ import cn.cslg.pas.domain.business.CustomField;
 import cn.cslg.pas.domain.business.CustomOption;
 import cn.cslg.pas.domain.business.TreeNode;
 import cn.cslg.pas.domain.es.*;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.business.CustomOptionService;
 import cn.cslg.pas.service.business.TreeNodeService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.SortOrder;
 import co.elastic.clients.elasticsearch._types.aggregations.*;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
@@ -34,6 +36,7 @@ import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.io.IOException;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -63,7 +66,7 @@ public class EsCustomFieldService {
         Date createDate = new Date();
 
         if (optionType.equals(1) && (addValues == null || addValues.size() == 0)) {
-            throw new XiaoShiException("请填写值");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "请填写值");
         }
 
 
@@ -338,7 +341,12 @@ public class EsCustomFieldService {
         if (startNum > 0 && number > 0) {
             builder.from(startNum - 1).size(number);
         }
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<String> patentNos = new ArrayList<>();
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
@@ -404,7 +412,12 @@ public class EsCustomFieldService {
         builder.sort(sortOptionsBuilder -> sortOptionsBuilder
                 .field(fieldSortBuilder -> fieldSortBuilder
                         .field("custom_field.create_time").order(SortOrder.Desc)));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             List<Hit<Patent>> hits = response.hits().hits();
@@ -464,7 +477,12 @@ public class EsCustomFieldService {
 
         SearchRequest.Builder builder = new SearchRequest.Builder();
         builder.query(bool);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             id = response.hits().hits().get(0).id();
@@ -514,7 +532,12 @@ public class EsCustomFieldService {
         builder.index("patent");
         Query q = QueryBuilders.ids(i -> i.values(Arrays.asList(customFieldId)));
         builder.query(q);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             patent = response.hits().hits().get(0).source();
@@ -607,7 +630,12 @@ public class EsCustomFieldService {
 
 
         builder.query(bool);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             List<Hit<Patent>> hits = response.hits().hits();
@@ -630,7 +658,12 @@ public class EsCustomFieldService {
         Query q2 = QueryBuilders.parentId(parent -> parent.type("patent").id(patentId));
         Query bool = QueryBuilders.bool(i -> i.must(q1, q2));
         try {
-            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+            SearchResponse<Patent> response = null;
+            try {
+                response = client.search(builder.build(), Patent.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             List<Hit<Patent>> hits = response.hits().hits();
             hits.forEach(item -> {
             });
@@ -673,7 +706,12 @@ public class EsCustomFieldService {
 
             builder.size(999);
             builder.query(queries);
-            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+            SearchResponse<Patent> response = null;
+            try {
+                response = client.search(builder.build(), Patent.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             long total = response.hits().total().value();
             List<ESCustomField> esCustomFields = new ArrayList<>();
             List<InnerPatentFieldsVO> innerPatentFieldsVOS = new ArrayList<>();
@@ -830,7 +868,12 @@ public class EsCustomFieldService {
             builder.from(0).size(10000);
         }
         try {
-            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+            SearchResponse<Patent> response = null;
+            try {
+                response = client.search(builder.build(), Patent.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             long total = response.hits().total().value();
             customFiledRecord.setTotal(total);
             if (total > 0) {
@@ -861,7 +904,12 @@ public class EsCustomFieldService {
                 .field(fieldSortBuilder -> fieldSortBuilder
                         .field("custom_field.create_time").order(SortOrder.Desc)));
         try {
-            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+            SearchResponse<Patent> response = null;
+            try {
+                response = client.search(builder.build(), Patent.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             long total = response.hits().total().value();
             if (total > 0) {
                 List<Hit<Patent>> hits = response.hits().hits();
@@ -925,7 +973,12 @@ public class EsCustomFieldService {
         builder.sort(sortOptionsBuilder -> sortOptionsBuilder
                 .field(fieldSortBuilder -> fieldSortBuilder
                         .field("custom_field.create_time").order(SortOrder.Desc)));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             List<Hit<Patent>> hits = response.hits().hits();

+ 85 - 41
src/main/java/cn/cslg/pas/service/business/es/EsExportService.java

@@ -18,12 +18,14 @@ import cn.cslg.pas.domain.es.ESCustomField;
 import cn.cslg.pas.domain.es.EsProjectTask;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.PatentJoin;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.business.ImportTaskService;
 import cn.cslg.pas.service.common.PatentStarApiService;
 import cn.cslg.pas.service.importPatent.ImportSinglePatentService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.SortOptions;
 import co.elastic.clients.elasticsearch._types.SortOrder;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
@@ -289,7 +291,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         long total = response.hits().total().value();
         System.out.println("total:" + total);
@@ -336,7 +338,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> list = new ArrayList<>();
@@ -403,7 +405,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         long total = response.hits().total().value();
         System.out.println("total:" + total);
@@ -452,7 +454,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> list = new ArrayList<>();
@@ -519,7 +521,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> list = new ArrayList<>();
@@ -566,7 +568,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> list = new ArrayList<>();
@@ -584,7 +586,7 @@ public class EsExportService {
 
     public void loadExport(List<String> list) throws Exception {
         try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
-            List<String> headers = Arrays.asList("专利号");
+            List<String> headers = Arrays.asList("专利号","位数");
             HSSFWorkbook hssfWorkbook = new HSSFWorkbook();//新建工作簿
             HSSFSheet sheet = hssfWorkbook.createSheet();//新建sheet页
             sheet.setDefaultColumnWidth(30);
@@ -613,6 +615,12 @@ public class EsExportService {
                 commonCellStyle.setWrapText(true);
                 cell.setCellStyle(commonCellStyle);
                 cell.setCellValue(no);
+                HSSFCell cell1 = row.createCell(1);
+                ExcelUtils.setExcelCellStyle(commonCellStyle);
+                commonCellStyle.setVerticalAlignment(VerticalAlignment.TOP);
+                commonCellStyle.setWrapText(true);
+                cell1.setCellStyle(commonCellStyle);
+                cell1.setCellValue(no.length());
             }
             hssfWorkbook.write(out);
             byte[] bytes = out.toByteArray();
@@ -650,7 +658,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         return response.hits().total().value();
     }
@@ -682,7 +690,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         return response.hits().total().value();
     }
@@ -716,7 +724,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         List<Hit<Patent>> hits = response.hits().hits();
         List<EsExportRefreshVO> list = new ArrayList<>();
@@ -870,7 +878,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         long total = response.hits().total().value();
         if (total > 1) {
@@ -900,8 +908,10 @@ public class EsExportService {
                 .readTimeout(60, TimeUnit.SECONDS)
                 .build();
         Request request = new Request.Builder()
-                .url("http://192.168.2.107:8087/api/xiaoshi/importTask/addImportTask")
-                .addHeader("Cookie", "token=5T_nvys1wCh4QKm4t_XYSxxNz0Me6O4PrV__")
+                .url("https://xsip.cn/api/xiaoshi/importTask/addImportTask")
+//                .url("http://192.168.2.107:8087/api/xiaoshi/importTask/addImportTask")
+                .addHeader("Cookie", "_ga=GA1.1.1311128280.1715044933; _ga_73YJPXJTLX=GS1.1.1732081012.6.0.1732081012.0.0.0; token=DS_hs9LNS6qwwZsd8_wnRUpFiOw3oZjMwN__")
+//                .addHeader("Cookie", "token=5T_nvys1wCh4QKm4t_XYSxxNz0Me6O4PrV__")
                 .post(requestBody)
                 .build();
         return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
@@ -934,7 +944,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         long total = response.hits().total().value();
         System.out.println("total:" + total);
@@ -982,7 +992,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> list = new ArrayList<>();
@@ -1024,7 +1034,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         long total = response.hits().total().value();
         System.out.println("total:" + total);
@@ -1073,7 +1083,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> list = new ArrayList<>();
@@ -1096,13 +1106,22 @@ public class EsExportService {
                 }
                 String newPatentId = "";
                 if (patentNo.startsWith("CN")) {
+                    if (patentNo.length() == 13 && patentNo.contains("W")) {
+                        continue;
+                    }
                     //中国专利
                     if (patentNo.length() == 12 && patentNo.contains(".")) {
                         String newPatentNo = this.formatCnNumber(patentNo);
                         newPatentId = this.queryNewByPatentNo(newPatentNo, oldPatentId);
-                    } else if (patentNo.length() == 15){
+                    } else if (patentNo.length() == 15 && !patentNo.contains(".")){
                         String newPatentNo = this.formatNumber(patentNo);
                         newPatentId = this.queryNewByPatentNo(newPatentNo, oldPatentId);
+                    } else if (patentNo.length() == 15 && patentNo.contains(".")) {
+                        String newPatentNo = this.formatNumber1(patentNo);
+                        newPatentId = this.queryNewByPatentNo(newPatentNo, oldPatentId);
+                    } else if (patentNo.length() == 14) {
+                        String newPatentNo = this.formatNumber2(patentNo);
+                        newPatentId = this.queryNewByPatentNo(newPatentNo, oldPatentId);
                     } else {
                         newPatentId = this.queryNewByPatentNo(patentNo, oldPatentId);
                     }
@@ -1129,6 +1148,19 @@ public class EsExportService {
                 str.substring(14, 15);
     }
 
+    public String formatNumber1(String str) {
+        String s1 = str.substring(0, 7) + "0" + str.substring(7, str.indexOf("."));
+        String s2 = s1.substring(2);
+        char c = calculateChecksum(s2);
+        return s1 + "." + c;
+//        String s = str.substring(str.indexOf(".") + 1);
+//        return str.substring(0, 13) + s + ".0";
+    }
+
+    public String formatNumber2(String str) {
+        return str + ".0";
+    }
+
     public String formatCnNumber(String str) {
         StringBuilder builder = new StringBuilder();
         builder.append(str, 0, 2);
@@ -1182,7 +1214,12 @@ public class EsExportService {
             builder.index("patent");
             Query query = QueryBuilders.term(t -> t.field("patent_no.keyword").value(oldPatentNo));
             builder.query(query);
-            SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+            SearchResponse<Patent> response = null;
+            try {
+                response = client.search(builder.build(), Patent.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             List<Hit<Patent>> hits = response.hits().hits();
             if (!CollectionUtils.isEmpty(hits)) {
                 patentId = hits.get(0).id();
@@ -1198,23 +1235,28 @@ public class EsExportService {
         builder.index("patent");
         Query query = QueryBuilders.term(t -> t.field("patent_no.keyword").value(newPatentNo));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> list = new ArrayList<>();
         String newPatentId = "";
         if (!CollectionUtils.isEmpty(hits)) {
-            for (Hit<Patent> hit : hits) {
-                String patentId = hit.id();
-                if (!patentId.equals(oldPatentId)) {
-                    Patent patent = hit.source();
-                    if (!CollectionUtils.isEmpty(patent.getApplicant()) &&
-                            !CollectionUtils.isEmpty(patent.getRightHolder()) &&
-                            !CollectionUtils.isEmpty(patent.getInventor())) {
-                        newPatentId = patentId;
-                        break;
-                    }
-                }
-            }
+//            for (Hit<Patent> hit : hits) {
+//                String patentId = hit.id();
+//                if (!patentId.equals(oldPatentId)) {
+//                    Patent patent = hit.source();
+//                    if (!CollectionUtils.isEmpty(patent.getApplicant()) &&
+//                            !CollectionUtils.isEmpty(patent.getRightHolder()) &&
+//                            !CollectionUtils.isEmpty(patent.getInventor())) {
+//                        newPatentId = patentId;
+//                        break;
+//                    }
+//                }
+//            }
             if (StringUtils.isEmpty(newPatentId)) {
                 Hit<Patent> hit = hits.stream().filter(i -> !i.id().equals(oldPatentId)).findFirst().orElse(null);
                 if (ObjectUtils.isNotEmpty(hit) && hit != null) {
@@ -1223,7 +1265,7 @@ public class EsExportService {
                     newPatentId = this.queryWDExtra(newPatentNo);
 //                    Boolean flag = this.queryExtra(newPatentNo);
 //                    if (Boolean.TRUE.equals(flag)) {
-//                        this.importPatent(Collections.singletonList(newPatentNo), 614);
+//                        this.importPatent(Collections.singletonList(newPatentNo), 5473);
 //                        Thread.sleep(3000);
 //                        newPatentId = this.queryOldByPatentNo(newPatentNo);
 //                    }
@@ -1239,7 +1281,7 @@ public class EsExportService {
             newPatentId = this.queryWDExtra(newPatentNo);
 //            Boolean flag = this.queryExtra(newPatentNo);
 //            if (Boolean.TRUE.equals(flag)) {
-//                this.importPatent(Collections.singletonList(newPatentNo), 614);
+//                this.importPatent(Collections.singletonList(newPatentNo), 5473);
 //                Thread.sleep(3000);
 //                newPatentId = this.queryOldByPatentNo(newPatentNo);
 //            }
@@ -1275,6 +1317,8 @@ public class EsExportService {
         String patentId = "";
         PatentStarListDTO vo = new PatentStarListDTO();
         vo.setCurrentQuery("F XX (" + patentNo + "/PN-CN/GJ)");
+//        vo.setCurrentQuery("F XX (" + patentNo + "/AN)");
+//        vo.setDBType("CN");
         vo.setDBType("WD");
         vo.setPageNum(1);
         vo.setRowCount(10);
@@ -1324,7 +1368,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         List<Hit<Patent>> hits = response.hits().hits();
         if (!CollectionUtils.isEmpty(hits)) {
@@ -1359,7 +1403,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         List<Hit<Patent>> hits = response.hits().hits();
         if (!CollectionUtils.isEmpty(hits)) {
@@ -1396,7 +1440,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         List<Hit<Patent>> hits = response.hits().hits();
         if (!CollectionUtils.isEmpty(hits)) {
@@ -1424,7 +1468,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         List<Hit<Patent>> hits = response.hits().hits();
         if (!CollectionUtils.isEmpty(hits)) {
@@ -1459,7 +1503,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         List<Hit<Patent>> hits = response.hits().hits();
         if (!CollectionUtils.isEmpty(hits)) {
@@ -1494,7 +1538,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         List<Hit<Patent>> hits = response.hits().hits();
         if (!CollectionUtils.isEmpty(hits)) {
@@ -1520,7 +1564,7 @@ public class EsExportService {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
             e.printStackTrace();
-            throw new XiaoShiException(e.getMessage());
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
         }
         List<Hit<Patent>> hits = response.hits().hits();
         Map<String, String> map = new HashMap<>();

+ 9 - 5
src/main/java/cn/cslg/pas/service/business/es/EsFamilyService.java

@@ -18,12 +18,11 @@ import cn.cslg.pas.common.vo.business.PatentKinDetailVO;
 import cn.cslg.pas.common.vo.business.PatentKinVO;
 import cn.cslg.pas.common.vo.business.PatentNoVO;
 import cn.cslg.pas.domain.es.*;
+import cn.cslg.pas.exception.ExceptionEnum;
+import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
-import co.elastic.clients.elasticsearch._types.FieldValue;
-import co.elastic.clients.elasticsearch._types.InlineScript;
-import co.elastic.clients.elasticsearch._types.Script;
-import co.elastic.clients.elasticsearch._types.SortOrder;
+import co.elastic.clients.elasticsearch._types.*;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
 import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
 import co.elastic.clients.elasticsearch._types.query_dsl.TermsQueryField;
@@ -74,7 +73,12 @@ public class EsFamilyService {
         Query nosQuerys = QueryBuilders.bool((i -> i.should(querys)));
         Query finalQuery = QueryBuilders.bool((i -> i.must(nosQuerys, query)));
         builder.query(finalQuery);
-        SearchResponse<PatentFamilyMessage> response = client.search(builder.build(), PatentFamilyMessage.class);
+        SearchResponse<PatentFamilyMessage> response = null;
+        try {
+            response = client.search(builder.build(), PatentFamilyMessage.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<PatentFamilyMessage>> hits = response.hits().hits();
 
         for (Hit<PatentFamilyMessage> hit : hits) {

+ 9 - 7
src/main/java/cn/cslg/pas/service/business/es/EsLegalEventService.java

@@ -8,10 +8,7 @@ import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.common.PatentStarApiService;
 import cn.cslg.pas.service.importPatent.WebVOTransformService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
-import co.elastic.clients.elasticsearch._types.InlineScript;
-import co.elastic.clients.elasticsearch._types.Refresh;
-import co.elastic.clients.elasticsearch._types.Script;
-import co.elastic.clients.elasticsearch._types.WaitForActiveShards;
+import co.elastic.clients.elasticsearch._types.*;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
 import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
 import co.elastic.clients.elasticsearch.core.*;
@@ -47,7 +44,12 @@ public class EsLegalEventService {
         Query query = QueryBuilders.bool(i -> i.should(q1, q2, q3));
 
         builder.query(query);
-        SearchResponse<LegalEvent> response = client.search(builder.build(), LegalEvent.class);
+        SearchResponse<LegalEvent> response = null;
+        try {
+            response = client.search(builder.build(), LegalEvent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<LegalEvent>> hits = response.hits().hits();
         List<LegalEvent> legalEvents = new ArrayList<>();
         if (hits.size() <= 0) {
@@ -70,7 +72,7 @@ public class EsLegalEventService {
             });
 
         } catch (Exception e) {
-            throw new XiaoShiException("获得事务错误");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "获得事务错误");
         }
         return stringList;
     }
@@ -127,7 +129,7 @@ public class EsLegalEventService {
                 try {
                     String reId = this.addLegalEvent(legalEvent1);
                 } catch (Exception e) {
-                    throw new XiaoShiException(e.getMessage());
+                    throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, e.getMessage());
                 }
             });
             webVOTransformService.transLegalEvent(patent, legalEvents);

+ 166 - 41
src/main/java/cn/cslg/pas/service/business/es/EsPatentService.java

@@ -37,6 +37,7 @@ import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.permissions.PermissionService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.SortOptions;
 import co.elastic.clients.elasticsearch._types.SortOrder;
 import co.elastic.clients.elasticsearch._types.aggregations.Aggregate;
@@ -61,6 +62,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import java.io.IOException;
+import java.text.ParseException;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -108,11 +110,16 @@ public class EsPatentService {
         Query q3 = QueryBuilders.term(t -> t.field("grant_no.keyword").value(vo.getPatentNo()));
         Query query = QueryBuilders.bool(i -> i.should(q1, q2, q3));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             Patent esMess = hit.source();
-            dto = esService.getPatentColumnDTO(esMess, vo.getProjectId(), hit.id());
+            dto = esService.getPatentColumnDTO(esMess, vo.getProjectId(), hit.id(), "");
             //格式化权利要求
             List<Text> claims = dto.getClaim();
             if (claims != null && claims.size() > 0) {
@@ -149,7 +156,12 @@ public class EsPatentService {
         if (!CollectionUtils.isEmpty(queries)) {
             Query query = QueryBuilders.bool(i -> i.should(queries));
             builder.query(query);
-            SearchResponse<LegalEvent> response = client.search(builder.build(), LegalEvent.class);
+            SearchResponse<LegalEvent> response = null;
+            try {
+                response = client.search(builder.build(), LegalEvent.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             List<Hit<LegalEvent>> hits = response.hits().hits();
             for (Hit<LegalEvent> hit : hits) {
                 LegalEvent event = hit.source();
@@ -199,7 +211,12 @@ public class EsPatentService {
         Query query = QueryBuilders.hasParent(i -> i.parentType("patent").query(ids));
         Query q = QueryBuilders.bool(i -> i.must(nested, query));
         builder.query(q);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (IOException e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<PatentMergePerson> list = new ArrayList<>();
         for (Hit<Patent> hit : hits) {
@@ -228,7 +245,12 @@ public class EsPatentService {
         Query query = QueryBuilders.hasParent(i -> i.parentType("patent").query(ids));
         Query q = QueryBuilders.bool(i -> i.must(nested, query));
         builder.query(q);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (IOException e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<PatentMergePerson> list = new ArrayList<>();
         for (Hit<Patent> hit : hits) {
@@ -257,7 +279,12 @@ public class EsPatentService {
         Query query = QueryBuilders.hasParent(i -> i.parentType("patent").query(ids));
         Query q = QueryBuilders.bool(i -> i.must(nested, query));
         builder.query(q);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (IOException e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<PatentMergePerson> list = new ArrayList<>();
         for (Hit<Patent> hit : hits) {
@@ -366,7 +393,12 @@ public class EsPatentService {
         if (pageNum > 0 && pageSize > 0) {
             builder.from((pageNum - 1) * pageSize).size(pageSize);
         }
-        SearchResponse<PatentFamilyMessage> response = client.search(builder.build(), PatentFamilyMessage.class);
+        SearchResponse<PatentFamilyMessage> response = null;
+        try {
+            response = client.search(builder.build(), PatentFamilyMessage.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<PatentFamilyMessage>> hits = response.hits().hits();
         List<PatentKinDTO> kinDTOS = new ArrayList<>();
         for (Hit<PatentFamilyMessage> hit : hits) {
@@ -453,7 +485,12 @@ public class EsPatentService {
 //        if (pageNum > 0 && pageSize > 0) {
 //            builder.from((pageNum - 1) * pageSize).size(pageSize);
 //        }
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             PatentKinDTO kinDTO = new PatentKinDTO();
@@ -503,7 +540,12 @@ public class EsPatentService {
         Query bool1 = QueryBuilders.bool(i -> i.must(q, query));
         builder.query(bool1);
 
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             Patent patent = hit.source();
@@ -525,7 +567,7 @@ public class EsPatentService {
      */
     public List<Patent> getPatentsByNo(List<String> patentNos, Boolean ifGetAll, Long current, Long size) throws Exception {
         List<Patent> patentList = new ArrayList<>();
-        if(patentNos==null||patentNos.size()==0){
+        if (patentNos == null || patentNos.size() == 0) {
             return patentList;
         }
         SearchRequest.Builder builder = new SearchRequest.Builder();
@@ -554,7 +596,12 @@ public class EsPatentService {
         } else {
             builder.from(0).size(10000);
         }
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         if (hits != null && hits.size() > 0) {
             hits.forEach(item -> {
@@ -566,6 +613,56 @@ public class EsPatentService {
         return patentList;
     }
 
+    public List<PatentColumnDTO> getPatentsByNo1(List<String> patentNos, Boolean ifGetAll, Long current, Long size, Integer projectId) throws Exception {
+        List<PatentColumnDTO> patentList = new ArrayList<>();
+        if (patentNos == null || patentNos.size() == 0) {
+            return patentList;
+        }
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        //设置查询索引
+        builder.index("patent");
+        List<Query> querys = new ArrayList<>();
+        for (String patentNo : patentNos) {
+            Query q1 = QueryBuilders.term(t -> t.field("app_no.keyword").value(patentNo));
+            //公开号
+            Query q2 = QueryBuilders.term(t -> t.field("public_no.keyword").value(patentNo));
+            //授权号
+            Query q3 = QueryBuilders.term(t -> t.field("grant_no.keyword").value(patentNo));
+            Query query = QueryBuilders.bool(i -> i.should(q1, q2, q3));
+            querys.add(query);
+        }
+        Query finalQuery = QueryBuilders.bool((i -> i.should(querys)));
+        builder.query(finalQuery);
+        if (!ifGetAll) {
+            List<String> reSources = this.rePatentSource();
+            builder.source(sourceOptionsBuilder -> sourceOptionsBuilder
+                    .filter(fieldSourceBuilder -> fieldSourceBuilder
+                            .includes(reSources)));
+        }
+        if (current != null && size != null && current > 0 && size > 0) {
+            builder.from((current.intValue() - 1) * size.intValue()).size(size.intValue());
+        } else {
+            builder.from(0).size(10000);
+        }
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
+        List<Hit<Patent>> hits = response.hits().hits();
+        if (hits != null && hits.size() > 0) {
+            hits.forEach(item -> {
+                        Patent patent = item.source();
+                        String id = item.id();
+                        PatentColumnDTO columnDTO = esService.getPatentColumnDTO(patent, projectId, id, "1");
+                        patentList.add(columnDTO);
+                    }
+            );
+        }
+        return patentList;
+    }
+
 
     private List<String> rePatentSource() {
         List<String> rePatentSource = new ArrayList<>();
@@ -601,7 +698,12 @@ public class EsPatentService {
         esPatentCommonVO.setSize(null);
         SearchRequest.Builder builder = esService.getCommonPatent(esPatentCommonVO);
         Records records = new Records();
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             PatentPageMessageVO patentPageMessageVO = new PatentPageMessageVO();
@@ -655,7 +757,12 @@ public class EsPatentService {
                 .filter(fieldSourceBuilder -> fieldSourceBuilder
                         .includes(reSources)));
 
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             if (hits != null && hits.size() > 0) {
@@ -679,7 +786,12 @@ public class EsPatentService {
         builder.source(sourceOptionsBuilder -> sourceOptionsBuilder
                 .filter(fieldSourceBuilder -> fieldSourceBuilder
                         .includes(reSources)));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         return response.hits().total().value();
     }
 
@@ -763,17 +875,16 @@ public class EsPatentService {
         }
         String condition = esService.appendIdsCondition(searchCondition, taskId, productFrom, projectId, productId);
 
-        Query q =null;
-        if(condition==null||condition.trim().equals("")){
-            q =QueryBuilders.exists(i->i.field("patent_no"));
-        }
-        else {
-        //1. 解析检索条件
-        treeNode tree = expressManager.getInstance().Parse(condition, false);
-        //3. 从es中检索数据
-        q = formatQueryService.EsQueryToQuery((operateNode) tree, "patent", projectId);
+        Query q = null;
+        if (StringUtils.isEmpty(condition)) {
+            q = QueryBuilders.exists(i -> i.field("patent_no"));
+        } else {
+            //1. 解析检索条件
+            treeNode tree = expressManager.getInstance().Parse(condition, false);
+            //3. 从es中检索数据
+            q = formatQueryService.EsQueryToQuery((operateNode) tree, "patent", projectId);
         }
-        Query finalQ=q;
+        Query finalQ = q;
         Query reQuery = null;
         if (patentNos != null && patentNos.size() > 0) {
             List<Query> notInQuery = this.getNoNotInQuery(patentNos);
@@ -797,7 +908,12 @@ public class EsPatentService {
         builder.index("patent");
         Query q = QueryBuilders.ids(i -> i.values(ids));
         builder.query(q);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             patents = response.hits().hits();
@@ -820,7 +936,12 @@ public class EsPatentService {
         esPatentCommonVO.setStartNum(startNum);
         esPatentCommonVO.setEndNum(endNum);
         SearchRequest.Builder builder = esService.getCommonPatent(esPatentCommonVO);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             if ((patentNos == null || patentNos.size() == 0) || (!patentNos.contains(hit.source().getPatentNo()))) {
@@ -865,7 +986,12 @@ public class EsPatentService {
         FieldCollapse collapse = FieldCollapse.of(i -> i.field("project_id"));
         builder.collapse(collapse);
         builder.trackTotalHits(i -> i.enabled(true));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         if (hits != null && hits.size() > 0) {
             hits.forEach(item -> {
@@ -879,16 +1005,15 @@ public class EsPatentService {
     }
 
 
-
     public PatentNoWithIdVO addPatentToProject(PatentNoWithIdVO patentWithIdVO, Integer projectId) {
 
         try {
 
 
             String patentId = patentWithIdVO.getId();
-            if(patentId==null){
+            if (patentId == null) {
                 PatentWithIdVO patentWithIdVO1 = esService.getIdByPatentNo(patentWithIdVO.getPatentNo());
-                patentId =patentWithIdVO1.getId();
+                patentId = patentWithIdVO1.getId();
             }
             Boolean ifInproject = esService.searchPatent(patentId, projectId);
             if (!ifInproject) {
@@ -911,6 +1036,7 @@ public class EsPatentService {
     /**
      * lrj
      * 为导入专利向量建立的方法,不具有普遍性,其他功能勿用
+     *
      * @param queryRequest
      * @return
      * @throws Exception
@@ -933,15 +1059,14 @@ public class EsPatentService {
                         .includes(reSources)));
         //解除最大条数限制
         builder.trackTotalHits(i -> i.enabled(true));
-        Query query =null;
-        if(projectId!=null) {
-            query= QueryBuilders.hasChild(child -> child.type("project")
+        Query query = null;
+        if (projectId != null) {
+            query = QueryBuilders.hasChild(child -> child.type("project")
                     .query(org.springframework.data.elasticsearch.client.elc.QueryBuilders.matchQueryAsQuery("project_id", projectId.toString(), null, null)));
+        } else {
+            query = QueryBuilders.exists(i -> i.field("patent_no"));
         }
-        else {
-            query=QueryBuilders.exists(i->i.field("patent_no"));
-        }
-            SearchResponse<Patent> response = null;
+        SearchResponse<Patent> response = null;
         builder.query(query);
 
         if (current > 0 && size > 0) {
@@ -952,18 +1077,18 @@ public class EsPatentService {
         try {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
-            e.printStackTrace();
-            throw new XiaoShiException("检索错误,请检查检索式");
+//            e.printStackTrace();
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "检索错误,请检查检索式");
         }
         List<PatentColumnDTO> list = new ArrayList<>();
         List<Hit<Patent>> hits = response.hits().hits();
         long total = 0L;
-            total = response.hits().total().value();
+        total = response.hits().total().value();
         for (Hit<Patent> hit : hits) {
             String id = hit.id();
             Patent esMess = hit.source();
             PatentColumnDTO columnDTO = new PatentColumnDTO();
-            BeanUtils.copyProperties(esMess,columnDTO);
+            BeanUtils.copyProperties(esMess, columnDTO);
             columnDTO.setPatentId(id);
             list.add(columnDTO);
         }

+ 9 - 1
src/main/java/cn/cslg/pas/service/business/es/EsPatentVectorService.java

@@ -7,8 +7,11 @@ import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.PatentJoin;
 import cn.cslg.pas.domain.es.Text;
+import cn.cslg.pas.exception.ExceptionEnum;
+import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.common.PythonApiService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
 import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
 import co.elastic.clients.elasticsearch.core.SearchRequest;
@@ -56,7 +59,12 @@ public class EsPatentVectorService {
         Query q2 = QueryBuilders.parentId(parent -> parent.type("patent_vector").id(parentId));
         Query bool = QueryBuilders.bool(i -> i.must(q2));
         builder.query(bool);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             flag = true;

+ 21 - 4
src/main/java/cn/cslg/pas/service/business/es/EsProductPatentService.java

@@ -6,9 +6,11 @@ import cn.cslg.pas.common.vo.PatentWithIdVO;
 import cn.cslg.pas.common.vo.es.EsProductPatentVO;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.PatentJoin;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.InlineScript;
 import co.elastic.clients.elasticsearch._types.Script;
 import co.elastic.clients.elasticsearch._types.query_dsl.IdsQuery;
@@ -82,7 +84,12 @@ public class EsProductPatentService {
                 Query bool1 = QueryBuilders.bool(i -> i.must(q, query));
                 builder.query(bool1);
 
-                SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+                SearchResponse<Patent> response = null;
+                try {
+                    response = client.search(builder.build(), Patent.class);
+                } catch (Exception e) {
+                    throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+                }
                 List<Hit<Patent>> hits = response.hits().hits();
                 for (Hit<Patent> hit : hits) {
                     String id = hit.id();
@@ -101,7 +108,7 @@ public class EsProductPatentService {
             client.deleteByQuery(request);
             return 1;
         } catch (IOException e) {
-            throw new XiaoShiException("删除失败");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "删除失败");
         }
     }
 
@@ -119,7 +126,12 @@ public class EsProductPatentService {
         Query q1 = QueryBuilders.term(t -> t.field("product_id").value(productId));
         Query query = QueryBuilders.hasChild(n -> n.type("product").query(q1));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         return response.hits().total().value();
     }
 
@@ -138,7 +150,12 @@ public class EsProductPatentService {
         Query bool = QueryBuilders.bool(i -> i.must(q1,q2));
         Query query = QueryBuilders.hasChild(n -> n.type("product").query(bool));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         return response.hits().total().value();
     }
 

+ 16 - 2
src/main/java/cn/cslg/pas/service/business/es/EsQuotePatentService.java

@@ -4,7 +4,10 @@ import cn.cslg.pas.domain.es.FamilyPatent;
 import cn.cslg.pas.domain.es.PatentFamilyMessage;
 import cn.cslg.pas.domain.es.PatentQuoteMessage;
 import cn.cslg.pas.domain.es.QuotePatent;
+import cn.cslg.pas.exception.ExceptionEnum;
+import cn.cslg.pas.exception.XiaoShiException;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
 import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
 import co.elastic.clients.elasticsearch.core.SearchRequest;
@@ -15,6 +18,7 @@ import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -40,7 +44,12 @@ public class EsQuotePatentService {
         Query query = QueryBuilders.bool(i -> i.should(q1, q2, q3));
 
         builder.query(query);
-        SearchResponse<PatentQuoteMessage> response = client.search(builder.build(), PatentQuoteMessage.class);
+        SearchResponse<PatentQuoteMessage> response = null;
+        try {
+            response = client.search(builder.build(), PatentQuoteMessage.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<PatentQuoteMessage>> hits = response.hits().hits();
         Map<String, Object> reQuotePatent = new HashMap<>();
         if(hits.size()<=0){
@@ -83,7 +92,12 @@ public class EsQuotePatentService {
         Query query = QueryBuilders.bool(i -> i.should(q1, q2, q3));
 
         builder.query(query);
-        SearchResponse<PatentQuoteMessage> response = client.search(builder.build(), PatentQuoteMessage.class);
+        SearchResponse<PatentQuoteMessage> response = null;
+        try {
+            response = client.search(builder.build(), PatentQuoteMessage.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<PatentQuoteMessage>> hits = response.hits().hits();
         if(hits.size()<=0){
             return null;

+ 46 - 10
src/main/java/cn/cslg/pas/service/business/es/EsScratchWordsService.java

@@ -26,6 +26,7 @@ import cn.cslg.pas.service.business.CommonService;
 import cn.cslg.pas.service.permissions.PermissionService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.FieldValue;
 import co.elastic.clients.elasticsearch._types.Refresh;
 import co.elastic.clients.elasticsearch._types.Time;
@@ -71,7 +72,7 @@ public class EsScratchWordsService {
     public String addScratchWords(ScratchWords scratchWords) {
         String patentNo = scratchWords.getPatentNo();
         if (patentNo == null) {
-            throw new XiaoShiException("请输入专利号");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "请输入专利号");
         }
 
         Marking marking = new Marking();
@@ -81,7 +82,7 @@ public class EsScratchWordsService {
         try {
             id = this.saveToEs(marking);
         } catch (Exception e) {
-            throw new XiaoShiException("保存失败");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "保存失败");
         }
         return id;
     }
@@ -119,7 +120,12 @@ public class EsScratchWordsService {
 
         long total = 0;
         try {
-            SearchResponse<Marking> response = client.search(builder.build(), Marking.class);
+            SearchResponse<Marking> response = null;
+            try {
+                response = client.search(builder.build(), Marking.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             List<Hit<Marking>> hits = response.hits().hits();
             total = response.hits().total().value();
             for (Hit<Marking> hit : hits) {
@@ -226,7 +232,12 @@ public class EsScratchWordsService {
         builder.index("patent_marking");
         Query q = QueryBuilders.ids(i -> i.values(Arrays.asList(wordsId)));
         builder.query(q);
-        SearchResponse<Marking> response = client.search(builder.build(), Marking.class);
+        SearchResponse<Marking> response = null;
+        try {
+            response = client.search(builder.build(), Marking.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             marking = response.hits().hits().get(0).source();
@@ -316,7 +327,12 @@ public class EsScratchWordsService {
                 .bucketsPath(n -> n.single("agg._count")).build()).build();
         builder.aggregations("total", totalAggregation);
         try {
-            SearchResponse<Marking> response = client.search(builder.build(), Marking.class);
+            SearchResponse<Marking> response = null;
+            try {
+                response = client.search(builder.build(), Marking.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             Aggregate agg = response.aggregations().get("agg");
             List<Map<String, Object>> maps = new ArrayList<>();
             if (esGroupFiled.equals("mark_time")) {
@@ -425,7 +441,12 @@ public class EsScratchWordsService {
 
         long total = 0;
         try {
-            SearchResponse<Marking> response = client.search(builder.build(), Marking.class);
+            SearchResponse<Marking> response = null;
+            try {
+                response = client.search(builder.build(), Marking.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             List<Hit<Marking>> hits = response.hits().hits();
             total = response.hits().total().value();
             for (Hit<Marking> hit : hits) {
@@ -450,7 +471,12 @@ public class EsScratchWordsService {
         builder.index("patent_marking");
         Query q = QueryBuilders.ids(i -> i.values(wordsIds));
         builder.query(q);
-        SearchResponse<Marking> response = client.search(builder.build(), Marking.class);
+        SearchResponse<Marking> response = null;
+        try {
+            response = client.search(builder.build(), Marking.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         response.hits().hits().forEach(item->{markings.add(item.source());
         });
@@ -498,7 +524,12 @@ public class EsScratchWordsService {
 
         long total = 0;
         try {
-            SearchResponse<Marking> response = client.search(builder.build(), Marking.class);
+            SearchResponse<Marking> response = null;
+            try {
+                response = client.search(builder.build(), Marking.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             List<Hit<Marking>> hits = response.hits().hits();
             total = response.hits().total().value();
             for (Hit<Marking> hit : hits) {
@@ -537,7 +568,12 @@ public class EsScratchWordsService {
         builder.query(q4);
 
         try {
-            SearchResponse<Marking> response = client.search(builder.build(), Marking.class);
+            SearchResponse<Marking> response = null;
+            try {
+                response = client.search(builder.build(), Marking.class);
+            } catch (Exception e) {
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+            }
             List<Hit<Marking>> hits = response.hits().hits();
             for (Hit<Marking> hit : hits) {
                 Marking marking = hit.source();
@@ -560,7 +596,7 @@ public class EsScratchWordsService {
             client.deleteByQuery(request);
             return 1;
         } catch (IOException e) {
-            throw new XiaoShiException("删除失败");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "删除失败");
         }
     }
 }

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

@@ -33,6 +33,7 @@ import co.elastic.clients.elasticsearch._types.query_dsl.*;
 import co.elastic.clients.elasticsearch.core.*;
 import co.elastic.clients.elasticsearch.core.search.FieldCollapse;
 import co.elastic.clients.elasticsearch.core.search.Hit;
+import co.elastic.clients.elasticsearch.core.search.TrackHits;
 import co.elastic.clients.json.JsonData;
 import com.alibaba.fastjson.JSON;
 import lombok.RequiredArgsConstructor;
@@ -122,7 +123,12 @@ public class EsService {
         Query q3 = QueryBuilders.term(t -> t.field("grant_no.keyword").value(patentNo));
         Query query = QueryBuilders.bool(i -> i.should(q1, q2, q3));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (IOException e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         if (hits != null && hits.size() > 0) {
             id = hits.get(0).id();
@@ -149,7 +155,12 @@ public class EsService {
         String id = null;
         Query query = QueryBuilders.term(t -> t.field("patent_no.keyword").value(patentNo));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         if (hits != null && hits.size() > 0) {
             id = hits.get(0).id();
@@ -225,8 +236,7 @@ public class EsService {
         try {
             response = client.search(builder.build(), Patent.class);
         } catch (Exception e) {
-            e.printStackTrace();
-            throw new XiaoShiException("检索错误,请检查检索式");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
         }
         List<PatentColumnDTO> list = new ArrayList<>();
         List<Hit<Patent>> hits = response.hits().hits();
@@ -244,7 +254,7 @@ public class EsService {
             double four = Double.parseDouble(str);
             String id = hit.id();
             Patent esMess = hit.source();
-            PatentColumnDTO columnDTO = this.getPatentColumnDTO(esMess, projectId, id);
+            PatentColumnDTO columnDTO = this.getPatentColumnDTO(esMess, projectId, id, "");
             columnDTO.setScore(four);
             list.add(columnDTO);
         }
@@ -363,7 +373,12 @@ public class EsService {
         Query q2 = QueryBuilders.term(i -> i.field(field).value(key));
         Query bool = QueryBuilders.bool(i -> i.must(q1, q2));
         builder.query(bool);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         if (!CollectionUtils.isEmpty(hits)) {
             String id = hits.get(0).id();
@@ -405,7 +420,7 @@ public class EsService {
     }
 
     //装载专利清单列表的数据
-    public PatentColumnDTO getPatentColumnDTO(Patent patent, Integer projectId, String id) {
+    public PatentColumnDTO getPatentColumnDTO(Patent patent, Integer projectId, String id, String typeStr) {
         PatentColumnDTO columnDTO = new PatentColumnDTO();
         columnDTO.setPatentId(id);
         BeanUtils.copyProperties(patent, columnDTO);
@@ -451,17 +466,30 @@ public class EsService {
         if (!CollectionUtils.isEmpty(patent.getPriorities())) {
             List<Priorities> priorities = patent.getPriorities();
             List<String> priorityCountrys = priorities.stream().map(Priorities::getPriorityCountry).distinct().collect(Collectors.toList());
-            String priorityCountry = String.join("<br>", priorityCountrys);
-            columnDTO.setPriorityCountry(priorityCountry);
             List<String> priorityNos = priorities.stream().map(Priorities::getPriorityNo).distinct().collect(Collectors.toList());
-            String priorityNo = String.join("<br>", priorityNos);
-            columnDTO.setPriorityNo(priorityNo);
             List<String> priorityDates = priorities.stream().map(Priorities::getPriorityDate).distinct().collect(Collectors.toList());
-            String priorityDate = String.join("<br>", priorityDates);
-            if (priorityDate.contains("null")) {
-                columnDTO.setPriorityDate("");
+            if (StringUtils.isNotEmpty(typeStr)) {
+                String priorityCountry = String.join(",", priorityCountrys);
+                columnDTO.setPriorityCountry(priorityCountry);
+                String priorityNo = String.join(",", priorityNos);
+                columnDTO.setPriorityNo(priorityNo);
+                String priorityDate = String.join(",", priorityDates);
+                if (priorityDate.contains("null")) {
+                    columnDTO.setPriorityDate("");
+                } else {
+                    columnDTO.setPriorityDate(priorityDate);
+                }
             } else {
-                columnDTO.setPriorityDate(priorityDate);
+                String priorityCountry = String.join("<br>", priorityCountrys);
+                columnDTO.setPriorityCountry(priorityCountry);
+                String priorityNo = String.join("<br>", priorityNos);
+                columnDTO.setPriorityNo(priorityNo);
+                String priorityDate = String.join("<br>", priorityDates);
+                if (priorityDate.contains("null")) {
+                    columnDTO.setPriorityDate("");
+                } else {
+                    columnDTO.setPriorityDate(priorityDate);
+                }
             }
         }
         columnDTO.setApplicant(esPatentService.loadName(patent.getApplicant()));
@@ -690,7 +718,12 @@ public class EsService {
         optionsList.add(sortOptions);
         builder.sort(optionsList);
 
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         Map<String, ESCustomField> map = new HashMap<>();
         for (Hit<Patent> hit : hits) {
@@ -739,7 +772,7 @@ public class EsService {
         String parentId = patent.getPatentJoin().getParent();
         Integer num = this.getIds(parentId, customField.getProjectId(), customField.getTaskId(), customField.getField());
         if (num < 1) {
-            throw new XiaoShiException("子文档是否最新更新失败");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "子文档是否最新更新失败");
         }
 
         String valueField = "[";
@@ -820,7 +853,12 @@ public class EsService {
 
 
         builder.query(q -> q.hasChild(hasChildQuery.build()));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Patent> list = new ArrayList<>();
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
@@ -848,7 +886,12 @@ public class EsService {
         Query q2 = QueryBuilders.parentId(parent -> parent.type("project").id(parentId));
         Query bool = QueryBuilders.bool(i -> i.must(q1, q2));
         builder.query(bool);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             flag = true;
@@ -874,7 +917,12 @@ public class EsService {
         Query q2 = QueryBuilders.parentId(parent -> parent.type("import_task").id(parentId));
         Query bool = QueryBuilders.bool(i -> i.must(q1, q2, q3));
         builder.query(bool);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             flag = true;
@@ -923,7 +971,12 @@ public class EsService {
                 Query p = QueryBuilders.bool(i -> i.should(q1, q2, q3));
                 Query bool = QueryBuilders.bool(i -> i.must(q4, p));
                 builder.query(bool);
-                SearchResponse<PatentFamilyMessage> response = client.search(builder.build(), PatentFamilyMessage.class);
+                SearchResponse<PatentFamilyMessage> response = null;
+                try {
+                    response = client.search(builder.build(), PatentFamilyMessage.class);
+                } catch (Exception e) {
+                    throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+                }
                 long total = response.hits().total().value();
                 if (total > 0) {
                     List<FamilyPatent> list = new ArrayList<>();
@@ -1172,7 +1225,12 @@ public class EsService {
         Query q1 = QueryBuilders.term(t -> t.field("patent.app_no").value(patent.getAppNo()));
         Query bool = QueryBuilders.bool(i -> i.must(q1));
         builder.query(bool);
-        SearchResponse<PatentQuoteMessage> response = client.search(builder.build(), PatentQuoteMessage.class);
+        SearchResponse<PatentQuoteMessage> response = null;
+        try {
+            response = client.search(builder.build(), PatentQuoteMessage.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         long total = response.hits().total().value();
         if (total > 0) {
             patentQuoteMessage = response.hits().hits().get(0).source();
@@ -1271,7 +1329,12 @@ public class EsService {
         Query query = QueryBuilders.bool(i -> i.should(q1, q2, q3));
         Query bool = QueryBuilders.bool(i -> i.must(q, query));
         builder.query(bool);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         SelectClaimDTO dto = new SelectClaimDTO();
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
@@ -1318,7 +1381,12 @@ public class EsService {
         //申请号
         Query query = QueryBuilders.bool(i -> i.mustNot(queryList));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         SelectClaimDTO dto = new SelectClaimDTO();
         List<Hit<Patent>> hits = response.hits().hits();
         long value = response.hits().total().value();
@@ -1396,7 +1464,12 @@ public class EsService {
         Query q = QueryBuilders.ids(i -> i.values(ids));
         builder.size(9999);
         builder.query(q);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> list = new ArrayList<>();
         for (Hit<Patent> hit : hits) {
@@ -1418,7 +1491,7 @@ public class EsService {
             for (String patentNo : isAdd) {
                 Integer number = this.getPatent(patentNo, projectId);
                 if (number < 1) {
-                    throw new XiaoShiException("删除失败");
+                    throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "删除失败");
                 }
             }
         } else if (startNum >= 1 && endNum > 0) {
@@ -1426,7 +1499,7 @@ public class EsService {
             for (String patentNo : patentNos) {
                 Integer number = this.getPatent(patentNo, projectId);
                 if (number < 1) {
-                    throw new XiaoShiException("删除失败");
+                    throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "删除失败");
                 }
             }
         }
@@ -1444,7 +1517,12 @@ public class EsService {
         builder.query(bool);
         //解除最大条数限制
         builder.trackTotalHits(i -> i.enabled(true));
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         List<String> list = new ArrayList<>();
         for (Hit<Patent> hit : hits) {
@@ -1462,7 +1540,7 @@ public class EsService {
             client.deleteByQuery(request);
             return 1;
         } catch (IOException e) {
-            throw new XiaoShiException("删除失败");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "删除失败");
         }
     }
 
@@ -1553,6 +1631,34 @@ public class EsService {
         return query;
 
     }
+
+    public long getMergePersonCount(Integer projectId, String patentId) {
+        SearchRequest.Builder builder = new SearchRequest.Builder();
+        //设置查询索引
+        builder.index("patent");
+        //合并申请人
+        Query q = QueryBuilders.term(i -> i.field("merge_applicant.project_id").value(projectId));
+        Query query1 = QueryBuilders.nested(i -> i.path("merge_applicant").query(q));
+        //合并权利人
+        Query q1 = QueryBuilders.term(i -> i.field("merge_right_holder.project_id").value(projectId));
+        Query query2 = QueryBuilders.nested(i -> i.path("merge_right_holder").query(q1));
+        //合并发明人
+        Query q2 = QueryBuilders.term(i -> i.field("merge_inventor.project_id").value(projectId));
+        Query query3 = QueryBuilders.nested(i -> i.path("merge_inventor").query(q2));
+        Query query = QueryBuilders.bool(i -> i.should(query1, query2, query3));
+        Query idQ = QueryBuilders.ids(i -> i.values(Collections.singletonList(patentId)));
+        Query parentQ = QueryBuilders.hasParent(i -> i.parentType("patent").query(idQ));
+        Query bool = QueryBuilders.bool(i -> i.must(parentQ, query));
+        builder.query(bool);
+        builder.size(10);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
+        return response.hits().total().value();
+    }
 }
 
 

+ 8 - 1
src/main/java/cn/cslg/pas/service/business/es/EsValueCurveService.java

@@ -20,6 +20,7 @@ import cn.cslg.pas.domain.business.PermissionRecord;
 import cn.cslg.pas.domain.business.Product;
 import cn.cslg.pas.domain.business.ProductMarketData;
 import cn.cslg.pas.domain.es.Patent;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.mapper.PermissionRecordMapper;
 import cn.cslg.pas.mapper.ProductMapper;
@@ -27,6 +28,7 @@ import cn.cslg.pas.mapper.ProductMarketDataMapper;
 import cn.cslg.pas.service.business.CommonService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.SortOrder;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
 import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
@@ -346,7 +348,12 @@ public class EsValueCurveService {
                 Query bool1 = QueryBuilders.bool(i -> i.must(q,query));
                 builder.query(bool1);
 
-                SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+                SearchResponse<Patent> response = null;
+                try {
+                    response = client.search(builder.build(), Patent.class);
+                } catch (Exception e) {
+                    throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+                }
                 List<Hit<Patent>> hits = response.hits().hits();
                 for (Hit<Patent> hit : hits) {
                     Patent patent = hit.source();

+ 5 - 4
src/main/java/cn/cslg/pas/service/business/invalidReport/AssoGroupFeatureService.java

@@ -14,6 +14,7 @@ import cn.cslg.pas.common.vo.business.SplitVO;
 import cn.cslg.pas.common.vo.invalidVO.GroupFeatureHistoryVO;
 import cn.cslg.pas.domain.BaseEntity;
 import cn.cslg.pas.domain.business.*;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.mapper.InvalidReport.AssoGroupFeatureMapper;
 import cn.cslg.pas.service.business.FeatureService;
@@ -266,7 +267,7 @@ public class AssoGroupFeatureService extends ServiceImpl<AssoGroupFeatureMapper,
         //更新特征
         Boolean flag = this.updateFeatureContent(featureId, featureContent);
         if (flag.equals(false)) {
-            throw new XiaoShiException("特征不存在");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "特征不存在");
         }
         //根据特征id查询证据组合和特征关联
         LambdaQueryWrapper<AssoGroupFeature> queryWrapper = new LambdaQueryWrapper<>();
@@ -386,11 +387,11 @@ public class AssoGroupFeatureService extends ServiceImpl<AssoGroupFeatureMapper,
         for (Integer id : ids) {
             AssoGroupFeature assoGroupFeature = this.getById(id);
             if (assoGroupFeature == null) {
-                throw new XiaoShiException("证据不存在");
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "证据不存在");
 
             }
             if (domainFieldDTOS == null || domainFieldDTOS.size() == 0) {
-                throw new XiaoShiException("请输入值");
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "请输入值");
             }
             domainFieldDTOS.forEach(item -> {
                     try {
@@ -399,7 +400,7 @@ public class AssoGroupFeatureService extends ServiceImpl<AssoGroupFeatureMapper,
                             assoGroupFeature.updateById();
                         }
                     } catch (Exception e) {
-                        throw new XiaoShiException("装载失败");
+                        throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "装载失败");
                     }
             });
         }

+ 1 - 0
src/main/java/cn/cslg/pas/service/common/PersonFieldService.java

@@ -316,6 +316,7 @@ public class PersonFieldService {
                     personSelfFieldVO.setType(item.getType().toString());
                     personSelfFieldVO.setValue(item.getId().toString());
                     personSelfFieldVO.setIfPersonal(true);
+                    personSelfFieldVO.setIfSort(false);
                     personSelfFieldVO.setDefaultHidden(true);
                     fieldVOS.add(personSelfFieldVO);
                 }

+ 8 - 1
src/main/java/cn/cslg/pas/service/common/TranslateService.java

@@ -13,8 +13,10 @@ import cn.cslg.pas.domain.es.Content;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.PatentTranslate;
 import cn.cslg.pas.domain.es.Text;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.InlineScript;
 import co.elastic.clients.elasticsearch._types.Refresh;
 import co.elastic.clients.elasticsearch._types.Script;
@@ -101,7 +103,12 @@ public class TranslateService {
         builder.index("patent");
         Query query = QueryBuilders.term(t -> t.field("patent_no.keyword").value(patentNo));
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             Patent patent = hit.source();

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

@@ -359,19 +359,19 @@ public class ImportSinglePatentService {
         List<Integer> contents = refreshPatentDTO.getRefreshContent();
         Integer projectId = refreshPatentDTO.getProjectId();
         if (patentNo == null) {
-            throw new XiaoShiException("请输入专利号");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "请输入专利号");
         }
         if (contents == null || contents.size() == 0) {
-            throw new XiaoShiException("请选择导入内容");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "请选择导入内容");
         }
 
         PatentWithIdVO patentWithIdVO = esService.getIdByPatentNo(patentNo);
         if (patentWithIdVO == null) {
-            throw new XiaoShiException("专利不存在");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "专利不存在");
         }
         StarPatentVO starPatentVO = this.getPatentFromWeb(patentNo);
         if (starPatentVO == null) {
-            throw new XiaoShiException("未检索到专利");
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "未检索到专利");
         }
 
         Patent patent = new Patent();

+ 58 - 5
src/main/java/cn/cslg/pas/service/importPatent/SavePatentToEsThread.java

@@ -6,9 +6,7 @@ import cn.cslg.pas.common.utils.FormatUtil;
 import cn.cslg.pas.common.vo.ImportTaskAMVO;
 import cn.cslg.pas.common.vo.PatentWithIdVO;
 import cn.cslg.pas.domain.business.ImportTask;
-import cn.cslg.pas.domain.es.ESImportTask;
-import cn.cslg.pas.domain.es.Patent;
-import cn.cslg.pas.domain.es.PatentJoin;
+import cn.cslg.pas.domain.es.*;
 import cn.cslg.pas.service.business.CompareLiteratureService;
 import cn.cslg.pas.service.business.ImportTaskService;
 import cn.cslg.pas.service.business.es.*;
@@ -16,9 +14,11 @@ import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.common.MessageService;
 import cn.cslg.pas.service.common.PatentStarApiService;
 import cn.cslg.pas.service.common.TranslateService;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
+import org.springframework.util.CollectionUtils;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -29,6 +29,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
+import java.util.function.BiConsumer;
 
 public class SavePatentToEsThread extends Thread {
     private ApplicationContext applicationContext;
@@ -104,12 +105,50 @@ public class SavePatentToEsThread extends Thread {
                     patentId = esService.addPatent(patent);
                     orgPatent = patent;
                 }
+                if (importTaskAMVO.getProjectId() != null && StringUtils.isNotEmpty(patentId)) {
+                    long mergePersonCount = esService.getMergePersonCount(importTaskAMVO.getProjectId(), patentId);
+                    if (mergePersonCount < 1) {
+                        //合并申请人
+                        if (!CollectionUtils.isEmpty(orgPatent.getApplicant())) {
+                            List<PatentMergePerson> mergeAppPerson = this.createMergePerson(orgPatent.getApplicant(), importTaskAMVO.getProjectId());
+                            Patent newPatent = new Patent();
+                            newPatent.setMergeApplicant(mergeAppPerson);
+                            PatentJoin patentJoin = new PatentJoin();
+                            patentJoin.setParent(patentId);
+                            patentJoin.setName("merge_applicat");
+                            newPatent.setPatentJoin(patentJoin);
+                            esService.addChildPatent(newPatent, patentId);
+                        }
+                        //合并权利人
+                        if (!CollectionUtils.isEmpty(orgPatent.getRightHolder())) {
+                            List<PatentMergePerson> mergeAppPerson = this.createMergePerson(orgPatent.getRightHolder(), importTaskAMVO.getProjectId());
+                            Patent newPatent = new Patent();
+                            newPatent.setMergeRightHolder(mergeAppPerson);
+                            PatentJoin patentJoin = new PatentJoin();
+                            patentJoin.setParent(patentId);
+                            patentJoin.setName("merge_right_holder");
+                            newPatent.setPatentJoin(patentJoin);
+                            esService.addChildPatent(newPatent, patentId);
+                        }
+                        //合并发明人
+                        if (!CollectionUtils.isEmpty(orgPatent.getInventor())) {
+                            List<PatentMergePerson> mergeAppPerson = this.createMergePerson(orgPatent.getInventor(), importTaskAMVO.getProjectId());
+                            Patent newPatent = new Patent();
+                            newPatent.setMergeInventor(mergeAppPerson);
+                            PatentJoin patentJoin = new PatentJoin();
+                            patentJoin.setParent(patentId);
+                            patentJoin.setName("merge_inventor");
+                            newPatent.setPatentJoin(patentJoin);
+                            esService.addChildPatent(newPatent, patentId);
+                        }
+                    }
+                }
                 //判断是否和专题库或报告关联
                 ImportTaskAMVO importTaskAMVO = taskThread.getImportTaskAMVO();
 
                 //添加专利向量信息
                 EsPatentVectorService esPatentVectorService = applicationContext.getBean(EsPatentVectorService.class);
-                 esPatentVectorService.asyncAddPatentVector(orgPatent,patentId);
+                esPatentVectorService.asyncAddPatentVector(orgPatent, patentId);
                 //和专题库或报告进行关联
                 if (importTaskAMVO.getProjectId() != null) {
 
@@ -134,7 +173,7 @@ public class SavePatentToEsThread extends Thread {
 
                         //添加报告对比文件
                         CompareLiteratureService compareLiteratureService = applicationContext.getBean(CompareLiteratureService.class);
-                        compareLiteratureService.addCompareLiteratureToProject(importTaskAMVO,patent);
+                        compareLiteratureService.addCompareLiteratureToProject(importTaskAMVO, patent);
 
 
                     }
@@ -220,6 +259,20 @@ public class SavePatentToEsThread extends Thread {
         }
     }
 
+    private List<PatentMergePerson> createMergePerson(List<PatentPerson> personList, Integer projectId) {
+        List<PatentMergePerson> mergePersonList = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(personList)) {
+            for (PatentPerson person : personList) {
+                PatentMergePerson merge = new PatentMergePerson();
+                merge.setName(person.getName());
+                merge.setType(person.getType());
+                merge.setOrder(person.getOrder());
+                merge.setProjectId(String.valueOf(projectId));
+                mergePersonList.add(merge);
+            }
+        }
+        return mergePersonList;
+    }
 
     public void setIfProductAll(Boolean ifProductAll) {
         this.ifProductAll = ifProductAll;

+ 3 - 1
src/main/java/cn/cslg/pas/service/quartzService/SysImportPatentJobService.java

@@ -17,6 +17,7 @@ import org.quartz.JobDataMap;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.springframework.scheduling.quartz.QuartzJobBean;
+import org.springframework.stereotype.Service;
 
 import java.time.LocalDate;
 import java.util.ArrayList;
@@ -26,6 +27,7 @@ import java.util.stream.Collectors;
 
 @DisallowConcurrentExecution
 @RequiredArgsConstructor
+@Service
 public class SysImportPatentJobService extends QuartzJobBean {
     private final ImportTaskConditionService importTaskConditionService;
     private final ImportTaskService importTaskService;
@@ -35,7 +37,7 @@ public class SysImportPatentJobService extends QuartzJobBean {
     @Override
     public void executeInternal(JobExecutionContext context) throws JobExecutionException {
 
-        mailSendService.sendSysCycleStartEmail();
+        mailSendService.sendSysCycleStartEmail("系统监控任务开始");
         System.out.println("task start");
         this.addChinesePatent();
 

+ 2 - 1
src/main/java/cn/cslg/pas/service/query/FormatQueryService.java

@@ -11,6 +11,7 @@ import cn.cslg.pas.common.utils.StringUtils;
 import cn.cslg.pas.common.utils.parseQueryToTree.*;
 import cn.cslg.pas.common.vo.EsConfigVO;
 import cn.cslg.pas.exception.ConditionException;
+import cn.cslg.pas.exception.ExceptionEnum;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.EsBuilderFactory.EsBuilderFactory;
 import cn.cslg.pas.factorys.EsBuilderFactory.IQueryBuilder;
@@ -275,7 +276,7 @@ public class FormatQueryService {
                 //格式化检索式
                 sql1 = this.ToString2((operateNode) tree, null, tableName);
             } catch (Exception e) {
-                throw new ConditionException("检索式错误");
+                throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "检索式错误");
             }
         }
 

BIN
src/main/resources/file/reportTemple/FTOTemplate1-chinese.docx


+ 8 - 2
src/main/resources/jsons/patent.json

@@ -292,8 +292,7 @@
     "ifStats": "false",
     "ifAsCondition": "false",
     "groupBy": "company",
-    "ifSort": "false",
-    "exportClass": "getNameValue"
+    "ifSort": "false"
   },
   {
     "name": "权利人",
@@ -1349,6 +1348,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifSort": "false",
     "ifAsCondition": "true"
   },
   {
@@ -1361,6 +1361,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifSort": "false",
     "ifAsCondition": "true"
   },
   {
@@ -1373,6 +1374,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifSort": "false",
     "ifAsCondition": "true"
   },
   {
@@ -1385,6 +1387,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifSort": "false",
     "ifAsCondition": "true"
   },
   {
@@ -1397,6 +1400,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifSort": "false",
     "ifAsCondition": "true"
   },
   {
@@ -1409,6 +1413,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifSort": "false",
     "ifAsCondition": "false"
   },
   {
@@ -1421,6 +1426,7 @@
     "ifSearch": "false",
     "ifGroup": "false",
     "ifShow": "false",
+    "ifSort": "false",
     "ifAsCondition": "true"
   }
 ]

+ 2 - 2
src/main/resources/mapper/PatentProjectMapper.xml

@@ -2,7 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="cn.cslg.pas.mapper.PatentProjectMapper">
     <select id="getPatentProject" resultType="cn.cslg.pas.common.vo.business.PatentProjectVO">
-        select * from ( select p.id as id,p.name as name ,p.contract_no as contract_no,p.volume_number as
+        select * from ( select p.id as id,p.name as name ,p.contract_no as contractNo,p.volume_number as
         volumeNumber,p.tenant_id as tenantId,p.commission_case_day as commissionCaseDay,p.description as description,p.create_id as
         createId,p.create_time as createTime,pp.if_update as ifUpdate,pp.crons as crons,pp.status as status,pp.update_cycle as updateCycle,
         p.entrust_type as entrustType,p.entrust_id as entrustId,p.head_id as headId,p.department_id as departmentId,
@@ -22,7 +22,7 @@
 
 
     <select id="getPatentProjectCount" resultType="java.lang.Long">
-        select count(*) from (select p.id as id,p.name as name ,p.contract_no as contract_no,p.volume_number as
+        select count(*) from (select p.id as id,p.name as name ,p.contract_no as contractNo,p.volume_number as
         volumeNumber,p.tenant_id as tenantId,p.commission_case_day as commissionCaseDay,p.description as description,p.create_id as
         createId,p.create_time as createTime,pp.if_update as ifUpdate,pp.crons as crons,pp.status as status,pp.update_cycle as updateCycle,
         p.entrust_type as entrustType,p.entrust_id as entrustId,p.head_id as headId,p.department_id as departmentId,

+ 40 - 30
src/test/java/cn/cslg/pas/service/EventServiceTests.java

@@ -23,6 +23,9 @@ import cn.cslg.pas.controller.PatentController;
 import cn.cslg.pas.domain.es.FamilyPatent;
 import cn.cslg.pas.domain.es.Patent;
 import cn.cslg.pas.domain.es.PatentFamilyMessage;
+import cn.cslg.pas.domain.es.PatentPerson;
+import cn.cslg.pas.exception.ExceptionEnum;
+import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.mapper.AssoProjectEventMapper;
 import cn.cslg.pas.service.business.MergePersonService;
 import cn.cslg.pas.service.business.ProductMarketDataService;
@@ -34,6 +37,7 @@ import cn.cslg.pas.service.common.TranslateService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import cn.hutool.core.util.IdUtil;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
 import co.elastic.clients.elasticsearch.core.SearchRequest;
 import co.elastic.clients.elasticsearch.core.SearchResponse;
@@ -626,7 +630,12 @@ public class EventServiceTests {
         treeNode tree = expressManager.getInstance().Parse(s, false);
         Query query = formatQueryService.EsQueryToQuery((operateNode) tree, "patent", 331);
         builder.query(query);
-        SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
+        SearchResponse<Patent> response = null;
+        try {
+            response = client.search(builder.build(), Patent.class);
+        } catch (Exception e) {
+            throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
+        }
         final List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {
             System.out.println(1);
@@ -813,10 +822,28 @@ public class EventServiceTests {
 
     @Test
     public void test118() throws Exception {
-        esExportService.getCNPatentNO();
-        System.out.println("--------------------finished-------------------");
+//        esExportService.getCNPatentNO();
+//        System.out.println("--------------------finished-------------------");
+//        String s = "CN00109126.3";
+//        System.out.println(s.length());
+//        final String s1 = esExportService.formatCnNumber(s);
+//        System.out.println(s1);
+
+        List<String> list = new ArrayList<>();
+        list.add("US62543082P0");
+//        list.add("CN201980102379.8");
+//        list.add("CN20121040471.2");
+        esExportService.formatPatentNO(list);
+//        String s = "CN20121014770.8";
+//        String s1 = s.substring(0, 7) + "0" + s.substring(7, s.indexOf("."));
+//        String s2 = s1.substring(2);
+//        char c = calculateChecksum(s2);
+//        String s3 = s1 + "." + c;
+//        System.out.println(s3);
+
     }
 
+
     @Test
     public void test119() throws Exception {
 //        esExportService.timingImportPatent();
@@ -833,7 +860,8 @@ public class EventServiceTests {
 //        final String s = esExportService.get("CN104276485A1");
 //        System.out.println(s);
 //        final String deficency = esExportService.getCNDeficency("CN202420077302.8");
-//        esExportService.getCNNum();
+//        final Long cnNumber = esExportService.getCNNumber();
+//        System.out.println(cnNumber);
 //        final Long worldNumber = esExportService.getWorldNumber();
 //        System.out.println("--------------------finished-------------------");
         // CN 19 998 00 15538.2     CN199910027176.0
@@ -862,8 +890,9 @@ public class EventServiceTests {
 //
 //        }
 //        System.out.println("AAA:" + builder);
-//        esExportService.cnPatent();
-        esExportService.worldPatent();
+        esExportService.cnPatent();
+//        esExportService.worldPatent();
+//        esExportService.getWOErrorPatent();
 
 //        PatentStarListDTO vo = new PatentStarListDTO();
 //        vo.setCurrentQuery("F XX (WO2023051704A1/PN-CN/GJ)");
@@ -885,29 +914,10 @@ public class EventServiceTests {
 //        esExportService.formatPatentNO(list);
     }
 
-
-    public char calculateChecksum(String input) {
-        int sum = 0;
-        int[] weights = {2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5};
-
-        // 遍历字符串中的每个字符,并计算乘积之和
-        for (int i = 0; i < input.length(); i++) {
-            char digit = input.charAt(i);
-            int num = Character.getNumericValue(digit);
-            sum += num * weights[i];
-        }
-
-        // 计算总和除以11的余数
-        int remainder = sum % 11;
-
-        // 根据余数确定校验位
-        char checksum;
-        if (remainder < 10) {
-            checksum = (char) ('0' + remainder);
-        } else {
-            checksum = 'X';
-        }
-
-        return checksum;
+    @Test
+    public void test120() throws Exception {
+        final long count = esService.getMergePersonCount(320, "fbLUhY8BdwlBaY8vCspo");
+        System.out.println(count);
     }
+
 }

+ 39 - 0
src/test/java/cn/cslg/pas/test/QuartzTaskTests.java

@@ -0,0 +1,39 @@
+package cn.cslg.pas.test;
+
+import cn.cslg.pas.common.utils.GenerateObjectUtil;
+import cn.cslg.pas.controller.AvoidDesignController;
+import cn.cslg.pas.service.MailSendService;
+import cn.cslg.pas.service.business.AvoidDesignService;
+import cn.cslg.pas.service.quartzService.SysImportPatentJobService;
+import cn.cslg.pas.service.test.*;
+import cn.hutool.crypto.SecureUtil;
+import com.alibaba.fastjson.JSONObject;
+import org.checkerframework.checker.units.qual.A;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Author xiexiang
+ * @Date 2023/12/5
+ */
+@SpringBootTest
+public class QuartzTaskTests {
+    @Autowired
+    private MailSendService mailSendService;
+    @Autowired
+    private SysImportPatentJobService sysImportPatentJobService;
+    @Test
+    public void testUpdate() {
+        mailSendService.sendSysCycleStartEmail("任务查询专利报错,请管理员手动更正");
+    }
+
+
+    @Test
+    public void testUpdate2() {
+        sysImportPatentJobService.addChinesePatent();
+    }
+}