|
@@ -13,7 +13,13 @@ import com.huaxu.service.MonitorDataService;
|
|
|
import com.huaxu.util.ByteArrayUtils;
|
|
|
import com.huaxu.util.DatesUtil;
|
|
|
import com.huaxu.util.RedisUtil;
|
|
|
+import com.mongodb.BasicDBObject;
|
|
|
+import com.mongodb.Block;
|
|
|
+import com.mongodb.DBCursor;
|
|
|
+import com.mongodb.DBObject;
|
|
|
+import com.mongodb.client.FindIterable;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.bson.Document;
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Sort;
|
|
@@ -125,7 +131,7 @@ public class MonitorDataServiceImpl implements MonitorDataService , Initializing
|
|
|
return monitorDataEntity;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
+ @Override
|
|
|
public List<DayReportEntity> getMonitorDataGroupByHour(LocalDateTime dateTime ,List<Integer> deviceIds ){
|
|
|
if (dateTime == null ){
|
|
|
return null;
|
|
@@ -138,8 +144,6 @@ public class MonitorDataServiceImpl implements MonitorDataService , Initializing
|
|
|
if(deviceIds!=null && deviceIds.size() > 0){
|
|
|
criteria.and("deviceId").in(deviceIds);
|
|
|
}
|
|
|
- Criteria criteria1 = new Criteria();
|
|
|
- criteria1.and("dataValues.dataValue").gt(0);
|
|
|
AggregationOptions aggregationOptions = AggregationOptions.builder().allowDiskUse(true).build();
|
|
|
Aggregation agg = Aggregation.newAggregation(
|
|
|
// 查询条件
|
|
@@ -164,6 +168,37 @@ public class MonitorDataServiceImpl implements MonitorDataService , Initializing
|
|
|
return durationData.getMappedResults();
|
|
|
}
|
|
|
|
|
|
+ /*@Override
|
|
|
+ public List<DayReportEntity> getMonitorDataGroupByHour(LocalDateTime dateTime ,List<Integer> deviceIds ){
|
|
|
+ if (dateTime == null ){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Criteria criteria = new Criteria();
|
|
|
+ criteria.and("year").is(dateTime.getYear());
|
|
|
+ criteria.and("month").is(dateTime.getMonthValue());
|
|
|
+ criteria.and("day").is(dateTime.getDayOfMonth());
|
|
|
+ criteria.and("hour").is(dateTime.getHour());
|
|
|
+ if(deviceIds!=null && deviceIds.size() > 0){
|
|
|
+ criteria.and("deviceId").in(deviceIds);
|
|
|
+ }
|
|
|
+ BasicDBObject query = new BasicDBObject();
|
|
|
+ query.put("year",dateTime.getYear());
|
|
|
+ query.put("month",dateTime.getMonthValue());
|
|
|
+ query.put("day",dateTime.getDayOfMonth());
|
|
|
+ query.put("hour",dateTime.getHour());
|
|
|
+ if (deviceIds != null && deviceIds.size() > 0) {
|
|
|
+ query.put("deviceId",new BasicDBObject("$in", deviceIds));
|
|
|
+ }
|
|
|
+ FindIterable<Document> iter = mongoTemplate.getCollection("SMS_MONITOR_DATA").find(query, Document.class);
|
|
|
+ iter.forEach(new Block<Document>() {
|
|
|
+ @Override
|
|
|
+ public void apply(Document entity) {
|
|
|
+ System.out.println(entity.toJson());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return null;
|
|
|
+ }*/
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public void getMonitorDataReportByHour(){
|