Compare commits

..

No commits in common. "501b1f132f0b0a0194c32496df32fa9f6132700d" and "39a77bcd6e3b95a3ef8225509f32feafb1dd9f4f" have entirely different histories.

9 changed files with 108 additions and 222 deletions

View File

@ -8,12 +8,8 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.DigestUtil;
import lombok.SneakyThrows;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Base64;
import java.io.ByteArrayInputStream;
import java.io.File;
/**
* 文件工具类
@ -85,41 +81,4 @@ public class FileUtils {
return sha256Hex + '.' + FileTypeUtil.getType(new ByteArrayInputStream(content));
}
/**
* 将Base64编码的字符串保存为文件
*
* @param base64String Base64编码的字符串
* @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 {
// 检查文件名是否有效
if (fileName.contains("..") || fileName.contains("/") || fileName.contains("\\")) {
throw new IllegalArgumentException("Invalid file name.");
}
// 解码Base64字符串为字节数组
byte[] decodedBytes = Base64.getDecoder().decode(base64String);
// 创建文件的路径
Path folder = Paths.get(folderPath);
if (!Files.exists(folder)) {
// 如果文件夹不存在则创建它
Files.createDirectories(folder);
}
// 构建完整的文件名包括扩展名
Path filePath = folder.resolve(fileName + "." + extension);
// 使用Files.newOutputStream创建OutputStream并设置为追加模式
try (java.io.OutputStream outputStream = Files.newOutputStream(filePath, StandardOpenOption.CREATE, StandardOpenOption.WRITE)) {
outputStream.write(decodedBytes);
} catch (IOException e) {
throw e;
}
}
}

View File

@ -25,5 +25,4 @@ public class IoUtils {
return StrUtil.utf8Str(IoUtil.read(in, isClose));
}
}

View File

@ -396,7 +396,7 @@ public class ApplyformController {
AdminUserDO user = userService.getUser(getLoginUserId());
//1表示接口
if (type.equals("1")) { //土贵乌拉
if (user.getOrgId().equals("150926PDY564156")) {
Map<String, String> tokendata = new HashMap<>();
tokendata.put("appkey", "7653571505643966826");
tokendata.put("appsecret", "z8SVG1NBFY9d74LM");
@ -410,7 +410,7 @@ public class ApplyformController {
LocalDate currentDate = LocalDate.now();
Map<String, String> data = new HashMap<>();
data.put("Yiyuanid", user.getOrgId());
data.put("Yiyuanid", "150926PDY564156");
data.put("dateStart",currentDate.toString());
data.put("token", accessToken);
data.put("dateEnd", currentDate.toString());
@ -470,7 +470,7 @@ public class ApplyformController {
{
StrMsg = "暂无需要同步的数据";
}
}
} else if (type.equals("2")) //2 数据库
{
switch (apiconfigDO.getDatabaseType()) {

View File

@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.tblist.controller.admin.patientexamlist;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.common.util.io.FileUtils;
import cn.iocoder.yudao.module.system.dal.dataobject.org.OrgUnitDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.service.org.OrgUnitService;
@ -397,80 +396,64 @@ public class PatientexamlistController {
@Operation(summary = "获取pdf上传ftp")
public void FtpPdf(@RequestBody inspdfscreenshotVO insimagescreenshotVO) {
String base64String = insimagescreenshotVO.getImagebase();
String ftpServer = "114.55.171.231";
int ftpPort = 21; // FTP端口默认为21
String ftpUser = "pacs";
String ftpPassword = "pacs";
String uploadPath = "/";
String fileName = System.currentTimeMillis() + ".pdf";
if(insimagescreenshotVO.getModel().equals("0"))
{
FTPClient ftpClient = new FTPClient();
ftpClient.enterLocalPassiveMode();
try {
// 连接FTP服务器
ftpClient.connect(ftpServer, ftpPort);
ftpClient.login(ftpUser, ftpPassword);
// 设置文件传输类型为二进制
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
// 解码Base64字符串
String base64Image = base64String.split(",")[1];
try
{
FileUtils.saveBase64ToFile(base64Image,insimagescreenshotVO.getFolderPath(),fileName.split("\\.")[0],"pdf");
String base64Image = base64String.split(",")[1]; // 去掉数据URL的头部
// 解码Base64字符串
byte[] decodedBytes = Base64.getDecoder().decode(base64Image);
// 创建输入流
InputStream inputStream = new ByteArrayInputStream(decodedBytes);
// 上传文件
boolean result = ftpClient.storeFile(uploadPath + "/" + fileName, inputStream);
if (result) {
//上传成功
//当前时间
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());
PatientexamlistSaveReqVO updateReqVO = new PatientexamlistSaveReqVO();
updateReqVO.setId(insimagescreenshotVO.getID());
updateReqVO.setPdfurl("http://114.55.171.231:48082/" + fileName);
patientexamlistService.updatePatientexamlist(updateReqVO);
} else {
System.out.println("文件上传失败");
}
catch (Exception ignored)
{
System.out.println("文件上传失败"+ignored.getMessage());
}
}
else
{
String ftpServer = "114.55.171.231";
int ftpPort = 21; // FTP端口默认为21
String ftpUser = "pacs";
String ftpPassword = "pacs";
String uploadPath = "/";
FTPClient ftpClient = new FTPClient();
ftpClient.enterLocalPassiveMode();
// 断开连接
ftpClient.logout();
ftpClient.disconnect();
} catch (SocketException e) {
System.err.println("无法连接到FTP服务器: " + e.getMessage());
} catch (IOException e) {
System.err.println("IO异常: " + e.getMessage());
} finally {
try {
// 连接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);
// 创建输入流
InputStream inputStream = new ByteArrayInputStream(decodedBytes);
// 上传文件
boolean result = ftpClient.storeFile(uploadPath + "/" + fileName, inputStream);
// 断开连接
ftpClient.logout();
ftpClient.disconnect();
} catch (SocketException e) {
System.err.println("无法连接到FTP服务器: " + e.getMessage());
} catch (IOException e) {
System.err.println("IO异常: " + e.getMessage());
} finally {
try {
if (ftpClient.isConnected()) {
ftpClient.disconnect();
}
} catch (IOException ignored) {
if (ftpClient.isConnected()) {
ftpClient.disconnect();
}
} catch (IOException ignored) {
}
}
//上传成功
//当前时间
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());
PatientexamlistSaveReqVO updateReqVO = new PatientexamlistSaveReqVO();
updateReqVO.setId(insimagescreenshotVO.getID());
updateReqVO.setPdfurl("https://pacs.gw12320.com/video/" +insimagescreenshotVO.getID()+"/"+ fileName);
patientexamlistService.updatePatientexamlist(updateReqVO);
}

View File

@ -9,8 +9,4 @@ public class inspdfscreenshotVO {
private String imagebase;
private String model;
private String folderPath;
}

View File

@ -1,19 +0,0 @@
package cn.iocoder.yudao.module.ultrasoniccom.controller.admin.ultrasonic.medicalimg;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class SaveFileBase64 {
@Schema(description = "文件保存的文件夹路径")
private String folderPath;
@Schema(description = "Base64编码的字符串")
private String imagebase;
@Schema(description = "文件名(不包含扩展名)")
private String fileName;
@Schema(description = "文件扩展名(例如 \"png\", \"jpg\", \"txt\"")
private String extension;
private String orgId;
}

View File

@ -17,8 +17,5 @@ public class insimagescreenshotVO {
private String imgDescription;
private String orgId;
//
private String model;
private String folderPath;
}

View File

@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.ultrasoniccom.controller.admin.ultrasonic;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.common.util.io.FileUtils;
import cn.iocoder.yudao.module.system.dal.dataobject.dicomworklist.DicomImagesDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dicomworklist.DicomSeriesDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dicomworklist.DicompatientDO;
@ -15,7 +14,6 @@ import cn.iocoder.yudao.module.ultrasoniccom.controller.admin.ultrasonic.image.I
import cn.iocoder.yudao.module.ultrasoniccom.controller.admin.ultrasonic.image.PatientInfoVO;
import cn.iocoder.yudao.module.ultrasoniccom.controller.admin.ultrasonic.image.SeriesVO;
import cn.iocoder.yudao.module.ultrasoniccom.controller.admin.ultrasonic.image.StudyVO;
import cn.iocoder.yudao.module.ultrasoniccom.controller.admin.ultrasonic.medicalimg.SaveFileBase64;
import cn.iocoder.yudao.module.ultrasoniccom.controller.admin.ultrasonic.medicalimg.insimagescreenshotVO;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.ultrasoniccom.controller.admin.ultrasonic.medicalimg.upmedicalimgVO;
@ -37,11 +35,15 @@ import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -428,32 +430,17 @@ public class ultrasonicController {
@Operation(summary = "获取图片上传ftp")
public void FtpImage(@RequestBody insimagescreenshotVO insimagescreenshotVO) {
String base64String = insimagescreenshotVO.getImagebase();
String ftpServer = "192.168.0.110"; //114.55.171.231
int ftpPort = 21; // FTP端口默认为21
String ftpUser = "pacs";
String ftpPassword = "pacs123";
String uploadPath = "/";
String fileName = System.currentTimeMillis() + ".jpg";
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());
}
}
else
{
String ftpServer = "192.168.0.110"; //114.55.171.231
int ftpPort = 21; // FTP端口默认为21
String ftpUser = "pacs";
String ftpPassword = "pacs123";
String uploadPath = "/";
FTPClient ftpClient = new FTPClient();
FTPClient ftpClient = new FTPClient();
try {
ftpClient.enterLocalPassiveMode();
ftpClient.enterLocalPassiveMode();
try {
// 连接FTP服务器
ftpClient.connect(ftpServer, ftpPort);
ftpClient.login(ftpUser, ftpPassword);
@ -470,48 +457,51 @@ public class ultrasonicController {
// 上传文件
boolean result = ftpClient.storeFile(uploadPath + "/" + fileName, inputStream);
if (result) {
//上传成功
//当前时间
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("http://192.168.0.110:48082/" + 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);
} else {
System.out.println("文件上传失败");
}
// 断开连接
ftpClient.logout();
ftpClient.disconnect();
} catch (SocketException e) {
System.err.println("无法连接到FTP服务器: " + e.getMessage());
} catch (IOException e) {
System.err.println("IO异常: " + e.getMessage());
} finally {
try {
if (ftpClient.isConnected()) {
ftpClient.disconnect();
}
} catch (IOException ignored) {
// 断开连接
ftpClient.logout();
ftpClient.disconnect();
} catch (SocketException e) {
System.err.println("无法连接到FTP服务器: " + e.getMessage());
} catch (IOException e) {
System.err.println("IO异常: " + e.getMessage());
} finally {
try {
if (ftpClient.isConnected()) {
ftpClient.disconnect();
}
} catch (IOException ignored) {
}
}
//上传成功
//当前时间
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);
}
@ -632,16 +622,5 @@ public class ultrasonicController {
return success("插入成功");
}
@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();
}
}
}

View File

@ -161,9 +161,7 @@ yudao:
- /admin-api/ultrasoniccom/ultrasonic/insimagescreenshot
- /admin-api/ultrasoniccom/ultrasonic/InsImageInfo
- /admin-api/tblist/patientexamlist/addPatientExamInfo
- /admin-api/tblist/patientexamlist/GetAnalysisInfo
- /admin-api/system/jwtToken/getToken
- /admin-api/applyregistration/applyform/GetPatientPDFDcm
- /admin-api/ultrasoniccom/ultrasonic/ftpimage
websocket:
enable: true # websocket的开关
@ -179,7 +177,7 @@ yudao:
topic: ${spring.application.name}-websocket # 消息发送的 Kafka Topic
consumer-group: ${spring.application.name}-websocket-consumer # 消息发送的 Kafka Consumer Group
swagger:
title: 开发平台
title: 芋道快速开发平台
description: 提供管理后台、用户 App 的所有功能
version: ${yudao.info.version}
url: ${yudao.web.admin-ui.url}
@ -211,9 +209,7 @@ yudao:
- /admin-api/ultrasoniccom/ultrasonic/insimagescreenshot
- /admin-api/ultrasoniccom/ultrasonic/InsImageInfo
- /admin-api/tblist/patientexamlist/addPatientExamInfo
- /admin-api/tblist/patientexamlist/GetAnalysisInfo
- /admin-api/system/jwtToken/getToken
- /admin-api/applyregistration/applyform/GetPatientPDFDcm
- /admin-api/ultrasoniccom/ultrasonic/ftpimage
ignore-tables:
- system_tenant
@ -257,7 +253,6 @@ yudao:
- rep_demo_jianpiao
- tmp_report_data_1
- tmp_report_data_income
- tb_patientexamlist
sms-code: # 短信验证码相关的配置项
expire-times: 10m
send-frequency: 1m
@ -285,7 +280,4 @@ debug: false
jeecg:
jmreport:
saas-mode: tenant
#土贵乌拉 需要的配置 项目名称:/admin
server:
servlet:
context-path: /admin