|
|
@@ -1,9 +1,9 @@
|
|
|
package com.its.vms.webapp.controller;
|
|
|
|
|
|
import com.its.vms.config.ApplicationConfig;
|
|
|
-import com.its.vms.entity.TbVmsCtlr;
|
|
|
-import com.its.vms.global.AppRepository;
|
|
|
import com.its.vms.dto.NET;
|
|
|
+import com.its.vms.entity.TbVmsCtlr;
|
|
|
+import com.its.vms.service.AppRepositoryService;
|
|
|
import com.its.vms.webapp.service.FileService;
|
|
|
import com.its.vms.xnettcp.vms.handler.VmsServerIdleStateHandler;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
@@ -30,13 +30,15 @@ public class WebAppController {
|
|
|
|
|
|
private final ResourceLoader resourceLoader;
|
|
|
private final ApplicationConfig applicationConfig;
|
|
|
+ private final AppRepositoryService repoService;
|
|
|
private final FileService fileService;
|
|
|
|
|
|
@RequestMapping(value = {"/controller"})
|
|
|
public String controller(Model model, HttpServletRequest request) {
|
|
|
String result = "controller";
|
|
|
SortedMap<Long, TbVmsCtlr> ctlrMap = new TreeMap<>();
|
|
|
- for (Map.Entry<Long, TbVmsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
|
|
|
+ //for (Map.Entry<Long, TbVmsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
|
|
|
+ for (Map.Entry<Long, TbVmsCtlr> e : this.repoService.getCtlrMap().entrySet()) {
|
|
|
TbVmsCtlr obj = e.getValue();
|
|
|
if (obj.getNetState() == NET.CLOSED) {
|
|
|
// if (obj.getChannel() != null || obj.getLogin() != null) {
|
|
|
@@ -56,7 +58,8 @@ public class WebAppController {
|
|
|
@ResponseBody
|
|
|
public ConcurrentHashMap<Long, TbVmsCtlr> getControllerInfo() {
|
|
|
ConcurrentHashMap<Long, TbVmsCtlr> ctlrMap = new ConcurrentHashMap<>();
|
|
|
- for (Map.Entry<Long, TbVmsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
|
|
|
+ //for (Map.Entry<Long, TbVmsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
|
|
|
+ for (Map.Entry<Long, TbVmsCtlr> e : this.repoService.getCtlrMap().entrySet()) {
|
|
|
TbVmsCtlr obj = e.getValue();
|
|
|
ctlrMap.put(obj.getCtlrNmbr(), obj);
|
|
|
}
|
|
|
@@ -65,9 +68,10 @@ public class WebAppController {
|
|
|
|
|
|
@RequestMapping(value = ("/disconnectController"))
|
|
|
@ResponseBody
|
|
|
- public String disconnectController(@RequestParam("id") String id) {
|
|
|
+ public String disconnectController(@RequestParam("id") Long id) {
|
|
|
String result = "제어기와의 통신 연결을 종료 하였습니다.";
|
|
|
- TbVmsCtlr ctlr = AppRepository.getInstance().getCtlrMap().get(id);
|
|
|
+ //TbVmsCtlr ctlr = AppRepository.getInstance().getCtlrMap().get(id);
|
|
|
+ TbVmsCtlr ctlr = this.repoService.getCtrlMap(id);
|
|
|
if (ctlr != null && ctlr.getNetState() > NET.CLOSED && ctlr.getChannel() != null) {
|
|
|
if (ctlr.getNetState() == NET.LOGIN_REQ) {
|
|
|
VmsServerIdleStateHandler.disconnectChannel(ctlr, ctlr.getChannel());
|
|
|
@@ -91,7 +95,8 @@ public class WebAppController {
|
|
|
@ResponseBody
|
|
|
public String allDisconnectController() {
|
|
|
String result = "통신 연결 중인 제어기와의 통신 연결을 종료 하였습니다.";
|
|
|
- for (Map.Entry<Long, TbVmsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
|
|
|
+ //for (Map.Entry<Long, TbVmsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
|
|
|
+ for (Map.Entry<Long, TbVmsCtlr> e : this.repoService.getCtlrMap().entrySet()) {
|
|
|
TbVmsCtlr ctlr = e.getValue();
|
|
|
//if (ctlr != null && ctlr.getNetState() > NET.CLOSED && ctlr.getChannel() != null) {
|
|
|
if (ctlr != null && ctlr.getChannel() != null) {
|
|
|
@@ -113,9 +118,10 @@ public class WebAppController {
|
|
|
|
|
|
@RequestMapping(value = ("/resetConnCount"))
|
|
|
@ResponseBody
|
|
|
- public String resetConnCount(@RequestParam("id") String id) {
|
|
|
+ public String resetConnCount(@RequestParam("id") Long id) {
|
|
|
String result = "통신 접속횟수를 초기화 하였습니다.";
|
|
|
- TbVmsCtlr ctlr = AppRepository.getInstance().getCtlrMap().get(id);
|
|
|
+ //TbVmsCtlr ctlr = AppRepository.getInstance().getCtlrMap().get(id);
|
|
|
+ TbVmsCtlr ctlr = this.repoService.getCtrlMap(id);
|
|
|
if (ctlr != null) {
|
|
|
ctlr.resetConnectCount();
|
|
|
}
|
|
|
@@ -126,7 +132,8 @@ public class WebAppController {
|
|
|
@ResponseBody
|
|
|
public String allResetConnCount() {
|
|
|
String result = "모든 제어기의 통신 접속횟수를 초기화 하였습니다.";
|
|
|
- for (Map.Entry<Long, TbVmsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
|
|
|
+ //for (Map.Entry<Long, TbVmsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
|
|
|
+ for (Map.Entry<Long, TbVmsCtlr> e : this.repoService.getCtlrMap().entrySet()) {
|
|
|
TbVmsCtlr ctlr = e.getValue();
|
|
|
ctlr.resetConnectCount();
|
|
|
}
|
|
|
@@ -135,9 +142,10 @@ public class WebAppController {
|
|
|
|
|
|
@RequestMapping(value = ("/resetController"))
|
|
|
@ResponseBody
|
|
|
- public String resetController(@RequestParam("id") String id) {
|
|
|
+ public String resetController(@RequestParam("id") Long id) {
|
|
|
String result = "제어기를 리셋 하였습니다.";
|
|
|
- TbVmsCtlr ctlr = AppRepository.getInstance().getCtlrMap().get(id);
|
|
|
+ //TbVmsCtlr ctlr = AppRepository.getInstance().getCtlrMap().get(id);
|
|
|
+ TbVmsCtlr ctlr = this.repoService.getCtrlMap(id);
|
|
|
if (ctlr != null && ctlr.getNetState() > NET.CLOSED && ctlr.getChannel() != null) {
|
|
|
// TcpServerIdleStateHandler.disconnectChannel(ctlr.getChannel());
|
|
|
// try {
|
|
|
@@ -156,7 +164,8 @@ public class WebAppController {
|
|
|
@ResponseBody
|
|
|
public String allResetController(@RequestParam("id") String id) {
|
|
|
String result = "통신 연결 중인 제어기를 리셋 하였습니다.";
|
|
|
- for (Map.Entry<Long, TbVmsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
|
|
|
+ //for (Map.Entry<Long, TbVmsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
|
|
|
+ for (Map.Entry<Long, TbVmsCtlr> e : this.repoService.getCtlrMap().entrySet()) {
|
|
|
TbVmsCtlr ctlr = e.getValue();
|
|
|
if (ctlr != null && ctlr.getNetState() > NET.CLOSED && ctlr.getChannel() != null) {
|
|
|
if (ctlr.getNetState() == NET.LOGIN_REQ) {
|