温振数据接收添加电量字段;上传接口移除温振数据

This commit is contained in:
zhanghan11 2024-04-16 08:37:17 +08:00
parent 611147c116
commit 01e4e20284
2 changed files with 18 additions and 17 deletions

View File

@ -60,6 +60,7 @@ public class IPCDataUploadSyncThread implements Runnable {
// fields.put("vx",vx[new Random().nextInt(8)]);
// fields.put("vy",vy[new Random().nextInt(8)]);
// fields.put("vz",vz[new Random().nextInt(8)]);
// fields.put("bat", "90");
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
// String format = simpleDateFormat.format(new Date());
// fields.put("insertTime", format);
@ -86,22 +87,22 @@ public class IPCDataUploadSyncThread implements Runnable {
}
}
// 查询最新传感器数据
QueryResult sensorQuery = influxDBService.query("select * from " + IpcConstant.SENSOR_MEASUREMENT + " where part = '" + partValue + "' order by time desc limit 1");
List<Map<String, Object>> sensorMaps = influxDBService.queryResultProcess(sensorQuery);
if (sensorMaps != null && !sensorMaps.isEmpty()) {
Map<String, Object> sensorMap = sensorMaps.get(0);
if (sensorMap.get("insertTime") != null) {
String insertTime = String.valueOf(sensorMap.get("insertTime"));
for (IpcMonitorField ipcMonitorField : sensorList) {
Map<String, String> map = new HashMap<>();
map.put("sid", partLabel + "-" + ipcMonitorField.getFieldLabel());
map.put("v", sensorMap.get(ipcMonitorField.getFieldValue()) == null ? "0" : String.valueOf(sensorMap.get(ipcMonitorField.getFieldValue())));
map.put("s", getSeconds(insertTime));
map.put("ms", getMillis(insertTime));
dataList.add(map);
}
}
}
// QueryResult sensorQuery = influxDBService.query("select * from " + IpcConstant.SENSOR_MEASUREMENT + " where part = '" + partValue + "' order by time desc limit 1");
// List<Map<String, Object>> sensorMaps = influxDBService.queryResultProcess(sensorQuery);
// if (sensorMaps != null && !sensorMaps.isEmpty()) {
// Map<String, Object> sensorMap = sensorMaps.get(0);
// if (sensorMap.get("insertTime") != null) {
// String insertTime = String.valueOf(sensorMap.get("insertTime"));
// for (IpcMonitorField ipcMonitorField : sensorList) {
// Map<String, String> map = new HashMap<>();
// map.put("sid", partLabel + "-" + ipcMonitorField.getFieldLabel());
// map.put("v", sensorMap.get(ipcMonitorField.getFieldValue()) == null ? "0" : String.valueOf(sensorMap.get(ipcMonitorField.getFieldValue())));
// map.put("s", getSeconds(insertTime));
// map.put("ms", getMillis(insertTime));
// dataList.add(map);
// }
// }
// }
}
msgMap.put("d", dataList);
// 进行数据推送

View File

@ -69,7 +69,7 @@ public class IpcDataReceiveServiceImpl implements IIpcDataReceiveService {
fields.put("vx", ipcBg4gszhp01tempdataX.getWData());
fields.put("vy", ipcBg4gszhp01tempdataY.getWData());
fields.put("vz", ipcBg4gszhp01tempdataZ.getWData());
fields.put("bat", ipcBg4gszhp01tempdataZ.getBat());
// 获取当前时间
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
String format = simpleDateFormat.format(new Date());