This commit is contained in:
wuweida 2022-08-18 14:46:38 +08:00
parent dc9a7b0099
commit e225cf9221
4 changed files with 21 additions and 13 deletions

View File

@ -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<BuildingRecordsDto> records = buildingRecordsMapper.selectRaise(page,pageSize);
public Result selectRaise(Integer page,Integer pageSize,String startTime,String endTime){
List<BuildingRecordsDto> records = buildingRecordsMapper.selectRaise(page,pageSize,startTime,endTime);
Integer integer = buildingRecordsMapper.selectCountRaise();
Map<String,Object> 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 "导出成功";
}
/**

View File

@ -37,13 +37,13 @@ public interface BuildingRecordsMapper extends BaseMapper<BuildingRecords> {
List<BuildingRecordsDtos> selectMonthPmAndNoice(@Param("buildLicense") String buildLicense);
List<BuildingRecordsDto> selectRaise(@Param("page") Integer page,@Param("pageSize") Integer pageSize);
List<BuildingRecordsDto> selectRaise(@Param("page") Integer page,@Param("pageSize") Integer pageSize,@Param("startTime")String startTime,@Param("endTime") String endTime);
List<BuildingRecordsDto> selectNoiceEvent(@Param("page") Integer page,@Param("pageSize") Integer pageSize);
List<EventDto> 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 ")

View File

@ -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<BuildingRecordsDto> buildingRecordsDtos = buildingRecordsMapper.selectRaise(null, null);
List<BuildingRecordsDto> 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();

View File

@ -32,7 +32,11 @@
<select id="selectRaise" resultType="com.hisense.monitormanage.dto.BuildingRecordsDto">
SELECT * FROM t_building_records br JOIN t_building_new_site bs
ON br.project_name = bs.gdmc WHERE br.pm10 > 80 ORDER BY br.push_time DESC
ON br.project_name = bs.gdmc WHERE br.pm10 > 80
<if test="startTime !=null and '' != startTime and endTime != null and '' != endTime">
AND br.push_time BETWEEN 'startTime' AND 'endTime'
</if>
ORDER BY br.push_time DESC
<if test="page!=null and '' != page and pageSize != null and '' != pageSize">
<bind name="page" value="(page-1)*pageSize"/>
limit #{page},#{pageSize}
@ -205,13 +209,13 @@
<select id="selectByWeekEvent" resultType="com.hisense.monitormanage.dto.EventDto">
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) &lt; DATE(te.capture_time)
</select>
<select id="selectByMonthEvent" resultType="com.hisense.monitormanage.dto.EventDto">
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 30 DAY) &lt; DATE(te.capture_time)
</select>