| | |
| | | package com.ard.web.controller.inspection; |
| | | |
| | | import com.ard.common.annotation.Log; |
| | | import com.ard.common.core.controller.BaseController; |
| | | import io.lettuce.core.dynamic.annotation.Value; |
| | | import com.ard.common.core.domain.AjaxResult; |
| | | import com.ard.common.enums.BusinessType; |
| | | import com.ard.inspection.domain.UploadFileEntity; |
| | | import com.ard.inspection.service.IBigFileUploadService; |
| | | import com.ard.inspection.utils.ZipFileUtils; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * @author xia |
| | | */ |
| | | @Api(tags = "大文件上传") |
| | | @RestController |
| | | @RequestMapping("/inspection/bigfile") |
| | | @Slf4j |
| | | public class BigFileUploadController extends BaseController { |
| | | |
| | | /** 若依文件上传根目录(从配置文件读取) */ |
| | | //@Value("${ruoyi.profile}") |
| | | private String uploadRootDir; |
| | | @Autowired |
| | | private IBigFileUploadService bigFileUploadService; |
| | | |
| | | @Value(value = "${inspection.profile}") |
| | | private String uploadPath; |
| | | |
| | | @Value(value = "${inspection.chunk.path}") |
| | | private String chunkPath; |
| | | |
| | | @Value(value = "${inspection.chunk.zipPath}") |
| | | private String zipPath; |
| | | |
| | | /** |
| | | * 检查分片是否存在 |
| | | */ |
| | | @ApiOperation("检查分片是否存在") |
| | | @GetMapping("/bigfile/{fileMd5}") |
| | | public AjaxResult checkChunk(@PathVariable String fileMd5) { |
| | | Map<String, Object> result = bigFileUploadService.checkChunk(fileMd5,chunkPath); |
| | | return AjaxResult.success(result); |
| | | } |
| | | |
| | | /** |
| | | * 上传分片 |
| | | */ |
| | | @ApiOperation("上传分片") |
| | | @PostMapping("/bigfile/chunk") |
| | | public AjaxResult uploadChunk(@RequestBody UploadFileEntity uploadFileEntity, |
| | | @RequestParam("file") MultipartFile file) { |
| | | // public AjaxResult uploadChunk(@RequestParam("file") MultipartFile file, |
| | | // @RequestParam("chunkNumber") Integer chunkNumber, |
| | | // @RequestParam("fileMd5") String fileMd5) { |
| | | Map<String, Object> result = bigFileUploadService.uploadChunk(file,uploadFileEntity,chunkPath); |
| | | return AjaxResult.success(result); |
| | | } |
| | | |
| | | /** |
| | | * 合并切片 |
| | | */ |
| | | @ApiOperation("合并分片") |
| | | @Log(title = "合并切片", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/bigfile/merge") |
| | | public AjaxResult mergeChunks(@RequestParam("md5") String md5, |
| | | @RequestParam("fileName") String fileName) { |
| | | Map<String, Object> result = bigFileUploadService.mergeChunks(md5, fileName, uploadPath); |
| | | return AjaxResult.success(result); |
| | | } |
| | | |
| | | /** |
| | | * 大文件上传并解压接口 |
| | | * @param file 上传的ZIP文件 |
| | | * @param overwrite 是否覆盖已存在文件(默认false) |
| | | * @return 上传结果 |
| | | */ |
| | | @ApiOperation("大文件上传并解压接口") |
| | | @Log(title = "大文件上传解压", businessType = BusinessType.INSERT) |
| | | @PostMapping("/upload/bigFileUnzip") |
| | | public AjaxResult uploadBigZipFile( |
| | | @RequestPart("file") MultipartFile file) { |
| | | //@RequestParam(value = "overwrite", defaultValue = "false") boolean overwrite) { |
| | | boolean overwrite = false; |
| | | return bigFileUploadService.uploadBigZipFile(file,overwrite,uploadPath,chunkPath,zipPath); |
| | | } |
| | | |
| | | } |