Browse Source

bit history and mobile id add

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

+ 4 - 0
src/main/java/com/its/op/dto/its/common/SttsCommErrDto.java

@@ -48,4 +48,8 @@ public class SttsCommErrDto {
     @JsonProperty("col_desc")
     private String colDesc;
 
+    @ApiModelProperty("localno")  // Y NUMBER(5)
+    @JsonProperty("localno")
+    private Integer localno;
+
 }

+ 5 - 0
src/main/java/com/its/op/service/bis/BitService.java

@@ -135,6 +135,7 @@ public class BitService {
             commErrorDto.setCommDesc(CodeManager.getCodeDescShort(CodeManager.CMNC_STTS_CD, commErrorDto.getCommCd()));
             commErrorDto.setCommErrCnt(0);
             commErrorDto.setColCnt(0);
+            commErrorDto.setLocalno(obj.getLocalno());  // FOR BIT MOBILE ID
             resultMap.put(obj.getBitid(), commErrorDto);
         });
 
@@ -144,6 +145,7 @@ public class BitService {
             if (commErrorDto == null) {
                 return;
             }
+            commErrorDto.setUpdtDt(obj.getRecorddate());
             if (("1").equals(obj.getWcommstatus())) {
                 // 유선통신 정상
                 commErrorDto.setCommCd(CodeManager.CMNC_STTS_NORMAL);
@@ -164,6 +166,9 @@ public class BitService {
 
         resultMap.forEach((key, obj) -> {
             if (CodeManager.CMNC_STTS_ERROR.equals(obj.getCommCd())) {
+                if (CodeManager.CMNC_STTS_ERROR_DT.equals(obj.getUpdtDt())) {
+                    obj.setUpdtDt("-");
+                }
                 result.add(obj);
             }
         });

+ 2 - 4
src/main/java/com/its/op/service/bis/BitStatusHistoryService.java

@@ -5,17 +5,15 @@ import com.its.op.dto.bis.BitStatusHistoryDto;
 import com.its.op.entity.bis.BitStatusHistory;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.context.annotation.Profile;
-import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.List;
 
-@Profile("bis")
+//@Profile("bis")
 @Slf4j
 @RequiredArgsConstructor
-@Service
+//@Service
 public class BitStatusHistoryService {
 
     private final BitStatusHistoryRepository repo;

+ 130 - 0
src/main/java/com/its/op/service/its/cctv/CctvControlProbeService2.java

@@ -0,0 +1,130 @@
+package com.its.op.service.its.cctv;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+
+import javax.annotation.PostConstruct;
+import java.util.HashMap;
+import java.util.Map;
+
+@Slf4j
+@RequiredArgsConstructor
+//@Service
+public class CctvControlProbeService2 {
+
+    Map<String, ProbeCommand2> startCmd = new HashMap<>();
+    Map<String, ProbeCommand2> stopCmd = new HashMap<>();
+    Map<String, ProbeCommand2> presetCmd = new HashMap<>();
+
+//   요청 URL: http://172.16.53.45/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=2&PTZCTRL.speed=30&nRanId=60142769
+//   요청 메서드: POST
+//   상태 코드: 200 / O
+// - 요청 헤더
+//   Accept: */*
+//    Accept-Encoding: gzip, deflate
+//    Accept-Language: ko
+//    Authorization: Basic YWRtaW46MTIzNDU=
+//            Cache-Control: no-cache
+//    Connection: Keep-Alive
+//    Content-Length: 8
+//    Content-Type: text/html; charset=UTF-8
+//    Cookie: nLANGUAGE=0; nDevType=4; nChnCount=1; nRtspPort=554; nRtmpPort=1935; nMsgPort=8080; nUserLevel=4; szUsername=admin; szPassword=12345
+//    Host: 172.16.53.45
+//    Referer: http://172.16.53.45/login.asp
+//    User-Agent: Mozilla/5.0 (
+//    Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
+//
+//    요청 URL: http://172.16.53.45/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0&nRanId=72662842
+//    요청 URL: http://172.16.53.45/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=3&PTZCTRL.speed=30&nRanId=16982543
+//    요청 URL: http://172.16.53.45/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0&nRanId=28699669
+//    요청 URL: http://172.16.53.45/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=4&PTZCTRL.speed=30&nRanId=40995292
+//    요청 URL: http://172.16.53.45/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0&nRanId=52674826
+//    요청 URL: http://172.16.53.45/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=5&PTZCTRL.speed=30&nRanId=95129168
+//    요청 URL: http://172.16.53.45/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0&nRanId=62661428
+
+    @PostConstruct
+    void init() {
+        this.startCmd.put("tilt-up",   new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=4&PTZCTRL.speed=", ""));
+        this.startCmd.put("tilt-down", new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=5&PTZCTRL.speed=",""));
+        this.startCmd.put("pan-left",  new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=2&PTZCTRL.speed=",""));
+        this.startCmd.put("pan-right", new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=3&PTZCTRL.speed=",""));
+        this.startCmd.put("zoom-in",   new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=13&PTZCTRL.speed=",""));
+        this.startCmd.put("zoom-out",  new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=14&PTZCTRL.speed=",""));
+        this.startCmd.put("focus-in",  new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=15&PTZCTRL.speed=",""));
+        this.startCmd.put("focus-out", new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=16&PTZCTRL.speed=",""));
+
+        this.stopCmd.put("tilt-up",   new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0",""));
+        this.stopCmd.put("tilt-down", new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0",""));
+        this.stopCmd.put("pan-left",  new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0",""));
+        this.stopCmd.put("pan-right", new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0",""));
+        this.stopCmd.put("zoom-in",   new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0",""));
+        this.stopCmd.put("zoom-out",  new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0",""));
+        this.stopCmd.put("focus-in",  new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0",""));
+        this.stopCmd.put("focus-out", new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0",""));
+
+        this.presetCmd.put("call",    new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=11&PTZCTRL.no=",""));
+        this.presetCmd.put("save",    new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=10&PTZCTRL.no=",""));
+        this.presetCmd.put("delete",  new ProbeCommand2("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=12&PTZCTRL.no=",""));
+    }
+
+    public String getPtzCmd(String control, String action, int speed) {
+        if (StringUtils.equalsIgnoreCase("start", action)) {
+            ProbeCommand2 command = this.startCmd.get(control);
+            if (command != null) {
+                return command.getUri() + speed;
+            }
+        } else if (StringUtils.equalsIgnoreCase("stop", action)) {
+            ProbeCommand2 command = this.stopCmd.get(control);
+            if (command != null) {
+                return command.getUri();
+            }
+        }
+        return null;
+    }
+    public String getPtzControlCmd(String control, String action, int speed) {
+        if (StringUtils.equalsIgnoreCase("start", action)) {
+            ProbeCommand2 command = this.startCmd.get(control);
+            if (command != null) {
+                return command.getCmd();
+            }
+        } else if (StringUtils.equalsIgnoreCase("stop", action)) {
+            ProbeCommand2 command = this.stopCmd.get(control);
+            if (command != null) {
+                return command.getCmd();
+            }
+        }
+        return null;
+    }
+
+    public String getPresetCmd(String action, Integer psetNmbr) {
+        ProbeCommand2 command = this.presetCmd.get(action);
+        if (command != null) {
+            return command.getUri() + psetNmbr;
+        }
+        return null;
+    }
+    public String getPresetControlCmd(String action, Integer psetNmbr) {
+        ProbeCommand2 command = this.presetCmd.get(action);
+        if (command != null) {
+            return command.getCmd();
+        }
+        return null;
+    }
+
+    public static class ProbeCommand2 {
+        private String uri;
+        private String cmd;
+        public ProbeCommand2(String uri, String cmd) {
+            this.uri = uri;
+            this.cmd = cmd;
+        }
+        public String getUri() {
+            return this.uri;
+        }
+        public String getCmd() {
+            return this.cmd;
+        }
+    }
+
+}

+ 81 - 1
src/main/java/com/its/op/service/its/cctv/CctvControlService.java

@@ -99,7 +99,7 @@ public class CctvControlService {
             connection.setRequestProperty("Accept-Encoding", "identity");
             connection.setRequestProperty("Authorization", "Basic " + encoding);
             //connection.setRequestProperty("charset", "UTF-8");
-            connection.setRequestProperty("Content-Length", Integer.toString(controlData.length));
+            //connection.setRequestProperty("Content-Length", Integer.toString(controlData.length));
             connection.setRequestProperty("User-Agent", "Mozilla/3.0");
 
             //connection.setUseCaches(false);
@@ -145,6 +145,86 @@ public class CctvControlService {
         }
         return result;
     }
+    public CctvControlDto.CctvControlRes requestHttpPostProbe2(CctvControlDto.CctvControlRes result, String controlUri, String controlData, String ipAddr, String userId, String userPswd) {
+        String encoding = Base64.getEncoder().encodeToString((userId + ":" + userPswd).getBytes());
+        String apiUrl = "http://" + ipAddr + controlUri;
+        log.info("{}, Basis: {}", apiUrl, encoding);
+
+        HttpURLConnection connection = null;
+        try {
+            URL url = new URL(apiUrl);
+            connection = (HttpURLConnection)url.openConnection();
+            connection.setConnectTimeout(5000); //서버에 연결되는 Timeout 시간 설정
+            connection.setReadTimeout(5000); // InputStream 읽어 오는 Timeout 시간 설정
+
+            connection.setDoOutput(true); //POST 데이터를 OutputStream 으로 넘겨 주겠다는 설정
+            connection.setDoInput(true);
+//   Accept: */*
+//   Accept-Encoding: gzip, deflate
+//   Accept-Language: ko
+//   Authorization: Basic YWRtaW46MTIzNDU=
+//   Cache-Control: no-cache
+//   Connection: Keep-Alive
+//   Content-Length: 8
+//   Content-Type: text/html; charset=UTF-8
+//   Cookie: nLANGUAGE=0; nDevType=4; nChnCount=1; nRtspPort=554; nRtmpPort=1935; nMsgPort=8080; nUserLevel=4; szUsername=admin; szPassword=12345
+//   Host: 172.16.53.45
+//   Referer: http://172.16.53.45/login.asp
+//   User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
+
+            connection.setRequestMethod("POST");
+            connection.setRequestProperty("Accept", "*/*");
+            connection.setRequestProperty("Accept-Encoding", "gzip, deflate");
+            connection.setRequestProperty("Accept-Language", "ko");
+            connection.setRequestProperty("Authorization", "Basic " + encoding);
+            //connection.setRequestProperty("charset", "UTF-8");
+            //connection.setRequestProperty("Content-Length", Integer.toString(controlData.length));
+            connection.setRequestProperty("Content-Type", "text/html; charset=UTF-8");
+            connection.setRequestProperty("User-Agent", "Mozilla/3.0");
+
+            //connection.setUseCaches(false);
+            //connection.setDefaultUseCaches(false);
+
+            DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
+            wr.write(controlData.getBytes());
+            wr.flush();
+            wr.close();
+
+            if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
+                String line;
+                StringBuilder sb = new StringBuilder();
+                try (
+                        BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
+                ) {
+                    while ((line = br.readLine()) != null) {
+                        sb.append(line).append("\n");
+                    }
+                    //br.close();
+                    log.info("HTTP_OK: CCTV, {}, {}", ipAddr, sb);
+                    result.setResult(0, sb.toString());
+                }
+                catch (IOException e) {
+                    log.error("requestHttpPostProbe: IOException");
+                    result.setResult(4, "CCTV 제어기에 연결 할 수 없습니다. 통신 확인 후 작업을 진행해 주세요.");
+                }
+            } else {
+                log.error("HTTP_FAIL: {}", connection.getResponseMessage());
+                if (connection.getResponseMessage() == null) {
+                    result.setResult(2, "cctv network fail.");
+                } else {
+                    result.setResult(3, connection.getResponseMessage());
+                }
+            }
+        } catch (IOException e){
+            log.error("Exception: IOException");
+            result.setResult(5, "CCTV 제어기에 연결 할 수 없습니다. 통신 확인 후 작업을 진행해 주세요.");
+        } finally {
+            if (connection != null) {
+                connection.disconnect();
+            }
+        }
+        return result;
+    }
 
     /**
      * ZENO Preset control

+ 1 - 13
src/main/resources/static/js/vworld/obj-facility.js

@@ -269,21 +269,9 @@ export class TRse extends TPoi {
 
 export class TBit extends TPoi {
     constructor(ALyrInfo, ADto) {
-        super(ALyrInfo, ADto.bitid, ADto.bitid, ADto.bitname, ADto.coordx, ADto.coordy, "1", "0", 0, "19700101000000");
+        super(ALyrInfo, ADto.bitid, ADto.localno, ADto.bitname, ADto.coordx, ADto.coordy, "1", "0", 0, "19700101000000");
         this.instdt = ADto.regdate;
         this.address = ADto.address;
-        // this.regioncd    = ADto.regioncd;
-        // this.areacd      = ADto.areacd;
-        // this.rseip       = ADto.rseip;
-        // this.radius1     = ADto.radius1;
-        // this.radius2     = ADto.radius2;
-        // this.compcd      = ADto.compcd;
-        // this.rseconfigid = ADto.rseconfigid;
-        // this.obeparamid  = ADto.obeparamid;
-        // this.port        = ADto.port;
-        // this.bridge      = ADto.bridge;
-        // this.comyn       = ADto.comyn;
-        // this.commtype    = ADto.commtype;
     }
 }