From 2c0510d325629e7d70bbc785460abb860b30af10 Mon Sep 17 00:00:00 2001 From: linjj <850658129@qq.com> Date: Thu, 17 Jul 2025 14:37:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A4=84=E7=90=86?= =?UTF-8?q?=E8=81=94=E4=BC=97=E5=9B=BE=E5=83=8F=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/emr/dao/CommomMapper.java | 10 ++ .../java/com/emr/service/CommomService.java | 165 ++++++++++-------- src/main/resources/mapper/CommomMapper.xml | 6 + 3 files changed, 111 insertions(+), 70 deletions(-) diff --git a/src/main/java/com/emr/dao/CommomMapper.java b/src/main/java/com/emr/dao/CommomMapper.java index b151fcf..ff0ad7c 100644 --- a/src/main/java/com/emr/dao/CommomMapper.java +++ b/src/main/java/com/emr/dao/CommomMapper.java @@ -189,4 +189,14 @@ public interface CommomMapper { Integer getIsExistFileName(String fileName); List> queryFileManage(); + + + /** + * @Author: linjj + * @Description: 查询是否为联众数据 + * @DateTime: 2025/7/17` 11:29 + * @Params: patientId + * @Return String + */ + List getSourceBypatientId(String patientId); } \ No newline at end of file diff --git a/src/main/java/com/emr/service/CommomService.java b/src/main/java/com/emr/service/CommomService.java index c75ee64..1eb1230 100644 --- a/src/main/java/com/emr/service/CommomService.java +++ b/src/main/java/com/emr/service/CommomService.java @@ -42,12 +42,14 @@ import javax.imageio.ImageIO; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; import java.net.InetAddress; import java.net.UnknownHostException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.List; import java.util.concurrent.*; /** @@ -421,10 +423,10 @@ public class CommomService { HttpServletRequest request = attributes.getRequest(); Power_User user; Object currentUser = request.getSession().getAttribute("CURRENT_USER"); - if(ObjectUtils.isEmpty(currentUser)){ + if (ObjectUtils.isEmpty(currentUser)) { ServletContext context = request.getServletContext(); - user = (Power_User)context.getAttribute("CURRENT_USER"); - }else{ + user = (Power_User) context.getAttribute("CURRENT_USER"); + } else { //查询通过审批且未过期的patientId集合 user = (Power_User) currentUser; } @@ -698,13 +700,15 @@ public class CommomService { // 从session获取用户名 Power_User user; Object currentUser = request.getSession().getAttribute("CURRENT_USER"); - if(ObjectUtils.isEmpty(currentUser)){ + if (ObjectUtils.isEmpty(currentUser)) { ServletContext context = request.getServletContext(); - user = (Power_User)context.getAttribute("CURRENT_USER"); - }else{ + user = (Power_User) context.getAttribute("CURRENT_USER"); + } else { //查询通过审批且未过期的patientId集合 user = (Power_User) currentUser; } + //查询是否为联众数据 + List source = commomMapper.getSourceBypatientId(patientId); List outs = new LinkedList<>(); if (StringUtils.isNotBlank(names)) { String[] rootPathList = rootPaths.split(","); @@ -719,6 +723,34 @@ public class CommomService { //获取是否打印用户信息 Short userEffective = emrPdfWaterSet.getUserEffective(); Integer roleId = user.getRoleId(); + //<-------------------------------------------------判断是否为联众数据,不为空就为联众数据单独处理联众图像逻辑------------------------------------------------------> + if (!ObjectUtils.isEmpty(source)) { + for (int i = 0; i < nameList.length; i++) { + //目录 + String rootPath = rootPathList[0]; + //原图片地址 + String srcPath = rootPath + File.separator + nameList[i]; + //处理后的图片存在目录 + String waterPicRoot = WATERPICPATH + patientId + File.separator + sourceList[i] + File.separator; + //目录不存在则创建 + if (!new File(waterPicRoot).isDirectory()) { + new File(waterPicRoot).mkdirs(); + } + //组织修改背景后图片存放地址 + String waterPicPath = waterPicRoot + nameList[i]; + //图像处理 + waterLz(srcPath,waterPicPath); + //获取盘符 + String root = selectRootByNotWater(WATERPICPATH); + //组织http地址 + String outSrc = EMRRECORDJSP + File.separator + root + "/jiashi/reload/" + patientId + File.separator + sourceList[i] + File.separator + nameList[i]; + outs.add(outSrc); + Integer value = Math.round((i + 1) * 100 / nameList.length); + printLoadingMap.put(mapKey, value); + return outs; + } + } + //<-------------------------------------------------单独处理联众图像逻辑------------------------------------------------------> for (int i = 0; i < nameList.length; i++) { //定义图片根目录地址 String rootPath = ""; @@ -751,14 +783,7 @@ public class CommomService { } else { //需要水印 //组织加水印后图片存放目录 - String waterPicRoot = WATERPICPATH + patientId + File.separator + sourceList[i] + File.separator;; -// if(srcPath.contains("/mnt/share") || srcPath.contains("/data")){ -// waterPicRoot = "/data/jiashi/reload/"+ patientId + File.separator + sourceList[i] + File.separator; -// //waterPicRoot = "/mnt/share/jiashi/reload/"+ patientId + File.separator + sourceList[i] + File.separator;//D:/jiashi/reload/patientId/1/ -// }else{ -// waterPicRoot = WATERPICPATH + patientId + File.separator + sourceList[i] + File.separator;//D:/jiashi/reload/patientId/1/ -// } - + String waterPicRoot = WATERPICPATH + patientId + File.separator + sourceList[i] + File.separator; //目录不存在则创建 if (!new File(waterPicRoot).isDirectory()) { new File(waterPicRoot).mkdirs(); @@ -781,7 +806,7 @@ public class CommomService { }else{ outSrc = EMRRECORDJSP + File.separator + root + "/jiashi/reload/" + patientId + File.separator + sourceList[i] + File.separator + nameList[i]; }*/ - if(srcPath.contains(linuxPath)){ + if (srcPath.contains(linuxPath)) { root = "picShare"; } outSrc = EMRRECORDJSP + File.separator + root + "/jiashi/reload/" + patientId + File.separator + sourceList[i] + File.separator + nameList[i]; @@ -810,55 +835,6 @@ 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("/")) { //截取字符串为磁盘路径 @@ -870,10 +846,10 @@ public class CommomService { //获取盘符并转换映射地址的头部地址 root = selectRootByNotWater(driveLetterPath); if (root == null) { - if(srcPath.contains(linuxPath)){ + if (srcPath.contains(linuxPath)) { srcPath = srcPath.replace(linuxPath, "picShare"); outSrc = EMRRECORDJSP + File.separator + srcPath; - }else{ + } else { outSrc = srcPath; } } else { @@ -946,6 +922,7 @@ public class CommomService { 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; // 示例返回值 @@ -1127,6 +1104,54 @@ public class CommomService { return outs; } + /** + * @Author: linjj + * @Description: 处理联众数据 + * @DateTime: 2025/7/17 14:13 + * @Params: + * @Return + */ + private boolean waterLz(String srcPath,String waterPicPath) { + try { + // 读取图像 + File inputFile = new File(srcPath); + BufferedImage inputImage = ImageIO.read(inputFile); + // 转换为灰度图像 + BufferedImage grayImage = new BufferedImage(inputImage.getWidth(), inputImage.getHeight(), BufferedImage.TYPE_BYTE_GRAY); + Graphics g = grayImage.getGraphics(); + g.drawImage(inputImage, 0, 0, null); + g.dispose(); + // 二值化处理 + BufferedImage binaryImage = new BufferedImage(inputImage.getWidth(), inputImage.getHeight(), BufferedImage.TYPE_BYTE_BINARY); + for (int y = 0; y < grayImage.getHeight(); y++) { + for (int x = 0; x < grayImage.getWidth(); x++) { + int gray = grayImage.getRGB(x, y) & 0xFF; + // 设置阈值,根据文字深浅给阈值 + if (gray < 200) { + binaryImage.setRGB(x, y, Color.BLACK.getRGB()); + } else { + binaryImage.setRGB(x, y, Color.WHITE.getRGB()); + } + } + } + // 创建一个新的白色背景图像 + BufferedImage whiteImage = new BufferedImage(inputImage.getWidth(), inputImage.getHeight(), BufferedImage.TYPE_INT_RGB); + whiteImage.createGraphics().fillRect(0, 0, whiteImage.getWidth(), whiteImage.getHeight()); + + // 将二值化图像绘制到白色背景上 + Graphics2D g2d = whiteImage.createGraphics(); + g2d.drawImage(binaryImage, 0, 0, null); + g2d.dispose(); + // 保存处理后的图像 + File outputFile = new File(waterPicPath); + ImageIO.write(whiteImage, "jpg", outputFile); + System.out.println("图像处理完成并保存。"); + } catch (IOException e) { + e.printStackTrace(); + return false; + } + return true; + } /** * 根据地址转换映射头 * @@ -1230,10 +1255,10 @@ public class CommomService { try { String osName = System.getProperty("os.name").toLowerCase(); - String costPath =""; + String costPath = ""; if (osName.contains("linux")) { costPath = linuxPath + File.separator + "cost"; - }else{ + } else { costPath = costPdfPath; } //解析压缩包文件上传并解压,返回存放pdf的全路径 @@ -1301,14 +1326,14 @@ public class CommomService { t_scan_assort.setSource((short) 1); //根据病人id,病案分段id,图片名称判断病案分段图片是否已存在 - List assorts = scanAssortService.getAssortListByPatientAssortPage(commomVo.getPatientId(), zd_assort.getAssortId(),picNameList.get(k)); + List assorts = scanAssortService.getAssortListByPatientAssortPage(commomVo.getPatientId(), zd_assort.getAssortId(), picNameList.get(k)); if (assorts != null && assorts.size() > 0) { continue; } insertList.add(t_scan_assort); } //批量新增图片记录 - if(!CollectionUtils.isEmpty(insertList)){ + if (!CollectionUtils.isEmpty(insertList)) { scanAssortService.SimpleInsert(insertList); } } diff --git a/src/main/resources/mapper/CommomMapper.xml b/src/main/resources/mapper/CommomMapper.xml index 52dd704..e9dd32d 100644 --- a/src/main/resources/mapper/CommomMapper.xml +++ b/src/main/resources/mapper/CommomMapper.xml @@ -1621,4 +1621,10 @@ b.scan_page scanPage from commomtable a join t_scan_assort b on a.patient_id = b.patient_id join zd_assort c on b.assort_id = c.assort_id + + + + \ No newline at end of file From ee60f27c4bc258f6907a577023ee64fbfe7ba454 Mon Sep 17 00:00:00 2001 From: linjj <850658129@qq.com> Date: Fri, 18 Jul 2025 11:37:18 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9return=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/emr/service/CommomService.java | 2 +- src/main/resources/config/config.properties | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/emr/service/CommomService.java b/src/main/java/com/emr/service/CommomService.java index 1eb1230..ff04129 100644 --- a/src/main/java/com/emr/service/CommomService.java +++ b/src/main/java/com/emr/service/CommomService.java @@ -747,8 +747,8 @@ public class CommomService { outs.add(outSrc); Integer value = Math.round((i + 1) * 100 / nameList.length); printLoadingMap.put(mapKey, value); - return outs; } + return outs; } //<-------------------------------------------------单独处理联众图像逻辑------------------------------------------------------> for (int i = 0; i < nameList.length; i++) { diff --git a/src/main/resources/config/config.properties b/src/main/resources/config/config.properties index bda5c8a..2ea845d 100644 --- a/src/main/resources/config/config.properties +++ b/src/main/resources/config/config.properties @@ -1,13 +1,12 @@ #power\u6743\u9650\u7CFB\u7EDF\u7684\u670D\u52A1\u5668\u5730\u5740\u5934 -POWER_IP =localhost -POWER_URLHEAD = http://localhost:8080/power +POWER_IP =10.1.1.146 +POWER_URLHEAD = http://10.1.1.146:8080/power -POWER_JSPHEAD = localhost -POWER_JSP = http://localhost:8080/power +POWER_JSPHEAD = 10.1.1.146 +POWER_JSP = http://10.1.1.146:8080/power #\u672C\u8EAB\u7CFB\u7EDF\u7684\u670D\u52A1\u5668\u5730\u5740\u5934 -EMR_RECORD_JSP = http://localhost:8081/emr_record - +EMR_RECORD_JSP = http://10.1.1.146:8080/emr_record #webSocket\u670D\u52A1\u5668\u5730\u5740 WEBSOCKET_URLHEAD = ${POWER_JSPHEAD}:8088