package com.whyc.controller;
|
|
import com.whyc.alarm.Fbs5100AlarmData;
|
import com.whyc.charge.Fbs5100ChargeData;
|
import com.whyc.charge.Fbs5100DisChargeData;
|
import com.whyc.pojo.Response;
|
import com.whyc.service.ExcelExportService;
|
import com.whyc.service.Fbs5100AlarmDataService;
|
import com.whyc.service.Fbs5100ChargeDataService;
|
import com.whyc.service.Fbs5100DisChargeDataService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.util.Locale;
|
|
@RestController
|
@Api(tags = "解析文件")
|
@RequestMapping("analysis")
|
public class AnalysisController {
|
@Autowired
|
private Fbs5100DisChargeDataService disChargeDataService;
|
|
@Autowired
|
private Fbs5100ChargeDataService chargeDataService;
|
|
@Autowired
|
private Fbs5100AlarmDataService alarmDataService;
|
|
@Autowired
|
private ExcelExportService exportService;
|
|
|
@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 "bcp"://放电数据
|
Fbs5100DisChargeData disChargeData = disChargeDataService.readFboFile(filePath);
|
response.set(1,disChargeData,filePath);
|
break;
|
case "chr"://充电数据
|
Fbs5100ChargeData chargeData=chargeDataService.readFileData(filePath);
|
response.set(1,chargeData,filePath);
|
break;
|
case "alm"://告警数据
|
Fbs5100AlarmData alarmData=alarmDataService.readFileData(filePath);
|
response.set(1,alarmData,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 "bcp":exportService.exportBcp(req,resp);
|
break;
|
case "chr":exportService.exportChr(req,resp);
|
break;
|
case "alm":exportService.exportAlm(req,resp);
|
break;
|
}*/
|
}
|
}
|