Xiajijian
2026-03-04 7b5d4c535ab770db4238389759c5e6a66ea7e661
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.ard.web.controller.inspection;
 
import com.ard.common.annotation.Log;
import com.ard.common.core.controller.BaseController;
import com.ard.common.core.domain.AjaxResult;
import com.ard.common.enums.BusinessType;
import com.ard.inspection.service.IBigFileUploadService;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import java.util.*;
 
/**
 * @author xia
 */
@Api(tags = "大文件上传")
@RestController
@RequestMapping("/inspection/bigfile")
@Slf4j
public class BigFileUploadController extends BaseController {
 
    @Autowired
    private IBigFileUploadService bigFileUploadService;
 
    @Value(value = "${inspection.profile}")
    private String uploadPath;
 
    @Value(value = "${inspection.chunk.path}")
    private String chunkPath;
 
    /**
     * 检查分片是否存在
     */
    @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(@RequestParam("file") MultipartFile file,
                                  @RequestParam("chunkNumber") Integer chunkNumber,
                                  @RequestParam("fileMd5") String fileMd5) {
        Map<String, Object> result = bigFileUploadService.uploadChunk(file, chunkNumber, fileMd5, 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);
    }
 
}