|
|
|
|
@ -15,6 +15,7 @@ import com.emr.service.ImportExcel.ImportExcelEntity;
|
|
|
|
|
import com.emr.service.ImportExcel.ImportExcelUtil;
|
|
|
|
|
import com.emr.service.tScanAssort.T_Scan_AssortService;
|
|
|
|
|
import com.emr.util.Pdf2ImgUtil;
|
|
|
|
|
import com.emr.util.ThreadPoolUtil;
|
|
|
|
|
import com.emr.util.UploadUtil;
|
|
|
|
|
import com.emr.util.img2PdfUtil;
|
|
|
|
|
import com.emr.vo.ExportInpVo;
|
|
|
|
|
@ -80,6 +81,9 @@ public class CommomService {
|
|
|
|
|
@Value("${linuxPath}")
|
|
|
|
|
private String linuxPath;
|
|
|
|
|
|
|
|
|
|
@Value("${httpMapPort}")
|
|
|
|
|
private String httpMapPort;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private CommomMapper commomMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
@ -94,6 +98,9 @@ public class CommomService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private Zd_AssortMapper zd_assortMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ThreadPoolUtil threadPoolUtil; // 注入统一的线程池
|
|
|
|
|
|
|
|
|
|
public static final Map<String, Object> CACHE_MAP = new ConcurrentHashMap<>();
|
|
|
|
|
|
|
|
|
|
//获取所属医院用户名集合
|
|
|
|
|
@ -320,80 +327,80 @@ public class CommomService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
if (StringUtils.isBlank(patientId)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(patientId)) {
|
|
|
|
|
patientId = patientId.replace("'", "");
|
|
|
|
|
// 查询
|
|
|
|
|
if (StringUtils.isNotBlank(flag)) {
|
|
|
|
|
CommomVo commomVo = commomMapper.selectByPrimaryKey(patientId);
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(flag)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 复制 request 中的关键信息,避免线程安全问题(request 不能直接跨线程使用)
|
|
|
|
|
Power_User user = getCurrentUser(request);
|
|
|
|
|
if (user == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String finalPatientId = patientId;
|
|
|
|
|
String finalFlag = flag;
|
|
|
|
|
String finalScanPages = scanPages;
|
|
|
|
|
String username = user.getUserName();
|
|
|
|
|
|
|
|
|
|
CompletableFuture.runAsync(() -> {
|
|
|
|
|
try {
|
|
|
|
|
CommomVo commomVo = commomMapper.selectByPrimaryKey(finalPatientId);
|
|
|
|
|
|
|
|
|
|
if (commomVo != null && StringUtils.isNotBlank(commomVo.getFilePath())) {
|
|
|
|
|
// flag = home_addr取home_addr字段,path_file取home_addr字段
|
|
|
|
|
String root1;
|
|
|
|
|
if ("home_addr".equals(flag)) {
|
|
|
|
|
if ("home_addr".equals(finalFlag)) {
|
|
|
|
|
root1 = commomVo.getHomeAddr();
|
|
|
|
|
} else if ("file_path".equals(flag)) {
|
|
|
|
|
} else if ("file_path".equals(finalFlag)) {
|
|
|
|
|
root1 = commomVo.getFilePath();
|
|
|
|
|
} else {
|
|
|
|
|
root1 = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 组织src
|
|
|
|
|
ExecutorService executor = Executors.newFixedThreadPool(6); // 创建线程池
|
|
|
|
|
String finalPatientId = patientId;
|
|
|
|
|
List<String> filePaths = CompletableFuture.supplyAsync(() -> {
|
|
|
|
|
List<String> pdfPaths = new LinkedList<>();
|
|
|
|
|
String[] scanPageArr = (scanPages != null) ? scanPages.split(",") : new String[0];
|
|
|
|
|
String[] scanPageArr = (finalScanPages != null) ? finalScanPages.split(",") : new String[0];
|
|
|
|
|
|
|
|
|
|
for (String scanPage : scanPageArr) {
|
|
|
|
|
if (StringUtils.isNotBlank(scanPage)) {
|
|
|
|
|
String srcStr = root1 + File.separator + scanPage;
|
|
|
|
|
if (StringUtils.isNotBlank(srcStr)) {
|
|
|
|
|
File file = new File(srcStr);
|
|
|
|
|
if (file.isFile()) {
|
|
|
|
|
pdfPaths.add(srcStr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return pdfPaths;
|
|
|
|
|
}, executor).exceptionally(ex -> {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
return Collections.emptyList(); // 返回空列表
|
|
|
|
|
}).join(); // 阻塞等待结果
|
|
|
|
|
|
|
|
|
|
executor.shutdown(); // 关闭线程池
|
|
|
|
|
|
|
|
|
|
Power_User user;
|
|
|
|
|
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
|
|
|
|
|
if(ObjectUtils.isEmpty(currentUser)){
|
|
|
|
|
ServletContext context = request.getServletContext();
|
|
|
|
|
user = (Power_User)context.getAttribute("CURRENT_USER");
|
|
|
|
|
}else{
|
|
|
|
|
//查询通过审批且未过期的patientId集合
|
|
|
|
|
user = (Power_User) currentUser;
|
|
|
|
|
}
|
|
|
|
|
if (user != null) {
|
|
|
|
|
String mapKey = user.getUserName() + "_" + finalPatientId;
|
|
|
|
|
request.getSession().setAttribute(mapKey, filePaths);
|
|
|
|
|
if (!pdfPaths.isEmpty()) {
|
|
|
|
|
String mapKey = username + "_" + finalPatientId;
|
|
|
|
|
CACHE_MAP.put(mapKey, pdfPaths);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
List<String> commomTrees = archiveDetailMapper.getPDFRATH(patientId, scanPages);
|
|
|
|
|
if (!CollectionUtils.isEmpty(commomTrees) && request != null) {
|
|
|
|
|
Power_User user;
|
|
|
|
|
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
|
|
|
|
|
if(ObjectUtils.isEmpty(currentUser)){
|
|
|
|
|
ServletContext context = request.getServletContext();
|
|
|
|
|
user = (Power_User)context.getAttribute("CURRENT_USER");
|
|
|
|
|
}else{
|
|
|
|
|
//查询通过审批且未过期的patientId集合
|
|
|
|
|
user = (Power_User) currentUser;
|
|
|
|
|
}
|
|
|
|
|
if (user != null) {
|
|
|
|
|
String mapKey = user.getUserName() + "_" + patientId;
|
|
|
|
|
request.getSession().setAttribute(mapKey, commomTrees);
|
|
|
|
|
List<String> commomTrees = archiveDetailMapper.getPDFRATH(finalPatientId, finalScanPages);
|
|
|
|
|
if (!CollectionUtils.isEmpty(commomTrees)) {
|
|
|
|
|
String mapKey = username + "_" + finalPatientId;
|
|
|
|
|
CACHE_MAP.put(mapKey, commomTrees);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}, threadPoolUtil.getExecutor());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Power_User getCurrentUser(HttpServletRequest request) {
|
|
|
|
|
Object currentUser = request.getSession().getAttribute("CURRENT_USER");
|
|
|
|
|
if (ObjectUtils.isEmpty(currentUser)) {
|
|
|
|
|
ServletContext context = request.getServletContext();
|
|
|
|
|
return (Power_User) context.getAttribute("CURRENT_USER");
|
|
|
|
|
} else {
|
|
|
|
|
return (Power_User) currentUser;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -803,6 +810,55 @@ public class CommomService {
|
|
|
|
|
root = selectRootByNotWater(WATERTIFTOJPGPATH);
|
|
|
|
|
outSrc = EMRRECORDJSP + File.separator + root + "/jiashi/tifToJpgLoad/" + format1 + ".jpg";
|
|
|
|
|
} else {
|
|
|
|
|
/*String driveLetterPath = srcPath.replaceAll("\\\\", "/");
|
|
|
|
|
if (driveLetterPath.startsWith("/")) {
|
|
|
|
|
String imageIpPath = "";//获取srcPath图像路径的ip
|
|
|
|
|
String localIP = getLocalIPAddress();//获取本机ip
|
|
|
|
|
//截取字符串为磁盘路径
|
|
|
|
|
int thirdBackslashIndex = driveLetterPath.indexOf('/', driveLetterPath.indexOf('/', driveLetterPath.indexOf('/') + 1) + 1);
|
|
|
|
|
if (thirdBackslashIndex != -1) {
|
|
|
|
|
imageIpPath = driveLetterPath.substring(2, thirdBackslashIndex);
|
|
|
|
|
driveLetterPath = driveLetterPath.substring(thirdBackslashIndex + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//将原图片地址转换成映射地址
|
|
|
|
|
//获取盘符并转换映射地址的头部地址
|
|
|
|
|
root = selectRootByNotWater(driveLetterPath);
|
|
|
|
|
// 判断IP是否一致
|
|
|
|
|
if (imageIpPath.equals(localIP)) {
|
|
|
|
|
if (root == null) {
|
|
|
|
|
if(srcPath.contains(linuxPath)){
|
|
|
|
|
srcPath = srcPath.replace(linuxPath, "picShare");
|
|
|
|
|
outSrc = EMRRECORDJSP + File.separator + srcPath;
|
|
|
|
|
}else{
|
|
|
|
|
outSrc = srcPath;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//获取盘符后面的地址
|
|
|
|
|
picPath = driveLetterPath.substring(driveLetterPath.indexOf('/'));
|
|
|
|
|
outSrc = EMRRECORDJSP + File.separator + root + picPath;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (root == null) {
|
|
|
|
|
if(srcPath.contains(linuxPath)){
|
|
|
|
|
srcPath = srcPath.replace(linuxPath, "picShare");
|
|
|
|
|
outSrc = EMRRECORDJSP + File.separator + srcPath;
|
|
|
|
|
}else{
|
|
|
|
|
outSrc = "http://" + imageIpPath + ":" + httpMapPort + File.separator + driveLetterPath;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//获取盘符后面的地址
|
|
|
|
|
picPath = driveLetterPath.substring(driveLetterPath.indexOf('/'));
|
|
|
|
|
outSrc = "http://" + imageIpPath + ":" + httpMapPort + File.separator + root + picPath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
root = selectRootByNotWater(driveLetterPath);
|
|
|
|
|
//获取盘符后面的地址
|
|
|
|
|
String str1 = driveLetterPath.substring(0, driveLetterPath.indexOf("/"));
|
|
|
|
|
picPath = driveLetterPath.substring(str1.length() + 1, driveLetterPath.length());
|
|
|
|
|
outSrc = EMRRECORDJSP + File.separator + root + picPath;
|
|
|
|
|
}*/
|
|
|
|
|
String driveLetterPath = srcPath.replaceAll("\\\\", "/");
|
|
|
|
|
if (driveLetterPath.startsWith("/")) {
|
|
|
|
|
//截取字符串为磁盘路径
|
|
|
|
|
@ -877,6 +933,19 @@ public class CommomService {
|
|
|
|
|
|
|
|
|
|
return outs;*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取本机IP地址
|
|
|
|
|
*/
|
|
|
|
|
private static String getLocalIPAddress() {
|
|
|
|
|
try {
|
|
|
|
|
InetAddress inetAddress = InetAddress.getLocalHost();
|
|
|
|
|
return inetAddress.getHostAddress();
|
|
|
|
|
} catch (UnknownHostException e) {
|
|
|
|
|
System.err.println("无法获取本机IP地址: " + e.getMessage());
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public String processImagePath(String rootPath, String name, String source, Power_User user, EmrPdfWaterSet emrPdfWaterSet, String patientId, String mapKey) throws IOException {
|
|
|
|
|
|
|
|
|
|
return "processed_" + name; // 示例返回值
|
|
|
|
|
|