Xiajijian
2026-02-05 cf57e1900603305d12bf76b647234be0dcfce9fe
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
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 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;
 
    /**
     * 检查分片是否存在
     */
    @GetMapping("/chunks/{fileMd5}")
    public AjaxResult checkChunk(@PathVariable String fileMd5) {
        Map<String, Object> result = bigFileUploadService.checkChunk(fileMd5,chunkPath);
        return AjaxResult.success(result);
    }
 
    /**
     * 上传分片
     */
    @PostMapping("/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);
    }
 
    /**
     * 合并切片
     */
    @Log(title = "合并切片", businessType = BusinessType.IMPORT)
    @PostMapping("/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);
    }
 
}