|
|
@@ -1,11 +1,19 @@
|
|
|
package com.its.api.xnetudp.thread;
|
|
|
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.its.api.its.model.dto.common.NotifyDto;
|
|
|
+import com.its.api.utils.ItsUtils;
|
|
|
+import com.its.api.websocket.ItsWebSocketMessage;
|
|
|
+import com.its.api.websocket.ItsWebSocketSessionManager;
|
|
|
import com.its.api.xnetudp.protocol.CENTER_COMM_DEFINE;
|
|
|
import com.its.api.xnetudp.protocol.CENTER_COMM_MESSAGE;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.socket.TextMessage;
|
|
|
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
import java.nio.ByteBuffer;
|
|
|
import java.nio.ByteOrder;
|
|
|
|
|
|
@@ -13,6 +21,13 @@ import java.nio.ByteOrder;
|
|
|
@Service
|
|
|
public class CenterCommServerReceiver {
|
|
|
|
|
|
+ private ObjectMapper mapper;
|
|
|
+
|
|
|
+ @PostConstruct
|
|
|
+ private void init() {
|
|
|
+ this.mapper = new ObjectMapper();
|
|
|
+ }
|
|
|
+
|
|
|
@Async("centerCommExecutor")
|
|
|
public void run(CENTER_COMM_MESSAGE data) {
|
|
|
if (data == null) {
|
|
|
@@ -22,7 +37,21 @@ public class CenterCommServerReceiver {
|
|
|
|
|
|
if (CENTER_COMM_DEFINE.INT_ID_TRAFFIC_SERVER == data.getSendId()) {
|
|
|
if (CENTER_COMM_DEFINE.INT_OP_TRAFFIC_CHANGE == data.getOpCode()) {
|
|
|
- log.error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ RECV Traffic server job completed.");
|
|
|
+ log.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ RECV Traffic server job completed.");
|
|
|
+ NotifyDto notifyDto = NotifyDto.builder()
|
|
|
+ .notify("traffic")
|
|
|
+ .notifyTm(ItsUtils.getCurrFiveMinString())
|
|
|
+ .notifyCount(0)
|
|
|
+ .notifyMsg("traffic")
|
|
|
+ .build();
|
|
|
+ ItsWebSocketMessage socketMessage = new ItsWebSocketMessage("traffic", notifyDto);
|
|
|
+ try {
|
|
|
+ String jsonData = this.mapper.writeValueAsString(socketMessage);
|
|
|
+ ItsWebSocketSessionManager.getInstance().sendBroadcastMessage(socketMessage.getCommand(), new TextMessage(jsonData));
|
|
|
+ }
|
|
|
+ catch(JsonProcessingException e){
|
|
|
+ log.error("CenterCommServerReceiver NotifyDto Json parsing Exception: {}, {}", notifyDto, e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
@@ -42,10 +71,45 @@ public class CenterCommServerReceiver {
|
|
|
byte msgSeq = byteBuffer.get();
|
|
|
log.error("OP CODE: {}, MsgSeq: {}", opCode, msgSeq);
|
|
|
switch(opCode) {
|
|
|
+ case CENTER_COMM_DEFINE.INT_OP_VMS_FORM_SAVE:
|
|
|
+ byte[] saveDt = new byte[CENTER_COMM_DEFINE.INT_VMS_MAX_DATETIME];
|
|
|
+ byteBuffer.get(saveDt);
|
|
|
+ // VMS 폼을 데이터베이스에 저장(다운로드 결과는 알수 없음)
|
|
|
+ log.info("INT_OP_VMS_FORM_SAVE: SaveTime: {}", new String(saveDt));
|
|
|
+ NotifyDto notifyDto1 = NotifyDto.builder()
|
|
|
+ .notify("form-save")
|
|
|
+ .notifyTm(new String(saveDt))
|
|
|
+ .notifyCount(0)
|
|
|
+ .notifyMsg("form-save")
|
|
|
+ .build();
|
|
|
+ ItsWebSocketMessage socketMessage1 = new ItsWebSocketMessage("form-save", notifyDto1);
|
|
|
+ try {
|
|
|
+ String jsonData = this.mapper.writeValueAsString(socketMessage1);
|
|
|
+ ItsWebSocketSessionManager.getInstance().sendBroadcastMessage(socketMessage1.getCommand(), new TextMessage(jsonData));
|
|
|
+ }
|
|
|
+ catch(JsonProcessingException e){
|
|
|
+ log.error("CenterCommServerReceiver NotifyDto Json parsing Exception: {}, {}", notifyDto1, e.getMessage());
|
|
|
+ }
|
|
|
+ break;
|
|
|
case CENTER_COMM_DEFINE.INT_OP_VMS_FORM_DOWNLOAD:
|
|
|
count = byteBuffer.get();
|
|
|
- log.error("INT_OP_VMS_FORM_DOWNLOAD: Count: {} EA", count);
|
|
|
- for (int ii = 0; ii < count; ii++) {
|
|
|
+ // VMS 폼 다운로드 결과 데이터베이스 저장
|
|
|
+ log.info("INT_OP_VMS_FORM_DOWNLOAD: Count: {} EA", count);
|
|
|
+ NotifyDto notifyDto2 = NotifyDto.builder()
|
|
|
+ .notify("form-download")
|
|
|
+ .notifyTm(ItsUtils.getSysTime())
|
|
|
+ .notifyCount(0)
|
|
|
+ .notifyMsg("form-download")
|
|
|
+ .build();
|
|
|
+ ItsWebSocketMessage socketMessage2 = new ItsWebSocketMessage("form-download", notifyDto2);
|
|
|
+ try {
|
|
|
+ String jsonData = this.mapper.writeValueAsString(socketMessage2);
|
|
|
+ ItsWebSocketSessionManager.getInstance().sendBroadcastMessage(socketMessage2.getCommand(), new TextMessage(jsonData));
|
|
|
+ }
|
|
|
+ catch(JsonProcessingException e){
|
|
|
+ log.error("CenterCommServerReceiver NotifyDto Json parsing Exception: {}, {}", notifyDto2, e.getMessage());
|
|
|
+ }
|
|
|
+/* for (int ii = 0; ii < count; ii++) {
|
|
|
vmsId = new byte[CENTER_COMM_DEFINE.INT_VMS_MAX_ID];
|
|
|
byte[] downloadDt = new byte[CENTER_COMM_DEFINE.INT_VMS_MAX_DATETIME];
|
|
|
byteBuffer.get(vmsId);
|
|
|
@@ -58,12 +122,7 @@ public class CenterCommServerReceiver {
|
|
|
}
|
|
|
}
|
|
|
//log.error("{}, {}, {}, {}", ii+1, new String(vmsId).trim(), new String(downloadDt), result);
|
|
|
- }
|
|
|
- break;
|
|
|
- case CENTER_COMM_DEFINE.INT_OP_VMS_FORM_SAVE:
|
|
|
- byte[] saveDt = new byte[CENTER_COMM_DEFINE.INT_VMS_MAX_DATETIME];
|
|
|
- byteBuffer.get(saveDt);
|
|
|
- log.error("INT_OP_VMS_FORM_SAVE: SaveTime: {}", new String(saveDt));
|
|
|
+ }*/
|
|
|
break;
|
|
|
case CENTER_COMM_DEFINE.INT_OP_VMS_STATE_RES:
|
|
|
short total = byteBuffer.getShort();
|