|
@@ -1,7 +1,6 @@
|
|
|
package cn.reghao.autodop.dmaster.machine.db.query;
|
|
package cn.reghao.autodop.dmaster.machine.db.query;
|
|
|
|
|
|
|
|
-import cn.reghao.autodop.dmaster.sys.model.vo.AppRuntimeLogVO;
|
|
|
|
|
-import cn.reghao.autodop.dmaster.sys.model.vo.RuntimeLogVO;
|
|
|
|
|
|
|
+import cn.reghao.autodop.dmaster.machine.model.po.NodeLog;
|
|
|
import com.mongodb.BasicDBObject;
|
|
import com.mongodb.BasicDBObject;
|
|
|
import com.mongodb.client.AggregateIterable;
|
|
import com.mongodb.client.AggregateIterable;
|
|
|
import org.bson.Document;
|
|
import org.bson.Document;
|
|
@@ -20,13 +19,13 @@ import java.util.*;
|
|
|
*/
|
|
*/
|
|
|
@Component
|
|
@Component
|
|
|
public class MongoQuery {
|
|
public class MongoQuery {
|
|
|
- private MongoTemplate mongoTemplate;
|
|
|
|
|
|
|
+ private final MongoTemplate mongoTemplate;
|
|
|
|
|
|
|
|
public MongoQuery(MongoTemplate mongoTemplate) {
|
|
public MongoQuery(MongoTemplate mongoTemplate) {
|
|
|
this.mongoTemplate = mongoTemplate;
|
|
this.mongoTemplate = mongoTemplate;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public List<RuntimeLogVO> aggregate(String col, Map<String, String> groupByIds) {
|
|
|
|
|
|
|
+ public List<NodeLog> aggregate(String col, Map<String, String> groupByIds) {
|
|
|
Document groupBy = new Document();
|
|
Document groupBy = new Document();
|
|
|
groupBy.putAll(groupByIds);
|
|
groupBy.putAll(groupByIds);
|
|
|
|
|
|
|
@@ -38,7 +37,7 @@ public class MongoQuery {
|
|
|
List<Document> pipeline = new ArrayList<>();
|
|
List<Document> pipeline = new ArrayList<>();
|
|
|
pipeline.add(queryObject);
|
|
pipeline.add(queryObject);
|
|
|
|
|
|
|
|
- List<RuntimeLogVO> list = new ArrayList<>();
|
|
|
|
|
|
|
+ List<NodeLog> list = new ArrayList<>();
|
|
|
AggregateIterable<Document> result = mongoTemplate.getCollection(col).aggregate(pipeline).allowDiskUse(true);
|
|
AggregateIterable<Document> result = mongoTemplate.getCollection(col).aggregate(pipeline).allowDiskUse(true);
|
|
|
for (Document document : result) {
|
|
for (Document document : result) {
|
|
|
Document doc = document.get("_id", Document.class);
|
|
Document doc = document.get("_id", Document.class);
|
|
@@ -46,12 +45,12 @@ public class MongoQuery {
|
|
|
String appId = doc.get("appId", String.class);
|
|
String appId = doc.get("appId", String.class);
|
|
|
String machineIpv4 = document.get("machineIpv4", String.class);
|
|
String machineIpv4 = document.get("machineIpv4", String.class);
|
|
|
Integer total = document.get("total", Integer.class);
|
|
Integer total = document.get("total", Integer.class);
|
|
|
- list.add(new RuntimeLogVO(machineId, machineIpv4, appId));
|
|
|
|
|
|
|
+ list.add(new NodeLog());
|
|
|
}
|
|
}
|
|
|
return list;
|
|
return list;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public List<AppRuntimeLogVO> aggregate1(String col, String machineId, String appId) {
|
|
|
|
|
|
|
+ public List<NodeLog> aggregate1(String col, String machineId, String appId) {
|
|
|
Map<String, String> matchMap = new HashMap<>();
|
|
Map<String, String> matchMap = new HashMap<>();
|
|
|
matchMap.put("machineId", machineId);
|
|
matchMap.put("machineId", machineId);
|
|
|
matchMap.put("appId", appId);
|
|
matchMap.put("appId", appId);
|
|
@@ -70,13 +69,13 @@ public class MongoQuery {
|
|
|
pipeline.add(matchObject);
|
|
pipeline.add(matchObject);
|
|
|
pipeline.add(groupObject);
|
|
pipeline.add(groupObject);
|
|
|
|
|
|
|
|
- List<AppRuntimeLogVO> list = new ArrayList<>();
|
|
|
|
|
|
|
+ List<NodeLog> list = new ArrayList<>();
|
|
|
AggregateIterable<Document> result = mongoTemplate.getCollection(col).aggregate(pipeline).allowDiskUse(true);
|
|
AggregateIterable<Document> result = mongoTemplate.getCollection(col).aggregate(pipeline).allowDiskUse(true);
|
|
|
for (Document document : result) {
|
|
for (Document document : result) {
|
|
|
Document doc = document.get("_id", Document.class);
|
|
Document doc = document.get("_id", Document.class);
|
|
|
String yearMonthDay = doc.get("yearMonthDay", String.class);
|
|
String yearMonthDay = doc.get("yearMonthDay", String.class);
|
|
|
Integer total = document.get("total", Integer.class);
|
|
Integer total = document.get("total", Integer.class);
|
|
|
- list.add(new AppRuntimeLogVO(machineId, appId, yearMonthDay, total));
|
|
|
|
|
|
|
+ list.add(new NodeLog());
|
|
|
}
|
|
}
|
|
|
return list;
|
|
return list;
|
|
|
}
|
|
}
|