|
|
|
@ -99,7 +99,9 @@ public class DmsMobileController extends BaseController {
|
|
|
|
|
log.error("文件上传过程中发生未知错误: {}", originalFilename, e);
|
|
|
|
|
throw new ServiceException("文件上传过程中发生未知错误,请联系管理员。");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// 返回上传文件的URL列表
|
|
|
|
|
return fileUrls;
|
|
|
|
@ -192,41 +194,7 @@ public class DmsMobileController extends BaseController {
|
|
|
|
|
@RepeatSubmit
|
|
|
|
|
public R insertFaultInstsanceActivity(DmsBillsFaultInstanceBo dmsBillsFaultInstance,
|
|
|
|
|
List<MultipartFile> files) {
|
|
|
|
|
List<String> fileUrls = new ArrayList<>();
|
|
|
|
|
if(files!=null){
|
|
|
|
|
for (MultipartFile file : files) {
|
|
|
|
|
// 从 MultipartFile 中提取 RemoteFileService 所需的参数
|
|
|
|
|
String originalFilename = file.getOriginalFilename();
|
|
|
|
|
String contentType = file.getContentType();
|
|
|
|
|
byte[] fileBytes;
|
|
|
|
|
try {
|
|
|
|
|
fileBytes = file.getBytes();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
log.error("获取文件字节失败: {}", originalFilename, e);
|
|
|
|
|
return R.fail("文件获取失败,请重试。");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 'name' 参数在当前RemoteFileServiceImpl实现中并非强制决定最终文件名,
|
|
|
|
|
// 这里传入originalFilename以保持一致性或作为备用标识
|
|
|
|
|
RemoteFile sysFile = remoteFileService.upload(originalFilename, originalFilename, contentType, fileBytes);
|
|
|
|
|
if (sysFile != null && sysFile.getUrl() != null) {
|
|
|
|
|
fileUrls.add(sysFile.getUrl());
|
|
|
|
|
} else {
|
|
|
|
|
log.warn("文件上传成功但未返回URL或返回数据为空: {}", originalFilename);
|
|
|
|
|
// 可以选择返回失败,或继续处理其他文件
|
|
|
|
|
}
|
|
|
|
|
} catch (ServiceException e) {
|
|
|
|
|
log.error("文件上传服务异常: {}", originalFilename, e);
|
|
|
|
|
return R.fail("文件上传服务异常:" + e.getMessage());
|
|
|
|
|
} catch (Exception e) { // 捕获其他未知异常
|
|
|
|
|
log.error("文件上传过程中发生未知错误: {}", originalFilename, e);
|
|
|
|
|
return R.fail("文件上传过程中发生未知错误,请联系管理员。");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO:文件存储待测试
|
|
|
|
|
List<String> fileUrls = handleFileUploads(files);
|
|
|
|
|
dmsBillsFaultInstance.setFileUrls(fileUrls);
|
|
|
|
|
return R.ok(dmsBillsFaultInstanceService.insertByBo(dmsBillsFaultInstance));
|
|
|
|
|
}
|
|
|
|
|