lxw
2023-02-10 bcd7202db10b9dc9600660230b0d8b39b6c68c6c
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 = "解析文件")
@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 = "根据文件后缀解析不同的文件")
    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)){