shjung 2 år sedan
förälder
incheckning
e9e8089ab5

+ 15 - 2
src/main/java/com/its/cctv/CctvCommServerApplication.java

@@ -66,17 +66,30 @@ public class CctvCommServerApplication implements CommandLineRunner, Application
             log.error("Program Already Running.....");
         }
 
+//        ApplicationConfig applicationConfig = (ApplicationConfig) AppUtils.getBean(ApplicationConfig.class);
+//        UnitSystService unitSystService = (UnitSystService)AppUtils.getBean(UnitSystService.class);
+//        unitSystService.loadMaster();
+//        unitSystService.updateUnitSystStts(true);
+//        TbUnitSyst unit = unitSystService.getUnitSystMap().get(applicationConfig.getId());
+//        if (unit != null) {
+//            applicationConfig.setListenPort(unit.getPRGM_PORT());
+//        }
+//        int serverPort = applicationConfig.getListenPort() - 1000;
+//        HashMap<String, Object> props = new HashMap<>();
+//        props.put("server.port", serverPort);
         if (OS.isWindows()) {
             ApplicationContext context = new SpringApplicationBuilder(CctvCommServerApplication.class)
                     //.web(WebApplicationType.NONE)
                     .listeners(new ApplicationPidFileWriter("./conf/" + applicationName + ".pid"))
                     .headless(false)
                     .bannerMode(Banner.Mode.OFF)
+                    //.properties(props)
                     .run(args);
         } else {
             SpringApplication application = new SpringApplicationBuilder()
                     .sources(CctvCommServerApplication.class)
                     .listeners(new ApplicationPidFileWriter("./conf/" + applicationName + ".pid"))
+                    //.properties(props)
                     .build();
             application.setBannerMode(Banner.Mode.OFF);
             application.run(args);
@@ -159,8 +172,8 @@ public class CctvCommServerApplication implements CommandLineRunner, Application
         CctvTcpClientCommService ctlrCommClientService = (CctvTcpClientCommService)AppUtils.getBean(CctvTcpClientCommService.class);
         ctlrCommClientService.run();
 
-        CenterTcpServerService centerService = (CenterTcpServerService)AppUtils.getBean(CenterTcpServerService.class);
-        centerService.run();
+//        CenterTcpServerService centerService = (CenterTcpServerService)AppUtils.getBean(CenterTcpServerService.class);
+//        centerService.run();
 
         // schedule enable
         applicationConfig.setStartSchedule(true);

+ 13 - 3
src/main/java/com/its/cctv/api/controller/CctvControlController.java

@@ -85,7 +85,7 @@ public class CctvControlController {
     }
 
     @ApiOperation(value = "CCTV 가변 문자 설정", response = CctvVarCharControlDto.CctvVarCharControlRes.class)
-    @PostMapping(value = "/char-fix/{id}", produces = {"application/json; charset=utf8"})
+    @PostMapping(value = "/var-char-set/{id}", produces = {"application/json; charset=utf8"})
     public CctvVarCharControlDto.CctvVarCharControlRes controlVarCharSet(
             @ApiParam(name = "id", value = "제어기번호", example = "1001", required = true)
             @PathVariable("id") Long id,
@@ -94,8 +94,8 @@ public class CctvControlController {
         return this.service.controlVarCharSet(id, req);
     }
 
-    @ApiOperation(value = "CCTV 가변 문자 설정", response = CctvVarCharControlDto.CctvVarCharControlRes.class)
-    @PostMapping(value = "/char-fix/{id}", produces = {"application/json; charset=utf8"})
+    @ApiOperation(value = "CCTV 가변 문자 삭제", response = CctvVarCharControlDto.CctvVarCharControlRes.class)
+    @PostMapping(value = "/var-char-del/{id}", produces = {"application/json; charset=utf8"})
     public CctvVarCharControlDto.CctvVarCharControlRes controlVarCharDel(
             @ApiParam(name = "id", value = "제어기번호", example = "1001", required = true)
             @PathVariable("id") Long id,
@@ -104,4 +104,14 @@ public class CctvControlController {
         return this.service.controlVarCharDel(id, req);
     }
 
+    @ApiOperation(value = "CCTV RESET", response = CctvControlDto.CctvControlResetRes.class)
+    @PostMapping(value = "/reset/{id}", produces = {"application/json; charset=utf8"})
+    public CctvControlDto.CctvControlResetRes controlReset(
+            @ApiParam(name = "id", value = "제어기번호", example = "1001", required = true)
+            @PathVariable("id") Long id,
+            @ApiParam(name = "req", value = "CCTV 제어기 리셋", example = "[0/1, ADMIN]", required = true)
+            @RequestBody @Valid final CctvControlDto.CctvControlResetReq req) {
+        return this.service.controlReset(id, req);
+    }
+
 }

+ 185 - 0
src/main/java/com/its/cctv/api/dto/CctvControlDto.java

@@ -0,0 +1,185 @@
+package com.its.cctv.api.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+
+import javax.validation.constraints.Positive;
+import javax.validation.constraints.PositiveOrZero;
+import java.io.Serializable;
+
+/**
+ * CCTV 제어기 제어정보 DTO Class
+ */
+@Data
+@Builder
+@ApiModel("CctvControlDto(CCTV 제어 정보")
+public class CctvControlDto implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModel("CctvControlPtzReq(CCTV PTZ 제어 정보)")
+    @Getter
+    @Setter
+    @ToString
+    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
+    public static class CctvControlPtzReq {
+
+        @ApiModelProperty("제어 명령(tilt-up, tilt-down, pan-left, pan-right, zoom-in, zoom-out, focus-in, focus-out, up-left, up-right, down-left, down-right)")
+        @JsonProperty("command")
+        private String command;
+
+        @ApiModelProperty("제어 명령 제어(start, stop)")
+        @JsonProperty("action")
+        private String action;
+
+        @ApiModelProperty("제어속도(0~63)")
+        @JsonProperty("speed")
+        @PositiveOrZero
+        private Integer speed;
+
+        @ApiModelProperty("로그인 사용자 ID")
+        @JsonProperty("user_id")
+        private String userId;
+
+        @Builder
+        public CctvControlPtzReq(String command, String action, Integer speed, String user_id) {
+            this.command = command;
+            this.action = action;
+            this.speed = speed;
+            this.userId = user_id;
+        }
+    }
+    @ApiModel("CctvControlPresetReq(CCTV Preset 제어 정보)")
+    @Getter
+    @Setter
+    @ToString
+    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
+    public static class CctvControlPresetReq {
+
+        @ApiModelProperty("제어 명령(preset-default)")
+        @JsonProperty("command")
+        private String command;
+
+        @ApiModelProperty("제어 명령 제어(call, save, delete)")
+        @JsonProperty("action")
+        private String action;
+
+        @ApiModelProperty("프리셋 번호(1~255)")
+        @JsonProperty("no")
+        @Positive
+        private Integer no;
+
+        @ApiModelProperty("속도(0~63), save only")
+        @JsonProperty("speed")
+        @PositiveOrZero
+        private Integer speed;
+
+        @ApiModelProperty("프리셋 타임(0~60 sec), save only")
+        @JsonProperty("time")
+        @PositiveOrZero
+        private Integer time;
+
+        @ApiModelProperty("프리셋 명(영문명만, 20 byte) save only, not use.")
+        @JsonProperty("name")
+        private String name;
+
+        @ApiModelProperty("로그인 사용자 ID")
+        @JsonProperty("user_id")
+        private String userId;
+
+        @Builder
+        public CctvControlPresetReq(String command, String action, Integer no, Integer speed, Integer time, String userId) {
+            this.command = command;
+            this.action = action;
+            this.no = no;
+            this.speed = speed;
+            this.time = time;
+            this.userId = userId;
+        }
+    }
+
+    @ApiModel("CctvControlResetReq(CCTV 제어기 리셋)")
+    @Getter
+    @Setter
+    @ToString
+    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
+    public static class CctvControlResetReq {
+
+        @ApiModelProperty("로그인 사용자 ID")
+        @JsonProperty("user_id")
+        private String userId;
+
+        @ApiModelProperty("RESET 유형(0: SW, 1: HW")
+        @JsonProperty("reset_type")
+        private Integer resetType;
+
+        @Builder
+        public CctvControlResetReq(String user_id, Integer reset_type) {
+            this.userId = user_id;
+            this.resetType = reset_type;
+        }
+    }
+
+    @ApiModel("CctvControlResetRes(CCTV 제어기 리셋 응답)")
+    @Getter
+    @Setter
+    @ToString
+    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
+    public static class CctvControlResetRes {
+
+        @ApiModelProperty("제어결과(0: 성공, 기타: 오류")
+        @JsonProperty("error")
+        private Integer error;
+
+        @ApiModelProperty("제어결과메시지")
+        @JsonProperty("message")
+        private String message;
+
+        public void setResult(Integer error, String message) {
+            this.error = error;
+            this.message = message;
+        }
+        @Builder
+        public CctvControlResetRes(Integer error, String message) {
+            this.error = error;
+            this.message = message;
+        }
+    }
+
+    @ApiModel("CctvControlRes(CCTV Control 응답)")
+    @Getter
+    @Setter
+    @ToString
+    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
+    public static class CctvControlRes {
+
+        @ApiModelProperty("제어 명령(tilt-up, tilt-down, pan-left, pan-right, zoom-in, zoom-out, focus-in, focus-out, up-left, up-right, down-left, down-right), 프리셋제어(call, save, delete)")
+        @JsonProperty("command")
+        private String command;
+
+        @ApiModelProperty("제어 명령 제어(start, stop), 프리셋제어(call, save, delete)")
+        @JsonProperty("action")
+        private String action;
+
+        @ApiModelProperty("제어결과(0: 성공, 기타: 오류")
+        @JsonProperty("error")
+        private Integer error;
+
+        @ApiModelProperty("제어결과메시지")
+        @JsonProperty("message")
+        private String message;
+
+        public void setResult(Integer error, String message) {
+            this.error = error;
+            this.message = message;
+        }
+        @Builder
+        public CctvControlRes(String command, String action, Integer error, String message) {
+            this.command = command;
+            this.action = action;
+            this.error = error;
+            this.message = message;
+        }
+    }
+}

+ 17 - 17
src/main/java/com/its/cctv/api/dto/CctvParamControlDto.java

@@ -13,11 +13,11 @@ import java.io.Serializable;
  */
 @Data
 @Builder
-@ApiModel("CctvParamControlDto(CCTV 프리셋제어 정보")
+@ApiModel("CctvParamControlDto(CCTV 파라미터설정 정보")
 public class CctvParamControlDto implements Serializable {
     private static final long serialVersionUID = 1L;
 
-    @ApiModel("CctvParamControlReq(CCTV 프리셋제어 정보)")
+    @ApiModel("CctvParamControlReq(CCTV 파라미터설정 정보)")
     @Getter
     @Setter
     @ToString
@@ -25,22 +25,22 @@ public class CctvParamControlDto implements Serializable {
     public static class CctvParamControlReq {
 
         @ApiModelProperty("FAN ON 설정 온도")
-        @JsonProperty("fanOnTmpr")
+        @JsonProperty("fan_on_tmpr")
         @PositiveOrZero
         private Integer fanOnTmpr;
 
         @ApiModelProperty("FAN OFF 설정 온도")
-        @JsonProperty("fanOffTmpr")
+        @JsonProperty("fan_off_tmpr")
         @PositiveOrZero
         private Integer fanOffTmpr;
 
         @ApiModelProperty("Heater ON 설정 온도")
-        @JsonProperty("zoom")
+        @JsonProperty("hetr_on_tmpr")
         @PositiveOrZero
         private Integer hetrOnTmpr;
 
         @ApiModelProperty("Heater OFF 설정 온도")
-        @JsonProperty("hetrOffTmpr")
+        @JsonProperty("hetr_off_tmpr")
         @PositiveOrZero
         private Integer hetrOffTmpr;
 
@@ -49,16 +49,16 @@ public class CctvParamControlDto implements Serializable {
         private String userId;
 
         @Builder
-        public CctvParamControlReq(Integer fanOnTmpr, Integer fanOffTmpr, Integer hetrOnTmpr, Integer hetrOffTmpr, String user_id) {
-            this.fanOnTmpr = fanOnTmpr;
-            this.fanOffTmpr = fanOffTmpr;
-            this.hetrOnTmpr = hetrOnTmpr;
-            this.hetrOffTmpr = hetrOffTmpr;
+        public CctvParamControlReq(Integer fan_on_tmpr, Integer fan_off_tmpr, Integer hetr_on_tmpr, Integer hetr_off_tmpr, String user_id) {
+            this.fanOnTmpr = fan_on_tmpr;
+            this.fanOffTmpr = fan_off_tmpr;
+            this.hetrOnTmpr = hetr_on_tmpr;
+            this.hetrOffTmpr = hetr_off_tmpr;
             this.userId = user_id;
         }
     }
 
-    @ApiModel("CctvParamControlRes(CCTV 프리셋제어 응답)")
+    @ApiModel("CctvParamControlRes(CCTV 파라미터설정 응답)")
     @Getter
     @Setter
     @ToString
@@ -84,7 +84,7 @@ public class CctvParamControlDto implements Serializable {
         }
     }
 
-    @ApiModel("CctvParamValueRes(CCTV 프리셋 상태 정보)")
+    @ApiModel("CctvParamValueRes(CCTV 파라미터설정 정보)")
     @Getter
     @Setter
     @ToString
@@ -100,22 +100,22 @@ public class CctvParamControlDto implements Serializable {
         private String message;
 
         @ApiModelProperty("FAN ON 설정 온도")
-        @JsonProperty("fanOnTmpr")
+        @JsonProperty("fan_on_tmpr")
         @PositiveOrZero
         private Integer fanOnTmpr;
 
         @ApiModelProperty("FAN OFF 설정 온도")
-        @JsonProperty("fanOffTmpr")
+        @JsonProperty("fan_off_tmpr")
         @PositiveOrZero
         private Integer fanOffTmpr;
 
         @ApiModelProperty("Heater ON 설정 온도")
-        @JsonProperty("zoom")
+        @JsonProperty("hetr_on_tmpr")
         @PositiveOrZero
         private Integer hetrOnTmpr;
 
         @ApiModelProperty("Heater OFF 설정 온도")
-        @JsonProperty("hetrOffTmpr")
+        @JsonProperty("hetr_off_tmpr")
         @PositiveOrZero
         private Integer hetrOffTmpr;
 

+ 32 - 28
src/main/java/com/its/cctv/api/dto/CctvVarCharControlDto.java

@@ -26,57 +26,57 @@ public class CctvVarCharControlDto implements Serializable {
     public static class CctvVarCharControlSetReq {
 
         @ApiModelProperty("Sector No. 0~6")
-        @JsonProperty("sectorNo")
+        @JsonProperty("sector_no")
         @PositiveOrZero
         private Integer sectorNo;
 
         @ApiModelProperty("Start Pan Value 0~1024")
-        @JsonProperty("startPan")
+        @JsonProperty("start_pan")
         @PositiveOrZero
         private Short startPan;
 
         @ApiModelProperty("End Pan Value 0~1024")
-        @JsonProperty("endPan")
+        @JsonProperty("end_pan")
         @PositiveOrZero
         private Short endPan;
 
         @ApiModelProperty("CH1 Character Size(Small: 0x02, Middle:0x03, Large:0x04)")
-        @JsonProperty("ch1CharSize")
+        @JsonProperty("ch1_char_size")
         @PositiveOrZero
         private Short ch1CharSize;
 
         @ApiModelProperty("CH1 Character X Position Value 0~1280")
-        @JsonProperty("ch1PosX")
+        @JsonProperty("ch1_pos_x")
         @PositiveOrZero
         private Short ch1PosX;
 
         @ApiModelProperty("CH1 Character Y Position Value 0~720")
-        @JsonProperty("ch1PosX")
+        @JsonProperty("ch1_pos_y")
         @PositiveOrZero
         private Short ch1PosY;
 
         @ApiModelProperty("CH2 Character Size(Small: 0x02, Middle:0x03, Large:0x04)")
-        @JsonProperty("ch1CharSize")
+        @JsonProperty("ch2_char_size")
         @PositiveOrZero
         private Short ch2CharSize;
 
         @ApiModelProperty("CH2 Character X Position Value 0~1280")
-        @JsonProperty("ch2PosX")
+        @JsonProperty("ch2_pos_x")
         @PositiveOrZero
         private Short ch2PosX;
 
         @ApiModelProperty("CH2 Character Y Position Value 0~720")
-        @JsonProperty("ch2PosX")
+        @JsonProperty("ch2_pos_y")
         @PositiveOrZero
         private Short ch2PosY;
 
         @ApiModelProperty("CH1 Character, Max: 16char(kor),32char(eng)")
-        @JsonProperty("ch1Char")
+        @JsonProperty("ch1_char")
         @Size(min=1, max=32)
         private String ch1Char;
 
         @ApiModelProperty("CH2 Character, Max: 16char(kor),32char(eng)")
-        @JsonProperty("ch2Char")
+        @JsonProperty("ch2_char")
         @Size(min=1, max=32)
         private String ch2Char;
 
@@ -85,19 +85,23 @@ public class CctvVarCharControlDto implements Serializable {
         private String userId;
 
         @Builder
-        public CctvVarCharControlSetReq(Integer sectorNo, Short startPan, Short endPan, Short ch1CharSize, Short ch1PosX, Short ch1PosY, Short ch2CharSize, Short ch2PosX, Short ch2PosY, String ch1Char, String ch2Char, String userId) {
-            this.sectorNo = sectorNo;
-            this.startPan = startPan;
-            this.endPan = endPan;
-            this.ch1CharSize = ch1CharSize;
-            this.ch1PosX = ch1PosX;
-            this.ch1PosY = ch1PosY;
-            this.ch2CharSize = ch2CharSize;
-            this.ch2PosX = ch2PosX;
-            this.ch2PosY = ch2PosY;
-            this.ch1Char = ch1Char;
-            this.ch2Char = ch2Char;
-            this.userId = userId;
+        public CctvVarCharControlSetReq(Integer sector_no, Short start_pan, Short end_pan,
+                                        Short ch1_char_size, Short ch1_pos_x, Short ch1_pos_y,
+                                        Short ch2_char_size, Short ch2_pos_x, Short ch2_pos_y,
+                                        String ch1_char, String ch2_char,
+                                        String user_id) {
+            this.sectorNo = sector_no;
+            this.startPan = start_pan;
+            this.endPan = end_pan;
+            this.ch1CharSize = ch1_char_size;
+            this.ch1PosX = ch1_pos_x;
+            this.ch1PosY = ch1_pos_y;
+            this.ch2CharSize = ch2_char_size;
+            this.ch2PosX = ch2_pos_x;
+            this.ch2PosY = ch2_pos_y;
+            this.ch1Char = ch1_char;
+            this.ch2Char = ch2_char;
+            this.userId = user_id;
         }
     }
 
@@ -109,7 +113,7 @@ public class CctvVarCharControlDto implements Serializable {
     public static class CctvVarCharControlDelReq {
 
         @ApiModelProperty("Sector No. 0~6")
-        @JsonProperty("sectorNo")
+        @JsonProperty("sector_no")
         @PositiveOrZero
         private Integer sectorNo;
 
@@ -118,9 +122,9 @@ public class CctvVarCharControlDto implements Serializable {
         private String userId;
 
         @Builder
-        public CctvVarCharControlDelReq(Integer sectorNo, String userId) {
-            this.sectorNo = sectorNo;
-            this.userId = userId;
+        public CctvVarCharControlDelReq(Integer sector_no, String user_id) {
+            this.sectorNo = sector_no;
+            this.userId = user_id;
         }
     }
 

+ 43 - 14
src/main/java/com/its/cctv/api/service/CctvControlService.java

@@ -83,7 +83,7 @@ public class CctvControlService {
             return new CctvStatusDto.CctvStatusDtoRes(1, "알수없는 CCTV 관리번호 입니다.", null);
         }
         if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvStatusDto.CctvStatusDtoRes(2, "CCTV 통신연결이 되어 있지 않습니다.", null);
+            return new CctvStatusDto.CctvStatusDtoRes(2, "CCTV 제어기와 통신연결이 되어 있지 않습니다.", null);
         }
 
         CctvStatusDto.CctvStatusDtoRes result = new CctvStatusDto.CctvStatusDtoRes(0, "success", cctv.getStts().toDto());
@@ -103,7 +103,7 @@ public class CctvControlService {
             return new CctvPtzControlDto.CctvPtzControlRes(req.getCommand(), req.getAction(), 1, "알수없는 CCTV 관리번호 입니다.");
         }
         if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvPtzControlDto.CctvPtzControlRes(req.getCommand(), req.getAction(), 2, "CCTV 통신연결이 되어 있지 않습니다.");
+            return new CctvPtzControlDto.CctvPtzControlRes(req.getCommand(), req.getAction(), 2, "CCTV 제어기와 통신연결이 되어 있지 않습니다.");
         }
 
         ControlCmd command = this.ptzControlMap.get(req.getCommand());
@@ -154,13 +154,13 @@ public class CctvControlService {
      * @return
      */
     public CctvPresetControlDto.CctvPresetControlRes controlPreset(Long id, CctvPresetControlDto.CctvPresetControlReq req) {
-        log.info("controlPreset: {}", req);
+        log.info("controlPreset: {}, {}", id, req);
         TbCctvCtlr cctv = this.requireOne(id);
         if (cctv == null) {
             return new CctvPresetControlDto.CctvPresetControlRes(1, "CCTV 제어기 정보를 찾을 수 없습니다.");
         }
         if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvPresetControlDto.CctvPresetControlRes(2, "CCTV 통신연결이 되어 있지 않습니다.");
+            return new CctvPresetControlDto.CctvPresetControlRes(2, "CCTV 제어기와 통신연결이 되어 있지 않습니다.");
         }
 
         CctvPresetControlDto.CctvPresetControlRes result = new CctvPresetControlDto.CctvPresetControlRes(0, "success");
@@ -183,13 +183,13 @@ public class CctvControlService {
      * @return
      */
     public CctvParamControlDto.CctvParamControlRes controlParam(Long id, CctvParamControlDto.CctvParamControlReq req) {
-        log.info("controlParam: {}", id);
+        log.info("controlParam: {}, {}", id, req);
         TbCctvCtlr cctv = this.requireOne(id);
         if (cctv == null) {
             return new CctvParamControlDto.CctvParamControlRes(1, "CCTV 제어기 정보를 찾을 수 없습니다.");
         }
         if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvParamControlDto.CctvParamControlRes(2, "CCTV 통신연결이 되어 있지 않습니다.");
+            return new CctvParamControlDto.CctvParamControlRes(2, "CCTV 제어기와 통신연결이 되어 있지 않습니다.");
         }
 
         CctvParamControlDto.CctvParamControlRes result = new CctvParamControlDto.CctvParamControlRes(0, "success");
@@ -217,7 +217,7 @@ public class CctvControlService {
             return new CctvParamControlDto.CctvParamValueRes(1, "CCTV 제어기 정보를 찾을 수 없습니다.");
         }
         if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvParamControlDto.CctvParamValueRes(2, "CCTV 통신연결이 되어 있지 않습니다.");
+            return new CctvParamControlDto.CctvParamValueRes(2, "CCTV 제어기와 통신연결이 되어 있지 않습니다.");
         }
 
         CctvParamControlDto.CctvParamValueRes result = new CctvParamControlDto.CctvParamValueRes(0, "success");
@@ -257,7 +257,7 @@ public class CctvControlService {
             return new CctvPresetControlDto.CctvPresetValueRes(1, "CCTV 제어기 정보를 찾을 수 없습니다.");
         }
         if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvPresetControlDto.CctvPresetValueRes(2, "CCTV 통신연결이 되어 있지 않습니다.");
+            return new CctvPresetControlDto.CctvPresetValueRes(2, "CCTV 제어기와 통신연결이 되어 있지 않습니다.");
         }
 
         CctvPresetControlDto.CctvPresetValueRes result = new CctvPresetControlDto.CctvPresetValueRes(0, "success");
@@ -281,7 +281,7 @@ public class CctvControlService {
                     log.error("PRESET QRY send failed.");
                 }
             } catch (InterruptedException e) {
-                result.setResult(9, "CCTV PRESET 값조회 명령 전송 중 오류가 발생하였습니다.");
+                result.setResult(6, "CCTV PRESET 값조회 명령 전송 중 오류가 발생하였습니다.");
             }
         }
         return result;
@@ -299,7 +299,7 @@ public class CctvControlService {
             return new CctvStatusDto.CctvStatusNotifyDtoRes(1, "CCTV 제어기 정보를 찾을 수 없습니다.");
         }
         if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvStatusDto.CctvStatusNotifyDtoRes(2, "CCTV 통신연결이 되어 있지 않습니다.");
+            return new CctvStatusDto.CctvStatusNotifyDtoRes(2, "CCTV 제어기와 통신연결이 되어 있지 않습니다.");
         }
 
         CctvStatusDto.CctvStatusNotifyDtoRes result = new CctvStatusDto.CctvStatusNotifyDtoRes(0, "success");
@@ -321,13 +321,13 @@ public class CctvControlService {
      * @return
      */
     public CctvVarCharControlDto.CctvVarCharControlRes controlVarCharSet(Long id, CctvVarCharControlDto.CctvVarCharControlSetReq req) {
-        log.info("controlVarCharSet: {}", id);
+        log.info("controlVarCharSet: {}, {}", id, req);
         TbCctvCtlr cctv = this.requireOne(id);
         if (cctv == null) {
             return new CctvVarCharControlDto.CctvVarCharControlRes(1, "CCTV 제어기 정보를 찾을 수 없습니다.");
         }
         if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvVarCharControlDto.CctvVarCharControlRes(2, "CCTV 통신연결이 되어 있지 않습니다.");
+            return new CctvVarCharControlDto.CctvVarCharControlRes(2, "CCTV 제어기와 통신연결이 되어 있지 않습니다.");
         }
 
         CctvVarCharControlDto.CctvVarCharControlRes result = new CctvVarCharControlDto.CctvVarCharControlRes(0, "success");
@@ -359,13 +359,13 @@ public class CctvControlService {
      * @return
      */
     public CctvVarCharControlDto.CctvVarCharControlRes controlVarCharDel(Long id, CctvVarCharControlDto.CctvVarCharControlDelReq req) {
-        log.info("controlVarCharDel: {}", id);
+        log.info("controlVarCharDel: {}, {}", id, req);
         TbCctvCtlr cctv = this.requireOne(id);
         if (cctv == null) {
             return new CctvVarCharControlDto.CctvVarCharControlRes(1, "CCTV 제어기 정보를 찾을 수 없습니다.");
         }
         if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvVarCharControlDto.CctvVarCharControlRes(2, "CCTV 통신연결이 되어 있지 않습니다.");
+            return new CctvVarCharControlDto.CctvVarCharControlRes(2, "CCTV 제어기와 통신연결이 되어 있지 않습니다.");
         }
 
         CctvVarCharControlDto.CctvVarCharControlRes result = new CctvVarCharControlDto.CctvVarCharControlRes(0, "success");
@@ -382,4 +382,33 @@ public class CctvControlService {
         return result;
     }
 
+    public CctvControlDto.CctvControlResetRes controlReset(Long id, CctvControlDto.CctvControlResetReq req) {
+        log.info("controlReset: {}, {}", id, req);
+        TbCctvCtlr cctv = this.requireOne(id);
+        if (cctv == null) {
+            return new CctvControlDto.CctvControlResetRes(1, "CCTV 제어기 정보를 찾을 수 없습니다.");
+        }
+        if (cctv.getNetState() != NET.LOGINED) {
+            return new CctvControlDto.CctvControlResetRes(2, "CCTV 제어기와 통신연결이 되어 있지 않습니다.");
+        }
+
+        CctvControlDto.CctvControlResetRes result = new CctvControlDto.CctvControlResetRes(0, "success");
+        if (0 == req.getResetType()) {
+            // SW Reset
+            if (!cctv.resetSw()) {
+                result.setResult(4, "CCTV 제어기 SW 리셋 명령 전송에 실패하였습니다.");
+            }
+        }
+        else if (1 == req.getResetType()) {
+            // HW Reset
+            if (!cctv.resetHw()) {
+                result.setResult(5, "CCTV 제어기 HW 리셋 명령 전송에 실패하였습니다.");
+            }
+        }
+        else {
+            result.setResult(3, "CCTV 리셋 정보가 잘못 되었습니다.");
+        }
+        return result;
+    }
+
 }

+ 2 - 4
src/main/java/com/its/cctv/api/websocket/ItsWebSocketConfig.java

@@ -2,15 +2,13 @@ package com.its.cctv.api.websocket;
 
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.socket.config.annotation.EnableWebSocket;
 import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
 import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
 
 @Slf4j
 @RequiredArgsConstructor
-@Configuration
-@EnableWebSocket
+//@Configuration
+//@EnableWebSocket
 public class ItsWebSocketConfig implements WebSocketConfigurer {
 
     private final ItsWebSocketHandler itsWebsocketHandler;

+ 1 - 2
src/main/java/com/its/cctv/api/websocket/ItsWebSocketHandler.java

@@ -1,7 +1,6 @@
 package com.its.cctv.api.websocket;
 
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.socket.CloseStatus;
 import org.springframework.web.socket.TextMessage;
@@ -11,7 +10,7 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
 import java.util.Map;
 
 @Slf4j
-@Controller
+//@Controller
 @RequestMapping("/ws/messages.do")
 public class ItsWebSocketHandler extends TextWebSocketHandler {
 

+ 0 - 37
src/main/java/com/its/cctv/xnettcp/center/handler/CenterTcpServerInboundHandler.java

@@ -68,43 +68,6 @@ public class CenterTcpServerInboundHandler extends ChannelInboundHandlerAdapter
             return;
         }
 
-//        if (opCode == CctvProtocol.vds_Reset) {
-//            ByteBuffer resultBuffer;
-//            CctvReqReset reqReset = new CctvReqReset((short)obj.getGROUP_NO(), (short)obj.getCCTV_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 == CctvProtocol.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);
-//            CctvReqImage reqImage = new CctvReqImage((short)obj.getGROUP_NO(), (short)obj.getCCTV_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;
-//        }
     }
 
 }

+ 3 - 2
src/main/resources/application.yml

@@ -12,7 +12,7 @@ running:
   connect-timeout: 5
 
 server:
-  port: 8903
+  port: 9903
   shutdown: graceful
   error:
     whitelabel:
@@ -67,7 +67,8 @@ spring:
   datasource:
     hikari:
       driver-class-name: oracle.jdbc.OracleDriver
-      jdbc-url: jdbc:oracle:thin:@172.19.10.11:1521:ptatms
+      #jdbc-url: jdbc:oracle:thin:@172.19.10.26:1521:ptatms
+      jdbc-url: jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.19.10.25)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=172.19.10.26)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ptatms)))
       username: ptatms
       password: ptatms
 

+ 22 - 55
src/test/java/com/its/app/CctvCommServerApplicationTests.java

@@ -8,15 +8,14 @@ import com.its.cctv.entity.TbCctvCtlr;
 import com.its.cctv.global.AppRepository;
 import com.its.cctv.xnettcp.cctv.process.CctvData;
 import com.its.cctv.xnettcp.cctv.process.CctvDataProcess;
-import com.its.cctv.xnettcp.cctv.protocol.*;
+import com.its.cctv.xnettcp.cctv.protocol.CctvProtocol;
+import com.its.cctv.xnettcp.cctv.protocol.CctvResFramePacket;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
 
-import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 @Slf4j
 @SpringBootTest(classes = CctvCommServerApplication.class)
@@ -174,58 +173,6 @@ public class CctvCommServerApplicationTests {
 
     @Test
     void Test4() {
-        //10 02 00 00 00 1C 04 10 03 03 09
-        byte[] packet = { (byte)0x10, (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x1C, (byte)0x04, (byte)0x10, (byte)0x03, (byte)0x00, (byte)0x00};
-        short crc = CctvProtocol.getCRC16ARC(packet, 2, packet.length - 6);
-
-        // 제어기 통과 데이터 요청
-        for (Map.Entry<String, TbCctvCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
-            TbCctvCtlr obj = e.getValue();
-            ByteBuffer sendBuffer = obj.getReqData().getByteBuffer();
-            //log.error("{}: {}", obj.getVDS_CTLR_LOCAL_NO(), SysUtils.byteArrayToHex(sendBuffer.array()));
-        }
-
-        // 제어기 SYC
-        for (Map.Entry<String, TbCctvCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
-            TbCctvCtlr obj = e.getValue();
-            ByteBuffer sendBuffer = obj.getReqSynchronize().getByteBuffer();
-            //log.error("{}: {}", obj.getVDS_CTLR_LOCAL_NO(), SysUtils.byteArrayToHex(sendBuffer.array()));
-        }
-
-        // 제어기 온도 데이터 요청
-        for (Map.Entry<String, TbCctvCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
-            TbCctvCtlr obj = e.getValue();
-            ByteBuffer sendBuffer = obj.getReqTemperature().getByteBuffer();
-            //log.error("{}: {}", obj.getVDS_CTLR_LOCAL_NO(), SysUtils.byteArrayToHex(sendBuffer.array()));
-        }
-
-        // 제어기 상태 RTC 변경
-        for (Map.Entry<String, TbCctvCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
-//            TbCctvCtlr obj = e.getValue();
-//            CctvReqRTC reqRTC = new CctvReqRTC((short)obj.getGROUP_NO(), (short)obj.getCCTV_CTLR_LOCAL_NO());
-//            reqRTC.makeCRC();
-//            ByteBuffer sendBuffer = reqRTC.getByteBuffer();
-            //log.error("{}: {}", obj.getVDS_CTLR_LOCAL_NO(), SysUtils.byteArrayToHex(sendBuffer.array()));
-        }
-
-        // 화상 이미지 요청
-        for (int ii = 0; ii < 13; ii++) {
-            CctvReqParam reqImage = new CctvReqParam((short)0, (short)2);
-            reqImage.setCameraNo(1);
-            reqImage.setFrameNo(ii);
-            reqImage.makeCRC();
-            ByteBuffer sendBuffer = reqImage.getByteBuffer();
-            //log.error("{}, {}: {}", 2, ii, SysUtils.byteArrayToHex(sendBuffer.array()));
-        }
-
-        // 제어기 RESET
-        for (Map.Entry<String, TbCctvCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
-            TbCctvCtlr obj = e.getValue();
-//            CctvReqReset reqReset = new CctvReqReset((short)obj.getGROUP_NO(), (short)obj.getCCTV_CTLR_LOCAL_NO());
-//            reqReset.makeCRC();
-//            ByteBuffer sendBuffer = reqReset.getByteBuffer();
-//            log.error("{}: {}", obj.getCCTV_CTLR_LOCAL_NO(), SysUtils.byteArrayToHex(sendBuffer.array()));
-        }
     }
 
     @Test
@@ -258,4 +205,24 @@ public class CctvCommServerApplicationTests {
         CctvProtocol.sleep(6000);
     }
 
+    @Test
+    void test7() {
+        String xCrdn = String.format("%09d", 128422119);
+        String yCrdn = String.format("%09d", 36136305);
+        log.error("{}", xCrdn);
+        log.error("{}", yCrdn);
+        Double x_crdn = (Integer.parseInt(xCrdn) / 1000000.);
+        Double y_crdn = (Integer.parseInt(yCrdn) / 1000000.);
+        log.error("{}", x_crdn);
+        log.error("{}", y_crdn);
+
+        int aRingPhase = 2087276;
+        String aPhase = String.format("%07d", aRingPhase);
+        int aDir = aRingPhase / 1000000;
+        log.error("{}", aPhase);
+        log.error("{}", aPhase.substring(0, 1));
+        log.error("{}", aPhase.substring(1, 4));
+        log.error("{}", aPhase.substring(4, 7));
+    }
+
 }