huangzhiyong преди 7 години
родител
ревизия
964914fde2
променени са 3 файла, в които са добавени 11 реда и са изтрити 14 реда
  1. 0 5
      pom.xml
  2. 2 0
      src/main/java/com/yihu/hos/filter/SessionOutTimeFilter.java
  3. 9 9
      src/main/java/com/yihu/hos/monitor/service/ServerMonitorService.java

+ 0 - 5
pom.xml

@ -31,11 +31,6 @@
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-cache</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>

+ 2 - 0
src/main/java/com/yihu/hos/filter/SessionOutTimeFilter.java

@ -28,6 +28,8 @@ public class SessionOutTimeFilter extends OncePerRequestFilter {
        HttpSession session = request.getSession();
        if (requestUri.indexOf("/login") != -1
                || requestUri.indexOf("/tenantAutoFail") != -1
                || requestUri.indexOf("/tokenValidFail") != -1
                || requestUri.indexOf("/system/loginAction") != -1
                || requestUri.indexOf("/error") != -1
                || requestUri.indexOf("/test.jsp") != -1

+ 9 - 9
src/main/java/com/yihu/hos/monitor/service/ServerMonitorService.java

@ -34,11 +34,11 @@ public class ServerMonitorService {
    private MongoOperations mongoOperations;
    @Autowired
    private Mongo mongo;
    private MongoClient mongoClient;
    public Result getMonitorList(HttpSession session, String host, String type, String beginTime, String endTime) {
        TenantSession tenantSession = (TenantSession) session.getAttribute(ContextAttributes.TENANT_SESSION);
        mongoOperations = new MongoTemplate(mongo, MONITOR);
        mongoOperations = new MongoTemplate(mongoClient, MONITOR);
        DBCollection envCollection = mongoOperations.getCollection(SERVER);
        Timestamp begin = DateUtil.toTimestamp(beginTime);
        Timestamp end = DateUtil.toTimestamp(endTime);
@ -47,8 +47,8 @@ public class ServerMonitorService {
                        new BasicDBObject().append("tenant", tenantSession.getTenant()),
                        new BasicDBObject().append("host", host),
                        new BasicDBObject().append("type", type),
                        new BasicDBObject("create_time", new BasicDBObject().append(QueryOperators.GTE, begin)
                                .append(QueryOperators.LT, end))
                        new BasicDBObject("create_date", new BasicDBObject().append(QueryOperators.GTE, beginTime)
                                .append(QueryOperators.LT, endTime))
                });
        List<DBObject> result = new ArrayList<>();
@ -66,7 +66,7 @@ public class ServerMonitorService {
    public Result getMonitorDetail(HttpSession session, String host, String type, String date) {
        TenantSession tenantSession = (TenantSession) session.getAttribute(ContextAttributes.TENANT_SESSION);
        mongoOperations = new MongoTemplate(mongo, MONITOR);
        mongoOperations = new MongoTemplate(mongoClient, MONITOR);
        DBCollection envCollection = mongoOperations.getCollection(SERVER);
        Timestamp timestamp = DateUtil.toTimestamp(date);
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
@ -74,10 +74,10 @@ public class ServerMonitorService {
                        new BasicDBObject().append("tenant", tenantSession.getTenant()),
                        new BasicDBObject().append("host", host),
                        new BasicDBObject().append("type", type),
                        new BasicDBObject("create_time", new BasicDBObject(QueryOperators.LTE, timestamp))});
                        new BasicDBObject("create_date", new BasicDBObject(QueryOperators.LTE, date))});
        Map result = new HashMap<>();
        DBCursor cursor = envCollection.find(queryObject).sort(new BasicDBObject("create_time", -1)).limit(1);
        DBCursor cursor = envCollection.find(queryObject).sort(new BasicDBObject("create_date", -1)).limit(1);
        while (cursor.hasNext()) {
            DBObject dbObject = cursor.next();
            dbObject.removeField("_id");
@ -92,7 +92,7 @@ public class ServerMonitorService {
    public Result getHosts() {
        List<Map<String, Object>> result = new ArrayList<>();
        mongoOperations = new MongoTemplate(mongo, MONITOR);
        mongoOperations = new MongoTemplate(mongoClient, MONITOR);
        DBCollection envCollection = mongoOperations.getCollection(HOST);
        DBCursor cursor = envCollection.find();
        while (cursor.hasNext()) {
@ -117,7 +117,7 @@ public class ServerMonitorService {
    public Result getServerTreeList(HttpSession session) throws Exception {
        List<TreeView> treeList = new ArrayList<>();
        TenantSession tenantSession = (TenantSession) session.getAttribute(ContextAttributes.TENANT_SESSION);
        mongoOperations = new MongoTemplate(mongo, MONITOR);
        mongoOperations = new MongoTemplate(mongoClient, MONITOR);
        DBCollection envCollection = mongoOperations.getCollection(HOST);
        //查询条件
        BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,