|
|
package com.sy.task;
|
|
|
|
|
|
import com.sy.bwAnalysis.AnalysisRoute;
|
|
|
import com.sy.logic.LiftBar;
|
|
|
import com.sy.utils.XMLThreadPoolFactory;
|
|
|
import com.tianbo.util.Date.DateUtil;
|
|
|
import com.tianbo.util.IO.FileTool;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
...
|
...
|
@@ -51,21 +49,17 @@ public class TaskAnalysis { |
|
|
List<File> files = FileTool.readDirectoryFiles(fileDirectory);
|
|
|
//文件数量大于50个,每次只解析前50个
|
|
|
if (files!=null && !files.isEmpty() && files.size()>theadamount){
|
|
|
CountDownLatch latch = new CountDownLatch(theadamount);
|
|
|
log.trace("本地解析报文任务开始{},剩余处理文件数量:{}",startTime,files.size());
|
|
|
for (int i=0;i<theadamount;i++){
|
|
|
threadJbob(files.get(i),latch,"",threadPool);
|
|
|
threadJbob(files.get(i),null,"",threadPool);
|
|
|
}
|
|
|
latch.await();
|
|
|
}
|
|
|
//文件数量小于50个,全部一次解析完
|
|
|
else if (files!=null && !files.isEmpty() && files.size()<theadamount){
|
|
|
CountDownLatch latch = new CountDownLatch(files.size());
|
|
|
log.trace("本地解析报文任务开始{},剩余处理文件数量文件数量:{}",startTime,files.size());
|
|
|
for (int i=0;i<files.size();i++){
|
|
|
threadJbob(files.get(i),latch,"",threadPool);
|
|
|
threadJbob(files.get(i),null,"",threadPool);
|
|
|
}
|
|
|
latch.await();
|
|
|
}
|
|
|
|
|
|
}catch (Exception e){
|
...
|
...
|
@@ -80,7 +74,7 @@ public class TaskAnalysis { |
|
|
private void threadJbob(File file,CountDownLatch latch,String transToCfps,ThreadPoolExecutor threadPool){
|
|
|
try{
|
|
|
AnalysisRoute analysisRoute=new AnalysisRoute();
|
|
|
String message = com.sy.utils.FileTool.readfile(file,"UTF-8");
|
|
|
String message = com.sy.utils.FileTool.readfile(file);
|
|
|
analysisRoute.setMessage(message);
|
|
|
threadPool.execute(analysisRoute);
|
|
|
FileUtils.moveFileToDirectory(file,new File("bw/handled/"),true);
|
...
|
...
|
|