Browse Source

1、修改报表导出方法

develop
bobol 9 months ago
parent
commit
bc23e3fcfe
  1. 17
      lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiHisReportController.java

17
lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiHisReportController.java

@ -38,7 +38,6 @@ import java.util.stream.Collectors;
public class DcBusiHisReportController extends BaseController {
@Resource
private LogTimesacleHistoryThreeService logTimesacleHistoryThreeService;
/**
* 分页列表查询
*
@ -161,7 +160,6 @@ public class DcBusiHisReportController extends BaseController {
return AjaxResult.success(dataInfo);
}
}
private String validatorator(LogTimeThreeQueryParamVo queryVo) {
if (StringUtils.isNull(queryVo.getBeginTime())||StringUtils.isEmpty(queryVo.getBeginTime())) {
return "查询失败,开始时间不能为空!";
@ -174,7 +172,6 @@ public class DcBusiHisReportController extends BaseController {
}
return null;
}
///按时间 设备+参数 形成数据--时间分组
private List<Map<String, Object>> getMapList(List<LogTimescaleHistoryThreeVo> list, List<DcDymicReportHeaderVo> dcDymicReportHeaderVos) {
Map<String, List<LogTimescaleHistoryThreeVo>> collect = list.stream().collect(Collectors.groupingBy(LogTimescaleHistoryThreeVo::getTimeStampString));
@ -192,7 +189,6 @@ public class DcBusiHisReportController extends BaseController {
return map;
}).collect(Collectors.toList());
}
/// 设备+参数 形成数据--设备-参数分组
private List<Map<String, Object>> getMapListDevice(List<LogTimescaleHistoryThreeVo> list,List<DcDymicReportHeaderVo> dcDymicReportHeaderVos) {
Map<String, List<LogTimescaleHistoryThreeVo>> collect = list.stream().collect(Collectors.groupingBy(item->item.getDeviceUuid()+"_"+item.getParamCode()));
@ -221,7 +217,6 @@ public class DcBusiHisReportController extends BaseController {
List<Map<String, Object>> mapList=getExcellData(queryVo,2);
toExcel(response,mapList);
}
@ApiOperation("生产设备参数统计明细表导出功能-时间横向")
@PostMapping("/export2")
public void export2(HttpServletResponse response, LogTimeThreeQueryParamVo queryVo) throws IOException {
@ -230,7 +225,6 @@ public class DcBusiHisReportController extends BaseController {
toExcel(response,mapList);
}
//获取excel数据 1 excel设备参数为列模式 2 excel时间为列模式 3 浏览器设备参数为列模式
//注意 excel有最大列数显示255 ,超出列数会报错
private List<Map<String, Object>> getExcellData(LogTimeThreeQueryParamVo queryVo,int type){
@ -249,31 +243,26 @@ public class DcBusiHisReportController extends BaseController {
}
}
private void toExcel(HttpServletResponse response, List<Map<String, Object>> mapList) {
// String fileName = "report" + DateUtil.now() + ".xls";
private void toExcel(HttpServletResponse response,List<Map<String, Object>> mapList) throws IOException {
String fileName ="report"+DateUtil.now() + ".xls";
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.write(mapList, true);
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
//response.setHeader("Content-Disposition", "attachment;filename="+fileName);
try (ServletOutputStream out = response.getOutputStream()) {
ServletOutputStream out = response.getOutputStream();
writer.flush(out, true);
// 关闭writer,释放内存
writer.close();
//此处记得关闭输出Servlet流
IoUtil.close(out);
} catch (IOException e) {
e.printStackTrace();
}
}
@ApiOperation("获取生产IOT系统参数模版列表")
@GetMapping("/getParamClass")
public AjaxResult getParamClass(){
return AjaxResult.success(logTimesacleHistoryThreeService.selectParamModels()) ;
}
@ApiOperation("获取生产IOT系统设备列表")
@GetMapping("/getDevicie/{orgCode}")
public AjaxResult selectDevices(@PathVariable Long orgCode) {

Loading…
Cancel
Save