whycxzp
2024-12-18 c27d774a5b0f123a551ea79929306d8cc92c885c
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.whyc.controller;
 
import com.whyc.dto.Response;
import com.whyc.pojo.ECR;
import com.whyc.service.ECRService;
import com.whyc.util.ActionUtil;
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 javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
 
/**
 * 设 计 工  程  变  更  申  请  调  查  表(ECR)
 */
@RestController
@Api(tags = "ecr")
@RequestMapping("ecr")
public class ECRController {
 
    @Autowired
    private ECRService service;
 
    @ApiOperation("excel导入ECR")
    @PostMapping("ecrImportByExcel")
    public Response ecrImportByExcel(@RequestPart 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.ecrImportByExcel(multipartFile);
        }
        return response;
    }
 
    @ApiOperation("手动输入")
    @PostMapping("ecrImport")
    public Response ecrImport(@RequestBody ECR ecr){
        return service.ecrImport(ecr);
    }
 
    @ApiOperation("分页查询ECR记录")
    @GetMapping("searchEcr")
    public Response searchEcr(@RequestParam(required = false) String number,
                              @RequestParam(required = false) String subCode,
                              @RequestParam(required = false) String subModel,
                              @RequestParam String createTime, @RequestParam String createTime1,
                              @RequestParam int pageCurr, @RequestParam int pageSize){
        Date testTime1= null;
        Date testTime2= null;
        try {
            testTime1 = ActionUtil.sdfwithALL.parse(createTime);
            testTime2 = ActionUtil.sdfwithALL.parse(createTime1);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return service.searchEcr(number,subCode,subModel,testTime1,testTime2,pageCurr,pageSize);
    }
 
    @ApiOperation("导出记录")
    @GetMapping("exportExcel")
    public void exportExcel(HttpServletResponse response,@RequestParam(required = false) List<Integer> ids){
        service.exportExcel(response,ids);
    }
 
    @ApiOperation("删除ECR记录")
    @GetMapping("deleteEcr")
    public Response deleteEcr( @RequestParam String number,
                               @RequestParam(required = false) String filePath){
        return service.deleteEcr(number,filePath);
    }
    @ApiOperation("反馈下拉查询ECR记录")
    @GetMapping("searchEcrInFeedback")
    public Response searchEcrInFeedback(){
        return service.searchEcrInFeedback();
    }
 
}