Browse Source

vmsifsc delete update

shjung 3 năm trước cách đây
mục cha
commit
776e78038a

+ 5 - 0
src/main/java/com/its/op/dao/repository/its/vms/TbVmsCmtrInfrRepository.java

@@ -3,6 +3,7 @@ package com.its.op.dao.repository.its.vms;
 import com.its.op.entity.its.vms.TbVmsCmtrInfr;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
@@ -19,4 +20,8 @@ public interface TbVmsCmtrInfrRepository extends JpaRepository<TbVmsCmtrInfr, Lo
            " where p.vmsIfscId in (select s.vmsIfscId from TbVmsIfscRltn s where s.vmsCtlrNmbr = :vmsCtlrNmbr)")
     List<TbVmsCmtrInfr> findAllByVms(@Param("vmsCtlrNmbr") Long vmsCtlrNmbr);
 
+    @Modifying
+    @Query("delete from TbVmsCmtrInfr p where p.vmsIfscId = :vmsIfscId")
+    void deleteDataById(@Param("vmsIfscId") Long vmsIfscId);
+
 }

+ 36 - 2
src/main/java/com/its/op/service/its/vds/VdsControlService.java

@@ -216,7 +216,30 @@ public class VdsControlService {
                 OutputStream os = socket.getOutputStream();
                 os.write(data);
                 os.flush();
-                result.setResult(0, "VDS 서버에 제어기 리셋명령을 정상적으로 전송하였습니다.");
+                InputStream recvStream = socket.getInputStream();
+                try {
+                    while (true) {
+                        byte[] head = receiveBytes(recvStream, 10);
+                        if (head[0] == (byte)0x24 && head[1] == (byte)0x04 && head[5] == (byte)0x0C) {
+                            log.info("RECV RESPONSE HEAD: 10 Bytes. {}", SysUtils.byteArrayToHex(head));
+                            if (head[4] == (byte) 0xFF) {
+                                result.setResult(8, "VDS 서버에서 알수 없는 VDS 제어기 입니다.");
+                            } else if (head[4] == (byte) 0xFE) {
+                                result.setResult(9, "VDS 서버에서 VDS 제어기 통신 상태가 비정상 입니다.");
+                            } else if (head[4] == (byte) 0xFD) {
+                                result.setResult(7, "VDS 서버에서 VDS 제어기로 리셋 명령을 전송하지 못하였습니다.");
+                            } else {
+                                result.setResult(0, "VDS 서버에 제어기 리셋명령을 정상적으로 전송하였습니다.");
+                            }
+                        } else {
+                            result.setResult(0, "VDS 서버에 제어기 리셋명령을 정상적으로 전송하였습니다.");
+                        }
+                        break;
+                    }
+                } catch (IOException e) {
+                    // 이전 VDS 통신 서버에서는 응답을 주지 않기 때문에 타임아웃 걸린 경우 정상적으로 처리하도록 함
+                    result.setResult(0, "VDS 서버에 제어기 리셋명령을 정상적으로 전송하였습니다.");
+                }
             } catch (IOException e) {
                 result.setResult(3, "VDS 서버에 제어기 리셋명령을 정상적으로 전송하지 못하였습니다.");
             }
@@ -307,8 +330,19 @@ public class VdsControlService {
                         // 이미지 헤더를 읽을 때 까지 헤더 크기 만큼 데이터 수신
                         // 상태 정보(ACK) 등이 수신될수 있다.
                         byte[] head = receiveBytes(recvStream, 10);
-                        if (head[0] == (byte) 0x00 && head[1] == (byte) 0x00 && head[5] == (byte) 0x16) {
+                        if (head[0] == (byte)0x24 && head[1] == (byte)0x04 && head[5] == (byte)0x16) {
+                            log.info("RECV RESPONSE HEAD: 10 Bytes. {}", SysUtils.byteArrayToHex(head));
+                            if (head[4] == (byte)0xFF) {
+                                result.setResult(8, "VDS 서버에서 알수 없는 VDS 제어기 입니다.");
+                            } else if (head[4] == (byte)0xFE) {
+                                result.setResult(9, "VDS 서버에서 VDS 제어기 통신 상태가 비정상 입니다.");
+                            }
+                            break;
+                        }
+
+                        if (head[0] == (byte)0x00 && head[1] == (byte)0x00 && head[5] == (byte)0x16) {
                             log.info("RECV IMAGE HEAD  FIRST: 10 Bytes. {}", SysUtils.byteArrayToHex(head));
+
                             int imageHeaderRemainLength = 172;  // 이미지 헤더 사이즈 만큼 더 읽어야 함
                             byte[] imageHead = receiveBytes(recvStream, imageHeaderRemainLength);
                             int imageSize = SysUtils.bytesToInt(imageHead, 159, ByteOrder.BIG_ENDIAN);

+ 4 - 0
src/main/java/com/its/op/service/its/vms/TbVmsCmtrInfrService.java

@@ -85,4 +85,8 @@ public class TbVmsCmtrInfrService {
         });
         return result;
     }
+
+    public void deleteDataById(Long id) {
+        this.repo.deleteDataById(id);
+    }
 }

+ 1 - 1
src/main/java/com/its/op/service/its/vms/TbVmsIfscService.java

@@ -173,7 +173,7 @@ public class TbVmsIfscService {
         this.linkIfscService.deleteDataById(id);
 
         // VMS 정보제공구간 소통정보 테이블 삭제
-        this.cmtrInfrService.deleteById(id);
+        this.cmtrInfrService.deleteDataById(id);
 
         // VMS 정보제공구간 정보 삭제
         this.repo.deleteById(id);