shjung 10 mesi fa
parent
commit
5a552d15f3

+ 1 - 0
conf/sig-todp-server-trace.cfg

@@ -0,0 +1 @@
+#L01=1,2,3

+ 2 - 2
conf/sig-todp-server.yml

@@ -1,8 +1,8 @@
 spring:
   profiles:
-    active: prod
+    active: dev
 server:
   port: 9873
 
 application:
-  binding-port: 7900
+  process-id: 81011

+ 4 - 0
src/main/java/com/sig/todp/server/SigTodpServerApplication.java

@@ -1,6 +1,7 @@
 package com.sig.todp.server;
 
 import com.sig.todp.server.common.SpringUtils;
+import com.sig.todp.server.config.TraceConfig;
 import com.sig.todp.server.process.dbms.DbmsDataProcess;
 import com.sig.todp.server.repository.ApplicationRepository;
 import com.sig.todp.server.service.SigTodpService;
@@ -58,6 +59,9 @@ public class SigTodpServerApplication implements CommandLineRunner, ApplicationL
         ApplicationRepository applicationRepository = SpringUtils.getBean(ApplicationRepository.class);
         applicationRepository.loadDb();
 
+        TraceConfig traceConfig = SpringUtils.getBean(TraceConfig.class);
+        traceConfig.loadTraceInfo();
+
         SigTodpService sigTodpService = SpringUtils.getBean(SigTodpService.class);
         sigTodpService.loadTodDatabase();
         sigTodpService.start();

+ 44 - 0
src/main/java/com/sig/todp/server/common/StringUtils.java

@@ -0,0 +1,44 @@
+package com.sig.todp.server.common;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+public class StringUtils {
+
+    private StringUtils() {}
+
+    public static String getString(boolean value) {
+        return value ? "1" : "0";
+    }
+
+    public static List<String> splitEmpty(String value, String separator) {
+        List<String> results = new ArrayList<String>();
+        StringTokenizer stringTokenizer = new StringTokenizer(value, separator);
+        while (stringTokenizer.hasMoreTokens()) {
+            results.add(stringTokenizer.nextToken().trim());
+        }
+        return results;
+    }
+
+    public static List<String> split(String value, String separator) {
+        String[] splits = value.split(separator);
+        List<String> results = new ArrayList<String>();
+        for (int ii = 0; ii < splits.length; ii++) {
+            splits[ii] = splits[ii].trim();
+            if (splits[ii].length() > 0) {
+                results.add(splits[ii]);
+            }
+        }
+        return results;
+    }
+
+    public static boolean isEmpty(String str) {
+        return str == null || str.length() == 0;
+    }
+
+    public static boolean isBlank(String s) {
+        return s == null || s.trim().isEmpty();
+    }
+
+}

+ 5 - 6
src/main/java/com/sig/todp/server/config/DatabaseConfig.java

@@ -15,7 +15,6 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Primary;
-import org.springframework.jdbc.datasource.DataSourceTransactionManager;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 
 import javax.annotation.PostConstruct;
@@ -72,9 +71,9 @@ public class DatabaseConfig {
         return new SqlSessionTemplate(sqlSessionFactory);
     }
 
-    @Primary
-    @Bean(name="transactionManager")
-    public DataSourceTransactionManager transactionManager(@Autowired @Qualifier("dataSource") DataSource dataSource) {
-        return new DataSourceTransactionManager(dataSource);
-    }
+//    @Primary
+//    @Bean(name="transactionManager")
+//    public DataSourceTransactionManager transactionManager(@Autowired @Qualifier("dataSource") DataSource dataSource) {
+//        return new DataSourceTransactionManager(dataSource);
+//    }
 }

+ 86 - 0
src/main/java/com/sig/todp/server/config/TraceConfig.java

@@ -0,0 +1,86 @@
+package com.sig.todp.server.config;
+
+import com.sig.todp.server.common.StringUtils;
+import com.sig.todp.server.dto.RegionCenter;
+import com.sig.todp.server.dto.TTodInt;
+import com.sig.todp.server.repository.ApplicationRepository;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.io.FileInputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+
+@Slf4j
+@Getter
+@Setter
+@ToString
+@RequiredArgsConstructor
+@Component
+public class TraceConfig {
+
+    private final ApplicationRepository repo;
+
+    private Properties getProperties() {
+        String workingDir = System.getProperty("user.dir");
+        try {
+            FileInputStream in = new FileInputStream(workingDir + "/conf/sig-todp-server-trace.cfg");
+            Properties props = new Properties();
+            props.load(in);
+            in.close();
+            return props;
+        }
+        catch(Exception e) {
+            log.error("{}.getTraceFileInputStream: Exception1: {}", this.getClass().getSimpleName(), e.toString());
+            return null;
+        }
+    }
+
+    private int getIntNo(String intNo) {
+        try {
+            return Integer.parseInt(intNo.trim());
+        }
+        catch (NumberFormatException e) {
+            return -1;
+        }
+    }
+    public void loadTraceInfo() {
+        try {
+            Properties props = getProperties();
+            if (props == null) {
+                return;
+            }
+
+            List<String> keySet = new ArrayList<>(this.repo.getCenterMap().keySet());
+            Collections.sort(keySet);
+            for (String key : keySet) {
+                RegionCenter region = this.repo.getCenterMap().get(key);
+                if (region == null) {
+                    continue;
+                }
+                region.getIntMap().forEach((id, value) -> value.setDebug(false));
+                String traceInts  = props.getProperty(region.getRegionCd(),  "").trim();
+                if (traceInts.isEmpty()) {
+                    continue;
+                }
+                List<String> intList = StringUtils.split(traceInts, ",");
+                intList.forEach(id -> {
+                    TTodInt intDto = region.getIntMap().get(getIntNo(id));
+                    if (intDto != null) {
+                        intDto.setDebug(true);
+                    }
+                });
+            }
+        }
+        catch(Exception e) {
+            log.error("{}.loadDebugInfo: Exception2: {}", this.getClass().getSimpleName(), e.toString());
+        }
+    }
+
+}

+ 4 - 0
src/main/java/com/sig/todp/server/dto/TTodInt.java

@@ -25,6 +25,8 @@ public class TTodInt implements Serializable {
     public boolean useTrans;
     public TTodTransition trans;
 
+    private boolean debug;
+
     public TTodInt(TbInt entity) {
         this.isDeleted = false;
         this.regionCd = entity.getRegionCd();
@@ -42,6 +44,7 @@ public class TTodInt implements Serializable {
 
         this.useTrans = false;
         this.trans = new TTodTransition();
+        this.debug = false;
     }
 
     public void update(TTodInt dto) {
@@ -50,5 +53,6 @@ public class TTodInt implements Serializable {
         this.intLampType = dto.getIntLampType();
         this.mainIntNo = dto.getMainIntNo();
         this.groupNo = dto.getGroupNo();
+        this.debug = dto.isDebug();
     }
 }

+ 3 - 0
src/main/java/com/sig/todp/server/scheduler/ApplicationScheduler.java

@@ -1,6 +1,7 @@
 package com.sig.todp.server.scheduler;
 
 import com.sig.todp.server.aspect.annotation.ScheduleElapsed;
+import com.sig.todp.server.config.TraceConfig;
 import com.sig.todp.server.repository.ApplicationRepository;
 import com.sig.todp.server.service.SigTodpService;
 import com.sig.todp.server.service.UnitSystService;
@@ -19,6 +20,7 @@ import javax.annotation.PreDestroy;
 @Component
 public class ApplicationScheduler {
 
+    private final TraceConfig traceConfig;
     private final UnitSystService unitSystService;
     private final ApplicationRepository applicationRepository;
     private final SigTodpService sigTodpService;
@@ -46,6 +48,7 @@ public class ApplicationScheduler {
     public void loadCenterService() {
         try {
             this.applicationRepository.loadCenterService();
+            this.traceConfig.loadTraceInfo();
         }
         catch(Exception e) {
             log.error("ApplicationScheduler.loadCenterService: Exception {}", e.getMessage());

+ 5 - 5
src/main/resources/application.yml

@@ -26,7 +26,7 @@ spring:
       maximumPoolSize: 20
       idleTimeout: 30000
 server:
-  port: 9873
+  port: 9872
 management:
   endpoints:
     web:
@@ -34,7 +34,7 @@ management:
         include: health, metrics
 
 application:
-  process-id: 81010
+  process-id: 81011
   packet-workers: 0
   dbms-workers: 1
   queue-size: 0
@@ -53,9 +53,9 @@ spring:
   datasource:
     hikari:
       driver-class-name: oracle.jdbc.OracleDriver
-      jdbc-url: jdbc:oracle:thin:@115.91.94.42:1521:HANTE
-      username: siguser
-      password: siguser
+      jdbc-url: jdbc:oracle:thin:@192.168.10.68:1521:CVIBDB
+      username: sigtest
+      password: sigtest
 
 ---
 spring:

+ 2 - 2
src/main/resources/logback-spring.xml

@@ -3,8 +3,8 @@
     <shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>
 
     <property name="APP_CLASS_PATH"  value="com.sig.todp.server"/>
-    <property name="PROJECT_PREFIX"  value="sig"/>
-    <property name="PROJECT_NAME"    value="${PROJECT_PREFIX}-todp-server"/>
+    <property name="PROJECT_PREFIX"  value="sig-todp"/>
+    <property name="PROJECT_NAME"    value="${PROJECT_PREFIX}-server"/>
     <property name="ROOT_LOG_LEVEL"  value="INFO"/>
     <property name="LOG_CHARSET"     value="UTF-8" />
     <property name="LOG_PATH"        value="${user.home}/logs/${PROJECT_NAME}/"/>