gpad1010
parent
c11b6c8635
commit
8dd797edcf
|
@ -7,7 +7,9 @@ import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.context.ApplicationPidFileWriter;
|
import org.springframework.boot.context.ApplicationPidFileWriter;
|
||||||
import org.springframework.boot.system.ApplicationHome;
|
import org.springframework.boot.system.ApplicationHome;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
|
@EnableScheduling
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class DevApplication {
|
public class DevApplication {
|
||||||
// implements CommandLineRunner
|
// implements CommandLineRunner
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,146 +1,146 @@
|
||||||
package kr.gmtc.gw.dev.asderecv.asde.asterix;
|
package kr.gmtc.gw.dev.asderecv.asde.asterix;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
import kr.gmtc.gw.dev.asderecv.asde.rest.vo.ServiceAsdeData;
|
import kr.gmtc.gw.dev.asderecv.asde.rest.vo.ServiceAsdeData;
|
||||||
import kr.gmtc.gw.dev.asderecv.asde.utils.AsdeUtil;
|
import kr.gmtc.gw.dev.asderecv.asde.utils.AsdeUtil;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
|
||||||
@Component("asterixParserThread")
|
@Component("asterixParserThread")
|
||||||
public class AsterixParserThread {
|
public class AsterixParserThread {
|
||||||
|
|
||||||
// @Autowired
|
// @Autowired
|
||||||
private AsterixParser asterixParser;
|
private AsterixParser asterixParser;
|
||||||
|
|
||||||
// @Autowired
|
// @Autowired
|
||||||
// private FMDecoder fmDecoder;
|
// private FMDecoder fmDecoder;
|
||||||
//
|
//
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(AsterixParserThread.class);
|
private Logger logger = LoggerFactory.getLogger(AsterixParserThread.class);
|
||||||
|
|
||||||
private boolean isRunning = true;
|
private boolean isRunning = true;
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
private int processCount = 0;
|
private int processCount = 0;
|
||||||
private int MAX_PROCESS_COUNT = 100;
|
private int MAX_PROCESS_COUNT = 100;
|
||||||
|
|
||||||
@Value("${asde.service.queueCount}")
|
@Value("${asde.service.queueCount}")
|
||||||
private Integer scvQcount;
|
private Integer scvQcount;
|
||||||
|
|
||||||
@Value("${spring.profiles.active}")
|
@Value("${spring.profiles.active}")
|
||||||
private String execMode;
|
private String execMode;
|
||||||
|
|
||||||
List<ServiceAsdeData> serviceMap;
|
List<ServiceAsdeData> serviceMap;
|
||||||
|
|
||||||
ObjectMapper mapper;
|
ObjectMapper mapper;
|
||||||
|
|
||||||
DateTimeFormatter dfPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
DateTimeFormatter dfPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
||||||
|
|
||||||
int recvCnt;
|
int recvCnt;
|
||||||
|
|
||||||
public AsterixParserThread(Queue<String> packetQ, HashMap<Integer, Queue<ServiceAsdeData>> sendQueue) {
|
public AsterixParserThread(Queue<String> packetQ, HashMap<Integer, Queue<ServiceAsdeData>> sendQueue) {
|
||||||
thread = new Thread(new Runnable() {
|
thread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (isRunning) {
|
while (isRunning) {
|
||||||
String packetMsg = "";
|
String packetMsg = "";
|
||||||
try {
|
try {
|
||||||
packetMsg = packetQ.poll();
|
packetMsg = packetQ.poll();
|
||||||
|
|
||||||
if (packetMsg != null) {
|
if (packetMsg != null) {
|
||||||
|
|
||||||
// 테스트용
|
// 테스트용
|
||||||
//String sBynary = "0A 05 BB E3 81 F1 91 03 8A 06 04 98 3C 00 C1 D9 F5 28 0E 72 45 54 48 33 36 36 37 20 04 01 68 45 54 41 57 45 20 20 20 02 8D 36 34 39 20 00 33 34 52 0B 8F 08 EB 81 71 01 03 02 06 04 98 41 00 D3 95 20 50 08 06 E8 41 46 4C 36 20 20 20 20 71 D1 48 53 49 41 31 34 38 20 20 08 20 EB 81 01 01 03 02 06 04 98 3D C1 CF 75 18 D7 01 00 E0 02 E0 EB 81 71 01 03 02 06 04 98 40 C1 EA EC E5 80 00 00 E8 46 49 52 45 35 20 20 20 71 D1 08 53 49 41 31 30 38 20 20 08 20 EB 81 01 01 03 02 06 04 98 3C 45 E9 6B EC FB 00 00 E0 02 E0 E3 81 81 81 03 02 06 04 98 3F C5 A3 C8 F1 38 06 03 02 AC 00 20 E3 81 81 81 03 02 06 04 98 41 05 46 90 F1 38 06 02 02 6A 00 20 EB 81 F1 91 03 8A 06 04 98 3E 46 E3 86 26 F7 F9 FB F2 07 E3 54 57 42 32 39 32 20 20 71 C3 24 48 4C 38 33 32 34 20 20 3F FE 31 32 39 20 02 33 33 52 04 A7 08 EB 81 F1 11 03 0A 06 04 98 3F 86 D5 73 10 DC FF 00 F8 04 00 4B 41 53 38 20 20 20 20 71 C2 12 48 4C 38 32 31 32 20 20 35 34 36 20 02 04 9A 08 EB 81 01 01 03 02 06 04 98 40 07 CB 78 28 01 00 00 E0 02 E0 EB 81 01 01 03 02 06 04 98 3C CB D6 2D 0F 8A 00 00 E0 02 E0 EB 81 01 01 03 02 06 04 98 3B 8E D3 69 14 D5 00 00 E0 02 E0 EB 81 01 01 03 02 06 04 98 30 51 E8 81 14 CC 00 00 E0 00 E0 EB 81 F1 91 03 8A 06 04 98 3E 12 DA FA 58 54 A1 07 F5 20 08 CF 4B 41 4C 35 35 31 20 20 71 BE 01 48 4C 37 36 30 31 20 20 00 6C 36 30 39 20 00 33 34 52 06 A5 08 E3 81 F1 91 03 8A 06 04 98 3C 14 E4 E6 F5 28 0E 73 41 49 48 32 32 31 20 20 71 C5 03 48 4C 38 35 30 33 20 20 02 73 36 31 36 20 00 33 34 52 05 B4 08 EB 81 F1 91 03 8A 06 04 98 3E 14 D1 26 0E 46 03 02 F2 09 1B 43 53 4E 33 30 36 31 20 78 1D AC 42 33 32 39 53 20 20 20 3F FE 31 32 34 20 02 33 34 4C 04 A6 08 EB 81 01 01 03 02 06 04 98 42 D8 CC 92 18 B2 00 00 E0 00 E0 EB 81 01 01 03 02 06 04 98 35 98 DE 2A 14 0B 00 00 E0 02 E0 EB 81 01 01 03 02 06 04 98 3E DA 0B 2E 16 DE FF 00 E0 00 E0 EB 81 01 01 03 02 06 04 98 40 9A DE FC 21 72 00 00 E0 00 E0 EB 81 01 01 03 02 06 04 98 27 5C D3 D8 32 98 00 00 E0 00 E0 EB 81 F1 91 03 8A 06 04 98 3E 9C D4 72 FA 1A E4 27 F2 07 A8 4B 41 4C 37 35 36 20 20 71 C2 76 48 4C 38 32 37 36 20 20 3F FD 32 34 36 20 02 33 34 4C 04 A8 08 EB 81 01 01 03 02 06 04 98 3F A0 EC 22 01 A7 00 00 E0 02 E0 EB 81 F1 91 83 8A 06 04 98 3E A1 2A 7C CF 65 D6 3B F2 06 BD 4A 4E 41 32 38 32 20 20 71 BF 57 48 4C 37 37 35 37 20 20 00 1D 32 30 20 20 80 71 33 33 52 00 33 33 52 04 A9 08 EB 81 F1 91 03 8A 06 04 98 40 22 05 38 14 50 FC FD F4 0E 70 47 45 43 38 33 39 31 20 3C 70 C9 44 41 4C 46 49 20 20 20 3F FF 36 33 33 20 02 33 34 52 04 23 08 EB 81 01 01 03 02 06 04 98 3F E4 EF 9C 04 0B 00 00 E0 00 E0 EB 81 71 01 03 02 06 04 98 3C E5 D9 E1 09 F9 FD 09 E8 53 41 46 45 54 59 31 20 71 D1 13 53 49 41 31 31 33 20 20 0A 20 EB 81 01 01 03 02 06 04 98 3F E5 EE CB FA B5 00 00 E0 00 E0 EB 81 F1 91 03 8A 06 04 98 3D 66 FE 13 13 E4 08 F5 F2 08 F2 43 59 5A 32 33 31 41 20 78 05 CA 42 32 38 38 31 20 20 20 3F FE 36 30 34 20 02 33 33 52 04 A4 08 EB 81 F1 91 03 8A 06 04 98 3F 66 F8 39 07 39 FB FD F4 0E 63 46 44 58 35 33 39 31 20 AC 25 C4 4E 38 38 32 46 44 20 20 3F FE 36 35 32 20 02 33 34 52 08 97 08 EB 81 E1 81 03 02 06 04 98 3B 28 10 A1 72 50 C4 44 F1 10 00 C1 48 4C 35 32 33 39 20 20 71 AA 39 01 6C 00 20 E3 81 F1 91 03 8A 06 04 98 3E 68 86 EA F5 20 0E 5D 44 4C 48 37 31 39 20 20 3C 67 0E 44 41 49 58 4E 20 20 20 00 6B 33 32 20 20 00 33 34 52 04 24 08 EB 81 01 01 03 02 06 04 98 41 29 CA 2D 1A CC 00 00 E0 02 E0 EB 81 01 01 03 02 06 04 98 39 2A 07 DB 16 5D 00 00 E0 00 E0 EB 81 01 01 03 02 06 04 98 3D ED 0D E0 18 E4 00 00 E0 00 E0 EB 81 01 01 03 02 06 04 98 2A AF CB D2 26 53 00 00 E0 02 E0 EB 81 F1 11 03 02 06 04 98 3A EF 0D 76 04 91 00 00 F2 08 E4 42 33 32 37 37 20 20 20 78 11 D5 42 33 32 37 37 20 20 20 38 34 32 20 02 E0 EB 81 01 01 03 02 06 04 98 3C 2F EA 89 ED 0F 00 00 E0 02 E0 EB 81 01 01 03 02 06 04 98 3B F2 CA 19 24 BF 03 03 E0 02 E0 EB 81 01 01 03 02 06 04 98 41 34 0F 9F 1B C5 00 00 E0 00 E0 EB 81 71 01 03 02 06 04 98 3D B7 01 C9 F6 FB FF FF E8 46 49 52 45 33 20 20 20 71 D1 09 53 49 41 31 30 39 20 20 08 20 EB 81 01 01 03 02 06 04 98 3D F8 D4 C1 12 10 00 00 E0 02 E0 E3 81 81 81 03 02 06 04 98 40 39 4E BC F1 38 06 01 02 44 00 20 EB 81 F1 91 03 8A 06 04 98 3D BA DA EC 01 57 05 F8 F2 06 A6 41 41 52 31 31 31 20 20 71 BF 92 48 4C 37 37 39 32 20 20 3F FE 32 31 20 20 02 33 34 4C 04 A2 08 EB 81 E1 81 03 02 06 04 98 3D BC 13 53 7B 69 C7 58 F1 30 0F 14 4A 4E 41 33 38 30 20 20 71 C0 14 02 29 00 20 EB 81 01 01 03 02 06 04 98 3D 7F 11 2A 1B 1E 00 00 E0 00 E0 ";
|
//String sBynary = "0A 05 BB E3 81 F1 91 03 8A 06 04 98 3C 00 C1 D9 F5 28 0E 72 45 54 48 33 36 36 37 20 04 01 68 45 54 41 57 45 20 20 20 02 8D 36 34 39 20 00 33 34 52 0B 8F 08 EB 81 71 01 03 02 06 04 98 41 00 D3 95 20 50 08 06 E8 41 46 4C 36 20 20 20 20 71 D1 48 53 49 41 31 34 38 20 20 08 20 EB 81 01 01 03 02 06 04 98 3D C1 CF 75 18 D7 01 00 E0 02 E0 EB 81 71 01 03 02 06 04 98 40 C1 EA EC E5 80 00 00 E8 46 49 52 45 35 20 20 20 71 D1 08 53 49 41 31 30 38 20 20 08 20 EB 81 01 01 03 02 06 04 98 3C 45 E9 6B EC FB 00 00 E0 02 E0 E3 81 81 81 03 02 06 04 98 3F C5 A3 C8 F1 38 06 03 02 AC 00 20 E3 81 81 81 03 02 06 04 98 41 05 46 90 F1 38 06 02 02 6A 00 20 EB 81 F1 91 03 8A 06 04 98 3E 46 E3 86 26 F7 F9 FB F2 07 E3 54 57 42 32 39 32 20 20 71 C3 24 48 4C 38 33 32 34 20 20 3F FE 31 32 39 20 02 33 33 52 04 A7 08 EB 81 F1 11 03 0A 06 04 98 3F 86 D5 73 10 DC FF 00 F8 04 00 4B 41 53 38 20 20 20 20 71 C2 12 48 4C 38 32 31 32 20 20 35 34 36 20 02 04 9A 08 EB 81 01 01 03 02 06 04 98 40 07 CB 78 28 01 00 00 E0 02 E0 EB 81 01 01 03 02 06 04 98 3C CB D6 2D 0F 8A 00 00 E0 02 E0 EB 81 01 01 03 02 06 04 98 3B 8E D3 69 14 D5 00 00 E0 02 E0 EB 81 01 01 03 02 06 04 98 30 51 E8 81 14 CC 00 00 E0 00 E0 EB 81 F1 91 03 8A 06 04 98 3E 12 DA FA 58 54 A1 07 F5 20 08 CF 4B 41 4C 35 35 31 20 20 71 BE 01 48 4C 37 36 30 31 20 20 00 6C 36 30 39 20 00 33 34 52 06 A5 08 E3 81 F1 91 03 8A 06 04 98 3C 14 E4 E6 F5 28 0E 73 41 49 48 32 32 31 20 20 71 C5 03 48 4C 38 35 30 33 20 20 02 73 36 31 36 20 00 33 34 52 05 B4 08 EB 81 F1 91 03 8A 06 04 98 3E 14 D1 26 0E 46 03 02 F2 09 1B 43 53 4E 33 30 36 31 20 78 1D AC 42 33 32 39 53 20 20 20 3F FE 31 32 34 20 02 33 34 4C 04 A6 08 EB 81 01 01 03 02 06 04 98 42 D8 CC 92 18 B2 00 00 E0 00 E0 EB 81 01 01 03 02 06 04 98 35 98 DE 2A 14 0B 00 00 E0 02 E0 EB 81 01 01 03 02 06 04 98 3E DA 0B 2E 16 DE FF 00 E0 00 E0 EB 81 01 01 03 02 06 04 98 40 9A DE FC 21 72 00 00 E0 00 E0 EB 81 01 01 03 02 06 04 98 27 5C D3 D8 32 98 00 00 E0 00 E0 EB 81 F1 91 03 8A 06 04 98 3E 9C D4 72 FA 1A E4 27 F2 07 A8 4B 41 4C 37 35 36 20 20 71 C2 76 48 4C 38 32 37 36 20 20 3F FD 32 34 36 20 02 33 34 4C 04 A8 08 EB 81 01 01 03 02 06 04 98 3F A0 EC 22 01 A7 00 00 E0 02 E0 EB 81 F1 91 83 8A 06 04 98 3E A1 2A 7C CF 65 D6 3B F2 06 BD 4A 4E 41 32 38 32 20 20 71 BF 57 48 4C 37 37 35 37 20 20 00 1D 32 30 20 20 80 71 33 33 52 00 33 33 52 04 A9 08 EB 81 F1 91 03 8A 06 04 98 40 22 05 38 14 50 FC FD F4 0E 70 47 45 43 38 33 39 31 20 3C 70 C9 44 41 4C 46 49 20 20 20 3F FF 36 33 33 20 02 33 34 52 04 23 08 EB 81 01 01 03 02 06 04 98 3F E4 EF 9C 04 0B 00 00 E0 00 E0 EB 81 71 01 03 02 06 04 98 3C E5 D9 E1 09 F9 FD 09 E8 53 41 46 45 54 59 31 20 71 D1 13 53 49 41 31 31 33 20 20 0A 20 EB 81 01 01 03 02 06 04 98 3F E5 EE CB FA B5 00 00 E0 00 E0 EB 81 F1 91 03 8A 06 04 98 3D 66 FE 13 13 E4 08 F5 F2 08 F2 43 59 5A 32 33 31 41 20 78 05 CA 42 32 38 38 31 20 20 20 3F FE 36 30 34 20 02 33 33 52 04 A4 08 EB 81 F1 91 03 8A 06 04 98 3F 66 F8 39 07 39 FB FD F4 0E 63 46 44 58 35 33 39 31 20 AC 25 C4 4E 38 38 32 46 44 20 20 3F FE 36 35 32 20 02 33 34 52 08 97 08 EB 81 E1 81 03 02 06 04 98 3B 28 10 A1 72 50 C4 44 F1 10 00 C1 48 4C 35 32 33 39 20 20 71 AA 39 01 6C 00 20 E3 81 F1 91 03 8A 06 04 98 3E 68 86 EA F5 20 0E 5D 44 4C 48 37 31 39 20 20 3C 67 0E 44 41 49 58 4E 20 20 20 00 6B 33 32 20 20 00 33 34 52 04 24 08 EB 81 01 01 03 02 06 04 98 41 29 CA 2D 1A CC 00 00 E0 02 E0 EB 81 01 01 03 02 06 04 98 39 2A 07 DB 16 5D 00 00 E0 00 E0 EB 81 01 01 03 02 06 04 98 3D ED 0D E0 18 E4 00 00 E0 00 E0 EB 81 01 01 03 02 06 04 98 2A AF CB D2 26 53 00 00 E0 02 E0 EB 81 F1 11 03 02 06 04 98 3A EF 0D 76 04 91 00 00 F2 08 E4 42 33 32 37 37 20 20 20 78 11 D5 42 33 32 37 37 20 20 20 38 34 32 20 02 E0 EB 81 01 01 03 02 06 04 98 3C 2F EA 89 ED 0F 00 00 E0 02 E0 EB 81 01 01 03 02 06 04 98 3B F2 CA 19 24 BF 03 03 E0 02 E0 EB 81 01 01 03 02 06 04 98 41 34 0F 9F 1B C5 00 00 E0 00 E0 EB 81 71 01 03 02 06 04 98 3D B7 01 C9 F6 FB FF FF E8 46 49 52 45 33 20 20 20 71 D1 09 53 49 41 31 30 39 20 20 08 20 EB 81 01 01 03 02 06 04 98 3D F8 D4 C1 12 10 00 00 E0 02 E0 E3 81 81 81 03 02 06 04 98 40 39 4E BC F1 38 06 01 02 44 00 20 EB 81 F1 91 03 8A 06 04 98 3D BA DA EC 01 57 05 F8 F2 06 A6 41 41 52 31 31 31 20 20 71 BF 92 48 4C 37 37 39 32 20 20 3F FE 32 31 20 20 02 33 34 4C 04 A2 08 EB 81 E1 81 03 02 06 04 98 3D BC 13 53 7B 69 C7 58 F1 30 0F 14 4A 4E 41 33 38 30 20 20 71 C0 14 02 29 00 20 EB 81 01 01 03 02 06 04 98 3D 7F 11 2A 1B 1E 00 00 E0 00 E0 ";
|
||||||
//sBynary = sBynary.replaceAll("\\p{Z}", "");
|
//sBynary = sBynary.replaceAll("\\p{Z}", "");
|
||||||
|
|
||||||
// UDP 수신데이터
|
// UDP 수신데이터
|
||||||
String sBynary = packetMsg.replaceAll("\\p{Z}", "");
|
String sBynary = packetMsg.replaceAll("\\p{Z}", "");
|
||||||
String sTime = null;
|
String sTime = null;
|
||||||
|
|
||||||
//sBynary = "0b00b5df5d6b02000501352f1a1aa4cbe959e6d555f35b05ddffe90021086840780fec074a410110000bffff00004fcc43455335303334413332314d524b53495a53504431364c0308071400100714004008380031323820202034520033f580472c43455335303334440000000000000000000000000000000000000000041000c9434553353033342020200001df0d0102000501352f561aa3b0e359ed549fffb0033bffff00000fcb010009520008902fba00d9";
|
//sBynary = "0b00b5df5d6b02000501352f1a1aa4cbe959e6d555f35b05ddffe90021086840780fec074a410110000bffff00004fcc43455335303334413332314d524b53495a53504431364c0308071400100714004008380031323820202034520033f580472c43455335303334440000000000000000000000000000000000000000041000c9434553353033342020200001df0d0102000501352f561aa3b0e359ed549fffb0033bffff00000fcb010009520008902fba00d9";
|
||||||
|
|
||||||
// 수신시각
|
// 수신시각
|
||||||
if(sBynary.indexOf("*") > 0) {
|
if(sBynary.indexOf("*") > 0) {
|
||||||
sTime = packetMsg.substring(packetMsg.indexOf("*") +1);
|
sTime = packetMsg.substring(packetMsg.indexOf("*") +1);
|
||||||
sBynary = sBynary.substring(0, sBynary.indexOf("*"));
|
sBynary = sBynary.substring(0, sBynary.indexOf("*"));
|
||||||
}else {
|
}else {
|
||||||
sTime = LocalDateTime.now().format(dfPattern);
|
sTime = LocalDateTime.now().format(dfPattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 수신 메시지(Hex) byte로 변환
|
// 수신 메시지(Hex) byte로 변환
|
||||||
byte[] data = new java.math.BigInteger(sBynary, 16).toByteArray();
|
byte[] data = new java.math.BigInteger(sBynary, 16).toByteArray();
|
||||||
|
|
||||||
recvCnt ++;
|
recvCnt ++;
|
||||||
|
|
||||||
// byte문자열 혹인
|
// byte문자열 혹인
|
||||||
// logger.writeLevelLog("[AsterixParserThread] ByteArray(" + recvCnt + "):" + packetMsg, LogLevelType.LOG_DEBUG, "AllLog");
|
// logger.writeLevelLog("[AsterixParserThread] ByteArray(" + recvCnt + "):" + packetMsg, LogLevelType.LOG_DEBUG, "AllLog");
|
||||||
|
|
||||||
// 수신메시지 파싱
|
// 수신메시지 파싱
|
||||||
List<LinkedHashMap<String,String>> result = asterixParser.parse(data, sTime);
|
List<LinkedHashMap<String,String>> result = asterixParser.parse(data, sTime);
|
||||||
|
|
||||||
// logger.info("[ASDE분석결과:"+LocalDateTime.now().format(dfPattern)+"] result = "+ result);
|
// logger.info("[ASDE분석결과:"+LocalDateTime.now().format(dfPattern)+"] result = "+ result);
|
||||||
logger.info("[ASDE분석결과(service):"+LocalDateTime.now().format(dfPattern)+"] serviceMap = "+ Arrays.deepToString(serviceMap.toArray()));
|
logger.info("[ASDE분석결과(service):"+LocalDateTime.now().format(dfPattern)+"] serviceMap = "+ Arrays.deepToString(serviceMap.toArray()));
|
||||||
|
|
||||||
if(!serviceMap.isEmpty()) {
|
if(!serviceMap.isEmpty()) {
|
||||||
|
|
||||||
for(int idx=0; idx<serviceMap.size(); idx++) {
|
for(int idx=0; idx<serviceMap.size(); idx++) {
|
||||||
for(int qi=0; qi<scvQcount; qi++) {
|
for(int qi=0; qi<scvQcount; qi++) {
|
||||||
sendQueue.get(qi).offer(serviceMap.get(idx));
|
sendQueue.get(qi).offer(serviceMap.get(idx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceMap.clear();
|
serviceMap.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e.getMessage() != null) {
|
if (e.getMessage() != null) {
|
||||||
logger.error("[AsterixParserThread] Parsing Error Message : " + AsdeUtil.getStatckTrace(e));
|
logger.error("[AsterixParserThread] Parsing Error Message : " + AsdeUtil.getStatckTrace(e));
|
||||||
logger.error("=> Packet Message : " + packetMsg);
|
logger.error("=> Packet Message : " + packetMsg);
|
||||||
} else {
|
} else {
|
||||||
logger.error("[AsterixParserThread] Parsing Error Packet Message :" + packetMsg);
|
logger.error("[AsterixParserThread] Parsing Error Packet Message :" + packetMsg);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
processCount++;
|
processCount++;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (processCount > MAX_PROCESS_COUNT) {
|
if (processCount > MAX_PROCESS_COUNT) {
|
||||||
processCount = 0;
|
processCount = 0;
|
||||||
}
|
}
|
||||||
Thread.sleep(1);
|
Thread.sleep(1);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error("[ParserThread] : " + AsdeUtil.getStatckTrace(e));
|
logger.error("[ParserThread] : " + AsdeUtil.getStatckTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
|
|
||||||
serviceMap = new ArrayList<ServiceAsdeData>();
|
serviceMap = new ArrayList<ServiceAsdeData>();
|
||||||
|
|
||||||
// Asterix Parser 객체 생성 (category별로 상이한 yaml파일의 spec내용을 로드)
|
// Asterix Parser 객체 생성 (category별로 상이한 yaml파일의 spec내용을 로드)
|
||||||
asterixParser = new AsterixParser(serviceMap, execMode);
|
asterixParser = new AsterixParser(serviceMap, execMode);
|
||||||
mapper = new ObjectMapper();
|
mapper = new ObjectMapper();
|
||||||
|
|
||||||
isRunning = true;
|
isRunning = true;
|
||||||
thread.start();
|
thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,63 +1,63 @@
|
||||||
package kr.gmtc.gw.dev.asderecv.asde.asterix;
|
package kr.gmtc.gw.dev.asderecv.asde.asterix;
|
||||||
|
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
|
||||||
public class YamlFileLoader {
|
public class YamlFileLoader {
|
||||||
|
|
||||||
private Object returnObj;
|
private Object returnObj;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* yamlLoadToVo()
|
* yamlLoadToVo()
|
||||||
* yaml 파일을 JSON포멧으로 로드하여 vo객체로 변환후 리턴
|
* yaml 파일을 JSON포멧으로 로드하여 vo객체로 변환후 리턴
|
||||||
*
|
*
|
||||||
* @param sFile - yaml 파일 경로
|
* @param sFile - yaml 파일 경로
|
||||||
* @param cVO - yaml파일 내용을 로드하여 담을 VO 클래스
|
* @param cVO - yaml파일 내용을 로드하여 담을 VO 클래스
|
||||||
* @return Object를 파라메터로 넘어온 VO클래수로 casting하여 반환
|
* @return Object를 파라메터로 넘어온 VO클래수로 casting하여 반환
|
||||||
* @throws Json 포멧의 데이터를 Object로 변환시 오류발생하면 예외발생.
|
* @throws Json 포멧의 데이터를 Object로 변환시 오류발생하면 예외발생.
|
||||||
* @date 2023.02.07
|
* @date 2023.02.07
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public <T> T yamlLoadToVo(String sFile, Class<T> cVO) {
|
public <T> T yamlLoadToVo(String sFile, Class<T> cVO) {
|
||||||
|
|
||||||
if(sFile == null || sFile.equals("")) return cVO.cast(returnObj);
|
if(sFile == null || sFile.equals("")) return cVO.cast(returnObj);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
InputStream is = this.getClass().getResourceAsStream("/" + sFile);
|
InputStream is = this.getClass().getResourceAsStream("/" + sFile);
|
||||||
Reader reader = (is != null ? new InputStreamReader(is) : new FileReader(sFile));
|
Reader reader = (is != null ? new InputStreamReader(is) : new FileReader(sFile));
|
||||||
|
|
||||||
// yaml 파일 로드
|
// yaml 파일 로드
|
||||||
//LinkedHashMap<String, Object> propMap = new Yaml().load(new FileReader(ResourceUtils.getFile(sFile)));
|
//LinkedHashMap<String, Object> propMap = new Yaml().load(new FileReader(ResourceUtils.getFile(sFile)));
|
||||||
LinkedHashMap<String, Object> propMap = new Yaml().load(reader);
|
LinkedHashMap<String, Object> propMap = new Yaml().load(reader);
|
||||||
|
|
||||||
// 파일내용을 JSON 포멧으로 변환
|
// 파일내용을 JSON 포멧으로 변환
|
||||||
JSONObject jsonObject = new JSONObject(propMap);
|
JSONObject jsonObject = new JSONObject(propMap);
|
||||||
|
|
||||||
// JSON 데이터를 Object로 변환
|
// JSON 데이터를 Object로 변환
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
// Array Null값, 중간중간 존재하지 않는 필드 무시
|
// Array Null값, 중간중간 존재하지 않는 필드 무시
|
||||||
objectMapper.enable(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT);
|
objectMapper.enable(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT);
|
||||||
objectMapper.configure(DeserializationFeature.FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY, false);
|
objectMapper.configure(DeserializationFeature.FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY, false);
|
||||||
|
|
||||||
returnObj = objectMapper.readValue(jsonObject.toJSONString(), cVO);
|
returnObj = objectMapper.readValue(jsonObject.toJSONString(), cVO);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return cVO.cast(returnObj);
|
return cVO.cast(returnObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,123 +1,123 @@
|
||||||
package kr.gmtc.gw.dev.asderecv.asde.controller;
|
package kr.gmtc.gw.dev.asderecv.asde.controller;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import kr.gmtc.gw.dev.asderecv.asde.rest.vo.AsdeServiceVO;
|
import kr.gmtc.gw.dev.asderecv.asde.rest.vo.AsdeServiceVO;
|
||||||
import kr.gmtc.gw.dev.asderecv.asde.rest.vo.ServiceAsdeData;
|
import kr.gmtc.gw.dev.asderecv.asde.rest.vo.ServiceAsdeData;
|
||||||
import kr.gmtc.gw.dev.asderecv.asde.rest.vo.ServiceHeader;
|
import kr.gmtc.gw.dev.asderecv.asde.rest.vo.ServiceHeader;
|
||||||
import kr.gmtc.gw.dev.asderecv.config.ServiceConfig;
|
import kr.gmtc.gw.dev.asderecv.config.ServiceConfig;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Component("AsdeServiceController")
|
@Component("AsdeServiceController")
|
||||||
public class AsdeServiceController{
|
public class AsdeServiceController{
|
||||||
|
|
||||||
// 프레임 워크 구성요소 //
|
// 프레임 워크 구성요소 //
|
||||||
/** 서비스 설정, {@code application.yml} */
|
/** 서비스 설정, {@code application.yml} */
|
||||||
@Resource(name = "ServiceConfig")
|
@Resource(name = "ServiceConfig")
|
||||||
private ServiceConfig serviceConfig;
|
private ServiceConfig serviceConfig;
|
||||||
|
|
||||||
/* 실생상태 확인 */
|
/* 실생상태 확인 */
|
||||||
private boolean running = false;
|
private boolean running = false;
|
||||||
|
|
||||||
/* UDP test 소켓 */
|
/* UDP test 소켓 */
|
||||||
//UDPEchoClient UDPSocket ;
|
//UDPEchoClient UDPSocket ;
|
||||||
|
|
||||||
@Resource(name = "sendQueue")
|
@Resource(name = "sendQueue")
|
||||||
HashMap<Integer, Queue<ServiceAsdeData>> sendQueue;
|
HashMap<Integer, Queue<ServiceAsdeData>> sendQueue;
|
||||||
|
|
||||||
Queue<ServiceAsdeData> testMap = new LinkedBlockingQueue<ServiceAsdeData>();
|
Queue<ServiceAsdeData> testMap = new LinkedBlockingQueue<ServiceAsdeData>();
|
||||||
|
|
||||||
/* 서비스중인지 확인 */
|
/* 서비스중인지 확인 */
|
||||||
@Resource(name = "serviceRunnig")
|
@Resource(name = "serviceRunnig")
|
||||||
|
|
||||||
private boolean serviceRunnig = false;
|
private boolean serviceRunnig = false;
|
||||||
|
|
||||||
@Value("${asde.service.queueCount}")
|
@Value("${asde.service.queueCount}")
|
||||||
private Integer scvQcount;
|
private Integer scvQcount;
|
||||||
|
|
||||||
@Value("${asde.service.serviceCount}")
|
@Value("${asde.service.serviceCount}")
|
||||||
private Integer scvDatacount;
|
private Integer scvDatacount;
|
||||||
|
|
||||||
private AsdeServiceVO asdeServiceVO;
|
private AsdeServiceVO asdeServiceVO;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@GetMapping(value = "/getASDE/{qid}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
@GetMapping(value = "/getASDE/{qid}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
public String getASDE( @PathVariable Integer qid) {
|
public String getASDE( @PathVariable Integer qid) {
|
||||||
String sendCode, sendMsg ;
|
String sendCode, sendMsg ;
|
||||||
ServiceHeader jsonHeader = new ServiceHeader();
|
ServiceHeader jsonHeader = new ServiceHeader();
|
||||||
List<ServiceAsdeData> jsonData = new ArrayList<ServiceAsdeData>();
|
List<ServiceAsdeData> jsonData = new ArrayList<ServiceAsdeData>();
|
||||||
|
|
||||||
sendCode = "200";
|
sendCode = "200";
|
||||||
sendMsg = "";
|
sendMsg = "";
|
||||||
|
|
||||||
asdeServiceVO = new AsdeServiceVO();
|
asdeServiceVO = new AsdeServiceVO();
|
||||||
|
|
||||||
int idx = qid -1;
|
int idx = qid -1;
|
||||||
long qSize = sendQueue.get(idx).size();
|
long qSize = sendQueue.get(idx).size();
|
||||||
|
|
||||||
if(qSize > 0) serviceRunnig = true ;
|
if(qSize > 0) serviceRunnig = true ;
|
||||||
|
|
||||||
if(qSize > scvDatacount) qSize = scvDatacount;
|
if(qSize > scvDatacount) qSize = scvDatacount;
|
||||||
|
|
||||||
if(qid > scvQcount || qid <= 0) {
|
if(qid > scvQcount || qid <= 0) {
|
||||||
sendCode = "Err-01";
|
sendCode = "Err-01";
|
||||||
sendMsg = "할당되지 않은 큐를 지정했습니다.";
|
sendMsg = "할당되지 않은 큐를 지정했습니다.";
|
||||||
// retList.add(sendMsg);
|
// retList.add(sendMsg);
|
||||||
}else {
|
}else {
|
||||||
if(sendQueue.get(idx).peek() == null) {
|
if(sendQueue.get(idx).peek() == null) {
|
||||||
sendCode = "200";
|
sendCode = "200";
|
||||||
sendMsg = "전송할 데이터 없음.";
|
sendMsg = "전송할 데이터 없음.";
|
||||||
// retList.add(sendMsg);
|
// retList.add(sendMsg);
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
while (qSize > 0 ) {
|
while (qSize > 0 ) {
|
||||||
jsonData.add(sendQueue.get(idx).poll());
|
jsonData.add(sendQueue.get(idx).poll());
|
||||||
qSize--;
|
qSize--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonHeader.setResult_code(sendCode);
|
jsonHeader.setResult_code(sendCode);
|
||||||
jsonHeader.setResult_msg(sendMsg);
|
jsonHeader.setResult_msg(sendMsg);
|
||||||
|
|
||||||
asdeServiceVO.setHeader(jsonHeader);
|
asdeServiceVO.setHeader(jsonHeader);
|
||||||
|
|
||||||
if (sendCode.equals("200")) {
|
if (sendCode.equals("200")) {
|
||||||
asdeServiceVO.setData(jsonData);
|
asdeServiceVO.setData(jsonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
String sTmp = "";
|
String sTmp = "";
|
||||||
try {
|
try {
|
||||||
sTmp = mapper.writeValueAsString(asdeServiceVO);
|
sTmp = mapper.writeValueAsString(asdeServiceVO);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceRunnig = false ;
|
serviceRunnig = false ;
|
||||||
|
|
||||||
return sTmp;
|
return sTmp;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package kr.gmtc.gw.dev.asderecv.asde.controller;
|
package kr.gmtc.gw.dev.asderecv.asde.controller;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import kr.gmtc.gw.dev.asderecv.asde.asterix.AsterixParserThread;
|
import kr.gmtc.gw.dev.asderecv.asde.asterix.AsterixParserThread;
|
||||||
|
|
||||||
|
|
||||||
@Component("parseController")
|
@Component("parseController")
|
||||||
public class ParseController {
|
public class ParseController {
|
||||||
public ParseController(Queue<String> packetQ, HashMap<Integer, Queue<String>> sendQueue, AsterixParserThread asterixParserThread) {
|
public ParseController(Queue<String> packetQ, HashMap<Integer, Queue<String>> sendQueue, AsterixParserThread asterixParserThread) {
|
||||||
asterixParserThread.start();
|
asterixParserThread.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package kr.gmtc.gw.dev.asderecv.asde.utils;
|
package kr.gmtc.gw.dev.asderecv.asde.utils;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
public class AsdeUtil {
|
public class AsdeUtil {
|
||||||
|
|
||||||
public static String getStatckTrace(Throwable t) {
|
public static String getStatckTrace(Throwable t) {
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
t.printStackTrace(new PrintWriter(sw));
|
t.printStackTrace(new PrintWriter(sw));
|
||||||
return sw.toString();
|
return sw.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,51 +1,51 @@
|
||||||
package kr.gmtc.gw.dev.asderecv.asde.utils;
|
package kr.gmtc.gw.dev.asderecv.asde.utils;
|
||||||
|
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class FieldNameReflectionUtils {
|
public class FieldNameReflectionUtils {
|
||||||
|
|
||||||
|
|
||||||
public String getItem(Object obj, String sFieldName) {
|
public String getItem(Object obj, String sFieldName) {
|
||||||
|
|
||||||
String sRetValue = "";
|
String sRetValue = "";
|
||||||
|
|
||||||
Field field = ReflectionUtils.findField(obj.getClass(), sFieldName);
|
Field field = ReflectionUtils.findField(obj.getClass(), sFieldName);
|
||||||
|
|
||||||
if(field != null) {
|
if(field != null) {
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
sRetValue = (String) ReflectionUtils.getField(field, obj);
|
sRetValue = (String) ReflectionUtils.getField(field, obj);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sRetValue;
|
return sRetValue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setItem(Object obj, String sFieldName, String sValue) {
|
public void setItem(Object obj, String sFieldName, String sValue) {
|
||||||
|
|
||||||
Field field = ReflectionUtils.findField(obj.getClass(), sFieldName);
|
Field field = ReflectionUtils.findField(obj.getClass(), sFieldName);
|
||||||
|
|
||||||
if(field != null) {
|
if(field != null) {
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ReflectionUtils.setField(field, obj, sValue);
|
ReflectionUtils.setField(field, obj, sValue);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,91 +1,91 @@
|
||||||
package kr.gmtc.gw.dev.asderecv.config;
|
package kr.gmtc.gw.dev.asderecv.config;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import kr.gmtc.gw.dev.asderecv.asde.rest.vo.ServiceAsdeData;
|
import kr.gmtc.gw.dev.asderecv.asde.rest.vo.ServiceAsdeData;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
@Configuration("ServiceConfig")
|
@Configuration("ServiceConfig")
|
||||||
public class ServiceConfig {
|
public class ServiceConfig {
|
||||||
|
|
||||||
@Value("${root}")
|
@Value("${root}")
|
||||||
private String root;
|
private String root;
|
||||||
|
|
||||||
// @Value("${tcpip.client.send}")
|
// @Value("${tcpip.client.send}")
|
||||||
// private String clientSendCharsetStr;
|
// private String clientSendCharsetStr;
|
||||||
// @Value("${tcpip.client.receive}")
|
// @Value("${tcpip.client.receive}")
|
||||||
// private String clientReceiveCharsetStr;
|
// private String clientReceiveCharsetStr;
|
||||||
// @Value("${tcpip.client.checksum}")
|
// @Value("${tcpip.client.checksum}")
|
||||||
// private boolean clientReceiveChecksum;
|
// private boolean clientReceiveChecksum;
|
||||||
//
|
//
|
||||||
// @Value("${tcpip.server.send}")
|
// @Value("${tcpip.server.send}")
|
||||||
// private String serverSendCharsetStr;
|
// private String serverSendCharsetStr;
|
||||||
// @Value("${tcpip.server.receive}")
|
// @Value("${tcpip.server.receive}")
|
||||||
// private String serverReceiveCharsetStr;
|
// private String serverReceiveCharsetStr;
|
||||||
// @Value("${tcpip.server.checksum}")
|
// @Value("${tcpip.server.checksum}")
|
||||||
// private boolean serverReceiveChecksum;
|
// private boolean serverReceiveChecksum;
|
||||||
|
|
||||||
private Charset clientReceiveCharset;
|
// private Charset clientReceiveCharset;
|
||||||
private Charset serverReceiveCharset;
|
// private Charset serverReceiveCharset;
|
||||||
private Charset clientSendCharset;
|
// private Charset clientSendCharset;
|
||||||
private Charset serverSendCharset;
|
// private Charset serverSendCharset;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
// clientSendCharset = Charset.forName(clientReceiveCharsetStr);
|
// clientSendCharset = Charset.forName(clientReceiveCharsetStr);
|
||||||
// serverSendCharset = Charset.forName(serverReceiveCharsetStr);
|
// serverSendCharset = Charset.forName(serverReceiveCharsetStr);
|
||||||
// clientReceiveCharset = Charset.forName(clientReceiveCharsetStr);
|
// clientReceiveCharset = Charset.forName(clientReceiveCharsetStr);
|
||||||
// serverReceiveCharset = Charset.forName(serverReceiveCharsetStr);
|
// serverReceiveCharset = Charset.forName(serverReceiveCharsetStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /** @return 프로그램 설치 경로 */
|
// /** @return 프로그램 설치 경로 */
|
||||||
// public String getRoot() {
|
// public String getRoot() {
|
||||||
// return root;
|
// return root;
|
||||||
// }
|
// }
|
||||||
// /** @return 클라이언트 포트 송신 인코드 캐릭터셋 */
|
// /** @return 클라이언트 포트 송신 인코드 캐릭터셋 */
|
||||||
// public Charset getClientSendCharset() {
|
// public Charset getClientSendCharset() {
|
||||||
// return clientSendCharset;
|
// return clientSendCharset;
|
||||||
// }
|
// }
|
||||||
// /** @return 클라이언트 포트 수신 디코드 캐릭터셋 */
|
// /** @return 클라이언트 포트 수신 디코드 캐릭터셋 */
|
||||||
// public Charset getClientReceiveCharset() {
|
// public Charset getClientReceiveCharset() {
|
||||||
// return clientReceiveCharset;
|
// return clientReceiveCharset;
|
||||||
// }
|
// }
|
||||||
// /** @return 클라이언트 포트 수신 체크섬 검증 여부 */
|
// /** @return 클라이언트 포트 수신 체크섬 검증 여부 */
|
||||||
// public boolean isClientReceiveChecksum() {
|
// public boolean isClientReceiveChecksum() {
|
||||||
// return clientReceiveChecksum;
|
// return clientReceiveChecksum;
|
||||||
// }
|
// }
|
||||||
// /** @return 서버 포트 송신 인코드 캐릭터셋 */
|
// /** @return 서버 포트 송신 인코드 캐릭터셋 */
|
||||||
// public Charset getServerSendCharset() {
|
// public Charset getServerSendCharset() {
|
||||||
// return serverSendCharset;
|
// return serverSendCharset;
|
||||||
// }
|
// }
|
||||||
// /** @return 서버 포트 수신 디코드 캐릭터셋 */
|
// /** @return 서버 포트 수신 디코드 캐릭터셋 */
|
||||||
// public Charset getServerReceiveCharset() {
|
// public Charset getServerReceiveCharset() {
|
||||||
// return serverReceiveCharset;
|
// return serverReceiveCharset;
|
||||||
// }
|
// }
|
||||||
// /** @return 서버 포트 수신 체크섬 검증 여부 */
|
// /** @return 서버 포트 수신 체크섬 검증 여부 */
|
||||||
// public boolean isServerReceiveChecksum() {
|
// public boolean isServerReceiveChecksum() {
|
||||||
// return serverReceiveChecksum;
|
// return serverReceiveChecksum;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Bean(name = "packetQ")
|
@Bean(name = "packetQ")
|
||||||
public Queue<String> packetQ(){
|
public Queue<String> packetQ(){
|
||||||
return new LinkedBlockingQueue<String>();
|
return new LinkedBlockingQueue<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "sendQueue")
|
@Bean(name = "sendQueue")
|
||||||
public HashMap<Integer, Queue<ServiceAsdeData>> sendQueue(){
|
public HashMap<Integer, Queue<ServiceAsdeData>> sendQueue(){
|
||||||
return new LinkedHashMap<Integer, Queue<ServiceAsdeData>>();
|
return new LinkedHashMap<Integer, Queue<ServiceAsdeData>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "serviceRunnig")
|
@Bean(name = "serviceRunnig")
|
||||||
public boolean serviceRunnig(){
|
public boolean serviceRunnig(){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,363 +1,363 @@
|
||||||
package kr.gmtc.gw.dev.asderecv.controller;
|
package kr.gmtc.gw.dev.asderecv.controller;
|
||||||
|
|
||||||
import kr.gmtc.gw.comp.socket.udp.UDPEventListener;
|
import kr.gmtc.gw.comp.socket.udp.UDPEventListener;
|
||||||
import kr.gmtc.gw.comp.socket.udp.UDPManager;
|
import kr.gmtc.gw.comp.socket.udp.UDPManager;
|
||||||
import kr.gmtc.gw.comp.socket.utils.SocketUtil;
|
import kr.gmtc.gw.comp.socket.utils.SocketUtil;
|
||||||
import kr.gmtc.gw.comp.socket.vo.MsgObjVO;
|
import kr.gmtc.gw.comp.socket.vo.MsgObjVO;
|
||||||
import kr.gmtc.gw.dev.asderecv.asde.rest.vo.ServiceAsdeData;
|
import kr.gmtc.gw.dev.asderecv.asde.rest.vo.ServiceAsdeData;
|
||||||
import kr.gmtc.gw.dev.asderecv.asde.utils.AsdeUtil;
|
import kr.gmtc.gw.dev.asderecv.asde.utils.AsdeUtil;
|
||||||
|
|
||||||
import kr.gmtc.gw.dev.asderecv.thread.CustomThread;
|
import kr.gmtc.gw.dev.asderecv.thread.CustomThread;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.context.event.ContextClosedEvent;
|
import org.springframework.context.event.ContextClosedEvent;
|
||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
|
|
||||||
@Component("controller")
|
//@Component("controller")
|
||||||
public class MainController implements ApplicationListener<ContextClosedEvent> {
|
public class MainController implements ApplicationListener<ContextClosedEvent> {
|
||||||
|
|
||||||
@Value("${root}")
|
@Value("${root}")
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
@Resource(name = "packetQ")
|
@Resource(name = "packetQ")
|
||||||
Queue<String> packetQ;
|
Queue<String> packetQ;
|
||||||
|
|
||||||
@Resource(name = "sendQueue")
|
@Resource(name = "sendQueue")
|
||||||
HashMap<Integer, Queue<ServiceAsdeData>> sendQueue;
|
HashMap<Integer, Queue<ServiceAsdeData>> sendQueue;
|
||||||
|
|
||||||
@Resource(name = "serviceRunnig")
|
@Resource(name = "serviceRunnig")
|
||||||
private boolean serviceRunnig = false;
|
private boolean serviceRunnig = false;
|
||||||
|
|
||||||
@Value("${asde.service.queueCount}")
|
@Value("${asde.service.queueCount}")
|
||||||
private Integer scvQcount;
|
private Integer scvQcount;
|
||||||
|
|
||||||
@Value("${asde.service.clearQ.maxCount}")
|
@Value("${asde.service.clearQ.maxCount}")
|
||||||
private Integer scvQmaxCount;
|
private Integer scvQmaxCount;
|
||||||
|
|
||||||
@Value("${asde.service.clearQ.diffTime}")
|
@Value("${asde.service.clearQ.diffTime}")
|
||||||
private Integer scvQdiffTime;
|
private Integer scvQdiffTime;
|
||||||
|
|
||||||
@Value("${asde.service.clearQ.clearTime}")
|
@Value("${asde.service.clearQ.clearTime}")
|
||||||
private Integer scvQclearTime;
|
private Integer scvQclearTime;
|
||||||
|
|
||||||
|
|
||||||
private boolean isRunning;
|
private boolean isRunning;
|
||||||
protected UDPManager udpManager;
|
protected UDPManager udpManager;
|
||||||
private UDPEventListener udpListener;
|
private UDPEventListener udpListener;
|
||||||
|
|
||||||
private ArrayBlockingQueue<MsgObjVO> recvQ;
|
private ArrayBlockingQueue<MsgObjVO> recvQ;
|
||||||
private ArrayBlockingQueue<MsgObjVO> sendQ;
|
private ArrayBlockingQueue<MsgObjVO> sendQ;
|
||||||
|
|
||||||
private Thread recvQThread;
|
private Thread recvQThread;
|
||||||
private Thread sendQThread;
|
private Thread sendQThread;
|
||||||
|
|
||||||
private CustomThread serviceQClearThread;
|
private CustomThread serviceQClearThread;
|
||||||
|
|
||||||
|
|
||||||
protected Logger logger;
|
protected Logger logger;
|
||||||
|
|
||||||
protected MainController(@Value("${root}") String path){
|
protected MainController(@Value("${root}") String path){
|
||||||
|
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
logger = LoggerFactory.getLogger(MainController.class);
|
logger = LoggerFactory.getLogger(MainController.class);
|
||||||
|
|
||||||
recvQ = new ArrayBlockingQueue<>(100000);
|
recvQ = new ArrayBlockingQueue<>(100000);
|
||||||
sendQ = new ArrayBlockingQueue<MsgObjVO>(100000);
|
sendQ = new ArrayBlockingQueue<MsgObjVO>(100000);
|
||||||
|
|
||||||
udpListener = createUDPEventListener();
|
udpListener = createUDPEventListener();
|
||||||
udpManager = new UDPManager(path, udpListener);
|
udpManager = new UDPManager(path, udpListener);
|
||||||
|
|
||||||
recvQThread = new Thread(new Runnable() {
|
recvQThread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (isRunning) {
|
while (isRunning) {
|
||||||
try {
|
try {
|
||||||
int cnt = recvQ.size();
|
int cnt = recvQ.size();
|
||||||
if (cnt > 1000) {
|
if (cnt > 1000) {
|
||||||
cnt = 1000;
|
cnt = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i <= cnt - 1; i++) {
|
for (int i = 0; i <= cnt - 1; i++) {
|
||||||
if (recvQ != null) {
|
if (recvQ != null) {
|
||||||
MsgObjVO vo = recvQ.poll();
|
MsgObjVO vo = recvQ.poll();
|
||||||
if (vo != null) {
|
if (vo != null) {
|
||||||
recvDataIn(vo);
|
recvDataIn(vo);
|
||||||
vo = null;
|
vo = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Thread.sleep(1);
|
Thread.sleep(1);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error(SocketUtil.getStatckTrace(e));
|
logger.error(SocketUtil.getStatckTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
sendQThread = new Thread(new Runnable() {
|
sendQThread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (isRunning) {
|
while (isRunning) {
|
||||||
try {
|
try {
|
||||||
int cnt = sendQ.size();
|
int cnt = sendQ.size();
|
||||||
if (cnt > 1000) {
|
if (cnt > 1000) {
|
||||||
cnt = 1000;
|
cnt = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i <= cnt - 1; i++) {
|
for (int i = 0; i <= cnt - 1; i++) {
|
||||||
if (sendQ != null) {
|
if (sendQ != null) {
|
||||||
MsgObjVO vo = sendQ.poll();
|
MsgObjVO vo = sendQ.poll();
|
||||||
if (vo != null) {
|
if (vo != null) {
|
||||||
sendDataIn(vo);
|
sendDataIn(vo);
|
||||||
vo = null;
|
vo = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Thread.sleep(1);
|
Thread.sleep(1);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error(SocketUtil.getStatckTrace(e));
|
logger.error(SocketUtil.getStatckTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Order(0)
|
@Order(0)
|
||||||
@EventListener(ApplicationReadyEvent.class)
|
@EventListener(ApplicationReadyEvent.class)
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// 전송용 Queue 생성
|
// 전송용 Queue 생성
|
||||||
createQueue();
|
createQueue();
|
||||||
|
|
||||||
// 업무 스레드 생성, 대기 없이 무한반복
|
// 업무 스레드 생성, 대기 없이 무한반복
|
||||||
serviceQClearThread = new CustomThread("serviceQClearThread", this, CustomThread.NO_SLEEP, this::serviceQClear, null, false);
|
serviceQClearThread = new CustomThread("serviceQClearThread", this, CustomThread.NO_SLEEP, this::serviceQClear, null, false);
|
||||||
|
|
||||||
} catch(Exception e){
|
} catch(Exception e){
|
||||||
logger.error("[MainController] Prepare Fail " + AsdeUtil.getStatckTrace(e));
|
logger.error("[MainController] Prepare Fail " + AsdeUtil.getStatckTrace(e));
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Order(1)
|
@Order(1)
|
||||||
@EventListener(ApplicationReadyEvent.class)
|
@EventListener(ApplicationReadyEvent.class)
|
||||||
public void start() {
|
public void start() {
|
||||||
isRunning = true;
|
isRunning = true;
|
||||||
udpManager.initializeUDPFromXML();
|
udpManager.initializeUDPFromXML();
|
||||||
|
|
||||||
udpManager.startClient();
|
udpManager.startClient();
|
||||||
recvQThread.start();
|
recvQThread.start();
|
||||||
sendQThread.start();
|
sendQThread.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
protected UDPEventListener createUDPEventListener() {
|
protected UDPEventListener createUDPEventListener() {
|
||||||
UDPEventListener listener = new UDPEventListener() {
|
UDPEventListener listener = new UDPEventListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void udpDataIn(MsgObjVO vo) {
|
public void udpDataIn(MsgObjVO vo) {
|
||||||
// // TODO Auto-generated method stub
|
// // TODO Auto-generated method stub
|
||||||
// throw new UnsupportedOperationException("Unimplemented method 'udpDataIn'");
|
// throw new UnsupportedOperationException("Unimplemented method 'udpDataIn'");
|
||||||
|
|
||||||
//logger.info("RECV-DATA : " + vo.getMsg().toString());
|
//logger.info("RECV-DATA : " + vo.getMsg().toString());
|
||||||
|
|
||||||
recvPacketAdd(vo);
|
recvPacketAdd(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void udpSendData(MsgObjVO vo) {
|
public void udpSendData(MsgObjVO vo) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'udpSendData'");
|
throw new UnsupportedOperationException("Unimplemented method 'udpSendData'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void udpSendData(String ip, int port, MsgObjVO vo) {
|
public void udpSendData(String ip, int port, MsgObjVO vo) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'udpSendData'");
|
throw new UnsupportedOperationException("Unimplemented method 'udpSendData'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connected(String ip, int port, int statusCode, String description) {
|
public void connected(String ip, int port, int statusCode, String description) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'connected'");
|
throw new UnsupportedOperationException("Unimplemented method 'connected'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected(String ip, int port, int statusCode, String description) {
|
public void disconnected(String ip, int port, int statusCode, String description) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'disconnected'");
|
throw new UnsupportedOperationException("Unimplemented method 'disconnected'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connectionStatus(String ip, int port, String connEvent, int statusCode, String description) {
|
public void connectionStatus(String ip, int port, String connEvent, int statusCode, String description) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'connectionStatus'");
|
throw new UnsupportedOperationException("Unimplemented method 'connectionStatus'");
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
return listener;
|
return listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void recvPacketAdd(MsgObjVO vo) {
|
protected void recvPacketAdd(MsgObjVO vo) {
|
||||||
if (vo.getMsg().length < 1) {
|
if (vo.getMsg().length < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String recvDate = "";
|
String recvDate = "";
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String msg = SocketUtil.byteArrayToHexString(vo.getMsg());
|
String msg = SocketUtil.byteArrayToHexString(vo.getMsg());
|
||||||
|
|
||||||
recvDate = vo.getRecvDT().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
|
recvDate = vo.getRecvDT().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
|
||||||
|
|
||||||
msg = msg.concat("*").concat(recvDate);
|
msg = msg.concat("*").concat(recvDate);
|
||||||
|
|
||||||
packetQ.add(msg);
|
packetQ.add(msg);
|
||||||
|
|
||||||
//logger.debug("[UDPDataIn] : " + msg);
|
//logger.debug("[UDPDataIn] : " + msg);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
logger.error("[UDPDataIn] Unknown Exception Occur " + e.getMessage() );
|
logger.error("[UDPDataIn] Unknown Exception Occur " + e.getMessage() );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recvDataIn(MsgObjVO vo) {
|
private void recvDataIn(MsgObjVO vo) {
|
||||||
try {
|
try {
|
||||||
recvPacketAdd(vo);
|
recvPacketAdd(vo);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(SocketUtil.getStatckTrace(e));
|
logger.error(SocketUtil.getStatckTrace(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendDataIn(MsgObjVO vo) {
|
private void sendDataIn(MsgObjVO vo) {
|
||||||
try {
|
try {
|
||||||
udpManager.sendMsg(vo.getSendClientIP(), vo.getSendClientPort(), vo);
|
udpManager.sendMsg(vo.getSendClientIP(), vo.getSendClientPort(), vo);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(SocketUtil.getStatckTrace(e));
|
logger.error(SocketUtil.getStatckTrace(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 설정에따라 REST용 서비스 큐 생성
|
// 설정에따라 REST용 서비스 큐 생성
|
||||||
public void createQueue() {
|
public void createQueue() {
|
||||||
|
|
||||||
Class cls ;
|
Class cls ;
|
||||||
|
|
||||||
for(int idx=0; idx<scvQcount; idx++) {
|
for(int idx=0; idx<scvQcount; idx++) {
|
||||||
|
|
||||||
String className = "java.util.LinkedList";
|
String className = "java.util.LinkedList";
|
||||||
|
|
||||||
Queue<ServiceAsdeData> obj = null;
|
Queue<ServiceAsdeData> obj = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
cls = Class.forName(className);
|
cls = Class.forName(className);
|
||||||
obj = (Queue<ServiceAsdeData>) cls.newInstance();
|
obj = (Queue<ServiceAsdeData>) cls.newInstance();
|
||||||
|
|
||||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
sendQueue.put(idx, obj);
|
sendQueue.put(idx, obj);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void serviceQClear() throws InterruptedException, IOException {
|
private void serviceQClear() throws InterruptedException, IOException {
|
||||||
|
|
||||||
String sRecvTime = "";
|
String sRecvTime = "";
|
||||||
|
|
||||||
ServiceAsdeData jsonData = new ServiceAsdeData();
|
ServiceAsdeData jsonData = new ServiceAsdeData();
|
||||||
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
||||||
|
|
||||||
LocalDateTime dateTime;
|
LocalDateTime dateTime;
|
||||||
|
|
||||||
int iQcnt = 0;
|
int iQcnt = 0;
|
||||||
|
|
||||||
if(serviceRunnig) return;
|
if(serviceRunnig) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
for(int idx=0; idx<scvQcount; idx++) {
|
for(int idx=0; idx<scvQcount; idx++) {
|
||||||
|
|
||||||
iQcnt = sendQueue.get(idx).size();
|
iQcnt = sendQueue.get(idx).size();
|
||||||
|
|
||||||
if (iQcnt > scvQmaxCount ) {
|
if (iQcnt > scvQmaxCount ) {
|
||||||
|
|
||||||
jsonData = sendQueue.get(idx).peek();
|
jsonData = sendQueue.get(idx).peek();
|
||||||
|
|
||||||
sRecvTime = jsonData.getRecptn_dt();
|
sRecvTime = jsonData.getRecptn_dt();
|
||||||
|
|
||||||
dateTime = LocalDateTime.parse(sRecvTime, formatter);
|
dateTime = LocalDateTime.parse(sRecvTime, formatter);
|
||||||
|
|
||||||
Duration diff = Duration.between(dateTime, LocalDateTime.now());
|
Duration diff = Duration.between(dateTime, LocalDateTime.now());
|
||||||
|
|
||||||
if( scvQclearTime > 0 && diff.toMillis() > scvQclearTime) { // 일정시간 미사용으로 판단
|
if( scvQclearTime > 0 && diff.toMillis() > scvQclearTime) { // 일정시간 미사용으로 판단
|
||||||
sendQueue.get(idx).clear();
|
sendQueue.get(idx).clear();
|
||||||
logger.info("[MainController] serviceQClear : " + (idx +1) +"번 Queue 장기 미사용으로 초기화 (" + iQcnt +"건), 설정시간:" + scvQclearTime);
|
logger.info("[MainController] serviceQClear : " + (idx +1) +"번 Queue 장기 미사용으로 초기화 (" + iQcnt +"건), 설정시간:" + scvQclearTime);
|
||||||
}
|
}
|
||||||
else if( diff.toMillis() > scvQdiffTime) { // 데이터 과적재
|
else if( diff.toMillis() > scvQdiffTime) { // 데이터 과적재
|
||||||
|
|
||||||
iQcnt = sendQueue.get(idx).size();
|
iQcnt = sendQueue.get(idx).size();
|
||||||
int iPollCnt = iQcnt - scvQmaxCount;
|
int iPollCnt = iQcnt - scvQmaxCount;
|
||||||
|
|
||||||
while (iQcnt - scvQmaxCount >= 0) {
|
while (iQcnt - scvQmaxCount >= 0) {
|
||||||
sendQueue.get(idx).poll();
|
sendQueue.get(idx).poll();
|
||||||
iQcnt--;
|
iQcnt--;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("[MainController] serviceQpoll : " + (idx +1) +"번 Queue 일부 버림 (" + iPollCnt +"건), 설정시간:" + scvQdiffTime + " 설정건수:"+ scvQmaxCount);
|
logger.info("[MainController] serviceQpoll : " + (idx +1) +"번 Queue 일부 버림 (" + iPollCnt +"건), 설정시간:" + scvQdiffTime + " 설정건수:"+ scvQmaxCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
logger.error("[MainController] serviceQClear-InterruptedException : " + AsdeUtil.getStatckTrace(e));
|
logger.error("[MainController] serviceQClear-InterruptedException : " + AsdeUtil.getStatckTrace(e));
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("[MainController] serviceQClear-Exception : " + AsdeUtil.getStatckTrace(e) + ">> " + sRecvTime.toString() );
|
logger.error("[MainController] serviceQClear-Exception : " + AsdeUtil.getStatckTrace(e) + ">> " + sRecvTime.toString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
|
public void onApplicationEvent(ContextClosedEvent contextClosedEvent) {
|
||||||
this.stop();
|
this.stop();
|
||||||
logger.info("====================== SYSTEM STOPED ======================");
|
logger.info("====================== SYSTEM STOPED ======================");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,112 +1,112 @@
|
||||||
package kr.gmtc.gw.dev.asderecv.thread;
|
package kr.gmtc.gw.dev.asderecv.thread;
|
||||||
|
|
||||||
import kr.gmtc.gw.dev.asderecv.thread.handler.CustomThreadOnTerminate;
|
import kr.gmtc.gw.dev.asderecv.thread.handler.CustomThreadOnTerminate;
|
||||||
import kr.gmtc.gw.dev.asderecv.thread.handler.CustomThreadWork;
|
import kr.gmtc.gw.dev.asderecv.thread.handler.CustomThreadWork;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class CustomThread extends Thread{
|
public class CustomThread extends Thread{
|
||||||
|
|
||||||
/* 대기시간 없음 */
|
/* 대기시간 없음 */
|
||||||
public static final long NO_SLEEP = 0;
|
public static final long NO_SLEEP = 0;
|
||||||
/* 1밀리 초 */
|
/* 1밀리 초 */
|
||||||
public static final long SLEEP_MILLI_SEC = 1;
|
public static final long SLEEP_MILLI_SEC = 1;
|
||||||
/* 1초 */
|
/* 1초 */
|
||||||
public static final long SLEEP_SECOND = 1000;
|
public static final long SLEEP_SECOND = 1000;
|
||||||
/* 30초 */
|
/* 30초 */
|
||||||
public static final long SLEEP_HALF_MINIUTE = 30000;
|
public static final long SLEEP_HALF_MINIUTE = 30000;
|
||||||
/* 1분 */
|
/* 1분 */
|
||||||
public static final long SLEEP_MINIUTE = 60000;
|
public static final long SLEEP_MINIUTE = 60000;
|
||||||
|
|
||||||
public final String controllClassName;
|
public final String controllClassName;
|
||||||
public final long repeatMiliSec;
|
public final long repeatMiliSec;
|
||||||
public final CustomThreadWork definedWork;
|
public final CustomThreadWork definedWork;
|
||||||
public final CustomThreadOnTerminate definedTerminate;
|
public final CustomThreadOnTerminate definedTerminate;
|
||||||
public final Logger logger;
|
public final Logger logger;
|
||||||
private boolean running;
|
private boolean running;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 인터럽트를 받을 시 스레드가 종료됨.<br>
|
* 인터럽트를 받을 시 스레드가 종료됨.<br>
|
||||||
* {@link Thread#sleep(long)} 기반으로 재실행 간격을 설정하므로 정확한 실행시간을 보장하지 않음.<br>
|
* {@link Thread#sleep(long)} 기반으로 재실행 간격을 설정하므로 정확한 실행시간을 보장하지 않음.<br>
|
||||||
* 정확한 실행시간 보장이 필요 할 경우 sleep 간격을 짧게 설정하고 호출위치에서 시간확인<br>
|
* 정확한 실행시간 보장이 필요 할 경우 sleep 간격을 짧게 설정하고 호출위치에서 시간확인<br>
|
||||||
* 정상적인 종료는 {@link #gracefulStop()}으로 종료함
|
* 정상적인 종료는 {@link #gracefulStop()}으로 종료함
|
||||||
* @param threadName 스레드 이름
|
* @param threadName 스레드 이름
|
||||||
* @param controllClass 스레드 관리 클래스, 일반적으로 this 사용
|
* @param controllClass 스레드 관리 클래스, 일반적으로 this 사용
|
||||||
* @param repeatMiliSec Sleep 시간(밀리 초), 0이하의 경우 대기시간 없음
|
* @param repeatMiliSec Sleep 시간(밀리 초), 0이하의 경우 대기시간 없음
|
||||||
* @param definedWork 반복할 작업
|
* @param definedWork 반복할 작업
|
||||||
* @param definedTerminate 스레드가 인터럽트에 의해 종료될 경우 할 작업
|
* @param definedTerminate 스레드가 인터럽트에 의해 종료될 경우 할 작업
|
||||||
* @param autoStart 생성즉시 실행
|
* @param autoStart 생성즉시 실행
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public CustomThread(String threadName, Object controllClass, long repeatMiliSec,
|
public CustomThread(String threadName, Object controllClass, long repeatMiliSec,
|
||||||
CustomThreadWork definedWork, CustomThreadOnTerminate definedTerminate, boolean autoStart) {
|
CustomThreadWork definedWork, CustomThreadOnTerminate definedTerminate, boolean autoStart) {
|
||||||
|
|
||||||
if (definedWork == null) {
|
if (definedWork == null) {
|
||||||
throw new IllegalArgumentException("[CustomThread] - definedWork is null.");
|
throw new IllegalArgumentException("[CustomThread] - definedWork is null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.definedWork = definedWork;
|
this.definedWork = definedWork;
|
||||||
this.definedTerminate = definedTerminate;
|
this.definedTerminate = definedTerminate;
|
||||||
this.controllClassName = controllClass == null ? "" : controllClass.getClass().getSimpleName();
|
this.controllClassName = controllClass == null ? "" : controllClass.getClass().getSimpleName();
|
||||||
this.repeatMiliSec = repeatMiliSec > 0 ? repeatMiliSec : 0;
|
this.repeatMiliSec = repeatMiliSec > 0 ? repeatMiliSec : 0;
|
||||||
this.logger = LoggerFactory.getLogger(CustomThread.class);
|
this.logger = LoggerFactory.getLogger(CustomThread.class);
|
||||||
this.running = false;
|
this.running = false;
|
||||||
|
|
||||||
setName(threadName);
|
setName(threadName);
|
||||||
setDaemon(true);
|
setDaemon(true);
|
||||||
if (autoStart) {
|
if (autoStart) {
|
||||||
this.start();
|
this.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
logger.info("[CustomThread] Started.");
|
logger.info("[CustomThread] Started.");
|
||||||
while ( this.running && !this.isInterrupted()) {
|
while ( this.running && !this.isInterrupted()) {
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
this.definedWork.work();
|
this.definedWork.work();
|
||||||
} finally {
|
} finally {
|
||||||
if (this.repeatMiliSec > 0) {
|
if (this.repeatMiliSec > 0) {
|
||||||
Thread.sleep(this.repeatMiliSec);
|
Thread.sleep(this.repeatMiliSec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(InterruptedException e) { // 인터럽트 수신시 종료
|
} catch(InterruptedException e) { // 인터럽트 수신시 종료
|
||||||
logger.error("[CustomThread] Interrupted. "+ e.toString());
|
logger.error("[CustomThread] Interrupted. "+ e.toString());
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
break;
|
break;
|
||||||
} catch(Exception e) { // 처리되지 않은 예외 로깅, 예외에 의한 무한루프에 주의
|
} catch(Exception e) { // 처리되지 않은 예외 로깅, 예외에 의한 무한루프에 주의
|
||||||
logger.error("[CustomThread] Unknown Exception Occur. " + e.toString());
|
logger.error("[CustomThread] Unknown Exception Occur. " + e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.definedTerminate != null) {
|
if(this.definedTerminate != null) {
|
||||||
this.definedTerminate.onTerminate();
|
this.definedTerminate.onTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.error("[CustomThread] Stoped.");
|
logger.error("[CustomThread] Stoped.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
return "CustomThread [controllClass=" + this.controllClassName + ", threadName=" + getName() +
|
return "CustomThread [controllClass=" + this.controllClassName + ", threadName=" + getName() +
|
||||||
", runnig=" + this.running + ", alive=" + isAlive()+ ", repeatMiliSec=" + this.repeatMiliSec +
|
", runnig=" + this.running + ", alive=" + isAlive()+ ", repeatMiliSec=" + this.repeatMiliSec +
|
||||||
", definedTerminate=" + (this.definedTerminate == null ? "no" : "yes") + "]";
|
", definedTerminate=" + (this.definedTerminate == null ? "no" : "yes") + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void start() {
|
public synchronized void start() {
|
||||||
this.running = true;
|
this.running = true;
|
||||||
super.start();
|
super.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 스레드 정상종료, 진행중인 작업 완료 후 종료됨.
|
* 스레드 정상종료, 진행중인 작업 완료 후 종료됨.
|
||||||
*/
|
*/
|
||||||
public void gracefulStop() {
|
public void gracefulStop() {
|
||||||
this.running = false;
|
this.running = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package kr.gmtc.gw.dev.asderecv.thread.handler;
|
package kr.gmtc.gw.dev.asderecv.thread.handler;
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface CustomThreadOnTerminate {
|
public interface CustomThreadOnTerminate {
|
||||||
public void onTerminate();
|
public void onTerminate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package kr.gmtc.gw.dev.asderecv.thread.handler;
|
package kr.gmtc.gw.dev.asderecv.thread.handler;
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface CustomThreadWork {
|
public interface CustomThreadWork {
|
||||||
public void work() throws Exception;
|
public void work() throws Exception;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package kr.gmtc.gw.dev.restdev.config;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import kr.gmtc.gw.dev.asderecv.asde.rest.vo.ServiceAsdeData;
|
||||||
|
|
||||||
|
//@Configuration("restConfig")
|
||||||
|
public class RestConfig {
|
||||||
|
|
||||||
|
@Value("${root}")
|
||||||
|
private String root;
|
||||||
|
|
||||||
|
@Value("${request.url.recvTest}")
|
||||||
|
private String testReqTestUrl = "http://localhost:18080/test";
|
||||||
|
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
private void initialize() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "serviceRunnig")
|
||||||
|
public boolean serviceRunnig(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean(name = "packetQ")
|
||||||
|
public Queue<String> packetQ(){
|
||||||
|
return new LinkedBlockingQueue<String>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Bean(name = "sendQueue")
|
||||||
|
public HashMap<Integer, Queue<ServiceAsdeData>> sendQueue(){
|
||||||
|
return new LinkedHashMap<Integer, Queue<ServiceAsdeData>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,160 @@
|
||||||
|
package kr.gmtc.gw.dev.restdev.controller;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import kr.gmtc.gw.dev.restdev.service.StandMasterService;
|
||||||
|
import kr.gmtc.gw.dev.restdev.vo.AImetaTestVO;
|
||||||
|
import kr.gmtc.gw.dev.restdev.vo.AImetaTestVO.Data;
|
||||||
|
import kr.gmtc.gw.dev.restdev.vo.AiMetaVideoStatusVO;
|
||||||
|
import kr.gmtc.gw.dev.restdev.vo.AiMetaVideoStatusVO.AiMetaVideoStatusVO_Data;
|
||||||
|
import kr.gmtc.gw.dev.restdev.vo.AiMetaVideoStatusVO.AiMetaVideoStatusVO_Sts;
|
||||||
|
import kr.gmtc.gw.dev.restdev.vo.StandMasterVO;
|
||||||
|
|
||||||
|
@Component("restReciveController")
|
||||||
|
public class RestReciveController {
|
||||||
|
|
||||||
|
|
||||||
|
private final RestTemplate restTemplate;
|
||||||
|
|
||||||
|
private final ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
private Queue<AImetaTestVO> recvQ;
|
||||||
|
|
||||||
|
private AiMetaVideoStatusVO mapStatus;
|
||||||
|
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StandMasterService standService;
|
||||||
|
|
||||||
|
public RestReciveController() {
|
||||||
|
|
||||||
|
this.restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
this.objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
this.recvQ = new LinkedBlockingQueue<AImetaTestVO>();
|
||||||
|
|
||||||
|
this.mapStatus = new AiMetaVideoStatusVO();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(fixedRate = 1000) // 1초마다 실행
|
||||||
|
public void requestJsonData() {
|
||||||
|
// JSON 데이터를 요청할 URL 설정
|
||||||
|
String apiUrl = "http://localhost";
|
||||||
|
String sPort = "18082";
|
||||||
|
String sReqMsg = "getVideoTest";
|
||||||
|
|
||||||
|
String sReqUrl = apiUrl + ":" +sPort + "/" + sReqMsg;
|
||||||
|
|
||||||
|
// 요청을 보내고 JSON 데이터를 받아옴
|
||||||
|
String jsonResponse = restTemplate.getForObject(sReqUrl, String.class);
|
||||||
|
|
||||||
|
// 받아온 JSON 데이터를 Message 객체로 변환
|
||||||
|
try {
|
||||||
|
AImetaTestVO message = objectMapper.readValue(jsonResponse, AImetaTestVO.class);
|
||||||
|
|
||||||
|
recvQ.offer(message);
|
||||||
|
|
||||||
|
// 변환된 Message 객체를 원하는 방식으로 처리
|
||||||
|
System.out.println("Received Message: " + message.toString());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// JSON 파싱 오류 처리
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
splitData();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void splitData(){
|
||||||
|
|
||||||
|
for(AImetaTestVO oneData : recvQ ){
|
||||||
|
|
||||||
|
List<Data> recvDatas = oneData.getData();
|
||||||
|
int iDataCnt = recvDatas.size();
|
||||||
|
|
||||||
|
for(int idx=0; idx<iDataCnt; idx++ ){
|
||||||
|
|
||||||
|
List<String> listCctvs = recvDatas.get(idx).getCc_id();
|
||||||
|
int iCctvCnt = listCctvs.size();
|
||||||
|
|
||||||
|
for(int idxC=0; idxC<iCctvCnt; idxC++){
|
||||||
|
|
||||||
|
// cctv_id <-> 주기장 번호 매핑
|
||||||
|
// MetaAIVideoStatus3 mapStatus3 = new MetaAIVideoStatus3();
|
||||||
|
|
||||||
|
String sCctvID = listCctvs.get(idxC);
|
||||||
|
String sStandNO = mappingStand(sCctvID);
|
||||||
|
String sSts = recvDatas.get(idx).getStts_cls();
|
||||||
|
|
||||||
|
AiMetaVideoStatusVO_Sts stsMap = mapStatus.getStsMap(sStandNO);
|
||||||
|
|
||||||
|
AiMetaVideoStatusVO_Data dataMap = mapStatus.getStsMap(sStandNO).getDataMap(sSts);
|
||||||
|
|
||||||
|
Map<String, AiMetaVideoStatusVO_Sts> standStsMap = new HashMap<String, AiMetaVideoStatusVO_Sts>();
|
||||||
|
|
||||||
|
|
||||||
|
Date now = new Date();
|
||||||
|
|
||||||
|
dataMap.setRecvTime( String.valueOf(sdf.format(now)));
|
||||||
|
dataMap.setStandNo(sStandNO);
|
||||||
|
dataMap.setSts(sSts);
|
||||||
|
|
||||||
|
standStsMap.put(sStandNO, stsMap);
|
||||||
|
|
||||||
|
mapStatus.setMapStandNoGroup(standStsMap);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private String mappingStand(String sCctvID){
|
||||||
|
|
||||||
|
String sRetStandNo = "";
|
||||||
|
|
||||||
|
List<StandMasterVO> standList = standService.getStandList();
|
||||||
|
|
||||||
|
for(StandMasterVO standMaster : standList){
|
||||||
|
if(standMaster.getCctvID().equals(sCctvID)){
|
||||||
|
sRetStandNo = standMaster.getStandNO();
|
||||||
|
return sRetStandNo;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return sRetStandNo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// private boolean checkExistMap(String sKey){
|
||||||
|
// boolean isEx = false;
|
||||||
|
|
||||||
|
// if(mapStatus.get(sKey) != null){
|
||||||
|
// isEx = true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return isEx;
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
package kr.gmtc.gw.dev.restdev.controller;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import kr.gmtc.gw.dev.restdev.vo.AImetaTestVO;
|
||||||
|
import kr.gmtc.gw.dev.restdev.vo.AImetaTestVO.Data;
|
||||||
|
import kr.gmtc.gw.dev.restdev.vo.AImetaTestVO.Header;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class RestReqeustController {
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value={"getTest/{param1}/{param2}"}, method=RequestMethod.GET)
|
||||||
|
public String getTest(@PathVariable String param1, @PathVariable String param2){
|
||||||
|
String sParam1, sParam2;
|
||||||
|
|
||||||
|
sParam1 = param1;
|
||||||
|
sParam2 = param2;
|
||||||
|
|
||||||
|
|
||||||
|
return "return :" + sParam1 + "/" + sParam2;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value={"getVideoTest"}, method=RequestMethod.GET)
|
||||||
|
public AImetaTestVO getMessage() {
|
||||||
|
// JSON 형식의 메시지를 생성
|
||||||
|
Header header = new Header("200", "OK");
|
||||||
|
|
||||||
|
List<Data> dataList = new ArrayList<>();
|
||||||
|
Random random = new Random();
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++) { // 두 개의 데이터 생성
|
||||||
|
String on_arcrft = random.nextBoolean() ? "true" : "false";
|
||||||
|
String stts_cls = getRandomStatusClass(random);
|
||||||
|
String arcrft_tp = "A380-800";
|
||||||
|
String zn_id = String.valueOf(106 + i);
|
||||||
|
List<String> bb_tlp = Arrays.asList("241", "489");
|
||||||
|
List<String> crd_frm = Arrays.asList("286", "500");
|
||||||
|
List<String> cc_id = Arrays.asList(String.valueOf(random.nextInt(4) + 102), String.valueOf(random.nextInt(4) + 102)); // 102부터 105까지의 랜덤값
|
||||||
|
List<String> crd_glb = Arrays.asList("37.344556", "127.422913");
|
||||||
|
List<String> bb_brp = Arrays.asList("331", "512");
|
||||||
|
String dtct_tm = "";
|
||||||
|
String arln = "KOR-001";
|
||||||
|
String trck_id = "";
|
||||||
|
|
||||||
|
Data data = new Data();
|
||||||
|
data.setOn_arcrft(on_arcrft);
|
||||||
|
data.setStts_cls(stts_cls);
|
||||||
|
data.setArcrft_tp(arcrft_tp);
|
||||||
|
data.setZn_id(zn_id);
|
||||||
|
data.setBb_brp(bb_brp);
|
||||||
|
data.setBb_tlp(bb_tlp);
|
||||||
|
data.setCrd_frm(crd_frm);
|
||||||
|
data.setCc_id(cc_id);
|
||||||
|
data.setCrd_glb(crd_glb);
|
||||||
|
data.setDtct_tm(dtct_tm);
|
||||||
|
data.setArln(arln);
|
||||||
|
data.setTrck_id(trck_id);
|
||||||
|
|
||||||
|
dataList.add(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new AImetaTestVO(header, dataList);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getRandomStatusClass(Random random) {
|
||||||
|
String[] statusClasses = {"brdg_cnnctd", "crg_dr_opnd", "twng_cr_cnnctd"};
|
||||||
|
int randomIndex = random.nextInt(statusClasses.length);
|
||||||
|
return statusClasses[randomIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package kr.gmtc.gw.dev.restdev.service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import kr.gmtc.gw.dev.restdev.vo.StandMasterVO;
|
||||||
|
|
||||||
|
@Service("standMasterService")
|
||||||
|
public class StandMasterService {
|
||||||
|
|
||||||
|
private List<StandMasterVO> standList;
|
||||||
|
|
||||||
|
|
||||||
|
public StandMasterService(){
|
||||||
|
|
||||||
|
standList = new ArrayList<StandMasterVO>();
|
||||||
|
|
||||||
|
|
||||||
|
standList.add(new StandMasterVO("G101", "101"));
|
||||||
|
standList.add(new StandMasterVO("G102", "102"));
|
||||||
|
standList.add(new StandMasterVO("G103", "103"));
|
||||||
|
standList.add(new StandMasterVO("G104", "104"));
|
||||||
|
standList.add(new StandMasterVO("G105", "105"));
|
||||||
|
standList.add(new StandMasterVO("G106", "106"));
|
||||||
|
standList.add(new StandMasterVO("G107", "107"));
|
||||||
|
standList.add(new StandMasterVO("G108", "108"));
|
||||||
|
standList.add(new StandMasterVO("G109", "109"));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StandMasterVO> getStandList(){
|
||||||
|
|
||||||
|
return this.standList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,178 @@
|
||||||
|
package kr.gmtc.gw.dev.restdev.vo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AImetaTestVO {
|
||||||
|
|
||||||
|
private Header header;
|
||||||
|
private List<Data> data;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public AImetaTestVO() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public AImetaTestVO(Header header, List<Data> data){
|
||||||
|
this.header = header;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Header getHeader() {
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeader(Header header) {
|
||||||
|
this.header = header;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Data> getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(List<Data> data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Header {
|
||||||
|
private String result_code;
|
||||||
|
private String result_msg;
|
||||||
|
|
||||||
|
public Header() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Header(String result_code, String result_msg) {
|
||||||
|
this.result_code = result_code;
|
||||||
|
this.result_msg = result_msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResult_code() {
|
||||||
|
return result_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResult_code(String result_code) {
|
||||||
|
this.result_code = result_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResult_msg() {
|
||||||
|
return result_msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResult_msg(String result_msg) {
|
||||||
|
this.result_msg = result_msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Data {
|
||||||
|
private String on_arcrft;
|
||||||
|
private String stts_cls;
|
||||||
|
private String arcrft_tp;
|
||||||
|
private String zn_id;
|
||||||
|
private List<String> bb_tlp;
|
||||||
|
private List<String> crd_frm;
|
||||||
|
private List<String> cc_id;
|
||||||
|
private List<String> crd_glb;
|
||||||
|
private List<String> bb_brp;
|
||||||
|
private String dtct_tm;
|
||||||
|
private String arln;
|
||||||
|
private String trck_id;
|
||||||
|
|
||||||
|
public String getOn_arcrft() {
|
||||||
|
return on_arcrft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOn_arcrft(String on_arcrft) {
|
||||||
|
this.on_arcrft = on_arcrft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStts_cls() {
|
||||||
|
return stts_cls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStts_cls(String stts_cls) {
|
||||||
|
this.stts_cls = stts_cls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getArcrft_tp() {
|
||||||
|
return arcrft_tp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArcrft_tp(String arcrft_tp) {
|
||||||
|
this.arcrft_tp = arcrft_tp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getZn_id() {
|
||||||
|
return zn_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZn_id(String zn_id) {
|
||||||
|
this.zn_id = zn_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getBb_tlp() {
|
||||||
|
return bb_tlp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBb_tlp(List<String> bb_tlp) {
|
||||||
|
this.bb_tlp = bb_tlp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getCrd_frm() {
|
||||||
|
return crd_frm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCrd_frm(List<String> crd_frm) {
|
||||||
|
this.crd_frm = crd_frm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getCc_id() {
|
||||||
|
return cc_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCc_id(List<String> cc_id) {
|
||||||
|
this.cc_id = cc_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getCrd_glb() {
|
||||||
|
return crd_glb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCrd_glb(List<String> crd_glb) {
|
||||||
|
this.crd_glb = crd_glb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getBb_brp() {
|
||||||
|
return bb_brp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBb_brp(List<String> bb_brp) {
|
||||||
|
this.bb_brp = bb_brp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDtct_tm() {
|
||||||
|
return dtct_tm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDtct_tm(String dtct_tm) {
|
||||||
|
this.dtct_tm = dtct_tm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getArln() {
|
||||||
|
return arln;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArln(String arln) {
|
||||||
|
this.arln = arln;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTrck_id() {
|
||||||
|
return trck_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrck_id(String trck_id) {
|
||||||
|
this.trck_id = trck_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package kr.gmtc.gw.dev.restdev.vo;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class AiMetaVideoStatusVO {
|
||||||
|
|
||||||
|
private Map<String, AiMetaVideoStatusVO_Sts> mapStandNoGroup;
|
||||||
|
|
||||||
|
public AiMetaVideoStatusVO(){
|
||||||
|
mapStandNoGroup = new HashMap<String, AiMetaVideoStatusVO_Sts>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AiMetaVideoStatusVO_Sts getStsMap(String sStandNo){
|
||||||
|
|
||||||
|
return mapStandNoGroup.get(sStandNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public static class AiMetaVideoStatusVO_Sts {
|
||||||
|
|
||||||
|
private Map<String, AiMetaVideoStatusVO_Data> mapStatusGroup;
|
||||||
|
|
||||||
|
public AiMetaVideoStatusVO_Sts(String sSts, AiMetaVideoStatusVO_Data map){
|
||||||
|
mapStatusGroup = new HashMap<String, AiMetaVideoStatusVO_Data>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AiMetaVideoStatusVO_Data getDataMap(String sSts){
|
||||||
|
|
||||||
|
return mapStatusGroup.get(sSts);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public static class AiMetaVideoStatusVO_Data {
|
||||||
|
|
||||||
|
private String standNo;
|
||||||
|
private String sts;
|
||||||
|
private String cctvID;
|
||||||
|
private String recvTime;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package kr.gmtc.gw.dev.restdev.vo;
|
||||||
|
|
||||||
|
public class StandMasterVO {
|
||||||
|
private String standNO;
|
||||||
|
private String cctvID;
|
||||||
|
|
||||||
|
|
||||||
|
public StandMasterVO(String standNO, String cctvID){
|
||||||
|
this.standNO = standNO;
|
||||||
|
this.cctvID = cctvID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getStandNO() {
|
||||||
|
return standNO;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setStandNO(String standNo) {
|
||||||
|
this.standNO = standNo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getCctvID() {
|
||||||
|
return cctvID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setCctvID(String cctvID) {
|
||||||
|
this.cctvID = cctvID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -41,3 +41,7 @@ spring:
|
||||||
|
|
||||||
root: D:\Workspace\Odroid_repository\EyeGW_CompDev
|
root: D:\Workspace\Odroid_repository\EyeGW_CompDev
|
||||||
|
|
||||||
|
request:
|
||||||
|
url:
|
||||||
|
recvTest: http://localhost:18082/getVideoTest
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<AsterixListCategory>
|
<AsterixListCategory>
|
||||||
<AsterixSpecFile category="10" file="spec/alterixCat010Indra.yml" />
|
<AsterixSpecFile category="10" file="spec/alterixCat010Indra.yml" />
|
||||||
<AsterixSpecFile category="11" file="spec/alterixCat011.yml" />
|
<AsterixSpecFile category="11" file="spec/alterixCat011.yml" />
|
||||||
</AsterixListCategory>
|
</AsterixListCategory>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue