feat:收到封存电子病历,使用封存id采集其他系统接口调用

master
wyb 2 years ago
parent 759cedfb22
commit 5fef2f8eba

@ -0,0 +1,27 @@
{
"sealCollectClassify": "SEAL_COLLECT",
"sealCollectConfigs":[
{
"desc":"封存病案-扫描视图报告采集",
"url":"http://127.0.0.1:9316/gdszy/patscan/collect/seal/collectBySealId"
},{
"desc":"封存病案-Lis检验报告采集",
"url":"http://127.0.0.1:9315/collect/gdszy/lisBySealId"
},{
"desc":"封存病案-pacs检查报告采集",
"url":"http://127.0.0.1:9303/seal/collect/pacs"
},{
"desc":"封存病案-内镜报告采集",
"url":"http://127.0.0.1:9304/seal/collect/endoscopy"
},{
"desc":"封存病案-心电报告采集",
"url":"http://127.0.0.1:9305/seal/collect/ecg"
},{
"desc":"封存病案-重症报告采集",
"url":"http://127.0.0.1:9409/seal/collect/icu"
},{
"desc":"封存病案-手麻报告采集",
"url":"http://127.0.0.1:9306/seal/collect/surgicalAnesthesia"
}
]
}

@ -0,0 +1,31 @@
package com.docus.bgts.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* @author YongBin Wen
* @date 2024/1/15 13:36
*/
@Configuration
public class ThreadPoolConfig {
public ThreadPoolConfig() {
}
@Bean
public ThreadPoolExecutor threadPoolExecutor() {
return new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(),
(int)((double)Runtime.getRuntime().availableProcessors() / 0.1),
60L, TimeUnit.SECONDS,
new LinkedBlockingQueue(Runtime.getRuntime().availableProcessors()),
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.CallerRunsPolicy());
}
}

@ -0,0 +1,65 @@
package com.docus.bgts.dto;
import lombok.Data;
import java.util.List;
/**
*
* @author YongBin Wen
* @date 2024/1/15 11:33
*/
@Data
public class SystemCollectConfig {
/**
* -
*/
private String sealCollectClassify;
/**
*
*/
private List<CollectConfig> sealCollectConfigs;
@Data
public static class CollectConfig {
private String desc;
private String url;
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
public enum Classify {
/**
* -
*/
SEAL_COLLECT("SEAL_COLLECT");
/**
*
*/
final String classify;
Classify(String classify) {
this.classify = classify;
}
public String getClassify() {
return classify;
}
}
}

@ -2,8 +2,7 @@ package com.docus.bgts.handler;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.docus.bgts.dto.SystemCollectConfig;
import com.docus.bgts.entity.*;
import com.docus.bgts.enums.Codes;
import com.docus.bgts.facade.IAfCollectTaskService;
@ -15,30 +14,25 @@ import com.docus.bgts.utils.FileUtils;
import com.docus.bgts.utils.HttpUtils;
import com.docus.bgts.utils.ResultUtils;
import com.docus.bgts.utils.XmlUtils;
//import com.sun.xml.internal.ws.util.xml.XmlUtil;
import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.Namespace;
import org.dom4j.io.SAXReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import sun.misc.BASE64Decoder;
import javax.annotation.Resource;
import javax.jws.WebService;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -60,6 +54,9 @@ public class TBasicWebService implements ITBasicWebService {
@Autowired
TScanAssortMapper tScanAssortMapper;
@Resource
private ThreadPoolExecutor threadPoolExecutor;
// private Object lock = new Object();
private final Logger logger = LoggerFactory.getLogger(getClass());
@ -165,6 +162,7 @@ public class TBasicWebService implements ITBasicWebService {
reportDownPatientDto.setJzh(empIdText);
reportDownPatientDto.setSealId(sealId);
logger.info("封存患者jzh " + empIdText);
sealCollect(sealId);
reportDownDto.setPatient(reportDownPatientDto);
List<Element> elementList = xmlUtils.getJsonByName(elementRoot);
for (Element element : elementList) {
@ -385,6 +383,65 @@ public class TBasicWebService implements ITBasicWebService {
}
}
public static void main(String[] args) {
TBasicWebService service = new TBasicWebService();
service.sealCollect("");
}
private void sealCollect(String sealId) {
final String systemCollectConfigFileName = "dataConfig" + File.separator + "SystemCollectConfig";
List<SystemCollectConfig.CollectConfig> sealCollectConfigs;
try {
String configJson = FileUtils.readJsonFromCurrentProject(systemCollectConfigFileName);
SystemCollectConfig systemCollectConfig = JSON.parseObject(configJson, SystemCollectConfig.class);
String sealCollectClassify = systemCollectConfig.getSealCollectClassify();
if (!SystemCollectConfig.Classify.SEAL_COLLECT.getClassify().equals(sealCollectClassify)) {
throw new RuntimeException("封存病案采集配置未配置!");
}
sealCollectConfigs = systemCollectConfig.getSealCollectConfigs();
for (SystemCollectConfig.CollectConfig config : sealCollectConfigs) {
if (StringUtils.isBlank(config.getDesc()) || StringUtils.isBlank(config.getUrl())) {
throw new RuntimeException("封存病案采集配置中描述和地址不能为空!");
}
}
} catch (RuntimeException runtimeException) {
logger.error(runtimeException.getMessage(), runtimeException);
return;
} catch (Exception ex) {
logger.error("封存病案获取采集配置出现未知错误!", ex);
return;
}
// 添加封存采集任务的容器
List<CompletableFuture<Void>> completableFutureList = new CopyOnWriteArrayList<>();
for (SystemCollectConfig.CollectConfig config : sealCollectConfigs) {
CompletableFuture<Void> completableFuture = CompletableFuture.runAsync(() -> {
sealCollect(sealId, config);
}, threadPoolExecutor);
completableFutureList.add(completableFuture);
}
// 封存采集任务的容器不为空,阻塞到所有任务完成
if (!completableFutureList.isEmpty()) {
CompletableFuture<Void> allFutures = CompletableFuture.allOf(completableFutureList.toArray(new CompletableFuture[0]));
try {
allFutures.get();
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
}
}
private void sealCollect(String sealId, SystemCollectConfig.CollectConfig config) {
String url = config.getUrl() + "?sealId=" + sealId;
String desc = config.getDesc();
try {
logger.info("{},采集地址:{}", desc, url);
String result = HttpUtils.get(url);
logger.info("{},采集地址:{},采集结果:{}", desc, url, result);
} catch (Exception ex) {
logger.error(desc + ",采集地址:" + url + ",采集失败!", ex);
}
}
/**
*
@ -751,9 +808,9 @@ public class TBasicWebService implements ITBasicWebService {
}
}
public static void main(String[] args) {
depdf();
}
// public static void main(String[] args) {
// depdf();
// }
}

@ -38,6 +38,19 @@ public class FileUtils {
return jsonMap.get(name);
}
/**
*
*
* @param fileName json
* @return json
*/
public static String readJsonFromCurrentProject(String fileName) {
//获取目录结构
String path = FileUtils.currentPath();
String filePath = path + File.separator + fileName;
//解析json映射文件
return JsonUtils.readJsonFile(filePath);
}
}

Loading…
Cancel
Save