|  | @ -14,6 +14,7 @@ import org.springframework.data.mongodb.core.MongoTemplate;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.servlet.http.HttpSession;
 | 
	
		
			
				|  |  | import java.sql.Timestamp;
 | 
	
		
			
				|  |  | import java.util.ArrayList;
 | 
	
		
			
				|  |  | import java.util.HashMap;
 | 
	
		
			
				|  |  | import java.util.List;
 | 
	
	
		
			
				|  | @ -35,23 +36,24 @@ public class ServerMonitorService {
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private Mongo mongo;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Result getMonitorList(HttpSession session,String host, String type, String beginTime, String endTime) {
 | 
	
		
			
				|  |  |         TenantSession tenantSession = (TenantSession)session.getAttribute(ContextAttributes.TENANT_SESSION);
 | 
	
		
			
				|  |  |     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);
 | 
	
		
			
				|  |  |         DBCollection envCollection = mongoOperations.getCollection(SERVER);
 | 
	
		
			
				|  |  |         Timestamp begin = DateUtil.toTimestamp(beginTime);
 | 
	
		
			
				|  |  |         Timestamp end = DateUtil.toTimestamp(endTime);
 | 
	
		
			
				|  |  |         BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
 | 
	
		
			
				|  |  |                 new BasicDBObject[]{
 | 
	
		
			
				|  |  |                         new BasicDBObject().append("tenant",tenantSession.getTenant()),
 | 
	
		
			
				|  |  |                         new BasicDBObject().append("host",host),
 | 
	
		
			
				|  |  |                         new BasicDBObject().append("type",type),
 | 
	
		
			
				|  |  |                         new BasicDBObject().append("create_time",
 | 
	
		
			
				|  |  |                                 new BasicDBObject().append(QueryOperators.GTE, DateUtil.toTimestamp(beginTime))),
 | 
	
		
			
				|  |  |                         new BasicDBObject().append("create_time",
 | 
	
		
			
				|  |  |                                 new BasicDBObject().append(QueryOperators.LT, DateUtil.toTimestamp(endTime)))});
 | 
	
		
			
				|  |  |                         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))
 | 
	
		
			
				|  |  |                 });
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<DBObject> result = new ArrayList<>();
 | 
	
		
			
				|  |  |         DBCursor cursor = envCollection.find(queryObject);
 | 
	
		
			
				|  |  |         while(cursor.hasNext()) {
 | 
	
		
			
				|  |  |         while (cursor.hasNext()) {
 | 
	
		
			
				|  |  |             DBObject dbObject = cursor.next();
 | 
	
		
			
				|  |  |             dbObject.removeField("_id");
 | 
	
		
			
				|  |  |             result.add(dbObject);
 | 
	
	
		
			
				|  | @ -62,20 +64,21 @@ public class ServerMonitorService {
 | 
	
		
			
				|  |  |         return actionResult;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Result getMonitorDetail(HttpSession session,String host, String type, String date) {
 | 
	
		
			
				|  |  |         TenantSession tenantSession = (TenantSession)session.getAttribute(ContextAttributes.TENANT_SESSION);
 | 
	
		
			
				|  |  |     public Result getMonitorDetail(HttpSession session, String host, String type, String date) {
 | 
	
		
			
				|  |  |         TenantSession tenantSession = (TenantSession) session.getAttribute(ContextAttributes.TENANT_SESSION);
 | 
	
		
			
				|  |  |         mongoOperations = new MongoTemplate(mongo, MONITOR);
 | 
	
		
			
				|  |  |         DBCollection envCollection = mongoOperations.getCollection(SERVER);
 | 
	
		
			
				|  |  |         Timestamp timestamp = DateUtil.toTimestamp(date);
 | 
	
		
			
				|  |  |         BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
 | 
	
		
			
				|  |  |                 new BasicDBObject[]{
 | 
	
		
			
				|  |  |                         new BasicDBObject().append("tenant",tenantSession.getTenant()),
 | 
	
		
			
				|  |  |                         new BasicDBObject().append("tenant", tenantSession.getTenant()),
 | 
	
		
			
				|  |  |                         new BasicDBObject().append("host", host),
 | 
	
		
			
				|  |  |                         new BasicDBObject().append("type", type),
 | 
	
		
			
				|  |  |                         new BasicDBObject().append("create_time",new BasicDBObject().append(QueryOperators.LTE, DateUtil.toTimestamp(date)))});
 | 
	
		
			
				|  |  |                         new BasicDBObject("create_time", new BasicDBObject(QueryOperators.LTE, timestamp))});
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map result = new HashMap<>();
 | 
	
		
			
				|  |  |         DBCursor cursor = envCollection.find(queryObject).sort(new BasicDBObject("create_time",-1)).limit(1);
 | 
	
		
			
				|  |  |         while(cursor.hasNext()) {
 | 
	
		
			
				|  |  |         DBCursor cursor = envCollection.find(queryObject).sort(new BasicDBObject("create_time", -1)).limit(1);
 | 
	
		
			
				|  |  |         while (cursor.hasNext()) {
 | 
	
		
			
				|  |  |             DBObject dbObject = cursor.next();
 | 
	
		
			
				|  |  |             dbObject.removeField("_id");
 | 
	
		
			
				|  |  |             result = dbObject.toMap();
 | 
	
	
		
			
				|  | @ -87,19 +90,18 @@ public class ServerMonitorService {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Result getHosts() {
 | 
	
		
			
				|  |  |         List<Map<String,Object>> result = new ArrayList<>();
 | 
	
		
			
				|  |  |         List<Map<String, Object>> result = new ArrayList<>();
 | 
	
		
			
				|  |  |         mongoOperations = new MongoTemplate(mongo, MONITOR);
 | 
	
		
			
				|  |  |         DBCollection envCollection = mongoOperations.getCollection(HOST);
 | 
	
		
			
				|  |  |         DBCursor cursor = envCollection.find();
 | 
	
		
			
				|  |  |         while(cursor.hasNext()) {
 | 
	
		
			
				|  |  |         while (cursor.hasNext()) {
 | 
	
		
			
				|  |  |             DBObject dbObject = cursor.next();
 | 
	
		
			
				|  |  |             Map<String,Object> hostMap = new HashMap<>();
 | 
	
		
			
				|  |  |             hostMap.put("host",dbObject.get("host"));
 | 
	
		
			
				|  |  |             hostMap.put("name",dbObject.get("name"));
 | 
	
		
			
				|  |  |             Map<String, Object> hostMap = new HashMap<>();
 | 
	
		
			
				|  |  |             hostMap.put("host", dbObject.get("host"));
 | 
	
		
			
				|  |  |             hostMap.put("name", dbObject.get("name"));
 | 
	
		
			
				|  |  |             result.add(hostMap);
 | 
	
		
			
				|  |  |             hostMap=null;
 | 
	
		
			
				|  |  |             hostMap = null;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         ActionResult actionResult = new ActionResult();
 | 
	
		
			
				|  |  |         actionResult.setData(result);
 | 
	
	
		
			
				|  | @ -108,27 +110,28 @@ public class ServerMonitorService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 獲取服務器列表 树
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Result getServerTreeList(HttpSession session) throws Exception {
 | 
	
		
			
				|  |  |         List<TreeView> treeList = new ArrayList<>();
 | 
	
		
			
				|  |  |         TenantSession tenantSession = (TenantSession)session.getAttribute(ContextAttributes.TENANT_SESSION);
 | 
	
		
			
				|  |  |         TenantSession tenantSession = (TenantSession) session.getAttribute(ContextAttributes.TENANT_SESSION);
 | 
	
		
			
				|  |  |         mongoOperations = new MongoTemplate(mongo, MONITOR);
 | 
	
		
			
				|  |  |         DBCollection envCollection = mongoOperations.getCollection(HOST);
 | 
	
		
			
				|  |  |         //查询条件
 | 
	
		
			
				|  |  |         BasicDBObject queryObject = new BasicDBObject().append(QueryOperators.AND,
 | 
	
		
			
				|  |  |                 new BasicDBObject[]{
 | 
	
		
			
				|  |  |                         new BasicDBObject().append("tenant",tenantSession.getTenant())});
 | 
	
		
			
				|  |  |                         new BasicDBObject().append("tenant", tenantSession.getTenant())});
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         DBCursor cursor = envCollection.find(queryObject);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         while(cursor.hasNext()) {
 | 
	
		
			
				|  |  |         while (cursor.hasNext()) {
 | 
	
		
			
				|  |  |             DBObject dbObject = cursor.next();
 | 
	
		
			
				|  |  |             TreeView rootTree = new TreeView();
 | 
	
		
			
				|  |  |             rootTree.setId(dbObject.get("host").toString());
 | 
	
		
			
				|  |  |             rootTree.setPid("-1");
 | 
	
		
			
				|  |  |             rootTree.setText(dbObject.get("name").toString()+"/"+dbObject.get("host").toString());
 | 
	
		
			
				|  |  |             rootTree.setText(dbObject.get("name").toString() + "/" + dbObject.get("host").toString());
 | 
	
		
			
				|  |  |             treeList.add(rootTree);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 |