StringquerySql=" SELECT * FROM test_%s WHERE equipmentIndexName='%s' and time >='%sT00:55:00Z' AND time < '%sT23:59:59Z' group by equipmentsIdx order by time desc LIMIT 1";
StringquerySql=" SELECT * FROM iot_data_%s WHERE equipmentIndexName='%s' and time >='%sT00:55:00Z' AND time < '%sT23:59:59Z' group by equipmentsIdx order by time desc LIMIT 1";
StringquerySql=" SELECT * FROM test_%s WHERE equipmentIndexName='%s' and equipmentSpecificName =~/.*逆变器.*/ and time >='%sT00:55:00Z' AND time < '%sT23:59:59Z' group by equipmentsIdx order by time desc LIMIT 1";
StringquerySql=" SELECT * FROM iot_data_%s WHERE equipmentIndexName='%s' and equipmentSpecificName =~/.*逆变器.*/ and time >='%sT00:55:00Z' AND time < '%sT23:59:59Z' group by equipmentsIdx order by time desc LIMIT 1";
equipmentNumber is not null and equipmentIndexName is not null
</if>
</where>
GROUP BY batch_no ,equipmentIndexName;
...
...
@@ -25,15 +25,29 @@
<selectid="getStatisticsInfo"resultType="map">
SELECT
avg( VALUE ) AS mean,
( SELECT created_time FROM temporary_data WHERE gatewayId = #{gatewayId} and equipmentIndexName =#{equipmentIndexName} ORDER BY `value` LIMIT 1 ) AS minTime,
( SELECT created_time FROM temporary_data WHERE
equipmentIndexName =#{equipmentIndexName}
<iftest="gatewayId != null and gatewayId != ''">
and gatewayId = #{gatewayId}
</if>
ORDER BY `value` LIMIT 1 ) AS minTime,
max( `value` ) AS max,
( SELECT created_time FROM temporary_data WHERE gatewayId = #{gatewayId} and equipmentIndexName =#{equipmentIndexName} ORDER BY `value` DESC LIMIT 1 ) AS maxTime,
( SELECT created_time FROM temporary_data WHERE
equipmentIndexName =#{equipmentIndexName}
<iftest="gatewayId != null and gatewayId != ''">
and gatewayId = #{gatewayId}
</if> ORDER BY `value` DESC LIMIT 1 ) AS maxTime,
min( `value` ) AS min
FROM
`temporary_data`
WHERE
gatewayId = #{gatewayId} and equipmentIndexName =#{equipmentIndexName}
<where>
<iftest="gatewayId != null and gatewayId != ''">
gatewayId = #{gatewayId} and equipmentIndexName =#{equipmentIndexName}
</if>
<iftest="gatewayId == null or gatewayId == ''">
equipmentNumber is not null and equipmentIndexName is not null and equipmentIndexName =#{equipmentIndexName}