chendayu vor 2 Jahren
Ursprung
Commit
c4ff995003

+ 2 - 2
PAS/src/main/java/cn/cslg/pas/common/utils/ReadExcelUtils.java

@@ -170,8 +170,8 @@ public class ReadExcelUtils {
                     XSSFClientAnchor anchor = (XSSFClientAnchor) shape.getAnchor();
                     //XSSFClientAnchor anchor = picture.getPreferredSize();
                     CTMarker marker = anchor.getFrom();
-                    int key = marker.getRow();
-                    if (key == row) {
+                    int excelRow = marker.getRow();
+                    if (excelRow == row) {
                         XSSFPicture picture = (XSSFPicture) shape;
                         return picture.getPictureData();
                     }

+ 2 - 2
PAS/src/main/java/cn/cslg/pas/service/upLoadPatent/ExcuteDataToVOService.java

@@ -13,7 +13,7 @@ import java.util.List;
 import java.util.Map;
 
 /**
- * 将专利数据转换为专利VO实体类业务层
+ * 将专利数据转换为专利VO实体类业务层
  *
  * @Author chenyu
  * @Date 2023/5/31
@@ -34,7 +34,7 @@ public class ExcuteDataToVOService {
         //取出专利摘要附图
         PictureData pictureData = patentData.getPictureData();
 
-        //专利基础数据装配(此步与数据源配置文件对象相关
+        //专利基础数据装配(与数据源配置文件对象进行匹配装载
         UploadParamsVO uploadParamsVO = UploadPatentBatchUtil.processData(patentMap, jsonData);
         uploadParamsVO.setPictureData(pictureData);
         return uploadParamsVO;

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

@@ -17,7 +17,7 @@ import java.util.List;
 @Service
 public class ExcuteUploadSettingService {
     /**
-     * 解析数据源配置文件
+     * 解析数据源配置文件并返回配置文件对象
      *
      * @param sourceId 数据来源id
      * @return 返回数据源配置文件对象

+ 6 - 1
PAS/src/main/java/cn/cslg/pas/service/upLoadPatent/MessageService.java

@@ -3,9 +3,14 @@ package cn.cslg.pas.service.upLoadPatent;
 
 import org.springframework.stereotype.Service;
 
-/**处理消息通知
+/**
+ * 处理消息通知
+ *
  * @Author 李仁杰
  */
 @Service
 public class MessageService {
+
+
+
 }

+ 21 - 19
PAS/src/main/java/cn/cslg/pas/service/upLoadPatent/PantentQueueService.java

@@ -19,7 +19,9 @@ import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-/** 将专利信息存入队列或从队列取出
+/**
+ * 将专利信息存入队列或从队列取出
+ *
  * @author 李仁杰
  */
 @Service
@@ -28,20 +30,22 @@ public class PantentQueueService {
     private final ExcuteDataToVOService excuteDataToVOService;
     private final ExcuteUploadSettingService excuteUploadSettingService;
     private Queue<UploadParamsVO> queue = new LinkedList<>();
-    private Boolean flag =false;
+    private Boolean flag = false;
     private CountDownLatch latch = new CountDownLatch(10);
+
     //将专利信息存入队列
     public void addPatnetToQueue(Task task) throws InterruptedException {
         try {
             //获得文件路径
-            String filePath=task.getUrl();
+            String filePath = task.getUrl();
             //检查文件合法性
-            Integer totalRow =  ReadExcelUtils.textExcel(filePath);
-            //解析配置信息
-            List<UploadSettingVO.Column> jsonData =excuteUploadSettingService.ExcuteUploadSetting(task.getProductId()+"");
-            for(int i=0;i<totalRow;i++){
-                PatentData patentData = ReadExcelUtils.readExcelOneRow(filePath,i);
-                UploadParamsVO  uploadParamsVO =excuteDataToVOService.fileToPatentVO(patentData,jsonData);
+            Integer totalRow = ReadExcelUtils.textExcel(filePath);
+            //根据数据来源id(如1:智慧芽)解析数据源配置文件信息
+            List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting("1");
+            //遍历专利总数量,在循环中保存专利
+            for (int i = 1; i <= totalRow; i++) {
+                PatentData patentData = ReadExcelUtils.readExcelOneRow(filePath, i);
+                UploadParamsVO uploadParamsVO = excuteDataToVOService.fileToPatentVO(patentData, jsonData);
                 queue.add(uploadParamsVO);
                 //通知消费者线程
                 latch.countDown();
@@ -51,25 +55,23 @@ public class PantentQueueService {
         } finally {
         }
 
-        flag=true;
+        flag = true;
     }
 
     //将专利信息从队列取出
     public void pushPantentToDb() throws InterruptedException {
         try {
-            while(true){
-                if(queue.isEmpty()){
-                    if(flag){
+            while (true) {
+                if (queue.isEmpty()) {
+                    if (flag) {
                         System.out.println("退出循环");
                         return;
-                    }
-                    else{
+                    } else {
                         latch.countDown();
                     }
-                }
-                else{
-                    UploadParamsVO uploadParamsVO=queue.remove();
-                    System.out.println("出队列"+uploadParamsVO);
+                } else {
+                    UploadParamsVO uploadParamsVO = queue.remove();
+                    System.out.println("出队列" + uploadParamsVO);
                 }
             }