whycxzp
2023-06-25 ca3c7bac6c32443d54b5d717d82c0f0761e2f625
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
package com.whyc.controller;
 
import com.whyc.dto.Response;
import com.whyc.dto.SopDto;
import com.whyc.pojo.SOP;
import com.whyc.service.SOPService;
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.text.ParseException;
import java.util.List;
 
@RequestMapping("sop")
@RestController
@Api(tags = "SOP")
public class SOPController {
 
    @Autowired
    private SOPService service;
 
    @ApiOperation("excel解析")
    @PostMapping("excelParse")
    public Response excelParse(@RequestParam MultipartFile multipartFile) throws IOException, InvalidFormatException, ParseException {
        Response<Object> response = new Response<>();
        String name=multipartFile.getOriginalFilename();
        assert name != null;
        if(!name.substring(name.length()-4).equals(".xls") && !name.substring(name.length()-5).equals(".xlsx")){
            response.set(1,false,"文件解析错误:上传格式非excel格式");
        }else{
            response =  service.excelParse(multipartFile);
        }
        return response;
    }
 
    @ApiOperation("确定sop")
    @PostMapping("confirm")
    public Response add(@RequestBody SOP sop) throws IOException {
        return service.add(sop);
    }
 
    @ApiOperation("查询sop信息")
    @PostMapping("getSopInfo")
    public Response getSopInfo(@RequestBody(required = false) List<SopDto> list, @RequestParam(required = false) String code, @RequestParam(required = false) String model) {
        return service.getSopInfo(list,code,model);
    }
}