From bcd7202db10b9dc9600660230b0d8b39b6c68c6c Mon Sep 17 00:00:00 2001 From: lxw <810412026@qq.com> Date: 星期五, 10 二月 2023 10:53:43 +0800 Subject: [PATCH] 修改 --- src/main/java/com/whyc/controller/TestController.java | 41 +++++++++++++++++++++++++++-------------- 1 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/whyc/controller/TestController.java b/src/main/java/com/whyc/controller/TestController.java index a3212cd..7a68ff1 100644 --- a/src/main/java/com/whyc/controller/TestController.java +++ b/src/main/java/com/whyc/controller/TestController.java @@ -5,10 +5,13 @@ import com.whyc.fbo.FboDataHeadStop; import com.whyc.fbo.FboDataInf; import com.whyc.pojo.Response; +import com.whyc.service.FboDataInfService; 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; @@ -21,13 +24,14 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Locale; @RestController @Api(tags = "瑙f瀽鏂囦欢") @RequestMapping("test") public class TestController { - //@Autowired - //private FboDataInf fboDataInf; + @Autowired + private FboDataInfService service; @GetMapping("/hello") public Response hello(){ @@ -35,20 +39,30 @@ } @PostMapping("/readFboFile") + @ApiOperation(value = "鏍规嵁鏂囦欢鍚庣紑瑙f瀽涓嶅悓鐨勬枃浠�") public Response readFboFile(@RequestParam String filePath){ - //log.info("鎺ュ彛readFboFile寮�濮�"); - FboDataInf fboDataInf = new FboDataInf(); - //log.info("fboDataInf:"+fboDataInf); - // log.info("filePath:"+filePath); - //String filePath1 = java.net.URLDecoder.decode(filePath,"utf-8"); - fboDataInf.readFboFile(filePath); - // log.info(fboDataInf.fboData.toString()); - // log.info("璇诲彇缁撴潫"); -// fileUrl = filePath; - return new Response().set(1,fboDataInf,filePath); + String suffix=filePath.substring(filePath.lastIndexOf(".")+1).toLowerCase(Locale.ROOT); + Response response=new Response(); + switch (suffix){ + case "fbx":FboDataInf fboDataInf = service.readFboFile(filePath); + response.set(1,fboDataInf,filePath); + break; + case "bres":response.set(1,filePath); + break; + case "alm":response.set(1,filePath); + break; + case "mcp":response.set(1,filePath); + break; + case "mch":response.set(1,filePath); + break; + default:response.set(1,false,filePath); + } + + return response; } @PostMapping("/export") + @ApiOperation(value = "鏂囦欢瀵煎嚭") public void export(HttpServletRequest req, HttpServletResponse resp){ String curr_echart = req.getParameter("curr_echart"); //鐢垫睜鐢垫祦鎶樼嚎鍥� @@ -61,8 +75,7 @@ String filePath = req.getParameter("filePath"); - FboDataInf fboDataInf = new FboDataInf(); - fboDataInf.readFboFile(filePath); + FboDataInf fboDataInf=service.readFboFile(filePath); // if (fboDataInf==null){ // fboDataInf = new FboDataInf(); // if (filePath==null || "".equals(filePath)){ -- Gitblit v1.9.1