【功能修复】IoT:解决物模型的 identifier 存在驼峰情况下,无法插入和查询的情况

This commit is contained in:
YunaiV 2025-01-28 23:16:30 +08:00
parent 76ab64a255
commit f14cc470aa
2 changed files with 5 additions and 5 deletions

View File

@ -33,7 +33,7 @@ public interface IotDevicePropertyMapper {
List<TDengineTableField> oldFields, List<TDengineTableField> oldFields,
List<TDengineTableField> newFields) { List<TDengineTableField> newFields) {
oldFields.removeIf(field -> StrUtil.equalsAny(field.getField(), oldFields.removeIf(field -> StrUtil.equalsAny(field.getField(),
TDengineTableField.FIELD_TS, "device_key", "report_time")); TDengineTableField.FIELD_TS, "report_time"));
List<TDengineTableField> addFields = newFields.stream().filter( // 新增的字段 List<TDengineTableField> addFields = newFields.stream().filter( // 新增的字段
newField -> oldFields.stream().noneMatch(oldField -> oldField.getField().equals(newField.getField()))) newField -> oldFields.stream().noneMatch(oldField -> oldField.getField().equals(newField.getField())))
.collect(Collectors.toList()); .collect(Collectors.toList());

View File

@ -51,7 +51,7 @@
TAGS ('${device.deviceKey}') TAGS ('${device.deviceKey}')
(ts, report_time, (ts, report_time,
<foreach item="key" collection="properties.keys" separator=","> <foreach item="key" collection="properties.keys" separator=",">
${key} ${@cn.hutool.core.util.StrUtil@toUnderlineCase(key)}
</foreach> </foreach>
) )
VALUES VALUES
@ -67,9 +67,9 @@
</select> </select>
<select id="selectPageByHistory" resultType="cn.iocoder.yudao.module.iot.controller.admin.device.vo.data.IotDevicePropertyRespVO"> <select id="selectPageByHistory" resultType="cn.iocoder.yudao.module.iot.controller.admin.device.vo.data.IotDevicePropertyRespVO">
SELECT ${reqVO.identifier} AS `value`, ts AS update_time SELECT ${@cn.hutool.core.util.StrUtil@toUnderlineCase(reqVO.identifier)} AS `value`, ts AS update_time
FROM device_property_${reqVO.deviceKey}1 FROM device_property_${reqVO.deviceKey}
WHERE ${reqVO.identifier} IS NOT NULL WHERE ${@cn.hutool.core.util.StrUtil@toUnderlineCase(reqVO.identifier)} IS NOT NULL
AND ts BETWEEN ${@cn.hutool.core.date.LocalDateTimeUtil@toEpochMilli(reqVO.times[0])} AND ts BETWEEN ${@cn.hutool.core.date.LocalDateTimeUtil@toEpochMilli(reqVO.times[0])}
AND ${@cn.hutool.core.date.LocalDateTimeUtil@toEpochMilli(reqVO.times[1])} AND ${@cn.hutool.core.date.LocalDateTimeUtil@toEpochMilli(reqVO.times[1])}
ORDER BY ts DESC ORDER BY ts DESC