Browse Source

修改bug

lwhhszx 2 years ago
parent
commit
3db757f607

+ 5 - 0
PAS/src/main/java/cn/cslg/pas/common/model/vo/PatentVO.java

@@ -22,6 +22,10 @@ public class PatentVO extends BaseVO {
     private String rightContent;
     private String rightContentSql;
     private List<Field> field;
+    private List<Field> mField;
+    private List<Field> textField;
+    private List<Field> treeField0;
+    private List<Field> treeField1;
     private List<Integer> selected;
     private Integer startNumber;
     private Integer endNumber;
@@ -92,6 +96,7 @@ public class PatentVO extends BaseVO {
     private List<String> patentNos;
     private String patentNo;
     private List<String> notInPatentNos;
+    private Integer sizeCount;
 
     @Data
     public static class Sort {

+ 7 - 0
PAS/src/main/java/cn/cslg/pas/controller/PatentFamilyController.java

@@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 /**
  * <p>
  * 专利同族 前端控制器
@@ -35,4 +37,9 @@ public class PatentFamilyController {
     public String getPageList(PatentSimpleFamilyVO params) {
         return Response.success(patentSimpleFamilyLinkService.getPageList(params));
     }
+    @GetMapping("cleanDate")
+    @Operation(summary = "清理脏数据")
+    public List<String> cleanDate(Integer type) {
+        return patentSimpleFamilyService.cleanDate(type);
+    }
 }

+ 3 - 0
PAS/src/main/java/cn/cslg/pas/domain/PatentSimpleFamily.java

@@ -1,6 +1,7 @@
 package cn.cslg.pas.domain;
 
 import cn.cslg.pas.common.model.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
@@ -25,5 +26,7 @@ public class PatentSimpleFamily extends BaseEntity<PatentSimpleFamily> {
      * 公开号
      */
     public String patentNo;
+    @TableField(exist = false)
+    public Integer count;
 
 }

+ 0 - 1
PAS/src/main/java/cn/cslg/pas/domain/PatentSimpleFamilyLink.java

@@ -18,7 +18,6 @@ import java.util.List;
 @Data
 @TableName("os_patent_simplefamily_link")
 public class PatentSimpleFamilyLink extends BaseEntity<PatentSimpleFamilyLink> {
-
     /**
      * 同族id
      */

+ 2 - 1
PAS/src/main/java/cn/cslg/pas/mapper/PatentSimpleFamilyLinkMapper.java

@@ -1,5 +1,6 @@
 package cn.cslg.pas.mapper;
 
+import cn.cslg.pas.domain.PatentSimpleFamily;
 import cn.cslg.pas.domain.PatentSimpleFamilyLink;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
@@ -18,6 +19,6 @@ public interface PatentSimpleFamilyLinkMapper extends BaseMapper<PatentSimpleFam
 
 
  List<PatentSimpleFamilyLink> getPatentFamilyLinkByPatentNo(@Param("patentNos") List<String> patentNos,@Param("type")Integer type);
-
+   List<PatentSimpleFamily> getDirtyData(Integer type);
 
 }

+ 35 - 2
PAS/src/main/java/cn/cslg/pas/service/PatentService.java

@@ -227,6 +227,10 @@ public class PatentService extends ServiceImpl<PatentMapper, Patent> {
     }
 
     private void setQueryPatentParams(PatentVO params) {
+        params.setTextField(new ArrayList<>());
+        params.setTreeField0(new ArrayList<>());
+        params.setTreeField1(new ArrayList<>());
+        params.setMField(new ArrayList<>());
         List<String> customIds = new ArrayList<>();
         if (StringUtils.isNotEmpty(params.getName())) {
             params.setNameSql(PatentUtils.formatTextQuerySql(params.getName(), "a.name"));
@@ -362,26 +366,55 @@ public class PatentService extends ServiceImpl<PatentMapper, Patent> {
                             params.setWhereTreeType1(queryList);
                             params.setQueryTreeType0(false);
                             params.setWhereTreeType0(null);
+                            List<PatentVO.Field> tem =new ArrayList<>(params.getTreeField1());
+                            tem.add(params.getField().get(i));
+                            params.setTreeField1(tem);
                         } else {
                             params.setQueryTreeType0(true);
                             params.setWhereTreeType0(queryList);
                             params.setQueryTreeType1(false);
                             params.setWhereTreeType1(null);
+                            List<PatentVO.Field> tem =new ArrayList<>(params.getTreeField0());
+                            tem.add(params.getField().get(i));
+                            params.setTreeField0(tem);
                         }
+
                     } else if (fieldType.equals("0") || fieldType.equals("1") || fieldType.equals("2")) {
                         params.setWhereFieldText(queryList);
                         params.setWhereFieldTextNull(queryList.stream().anyMatch(item -> item.equals("null")));
+                        List<PatentVO.Field> tem =new ArrayList<>(params.getTextField());
+                        tem.add(params.getField().get(i));
+                        params.setQueryFieldText(true);
+                        params.setTextField(tem);
                     } else {
+                        params.setQueryFieldMultiple(true);
                         params.setWhereFieldMultiple(queryList);
                         params.setWhereFieldMultipleNull(queryList.stream().anyMatch(item -> item.equals("null")));
+                        List<PatentVO.Field> tem =new ArrayList<>(params.getMField());
+                        tem.add(params.getField().get(i));
+                        params.setMField(tem);
                     }
             }
         }
         if (customIds.size() != 0) {
-            params.setQueryFieldText(true);
-            params.setQueryFieldMultiple(true);
             params.setCustomIds(customIds);
         }
+        Integer msize =params.getMField().size();
+        Integer textSize =params.getTextField().size();
+        Integer tree0Size =params.getTreeField0().size();
+        Integer tree1Size =params.getTreeField1().size();
+        if(msize>textSize&&msize>tree0Size&&msize>tree1Size){
+            params.setSizeCount(msize-1);
+        }
+        else if(textSize>msize&&textSize>tree0Size&&textSize>tree1Size){
+            params.setSizeCount(textSize-1);
+        }
+        else if(tree1Size>msize&&tree1Size>tree0Size&&tree1Size>tree0Size) {
+            params.setSizeCount(tree1Size-1);
+        }
+        else {
+            params.setSizeCount(tree0Size-1);
+        }
     }
 
     public List<Integer> getPatentListIds(PatentVO params) {

+ 72 - 49
PAS/src/main/java/cn/cslg/pas/service/PatentSimpleFamilyService.java

@@ -10,11 +10,13 @@ import cn.cslg.pas.mapper.PatentSimpleFamilyLinkMapper;
 import cn.cslg.pas.mapper.PatentSimpleFamilyMapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 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;
 
@@ -83,7 +85,7 @@ public class PatentSimpleFamilyService extends ServiceImpl<PatentSimpleFamilyMap
         }
     }
 
-    public PatentSimpleFamily add(Integer type,String patentNO) {
+    public PatentSimpleFamily add(Integer type, String patentNO) {
         PatentSimpleFamily patentSimpleFamily = new PatentSimpleFamily();
         patentSimpleFamily.setType(type);
         patentSimpleFamily.setPatentNo(patentNO);
@@ -92,7 +94,6 @@ public class PatentSimpleFamilyService extends ServiceImpl<PatentSimpleFamilyMap
     }
 
     public void updateData(List<String> familyNo, String patentNo, Integer patentId, Integer type) {
-        long start =System.currentTimeMillis();
         //0.合并专利号
         if (!familyNo.contains(patentNo)) {
             familyNo.add(patentNo);
@@ -101,37 +102,36 @@ public class PatentSimpleFamilyService extends ServiceImpl<PatentSimpleFamilyMap
         List<Patent> patent1s = patentService.getPublicDateAndPatentNoByPatentNo(familyNo);
 
         //2.从1步取得的专利清单获取第一个CN专利号,为插入Family表中的专利号,如果没有CN专利,取第一个专利号
-        String temPatentNo="";
-        if(patent1s != null) {
+        String temPatentNo = "";
+        if (patent1s != null) {
             Patent patentTem = patent1s.stream().filter(item -> PatentUtils.getPatentCountry(item.getPatentNo()) == "CN").findFirst().orElse(null);
             if (patentTem == null) {
                 patentTem = patent1s.get(0);
             }
-            temPatentNo=patentTem.getPatentNo();
+            temPatentNo = patentTem.getPatentNo();
+        } else {
+            temPatentNo = patentNo;
         }
-        else{
-            temPatentNo= patentNo;
-        }
-        String familyPatent =temPatentNo;
-         //根据专利号查询同族信息
-        LambdaQueryWrapper<PatentSimpleFamily> wrapper =new LambdaQueryWrapper<>();
-        wrapper.in(PatentSimpleFamily::getPatentNo,familyNo)
-               .eq(PatentSimpleFamily::getType,type);
-        List<PatentSimpleFamily>  simpleFamilies = this.list(wrapper);
+        String familyPatent = temPatentNo;
+        //根据专利号查询同族信息
+        LambdaQueryWrapper<PatentSimpleFamily> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(PatentSimpleFamily::getPatentNo, familyNo)
+                .eq(PatentSimpleFamily::getType, type);
+        List<PatentSimpleFamily> simpleFamilies = this.list(wrapper);
         //获得同族专利的同族id
-        List<Integer> familyIds =simpleFamilies.stream().map(PatentSimpleFamily::getId).collect(Collectors.toList());
+        List<Integer> familyIds = simpleFamilies.stream().map(PatentSimpleFamily::getId).collect(Collectors.toList());
         //查询是否有满足条件的
-      PatentSimpleFamily simpleFamily  =simpleFamilies.stream().filter(item->item.getPatentNo().equals(familyPatent)&&item.getType().equals(type)).findFirst().orElse(null);
-      if(simpleFamily==null){
-          simpleFamily= this.add(type,familyPatent);
-      }
-      familyIds.remove(simpleFamily.getId());
+        PatentSimpleFamily simpleFamily = simpleFamilies.stream().filter(item -> item.getPatentNo().equals(familyPatent) && item.getType().equals(type)).findFirst().orElse(null);
+        if (simpleFamily == null) {
+            simpleFamily = this.add(type, familyPatent);
+        }
+        familyIds.remove(simpleFamily.getId());
 
         //3.根据专利号(faimlyNo + patentNo)和同族类型从family关联表中取数据
-        List<PatentSimpleFamilyLink> patentSimpleFamilyLinkList = patentSimpleFamilyLinkMapper.getPatentFamilyLinkByPatentNo(familyNo,type);
+        List<PatentSimpleFamilyLink> patentSimpleFamilyLinkList = patentSimpleFamilyLinkMapper.getPatentFamilyLinkByPatentNo(familyNo, type);
 
         //5.专利号(faimlyNo + patentNo)和第三步获得的记录比较,如果没有则在关联表中添加一条记录
-        for(String temPN:familyNo) {
+        for (String temPN : familyNo) {
             PatentSimpleFamilyLink temp = patentSimpleFamilyLinkList.stream().filter(item -> item.getPatentNo().equals(temPN)).findFirst().orElse(null);
             if (temp == null) {
                 //5.1 如果关联表中没有记录,添加一个
@@ -152,22 +152,19 @@ public class PatentSimpleFamilyService extends ServiceImpl<PatentSimpleFamilyMap
         if (patent1 != null) {
             switch (type) {
                 case 1:
-                    if(patent1.getSimpleFamily()!=simpleFamily.getId())
-                    {
+                    if (patent1.getSimpleFamily() != simpleFamily.getId()) {
                         patent1.setSimpleFamily(simpleFamily.getId());
                         patent1.updateById();
                     }
                     break;
                 case 2:
-                    if(patent1.getInpadocFamily()!=simpleFamily.getId())
-                    {
+                    if (patent1.getInpadocFamily() != simpleFamily.getId()) {
                         patent1.setInpadocFamily(simpleFamily.getId());
                         patent1.updateById();
                     }
                     break;
                 case 3:
-                    if(patent1.getPatSnapFamily()!=simpleFamily.getId())
-                    {
+                    if (patent1.getPatSnapFamily() != simpleFamily.getId()) {
                         patent1.setPatSnapFamily(simpleFamily.getId());
                         patent1.updateById();
                     }
@@ -175,33 +172,59 @@ public class PatentSimpleFamilyService extends ServiceImpl<PatentSimpleFamilyMap
             }
 
         }
-        if(familyIds.size()!=0) {
+        if (familyIds.size() != 0) {
             //删除同族关联信息
-            LambdaQueryWrapper<PatentSimpleFamilyLink> linkWrapper =new LambdaQueryWrapper<>();
-            linkWrapper.in(PatentSimpleFamilyLink::getId,familyIds);
+            LambdaQueryWrapper<PatentSimpleFamilyLink> linkWrapper = new LambdaQueryWrapper<>();
+            linkWrapper.in(PatentSimpleFamilyLink::getId, familyIds);
             patentSimpleFamilyLinkService.remove(linkWrapper);
             //删除其他同族信息
-            LambdaUpdateWrapper<PatentSimpleFamily> deleteWrapper= new LambdaUpdateWrapper<>();
-            deleteWrapper.in(PatentSimpleFamily::getId,familyIds);
+            LambdaUpdateWrapper<PatentSimpleFamily> deleteWrapper = new LambdaUpdateWrapper<>();
+            deleteWrapper.in(PatentSimpleFamily::getId, familyIds);
             this.remove(deleteWrapper);
         }
-        long end =System.currentTimeMillis();
-        System.out.println("总共用时---"+(start-end));
     }
 
-//
-//        //4.第3步中如果有数据,则取得一个familID为下一步的插入关联表中的id
-//        PatentSimpleFamily patentSimpleFamily;
-//        if(patentSimpleFamilyLinkList !=null && patentSimpleFamilyLinkList.size() >0){
-//            //4.1 第3步中有数据
-//             patentSimpleFamily = this.getPatentSimpleFamilyByIdsAndType(patentSimpleFamilyLinkList.stream().map(PatentSimpleFamilyLink::getFamilyId).collect(Collectors.toList()), type);
-//        }
-//        else{
-//            //4.2 第3步中有数据则在Family表中添加一条记录,并
-//            patentSimpleFamily = this.add(type,temPatentNo);
-//        }
-//
-
-//
+    public static void main(String[] args) {
+
+    }
+
+    public List<String> cleanDate(Integer type) {
+        List<String> patentNos =new ArrayList<>();
+        List<PatentSimpleFamily> patentSimpleFamilies = patentSimpleFamilyLinkService.getBaseMapper().getDirtyData(type);
+      for(PatentSimpleFamily item :patentSimpleFamilies) {
+            LambdaQueryWrapper<PatentSimpleFamily> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(PatentSimpleFamily::getPatentNo, item.getPatentNo())
+                    .eq(PatentSimpleFamily::getType, type);
+            List<PatentSimpleFamily> patentSimpleFamilys = this.list(wrapper);
+            List<Integer> ids = patentSimpleFamilys.stream().map(PatentSimpleFamily::getId).collect(Collectors.toList());
+            PatentSimpleFamily mainFamily = patentSimpleFamilys.get(0);
+            Integer mainId = mainFamily.getId();
+             ids.remove(mainId);
+             this.removeByIds(ids);
+            UpdateWrapper<PatentSimpleFamilyLink> updateWrapper = new UpdateWrapper<>();
+            updateWrapper.in("family_id", ids).set("family_id", mainId);
+            patentSimpleFamilyLinkService.update(null, updateWrapper);
+
+            if (type == 1) {
+                UpdateWrapper<Patent> updateWrapper2 = new UpdateWrapper<>();
+                updateWrapper2.in("simple_family", ids).set("simple_family", mainId);
+                patentService.update(null, updateWrapper2);
+
+            } else if (type == 2) {
+                UpdateWrapper<Patent> updateWrapper2 = new UpdateWrapper<>();
+                updateWrapper2.in("inpadoc_family", ids).set("inpadoc_family", mainId);
+                patentService.update(null, updateWrapper2);
+
+            } else if (type == 3) {
+                UpdateWrapper<Patent> updateWrapper2 = new UpdateWrapper<>();
+                updateWrapper2.in("patsnap_family", ids).set("patsnap_family", mainId);
+                patentService.update(null, updateWrapper2);
+
+            }
+            patentNos.add(mainFamily.getPatentNo());
+
+        }
+return patentNos;
+    }
 
 }

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

@@ -350,7 +350,7 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
         systemDictList.forEach(systemDict -> {
             switch (systemDict.getType()) {
                 case Constants.ENTERPRISE_APPLICATION_SCENARIO:
-                    scenario.put(systemDict.getLabel(), projectList.stream().filter(item -> item.getScenarioList().contains(Integer.parseInt(systemDict.getValue()))).count());
+                    scenario.put(systemDict.getLabel(), projectList.stream().filter(item ->item.getScenarioList()!=null && item.getScenarioList().contains(Integer.parseInt(systemDict.getValue()))).count());
                     break;
                 case Constants.INVESTIGATION_TYPE:
                     type.put(systemDict.getLabel(), projectList.stream().filter(item -> item.getTypeList().contains(Integer.parseInt(systemDict.getValue()))).count());

+ 0 - 1
PAS/src/main/java/cn/cslg/pas/service/ProjectUserService.java

@@ -53,7 +53,6 @@ public class ProjectUserService extends ServiceImpl<ProjectUserMapper, ProjectUs
     public List<Integer> getProIdByUserId(Integer userId) {
         return this.getProjectUserByUserId(userId).stream().map(ProjectUser::getProjectId).collect(Collectors.toList());
     }
-
     public List<Integer> getProjectUserIdByProjectId(Integer projectId) {
         LambdaQueryWrapper<ProjectUser> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(ProjectUser::getProjectId, projectId);

+ 1 - 2
PAS/src/main/java/cn/cslg/pas/service/asso/AssoProductPatentService.java

@@ -120,8 +120,7 @@ public class AssoProductPatentService extends ServiceImpl<AssoProductPatentMappe
             wrapper.eq(AssoProductPatent::getProductId, patentDTO.getProductId());
             wrapper.in(AssoProductPatent::getPatentNo, patentNos);
             this.remove(wrapper);
-            patentNos.removeAll(assoPatents);
-            return patentNos;
+            return assoPatents;
         }
         return patentNos;
     }

+ 3 - 2
PAS/src/main/resources/application-prodNetOut.yml

@@ -1,6 +1,6 @@
 spring:
   redis:
-    host: 47.101.137.223
+    host: 192.168.1.24
     port: 6379
     database: 3
     password: Xx0GWxdWQJxx6Swe
@@ -25,4 +25,5 @@ spring:
         exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"
 springdoc:
   api-docs:
-    enabled: false
+    enabled: false
+authorUrl: http://localhost:8871

+ 1 - 1
PAS/src/main/resources/application.yml

@@ -20,7 +20,7 @@ spring:
       max-file-size: 1000MB
       max-request-size: 1000MB
   profiles:
-    active: dev
+    active: prodNetOut
   jackson:
     default-property-inclusion: non_null
     serialization:

+ 48 - 20
PAS/src/main/resources/mapper/PatentMapper.xml

@@ -417,41 +417,69 @@
                 </foreach>
             </if>
             <if test="params.whereFieldMultiple != null">
-                and (
-                a2.fid in
-                <foreach collection="params.whereFieldMultiple" item="item" separator="," open="(" close=")">
-                    #{item}
+                and(
+                <foreach collection="params.mField" item="item" separator="or" open="(" close=")">
+                    (a2.cid =#{item.key}
+                    and
+                    a2.fid in
+                    <foreach collection="item.value" item="item2" separator="," open="(" close=")">
+                        #{item2}
+                    </foreach>
+                    <if test="params.whereFieldMultipleNull == true">
+                        or a2.id is null
+                    </if>
+                    )
                 </foreach>
-                <if test="params.whereFieldMultipleNull == true">
-                    or a2.id is null
-                </if>
                 )
             </if>
             <if test="params.whereFieldText != null">
-                and (
-                a3.fid in
-                <foreach collection="params.whereFieldText" item="item" separator="," open="(" close=")">
-                    #{item}
+                and(
+                <foreach collection="params.textField" item="item" separator="or" open="(" close=")">
+                    (a3.cid
+                    =#{item.key} and(
+                    a3.fid in
+                    <foreach collection="item.value" item="item2" separator="," open="(" close=")">
+                        #{item2}
+                    </foreach>
+                    <if test="params.whereFieldTextNull == true">
+                        or a3.id is null
+                    </if>
+                        )
+                    )
                 </foreach>
-                <if test="params.whereFieldTextNull == true">
-                    or a2.id is null
-                </if>
                 )
             </if>
             <if test="params.whereTreeType0 != null">
-                and a4.fid in
-                <foreach collection="params.whereTreeType0" item="item" separator="," open="(" close=")">
-                    #{item}
+                and(
+                <foreach collection="params.tree0Field" item="item" separator="or" open="(" close=")">
+                    (a4.cid
+                    =#{item.key} and
+                    a4.fid in
+                    <foreach collection="item.value" item="item2" separator="," open="(" close=")">
+                        #{item2}
+                    </foreach>
+                    )
                 </foreach>
+                )
             </if>
             <if test="params.whereTreeType1 != null">
-                and a1.fid in
-                <foreach collection="params.whereTreeType1" item="item" separator="," open="(" close=")">
-                    #{item}
+                and(
+                <foreach collection="params.tree1Field" item="item" separator="or" open="(" close=")">
+                    (a1.cid
+                    =#{item.key} and
+                    a1.fid in
+                    <foreach collection="item.value" item="item2" separator="," open="(" close=")">
+                        #{item2}
+                    </foreach>
+                    )
                 </foreach>
+                )
             </if>
         </where>
         group by a.id
+        <if test="params.sizeCount >0">
+            having count(*) >#{params.sizeCount}
+        </if>
         order by
         <if test="params.sort.prop == 'id'">a.id</if>
         <if test="params.sort.prop == 'name'">a.name</if>

+ 3 - 1
PAS/src/main/resources/mapper/PatentSimpleFamilyLinkMapper.xml

@@ -6,5 +6,7 @@
         select a.* from os_patent_simplefamily_link a left join os_patent_simplefamily b on a.family_id=b.id where b.type=#{type}
         and a.patent_no in <foreach collection="patentNos" item="id" open="(" separator="," close=")"> #{id}</foreach>
     </select>
-
+    <select id="getDirtyData"  resultType="cn.cslg.pas.domain.PatentSimpleFamily">
+        select *,count(*) as count from os_patent_simplefamily where type =#{type} group by patent_no having  count(*)>1 limit 10000
+    </select>
 </mapper>