环境监测后端
This commit is contained in:
parent
e6dc515248
commit
fd4d0e649e
|
|
@ -17,5 +17,5 @@ public interface EnvironmentMapper {
|
||||||
|
|
||||||
EnvironmentDto getEnvironmentList(EnvironmentDto dto);
|
EnvironmentDto getEnvironmentList(EnvironmentDto dto);
|
||||||
|
|
||||||
List<EnvironmentDto> getEnvironmentListByDate(@Param("startDate") String s,@Param("endDate") String today);
|
List<EnvironmentDto> getEnvironmentListByDate(@Param("currentDay") String currentDay);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,7 @@ public class EnvironmentServiceImpl implements EnvironmentService {
|
||||||
try {
|
try {
|
||||||
//先查固定时间-- currentDay:2021-05-01 hours:9
|
//先查固定时间-- currentDay:2021-05-01 hours:9
|
||||||
vo = mapper.getEnvironmentList(dto);
|
vo = mapper.getEnvironmentList(dto);
|
||||||
//在查最近七天,每天的平均值
|
List<EnvironmentDto> list = mapper.getEnvironmentListByDate(dto.getCurrentDay());
|
||||||
String today = DateUtil.today();
|
|
||||||
// 获取七天前的日期,subtract方法可以用来减去指定的时间间隔
|
|
||||||
Date sevenDaysAgo = DateUtil.offsetDay(DateUtil.date(), -7);
|
|
||||||
List<EnvironmentDto> list = mapper.getEnvironmentListByDate(DateUtil.format(sevenDaysAgo, "yyyy-MM-dd"),today);
|
|
||||||
vo.setList(list);
|
vo.setList(list);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("环境监测分析-查询失败", e);
|
log.error("环境监测分析-查询失败", e);
|
||||||
|
|
|
||||||
|
|
@ -30,20 +30,17 @@
|
||||||
</select>
|
</select>
|
||||||
<select id="getEnvironmentListByDate" resultType="com.securitycontrol.entity.screen.dto.EnvironmentDto">
|
<select id="getEnvironmentListByDate" resultType="com.securitycontrol.entity.screen.dto.EnvironmentDto">
|
||||||
SELECT
|
SELECT
|
||||||
current_day as currentDay,
|
concat(`hour`,"时") as currentDay,
|
||||||
AVG(slope_displacement) AS slopeDisplacement,
|
slope_displacement AS slopeDisplacement,
|
||||||
AVG(temperature) AS temperature,
|
temperature AS temperature,
|
||||||
AVG(humidity) AS humidity,
|
humidity AS humidity,
|
||||||
AVG(air_quality_index) AS airQualityIndex,
|
air_quality_index AS airQualityIndex,
|
||||||
AVG(noise_level) AS noiseLevel,
|
noise_level AS noiseLevel,
|
||||||
AVG(illumination) AS illumination
|
illumination AS illumination
|
||||||
FROM
|
FROM
|
||||||
wide_sensor_data
|
wide_sensor_data
|
||||||
WHERE
|
WHERE
|
||||||
current_day between #{startDate} AND #{endDate}
|
current_day = #{currentDay}
|
||||||
GROUP BY
|
and `hour` in ("00","02","04","06","08","10","12","14","16","18","20","22")
|
||||||
current_day
|
|
||||||
ORDER BY
|
|
||||||
current_day ASC
|
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue