|
@@ -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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|