|
@@ -1,5 +1,6 @@
|
|
package cn.cslg.pas.service.upLoadPatent;
|
|
package cn.cslg.pas.service.upLoadPatent;
|
|
|
|
|
|
|
|
+import cn.cslg.pas.common.model.vo.ProjectImportPatentVO;
|
|
import cn.cslg.pas.common.model.vo.UploadParamsVO;
|
|
import cn.cslg.pas.common.model.vo.UploadParamsVO;
|
|
import cn.cslg.pas.common.model.vo.UploadSettingVO;
|
|
import cn.cslg.pas.common.model.vo.UploadSettingVO;
|
|
import cn.cslg.pas.common.utils.ReadExcelUtils;
|
|
import cn.cslg.pas.common.utils.ReadExcelUtils;
|
|
@@ -29,19 +30,20 @@ import java.util.concurrent.locks.ReentrantLock;
|
|
public class PantentQueueService {
|
|
public class PantentQueueService {
|
|
private final ExcuteDataToVOService excuteDataToVOService;
|
|
private final ExcuteDataToVOService excuteDataToVOService;
|
|
private final ExcuteUploadSettingService excuteUploadSettingService;
|
|
private final ExcuteUploadSettingService excuteUploadSettingService;
|
|
|
|
+ private final MessageService messageService;
|
|
private Queue<UploadParamsVO> queue = new LinkedList<>();
|
|
private Queue<UploadParamsVO> queue = new LinkedList<>();
|
|
private Boolean flag = false;
|
|
private Boolean flag = false;
|
|
private CountDownLatch latch = new CountDownLatch(10);
|
|
private CountDownLatch latch = new CountDownLatch(10);
|
|
|
|
|
|
//将专利信息存入队列
|
|
//将专利信息存入队列
|
|
- public void addPatnetToQueue(Task task) throws InterruptedException {
|
|
|
|
|
|
+ public void addPatnetToQueue(Task task, ProjectImportPatentVO projectImportPatentVO) throws InterruptedException {
|
|
try {
|
|
try {
|
|
//获得文件路径
|
|
//获得文件路径
|
|
String filePath = task.getUrl();
|
|
String filePath = task.getUrl();
|
|
//检查文件合法性
|
|
//检查文件合法性
|
|
Integer totalRow = ReadExcelUtils.textExcel(filePath);
|
|
Integer totalRow = ReadExcelUtils.textExcel(filePath);
|
|
//根据数据来源id(如1:智慧芽)解析数据源配置文件信息
|
|
//根据数据来源id(如1:智慧芽)解析数据源配置文件信息
|
|
- List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting("1");
|
|
|
|
|
|
+ List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(projectImportPatentVO.getSourceId());
|
|
//遍历专利总数量,在循环中保存专利
|
|
//遍历专利总数量,在循环中保存专利
|
|
for (int i = 1; i <= totalRow; i++) {
|
|
for (int i = 1; i <= totalRow; i++) {
|
|
//解析读取一行专利
|
|
//解析读取一行专利
|
|
@@ -52,7 +54,15 @@ public class PantentQueueService {
|
|
queue.add(uploadParamsVO);
|
|
queue.add(uploadParamsVO);
|
|
//通知消费者线程
|
|
//通知消费者线程
|
|
latch.countDown();
|
|
latch.countDown();
|
|
|
|
+
|
|
|
|
+ //Websocket发送message:通过WebSocket 在每一次循环结束后 向前端发送完成进度
|
|
|
|
+ Long percentage = totalRow == 0 ? 0 : Math.round((totalRow.equals(i) ? (i * 1D) : (i + 1D)) / totalRow * 100D);
|
|
|
|
+ messageService.sendWebsocketMessage(task, projectImportPatentVO, totalRow, i, percentage);
|
|
}
|
|
}
|
|
|
|
+ //全部循环结束后,发送进度
|
|
|
|
+ Long percentage = 100L;
|
|
|
|
+ messageService.sendWebsocketMessage(task, projectImportPatentVO, totalRow, totalRow, percentage);
|
|
|
|
+
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
} finally {
|
|
} finally {
|