|
@@ -33,8 +33,8 @@ public class FileFactoryService {
|
|
|
* @param sourceId
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<SystemFileDTO> uploadFiles(List<MultipartFile> files, Integer sourceId){
|
|
|
- if(files != null && files.size() != 0) {
|
|
|
+ public List<SystemFileDTO> uploadFiles(List<MultipartFile> files, Integer sourceId) {
|
|
|
+ if (files != null && files.size() != 0) {
|
|
|
//调用解析配置方法,获取配置信息
|
|
|
List<ConfigSettingVO> configSettingVOS = ExcuteConfigUtils.excuteConfigVO();
|
|
|
ConfigSettingVO configSettingVO = configSettingVOS.stream().filter(item -> item.getSourceId().equals(sourceId)).findFirst().orElse(null);
|
|
@@ -42,7 +42,7 @@ public class FileFactoryService {
|
|
|
return null;
|
|
|
}
|
|
|
String sourceName = configSettingVO.getSourceName();
|
|
|
- if(sourceName.equals("FSS")) {
|
|
|
+ if (sourceName.equals("FSS")) {
|
|
|
return this.uploadToFSS(files, configSettingVO);
|
|
|
}
|
|
|
return null;
|
|
@@ -58,15 +58,15 @@ public class FileFactoryService {
|
|
|
* @param configSettingVO
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<SystemFileDTO> uploadToFSS(List<MultipartFile> files, ConfigSettingVO configSettingVO){
|
|
|
+ public List<SystemFileDTO> uploadToFSS(List<MultipartFile> files, ConfigSettingVO configSettingVO) {
|
|
|
List<SystemFileDTO> systemFileDTOS = new ArrayList<>();
|
|
|
- for(MultipartFile file:files){
|
|
|
+ for (MultipartFile file : files) {
|
|
|
try {
|
|
|
String directoryName = fileUtils.getDirectoryName();
|
|
|
SystemFileDTO systemFileDTO = SftpService.upload(configSettingVO.getFilePath() + directoryName, file, configSettingVO);
|
|
|
- systemFileDTO.setPType(0);
|
|
|
+ systemFileDTO.setPType(configSettingVO.getSourceId());
|
|
|
systemFileDTO.setOriginalName(file.getOriginalFilename());
|
|
|
- systemFileDTO.setFilePath("/file/" + directoryName + "/" + systemFileDTO.getFileName());
|
|
|
+ systemFileDTO.setFilePath(configSettingVO.getFilePath() + directoryName + "/" + systemFileDTO.getFileName());
|
|
|
systemFileDTOS.add(systemFileDTO);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -78,6 +78,7 @@ public class FileFactoryService {
|
|
|
|
|
|
/**
|
|
|
* 下载文件
|
|
|
+ *
|
|
|
* @param downloadSysFileDTO
|
|
|
* @throws Exception
|
|
|
*/
|
|
@@ -98,16 +99,17 @@ public class FileFactoryService {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * @param //directory 下载目录 根据SFTP设置的根目录来进行传输
|
|
|
+ * @param //directory 下载目录 根据SFTP设置的根目录来进行传输
|
|
|
* @param //downloadFile 下载的文件
|
|
|
- * @param //saveFile 存在本地的路径
|
|
|
+ * @param //saveFile 存在本地的路径
|
|
|
*/
|
|
|
public byte[] downloadFromFSS(DownloadSysFileDTO downloadSysFileDTO, ConfigSettingVO configSettingVO) throws Exception {
|
|
|
//下载目录,也是存储路径
|
|
|
String filePath = downloadSysFileDTO.getFilePath();
|
|
|
int index = filePath.lastIndexOf("/");
|
|
|
- String directory = filePath.substring(0,index);
|
|
|
+ String directory = filePath.substring(0, index);
|
|
|
//下载的文件,也就是文件名
|
|
|
String downloadFile = downloadSysFileDTO.getFileName();
|
|
|
//存在本地的路径,随机生成
|
|
@@ -116,18 +118,19 @@ public class FileFactoryService {
|
|
|
byte[] fileData = SftpService.download(directory, downloadFile, configSettingVO);
|
|
|
return fileData;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 删除文件
|
|
|
*
|
|
|
* @param filePath
|
|
|
* @param pType
|
|
|
*/
|
|
|
- public static void delete(String filePath, Integer pType){
|
|
|
+ public static void delete(String filePath, Integer pType) {
|
|
|
//调用解析配置方法,获取配置信息
|
|
|
List<ConfigSettingVO> configSettingVOS = ExcuteConfigUtils.excuteConfigVO();
|
|
|
//根据传入类型判断从哪里删除数据
|
|
|
//如果为1,则为服务器
|
|
|
- if(pType.equals(1)){
|
|
|
+ if (pType.equals(1)) {
|
|
|
int sourceId = 1;
|
|
|
ConfigSettingVO configSettingVO = configSettingVOS.stream().filter(item -> item.getSourceId().equals(sourceId)).findFirst().orElse(null);
|
|
|
//拆分路径字符串
|
|
@@ -141,12 +144,11 @@ public class FileFactoryService {
|
|
|
} catch (Exception e) {
|
|
|
throw new XiaoShiException("删除错误");
|
|
|
}
|
|
|
- } else if(pType.equals(2)){//类型为2,则为阿里云OSS
|
|
|
+ } else if (pType.equals(2)) {//类型为2,则为阿里云OSS
|
|
|
int sourceId = 2;
|
|
|
ConfigSettingVO configSettingVO = configSettingVOS.stream().filter(item -> item.getSourceId().equals(sourceId)).findFirst().orElse(null);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|