修改获取患者DCM和PDF信息接口
Some checks failed
Java CI with Maven / build (11) (push) Has been cancelled
Java CI with Maven / build (17) (push) Has been cancelled
Java CI with Maven / build (8) (push) Has been cancelled
yudao-ui-admin CI / build (14.x) (push) Has been cancelled
yudao-ui-admin CI / build (16.x) (push) Has been cancelled

This commit is contained in:
lxd 2024-11-05 19:55:26 +08:00
parent 22eeb255dc
commit 3e6291fff0
3 changed files with 90 additions and 61 deletions

View File

@ -89,9 +89,9 @@ public class FileUtils {
* 将Base64编码的字符串保存为文件 * 将Base64编码的字符串保存为文件
* *
* @param base64String Base64编码的字符串 * @param base64String Base64编码的字符串
* @param folderPath 文件保存的文件夹路径 * @param folderPath 文件保存的文件夹路径
* @param fileName 文件名不包含扩展名 * @param fileName 文件名不包含扩展名
* @param extension 文件扩展名例如 "png", "jpg", "txt" * @param extension 文件扩展名例如 "png", "jpg", "txt"
* @throws IOException 如果写入文件时发生错误 * @throws IOException 如果写入文件时发生错误
*/ */
public static void saveBase64ToFile(String base64String, String folderPath, String fileName, String extension) 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; 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());
}
}
} }

View File

@ -535,8 +535,11 @@ public class ApplyformController {
List<String> dcmurl = new ArrayList<>(); List<String> dcmurl = new ArrayList<>();
for (PatientexamlistDO patientexamlistDO : patientexamlistDOList) { for (PatientexamlistDO patientexamlistDO : patientexamlistDOList) {
//条件不满足说明这个人没有进行分析 无法提供相关数据 //条件不满足说明这个人没有进行分析 无法提供相关数据
if (patientexamlistDO.getDiagDoctor() != null && !patientexamlistDO.getDiagDoctor().isEmpty()) { if (patientexamlistDO.getReviewDoctor() != null && !patientexamlistDO.getReviewDoctor().isEmpty()) {
//存放PDF
pdfurl.add(patientexamlistDO.getPdfurl()); pdfurl.add(patientexamlistDO.getPdfurl());
//存放访问地址 一次检查一个地址
dcmurl.add("https://pacs.gw12320.com/viewdcm/?regid="+patientexamlistDO.getRegId()+"&orgId="+patientexamlistDO.getOrgId()+"&examid="+patientexamlistDO.getExamId());
} }
} }
if(pdfurl.isEmpty()) if(pdfurl.isEmpty())
@ -545,8 +548,8 @@ public class ApplyformController {
} }
else else
{ {
//取这个患者的所有的dcm地址 //取这个患者的所有的dcm地址 dcm地址 现在变成网页路径
dcmurl = dicompatientsService.GetDcmUrl(regId, orgId); // dcmurl = dicompatientsService.GetDcmUrl(regId, orgId);
medicalDataVO.setPdflist(pdfurl); medicalDataVO.setPdflist(pdfurl);
medicalDataVO.setDcm(dcmurl); medicalDataVO.setDcm(dcmurl);
medicalDataVO.setPdf(""); medicalDataVO.setPdf("");

View File

@ -429,17 +429,13 @@ public class ultrasonicController {
public void FtpImage(@RequestBody insimagescreenshotVO insimagescreenshotVO) { public void FtpImage(@RequestBody insimagescreenshotVO insimagescreenshotVO) {
String base64String = insimagescreenshotVO.getImagebase(); String base64String = insimagescreenshotVO.getImagebase();
String fileName = System.currentTimeMillis() + ".jpg"; String fileName = System.currentTimeMillis() + ".jpg";
if(insimagescreenshotVO.getModel().equals("0")) if (insimagescreenshotVO.getModel().equals("0")) {
{
// 解码Base64字符串 // 解码Base64字符串
String base64Image = base64String.split(",")[1]; String base64Image = base64String.split(",")[1];
try try {
{ FileUtils.saveBase64ToFile2(base64Image, insimagescreenshotVO.getFolderPath(), fileName.split("\\.")[0], "jpg");
FileUtils.saveBase64ToFile(base64Image,insimagescreenshotVO.getFolderPath(),fileName.split("\\.")[0],"jpg"); } catch (Exception ignored) {
} System.out.println("文件上传失败" + ignored.getMessage());
catch (Exception ignored)
{
System.out.println("文件上传失败"+ignored.getMessage());
} }
} }
else else
@ -453,23 +449,23 @@ public class ultrasonicController {
FTPClient ftpClient = new FTPClient(); FTPClient ftpClient = new FTPClient();
try { try {
ftpClient.enterLocalPassiveMode(); ftpClient.enterLocalPassiveMode();
// 连接FTP服务器 // 连接FTP服务器
ftpClient.connect(ftpServer, ftpPort); ftpClient.connect(ftpServer, ftpPort);
ftpClient.login(ftpUser, ftpPassword); ftpClient.login(ftpUser, ftpPassword);
// 设置文件传输类型为二进制 // 设置文件传输类型为二进制
ftpClient.setFileType(FTP.BINARY_FILE_TYPE); ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
// 解码Base64字符串 // 解码Base64字符串
String base64Image = base64String.split(",")[1]; // 去掉数据URL的头部 String base64Image = base64String.split(",")[1]; // 去掉数据URL的头部
// 解码Base64字符串 // 解码Base64字符串
byte[] decodedBytes = Base64.getDecoder().decode(base64Image); 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(); ftpClient.logout();
@ -489,30 +485,32 @@ public class ultrasonicController {
} }
} }
//上传成功 //上传成功
//当前时间 //当前时间
LocalDateTime dateTime = LocalDateTime.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), LocalDateTime dateTime = LocalDateTime.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
AdminUserDO user = userService.getUser(getLoginUserId()); AdminUserDO user = null;
// 生成随机 UUID if (insimagescreenshotVO.getOrgId() == null || insimagescreenshotVO.getOrgId().trim().equals(""))
UUID randomUUID = UUID.randomUUID(); user = userService.getUser(getLoginUserId());
medicalimgDO medicalimgDO = new medicalimgDO(); // 生成随机 UUID
medicalimgDO.setId(randomUUID.toString()); UUID randomUUID = UUID.randomUUID();
medicalimgDO.setImgUrl("/video/" +insimagescreenshotVO.getID()+"/"+ fileName); medicalimgDO medicalimgDO = new medicalimgDO();
medicalimgDO.setCreatePerson(""); medicalimgDO.setId(randomUUID.toString());
medicalimgDO.setCreateDate(dateTime); medicalimgDO.setImgUrl("/video/" + insimagescreenshotVO.getID() + "/" + fileName);
medicalimgDO.setRegId(insimagescreenshotVO.getID()); medicalimgDO.setCreatePerson("");
if (insimagescreenshotVO.getOrgId() != null && !insimagescreenshotVO.getOrgId().trim().equals("")) medicalimgDO.setCreateDate(dateTime);
medicalimgDO.setOrgId(insimagescreenshotVO.getOrgId().trim()); medicalimgDO.setRegId(insimagescreenshotVO.getID());
else if (user != null && user.getOrgId() != null) if (insimagescreenshotVO.getOrgId() != null && !insimagescreenshotVO.getOrgId().trim().equals(""))
medicalimgDO.setOrgId(user.getOrgId()); medicalimgDO.setOrgId(insimagescreenshotVO.getOrgId().trim());
medicalimgDO.setSelected("0"); else if (user != null && user.getOrgId() != null)
if (insimagescreenshotVO.getImgType() == null || insimagescreenshotVO.getImgType().trim().equals("")) medicalimgDO.setOrgId(user.getOrgId());
medicalimgDO.setImgType("1"); medicalimgDO.setSelected("0");
else if (insimagescreenshotVO.getImgType() == null || insimagescreenshotVO.getImgType().trim().equals(""))
medicalimgDO.setImgType(insimagescreenshotVO.getImgType().trim()); medicalimgDO.setImgType("1");
int count = medicalimgService.insimage(medicalimgDO); else
medicalimgDO.setImgType(insimagescreenshotVO.getImgType().trim());
int count = medicalimgService.insimage(medicalimgDO);
System.out.println("----------------------44444444444----------------------");
} }
@PostMapping("/InsImageInfo") @PostMapping("/InsImageInfo")
@ -634,14 +632,14 @@ public class ultrasonicController {
@PostMapping("/SaveFileBase64") @PostMapping("/SaveFileBase64")
@Operation(summary = "base64保存文件") @Operation(summary = "base64保存文件")
public String SaveFileBase64(@RequestBody SaveFileBase64 fileBase64){ public String SaveFileBase64(@RequestBody SaveFileBase64 fileBase64) {
try{ try {
String base=fileBase64.getImagebase(); String base = fileBase64.getImagebase();
FileUtils.saveBase64ToFile(base,fileBase64.getFolderPath(),fileBase64.getFileName(),fileBase64.getExtension()); FileUtils.saveBase64ToFile(base, fileBase64.getFolderPath(), fileBase64.getFileName(), fileBase64.getExtension());
return "上传成功"; return "上传成功";
} catch (Exception e) { } catch (Exception e) {
return "上传失败" +e.getMessage(); return "上传失败" + e.getMessage();
} }
} }
} }