Browse Source

1.新增ees

guanzi 3 years ago
parent
commit
2396f76ece

+ 5 - 1
saas-backen/src/main/java/com/pavis/app/saasbacken/controller/DataEntryController.java

@@ -4,10 +4,12 @@ import com.alibaba.fastjson.JSON;
 import com.pavis.app.saasbacken.aop.PreSaveLog;
 import com.pavis.app.saasbacken.exception.GlobalExceptionHandler;
 import com.pavis.app.saasbacken.http.ResultBody;
+import com.pavis.app.saasbacken.service.EnterpriseBasicInfoService;
 import com.pavis.app.saasbacken.utils.HttpContextUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -32,6 +34,8 @@ public class DataEntryController {
      * 一键导入。
      */
 
+    @Autowired
+    private EnterpriseBasicInfoService enterpriseBasicInfoService;
 
     // 使用object接收。
     @PreSaveLog("企业基本信息录入")
@@ -42,7 +46,7 @@ public class DataEntryController {
         String uri = request.getRequestURI();
         try {
             log.info("orgAdd:{}", JSON.toJSONString(basicInfo));
-            return ResultBody.ok().path(uri).data(null);
+            return ResultBody.ok().path(uri).data(enterpriseBasicInfoService.orgBasicAdd(basicInfo));
         } catch (Exception e) {
             return GlobalExceptionHandler.resolveException(e, uri);
         }

+ 51 - 0
saas-backen/src/main/java/com/pavis/app/saasbacken/dao/ResourceLibraryEntityMapper.java

@@ -0,0 +1,51 @@
+package com.pavis.app.saasbacken.dao;
+
+import com.pavis.app.saasbacken.entity.ResourceLibraryEntity;
+import org.springframework.data.elasticsearch.annotations.Query;
+import org.springframework.data.elasticsearch.core.SearchHits;
+import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
+import org.springframework.data.repository.query.Param;
+import org.springframework.stereotype.Repository;
+
+import java.awt.print.Pageable;
+import java.util.List;
+import java.util.Map;
+
+@Repository
+// public interface ResourceLibraryEntityMapper extends ElasticsearchRepository<ResourceLibraryEntity, String> {
+public interface ResourceLibraryEntityMapper extends ElasticsearchRepository<ResourceLibraryEntity, String> {
+
+    List<ResourceLibraryEntity> findByName(String name);
+
+    List<ResourceLibraryEntity> findByRegisterAddress(String address);
+
+    @Query("{ \"bool\" : { \"must\" : { \"term\" : { \"softwareCopyrightCount\" : 2 } } } }")
+    List<ResourceLibraryEntity> findByFlag();
+
+    // List<ResourceLibraryEntity> findByAnnualRevenue();
+
+    @Query("{\"bool\": {\"must\": [{\"nested\": {\"path\": \"annualRevenue\",\"query\": {\"bool\": {\n" +
+            "                \"must\": [{\"match\": {\"annualRevenue.year\": \"2019\"}}],\n" +
+            "                \"filter\":{\"script\":{\"script\":{\"source\":\"73 <= doc['annualRevenue.val'].value && doc['annualRevenue.val'].value < 75\"}}}}}}}]}}")
+    SearchHits sel(Map<String, Object> param);
+
+    @Query("{\"bool\": {\"must\": [{\"nested\": {\"path\": \"annualRevenue\",\"query\": {\"bool\": {\n" +
+            "                \"must\": [{\"match\": {\"annualRevenue.year\": \"?0\"}}],\n" +
+            "                \"filter\":{\"script\":{\"script\":{\"source\":\"73 <= doc['annualRevenue.val'].value && doc['annualRevenue.val'].value < 75\"}}}}}}}]}}")
+    SearchHits sels(String year);
+
+    @Query("{\"bool\": {\"must\": [{\"nested\": {\"path\": \"annualRevenue\",\"query\": {\"bool\": {\n" +
+            "                \"must\": [{\"match\": {\"annualRevenue.year\": \"{param}.year\"}}],\n" +
+            "                \"filter\":{\"script\":{\"script\":{\"source\":\"73 <= doc['annualRevenue.val'].value && doc['annualRevenue.val'].value < 75\"}}}}}}}]}}")
+    SearchHits selss(@Param("param") Map<String, String> param);
+
+    @Query("{\"bool\": {\"must\": [{\"nested\": {\"path\": \"annualRevenue\",\"query\": {\"bool\": {\"must\": \n" +
+            "[{\"match\": {\"annualRevenue.year\": \"2019\"}},\n" +
+            "{\"range\":{\"annualRevenue.val\":{\"gte\":23,\"lte\":120}}}\n" +
+            "]}}}}]}}")
+    SearchHits selsss(@Param("param") Map<String, String> param);
+
+    @Query("{\"match\": {\"name\": {\"query\": \"?0\"}}}")
+    // Page<Book> findByName(String name, Pageable pageable);
+    SearchHits findByName(String name, Pageable pageable);
+}

+ 10 - 0
saas-backen/src/main/java/com/pavis/app/saasbacken/dao/ResourceLibraryMapper.java

@@ -0,0 +1,10 @@
+package com.pavis.app.saasbacken.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.pavis.app.saasbacken.entity.ResourceLibrary;
+import org.springframework.stereotype.Component;
+
+@Component
+public interface ResourceLibraryMapper extends BaseMapper<ResourceLibrary> {
+
+}

+ 88 - 0
saas-backen/src/main/java/com/pavis/app/saasbacken/entity/ResourceLibrary.java

@@ -0,0 +1,88 @@
+package com.pavis.app.saasbacken.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.*;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @program: saas-test
+ * @description: 企业库对应es信息
+ * @author: Guanzi
+ * @created: 2021/10/18 11:30
+ */
+@Getter
+@Setter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class ResourceLibrary implements Serializable {
+
+    @TableId(type = IdType.ID_WORKER_STR)
+    private String id;
+    // 企业名称【(全名[可针对企业名称做dic词典]、关键词)、人才名称、专利名称、需求成功名称、产品名称、需求名称】
+
+    private String name;
+    // 区域,逗号分词。
+    private String district;
+    // 企业地址,不可拆分,todo 可不存储。
+    private String registerAddress;
+    // 对应各表的主键id。
+    private String uniqueId;
+    // 各资源库类型。6 企业库 等等。
+    private String resType;
+    // 成立日期。
+    private String setupDate;
+    // 所属行业(包含八大领域)。
+    private String industry;
+    // 国高领域。
+    private String highfield;
+    // 研发、飞地等类型,是否是国高 【逗号分隔】。
+    private String othertype;
+    // 国高认定年份。
+    private String highIdentifiedYear;
+    // 省级重点企业研究院认定年份。
+    private String keyProvincialIdentifiedYear;
+    // 省级企业研究院认定年份。
+    private String provincialIdentifiedYear;
+    // 浙江省高新技术研究开发中心认定年份。
+    private String highTechIdentifiedYear;
+    // 省科小认定年份。
+    private String provincialTechSmallIdentifiedYear;
+    // 雏鹰计划认定年份。
+    private String youngEaglesIdentifiedYear;
+    // 市级研发中心认定年份。
+    private String municipalResearchCenterIdentifiedYear;
+
+
+    // 飞地研发中心专职人员数
+    private Integer enclaveFulltimeStaffCount;
+    // 发明专利数量
+    private Integer patentCount;
+    // 软件著作权数量
+    private Integer softwareCopyrightCount;
+    // 实用新型数量
+    private Integer utilityLicensesCount;
+    // 成立年限
+    private Integer establishYear;
+    // 飞地研发中心面积
+    private Double areaOfEnclave;
+    // 访问量
+    private Integer pageViews;
+    // 产值规模
+    private Integer productionScale;
+    // 年度营收
+    private String annualRevenue;
+    // 允许扣除的研发费用
+    private String rdDeductible;
+    // 创建时间
+    @TableField(value = "create_time",fill = FieldFill.INSERT)
+    private Date createTime;
+    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
+    private Date updateTime;
+
+}

+ 115 - 0
saas-backen/src/main/java/com/pavis/app/saasbacken/entity/ResourceLibraryEntity.java

@@ -0,0 +1,115 @@
+package com.pavis.app.saasbacken.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.pavis.app.saasbacken.form.TaxParam;
+import lombok.*;
+import org.springframework.data.elasticsearch.annotations.Document;
+import org.springframework.data.elasticsearch.annotations.Field;
+import org.springframework.data.elasticsearch.annotations.FieldType;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @program: saas-test
+ * @description: 企业库对应es信息
+ * @author: Guanzi
+ * @created: 2021/10/18 11:30
+ */
+@Getter
+@Setter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+@Data
+// @Document(indexName = "saas_test")
+@Document(indexName = "push-test")
+public class ResourceLibraryEntity implements Serializable {
+
+    @TableId(type = IdType.ID_WORKER_STR)
+    private String id;
+    // 企业名称【(全名[可针对企业名称做dic词典]、关键词)、人才名称、专利名称、需求成功名称、产品名称、需求名称】
+    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_max_word")
+    private String name;
+    @Field(type = FieldType.Text,analyzer = "douhao",searchAnalyzer = "douhao")
+    private String district;
+    // 企业地址,不可拆分,todo 可不存储。
+    @Field(type = FieldType.Text,analyzer = "douhao",searchAnalyzer = "douhao")
+    private String registerAddress;
+    // 对应各表的主键id。
+    @Field(type = FieldType.Keyword)
+    private String uniqueId;
+    // 各资源库类型。6 企业库 等等。
+    @Field(type = FieldType.Keyword)
+    private String flag;
+    // 成立日期。
+    @Field(type = FieldType.Date)
+    private Date setupDate;
+    // 所属行业(包含八大领域)。
+    @Field(type = FieldType.Text,analyzer = "douhao",searchAnalyzer = "douhao")
+    private String industry;
+    // 国高领域。
+    @Field(type = FieldType.Text,analyzer = "douhao",searchAnalyzer = "douhao")
+    private String highfield;
+    // 研发、飞地等类型,是否是国高 【逗号分隔】。
+    @Field(type = FieldType.Text,analyzer = "douhao",searchAnalyzer = "douhao")
+    private String othertype;
+    // 创建时间。
+    @Field(type = FieldType.Date)
+    // private Date createTime;
+    private Date createTime;
+    // 国高认定年份。
+    @Field(type = FieldType.Keyword)
+    private String highIdentifiedYear;
+    // 省级重点企业研究院认定年份。
+    @Field(type = FieldType.Keyword)
+    private String keyProvincialIdentifiedYear;
+    // 省级企业研究院认定年份。
+    @Field(type = FieldType.Keyword)
+    private String provincialIdentifiedYear;
+    // 浙江省高新技术研究开发中心认定年份。
+    @Field(type = FieldType.Keyword)
+    private String highTechIdentifiedYear;
+    // 省科小认定年份。
+    @Field(type = FieldType.Keyword)
+    private String provincialTechSmallIdentifiedYear;
+    // 雏鹰计划认定年份。
+    @Field(type = FieldType.Keyword)
+    private String youngEaglesIdentifiedYear;
+    // 市级研发中心认定年份。
+    @Field(type = FieldType.Keyword)
+    private String municipalResearchCenterIdentifiedYear;
+
+    // 飞地研发中心专职人员数
+    @Field(type = FieldType.Integer)
+    private Integer enclaveFulltimeStaffCount;
+    // 发明专利数量
+    @Field(type = FieldType.Integer)
+    private Integer patentCount;
+    // 软件著作权数量
+    @Field(type = FieldType.Integer)
+    private Integer softwareCopyrightCount;
+    // 实用新型数量
+    @Field(type = FieldType.Integer)
+    private Integer utilityLicensesCount;
+    // 成立年限
+    @Field(type = FieldType.Integer)
+    private Integer establishYear;
+    // 飞地研发中心面积
+    @Field(type = FieldType.Double)
+    private Double areaOfEnclave;
+    // 访问量
+    @Field(type = FieldType.Integer)
+    private Integer pageViews;
+    // 产值规模
+    @Field(type = FieldType.Integer)
+    private Integer productionScale;
+    // 年度营收
+    @Field(type = FieldType.Nested)
+    private List<TaxParam> annualRevenue;
+    // 允许扣除的研发费用
+    @Field(type = FieldType.Nested)
+    private List<TaxParam> rdDeductible;
+}

+ 28 - 0
saas-backen/src/main/java/com/pavis/app/saasbacken/form/TaxParam.java

@@ -0,0 +1,28 @@
+package com.pavis.app.saasbacken.form;
+
+import lombok.*;
+import org.springframework.data.elasticsearch.annotations.Field;
+import org.springframework.data.elasticsearch.annotations.FieldType;
+
+/**
+ * @program: saas-test
+ * @description: 企业库对应es信息
+ * @author: Guanzi
+ * @created: 2021/10/18 11:30
+ */
+@Getter
+@Setter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+@Data
+public class TaxParam {
+
+    @Field(type = FieldType.Keyword)
+    private String year;
+    // 区域,逗号分词。
+    @Field(type = FieldType.Integer)
+    private Integer val;
+
+
+}

+ 10 - 0
saas-backen/src/main/java/com/pavis/app/saasbacken/service/EsService.java

@@ -1,9 +1,19 @@
 package com.pavis.app.saasbacken.service;
 
+import com.pavis.app.saasbacken.entity.EnterpriseBasicInfo;
 import org.elasticsearch.action.search.SearchResponse;
 
 import java.io.IOException;
+import java.util.List;
 
 public interface EsService {
+
     SearchResponse findByAannualRevenue() throws IOException;
+
+    /**
+     * 根据企业名称,全文检索企业信息.
+     * @param name
+     * @return
+     */
+    List<EnterpriseBasicInfo> selEsByName(String name);
 }

+ 9 - 4
saas-backen/src/main/java/com/pavis/app/saasbacken/service/impl/base/EnterpriseBasicInfoServiceImpl.java

@@ -1,13 +1,15 @@
 package com.pavis.app.saasbacken.service.impl.base;
 
 import com.alibaba.fastjson.JSONObject;
-import com.pavis.app.saasbacken.entity.EnterpriseBasicInfo;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.pavis.app.saasbacken.dao.EnterpriseBasicInfoMapper;
+import com.pavis.app.saasbacken.entity.EnterpriseBasicInfo;
 import com.pavis.app.saasbacken.service.EnterpriseBasicInfoService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.pavis.app.saasbacken.service.EsService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -22,6 +24,9 @@ import java.util.List;
 @Service
 public class EnterpriseBasicInfoServiceImpl extends ServiceImpl<EnterpriseBasicInfoMapper, EnterpriseBasicInfo> implements EnterpriseBasicInfoService {
 
+    @Resource
+    private EsService esService;
+
     @Override
     public List<EnterpriseBasicInfo> orgBasicAdd(List<Object> basicInfo) {
         List<EnterpriseBasicInfo> basicInfos = JSONObject.parseArray(JSONObject.toJSONString(basicInfo), EnterpriseBasicInfo.class);
@@ -32,9 +37,9 @@ public class EnterpriseBasicInfoServiceImpl extends ServiceImpl<EnterpriseBasicI
             addBasicInfo = new EnterpriseBasicInfo();
             BeanUtils.copyProperties(info,addBasicInfo);
             // 行业领域也由节点管理员进行配置,。
-
+            addedBasicInfos.add(addBasicInfo);
         }
 
-        return null;
+        return esService.selEsByName(addedBasicInfos.get(0).getName());
     }
 }

+ 27 - 0
saas-backen/src/main/java/com/pavis/app/saasbacken/service/impl/other/EsServiceImpl.java

@@ -1,5 +1,9 @@
 package com.pavis.app.saasbacken.service.impl.other;
 
+import com.alibaba.fastjson.JSON;
+import com.pavis.app.saasbacken.dao.ResourceLibraryEntityMapper;
+import com.pavis.app.saasbacken.entity.EnterpriseBasicInfo;
+import com.pavis.app.saasbacken.entity.ResourceLibraryEntity;
 import com.pavis.app.saasbacken.service.EsService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.lucene.search.join.ScoreMode;
@@ -12,11 +16,14 @@ import org.elasticsearch.index.query.BoolQueryBuilder;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.search.builder.SearchSourceBuilder;
 import org.elasticsearch.search.sort.SortOrder;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @program:
@@ -35,6 +42,9 @@ public class EsServiceImpl implements EsService {
     @Qualifier("restHighLevelClient")
     private RestHighLevelClient client;
 
+    @Autowired
+    private ResourceLibraryEntityMapper resourceLibraryEntityMapper;
+
     @Override
     public SearchResponse findByAannualRevenue() throws IOException {
 
@@ -96,4 +106,21 @@ public class EsServiceImpl implements EsService {
 
         return searchResp;
     }
+
+    @Override
+    public List<EnterpriseBasicInfo> selEsByName(String name) {
+        List<ResourceLibraryEntity> byNames = resourceLibraryEntityMapper.findByName(name);
+        Iterable<ResourceLibraryEntity> all = resourceLibraryEntityMapper.findAll();
+        System.err.println(JSON.toJSONString(all));
+
+        EnterpriseBasicInfo enterpriseBasicInfo;
+        List<EnterpriseBasicInfo> enterpriseBasicInfos = new ArrayList<>();
+        for (ResourceLibraryEntity byName : byNames) {
+            System.err.println("***" + byName.getName());
+            enterpriseBasicInfo = new EnterpriseBasicInfo();
+            BeanUtils.copyProperties(byName,enterpriseBasicInfo);
+            enterpriseBasicInfos.add(enterpriseBasicInfo);
+        }
+        return enterpriseBasicInfos;
+    }
 }