修改获取患者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编码的字符串保存为文件
*
* @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());
}
}
}

View File

@ -535,8 +535,11 @@ public class ApplyformController {
List<String> 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("");

View File

@ -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();
}
}
}