shjung 2 éve
szülő
commit
c9f6610a0c

+ 2 - 0
src/main/java/com/its/dsrc/dao/mapper/RseCtlrMapper.java

@@ -22,4 +22,6 @@ public interface RseCtlrMapper {
     int insertRseCtrlHs(@Param("obj") TbRseCtrlHs obj);             // 제어이력
 
     int updateRseCtlrSttsList(@Param("list") List list);    // Not Use
+
+    int updateRseCtrlHs(@Param("obj") TbRseCtrlHs obj);
 }

+ 27 - 27
src/main/java/com/its/dsrc/entity/TbRseCtlr.java

@@ -41,7 +41,7 @@ public class TbRseCtlr {
 	private int    CLCT_ABNR_BASI;
 	private String DEL_YN;
 
-	private TbRseCtlrStts 			stts;
+	private TbRseCtlrStts     stts;
 	private int 			  netState;
 	private boolean           isDupCon;
 	private boolean           isDupLogin;
@@ -55,9 +55,9 @@ public class TbRseCtlr {
 	private HeaderOptions headerOptions = null;
 	private Login login = null;
 
-	private ConcurrentHashMap<Integer, C2CAuthenticatedMessage> registeredCommands = null;
-	private ConcurrentHashMap<Integer, Timer> registeredCommandsTimer = null;
-	private ConcurrentHashMap<Integer, TbRseCtrlHs> userCommands = null;
+	private ConcurrentHashMap<Long, C2CAuthenticatedMessage> registeredCommands = null;
+	private ConcurrentHashMap<Long, Timer> registeredCommandsTimer = null;
+	private ConcurrentHashMap<Long, TbRseCtrlHs> userCommands = null;
 	private ConcurrentHashMap<String, TbRseOffrSect> offrSectMap = null;
 
 	private int connectCount;
@@ -71,9 +71,9 @@ public class TbRseCtlr {
 
 		this.stts = new TbRseCtlrStts();
 		this.seq  = new DsrcAsn1Sequence();
-		this.registeredCommands = new ConcurrentHashMap<Integer, C2CAuthenticatedMessage>();
-		this.registeredCommandsTimer = new ConcurrentHashMap<Integer, Timer>();
-		this.userCommands = new ConcurrentHashMap<Integer, TbRseCtrlHs>();
+		this.registeredCommands = new ConcurrentHashMap<Long, C2CAuthenticatedMessage>();
+		this.registeredCommandsTimer = new ConcurrentHashMap<Long, Timer>();
+		this.userCommands = new ConcurrentHashMap<Long, TbRseCtrlHs>();
 		this.offrSectMap = new ConcurrentHashMap<String, TbRseOffrSect>();
 
 		this.connectCount = 0;
@@ -93,7 +93,7 @@ public class TbRseCtlr {
 		return this.RSE_CTLR_ID;
 	}
 	public void resetConnectCount() {
-		if (this.netState == com.its.dsrc.vo.NET.CLOSED)
+		if (this.netState == NET.CLOSED)
 			this.connectCount = 0;
 		else
 			this.connectCount = 1;
@@ -107,7 +107,7 @@ public class TbRseCtlr {
 	}
 
 	void initNet() {
-		this.netState   = com.its.dsrc.vo.NET.CLOSED;
+		this.netState   = NET.CLOSED;
 		this.isDupCon   = false;
 		this.isDupLogin = false;
 		this.dstIpAddr  = "";
@@ -123,7 +123,7 @@ public class TbRseCtlr {
 		this.login = login;
 
 		this.registeredCommands.clear();
-		for (Map.Entry<Integer, Timer> e : this.registeredCommandsTimer.entrySet()) {
+		for (Map.Entry<Long, Timer> e : this.registeredCommandsTimer.entrySet()) {
 			Timer task = e.getValue();
 			task.cancel();
 		}
@@ -144,29 +144,29 @@ public class TbRseCtlr {
 		setDisConnectTm();
 	}
 
-	public synchronized boolean addUserCommands(int packetNmbr, TbRseCtrlHs command) {
+	public synchronized boolean addUserCommands(Long packetNmbr, TbRseCtrlHs command) {
 
-		this.userCommands.put(Integer.valueOf(packetNmbr), command);
+		this.userCommands.put(packetNmbr, command);
 		return addCommandTimer(packetNmbr);
 	}
 
-	public synchronized boolean removeUserCommands(int packetNmbr) {
+	public synchronized boolean removeUserCommands(Long packetNmbr) {
 
-		TbRseCtrlHs command = this.userCommands.get(Integer.valueOf(packetNmbr));
+		TbRseCtrlHs command = this.userCommands.get(packetNmbr);
 		if (command != null) {
-			this.userCommands.remove(Integer.valueOf(packetNmbr));
+			this.userCommands.remove(packetNmbr);
 			return true;
 		}
 		return false;
 	}
 
-	public synchronized TbRseCtrlHs getUserCommands(int packetNmbr) {
+	public synchronized TbRseCtrlHs getUserCommands(Long packetNmbr) {
 
-		TbRseCtrlHs command = this.userCommands.get(Integer.valueOf(packetNmbr));
+		TbRseCtrlHs command = this.userCommands.get(packetNmbr);
 		return command;
 	}
 
-	private boolean addCommandTimer(int packetNmbr) {
+	private boolean addCommandTimer(Long packetNmbr) {
 
 		long timeoutSec = this.login.getDatexLoginResponseTimeOutQty().value.longValue();
 		if (timeoutSec == 0L || timeoutSec > 30L) {
@@ -178,7 +178,7 @@ public class TbRseCtlr {
 		timeoutSec = 1000L * timeoutSec;
 		Timer timer = new Timer();
 		timer.schedule((TimerTask)new DsrcAsn1TimeoutTask(this, packetNmbr), timeoutSec);
-		this.registeredCommandsTimer.put(Integer.valueOf(packetNmbr), timer);
+		this.registeredCommandsTimer.put(packetNmbr, timer);
 
 		log.info("addCommandTimer: [{}], packetNmbr: {}, timeoutSec: {} ms, {}", this.RSE_CTLR_NMBR, packetNmbr, timeoutSec, timer);
 		return true;
@@ -195,8 +195,8 @@ public class TbRseCtlr {
 			return false;
 		}
 
-		int packetNmbr = c2c.getDatexDataPacketNumber().value.intValue();
-		this.registeredCommands.put(Integer.valueOf(packetNmbr), c2c);
+		Long packetNmbr = c2c.getDatexDataPacketNumber().value.longValue();
+		this.registeredCommands.put(packetNmbr, c2c);
 		return addCommandTimer(packetNmbr);
 	}
 
@@ -209,24 +209,24 @@ public class TbRseCtlr {
 		return true;
 	}
 
-	public synchronized boolean removeRegisteredCommands(int packetNmbr, boolean cancelTimer) {
+	public synchronized boolean removeRegisteredCommands(Long packetNmbr, boolean cancelTimer) {
 
-		Timer timer = this.registeredCommandsTimer.get(Integer.valueOf(packetNmbr));
+		Timer timer = this.registeredCommandsTimer.get(packetNmbr);
 		if (timer != null) {
 			if (cancelTimer)
 				timer.cancel();
-			this.registeredCommandsTimer.remove(Integer.valueOf(packetNmbr));
+			this.registeredCommandsTimer.remove(packetNmbr);
 		}
 
-		C2CAuthenticatedMessage c2c = this.registeredCommands.get(Integer.valueOf(packetNmbr));
+		C2CAuthenticatedMessage c2c = this.registeredCommands.get(packetNmbr);
 		if (c2c != null) {
-			this.registeredCommands.remove(Integer.valueOf(packetNmbr));
+			this.registeredCommands.remove(packetNmbr);
 		}
 		return false;
 	}
 
 	public synchronized C2CAuthenticatedMessage getRegisteredCommands(int packetNmbr) {
-		C2CAuthenticatedMessage c2c = this.registeredCommands.get(Integer.valueOf(packetNmbr));
+		C2CAuthenticatedMessage c2c = this.registeredCommands.get(packetNmbr);
 		return c2c;
 	}
 

+ 7 - 9
src/main/java/com/its/dsrc/entity/TbRseCtrlHs.java

@@ -8,13 +8,11 @@ import lombok.ToString;
 @Setter
 @ToString
 public class TbRseCtrlHs {
-    private String RSE_CTLR_NMBR;   //	N	NUMBER(10)	    N			RSE 제어기 번호
-    private String CNTL_DT;         //	N	VARCHAR2(14)	N			제어 일시
-    private String DEVC_TYPE;       //	N	VARCHAR2(7)	    N			장치 유형
-    private String CNTL_TYPE;       //	N	VARCHAR2(7)	    Y			제어 유형
-    private String RSPS_TYPE;       //	N	VARCHAR2(7)	    Y			응답 유형
-
-    //CENTER_DSRC_REQ_CONTROL req;
-    String           reqIpAddress;
-    int              reqPort;
+    private Long ctrlSeq;
+    private Long rseCtlrNmbr;
+    private String cntlDt;
+    private String devcType;
+    private String cntlType;
+    private String rspsType;
+    private String userId;
 }

+ 0 - 2
src/main/java/com/its/dsrc/entity/TbRseObuClct.java

@@ -15,6 +15,4 @@ public class TbRseObuClct {
     private String OBU_IDNT_NMBR;   //	N	VARCHAR2(200)	N			OBU 인식 번호
     private String CTYP;            //	N	VARCHAR2(7)	    Y			차종
     private String OBU_KIND;        //	N	VARCHAR2(7)	    Y			OBU 종류
-    //TODO
-    private String PREV_RSE_CTLR_NMBR;  // 이전 통과 RSE
 }

+ 104 - 76
src/main/java/com/its/dsrc/xnettcp/center/handler/CenterTcpServerInboundHandler.java

@@ -1,13 +1,27 @@
 package com.its.dsrc.xnettcp.center.handler;
 
+import com.beanit.asn1dsrc.enums.eControlCommand;
+import com.beanit.asn1dsrc.enums.eControlDeviceId;
+import com.its.app.AppUtils;
 import com.its.app.utils.NettyUtils;
+import com.its.dsrc.dao.mapper.RseCtlrMapper;
+import com.its.dsrc.entity.TbRseCtlr;
+import com.its.dsrc.entity.TbRseCtrlHs;
+import com.its.dsrc.global.AppRepository;
+import com.its.dsrc.vo.NET;
+import com.its.dsrc.xnettcp.center.protocol.CenterProtocol;
 import com.its.dsrc.xnettcp.center.protocol.CenterReqFramePacket;
+import com.its.dsrc.xnettcp.center.protocol.CenterResProtocol;
+import com.its.dsrc.xnettcp.dsrc.process.service.ControlDeviceService;
+import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelInboundHandlerAdapter;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 
+import java.nio.ByteBuffer;
+
 @Slf4j
 @Component
 @ChannelHandler.Sharable
@@ -15,87 +29,101 @@ public class CenterTcpServerInboundHandler extends ChannelInboundHandlerAdapter
 
     public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
 
+        RseCtlrMapper mapper = (RseCtlrMapper) AppUtils.getBean(RseCtlrMapper.class);
         String ipAddress = NettyUtils.getRemoteIpAddress(ctx.channel());
         if (!(msg instanceof CenterReqFramePacket)) {
             log.error("[{}] | Received Data is not CenterReqFramePacket Object", NettyUtils.getRemoteIpAddress(ctx.channel()));
             return;
         }
-//        CenterReqFramePacket centerReqHead = (CenterReqFramePacket)msg;
-//        VdsReqFrameHead vdsReqHead = new VdsReqFrameHead(centerReqHead.getBody());
-//        short groupNo = vdsReqHead.getGroupNo();
-//        short ctlrNo = vdsReqHead.getControllerNo();
-//        byte opCode = vdsReqHead.getOpCode();
-//
-//        TbVdsCtlr obj = null;
-//        for (Map.Entry<String, TbVdsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
-//            TbVdsCtlr tmp = e.getValue();
-//            if (tmp.getVDS_CTLR_LOCAL_NO() == ctlrNo) {
-//                obj = tmp;
-//                break;
-//            }
-//        }
-//        if (obj == null) {
-//            log.error("CenterTcpServerInboundHandler: Center Request Unknown VDS: [{}]", ctlrNo);
-//            ByteBuffer sendBuffer = CenterResProtocol.getResponse(opCode, (byte)(0xFF));
-//            ChannelFuture f = ctx.channel().writeAndFlush(sendBuffer);
-//            f.awaitUninterruptibly();
-//            if (f.isDone() || f.isSuccess()) {
-//                log.info("CenterTcpServerInboundHandler: Response OK. Center Request Unknown VDS: [{}]", ctlrNo);
-//            } else {
-//                log.error("CenterTcpServerInboundHandler: Response Failed. Center Request Unknown VDS: [{}]", ctlrNo);
-//            }
-//            return;
-//        }
-//        if (obj.getChannel() == null || obj.getNetState() == NET.CLOSED) {
-//            log.error("CenterTcpServerInboundHandler: Center Request VDS Not Connect: [{}]", obj);
-//            ByteBuffer sendBuffer = CenterResProtocol.getResponse(opCode, (byte)(0xFE));
-//            ChannelFuture f = ctx.channel().writeAndFlush(sendBuffer);
-//            f.awaitUninterruptibly();
-//            if (f.isDone() || f.isSuccess()) {
-//                log.info("CenterTcpServerInboundHandler: Response OK. Center Not Connect VDS: [{}]", ctlrNo);
-//            } else {
-//                log.error("CenterTcpServerInboundHandler: Response Failed. Center Not Connect VDS: [{}]", ctlrNo);
-//            }
-//            return;
-//        }
-//
-//        if (opCode == VdsProtocol.vds_Reset) {
-//            ByteBuffer resultBuffer;
-//            VdsReqReset reqReset = new VdsReqReset((short)obj.getGROUP_NO(), (short)obj.getVDS_CTLR_LOCAL_NO());
-//            reqReset.makeCRC();
-//            ByteBuffer sendBuffer = reqReset.getByteBuffer();
-//            if (!obj.sendData(sendBuffer, 0, "vds_Reset")) {
-//                log.error("CenterTcpServerInboundHandler: Center Request VDS Reset Data Send Failed: [{}]", obj);
-//                resultBuffer = CenterResProtocol.getResponse(opCode, (byte)(0xFD));
-//            } else {
-//                resultBuffer = CenterResProtocol.getResponse(opCode, (byte)(0x00));
-//            }
-//            ChannelFuture f = ctx.channel().writeAndFlush(resultBuffer);
-//            f.awaitUninterruptibly();
-//            if (f.isDone() || f.isSuccess()) {
-//                log.info("CenterTcpServerInboundHandler: Response OK. VDS Reset: [{}]", ctlrNo);
-//            } else {
-//                log.error("CenterTcpServerInboundHandler: Response Failed. VDS Reset: [{}]", ctlrNo);
-//            }
-//        }
-//        else if (opCode == VdsProtocol.vds_Image) {
-//            int frameNo = 0;    // first image request
-//            byte cameraNo = (centerReqHead.getBody()[9] == (byte)0x00) ? (byte)0x01 : centerReqHead.getBody()[9];
-//            obj.setStopImageRequest(ctx.channel(), cameraNo, frameNo);
-//            VdsReqImage reqImage = new VdsReqImage((short)obj.getGROUP_NO(), (short)obj.getVDS_CTLR_LOCAL_NO());
-//            reqImage.setCameraNo(cameraNo);
-//            reqImage.setFrameNo(frameNo);
-//            reqImage.makeCRC();
-//            ByteBuffer sendBuffer = reqImage.getByteBuffer();
-//            if (!obj.sendData(sendBuffer, 0, "vds_Image")) {
-//                obj.setStopImageResponse();
-//                log.error("CenterTcpServerInboundHandler: Center Request VDS Image Data Send Failed: [{}]", obj);
-//            }
-//        }
-//        else {
-//            log.error("CenterTcpServerInboundHandler: Center Request Not Support: [{}]", opCode);
-//            return;
-//        }
+        CenterReqFramePacket centerReqHead = (CenterReqFramePacket)msg;
+        byte opCode = centerReqHead.getHead().getOpCode();
+        byte[] body = centerReqHead.getBody();
+        if (body == null) {
+            return;
+        }
+        ByteBuffer msgBuffer = ByteBuffer.wrap(body);
+        msgBuffer.order(CenterProtocol.byteOrder);
+        if (opCode == CenterProtocol.INT_OP_DSRC_CONTROL_REQ) {
+            long ctlrNmbr = msgBuffer.getLong();
+            long ctrlSeq = msgBuffer.getLong();
+            int devcType = msgBuffer.getInt();
+            int cntlType = msgBuffer.getInt();
+
+            TbRseCtrlHs cntl = new TbRseCtrlHs();
+            cntl.setCtrlSeq(ctrlSeq);
+            cntl.setDevcType(String.valueOf(devcType));
+            cntl.setCntlType(String.valueOf(cntlType));
+            cntl.setRspsType("0");
+
+            TbRseCtlr obj = AppRepository.getInstance().getCtlrMap().get(String.valueOf(ctlrNmbr));
+            if (obj == null) {
+                log.error("CenterTcpServerInboundHandler: Center Request Unknown RSE: [{}]", ctlrNmbr);
+                cntl.setRspsType("9");  // 알수없는제어기
+                ByteBuffer sendBuffer = CenterResProtocol.getResponse(opCode, (byte)(0xFF));
+                ChannelFuture f = ctx.channel().writeAndFlush(sendBuffer);
+                f.awaitUninterruptibly();
+                if (f.isDone() || f.isSuccess()) {
+                    log.info("CenterTcpServerInboundHandler: Response OK. Center Request Unknown VDS: [{}]", ctlrNmbr);
+                } else {
+                    log.error("CenterTcpServerInboundHandler: Response Failed. Center Request Unknown VDS: [{}]", ctlrNmbr);
+                }
+                mapper.updateRseCtrlHs(cntl);
+                return;
+            }
+
+            if (obj.getChannel() == null || obj.getNetState() == NET.CLOSED) {
+                log.error("CenterTcpServerInboundHandler: Center Request VDS Not Connect: [{}]", obj);
+                ByteBuffer sendBuffer = CenterResProtocol.getResponse(opCode, (byte)(0xFE));
+                cntl.setRspsType("8");  // 통신불량
+                ChannelFuture f = ctx.channel().writeAndFlush(sendBuffer);
+                f.awaitUninterruptibly();
+                if (f.isDone() || f.isSuccess()) {
+                    log.info("CenterTcpServerInboundHandler: Response OK. Center Not Connect VDS: [{}]", ctlrNmbr);
+                } else {
+                    log.error("CenterTcpServerInboundHandler: Response Failed. Center Not Connect VDS: [{}]", ctlrNmbr);
+                }
+                mapper.updateRseCtrlHs(cntl);
+                return;
+            }
+
+            // 제어요청 패킷을 만든다
+            eControlDeviceId controlDeviceId = eControlDeviceId.getByValue(devcType);
+            eControlCommand commandType = eControlCommand.getByValue(cntlType);
+            if (controlDeviceId == null || commandType == null) {
+                log.error("RSE REQ RESET CONTROL Value Error: [{}] [{},{}]", ctlrNmbr, devcType, cntlType);
+                ByteBuffer sendBuffer = CenterResProtocol.getResponse(opCode, (byte)(0xFD));
+                cntl.setRspsType("7");  // 통신불량
+                ChannelFuture f = ctx.channel().writeAndFlush(sendBuffer);
+                f.awaitUninterruptibly();
+                if (f.isDone() || f.isSuccess()) {
+                    log.info("CenterTcpServerInboundHandler: Response OK. Center Not Connect VDS: [{}]", ctlrNmbr);
+                } else {
+                    log.error("CenterTcpServerInboundHandler: Response Failed. Center Not Connect VDS: [{}]", ctlrNmbr);
+                }
+                mapper.updateRseCtrlHs(cntl);
+                return;
+            }
+
+            log.warn("[{}] [{},{}], controlDeviceId: {}, commandType: {}", ctlrNmbr, devcType, cntlType, controlDeviceId.toString(), commandType.toString());
+            boolean res = ControlDeviceService.getInstance().requestSubscriptionDeviceCommand(true, obj, obj.getChannel(), controlDeviceId.getValue(), commandType.getValue(), cntl);
+            if (res) {
+                log.info("RSE REQ CONTROL SEND OK: [{}] [{},{}]", ctlrNmbr, devcType, cntlType);
+                cntl.setRspsType("0");  // 성공, 리셋응답없을수 있으므로 먼저 성공으로 입력한다.
+            } else {
+                log.error("RSE REQ CONTROL SEND Error: [{}] [{},{}]", ctlrNmbr, devcType, cntlType);
+                ByteBuffer sendBuffer = CenterResProtocol.getResponse(opCode, (byte)(0xFC));
+                cntl.setRspsType("6");  // 데이터전송실패
+                ChannelFuture f = ctx.channel().writeAndFlush(sendBuffer);
+                f.awaitUninterruptibly();
+                if (f.isDone() || f.isSuccess()) {
+                    log.info("CenterTcpServerInboundHandler: Response OK. Center Not Connect VDS: [{}]", ctlrNmbr);
+                } else {
+                    log.error("CenterTcpServerInboundHandler: Response Failed. Center Not Connect VDS: [{}]", ctlrNmbr);
+                }
+            }
+            mapper.updateRseCtrlHs(cntl);
+        }
+
     }
 
 }

+ 1 - 1
src/main/java/com/its/dsrc/xnettcp/center/protocol/CenterProtocol.java

@@ -36,7 +36,7 @@ public class CenterProtocol {
     public static final int INT_ID_SIG_OPER 			= 0x23;    /* 신호운영단말 */
     public static final int INT_ID_VDS_OPER 			= 0x24;    /* VDS운영단말 */
     public static final int INT_ID_AVI_OPER 			= 0x25;    /* AVI운영단말 */
-    public static final int INT_ID_DSRC_OPER 			= 0x26;    /* DSRC운영단말 */
+    public static final int INT_ID_RSE_OPER 			= 0x26;    /* DSRC운영단말 */
     public static final int INT_ID_VMS_OPER 			= 0x27;    /* VMS운영단말 */
     public static final int INT_ID_CCTV_OPER 			= 0x28;    /* CCTV운영단말 */
     public static final int INT_ID_FMS_OPER 			= 0x29;    /* 시설물관리단말 */

+ 2 - 34
src/main/java/com/its/dsrc/xnettcp/center/protocol/CenterResProtocol.java

@@ -5,24 +5,11 @@ import java.nio.ByteOrder;
 
 public class CenterResProtocol {
 
-    public static ByteBuffer getImageHeader1() {
-        ByteBuffer byteBuffer = ByteBuffer.allocate(10);
-        byteBuffer.order(ByteOrder.BIG_ENDIAN);
-        byteBuffer.put((byte)0x00); // 송신시스템-운영단말
-        byteBuffer.put((byte)0x00); // 수신시스템-VDS 서버
-        byteBuffer.put((byte)0x00); // 전체프레임개수
-        byteBuffer.put((byte)0x00); // 현재프레임번호
-        byteBuffer.put((byte)0x00); // Reserved
-        //byteBuffer.put(VdsProtocol.vds_Image);     // OP Code
-        byteBuffer.putInt(0);  // 데이터 길이
-
-        return byteBuffer;
-    }
     public static ByteBuffer getResponse(byte opCode, byte result) {
         ByteBuffer byteBuffer = ByteBuffer.allocate(10);
         byteBuffer.order(ByteOrder.BIG_ENDIAN);
-        byteBuffer.put((byte)0x24); // 송신시스템-운영단말
-        byteBuffer.put((byte)0x04); // 수신시스템-VDS 서버
+        byteBuffer.put((byte)CenterProtocol.INT_ID_RSE_SERVER); // 송신시스템-운영단말
+        byteBuffer.put((byte)CenterProtocol.INT_ID_RSE_OPER); // 수신시스템-RSE 서버
         byteBuffer.put((byte)0x01); // 전체프레임개수
         byteBuffer.put((byte)0x01); // 현재프레임번호
         byteBuffer.put(result); // Reserved
@@ -32,23 +19,4 @@ public class CenterResProtocol {
         return byteBuffer;
     }
 
-    public static ByteBuffer getImageHeader2(int length) {
-        ByteBuffer byteBuffer = ByteBuffer.allocate(172);
-        byteBuffer.order(ByteOrder.BIG_ENDIAN);
-        for (int ii = 0; ii < 159; ii++) {
-            byteBuffer.put((byte)0x00);
-        }
-        byteBuffer.putInt(length);  // 데이터 길이
-        for (int ii = 163; ii < 172; ii++) {
-            byteBuffer.put((byte)0x00);
-        }
-        return byteBuffer;
-    }
-
-    public static ByteBuffer getImageData(byte[] data) {
-        ByteBuffer byteBuffer = ByteBuffer.wrap(data);
-        byteBuffer.order(ByteOrder.BIG_ENDIAN);
-        return byteBuffer;
-    }
-
 }

+ 5 - 5
src/main/java/com/its/dsrc/xnettcp/dsrc/process/response/AcceptResponse.java

@@ -5,11 +5,10 @@ import com.beanit.asn1dsrc.dsrc.C2CAuthenticatedMessage;
 import com.beanit.asn1dsrc.dsrc.PDUs;
 import com.its.app.AppUtils;
 import com.its.app.utils.NettyUtils;
+import com.its.dsrc.dao.mapper.RseCtlrMapper;
 import com.its.dsrc.entity.TbRseCtlr;
 import com.its.dsrc.entity.TbRseCtrlHs;
-import com.its.dsrc.process.DbmsData;
 import com.its.dsrc.process.DbmsDataProcess;
-import com.its.dsrc.process.DbmsDataType;
 import io.netty.channel.ChannelHandlerContext;
 import lombok.extern.slf4j.Slf4j;
 
@@ -41,7 +40,7 @@ public class AcceptResponse implements DsrcAsn1Response {
 
         TbRseCtrlHs command = null;
         long dataPacketNmbr = c2c.getDatexDataPacketNumber().value.longValue();
-        int acceptPacketNmbr = accept.getDatexAcceptPacketNbr().value.intValue();
+        Long acceptPacketNmbr = accept.getDatexAcceptPacketNbr().value.longValue();
         Accept.DatexAcceptType acceptType = accept.getDatexAcceptType();
         if (acceptType.getLogIn() != null) {
             // Login = 1, 여기는 들어오지 않는다.
@@ -74,8 +73,9 @@ public class AcceptResponse implements DsrcAsn1Response {
             log.info("AcceptResponse.response: {}. Accept User Command: {} {}", ipAddress, dataPacketNmbr, acceptPacketNmbr);
             this.obj.removeUserCommands(acceptPacketNmbr);
             // TODO: 제어명령 성공 전송(성공)
-            command.setRSPS_TYPE("0");  // 명령 성공으로 설정
-            this.dbmsDataProcess.add(new DbmsData(DbmsDataType.DBMS_DATA_CTRL_HS, false, command));
+            command.setRspsType("0");  // 명령 성공으로 설정
+            RseCtlrMapper mapper = (RseCtlrMapper) AppUtils.getBean(RseCtlrMapper.class);
+            mapper.updateRseCtrlHs(command);
         }
         return true;
     }

+ 5 - 5
src/main/java/com/its/dsrc/xnettcp/dsrc/process/response/RejectResponse.java

@@ -6,11 +6,10 @@ import com.beanit.asn1dsrc.dsrc.Reject;
 import com.beanit.asn1dsrc.dsrc.RejectType;
 import com.its.app.AppUtils;
 import com.its.app.utils.NettyUtils;
+import com.its.dsrc.dao.mapper.RseCtlrMapper;
 import com.its.dsrc.entity.TbRseCtlr;
 import com.its.dsrc.entity.TbRseCtrlHs;
-import com.its.dsrc.process.DbmsData;
 import com.its.dsrc.process.DbmsDataProcess;
-import com.its.dsrc.process.DbmsDataType;
 import com.its.dsrc.xnettcp.dsrc.handler.DsrcAsn1ServerIdleStatePacketHandler;
 import io.netty.channel.ChannelHandlerContext;
 import lombok.extern.slf4j.Slf4j;
@@ -42,7 +41,7 @@ public class RejectResponse implements DsrcAsn1Response {
         }
 
         long dataPacketNmbr = c2c.getDatexDataPacketNumber().value.longValue();
-        int  rejectPacketNmbr = reject.getDatexRejectPacketNbr().value.intValue();
+        Long  rejectPacketNmbr = reject.getDatexRejectPacketNbr().value.longValue();
         RejectType rejectType = reject.getDatexRejectType();
 
         TbRseCtrlHs command = null;
@@ -70,8 +69,9 @@ public class RejectResponse implements DsrcAsn1Response {
             log.error("RejectResponse.response: {}. Reject User Command: dataPacketNmbr: {}, rejectPacketNmbr: {}, rejectCode: {}", ipAddress, dataPacketNmbr, rejectPacketNmbr, rejectCode);
             this.obj.removeUserCommands(rejectPacketNmbr);
             // TODO: 제어명령 전송정보 전송(실패)
-            command.setRSPS_TYPE("1");  // 명령 실패(REJECT)로 설정
-            this.dbmsDataProcess.add(new DbmsData(DbmsDataType.DBMS_DATA_CTRL_HS, false, command));
+            command.setRspsType("4");  // 명령 실패(REJECT)로 설정
+            RseCtlrMapper mapper = (RseCtlrMapper) AppUtils.getBean(RseCtlrMapper.class);
+            mapper.updateRseCtrlHs(command);
         }
         return true;
     }

+ 6 - 5
src/main/java/com/its/dsrc/xnettcp/dsrc/process/service/ControlDeviceService.java

@@ -8,6 +8,7 @@ import com.beanit.asn1dsrc.util.DsrcAsn1Utils;
 import com.its.app.AppUtils;
 import com.its.app.utils.SysUtils;
 import com.its.dsrc.entity.TbRseCtlr;
+import com.its.dsrc.entity.TbRseCtrlHs;
 import com.its.dsrc.entity.TbRseObuNonCrypt;
 import com.its.dsrc.entity.TbRseOffrDrct;
 import com.its.dsrc.global.AppRepository;
@@ -228,7 +229,7 @@ public class ControlDeviceService {
         return true;
     }
 
-    public boolean requestSubscriptionDeviceCommand(boolean fromOperator, TbRseCtlr obj, Channel channel, int controlDeviceId, int commandType)
+    public boolean requestSubscriptionDeviceCommand(boolean fromOperator, TbRseCtlr obj, Channel channel, int controlDeviceId, int commandType, TbRseCtrlHs cntl)
     {
         log.info("ControlDeviceService.requestSubscriptionDeviceCommand: {}, {}, operator: {}, controlDeviceId: {}, commandType: {}", obj.getID(), obj.getRSE_ID(), fromOperator, controlDeviceId, commandType);
         try {
@@ -313,6 +314,10 @@ public class ControlDeviceService {
             f.awaitUninterruptibly();
             if (f.isDone() || f.isSuccess()) {
                 log.info("ControlDeviceService.requestSubscriptionDeviceCommand: {}, {}, operator: {}, send ok", obj.getID(), obj.getRSE_ID(), fromOperator);
+                if (fromOperator) {
+                    // TODO: 리셋 명령은 응답을 안 받으므로 타임아웃 체크를 하지 않는다.
+                    //obj.addUserCommands(cntl.getCtrlSeq(), cntl);
+                }
             } else {
                 log.error("ControlDeviceService.requestSubscriptionDeviceCommand: {}, {}, operator: {}, send failed.", obj.getID(), obj.getRSE_ID(), fromOperator);
                 return false;
@@ -322,10 +327,6 @@ public class ControlDeviceService {
             log.error("ControlDeviceService.requestSubscriptionDeviceCommand: {}, {}, operator: {}, Exception: {}", obj.getID(), obj.getRSE_ID(), fromOperator, e.toString());
             return false;
         }
-
-        if (fromOperator) {
-            //obj.addUserCommands(packetNmbr, cntl);
-        }
         return true;
     }
 

+ 1 - 1
src/main/java/com/its/dsrc/xnettcp/dsrc/process/service/LoginDeviceService.java

@@ -66,7 +66,7 @@ public class LoginDeviceService {
      */
     public boolean requestSubscriptionDeviceCommand(TbRseCtlr obj, Channel channel, int controlDeviceId, int commandType)
     {
-        return ControlDeviceService.getInstance().requestSubscriptionDeviceCommand(false, obj, channel, controlDeviceId, commandType);
+        return ControlDeviceService.getInstance().requestSubscriptionDeviceCommand(false, obj, channel, controlDeviceId, commandType, null);
     }
 
     /*

+ 1 - 2
src/main/java/com/its/dsrc/xnettcp/dsrc/process/service/OBUGatherInfoService.java

@@ -72,7 +72,6 @@ public class OBUGatherInfoService {
                 String obuIdNumber = "0";
                 String generationDate = "0";
                 String generationTime = "0";
-                String prevRseCtlrNmbr = "";
                 if (obuGatherInfo.getObuType() != null) {
                     obuType = obuGatherInfo.getObuType().toString();
                 }
@@ -93,7 +92,7 @@ public class OBUGatherInfoService {
                 //
 
                 String generationTm = generationDate+generationTime;
-                TbRseObuClct voObu = new TbRseObuClct(obj.getID(), generationTm, obuIdNumber, vehicleType, obuType, prevRseCtlrNmbr);
+                TbRseObuClct voObu = new TbRseObuClct(obj.getID(), generationTm, obuIdNumber, vehicleType, obuType);
                 obuGatherInfos.add(voObu);
 
                 log.debug("OBUGatherInfoService.decoding_OBUGatherInfo: {}, {}, {}, {}, voObu: {}",

+ 6 - 8
src/main/java/com/its/dsrc/xnettcp/dsrc/task/DsrcAsn1TimeoutTask.java

@@ -1,11 +1,9 @@
 package com.its.dsrc.xnettcp.dsrc.task;
 
 import com.its.app.AppUtils;
+import com.its.dsrc.dao.mapper.RseCtlrMapper;
 import com.its.dsrc.entity.TbRseCtlr;
 import com.its.dsrc.entity.TbRseCtrlHs;
-import com.its.dsrc.process.DbmsData;
-import com.its.dsrc.process.DbmsDataProcess;
-import com.its.dsrc.process.DbmsDataType;
 import lombok.extern.slf4j.Slf4j;
 import org.slf4j.MDC;
 
@@ -15,9 +13,9 @@ import java.util.TimerTask;
 public class DsrcAsn1TimeoutTask extends TimerTask {
 
     private final TbRseCtlr obj;
-    private final int       packetNmbr;
+    private final Long      packetNmbr;
 
-    public DsrcAsn1TimeoutTask(TbRseCtlr obj, int packetNmbr) {
+    public DsrcAsn1TimeoutTask(TbRseCtlr obj, Long packetNmbr) {
         this.obj = obj;
         this.packetNmbr = packetNmbr;
     }
@@ -34,9 +32,9 @@ public class DsrcAsn1TimeoutTask extends TimerTask {
         if (command != null) {
             this.obj.removeUserCommands(this.packetNmbr);
             // TODO: 제어명령 성공 전송(실패)
-            command.setRSPS_TYPE("2");  // 명령 실패(타임아웃)로 설정
-            DbmsDataProcess dbmsDataProcess = (DbmsDataProcess) AppUtils.getBean(DbmsDataProcess.class);
-            dbmsDataProcess.add(new DbmsData(DbmsDataType.DBMS_DATA_CTRL_HS, false, command));
+            command.setRspsType("5");  // 명령 실패(타임아웃)로 설정
+            RseCtlrMapper mapper = (RseCtlrMapper) AppUtils.getBean(RseCtlrMapper.class);
+            mapper.updateRseCtrlHs(command);
         }
 
         MDC.remove(this.obj.getLogKey());

+ 8 - 0
src/main/resources/mybatis/mapper/RseCtlrMapper.xml

@@ -482,4 +482,12 @@
         ]]>
     </insert>
 
+    <insert id="updateRseCtrlHs" parameterType="com.its.dsrc.entity.TbRseCtrlHs">
+    <![CDATA[
+        UPDATE TB_RSE_CTRL_HS
+            SET RSPS_TYPE = #{obj.RSPS_TYPE}
+        WHERE CTRL_SEQ = #{obj.CTRL_SEQ}
+        ]]>
+    </insert>
+
 </mapper>