lwhhszx 1 ano atrás
pai
commit
83c2a1cbc2
36 arquivos alterados com 928 adições e 3294 exclusões
  1. 0 58
      src/main/java/cn/cslg/pas/common/GlobalException.java
  2. 0 32
      src/main/java/cn/cslg/pas/common/PageHelperT.java
  3. 0 156
      src/main/java/cn/cslg/pas/common/config/InnerInterceptor/LizzMybatisIntercepts.java
  4. 1 6
      src/main/java/cn/cslg/pas/common/config/MybatisPlusConfig.java
  5. 0 13
      src/main/java/cn/cslg/pas/common/config/WebSocketConfig.java
  6. 0 89
      src/main/java/cn/cslg/pas/common/core/CreateTaskThread.java
  7. 0 74
      src/main/java/cn/cslg/pas/common/core/annotation/PermissionAspect.java
  8. 167 0
      src/main/java/cn/cslg/pas/common/model/cronModel/PersonnelVO.java
  9. 0 147
      src/main/java/cn/cslg/pas/common/utils/BackupUtils.java
  10. 0 170
      src/main/java/cn/cslg/pas/common/utils/CacheUtils.java
  11. 0 183
      src/main/java/cn/cslg/pas/common/utils/ExcelUtils.java
  12. 0 243
      src/main/java/cn/cslg/pas/common/utils/FileUtils.java
  13. 0 321
      src/main/java/cn/cslg/pas/common/utils/PatentRightUtils.java
  14. 0 220
      src/main/java/cn/cslg/pas/common/utils/PatentUtils.java
  15. 0 220
      src/main/java/cn/cslg/pas/common/utils/ReadExcelUtils.java
  16. 0 18
      src/main/java/cn/cslg/pas/common/utils/ThrowException.java
  17. 0 241
      src/main/java/cn/cslg/pas/common/utils/UploadPatentBatchUtil.java
  18. 0 113
      src/main/java/cn/cslg/pas/common/utils/WebSocketServer.java
  19. 0 171
      src/main/java/cn/cslg/pas/common/utils/auth/AuthAop.java
  20. 0 362
      src/main/java/cn/cslg/pas/common/utils/auth/TreeUtils.java
  21. 0 17
      src/main/java/cn/cslg/pas/common/utils/auth/checkAuth.java
  22. 34 0
      src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/Symbol.java
  23. 13 0
      src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/enuType.java
  24. 473 0
      src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/expressManager.java
  25. 42 0
      src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/operate.java
  26. 53 0
      src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/operateNode.java
  27. 25 0
      src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/pairSymbol.java
  28. 58 0
      src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/treeNode.java
  29. 16 0
      src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/valueNode.java
  30. 0 163
      src/main/java/cn/cslg/pas/service/TestService.java
  31. 22 0
      src/main/java/cn/cslg/pas/service/query/QueryService.java
  32. 24 24
      src/test/java/cn/cslg/pas/service/PatentPDFServiceTests.java
  33. 0 24
      src/test/java/cn/cslg/pas/service/PatentRightServiceTests.java
  34. 0 56
      src/test/java/cn/cslg/pas/service/PatentRightSplitCNServiceTests.java
  35. 0 58
      src/test/java/cn/cslg/pas/service/PatentRightSplitENServiceTests.java
  36. 0 115
      src/test/java/cn/cslg/pas/service/TextExcelTests.java

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

@@ -1,58 +0,0 @@
-package cn.cslg.pas.common;
-
-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 lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.RestControllerAdvice;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * 全局异常处理
- */
-@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) {
-            NotLoginException notLoginException = (NotLoginException) e;
-            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 handleXiaoShiException(XiaoShiException e) {
-        log.info("全局异常处理机制捕获到XiaoShiException,异常信息提示:{}", e.getMessage());
-        return Response.fail(e.getMessage());
-    }
-
-    @ExceptionHandler
-    public Response handleIOException(IOException e) {
-        log.info("全局异常处理机制捕获到IOException,异常信息打桩输出为:");
-        e.printStackTrace();
-        return Response.fail();
-    }
-
-    @ExceptionHandler
-    public Response handleThrowable(Throwable e) {
-        log.info("全局异常处理机制捕获到Throwable,异常信息打桩输出为:");
-        e.printStackTrace();
-        return Response.fail();
-    }
-
-}

+ 0 - 32
src/main/java/cn/cslg/pas/common/PageHelperT.java

@@ -1,32 +0,0 @@
-package cn.cslg.pas.common;
-
-import cn.cslg.pas.common.model.vo.PermissionRecordVO;
-import lombok.Data;
-
-import java.util.List;
-
-/**
- * 分页查询
- *
- * @Author xiexiang
- * @Date 2023/3/10
- */
-@Data
-public class PageHelperT {
-    /**
-     * 总条数
-     */
-    private Integer total;
-    /**
-     * 当前页
-     */
-    private Integer current;
-    /**
-     * 每页条数
-     */
-    private Integer size;
-    /**
-     * 分页查询结果
-     */
-    private List<PermissionRecordVO> list;
-}

+ 0 - 156
src/main/java/cn/cslg/pas/common/config/InnerInterceptor/LizzMybatisIntercepts.java

@@ -1,156 +0,0 @@
-package cn.cslg.pas.common.config.InnerInterceptor;
-
-import cn.cslg.pas.common.model.DataSource;
-import cn.cslg.pas.common.model.PersonnelVO;
-import cn.cslg.pas.common.utils.CacheUtils;
-import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
-import cn.cslg.pas.common.utils.SecurityUtils.SecurityUtils;
-import cn.cslg.pas.common.utils.auth.TreeUtils;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;
-import lombok.SneakyThrows;
-import lombok.extern.slf4j.Slf4j;
-import okhttp3.FormBody;
-import okhttp3.OkHttpClient;
-import okhttp3.Request;
-import okhttp3.RequestBody;
-import org.apache.ibatis.executor.Executor;
-import org.apache.ibatis.executor.statement.StatementHandler;
-import org.apache.ibatis.mapping.BoundSql;
-import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.session.ResultHandler;
-import org.apache.ibatis.session.RowBounds;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Lazy;
-
-import java.lang.reflect.Field;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Properties;
-
-@Slf4j
-public class LizzMybatisIntercepts implements InnerInterceptor {
-    @Lazy//懒加载,当调用时注入
-    @Autowired
-    private CacheUtils cacheUtils;
-    @Lazy//懒加载,当调用时注入
-    @Autowired
-    private LoginUtils loginUtils;
-
-    @Value("${authorUrl}")
-    private String url;
-
-    @SneakyThrows
-    @Override
-    public boolean willDoQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException {
-        try {
-            //获得原始sql
-            String Localsql = boundSql.getSql();
-            Map<String, Object> maps = SecurityUtils.getDataScope(); //获得线程里保存的functionId
-            //如果线程里有保存信息则进行sql拦截操作,若没有则sql保持不变
-            if (maps != null) {
-                SecurityUtils.cleanDataScope(); //当第一次进来后删除线程保存的functionId,避免后续使用的查询sql进来
-                String token = maps.get("token").toString();
-                //查询数据规则
-                //设定formdata类型参数
-                RequestBody requestBody = new FormBody.Builder()
-                        .add("loginId", maps.get("loginId").toString())
-                        .add("functionId", maps.get("functionId").toString())
-                        .build();
-                //建立连接
-                OkHttpClient okHttpClient = new OkHttpClient();
-                //发送远程请求
-                Request request = new Request.Builder()
-                        .url(url + "/permission/api/data/queryDataRule")
-                        .post(requestBody)
-                        .addHeader("Cookie", token)
-                        .build();
-                //获得请求返回
-                String resBody = Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
-                //处理请求返回
-                JSONArray jsonArray = JSONArray.parseArray(resBody);
-                //当返回结果不为[0]或[-1]进行sql拦截操作
-                if (!(jsonArray.get(0).equals("0") || jsonArray.get(0).equals("-1"))) {
-                    StringBuilder sqls = new StringBuilder();
-                    // 查询字典数据
-                    //设定formdata类型参数
-                    RequestBody reBodySource = new FormBody.Builder()
-                            .add("tableName", "local")
-                            .build();
-                    //建立连接
-                    OkHttpClient okHttpClientSou = new OkHttpClient();
-                    //发送请求
-                    Request requestSou = new Request.Builder()
-                            .url(url + "/permission/api/data/getDataSource")
-                            .post(reBodySource)
-                            .addHeader("Cookie", token)
-                            .build();
-                    //获得请求返回
-                    String resSource = Objects.requireNonNull(okHttpClientSou.newCall(requestSou).execute().body()).string();
-
-                    JSONArray jsonArray1 = JSON.parseArray(resSource);
-                    // 获得字典
-                    List<DataSource> dataSources = jsonArray1.toJavaList(DataSource.class);
-                    //拼接所有角色的限制条件
-                    if (jsonArray.size() > 0) {
-                        PersonnelVO personnelVO = cacheUtils.getLoginUserPersonnel(loginUtils.getId());
-                        for (int i = 0; i < jsonArray.size(); i++) {
-                            String sql1 = TreeUtils.reSql(JSONObject.parseObject(jsonArray.get(i).toString()), dataSources, personnelVO);
-                            if (!sql1.equals("")) {
-                                sqls.append(jsonArray.size() != i + 1 ? sql1 + " OR " : sql1);
-                            }
-                        }
-                        // 根据sql语句结构,将拼接sql放入合适的位置
-                        if (Localsql.contains("order by")) {
-                            Localsql = Localsql.replace("order by", "And (" + sqls + ") order by");
-                        } else {
-                            Localsql += " And (" + sqls + ")";
-                        }
-                        //将限制条件拼接到sql语句
-
-                        Field field = boundSql.getClass().getDeclaredField("sql");//反射获得boundsql的sql属性并改变sql参数
-                        field.setAccessible(true); //属性设为可见(反射不安全的原因)
-                        field.set(boundSql, Localsql);
-                    }
-                }
-            }
-
-            return true;
-        } finally {
-            SecurityUtils.cleanDataScope();//无论是否进行成功最后都要删除线程里的保存的参数
-
-        }
-    }
-
-    @Override
-    public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException {
-
-    }
-
-    @Override
-    public boolean willDoUpdate(Executor executor, MappedStatement ms, Object parameter) throws SQLException {
-        return true;
-    }
-
-    @Override
-    public void beforeUpdate(Executor executor, MappedStatement ms, Object parameter) throws SQLException {
-    }
-
-    @Override
-    public void beforePrepare(StatementHandler sh, Connection connection, Integer transactionTimeout) {
-    }
-
-    @Override
-    public void beforeGetBoundSql(StatementHandler sh) {
-    }
-
-    @Override
-    public void setProperties(Properties properties) {
-    }
-}

+ 1 - 6
src/main/java/cn/cslg/pas/common/config/MybatisPlusConfig.java

@@ -1,6 +1,6 @@
 package cn.cslg.pas.common.config;
 
-import cn.cslg.pas.common.config.InnerInterceptor.LizzMybatisIntercepts;
+
 import com.baomidou.mybatisplus.annotation.DbType;
 import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
 import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
@@ -11,14 +11,9 @@ import org.springframework.context.annotation.Configuration;
 @Configuration
 @MapperScan("cn.cslg.pas.mapper")
 public class MybatisPlusConfig {
-    @Bean//必须加Bean注解,否则无法拦截器里无法实例化serve
-    public LizzMybatisIntercepts lizzMybatisIntercepts(){
-        return  new LizzMybatisIntercepts();
-    } //自定义拦截器
     @Bean
     public MybatisPlusInterceptor mybatisPlusInterceptor() {
         MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
-        interceptor.addInnerInterceptor(lizzMybatisIntercepts());//加入自定义拦截器
         interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
         return interceptor;
     }

+ 0 - 13
src/main/java/cn/cslg/pas/common/config/WebSocketConfig.java

@@ -1,13 +0,0 @@
-package cn.cslg.pas.common.config;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.socket.server.standard.ServerEndpointExporter;
-
-@Configuration
-public class WebSocketConfig {
-    @Bean
-    public ServerEndpointExporter serverEndpointExporter() {
-        return new ServerEndpointExporter();
-    }
-}

+ 0 - 89
src/main/java/cn/cslg/pas/common/core/CreateTaskThread.java

@@ -1,89 +0,0 @@
-package cn.cslg.pas.common.core;
-
-import cn.cslg.pas.domain.Task;
-import cn.cslg.pas.service.TaskService;
-import cn.cslg.pas.service.upLoadPatent.PantentQueueService;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import lombok.RequiredArgsConstructor;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Lazy;
-import org.springframework.stereotype.Component;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * 项目启动时初始化任务列表队列
- *
- * @Author chenyu
- * @Date 2023/6/2
- */
-@Component
-@RequiredArgsConstructor(onConstructor_ = {@Lazy})
-public class CreateTaskThread implements InitializingBean {
-
-    private final TaskService taskService;
-    private final PantentQueueService pantentQueueService;
-
-    @Override
-    public void afterPropertiesSet() throws Exception {
-        //初始化任务队列
-        //查找任务状态为0(队列中)和1(进行中)的任务
-        List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().in(Task::getStatus, new ArrayList<>(Arrays.asList(0, 1))));
-        if (tasks.size() > 0) {
-            //过滤出任务ids
-            List<Integer> taskIds = tasks.stream().map(Task::getId).collect(Collectors.toList());
-            //过滤出进行中的任务的id
-            List<Task> doingTasks = tasks.stream().filter(item -> item.getStatus() == 1).collect(Collectors.toList());
-            List<Integer> doingTaskIds = doingTasks.stream().map(Task::getId).collect(Collectors.toList());
-            if (doingTaskIds.size() > 0) {
-                //先将进行中的任务(项目重启后进行中的任务仅会有1个)的id先存入任务队列,再将其余存入
-                pantentQueueService.taskQueueListAddTask(doingTaskIds);
-                taskIds.removeAll(doingTaskIds);
-            }
-            pantentQueueService.taskQueueListAddTask(taskIds);
-        }
-
-        //生产者线程
-        Thread threadProducer = new Thread(pantentQueueService::addPatnetToQueue);
-        threadProducer.start();
-
-        //装载专利著录线程
-        Thread threadSetPatentZhuLu = new Thread(pantentQueueService::setPatentZhuLu);
-        threadSetPatentZhuLu.start();
-        //装载权要线程
-        Thread threadSetPatentClaim = new Thread(pantentQueueService::setPatentRight);
-        threadSetPatentClaim.start();
-        //装载说明书文本线程
-        Thread threadSetPatentInstructionText = new Thread(pantentQueueService::setPatentInstructionText);
-        threadSetPatentInstructionText.start();
-        //装载说明书pdf线程
-        Thread threadSetPatentInstructionPDF = new Thread(pantentQueueService::setPatentInstructionPDF);
-        threadSetPatentInstructionPDF.start();
-        //装载摘要附图线程
-        Thread threadSetPatentPicture = new Thread(pantentQueueService::setPatentImage);
-        threadSetPatentPicture.start();
-
-        //消费者1线程(著录项目)
-        Thread threadConsumer1 = new Thread(pantentQueueService::pushPatentZhuLuToDB);
-        threadConsumer1.start();
-        //消费者2线程(权利要求)
-        Thread threadConsumer2 = new Thread(pantentQueueService::pushPatentRightToDB);
-        threadConsumer2.start();
-        //消费者3线程(说明书文本)
-        Thread threadConsumer3 = new Thread(pantentQueueService::pushPatentInstructionTextToDB);
-        threadConsumer3.start();
-        //消费者4线程(说明书pdf)
-        Thread threadConsumer4 = new Thread(pantentQueueService::pushPatentInstructionPDFToDB);
-        threadConsumer4.start();
-        //消费者5线程(摘要附图)
-        Thread threadConsumer5 = new Thread(pantentQueueService::pushPatentImageToDB);
-        threadConsumer5.start();
-
-    }
-
-}

+ 0 - 74
src/main/java/cn/cslg/pas/common/core/annotation/PermissionAspect.java

@@ -1,74 +0,0 @@
-package cn.cslg.pas.common.core.annotation;
-
-import cn.cslg.pas.common.core.base.RequestHolder;
-import cn.cslg.pas.common.core.exception.PermissionException;
-import cn.cslg.pas.common.model.PersonnelVO;
-import cn.cslg.pas.common.utils.CacheUtils;
-import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
-import cn.cslg.pas.common.utils.StringUtils;
-import cn.cslg.pas.domain.Project;
-import cn.cslg.pas.domain.ProjectUser;
-import cn.cslg.pas.service.ProjectService;
-import cn.cslg.pas.service.ProjectUserService;
-import lombok.extern.slf4j.Slf4j;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Pointcut;
-import org.aspectj.lang.reflect.MethodSignature;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Component;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import javax.servlet.http.HttpServletRequest;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-@Order(1)
-@Slf4j
-@Aspect
-@Component
-public class PermissionAspect {
-
-    @Autowired
-    private ProjectUserService projectUserService;
-    @Autowired
-    private ProjectService projectService;
-    @Autowired
-    private CacheUtils cacheUtils;
-    @Autowired
-    private LoginUtils loginUtils;
-    @Pointcut("execution(public * cn.cslg.pas.controller.*.*(..))")
-    public void privilege() {
-    }
-
-    @ResponseBody
-    @Around("privilege()")
-    public Object isAccessMethod(ProceedingJoinPoint joinPoint) throws Throwable {
-        //获取访问目标方法
-        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
-        Method targetMethod = methodSignature.getMethod();
-        final int[] methodAccess = AnnotationParse.permissionParse(targetMethod);
-        if (methodAccess != null && methodAccess.length != 0) {
-            HttpServletRequest request = RequestHolder.getRequest();
-            if (request != null) {
-                String projectId = request.getHeader("x-project-id");
-                Integer userId = loginUtils.getId();
-                if (StringUtils.isNotEmpty(projectId)) {
-                    Project project = projectService.getById(projectId);
-                    PersonnelVO user = cacheUtils.getLoginUserPersonnel(userId);
-                    ProjectUser projectUser = projectUserService.getProjectUserByProjectIdAndUserId(Integer.parseInt(projectId), userId);
-                    if (projectUser != null && project != null && user != null) {
-                        if (project.getCreateBy().equals(userId)) {
-                            return joinPoint.proceed();
-                        }
-                        if (Arrays.stream(methodAccess).noneMatch(item -> item == projectUser.getType())) {
-                            throw new PermissionException("用户操作拦截");
-                        }
-                    }
-                }
-            }
-        }
-        return joinPoint.proceed();
-    }
-}

+ 167 - 0
src/main/java/cn/cslg/pas/common/model/cronModel/PersonnelVO.java

@@ -0,0 +1,167 @@
+package cn.cslg.pas.common.model.cronModel;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+/**
+ * @author 沈永艺
+ * @date 2022-8-4
+ * @description 人员类 前台对应实体
+ */
+
+@Data
+@Accessors(chain = true)
+public class PersonnelVO {
+    /**
+     * ID
+     */
+    private Integer id;
+
+    /**
+     * Front:姓名
+     * Back:人员名称
+     */
+    private String name;
+
+    /**
+     * Front:性别
+     * Back:人员性别
+     */
+    private Integer gender;
+
+    /**
+     * Front:邮箱
+     * Back:人员邮箱
+     */
+    private String email;
+
+    /**
+     * Front:联系方式
+     * Back:人员联系电话
+     */
+    private String mobile;
+
+    /**
+     * Front:所属租户
+     * Back:租户ID
+     */
+    private Integer tenant;
+
+    /**
+     * Front:状态
+     * Back:人员账号状态(1启用0停用)
+     */
+    private Integer state;
+
+    /**
+     * Front:账号
+     * Back:人员账号
+     */
+    private String username;
+
+    /**
+     * Front:密码
+     * Back:人员密码
+     */
+    private String password;
+
+    /**
+     * Front:备注
+     * Back:人员描述
+     */
+    private String remark;
+
+    /**
+     * Front:QQ号
+     * Back:人员QQ号
+     */
+    private String qqNumber;
+
+    /**
+     * Front:微信号
+     * Back:人员微信号
+     */
+    private String wechat;
+
+    /**
+     * Front:钉钉号
+     * Back:人员钉钉号
+     */
+    private String nail;
+
+    /**
+     * Front:
+     * Back:租户名称
+     */
+    private String tenantName;
+
+    /**
+     * Front:
+     * Back:租户ID
+     */
+    private Integer tenantId;
+
+    /**
+     * 登陆成功后生成的Token
+     */
+    private String token;
+
+    /**
+     * 角色List
+     */
+    private List<PerRole> rList;
+
+    /**
+     * 部门职位List
+     */
+    private List<DP> dpList;
+    /**
+     * 角色类型(是否为管理角色)
+     */
+    private Integer roleType;
+    /**
+     * 租户类型
+     */
+    private String tenantType;
+
+    /**
+     * 部门职位绑定关系
+     */
+    @Data
+    public static class DP {
+        /**
+         * 部门名称
+         */
+        private String departmentName;
+        /**
+         * 部门ID
+         */
+        private Integer departmentId;
+        /**
+         * 职位名称
+         */
+        private String positionName;
+        /**
+         * 职位ID
+         */
+        private Integer positionId;
+    }
+
+    /**
+     * 角色信息
+     */
+    @Data
+    public static class PerRole {
+        /**
+         * 角色名称
+         */
+        private String roleName;
+        /**
+         * 角色ID
+         */
+        private Integer roleId;
+    }
+
+}

+ 0 - 147
src/main/java/cn/cslg/pas/common/utils/BackupUtils.java

@@ -1,147 +0,0 @@
-package cn.cslg.pas.common.utils;
-
-import cn.hutool.core.io.FileUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.system.ApplicationHome;
-import org.springframework.stereotype.Component;
-import org.yaml.snakeyaml.Yaml;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-
-@Slf4j
-public class BackupUtils {
-
-    private final static String BACKUP_CONFIG = "backup-config.yml";
-
-    private static Backup getBackupConfig() {
-        try {
-            ApplicationHome ah = new ApplicationHome(BackupUtils.class);
-            File file = ah.getSource();
-            String rootPath = file.getParentFile().toString() + FileUtils.FILE_SEPARATOR + BACKUP_CONFIG;
-            Yaml yaml = new Yaml();
-            InputStream in = FileUtil.getInputStream(rootPath);
-            Backup backup = yaml.loadAs(in, Backup.class);
-            if (in != null) {
-                in.close();
-            }
-            return backup;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return null;
-        }
-    }
-
-    public static void main(String[] args) {
-        System.out.println(getBackupConfig());
-    }
-
-    public void run() {
-        Backup backup = getBackupConfig();
-        if (backup == null) {
-            log.info("数据库备份配置文件不存在");
-            return;
-        }
-        log.info("数据库备份配置文件:{}", backup);
-        if (backup.isEnable()) {
-            String path = FileUtils.getStaticPath(FileUtils.BACKUP_FILE);
-            String fileName = DateUtils.getNowTimeFormat(DateUtils.YYYYMMDDHHMMSS) + ".sql";
-            try {
-                String cmd = String.format("mysqldump --skip-opt -h%s -P%s -u%s -p%s %s > %s", backup.getHost(), backup.getPort(), backup.getUsername(), backup.getPassword(), backup.getDb(), path + FileUtils.FILE_SEPARATOR + fileName);
-                String[] command;
-                if (backup.getOs() == 0) {
-                    command = new String[]{"cmd", "/c", String.valueOf(cmd)};
-                } else {
-                    command = new String[]{"/bin/sh", "-c", String.valueOf(cmd)};
-                }
-                Runtime.getRuntime().exec(command);
-                log.info("备份数据库成功");
-            } catch (Exception e) {
-                e.printStackTrace();
-                log.error("备份数据库失败");
-            }
-        }
-    }
-
-    public static class Backup {
-        private String host;
-        private String port;
-        private String db;
-        private String username;
-        private String password;
-        private int os;
-        private boolean enable;
-
-        @Override
-        public String toString() {
-            return "Backup{" +
-                    "host='" + host + '\'' +
-                    ", port='" + port + '\'' +
-                    ", db='" + db + '\'' +
-                    ", username='" + username + '\'' +
-                    ", password='" + password + '\'' +
-                    ", os=" + os +
-                    ", enable=" + enable +
-                    '}';
-        }
-
-        public boolean isEnable() {
-            return enable;
-        }
-
-        public void setEnable(boolean enable) {
-            this.enable = enable;
-        }
-
-        public String getHost() {
-            return host;
-        }
-
-        public void setHost(String host) {
-            this.host = host;
-        }
-
-        public String getPort() {
-            return port;
-        }
-
-        public void setPort(String port) {
-            this.port = port;
-        }
-
-        public String getDb() {
-            return db;
-        }
-
-        public void setDb(String db) {
-            this.db = db;
-        }
-
-        public String getUsername() {
-            return username;
-        }
-
-        public void setUsername(String username) {
-            this.username = username;
-        }
-
-        public String getPassword() {
-            return password;
-        }
-
-        public void setPassword(String password) {
-            this.password = password;
-        }
-
-        public int getOs() {
-            return os;
-        }
-
-        public void setOs(int os) {
-            this.os = os;
-        }
-    }
-
-}

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

@@ -1,170 +0,0 @@
-package cn.cslg.pas.common.utils;
-
-import cn.cslg.pas.common.core.base.RedisConf;
-import cn.cslg.pas.common.model.PersonnelVO;
-import cn.cslg.pas.common.model.dto.ProjectFieldOrderDTO;
-import cn.cslg.pas.domain.PatentField;
-import cn.cslg.pas.domain.User;
-import cn.cslg.pas.common.model.dto.analysis.AnalysisItemResultDTO;
-import cn.cslg.pas.common.model.dto.CommonData;
-import cn.dev33.satoken.exception.NotLoginException;
-import cn.hutool.core.lang.tree.Tree;
-import cn.hutool.core.util.IdUtil;
-import cn.hutool.crypto.SecureUtil;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-
-@Component
-public class CacheUtils {
-
-    @Resource
-    private RedisUtil redisUtil;
-
-    public void setCommonData(CommonData commonData) {
-        redisUtil.set(RedisConf.COMMON_DATA, JsonUtils.objectToJson(commonData));
-    }
-
-    public CommonData getCommonData() {
-        String json = redisUtil.get(RedisConf.COMMON_DATA);
-        if (StringUtils.isEmpty(json)) {
-            return null;
-        } else {
-            return JsonUtils.jsonToPojo(json, CommonData.class);
-        }
-    }
-
-    public void setLoginUser(User user) {
-        redisUtil.set(RedisConf.LOGIN_USER + RedisConf.SYMBOL_COLON + user.getId(), JsonUtils.objectToJson(user));
-    }
-
-    public PersonnelVO getLoginUser(Object userId) {
-        String json = redisUtil.get(RedisConf.LOGIN_USER + RedisConf.SYMBOL_COLON + userId);
-        if (StringUtils.isEmpty(json)) {
-            throw new NotLoginException("无数据", "user", "");
-        } else {
-            return com.alibaba.fastjson2.JSONObject.parseObject(json, PersonnelVO.class);
-        }
-    }
-
-    public  PersonnelVO getLoginUserPersonnel(Object userId) {
-        String json = redisUtil.get(RedisConf.LOGIN_USER + RedisConf.SYMBOL_COLON + userId);
-        if (StringUtils.isEmpty(json)) {
-            throw new NotLoginException("无数据", "user", "");
-        } else {
-            return com.alibaba.fastjson2.JSONObject.parseObject(json, PersonnelVO.class);
-        }
-    }
-
-    public String getSelectPatentIds(String patentKey) {
-        return redisUtil.get(RedisConf.SELECT_PATENT + RedisConf.SYMBOL_COLON + patentKey);
-    }
-
-    public Integer getSelectPatentNum(String patentKey) {
-        String ids = getSelectPatentIds(patentKey);
-        if (StringUtils.isEmpty(ids)) {
-            return 0;
-        }
-        return StringUtils.changeStringToInteger(ids, ",").size();
-    }
-
-    public void setAnalysisCountV2(String patentKey, Integer field, Integer expand, String value, String ids) {
-        String md5 = SecureUtil.md5(field + RedisConf.SYMBOL_COLON + expand + RedisConf.SYMBOL_COLON + patentKey);
-        String key = RedisConf.ANALYSIS_COUNT + RedisConf.SYMBOL_COLON + md5;
-        if (StringUtils.isNotEmpty(value) && StringUtils.isNotEmpty(ids)) {
-            redisUtil.hPut(key, value, ids);
-            redisUtil.expire(key, 7200, TimeUnit.SECONDS);
-        }
-    }
-
-    public Object getAnalysisCountIdsV2(String patentKey, Integer field, Integer expand, String name) {
-        String md5 = SecureUtil.md5(field + RedisConf.SYMBOL_COLON + expand + RedisConf.SYMBOL_COLON + patentKey);
-        String key = RedisConf.ANALYSIS_COUNT + RedisConf.SYMBOL_COLON + md5;
-        return redisUtil.hGet(key, name);
-    }
-
-    public List<AnalysisItemResultDTO> getAnalysisCountV2(String patentKey, Integer field, Integer expand) {
-        List<AnalysisItemResultDTO> resultList = new ArrayList<>();
-        String md5 = SecureUtil.md5(field + RedisConf.SYMBOL_COLON + expand + RedisConf.SYMBOL_COLON + patentKey);
-        String key = RedisConf.ANALYSIS_COUNT + RedisConf.SYMBOL_COLON + md5;
-        Map<Object, Object> result = redisUtil.hGetAll(key);
-        for (Object name : result.keySet()) {
-            Object value = result.get(name);
-            if (StringUtils.isNotNull(value)) {
-                List<Integer> ids = StringUtils.changeStringToInteger(value.toString(), ",");
-                AnalysisItemResultDTO analysisItemResultDTO = new AnalysisItemResultDTO();
-                analysisItemResultDTO.setIds(value.toString());
-                analysisItemResultDTO.setName(name.toString());
-                analysisItemResultDTO.setCount(ids.size());
-                resultList.add(analysisItemResultDTO);
-            }
-        }
-        return resultList;
-    }
-
-    public List<Tree> setAreaTreeList(List<Tree<Integer>> treeList) {
-        redisUtil.set(RedisConf.COMMON_DATA + RedisConf.SYMBOL_COLON + RedisConf.AREA_LIST, JsonUtils.objectToJson(treeList));
-        return this.getAreaTreeList();
-    }
-
-    public List<Tree> getAreaTreeList() {
-        String json = redisUtil.get(RedisConf.COMMON_DATA + RedisConf.SYMBOL_COLON + RedisConf.AREA_LIST);
-        if (StringUtils.isNotEmpty(json)) {
-            return JsonUtils.jsonToList(json, Tree.class);
-        }
-        return null;
-    }
-
-    public String setSelectPatentIds(List<Integer> patentIds) {
-        String uuid = IdUtil.simpleUUID();
-        redisUtil.setEx(RedisConf.SELECT_PATENT + RedisConf.SYMBOL_COLON + uuid, StringUtils.join(patentIds, ","), 43200, TimeUnit.SECONDS);
-        return uuid;
-    }
-
-    public void deleteUserSystemFieldSetting(Integer projectId, String type, String view, Integer userId,Integer createId) {
-        String key = SecureUtil.md5(projectId + RedisConf.SYMBOL_COLON + type + RedisConf.SYMBOL_COLON + view + RedisConf.SYMBOL_COLON + userId+createId);
-        redisUtil.delete(RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key);
-    }
-
-    public void setUserSystemFieldSetting(Integer projectId, String type, String view, Integer userId, List<PatentField> defaultField,Integer createId) {
-        String key = SecureUtil.md5(projectId + RedisConf.SYMBOL_COLON + type + RedisConf.SYMBOL_COLON + view + RedisConf.SYMBOL_COLON + userId+createId);
-        redisUtil.set(RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key, JsonUtils.objectToJson(defaultField));
-    }
-
-    public List<PatentField> getUserSystemFieldSetting(Integer projectId, String type, String view, Integer userId,Integer createId) {
-        String key = SecureUtil.md5(projectId + RedisConf.SYMBOL_COLON + type + RedisConf.SYMBOL_COLON + view + RedisConf.SYMBOL_COLON + userId+createId);
-        String json = redisUtil.get(RedisConf.USER_FIELD + RedisConf.SYMBOL_COLON + key);
-        if (StringUtils.isNotEmpty(json)) {
-            return JsonUtils.jsonToList(json, PatentField.class);
-        }
-        return new ArrayList<>();
-    }
-
-    public List<ProjectFieldOrderDTO> getProjectFieldOrder(Integer projectId, Integer userId) {
-        String key = SecureUtil.md5(projectId + RedisConf.SYMBOL_COLON + userId);
-        String json = redisUtil.get(RedisConf.FIELD_ORDER + RedisConf.SYMBOL_COLON + key);
-        if (StringUtils.isNotEmpty(json)) {
-            return JsonUtils.jsonToList(json, ProjectFieldOrderDTO.class);
-        }
-        return new ArrayList<>();
-    }
-
-    public void setProjectFieldOrder(Integer projectId, Integer userId, List<ProjectFieldOrderDTO> data) {
-        String key = SecureUtil.md5(projectId + RedisConf.SYMBOL_COLON + userId);
-        redisUtil.set(RedisConf.FIELD_ORDER + RedisConf.SYMBOL_COLON + key, JsonUtils.objectToJson(data));
-    }
-
-    public void setUserImportId(Integer userId, Integer importId) {
-        redisUtil.set(RedisConf.USER_IMPORT + RedisConf.SYMBOL_COLON + userId, String.valueOf(importId));
-    }
-
-    public String getUserImportId(Integer userId) {
-        return redisUtil.get(RedisConf.USER_IMPORT + RedisConf.SYMBOL_COLON + userId);
-    }
-
-    public void deleteUserImport(Integer userId) {
-        redisUtil.delete(RedisConf.USER_IMPORT + RedisConf.SYMBOL_COLON + userId);
-    }
-}

+ 0 - 183
src/main/java/cn/cslg/pas/common/utils/ExcelUtils.java

@@ -1,183 +0,0 @@
-package cn.cslg.pas.common.utils;
-
-import cn.hutool.core.util.IdUtil;
-import org.apache.poi.hssf.usermodel.*;
-import org.apache.poi.ooxml.POIXMLDocumentPart;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.usermodel.*;
-import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
-
-import java.awt.*;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.util.List;
-
-public class ExcelUtils {
-
-    public static Map<String, PictureData> getDataFromExcel(String filePath) throws IOException {
-        //判断是否为excel类型文件
-        if (!filePath.endsWith(".xls") && !filePath.endsWith(".xlsx") && !filePath.endsWith(".XLS") && !filePath.endsWith(".XLSX")) {
-            System.out.println("文件不是excel类型");
-        }
-
-        FileInputStream fis = null;
-        Workbook wookbook = null;
-        Sheet sheet = null;
-        try {
-            //获取一个绝对地址的流
-            fis = new FileInputStream(filePath);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        try {
-            //2003版本的excel,用.xls结尾
-            wookbook = new HSSFWorkbook(fis);//得到工作簿
-        } catch (Exception ex) {
-            //ex.printStackTrace();
-            try {
-                //2007版本的excel,用.xlsx结尾
-                fis = new FileInputStream(filePath);
-                wookbook = new XSSFWorkbook(fis);//得到工作簿
-            } catch (IOException e) {
-                // TODO Auto-generated catch block
-                e.printStackTrace();
-            }
-        }
-        Map<String, PictureData> maplist = null;
-        //拿到excel表格的第一个sheet工作簿
-        sheet = wookbook.getSheetAt(0);
-        // 判断用07还是03的方法获取图片
-        if (filePath.endsWith(".xls") || filePath.endsWith(".XLS")) {
-            maplist = getPictures1((HSSFSheet) sheet);
-        } else if (filePath.endsWith(".xlsx") || filePath.endsWith(".XLSX")) {
-            maplist = getPictures2((XSSFSheet) sheet);
-        }
-        wookbook.close();
-        return maplist;
-    }
-
-    /**
-     * 获取图片和位置 (xls)
-     *
-     * @param sheet
-     * @return
-     * @throws IOException
-     */
-    public static Map<String, PictureData> getPictures1(HSSFSheet sheet) throws IOException {
-        Map<String, PictureData> map = new HashMap();
-        if (sheet.getDrawingPatriarch() != null) {
-            List<HSSFShape> list = sheet.getDrawingPatriarch().getChildren();
-            for (HSSFShape shape : list) {
-                if (shape instanceof HSSFPicture) {
-                    HSSFPicture picture = (HSSFPicture) shape;
-                    HSSFClientAnchor cAnchor = (HSSFClientAnchor) picture.getAnchor();
-                    PictureData pdata = picture.getPictureData();
-                    String key = String.valueOf(cAnchor.getRow1());
-                    map.put(key, pdata);
-                }
-            }
-        }
-        return map;
-    }
-
-    /**
-     * 获取图片和位置 (xlsx)
-     *
-     * @param sheet
-     * @return
-     * @throws IOException
-     */
-    public static Map<String, PictureData> getPictures2(XSSFSheet sheet) throws IOException {
-        Map<String, PictureData> map = new HashMap();
-        List<POIXMLDocumentPart> list = sheet.getRelations();
-        for (POIXMLDocumentPart part : list) {
-            if (part instanceof XSSFDrawing) {
-                XSSFDrawing drawing = (XSSFDrawing) part;
-                List<XSSFShape> shapes = drawing.getShapes();
-                for (XSSFShape shape : shapes) {
-                    XSSFPicture picture = (XSSFPicture) shape;
-                    Dimension d = picture.getImageDimension();
-                    //解决图片空指针报错问题 lig  2021-06-03
-                    XSSFClientAnchor anchor = (XSSFClientAnchor) shape.getAnchor();
-                    //XSSFClientAnchor anchor = picture.getPreferredSize();
-                    CTMarker marker = anchor.getFrom();
-                    String key = String.valueOf(marker.getRow());
-                    map.put(key, picture.getPictureData());
-                }
-            }
-        }
-        return map;
-    }
-
-    /**
-     * @param pictureData 图片
-     * @return 返回图片的文件路径和文件名称
-     */
-    public static Map<String, String> savePicture(PictureData pictureData) throws IOException {
-        FileUtils fileUtils = SpringUtils.getBean(FileUtils.class);
-        Map<String, String> result = new HashMap<>();
-        String ext = pictureData.suggestFileExtension();
-        byte[] data = pictureData.getData();
-        String picName = IdUtil.simpleUUID() + "." + ext;
-        String date = DateUtils.getNowTimeFormat("yyyyMMdd");
-        String folderPath = fileUtils.getSavePath(date);
-        String filePath = FileUtils.FILE_SEPARATOR + date + FileUtils.FILE_SEPARATOR + picName;
-        File directory = new File(folderPath);
-        if (!directory.exists()) {
-            directory.mkdir();
-        }
-        FileOutputStream out = new FileOutputStream(folderPath + picName);
-        out.write(data);
-        out.close();
-        result.put("path", filePath);
-        result.put("name", picName);
-        return result;
-    }
-
-    /**
-     * @param
-     * @param x           单元格x轴坐标
-     * @param y           单元格y轴坐标
-     * @param pictureData 图片二进制数据
-     * @param picType     图片格式
-     */
-    public static void writePicture(Sheet sheet, int x, int y, byte[] pictureData, int picType) {
-        Drawing drawingPatriarch = sheet.createDrawingPatriarch();
-        //设置图片单元格位置
-        ClientAnchor anchor = drawingPatriarch.createAnchor(0, 0, 0, 0, x, y, x + 1, y + 1);
-        //随单元格改变位置和大小
-        anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
-        //添加图片
-        int pictureIndex = sheet.getWorkbook().addPicture(pictureData, picType);
-        drawingPatriarch.createPicture(anchor, pictureIndex);
-    }
-
-    public static void setExcelCellStyle(HSSFCellStyle cellStyle) {
-        cellStyle.setBorderBottom(BorderStyle.THIN);
-        cellStyle.setBorderLeft(BorderStyle.THIN);
-        cellStyle.setBorderRight(BorderStyle.THIN);
-        cellStyle.setBorderTop(BorderStyle.THIN);
-    }
-    public static String getValue(Cell cell) {
-        if (cell != null) {
-            if (cell.getCellType() == CellType.NUMERIC && HSSFDateUtil.isCellDateFormatted(cell)) {
-                Date date = cell.getDateCellValue();
-                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                String dateString = dateFormat.format(date);
-            return dateString;
-            }
-            else{
-                return cell.toString();
-            }
-        }
-        return "";
-    }
-
-
-}

+ 0 - 243
src/main/java/cn/cslg/pas/common/utils/FileUtils.java

@@ -1,243 +0,0 @@
-package cn.cslg.pas.common.utils;
-
-import cn.cslg.pas.common.model.dto.UploadFileDTO;
-import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.util.IdUtil;
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.springframework.boot.system.ApplicationHome;
-import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
-import org.springframework.web.multipart.commons.CommonsMultipartFile;
-
-import java.io.*;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-
-@Service
-public class FileUtils {
-
-    public static final String FILE_SEPARATOR = System.getProperty("file.separator");
-    public static final String COMMON_FILE = "file";
-    public static final String BACKUP_FILE = "backup";
-
-    public static String getStaticPath(String fileName) {
-        //ApplicationHome类 返回target目录层级
-        ApplicationHome ah = new ApplicationHome(FileUtils.class);
-        //获取 applicationHome 内的路径 ...\target\classes 到这一层级下
-        File file = ah.getSource();
-        //获取 file的parentFile 即最后一级之前的所有层级路径(包括盘符) 这里能获得到的最终层级为  ...\target 后续用FILE_SEPARATOR(系统路径分割通配符 即 "\") 以及fileName拼接生成存放文件的目录层级 即为根目录 root
-        String rootPath = file.getParentFile().toString() + FILE_SEPARATOR + fileName;
-        //根据上方生成的根目录路径 生成对应文件夹 没有就新建
-        File root = new File(rootPath);
-        if (!root.exists()) {
-            root.mkdir();
-        }
-        //返回的最终形式为 盘符:\项目层级\target\file
-        return rootPath;
-    }
-
-    public UploadFileDTO uploadFile(MultipartFile file) {
-        UploadFileDTO fileDTO = new UploadFileDTO();
-        //以下操作为 先取得传入文件的完整文件名 (文件名 + 后缀) 然后用FileUtil分别取出 文件名 和 不带 "." 的后缀 然后将这些内容装配进 实体中
-        //file.getOriginFilename 获取源文件
-        //FileUtil.getPrefix 返回主文件名
-        fileDTO.setName(FileUtil.getPrefix(file.getOriginalFilename()));
-        //FileUtil.extName 获取文件的扩展名(后缀名),扩展名不带 "."
-        fileDTO.setExtName(FileUtil.extName(file.getOriginalFilename()));
-        //获取目录名 用时间作为目录名称
-        String directoryName = this.getDirectoryName();
-        //用IdUtil生成的UUID 与实体中的 extName(后缀名) 拼接后作为文件名 simpleUUID与randomUUID的区别是 simpleUUID 没有 "-"
-        String fileName = IdUtil.simpleUUID() + "." + fileDTO.getExtName();
-        //将完整文件名进行装配
-        fileDTO.setFileName(fileName);
-        //生成存储文件的路径
-        String savePath = this.getSavePath(directoryName);
-        //根据生成存储文件的路径 生成对应文件夹 没有就新建
-        File directory = new File(savePath);
-        if (!directory.exists()) {
-            directory.mkdir();
-        }
-        this.saveFile(file, savePath + fileName);
-        fileDTO.setPath(FILE_SEPARATOR + directoryName + FILE_SEPARATOR + fileName);
-        fileDTO.setFileSize(file.getSize());
-        return fileDTO;
-    }
-
-    public String createDirectory() {
-        String directoryName = this.getDirectoryName();
-        String savePath = this.getSavePath(directoryName);
-        File directory = new File(savePath);
-        if (!directory.exists()) {
-            directory.mkdir();
-        }
-        return directoryName;
-    }
-
-    public void saveFile(MultipartFile file, String path) {
-        try {
-            file.transferTo(new File(path));
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    public String getTempPath(String fileName) {
-        String tempPath = getStaticPath(COMMON_FILE) + FILE_SEPARATOR + "temp";
-        File file = new File(tempPath);
-        if (!file.exists()) {
-            file.mkdir();
-        }
-        return tempPath + FILE_SEPARATOR + fileName;
-    }
-
-    public String getSavePath(String directoryName) {
-        return getStaticPath(COMMON_FILE) + FILE_SEPARATOR + directoryName + FILE_SEPARATOR;
-    }
-
-    public String getDirectory(String fileName) {
-        return FILE_SEPARATOR + this.createDirectory() + FILE_SEPARATOR + fileName;
-    }
-
-    public String getDirectory2(String directoryName) {
-        return FILE_SEPARATOR + directoryName + FILE_SEPARATOR;
-    }
-
-    public String getSystemPath(String url) {
-        return getStaticPath(COMMON_FILE) + FILE_SEPARATOR + url;
-    }
-
-    public String getSystemPath() {
-        return getStaticPath(COMMON_FILE);
-    }
-
-    public String getDirectoryName() {
-        return DateUtils.getNowTimeFormat("yyyyMMdd");
-    }
-
-    public String getPath(String url) {
-        return getStaticPath(COMMON_FILE) + url;
-    }
-
-    public String analysisJsonFile() {
-        ApplicationHome ah = new ApplicationHome(BackupUtils.class);
-        File file = ah.getSource();
-        String settingFilePath = file.getParentFile().toString() + FileUtils.FILE_SEPARATOR + "uploadSetting.json";
-        BufferedReader reader = null;
-        StringBuilder last = new StringBuilder();
-        InputStreamReader inputStreamReader;
-        try (FileInputStream fileInputStream = new FileInputStream(settingFilePath)) {
-            inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8);
-
-            reader = new BufferedReader(inputStreamReader);
-            String tempString;
-            while ((tempString = reader.readLine()) != null) {
-                last.append(tempString);
-            }
-            reader.close();
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            if (reader != null) {
-                try {
-                    reader.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        return last.toString();
-    }
-    public String analysisJsonFile(String fileName) {
-        ApplicationHome ah = new ApplicationHome(BackupUtils.class);
-        File file = ah.getSource();
-        String settingFilePath = file.getParentFile().toString() + FileUtils.FILE_SEPARATOR + "uploadSetting.json";
-        BufferedReader reader = null;
-        StringBuilder last = new StringBuilder();
-        InputStreamReader inputStreamReader;
-        try (FileInputStream fileInputStream = new FileInputStream(settingFilePath)) {
-            inputStreamReader = new InputStreamReader(fileInputStream, StandardCharsets.UTF_8);
-
-            reader = new BufferedReader(inputStreamReader);
-            String tempString;
-            while ((tempString = reader.readLine()) != null) {
-                last.append(tempString);
-            }
-            reader.close();
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            if (reader != null) {
-                try {
-                    reader.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        return last.toString();
-    }
-
-    public static MultipartFile fileToMultipartFile(File file) {
-        DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(16, null);
-        FileItem item = diskFileItemFactory.createItem(file.getName(), "text/plain", true, file.getName());
-        int bytesRead = 0;
-        byte[] buffer = new byte[8192];
-        try {
-            FileInputStream fis = new FileInputStream(file);
-            OutputStream os = item.getOutputStream();
-            int len = 8192;
-            while ((bytesRead = fis.read(buffer, 0, len)) != -1) {
-                os.write(buffer, 0, bytesRead);
-            }
-            os.close();
-            fis.close();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return (MultipartFile) new CommonsMultipartFile(item);
-    }
-
-    public static File getFile(String url) throws Exception {
-        //读取图片类型
-        String fileName = url.substring(url.lastIndexOf("."), url.length());
-        File file = null;
-
-        URL urlfile;
-        InputStream inStream = null;
-        OutputStream os = null;
-        try {
-            file = File.createTempFile("new_url", ".jpg");
-            //获取文件
-            urlfile = new URL(url);
-            inStream = urlfile.openStream();
-            os = new FileOutputStream(file);
-
-            int bytesRead = 0;
-            byte[] buffer = new byte[8192];
-            while ((bytesRead = inStream.read(buffer, 0, 8192)) != -1) {
-                os.write(buffer, 0, bytesRead);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            try {
-                if (null != os) {
-                    os.close();
-                }
-                if (null != inStream) {
-                    inStream.close();
-                }
-
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-
-        return file;
-    }
-
-
-}
-

+ 0 - 321
src/main/java/cn/cslg/pas/common/utils/PatentRightUtils.java

@@ -1,321 +0,0 @@
-package cn.cslg.pas.common.utils;
-
-import cn.cslg.pas.common.model.params.PatentRightParams;
-import cn.cslg.pas.domain.PatentRight;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * 拆分权要工具类
- *
- * @Author chenyu
- * @Date 2023/4/25
- */
-public class PatentRightUtils {
-
-    public static List<PatentRight> formatPatentRight(PatentRightParams params) {
-        try {
-            //国家
-            String country = params.getPatentNo().substring(0, 2);
-            //原文
-            String content = params.getContent();
-            //译文
-            String contentOut = params.getContentOut();
-
-            //创建一个权要集合
-            ArrayList<PatentRight> patentRights = new ArrayList<>();
-
-            //若原文为null或空串,则直接结束并返回空集合;若译文为null,则置为空串
-            if (content == null || content.equals("")) {
-                return patentRights;
-            }
-
-            if (contentOut == null) {
-                contentOut = "";
-            }
-
-            //将原文和译文的所有换行符 "\r\n"或是"\n" 替换成 "$#&@",这样首先可以使得全文连在一起,其次再根据特殊符号$#&@拆分权要
-            if (content.contains("\r\n")) {
-                content = content.replaceAll("\r\n", "$#&@");
-            }
-            if (content.contains("\n")) {
-                content = content.replaceAll("\n", "$#&@");
-            }
-
-            if (contentOut.contains("\r\n")) {
-                contentOut = contentOut.replaceAll("\r\n", "$#&@");
-            }
-            if (contentOut.contains("\n")) {
-                contentOut = contentOut.replaceAll("\n", "$#&@");
-            }
-
-            //去掉译文的所有空格
-            contentOut = contentOut.replaceAll(" +", "");
-
-            //中日韩权要↓
-            if (country.equals("CN") || country.equals("JP") || country.equals("KR") || content.contains("权利要求")) {
-                String regex;
-                if (content.contains("$#&@2")) {
-                    regex = "\\$#&@[0-9]+";
-                } else if (content.contains("$#&@[00")) {
-                    regex = "\\$#&@\\[[0-9]+]";
-                } else if (content.contains("$#&@請求項")) {
-                    regex = "\\$#&@【請求項[0-9]+】";
-                } else if (content.contains("$#&@청구항")) {
-                    regex = "\\$#&@청구항 [0-9]+";
-                } else {
-                    regex = "";
-                }
-                String[] strs;  //原文数组
-                String[] strsOut;  //译文数组
-                //若以上没有匹配到,则权要直接以句号 "。" 拆分
-                if (regex.equals("")) {
-                    content = content.replaceAll("\\$#&@", "");
-                    contentOut = contentOut.replaceAll("\\$#&@", "");
-                    strs = content.split("。");
-                    strsOut = contentOut.split("。");
-                    //若匹配到,则根据不同情形拆分
-                } else {
-                    Matcher matcher = Pattern.compile(regex).matcher(content);
-                    Matcher matcherOut = Pattern.compile(regex).matcher(contentOut);
-                    while (matcher.find()) {
-                        content = content.replaceFirst(matcher.group(), "\n" + matcher.group().substring(matcher.group().indexOf("$#&@") + 1));
-                    }
-                    while (matcherOut.find()) {
-                        contentOut = contentOut.replaceFirst(matcherOut.group(), "\n" + matcherOut.group().substring(matcherOut.group().indexOf("$#&@") + 1));
-                    }
-                    content = content.replaceAll("\\$#&@", "");
-                    contentOut = contentOut.replaceAll("\\$#&@", "");
-                    strs = content.split("\n");
-                    strsOut = contentOut.split("\n");
-                }
-                //定义父权要排序号
-                String regex1 = "权利要求[0-9]+";
-                String regex2 = "权利要求[0-9]+[至或~-]+[0-9]+";
-                for (int i = 0; i < strs.length; i++) {
-                    //之前:if (strs[i].contains("权利要求")) {
-                    //现在:if(该权要有逗号,并且它第一句话中有"权利要求"4个字 || 该权要没有逗号,并且它有"权利要求"4个字) {
-                    if ((strs[i].contains(",") && strs[i].substring(0, strs[i].indexOf(",")).contains("权利要求")) || (!strs[i].contains(",") && strs[i].contains("权利要求"))) {
-                        Matcher matcher1 = Pattern.compile(regex1).matcher(strs[i]);
-                        Matcher matcher2 = Pattern.compile(regex2).matcher(strs[i]);
-                        if (matcher2.find()) {
-                            String parentNum = matcher2.group().substring(matcher2.group().indexOf("求") + 1);
-                            String[] parentNums;
-                            if (parentNum.contains("~")) {
-                                parentNums = parentNum.split("~");
-                            } else if (parentNum.contains("-")) {
-                                parentNums = parentNum.split("-");
-                            } else if (parentNum.contains("至")) {
-                                parentNums = parentNum.split("至");
-                            } else if (parentNum.contains("或")) {
-                                parentNums = parentNum.split("或");
-                            } else {
-                                parentNums = new String[0];
-                            }
-                            StringBuilder builder = new StringBuilder();
-                            for (int j = Integer.parseInt(parentNums[0]) - 1; j < Integer.parseInt(parentNums[parentNums.length - 1]); j++) {
-                                if ((builder + "").equals("")) {
-                                    builder.append(j);
-                                } else {
-                                    builder.append(",").append(j);
-                                }
-                            }
-                            PatentRight patentRight = new PatentRight()
-                                    .setPatentId(params.getPatentId())
-                                    .setType(0)
-                                    .setContent(strs[i])
-                                    .setSort(i)
-                                    .setParentSort(builder + "");
-                            if (strsOut.length - 1 >= i) {
-                                //当翻译的长度大于原文权要的长度时,将剩下所有的译文给最后一条原文
-                                if (strsOut.length > strs.length && strs.length == (i + 1)) {
-                                    patentRight.setContentOut(String.join(" ", Arrays.copyOfRange(strsOut, i, strsOut.length)));
-                                } else {
-                                    patentRight.setContentOut(strsOut[i]);
-                                }
-                            }
-                            patentRights.add(patentRight);
-                        } else if (matcher1.find()) {
-                            String parentNum = matcher1.group().substring(matcher1.group().indexOf("求") + 1);
-                            PatentRight patentRight = new PatentRight()
-                                    .setPatentId(params.getPatentId())
-                                    .setType(0)
-                                    .setContent(strs[i])
-                                    .setSort(i)
-                                    .setParentSort((Integer.parseInt(parentNum) - 1) + "");
-                            if (strsOut.length - 1 >= i) {
-                                patentRight.setContentOut(strsOut[i]);
-                            }
-                            patentRights.add(patentRight);
-                        }
-
-                    } else {
-                        PatentRight patentRight = new PatentRight()
-                                .setPatentId(params.getPatentId())
-                                .setType(1)
-                                .setContent(strs[i])
-                                .setSort(i)
-                                .setParentSort("-1");
-                        if (strsOut.length - 1 >= i) {
-                            //当翻译的长度大于原文权要的长度时,将剩下所有的译文给最后一条原文
-                            if (strsOut.length > strs.length && strs.length == (i + 1)) {
-                                patentRight.setContentOut(String.join(" ", Arrays.copyOfRange(strsOut, i, strsOut.length)));
-                            } else {
-                                patentRight.setContentOut(strsOut[i]);
-                            }
-                        }
-                        patentRights.add(patentRight);
-                    }
-                }
-                //英文专利的权要拆分 ↓
-            } else {
-                if (!content.equals("") && content.contains("1")) {
-                    content = content.substring(content.indexOf("1"));
-                }
-                if (!contentOut.equals("") && contentOut.contains("1")) {
-                    contentOut = contentOut.substring(contentOut.indexOf("1"));
-                }
-
-                String regex;
-                if (content.contains("$#&@2")) {
-                    regex = "\\$#&@[0-9]+";
-                } else if (content.contains("[001]")) {
-                    regex = "\\[[0-9]+]";
-                } else {
-                    regex = "";
-                }
-
-                Matcher matcher = Pattern.compile(regex).matcher(content);
-                Matcher matcherOut = Pattern.compile(regex).matcher(contentOut);
-                while (matcher.find()) {
-                    content = content.replaceFirst(matcher.group(), "\n" + matcher.group().substring(matcher.group().indexOf("$#&@") + 1));
-                }
-                while (matcherOut.find()) {
-                    contentOut = contentOut.replaceFirst(matcherOut.group(), "\n" + matcherOut.group().substring(matcherOut.group().indexOf("$#&@") + 1));
-                }
-                content = content.replaceAll("\\$#&@", "");
-                contentOut = contentOut.replaceAll("\\$#&@", "");
-                String[] strs = content.split("\n");
-                String[] strsOut = contentOut.split("\n");
-
-                //定义父权要排序号
-                String regex1 = "claim [0-9]+";
-                String regex2 = "claims [0-9]+ or [0-9]+";
-                String regex3 = "any preceding claim";
-                for (int i = 0; i < strs.length; i++) {
-                    if (strs[i].contains("claim")) {
-                        Matcher matcher1 = Pattern.compile(regex1).matcher(strs[i]);
-                        Matcher matcher2 = Pattern.compile(regex2).matcher(strs[i]);
-                        Matcher matcher3 = Pattern.compile(regex3).matcher(strs[i]);
-                        if (matcher2.find()) {
-                            String parentNum = matcher2.group().substring(matcher2.group().indexOf("s") + 2);
-                            String[] parentNums;
-                            if (parentNum.contains(" or ")) {
-                                parentNums = parentNum.split(" or ");
-                            } else if (parentNum.contains(" - ")) {
-                                parentNums = parentNum.split(" - ");
-                            } else if (parentNum.contains(" to ")) {
-                                parentNums = parentNum.split(" to ");
-                            } else {
-                                parentNums = new String[0];
-                            }
-                            StringBuilder builder = new StringBuilder();
-                            for (int j = Integer.parseInt(parentNums[0]) - 1; j < Integer.parseInt(parentNums[parentNums.length - 1]); j++) {
-                                if ((builder + "").equals("")) {
-                                    builder.append(j);
-                                } else {
-                                    builder.append(",").append(j);
-                                }
-                            }
-                            PatentRight patentRight = new PatentRight()
-                                    .setPatentId(params.getPatentId())
-                                    .setType(0)
-                                    .setContent(strs[i])
-                                    .setSort(i)
-                                    .setParentSort(builder + "");
-                            if (strsOut.length - 1 >= i) {
-                                //当翻译的长度大于原文权要的长度时,将剩下所有的译文给最后一条原文
-                                if (strsOut.length > strs.length && strs.length == (i + 1)) {
-                                    patentRight.setContentOut(String.join(" ", Arrays.copyOfRange(strsOut, i, strsOut.length)));
-                                } else {
-                                    patentRight.setContentOut(strsOut[i]);
-                                }
-                            }
-                            patentRights.add(patentRight);
-                        } else if (matcher1.find()) {
-                            String parentNum = matcher1.group().substring(matcher1.group().indexOf("m") + 2);
-                            PatentRight patentRight = new PatentRight()
-                                    .setPatentId(params.getPatentId())
-                                    .setType(0)
-                                    .setContent(strs[i])
-                                    .setSort(i)
-                                    .setParentSort((Integer.parseInt(parentNum) - 1) + "");
-                            if (strsOut.length - 1 >= i) {
-                                //当翻译的长度大于原文权要的长度时,将剩下所有的译文给最后一条原文
-                                if (strsOut.length > strs.length && strs.length == (i + 1)) {
-                                    patentRight.setContentOut(String.join(" ", Arrays.copyOfRange(strsOut, i, strsOut.length)));
-                                } else {
-                                    patentRight.setContentOut(strsOut[i]);
-                                }
-                            }
-                            patentRights.add(patentRight);
-                        } else if (matcher3.find()) {
-                            StringBuilder builder = new StringBuilder();
-                            for (int sort = 0; sort < strs.length; sort++) {
-                                if (sort == i) {
-                                    continue;
-                                }
-                                builder.append(i).append(",");
-                            }
-                            PatentRight patentRight = new PatentRight()
-                                    .setPatentId(params.getPatentId())
-                                    .setType(0)
-                                    .setContent(strs[i])
-                                    .setSort(i)
-                                    .setParentSort(builder.substring(0, builder.lastIndexOf(",")));
-                            if (strsOut.length - 1 >= i) {
-                                //当翻译的长度大于原文权要的长度时,将剩下所有的译文给最后一条原文
-                                if (strsOut.length > strs.length && strs.length == (i + 1)) {
-                                    patentRight.setContentOut(String.join(" ", Arrays.copyOfRange(strsOut, i, strsOut.length)));
-                                } else {
-                                    patentRight.setContentOut(strsOut[i]);
-                                }
-                            }
-                            patentRights.add(patentRight);
-                        }
-
-                    } else {
-                        PatentRight patentRight = new PatentRight()
-                                .setPatentId(params.getPatentId())
-                                .setType(1)
-                                .setContent(strs[i])
-                                .setSort(i)
-                                .setParentSort("-1");
-                        if (strsOut.length - 1 >= i) {
-                            //当翻译的长度大于原文权要的长度时,将剩下所有的译文给最后一条原文
-                            if (strsOut.length > strs.length && strs.length == (i + 1)) {
-                                patentRight.setContentOut(String.join(" ", Arrays.copyOfRange(strsOut, i, strsOut.length)));
-                            } else {
-                                patentRight.setContentOut(strsOut[i]);
-                            }
-                        }
-                        patentRights.add(patentRight);
-                    }
-                }
-            }
-
-            return patentRights;
-        } catch (Exception e) {
-            e.printStackTrace();
-            ArrayList<PatentRight> patentRights = new ArrayList<>();
-            patentRights.add(new PatentRight().setPatentId(params.getPatentId()).setContent(params.getContent()).setContentOut(params.getContentOut()).setType(1).setSort(0).setParentSort("-1"));
-            return patentRights;
-        }
-    }
-
-}

+ 0 - 220
src/main/java/cn/cslg/pas/common/utils/PatentUtils.java

@@ -1,220 +0,0 @@
-package cn.cslg.pas.common.utils;
-
-import cn.cslg.pas.common.core.base.Constants;
-import cn.cslg.pas.domain.PatentAffair;
-import cn.cslg.pas.domain.PatentApplicant;
-import cn.cslg.pas.domain.ProjectFieldTree;
-import cn.cslg.pas.common.model.dto.ClassNumberDTO;
-import cn.hutool.core.util.StrUtil;
-
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
-public class PatentUtils {
-
-    /**
-     * 直辖市
-     */
-    public static final List<String> CHARTERED_CITIES = Arrays.asList("北京市", "天津市", "重庆市", "上海市");
-
-    public static String getMapKeyByValue(Map<String, String> map, String value) {
-        for (String key : map.keySet()) {
-            if (map.get(key).equals(value)) {
-                return key;
-            }
-        }
-        return null;
-    }
-
-    public static Integer getIntKeyByValue(Map<String, String> map, String value) {
-        String key = getMapKeyByValue(map, value);
-        if (key != null) {
-            return Integer.parseInt(key);
-        }
-        return 0;
-    }
-
-    public static Integer getIntKeyByOrganType(String name) {
-        if (name.length() < 4) {
-            return 1;
-        }
-        if (Arrays.asList("大学", "学院", "学校").contains(name.substring(name.length() - 2))) {
-            return 3;
-        }
-        if (Arrays.asList("研究所", "研究所").contains(name.substring(name.length() - 3)) || "研究总院".equals(name.substring(name.length() - 4))) {
-            return 4;
-        }
-        return 2;
-    }
-
-    public static List<String> formatValue(String string) {
-        return StringUtils.changeStringToString(string.replaceAll(" ", ""), "\\|");
-    }
-
-    public static List<String> formatValue2(String string) {
-        return StringUtils.changeStringToString(string.replaceAll(">", ""), "\\\n");
-    }
-
-    public static String getPatentCountry(String patentNo) {
-        return StrUtil.sub(patentNo, 0, 2);
-    }
-
-    public static String formatAddress(String address, Integer level) {
-        for (String name : CHARTERED_CITIES) {
-            if (address.contains(name)) {
-                if (level == 1 || level == 2) {
-                    return name;
-                } else {
-                    return StrUtil.sub(address, address.indexOf("市") + 1, address.indexOf("区") + 1);
-                }
-            }
-        }
-        String a = removeStringNotChinese(address);
-        switch (level) {
-            case 1:
-                return StrUtil.sub(a, 0, a.indexOf("省") + 1);
-            case 2:
-                return StrUtil.sub(a, a.indexOf("省") + 1, a.indexOf("市") + 1);
-            case 3:
-                return StrUtil.sub(a, a.indexOf("市") + 1, a.indexOf("区") + 1);
-        }
-        return "暂无";
-    }
-
-    private static String removeStringNotChinese(String address) {
-        String tmpString = address.replaceAll("(?i)[^a-zA-Z0-9\u4E00-\u9FA5]", "");
-        char[] carr = tmpString.toCharArray();
-        for (int i = 0; i < tmpString.length(); i++) {
-            if (carr[i] < 0xFF) {
-                carr[i] = ' ';
-            }
-        }
-        return String.copyValueOf(carr).trim();
-    }
-
-    public static ClassNumberDTO getClassNumberDTO(String classNumber, Integer type) {
-        ClassNumberDTO dto = new ClassNumberDTO();
-        dto.setClassNumber(classNumber);
-        switch (type) {
-            case 1:
-            case 2:
-                dto.setA(StrUtil.sub(classNumber, 0, 1));
-                dto.setB(StrUtil.sub(classNumber, 0, 3));
-                dto.setC(StrUtil.sub(classNumber, 0, 4));
-                dto.setD(StrUtil.sub(classNumber, 0, classNumber.indexOf("/")));
-                dto.setE(classNumber);
-                break;
-            case 3:
-                String[] a = StrUtil.split(classNumber, "/");
-                dto.setB(a[0]);
-                dto.setC(a[1]);
-                break;
-            case 4:
-                String[] b = StrUtil.split(classNumber, "-");
-                dto.setB(b[0]);
-                dto.setC(b[1]);
-                break;
-        }
-        return dto;
-    }
-
-    public static String getPeopleCountry(List<PatentApplicant> people) {
-        if (people.size() != 0) {
-            return people.get(0).getCountry();
-        }
-        return "";
-    }
-
-    public static String getPeopleAddress(List<PatentApplicant> people) {
-        if (people.size() != 0) {
-            return people.get(0).getAddressStr();
-        }
-        return "";
-    }
-
-    public static String getPeopleProvinceAndCityAndArea(List<PatentApplicant> people) {
-        if (people.size() != 0) {
-            return "";
-        }
-        return "";
-    }
-
-    public static String getPatentAffair(List<PatentAffair> affairList, Integer type) {
-        if (affairList.size() == 0) {
-            return "";
-        }
-        PatentAffair affair = affairList.get(0);
-        switch (type) {
-            case 0:
-                return DateUtils.formatDate(affair.getDateTime(), DateUtils.YYYY_MM_DD);
-            case 1:
-                return affair.getCreateStatus();
-            case 2:
-                return affair.getCreateSimpleStatus();
-            case 3:
-                return StringUtils.join(affairList.stream().map(PatentAffair::getContent).collect(Collectors.toList()), Constants.SEPARATOR_VERTICAL_BAR);
-            default:
-                return "";
-        }
-    }
-
-    public static String getTreeNodeFullName(List<ProjectFieldTree> treeList, String path) {
-        List<String> paths = StringUtils.changeStringToString(path, "/");
-        List<String> fullName = new ArrayList<>();
-        paths.forEach(id -> fullName.add(treeList.stream().filter(item -> item.getId().equals(Integer.parseInt(id))).findFirst().orElse(new ProjectFieldTree()).getName()));
-        return StringUtils.join(fullName, "\\");
-    }
-
-    public static List<String> getPatentLicensor(String text) {
-        return Arrays.stream(text.replaceAll("\n", "").split("[0-99]\\.")).filter(StringUtils::isNotEmpty).collect(Collectors.toList());
-    }
-
-    public static String formatTextQuerySql(String content, String keyword) {
-        String space = " ";
-        String like = " LIKE ";
-        String notLike = " NOT LIKE ";
-        String left = "'%";
-        String right = "%'";
-        String placeholder = "#";
-        Pattern patten = Pattern.compile(" OR | AND ");
-        Matcher matcher = patten.matcher(content);
-        String copy = matcher.replaceAll(placeholder);
-        String[] querys = StringUtils.split(copy, placeholder);
-        List<String> queryList = new ArrayList<>();
-
-        if (content.split(",").length > 1) {
-            String[] a = content.split(",");
-            StringBuffer sb = new StringBuffer();
-
-            for (int j = 0; j < a.length; j++) {
-                content = sb.append(keyword).append(like).append(left).append(a[j]).append(right).append(" or ").toString();
-
-                if (j == a.length - 1) {
-                    content = sb.delete(sb.length() - 4, sb.length()).toString();
-
-                }
-            }
-        } else {
-            for (int i = 0; i < querys.length; i++) {
-                String query = querys[i].replaceAll("\\(|\\)", "");
-                queryList.add(query);
-                content = content.replaceFirst(query, i + placeholder);
-            }
-            for (int i = 0; i < queryList.size(); i++) {
-                StringBuffer sb = new StringBuffer();
-                content = content.replaceAll(i + placeholder, sb.append(keyword).append(like).append(left).append(queryList.get(i)).append(right).toString());
-            }
-        }
-        return content;
-    }
-
-    public static void main(String[] args) {
-//        System.out.println(formatTextQuerySql("(一种 OR 测试) AND 测试2 AND (测试 OR A method)", "a.name"));
-        System.out.println(formatTextQuerySql("(A method for manufacturing OR A test) AND 测试", "a.name"));
-        System.out.println(formatTextQuerySql("CN", "a.name"));
-        System.out.println(formatTextQuerySql("CN OR CM AND SD", "a.name"));
-        System.out.println(formatTextQuerySql("CN OR CM AND CM", "a.name"));
-    }
-}

+ 0 - 220
src/main/java/cn/cslg/pas/common/utils/ReadExcelUtils.java

@@ -1,220 +0,0 @@
-package cn.cslg.pas.common.utils;
-
-import cn.cslg.pas.domain.PatentData;
-import org.apache.poi.hssf.usermodel.*;
-import org.apache.poi.ooxml.POIXMLDocumentPart;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.usermodel.*;
-import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
-import org.springframework.stereotype.Service;
-
-import java.awt.*;
-import java.io.*;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @Author xiexiang
- * @Date 2023/5/30
- */
-@Service
-public class ReadExcelUtils {
-    /**
-     * 检测Excel文件合法性
-     *
-     * @param tempFile 临时文件
-     * @return 返回文件总行数
-     */
-    public static Integer textExcel(File tempFile, String sourceId) throws IOException {
-        //判断文件是否存在
-        if (!tempFile.exists() || tempFile.getPath().trim().equals("")) {
-            ThrowException.throwXiaoShiException("文件上传失败,服务器忙请稍后再试!");
-        }
-
-        // 检测是否为excel文件
-        String suffix = tempFile.getPath().substring(tempFile.getPath().lastIndexOf("."));
-        if (!suffix.equals(".xls") && !suffix.equals(".xlsx") && !suffix.equals(".XLS") && !suffix.equals(".XLSX")) {
-            //删除临时文件tempFile
-            new File(tempFile.getPath()).delete();
-            ThrowException.throwXiaoShiException("文件格式错误,请上传Excel文件!");
-        }
-
-        InputStream fis = new FileInputStream(tempFile);
-        //使用poi框架解析处理Excel文件
-        Workbook workbook = null;
-        //区分不同版本Excel,使用各自对应的工具类
-        if (suffix.equals(".xls") || suffix.equals(".XLS")) {
-            workbook = new HSSFWorkbook(fis);
-        } else if (suffix.equals(".xlsx") || suffix.equals(".XLSX")) {
-            workbook = new XSSFWorkbook(fis);
-        }
-        //读取第几个sheet
-        Sheet sheet = workbook.getSheetAt(0);
-        //读取总行数
-        int rows = sheet.getPhysicalNumberOfRows();
-        if (rows <= 1) {
-            //删除临时文件tempFile
-            fis.close();
-            new File(tempFile.getPath()).delete();
-            ThrowException.throwXiaoShiException("文件内容格式不正确,请检查总行数是否有专利内容");
-        }
-
-        //获取第一行抬头
-        Row firstRow = sheet.getRow(0);
-        boolean flag1 = false;  //是否有 "公开(公告)号"
-        boolean flag2 = false;  //是否有 "申请号"
-        //遍历第一行单元格抬头,检查合法性
-        String title = "", source = "";
-        if (sourceId.equals("1")) {
-            source = "智慧芽";
-            title = "公开(公告)号";
-        } else if (sourceId.equals("2")) {
-            source = "合享";
-            title = "公开(公告)号";
-        } else {
-            source = "Patentics";
-            title = "公开号";
-        }
-        for (Cell cell : firstRow) {
-            if (cell.getStringCellValue().equals(title)) {
-                flag1 = true;
-            }
-            if (cell.getStringCellValue().equals("申请号")) {
-                flag2 = true;
-            }
-        }
-        if (!flag1 || !flag2) {
-            //删除临时文件tempFile
-            fis.close();
-            new File(tempFile.getPath()).delete();
-            ThrowException.throwXiaoShiException("文件内容格式不正确,您选择【" + source + "】来源,Excel第一行抬头必须有【" + title + "】和【申请号】");
-        }
-
-        //关闭流
-        fis.close();
-
-        //返回文件总行数-1(即专利总数量)
-        return rows - 1;
-    }
-
-    /**
-     * 获取一行专利的全部数据(专利内容数据 + 摘要附图)
-     *
-     * @param tempFile Excel临时文件
-     * @param row      行数
-     * @return 返回装载专利数据(专利内容数据 + 摘要附图)的对象
-     */
-    public static PatentData readExcelOneRow(File tempFile, Sheet sheet, int row) throws IOException {
-        //创建返回最终结果的对象 patentData
-        PatentData patentData = new PatentData();
-        //装载专利数据(除了摘要附图)的map:(key:表头如 "公开(公告)号"  value:表头对应内容如 "CN1307082B")
-        Map<Object, Object> map = new HashMap<>();
-        //装载摘要附图的对象
-        PictureData pictureData = null;
-
-        //开始装载专利数据
-        Row firstRow = sheet.getRow(0);
-        Row needRow = sheet.getRow(row);
-        //获得总列数
-        int columns = firstRow.getLastCellNum();
-        for (int i = 0; i < columns; i++) {
-            map.put(firstRow.getCell(i) + "", ExcelUtils.getValue(needRow.getCell(i)) + "");
-        }
-
-        //开始装载专利摘要附图(判断用07还是03的方法获取图片)
-        String suffix = tempFile.getName().substring(tempFile.getName().lastIndexOf("."));
-        if (suffix.equals(".xls") || suffix.equals(".XLS")) {
-            pictureData = getPictures1((HSSFSheet) sheet, row);
-        } else if (suffix.equals(".xlsx") || suffix.equals(".XLSX")) {
-            pictureData = getPictures2((XSSFSheet) sheet, row);
-        }
-
-        //返回结果对象装载结果
-        patentData.setMap(map);
-        patentData.setPictureData(pictureData);
-
-        return patentData;
-    }
-
-    public static Sheet readExcel(File tempFile) {
-        Sheet sheet = null;
-
-        try {
-            InputStream inputStream = new FileInputStream(tempFile);
-            //POI可以处理Excel文件
-            Workbook workbook = null;
-            //当文件以.xls结尾时
-            String suffix = tempFile.getName().substring(tempFile.getName().lastIndexOf("."));
-            if (suffix.equals(".xls") || suffix.equals(".XLS")) {
-                workbook = new HSSFWorkbook(inputStream);
-            } else if (suffix.equals(".xlsx") || suffix.equals(".XLSX")) {
-                workbook = new XSSFWorkbook(inputStream);
-            }
-
-            //读取第几个sheet
-            sheet = workbook.getSheetAt(0);
-
-            //关闭流
-            inputStream.close();
-
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-        return sheet;
-    }
-
-    /**
-     * 03版本Excel取附图
-     *
-     * @param sheet Excel工作簿
-     * @return 返回附图map
-     */
-    public static PictureData getPictures1(HSSFSheet sheet, Integer row) throws IOException {
-        if (sheet.getDrawingPatriarch() != null) {
-            List<HSSFShape> list = sheet.getDrawingPatriarch().getChildren();
-            for (HSSFShape shape : list) {
-                if (shape instanceof HSSFPicture) {
-                    HSSFPicture picture = (HSSFPicture) shape;
-                    HSSFClientAnchor cAnchor = (HSSFClientAnchor) picture.getAnchor();
-                    int row1 = cAnchor.getRow1();
-                    if (row1 == row) {
-                        return picture.getPictureData();
-                    }
-                }
-            }
-        }
-        return null;
-    }
-
-    /**
-     * 07版本Excel取附图
-     *
-     * @param sheet Excel工作簿
-     * @return 返回附图map
-     */
-    public static PictureData getPictures2(XSSFSheet sheet, Integer row) throws IOException {
-        List<POIXMLDocumentPart> list = sheet.getRelations();
-        for (POIXMLDocumentPart part : list) {
-            if (part instanceof XSSFDrawing) {
-                XSSFDrawing drawing = (XSSFDrawing) part;
-                List<XSSFShape> shapes = drawing.getShapes();
-                for (XSSFShape shape : shapes) {
-                    //解决图片空指针报错问题 lig  2021-06-03
-                    XSSFClientAnchor anchor = (XSSFClientAnchor) shape.getAnchor();
-                    //XSSFClientAnchor anchor = picture.getPreferredSize();
-                    CTMarker marker = anchor.getFrom();
-                    int excelRow = marker.getRow();
-                    if (excelRow == row) {
-                        XSSFPicture picture = (XSSFPicture) shape;
-                        return picture.getPictureData();
-                    }
-                }
-            }
-        }
-
-        return null;
-    }
-
-}

+ 0 - 18
src/main/java/cn/cslg/pas/common/utils/ThrowException.java

@@ -1,18 +0,0 @@
-package cn.cslg.pas.common.utils;
-
-import cn.cslg.pas.exception.XiaoShiException;
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * @Author chenyu
- * @Date 2023/4/2
- */
-@Slf4j
-public class ThrowException {
-
-    public static void throwXiaoShiException(String message) {
-        log.info("{}", message);
-        throw new XiaoShiException(message);
-    }
-
-}

+ 0 - 241
src/main/java/cn/cslg/pas/common/utils/UploadPatentBatchUtil.java

@@ -1,241 +0,0 @@
-package cn.cslg.pas.common.utils;
-
-import cn.cslg.pas.common.model.vo.ProjectImportPatentVO;
-import cn.cslg.pas.common.model.vo.UploadParamsVO;
-import cn.cslg.pas.common.model.vo.UploadSettingVO;
-import cn.cslg.pas.common.utils.handler.DataProcessHandler;
-import cn.cslg.pas.common.utils.handler.StringSpecialHandler;
-import org.springframework.stereotype.Component;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * @date 2022/7/7
- * @description 批量上传专利数据的数据处理工具类
- */
-
-@Component
-public class UploadPatentBatchUtil {
-    /**
-     * @param projectImportPatentVO 前台传入参数
-     * @param getSettingJson        配置文件解析出的Json串
-     * @return uploadParamsVO 返回一个由processData方法填充完数据的Pojo类
-     * @date 2022/7/7
-     * @name 解析配置文件
-     * @description 通过与前段传入参数中的数据源ID进行比对从而得到对应数据源的配置项目
-     */
-    public static List<UploadSettingVO.Column> parsingConfigurationFiles(ProjectImportPatentVO projectImportPatentVO, String getSettingJson) {
-        //将uploadSetting.json数据源配置文件的json字符串转换为UploadSettingVO对象(即实体类)集合
-        List<UploadSettingVO> uploadSettingVOs = JsonUtils.jsonToList(getSettingJson, UploadSettingVO.class);
-        //创建一个存放单一数据源的对象 这个对象存放的是 我们需要使用哪一个数据源的配置数据 所以只存一个 正常在Json文件里面会有多个数据源 也就是多条数据
-        List<UploadSettingVO.Column> jsonData = new ArrayList<>();
-        //遍历uploadSettingVOs,
-        for (int i = 0; i < Objects.requireNonNull(uploadSettingVOs).size(); i++) {
-            //提取一个常量
-            UploadSettingVO constant = Objects.requireNonNull(uploadSettingVOs).get(i);
-            //判断 如果说 Json 解析出来的 List<T> 中的 sourceId 和传入参数的 sourceId 匹配成功 则开始装配数据
-            if (constant.getSourceId().equals(projectImportPatentVO.getSourceId())) {
-                //填充数据
-                jsonData = constant.getColumn();
-            }
-        }
-        //返回填充好的数据
-        return jsonData;
-    }
-
-    /**
-     * @param getSettingJson 配置文件解析出的Json串
-     * @return uploadParamsVO 返回一个由processData方法填充完数据的Pojo类
-     * @date 2022/7/7
-     * @name 解析配置文件
-     * @description 通过与前段传入参数中的数据源ID进行比对从而得到对应数据源的配置(parsingConfigurationFiles的兄弟方法)
-     */
-    public static List<UploadSettingVO.Column> parsingConfigurationFilesBro(String getSettingJson) {
-        //将 Json 转换为 对象数组
-        List<UploadSettingVO> test = JsonUtils.jsonToList(getSettingJson, UploadSettingVO.class);
-        //创建一个存放单一数据源的对象 这个对象存放的是 我们需要使用哪一个数据源的配置数据 所以只存一个 正常在Json文件里面会有多个数据源 也就是多条数据
-        List<UploadSettingVO.Column> jsonData = new ArrayList<>();
-        //开始将前端传入的数据源参数与 Json 中解析出来的 sourceId(数据来源ID) 进行比对 并将比对中的那一条数据放入上方定义的 jsonData 中 用于后续使用
-        for (int i = 0; i < Objects.requireNonNull(test).size(); i++) {
-            //提取一个常量
-            UploadSettingVO constant = Objects.requireNonNull(test).get(i);
-            //判断 如果说 Json 解析出来的 List<T> 中的 sourceId 和传入参数的 sourceId 匹配成功 则开始装配数据
-            if (constant.getSourceId().equals("1")) {
-                //填充数据
-                jsonData = constant.getColumn();
-            }
-        }
-        //返回填充好的数据
-        return jsonData;
-    }
-
-    /**
-     * @param row      任务参数
-     * @param jsonData 处理好后转换为Pojo类的配置文件数据
-     * @return uploadParamsVO 返回一个填充完数据的Pojo类
-     * @date 2022/7/7
-     * @name 处理数据
-     * @description 通过配置项目中的栏位名称和通过解析Excel得到的栏位名称进行比对 并对所属栏位的数据进行分割或其他处理 最后将处理完的数据填充进类中 用于向数据库存入数据
-     */
-    public static UploadParamsVO processData(Map<Object, Object> row, List<UploadSettingVO.Column> jsonData) {
-        UploadParamsVO uploadParamsVO = new UploadParamsVO();
-        List<UploadParamsVO.Field> list = new ArrayList<>();
-        try {
-            for (Object object : row.keySet()) {
-                String key = object.toString();
-                Object value = row.get(key);
-                if (key.contains(":")) {
-                    // TODO: 2022/10/15 添加判空校验
-                    if (value != null && !value.equals("")) {
-                        UploadParamsVO.Field field = new UploadParamsVO.Field();
-                        StringSpecialHandler stringSpecialHandler = new StringSpecialHandler();
-                        field.setKey(key);
-                        field.setFieldList((List<String>) stringSpecialHandler.processData(value.toString(), "\\\n"));
-                        list.add(field);
-                    }
-                }
-                if (StringUtils.isNotNull(value) && !value.equals("") && !value.equals("-") && !value.equals("\\")) {
-                    //将配置项与Excel栏位进行比对
-                    List<UploadSettingVO.Column> temVOColumn = getColumn(jsonData, key);
-                    for (UploadSettingVO.Column column : temVOColumn) {
-                        //创建处理对象
-                        Object processData = DataProcessHandler.getData(column.getHandler(), column.getJarOrClassPath());
-                        //调用处理对象中的对应处理方法对Excel中的数据进行处理
-                        Object getProcessData = null;
-                        if (processData != null) {
-                            Method method = processData.getClass().getMethod("processData", Object.class, Object.class);
-                            getProcessData = method.invoke(processData, value.toString(), column.getSplitSymbol());
-                        }
-                        //将格式化后的数据装配到VO类
-                        assemblyObject(uploadParamsVO, column.getColumn(), getProcessData);
-
-                    }
-                }
-            }
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        //数据装配完毕 准备返回Service层 进行数据库操作
-        uploadParamsVO.setCustomerFieldList(list);
-        return uploadParamsVO;
-    }
-
-    private static List<UploadSettingVO.Column> getColumn(List<UploadSettingVO.Column> jsonData, String key) {
-        List<UploadSettingVO.Column> columnList = new ArrayList<>();
-
-        for (UploadSettingVO.Column jsonDatum : jsonData) {
-            if (jsonDatum.getSetName().equals(key)) {
-                columnList.add(jsonDatum);
-            }
-        }
-
-        return columnList;
-    }
-
-    /**
-     * @param obj          装配对象(UploadParamsVO)
-     * @param propertyPath 以.隔开的属性路径(配置文件中的 Column)
-     * @param value        值(row 每一行的值 在上层方法中叫 value)
-     * @name 装配对象
-     * @description 通过反射将处理后的数据赋值到装配对象的给定路径的属性值
-     */
-
-    private static void assemblyObject(Object obj, String propertyPath, Object value) {
-        //将属性的路径通过 "." 进行拆分 数据样式大致为 patentRightList.content 或者 patentInstructionText.manual
-        //"."前面的是UploadParamsVO的属性名称 可能是List或者Object
-        //"."后面的是List中的Object的属性 或者Object的属性
-        String[] splitProperty = propertyPath.split("\\.");
-        //初始化一个基类 用于存储数据
-        Object temObj = obj;
-        try {
-            //进行属性路径的循环 这里一般都是两次
-            for (int i = 0; i < splitProperty.length; i++) {
-                //如果需要为对应参数赋值 第一次循环不会进入这一分支
-                if (i == splitProperty.length - 1) {
-                    //如果是列表
-                    if (temObj instanceof List) {
-                        //取创建空数据中的第一条
-                        Object firstItem = ((List<?>) temObj).get(0);
-                        //获取该条数据的类型
-                        String listObjectType = firstItem.getClass().getTypeName();
-                        //如果列表中的数据少于给的值的列表中的数据量
-                        //添加数据以与给定的值对齐
-                        if (((List<?>) temObj).size() < ((List<?>) Objects.requireNonNull(value)).size()) {
-                            for (int iIndex = ((List<?>) temObj).size(); iIndex < ((List<?>) value).size(); iIndex++) {
-                                Object cObj = Class.forName(listObjectType).newInstance();// trueType.newInstance();
-                                ((List<Object>) temObj).add(cObj);
-                            }
-                        }
-
-                        //给列表中的对象相对应的属性赋值
-                        for (int iIndex = 0; iIndex < ((List<?>) value).size(); iIndex++) {
-
-                            Object inListObj = ((List<?>) temObj).get(iIndex);
-                            Field f = inListObj.getClass().getDeclaredField(splitProperty[i]);
-                            f.setAccessible(true);
-                            if (!((List<?>) value).isEmpty()) {
-                                f.set(inListObj, ((List<?>) value).get(iIndex));
-                            }
-                        }
-
-                    } else {
-                        Field f = temObj.getClass().getDeclaredField(splitProperty[i]);
-                        f.setAccessible(true);
-                        if (value != null) {
-                            f.set(temObj, value);
-                        }
-                    }
-                } else {
-
-                    //
-                    Field f = temObj.getClass().getDeclaredField(splitProperty[i]);
-                    //允许设置私有(private)属性
-                    f.setAccessible(true);
-                    //获取
-                    Object propertyValue = f.get(obj);
-
-                    if (propertyValue == null) {
-                        if (f.getType().getName().contains("List")) {
-                            propertyValue = createList(f);
-                        } else {
-                            propertyValue = f.getType().newInstance();
-                        }
-                        f.set(temObj, propertyValue);
-                    }
-
-                    temObj = propertyValue;
-                }
-
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-    }
-
-    private static List<Object> createList(Field f) {
-        //如果是列表,创建一个List<Object>并添加一个对应类型的对象
-        List<Object> lst = new ArrayList<>();
-
-        //取List属性中包含的对象类型
-        Type trueType = f.getGenericType();
-        Type listArgumentObj = ((ParameterizedType) trueType).getActualTypeArguments()[0];
-        Object cObj = null;
-        try {
-            cObj = Class.forName(listArgumentObj.getTypeName()).newInstance();
-        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
-            e.printStackTrace();
-        }
-        lst.add(cObj);
-        return lst;
-    }
-
-}

+ 0 - 113
src/main/java/cn/cslg/pas/common/utils/WebSocketServer.java

@@ -1,113 +0,0 @@
-package cn.cslg.pas.common.utils;
-
-import cn.cslg.pas.common.core.base.Constants;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-import javax.websocket.*;
-import javax.websocket.server.PathParam;
-import javax.websocket.server.ServerEndpoint;
-import java.io.IOException;
-import java.util.concurrent.CopyOnWriteArraySet;
-
-@Slf4j
-@Component
-@ServerEndpoint(Constants.API_VERSION_V2 + "/ws/{sid}")
-public class WebSocketServer {
-
-    //静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
-    private static int onlineCount = 0;
-    //concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
-    private static CopyOnWriteArraySet<WebSocketServer> webSocketSet
-            = new CopyOnWriteArraySet<WebSocketServer>();
-    //与某个客户端的连接会话,需要通过它来给客户端发送数据
-    private Session session;
-    //接收sid
-    private String sid = "";
-
-    /**
-     * 连接建立成功调用的方法
-     */
-    @OnOpen
-    public void onOpen(Session session, @PathParam("sid") String sid) {
-        this.session = session;
-        webSocketSet.add(this);     //加入set中
-        addOnlineCount();           //在线数加1
-        log.info("有新窗口开始监听:" + sid + ",当前在线人数为" + getOnlineCount());
-        this.sid = sid;
-        try {
-            sendMessage(Response.success("连接成功"));
-        } catch (IOException e) {
-            log.error("websocket IO异常");
-        }
-    }
-
-    /**
-     * 连接关闭调用的方法
-     */
-    @OnClose
-    public void onClose() {
-        webSocketSet.remove(this);  //从set中删除
-        subOnlineCount();           //在线数减1
-        log.info("有一连接关闭!当前在线人数为" + getOnlineCount());
-    }
-
-    /**
-     * 收到客户端消息后调用的方法
-     *
-     * @param message 客户端发送过来的消息
-     */
-    @OnMessage
-    public void onMessage(String message, Session session) {
-        log.info("收到来自窗口" + sid + "的信息:" + message);
-        //群发消息
-        for (WebSocketServer item : webSocketSet) {
-            try {
-                item.sendMessage(message);
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    @OnError
-    public void onError(Session session, Throwable error) {
-        log.error("发生错误");
-        error.printStackTrace();
-    }
-
-    //实现服务器主动推送
-    public synchronized void sendMessage(String message) throws IOException {
-        this.session.getBasicRemote().sendText(message);
-    }
-
-    //群发自定义消息
-    public synchronized static void sendInfo(String message, @PathParam("sid") String sid) {
-        log.info("推送消息到窗口" + sid + ",推送内容:" + message);
-        for (WebSocketServer item : webSocketSet) {
-            try {
-                //这里可以设定只推送给这个sid的,为null则全部推送
-                if (sid == null || "null".equals(sid)) {
-                    item.sendMessage(message);
-                } else if (item.sid.equals(sid)) {
-                    item.sendMessage(message);
-                }
-            } catch (IOException e) {
-                continue;
-            }
-        }
-    }
-
-    public static synchronized int getOnlineCount() {
-        return onlineCount;
-    }
-
-    public static synchronized void addOnlineCount() {
-        WebSocketServer.onlineCount++;
-    }
-
-    public static synchronized void subOnlineCount() {
-        WebSocketServer.onlineCount--;
-    }
-}
-

+ 0 - 171
src/main/java/cn/cslg/pas/common/utils/auth/AuthAop.java

@@ -1,171 +0,0 @@
-package cn.cslg.pas.common.utils.auth;
-
-import cn.cslg.pas.common.model.DataSource;
-import cn.cslg.pas.common.model.PersonnelVO;
-import cn.cslg.pas.common.utils.CacheUtils;
-import cn.cslg.pas.common.utils.Response;
-import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import io.swagger.v3.oas.annotations.Operation;
-import okhttp3.FormBody;
-import okhttp3.OkHttpClient;
-import okhttp3.Request;
-import okhttp3.RequestBody;
-import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.*;
-import org.aspectj.lang.reflect.MethodSignature;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Component;
-
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Objects;
-
-import static cn.cslg.pas.common.utils.JsonUtils.log;
-
-@Order(2)
-@Aspect
-@Component
-public class AuthAop {
-    @Value("${authorUrl}")
-    private String url;
-
-    @Autowired
-    private CacheUtils cacheUtils;
-    @Autowired
-    private LoginUtils loginUtils;
-
-    /**
-     * 定义切点
-     */
-    @Pointcut("@annotation(cn.cslg.pas.common.utils.auth.checkAuth)")
-    public void annotationPointcut() {
-
-    }
-
-    /**
-     * @param joinPoint 当前执行的方法
-     */
-    @Around("annotationPointcut()")
-    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
-        try {
-            //获得登录人信息
-            PersonnelVO personnelVO = cacheUtils.getLoginUserPersonnel(loginUtils.getId());
-            if (personnelVO.getState() == 0) {
-                return Response.error("登录账号已被禁用,请联系管理员启用");
-            }
-
-
-            // 是否通过切面过滤标记
-            Boolean isPass = true;
-            MethodSignature ms = (MethodSignature) joinPoint.getSignature();
-            //获得执行方法对象
-            Method method = ms.getMethod();
-            //获得执行方法对象上的@checkAuth,@Operation注解对象
-            checkAuth myAnnotation = method.getAnnotation(checkAuth.class);
-            Operation operAnnotation = method.getAnnotation(Operation.class);
-            //获得@checkAuth注解上FunId参数的值
-            String functionId = myAnnotation.FunId();
-            //获得执行方法的参数对象
-            Object[] args = joinPoint.getArgs();
-            //根据登录人的id以及功能id获得规则信息
-            //将登录人的id以及功能id放入requestBody中
-            RequestBody requestBody = new FormBody.Builder()
-                    .add("loginId", loginUtils.getId().toString())
-                    .add("functionId", functionId)
-                    .build();
-            //建立远程连接
-            OkHttpClient okHttpClient = new OkHttpClient();
-            //发送请求
-            Request request = new Request.Builder()
-                    .url(url + "/permission/api/data/queryDataRule")
-                    .addHeader("Cookie", LoginUtils.getToken())
-                    .post(requestBody)
-                    .build();
-            //获得请求结果
-            String resBody = Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
-            JSONArray jsonArray = JSONArray.parseArray(resBody);
-            //如果获得规则的返回值为[-1]则代表登录人没有使用该功能的权限
-            if (jsonArray.get(0).toString().equals("-1")) {
-                return Response.noPermissions("没有" + operAnnotation.summary() + "的功能");
-            }
-            //如果获得规则的返回值为[0],则直接通过判断
-            else if (jsonArray.size() == 1 && jsonArray.get(0).equals("0")) {
-                return joinPoint.proceed();
-            }
-            // 如果查询结果的size大于0证明有限制逻辑
-            if (jsonArray.size() > 0) {
-                RequestBody reBodySource = new FormBody.Builder()
-                        .add("tableName", "local")
-                        .build();
-                //处理jsonObject,变为(x==y)&&(z==t)的形式 ,并用js引擎进行boolean判断
-                //建立连接去获得字典信息
-                OkHttpClient okHttpClientSou = new OkHttpClient();
-                //发送请求
-                Request requestSou = new Request.Builder()
-                        .url(url + "/permission/api/data/getDataSource")
-                        .post(reBodySource)
-                        .addHeader("Cookie", LoginUtils.getToken())
-                        .build();
-                //获得请求返回
-                String resSource = Objects.requireNonNull(okHttpClientSou.newCall(requestSou).execute().body()).string();
-
-                JSONArray jsonArray1 = JSON.parseArray(resSource);
-                // 获得字典
-                List<DataSource> dataSources = jsonArray1.toJavaList(DataSource.class);
-                //循环遍历将多个规则拼接起来
-                StringBuilder sqlStr = new StringBuilder();
-                for (int i = 0; i < jsonArray.size(); i++) {
-                    //将数据库里存的规则转换为可识别的判断逻辑
-                    String sql = TreeUtils.reCompute(JSONObject.parseObject(jsonArray.get(i).toString()), args, dataSources, personnelVO);
-                    sqlStr.append(jsonArray.size() != i + 1 ? sql + " || " : sql);
-                }
-                //js引擎进行判断
-                ScriptEngineManager manager = new ScriptEngineManager();
-                //根据名字获得引擎
-                ScriptEngine engine = manager.getEngineByName("javascript");
-                //进行判断,生成判断结果并将判断结果赋给isPass
-                Object result = engine.eval(sqlStr.toString());//进行判断
-                isPass = (Boolean) result;
-            }
-
-            //判断不通过
-            if (!isPass) {
-                return Response.noPermissions("没有权限进行" + operAnnotation.summary() + "的操作");
-            }
-            //判断通过
-            return joinPoint.proceed();
-        }
-        catch (Exception var10) {
-            log.error("operlog exception:{}", var10);
-            return joinPoint.proceed();
-        }
-
-    }
-
-
-    @Before(value = "annotationPointcut()")
-    public void doAfterReturning(JoinPoint joinPoint) {
-        this.handleAfterLog(joinPoint);
-
-    }
-
-    protected void handleAfterLog(JoinPoint joinPoint) {
-        try {
-            log.info("after ----> title:{}, desc:{}",1,2);
-            return;
-        } catch (Exception var10) {
-            log.error("operlog exception:{}", var10);
-            return;
-        }
-    }
-
-}
-

+ 0 - 362
src/main/java/cn/cslg/pas/common/utils/auth/TreeUtils.java

@@ -1,362 +0,0 @@
-package cn.cslg.pas.common.utils.auth;
-
-import cn.cslg.pas.common.model.DataSource;
-import cn.cslg.pas.common.model.PersonnelVO;
-import com.alibaba.fastjson.JSONObject;
-import org.springframework.stereotype.Component;
-
-import java.lang.reflect.Field;
-import java.util.List;
-import java.util.Map;
-
-@Component
-public class TreeUtils {
-    /**
-     * 将二叉树json对象转为sql where后的条件语句
-     * liRJ
-     *
-     * @param jsonObject  要处理的jsonObject对象
-     * @param dataSource  要使用的数据字典
-     * @param personnelVO 登录人的信息
-     * @return 拼接的sql
-     */
-    // 处理sql语句,返回拼接sql
-    public static String reSql(JSONObject jsonObject, List<DataSource> dataSource, PersonnelVO personnelVO) throws NoSuchFieldException, IllegalAccessException {
-        String sql;
-        //判断是否为规则,是的话则返回为“”,不对其他sql条件产生影响
-        if (jsonObject.get("nodeType").equals("logic")) {
-            sql = "";
-        }
-        //符合二叉树形式
-        else if (jsonObject.containsKey("left") && jsonObject.containsKey("right")) {
-            //将二叉树转换为sql条件
-            sql = recursionTree(jsonObject, dataSource, personnelVO);
-        }
-        // 不符合二叉树形式(单条数据)
-        else {
-            //获得规则的field字段,作为sql条件的栏位
-            String field = jsonObject.get("field").toString();
-            //获得规则的栏位值,并且要对值进行识别操作
-            String value = distinguishFields(jsonObject.get("value").toString(), dataSource, personnelVO);
-            if (jsonObject.get("opr").toString().equals("FIND_IN_SET")) {
-                sql = "FIND_IN_SET(" + value + "," + field + ")";
-            } else {
-                sql = field + " " + jsonObject.get("opr").toString() + " " + value;
-            }
-        }
-
-        return sql;
-    }
-
-    /**
-     * 将二叉树json对象转为sql where后的条件语句
-     * liRJ
-     *
-     * @param jsonObject  要处理的jsonObject对象
-     * @param dataSource  要使用的数据字典
-     * @param personnelVO 登录人的信息
-     * @return 拼接的sql
-     */
-    // 处理规则
-    public static String reCompute(JSONObject jsonObject, Object[] object, List<DataSource> dataSource, PersonnelVO personnelVO) throws NoSuchFieldException, IllegalAccessException {
-        String sql;
-        //判断是否为sql类型规则,是的话规则转换为1==1,不对其他规则产生影响
-        if (jsonObject.get("nodeType").equals("sql")) {
-            sql = "1==1";
-        }
-        //符合二叉树形式
-        else if (jsonObject.containsKey("left") && jsonObject.containsKey("right")) {
-            //将二叉树转换为规则判断
-            sql = cRecursionTree(jsonObject, object, dataSource, personnelVO);
-        }
-        // 不符合二叉树形式(单条数据)
-        else {
-            //获得规则的 field字段,并进行识别操作
-            String field = distinguishFields(jsonObject.get("field").toString(), object, dataSource, personnelVO);
-            //获得规则的 value字段,并进行识别操作
-            String value = distinguishValues(jsonObject.get("value").toString(), object);
-            //获得规则的 运算符字段,并进行识别操作
-            String opr = distinguishLogic(jsonObject.getString("nodeType"), jsonObject.getString("opr"));
-            //field 和value若为以,隔开的数组时,将被拆开,并合成为新的规则
-            sql = arrayEqlToString(field, value, opr);
-        }
-
-        return sql;
-    }
-
-    /**
-     * 递归将二叉树转换为字符串
-     * liRJ
-     *
-     * @param jsonObject jsonObject
-     */
-    //将二叉树转换为sql条件
-    public static String recursionTree(JSONObject jsonObject, List<DataSource> dataSource, PersonnelVO personnelVO) throws NoSuchFieldException, IllegalAccessException {
-        String str1;
-        String str2;
-        // 获得规则左边
-        JSONObject jsonLeft = jsonObject.getJSONObject("left");
-        // 获得规则右边
-        JSONObject jsonRight = jsonObject.getJSONObject("right");
-        //判断是否含有left分支,有的话进行递归
-        if (jsonLeft.containsKey("left")) {
-            str1 = recursionTree(jsonLeft, dataSource, personnelVO);//递归
-        }
-        //没有的话解析字符串拼接成子sql
-        else {
-            String field = jsonLeft.get("field").toString();
-            //获得规则的 value字段,并进行识别操作
-            String value = distinguishFields(jsonLeft.get("value").toString(), dataSource, personnelVO); //没有的话解析字符串拼接成子sql
-            if (jsonLeft.get("opr").toString().equals("FIND_IN_SET")) {
-                str1 = "FIND_IN_SET(" + value + "," + field + ")";
-            } else {
-                str1 = field + " " + jsonLeft.get("opr").toString() + " " + value;
-            }
-        }
-        //同上部分处理left分支
-        if (jsonRight.containsKey("right")) {
-            str2 = recursionTree(jsonRight, dataSource, personnelVO);
-        } else {
-            String field = jsonRight.get("field").toString();
-            String value = distinguishFields(jsonRight.get("value").toString(), dataSource, personnelVO);
-            if (jsonRight.get("opr").toString().equals("FIND_IN_SET")) {
-                str2 = "FIND_IN_SET(" + value + "," + field + ")";
-            } else {
-                str2 = field + " " + jsonRight.get("opr").toString() + " " + value;
-            }
-        }
-        return "(" + str1 + ") " + jsonObject.get("logicOpr") + " (" + str2 + ")";
-    }
-
-    //将二叉树转换为规则判断
-    public static String cRecursionTree(JSONObject jsonObject, Object[] object, List<DataSource> dataSource, PersonnelVO personnelVO) throws NoSuchFieldException, IllegalAccessException {
-        String str1;
-        String str2;
-        // 获得规则左边
-        JSONObject jsonLeft = jsonObject.getJSONObject("left");
-        // 获得规则右边
-        JSONObject jsonRight = jsonObject.getJSONObject("right");
-        //判断是否含有left分支,有的话进行递归
-        if (jsonLeft.containsKey("left")) {
-            str1 = cRecursionTree(jsonLeft, object, dataSource, personnelVO);
-        } else {
-            //获得规则的 field字段,并进行识别操作
-            String field = distinguishFields(jsonLeft.get("field").toString(), object, dataSource, personnelVO);
-            //获得规则的 value字段,并进行识别操作
-            String value = distinguishValues(jsonLeft.get("value").toString(), object);
-            //获得规则的 opr字段,并进行识别操作
-            String opr = distinguishLogic(jsonLeft.getString("nodeType"), jsonLeft.getString("opr"));
-            str1 = arrayEqlToString(field, value, opr);
-        }
-        //同上部分处理right分支
-        if (jsonRight.containsKey("right")) {
-            str2 = cRecursionTree(jsonRight, object, dataSource, personnelVO);
-        } else {
-            String field = distinguishFields(jsonRight.get("field").toString(), object, dataSource, personnelVO);
-            String value = distinguishValues(jsonRight.get("value").toString(), object);
-            String opr = distinguishLogic(jsonRight.getString("nodeType"), jsonRight.getString("opr"));
-            str2 = arrayEqlToString(field, value, opr);
-        }
-
-        return "(" + str1 + ") " + distinguishLogic(jsonObject.getString("nodeType"), jsonObject.getString("logicOpr")) + " (" + str2 + ")";
-    }
-
-    //对field和value部分进行计算 sql查询
-    public static String distinguishFields(String field, List<DataSource> dataSources, PersonnelVO personnelVO) throws NoSuchFieldException, IllegalAccessException {
-        //获得登录用户部门列表信息
-        List<PersonnelVO.DP> dps = personnelVO.getDpList();
-        //获得登录用户角色列表信息
-        List<PersonnelVO.PerRole> perRoles = personnelVO.getRList();
-        String tem = "";
-        String reField = field;
-        //如果参数是sql语句
-        if (field.contains("select")) {
-            for (DataSource dataSource : dataSources) {
-                String sourceField = dataSource.getDataSourceField();
-                if (field.contains("local." + sourceField)) {
-                    // 判断是否是部门信息
-                    if (sourceField.contains("DP.")) {
-                        // 分割字符串获得部门字段
-                        String Fields = sourceField.split("\\.")[1];
-                        // 遍历部门信息,用反射将对应字段转换成(*,*,...)格式
-                        for (PersonnelVO.DP dp : dps) {
-                            Class<?> DPClass = dp.getClass();
-                            Field dataField = DPClass.getDeclaredField(Fields);
-                            dataField.setAccessible(true);
-                            tem = dataField.get(dp).toString() + ",";
-
-                        }
-                        reField = sourceField.replace("local." + sourceField, "(" + tem.substring(0, tem.length() - 1) + ")");
-                    }
-                    //判断是否是角色信息(处理过程同部门信息处理过程)
-                    else if (sourceField.contains("PerRole.")) {
-                        String Fields = sourceField.split("\\.")[1];
-                        for (PersonnelVO.PerRole perRole : perRoles) {
-                            Class<?> DPClass = perRole.getClass();
-                            Field dataField = DPClass.getDeclaredField(Fields);
-                            dataField.setAccessible(true);
-                            tem = dataField.get(perRole).toString() + ",";
-                        }
-                        reField = sourceField.replace("local." + sourceField, "(" + tem.substring(0, tem.length() - 1) + ")");
-                    } else {
-                        Class<?> personClass = personnelVO.getClass();
-                        Field dataField = personClass.getDeclaredField(sourceField);
-                        dataField.setAccessible(true);
-                        reField = reField.replace("local." + sourceField, dataField.get(personnelVO).toString());
-                    }
-                }
-            }
-        }
-        //遍历字典数据
-        else {
-            for (DataSource dataSource : dataSources) {
-                // 如果匹配上字典字段则进行处理
-                if (field.equals(dataSource.getDataSourceField())) {
-                    // 判断是否是部门信息
-                    if (field.contains("DP.")) {
-                        // 分割字符串获得部门字段
-                        String Fields = field.split("\\.")[1];
-                        // 遍历部门信息,用反射将对应字段转换成(*,*,...)格式
-                        for (PersonnelVO.DP dp : dps) {
-                            Class<?> DPClass = dp.getClass();
-                            Field dataField = DPClass.getDeclaredField(Fields);
-                            dataField.setAccessible(true);
-                            tem = dataField.get(dp).toString() + ",";
-
-                        }
-                        reField = "(" + tem.substring(0, tem.length() - 1) + ")";
-                    }
-                    //判断是否是角色信息(处理过程同部门信息处理过程)
-                    else if (field.contains("PerRole.")) {
-                        String Fields = field.split("\\.")[1];
-                        for (PersonnelVO.PerRole perRole : perRoles) {
-                            Class<?> DPClass = perRole.getClass();
-                            Field dataField = DPClass.getDeclaredField(Fields);
-                            dataField.setAccessible(true);
-                            tem = dataField.get(perRole).toString() + ",";
-                        }
-                        reField = "(" + tem.substring(0, tem.length() - 1) + ")";
-                    } else {
-                        Class<?> personClass = personnelVO.getClass();
-                        Field dataField = personClass.getDeclaredField(field);
-                        dataField.setAccessible(true);
-                        reField = dataField.get(personnelVO).toString();
-                        break;
-                    }
-                }
-            }
-        }
-        return reField;
-    }
-
-    //对field部分进行计算
-    public static String distinguishFields(String field, Object[] object, List<DataSource> dataSources, PersonnelVO personnelVO) throws NoSuchFieldException, IllegalAccessException {
-        String reField = "'" + field + "'";
-        //反射获方法的参数值
-        Class<?> jsonClass = object[0].getClass();
-        for (Field field1 : jsonClass.getDeclaredFields()) {
-            if (field1.getName().equals(field)) {     //判断field的值是否和参数名一样,一样的话变为参数值
-                Field dataField = jsonClass.getDeclaredField(field);
-                dataField.setAccessible(true);//设置data属性为可访问的
-                String fie = dataField.get(object[0]).toString();
-                reField = "'" + fie + "'";
-                break;
-            }
-        }
-        //获得登录用户部门列表信息
-        List<PersonnelVO.DP> dps = personnelVO.getDpList();
-        //获得登录用户角色列表信息
-        List<PersonnelVO.PerRole> perRoles = personnelVO.getRList();
-        String tem = "";
-        //遍历字典数据
-        for (DataSource dataSource : dataSources) {
-            // 如果匹配上字典字段则进行处理
-            if (field.equals(dataSource.getDataSourceField())) {
-                // 判断是否是部门信息
-                if (field.contains("DP.")) {
-                    // 分割字符串获得部门字段
-                    String Fields = field.split("\\.")[1];
-                    // 遍历部门信息,用反射将对应字段转换成(*,*,...)格式
-                    for (PersonnelVO.DP dp : dps) {
-                        Class<?> DPClass = dp.getClass();
-                        Field dataField = DPClass.getDeclaredField(Fields);
-                        dataField.setAccessible(true);
-                        tem = dataField.get(dp).toString() + ",";
-
-                    }
-                    reField = tem.substring(0, tem.length() - 1);
-                }
-                //判断是否是角色信息(处理过程同部门信息处理过程)
-                else if (field.contains("PerRole.")) {
-                    String Fields = field.split("\\.")[1];
-                    for (PersonnelVO.PerRole perRole : perRoles) {
-                        Class<?> DPClass = perRole.getClass();
-                        Field dataField = DPClass.getDeclaredField(Fields);
-                        dataField.setAccessible(true);
-                        tem = dataField.get(perRole).toString() + ",";
-                    }
-                    reField = tem.substring(0, tem.length() - 1);
-                } else {
-                    Class<?> personClass = personnelVO.getClass();
-                    Field dataField = personClass.getDeclaredField(field);
-                    dataField.setAccessible(true);
-                    reField = "'" + dataField.get(personnelVO).toString() + "'";
-                    break;
-                }
-            }
-        }
-
-        return reField;
-    }
-
-    //对value部分进行计算
-    public static String distinguishValues(String value, Object[] object) throws NoSuchFieldException, IllegalAccessException {
-        String reValue = "'" + value + "'";
-        //反射获得参数值
-        Class<?> jsonClass = object[0].getClass();
-        for (Field field1 : jsonClass.getDeclaredFields()) {
-            if (field1.getName().equals(value)) {     //判断value的值是否和参数名一样,一样的话变为参数值
-                Field dataField = jsonClass.getDeclaredField(value);
-                dataField.setAccessible(true);//设置data属性为可访问的
-                String fie = dataField.get(object[0]).toString();
-                reValue = "'" + fie + "'";
-                break;
-            }
-        }
-
-        return reValue;
-    }
-
-    //对应改变运算逻辑
-    public static String distinguishLogic(String nodeType, String opr) {
-        if (nodeType.equals("logic")) {
-            switch (opr) {
-                case "=":
-                    opr = "==";
-                    break;
-                case "and":
-                    opr = "&&";
-                    break;
-                case "or":
-                    opr = "||";
-                    break;
-            }
-        }
-
-        return opr;
-    }
-
-    // 将x,y=z,w 形式改为 x=z||x=w||y=z||y=w形式
-    public static String arrayEqlToString(String field, String value, String opr) {
-        StringBuilder reStr = new StringBuilder();
-        String[] fields = field.split(",");
-        String[] values = value.split(",");
-        for (int i = 0; i < fields.length; i++) {
-            for (int t = 0; t < values.length; t++) {
-                reStr.append(i == fields.length - 1 && t == values.length - 1 ? fields[i] + opr + values[t] : fields[i] + opr + values[t] + "||");
-            }
-        }
-
-        return reStr.toString();
-    }
-}

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

@@ -1,17 +0,0 @@
-package cn.cslg.pas.common.utils.auth;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * @author LRJ
- * @date 2022-8-23
- * @description 数据权限(增删改)条件判断注解
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface checkAuth {
-    String FunId() default "0";
-}
-

+ 34 - 0
src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/Symbol.java

@@ -0,0 +1,34 @@
+package cn.cslg.pas.common.utils.parseQueryToTree;
+
+public class Symbol {
+    String Code;
+    String ShowName;
+
+
+    public Symbol(){
+
+    }
+
+    public Symbol(String code, String showname) {
+        this.Code = code;
+        this.ShowName= showname;
+    }
+
+    public void setCode(String code)
+    {
+        this.Code = code;
+    }
+
+    public String getCode(){
+        return this.Code;
+    }
+
+    public void setShowName(String showname)
+    {
+        this.ShowName= showname;
+    }
+
+    public String getShowName(){
+        return this.ShowName;
+    }
+}

+ 13 - 0
src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/enuType.java

@@ -0,0 +1,13 @@
+package cn.cslg.pas.common.utils.parseQueryToTree;
+
+public enum enuType {
+    /// <summary>
+    /// 逻辑操作符号,比如AND、OR、NOT
+    /// </summary>
+    Logic,
+
+    /// <summary>
+    /// 赋值操作符号,比如:=、>、< 、>=、<=、like等
+    /// </summary>
+    Assignment
+}

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

@@ -0,0 +1,473 @@
+package cn.cslg.pas.common.utils.parseQueryToTree;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Stack;
+
+public class expressManager {
+    HashMap<String,Symbol> hSymbols = new HashMap<String, Symbol>();
+    private static expressManager instance = new expressManager();
+    private expressManager(){
+        //#region 添加逻辑符号
+            operate oAnd = new operate();
+            oAnd.Code = "AND";
+            oAnd.ShowName = "AND";
+            oAnd.type = enuType.Logic;
+            oAnd.priorityVale = 11;
+            oAnd.operateValue = 2;
+            hSymbols.put(oAnd.Code, oAnd);
+
+            operate oOR = new operate();
+            oOR.Code = "OR";
+            oOR.ShowName = "OR";
+            oOR.type = enuType.Logic;
+            oOR.priorityVale = 11;
+            oOR.operateValue = 2;
+            hSymbols.put(oOR.Code, oOR);
+
+            oOR = new operate();
+            oOR.Code = "NOT";
+            oOR.ShowName = "NOT";
+            oOR.type = enuType.Logic;
+            oOR.priorityVale = 12;
+            oOR.operateValue = 1;
+            hSymbols.put(oOR.Code, oOR);
+
+            oOR = new operate();
+            oOR.Code = "TO";
+            oOR.ShowName = "TO";
+            oOR.type = enuType.Logic;
+            oOR.priorityVale = 13;
+            oOR.operateValue = 2;
+            hSymbols.put(oOR.Code, oOR);
+
+            oOR = new operate();
+            oOR.Code = "=";
+            oOR.ShowName = "=";
+            oOR.type = enuType.Assignment;
+            oOR.priorityVale = 20;
+            oOR.operateValue = 2;
+            hSymbols.put(oOR.Code, oOR);
+
+            oOR = new operate();
+            oOR.Code = ">";
+            oOR.ShowName = ">";
+            oOR.type = enuType.Assignment;
+            oOR.priorityVale = 20;
+            oOR.operateValue = 2;
+            hSymbols.put(oOR.Code, oOR);
+
+            oOR = new operate();
+            oOR.Code = "<";
+            oOR.ShowName = "<";
+            oOR.type = enuType.Assignment;
+            oOR.priorityVale = 20;
+            oOR.operateValue = 2;
+            hSymbols.put(oOR.Code, oOR);
+
+            oOR = new operate();
+            oOR.Code = ">=";
+            oOR.ShowName = ">=";
+            oOR.type = enuType.Assignment;
+            oOR.priorityVale = 20;
+            oOR.operateValue = 2;
+            hSymbols.put(oOR.Code, oOR);
+
+            oOR = new operate();
+            oOR.Code = "<=";
+            oOR.ShowName = "<=";
+            oOR.type = enuType.Assignment;
+            oOR.priorityVale = 20;
+            oOR.operateValue = 2;
+            hSymbols.put(oOR.Code, oOR);
+
+            //#endregion
+
+            //#region 添加成对出现的符号
+            pairSymbol first = new pairSymbol();
+            first.Code = "(";
+            first.isEndSymbol = false;
+
+
+            pairSymbol end = new pairSymbol();
+            end.Code = ")";
+            end.previewSymbol = first;
+            end.isEndSymbol = true;
+
+            hSymbols.put(first.Code, first);
+            hSymbols.put(end.Code, end);
+
+            pairSymbol first1 = new pairSymbol();
+            first1.Code = "[";
+            first1.isEndSymbol = false;
+
+            pairSymbol end1 = new pairSymbol();
+            end1.Code = "]";
+            end1.previewSymbol = first1;
+            end1.isEndSymbol = true;
+
+            hSymbols.put(first1.Code, first1);
+            hSymbols.put(end1.Code, end1);
+
+            end = new pairSymbol();
+            end.Code = "\"";
+            end.previewSymbol = end;
+
+            hSymbols.put(end.Code, end);
+            //#endregion
+    }
+
+    public static expressManager getInstance()
+    {
+        return instance;
+    }
+
+    public Symbol getSymbol(String strSymbol)
+        {
+            String strKey = strSymbol.trim().toUpperCase();
+            if ((strKey!=null && !strKey.trim().equals("")) && hSymbols.containsKey(strKey))
+            {
+                return hSymbols.get(strKey);
+            }
+            else
+            {
+                return null;
+            }
+        }
+
+    /// <summary>
+        /// 解析表达式字符串,返回表达式树
+        /// </summary>
+        /// <param name="strExpress">表达式字符串</param>
+        /// <param name="isAnd">如果输入的是多个条件,之间的关系是and还是or,true为and,false为or</param>
+        /// <returns>表达式树节点</returns>
+        public treeNode Parse(String strExpress, boolean isAnd) throws Exception
+        {
+            ArrayList<String> Tokens = GetTokens(strExpress);
+            Stack<Symbol> symbolStack = new Stack<Symbol>();
+            Stack<treeNode> valueStack = new Stack<treeNode>();
+                 for (String strTem : Tokens)
+            {
+                Symbol temSymbol = expressManager.getInstance().getSymbol(strTem);
+                if (temSymbol != null)
+                {
+                    if (temSymbol instanceof operate)
+                    {
+                        //#region 如果是操作符,从操作符堆栈中取出优先级大于等于该操作符的结合值堆栈生成节点后压入值堆栈,然后将该操作符压入堆栈
+                        operate temOperate = (operate)temSymbol;
+                        if (symbolStack.size() > 0)
+                        {
+                            Symbol lastSymbol = symbolStack.peek();
+
+                            while (lastSymbol instanceof operate && ((operate)lastSymbol).priorityVale >= temOperate.priorityVale)
+                            {
+                                operateNode temSymbolNode = new operateNode();
+                                temSymbolNode.operate = (operate)lastSymbol;
+                                if (((operate)lastSymbol).operateValue == 1)
+                                {
+                                    temSymbolNode.Right = valueStack.pop();
+                                }
+                                else
+                                {temSymbolNode.Right = valueStack.pop();
+                                    temSymbolNode.Left = valueStack.pop();
+                                }
+
+                                valueStack.push(temSymbolNode);
+
+                                symbolStack.pop();
+
+                                if (symbolStack.size() > 0)
+                                {
+                                    lastSymbol = symbolStack.peek();
+                                }
+                                else
+                                {
+                                    break;
+                                }
+                            }
+                        }
+                        symbolStack.push(temSymbol);
+                        //#endregion
+                    }
+                    else
+                    {
+                        //#region 括号处理
+                        if (temSymbol instanceof pairSymbol && ((pairSymbol)temSymbol).isEndSymbol)
+                        {
+                            Symbol lastSymbol = symbolStack.peek();
+
+                            if (lastSymbol == null)
+                            {
+                                throw new Exception("无效的括号!");
+                            }
+
+                            while (lastSymbol instanceof operate ||
+                                (lastSymbol instanceof pairSymbol && ((pairSymbol)lastSymbol).Code != ((pairSymbol)temSymbol).previewSymbol.Code))
+                            {
+                                operateNode temSymbolNode = new operateNode();
+                                temSymbolNode.operate = (operate)lastSymbol;
+
+                                if (((operate)lastSymbol).operateValue == 1)
+                                {
+                                    temSymbolNode.Right = valueStack.pop();
+                                }
+                                else
+                                {
+                                    temSymbolNode.Right = valueStack.pop();
+                                    temSymbolNode.Left = valueStack.pop();
+                                }
+                                valueStack.push(temSymbolNode);
+
+                                symbolStack.pop();
+                                lastSymbol = symbolStack.peek();
+                            }
+
+                            if ((lastSymbol instanceof pairSymbol && ((pairSymbol)temSymbol).previewSymbol.Code == ((pairSymbol)lastSymbol).Code))
+                            {
+                                symbolStack.pop();
+                            }
+                            else
+                            {
+                                throw new Exception("无效的括号");
+                            }
+
+                        }
+                        else
+                        {
+                            symbolStack.push(temSymbol);
+                        }
+                        //#endregion
+                    }
+                }
+                else
+                {
+                    valueNode temNode = new valueNode();
+                    temNode.value = strTem;
+
+                    valueStack.push(temNode);
+                }
+            }
+
+            while (symbolStack.size() > 0)
+            {
+                Symbol temSymbol = symbolStack.pop();
+
+                if (temSymbol instanceof operate)
+                {
+                    operateNode temNode = new operateNode();
+                    temNode.operate = (operate)temSymbol;
+
+                    if (((operate)temSymbol).operateValue == 1)
+                    {
+                        temNode.Right = valueStack.pop();
+                    }
+                    else
+                    {
+                        temNode.Right = valueStack.pop();
+                        temNode.Left = valueStack.pop();
+                    }
+
+                    valueStack.push(temNode);
+
+                }
+                else
+                {
+                    throw new Exception("无效的括号!");
+                }
+            }
+
+            if (valueStack.size() == 1)
+            {
+                return valueStack.pop();
+            }
+            else
+            {
+
+                if (valueStack.size() > 1)
+                {
+                    List<treeNode> lstValues = new ArrayList<treeNode>();
+
+                    while (valueStack.size() > 0)
+                    {
+                        treeNode temNode = valueStack.pop();
+
+                        if (temNode instanceof valueNode)
+                        {
+                            lstValues.add(temNode);
+                        }
+                        else
+                        {
+                            throw new Exception("无效的检索式!");
+                        }
+                    }
+
+                    treeNode retNode = null;
+
+                    for (treeNode temNode : lstValues)
+                    {
+                        if (retNode == null)
+                        {
+                            retNode = temNode;
+                        }
+                        else
+                        {
+                            operateNode sNode = new operateNode();
+
+                            if (!isAnd)
+                            {
+                                sNode.operate = (operate)expressManager.getInstance().getSymbol("OR");
+                            }
+                            else
+                            {
+                                sNode.operate = (operate)expressManager.getInstance().getSymbol("AND");
+                            }
+
+                            sNode.Left = retNode;
+                            sNode.Right = temNode;
+                            retNode = sNode;
+                        }
+                    }
+
+                    return retNode;
+                }
+
+                throw new Exception("无效的检索式!");
+
+            }
+        }
+
+
+    /// <summary>
+        /// 语法分析,将表达式字符按照空格分开,
+        /// 且将双引号或者是括号从字符串中拿出来
+        /// </summary>
+        /// <param name="strExpress"></param>
+        /// <returns></returns>
+        public ArrayList<String> GetTokens(String strExpress)
+        {
+            if (strExpress != null)
+            {
+                ArrayList<String> Tokens = new ArrayList<String>();
+                //#region 
+                String strTem = strExpress.trim();
+
+                String strTemToken = "";
+                Boolean isFindingEndYinHao = false;
+                int step = -1;
+                for (int i = 0; i < strTem.length(); i++)
+                {
+                    char c = strTem.charAt(i);
+
+                    switch (c)
+                    {
+                        case '"':
+                            if (!isFindingEndYinHao)
+                            {
+                                isFindingEndYinHao = true;
+                                step = i;
+                            }
+                            else
+                            {
+                                if ((i < strTem.length() - 1 && strTem.charAt(i + 1) == ' ')
+                                    || (i < strTem.length() - 1 && strTem.charAt(i + 1) == ')')
+                                    || (i < strTem.length() - 1 && strTem.charAt(i + 1) == ']')
+                                    || i == strTem.length() - 1)
+                                {
+                                    strTemToken = strTem.substring(step + 1, i );
+                                    Tokens.add(strTemToken);
+                                    step = i;
+                                    isFindingEndYinHao = false;
+                                }
+
+                            }
+                            break;
+                        case ' ':
+                            if (!isFindingEndYinHao)
+                            {
+                                if (step == (i - 1))
+                                {
+                                    step = i;
+                                }
+                                else
+                                {
+                                    strTemToken = strTem.substring(step + 1, i );
+                                    Tokens.add(strTemToken);
+                                    step = i;
+
+                                }
+                            }
+                            break;
+                        case '(':
+                        case '[':
+                        if (i == 0 || strTem.charAt(i - 1) == ' ' || (Tokens.size() > 0 && Tokens.get(Tokens.size() - 1) == String.valueOf(c)) || strTem.charAt(i - 1) == '=')
+                        {
+                            Tokens.add(String.valueOf(c));
+                            step = i;
+                        }
+                        break;
+                        case ')':
+                        case ']':
+                            if ((i < strTem.length() - 1 && (strTem.charAt(i + 1) == ' ' || strTem.charAt(i + 1) == c)) || i == strTem.length() - 1)
+                            {
+                                Boolean isAdd = false;
+                                for (int index = Tokens.size() - 1; index >= 0; index--)
+                                {
+                                    if ((c == ')' && Tokens.get(index).equals("("))  || (c == ']' && Tokens.get(index).equals("[")))
+                                    {
+                                        isAdd = true;
+                                        break;
+                                    }
+                                }
+                                if (isAdd)
+                                {
+                                    strTemToken = strTem.substring(step + 1, i );
+                                    if (strTemToken != null && !strTemToken.equals(""))
+                                    {
+                                        Tokens.add(strTemToken);
+                                    }
+                                    Tokens.add(String.valueOf(c));
+                                    step = i;
+                                }
+                            }
+                            break;
+                        case '=':
+                        case '>':
+                        case '>':
+                        case '<':
+                        case '<':
+                            strTemToken = strTem.substring(step + 1, i );
+
+                            if (strTemToken !=null && strTemToken !="")
+                            {
+                                Tokens.add(strTemToken);
+                            }
+
+                            if (strTem.charAt(i + 1) == '=')
+                            {
+                                Tokens.add(String.valueOf(c) + "=");
+                                step = i + 1;
+                                i++;
+                            }
+                            else
+                            {
+                                Tokens.add(String.valueOf(c));
+                                step = i;
+                            }
+                            break;
+                    }
+                }
+
+                if (step < strTem.length() - 1)
+                {
+                    Tokens.add(strTem.substring(step + 1));
+                }
+                //#endregion
+                return Tokens;
+            }
+            else
+            {
+                return null;
+            }
+        }
+}

+ 42 - 0
src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/operate.java

@@ -0,0 +1,42 @@
+package cn.cslg.pas.common.utils.parseQueryToTree;
+
+public class operate extends Symbol {
+    
+    /// <summary>
+    /// 优先级
+    /// </summary>
+    int priorityVale;
+    public void setpriorityVale(int v){
+        this.priorityVale = v;
+    }
+
+    public int getpriorityVale(){
+        return this.priorityVale;
+    }
+
+    /// <summary>
+    /// 操作符元数
+    /// 1表示一元操作符 NOT
+    /// 2表示二元操作符 AND、OR、>、<、= 、>=、<=、like等
+    /// </summary>
+    int operateValue;
+
+    public void setoperateValue(int v){
+        this.operateValue = v;
+    }
+
+    public int getoperateValue(){
+        return this. operateValue;
+    }
+
+
+    enuType type;
+
+    public void setenyType(enuType type){
+        this.type = type;
+    }
+
+    public enuType gettype(){
+        return this.type;
+    }
+}

+ 53 - 0
src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/operateNode.java

@@ -0,0 +1,53 @@
+package cn.cslg.pas.common.utils.parseQueryToTree;
+
+public class operateNode extends treeNode {
+    operate operate ;
+
+    public void setoperate(operate op){
+        this.operate = op;
+    }
+
+    public operate getoperate(){
+        return this.operate;
+    }
+
+    public String ToString(){
+        String strCode = "";
+            if ((operate.getShowName()!=null))
+            {
+                strCode = operate.getShowName();
+            }
+            else
+            {
+                strCode = operate.Code;
+            }
+
+            if(Left != null)
+            {
+                if((operate.type == enuType.Logic || operate.type == enuType.Assignment ) && (Left.Left != null || Left.Right != null))
+                {
+                    strCode = "(" + Left.ToString() +") " + strCode;
+                }
+                else
+                {
+                    strCode = Left.ToString() +" " + strCode;
+                }
+                
+            }
+
+            if(Right!= null)
+            {
+                if ((operate.type == enuType.Logic || operate.type == enuType.Assignment ) && (Right.Left != null || Right.Right != null))
+                {
+                    strCode = strCode +" (" + Right.ToString()+ ") ";
+                }
+                else
+                {
+                    strCode = strCode + " " + Right.ToString();
+                }
+                
+            }
+
+            return strCode;
+    }
+}

+ 25 - 0
src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/pairSymbol.java

@@ -0,0 +1,25 @@
+package cn.cslg.pas.common.utils.parseQueryToTree;
+
+public class pairSymbol extends Symbol {
+    Boolean isEndSymbol;
+    pairSymbol previewSymbol;
+
+    public void setisEndSymbol(Boolean endflag)
+    {
+        this.isEndSymbol = endflag;
+    }
+
+    public Boolean getisEndSymbol(){
+        return this.isEndSymbol;
+    }
+
+    public void setpreviewSymbol(pairSymbol pre)
+    {
+        this.previewSymbol= pre;
+    }
+
+    public pairSymbol getpreviewSymbol(){
+        return this.previewSymbol;
+    }
+    
+}

+ 58 - 0
src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/treeNode.java

@@ -0,0 +1,58 @@
+package cn.cslg.pas.common.utils.parseQueryToTree;
+
+public class treeNode {
+    treeNode Left ;
+    treeNode Right;
+
+    public void setLeft(treeNode node){
+        this.Left = node;
+    }
+
+    public treeNode getLeft(){
+        return Left;
+    }
+
+    public void setRight(treeNode node){
+        this.Right = node;
+    }
+
+    public treeNode getRight(){
+        return Right;
+    }
+
+    public String ToString(){
+        return "";
+    }
+
+    public treeNode AND(treeNode expressNode)
+    {
+        operateNode AndNode = new operateNode();
+        AndNode.operate = (operate)expressManager.getInstance().getSymbol("and");
+        AndNode.Left = this;
+        AndNode.Right = expressNode;
+        return AndNode;
+    }
+
+    public treeNode OR(treeNode expressNode)
+    {
+        operateNode retNode = new operateNode();
+        retNode.operate = (operate) expressManager.getInstance().getSymbol("or");
+        retNode.Left = this;
+        retNode.Right = expressNode;
+        return retNode;
+    }
+
+    public treeNode NOT(treeNode expressNode) 
+    {
+        operateNode AndNode = new operateNode();
+        AndNode.operate = (operate) expressManager.getInstance().getSymbol("AND");
+        AndNode.Left = this;
+
+        operateNode NotNode = new operateNode();
+        AndNode.operate = (operate) expressManager.getInstance().getSymbol("not");
+        AndNode.Right = expressNode;
+
+        AndNode.Right = NotNode;
+        return AndNode;
+    }
+}

+ 16 - 0
src/main/java/cn/cslg/pas/common/utils/parseQueryToTree/valueNode.java

@@ -0,0 +1,16 @@
+package cn.cslg.pas.common.utils.parseQueryToTree;
+
+public class valueNode extends treeNode {
+    String value;
+    public void setvalue(String v){
+        this.value =v;
+    }
+
+    public String getvalue(){
+        return this.value;
+    }
+
+    public String ToString(){
+        return this.value;
+    }
+}

+ 0 - 163
src/main/java/cn/cslg/pas/service/TestService.java

@@ -1,163 +0,0 @@
-package cn.cslg.pas.service;
-
-import cn.cslg.pas.domain.*;
-import cn.cslg.pas.domain.asso.AssoStructurePatent;
-import cn.cslg.pas.mapper.WebConfigMapper;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import lombok.RequiredArgsConstructor;
-import org.springframework.context.annotation.Lazy;
-import org.springframework.stereotype.Service;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
-* @author admin
-* @description 针对表【web_config(网站配置)】的数据库操作Service实现
-* @createDate 2023-03-08 18:51:17
-*/
-@Service
-@RequiredArgsConstructor(onConstructor_ = {@Lazy})
-public class TestService
-  {
-    private final IStructureService structureService;
-    private final ProjectFieldTreeService projectFieldTreeService;
-    private final ProjectFieldPatentLinkService patentLinkService;
-    private final PatentService patentService;
-    private final IStructurePatentService structurePatentService;
-     public void  getConfigById(Integer id,Integer optionId){
- // 查询产品id查询产品架构
-       LambdaQueryWrapper<Structure> wrapper =new LambdaQueryWrapper<>();
-       wrapper.eq(Structure::getProductId,id);
-       List<Structure> structureList =structureService.list(wrapper);
-       List<Structure> structures =structureList.stream().filter(item->item.getParentId().equals(0)).collect(Collectors.toList());
-         LambdaQueryWrapper<ProjectFieldPatentLink> wrapper1 =new LambdaQueryWrapper<>();
-         wrapper1.eq(ProjectFieldPatentLink::getFieldId,4766)
-                 .eq(ProjectFieldPatentLink::getOptionId,optionId);
-         List<ProjectFieldPatentLink> links =patentLinkService.list(wrapper1);
-         List<Integer> pids =links.stream().map(ProjectFieldPatentLink::getPatentId).collect(Collectors.toList());
-      this.reT(structureList,structures,0,0,id,pids);
-  }
-
-  public void reT(List<Structure> structureList,List<Structure> structures,Integer t,Integer b,Integer id,List<Integer> pids){
-    structures.forEach(item->{
-      //根据父节点和名称查找自定义字段
-      LambdaQueryWrapper<ProjectFieldTree> wrapper =new LambdaQueryWrapper<>();
-      wrapper.eq(ProjectFieldTree::getParentId,t)
-              .eq(ProjectFieldTree::getName,item.getStructureName())
-               .eq(ProjectFieldTree::getFieldId,4767);
-  ProjectFieldTree projectFieldTree =    projectFieldTreeService.getOne(wrapper);
-   if(projectFieldTree !=null) {
-       //根据projectFieldTree.getId()查询关联专利
-       LambdaQueryWrapper<ProjectFieldPatentLink> wrapper1 =new LambdaQueryWrapper<>();
-       wrapper1.eq(ProjectFieldPatentLink::getFieldId,4767)
-               .eq(ProjectFieldPatentLink::getOptionId,projectFieldTree.getId());
-       List<ProjectFieldPatentLink> links =      patentLinkService.list(wrapper1);
-       List<Integer> patentIds =links.stream().map(ProjectFieldPatentLink::getPatentId).collect(Collectors.toList());
-       //取交集
-       patentIds.retainAll(pids);
-//根据专利id查询专利号
-       if(patentIds.size()!=0){
-           LambdaQueryWrapper<Patent> wrapper2 =new LambdaQueryWrapper<>();
-           wrapper2.in(Patent::getId,patentIds);
-           List<Patent> patents =patentService.list(wrapper2);
-           List<String> patentNos =patents.stream().map(Patent::getPatentNo).collect(Collectors.toList());
-           List<AssoStructurePatent> assoStructurePatents =new ArrayList<>();
-           patentNos.forEach(tem->{
-               AssoStructurePatent assoStructurePatent =new AssoStructurePatent();
-               assoStructurePatent.setPath(item.getPath());
-               assoStructurePatent.setPatentNo(tem);
-               assoStructurePatent.setProjectId(81);
-               assoStructurePatent.setProductId(id);
-               assoStructurePatent.setStructureId(item.getId());
-               assoStructurePatents.add(assoStructurePatent);
-           });
-           structurePatentService.saveBatch(assoStructurePatents);
-       }
-     //根据父节点查询子节点
-     List<Structure> child = structureList.stream().filter(tem -> tem.getParentId().equals(item.getId())).collect(Collectors.toList());
-     if (child.size() == 0) {
-         //根据自定义字段父节点id查询子节点
-         LambdaQueryWrapper<ProjectFieldTree> wrapper2 =new LambdaQueryWrapper<>();
-         wrapper2.eq(ProjectFieldTree::getParentId,projectFieldTree.getId());
-         List<ProjectFieldTree> trees =projectFieldTreeService.list(wrapper2);
-         List<Integer> treeIds =trees.stream().map(ProjectFieldTree::getId).collect(Collectors.toList());
-         if(treeIds.size()!=0) {
-             LambdaQueryWrapper<ProjectFieldPatentLink> wrapper3 = new LambdaQueryWrapper<>();
-             wrapper3.eq(ProjectFieldPatentLink::getFieldId, 4767)
-                     .in(ProjectFieldPatentLink::getOptionId, treeIds);
-             List<ProjectFieldPatentLink> links2 = patentLinkService.list(wrapper3);
-             List<Integer> patentIds2 =links2.stream().map(ProjectFieldPatentLink::getPatentId).collect(Collectors.toList());
-             patentIds2.retainAll(pids);
-             if(patentIds2.size()!=0){
-                 LambdaQueryWrapper<Patent> wrapper4 =new LambdaQueryWrapper<>();
-                 wrapper4.in(Patent::getId,patentIds2);
-                 List<Patent> patents =patentService.list(wrapper4);
-                 List<String> patentNos =patents.stream().map(Patent::getPatentNo).collect(Collectors.toList());
-                 List<AssoStructurePatent> assoStructurePatents =new ArrayList<>();
-                 patentNos.forEach(tem->{
-                     AssoStructurePatent assoStructurePatent =new AssoStructurePatent();
-                     assoStructurePatent.setPath(item.getPath());
-                     assoStructurePatent.setPatentNo(tem);
-                     assoStructurePatent.setProjectId(81);
-                     assoStructurePatent.setProductId(id);
-                     assoStructurePatent.setStructureId(item.getId());
-                     assoStructurePatents.add(assoStructurePatent);
-                 });
-                 structurePatentService.saveBatch(assoStructurePatents);
-
-
-
-                 LambdaQueryWrapper<ProjectFieldTree> wrapper5 =new LambdaQueryWrapper<>();
-                 wrapper5.in(ProjectFieldTree::getParentId,treeIds);
-                 List<ProjectFieldTree> trees5 =projectFieldTreeService.list(wrapper5);
-                 List<Integer> treeIds5 =trees5.stream().map(ProjectFieldTree::getId).collect(Collectors.toList());
-                 if(treeIds5.size()>0) {
-                     LambdaQueryWrapper<ProjectFieldPatentLink> wrapper6 = new LambdaQueryWrapper<>();
-                     wrapper6.eq(ProjectFieldPatentLink::getFieldId, 4767)
-                             .in(ProjectFieldPatentLink::getOptionId, treeIds5);
-                     List<ProjectFieldPatentLink> links5 = patentLinkService.list(wrapper6);
-                     List<Integer> patentIds5 = links5.stream().map(ProjectFieldPatentLink::getPatentId).collect(Collectors.toList());
-                     patentIds5.retainAll(pids);
-                     if (patentIds5.size() != 0) {
-                         LambdaQueryWrapper<Patent> wrapper7= new LambdaQueryWrapper<>();
-                         wrapper7.in(Patent::getId, patentIds5);
-                         List<Patent> patents7 = patentService.list(wrapper7);
-                         List<String> patentNos7 = patents7.stream().map(Patent::getPatentNo).collect(Collectors.toList());
-                         List<AssoStructurePatent> assoStructurePatents1 = new ArrayList<>();
-                         patentNos7.forEach(tem -> {
-                             AssoStructurePatent assoStructurePatent = new AssoStructurePatent();
-                             assoStructurePatent.setPath(item.getPath());
-                             assoStructurePatent.setPatentNo(tem);
-                             assoStructurePatent.setProjectId(81);
-                             assoStructurePatent.setProductId(id);
-                             assoStructurePatent.setStructureId(item.getId());
-                             assoStructurePatents1.add(assoStructurePatent);
-                         });
-                         structurePatentService.saveBatch(assoStructurePatents1);
-                     }
-                 }
-
-
-
-
-
-             }
-
-
-         }
-     } else {
-       Integer re = projectFieldTree.getId();
-       this.reT(structureList, child, re,t,id,pids);
-
-     }
-   }
- });
-  }
-}
-
-
-
-

+ 22 - 0
src/main/java/cn/cslg/pas/service/query/QueryService.java

@@ -0,0 +1,22 @@
+package cn.cslg.pas.service.query;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+@Slf4j
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
+public class QueryService {
+    public String getText(String text) {
+
+
+        return "";
+    }
+
+
+}

+ 24 - 24
src/test/java/cn/cslg/pas/service/PatentPDFServiceTests.java

@@ -1,24 +1,24 @@
-//package cn.cslg.pas.service;
-//
-//import cn.cslg.pas.service.patentPDF.PatentPDFService;
-//import org.junit.jupiter.api.Test;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.boot.test.context.SpringBootTest;
-//
-//import java.io.IOException;
-//
-///**
-// * @author chenyu
-// * @date 2023/9/6
-// */
-//@SpringBootTest
-//public class PatentPDFServiceTests {
-//    @Autowired
-//    private PatentPDFService patentPDFService;
-//
-//    @Test
-//    void test() throws IOException {
-//        patentPDFService.queryPatentPdfFirstPages("CN201080016105.6");
-//    }
-//
-//}
+package cn.cslg.pas.service;
+
+import cn.cslg.pas.service.query.QueryService;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.io.IOException;
+
+/**
+ * @author chenyu
+ * @date 2023/9/6
+ */
+@SpringBootTest
+public class PatentPDFServiceTests {
+    @Autowired
+    private QueryService queryService;
+
+    @Test
+    void test() throws IOException {
+        queryService.getText("CN201080016105.6");
+    }
+
+}

+ 0 - 24
src/test/java/cn/cslg/pas/service/PatentRightServiceTests.java

@@ -1,24 +0,0 @@
-package cn.cslg.pas.service;
-
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-
-/**
- * @author chenyu
- * @date 2023/8/31
- */
-@SpringBootTest
-public class PatentRightServiceTests {
-    @Autowired
-    private TestService testService1;
-
-    /**
-     * 查询权利要求树
-     */
-    @Test
-    void queryPatentRightTree() {
-        testService1.getConfigById(76,2703);
-    }
-
-}

+ 0 - 56
src/test/java/cn/cslg/pas/service/PatentRightSplitCNServiceTests.java

@@ -1,56 +0,0 @@
-package cn.cslg.pas.service;
-
-import cn.cslg.pas.common.PatentRightContent;
-import cn.cslg.pas.common.model.params.PatentRightParams;
-import cn.cslg.pas.service.patentRightSplit.PatentRightSplitCNService;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-
-import java.util.List;
-
-/**
- * 测试拆分CN中国专利的权要
- *
- * @author chenyu
- * @date 2023/8/30
- *
- *
- *
- */
-@SpringBootTest
-public class PatentRightSplitCNServiceTests {
-    @Autowired
-    private PatentRightSplitCNService patentRightSplitCNService;
-
-    @Test
-    void testFormatPatentRight() {
-        PatentRightParams params = new PatentRightParams();
-        params.setContent("\"1.一种用于多电机的自适应冷却分配系统,其特征在于,包括:\n" +
-                "多个冷却组,所述冷却组包括电机和调节阀,所述电机内设置有冷却通道,所述调节阀内分别设置有进液通道和出液通道,所述进液通道的出口端与冷却通道的入口端连通,所述冷却通道的出口端与出液通道的入口端连通;以及,\n" +
-                "进液总通道,多个所述进液通道的入口端分别与进液总通道连通;\n" +
-                "其中,所述调节阀内还设置有调节通道;所述调节通道内设置有阀块,所述阀块伸入至进液通道内,使得阀块与进液通道之间形成调节孔;\n" +
-                "所述调节通道内还设置有根据出液通道内冷却介质温度来控制阀块移动的温控调节机构,从而能够对多个冷却组进行差异化冷却分配;\n" +
-                "初始状态下,所述调节孔为最小开度状态;冷却介质流通后,根据出液通道内冷却介质温度,所述阀块的位置保持不变来使得调节孔保持在最小开度状态,或者所述温控调节机构控制阀块移动来增大调节孔的开度;\n" +
-                "所述温控调节机构包括温控驱动件,所述温控驱动件能够根据温度变化来发生形变,利用形变产生的驱动力来控制阀块移动。\n" +
-                "2.根据权利要求1所述的用于多电机的自适应冷却分配系统,其特征在于:所述温控驱动件为温控弹簧,所述温控弹簧能够与出液通道内的冷却介质接触;所述温控弹簧在低温时伸长,在高温时收缩;\n" +
-                "所述温控调节机构还包括预紧弹簧,所述预紧弹簧与温控弹簧分别作用于阀块两侧。\n" +
-                "3.根据权利要求2所述的用于多电机的自适应冷却分配系统,其特征在于:所述温控弹簧一端与出液通道内壁接触,另一端与阀块接触;所述预紧弹簧的一端与进液通道内壁接触,另一端与阀块接触。\n" +
-                "4.根据权利要求1所述的用于多电机的自适应冷却分配系统,其特征在于:所述温控调节机构包括驱动块,所述驱动块与阀块之间设置有驱动杆;\n" +
-                "所述温控驱动件为温控弹簧,所述温控弹簧能够与出液通道内的冷却介质接触;所述温控弹簧在低温时收缩,在高温时伸长;所述温控弹簧作用于驱动块,且驱动杆穿过温控弹簧;\n" +
-                "所述温控调节机构包括两个作用力方向相反的预紧弹簧,两个预紧弹簧分别作用于阀块和驱动块,或者两个预紧弹簧分别作用于阀块两侧。\n" +
-                "5.根据权利要求1-4所述的用于多电机的自适应冷却分配系统,其特征在于:所述温控调节机构包括驱动块,所述驱动块与阀块之间设置有驱动杆;\n" +
-                "所述调节通道内固定设置有能够与出液通道内冷却介质接触的导热块,所述驱动杆穿过导热块,所述驱动块、导热块以及调节通道内壁之间形成热胀冷缩的温控腔;\n" +
-                "所述温控调节机构包括两个作用力方向相反的预紧弹簧,两个预紧弹簧分别作用于阀块和驱动块,或者两个预紧弹簧分别作用于阀块两侧。\n" +
-                "6.根据权利要求4或5所述的用于多电机的自适应冷却分配系统,其特征在于:所述调节阀内设置有出液分流道,所述出液分流道的进口和出口分别位于出液通道内壁;所述出液通道内的冷却介质经过出液分流道,在出液分流道内向温控驱动件传递热量。\n" +
-                "7.根据权利要求1所述的用于多电机的自适应冷却分配系统,其特征在于:多个所述调节阀集成为调节总阀,所述进液总通道设置于调节总阀内;所述调节总阀内设置有出液总通道,所述出液通道的出口端与出液总通道连通。\n" +
-                "8.一种汇流电机总成,包括齿轮箱以及分别与齿轮箱连接的多个电机,其特征在于:还包括权利要求1-7中任一项所述的用于多电机的自适应冷却分配系统;还包括与多个电机同时连接的固定板,且相邻所述电机之间连接有固定杆;所述电机包括电机壳体,所述电机壳体外侧壁设置有用于与固定杆或者固定板连接的固定环。\n" +
-                "\"\n");
-
-        List<PatentRightContent> patentRightContents = patentRightSplitCNService.formatPatentRight(params);
-
-
-    }
-
-
-}

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 58
src/test/java/cn/cslg/pas/service/PatentRightSplitENServiceTests.java


+ 0 - 115
src/test/java/cn/cslg/pas/service/TextExcelTests.java

@@ -1,115 +0,0 @@
-package cn.cslg.pas.service;
-
-import cn.cslg.pas.common.utils.ReadExcelUtils;
-import cn.cslg.pas.service.impl.StructureServiceImpl;
-import lombok.extern.slf4j.Slf4j;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-
-import java.io.File;
-
-/**
- * 检测文件合法性方法单元测试
- *
- * @Author chenyu
- * @Date 2023/8/22
- */
-@Slf4j
-@SpringBootTest
-public class TextExcelTests {
-    private String filePath;
-    @Autowired
-    private IStructureService structureService;
-    /**
-     * 测试用例1:上传的文件丢失或不存在
-     */
-    @Test
-    void addNotFoundFileTask() {
-    }
-
-    /**
-     * 测试用例2:上传非Excel文件
-     */
-    @Test
-    void addNotExcelTask() {
-        filePath = ".\\单元测试用例专用文件\\FTO风险排查报告用户操作手册.pptx";
-        File file = new File(filePath);
-
-        try {
-            ReadExcelUtils.textExcel(file, "1");
-
-        } catch (Exception e) {
-            Assertions.assertEquals("文件格式错误,请上传Excel文件!", e.getMessage(), "测试用例2不通过");
-        }
-    }
-
-    /**
-     * 测试用例3:上传Excel文件,单元格行数 <= 1
-     */
-    @Test
-    void addRowLessThan1ExcelTask() {
-        filePath = ".\\单元测试用例专用文件\\1件CN专利 - 单元格行数不大于1.XLSX";
-        File file = new File(filePath);
-
-        try {
-            ReadExcelUtils.textExcel(file, "1");
-
-        } catch (Exception e) {
-            Assertions.assertEquals("文件内容格式不正确,请检查总行数是否有专利内容", e.getMessage(), "测试用例3不通过");
-        }
-    }
-
-    /**
-     * 测试用例4:上传Excel文件,抬头没有申请号
-     */
-    @Test
-    void addFalseTitleExcelTask() {
-        filePath = ".\\单元测试用例专用文件\\1件CN专利 - 抬头没有申请号.XLSX";
-        File file = new File(filePath);
-
-        try {
-            ReadExcelUtils.textExcel(file, "1");
-
-        } catch (Exception e) {
-            Assertions.assertEquals("文件内容格式不正确,第一行抬头必须有【公开(公告)号】和【申请号】", e.getMessage(), "测试用例4不通过");
-        }
-
-    }
-
-    /**
-     * 测试用例5:上传Excel文件,抬头没有公开公告号
-     */
-    @Test
-    void addFalseTitleExcelTask2() {
-        filePath = ".\\单元测试用例专用文件\\1件CN专利 - 抬头没有公开公告号.XLSX";
-        File file = new File(filePath);
-
-        try {
-            ReadExcelUtils.textExcel(file, "1");
-
-        } catch (Exception e) {
-            Assertions.assertEquals("文件内容格式不正确,第一行抬头必须有【公开(公告)号】和【申请号】", e.getMessage(), "测试用例5不通过");
-        }
-
-    }
-
-    /**
-     * 测试用例6:上传Excel文件,格式内容符合标准
-     */
-    @Test
-    void addExcelTask() {
-        filePath = ".\\单元测试用例专用文件\\1件CN专利.XLSX";
-        File file = new File(filePath);
-
-        try {
-            ReadExcelUtils.textExcel(file, "1");
-
-        } catch (Exception e) {
-            Assertions.assertEquals("文件内容格式不正确,第一行抬头必须有【公开(公告)号】和【申请号】", e.getMessage(), "测试用例5不通过");
-        }
-
-    }
-
-}