shjung 1 year ago
parent
commit
c186daa697

+ 0 - 2
app-install/conf/debug.properties

@@ -1,5 +1,3 @@
 #system debug setting configuration...
 #Tue Nov 07 17:54:17 KST 2023
-packet-info=x
-packet-dump=x
 system-debug=false

+ 0 - 1
conf/agip-comm-server.pid

@@ -1 +0,0 @@
-70372

+ 1 - 3
conf/debug.properties

@@ -1,5 +1,3 @@
 #system debug setting configuration...
-#Mon Nov 27 16:51:26 KST 2023
-packet-info=x
-packet-dump=x
+#Tue Nov 28 11:31:30 KST 2023
 system-debug=false

+ 17 - 22
src/main/java/com/its/bis/AgipCommServerApplication.java

@@ -5,12 +5,8 @@ import com.its.app.utils.OS;
 import com.its.app.utils.SysUtils;
 import com.its.bis.config.ApplicationConfig;
 import com.its.bis.config.DebugConfig;
-import com.its.bis.dto.Location;
-import com.its.bis.dto.NearNodeDto;
-import com.its.bis.dto.TbLinkDto;
 import com.its.bis.entity.TbUnitSyst;
 import com.its.bis.process.DbmsDataProcess;
-import com.its.bis.service.BisAgipService;
 import com.its.bis.service.NodeLinkService;
 import com.its.bis.service.UnitSystService;
 import com.its.bis.ui.JTextAreaOutputStream;
@@ -153,30 +149,29 @@ public class AgipCommServerApplication implements CommandLineRunner, Application
         NodeLinkService nodeLinkService = (NodeLinkService)AppUtils.getBean(NodeLinkService.class);
         nodeLinkService.loadDb();
 
-        BisAgipService bisAgipService = (BisAgipService)AppUtils.getBean(BisAgipService.class);
-        Location from = Location.builder()
-                .mLatitude(128.74352336)
-                .mLongitude(36.56392018)
-                .build();
-        NearNodeDto fNode = bisAgipService.getNearNode(from);
-        log.info("From NearNode: {}", fNode);
-
-        Location to = Location.builder()
-                .mLatitude(128.73881251)
-                .mLongitude(36.56128759)
-                .build();
-        NearNodeDto tNode = bisAgipService.getNearNode(to);
-        log.info("  To NearNode: {}", tNode);
-
-        TbLinkDto link = bisAgipService.getSectInfo(fNode.getNodeId(), tNode.getNodeId());
-        log.info("Matching Link: {}", link);
+//        BisAgipService bisAgipService = (BisAgipService)AppUtils.getBean(BisAgipService.class);
+//        Location from = Location.builder()
+//                .mLatitude(128.74352336)
+//                .mLongitude(36.56392018)
+//                .build();
+//        NearNodeDto fNode = bisAgipService.getNearNode(from);
+//        log.info("From NearNode: {}", fNode);
+//
+//        Location to = Location.builder()
+//                .mLatitude(128.73881251)
+//                .mLongitude(36.56128759)
+//                .build();
+//        NearNodeDto tNode = bisAgipService.getNearNode(to);
+//        log.info("  To NearNode: {}", tNode);
+//
+//        TbLinkDto link = bisAgipService.getSectInfo(fNode.getNodeId(), tNode.getNodeId());
+//        log.info("Matching Link: {}", link);
 
         DebugConfig debugConfig = (DebugConfig)AppUtils.getBean(DebugConfig.class);
         debugConfig.loadDebugInfo();
 
         // schedule enable
         applicationConfig.setStartSchedule(true);
-//        log.error("AAAAA: {}", Toolkit.getDefaultToolkit().getScreenSize());
     }
 
     public void terminateApplication() {

+ 8 - 2
src/main/java/com/its/bis/api/controller/AgipControlController.java

@@ -3,6 +3,7 @@ package com.its.bis.api.controller;
 import com.its.app.utils.SysUtils;
 import com.its.bis.api.dto.AgipObeLoc;
 import com.its.bis.api.service.AgipControlService;
+import com.its.bis.config.DebugConfig;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
@@ -25,17 +26,22 @@ import java.util.Map;
 public class AgipControlController {
 
     private final AgipControlService service;
+    private final DebugConfig debugConfig;
 
     @ApiOperation(value = "AGIP 실시간 OBE 위치정보 수집")
     @PostMapping(value = "/location2", produces = {"application/json; charset=utf8"})
     public void receiveWebhooksFromAGIP2(@RequestBody List<Map<String, Object>> payload) {
-        log.error("{}", payload);
+        if (this.debugConfig.isDebug()) {
+            log.error("{}", payload);
+        }
     }
 
     @ApiOperation(value = "AGIP 실시간 OBE 위치정보 수집")
     @PostMapping(value = "/location", produces = {"application/json; charset=utf8"})
     public void receiveWebhooksFromAGIP(@RequestBody AgipObeLoc payload) {
-        log.info("{}", payload);
+        if (this.debugConfig.isDebug()) {
+            log.info("{}", payload);
+        }
         this.service.add(payload);
     }
 

+ 29 - 31
src/main/java/com/its/bis/config/DebugConfig.java

@@ -1,7 +1,6 @@
 package com.its.bis.config;
 
 import com.its.app.AppUtils;
-import com.its.app.utils.StringUtils;
 import com.its.bis.service.AppRepositoryService;
 import lombok.Getter;
 import lombok.Setter;
@@ -14,7 +13,6 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.util.List;
 import java.util.Properties;
 
 @Slf4j
@@ -40,7 +38,7 @@ public class DebugConfig {
                 in = new FileInputStream(workingDir + "/conf/debug.properties");
             }
             catch(Exception e) {
-                log.error("{}.loadDebugInfo: Exception1: {}", this.getClass().getSimpleName(), e.toString());
+                log.error("{}.loadDefaultInfo: Exception1: {}", this.getClass().getSimpleName(), e.toString());
                 return;
             }
 
@@ -52,7 +50,7 @@ public class DebugConfig {
             this.isDebug = "true".equalsIgnoreCase(isDebug);
         }
         catch(Exception e) {
-            log.error("{}.loadDebugInfo: Exception2: {}", this.getClass().getSimpleName(), e.toString());
+            log.error("{}.loadDefaultInfo: Exception2: {}", this.getClass().getSimpleName(), e.toString());
         }
     }
 
@@ -76,33 +74,33 @@ public class DebugConfig {
             String isDebug  = props.getProperty("system-debug",  "false").trim();
             this.isDebug = "true".equalsIgnoreCase(isDebug);
 
-            AppRepositoryService repoService = (AppRepositoryService) AppUtils.getBean(AppRepositoryService.class);
-//            repoService.getCtlrMap().forEach((ctlrNmbr, vmsObj) -> {
-//                vmsObj.getDebug().init();
-//            });
-
-            String packetDump  = props.getProperty("packet-dump",  "x").trim();
-            if (!packetDump.equals("x")) {
-                List<String> packetDumps = StringUtils.split(packetDump, ",");
-                packetDumps.forEach(id -> {
-//                    Long vmsCtlrNmbr = Long.parseLong(id);
-//                    TbVmsCtlrDto vmsObj = repoService.getCtlrMap(vmsCtlrNmbr);
-//                    if (vmsObj != null) {
-//                        vmsObj.getDebug().setDump(true);
-//                    }
-                });
-            }
-            String packetInfo  = props.getProperty("packet-info",  "x").trim();
-            if (!packetInfo.equals("x")) {
-                List<String> packetInfos = StringUtils.split(packetInfo, ",");
-                packetInfos.forEach(id -> {
-//                    Long vmsCtlrNmbr = Long.parseLong(id);
-//                    TbVmsCtlrDto vmsObj = repoService.getCtlrMap(vmsCtlrNmbr);
-//                    if (vmsObj != null) {
-//                        vmsObj.getDebug().setDebug(true);
-//                    }
-                });
-            }
+//            AppRepositoryService repoService = (AppRepositoryService) AppUtils.getBean(AppRepositoryService.class);
+////            repoService.getCtlrMap().forEach((ctlrNmbr, vmsObj) -> {
+////                vmsObj.getDebug().init();
+////            });
+//
+//            String packetDump  = props.getProperty("packet-dump",  "x").trim();
+//            if (!packetDump.equals("x")) {
+//                List<String> packetDumps = StringUtils.split(packetDump, ",");
+//                packetDumps.forEach(id -> {
+////                    Long vmsCtlrNmbr = Long.parseLong(id);
+////                    TbVmsCtlrDto vmsObj = repoService.getCtlrMap(vmsCtlrNmbr);
+////                    if (vmsObj != null) {
+////                        vmsObj.getDebug().setDump(true);
+////                    }
+//                });
+//            }
+//            String packetInfo  = props.getProperty("packet-info",  "x").trim();
+//            if (!packetInfo.equals("x")) {
+//                List<String> packetInfos = StringUtils.split(packetInfo, ",");
+//                packetInfos.forEach(id -> {
+////                    Long vmsCtlrNmbr = Long.parseLong(id);
+////                    TbVmsCtlrDto vmsObj = repoService.getCtlrMap(vmsCtlrNmbr);
+////                    if (vmsObj != null) {
+////                        vmsObj.getDebug().setDebug(true);
+////                    }
+//                });
+//            }
         }
         catch(Exception e) {
             log.error("{}.loadDebugInfo: Exception2: {}", this.getClass().getSimpleName(), e.toString());

+ 27 - 32
src/main/java/com/its/bis/service/BisAgipService.java

@@ -1,13 +1,9 @@
 package com.its.bis.service;
 
-import com.its.app.utils.Elapsed;
 import com.its.bis.api.dto.AgipObeLoc;
 import com.its.bis.config.ServerConfig;
 import com.its.bis.config.ThreadPoolInitializer;
-import com.its.bis.dto.Location;
-import com.its.bis.dto.NearNodeDto;
 import com.its.bis.dto.TbLinkDto;
-import com.its.bis.dto.TbNodeDto;
 import com.its.bis.process.DbmsDataProcess;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -18,7 +14,6 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.PostConstruct;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 @Slf4j
 @Service
@@ -87,34 +82,34 @@ public class BisAgipService {
         }
     }
 
-    public double getDistance(double lat1, double lon1, double lat2, double lon2) {
-        double EARTH_RADIUS = 6371.0;
-        double dLat = Math.toRadians(lat2 - lat1);
-        double dLon = Math.toRadians(lon2 - lon1);
+//    public double getDistance(double lat1, double lon1, double lat2, double lon2) {
+//        double EARTH_RADIUS = 6371.0;
+//        double dLat = Math.toRadians(lat2 - lat1);
+//        double dLon = Math.toRadians(lon2 - lon1);
+//
+//        double a = Math.sin(dLat/2)* Math.sin(dLat/2)+ Math.cos(Math.toRadians(lat1))* Math.cos(Math.toRadians(lat2))* Math.sin(dLon/2)* Math.sin(dLon/2);
+//        double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
+//        return (EARTH_RADIUS * c * 1000);    // Distance in m
+//    }
 
-        double a = Math.sin(dLat/2)* Math.sin(dLat/2)+ Math.cos(Math.toRadians(lat1))* Math.cos(Math.toRadians(lat2))* Math.sin(dLon/2)* Math.sin(dLon/2);
-        double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
-        return (EARTH_RADIUS * c * 1000);    // Distance in m
-    }
-
-    public NearNodeDto getNearNode(Location loc) {
-        Elapsed elapsed = new Elapsed();
-        log.info("getNearNode: {}", loc);
-        //Location(mDistance=0.0, mInitialBearing=0.0, mFinalBearing=0.0, mLatitude=128.73881251, mLongitude=36.56128759)
-        double maxDistance = 40;
-        NearNodeDto node = NearNodeDto.builder().nodeId(0L).distance(maxDistance).build();
-        for (Map.Entry<Long, TbNodeDto> e : this.repoService.getEntrySetNode()) {
-            TbNodeDto obj = e.getValue();
-            double fDistance = (float) getDistance(loc.getMLatitude(), loc.getMLongitude(), obj.getXCrdn(), obj.getYCrdn());
-            if (fDistance < maxDistance) {
-                maxDistance = fDistance;
-                node.setNodeId(obj.getNodeId());
-                node.setDistance(fDistance);
-            }
-        }
-        log.info("getNearNode: {} ms. {} m, {}", elapsed.milliSeconds(), maxDistance, node);
-        return node;
-    }
+//    public NearNodeDto getNearNode(Location loc) {
+//        Elapsed elapsed = new Elapsed();
+//        log.info("getNearNode: {}", loc);
+//        //Location(mDistance=0.0, mInitialBearing=0.0, mFinalBearing=0.0, mLatitude=128.73881251, mLongitude=36.56128759)
+//        double maxDistance = 100;
+//        NearNodeDto node = NearNodeDto.builder().nodeId(0L).distance(maxDistance).build();
+//        for (Map.Entry<Long, TbNodeDto> e : this.repoService.getEntrySetNode()) {
+//            TbNodeDto obj = e.getValue();
+//            double fDistance = (float) getDistance(loc.getMLatitude(), loc.getMLongitude(), obj.getXCrdn(), obj.getYCrdn());
+//            if (fDistance < maxDistance) {
+//                maxDistance = fDistance;
+//                node.setNodeId(obj.getNodeId());
+//                node.setDistance(fDistance);
+//            }
+//        }
+//        log.info("getNearNode: {} ms. {} m, {}", elapsed.milliSeconds(), maxDistance, node);
+//        return node;
+//    }
 
     public TbLinkDto getSectInfo(Long fNodeId, Long tNodeId) {
         return this.repoService.getSectMap(fNodeId, tNodeId);

+ 0 - 1
src/main/java/com/its/bis/service/BisAgipWorker.java

@@ -239,7 +239,6 @@ public class BisAgipWorker implements Runnable {
                 maxDistance = fDistance;
                 nearNode.setNodeId(node.getNodeId());
                 nearNode.setDistance(fDistance);
-                //log.info("{}", nearNode);
             }
         }
         log.info("getNearNode: {} ms. {} m, {}", elapsed.milliSeconds(), maxDistance, nearNode);