|
|
|
@ -93,7 +93,11 @@ private FxfxdxService fxfxdxService; |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/uploadPDF") |
|
|
|
public ResponseEntity<String> uploadPdf(@RequestParam("file") MultipartFile file) { |
|
|
|
public ResponseEntity<String> uploadPdf( |
|
|
|
@RequestParam("file") MultipartFile file, |
|
|
|
@RequestParam("id") String id, |
|
|
|
@RequestParam("ticketNumber") String ticketNumber) { |
|
|
|
//上线
|
|
|
|
String uploadDir = "F://dataUpload/zypPdfs/"; |
|
|
|
// 1. 验证文件类型和大小
|
|
|
|
if (file.isEmpty()) { |
|
|
|
@ -105,6 +109,8 @@ private FxfxdxService fxfxdxService; |
|
|
|
if (file.getSize() > 10 * 1024 * 1024) { // 限制10MB
|
|
|
|
return ResponseEntity.badRequest().body("文件大小超过限制"); |
|
|
|
} |
|
|
|
System.out.println(id); |
|
|
|
System.out.println(ticketNumber); |
|
|
|
|
|
|
|
try { |
|
|
|
// 确保目录存在
|
|
|
|
@ -114,7 +120,7 @@ private FxfxdxService fxfxdxService; |
|
|
|
} |
|
|
|
|
|
|
|
// 生成唯一文件名(可选,避免重复覆盖)
|
|
|
|
String fileName = UUID.randomUUID() + "_" + file.getOriginalFilename(); |
|
|
|
String fileName = id+ "_" +ticketNumber+".pdf"; |
|
|
|
|
|
|
|
// 构建目标文件的绝对路径
|
|
|
|
File targetFile = new File(targetDir.getAbsolutePath() + File.separator + fileName); |
|
|
|
|