From e541fba4a02f50b1737805e00c0bc868297cebbe Mon Sep 17 00:00:00 2001
From: wuweida <2918581207@qq.com>
Date: Wed, 17 Aug 2022 13:51:03 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=9C=B0=E6=8E=A5=E5=8F=A3=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=E8=BF=917=E5=A4=A9=E8=BF=9130=E5=A4=A9=E6=89=AC?=
=?UTF-8?q?=E5=B0=98=20=E5=99=AA=E5=A3=B0=20=E5=92=8C=E8=A7=86=E9=A2=91?=
=?UTF-8?q?=E6=84=9F=E7=9F=A5=E4=BA=8B=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 11 ++
.../controller/BuildingController.java | 102 ++++++++++++++++++
.../monitormanage/dto/BuildingRecordsDto.java | 17 +++
.../mapper/BuildingRecordsMapper.java | 12 +++
.../service/BuildingRecordsService.java | 102 ++++++++++++------
.../mapper/BuildingRecordsMapper.xml | 76 +++++++++++--
6 files changed, 279 insertions(+), 41 deletions(-)
diff --git a/pom.xml b/pom.xml
index 36b7293..ed787f8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -123,6 +123,17 @@
1.9.2
+
+ org.apache.poi
+ poi-ooxml
+ 3.11
+
+
+
+ com.alibaba
+ easyexcel
+ 2.2.6
+
diff --git a/src/main/java/com/hisense/monitormanage/controller/BuildingController.java b/src/main/java/com/hisense/monitormanage/controller/BuildingController.java
index faafb9b..cd8dd5b 100644
--- a/src/main/java/com/hisense/monitormanage/controller/BuildingController.java
+++ b/src/main/java/com/hisense/monitormanage/controller/BuildingController.java
@@ -286,5 +286,107 @@ public class BuildingController {
return success;
}
+ /*@GetMapping("exportEvent")
+ public void exportRaiseEvent() throws Exception {
+ buildingRecordsService.testHSSF();
+ }*/
+
+ /**
+ * 查询近7天噪声事件
+ * @return
+ */
+ @GetMapping("selectByWeekNoice")
+ @ApiOperation("查询近7天噪声事件")
+ public Result selectByWeekNoice(){
+ List buildingRecordsDtos = buildingRecordsMapper.selectByWeekNoice();
+ Map map = new HashMap<>();
+ map.put("sum",buildingRecordsDtos.size());
+ map.put("data",buildingRecordsDtos);
+ Result success = Result.success(map);
+ return success;
+ }
+
+ /**
+ * 查询近30天噪声事件
+ * @return
+ */
+ @GetMapping("selectByMonthNoice")
+ @ApiOperation("查询近30天噪声事件")
+ public Result selectByMonthNoice(){
+ List buildingRecordsDtos = buildingRecordsMapper.selectByMonthNoice();
+ Map map = new HashMap<>();
+ map.put("sum",buildingRecordsDtos.size());
+ map.put("data",buildingRecordsDtos);
+ Result success = Result.success(map);
+ return success;
+ }
+
+ /**
+ * 查询近7天扬尘事件
+ * @return
+ */
+ @GetMapping("selectByWeekNaise")
+ @ApiOperation("查询近7天扬尘事件")
+ public Result selectByWeekNaise(){
+ List buildingRecordsDtos = buildingRecordsMapper.selectByWeekNaise();
+ Map map = new HashMap<>();
+ map.put("sum",buildingRecordsDtos.size());
+ map.put("data",buildingRecordsDtos);
+ Result success = Result.success(map);
+ return success;
+ }
+
+ /**
+ * 查询近30天扬尘事件
+ * @return
+ */
+ @GetMapping("selectByMonthNaise")
+ @ApiOperation("查询近30天扬尘事件")
+ public Result selectByMonthNaise(){
+ List buildingRecordsDtos = buildingRecordsMapper.selectByMonthNaise();
+ Map map = new HashMap<>();
+ map.put("sum",buildingRecordsDtos.size());
+ map.put("data",buildingRecordsDtos);
+ Result success = Result.success(map);
+ return success;
+ }
+
+ /**
+ * 查询近7天工地视频感知事件
+ * @return
+ */
+ @GetMapping("selectByWeekEvent")
+ @ApiOperation("查询近7天工地视频感知事件")
+ public Result selectByWeekEvent(){
+ List events = buildingRecordsMapper.selectByWeekEvent();
+ events.forEach(eventDto -> {
+ eventDto.setEventNewName(eventDto.getEventCnName());
+ });
+ Map map = new HashMap<>();
+ map.put("sum",events.size());
+ map.put("data",events);
+ Result success = Result.success(map);
+ return success;
+ }
+
+ /**
+ * 查询近30天工地视频感知事件
+ * @return
+ */
+ @GetMapping("selectByMonthEvent")
+ @ApiOperation("查询近30天工地视频感知事件")
+ public Result selectByMonthEvent(){
+ List events = buildingRecordsMapper.selectByMonthEvent();
+ events.forEach(eventDto -> {
+ eventDto.setEventNewName(eventDto.getEventCnName());
+ });
+ Map map = new HashMap<>();
+ map.put("sum",events.size());
+ map.put("data",events);
+ Result success = Result.success(map);
+ return success;
+ }
+
+
}
diff --git a/src/main/java/com/hisense/monitormanage/dto/BuildingRecordsDto.java b/src/main/java/com/hisense/monitormanage/dto/BuildingRecordsDto.java
index a8c6d36..b1d4191 100644
--- a/src/main/java/com/hisense/monitormanage/dto/BuildingRecordsDto.java
+++ b/src/main/java/com/hisense/monitormanage/dto/BuildingRecordsDto.java
@@ -1,36 +1,53 @@
package com.hisense.monitormanage.dto;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
@Data
public class BuildingRecordsDto {
+ @ExcelProperty(value = {"工地名称"},index = 0)
private String projectName;//工地名称
+ @ExcelProperty(value = {"建筑编号"},index = 1)
private String buildLicense;//建筑编号
+ @ExcelProperty(value = {"推送时间"},index = 2)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private String pushTime;//推送时间
+ @ExcelProperty(value = {"appid"},index = 3)
private String appid;
+ @ExcelProperty(value = {"施工位置"},index = 4)
private String sgwz;//施工位置
+ @ExcelProperty(value = {"经度"},index = 5)
private double jd;//经度
+ @ExcelProperty(value = {"纬度"},index = 6)
private double wd;//纬度
+ @ExcelProperty(value = {"所属区域"},index = 7)
private String ssdq;//所属区域
+ @ExcelProperty(value = {"扬尘"},index = 8)
private double pm10;//扬尘
+ @ExcelProperty(value = {"噪声"},index = 9)
private double noice;//噪声
+ @ExcelProperty(value = {"夜间施工"},index = 10)
private String yjsg;//夜间施工
+ @ExcelProperty(value = {"图片路径"},index = 11)
private String picUrl;//图片路径
+ @ExcelProperty(value = {"摄像头编号"},index = 12)
private String channelCode;//摄像头编号
+ @ExcelProperty(value = {"摄像头名称"},index = 13)
private String channelName;//摄像头名称
}
diff --git a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java
index 49c79ea..a0f55af 100644
--- a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java
+++ b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java
@@ -74,4 +74,16 @@ public interface BuildingRecordsMapper extends BaseMapper {
@Select("select * from t_event te JOIN t_scene_event tse ON te.camera_name = tse.channel_name where te.track_event = 'START' AND TO_DAYS(te.capture_time) = TO_DAYS(NOW())")
List selectByEvent();
+ List selectByWeekNoice();
+
+ List selectByMonthNoice();
+
+ List selectByWeekNaise();
+
+ List selectByMonthNaise();
+
+ List selectByWeekEvent();
+
+ List selectByMonthEvent();
+
}
diff --git a/src/main/java/com/hisense/monitormanage/service/BuildingRecordsService.java b/src/main/java/com/hisense/monitormanage/service/BuildingRecordsService.java
index cb2c9a6..54c303b 100644
--- a/src/main/java/com/hisense/monitormanage/service/BuildingRecordsService.java
+++ b/src/main/java/com/hisense/monitormanage/service/BuildingRecordsService.java
@@ -4,19 +4,23 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
+import com.hisense.monitormanage.dto.BuildingRecordsDto;
import com.hisense.monitormanage.entity.BuildingRecords;
import com.hisense.monitormanage.mapper.BuildingRecordsMapper;
import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.io.FileOutputStream;
+import java.lang.reflect.Field;
+import java.util.*;
/**
* @author admin
@@ -35,72 +39,100 @@ public class BuildingRecordsService {
@Autowired
private RestTemplate restTemplate;
- public List