|
|
@ -34,6 +34,9 @@ import java.util.concurrent.ExecutionException;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
import java.util.concurrent.Future;
|
|
|
|
import java.util.concurrent.Future;
|
|
|
|
|
|
|
|
import java.util.concurrent.LinkedBlockingDeque;
|
|
|
|
|
|
|
|
import java.util.concurrent.ThreadFactory;
|
|
|
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.function.Function;
|
|
|
|
import java.util.function.Function;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
@ -75,13 +78,25 @@ public class UpdateService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void syncNotStart() {
|
|
|
|
public void syncNotStart() {
|
|
|
|
log.info("联众同步数据启动>>>>>>>>>>>>>>>>>>>>");
|
|
|
|
log.info("联众同步数据启动>>>>>>>>>>>>>>>>>>>>");
|
|
|
|
String syncDir = FilePathUtil.currentPath() + File.separator + "lianzhong-sync";
|
|
|
|
String syncDir = FilePathUtil.currentPath() + File.separator + "lianzhong-sync";
|
|
|
|
FilePathUtil.mkdirs(syncDir);
|
|
|
|
FilePathUtil.mkdirs(syncDir);
|
|
|
|
|
|
|
|
int corePoolSize = Runtime.getRuntime().availableProcessors();
|
|
|
|
ExecutorService patientExecutors = Executors.newFixedThreadPool(10);
|
|
|
|
int maximumPoolSize = corePoolSize * 2;
|
|
|
|
ExecutorService fileExecutor = Executors.newFixedThreadPool(90);
|
|
|
|
long keepAliveTime = 300L;
|
|
|
|
|
|
|
|
TimeUnit unit = TimeUnit.SECONDS;
|
|
|
|
|
|
|
|
LinkedBlockingDeque<Runnable> workQueue = new LinkedBlockingDeque<>();
|
|
|
|
|
|
|
|
ThreadFactory threadFactory = Executors.defaultThreadFactory();
|
|
|
|
|
|
|
|
ThreadPoolExecutor.CallerRunsPolicy handler = new ThreadPoolExecutor.CallerRunsPolicy();
|
|
|
|
|
|
|
|
ThreadPoolExecutor executor = new ThreadPoolExecutor(corePoolSize,
|
|
|
|
|
|
|
|
maximumPoolSize,
|
|
|
|
|
|
|
|
keepAliveTime,
|
|
|
|
|
|
|
|
unit,
|
|
|
|
|
|
|
|
workQueue,
|
|
|
|
|
|
|
|
threadFactory,
|
|
|
|
|
|
|
|
handler);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
while (true) {
|
|
|
|
while (true) {
|
|
|
|
List<CardInfo> cardInfos = this.updateData();
|
|
|
|
List<CardInfo> cardInfos = this.updateData();
|
|
|
@ -91,7 +106,7 @@ public class UpdateService {
|
|
|
|
String picDir = syncDir + File.separator + cardInfo.getId();
|
|
|
|
String picDir = syncDir + File.separator + cardInfo.getId();
|
|
|
|
FilePathUtil.mkdirs(picDir);
|
|
|
|
FilePathUtil.mkdirs(picDir);
|
|
|
|
|
|
|
|
|
|
|
|
Future patientFuture = patientExecutors.submit(() -> {
|
|
|
|
Future patientFuture = executor.submit(() -> {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
List<Picture> pictures = dataQuery.getPictures(cardInfo.getId());
|
|
|
|
List<Picture> pictures = dataQuery.getPictures(cardInfo.getId());
|
|
|
|
if (CollectionUtils.isEmpty(pictures)) {
|
|
|
|
if (CollectionUtils.isEmpty(pictures)) {
|
|
|
@ -110,7 +125,7 @@ public class UpdateService {
|
|
|
|
dataQuery.updatePicPath(cardInfo, lianZhongDir);
|
|
|
|
dataQuery.updatePicPath(cardInfo, lianZhongDir);
|
|
|
|
List<Future> fileFutures = new ArrayList<>();
|
|
|
|
List<Future> fileFutures = new ArrayList<>();
|
|
|
|
for (Picture picture : pictures) {
|
|
|
|
for (Picture picture : pictures) {
|
|
|
|
Future fileFuture = fileExecutor.submit(() -> {
|
|
|
|
Future fileFuture = executor.submit(() -> {
|
|
|
|
String tifFilePath = lianZhongDir + File.separator + removeFileExtension(picture.getPicname()) + ".tif";
|
|
|
|
String tifFilePath = lianZhongDir + File.separator + removeFileExtension(picture.getPicname()) + ".tif";
|
|
|
|
File tifFile = new File(tifFilePath);
|
|
|
|
File tifFile = new File(tifFilePath);
|
|
|
|
if (tifFile.exists()) {
|
|
|
|
if (tifFile.exists()) {
|
|
|
@ -242,8 +257,11 @@ public class UpdateService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
|
|
} catch (Exception ex) {
|
|
|
|
log.error("联众同步数据异常:" + ex.getMessage(), ex);
|
|
|
|
log.error("联众同步数据异常:" + ex.getMessage(), ex);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
executor.shutdown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void sycDirNotExistsJob() {
|
|
|
|
public void sycDirNotExistsJob() {
|
|
|
|
while (true) {
|
|
|
|
while (true) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -381,6 +399,8 @@ public class UpdateService {
|
|
|
|
System.out.println(new Gson().toJson(stringSetMap));
|
|
|
|
System.out.println(new Gson().toJson(stringSetMap));
|
|
|
|
Set<String> strings = stringSetMap.get("12345");
|
|
|
|
Set<String> strings = stringSetMap.get("12345");
|
|
|
|
System.out.println(new Gson().toJson(strings));
|
|
|
|
System.out.println(new Gson().toJson(strings));
|
|
|
|
|
|
|
|
int processors = Runtime.getRuntime().availableProcessors();
|
|
|
|
|
|
|
|
System.out.println(processors);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void initLianZhongPatPicDir() {
|
|
|
|
private void initLianZhongPatPicDir() {
|
|
|
@ -567,6 +587,4 @@ public class UpdateService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|