|
@@ -264,17 +264,10 @@ public class CommonLogic {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- String uploadFileSuffix = "";
|
|
|
- String uploadFileName = "";
|
|
|
- if (StringUtils.isNotBlank(file.getOriginalFilename())) {
|
|
|
- String uploadFilePath = file.getOriginalFilename().replaceAll("\\\\", "/");
|
|
|
- uploadFileName = uploadFilePath.substring(
|
|
|
- uploadFilePath.lastIndexOf('/') + 1, uploadFilePath.lastIndexOf('.'));
|
|
|
- uploadFileSuffix = uploadFilePath.substring(uploadFilePath.lastIndexOf('.') + 1, uploadFilePath.length());
|
|
|
- } else {
|
|
|
- uploadFileName = "未定义";
|
|
|
- uploadFileSuffix = "png";
|
|
|
- }
|
|
|
+ String uploadFilePath = file.getOriginalFilename().replaceAll("\\\\", "/");
|
|
|
+ String uploadFileName = uploadFilePath.substring(
|
|
|
+ uploadFilePath.lastIndexOf('/') + 1, uploadFilePath.lastIndexOf('.'));
|
|
|
+ String uploadFileSuffix = uploadFilePath.substring(uploadFilePath.lastIndexOf('.') + 1, uploadFilePath.length());
|
|
|
if (StringUtils.isNotBlank(uploadFileSuffix) && uploadFileSuffix.equals("quicktime")) {
|
|
|
uploadFileSuffix = "mp4";
|
|
|
}
|
|
@@ -310,6 +303,53 @@ public class CommonLogic {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 上传确认书附件
|
|
|
+ *
|
|
|
+ * @param file
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public CommonFile uploadWorkerConfirmFile(MultipartFile file) throws IOException, RemoteServiceException {
|
|
|
+
|
|
|
+ if (file == null || file.isEmpty()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ String uploadFileName = "师傅确认书";
|
|
|
+ String uploadFileSuffix = "png";
|
|
|
+
|
|
|
+ long currentTime = System.currentTimeMillis();
|
|
|
+ BufferedOutputStream bufferedOutputStream = null;
|
|
|
+
|
|
|
+ //限制大小为10m
|
|
|
+ if (file.getSize() > 1024 * 1024 * 30) {
|
|
|
+ throw new RemoteServiceException("文件大小超出限制");
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ String filePath = ossUtil.getFilePath() + "/" + currentTime + UUID.randomUUID().toString() + "." + uploadFileSuffix;
|
|
|
+ if (!ossUtil.uploadFile(filePath, file.getBytes())) {
|
|
|
+ throw new RemoteServiceException("文件同步oss失败");
|
|
|
+ }
|
|
|
+ String ossUrl = ossUtil.getAccessUrl2() + filePath;
|
|
|
+
|
|
|
+ CommonFile commonFile = new CommonFile();
|
|
|
+ commonFile.setUrl(ossUrl);
|
|
|
+ commonFile.setName(uploadFileName);
|
|
|
+ commonFile.setFileType(uploadFileSuffix);
|
|
|
+ commonFile.setFileSize(BigDecimal.valueOf(file.getSize()));
|
|
|
+ commonFile.setCreateTime(new Date());
|
|
|
+ commonFileService.save(commonFile);
|
|
|
+ return commonFile;
|
|
|
+ } finally {
|
|
|
+ if (bufferedOutputStream != null) {
|
|
|
+ bufferedOutputStream.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 生成订单号
|
|
|
*
|
|
|
* @param start 前缀
|