From a5ab06eee57b72ccb50a0f7754ff8c5cc6a2d5d9 Mon Sep 17 00:00:00 2001 From: wuweida <2918581207@qq.com> Date: Tue, 23 Aug 2022 13:55:17 +0800 Subject: [PATCH] 1 --- .../controller/QidiController.java | 21 ++++++++++++-- .../monitormanage/entity/SedimentTrail.java | 10 +++---- .../mapper/BuildingRecordsMapper.java | 18 ++++++------ .../mapper/BuildingSiteMapper.java | 4 +-- .../monitormanage/mapper/RoadDataMapper.java | 2 +- .../mapper/SedimentTrailMapper.java | 4 +++ .../service/SedimentTrailService.java | 14 ++-------- .../mapper/BuildingRecordsMapper.xml | 28 +++++++++---------- 8 files changed, 56 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/hisense/monitormanage/controller/QidiController.java b/src/main/java/com/hisense/monitormanage/controller/QidiController.java index 7a34059..1ddfe23 100644 --- a/src/main/java/com/hisense/monitormanage/controller/QidiController.java +++ b/src/main/java/com/hisense/monitormanage/controller/QidiController.java @@ -1,5 +1,6 @@ package com.hisense.monitormanage.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.hisense.monitormanage.dto.PassengerFlowDto; import com.hisense.monitormanage.dto.RoadDataDtos; import com.hisense.monitormanage.entity.*; @@ -55,6 +56,9 @@ public class QidiController { @Autowired private RoadDataMapper roadDataMapper; + @Autowired + private SedimentTrailMapper sedimentTrailMapper; + //道路统计数据与排名 @GetMapping("roadData") @ApiOperation("道路统计数据与排名,根据后台dt调用接口") @@ -141,10 +145,12 @@ public class QidiController { @RequestParam(value="start") String start, @RequestParam(value = "end") String end ){ - Map> map = sedimentTrailService.listSedimentTrailByPoints(longitude,latitude,radius,start,end); + List map = sedimentTrailService.listSedimentTrailByPoints(longitude,latitude,radius,start,end); return Result.success(map); } + + //测试获取最新的客流列表,从接口获取 @GetMapping("passengerFlow") @ApiOperation("获取最新的客流列表,测试接口,调用接口获取") @@ -268,6 +274,18 @@ public class QidiController { return success; } + /** + * 查询全部渣土车轨迹信息 + * @return + */ + @GetMapping("selectAllSedimentTrail") + @ApiOperation("查询全部渣土车轨迹信息") + public Result selectAllSedimentTrail(){ + List trailSanitations = sedimentTrailMapper.selectAllSedimentTrail(); + Result success = Result.success(trailSanitations); + return success; + } + //查询道路污染数据 //输入参考:2022-05-10 00:00:00,只能查询当前日期前一天及以前的 @GetMapping(value="listRoadData") @@ -341,5 +359,4 @@ public class QidiController { return success; } - } diff --git a/src/main/java/com/hisense/monitormanage/entity/SedimentTrail.java b/src/main/java/com/hisense/monitormanage/entity/SedimentTrail.java index 8dbd92e..90b508a 100644 --- a/src/main/java/com/hisense/monitormanage/entity/SedimentTrail.java +++ b/src/main/java/com/hisense/monitormanage/entity/SedimentTrail.java @@ -25,16 +25,16 @@ public class SedimentTrail{ @TableId private Integer id; - private double speed; + private String speed; private String simCardNum; @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") private LocalDateTime uploadtime; - private double coordinateX; + private String coordinateX; - private double coordinateY; + private String coordinateY; private double longitude; @@ -43,13 +43,13 @@ public class SedimentTrail{ @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") private LocalDateTime recordTime; - private double angle; + private String angle; @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") private LocalDateTime updateTime; private String status; - private double fuel; + private String fuel; } diff --git a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java index 824c145..5df5197 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java @@ -29,8 +29,7 @@ public interface BuildingRecordsMapper extends BaseMapper { void batchUpdate(@Param("list") List list); - @Select("select * from (SELECT bns.*,br.project_name,br.push_time,br.pm10,br.noice,br.build_license FROM t_building_records br JOIN t_building_new_site bns " + - "ON br.project_name = bns.gdmc ORDER BY br.push_time DESC LIMIT 93) bs LEFT JOIN t_channel_picture cp ON bs.channel_code = cp.channel_code") + @Select("select * from (select bs.sgwz,bs.jd,bs.wd,bs.ssdq,bs.yjsg,bs.channel_code,bs.channel_name,b.* from t_building_site bs LEFT JOIN (select a.*,br.appid,br.noice,br.pm10,br.project_name FROM t_building_records br JOIN (select build_license,MAX(push_time) AS push_time from t_building_records GROUP BY build_license) a ON br.build_license = a.build_license AND br.push_time = a.push_time) b ON bs.gdmc = b.project_name ) c LEFT JOIN t_channel_picture cp ON c.channel_code = cp.channel_code") List selectAllBuilding(); List selectWeekPmAndNoice(@Param("buildLicense") String buildLicense); @@ -46,26 +45,25 @@ public interface BuildingRecordsMapper extends BaseMapper { @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 ") + @Select("select COUNT(*) from (select br.pm10 from t_building_records br JOIN t_building_site bs ON br.project_name = bs.gdmc where br.pm10 > 80) a ") Integer selectCountRaise(); - @Select("SELECT COUNT(*) FROM (SELECT br.noice,br.push_time FROM t_building_records br JOIN t_building_new_site bs ON br.project_name = bs.gdmc WHERE (hour(br.push_time)>=22 or 6 > hour(br.push_time)) AND br.noice > 55 " + - "UNION SELECT br.noice,br.push_time FROM t_building_records br JOIN t_building_new_site bs ON br.project_name = bs.gdmc WHERE DATE_FORMAT(br.push_time,'%H')>=6 AND DATE_FORMAT(br.push_time,'%H')<=22 AND br.noice > 70) a") + @Select("SELECT COUNT(*) FROM (SELECT br.noice,br.push_time FROM t_building_records br JOIN t_building_site bs ON br.project_name = bs.gdmc WHERE (hour(br.push_time)>=22 or 6 > hour(br.push_time)) AND br.noice > 55 " + + "UNION SELECT br.noice,br.push_time FROM t_building_records br JOIN t_building_site bs ON br.project_name = bs.gdmc WHERE DATE_FORMAT(br.push_time,'%H')>=6 AND DATE_FORMAT(br.push_time,'%H')<=22 AND br.noice > 70) a") Integer selectCountNoice(); - @Select("select * from t_building_new_site bs JOIN (select a.*,br.appid,br.noice,br.pm10,br.project_name FROM t_building_records br JOIN (select build_license,MAX(push_time) AS push_time from t_building_records GROUP BY build_license) a ON br.build_license = a.build_license AND br.push_time = a.push_time) b on b.project_name = bs.gdmc where b.project_name like concat('%',#{projectName},'%') ORDER BY b.push_time DESC") + @Select("select * from t_building_site bs JOIN (select a.*,br.appid,br.noice,br.pm10,br.project_name FROM t_building_records br JOIN (select build_license,MAX(push_time) AS push_time from t_building_records GROUP BY build_license) a ON br.build_license = a.build_license AND br.push_time = a.push_time) b on b.project_name = bs.gdmc where b.project_name like concat('%',#{projectName},'%') ORDER BY b.push_time DESC") List selectByProjectName(String projectName); - @Select("select rns.*,cp.pic_url from (select bs.*,br.project_name,br.push_time,br.pm10,br.noice from (select * from t_building_records ORDER BY push_time DESC LIMIT 1639) br JOIN t_building_new_site bs on br.project_name = bs.gdmc where (bs.jd between #{jd} and #{jd1}) and (bs.wd between #{wd} and #{wd1} ) ORDER BY br.push_time DESC LIMIT 93) rns " + - "LEFT JOIN t_channel_picture cp ON rns.channel_code = cp.channel_code") + @Select("select * from t_building_site bs LEFT JOIN (select a.*,br.appid,br.noice,br.pm10,br.project_name FROM t_building_records br JOIN (select build_license,MAX(push_time) AS push_time from t_building_records GROUP BY build_license) a ON br.build_license = a.build_license AND br.push_time = a.push_time) b ON b.project_name = bs.gdmc WHERE (bs.jd between #{jd} and #{jd1}) and (bs.wd between #{wd} and #{wd1}") List selectByJdWd(@Param("jd") Double jd, @Param("jd1") Double jd1, @Param("wd") Double wd, @Param("wd1") Double wd1); - @Select("select * from t_building_records br JOIN t_building_new_site bs ON br.project_name = bs.gdmc where TO_DAYS(push_time) = TO_DAYS(NOW()) AND br.pm10 > 80") + @Select("select * from t_building_records br JOIN t_building_site bs ON br.project_name = bs.gdmc where TO_DAYS(push_time) = TO_DAYS(NOW()) AND br.pm10 > 80") List selectByDayRaise(); - @Select("SELECT a.* FROM (SELECT br.noice,br.push_time,br.project_name,bs.jd,bs.wd,bs.channel_name,bs.sgwz,bs.ssdq FROM t_building_records br JOIN t_building_new_site bs ON br.project_name = bs.gdmc WHERE (hour(br.push_time)>=22 or 6 > hour(br.push_time)) AND br.noice > 55 AND TO_DAYS(br.push_time) = TO_DAYS(NOW()) UNION SELECT br.noice,br.push_time,br.project_name,bs.jd,bs.wd,bs.channel_name,bs.sgwz,bs.ssdq FROM t_building_records br JOIN t_building_new_site bs ON br.project_name = bs.gdmc WHERE DATE_FORMAT(br.push_time,'%H')>=6 AND DATE_FORMAT(br.push_time,'%H') < 22 AND br.noice > 70 AND TO_DAYS(br.push_time) = TO_DAYS(NOW())) a") + @Select("SELECT a.* FROM (SELECT br.noice,br.push_time,br.project_name,bs.jd,bs.wd,bs.channel_name,bs.sgwz,bs.ssdq FROM t_building_records br JOIN t_building_site bs ON br.project_name = bs.gdmc WHERE (hour(br.push_time)>=22 or 6 > hour(br.push_time)) AND br.noice > 55 AND TO_DAYS(br.push_time) = TO_DAYS(NOW()) UNION SELECT br.noice,br.push_time,br.project_name,bs.jd,bs.wd,bs.channel_name,bs.sgwz,bs.ssdq FROM t_building_records br JOIN t_building_site bs ON br.project_name = bs.gdmc WHERE DATE_FORMAT(br.push_time,'%H')>=6 AND DATE_FORMAT(br.push_time,'%H') < 22 AND br.noice > 70 AND TO_DAYS(br.push_time) = TO_DAYS(NOW())) a") List selectByDayNoice(); @Select("select * from t_road_data where pm10 > 150 AND dt = #{dt}") diff --git a/src/main/java/com/hisense/monitormanage/mapper/BuildingSiteMapper.java b/src/main/java/com/hisense/monitormanage/mapper/BuildingSiteMapper.java index 904401a..5b91b47 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/BuildingSiteMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/BuildingSiteMapper.java @@ -17,9 +17,9 @@ import java.util.List; @Repository public interface BuildingSiteMapper extends BaseMapper { - @Select("select * from t_building_new_site") + @Select("select * from t_building_site") List selectBuildSite(); - @Select("select * from t_building_new_site where channel_code is not null") + @Select("select * from t_building_site where channel_code is not null") List selectByList(); } diff --git a/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java b/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java index 998d2a0..7951dd7 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java @@ -36,6 +36,6 @@ public interface RoadDataMapper extends BaseMapper { RoadData getByMaxId(); - @Select("select * from t_road_data where dt between #{begin} and #{over} and pm10 > 150 order by dt desc ") + @Select("select * from t_road_data where dt between #{begin} and #{over} and pm10 > 150 order by dt asc ") List listRoadDataByTimeRegion(@Param("begin") String begin, @Param("over") String over); } diff --git a/src/main/java/com/hisense/monitormanage/mapper/SedimentTrailMapper.java b/src/main/java/com/hisense/monitormanage/mapper/SedimentTrailMapper.java index f605c64..f2ff9ef 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/SedimentTrailMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/SedimentTrailMapper.java @@ -2,6 +2,7 @@ package com.hisense.monitormanage.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hisense.monitormanage.entity.SedimentTrail; +import org.apache.ibatis.annotations.Select; import org.springframework.stereotype.Repository; import java.util.List; @@ -19,4 +20,7 @@ public interface SedimentTrailMapper extends BaseMapper { void batchaSave(List list); + @Select("select * from t_trail_sediment") + List selectAllSedimentTrail(); + } diff --git a/src/main/java/com/hisense/monitormanage/service/SedimentTrailService.java b/src/main/java/com/hisense/monitormanage/service/SedimentTrailService.java index 631b8a9..83252a0 100644 --- a/src/main/java/com/hisense/monitormanage/service/SedimentTrailService.java +++ b/src/main/java/com/hisense/monitormanage/service/SedimentTrailService.java @@ -51,20 +51,12 @@ public class SedimentTrailService { * @param longitude(经度) latitude(纬度) radius(米) start(时间) end(时间) * */ - public Map> listSedimentTrailByPoints(double longitude, double latitude, Integer radius,String start,String end){ + public List listSedimentTrailByPoints(double longitude, double latitude, Integer radius,String start,String end){ double[] points = LongLatUtil.getAround(longitude,latitude,radius); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.between("update_time",start,end).between("longitude",points[0],points[2]).between("latitude",points[1],points[3]) .orderByAsc("sim_card_num","record_time"); - List maps = new ArrayList<>(); - Map> map = new HashMap<>(); - try{ - List list = sedimentTrailMapper.selectList(wrapper); - map = list.stream().collect(Collectors.groupingBy(SedimentTrail::getSimCardNum)); - - }catch (Exception e){ - log.error("[listSedimentTrailByPoints] Exception:",e.getMessage()); - } - return map; + List list = sedimentTrailMapper.selectList(wrapper); + return list; } } diff --git a/src/main/resources/mapper/BuildingRecordsMapper.xml b/src/main/resources/mapper/BuildingRecordsMapper.xml index ff4debe..899de4d 100644 --- a/src/main/resources/mapper/BuildingRecordsMapper.xml +++ b/src/main/resources/mapper/BuildingRecordsMapper.xml @@ -34,7 +34,7 @@ SELECT * FROM (SELECT br.project_name,br.build_license,br.noice,br.pm10,br.push_time,bs.channel_code, bs.channel_name,bs.jd,bs.wd,bs.ssdq,bs.yjsg,bs.sgwz FROM t_building_records br - JOIN t_building_new_site bs + JOIN t_building_site bs ON br.project_name = bs.gdmc WHERE br.pm10 > 80 ) ss LEFT JOIN t_channel_picture cp ON ss.channel_code = cp.channel_code ORDER BY ss.push_time DESC @@ -48,11 +48,11 @@ SELECT * FROM (SELECT a.* FROM (SELECT br.noice,br.push_time,br.project_name,bs.jd,bs.wd,bs.channel_name,bs.sgwz,bs.ssdq,bs.channel_code FROM - t_building_records br JOIN t_building_new_site bs ON br.project_name = bs.gdmc + t_building_records br JOIN t_building_site bs ON br.project_name = bs.gdmc WHERE (HOUR(br.push_time)>=22 OR 6 > HOUR(br.push_time)) AND br.noice > 55 UNION SELECT br.noice,br.push_time,br.project_name,bs.jd,bs.wd,bs.channel_name,bs.sgwz,bs.ssdq,bs.channel_code FROM - t_building_records br JOIN t_building_new_site bs ON br.project_name = bs.gdmc + t_building_records br JOIN t_building_site bs ON br.project_name = bs.gdmc WHERE DATE_FORMAT(br.push_time,'%H')>=6 AND DATE_FORMAT(br.push_time,'%H') < 22 AND br.noice > 70) a ORDER BY a.push_time DESC) b LEFT JOIN t_channel_picture cp ON b.channel_code = cp.channel_code @@ -91,7 +91,7 @@ ) a LEFT JOIN ( SELECT DATE_FORMAT(br.push_time,'%Y%-%m-%d') pushTime,ROUND(AVG(br.pm10)) pm10,ROUND(AVG(br.noice)) noice - FROM t_building_records br JOIN t_building_new_site bns ON br.project_name = bns.gdmc + FROM t_building_records br JOIN t_building_site bns ON br.project_name = bns.gdmc WHERE br.build_license = #{buildLicense} AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) < DATE(br.push_time) GROUP BY pushTime) b ON a.pushTime = b.pushTime ORDER BY a.pushTime @@ -162,7 +162,7 @@ ) a LEFT JOIN ( SELECT DATE_FORMAT(br.push_time,'%Y%-%m-%d') pushTime,ROUND(AVG(br.pm10)) pm10,ROUND(AVG(br.noice)) noice - FROM t_building_records br JOIN t_building_new_site bns ON br.project_name = bns.gdmc + FROM t_building_records br JOIN t_building_site bns ON br.project_name = bns.gdmc WHERE br.build_license = #{buildLicense} AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) < DATE(br.push_time) GROUP BY pushTime) b ON a.pushTime = b.pushTime ORDER BY a.pushTime @@ -171,13 +171,13 @@ @@ -185,27 +185,27 @@ @@ -287,18 +287,18 @@ LEFT JOIN ( SELECT DATE_FORMAT(a.push_time,'%Y%-%m-%d') AS pushTime,COUNT(*) AS number FROM( SELECT br.noice,br.push_time,br.project_name,bs.jd,bs.wd,bs.channel_name,bs.sgwz,bs.ssdq - FROM t_building_records br JOIN t_building_new_site bs + FROM t_building_records br JOIN t_building_site bs ON br.project_name = bs.gdmc WHERE br.pm10 > 80 AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= DATE(br.push_time) UNION SELECT br.noice,br.push_time,br.project_name,bs.jd,bs.wd,bs.channel_name,bs.sgwz,bs.ssdq - FROM t_building_records br JOIN t_building_new_site bs + FROM t_building_records br JOIN t_building_site bs ON br.project_name = bs.gdmc WHERE (HOUR(br.push_time)>=22 OR 6 > HOUR(br.push_time)) AND br.noice > 55 AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= DATE(br.push_time) UNION SELECT br.noice,br.push_time,br.project_name,bs.jd,bs.wd,bs.channel_name,bs.sgwz,bs.ssdq - FROM t_building_records br JOIN t_building_new_site bs + FROM t_building_records br JOIN t_building_site bs ON br.project_name = bs.gdmc WHERE DATE_FORMAT(br.push_time,'%H')>=6 AND DATE_FORMAT(br.push_time,'%H') < 22 AND br.noice > 70 AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= DATE(br.push_time)