|
|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.usky.cdi.domain.DmpDevice;
|
|
|
import com.usky.cdi.mapper.DmpDeviceMapper;
|
|
|
+import com.usky.cdi.service.config.DeviceFieldConfig;
|
|
|
import com.usky.cdi.service.vo.IotDataTransferVO;
|
|
|
import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -28,7 +29,6 @@ import java.util.stream.Collectors;
|
|
|
@Data
|
|
|
@Slf4j
|
|
|
@Component
|
|
|
-@ConfigurationProperties(prefix = "device")
|
|
|
public class DeviceDataQuery {
|
|
|
@Autowired
|
|
|
private DmpDeviceMapper dmpDeviceMapper;
|
|
|
@@ -36,7 +36,9 @@ public class DeviceDataQuery {
|
|
|
private String baseUrl;
|
|
|
@Value("${device.data.simulation}")
|
|
|
private boolean simulation;
|
|
|
- private Map<String, String> deviceFieldMapping;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DeviceFieldConfig deviceFieldConfig;
|
|
|
|
|
|
// 定义各参数的格式化器(整数位,小数位)
|
|
|
private static final DecimalFormat FORMAT_2_2 = new DecimalFormat("00.00"); // 2位整数+2位小数
|
|
|
@@ -218,7 +220,7 @@ public class DeviceDataQuery {
|
|
|
return Collections.singletonList("time");
|
|
|
}
|
|
|
|
|
|
- String fieldsStr = deviceFieldMapping.get(deviceType.toString());
|
|
|
+ String fieldsStr = deviceFieldConfig.deviceFieldMapping().get(deviceType.toString());
|
|
|
if (fieldsStr == null || fieldsStr.trim().isEmpty()) {
|
|
|
log.warn("获取目标字段失败:设备类型{}对应的字段映射不存在", deviceType);
|
|
|
return Collections.singletonList("time");
|
|
|
@@ -407,4 +409,4 @@ public class DeviceDataQuery {
|
|
|
currentReuseCountCache.put(cacheKey, 0);
|
|
|
return newValue;
|
|
|
}
|
|
|
-}
|
|
|
+}
|