whycxzp
2023-07-27 2cd3c864603eaba1fc19b19a6e70d02e1665b184
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
package com.whyc.controller;
 
import com.whyc.dto.Response;
import com.whyc.dto.StandardFeatureCurve;
import com.whyc.service.StandardFeatureCurveService;
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;
 
@Api(tags = "标准特性曲线")
@RestController
@RequestMapping("standardFeatureCurve")
public class StandardFeatureCurveController {
 
    @Autowired
    private StandardFeatureCurveService service;
 
    @ApiOperation("查询指定VA/C的数据")
    @GetMapping("list")
    public Response<List<StandardFeatureCurve>> getList(@RequestParam String va,@RequestParam String c){
        List<StandardFeatureCurve> list = service.getList(va,c);
        if(list == null){
            return new Response().set(1,false);
        }
        return new Response().setII(1,true,list,null);
    }
 
    @ApiOperation("数据导入")
    @PostMapping("excelImport")
    public Response excelImport(@RequestParam 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{
            service.excelImport(file.getInputStream());
            response.set(1,true,"数据导入完成");
        }
        return response;
    }
 
}