From 3e6291fff08e012a1b2fd20ddb8be35591f37535 Mon Sep 17 00:00:00 2001 From: lxd <1004405501@qq.com> Date: Tue, 5 Nov 2024 19:55:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96=E6=82=A3?= =?UTF-8?q?=E8=80=85DCM=E5=92=8CPDF=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/common/util/io/FileUtils.java | 34 +++++- .../admin/applyform/ApplyformController.java | 9 +- .../ultrasonic/ultrasonicController.java | 108 +++++++++--------- 3 files changed, 90 insertions(+), 61 deletions(-) diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/io/FileUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/io/FileUtils.java index 0483b7d5f..4c8dbefee 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/io/FileUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/io/FileUtils.java @@ -89,9 +89,9 @@ public class FileUtils { * 将Base64编码的字符串保存为文件。 * * @param base64String Base64编码的字符串 - * @param folderPath 文件保存的文件夹路径 - * @param fileName 文件名(不包含扩展名) - * @param extension 文件扩展名(例如 "png", "jpg", "txt") + * @param folderPath 文件保存的文件夹路径 + * @param fileName 文件名(不包含扩展名) + * @param extension 文件扩展名(例如 "png", "jpg", "txt") * @throws IOException 如果写入文件时发生错误 */ public static void saveBase64ToFile(String base64String, String folderPath, String fileName, String extension) throws IOException { @@ -122,4 +122,32 @@ public class FileUtils { throw e; } } + + public static void saveBase64ToFile2(String base64String, String folderPath, String fileName, String extension) { + //参数校验 + if (fileName.contains("..") || fileName.contains("/") || fileName.contains("\\")) { + throw new IllegalArgumentException("Invalid file name."); + } + + try { + byte[] decodedBytes = Base64.getDecoder().decode(base64String); + +// Path folder = Paths.get(folderPath); +// if (!Files.exists(folder)) { +// Files.createDirectories(folder); +// } +// Path filePath = folder.resolve(fileName + "." + extension); + + File file = new File(folderPath); + file.setWritable(true, false); + file.mkdirs(); + Path filePath = Paths.get(folderPath + "/" + fileName + "." + extension); + + java.io.OutputStream outputStream = Files.newOutputStream(filePath, StandardOpenOption.CREATE, StandardOpenOption.WRITE); + outputStream.write(decodedBytes); + } catch (Exception ex) { + System.out.println("----------------------FileUtils Exception------------------------"); + System.out.println(ex.getMessage()); + } + } } diff --git a/yudao-module-applyregistration/yudao-module-applyregistration-biz/src/main/java/cn/iocoder/yudao/module/applyregistration/controller/admin/applyform/ApplyformController.java b/yudao-module-applyregistration/yudao-module-applyregistration-biz/src/main/java/cn/iocoder/yudao/module/applyregistration/controller/admin/applyform/ApplyformController.java index 5567a1f58..86408c83d 100644 --- a/yudao-module-applyregistration/yudao-module-applyregistration-biz/src/main/java/cn/iocoder/yudao/module/applyregistration/controller/admin/applyform/ApplyformController.java +++ b/yudao-module-applyregistration/yudao-module-applyregistration-biz/src/main/java/cn/iocoder/yudao/module/applyregistration/controller/admin/applyform/ApplyformController.java @@ -535,8 +535,11 @@ public class ApplyformController { List dcmurl = new ArrayList<>(); for (PatientexamlistDO patientexamlistDO : patientexamlistDOList) { //条件不满足说明这个人没有进行分析 无法提供相关数据 - if (patientexamlistDO.getDiagDoctor() != null && !patientexamlistDO.getDiagDoctor().isEmpty()) { + if (patientexamlistDO.getReviewDoctor() != null && !patientexamlistDO.getReviewDoctor().isEmpty()) { + //存放PDF pdfurl.add(patientexamlistDO.getPdfurl()); + //存放访问地址 一次检查一个地址 + dcmurl.add("https://pacs.gw12320.com/viewdcm/?regid="+patientexamlistDO.getRegId()+"&orgId="+patientexamlistDO.getOrgId()+"&examid="+patientexamlistDO.getExamId()); } } if(pdfurl.isEmpty()) @@ -545,8 +548,8 @@ public class ApplyformController { } else { - //取这个患者的所有的dcm地址 - dcmurl = dicompatientsService.GetDcmUrl(regId, orgId); + //取这个患者的所有的dcm地址 dcm地址 现在变成网页路径 + // dcmurl = dicompatientsService.GetDcmUrl(regId, orgId); medicalDataVO.setPdflist(pdfurl); medicalDataVO.setDcm(dcmurl); medicalDataVO.setPdf(""); diff --git a/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/controller/admin/ultrasonic/ultrasonicController.java b/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/controller/admin/ultrasonic/ultrasonicController.java index 7bde64811..91e4d03e5 100644 --- a/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/controller/admin/ultrasonic/ultrasonicController.java +++ b/yudao-module-ultrasoniccom/yudao-module-ultrasoniccom-biz/src/main/java/cn/iocoder/yudao/module/ultrasoniccom/controller/admin/ultrasonic/ultrasonicController.java @@ -429,17 +429,13 @@ public class ultrasonicController { public void FtpImage(@RequestBody insimagescreenshotVO insimagescreenshotVO) { String base64String = insimagescreenshotVO.getImagebase(); String fileName = System.currentTimeMillis() + ".jpg"; - if(insimagescreenshotVO.getModel().equals("0")) - { + if (insimagescreenshotVO.getModel().equals("0")) { // 解码Base64字符串 String base64Image = base64String.split(",")[1]; - try - { - FileUtils.saveBase64ToFile(base64Image,insimagescreenshotVO.getFolderPath(),fileName.split("\\.")[0],"jpg"); - } - catch (Exception ignored) - { - System.out.println("文件上传失败"+ignored.getMessage()); + try { + FileUtils.saveBase64ToFile2(base64Image, insimagescreenshotVO.getFolderPath(), fileName.split("\\.")[0], "jpg"); + } catch (Exception ignored) { + System.out.println("文件上传失败" + ignored.getMessage()); } } else @@ -453,23 +449,23 @@ public class ultrasonicController { FTPClient ftpClient = new FTPClient(); try { - ftpClient.enterLocalPassiveMode(); - // 连接FTP服务器 - ftpClient.connect(ftpServer, ftpPort); - ftpClient.login(ftpUser, ftpPassword); + ftpClient.enterLocalPassiveMode(); + // 连接FTP服务器 + ftpClient.connect(ftpServer, ftpPort); + ftpClient.login(ftpUser, ftpPassword); - // 设置文件传输类型为二进制 - ftpClient.setFileType(FTP.BINARY_FILE_TYPE); - // 解码Base64字符串 - String base64Image = base64String.split(",")[1]; // 去掉数据URL的头部 - // 解码Base64字符串 - byte[] decodedBytes = Base64.getDecoder().decode(base64Image); + // 设置文件传输类型为二进制 + ftpClient.setFileType(FTP.BINARY_FILE_TYPE); + // 解码Base64字符串 + String base64Image = base64String.split(",")[1]; // 去掉数据URL的头部 + // 解码Base64字符串 + byte[] decodedBytes = Base64.getDecoder().decode(base64Image); - // 创建输入流 - InputStream inputStream = new ByteArrayInputStream(decodedBytes); + // 创建输入流 + InputStream inputStream = new ByteArrayInputStream(decodedBytes); - // 上传文件 - boolean result = ftpClient.storeFile(uploadPath + "/" + fileName, inputStream); + // 上传文件 + boolean result = ftpClient.storeFile(uploadPath + "/" + fileName, inputStream); // 断开连接 ftpClient.logout(); @@ -489,30 +485,32 @@ public class ultrasonicController { } } - //上传成功 - //当前时间 - LocalDateTime dateTime = LocalDateTime.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), - DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); - AdminUserDO user = userService.getUser(getLoginUserId()); - // 生成随机 UUID - UUID randomUUID = UUID.randomUUID(); - medicalimgDO medicalimgDO = new medicalimgDO(); - medicalimgDO.setId(randomUUID.toString()); - medicalimgDO.setImgUrl("/video/" +insimagescreenshotVO.getID()+"/"+ fileName); - medicalimgDO.setCreatePerson(""); - medicalimgDO.setCreateDate(dateTime); - medicalimgDO.setRegId(insimagescreenshotVO.getID()); - if (insimagescreenshotVO.getOrgId() != null && !insimagescreenshotVO.getOrgId().trim().equals("")) - medicalimgDO.setOrgId(insimagescreenshotVO.getOrgId().trim()); - else if (user != null && user.getOrgId() != null) - medicalimgDO.setOrgId(user.getOrgId()); - medicalimgDO.setSelected("0"); - if (insimagescreenshotVO.getImgType() == null || insimagescreenshotVO.getImgType().trim().equals("")) - medicalimgDO.setImgType("1"); - else - medicalimgDO.setImgType(insimagescreenshotVO.getImgType().trim()); - int count = medicalimgService.insimage(medicalimgDO); - + //上传成功 + //当前时间 + LocalDateTime dateTime = LocalDateTime.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + AdminUserDO user = null; + if (insimagescreenshotVO.getOrgId() == null || insimagescreenshotVO.getOrgId().trim().equals("")) + user = userService.getUser(getLoginUserId()); + // 生成随机 UUID + UUID randomUUID = UUID.randomUUID(); + medicalimgDO medicalimgDO = new medicalimgDO(); + medicalimgDO.setId(randomUUID.toString()); + medicalimgDO.setImgUrl("/video/" + insimagescreenshotVO.getID() + "/" + fileName); + medicalimgDO.setCreatePerson(""); + medicalimgDO.setCreateDate(dateTime); + medicalimgDO.setRegId(insimagescreenshotVO.getID()); + if (insimagescreenshotVO.getOrgId() != null && !insimagescreenshotVO.getOrgId().trim().equals("")) + medicalimgDO.setOrgId(insimagescreenshotVO.getOrgId().trim()); + else if (user != null && user.getOrgId() != null) + medicalimgDO.setOrgId(user.getOrgId()); + medicalimgDO.setSelected("0"); + if (insimagescreenshotVO.getImgType() == null || insimagescreenshotVO.getImgType().trim().equals("")) + medicalimgDO.setImgType("1"); + else + medicalimgDO.setImgType(insimagescreenshotVO.getImgType().trim()); + int count = medicalimgService.insimage(medicalimgDO); + System.out.println("----------------------44444444444----------------------"); } @PostMapping("/InsImageInfo") @@ -634,14 +632,14 @@ public class ultrasonicController { @PostMapping("/SaveFileBase64") @Operation(summary = "base64保存文件") - public String SaveFileBase64(@RequestBody SaveFileBase64 fileBase64){ - try{ - String base=fileBase64.getImagebase(); - FileUtils.saveBase64ToFile(base,fileBase64.getFolderPath(),fileBase64.getFileName(),fileBase64.getExtension()); - return "上传成功"; - } catch (Exception e) { - return "上传失败" +e.getMessage(); - } + public String SaveFileBase64(@RequestBody SaveFileBase64 fileBase64) { + try { + String base = fileBase64.getImagebase(); + FileUtils.saveBase64ToFile(base, fileBase64.getFolderPath(), fileBase64.getFileName(), fileBase64.getExtension()); + return "上传成功"; + } catch (Exception e) { + return "上传失败" + e.getMessage(); + } } }