shjung vor 1 Jahr
Ursprung
Commit
249f2c4323
20 geänderte Dateien mit 503 neuen und 108 gelöschten Zeilen
  1. 2 1
      conf/evps-comm-local.yml
  2. 2 1
      evps-comm-local/conf/evps-comm-local.yml
  3. 18 0
      evps-comm-local/src/main/java/com/evps/comm/local/config/ApplicationConfig.java
  4. 7 6
      evps-comm-local/src/main/java/com/evps/comm/local/dto/CenterDto.java
  5. 1 0
      evps-comm-local/src/main/java/com/evps/comm/local/scheduler/ApplicationScheduler.java
  6. 36 9
      evps-comm-local/src/main/java/com/evps/comm/local/service/EvpsLocalClientManagerService.java
  7. 10 39
      evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/codec/EvpsLocalClientEncoder.java
  8. 42 0
      evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsEvent.java
  9. 35 0
      evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsFrameData.java
  10. 79 0
      evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsFrameHead.java
  11. 30 0
      evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsNetPing.java
  12. 68 0
      evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsNode.java
  13. 68 0
      evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsService.java
  14. 35 0
      evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsServiceEnd.java
  15. 49 0
      evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsSignal.java
  16. 0 9
      evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/ReqEvpsLocalData.java
  17. 0 24
      evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/ReqEvpsNetPing.java
  18. 3 0
      evps-comm-local/src/main/resources/application.yml
  19. 15 16
      evps-comm-server/src/main/java/com/evps/comm/server/dao/mapper/batch/EvpCommServerDao.java
  20. 3 3
      evps-comm-server/src/main/java/com/evps/comm/server/xnet/server/process/response/EvpsServiceEnd.java

+ 2 - 1
conf/evps-comm-local.yml

@@ -8,4 +8,5 @@ application:
   server-ip: 192.168.20.44
   server-port: 7800
   connection-timeout: 5
-  retry-connect-seconds: 60
+  retry-connect-seconds: 30
+  net-ping-seconds: 30

+ 2 - 1
evps-comm-local/conf/evps-comm-local.yml

@@ -8,4 +8,5 @@ application:
   server-ip: 10.4.4.51
   server-port: 7800
   connection-timeout: 5
-  retry-connect-seconds: 60
+  retry-connect-seconds: 30
+  net-ping-seconds: 30

+ 18 - 0
evps-comm-local/src/main/java/com/evps/comm/local/config/ApplicationConfig.java

@@ -26,13 +26,31 @@ public class ApplicationConfig {
     private int serverPort = 7800;
     private int connectionTimeout = 5;
     private int retryConnectSeconds = 60;
+    private int netPingSeconds = 30;
 
     @PostConstruct
     private void init() {
         if (this.connectionTimeout < 5) {
+            this.connectionTimeout = 5;
+        }
+        if (this.connectionTimeout > 10) {
             this.connectionTimeout = 10;
         }
 
+        if (this.retryConnectSeconds < 5) {
+            this.retryConnectSeconds = 10;
+        }
+        if (this.retryConnectSeconds > 60) {
+            this.retryConnectSeconds = 60;
+        }
+
+        if (this.netPingSeconds < 30) {
+            this.netPingSeconds = 30;
+        }
+        if (this.netPingSeconds > 60) {
+            this.netPingSeconds = 60;
+        }
+
         log.info("[{}] -------------------------", this.getClass().getSimpleName());
         log.info("[{}]           server Ip: {}", this.getClass().getSimpleName(), this.serverIp);
         log.info("[{}]         server Port: {}", this.getClass().getSimpleName(), this.serverPort);

+ 7 - 6
evps-comm-local/src/main/java/com/evps/comm/local/dto/CenterDto.java

@@ -1,6 +1,6 @@
 package com.evps.comm.local.dto;
 
-import com.evps.comm.local.xnet.client.process.request.ReqEvpsLocalData;
+import com.evps.comm.local.xnet.client.process.request.EvpsFrameData;
 import com.evps.common.dto.NET;
 import com.evps.common.dto.NetState;
 import io.netty.channel.ChannelFuture;
@@ -57,18 +57,19 @@ public class CenterDto implements Serializable {
         return this.centerId;
     }
 
-    public boolean sendData(ReqEvpsLocalData data) {
+    public boolean sendData(EvpsFrameData data) {
         if (this.netState.getChannel() == null) {
-            log.warn("SEND: [{}, {}]. Channel closed. {}.", this.centerId, this.ipAddress, msg);
+            log.warn("SEND: [{}, {}]. Channel closed. {}.", this.centerId, this.ipAddress, data.getMsgType());
             return false;
         }
-        ChannelFuture f = this.netState.getChannel().writeAndFlush(c2c);
+        ChannelFuture f = this.netState.getChannel().writeAndFlush(data.getByteBuffer());
         f.awaitUninterruptibly();
         if (f.isDone() || f.isSuccess()) {
-            log.info("SEND: [{}, {}]. Packet send Ok. {}.", this.centerId, this.ipAddress, msg);
+            this.lastCommTm = System.currentTimeMillis();
+            log.info("SEND: [{}, {}]. Packet send Ok. {}.", this.centerId, this.ipAddress, data.getMsgType());
             return true;
         }
-        log.error("SEND: [{}, {}]. Packet send Failed. {}. will be closed.", this.centerId, this.ipAddress, msg);
+        log.error("SEND: [{}, {}]. Packet send Failed. {}. will be closed.", this.centerId, this.ipAddress, data.getMsgType());
         return false;
     }
 

+ 1 - 0
evps-comm-local/src/main/java/com/evps/comm/local/scheduler/ApplicationScheduler.java

@@ -24,6 +24,7 @@ public class ApplicationScheduler {
 
     @Async
     @Scheduled(cron = "10 0/10 * * * *")  // 10분주기 작업 실행
+//    @Scheduled(cron = "3 * * * * *")
     public void sendEvpsCommLocalData() {
         try {
             this.evpsLocalClientManagerService.run();

+ 36 - 9
evps-comm-local/src/main/java/com/evps/comm/local/service/EvpsLocalClientManagerService.java

@@ -3,7 +3,7 @@ package com.evps.comm.local.service;
 import com.evps.comm.local.config.ApplicationConfig;
 import com.evps.comm.local.dto.CenterDto;
 import com.evps.comm.local.repository.ApplicationRepository;
-import com.evps.comm.local.xnet.client.process.request.ReqEvpsNetPing;
+import com.evps.comm.local.xnet.client.process.request.*;
 import com.evps.common.dto.NET;
 import com.evps.common.kafka.dto.*;
 import com.evps.common.utils.EvpsUtils;
@@ -29,13 +29,29 @@ public class EvpsLocalClientManagerService {
     }
 
     public void sendPing() {
+        if (this.isRunning) {
+            log.info("Sending ping: Evps Data Sending....");
+            return; // 시뮬레이션 데이터 전송 중이면 리턴
+        }
+
         CenterDto center = ApplicationRepository.center;
         if (center.getNetState().getState() < NET.LOGIN_WAIT || center.getNetState().getChannel() == null) {
-            return;
+            log.info("Sending ping: Center communication failed.");
+            return; // 통신연결이 해제 되었으면 리턴
         }
 
-        ReqEvpsNetPing ping = new ReqEvpsNetPing(center.getSeq().nextValue());
-        center.sen
+        long currentTimeMilliSeconds = System.currentTimeMillis();
+        if (currentTimeMilliSeconds - center.getLastCommTm() >= (this.config.getNetPingSeconds() * 1000L)) {
+            // 마지막 전송 시각을 계산해서 전송해야 할 경우에만 전송
+            String now = TimeUtils.getCurrentTimeString();
+            String serviceId = this.config.getRegionId() + now + "00";
+            EvpsNetPing ping = new EvpsNetPing(serviceId, center.getSeq().nextValue());
+            center.sendData(ping);
+        }
+        else {
+            log.info("Sending ping: Last ping sent {} seconds ago. net ping duration {} seconds.",
+                    (currentTimeMilliSeconds - center.getLastCommTm()) / 1000L, this.config.getNetPingSeconds());
+        }
     }
 
     public void run() {
@@ -44,6 +60,12 @@ public class EvpsLocalClientManagerService {
             return;
         }
 
+        CenterDto center = ApplicationRepository.center;
+        if (center.getNetState().getState() < NET.LOGIN_WAIT || center.getNetState().getChannel() == null) {
+            log.info("EvpsLocalClientManagerService: Center communication failed.");
+            return; // 통신연결이 해제 되었으면 리턴
+        }
+
         this.isRunning = true;
         Elapsed elapsed = new Elapsed();
 
@@ -53,27 +75,32 @@ public class EvpsLocalClientManagerService {
 
         KafkaEvpsServiceDto serviceDto = simGenData.getServiceStartDto();
         serviceDto.setClctDt(EvpsUtils.getClctDt());
-//        this.kafkaProducerService.sendEvpsServiceTopic(serviceDto);
+        EvpsService service = new EvpsService(serviceDto);
+        center.sendData(service);
 
         KafkaEvpsNodeDto nodeDto = simGenData.getEvpsNodeDto();
         nodeDto.setClctDt(EvpsUtils.getClctDt());
-//        this.kafkaProducerService.sendEvpsNodeTopic(nodeDto);
+        EvpsNode node = new EvpsNode(nodeDto);
+        center.sendData(node);
 
         for (int ii = 0; ii < simGenData.getListSignalDto().size(); ii++) {
             TimeUtils.sleep(1000);
 
             KafkaEvpsSignalDto signalDto = simGenData.getListSignalDto().get(ii);
             signalDto.setClctDt(EvpsUtils.getClctDt());
-//            this.kafkaProducerService.sendEvpsSignalTopic(signalDto);
+            EvpsSignal signal = new EvpsSignal(signalDto);
+            center.sendData(signal);
 
             KafkaEvpsEventDto eventDto = simGenData.getListEventDto().get(ii);
             eventDto.setClctDt(EvpsUtils.getClctDt());
-//            this.kafkaProducerService.sendEvpsEventTopic(eventDto);
+            EvpsEvent event = new EvpsEvent(eventDto);
+            center.sendData(event);
         }
 
         KafkaEvpsServiceEndDto endDto = simGenData.getServiceEndDto();
         endDto.setClctDt(EvpsUtils.getClctDt());
-//        this.kafkaProducerService.sendEvpsServiceEndTopic(endDto);
+        EvpsServiceEnd serviceEnd = new EvpsServiceEnd(endDto);
+        center.sendData(serviceEnd);
 
         log.info("EvpsLocalClientManagerService: Run completed. {}", elapsed.elapsedTimeStr());
         this.isRunning = false;

+ 10 - 39
evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/codec/EvpsLocalClientEncoder.java

@@ -12,6 +12,8 @@ import lombok.extern.slf4j.Slf4j;
 import org.slf4j.MDC;
 import org.springframework.stereotype.Component;
 
+import java.nio.ByteBuffer;
+
 @Slf4j
 @RequiredArgsConstructor
 @Component
@@ -29,45 +31,14 @@ public class EvpsLocalClientEncoder extends MessageToByteEncoder<Object> {
 
         MDC.put("id", center.getLogKey());
 
-//        if (!(msg instanceof C2CAuthenticatedMessage)) {
-//            log.info("SEND: [{}, {}], Unknown Send Object type {}.", center.getLogKey(), center.getIpAddress(), msg.getClass().getName());
-//            ApplicationRepository.closeChannel(center, ctx.channel());
-//            return;
-//        }
-//
-//        C2CAuthenticatedMessage c2c = (C2CAuthenticatedMessage)msg;
-//        try {
-//            ReverseByteArrayOutputStream c2cBuff = new ReverseByteArrayOutputStream(ItsAsn.ITS_ASN_PACKET_MAX_SIZE);
-//            ReverseByteArrayOutputStream pktBuff = new ReverseByteArrayOutputStream(ItsAsn.ITS_ASN_PACKET_MAX_SIZE);
-//            int length = c2c.encode(c2cBuff);
-//            if (length > 0) {
-//                DatexDataPacket dataPkt = new DatexDataPacket();
-//                dataPkt.setDatexVersionNumber(new BerEnum(ItsAsn.DATEX_VERSION_NUMBER_VERSION1));  // version == 1
-//                dataPkt.setDatexData(new BerOctetString(c2cBuff.getArray()));
-//                dataPkt.setDatexCrcNbr(new BerOctetString(ItsAsnCrc16.getCrc16ToByteArray(c2cBuff.getArray())));  // crc
-//
-//                dataPkt.encode(pktBuff);
-//                outByteBuf.writeBytes(pktBuff.getArray());
-//                center.getNetState().setLastSendTime();
-//                log.info("SEND: [{}, {}], {} Bytes.", center.getLogKey(), center.getIpAddress(), pktBuff.getArray().length);
-//                if (center.isCommLogging()) {
-//                    byte[] debugBytes = new byte[outByteBuf.readableBytes()];
-//                    outByteBuf.getBytes(outByteBuf.readerIndex(), debugBytes);
-//                    log.info("SEND: [{}, {}], {} Bytes. {}", center.getLogKey(), center.getIpAddress(), debugBytes.length, SysUtils.byteArrayToHex(debugBytes));
-//                }
-//            }
-//            else {
-//                log.error("SEND: [{}, {}]. C2CAuthenticatedMessage encode buffer length zero: will be closed.", center.getLogKey(), center.getIpAddress());
-//                ApplicationRepository.closeChannel(center, ctx.channel());
-//            }
-//        }
-//        catch (Exception e) {
-//            log.error("SEND: [{}, {}]. Exception Error: will be closed: {}.", center.getLogKey(), center.getIpAddress(), e.getMessage());
-//            if (center.getNetState().getState() != NET.TERMINATE) {
-//                ApplicationRepository.closeChannel(center, ctx.channel());
-//            }
-//        }
-
+        if (!(msg instanceof ByteBuffer)) {
+            log.info("SEND: [{}, {}], Unknown Send Object type {}.", center.getLogKey(), center.getIpAddress(), msg.getClass().getName());
+            ApplicationRepository.closeChannel(center, ctx.channel());
+            return;
+        }
+        ByteBuffer buffer = (ByteBuffer)msg;
+        outByteBuf.writeBytes(buffer.array());
+        log.info("SEND: [{}, {}], {} Bytes.", center.getLogKey(), center.getIpAddress(), buffer.array().length);
         MDC.remove(center.getLogKey());
         MDC.clear();
     }

+ 42 - 0
evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsEvent.java

@@ -0,0 +1,42 @@
+package com.evps.comm.local.xnet.client.process.request;
+
+import com.evps.common.kafka.dto.KafkaEvpsEventDto;
+import com.evps.common.protocol.EvpsProtocolConst;
+import com.evps.common.protocol.eEvpsOpCode;
+import com.its.common.utils.ByteUtils;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+public class EvpsEvent extends EvpsFrameData {
+
+
+    public EvpsEvent(KafkaEvpsEventDto event) {
+        super(eEvpsOpCode.EVPS_EVENT.getValue(), event.getServiceId());
+
+        int bodySize = EvpsProtocolConst.EVENT_DATA_SIZE;   // lcList size short
+
+        this.body = ByteBuffer.allocate(bodySize);
+        this.body.order(ByteOrder.BIG_ENDIAN);
+        setLength(bodySize);
+
+        byte[] evNoArr = new byte[EvpsProtocolConst.EVPS_VEHICLE_NO_SIZE];
+        ByteUtils.copyStringToByteArray(evNoArr, event.getEvNo());
+        this.body.put(evNoArr);
+        this.body.putInt((int)(event.getCurLat() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+        this.body.putInt((int)(event.getCurLng() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+        this.body.putInt(event.getRemDist());
+    }
+
+    public String getMsgType() {
+        return "EvpsEvent";
+    }
+
+    public ByteBuffer getByteBuffer() {
+        ByteBuffer frame = ByteBuffer.allocate(getHeadSize() + getBodySize());
+        frame.put(getHeadBuffer().array());
+        frame.put(getBodyBuffer().array());
+        return frame;
+    }
+
+}

+ 35 - 0
evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsFrameData.java

@@ -0,0 +1,35 @@
+package com.evps.comm.local.xnet.client.process.request;
+
+import java.nio.ByteBuffer;
+
+public abstract class EvpsFrameData {
+
+    protected EvpsFrameHead head;
+    protected ByteBuffer body;
+
+    public EvpsFrameData(byte opCode, String serviceId) {
+        this.head = new EvpsFrameHead(opCode, serviceId);
+    }
+
+    public int getHeadSize() {
+        return this.head.getSize();
+    }
+    public int getBodySize() {
+        return this.body.array().length;
+    }
+
+    public void setLength(int length) {
+        this.head.setLength(length);
+    }
+
+    public ByteBuffer getHeadBuffer() {
+        return this.head.getBuffer();
+    }
+    public ByteBuffer getBodyBuffer() {
+        return this.body;
+    }
+
+    public abstract String getMsgType();
+    public abstract ByteBuffer getByteBuffer();
+
+}

+ 79 - 0
evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsFrameHead.java

@@ -0,0 +1,79 @@
+package com.evps.comm.local.xnet.client.process.request;
+
+import com.evps.common.protocol.EvpsProtocolConst;
+import com.its.common.utils.ByteUtils;
+import lombok.Data;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.time.LocalDateTime;
+
+@Data
+public class EvpsFrameHead {
+
+    public static final int HEAD_SIZE = 13;
+
+    private final byte  stx1;
+    private final byte  stx2;
+    private final byte  opCode;
+
+    private int sequence;     // unsigned short
+    private int current;      // unsigned short
+    private int total;        // unsigned short
+
+    private final short year;
+    private final byte  month;
+    private final byte  day;
+    private final byte  hour;
+    private final byte  minute;
+    private final byte  second;
+
+    private final String serviceId;   // NNN(RegionId) + YYYYMMDDHHMISS + SS(Sequence, 00 ~ 99), Total 19 bytes
+    private int   length;       // unsigned short
+
+    public EvpsFrameHead(byte opCode, String serviceId) {
+        this.stx1 = (byte)'U';
+        this.stx2 = (byte)'E';
+        this.opCode = opCode;
+        this.sequence = 1;
+        this.current = 1;
+        this.total = 1;
+        LocalDateTime now = LocalDateTime.now();
+
+        this.year   = (short)now.getYear();
+        this.month  = (byte)now.getMonthValue();
+        this.day    = (byte)now.getDayOfMonth();
+        this.hour   = (byte)now.getHour();
+        this.minute = (byte)now.getMinute();
+        this.second = (byte)now.getSecond();
+        this.serviceId = serviceId;
+        this.length = 1;
+
+    }
+
+    public int getSize() {
+        return EvpsProtocolConst.EVPS_HEAD_SIZE;
+    }
+
+    public ByteBuffer getBuffer() {
+        ByteBuffer head = ByteBuffer.allocate(EvpsProtocolConst.EVPS_HEAD_SIZE);
+        head.order(ByteOrder.BIG_ENDIAN);
+        head.put(this.stx1);
+        head.put(this.stx2);
+        head.put(this.opCode);
+        head.putShort((short)this.sequence);
+        head.putShort((short)this.current);
+        head.putShort((short)this.total);
+        head.putShort(year);
+        head.put(this.month);
+        head.put(this.day);
+        head.put(this.hour);
+        head.put(this.minute);
+        head.put(this.second);
+        byte[] serviceIdArr = new byte[EvpsProtocolConst.EVPS_SERVICE_ID_SIZE];
+        ByteUtils.copyStringToByteArray(serviceIdArr, this.serviceId);
+        head.put(serviceIdArr);
+        head.putShort((short)this.length);
+        return head;
+    }
+}

+ 30 - 0
evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsNetPing.java

@@ -0,0 +1,30 @@
+package com.evps.comm.local.xnet.client.process.request;
+
+import com.evps.common.protocol.eEvpsOpCode;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+public class EvpsNetPing extends EvpsFrameData {
+
+
+    public EvpsNetPing(String serviceId, long sequence) {
+        super(eEvpsOpCode.EVPS_NET_PING.getValue(), serviceId);
+        this.body = ByteBuffer.allocate(4);
+        this.body.order(ByteOrder.BIG_ENDIAN);
+        this.body.putInt((int)sequence);
+        setLength(4);
+    }
+
+    public String getMsgType() {
+        return "EvpsNetPing";
+    }
+
+    public ByteBuffer getByteBuffer() {
+        ByteBuffer frame = ByteBuffer.allocate(getHeadSize() + getBodySize());
+        frame.put(getHeadBuffer().array());
+        frame.put(getBodyBuffer().array());
+        return frame;
+    }
+
+}

+ 68 - 0
evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsNode.java

@@ -0,0 +1,68 @@
+package com.evps.comm.local.xnet.client.process.request;
+
+import com.evps.common.kafka.dto.*;
+import com.evps.common.protocol.EvpsProtocolConst;
+import com.evps.common.protocol.eEvpsOpCode;
+import com.its.common.utils.ByteUtils;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+public class EvpsNode extends EvpsFrameData {
+
+
+    public EvpsNode(KafkaEvpsNodeDto node) {
+        super(eEvpsOpCode.EVPS_NODE.getValue(), node.getServiceId());
+
+        int ii;
+        int bodySize = 2;   // lcList size short
+        int lcList = node.getNodeList().size();
+        for (ii = 0; ii < lcList; ii++) {
+            bodySize += (EvpsProtocolConst.MIN_NODE_DATA_NODE_SIZE) + (node.getNodeList().get(ii).getPhaseList().size() * EvpsProtocolConst.NODE_DATA_PHASE_SIZE);
+        }
+
+        this.body = ByteBuffer.allocate(bodySize);
+        this.body.order(ByteOrder.BIG_ENDIAN);
+        setLength(bodySize);
+
+        this.body.putShort((short)lcList);
+        for (ii = 0; ii < lcList; ii++) {
+            EvpsNodeInfo nodeInfo = node.getNodeList().get(ii);
+            this.body.putInt(nodeInfo.getNodeId().intValue());
+            byte[] intNameArr = new byte[EvpsProtocolConst.EVPS_NODE_NAME_SIZE];
+            ByteUtils.copyStringToByteArray(intNameArr, nodeInfo.getNodeNm());
+            this.body.put(intNameArr);
+            this.body.putInt((int)(nodeInfo.getLat() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+            this.body.putInt((int)(nodeInfo.getLng() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+            int phaseList = nodeInfo.getPhaseList().size();
+            this.body.putShort((short)phaseList);
+            for (int jj = 0; jj < phaseList; jj++) {
+                EvpsPhaseInfo phaseInfo = nodeInfo.getPhaseList().get(jj);
+                this.body.put(phaseInfo.getRing().byteValue());
+                this.body.put(phaseInfo.getPhaseNo().byteValue());
+                this.body.put(phaseInfo.getPlanClass().byteValue());
+                this.body.put(phaseInfo.getFlowNo().byteValue());
+                this.body.putInt((int)(phaseInfo.getHeadLat() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+                this.body.putInt((int)(phaseInfo.getHeadLng() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+                this.body.putInt((int)(phaseInfo.getMidLat() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+                this.body.putInt((int)(phaseInfo.getMidLng() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+                this.body.putInt((int)(phaseInfo.getEndLat() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+                this.body.putInt((int)(phaseInfo.getEndLng() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+                this.body.putShort(phaseInfo.getHeadAngle().shortValue());
+                this.body.putShort(phaseInfo.getEndAngle().shortValue());
+            }
+        }
+    }
+
+    public String getMsgType() {
+        return "EvpsNode";
+    }
+
+    public ByteBuffer getByteBuffer() {
+        ByteBuffer frame = ByteBuffer.allocate(getHeadSize() + getBodySize());
+        frame.put(getHeadBuffer().array());
+        frame.put(getBodyBuffer().array());
+        return frame;
+    }
+
+}

+ 68 - 0
evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsService.java

@@ -0,0 +1,68 @@
+package com.evps.comm.local.xnet.client.process.request;
+
+import com.evps.common.kafka.dto.EvpsRouteInfo;
+import com.evps.common.kafka.dto.KafkaEvpsServiceDto;
+import com.evps.common.protocol.EvpsProtocolConst;
+import com.evps.common.protocol.eEvpsOpCode;
+import com.its.common.utils.ByteUtils;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+public class EvpsService extends EvpsFrameData {
+
+
+    public EvpsService(KafkaEvpsServiceDto service) {
+        super(eEvpsOpCode.EVPS_SERVICE.getValue(), service.getServiceId());
+
+        int routeList = service.getRouteList().size();
+        int bodySize = (routeList * EvpsProtocolConst.SERVICE_DATA_ROUTE_SIZE) + EvpsProtocolConst.MIN_SERVICE_DATA_SIZE;
+        this.body = ByteBuffer.allocate(bodySize);
+        this.body.order(ByteOrder.BIG_ENDIAN);
+        setLength(bodySize);
+
+        byte[] evNoArr = new byte[EvpsProtocolConst.EVPS_VEHICLE_NO_SIZE];
+        ByteUtils.copyStringToByteArray(evNoArr, service.getEvNo());
+        this.body.put(evNoArr);
+
+        this.body.putInt((int)(service.getCurLat() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+        this.body.putInt((int)(service.getCurLng() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+
+        byte[] serviceNameArr = new byte[EvpsProtocolConst.EVPS_SERVICE_NAME_SIZE];
+        ByteUtils.copyStringToByteArray(serviceNameArr, service.getServiceNm());
+        this.body.put(serviceNameArr);
+
+        this.body.putInt((int)(service.getArrLat() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+        this.body.putInt((int)(service.getArrLng() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+        this.body.putInt(service.getVehLen());
+
+        byte[] ocrNoArr = new byte[EvpsProtocolConst.EVPS_OCR_NO_SIZE];
+        ByteUtils.copyStringToByteArray(ocrNoArr, service.getOcrNo());
+        this.body.put(ocrNoArr);
+
+        byte[] ocrTypeArr = new byte[EvpsProtocolConst.EVPS_OCR_TYPE_SIZE];
+        ByteUtils.copyStringToByteArray(ocrTypeArr, service.getOcrType());
+        this.body.put(ocrTypeArr);
+
+        this.body.putInt(service.getArrTm());
+        this.body.putInt(service.getServiceDist());
+        this.body.putShort((short)routeList);
+        for (int ii = 0; ii < routeList; ii++) {
+            EvpsRouteInfo routeInfo = service.getRouteList().get(ii);
+            this.body.putInt((int)(routeInfo.getLat() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+            this.body.putInt((int)(routeInfo.getLng() * EvpsProtocolConst.EVPS_GEO_CORRECT));
+        }
+    }
+
+    public String getMsgType() {
+        return "EvpsService";
+    }
+
+    public ByteBuffer getByteBuffer() {
+        ByteBuffer frame = ByteBuffer.allocate(getHeadSize() + getBodySize());
+        frame.put(getHeadBuffer().array());
+        frame.put(getBodyBuffer().array());
+        return frame;
+    }
+
+}

+ 35 - 0
evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsServiceEnd.java

@@ -0,0 +1,35 @@
+package com.evps.comm.local.xnet.client.process.request;
+
+import com.evps.common.kafka.dto.KafkaEvpsServiceEndDto;
+import com.evps.common.protocol.eEvpsOpCode;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+public class EvpsServiceEnd extends EvpsFrameData {
+
+
+    public EvpsServiceEnd(KafkaEvpsServiceEndDto service) {
+        super(eEvpsOpCode.EVPS_SERVICE_END.getValue(), service.getServiceId());
+
+        int bodySize = 4;
+
+        this.body = ByteBuffer.allocate(bodySize);
+        this.body.order(ByteOrder.BIG_ENDIAN);
+        setLength(bodySize);
+
+        this.body.putInt(service.getReason());
+    }
+
+    public String getMsgType() {
+        return "EvpsServiceEnd";
+    }
+
+    public ByteBuffer getByteBuffer() {
+        ByteBuffer frame = ByteBuffer.allocate(getHeadSize() + getBodySize());
+        frame.put(getHeadBuffer().array());
+        frame.put(getBodyBuffer().array());
+        return frame;
+    }
+
+}

+ 49 - 0
evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/EvpsSignal.java

@@ -0,0 +1,49 @@
+package com.evps.comm.local.xnet.client.process.request;
+
+import com.evps.common.kafka.dto.EvpsSignalInfo;
+import com.evps.common.kafka.dto.KafkaEvpsSignalDto;
+import com.evps.common.protocol.EvpsProtocolConst;
+import com.evps.common.protocol.eEvpsOpCode;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+public class EvpsSignal extends EvpsFrameData {
+
+
+    public EvpsSignal(KafkaEvpsSignalDto signal) {
+        super(eEvpsOpCode.EVPS_SIGNAL.getValue(), signal.getServiceId());
+
+        int ii;
+        int signalList = signal.getSignalList().size();
+        int bodySize = 2 + (signalList * EvpsProtocolConst.SIGNAL_DATA_SIGNAL_SIZE);
+
+        this.body = ByteBuffer.allocate(bodySize);
+        this.body.order(ByteOrder.BIG_ENDIAN);
+        setLength(bodySize);
+
+        this.body.putShort((short)signalList);
+        for (ii = 0; ii < signalList; ii++) {
+            EvpsSignalInfo signalInfo = signal.getSignalList().get(ii);
+            this.body.putInt(signalInfo.getNodeId().intValue());
+            this.body.putInt(signalInfo.getRemDist());
+            this.body.put(signalInfo.getState().byteValue());
+            this.body.put(signalInfo.getPlanClass().byteValue());
+            this.body.put(signalInfo.getARingPhase().byteValue());
+            this.body.put(signalInfo.getBRingPhase().byteValue());
+            this.body.put(signalInfo.getHoldPhase().byteValue());
+        }
+    }
+
+    public String getMsgType() {
+        return "EvpsSignal";
+    }
+
+    public ByteBuffer getByteBuffer() {
+        ByteBuffer frame = ByteBuffer.allocate(getHeadSize() + getBodySize());
+        frame.put(getHeadBuffer().array());
+        frame.put(getBodyBuffer().array());
+        return frame;
+    }
+
+}

+ 0 - 9
evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/ReqEvpsLocalData.java

@@ -1,9 +0,0 @@
-package com.evps.comm.local.xnet.client.process.request;
-
-import io.netty.buffer.ByteBuf;
-
-public interface ReqEvpsLocalData {
-
-    String getMsgType();
-    ByteBuf getByteBuf();
-}

+ 0 - 24
evps-comm-local/src/main/java/com/evps/comm/local/xnet/client/process/request/ReqEvpsNetPing.java

@@ -1,24 +0,0 @@
-package com.evps.comm.local.xnet.client.process.request;
-
-import io.netty.buffer.ByteBuf;
-import lombok.Data;
-
-@Data
-public class ReqEvpsNetPing implements ReqEvpsLocalData {
-
-    private long sequence;
-
-    public ReqEvpsNetPing(long sequence) {
-        this.sequence = sequence;
-    }
-
-    @Override
-    public String getMsgType() {
-        return "EvpsNetPing";
-    }
-
-    public ByteBuf getByteBuf() {
-        return null;
-    }
-
-}

+ 3 - 0
evps-comm-local/src/main/resources/application.yml

@@ -30,6 +30,9 @@ application:
   region-id: 183
   server-ip: 10.4.4.51
   server-port: 7800
+  connection-timeout: 5
+  retry-connect-seconds: 30
+  net-ping-seconds: 30
 
 ---
 spring:

+ 15 - 16
evps-comm-server/src/main/java/com/evps/comm/server/dao/mapper/batch/EvpCommServerDao.java

@@ -1,7 +1,6 @@
 package com.evps.comm.server.dao.mapper.batch;
 
 import com.evps.comm.server.dao.mapper.BatchDaoService;
-import com.its.common.utils.Elapsed;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.ibatis.session.SqlSessionFactory;
 import org.springframework.stereotype.Repository;
@@ -18,41 +17,41 @@ public class EvpCommServerDao extends BatchDaoService {
         this.serviceName = "EvpCommServerDao";
     }
     public int insertEvpRoute(List<HashMap<String, Object>> req) {
-        log.info("{}.insertEvpRoute: START. {} EA", this.serviceName, req.size());
-        Elapsed elapsed = new Elapsed();
+//        log.info("{}.insertEvpRoute: START. {} EA", this.serviceName, req.size());
+//        Elapsed elapsed = new Elapsed();
         int total = insertBatch("insertEvpRoute", req);
-        log.info("{}.insertEvpRoute: ..END. {} EA. {} ms.", this.serviceName, total, elapsed.milliSeconds());
+//        log.info("{}.insertEvpRoute: ..END. {} EA. {} ms.", this.serviceName, total, elapsed.milliSeconds());
         return total;
     }
 
     public int insertEvpNode(List<HashMap<String, Object>> req) {
-        log.info("{}.insertEvpNode: START. {} EA", this.serviceName, req.size());
-        Elapsed elapsed = new Elapsed();
+//        log.info("{}.insertEvpNode: START. {} EA", this.serviceName, req.size());
+//        Elapsed elapsed = new Elapsed();
         int total = insertBatch("insertEvpNode", req);
-        log.info("{}.insertEvpNode: ..END. {} EA. {} ms.", this.serviceName, total, elapsed.milliSeconds());
+//        log.info("{}.insertEvpNode: ..END. {} EA. {} ms.", this.serviceName, total, elapsed.milliSeconds());
         return total;
     }
 
     public int insertEvpPhase(List<HashMap<String, Object>> req) {
-        log.info("{}.insertEvpPhase: START. {} EA", this.serviceName, req.size());
-        Elapsed elapsed = new Elapsed();
+//        log.info("{}.insertEvpPhase: START. {} EA", this.serviceName, req.size());
+//        Elapsed elapsed = new Elapsed();
         int total = insertBatch("insertEvpPhase", req);
-        log.info("{}.insertEvpPhase: ..END. {} EA. {} ms.", this.serviceName, total, elapsed.milliSeconds());
+//        log.info("{}.insertEvpPhase: ..END. {} EA. {} ms.", this.serviceName, total, elapsed.milliSeconds());
         return total;
     }
 
     public int insertEvpSignal(List<HashMap<String, Object>> req) {
-        log.info("{}.insertEvpSignal: START. {} EA", this.serviceName, req.size());
-        Elapsed elapsed = new Elapsed();
+//        log.info("{}.insertEvpSignal: START. {} EA", this.serviceName, req.size());
+//        Elapsed elapsed = new Elapsed();
         int total = insertBatch("insertEvpSignal", req);
-        log.info("{}.insertEvpSignal: ..END. {} EA. {} ms.", this.serviceName, total, elapsed.milliSeconds());
+//        log.info("{}.insertEvpSignal: ..END. {} EA. {} ms.", this.serviceName, total, elapsed.milliSeconds());
         return total;
     }
     public int insertEvpSignalCurr(List<HashMap<String, Object>> req) {
-        log.info("{}.insertEvpSignalCurr: START. {} EA", this.serviceName, req.size());
-        Elapsed elapsed = new Elapsed();
+//        log.info("{}.insertEvpSignalCurr: START. {} EA", this.serviceName, req.size());
+//        Elapsed elapsed = new Elapsed();
         int total = insertBatch("insertEvpSignalCurr", req);
-        log.info("{}.insertEvpSignalCurr: ..END. {} EA. {} ms.", this.serviceName, total, elapsed.milliSeconds());
+//        log.info("{}.insertEvpSignalCurr: ..END. {} EA. {} ms.", this.serviceName, total, elapsed.milliSeconds());
         return total;
     }
 }

+ 3 - 3
evps-comm-server/src/main/java/com/evps/comm/server/xnet/server/process/response/EvpsServiceEnd.java

@@ -112,12 +112,12 @@ public class EvpsServiceEnd implements EvpsCommResponse {
         //  종료이벤트이므로 메모리에서 먼저 삭제해서 종료후 다른 이벤트가 발생하지 않도록 한다.
         ApplicationRepository.delService(service.getServiceId());
 
-        // kafka service 전송
-        this.kafkaProducerService.sendEvpsServiceEndTopic(data);
-
         // kafka event-terminate 전송
         this.kafkaProducerService.sendEvpsEventTopic(event);
 
+        // kafka service 전송
+        this.kafkaProducerService.sendEvpsServiceEndTopic(data);
+
         this.dbmsDataProcess.add(new DbmsData(DbmsData.DBMS_DATA_UPD_SERVICE, center, service));
         this.dbmsDataProcess.add(new DbmsData(DbmsData.DBMS_DATA_INS_EVENT, center, event));