فهرست منبع

4/10 导入专利

lwhhszx 1 سال پیش
والد
کامیت
bb2c57633d

+ 1 - 0
src/main/java/com/example/xiaoshiweixinback/business/common/base/RedisConf.java

@@ -26,4 +26,5 @@ public class RedisConf {
     public final static String PROJECT = "project";
     public final static String PRODUCT = "product";
     public final static String EVIDENCE_REASON = "evidence_reason";
+    public final static String PERSON_FUNCTION = "person_function";
 }

+ 14 - 0
src/main/java/com/example/xiaoshiweixinback/business/config/ElasticSearchClientConfig.java

@@ -63,5 +63,19 @@ public class ElasticSearchClientConfig {
 //            ElasticsearchTransport transport = new RestClientTransport(client,new JacksonJsonpMapper());
 //            return new ElasticsearchClient(transport);
 //        }
+
+//        @Bean
+//        public ElasticsearchClient elasticsearchClient() throws Exception {
+//            RestClientBuilder builder = RestClient.builder(new HttpHost("es-cn-em93o8856000ho9e7.elasticsearch.aliyuncs.com", 9200, "http"));
+//            CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+//            credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "Xiaoshi221101"));
+//            SSLContext sslContext = SSLContextBuilder.create()
+//                    .loadTrustMaterial(new TrustSelfSignedStrategy())
+//                    .build();
+//            builder.setHttpClientConfigCallback(f -> f.setDefaultCredentialsProvider(credentialsProvider).setSSLContext(sslContext).setSSLHostnameVerifier(new NoopHostnameVerifier()));
+//            RestClient client =builder.build();
+//            ElasticsearchTransport transport = new RestClientTransport(client,new JacksonJsonpMapper());
+//            return new ElasticsearchClient(transport);
+//        }
     }
 }

+ 21 - 0
src/main/java/com/example/xiaoshiweixinback/business/redis/RedisService.java

@@ -455,6 +455,7 @@ public class RedisService {
 
     /**
      * 设置key值在下一天零点过期
+     *
      * @param key
      */
     public void removeKeyBySecond(String key) {
@@ -463,6 +464,26 @@ public class RedisService {
             this.delete(key);
         }
     }
+
+    /**
+     * 将值 value 关联到 key ,并将 key 的过期时间设为 timeout
+     *
+     * @param key
+     * @param value
+     * @param timeout 过期时间
+     * @param unit    时间单位, 天:TimeUnit.DAYS 小时:TimeUnit.HOURS 分钟:TimeUnit.MINUTES
+     *                秒:TimeUnit.SECONDS 毫秒:TimeUnit.MILLISECONDS
+     */
+    public void setEx(String key, Object value, long timeout, TimeUnit unit) {
+        redisTemplate.opsForValue().set(key, value, timeout, unit);
+    }
+
+    /**
+     * 获取指定 key 的值
+     *
+     * @param key
+     * @return
+     */
 }
 
 

+ 2 - 0
src/main/java/com/example/xiaoshiweixinback/domain/AssoPersonFunction.java

@@ -45,5 +45,7 @@ public class AssoPersonFunction extends BaseEntity<AssoPersonFunction> {
      * 
      */
     private String functionParameter;
+    private String vipUuid;
+    private Integer vipType;
 
 }

+ 38 - 0
src/main/java/com/example/xiaoshiweixinback/service/AssoPersonFunctionService.java

@@ -1,11 +1,19 @@
 package com.example.xiaoshiweixinback.service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.xiaoshiweixinback.business.common.base.RedisConf;
+import com.example.xiaoshiweixinback.business.redis.RedisService;
 import com.example.xiaoshiweixinback.domain.AssoPersonFunction;
 
+import com.example.xiaoshiweixinback.domain.AssoPersonVip;
+import com.example.xiaoshiweixinback.domain.AssoVipFunction;
+import com.example.xiaoshiweixinback.domain.Vip;
 import com.example.xiaoshiweixinback.mapper.AssoPersonFunctionMapper;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
 * @author admin
 * @description 针对表【asso_person_function(人员功能关联表)】的数据库操作Service实现
@@ -13,7 +21,37 @@ import org.springframework.stereotype.Service;
 */
 @Service
 public class AssoPersonFunctionService extends ServiceImpl<AssoPersonFunctionMapper, AssoPersonFunction> {
+@Autowired
+private RedisService redisService;
+@Autowired
+private VipService vipService;
+@Autowired
+private AssoVipFunctionService assoVipFunctionService;
+    public void get(String functionUuid){
+        String personUuid ="";
+        String redisKey =RedisConf.PERSON_FUNCTION+RedisConf.SYMBOL_COLON+personUuid+RedisConf.SYMBOL_COLON+functionUuid;
+      Object o =redisService.get(redisKey);
+      if(o==null){
+          AssoPersonFunction assoPersonFunction = vipService.getAssoPersonFunction(functionUuid);
+          if(assoPersonFunction==null){
+          Vip vip =vipService.getDefaultVip();
+              AssoVipFunction assoVipFunction =   assoVipFunctionService.getByVipUuidAndFunId(vip.getVipUuid(),personUuid);
+         if(assoVipFunction!=null){}
+
+          }
+      }
+
+    }
+
+
+
+
+    public  void addDefault() {
+        //获得
+        Vip vip = vipService.getDefaultVip();
+        List<AssoVipFunction> assoVipFunctions = assoVipFunctionService.getVipFunctionByVipUuid(vip.getVipUuid());
 
+    }
 }
 
 

+ 14 - 0
src/main/java/com/example/xiaoshiweixinback/service/AssoVipFunctionService.java

@@ -36,6 +36,20 @@ public class AssoVipFunctionService extends ServiceImpl<AssoVipFunctionMapper, A
 
     }
 
+    public AssoVipFunction getByVipUuidAndFunId(String vipUuId, String functionUuid) {
+        AssoVipFunction assoVipFunction = null;
+        if(vipUuId==null||functionUuid==null){
+            return assoVipFunction;
+        }
+        LambdaQueryWrapper<AssoVipFunction> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(AssoVipFunction::getVipUuid, vipUuId)
+                .eq(AssoVipFunction::getFunctionUuid, functionUuid);
+        assoVipFunction = this.getOne(queryWrapper, false);
+
+        return assoVipFunction;
+
+
+    }
 }
 
 

+ 11 - 0
src/main/java/com/example/xiaoshiweixinback/service/VipService.java

@@ -41,6 +41,7 @@ public class VipService extends ServiceImpl<VipMapper, Vip> {
     @Autowired
     private AssoPersonVipService assoPersonVipService;
     @Autowired
+    @Lazy
     private AssoPersonFunctionService assoPersonFunctionService;
     @Autowired
     private SysFunctionService sysFunctionService;
@@ -85,6 +86,8 @@ public class VipService extends ServiceImpl<VipMapper, Vip> {
             assoPersonFunction.setExpiryTime(assoPersonVip.getExpiryTime());
             assoPersonFunction.setCreateTime(assoPersonVip.getCreateTime());
             assoPersonFunction.setFunctionParameter(item.getFunctionParameter());
+            assoPersonFunction.setVipType(vip.getVipType());
+            assoPersonFunction.setVipUuid(vip.getVipUuid());
             assoPersonFunction.setPersonUuid(personUuId);
             assoPersonFunctions.add(assoPersonFunction);
         });
@@ -213,6 +216,14 @@ public class VipService extends ServiceImpl<VipMapper, Vip> {
 
         return assoPersonFunction;
     }
+
+
+    public Vip getDefaultVip( ) {
+        LambdaQueryWrapper<Vip> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(Vip::getVipType, 0);
+        Vip vip = this.getOne(queryWrapper,false);
+        return vip;
+    }
 }
 
 

+ 19 - 4
src/main/java/com/example/xiaoshiweixinback/service/importPatent/EsDenseVectorService.java

@@ -14,10 +14,13 @@ import co.elastic.clients.elasticsearch.core.search.FieldCollapse;
 import co.elastic.clients.elasticsearch.core.search.Hit;
 import co.elastic.clients.json.JsonData;
 import com.example.xiaoshiweixinback.business.common.base.Records;
+import com.example.xiaoshiweixinback.business.common.base.RedisConf;
+import com.example.xiaoshiweixinback.business.redis.RedisService;
 import com.example.xiaoshiweixinback.business.utils.BeanUtil;
 import com.example.xiaoshiweixinback.business.utils.parseQueryToTree.expressManager;
 import com.example.xiaoshiweixinback.business.utils.parseQueryToTree.operateNode;
 import com.example.xiaoshiweixinback.business.utils.parseQueryToTree.treeNode;
+import com.example.xiaoshiweixinback.domain.AssoPersonFunction;
 import com.example.xiaoshiweixinback.domain.Product;
 import com.example.xiaoshiweixinback.domain.es.PatentVector;
 import com.example.xiaoshiweixinback.entity.dto.esPicture.EsPictureNoDTO;
@@ -28,6 +31,7 @@ import com.example.xiaoshiweixinback.entity.vo.esPicture.EsPictureNoVo;
 import com.example.xiaoshiweixinback.entity.vo.esPicture.EsPatentVectorVo;
 import com.example.xiaoshiweixinback.mapper.ProductMapper;
 import com.example.xiaoshiweixinback.service.SearchRecordService;
+import com.example.xiaoshiweixinback.service.VipService;
 import com.example.xiaoshiweixinback.service.common.FileManagerService;
 import com.example.xiaoshiweixinback.service.common.GetVectorService;
 import com.example.xiaoshiweixinback.service.importPatent.FormatQueryService;
@@ -71,6 +75,12 @@ public class EsDenseVectorService {
     @Autowired
     private EsPatentService esPatentService;
 
+    @Autowired
+    private VipService vipService;
+
+    @Autowired
+    private RedisService redisService;
+
     /**
      * 根据图片排序获取列表
      *
@@ -79,16 +89,20 @@ public class EsDenseVectorService {
      * @throws IOException
      */
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
-    public Records getPatentVectors(EsPatentVectorDTO dto,File file) throws Exception {
+    public Records getPatentVectors(EsPatentVectorDTO dto, File file) throws Exception {
         Long pageNum = dto.getPageNum();
         Long pageSize = dto.getPageSize();
         Boolean ifAddSearchRecord = dto.getIfAddSearchRecord();
 
+        AssoPersonFunction assoPersonFunction = vipService.getAssoPersonFunction("3");
+        if (assoPersonFunction == null) {
+
+        }
         SearchRequest.Builder builder = new SearchRequest.Builder();
         //设置查询索引
         builder.index("patent_vector");
         Query q = null;
-        String condition = this.appendCondition(dto.getProductId(), dto.getKey(),dto.getAppCountry(),dto.getCompanyName());
+        String condition = this.appendCondition(dto.getProductId(), dto.getKey(), dto.getAppCountry(), dto.getCompanyName());
         if (StringUtils.isNotEmpty(condition)) {
             //1. 解析检索条件
             treeNode tree = expressManager.getInstance().Parse(condition, false);
@@ -197,6 +211,7 @@ public class EsDenseVectorService {
 
     /**
      * 根据专利号获取相关图片
+     *
      * @param noDTO
      * @return
      * @throws IOException
@@ -229,7 +244,7 @@ public class EsDenseVectorService {
      * @return
      * @throws Exception
      */
-    public String appendCondition(Integer productId, String keyword,String appCountry,String companyName) {
+    public String appendCondition(Integer productId, String keyword, String appCountry, String companyName) {
         SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
         SimpleDateFormat format1 = new SimpleDateFormat("yyyy");
 
@@ -301,7 +316,7 @@ public class EsDenseVectorService {
             String ccName = "";
             for (int i = 0; i < split.length; i++) {
                 String s = split[i];
-                if (split.length -1 != i) {
+                if (split.length - 1 != i) {
                     ccName = ccName + "\"" + s + "\"" + " OR ";
                 } else {
                     ccName = ccName + "\"" + s + "\"";

+ 1 - 0
src/main/java/com/example/xiaoshiweixinback/service/importPatent/GetPatentPictureFromExcelService.java

@@ -54,6 +54,7 @@ public class GetPatentPictureFromExcelService {
 
     public void tem(File file, Patent patent, Integer i) throws Exception {
         String guid = FormatUtil.getPictureFormat(patent.getAppNo()) + i;
+        System.out.println(guid);
             fileManagerService.uploadFileWithGuid(file, guid);
         PatentVector patentVectorOrg = esService.getVectorByIndex(patent.getAppNo(), i);
         if (patentVectorOrg != null) {

+ 26 - 26
src/main/java/com/example/xiaoshiweixinback/service/importPatent/excel/GetPatentFromSzService.java

@@ -31,16 +31,19 @@ import java.util.Map;
 
 @Service
 public class GetPatentFromSzService {
-@Autowired
-private ExcuteUploadSettingService excuteUploadSettingService;
-@Autowired
-private GetPatentFromExcelService getPatentFromExcelService;
-@Autowired
-private GetPatentPictureFromExcelService getPatentPictureFromExcelService;
-@Autowired
-private SavePatentToEsService savePatentToEsService;
-    public void test(String path) throws  Exception {
-
+    @Autowired
+    private ExcuteUploadSettingService excuteUploadSettingService;
+    @Autowired
+    private GetPatentFromExcelService getPatentFromExcelService;
+    @Autowired
+    private GetPatentPictureFromExcelService getPatentPictureFromExcelService;
+    @Autowired
+    private SavePatentToEsService savePatentToEsService;
+
+    public void test(String pathStr) throws Exception {
+        String[] paths = pathStr.split(",");
+        for (int t=0;t<paths.length;t++) {
+            String path =paths[t];
             File tempFile = new File(path);
 
             Sheet sheet = ReadExcelUtils.readExcel(tempFile);
@@ -48,7 +51,7 @@ private SavePatentToEsService savePatentToEsService;
             Row firstRow = sheet.getRow(0);
             int columns = firstRow.getLastCellNum();
 
-            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5+"");
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "");
 
             for (int r = 0; r < total; r++) {
                 Row needRow = sheet.getRow(r + 1);
@@ -56,33 +59,30 @@ private SavePatentToEsService savePatentToEsService;
                 for (int i = 0; i < columns; i++) {
                     map.put(firstRow.getCell(i) + "", ExcelUtils.getValue(needRow.getCell(i)) + "");
                 }
-                UploadParamsVO uploadParamsVO = UploadPatentBatchUtil.processData(map,jsonData);
+                UploadParamsVO uploadParamsVO = UploadPatentBatchUtil.processData(map, jsonData);
                 getPatentFromExcelService.loadPatent(uploadParamsVO);
 
                 List<PictureData> pictureDatas = ReadExcelUtils.getPictures((XSSFSheet) sheet, r + 1);
 
-                    for(int i=0;i<pictureDatas.size();i++) {
-                        PictureData pictureData  =pictureDatas.get(i);
-                        String ext = pictureData.suggestFileExtension();
-                        byte[] data = pictureData.getData();
-                        String picName = IdUtil.simpleUUID();
-                        File file = FileUtils.getFileByBytes(data, picName, "." + ext);
-                        getPatentPictureFromExcelService.tem(file, uploadParamsVO.getPatent(),i);
-                    }
-                UploadPatentWebDTO uploadPatentWebDTO =new UploadPatentWebDTO();
+                for (int i = 0; i < pictureDatas.size(); i++) {
+                    PictureData pictureData = pictureDatas.get(i);
+                    String ext = pictureData.suggestFileExtension();
+                    byte[] data = pictureData.getData();
+                    String picName = IdUtil.simpleUUID();
+                    File file = FileUtils.getFileByBytes(data, picName, "." + ext);
+                    getPatentPictureFromExcelService.tem(file, uploadParamsVO.getPatent(), i);
+                }
+                UploadPatentWebDTO uploadPatentWebDTO = new UploadPatentWebDTO();
                 uploadPatentWebDTO.setPatent(uploadParamsVO.getPatent());
                 savePatentToEsService.saveOrUpdate(uploadPatentWebDTO);
                 System.out.println(r);
             }
-
+            System.out.println("完成"+t);
 
             //获得总列数
 
-
-
+        }
     }
 
 
-
-
 }

+ 1 - 1
src/main/resources/mapper/AssoPersonFunctionMapper.xml

@@ -13,7 +13,7 @@
         left join sys_function as sf on apf.function_uuid = sf.uuid
         <where>
             apf.person_uuid = #{personUuid}
-            and apf.expiry_time > now()
+            and apf.expiry_time > now() and apf.create_time &lt;= now()
             <if test="functionUuid!=null">
                 and apf.function_uuid =#{functionUuid}
             </if>