diff --git a/src/main/java/com/hisense/monitormanage/controller/QidiController.java b/src/main/java/com/hisense/monitormanage/controller/QidiController.java index de48274..7a34059 100644 --- a/src/main/java/com/hisense/monitormanage/controller/QidiController.java +++ b/src/main/java/com/hisense/monitormanage/controller/QidiController.java @@ -1,6 +1,7 @@ package com.hisense.monitormanage.controller; import com.hisense.monitormanage.dto.PassengerFlowDto; +import com.hisense.monitormanage.dto.RoadDataDtos; import com.hisense.monitormanage.entity.*; import com.hisense.monitormanage.mapper.*; import com.hisense.monitormanage.service.*; @@ -283,18 +284,15 @@ public class QidiController { @GetMapping(value="listRoadDataByTimeRegion") @ApiOperation("根据输入的日期间隔查询道路污染数据(例如:2022-05-10 00:00:00至2022-05-11 00:00:00)") @ApiImplicitParams({ - @ApiImplicitParam(name = "start", value = "开始日期", paramType = "query", dataType = "string", required = true), - @ApiImplicitParam(name = "end", value = "结束日期", paramType = "query", dataType = "string", required = true) + @ApiImplicitParam(name = "begin", value = "开始日期", paramType = "query", dataType = "string", required = true), + @ApiImplicitParam(name = "over", value = "结束日期", paramType = "query", dataType = "string", required = true) }) - public Result listRoadDataByTimeRegion( - @RequestParam(value="start") String start, - @RequestParam(value="end") String end - ){ - List roadData = roadDataService.listRoadDataByTimeRegion(start,end); - roadData.forEach(roadData1 -> { + public Result listRoadDataByTimeRegion(String begin, String over){ + List roadDataDtos = roadDataMapper.listRoadDataByTimeRegion(begin, over); + roadDataDtos.forEach(roadData1 -> { roadData1.setDt(roadData1.getDt().substring(0,10)); }); - return Result.success(roadData); + return Result.success(roadDataDtos); } /** diff --git a/src/main/java/com/hisense/monitormanage/dto/RoadDataDtos.java b/src/main/java/com/hisense/monitormanage/dto/RoadDataDtos.java new file mode 100644 index 0000000..60ef454 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/dto/RoadDataDtos.java @@ -0,0 +1,44 @@ +package com.hisense.monitormanage.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +@Data +public class RoadDataDtos { + private String regionName; + + private String streetName; + + private String roadName; + + private String start; + + private String end; + + private double lng; + + private double lat; + + private double pm10; + + private double pm25; + + private Integer descPm10Rank; + + private Integer ascPm10Rank; + + private Integer descPm25Rank; + + private Integer ascPm25Rank; + + private String points; + + @JsonFormat(pattern="yyyy-MM-dd mm:HH:ss",timezone = "GMT+8") + private String dt; + + @JsonFormat(pattern="yyyy-MM-dd mm:HH:ss",timezone = "GMT+8") + private String begin; + + @JsonFormat(pattern="yyyy-MM-dd mm:HH:ss",timezone = "GMT+8") + private String over; +} diff --git a/src/main/java/com/hisense/monitormanage/entity/BuildingSite.java b/src/main/java/com/hisense/monitormanage/entity/BuildingSite.java index d021d15..2ac055d 100644 --- a/src/main/java/com/hisense/monitormanage/entity/BuildingSite.java +++ b/src/main/java/com/hisense/monitormanage/entity/BuildingSite.java @@ -16,7 +16,7 @@ import lombok.NoArgsConstructor; @Data @AllArgsConstructor @NoArgsConstructor -@TableName("t_building_new_site") +@TableName("t_building_site") public class BuildingSite { @TableId diff --git a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java index edba956..824c145 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java @@ -53,8 +53,7 @@ public interface BuildingRecordsMapper extends BaseMapper { "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") Integer selectCountNoice(); - @Select("select br.*,bs.sgwz,bs.jd,bs.wd,bs.ssdq,bs.yjsg from t_building_records br JOIN t_building_new_site bs on br.project_name = bs.gdmc" + - " where br.project_name like concat('%',#{projectName},'%') ORDER BY br.push_time DESC LIMIT 1") + @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") 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 " + diff --git a/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java b/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java index 46fe71a..998d2a0 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/RoadDataMapper.java @@ -1,6 +1,7 @@ package com.hisense.monitormanage.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hisense.monitormanage.dto.RoadDataDtos; import com.hisense.monitormanage.entity.PassengerFlow; import com.hisense.monitormanage.entity.RoadData; import org.apache.ibatis.annotations.Param; @@ -34,4 +35,7 @@ public interface RoadDataMapper extends BaseMapper { Integer selectCountMonthRoadData(); RoadData getByMaxId(); + + @Select("select * from t_road_data where dt between #{begin} and #{over} and pm10 > 150 order by dt desc ") + List listRoadDataByTimeRegion(@Param("begin") String begin, @Param("over") String over); } diff --git a/src/main/java/com/hisense/monitormanage/service/RoadDataService.java b/src/main/java/com/hisense/monitormanage/service/RoadDataService.java index 15718df..a7a5a85 100644 --- a/src/main/java/com/hisense/monitormanage/service/RoadDataService.java +++ b/src/main/java/com/hisense/monitormanage/service/RoadDataService.java @@ -4,6 +4,7 @@ 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.RoadDataDtos; import com.hisense.monitormanage.entity.RoadData; import com.hisense.monitormanage.mapper.RoadDataMapper; import lombok.extern.slf4j.Slf4j; @@ -112,13 +113,6 @@ public class RoadDataService { return list; } - public List listRoadDataByTimeRegion(String start,String end){ - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.between("dt",start,end).gt("pm10",150); - List list = roadDataMapper.selectList(wrapper); - return list; - } - //获取当前日期的时间串,2022-05-08 00:00:00 private String dateTimeStr(){ LocalDate localDate = LocalDate.now(); diff --git a/src/main/resources/mapper/BuildingRecordsMapper.xml b/src/main/resources/mapper/BuildingRecordsMapper.xml index 2db9f35..ff4debe 100644 --- a/src/main/resources/mapper/BuildingRecordsMapper.xml +++ b/src/main/resources/mapper/BuildingRecordsMapper.xml @@ -31,12 +31,13 @@