Prechádzať zdrojové kódy

自定义字段数量

liRJ 2 rokov pred
rodič
commit
163fd96bcd

+ 3 - 0
.idea/.gitignore

@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml

+ 7 - 4
RMS/src/main/java/cn/cslg/report/common/model/vo/PatentQueryFieldSourceVO.java

@@ -1,14 +1,17 @@
 package cn.cslg.report.common.model.vo;
 
+import cn.cslg.report.common.model.BaseVO;
+import io.swagger.v3.oas.models.security.SecurityScheme;
 import lombok.Data;
 
 @Data
-public class PatentQueryFieldSourceVO {
-    private Integer projectId;
-    private String key;
+public class PatentQueryFieldSourceVO extends BaseVO {
+    private Integer fieldId;
+    private Integer key;
+    private Integer count;
     private String folder;
     private String label;
-    private String type;
+    private Integer type;
     private String startDate;
     private String endDate;
     private PatentVO queryParams;

+ 1 - 5
RMS/src/main/java/cn/cslg/report/controller/CompareFilesController.java

@@ -38,11 +38,7 @@ public class CompareFilesController {
          compareFilesService.getPatentIndexSetting(params);
        return Response.success();
     }
-    @PostMapping("/query/source")
-    @Operation(summary = "查看字段的统计数据")
-    public String getPatentQuerySourcePageList(@RequestBody PatentQueryFieldSourceVO params) {
-        return Response.success(compareFilesService.getPatentQuerySourcePageList(params));
-    }
+
 
 
 

+ 5 - 0
RMS/src/main/java/cn/cslg/report/controller/PatentFiledController.java

@@ -102,4 +102,9 @@ public class PatentFiledController {
     public String setect(Integer reportId)throws IOException{
         return reportFieldService.selectReportField(reportId);
     }
+    @PostMapping("/query/source")
+    @Operation(summary = "查看字段的统计数据")
+    public String getPatentQuerySourcePageList(@RequestBody PatentQueryFieldSourceVO params) {
+        return Response.success(reportFieldService.getPatentQuerySourcePageList(params));
+    }
 }

+ 5 - 0
RMS/src/main/java/cn/cslg/report/mapper/ReportFieldMapper.java

@@ -1,8 +1,12 @@
 package cn.cslg.report.mapper;
 
+import cn.cslg.report.common.model.dto.PatentQueryFieldSourceDTO;
+import cn.cslg.report.common.model.vo.PatentQueryFieldSourceVO;
 import cn.cslg.report.entity.CompareFiles;
 import cn.cslg.report.entity.ReportField;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -13,4 +17,5 @@ public interface ReportFieldMapper extends BaseMapper<ReportField> {
     List<ReportField> find(@Param("reportId") int reportId,@Param("id") int id);
     int deleteReportId(@Param("reportId") int reportId,@Param("id") int id);
     int updateReportId(ReportField reportField);
+    IPage<PatentQueryFieldSourceDTO> getPatentQuerySourcePageList(Page<ReportField> page, @Param("params") PatentQueryFieldSourceVO params, @Param("ids") List<Integer> patentIds);
 }

+ 2 - 89
RMS/src/main/java/cn/cslg/report/service/business/CompareFilesService.java

@@ -223,95 +223,8 @@ public class CompareFilesService extends ServiceImpl<CompareFilesMapper, Compare
     }
 
     public IPage<PatentQueryFieldSourceDTO> getPatentAttributeSourcePageList(PatentQueryFieldSourceVO params) {
-        this.setPatentQuerySourceParams(params);
-        if (params.getKey().equals("40-0")) {
-            Integer projectId = params.getProjectId();
-//            List<PatentQueryFieldSourceDTO> dataList = baseMapper.getCountStatus(projectId);
-            List<PatentQueryFieldSourceDTO> lstA = new ArrayList<>();
-            List<PatentQueryFieldSourceDTO> lstB = new ArrayList<>();
-//            dataList.forEach(item -> {
-//                if (StringUtils.changeStringToString(item.getLabel(), "\\|").size() > 1) {
-//                    lstA.add(item);
-//                } else {
-//                    lstB.add(item);
-//                }
-//            });
-            lstA.forEach(item -> {
-                List<String> stringList = StringUtils.changeStringToString(item.getLabel(), "\\|");
-
-                stringList.forEach(x -> {
-                    List<PatentQueryFieldSourceDTO> lstC = new ArrayList<>();
-                    for (PatentQueryFieldSourceDTO patentQueryFieldSourceDTO : lstB) {
-                        if (!lstB.stream().map(PatentQueryFieldSourceDTO::getLabel).collect(Collectors.toList()).contains(x)) {
-                            PatentQueryFieldSourceDTO a = new PatentQueryFieldSourceDTO();
-                            a.setCount(item.getCount());
-                            a.setLabel(x);
-                            lstC.add(a);
-                            break;
-                        }
-                        if (patentQueryFieldSourceDTO.getLabel().equals(x)) {
-                            patentQueryFieldSourceDTO.setCount(patentQueryFieldSourceDTO.getCount() + item.getCount());
-                        }
-                    }
-                    lstB.addAll(lstC);
-                });
-            });
-            List<SysDictItem> systemDictList = sysDictItemService.getSystemDictListByType(Collections.singletonList(Constants.PATENT_STATUS));
-            lstB.forEach(b -> {
-                Integer status = Integer.parseInt(systemDictList.stream()
-                        .filter(systemDict -> systemDict.getType().equals(Constants.PATENT_STATUS) && systemDict.getLabel().equals(b.getLabel()))
-                        .findFirst()
-                        .orElse(new SystemDict()).getValue());
-                b.setValue(String.valueOf(status));
-            });
-            IPage<PatentQueryFieldSourceDTO> pageList = baseMapper.getPatentQuerySourcePageList(new Page<>(params.getCurrent(), params.getSize()), params, new ArrayList<>());
-            pageList.setRecords(lstB);
-            return pageList;
-        }
-        IPage<PatentQueryFieldSourceDTO> pageList = baseMapper.getPatentQuerySourcePageList(new Page<>(params.getCurrent(), params.getSize()), params, new ArrayList<>());
-        pageList.getRecords().forEach(item -> item.setIds(null));
-        return pageList;
-    }
-    private void setPatentQuerySourceParams(PatentQueryFieldSourceVO params) {
-        List<Integer> field = StringUtils.changeStringToInteger(params.getKey(), "-");
-        Integer type = 0;
-        Integer level = 0;
-        Integer status = 0;
-        switch (params.getKey()) {
-            case "18-6":
-            case "18-7":
-            case "18-8":
-            case "23-6":
-            case "23-7":
-            case "23-8":
-                params.setApplicantType(2);
-                break;
-            case "19-6":
-            case "19-7":
-            case "19-8":
-            case "24-6":
-            case "24-7":
-            case "24-8":
-                params.setApplicantType(1);
-                break;
-            case "29-17":
-            case "30-17":
-            case "29-18":
-            case "29-19":
-            case "29-20":
-            case "30-18":
-            case "30-19":
-            case "30-20":
-                params.setApplicantType(field.get(0) == 29 ? 2 : 1);
-                break;
-            default:
-                params.setCustomFieldId(field.get(0));
-                if (params.getType().equals("6") && field.get(1).equals(0)) {
-                    params.setCustomFieldTreeType(0);
-                } else {
-                    params.setCustomFieldTreeType(null);
-                }
-        }
+
+        return  null;
     }
 
 

+ 171 - 7
RMS/src/main/java/cn/cslg/report/service/business/ReportFieldService.java

@@ -1,14 +1,18 @@
 package cn.cslg.report.service.business;
 
+import cn.cslg.report.common.model.dto.PatentQueryFieldSourceDTO;
 import cn.cslg.report.common.model.vo.PatentField;
+import cn.cslg.report.common.model.vo.PatentQueryFieldSourceVO;
 import cn.cslg.report.common.model.vo.ReportFieldVO;
 import cn.cslg.report.common.utils.DataUtils;
 import cn.cslg.report.common.utils.PatentUtils;
 import cn.cslg.report.common.utils.Response;
 import cn.cslg.report.common.utils.SecurityUtils.LoginUtils;
+
 import cn.cslg.report.entity.*;
 import cn.cslg.report.mapper.ReportFieldMapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
@@ -205,14 +209,174 @@ public class ReportFieldService extends ServiceImpl<ReportFieldMapper, ReportFie
 
     }
 
-    /**
-     * 统计(自定义字段的id和报告id)查询哪些专利号与之对应
-     * 返回相关的专利的数量
-     */
+    public List<PatentQueryFieldSourceVO> getPatentQuerySourcePageList(PatentQueryFieldSourceVO params) {
+        List<PatentQueryFieldSourceVO> list =new ArrayList<>();
+        //根据fieldId 从patent_field中获得 自定义字段对象
+        LambdaQueryWrapper<ReportField> wrapper =new LambdaQueryWrapper<>();
+        wrapper.eq(ReportField::getId,params.getFieldId());
+        ReportField reportField =this.list(wrapper).get(0);
+        //根据自定义字段的类型,从三张值表中查询该自定义字段所有值的id
+        Integer type1 =reportField.getType();
+        switch (type1){
+            //数字
+            case 0:
+                //日期
+            case 1:
+                //文本
+            case 2:
+                LambdaQueryWrapper<ReportFieldText> queryWrapper =new LambdaQueryWrapper<>();
+                queryWrapper.eq(ReportFieldText::getFieldId,params.getFieldId());
+                List<ReportFieldText> reportFieldTexts =reportFieldTextService.list(queryWrapper);
+               reportFieldTexts.forEach(item->{
+                   PatentQueryFieldSourceVO patentQueryFieldSourceVO=new PatentQueryFieldSourceVO();
+                   patentQueryFieldSourceVO.setFieldId(params.getFieldId());
+                   patentQueryFieldSourceVO.setKey(item.getId());
+                   patentQueryFieldSourceVO.setLabel(item.getText());
+                   list.add(patentQueryFieldSourceVO);
+               });
+                break;
+
+                //单选
+            case 4:
+
+                //多选
+            case 5:
+                LambdaQueryWrapper<ReportFieldOption> queryWrapper5 =new LambdaQueryWrapper<>();
+                queryWrapper5.eq(ReportFieldOption::getFieldId,params.getFieldId());
+                List<ReportFieldOption> reportFieldOption =reportFieldOptionService.list(queryWrapper5);
+                reportFieldOption.forEach(item->{
+                    PatentQueryFieldSourceVO patentQueryFieldSourceVO=new PatentQueryFieldSourceVO();
+                    patentQueryFieldSourceVO.setFieldId(params.getFieldId());
+                    patentQueryFieldSourceVO.setKey(item.getId());
+                    patentQueryFieldSourceVO.setLabel(item.getName());
+                    list.add(patentQueryFieldSourceVO);
+                });
+                break;
+
+                //树
+            case 6:
+                LambdaQueryWrapper<ReportFieldTree> queryWrapper6 =new LambdaQueryWrapper<>();
+                queryWrapper6.eq(ReportFieldTree::getFieldId,params.getFieldId());
+                List<ReportFieldTree> reportFieldTrees =reportFieldTreeService.list(queryWrapper6);
+                reportFieldTrees.forEach(item->{
+                    PatentQueryFieldSourceVO patentQueryFieldSourceVO=new PatentQueryFieldSourceVO();
+                    patentQueryFieldSourceVO.setFieldId(params.getFieldId());
+                    patentQueryFieldSourceVO.setKey(item.getId());
+                    patentQueryFieldSourceVO.setLabel(item.getName());
+                    list.add(patentQueryFieldSourceVO);
+                });
+                break;
+        }
+        List<Integer> valueIds =list.stream().map(PatentQueryFieldSourceVO::getKey).collect(Collectors.toList());
+        LambdaQueryWrapper<ReportFieldPatentLink> lambdaQueryWrapper =new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(ReportFieldPatentLink::getFieldId,params.getFieldId())
+                .in(ReportFieldPatentLink::getOptionId,valueIds);
+        List<ReportFieldPatentLink> reportFieldPatentLinks =reportFieldPatentLinkService.list(lambdaQueryWrapper);
+        list.forEach(tem->{
+         List<ReportFieldPatentLink> part =reportFieldPatentLinks.stream().filter(tm->tm.getFieldId().equals(params.getFieldId())&&tm.getOptionId().equals(tem.getKey()
+            )).collect(Collectors.toList());
+         tem.setCount(part.size());
+         tem.setType(type1);
+        });
+        //根据值id从ReportFieldPatentLink表中获得信息
+        return list;
+
+    }
+
+//    public IPage<PatentQueryFieldSourceDTO> getPatentAttributeSourcePageList(PatentQueryFieldSourceVO params) {
+//        this.setPatentQuerySourceParams(params);
+//        if (params.getKey().equals("40-0")) {
+//            Integer projectId = params.getProjectId();
+//            List<PatentQueryFieldSourceDTO> dataList = baseMapper.getCountStatus(projectId);
+//            List<PatentQueryFieldSourceDTO> lstA = new ArrayList<>();
+//            List<PatentQueryFieldSourceDTO> lstB = new ArrayList<>();
+//            dataList.forEach(item -> {
+//                if (StringUtils.changeStringToString(item.getLabel(), "\\|").size() > 1) {
+//                    lstA.add(item);
+//                } else {
+//                    lstB.add(item);
+//                }
+//            });
+//            lstA.forEach(item -> {
+//                List<String> stringList = StringUtils.changeStringToString(item.getLabel(), "\\|");
+//
+//                stringList.forEach(x -> {
+//                    List<PatentQueryFieldSourceDTO> lstC = new ArrayList<>();
+//                    for (PatentQueryFieldSourceDTO patentQueryFieldSourceDTO : lstB) {
+//                        if (!lstB.stream().map(PatentQueryFieldSourceDTO::getLabel).collect(Collectors.toList()).contains(x)) {
+//                            PatentQueryFieldSourceDTO a = new PatentQueryFieldSourceDTO();
+//                            a.setCount(item.getCount());
+//                            a.setLabel(x);
+//                            lstC.add(a);
+//                            break;
+//                        }
+//                        if (patentQueryFieldSourceDTO.getLabel().equals(x)) {
+//                            patentQueryFieldSourceDTO.setCount(patentQueryFieldSourceDTO.getCount() + item.getCount());
+//                        }
+//                    }
+//                    lstB.addAll(lstC);
+//                });
+//            });
+//            List<SystemDict> systemDictList = systemDictService.getSystemDictListByType(Collections.singletonList(Constants.PATENT_STATUS));
+//            lstB.forEach(b -> {
+//                Integer status = Integer.parseInt(systemDictList.stream()
+//                        .filter(systemDict -> systemDict.getType().equals(Constants.PATENT_STATUS) && systemDict.getLabel().equals(b.getLabel()))
+//                        .findFirst()
+//                        .orElse(new SystemDict()).getValue());
+//                b.setValue(String.valueOf(status));
+//            });
+//            IPage<PatentQueryFieldSourceDTO> pageList = baseMapper.getPatentQuerySourcePageList(new Page<>(params.getCurrent(), params.getSize()), params, new ArrayList<>());
+//            pageList.setRecords(lstB);
+//            return pageList;
+//        }
+//        IPage<PatentQueryFieldSourceDTO> pageList = baseMapper.getPatentQuerySourcePageList(new Page<>(params.getCurrent(), params.getSize()), params, new ArrayList<>());
+//        pageList.getRecords().forEach(item -> item.setIds(null));
+//        return pageList;
+//    }
+
+//    private void setPatentQuerySourceParams(PatentQueryFieldSourceVO params) {
+//        List<Integer> field = StringUtils.changeStringToInteger(params.getKey(), "-");
+//        Integer type = 0;
+//        Integer level = 0;
+//        Integer status = 0;
+//        switch (params.getKey()) {
+//            case "18-6":
+//            case "18-7":
+//            case "18-8":
+//            case "23-6":
+//            case "23-7":
+//            case "23-8":
+//                params.setApplicantType(2);
+//                break;
+//            case "19-6":
+//            case "19-7":
+//            case "19-8":
+//            case "24-6":
+//            case "24-7":
+//            case "24-8":
+//                params.setApplicantType(1);
+//                break;
+//            case "29-17":
+//            case "30-17":
+//            case "29-18":
+//            case "29-19":
+//            case "29-20":
+//            case "30-18":
+//            case "30-19":
+//            case "30-20":
+//                params.setApplicantType(field.get(0) == 29 ? 2 : 1);
+//                break;
+//            default:
+//                params.setCustomFieldId(field.get(0));
+//                if (params.getType().equals("6") && field.get(1).equals(0)) {
+//                    params.setCustomFieldTreeType(0);
+//                } else {
+//                    params.setCustomFieldTreeType(null);
+//                }
+//        }
+//    }
+
 
-    /**
-     *
-     */
 
     }
 

+ 3 - 0
RMS/src/main/java/cn/cslg/report/service/business/ReportFileService.java

@@ -1,6 +1,8 @@
 package cn.cslg.report.service.business;
 
+import cn.cslg.report.common.model.dto.PatentQueryFieldSourceDTO;
 import cn.cslg.report.common.model.dto.UploadFileDTO;
+import cn.cslg.report.common.model.vo.PatentQueryFieldSourceVO;
 import cn.cslg.report.common.utils.DateUtils;
 import cn.cslg.report.common.utils.FileUtils;
 import cn.cslg.report.common.utils.Response;
@@ -9,6 +11,7 @@ import cn.cslg.report.entity.ReportFiles;
 import cn.cslg.report.mapper.ReportFileMapper;
 import cn.hutool.core.io.FileUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;

+ 0 - 1
RMS/src/main/java/cn/cslg/report/service/business/SysDictItemService.java

@@ -21,7 +21,6 @@ public class SysDictItemService extends ServiceImpl<SystemDictItemMapper, SysDic
             return new ArrayList<>();
         }
         LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.in(SysDictItem::, type);
         return this.list(queryWrapper);
     }
 

+ 85 - 0
RMS/src/main/resources/mapper/ReportFieldMapper.xml

@@ -1,6 +1,46 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="cn.cslg.report.mapper.ReportFieldMapper">
+    <sql id="Patent_Query_Source_Base_Select">
+        select ifnull(${label}, '未选择') as label, count(${count}) as `count`, ifnull(${value}, 'null') as `value`,
+        group_concat(distinct a.id) as ids
+        from os_patent a
+        <if test="params.folder != null and params.folder != ''">
+            left join os_portfolio_link b on b.pid = a.id
+        </if>
+        <if test="params.folder == null or params.folder == ''">
+            left join os_thematic_pid b on b.pid = a.id
+        </if>
+    </sql>
+    <sql id="Patent_Query_Source_Base_Where">
+        <where>
+            <if test="params.projectId != null">
+                and b.zid = #{params.projectId}
+            </if>
+            <if test="params.folder != '' and params.folder != null">
+                and b.fid = #{params.folder}
+            </if>
+            <if test="params.label != '' and params.label != null">
+                and ${label} like concat('%', #{params.label}, '%')
+            </if>
+            <if test="ids != null and ids.size() != 0">
+                and b.pid in
+                <foreach collection="ids" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+    </sql>
+    <sql id="Patent_Query_Source_Base_Group">
+        group by
+        ${groupBy}
+        order
+        by
+        `${orderBy}`
+        desc,
+        `value`
+        asc
+    </sql>
     <select id="find" resultType="cn.cslg.report.entity.ReportField">
      select * from OS_PATENT_FIELD where REPORT_ID=#{reportId} and ID=#{id}
     </select>
@@ -12,5 +52,50 @@
                                 CID=#{createBy},CREATE_TIME=#{createTime},REPORT_TYPE=#{reportType} where REPORT_ID=#{reportId} and ID=#{id}
 
     </update>
+    <select id="getPatentQuerySourcePageList" parameterType="cn.cslg.report.common.model.vo.PatentQueryFieldSourceVO"
+            resultType="cn.cslg.report.common.model.dto.PatentQueryFieldSourceDTO">
 
+        <if test="params.type != 'query'">
+            select temp.* from ((
+            <include refid="Patent_Query_Source_Base_Select">
+                <property name="label" value="null"/>
+                <property name="count" value="a.id"/>
+                <property name="value" value="null"/>
+            </include>
+            <include refid="Patent_Query_Source_Base_Where">
+                <property name="label" value="null"/>
+            </include>
+            and a.id not in (select pid from os_patent_field_patent_link where cid = #{params.customFieldId})
+            ) union all (
+            <include refid="Patent_Query_Source_Base_Select">
+                <property name="label" value="d.name"/>
+                <property name="count" value="distinct e.pid"/>
+                <property name="value" value="d.id"/>
+            </include>
+            left join os_patent_field_patent_link e on e.pid = b.pid
+            left join os_patent_field c1 on c1.id = e.cid
+            <if test="params.type == 6">
+                left join os_patent_field_tree d on d.cid = e.cid
+            </if>
+            <if test="params.type == 0 or params.type == 1 or params.type == 2">
+                left join os_patent_field_text d on d.cid = e.cid and d.name is not null and d.name != ''
+            </if>
+            <if test="params.type == 3 or params.type == 4 or params.type == 5">
+                left join os_patent_field_multiple d on d.cid = e.cid
+            </if>
+            <include refid="Patent_Query_Source_Base_Where">
+                <property name="label" value="d.name"/>
+            </include>
+            and c1.id = #{params.customFieldId}
+            <if test="params.customFieldTreeType == 0">
+                and e.fid in (select id from os_patent_field_tree where cid = c1.id and find_in_set(d.id , replace(path
+                , '/', ',')))
+            </if>
+            <if test="params.customFieldTreeType == null">
+                and e.fid = d.id
+            </if>
+            group by d.id
+            )) as temp where 1 = 1 order by `count` desc, `value` asc
+        </if>
+    </select>
 </mapper>

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 10090
logs/rms/rms-debug.2022-11-25.0.log


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 9944
logs/rms/rms-debug.2022-11-25.1.log


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 680
logs/rms/rms-info.2022-11-25.0.log