whyclxw
2 天以前 12154b62b42df29173cdc54d7fd35d02d9a6422b
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
package com.whyc.controller;
 
import com.whyc.dto.Response;
import com.whyc.pojo.ProductBomApproving;
import com.whyc.service.ProductBomApprovingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import java.io.IOException;
import java.util.List;
 
/**
 * 产品bom审批
 */
@RestController
@RequestMapping("bomApproving")
@Api(tags = "工作流子表-产品bom审批表")
public class ProductBomApprovingController {
 
    @Autowired
    private ProductBomApprovingService service;
 
    /**
     * excel解析bom
     */
    @PostMapping("excelParse")
    @ApiOperation("excel解析")
    public Response excelParse(@RequestParam("file") MultipartFile file) throws IOException, InvalidFormatException {
        Response<Object> response = new Response<>();
        String name=file.getOriginalFilename();
        if(!name.substring(name.length()-4).equals(".xls") && !name.substring(name.length()-5).equals(".xlsx")){
            response.set(1,false,"文件解析错误");
        }else{
            List<ProductBomApproving> list = service.excelParse(file.getInputStream());
            response.setII(1,true,list,"文件解析成功");
        }
        return response;
    }
 
    @PostMapping("zipParse")
    @ApiOperation("zip解析")
    public Response zipParse(@RequestParam("file") MultipartFile file) throws IOException, InvalidFormatException {
        return service.zipParse(file);
    }
 
    @GetMapping("dwgReview")
    @ApiOperation("dwg文件预览")
    public Response dwgReview(@RequestParam String dwgUrl) throws IOException {
        return service.dwgReview(dwgUrl);
    }
 
}