|
@@ -3,6 +3,7 @@ package com.tianbo.analysis.controller; |
|
@@ -3,6 +3,7 @@ package com.tianbo.analysis.controller; |
3
|
import lombok.extern.slf4j.Slf4j;
|
3
|
import lombok.extern.slf4j.Slf4j;
|
4
|
import org.apache.commons.io.FileUtils;
|
4
|
import org.apache.commons.io.FileUtils;
|
5
|
import org.springframework.beans.factory.annotation.Value;
|
5
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
6
|
+import org.springframework.web.bind.annotation.GetMapping;
|
6
|
import org.springframework.web.bind.annotation.PostMapping;
|
7
|
import org.springframework.web.bind.annotation.PostMapping;
|
7
|
import org.springframework.web.bind.annotation.RequestMapping;
|
8
|
import org.springframework.web.bind.annotation.RequestMapping;
|
8
|
import org.springframework.web.bind.annotation.RestController;
|
9
|
import org.springframework.web.bind.annotation.RestController;
|
|
@@ -23,8 +24,12 @@ public class RadioMsgController { |
|
@@ -23,8 +24,12 @@ public class RadioMsgController { |
23
|
@Value("${custom.extRedioMsgDir}")
|
24
|
@Value("${custom.extRedioMsgDir}")
|
24
|
private String extRedioMsgDir;
|
25
|
private String extRedioMsgDir;
|
25
|
|
26
|
|
|
|
27
|
+ //系统类型
|
|
|
28
|
+ @Value("${custom.operationSystemType}")
|
|
|
29
|
+ private String operationSystemType;
|
|
|
30
|
+
|
26
|
private final static String FFM_HEADER = "<MSG>\n" +
|
31
|
private final static String FFM_HEADER = "<MSG>\n" +
|
27
|
- "<META>\n" +
|
32
|
+ "<META>\r\n" +
|
28
|
"<SNDR>TXD</SNDR>\n" +
|
33
|
"<SNDR>TXD</SNDR>\n" +
|
29
|
"<DDTM>20200113050339</DDTM>\n" +
|
34
|
"<DDTM>20200113050339</DDTM>\n" +
|
30
|
"<TYPE>IATA</TYPE>\n" +
|
35
|
"<TYPE>IATA</TYPE>\n" +
|
|
@@ -60,13 +65,14 @@ public class RadioMsgController { |
|
@@ -60,13 +65,14 @@ public class RadioMsgController { |
60
|
private final static String FHL_FOOTER="\n</FHL>\n" +
|
65
|
private final static String FHL_FOOTER="\n</FHL>\n" +
|
61
|
"</MSG>";
|
66
|
"</MSG>";
|
62
|
|
67
|
|
63
|
- @PostMapping("ffm")
|
68
|
+ @GetMapping("ffm")
|
64
|
public int extFFM(String ffmmsg){
|
69
|
public int extFFM(String ffmmsg){
|
65
|
if (ffmmsg!=null){
|
70
|
if (ffmmsg!=null){
|
66
|
ffmmsg = FFM_HEADER + ffmmsg;
|
71
|
ffmmsg = FFM_HEADER + ffmmsg;
|
67
|
ffmmsg = ffmmsg + FFM_FOOTER;
|
72
|
ffmmsg = ffmmsg + FFM_FOOTER;
|
68
|
File file = new File(extRedioMsgDir+UUID.randomUUID()+".txt");
|
73
|
File file = new File(extRedioMsgDir+UUID.randomUUID()+".txt");
|
69
|
try {
|
74
|
try {
|
|
|
75
|
+ ffmmsg = redioStrFilter(ffmmsg);
|
70
|
FileUtils.writeStringToFile(file,ffmmsg,"UTF-8");
|
76
|
FileUtils.writeStringToFile(file,ffmmsg,"UTF-8");
|
71
|
log.info("FFM报文导入成功");
|
77
|
log.info("FFM报文导入成功");
|
72
|
return 1;
|
78
|
return 1;
|
|
@@ -78,13 +84,14 @@ public class RadioMsgController { |
|
@@ -78,13 +84,14 @@ public class RadioMsgController { |
78
|
}
|
84
|
}
|
79
|
|
85
|
|
80
|
|
86
|
|
81
|
- @PostMapping("fwb")
|
87
|
+ @GetMapping("fwb")
|
82
|
public int extFWB(String ffmmsg){
|
88
|
public int extFWB(String ffmmsg){
|
83
|
if (ffmmsg!=null) {
|
89
|
if (ffmmsg!=null) {
|
84
|
ffmmsg = FWB_HEADER + ffmmsg;
|
90
|
ffmmsg = FWB_HEADER + ffmmsg;
|
85
|
ffmmsg = ffmmsg + FWB_FOOTER;
|
91
|
ffmmsg = ffmmsg + FWB_FOOTER;
|
86
|
File file = new File(extRedioMsgDir + UUID.randomUUID() + ".txt");
|
92
|
File file = new File(extRedioMsgDir + UUID.randomUUID() + ".txt");
|
87
|
try {
|
93
|
try {
|
|
|
94
|
+ ffmmsg = redioStrFilter(ffmmsg);
|
88
|
FileUtils.writeStringToFile(file, ffmmsg, "UTF-8");
|
95
|
FileUtils.writeStringToFile(file, ffmmsg, "UTF-8");
|
89
|
log.info("FWB报文导入成功");
|
96
|
log.info("FWB报文导入成功");
|
90
|
return 1;
|
97
|
return 1;
|
|
@@ -95,13 +102,14 @@ public class RadioMsgController { |
|
@@ -95,13 +102,14 @@ public class RadioMsgController { |
95
|
return 0;
|
102
|
return 0;
|
96
|
}
|
103
|
}
|
97
|
|
104
|
|
98
|
- @PostMapping("fhl")
|
105
|
+ @GetMapping("fhl")
|
99
|
public int extFHL(String ffmmsg){
|
106
|
public int extFHL(String ffmmsg){
|
100
|
if (ffmmsg!=null) {
|
107
|
if (ffmmsg!=null) {
|
101
|
ffmmsg = FHL_HEADER + ffmmsg;
|
108
|
ffmmsg = FHL_HEADER + ffmmsg;
|
102
|
ffmmsg = ffmmsg + FHL_FOOTER;
|
109
|
ffmmsg = ffmmsg + FHL_FOOTER;
|
103
|
File file = new File(extRedioMsgDir + UUID.randomUUID() + ".txt");
|
110
|
File file = new File(extRedioMsgDir + UUID.randomUUID() + ".txt");
|
104
|
try {
|
111
|
try {
|
|
|
112
|
+ ffmmsg = redioStrFilter(ffmmsg);
|
105
|
FileUtils.writeStringToFile(file, ffmmsg, "UTF-8");
|
113
|
FileUtils.writeStringToFile(file, ffmmsg, "UTF-8");
|
106
|
log.info("FHL报文导入成功");
|
114
|
log.info("FHL报文导入成功");
|
107
|
return 1;
|
115
|
return 1;
|
|
@@ -111,4 +119,21 @@ public class RadioMsgController { |
|
@@ -111,4 +119,21 @@ public class RadioMsgController { |
111
|
}
|
119
|
}
|
112
|
return 0;
|
120
|
return 0;
|
113
|
}
|
121
|
}
|
|
|
122
|
+
|
|
|
123
|
+ /**
|
|
|
124
|
+ * 过滤处理不同操作系统的换行符
|
|
|
125
|
+ * @param content
|
|
|
126
|
+ * @return
|
|
|
127
|
+ */
|
|
|
128
|
+ private String redioStrFilter(String content){
|
|
|
129
|
+ if ("windows".equals(operationSystemType)){
|
|
|
130
|
+ /**
|
|
|
131
|
+ * 如果用户端的操作系统是windows,那么传过来的报文内容的换行符是\r\n,
|
|
|
132
|
+ * 先删除文本中过来的\r,再统一替换成\r\n.
|
|
|
133
|
+ * 如果用户端的操作系统是linux,则无所谓
|
|
|
134
|
+ */
|
|
|
135
|
+ content = content.replaceAll("\\r?\\n","\r\n");
|
|
|
136
|
+ }
|
|
|
137
|
+ return content;
|
|
|
138
|
+ }
|
114
|
} |
139
|
} |