Bläddra i källkod

7/8 韶音修改

lwhhszx 1 år sedan
förälder
incheckning
d4b966ee1d

+ 17 - 0
src/main/java/cn/cslg/pas/common/utils/PatentNoUtil.java

@@ -25,4 +25,21 @@ public class PatentNoUtil {
             throw new IllegalArgumentException("Invalid patent number format: " + patentNo);
         }
     }
+
+
+    public static String formatApNo(String patentNo){
+        Pattern patternEn = Pattern.compile("^[A-Za-z]{2}.*");
+        Matcher matcher = patternEn.matcher(patentNo);
+        if(!matcher.find()){
+            patentNo ="CN"+patentNo;
+        }
+        String numbers = patentNo.replaceAll("[^\\d]", "");
+        char secondLastChar = patentNo.charAt(patentNo.length() - 2);
+        if(numbers.length()==13&&secondLastChar!='.'){
+            StringBuilder stringBuilder =new StringBuilder(patentNo);
+            stringBuilder.insert(patentNo.length() - 1,".");
+            patentNo =stringBuilder.toString();
+        }
+        return patentNo;
+    }
 }

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

@@ -43,13 +43,6 @@ public class expressManager {
         oOR.operateValue = 2;
         hSymbols.put(oOR.Code, oOR);
 
-        oOR = new operate();
-        oOR.Code = "~";
-        oOR.ShowName = "TO";
-        oOR.type = enuType.Logic;
-        oOR.priorityVale = 21;
-        oOR.operateValue = 2;
-        hSymbols.put(oOR.Code, oOR);
 
         oOR = new operate();
         oOR.Code = "=";
@@ -398,7 +391,6 @@ public class expressManager {
                         }
                         break;
                     case '=':
-                    case '~':
                     case '>':
                     case '>':
                     case '<':

+ 0 - 1
src/main/java/cn/cslg/pas/controller/InvalidStatutesController.java

@@ -98,7 +98,6 @@ public class InvalidStatutesController {
     public Response importFinalInvalidStatues(Integer id) {
         try {
            finalInvalidStatueService.importFinalInvalidStatutes(id);
-
         } catch (Exception e) {
             return Response.error(e.getMessage());
         }

+ 36 - 0
src/main/java/cn/cslg/pas/factorys/getSqlFactorys/GetWebAppNoSql.java

@@ -0,0 +1,36 @@
+package cn.cslg.pas.factorys.getSqlFactorys;
+
+import cn.cslg.pas.common.model.cronModel.SqlObject;
+import cn.cslg.pas.common.utils.PatentNoUtil;
+import cn.cslg.pas.factorys.getSqlFactorys.GetSqlObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+
+@Slf4j
+@Component
+public class GetWebAppNoSql implements GetSqlObject {
+
+    private SqlObject sqlObject;
+
+    @Override
+    public String getSql(String value) {
+        String filed = sqlObject.getSqlField();
+        String option = sqlObject.getOption();
+        String reQuery = "";
+        if (option.equals("=")) {
+            option = "/";
+        }
+         value = PatentNoUtil.formatApNo(value);
+        reQuery =value + option + filed;
+        return reQuery;
+    }
+
+    public void setSqlObject(SqlObject sqlObject) {
+        this.sqlObject = sqlObject;
+    }
+
+    public SqlObject getSqlObject() {
+        return sqlObject;
+    }
+}

+ 38 - 0
src/main/java/cn/cslg/pas/factorys/getSqlFactorys/GetWebDateSql.java

@@ -0,0 +1,38 @@
+package cn.cslg.pas.factorys.getSqlFactorys;
+
+import cn.cslg.pas.common.model.cronModel.SqlObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+
+@Slf4j
+@Component
+public class GetWebDateSql implements GetSqlObject {
+
+    private SqlObject sqlObject;
+
+    @Override
+    public String getSql(String value) {
+        String filed = sqlObject.getSqlField();
+        String option = sqlObject.getOption();
+        String reQuery = "";
+        if (option.equals("=")) {
+            option = "/";
+        }
+        if (value.trim().contains("~")) {
+            value = value.replace("~", ">");
+            reQuery = value + option + filed;
+        } else {
+            reQuery = value + option + filed;
+        }
+        return reQuery;
+    }
+
+    public void setSqlObject(SqlObject sqlObject) {
+        this.sqlObject = sqlObject;
+    }
+
+    public SqlObject getSqlObject() {
+        return sqlObject;
+    }
+}

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

@@ -121,7 +121,7 @@ public class FinalInvalidStatueService extends ServiceImpl<FinalInvalidStatueMap
 
         List<FinalProofGroup> finalProofGroups = new ArrayList<>();
         LambdaQueryWrapper<FinalProofGroup> queryWrapper1 = new LambdaQueryWrapper<>();
-        queryWrapper1.in(FinalProofGroup::getFinalInvalidStatueId, ids).orderByDesc(FinalProofGroup::getFinalInvalidStatueId);
+        queryWrapper1.in(FinalProofGroup::getFinalInvalidStatueId, ids);
         finalProofGroups = finalProofGroupService.list(queryWrapper1);
 
         for(FinalInvalidStatue finalInvalidStatue:finalInvalidStatues)

+ 9 - 8
src/main/java/cn/cslg/pas/service/business/ProductCategoryService.java

@@ -101,6 +101,13 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
      */
     @Override
     public Object addMessage(Object object, List<MultipartFile> files) {
+        //获取登陆人信息 用于设置创建人
+        PersonnelVO personnelVO = new PersonnelVO();
+        try {
+            personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
+        } catch (Exception e) {
+            throw new UnLoginException("未登录");
+        }
         //object to productCategoryDTO
         ProductCategoryDTO productCategoryDTO = (ProductCategoryDTO)object;
         //检测名称是否不规范
@@ -108,18 +115,12 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
         //根据名称查询数据库中是否存在
         String name = productCategoryDTO.getName();
         LambdaQueryWrapper<ProductCategory> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(ProductCategory::getName, name);
+        queryWrapper.eq(ProductCategory::getName, name)
+                .eq(ProductCategory::getTenant,personnelVO.getTenantId());
         List<ProductCategory> productCategories = this.list(queryWrapper);
         if (productCategories != null && productCategories.size() != 0) {
             throw new XiaoShiException("参数错误");
         }
-        //获取登陆人信息 用于设置创建人
-        PersonnelVO personnelVO = new PersonnelVO();
-        try {
-            personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
-        } catch (Exception e) {
-            throw new UnLoginException("未登录");
-        }
         //产品类别入表
         ProductCategory productCategory = new ProductCategory();
         BeanUtils.copyProperties(productCategoryDTO, productCategory);

+ 83 - 22
src/main/java/cn/cslg/pas/service/query/FormatQueryService.java

@@ -11,12 +11,14 @@ 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.XiaoShiException;
 import cn.cslg.pas.factorys.EsBuilderFactory.EsBuilderFactory;
 import cn.cslg.pas.factorys.EsBuilderFactory.IQueryBuilder;
 import cn.cslg.pas.factorys.getOrderFactory.GetOrderFactory;
 import cn.cslg.pas.factorys.getOrderFactory.GetOrderObject;
 import cn.cslg.pas.factorys.getSqlFactorys.GetSqlFactory;
 import cn.cslg.pas.factorys.getSqlFactorys.GetSqlObject;
+import cn.cslg.pas.factorys.getSqlFactorys.GetWebQuerySql;
 import cn.cslg.pas.service.business.CommonService;
 import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
 import com.alibaba.fastjson.JSON;
@@ -340,27 +342,6 @@ public class FormatQueryService {
             }
         }
 
-//        if ((operate1.getShowName() != null)) {
-//            if (operate1.getShowName().equals("AND")) {
-//                operate1.setShowName("*");
-//            } else if (operate1.getShowName().equals("OR")) {
-//                operate1.setShowName("+");
-//            } else if (operate1.getShowName().equals("NOT")) {
-//                operate1.setShowName("-");
-//            }
-//            strCode = operate1.getShowName();
-//            optionName = operate1.getShowName();
-//        } else {
-//            if (operate1.getCode().equals("AND")) {
-//                operate1.setCode("*");
-//            } else if (operate1.getCode().equals("OR")) {
-//                operate1.setCode("+");
-//            } else if (operate1.getCode().equals("NOT")) {
-//                operate1.setCode("-");
-//            }
-//            strCode = operate1.getCode();
-//            optionName = operate1.getCode();
-//        }
         GetSqlObject getSqlObjectLocal = null;
         if (Left != null) {
             if ((operate1.gettype() == enuType.Logic || operate1.gettype() == enuType.Assignment) && (Left instanceof operateNode)) {
@@ -428,7 +409,7 @@ public class FormatQueryService {
             e.printStackTrace();
         }
         //格式化检索式
-        String reQuery = this.webQueryToString((operateNode) tree, null, configName);
+        String reQuery = this.webQueryToString2( tree,  configName);
         reQuery = "F XX (" + reQuery + ")";
         return reQuery;
     }
@@ -542,4 +523,84 @@ public class FormatQueryService {
         }
     }
 
+
+
+    public String webQueryToString2(treeNode treenode, String tableName) {
+        operateNode node =(operateNode)treenode;
+        treeNode Left = node.getLeft();
+        treeNode Right = node.getRight();
+        operate operate1 =  node.getoperate();
+        if(operate1.gettype() == enuType.Assignment)
+        {
+           if(!(Left instanceof valueNode)) {
+               throw new XiaoShiException("检索式错误");
+           }
+           valueNode leftValue = (valueNode) Left;
+       return   this.getQueryValue(Right,tableName,leftValue.getvalue(),this.getNodeStrCode(operate1));
+        }
+      else if(operate1.gettype()==enuType.Logic)
+        {
+      return "("+ this.webQueryToString2(Left,tableName)+" "+this.getNodeStrCode(operate1)+" "+this.webQueryToString2(Right,tableName)+")";
+        }
+      return null;
+    }
+
+
+    public String getQueryValue(treeNode node, String tableName,String field,String option){
+        if(node instanceof valueNode){
+            valueNode valuenode =(valueNode) node;
+            String json = CommonService.readJsonFile(tableName + ".json");
+            List<SqlObject> sqlObjects = JSON.parseArray(json, SqlObject.class);
+            SqlObject sqlObject = sqlObjects.stream().filter(item -> item.getField().equals(field)).findFirst().orElse(null);
+            sqlObject.setOption(option);
+            GetSqlObject getSqlObject =getSqlFactory.getClass(sqlObject.getSqlClass());
+            getSqlObject.setSqlObject(sqlObject);
+           return getSqlObject.getSql(valuenode.getvalue());
+        }
+        else {
+            operateNode operatenode =(operateNode)node;
+            treeNode Left = operatenode.getLeft();
+            treeNode Right = operatenode.getRight();
+            operate operate1 =  operatenode.getoperate();
+      return "("+this.getQueryValue(Left,tableName,field,option)+" "+this.getNodeStrCode(operate1)+" "+this.getQueryValue(Right,tableName,field,option)+")";
+        }
+
+    }
+
+    public  String getNodeStrCode(operate operate1){
+        String strCode = "";
+        String optionName = "";
+        if ((operate1.getShowName() != null)) {
+            if (operate1.getShowName().equals("AND")) {
+                strCode="*";
+                optionName="*";
+            } else if (operate1.getShowName().equals("OR")) {
+                strCode="+";
+                optionName="+";
+            } else if (operate1.getShowName().equals("NOT")) {
+                strCode="-";
+                optionName="-";
+            }
+            else {
+                strCode=operate1.getShowName();
+                optionName=operate1.getShowName();
+            }
+        } else {
+            if (operate1.getCode().equals("AND")) {
+                strCode="*";
+                optionName="*";
+            } else if (operate1.getCode().equals("OR")) {
+                strCode="+";
+                optionName="+";
+            } else if (operate1.getCode().equals("NOT")) {
+                strCode="-";
+                optionName="-";
+            }
+            else {
+                strCode=operate1.getShowName();
+                optionName=operate1.getShowName();
+            }
+        }
+        return strCode;
+    }
 }

+ 16 - 3
src/main/resources/jsons/webSearchConfig.json

@@ -188,7 +188,7 @@
     "value": "AD",
     "field": "AD",
     "sqlField": "AD",
-    "sqlClass": "getWebQuerySql",
+    "sqlClass": "getWebDateSql",
     "orderClass": "",
     "groupClass": "",
     "ifSearch": "true",
@@ -201,7 +201,7 @@
     "value": "GD",
     "field": "GD",
     "sqlField": "GD",
-    "sqlClass": "getWebQuerySql",
+    "sqlClass": "getWebDateSql",
     "orderClass": "",
     "groupClass": "",
     "ifSearch": "true",
@@ -214,7 +214,7 @@
     "value": "PD",
     "field": "PD",
     "sqlField": "PD",
-    "sqlClass": "getWebQuerySql",
+    "sqlClass": "getWebDateSql",
     "orderClass": "",
     "groupClass": "",
     "ifSearch": "true",
@@ -365,5 +365,18 @@
     "ifSearch": "true",
     "ifGroup": "false",
     "ifShow": "false"
+  },
+  {
+    "name": "GJ",
+    "type": "Integer",
+    "value": "GJ",
+    "field": "GJ",
+    "sqlField": "GJ",
+    "sqlClass": "getWebQuerySql",
+    "orderClass": "",
+    "groupClass": "",
+    "ifSearch": "true",
+    "ifGroup": "false",
+    "ifShow": "false"
   }
 ]

+ 18 - 9
src/test/java/cn/cslg/pas/service/CommonServiceTests.java

@@ -3,10 +3,7 @@ package cn.cslg.pas.service;
 import cn.cslg.pas.common.model.common.QueryCondition;
 import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.common.model.request.StringRequest;
-import cn.cslg.pas.common.utils.FormatUtil;
-import cn.cslg.pas.common.utils.MathUtils;
-import cn.cslg.pas.common.utils.RabbitMQUtils;
-import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.common.utils.*;
 import cn.cslg.pas.common.utils.esDataForm.AddressSplitter;
 import cn.cslg.pas.common.vo.DepartmentVO;
 import cn.cslg.pas.common.vo.ImportTaskAMVO;
@@ -61,6 +58,9 @@ public class CommonServiceTests {
 
     @Autowired
     private PatentImportFactory patentImportFactory;
+    @Autowired
+    private PatentNoUtil patentNoUtil;
+
     @Test
     void test() throws Exception {
         String aa = permissionService.getPersonIdByNamePCS("朱", false);
@@ -141,11 +141,20 @@ public class CommonServiceTests {
         PersonAddress personAddress = AddressSplitter.splitAddress(te, "91(上海)");
         System.out.println(personAddress);
     }
-//李仁杰<2232723707@qq.com>"
+
+    //李仁杰<2232723707@qq.com>"
     @Test
-    public void testEmail() throws Exception{
-          String  a ="多功能应用\\烟熏模块";
-         String[] ab =a.split("\\\\");
-          System.out.println(ab);
+    public void testEmail() throws Exception {
+        String a = "多功能应用\\烟熏模块";
+        String[] ab = a.split("\\\\");
+        System.out.println(ab);
+
     }
+
+    @Test
+    public void testPatentNo() throws Exception {
+
+        String patentNo = PatentNoUtil.formatApNo("2023306875789");
+        System.out.println(patentNo);
     }
+}