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);