Commit 09a26666ec0036c0536ce891de7aef303ea53779

Authored by YunaiV
1 parent 245ab4e6

【功能修复】IoT:解决 device 建表的时候,tdengine 默认字段都是小写的问题,通过 _ 解决

yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDevicePropertyDataServiceImpl.java
... ... @@ -100,7 +100,6 @@ public class IotDevicePropertyDataServiceImpl implements IotDevicePropertyDataSe
100 100 }
101 101 }
102 102  
103   - // TODO 芋艿:建表的时候,表名要小写么?
104 103 // 2.1 情况一:如果是新增的时候,需要创建表
105 104 List<TDengineTableField> newFields = buildTableFieldList(thingModels);
106 105 if (CollUtil.isEmpty(oldFields)) {
... ... @@ -119,7 +118,7 @@ public class IotDevicePropertyDataServiceImpl implements IotDevicePropertyDataSe
119 118 private List<TDengineTableField> buildTableFieldList(List<IotProductThingModelDO> thingModels) {
120 119 return convertList(thingModels, thingModel -> {
121 120 TDengineTableField field = new TDengineTableField(
122   - thingModel.getIdentifier().toLowerCase(), // TODO 芋艿:为什么要转成小写?
  121 + StrUtil.toUnderlineCase(thingModel.getIdentifier()), // TDengine 字段默认都是小写
123 122 TYPE_MAPPING.get(thingModel.getProperty().getDataType()));
124 123 if (thingModel.getProperty().getDataType().equals(IotDataSpecsDataTypeEnum.TEXT.getDataType())) {
125 124 field.setLength(((ThingModelDateOrTextDataSpecs) thingModel.getProperty().getDataSpecs()).getLength());
... ...