From 1aaf4edd253217e216154f45a4745dee3e0a164f Mon Sep 17 00:00:00 2001 From: wuweida <2918581207@qq.com> Date: Fri, 1 Jul 2022 09:13:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E5=BB=BA=E7=AD=91=E7=BC=96?= =?UTF-8?q?=E5=8F=B7=E6=9F=A5=E8=AF=A2=E8=BF=917=E5=A4=A9=E8=BF=9130?= =?UTF-8?q?=E5=A4=A9=E5=99=AA=E5=A3=B0=E5=92=8C=E6=89=AC=E5=B0=98=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BuildingController.java | 35 ++++++++++--------- .../dto/BuildingRecordsDtos.java | 10 ++++++ .../mapper/BuildingRecordsMapper.java | 14 ++++---- 3 files changed, 35 insertions(+), 24 deletions(-) create mode 100644 src/main/java/com/hisense/monitormanage/dto/BuildingRecordsDtos.java diff --git a/src/main/java/com/hisense/monitormanage/controller/BuildingController.java b/src/main/java/com/hisense/monitormanage/controller/BuildingController.java index 2e5d460..4098dbb 100644 --- a/src/main/java/com/hisense/monitormanage/controller/BuildingController.java +++ b/src/main/java/com/hisense/monitormanage/controller/BuildingController.java @@ -1,6 +1,7 @@ package com.hisense.monitormanage.controller; import com.hisense.monitormanage.dto.BuildingRecordsDto; +import com.hisense.monitormanage.dto.BuildingRecordsDtos; import com.hisense.monitormanage.entity.BuildingRecords; import com.hisense.monitormanage.entity.Result; import com.hisense.monitormanage.mapper.BuildingRecordsMapper; @@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -64,7 +66,7 @@ public class BuildingController { /** - * 查询所有工地 + * 查询所有工地最新列表 * @return */ @GetMapping("selectAllBuilding") @@ -76,13 +78,25 @@ public class BuildingController { } /** - * 查询近7天工地噪声和扬尘的信息 + * 根据建筑编号查询近7天工地噪声和扬尘的信息 * @return */ @GetMapping("selectWeekPmAndNoice") @ApiOperation("查询近7天工地噪声和扬尘的信息") - public Result selectWeekPmAndNoice(){ - List recordsDtos = buildingRecordsMapper.selectWeekPmAndNoice(); + public Result selectWeekPmAndNoice(String buildLicense){ + List recordsDtos = buildingRecordsMapper.selectWeekPmAndNoice(buildLicense); + Result success = Result.success(recordsDtos); + return success; + } + + /** + * 根据建筑编号查询近30天工地噪声和扬尘的信息 + * @return + */ + @GetMapping("selectMonthPmAndNoice") + @ApiOperation("查询近30天工地噪声和扬尘的信息") + public Result selectMonthPmAndNoice(String buildLicense){ + List recordsDtos = buildingRecordsMapper.selectMonthPmAndNoice(buildLicense); Result success = Result.success(recordsDtos); return success; } @@ -99,19 +113,6 @@ public class BuildingController { return success; } - /** - * 查询近30天工地噪声和扬尘的信息 - * @return - */ - @GetMapping("selectMonthPmAndNoice") - @ApiOperation("查询近30天工地噪声和扬尘的信息") - public Result selectMonthPmAndNoice(){ - List recordsDtos = buildingRecordsMapper.selectMonthPmAndNoice(); - Result success = Result.success(recordsDtos); - return success; - } - - /** * 根据工地名称搜索工地 * @param projectName diff --git a/src/main/java/com/hisense/monitormanage/dto/BuildingRecordsDtos.java b/src/main/java/com/hisense/monitormanage/dto/BuildingRecordsDtos.java new file mode 100644 index 0000000..5de2013 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/dto/BuildingRecordsDtos.java @@ -0,0 +1,10 @@ +package com.hisense.monitormanage.dto; + +import lombok.Data; + +@Data +public class BuildingRecordsDtos { + private String pushTime; + private Integer pm10; + private Integer noice; +} diff --git a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java index 6bd7cc2..c62d6bf 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/BuildingRecordsMapper.java @@ -2,6 +2,7 @@ package com.hisense.monitormanage.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hisense.monitormanage.dto.BuildingRecordsDto; +import com.hisense.monitormanage.dto.BuildingRecordsDtos; import com.hisense.monitormanage.entity.BuildingRecords; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -21,16 +22,15 @@ public interface BuildingRecordsMapper extends BaseMapper { void batchUpdate(@Param("list") List list); - @Select("SELECT * FROM t_building_new_site bns JOIN t_building_records br ON bns.gdmc = br.project_name") + @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") List selectAllBuilding(); - @Select("select * from t_building_records br JOIN t_building_new_site bs on br.project_name = bs.gdmc" + - " where DATE_SUB(CURDATE(), INTERVAL 7 DAY) < date(br.push_time)") - List selectWeekPmAndNoice(); + @Select("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 WHERE br.build_license = #{buildLicense} AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) < date(br.push_time) group by pushTime") + List selectWeekPmAndNoice(String buildLicense); - @Select("select * from t_building_records br JOIN t_building_new_site bs on br.project_name = bs.gdmc" + - " where DATE_SUB(CURDATE(), INTERVAL 30 DAY) < date(br.push_time)") - List selectMonthPmAndNoice(); + @Select("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 WHERE br.build_license = #{buildLicense} AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) < date(br.push_time) group by pushTime") + List selectMonthPmAndNoice(String buildLicense); List selectRaise(@Param("page") Integer page,@Param("pageSize") Integer pageSize);