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