|
@@ -26,6 +26,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.sql.DataSource;
|
|
|
import java.sql.*;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -194,7 +196,7 @@ public class QueryTdengineDataServiceImpl extends AbstractCrudService<QueryTdeng
|
|
|
resultVO.setTags(tag);
|
|
|
|
|
|
Map<String, Object> field = new HashMap<String,Object>();
|
|
|
- field.put("time",metricList.getString("ts"));
|
|
|
+ field.put("realtime",metricList.getTimestamp("ts").getTime());
|
|
|
for(int k =0;k<filterValidFields.size();k++){
|
|
|
field.put(filterValidFields.get(k),metricList.getString(filterValidFields.get(k)));
|
|
|
}
|
|
@@ -438,15 +440,46 @@ public class QueryTdengineDataServiceImpl extends AbstractCrudService<QueryTdeng
|
|
|
|
|
|
@Override
|
|
|
public List<Map<String, Object>> getAllDeviceRealTime(){
|
|
|
- List<DeviceRealDataVO> realData = queryTdengineDataMapper.getAllDeviceRealTime();
|
|
|
- return realData.stream().map(item -> {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("device_uuid", item.getDeviceUuid());
|
|
|
- map.put("device_id", item.getDeviceId());
|
|
|
- map.put("ts", item.getTs());
|
|
|
- map.put("realtime", item.getRealtime());
|
|
|
- return map;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
|
|
|
+// List<DeviceRealDataVO> realData = queryTdengineDataMapper.getAllDeviceRealTime();
|
|
|
+// return realData.stream().map(item -> {
|
|
|
+// Map<String, Object> map = new HashMap<>();
|
|
|
+// map.put("device_uuid", item.getDeviceUuid());
|
|
|
+// map.put("device_id", item.getDeviceId());
|
|
|
+// try {
|
|
|
+// map.put("realtime", sdf.parse(item.getRealtime().toString()).getTime());
|
|
|
+// } catch (ParseException e) {
|
|
|
+// throw new RuntimeException(e);
|
|
|
+// }
|
|
|
+// return map;
|
|
|
+// }).collect(Collectors.toList());
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ Connection connection = dataSource.getConnection();
|
|
|
+ Statement statement = connection.createStatement();
|
|
|
+
|
|
|
+ String query = "select device_uuid,realtime,device_id from datarealtime";
|
|
|
+ ResultSet resultSet1 = statement.executeQuery(query);
|
|
|
+
|
|
|
+ while (resultSet1.next()) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("device_uuid", resultSet1.getString("device_uuid"));
|
|
|
+ map.put("device_id", resultSet1.getString("device_id"));
|
|
|
+ map.put("realtime", resultSet1.getTimestamp("realtime").getTime());
|
|
|
+
|
|
|
+ resultList.add(map);
|
|
|
+ }
|
|
|
+ resultSet1.close();
|
|
|
+
|
|
|
+ statement.close();
|
|
|
+ connection.close();
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultList;
|
|
|
}
|
|
|
|
|
|
@Override
|