转换文件线程池优化;上传文件页面优化

gov
Mahone 4 years ago
parent 5ebde3f2ef
commit 9f94abc5e2

@ -73,7 +73,7 @@
if (info.file.status === 'done') {
if(info.file.response.code===200){
this.$message.success(`${info.file.name} 文件上传成功`);
this.$emit('nd');
// this.$emit('nd');
}else{
this.fileList.forEach((item,index)=>{
if(item.uid===info.file.uid){

@ -265,7 +265,7 @@ public class KmDocServiceImpl extends ServiceImpl<KmDocMapper, KmDoc> implements
@Override
public void indexDocSyncBatch(List<String> idList) {
executorService.execute(() -> indexDocBatch(idList));
executorService.singleExecute(() -> indexDocBatch(idList));
}
private void indexDocBatch(List<String> idList) {
@ -279,7 +279,7 @@ public class KmDocServiceImpl extends ServiceImpl<KmDocMapper, KmDoc> implements
@Override
public void indexDocSync(KmDoc kmDoc) {
executorService.execute(() -> ftiIndexDoc(kmDoc));
executorService.singleExecute(() -> ftiIndexDoc(kmDoc));
}
//KmDoc对象分析内容并入库ES

@ -130,7 +130,7 @@ public class KmFileServiceImpl extends ServiceImpl<KmFileMapper, KmFile> impleme
KmFile KmFile=getKmFile(fileId);
if(KmFile!=null){
String filePath=KmFile.getPhysicalPath();
File f=new File(filePath);
File f=new File(baseConfig.getUploadDir(),filePath);
if(f.exists()){
f.delete();
}

@ -5,6 +5,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.PreDestroy;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@ -12,26 +13,30 @@ import java.util.concurrent.TimeUnit;
@Service
public class ThreadPoolExecutorService implements IThreadPoolExecutorService {
private ThreadPoolExecutor poolExecutor;
private ThreadPoolExecutor singleExecutor;
private static LinkedBlockingDeque<Runnable> deque = new LinkedBlockingDeque<Runnable>(10000);
private static ThreadPoolExecutor singleExecutor =new ThreadPoolExecutor(
5,10000, 20, TimeUnit.SECONDS,deque);;
private Logger logger= LoggerFactory.getLogger(ThreadPoolExecutorService.class);
public ThreadPoolExecutorService(){
LinkedBlockingDeque<Runnable> deque = new LinkedBlockingDeque<Runnable>();
ArrayBlockingQueue<Runnable> poolQeque = new ArrayBlockingQueue<Runnable>(10);
poolExecutor=new ThreadPoolExecutor(
4,4, 5, TimeUnit.SECONDS,deque);
5,20, 5, TimeUnit.SECONDS,poolQeque);
poolExecutor.allowCoreThreadTimeOut(true);
singleExecutor =new ThreadPoolExecutor(
1,1, 5, TimeUnit.SECONDS,deque);
1,10000, 20, TimeUnit.SECONDS,deque);
singleExecutor.allowCoreThreadTimeOut(true);
}
@Override
public void singleExecute(Runnable runnable){
singleExecutor.execute(() -> {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
// try {
// Thread.sleep(300);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
runnable.run();
});
}
@ -39,11 +44,11 @@ public class ThreadPoolExecutorService implements IThreadPoolExecutorService {
@Override
public void execute(Runnable runnable){
poolExecutor.execute(() -> {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
runnable.run();
});
}

Loading…
Cancel
Save