lxw
2023-02-13 5fbfb845497156b972153ab58a1f2ce91b5340e9
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package com.whyc.controller;
 
import com.whyc.fbo.FboData;
import com.whyc.fbo.FboDataHeadStart;
import com.whyc.fbo.FboDataHeadStop;
import com.whyc.fbo.FboDataInf;
import com.whyc.mcp.TestDataInfo;
import com.whyc.pojo.Response;
import com.whyc.res.RESDataInfo;
import com.whyc.service.ExcelExportService;
import com.whyc.service.FboDataInfService;
import com.whyc.service.RESDataInfoService;
import com.whyc.service.TestDataInfoService;
import com.whyc.util.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.xssf.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sun.misc.BASE64Decoder;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
 
@RestController
@Api(tags = "解析文件")
@RequestMapping("test")
public class TestController {
    @Autowired
    private FboDataInfService fboService;
 
    @Autowired
    private ExcelExportService exportService;
 
    @Autowired
    private RESDataInfoService resService;
 
    @Autowired
    private TestDataInfoService testDataInfoService;
 
    @GetMapping("/hello")
    public Response hello(){
        return new Response().set(1,"hello");
    }
 
    @GetMapping("/readFboFile")
    @ApiOperation(value = "根据文件后缀解析不同的文件")
    public Response readFboFile(@RequestParam String filePath){
        String suffix=filePath.substring(filePath.lastIndexOf(".")+1).toLowerCase(Locale.ROOT);
        Response response=new Response();
        switch (suffix){
            case "fbx":
                       FboDataInf fboDataInf = fboService.readFboFile(filePath);
                       response.set(1,fboDataInf,filePath);
                       break;
            case "bres":
                       RESDataInfo resDataInfo =resService.readFileData(filePath);
                       response.set(1,resDataInfo,filePath);
                       break;
            case "alm":response.set(1,filePath);
                       break;
            case "mcp":
                       TestDataInfo testDataInfoMcp=testDataInfoService.readFileData(filePath);
                       response.set(1,testDataInfoMcp,filePath);
                       break;
            case "mch":TestDataInfo testDataInfoMch=testDataInfoService.readFileData(filePath);
                       response.set(1,testDataInfoMch,filePath);
                       break;
            default:response.set(1,false,filePath);
        }
 
        return response;
    }
 
    @PostMapping("/export")
    @ApiOperation(value = "文件导出")
    public void export(HttpServletRequest req, HttpServletResponse resp ){
        String filePath = req.getParameter("filePath");
        String suffix=filePath.substring(filePath.lastIndexOf(".")+1).toLowerCase(Locale.ROOT);
        switch (suffix){
            case "fbx":exportService.exportFbx(req,resp);
                break;
            case "bres":exportService.exportBres(req,resp);
                break;
            /*case "alm":exportService.exportAlm(req,resp);
                break;
            case "mcp":exportService.exportMcp(req,resp);
                break;
            case "mch":exportService.exportMch(req,resp);
                break;*/
        }
    }
 
}