浏览代码

home dev3

shjung 2 年之前
父节点
当前提交
705a234931

+ 27 - 97
src/main/java/com/its/vms/api/controller/VmsControlController.java

@@ -1,16 +1,19 @@
 package com.its.vms.api.controller;
 
-import com.its.vms.api.dto.*;
+import com.its.vms.api.dto.VmsControlDto;
 import com.its.vms.api.service.VmsControlService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.validation.Valid;
+import java.util.NoSuchElementException;
 
 @Slf4j
 @Api(tags = "1.VMS-0.제어")
@@ -22,102 +25,29 @@ public class VmsControlController {
 
     private final VmsControlService service;
 
-//    @ApiOperation(value = "TEST", response = CctvStatusDto.CctvStatusNotifyDtoRes.class)
-//    @GetMapping(value = "/status/notify/{id}", produces = {"application/json; charset=utf8"})
-//    public CctvStatusDto.CctvStatusNotifyDtoRes notifyStatus(
-//            @ApiParam(name = "id", value = "제어기번호", example = "1001", required = true)
-//            @PathVariable("id") Long id) {
-//        return this.service.notifyStatus(id);
-//    }
-
-    @ApiOperation(value = "VMS 환경 파라미터 조회", response = CctvParamControlDto.CctvParamValueRes.class)
-    @GetMapping(value = "/param-qry/{id}", produces = {"application/json; charset=utf8"})
-    public CctvParamControlDto.CctvParamValueRes requestParam(
-            @ApiParam(name = "id", value = "제어기번호", example = "1001", required = true)
-            @PathVariable("id") Long id) {
-        return this.service.requestParam(id);
-    }
-
-    @ApiOperation(value = "VMS 환경 파라미터 설정", response = CctvParamControlDto.CctvParamControlRes.class)
-    //@PostMapping(value = "/param-set/{id}", produces = {"application/json; charset=utf8"})
-    @RequestMapping(value = "/param-set/{id}", method = {RequestMethod.GET, RequestMethod.POST})
-    public CctvParamControlDto.CctvParamControlRes controlParam(
-            @ApiParam(name = "id", value = "제어기번호", example = "1001", required = true)
-            @PathVariable("id") Long id,
-            @ApiParam(name = "req", value = "CCTV PARAMETER 설정 정보", example = "[ADMIN]", required = true)
-            @RequestBody @Valid final CctvParamControlDto.CctvParamControlReq req) {
-        return this.service.controlParam(id, req);
-    }
-
-    @ApiOperation(value = "VMS 상태 조회", response = CctvStatusDto.CctvStatusDtoRes.class)
-    @GetMapping(value = "/status/{id}", produces = {"application/json; charset=utf8"})
-    public CctvStatusDto.CctvStatusDtoRes requestStatus(
-            @ApiParam(name = "id", value = "제어기번호", example = "1001", required = true)
-            @PathVariable("id") Long id) {
-        return this.service.requestStatus(id);
-    }
-
-    @ApiOperation(value = "VMS 현재위치정보 조회", response = CctvPresetControlDto.CctvPresetValueRes.class)
-    @GetMapping(value = "/preset-value/{id}", produces = {"application/json; charset=utf8"})
-    public CctvPresetControlDto.CctvPresetValueRes requestPresetValue(
-            @ApiParam(name = "id", value = "제어기번호", example = "1001", required = true)
-            @PathVariable("id") Long id) {
-        return this.service.requestPresetValue(id);
-    }
-
-    @ApiOperation(value = "VMS PTZ 제어", response = CctvPtzControlDto.CctvPtzControlRes.class)
-    //@PostMapping(value = "/ptz/{id}", produces = {"application/json; charset=utf8"})
-    @RequestMapping(value = "/ptz/{id}", method = {RequestMethod.GET, RequestMethod.POST})
-    public CctvPtzControlDto.CctvPtzControlRes controlPtz(
-            @ApiParam(name = "id", value = "제어기번호", example = "1001", required = true)
-            @PathVariable("id") Long id,
-            @ApiParam(name = "req", value = "VMS PTZ 제어 정보", example = "[tilt-up, start, 20, ADMIN]", required = true)
-            @RequestBody @Valid final CctvPtzControlDto.CctvControlPtzReq req) {
-        return this.service.controlPtz(id, req);
-    }
-
-    @ApiOperation(value = "VMS Preset 제어", response = CctvPresetControlDto.CctvPresetControlRes.class)
-    //@PostMapping(value = "/preset/{id}", produces = {"application/json; charset=utf8"})
-    @RequestMapping(value = "/preset/{id}", method = {RequestMethod.GET, RequestMethod.POST})
-    public CctvPresetControlDto.CctvPresetControlRes controlPreset(
-            @ApiParam(name = "id", value = "제어기번호", example = "1001", required = true)
-            @PathVariable("id") Long id,
-            @ApiParam(name = "req", value = "VMS Preset 제어 정보", example = "[preset, call, 1, 0, 0, ADMIN]", required = true)
-            @RequestBody @Valid final CctvPresetControlDto.CctvPresetControlReq req) {
-        return this.service.controlPreset(id, req);
-    }
-
-    @ApiOperation(value = "VMS 가변 문자 설정", response = CctvVarCharControlDto.CctvVarCharControlRes.class)
-    //@PostMapping(value = "/var-char-set/{id}", produces = {"application/json; charset=utf8"})
-    @RequestMapping(value = "/var-char-set/{id}", method = {RequestMethod.GET, RequestMethod.POST})
-    public CctvVarCharControlDto.CctvVarCharControlRes controlVarCharSet(
-            @ApiParam(name = "id", value = "제어기번호", example = "1001", required = true)
-            @PathVariable("id") Long id,
-            @ApiParam(name = "req", value = "VMS 가변문자 설정 정보", example = "[preset, call, 1, 0, 0, ADMIN]", required = true)
-            @RequestBody @Valid final CctvVarCharControlDto.CctvVarCharControlSetReq req) {
-        return this.service.controlVarCharSet(id, req);
-    }
-
-    @ApiOperation(value = "VMS 가변 문자 삭제", response = CctvVarCharControlDto.CctvVarCharControlRes.class)
-    //@PostMapping(value = "/var-char-del/{id}", produces = {"application/json; charset=utf8"})
-    @RequestMapping(value = "/var-char-del/{id}", method = {RequestMethod.GET, RequestMethod.POST})
-    public CctvVarCharControlDto.CctvVarCharControlRes controlVarCharDel(
-            @ApiParam(name = "id", value = "제어기번호", example = "1001", required = true)
-            @PathVariable("id") Long id,
-            @ApiParam(name = "req", value = "VMS 가변문자 삭제 정보", example = "[preset, call, 1, 0, 0, ADMIN]", required = true)
-            @RequestBody @Valid final CctvVarCharControlDto.CctvVarCharControlDelReq req) {
-        return this.service.controlVarCharDel(id, req);
-    }
-
-    @ApiOperation(value = "VMS RESET", response = CctvControlDto.CctvControlResetRes.class)
-    //@PostMapping(value = "/reset/{id}", produces = {"application/json; charset=utf8"})
-    @RequestMapping(value = "/reset/{id}", method = {RequestMethod.GET, RequestMethod.POST})
-    public CctvControlDto.CctvControlResetRes controlReset(
-            @ApiParam(name = "id", value = "제어기번호", example = "1001", required = true)
-            @PathVariable("id") Long id,
-            @ApiParam(name = "req", value = "VMS 제어기 리셋", example = "[0/1, ADMIN]", required = true)
-            @RequestBody @Valid final CctvControlDto.CctvControlResetReq req) {
-        return this.service.controlReset(id, req);
+    @ApiOperation(value = "VMS 제어기 리셋", response = VmsControlDto.VmsControlRes.class)
+    @PostMapping(value = "/reset/{ctlrNmbr}", produces = {"application/json; charset=utf8"})
+    public VmsControlDto.VmsControlRes controlReset(
+            @ApiParam(name = "ctlrNmbr", value = "제어기번호", example = "10021", required = true)
+            @PathVariable("ctlrNmbr") Long ctlrNmbr,
+            @ApiParam(name = "req", value = "VMS 제어기 제어 정보", example = "[ADMIN]", required = true)
+            @RequestBody @Valid final VmsControlDto.VmsControlReq req,
+            HttpServletRequest request) {
+        return this.service.controlReset(ctlrNmbr, req);
+    }
+    @ApiOperation(value = "VMS 제어기 리셋(CS)", response = VmsControlDto.VmsControlRes.class)
+    @PostMapping(value = "/cs/reset/{key}/{ctlrNmbr}", produces = {"application/json; charset=utf8"})
+    public VmsControlDto.VmsControlRes controlReset(
+            @PathVariable final String key,
+            @ApiParam(name = "ctlrNmbr", value = "제어기번호", example = "10021", required = true)
+            @PathVariable("ctlrNmbr") Long ctlrNmbr,
+            @ApiParam(name = "req", value = "VMS 제어기 제어 정보", example = "[ADMIN]", required = true)
+            @RequestBody @Valid final VmsControlDto.VmsControlReq req) throws NoSuchElementException {
+        log.warn("Vms reset: {}, {}, {}", key, ctlrNmbr, req);
+        if (!StringUtils.equals(key, "abcdefg1234567890x")) {
+            throw new NoSuchElementException("Authentication key mismatched: " + ctlrNmbr);
+        }
+        return this.service.controlReset(ctlrNmbr, req);
     }
 
 }

+ 181 - 0
src/main/java/com/its/vms/api/dto/VmsControlDto.java

@@ -0,0 +1,181 @@
+package com.its.vms.api.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+
+/**
+ * Vms 제어기 제어정보 DTO Class
+ */
+@Data
+@Builder
+@ApiModel("VmsControlDto(VMS 제어 정보")
+public class VmsControlDto implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModel("VmsControlReq(VMS 제어기 제어 정보)")
+    @Getter
+    @Setter
+    @ToString
+    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
+    public static class VmsControlReq {
+
+        @ApiModelProperty("로그인 사용자 ID")
+        @JsonProperty("user_id")
+        @NotEmpty
+        @Size(min=1)
+        private String userId;
+
+        @Builder
+        public VmsControlReq(String user_id) {
+            this.userId = user_id;
+        }
+    }
+
+    @ApiModel("VmsControlParamReq(VDS 제어기 파라미터설정)")
+    @Getter
+    @Setter
+    @ToString
+    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
+    public static class VmsControlParamReq {
+
+        @ApiModelProperty("로그인 사용자 ID")
+        @JsonProperty("user_id")
+        private String userId;
+
+        //@ApiModelProperty("계획된 메시지 동작시간")
+        //@JsonProperty("sch_msg_time")
+        //@JsonIgnore
+        //private Integer schMsgTime;
+
+        //@ApiModelProperty("모듈전원 OFF 온도")
+        //@JsonProperty("module_temp")
+        //@JsonIgnore
+        //private Integer moduleTemp;
+
+        @ApiModelProperty("Fan 동작 기준온도")
+        @JsonProperty("fan_run_tmpr")
+        private Integer fanRunTmpr;
+
+        @ApiModelProperty("Heater 동작 기준온도")
+        @JsonProperty("hetr_run_tmpr")
+        private Integer hetrRunTmpr;
+
+        //@ApiModelProperty("모듈장애 판단율")
+        //@JsonProperty("module_fail")
+        //@JsonIgnore
+        //private Integer moduleFail;
+
+        //@ApiModelProperty("재시도 횟수")
+        //@JsonProperty("retry_count")
+        //@JsonIgnore
+        //private Integer retryCount;
+
+        //@ApiModelProperty("최대응답대기시간")
+        //@JsonProperty("timeout")
+        //@JsonIgnore
+        //private Integer timeOut;
+
+        @ApiModelProperty("ON 시각")
+        @JsonProperty("panl_on_time")
+        private String panlOnTime;
+
+        @ApiModelProperty("OFF 시각")
+        @JsonProperty("panl_off_time")
+        private String panlOffTime;
+
+        @Builder
+        public VmsControlParamReq(String user_id, Integer fan_run_tmpr, Integer hetr_run_tmpr, String panl_on_time, String panl_off_time) {
+            this.userId = user_id;
+            this.fanRunTmpr = fan_run_tmpr;
+            this.hetrRunTmpr = hetr_run_tmpr;
+            this.panlOnTime = panl_on_time;
+            this.panlOffTime = panl_off_time;
+        }
+
+    }
+
+    @ApiModel("VmsControlRes(VMS 제어기 제어 응답)")
+    @Getter
+    @Setter
+    @ToString
+    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
+    public static class VmsControlRes {
+
+        @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 VmsControlRes(Integer error, String message) {
+            this.error = error;
+            this.message = message;
+        }
+    }
+
+    @ApiModel("VmsControlOnOffTimeReq(VMS 제어기 전광판 ON-OFF 시각 설정 정보)")
+    @Getter
+    @Setter
+    @ToString
+    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
+    public static class VmsControlOnOffTimeReq {
+
+        @ApiModelProperty("로그인 사용자 ID")
+        @JsonProperty("user_id")
+        private String userId;
+
+        @ApiModelProperty("ON 시각")
+        @JsonProperty("on_time")
+        private String onTime;
+
+        @ApiModelProperty("OFF 시각")
+        @JsonProperty("off_time")
+        private String offTime;
+
+        @Builder
+        public VmsControlOnOffTimeReq(String user_id, String on_time, String off_time) {
+            this.userId = user_id;
+            this.onTime = on_time;
+            this.offTime = off_time;
+        }
+    }
+
+    @ApiModel("VmsControlOprModeReq(VMS 제어기 운영모드 설정 정보)")
+    @Getter
+    @Setter
+    @ToString
+    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
+    public static class VmsControlOprModeReq {
+
+        @ApiModelProperty("로그인 사용자 ID")
+        @JsonProperty("user_id")
+        private String userId;
+
+        @ApiModelProperty("운영모드(A:자동, F:고정, B:기본)")
+        @JsonProperty("opr_mode")
+        @Size(min=1, max=1)
+        @Pattern(regexp = "[AFB]")
+        private String oprMode;
+
+        @Builder
+        public VmsControlOprModeReq(String user_id, String opr_mode) {
+            this.userId = user_id;
+            this.oprMode = opr_mode;
+        }
+    }
+
+}

+ 58 - 397
src/main/java/com/its/vms/api/service/VmsControlService.java

@@ -1,429 +1,90 @@
 package com.its.vms.api.service;
 
-import com.its.vms.api.dto.*;
+import com.its.app.utils.ItsUtils;
+import com.its.vms.api.dto.VmsControlDto;
 import com.its.vms.domain.NET;
 import com.its.vms.dto.TbVmsCtlrDto;
+import com.its.vms.entity.TbVmsCtrlHs;
 import com.its.vms.service.AppRepositoryService;
-import lombok.Getter;
 import lombok.RequiredArgsConstructor;
-import lombok.Setter;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
-
-import javax.annotation.PostConstruct;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.NoSuchElementException;
+import org.springframework.transaction.annotation.Transactional;
 
 @Slf4j
 @RequiredArgsConstructor
 @Service
 public class VmsControlService {
-    
-    private final AppRepositoryService repoService;
-
-    Map<String, ControlCmd> ptzControlMap = new HashMap<>();
-
-    @PostConstruct
-    void init() {
-        this.ptzControlMap.put("zoom-in",    new ControlCmd((byte)0, (byte)0, (byte)1, (byte)0, (byte)0,    (byte)0,    (byte)0xFE, (byte)0,    "Zoom In"));
-        this.ptzControlMap.put("zoom-out",   new ControlCmd((byte)0, (byte)0, (byte)2, (byte)0, (byte)0,    (byte)0,    (byte)0xFE, (byte)0,    "Zoom Out"));
-        this.ptzControlMap.put("focus-in",   new ControlCmd((byte)0, (byte)0, (byte)0, (byte)1, (byte)0,    (byte)0,    (byte)0,    (byte)0xFE, "Focus Near"));
-        this.ptzControlMap.put("focus-out",  new ControlCmd((byte)0, (byte)0, (byte)0, (byte)2, (byte)0,    (byte)0,    (byte)0,    (byte)0xFE, "Focus Far"));
-        this.ptzControlMap.put("pan-left",   new ControlCmd((byte)1, (byte)0, (byte)0, (byte)0, (byte)0xFE, (byte)0,    (byte)0,    (byte)0,    "Pan Left"));
-        this.ptzControlMap.put("pan-right",  new ControlCmd((byte)2, (byte)0, (byte)0, (byte)0, (byte)0xFE, (byte)0,    (byte)0,    (byte)0,    "Pan Right"));
-        this.ptzControlMap.put("tilt-up",    new ControlCmd((byte)0, (byte)1, (byte)0, (byte)0, (byte)0,    (byte)0xFE, (byte)0,    (byte)0,    "Tilt Up"));
-        this.ptzControlMap.put("tilt-down",  new ControlCmd((byte)0, (byte)2, (byte)0, (byte)0, (byte)0,    (byte)0xFE, (byte)0,    (byte)0,    "Tilt Down"));
-        this.ptzControlMap.put("up-left",    new ControlCmd((byte)1, (byte)1, (byte)0, (byte)0, (byte)0xFE, (byte)0xFE, (byte)0,    (byte)0,    "Pan Tilt Left Up"));
-        this.ptzControlMap.put("up-right",   new ControlCmd((byte)2, (byte)1, (byte)0, (byte)0, (byte)0xFE, (byte)0xFE, (byte)0,    (byte)0,    "Pan Tilt Right Up"));
-        this.ptzControlMap.put("down-left",  new ControlCmd((byte)1, (byte)2, (byte)0, (byte)0, (byte)0xFE, (byte)0xFE, (byte)0,    (byte)0,    "Pan Tilt Left Down"));
-        this.ptzControlMap.put("down-right", new ControlCmd((byte)2, (byte)2, (byte)0, (byte)0, (byte)0xFE, (byte)0xFE, (byte)0,    (byte)0,    "Pan Tilt Right Down"));
-    }
-
-    @Getter
-    @Setter
-    public static class ControlCmd {
-        byte pan;
-        byte tilt;
-        byte zoom;
-        byte focus;
-        byte panSped;
-        byte tiltSped;
-        byte zoomSped;
-        byte focusSped;
-        String cmdDesc;
-        public ControlCmd(byte pan, byte tilt, byte zoom, byte focus, byte panSped, byte tiltSped, byte zoomSped, byte focusSped, String cmdDesc) {
-            this.pan = pan;
-            this.tilt = tilt;
-            this.zoom = zoom;
-            this.focus = focus;
-            this.panSped = panSped;
-            this.tiltSped = tiltSped;
-            this.zoomSped = zoomSped;
-            this.focusSped = focusSped;
-            this.cmdDesc = cmdDesc;
-        }
-    }
-
-    // 데이터 1건 조회, 없으면 exception
-    private TbVmsCtlrDto requireOne(Long id) throws NoSuchElementException {
-        return this.repoService.getCtrlMap(id);
-    }
-
-    /**
-     * VMS 상태정보 요청 처리
-     * @param id
-     * @return
-     */
-    public CctvStatusDto.CctvStatusDtoRes requestStatus(Long id) {
-        log.info("requestStatus: {}", id);
-        TbVmsCtlrDto obj = this.requireOne(id);
-        if (obj == null) {
-            return new CctvStatusDto.CctvStatusDtoRes(1, "알수없는 VMS 관리번호 입니다.", null);
-        }
-        if (obj.getNetState() != NET.LOGINED) {
-            return new CctvStatusDto.CctvStatusDtoRes(2, "VMS 제어기와 통신연결이 되어 있지 않습니다.", null);
-        }
-
-        return new CctvStatusDto.CctvStatusDtoRes(0, "success", null);//obj.getStts().toDto());
-    }
-
-    /**
-     * VMS PTZ 컨트롤
-     * @param id
-     * @param req
-     * @return
-     */
-    public CctvPtzControlDto.CctvPtzControlRes controlPtz(Long id, CctvPtzControlDto.CctvControlPtzReq req) {
-        log.info("controlPtz: {}, {}", id, req);
-        TbVmsCtlrDto obj = this.requireOne(id);
-        if (obj == null) {
-            return new CctvPtzControlDto.CctvPtzControlRes(req.getCommand(), req.getAction(), 1, "알수없는 VMS 관리번호 입니다.");
-        }
-        if (obj.getNetState() != NET.LOGINED) {
-            return new CctvPtzControlDto.CctvPtzControlRes(req.getCommand(), req.getAction(), 2, "VMS 제어기와 통신연결이 되어 있지 않습니다.");
-        }
-
-        ControlCmd command = this.ptzControlMap.get(req.getCommand());
-        if (command == null) {
-            return new CctvPtzControlDto.CctvPtzControlRes(req.getCommand(), req.getAction(), 3, "VMS PTZ 명령이 잘못 되었습니다.");
-        }
-
-        CctvPtzControlDto.CctvPtzControlRes result = new CctvPtzControlDto.CctvPtzControlRes(req.getCommand(), req.getAction(), 0, "success");
-        String cmdDesc = command.getCmdDesc();
-//        if (StringUtils.equalsIgnoreCase("start", req.getAction())) {
-//            byte speed = req.getSpeed().byteValue();
-//            byte pan = command.getPan();
-//            byte tilt = command.getTilt();
-//            byte zoom = command.getZoom();
-//            byte focus = command.getFocus();
-//            byte panSped = (byte)Math.min(command.getPanSped(), speed);
-//            byte tiltSped = (byte)Math.min(command.getTiltSped(), speed);
-//            byte zoomSped = (byte)Math.min(command.getZoomSped(), speed);
-//            byte focusSped = (byte)Math.min(command.getFocusSped(), speed);
-//            CctvReqPtzCtrl pkt = new CctvReqPtzCtrl(obj.getAddress());
-//            byte ptz = pkt.setPtzValue((byte) pan, (byte) tilt, (byte) zoom, (byte) focus, (byte) panSped, (byte) tiltSped, (byte) zoomSped, (byte) focusSped);
-//            //log.info("[{}]. PTZ Control: " + ByteUtils.byteToBitString(ptz));
-//            ByteBuffer sendBuffer = pkt.getByteBuffer();
-//            if (obj.sendData(sendBuffer, 0, "cctv_PtzStart")) {
-//                log.info("[{}]. START send success. {}", obj.getCCTV_CTLR_ID(), cmdDesc);
-//            } else {
-//                result.setResult(4, "CCTV PTZ 시작 명령 전송이 실패하였습니다.");
-//                log.error("[{}]. START send failed. {}", obj.getCCTV_CTLR_ID(), cmdDesc);
-//            }
-//        } else {
-//            // stop
-//            CctvReqPtzCtrl pkt = new CctvReqPtzCtrl(obj.getAddress());
-//            ByteBuffer sendBuffer = pkt.getByteBuffer();
-//            if (obj.sendData(sendBuffer, 0, "cctv_PtzStop")) {
-//                log.info("[{}]. STOP send success. {}", obj.getCCTV_CTLR_ID(), cmdDesc);
-//            } else {
-//                result.setResult(4, "CCTV PTZ 정지 명령 전송이 실패하였습니다.");
-//                log.error("[{}]. STOP send failed. {}", obj.getCCTV_CTLR_ID(), cmdDesc);
-//            }
-//        }
-        return result;
-    }
-
-    /**
-     * VMS Preset 컨트롤
-     * @param id
-     * @param req
-     * @return
-     */
-    public CctvPresetControlDto.CctvPresetControlRes controlPreset(Long id, CctvPresetControlDto.CctvPresetControlReq req) {
-        log.info("controlPreset: {}, {}", id, req);
-        TbVmsCtlrDto cctv = this.requireOne(id);
-        if (cctv == null) {
-            return new CctvPresetControlDto.CctvPresetControlRes(1, "VMS 제어기 정보를 찾을 수 없습니다.");
-        }
-        if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvPresetControlDto.CctvPresetControlRes(2, "VMS 제어기와 통신연결이 되어 있지 않습니다.");
-        }
-
-        CctvPresetControlDto.CctvPresetControlRes result = new CctvPresetControlDto.CctvPresetControlRes(0, "success");
-//        CctvReqPresetMove pkt = new CctvReqPresetMove(cctv.getAddress());
-//        pkt.setValue(req.getPan().shortValue(), req.getTilt().shortValue(), req.getZoom().shortValue(), req.getFocus().shortValue());
-//        ByteBuffer sendBuffer = pkt.getByteBuffer();
-//        if (cctv.sendData(sendBuffer, 0, "cctv_PresetMove")) {
-//            log.info("[{}]. PRESET send success.", cctv.getCCTV_CTLR_ID());
-//        } else {
-//            result.setResult(4, "CCTV PRESET 명령 전송이 실패하였습니다.");
-//            log.error("[{}]. PRESET send failed.", cctv.getCCTV_CTLR_ID());
-//        }
-        return result;
-    }
-
-    /**
-     * VMS 파라미터정보 설정
-     * @param id
-     * @param req
-     * @return
-     */
-    public CctvParamControlDto.CctvParamControlRes controlParam(Long id, CctvParamControlDto.CctvParamControlReq req) {
-        log.info("controlParam: {}, {}", id, req);
-        TbVmsCtlrDto cctv = this.requireOne(id);
-        if (cctv == null) {
-            return new CctvParamControlDto.CctvParamControlRes(1, "VMS 제어기 정보를 찾을 수 없습니다.");
-        }
-        if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvParamControlDto.CctvParamControlRes(2, "VMS 제어기와 통신연결이 되어 있지 않습니다.");
-        }
-
-        CctvParamControlDto.CctvParamControlRes result = new CctvParamControlDto.CctvParamControlRes(0, "success");
-//        CctvReqParamSet pkt = new CctvReqParamSet(cctv.getAddress());
-//        pkt.setValue(req.getFanOnTmpr().byteValue(), req.getFanOffTmpr().byteValue(), req.getHetrOnTmpr().byteValue(), req.getHetrOffTmpr().byteValue());
-//        ByteBuffer sendBuffer = pkt.getByteBuffer();
-//        if (cctv.sendData(sendBuffer, 0, "cctv_ParamSet")) {
-//            log.info("[{}]. PARAMETER SET send success.", cctv.getCCTV_CTLR_ID());
-//        } else {
-//            result.setResult(4, "CCTV PARAMETER 명령 전송이 실패하였습니다.");
-//            log.error("[{}]. PARAMETER SET send failed.", cctv.getCCTV_CTLR_ID());
-//        }
-        return result;
-    }
-
-    /**
-     * VMS 파라미터 정보 조회
-     * @param id
-     * @return
-     */
-    public CctvParamControlDto.CctvParamValueRes requestParam(Long id) {
-        log.info("requestParam: {}", id);
-        TbVmsCtlrDto cctv = this.requireOne(id);
-        if (cctv == null) {
-            return new CctvParamControlDto.CctvParamValueRes(1, "VMS 제어기 정보를 찾을 수 없습니다.");
-        }
-        if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvParamControlDto.CctvParamValueRes(2, "VMS 제어기와 통신연결이 되어 있지 않습니다.");
-        }
-
-        CctvParamControlDto.CctvParamValueRes result = new CctvParamControlDto.CctvParamValueRes(0, "success");
-
-//        synchronized (cctv.getParamVal()) {
-//            try {
-//                cctv.getParamVal().setRequest(true);
-//                cctv.getParamVal().setCompleted(false);
-//                ByteBuffer sendBuffer = cctv.getReqParam().getByteBuffer();
-//                if (cctv.sendData(sendBuffer, 0, "cctv_ParamReq")) {
-//                    log.info("[{}]. PARAMETER QRY send success.", cctv.getCCTV_CTLR_ID());
-//                    cctv.getParamVal().wait(5000);
-//                    if (cctv.getParamVal().isCompleted()) {
-//                        result.setValue(cctv.getParamVal().getFanOnTmpr(), cctv.getParamVal().getFanOffTmpr(), cctv.getParamVal().getHetrOnTmpr(), cctv.getParamVal().getHetrOffTmpr());
-//                    } else {
-//                        result.setResult(5, "CCTV PARAMETER 값조회 명령 중 타임아웃이 발생하였습니다.");
-//                    }
-//                } else {
-//                    result.setResult(4, "CCTV PARAMETER 값조회 명령 전송이 실패하였습니다.");
-//                    log.error("[{}]. PARAMETER QRY send failed.", cctv.getCCTV_CTLR_ID());
-//                }
-//            } catch (InterruptedException e) {
-//                result.setResult(9, "CCTV PARAMETER 값조회 명령 전송 중 오류가 발생하였습니다.");
-//                log.error("[{}]. PARAMETER QRY send failed. InterruptedException.", cctv.getCCTV_CTLR_ID());
-//            }
-//            cctv.getParamVal().setRequest(false);
-//        }
-        return result;
-    }
-
-    /**
-     * VMS 프리셋 현재위치정보 요청
-     * @param id
-     * @return
-     */
-    public CctvPresetControlDto.CctvPresetValueRes requestPresetValue(Long id) {
-        log.info("requestPresetValue: {}", id);
-        TbVmsCtlrDto cctv = this.requireOne(id);
-        if (cctv == null) {
-            return new CctvPresetControlDto.CctvPresetValueRes(1, "VMS 제어기 정보를 찾을 수 없습니다.");
-        }
-        if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvPresetControlDto.CctvPresetValueRes(2, "VMS 제어기와 통신연결이 되어 있지 않습니다.");
-        }
-
-        CctvPresetControlDto.CctvPresetValueRes result = new CctvPresetControlDto.CctvPresetValueRes(0, "success");
-//        synchronized (cctv.getPsetVal()) {
-//            try {
-//                cctv.getPsetVal().setCompleted(false);
-//                cctv.getPsetVal().setRequest(true);
-////                CctvReqPresetQry pkt = new CctvReqPresetQry(cctv.getAddress());
-////                pkt.setValue((byte)0x00);
-////                ByteBuffer sendBuffer = pkt.getByteBuffer();
-////                if (cctv.sendData(sendBuffer, 0, "cctv_PresetQry")) {
-//                ByteBuffer sendBuffer = cctv.getReqState().getByteBuffer();
-//                if (cctv.sendData(sendBuffer, 0, "cctv_PresetQry")) {
-//                    log.info("[{}]. PRESET QRY send success.", cctv.getCCTV_CTLR_ID());
-//                    cctv.getPsetVal().wait(5000);
-//                    if (cctv.getPsetVal().isCompleted()) {
-//                        result.setValue(cctv.getPsetVal().getPan(), cctv.getPsetVal().getTilt(), cctv.getPsetVal().getZoom(), cctv.getPsetVal().getFocus());
-//                    } else {
-//                        result.setResult(5, "CCTV PRESET 값조회 명령 중 타임아웃이 발생하였습니다.");
-//                    }
-//                } else {
-//                    result.setResult(4, "CCTV PRESET 값조회 명령 전송이 실패하였습니다.");
-//                    log.error("[{}]. PRESET QRY send failed.", cctv.getCCTV_CTLR_ID());
-//                }
-//            } catch (InterruptedException e) {
-//                result.setResult(6, "CCTV PRESET 값조회 명령 전송 중 오류가 발생하였습니다.");
-//                log.error("[{}]. PRESET QRY send failed. InterruptedException.", cctv.getCCTV_CTLR_ID());
-//            }
-//            cctv.getPsetVal().setRequest(false);
-//        }
-        return result;
-    }
 
-    /**
-     * Object Notify TEST
-     * @param id
-     * @return
-     */
-    public CctvStatusDto.CctvStatusNotifyDtoRes notifyStatus(Long id) {
-        log.info("notifyStatus: {}", id);
-        TbVmsCtlrDto cctv = this.requireOne(id);
-        if (cctv == null) {
-            return new CctvStatusDto.CctvStatusNotifyDtoRes(1, "VMS 제어기 정보를 찾을 수 없습니다.");
-        }
-        if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvStatusDto.CctvStatusNotifyDtoRes(2, "VMS 제어기와 통신연결이 되어 있지 않습니다.");
-        }
-
-        CctvStatusDto.CctvStatusNotifyDtoRes result = new CctvStatusDto.CctvStatusNotifyDtoRes(0, "success");
-//        synchronized (cctv.getPsetVal()) {
-//            try {
-//                cctv.getPsetVal().notifyAll();
-//            }
-//            catch(Exception e) {
-//                log.error("{}, {}", cctv.getPsetVal(), e.getMessage());
-//            }
-//        }
-        return result;
-    }
+    private final AppRepositoryService repoService;
+    //제어유형(V01:전광판ON,V02:전광판OFF,V03:제어기리셋,V04:함체환경설정,V05:전광판ON/OFF시각설정)
+//    if      (sCtlType == "V01") sCtlType = lblV01->Caption;//"전광판ON";
+//    else if (sCtlType == "V02") sCtlType = lblV02->Caption;//"전광판OFF";
+//    else if (sCtlType == "V03") sCtlType = lblV03->Caption;//"제어기리셋";
+//    else if (sCtlType == "V04") sCtlType = lblV04->Caption;//"함체환경설정";
+//    else if (sCtlType == "V05") sCtlType = lblV05->Caption;//"전광판ON/OFF시각설정";
+//    else if (sCtlType == "V06") sCtlType = lblV06->Caption;//"운영모드변경";
+//    else if (sCtlType == "V07") sCtlType = lblV07->Caption;//"휘도제어";
+//    else if (sCtlType == "V08") sCtlType = lblV08->Caption;//"기본메시지다운로드";
+//    else if (sCtlType == "V09") sCtlType = lblV09->Caption;//"폼 표출주기";
+//    else if (sCtlType == "V10") sCtlType = lblV10->Caption;//"폼 즉시 다운로드";
 
     /**
-     * VMS 가변문자 설정
-     * @param id
-     * @param req
-     * @return
+     * VMS 제어 이력 저장
+     * @param dto
      */
-    public CctvVarCharControlDto.CctvVarCharControlRes controlVarCharSet(Long id, CctvVarCharControlDto.CctvVarCharControlSetReq req) {
-        log.info("controlVarCharSet: {}, {}", id, req);
-        TbVmsCtlrDto cctv = this.requireOne(id);
-        if (cctv == null) {
-            return new CctvVarCharControlDto.CctvVarCharControlRes(1, "VMS 제어기 정보를 찾을 수 없습니다.");
-        }
-        if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvVarCharControlDto.CctvVarCharControlRes(2, "VMS 제어기와 통신연결이 되어 있지 않습니다.");
-        }
-
-        CctvVarCharControlDto.CctvVarCharControlRes result = new CctvVarCharControlDto.CctvVarCharControlRes(0, "success");
-//        CctvReqCharVar pkt = new CctvReqCharVar(cctv.getAddress());
-//        if (!pkt.setValue(
-//                req.getSectorNo().byteValue(),
-//                req.getStartPan(), req.getEndPan(),
-//                req.getCh1CharSize().byteValue(), req.getCh1PosX(), req.getCh2PosY(),
-//                req.getCh2CharSize().byteValue(), req.getCh2PosX(), req.getCh2PosY(),
-//                req.getCh1Char(), req.getCh2Char()
-//                )) {
-//            return new CctvVarCharControlDto.CctvVarCharControlRes(3, "CCTV 가변문자 설정값에 오류가 있습니다.");
-//        }
-//
-//        ByteBuffer sendBuffer = pkt.getByteBuffer();
-//        if (cctv.sendData(sendBuffer, 0, "cctv_CharVarSet")) {
-//            log.info("[{}]. CHAR-VAR-SET send success.", cctv.getCCTV_CTLR_ID());
-//        } else {
-//            result.setResult(4, "CCTV CHAR-VAR-SET 명령 전송이 실패하였습니다.");
-//            log.error("[{}]. CHAR-VAR-SET send failed.", cctv.getCCTV_CTLR_ID());
-//        }
-        return result;
+    @Transactional
+    public void saveCtrlHs(TbVmsCtrlHs dto) {
+        //this.repoCtrlHs.insertHs(dto.getCtrlDt(), dto.getVmsCtlrNmbr(), dto.getCtrlType(), dto.getCtrlVal(), dto.getCtrlResult(), dto.getUserId());
     }
 
     /**
-     * VMS 가변문자 삭제
-     * @param id
-     * @param req
+     * VMS 정보를 메모리에서 찾는다.
+     * @param vmsCtlrNmbr
      * @return
      */
-    public CctvVarCharControlDto.CctvVarCharControlRes controlVarCharDel(Long id, CctvVarCharControlDto.CctvVarCharControlDelReq req) {
-        log.info("controlVarCharDel: {}, {}", id, req);
-        TbVmsCtlrDto cctv = this.requireOne(id);
-        if (cctv == null) {
-            return new CctvVarCharControlDto.CctvVarCharControlRes(1, "VMS 제어기 정보를 찾을 수 없습니다.");
-        }
-        if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvVarCharControlDto.CctvVarCharControlRes(2, "VMS 제어기와 통신연결이 되어 있지 않습니다.");
-        }
-
-        CctvVarCharControlDto.CctvVarCharControlRes result = new CctvVarCharControlDto.CctvVarCharControlRes(0, "success");
-//        CctvReqCharDel pkt = new CctvReqCharDel(cctv.getAddress());
-//        pkt.setValue(req.getSectorNo().byteValue());
-//
-//        ByteBuffer sendBuffer = pkt.getByteBuffer();
-//        if (cctv.sendData(sendBuffer, 0, "cctv_CharVarDel")) {
-//            log.info("[{}]. CHAR-VAR-DEL send success.", cctv.getCCTV_CTLR_ID());
-//        } else {
-//            result.setResult(4, "CCTV CHAR-VAR-DEL 명령 전송이 실패하였습니다.");
-//            log.error("[{}]. CHAR-VAR-DEL send failed.", cctv.getCCTV_CTLR_ID());
-//        }
-        return result;
+    public TbVmsCtlrDto findVms(Long vmsCtlrNmbr) {
+        return this.repoService.getCtrlMap(vmsCtlrNmbr);
     }
 
     /**
      * VMS 제어기 리셋
-     * @param id
+     * @param vmsCtlrNmbr
      * @param req
      * @return
      */
-    public CctvControlDto.CctvControlResetRes controlReset(Long id, CctvControlDto.CctvControlResetReq req) {
-        log.info("controlReset: {}, {}", id, req);
-        TbVmsCtlrDto cctv = this.requireOne(id);
-        if (cctv == null) {
-            return new CctvControlDto.CctvControlResetRes(1, "VMS 제어기 정보를 찾을 수 없습니다.");
-        }
-        if (cctv.getNetState() != NET.LOGINED) {
-            return new CctvControlDto.CctvControlResetRes(2, "VMS 제어기와 통신연결이 되어 있지 않습니다.");
-        }
-
-        CctvControlDto.CctvControlResetRes result = new CctvControlDto.CctvControlResetRes(0, "success");
-//        if (0 == req.getResetType()) {
-//            // SW Reset
-//            if (!cctv.resetSw()) {
-//                result.setResult(4, "CCTV 제어기 SW 리셋 명령 전송에 실패하였습니다.");
-//            } else {
-//                log.info("[{}]. SW Reset send success.", cctv.getCCTV_CTLR_ID());
-//            }
-//        }
-//        else if (1 == req.getResetType()) {
-//            // HW Reset
-//            if (!cctv.resetHw()) {
-//                result.setResult(5, "CCTV 제어기 HW 리셋 명령 전송에 실패하였습니다.");
-//            } else {
-//                log.info("[{}]. HW Reset send success.", cctv.getCCTV_CTLR_ID());
-//            }
-//        }
-//        else {
-//            result.setResult(3, "CCTV 리셋 정보가 잘못 되었습니다.");
-//        }
-        return result;
+    public VmsControlDto.VmsControlRes controlReset(Long vmsCtlrNmbr, VmsControlDto.VmsControlReq req) {
+        log.warn("controlReset: VMS {}, controlReset {}.", vmsCtlrNmbr, req);
+        TbVmsCtlrDto vmsObj = findVms(vmsCtlrNmbr);
+        Integer error = 0;
+        String message = "success";
+
+        if (vmsObj == null) {
+            error = 8;
+            message = "알수 없는 제어기 입니다.";
+        }
+        else {
+            if (vmsObj.getNetState() == NET.CLOSED) {
+                error = 1;
+                message = "통신이 연결되어 있지 않습니다.";
+            }
+            else {
+                if (!vmsObj.reset()) {
+                    error = 2;
+                    message = "데이터 전송 중 오류가 발생 했습니다.";
+                }
+            }
+        }
+
+        saveCtrlHs(TbVmsCtrlHs.builder()
+                .ctrlDt(ItsUtils.getSysTime())
+                .vmsCtlrNmbr(vmsCtlrNmbr)
+                .ctrlType("V03")
+                .ctrlVal("Reset")
+                .ctrlResult(error)
+                .userId(req.getUserId())
+                .build());
+        return new VmsControlDto.VmsControlRes(error, message);
     }
 
 }

+ 1 - 1
src/main/java/com/its/vms/dto/TbVmsCtlrDto.java

@@ -329,7 +329,7 @@ public class TbVmsCtlrDto implements Serializable {
         return true;
     }
 
-    public boolean reset(TbVmsCtrlHs ctrlHs) {
+    public boolean reset() {
         if (getChannel() == null || getNetState() == NET.CLOSED) {
             log.error("Reset Request: channel not connected: [{}]", this);
             return false;

+ 1 - 1
src/main/java/com/its/vms/ui/MainUI.java

@@ -257,7 +257,7 @@ public class MainUI {
                 result = this.selObj.channelClose();
                 break;
             case 2:
-                result = this.selObj.reset(null);
+                result = this.selObj.reset();
                 break;
             case 4:
                 result = true;