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;*/
|
}
|
}
|
|
}
|