|
@@ -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();
|
|
|
//根据配置id获得配置
|
|
@@ -43,7 +43,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;
|
|
@@ -59,9 +59,9 @@ 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);
|
|
@@ -80,6 +80,7 @@ public class FileFactoryService {
|
|
|
|
|
|
/**
|
|
|
* 下载文件
|
|
|
+ *
|
|
|
* @param downloadSysFileDTO
|
|
|
* @throws Exception
|
|
|
*/
|
|
@@ -100,16 +101,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();
|
|
|
//存在本地的路径,随机生成
|
|
@@ -118,34 +120,34 @@ public class FileFactoryService {
|
|
|
byte[] fileData = SftpService.download(directory, downloadFile, configSettingVO);
|
|
|
return fileData;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 删除文件
|
|
|
*
|
|
|
* @param filePath
|
|
|
- * @param sourceId
|
|
|
+ * @param pType
|
|
|
*/
|
|
|
- public static void delete(String filePath, Integer sourceId){
|
|
|
+ public static void delete(String filePath, Integer pType) {
|
|
|
//调用解析配置方法,获取配置信息
|
|
|
List<ConfigSettingVO> configSettingVOS = ExcuteConfigUtils.excuteConfigVO();
|
|
|
- ConfigSettingVO configSettingVO = configSettingVOS.stream().filter(item -> item.getSourceId().equals(sourceId)).findFirst().orElse(null);
|
|
|
+ ConfigSettingVO configSettingVO = configSettingVOS.stream().filter(item -> item.getId().equals(pType)).findFirst().orElse(null);
|
|
|
//根据传入类型判断从哪里删除数据
|
|
|
//如果为1,则为服务器
|
|
|
- if(sourceId.equals(1)){
|
|
|
- //拆分路径字符串
|
|
|
- int index = filePath.lastIndexOf('/');
|
|
|
- //要删除文件所在目录
|
|
|
- String directory = filePath.substring(0, index);
|
|
|
- //要删除的文件
|
|
|
- String deleteFile = filePath.substring(index + 1, filePath.length());
|
|
|
- try {
|
|
|
- SftpService.delete(directory, deleteFile, configSettingVO);
|
|
|
- } catch (Exception e) {
|
|
|
- throw new XiaoShiException("删除错误");
|
|
|
- }
|
|
|
- } else if(sourceId.equals(2)){//类型为2,则为阿里云OSS
|
|
|
+ //if(sourceId.equals(1)){
|
|
|
+ //拆分路径字符串
|
|
|
+ int index = filePath.lastIndexOf('/');
|
|
|
+ //要删除文件所在目录
|
|
|
+ String directory = filePath.substring(0, index);
|
|
|
+ //要删除的文件
|
|
|
+ String deleteFile = filePath.substring(index + 1, filePath.length());
|
|
|
+ try {
|
|
|
+ SftpService.delete(directory, deleteFile, configSettingVO);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException("删除错误");
|
|
|
}
|
|
|
+ //} else if(sourceId.equals(2)){//类型为2,则为阿里云OSS
|
|
|
+ //}
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|