diff --git a/dev/Server/build.gradle b/dev/Server/build.gradle index 9b115d8..d99b0a9 100644 --- a/dev/Server/build.gradle +++ b/dev/Server/build.gradle @@ -6,7 +6,7 @@ plugins { } group = 'com.hours22' -version = '3.3.0-SNAPSHOT' +version = '3.4.0-SNAPSHOT' sourceCompatibility = '1.8' repositories { diff --git a/dev/Server/src/main/java/com/hours22/system_monitor_ver11/db/DataService.java b/dev/Server/src/main/java/com/hours22/system_monitor_ver11/db/DataService.java index 9cedcc8..b2547c0 100644 --- a/dev/Server/src/main/java/com/hours22/system_monitor_ver11/db/DataService.java +++ b/dev/Server/src/main/java/com/hours22/system_monitor_ver11/db/DataService.java @@ -125,7 +125,11 @@ public Map GetAllTypeDataRedis(String t1, String t2) throws Json e.printStackTrace(); } JSONObject jsonTmpObj = (JSONObject) obj; - + if(t1.equals("CLASS")) { + Map tmpmap = GetClassOnOffInfo(tmpMap.get("id")); + jsonTmpObj.put("cntOn", tmpmap.get("cntOn")); + jsonTmpObj.put("cntOff", tmpmap.get("cntOff")); + } jsonArray.add(jsonTmpObj); } } finally { @@ -136,6 +140,50 @@ public Map GetAllTypeDataRedis(String t1, String t2) throws Json return jsonObject; } + public Map GetClassOnOffInfo (String className) throws JsonProcessingException { + + ValueOperations valueOperations = redisTemplate.opsForValue(); + int cntON = 0, cntOFF = 0; + + RedisConnection redisConnection = null; + try { + redisConnection = redisTemplate.getConnectionFactory().getConnection(); + ScanOptions options = ScanOptions.scanOptions().match("*").count(50).build(); + Cursor cursor = redisConnection.scan(options); + while (cursor.hasNext()) { + System.out.println("Cursor 작동중 !!!"); + String tkey = new String(cursor.next()); + String kvalue = mc.getConnectionHgetall(tkey); + Map tmpMap = ojm.readValue(kvalue, Map.class); + String type = tmpMap.get("type"); + if(!type.equals("PC")) continue; + + String cid = tmpMap.get("classId"); + System.out.println("지금 type : "+type); + + if(!cid.equals(className)) continue; + + String tmp = tmpMap.get("powerStatus"); + System.out.println("여기에서 PowerStatus 는 "+tmp); + if(tmp.equals("ON")) { + cntON++; + System.out.println("cntOn 증가중 ! - " + cntON); + } + else { + cntOFF++; + System.out.println("cntOff 증가중 ! - " + cntOFF); + } + } + } finally { + System.out.println("Finished!"); + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("cntOn", Integer.toString(cntON)); + jsonObject.put("cntOff", Integer.toString(cntOFF)); + return jsonObject; + } + public Map ClassPcs (String className) throws JsonProcessingException { // t1 : D401 // 2차원 초기화, PC[20][20], new PC(); diff --git a/dev/Server/src/main/java/com/hours22/system_monitor_ver11/db/LettuceController.java b/dev/Server/src/main/java/com/hours22/system_monitor_ver11/db/LettuceController.java index 41133c4..b5f91d4 100644 --- a/dev/Server/src/main/java/com/hours22/system_monitor_ver11/db/LettuceController.java +++ b/dev/Server/src/main/java/com/hours22/system_monitor_ver11/db/LettuceController.java @@ -259,6 +259,20 @@ public boolean getConnectionHset(String key, Map map) { System.out.println("hset "+key+" type -> false"); } + if(map.get("posR") != null) { + syncCmd.hset(key, "posR", map.get("posR")); + System.out.println("hset "+key+" posR -> true"); + } else { + System.out.println("hset "+key+" posR -> false"); + } + + if(map.get("posC") != null) { + syncCmd.hset(key, "posC", map.get("posC")); + System.out.println("hset "+key+" posC -> true"); + } else { + System.out.println("hset "+key+" posC -> false"); + } + System.out.println("**** Finished Hset ****"); return true; } catch (Exception e) { @@ -267,6 +281,8 @@ public boolean getConnectionHset(String key, Map map) { } } + + //@GetMapping(path="/connections/hget/{keyMap}") public Map getConnectionHget(String key) { // This returns a JSON or XML with the users diff --git a/dev/Server/src/main/java/com/hours22/system_monitor_ver11/vo/PcData.java b/dev/Server/src/main/java/com/hours22/system_monitor_ver11/vo/PcData.java index c627767..534b159 100644 --- a/dev/Server/src/main/java/com/hours22/system_monitor_ver11/vo/PcData.java +++ b/dev/Server/src/main/java/com/hours22/system_monitor_ver11/vo/PcData.java @@ -59,7 +59,7 @@ public PcData() { public void setAllData(String cId, String status, String tid, String tname, String cpu, String ram, String st, String et, String pr, String pc, String ttype) { this.classId = cId; this.powerStatus = status; - this.id = id; + this.id = tid; this.name = tname; this.cpuData = cpu; this.ramData = ram;