feat: 新功能开发,监测历史记录。微信和物联网平台,模块搭建。

This commit is contained in:
tianyongbao
2025-11-05 00:35:23 +08:00
parent 1d2e2e2513
commit 05fb822744
38 changed files with 2099 additions and 49 deletions

View File

@@ -52,14 +52,57 @@
</foreach>
</insert>
<select id="getHistoryDataList" parameterType="String" resultType="com.intc.tdengine.domain.DeviceSensorData">
select time,createTime,dissolvedOxygen,temperature,saturability,ph,salinity,treference,tfluorescence,phaseDifference,battery,serialNum,deviceId,data.mobilePhone,deviceType from fishery.t_#{serialNum}
<where>
time >= #{startTime} and time &lt;= #{endTime}
<if test="serialNum != null and serialNum != ''"> AND serialNum=#{serialNum}</if>
<if test="deviceId != null "> AND deviceId=#{deviceId}</if>
<if test="mobilePhone != null and mobilePhone != ''"> AND mobilePhone=#{mobilePhone}</if>
<if test="deviceType != null"> AND deviceType=#{deviceType}</if>
</where>
<select id="getHistoryDataList" resultType="com.intc.tdengine.domain.DeviceSensorData">
<if test="intervalType == null or intervalType == 1">
<!-- 原始数据,不聚合 -->
SELECT
`time`,
createTime,
dissolvedOxygen,
temperature,
saturability,
ph,
salinity,
treference,
tfluorescence,
phaseDifference,
battery,
serialNum,
deviceId,
mobilePhone,
deviceType
FROM `fishery`.`t_${serialNum}`
<where>
<if test="startTime != null and startTime != ''">AND `time` >= #{startTime}</if>
<if test="endTime != null and endTime != ''">AND `time` &lt;= #{endTime}</if>
</where>
</if>
<if test="intervalType != null and intervalType != 1">
<!-- 按时间间隔聚合 -->
SELECT
_wstart as `time`,
_wstart as createTime,
AVG(dissolvedOxygen) as dissolvedOxygen,
AVG(temperature) as temperature,
AVG(saturability) as saturability,
AVG(ph) as ph,
AVG(salinity) as salinity,
AVG(treference) as treference,
AVG(tfluorescence) as tfluorescence,
AVG(phaseDifference) as phaseDifference,
AVG(battery) as battery
FROM `fishery`.`t_${serialNum}`
<where>
<if test="startTime != null and startTime != ''">AND `time` >= #{startTime}</if>
<if test="endTime != null and endTime != ''">AND `time` &lt;= #{endTime}</if>
</where>
<choose>
<when test="intervalType == 2">INTERVAL(10m)</when>
<when test="intervalType == 3">INTERVAL(30m)</when>
<when test="intervalType == 4">INTERVAL(1h)</when>
<when test="intervalType == 5">INTERVAL(3h)</when>
<when test="intervalType == 6">INTERVAL(6h)</when>
</choose>
</if>
</select>
</mapper>