浏览代码

5/31 拆分权要修改

lwhhszx 1 年之前
父节点
当前提交
64910e9380

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

@@ -6,8 +6,8 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter;
 
 @Configuration
 public class WebSocketConfig {
-    @Bean
-    public ServerEndpointExporter serverEndpointExporter() {
-        return new ServerEndpointExporter();
-    }
+//    @Bean
+//    public ServerEndpointExporter serverEndpointExporter() {
+//        return new ServerEndpointExporter();
+//    }
 }

+ 4 - 5
src/main/java/cn/cslg/pas/common/model/addPatentToReport/AddProjectPatentToReportDTO.java

@@ -9,11 +9,10 @@ import java.util.List;
 @Data
 public class AddProjectPatentToReportDTO {
     private StringRequest stringRequest;
-    private Integer taskType;
     private Integer fromProjectId;
-    private Long start;
-    private Long end;
+    private Long startNumber;
+    private Long endNumber;
     private Integer toProjectId;
-    private List<String> notInPatentNos;
-    private List<String> InPatentNos;
+    private List<String> isDelete;
+    private List<String> isAdd;
 }

+ 0 - 1
src/main/java/cn/cslg/pas/common/utils/ClaimUtils/ClaimSplitUtils.java

@@ -384,7 +384,6 @@ public class ClaimSplitUtils {
                         .setPatentNo(patentNo)
                         .setType(1)
                         .setParentSort("-1");
-                patentRights.add(patentRight);
             }
         }
 

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

@@ -211,4 +211,29 @@ public class FileUtils {
     public String getSystemPath(String url) {
         return getStaticPath(COMMON_FILE) + FILE_SEPARATOR + url;
     }
+
+    public  static void  writeFile(String json, String FilePath) {
+
+        try {
+            File file = new File(FilePath);
+
+            // if file doesnt exists, then create it
+            if (!file.exists()) {
+                file.createNewFile();
+            } else {
+                file.delete();
+                file.createNewFile();
+            }
+
+            // true = append file
+            FileWriter fileWritter = new FileWriter(file, false);
+            BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
+            bufferWritter.write(json);
+            bufferWritter.close();
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
 }

+ 2 - 0
src/main/java/cn/cslg/pas/common/vo/business/ReportProjectVO.java

@@ -224,5 +224,7 @@ public class ReportProjectVO {
     private Integer patentType;
     @Schema(description = "梳理意见")
     private String cardingOpinion;
+    @Schema(description = "关联id")
+    private Integer assoReportId;
 
 }

+ 112 - 0
src/main/java/cn/cslg/pas/controller/TemController.java

@@ -0,0 +1,112 @@
+package cn.cslg.pas.controller;
+
+import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.dto.PatentColumnDTO;
+import cn.cslg.pas.common.dto.PatentDTO;
+import cn.cslg.pas.common.dto.business.AsInvalidReasonHistoryDTO;
+import cn.cslg.pas.common.dto.business.OtherPatentInfoDTO;
+import cn.cslg.pas.common.model.cronModel.Records;
+import cn.cslg.pas.common.model.request.StringRequest;
+import cn.cslg.pas.common.utils.ClaimUtils.ClaimSplitUtils;
+import cn.cslg.pas.common.utils.FileUtils;
+import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.common.vo.PatentRightParams;
+import cn.cslg.pas.common.vo.RePatentClaim;
+import cn.cslg.pas.domain.es.Text;
+import cn.cslg.pas.service.business.AsInvalidReasonHistoryService;
+import cn.cslg.pas.service.business.es.EsService;
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
+import com.google.gson.JsonObject;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 作为无效证据使用历史
+ *
+ * @Author xiexiang
+ * @Date 2024/1/19
+ */
+@Slf4j
+@RequestMapping(Constants.API_XiaoSHI + "/tem")
+@RestController
+public class TemController {
+    @Autowired
+    private AsInvalidReasonHistoryService asInvalidReasonHistoryService;
+
+    @Autowired
+    private EsService esService;
+
+    @Operation(summary = "添加or更新作为无效证据使用历史")
+    @GetMapping("/saveOrUpdate")
+    public Response saveOrUpdate() throws Exception {
+        String rootPath1 = "C:\\Users\\admin\\Desktop\\patentClaim\\";
+        String rootPath2 = "C:\\Users\\admin\\Desktop\\patentClaimOnlyOne\\";
+
+        Long total = 0L;
+        Long current = 37L;
+        Boolean flag = true;
+        while (flag) {
+            System.out.println(current);
+            StringRequest stringRequest = new StringRequest();
+            stringRequest.setProjectId(323);
+            stringRequest.setCurrent(current);
+            stringRequest.setSize(10L);
+            PatentDTO patentDTO = esService.esSearch(stringRequest);
+            List<PatentColumnDTO> patentColumnDTOS = patentDTO.getPatents();
+            total = patentDTO.getTotal();
+            if (current * 10L > total) {
+                flag = false;
+            } else {
+                current++;
+            }
+            for (PatentColumnDTO patentColumnDTO : patentColumnDTOS) {
+                String pn = patentColumnDTO.getPatentNo();
+                List<Text> claims = patentColumnDTO.getClaim();
+                if (claims == null || claims.size() == 0) {
+                    continue;
+                }
+                Text text = claims.stream().filter(item -> item.getIfOrigin().equals(true)).findFirst().orElse(null);
+                if (text == null) {
+                    continue;
+                }
+                PatentRightParams rightParams = new PatentRightParams();
+                String content = text.getTextContent();
+                rightParams.setPatentNo(pn);
+                rightParams.setContent(content);
+                List<RePatentClaim> rePatentClaims = ClaimSplitUtils.formatPatentRight(rightParams);
+                StringBuilder stringBuilder = new StringBuilder();
+                rePatentClaims.forEach(item -> stringBuilder.append(item.getContent()));
+
+                if (rePatentClaims.size() == 1) {
+                    Map<String, Object> map = new HashMap<>();
+                    map.put("content", content);
+                    map.put("PN", patentColumnDTO.getPatentNo());
+                    String path = rootPath2 + patentColumnDTO.getPatentNo() + ".json";
+                    String json = JSONObject.toJSONString(map);
+                    FileUtils.writeFile(json, path);
+                }
+                if (!stringBuilder.toString().equals(content)) {
+                    Map<String, Object> map = new HashMap<>();
+                    map.put("content", content);
+                    map.put("PN", patentColumnDTO.getPatentNo());
+                    String path = rootPath1 + patentColumnDTO.getPatentNo() + ".json";
+                    String json = JSONObject.toJSONString(map);
+                    FileUtils.writeFile(json, path);
+                }
+                System.out.println(pn);
+            }
+        }
+        System.out.println("done");
+        return Response.success("");
+    }
+
+
+}

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

@@ -101,12 +101,13 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
         //查询专利号
         StringRequest stringRequest = addProjectPatentToReportDTO.getStringRequest();
         Integer toProjectId = addProjectPatentToReportDTO.getToProjectId();
-        List<String> notInNos = addProjectPatentToReportDTO.getNotInPatentNos();
-
+        List<String> notInNos = addProjectPatentToReportDTO.getIsDelete();
+     Long startNum =addProjectPatentToReportDTO.getStartNumber();
+     Long endNum =addProjectPatentToReportDTO.getEndNumber();
         List<PatentNoWithIdVO> patentWithIdVOS = new ArrayList<>();
-        List<String> InPatentNos = addProjectPatentToReportDTO.getInPatentNos();
+        List<String> InPatentNos = addProjectPatentToReportDTO.getIsAdd();
         try {
-            patentWithIdVOS = esPatentService.getPatentIdsWithNotNo(stringRequest, notInNos);
+            patentWithIdVOS = esPatentService.getPatentIdsWithNotNo(stringRequest, notInNos,startNum,endNum);
             if (patentWithIdVOS != null && patentWithIdVOS.size() > 0) {
                 this.addAssoToEs(patentWithIdVOS, toProjectId);
             }

+ 22 - 14
src/main/java/cn/cslg/pas/service/business/ReportProjectService.java

@@ -205,7 +205,7 @@ public class ReportProjectService extends ServiceImpl<ReportProjectMapper, Repor
         StringRequest stringRequest = new StringRequest();
         BeanUtils.copyProperties(groupRequest, stringRequest);
         List<String> sqls = formatQueryService.reSqls(stringRequest, tableName);
-        sqls=this.loadSearchSql(sqls);
+        sqls = this.loadSearchSql(sqls);
         //格式化 分组
         GroupConfig groupConfig = null;
         if (groupRequest.getGroupBy() != null) {
@@ -217,13 +217,13 @@ public class ReportProjectService extends ServiceImpl<ReportProjectMapper, Repor
             }
         }
         tableName = "report as rp left join project as p on rp.project_id =p.id ";
-        tableName+=  "left join (select * from asso_project_event where scenario_id is not null ) as asps on p.id = asps.project_id " +
+        tableName += "left join (select * from asso_project_event where scenario_id is not null ) as asps on p.id = asps.project_id " +
                 "left join (select * from asso_project_event where event_id is not null ) as aspe on p.id = aspe.project_id " +
                 "left join (select * from asso_project_event where matter_id is not null ) as aspm on p.id = aspm.project_id";
         //返回分组数据
         QueryGroupImp queryGroupImp = queryGroupFactory.getClass(groupConfig.getGroupClass());
-        String countFiled="distinct p.id";
-        ReGroupDataVO reGroupDataVO = queryGroupImp.getGroup(sqls, tableName, groupConfig.getSqlField(),countFiled);
+        String countFiled = "distinct p.id";
+        ReGroupDataVO reGroupDataVO = queryGroupImp.getGroup(sqls, tableName, groupConfig.getSqlField(), countFiled);
 
         //装载数据
         GroupVO groupVO = new GroupVO();
@@ -333,10 +333,10 @@ public class ReportProjectService extends ServiceImpl<ReportProjectMapper, Repor
             try {
                 PatentWithIdVO patentWithIdVO = esService.getIdByPatentNo(reportProject.getSignPatentNo());
                 if (patentWithIdVO != null && patentWithIdVO.getPatent() != null) {
-                    if(patentWithIdVO.getPatent().getPatentType()!=null) {
+                    if (patentWithIdVO.getPatent().getPatentType() != null) {
                         reportProject.setPatentType(Integer.parseInt(patentWithIdVO.getPatent().getPatentType()));
                     }
-                    }
+                }
             } catch (Exception e) {
                 throw new XiaoShiException("未查询到标的专利");
             }
@@ -371,7 +371,7 @@ public class ReportProjectService extends ServiceImpl<ReportProjectMapper, Repor
         List<AssoProjectEvent> assoProjectEvents = new ArrayList<>();
         List<ProjectEventDTO> events = reportProjectDTO.getEvents();
         if (events != null && events.size() != 0) {
-            assoProjectEventService.addAssoEventProject(events,project.getId(),1);
+            assoProjectEventService.addAssoEventProject(events, project.getId(), 1);
         }
         /**
          * 装载和附件关联
@@ -548,7 +548,7 @@ public class ReportProjectService extends ServiceImpl<ReportProjectMapper, Repor
         List<ProjectEventDTO> events = updateReportProjectDTO.getEvents();
         if (events != null && events.size() != 0) {
             if (events != null && events.size() != 0) {
-                assoProjectEventService.addAssoEventProject(events,project.getId(),1);
+                assoProjectEventService.addAssoEventProject(events, project.getId(), 1);
             }
         }
         /**
@@ -612,6 +612,7 @@ public class ReportProjectService extends ServiceImpl<ReportProjectMapper, Repor
         List<SystemDict> reportTypeList = new ArrayList<>();
         List<Scenario> scenarios = new ArrayList<>();
         List<Matter> matters = new ArrayList<>();
+        List<AssoProject> assoProjects = new ArrayList<>();
         reportProjectVOs.forEach(
                 item -> {
 
@@ -682,6 +683,11 @@ public class ReportProjectService extends ServiceImpl<ReportProjectMapper, Repor
             systemDictLambdaQueryWrapper.eq(SystemDict::getType, "REPORT_TYPE").or().eq(SystemDict::getType, "REPORT_STATE");
             reportTypeList = systemDictService.list(systemDictLambdaQueryWrapper);
 
+
+            //
+            LambdaQueryWrapper<AssoProject> queryWrapper1 = new LambdaQueryWrapper<>();
+            queryWrapper1.in(AssoProject::getAssoProjectId, ids);
+            assoProjects = assoProjectService.list(queryWrapper1);
         }
 
 
@@ -853,7 +859,11 @@ public class ReportProjectService extends ServiceImpl<ReportProjectMapper, Repor
                     reportProjectVO.setStatusName(systemDictStatus.getLabel());
                 }
             }
-
+            //装载关联报告id
+            AssoProject assoProject = assoProjects.stream().filter(item -> item.getAssoProjectId().equals(reportProjectVO.getId())).findFirst().orElse(null);
+            if (assoProject != null) {
+                reportProjectVO.setAssoReportId(assoProject.getProjectId());
+            }
         }
     }
 
@@ -882,16 +892,14 @@ public class ReportProjectService extends ServiceImpl<ReportProjectMapper, Repor
     private List<String> loadSearchSql(List<String> sqls) {
         PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
         String id = personnelVO.getId();
-        Integer tenantId= personnelVO.getTenantId();
+        Integer tenantId = personnelVO.getTenantId();
         Integer roleType = personnelVO.getRoleType();
         String rootSql = "";
         if (roleType == null || roleType.equals(0)) {
             rootSql = "(p.create_id =" + id + " or p.head_id=" + id + " or p.id in (select project_id from asso_project_person where person_id =" + id + "))";
 
-        }
-        else if(roleType.equals(2))
-        {
-            rootSql="p.tenant_id="+tenantId;
+        } else if (roleType.equals(2)) {
+            rootSql = "p.tenant_id=" + tenantId;
         }
         if (sqls.get(0) != null && !sqls.get(0).equals("") && !rootSql.equals("")) {
             sqls.set(0, rootSql + " and " + "(" + sqls.get(0) + ")");

+ 47 - 3
src/main/java/cn/cslg/pas/service/business/es/EsPatentService.java

@@ -32,6 +32,7 @@ import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.permissions.PermissionService;
 import cn.cslg.pas.service.query.FormatQueryService;
 import co.elastic.clients.elasticsearch.ElasticsearchClient;
+import co.elastic.clients.elasticsearch._types.SortOptions;
 import co.elastic.clients.elasticsearch._types.SortOrder;
 import co.elastic.clients.elasticsearch._types.query_dsl.Query;
 import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
@@ -792,11 +793,13 @@ public class EsPatentService {
     }
 
 
-    public List<PatentNoWithIdVO> getPatentIdsWithNotNo(QueryRequest queryRequest, List<String> patentNos) throws Exception {
+    public List<PatentNoWithIdVO> getPatentIdsWithNotNo(QueryRequest queryRequest, List<String> patentNos,Long startNum,Long endNum) throws Exception {
         List<PatentNoWithIdVO> patentWithIdVOS=new ArrayList<>();
         SearchRequest.Builder builder = new SearchRequest.Builder();
         Long current =queryRequest.getCurrent();
         Long size =queryRequest.getSize();
+        String groupField = queryRequest.getGroupField();
+
         //设置查询索引
         builder.index("patent");
         Query q = this.getQuery(queryRequest);
@@ -810,14 +813,55 @@ public class EsPatentService {
         }
         //4. 返回数据
         builder.query(reQuery);
-        if (current > 0 && size > 0) {
-            builder.from(current.intValue() - 1).size(size.intValue());
+        if (startNum > 0 && endNum>0) {
+            builder.from(startNum.intValue()-1).size((endNum.intValue()-startNum.intValue())+1);
         }
         List<String> reSources = this.rePatentSource();
         builder.source(sourceOptionsBuilder -> sourceOptionsBuilder
                 .filter(fieldSourceBuilder -> fieldSourceBuilder
                         .includes(reSources)));
 
+        //判断同族分组
+        String str = "";
+        if (StringUtils.isNotEmpty(groupField)) {
+            switch (groupField) {
+                case "simpleFamilyId":
+                    str = "simple_family_id";
+                    break;
+                case "inpadocFamilyId":
+                    str = "inpadoc_family_id";
+                    break;
+                case "patsnapFamilyId":
+                    str = "patsnap_family_id";
+                    break;
+            }
+        }
+
+
+
+
+        List<SortOptions> optionsList = new ArrayList<>();
+        List<OrderDTO> dtoList = queryRequest.getOrderDTOList();
+        if (!CollectionUtils.isEmpty(dtoList)) {
+            String json = CommonService.readJsonFile("patent.json");
+            List<EsConfigVO> esConfigVOS = JSON.parseArray(json, EsConfigVO.class);
+            for (OrderDTO orderDTO : dtoList) {
+                EsConfigVO configVO = esConfigVOS.stream().filter(item -> item.getField().equals(orderDTO.getOrderBy())).findFirst().orElse(null);
+                if (configVO != null) {
+                    if (orderDTO.getOrderType().equals(IfConstant.NO)) {
+                        SortOptions sortOptions = SortOptions.of(i -> i.field(j -> j.field(configVO.getEsField()).order(SortOrder.Asc).missing(-1)));
+                        optionsList.add(sortOptions);
+                    } else {
+                        SortOptions sortOptions = SortOptions.of(i -> i.field(j -> j.field(configVO.getEsField()).order(SortOrder.Desc).missing(-1)));
+                        optionsList.add(sortOptions);
+                    }
+                }
+            }
+        } else {
+            SortOptions sortOptions = SortOptions.of(i -> i.field(j -> j.field("patent_no.keyword").order(SortOrder.Desc).missing(-1)));
+            optionsList.add(sortOptions);
+        }
+        builder.sort(optionsList);
         SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
         List<Hit<Patent>> hits = response.hits().hits();
         for (Hit<Patent> hit : hits) {

+ 47 - 0
src/test/java/cn/cslg/pas/service/ClaimTextTests.java

@@ -1,19 +1,29 @@
 package cn.cslg.pas.service;
 
 
+import cn.cslg.pas.common.dto.PatentColumnDTO;
+import cn.cslg.pas.common.dto.PatentDTO;
+import cn.cslg.pas.common.model.request.StringRequest;
 import cn.cslg.pas.common.utils.ClaimUtils.ClaimSplitUtils;
 import cn.cslg.pas.common.vo.PatentRightParams;
 import cn.cslg.pas.common.vo.RePatentClaim;
+import cn.cslg.pas.domain.es.Text;
 import cn.cslg.pas.service.business.CommonService;
+import cn.cslg.pas.service.business.es.EsService;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.thymeleaf.templateparser.text.TextTemplateParser;
 
+import java.util.ArrayList;
 import java.util.List;
 
 @SpringBootTest
 public class ClaimTextTests {
+    @Autowired
+    private EsService esService;
 
     @Test
     public void test() throws Exception {
@@ -37,4 +47,41 @@ public class ClaimTextTests {
         System.out.println(pn);
     }
 
+
+    @Test
+    public void testTotal() throws Exception {
+        StringRequest stringRequest = new StringRequest();
+        stringRequest.setProjectId(323);
+        stringRequest.setCurrent(1L);
+        stringRequest.setSize(10L);
+        PatentDTO patentDTO = esService.esSearch(stringRequest);
+        List<PatentColumnDTO> patentColumnDTOS = patentDTO.getPatents();
+
+        for (PatentColumnDTO patentColumnDTO : patentColumnDTOS) {
+            String pn = patentColumnDTO.getPatentNo();
+            List<Text> claims = patentColumnDTO.getClaim();
+            if (claims == null || claims.size() == 0) {
+                continue;
+            }
+            Text text =claims.stream().filter(item->item.getIfOrigin().equals(true)).findFirst().orElse(null);
+            if(text==null){
+                continue;
+            }
+            PatentRightParams rightParams = new PatentRightParams();
+            String content =text.getTextContent();
+            rightParams.setPatentNo(pn);
+            rightParams.setContent(content);
+            List<RePatentClaim> rePatentClaims = ClaimSplitUtils.formatPatentRight(rightParams);
+            StringBuilder stringBuilder = new StringBuilder();
+            rePatentClaims.forEach(item -> stringBuilder.append(item.getContent()));
+
+            if (stringBuilder.toString().equals(content)) {
+                System.out.println(true);
+            }
+
+            System.out.println(pn);
+        }
+
+
+    }
 }