From e225cf92218ab1a8bc0eac03920f8a84437cfcee Mon Sep 17 00:00:00 2001 From: wuweida <2918581207@qq.com> Date: Thu, 18 Aug 2022 14:46:38 +0800 Subject: [PATCH] 1 --- .../controller/BuildingController.java | 13 ++++++++----- .../monitormanage/mapper/BuildingRecordsMapper.java | 4 ++-- .../service/BuildingRecordsService.java | 7 ++++--- src/main/resources/mapper/BuildingRecordsMapper.xml | 10 +++++++--- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/hisense/monitormanage/controller/BuildingController.java b/src/main/java/com/hisense/monitormanage/controller/BuildingController.java index f09c5c4..320e1c1 100644 --- a/src/main/java/com/hisense/monitormanage/controller/BuildingController.java +++ b/src/main/java/com/hisense/monitormanage/controller/BuildingController.java @@ -135,10 +135,12 @@ public class BuildingController { @ApiOperation("查询工地扬尘事件") @ApiImplicitParams({ @ApiImplicitParam(name = "page", value = "页码", required = true, dataType = "Integer"), - @ApiImplicitParam(name = "pageSize", value = "页码大小", required = true, dataType = "Integer") + @ApiImplicitParam(name = "pageSize", value = "页码大小", required = true, dataType = "Integer"), + @ApiImplicitParam(name = "startTime",value = "开始时间",required = false,dataType = "String"), + @ApiImplicitParam(name = "endTime",value = "结束时间",required = false,dataType = "String") }) - public Result selectRaise(Integer page,Integer pageSize){ - List records = buildingRecordsMapper.selectRaise(page,pageSize); + public Result selectRaise(Integer page,Integer pageSize,String startTime,String endTime){ + List records = buildingRecordsMapper.selectRaise(page,pageSize,startTime,endTime); Integer integer = buildingRecordsMapper.selectCountRaise(); Map map = new HashMap<>(); map.put("sum",integer); @@ -291,8 +293,9 @@ public class BuildingController { } @GetMapping("exportEvent") - public void exportRaiseEvent() throws Exception { - buildingRecordsService.testHSSF(); + public String exportRaiseEvent(String startTime,String endTime) throws Exception { + buildingRecordsService.testHSSF(startTime,endTime); + return "导出成功"; } /** diff --git a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java index 893fa40..edba956 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java @@ -37,13 +37,13 @@ public interface BuildingRecordsMapper extends BaseMapper { List selectMonthPmAndNoice(@Param("buildLicense") String buildLicense); - List selectRaise(@Param("page") Integer page,@Param("pageSize") Integer pageSize); + List selectRaise(@Param("page") Integer page,@Param("pageSize") Integer pageSize,@Param("startTime")String startTime,@Param("endTime") String endTime); List selectNoiceEvent(@Param("page") Integer page,@Param("pageSize") Integer pageSize); List selectByAllEvent(@Param("page") Integer page,@Param("pageSize") Integer pageSize); - @Select("select COUNT(*) from t_event te JOIN t_scene_event tse ON te.camera_name = tse.channel_name where te.track_event = 'START'") + @Select("select COUNT(*) from t_event te JOIN t_scene_event tse ON te.camera_name = tse.channel_name where te.track_event = 'START' and tse.scene_id = 1 ") Integer selectCountEvent(); @Select("select COUNT(*) from (select br.pm10 from t_building_records br JOIN t_building_new_site bs ON br.project_name = bs.gdmc where br.pm10 > 80) a ") diff --git a/src/main/java/com/hisense/monitormanage/service/BuildingRecordsService.java b/src/main/java/com/hisense/monitormanage/service/BuildingRecordsService.java index 54c303b..1ce952d 100644 --- a/src/main/java/com/hisense/monitormanage/service/BuildingRecordsService.java +++ b/src/main/java/com/hisense/monitormanage/service/BuildingRecordsService.java @@ -108,13 +108,14 @@ public class BuildingRecordsService { return list; } - public void testHSSF() throws Exception { + //导出excel表格 + public void testHSSF(String startTime,String endTime) throws Exception { // 1. 创建一个工作簿 HSSFWorkbook wb = new HSSFWorkbook(); // 2. 创建一个工作表 HSSFSheet sheet = wb.createSheet(); // 3. 获取数据库数据 - List buildingRecordsDtos = buildingRecordsMapper.selectRaise(null, null); + List buildingRecordsDtos = buildingRecordsMapper.selectRaise(null, null,startTime,endTime); for (int i = 0; i < buildingRecordsDtos.size(); i++) { // 4. 创建行 HSSFRow row = sheet.createRow(i); @@ -130,7 +131,7 @@ public class BuildingRecordsService { } } // 7.写文件 - FileOutputStream fos = new FileOutputStream("C:/Users/szkingdom/"+System.currentTimeMillis()+".xls"); + FileOutputStream fos = new FileOutputStream("D:/"+System.currentTimeMillis()+".xls"); // 8.关闭流 wb.write(fos); fos.close(); diff --git a/src/main/resources/mapper/BuildingRecordsMapper.xml b/src/main/resources/mapper/BuildingRecordsMapper.xml index 450c768..2db9f35 100644 --- a/src/main/resources/mapper/BuildingRecordsMapper.xml +++ b/src/main/resources/mapper/BuildingRecordsMapper.xml @@ -32,7 +32,11 @@ SELECT * FROM t_event te JOIN t_scene_event tse ON te.camera_name = tse.channel_name - WHERE te.track_event = 'START' + WHERE te.track_event = 'START' AND tse.scene_id = 1 AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) < DATE(te.capture_time)