diff --git a/src/main/java/com/emr/controller/commomSearch/CommomSearchController.java b/src/main/java/com/emr/controller/commomSearch/CommomSearchController.java index 4942b3b..4589abf 100644 --- a/src/main/java/com/emr/controller/commomSearch/CommomSearchController.java +++ b/src/main/java/com/emr/controller/commomSearch/CommomSearchController.java @@ -1162,7 +1162,7 @@ public class CommomSearchController { @RequestMapping(value = "getRecordContentBlood") @ResponseBody public void getRecordContentBlood(String patientId, HttpServletRequest request, HttpServletResponse response) { - Map cacheMap = commomService.CACHE_MAP; + // Map cacheMap = commomService.CACHE_MAP; List commomTrees = archiveDetailMapper.selectPdfPathByPatient2(patientId); Power_User user; Object currentUser = request.getSession().getAttribute("CURRENT_USER"); @@ -1176,7 +1176,8 @@ public class CommomSearchController { if (commomTrees.size() == 0) { try { String mapKey = user.getUserName() + "_" + patientId; - List scanPages = (List) cacheMap.get(mapKey); + //List scanPages = (List) cacheMap.get(mapKey); + List scanPages = (List) request.getSession().getAttribute(mapKey); if (!CollectionUtils.isEmpty(scanPages)) { String pdfName = "档案管理PDF"; //根据图片路径转换pdf @@ -1192,7 +1193,8 @@ public class CommomSearchController { img2PdfUtil.imageToPdfUserEffective(response, scanPages, pdfName, emrPdfWaterSet); } //移除缓存 - commomService.CACHE_MAP.clear(); + //commomService.CACHE_MAP.clear(); + request.removeAttribute(mapKey); } } catch (Exception e) { ExceptionPrintUtil.printException(e); @@ -1201,14 +1203,16 @@ public class CommomSearchController { } else { String pdfWater = ""; String mapKey = user.getUserName() + "_" + patientId; - List filePaths = (List) cacheMap.get(mapKey); + //List filePaths = (List) cacheMap.get(mapKey); + List filePaths = (List) request.getSession().getAttribute(mapKey); if (!CollectionUtils.isEmpty(filePaths)) { //根据图片路径转换pdf EmrPdfWaterSet emrPdfWaterSet = pdfWaterSetMapper.selectByPrimaryKey(1); //定义第二文本水印 姓名 + 科室 + ip Jpg2PdfUtil.mulFile2One2(response, filePaths, pdfWater,emrPdfWaterSet); //移除缓存 - commomService.CACHE_MAP.clear(); + //commomService.CACHE_MAP.clear(); + request.removeAttribute(mapKey); } } } diff --git a/src/main/java/com/emr/controller/templateSearch/TemplateSearchController.java b/src/main/java/com/emr/controller/templateSearch/TemplateSearchController.java index 398b2c1..9d5ae0a 100644 --- a/src/main/java/com/emr/controller/templateSearch/TemplateSearchController.java +++ b/src/main/java/com/emr/controller/templateSearch/TemplateSearchController.java @@ -998,14 +998,51 @@ public class TemplateSearchController { private String getSql(String selectSql, String fromTableSql, String whereSql, String orderBys, Power_User user) { String userName = user.getUserName(); + String powerDepts = user.getPowerDepts(); String initSelectSql = "select commomtable.patient_id,CASE WHEN emr_apply_approve.id is null THEN 0 ELSE 1 END isShowDetail,CASE WHEN emr_apply_approve1.id IS NULL THEN 0 ELSE 1 END isDownload,CASE WHEN emr_lock.id is null THEN 0 ELSE 1 END lockStatus"; if(StringUtils.isNotBlank(selectSql)){ initSelectSql += "," + selectSql; } String initFromTableSql = " from commomtable left join emr_apply_approve on commomtable.patient_id = emr_apply_approve.patient_id and emr_apply_approve.approve_state = 1 and emr_apply_approve.effe_time > GETDATE()-1 and emr_apply_approve.applyer = '" +userName+ "' and emr_apply_approve.apply_type != 3 left join emr_apply_approve emr_apply_approve1 on commomtable.patient_id = emr_apply_approve1.patient_id and emr_apply_approve1.approve_state = 1 and emr_apply_approve1.effe_time > GETDATE()-1 and emr_apply_approve1.applyer = '" +userName+ "' and emr_apply_approve1.apply_type = 3 left join emr_lock on commomtable.patient_id = emr_lock.patient_id and emr_lock.lock_state = 1 "; + String powerDeptsSql = ""; + if(StringUtils.isNotBlank(powerDepts)){ + // 将powerDepts转换为SQL IN条件 + String[] deptArray = powerDepts.split(","); + StringBuilder inClause = new StringBuilder(); + for(int i = 0; i < deptArray.length; i++) { + if(i == 0) { + inClause.append("'").append(deptArray[i]).append("'"); + } else { + inClause.append(",'").append(deptArray[i]).append("'"); + } + } + powerDeptsSql = "where commomtable.dis_dept in (" + inClause.toString() + ")"; + } + if(StringUtils.isNotBlank(fromTableSql)){ initFromTableSql += fromTableSql; } + + String sql = initSelectSql + initFromTableSql; + + // 添加powerDepts条件到SQL中 + if(StringUtils.isNotBlank(powerDeptsSql)) { + if(StringUtils.isNotBlank(whereSql) && !"undefined".equals(whereSql)){ + sql += " " + whereSql.replaceFirst("where", powerDeptsSql + " and "); + } else { + sql += " " + powerDeptsSql; + } + } else if(StringUtils.isNotBlank(whereSql) && !"undefined".equals(whereSql)){ + sql += " " + whereSql; + } + + if(StringUtils.isNotBlank(orderBys)){ + sql += " " + orderBys; + } + return sql; + /*if(StringUtils.isNotBlank(fromTableSql)){ + initFromTableSql += fromTableSql; + } String sql = initSelectSql + initFromTableSql; if(StringUtils.isNotBlank(whereSql) && !"undefined".equals(whereSql)){ sql += whereSql; @@ -1013,7 +1050,7 @@ public class TemplateSearchController { if(StringUtils.isNotBlank(orderBys)){ sql += orderBys; } - return sql; + return sql;*/ } /** diff --git a/src/main/java/com/emr/service/CommomService.java b/src/main/java/com/emr/service/CommomService.java index 48b9276..259b74a 100644 --- a/src/main/java/com/emr/service/CommomService.java +++ b/src/main/java/com/emr/service/CommomService.java @@ -46,6 +46,7 @@ import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; import java.net.InetAddress; +import java.net.URL; import java.net.UnknownHostException; import java.text.SimpleDateFormat; import java.util.*; @@ -288,7 +289,7 @@ public class CommomService { //脐血库显示pdf public void showRecordContentBlood(String patientId, String scanPages, String sources, String flag, HttpServletResponse response, HttpServletRequest request) throws Exception { - /*if (StringUtils.isNotBlank(patientId)) { + if (StringUtils.isNotBlank(patientId)) { patientId = patientId.replace("\'", ""); //查询 if (StringUtils.isNotBlank(flag)) { @@ -315,21 +316,21 @@ public class CommomService { } } if (!filePaths.isEmpty()) { - Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER"); + Power_User user = getCurrentUser(request); String mapKey = user.getUserName() + "_" + patientId; request.getSession().setAttribute(mapKey, filePaths); } } else { List commomTrees = archiveDetailMapper.getPDFRATH(patientId, scanPages); if (!commomTrees.isEmpty()) { - Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER"); + Power_User user = getCurrentUser(request); String mapKey = user.getUserName() + "_" + patientId; request.getSession().setAttribute(mapKey, commomTrees); } } } - }*/ - if (StringUtils.isBlank(patientId)) { + } + /*if (StringUtils.isBlank(patientId)) { return; } @@ -393,10 +394,10 @@ public class CommomService { } catch (Exception e) { e.printStackTrace(); } - }, threadPoolUtil.getExecutor()); + }, threadPoolUtil.getExecutor());*/ } - private Power_User getCurrentUser(HttpServletRequest request) { + public Power_User getCurrentUser(HttpServletRequest request) { Object currentUser = request.getSession().getAttribute("CURRENT_USER"); if (ObjectUtils.isEmpty(currentUser)) { ServletContext context = request.getServletContext(); @@ -850,7 +851,32 @@ public class CommomService { srcPath = srcPath.replace(linuxPath, "picShare"); outSrc = EMRRECORDJSP + File.separator + srcPath; } else { - outSrc = srcPath; + // <-------------------------------------------------共享文件夹路径处理------------------------------------------------------> + // 1. 下载文件到本地 F:\tmp + String name = user.getUserName(); + String localDownloadDir = "F:\\tmp"+File.separator+name; + File downloadDir = new File(localDownloadDir); + if (!downloadDir.exists()) { + downloadDir.mkdirs(); // 确保目录存在 + } + clearImageFiles(downloadDir); + // 提取文件名 + String fileName = new File(srcPath).getName(); + String localFilePath = localDownloadDir + File.separator + fileName; + + try { + // 执行下载(支持网络路径和本地路径) + downloadFile(srcPath, localFilePath); + } catch (IOException e) { + throw new RuntimeException("文件下载失败: " + srcPath, e); + } + + // 使用本地路径进行映射 + root = selectRootByNotWater(localFilePath); + String str1 = localFilePath.substring(0, localFilePath.indexOf(":") + 1); + picPath = localFilePath.substring(str1.length() + 1); + outSrc = EMRRECORDJSP + "/" + root + "/" + picPath.replace("\\", "/"); + // <-------------------------------------------------共享文件夹路径处理------------------------------------------------------> } } else { //获取盘符后面的地址 @@ -910,6 +936,56 @@ public class CommomService { return outs;*/ } + + private void clearImageFiles(File directory) { + if (directory.isDirectory()) { + File[] files = directory.listFiles((dir, name) -> + name.endsWith(".jpg") || name.endsWith(".jpeg") || + name.endsWith(".png") || name.endsWith(".gif") || + name.endsWith(".bmp") + ); + + if (files != null) { + for (File file : files) { + if (file.isFile()) { + file.delete(); // 删除图像文件 + } + } + } + } + } + + + + private void downloadFile(String sourcePath, String targetPath) throws IOException { + InputStream in = null; + OutputStream out = null; + try { + // 处理网络路径 + if (sourcePath.startsWith("\\\\")) { + sourcePath = sourcePath.replace("\\", "/"); + if (!sourcePath.startsWith("file:")) { + sourcePath = "file:" + sourcePath; + } + } + + URL sourceUrl = new URL(sourcePath); + in = sourceUrl.openStream(); + out = new FileOutputStream(targetPath); + + byte[] buffer = new byte[4096]; + int bytesRead; + while ((bytesRead = in.read(buffer)) != -1) { + out.write(buffer, 0, bytesRead); + } + } finally { + if (in != null) in.close(); + if (out != null) out.close(); + } + } + + + /** * 获取本机IP地址 */ @@ -1182,6 +1258,8 @@ public class CommomService { return "reloadK\\"; case "Z:": return "reloadZ\\"; + case "Y:": + return "reloadY\\"; case "W:": return "reloadW\\"; default: @@ -1264,7 +1342,7 @@ public class CommomService { //解析压缩包文件上传并解压,返回存放pdf的全路径 String saveFileName = UploadUtil.resolveCompressUploadFile(request, multipartFile, costPath); //获取pdf文件名 - List pdfNameList = Pdf2ImgUtil.getPdfName(saveFileName); + List pdfNameList = Pdf2ImgUtil.getPdfName(saveFileName+"2025-10医保清单"); //导出失败病案号,出院日期数组 List exportInpVoList = new ArrayList<>(); //定义导出异常病案号,出院日期实体对象 @@ -1310,7 +1388,7 @@ public class CommomService { filePath.mkdirs(); }*/ //pdf转jpg图片生成到指定路徑 - List picNameList = Pdf2ImgUtil.pdfToPic(saveFileName, pdfName, "jpg", commomVo.getFilePath()); + List picNameList = Pdf2ImgUtil.pdfToPic(saveFileName+"2025-10医保清单", pdfName, "jpg", commomVo.getFilePath()); //Zd_Assort zd_assort = zd_assortMapper.getZdAssortByName(commomVo.getPatientId()); Zd_Assort zd_assort = zd_assortMapper.getZdAssortByName("费用"); diff --git a/src/main/resources/config/config.properties b/src/main/resources/config/config.properties index 9677366..eedd3d5 100644 --- a/src/main/resources/config/config.properties +++ b/src/main/resources/config/config.properties @@ -1,16 +1,16 @@ #power\u6743\u9650\u7CFB\u7EDF\u7684\u670D\u52A1\u5668\u5730\u5740\u5934 POWER_IP =localhost -POWER_URLHEAD = http://localhost:8080/power +POWER_URLHEAD = http://localhost:8081/power POWER_JSPHEAD = localhost -POWER_JSP = http://localhost:8080/power +POWER_JSP = http://localhost:8081/power #\u672C\u8EAB\u7CFB\u7EDF\u7684\u670D\u52A1\u5668\u5730\u5740\u5934 -EMR_RECORD_JSP = http://localhost:8081/emr_record +EMR_RECORD_JSP = http://localhost:8082/emr_record #webSocket\u670D\u52A1\u5668\u5730\u5740 WEBSOCKET_URLHEAD = ${POWER_JSPHEAD}:8088 -#\u901A\u77E5\u5B57\u7B26\u4E32\u95F4\u9694\u7B26 +#\u901A\u77E5\u5B57\u7B26\u4E32\u95F4\u9694\u7B26x STR_SPLIT = *^:|,. #\u65E5\u5FD7\u4FDD\u7559\u5929\u6570 @@ -44,7 +44,7 @@ applyApproveFlag =0 #//????? initialization =0 -export_pdf_hospital_info = \u5e7f\u4e1c\u7701\u005f\u6e5b\u6c5f\u5e02\u005f\u9042\u6eaa\u53bf\u4eba\u6c11\u533b\u9662 +export_pdf_hospital_info = \u5e7f\u4e1c\u7701_\u6e5b\u6c5f\u5e02_\u9042\u6eaa\u53bf\u4eba\u6c11\u533b\u9662 #\u5e7f\u4e1c\u7701\u005f\u6e5b\u6c5f\u5e02\u005f\u9042\u6eaa\u53bf\u4eba\u6c11\u533b\u9662 ?? #\u5e7f\u4e1c\u7701\u005f\u5e7f\u5dde\u5e02\u5929\u6cb3\u533a\u4eba\u6c11\u533b\u9662 ?? @@ -66,7 +66,7 @@ fullTextDays = 90 NEW_EMR_RECORD_JSP : http://localhost:8081/emr_record #\u8D39\u7528\u6E05\u5355\u751F\u6210\u7684\u76EE\u5F55 -cost_pdf_path=D://cost// +cost_pdf_path=D:/cost httpMapPort = 9001