Skip to content

Commit

Permalink
v3.4.0 (data POST누락되었던 것들, id에 0들어갔던 것, cntOff/On 반환)
Browse files Browse the repository at this point in the history
v3.4.0 (20-04-19 회의 이후)
- cntOn, cntOff 반환해주는 것
- data POST 누락되는 것 추가해서 class만들수 있고, id만들 수 있다.
- id에 0들어가는 것 수정.
  • Loading branch information
jongwuner committed Apr 19, 2020
1 parent 0a04b8b commit d16c977
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dev/Server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = 'com.hours22'
version = '3.3.0-SNAPSHOT'
version = '3.4.0-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ public Map<String, String> GetAllTypeDataRedis(String t1, String t2) throws Json
e.printStackTrace();
}
JSONObject jsonTmpObj = (JSONObject) obj;

if(t1.equals("CLASS")) {
Map<String, String> tmpmap = GetClassOnOffInfo(tmpMap.get("id"));
jsonTmpObj.put("cntOn", tmpmap.get("cntOn"));
jsonTmpObj.put("cntOff", tmpmap.get("cntOff"));
}
jsonArray.add(jsonTmpObj);
}
} finally {
Expand All @@ -136,6 +140,50 @@ public Map<String, String> GetAllTypeDataRedis(String t1, String t2) throws Json
return jsonObject;
}

public Map<String, String> GetClassOnOffInfo (String className) throws JsonProcessingException {

ValueOperations<String, Object> 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<byte[]> cursor = redisConnection.scan(options);
while (cursor.hasNext()) {
System.out.println("Cursor 작동중 !!!");
String tkey = new String(cursor.next());
String kvalue = mc.getConnectionHgetall(tkey);
Map<String, String> 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<String, String> ClassPcs (String className) throws JsonProcessingException {
// t1 : D401
// 2차원 초기화, PC[20][20], new PC();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,20 @@ public boolean getConnectionHset(String key, Map<String, String> 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) {
Expand All @@ -267,6 +281,8 @@ public boolean getConnectionHset(String key, Map<String, String> map) {
}
}



//@GetMapping(path="/connections/hget/{keyMap}")
public Map<String, String> getConnectionHget(String key) {
// This returns a JSON or XML with the users
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d16c977

Please sign in to comment.