Commit 2530f35f authored by 曹雷's avatar 曹雷

Merge remote-tracking branch 'origin/wangsong_config' into feat-config-web

parents 20b6f5e4 b65852c8
......@@ -11,6 +11,7 @@ import cn.sh.chineseall.framework.dao.core.hql.Criteria;
import cn.sh.chineseall.framework.dao.core.hql.Query;
import cn.sh.chineseall.framework.dao.mongo.dao.StaticCacheDimensionDocumentMongoDao;
import cn.sh.chineseall.framework.dao.mongo.hql.MongoCriteriaTranslator;
import cn.sh.chineseall.framework.lang.calendar.DateUtils;
import com.chineseall.eden.authcenter.log.model.AuthLog;
import com.chineseall.eden.authcenter.log.model.AuthLogHourCount;
import com.mongodb.MongoClient;
......@@ -18,9 +19,11 @@ import com.mongodb.client.AggregateIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.*;
import com.mongodb.util.JSON;
import org.bson.BsonDocument;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.json.JSONObject;
import org.springframework.stereotype.Component;
import java.util.*;
......@@ -177,11 +180,23 @@ public class AuthLogDao extends StaticCacheDimensionDocumentMongoDao<AuthLog, St
aggregateList.add(Aggregates.sort(Sorts.descending("count")));
aggregateList.add(Aggregates.limit(topN));
AggregateIterable<AuthLogHourCount> iterable = collection.aggregate(aggregateList, AuthLogHourCount.class);
AggregateIterable<BsonDocument> iterable = collection.aggregate(aggregateList);
List<AuthLogHourCount> dataList = new ArrayList<>();
for(AuthLogHourCount item : iterable){
dataList.add(item);
for(BsonDocument item : iterable){
AuthLogHourCount data = new AuthLogHourCount();
if(item.containsKey("yearMonthDay")){
data.setYearMonthDay(item.getString("yearMonthDay").getValue());
}
if(item.containsKey("hour") ){
data.setHour(item.getInt32("hour").getValue());
}
if(item.containsKey("count")){
double count = item.getInt32("count").getValue();
data.setCount(Double.valueOf(count).longValue());
}
dataList.add(data);
}
return dataList;
}
......
package com.chineseall.eden.authcenter.log.model;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
public class AuthLogHourCount implements Serializable {
private String yearMonthDay;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment