瀏覽代碼

7/8 韶音修改

lwhhszx 1 年之前
父節點
當前提交
a06b633b00

+ 23 - 0
src/main/java/cn/cslg/pas/common/core/GlobalExceptionHandler.java

@@ -0,0 +1,23 @@
+package cn.cslg.pas.common.core;
+
+import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.exception.XiaoShiException;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.context.request.WebRequest;
+
+@ControllerAdvice
+public class GlobalExceptionHandler {
+
+    @ExceptionHandler(value = {Exception.class})
+    @ResponseBody
+    public Response handleAllExceptions(XiaoShiException ex) {
+        // 返回一个包含错误信息的 HTTP 响应
+        return Response.error(ex.getErrorCode(), ex.getErrorMessage());
+    }
+
+}

+ 1 - 0
src/main/java/cn/cslg/pas/common/core/annotation/LoggerAspect.java

@@ -53,6 +53,7 @@ public class LoggerAspect {
             String str3="异常方法:" + (joinPoint.getTarget().getClass().getName() + "." + joinPoint.getSignature().getName() + "()");
             String str4="请求参数:" + params; System.out.println("异常代码:" + e.getClass().getName());
    log.error(str1+"\r"+str2+"\r"+str3+"\r"+str4);
+   log.error(e.getMessage());
         }catch (Exception ex){
             //记录本地异常日志
             log.error("==异常通知异常==");

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

@@ -5,6 +5,8 @@ import cn.cslg.pas.common.core.base.RedisConf;
 import cn.cslg.pas.common.model.cronModel.PersonnelVO;
 
 import cn.cslg.pas.common.vo.business.AllCustomFieldVO;
+import cn.cslg.pas.exception.ExceptionEnum;
+import cn.cslg.pas.exception.XiaoShiException;
 import cn.dev33.satoken.exception.NotLoginException;
 import cn.hutool.core.lang.tree.Tree;
 import cn.hutool.core.util.IdUtil;
@@ -28,7 +30,7 @@ public class CacheUtils {
     public PersonnelVO getLoginUser(Object userId) {
         String json = redisUtil.get(RedisConf.LOGIN_USER + RedisConf.SYMBOL_COLON + userId);
         if (StringUtils.isEmpty(json)) {
-            throw new NotLoginException("无数据", "user", "");
+            throw new XiaoShiException(ExceptionEnum.LOGIN_NO_LOGIN,"未登录");
         } else {
             return com.alibaba.fastjson2.JSONObject.parseObject(json, PersonnelVO.class);
         }

+ 8 - 0
src/main/java/cn/cslg/pas/common/utils/Response.java

@@ -76,6 +76,14 @@ public class Response {
         return response;
     }
 
+
+    public static Response error(String code,String message) {
+        Integer erCode= Integer.parseInt(code);
+        Response response = new Response();
+        response.setCode(erCode);
+        response.setMessage(message);
+        return response;
+    }
     public static Response noPermissions(String message) {
         Response response = new Response();
         response.setCode(ResponseEnum.NO_PERMISSION.getCode());

+ 81 - 0
src/main/java/cn/cslg/pas/exception/ExceptionEnum.java

@@ -0,0 +1,81 @@
+package cn.cslg.pas.exception;
+
+import lombok.Getter;
+
+@Getter
+public enum ExceptionEnum {
+    LOGIN_NO_LOGIN("401","未登录"),
+    LOGIN_ACCOUNT_MISTAKE("402","账号错误"),
+    LOGIN_PASWORD_MISTAKE("403","密码错误"),
+    LOGIN_ERROR("405","登录错误"),
+    LOGIN_INVITE_ERROR("406","邀请码错误"),
+
+    PERMISSION_ERROR("601","无权限"),
+    PERMISSION_NO_VIP("606","未开会员"),
+    PERMISSION_BEYOND_USETIME("607","超过使用次数"),
+
+    BUSINESS_ERROR("708","业务错误"),
+    BUSINESS_CHECK("709","参数校验错误"),
+
+
+    NO_NEED_PAY("901","支付成功"),
+
+
+
+
+
+    /*APP端 100000-300000*/
+    SUCCESS("000000", "调用成功"),
+    PARAMETER_VERIFICATION_ERROR("000001", "数据参数校验异常"),
+    PHONE_FORMAT_ERROR("000002","手机号格式错误"),
+
+    VERIFY_CODE("10001", "校验码失效"),
+    CODE_WRONG("10002","验证码错误"),
+    INIT_GENERICITY_BEAN_ERROR("10003","泛型实例化异常"),
+    THE_PHONE_CANNOT_BE_EXIST("10004","手机号已存在"),
+    THE_LOG_OUT("10004","未登录"),
+    THE_CODE_IS_NOT_NULL("10006","验证码不能为空"),
+
+    //异常20000
+    THE_PARAMETER_EXCEPTION("20001", "参数异常,请传入数据"),
+    THE_GET_INFORMATION_TOKEN_INVALID("20002", "获取用户信息token失效"),
+    THE_FAIL_TO_DELETE("20003", "删除失败"),
+
+    //业务异常
+    THE_PRODUCT_CATEGORY_NAME_IS_EXIST("607", "产品类别名称已存在"),
+    THE_LOG_INVALID_NEED_LOGIN_AGAIN("606","登录失效,请重新登录"),
+
+
+
+
+
+
+
+
+
+    SYSTEM_ERROR("999999", "系统异常");
+
+    private String code;// 异常代码
+    private String message;// 异常信息
+
+    ExceptionEnum(String code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+}

+ 25 - 1
src/main/java/cn/cslg/pas/exception/XiaoShiException.java

@@ -7,9 +7,33 @@ package cn.cslg.pas.exception;
  * @Date 2023/3/7
  */
 public class XiaoShiException extends RuntimeException {
-
+    private String errorCode;// 异常代码
+    private String errorMessage;// 异常信息
     public XiaoShiException(String message) {
         super(message);
     }
 
+    public XiaoShiException(ExceptionEnum e, String errorMessage) {
+        super(errorMessage);
+        this.errorCode = e.getCode();
+        this.errorMessage = errorMessage;
+    }
+
+
+    public String getErrorCode() {
+        return errorCode;
+    }
+
+    public void setErrorCode(String errorCode) {
+        this.errorCode = errorCode;
+    }
+
+    public String getErrorMessage() {
+        return errorMessage;
+    }
+
+    public void setErrorMessage(String errorMessage) {
+        this.errorMessage = errorMessage;
+    }
+
 }

+ 3 - 0
src/main/java/cn/cslg/pas/service/business/PatentProjectService.java

@@ -690,6 +690,9 @@ public class PatentProjectService extends ServiceImpl<PatentProjectMapper, Paten
             String res = fileManagerService.getSystemFileFromFMS(guids);
 
             systemFiles = JSONObject.parseArray(res, SystemFile.class);
+            if(systemFiles==null){
+                systemFiles=new ArrayList<>();
+            }
         }
 
         //查询客户名称

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

@@ -135,6 +135,7 @@ public class PatentStarApiService {
                 PatentStarListDTO.setFormed(true);
             }
         } catch (Exception e) {
+            e.printStackTrace();
             return null;
         }
         JSONObject configObject = this.getConfigObject(4, 1);

+ 42 - 7
src/main/java/cn/cslg/pas/service/importPatent/SavePatentToEsThread.java

@@ -40,7 +40,8 @@ public class SavePatentToEsThread extends Thread {
     private TaskThread taskThread;
     private ImportTaskAMVO importTaskAMVO;
     private Boolean ifProductAll = false;
-    private Integer i=0;
+    private Integer i = 0;
+
     @Override
     public void run() {
         while ((!ifProductAll || uploadPatentWebDTOS.size() > 0) && importTaskAMVO.getState().equals(1)) {
@@ -52,7 +53,7 @@ public class SavePatentToEsThread extends Thread {
                 }
             } catch (Exception e) {
             }
-            if(uploadPatentWebDTOS.size()==0){
+            if (uploadPatentWebDTOS.size() == 0) {
                 break;
             }
             UploadPatentWebDTO uploadPatentWebDTO = uploadPatentWebDTOS.remove(0);
@@ -63,10 +64,14 @@ public class SavePatentToEsThread extends Thread {
                 PatentWithIdVO patentWithIdVO = esService.getIdByPatentNo(patent.getPatentNo());
                 String patentId = null;
                 // 若查出专利则更新
-                Patent orgPatent =null;
+                Patent orgPatent = null;
+
+
+                //更新专利
                 if (patentWithIdVO != null) {
                     patentId = patentWithIdVO.getId();
-                   orgPatent = patentWithIdVO.getPatent();
+                    orgPatent = patentWithIdVO.getPatent();
+                    patent = this.formPatent(patent, orgPatent);
                     BeanUtils.copyProperties(patent, orgPatent, FormatUtil.getNullPropertyNames(patent));
                     esService.updatePatent(orgPatent, patentWithIdVO.getId());
                 } else {
@@ -74,7 +79,7 @@ public class SavePatentToEsThread extends Thread {
                     patentJoin.setName("patent");
                     patent.setPatentJoin(patentJoin);
                     patentId = esService.addPatent(patent);
-                    orgPatent= patent;
+                    orgPatent = patent;
                 }
                 //判断是否和专题库或报告关联
                 ImportTaskAMVO importTaskAMVO = taskThread.getImportTaskAMVO();
@@ -85,7 +90,7 @@ public class SavePatentToEsThread extends Thread {
                     if (patentId != null) {
                         Boolean ifInproject = esService.searchPatent(patentId, importTaskAMVO.getProjectId());
                         if (!ifInproject) {
-                            System.out.println("多添加的专利:"+patent.getPatentNo());
+                            System.out.println("多添加的专利:" + patent.getPatentNo());
                             Patent patentChild = new Patent();
                             PatentJoin patentJoin = new PatentJoin();
                             patentJoin.setParent(patentId);
@@ -181,7 +186,7 @@ public class SavePatentToEsThread extends Thread {
             UploadPatentWebDTO uploadPatentWebDTO1 = new UploadPatentWebDTO();
             BeanUtils.copyProperties(uploadPatentWebDTO, uploadPatentWebDTO1);
             i++;
-     System.out.println("添加了"+i);
+            System.out.println("添加了" + i);
             uploadPatentWebDTOS.add(uploadPatentWebDTO1);
             if (taskLock.tryLock()) {
                 taskCondition.signalAll();
@@ -202,4 +207,34 @@ public class SavePatentToEsThread extends Thread {
     }
 
 
+    public Patent formPatent(Patent patent, Patent orgPatent) {
+        String publicNo = patent.getPublicNo();
+        String grantNo = patent.getGrantNo();
+        if (patent.getPatentNo().startsWith("CN")) {
+            if (patent.getPublicNo() != null) {
+                if (patent.getPublicNo().endsWith("B")) {
+                    grantNo = patent.getPublicNo();
+                }
+            }
+            if (patent.getGrantNo() != null) {
+                if (patent.getGrantNo().endsWith("A")) {
+                    publicNo = patent.getGrantNo();
+                }
+            }
+
+            patent.setPublicNo(publicNo);
+            patent.setGrantNo(grantNo);
+
+            if (orgPatent.getClaim() != null && orgPatent.getClaim().size() > 0 && orgPatent.getGrantNo() != null && patent.getGrantNo() == null) {
+                patent.setClaim(orgPatent.getClaim());
+            }
+            if(orgPatent.getGrantNo()!=null){
+                patent.setGrantFullText(patent.getPublicFullText());
+                patent.setPublicFullText(null);
+            }
+        }
+
+return  patent;
+    }
+
 }

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

@@ -538,9 +538,13 @@ public class FormatQueryService {
            valueNode leftValue = (valueNode) Left;
        return   this.getQueryValue(Right,tableName,leftValue.getvalue(),this.getNodeStrCode(operate1));
         }
-      else if(operate1.gettype()==enuType.Logic)
+      else if(operate1.gettype()==enuType.Logic&&operate1.getoperateValue()==1)
         {
-      return "("+ this.webQueryToString2(Left,tableName)+this.getNodeStrCode(operate1)+this.webQueryToString2(Right,tableName)+")";
+      return "("+"/TI"+this.getNodeStrCode(operate1)+this.webQueryToString2(Right,tableName)+")";
+        }
+        else if(operate1.gettype()==enuType.Logic)
+        {
+            return "("+ this.webQueryToString2(Left,tableName)+this.getNodeStrCode(operate1)+this.webQueryToString2(Right,tableName)+")";
         }
       return null;
     }
@@ -562,6 +566,9 @@ public class FormatQueryService {
             treeNode Left = operatenode.getLeft();
             treeNode Right = operatenode.getRight();
             operate operate1 =  operatenode.getoperate();
+            if(operate1.getoperateValue()==1){
+                return "("+"/TI"+this.getNodeStrCode(operate1)+this.getQueryValue(Right,tableName,field,option)+")";
+            }
       return "("+this.getQueryValue(Left,tableName,field,option)+this.getNodeStrCode(operate1)+this.getQueryValue(Right,tableName,field,option)+")";
         }
 

+ 3 - 3
src/main/resources/application-dev.yml

@@ -61,12 +61,12 @@ spring:
     #初始化表结构
     jdbc:
       initialize-schema: always
-authorUrl: http://localhost:8871
-PCSUrl: http://localhost:8871
+authorUrl: http://localhost:8885
+PCSUrl: http://localhost:8885
 #OPSUrl: http://192.168.2.24:5001
 OPSUrl: http://139.224.24.90:5001
 PASUrl: http://localhost:8879
-FMSUrl: http://192.168.2.24:8803
+FMSUrl: http://localhost:8803
 FileSource: 1
 ES:
   patentVector: patent_vector