|
|
1
|
+package com.tianbo.analysis.controller;
|
|
|
2
|
+
|
|
|
3
|
+import org.apache.commons.io.FileUtils;
|
|
|
4
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
5
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
6
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
7
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
8
|
+
|
|
|
9
|
+import java.io.File;
|
|
|
10
|
+import java.io.IOException;
|
|
|
11
|
+import java.util.UUID;
|
|
|
12
|
+
|
|
|
13
|
+/**
|
|
|
14
|
+ * 在线报文导入管理
|
|
|
15
|
+ */
|
|
|
16
|
+@RestController
|
|
|
17
|
+@RequestMapping("/Rmsg")
|
|
|
18
|
+public class RadioMsgController {
|
|
|
19
|
+
|
|
|
20
|
+ //备份目录
|
|
|
21
|
+ @Value("${custom.extRedioMsgDir}")
|
|
|
22
|
+ private String extRedioMsgDir;
|
|
|
23
|
+
|
|
|
24
|
+ private final static String FFM_HEADER = "<MSG>\n" +
|
|
|
25
|
+ "<META>\n" +
|
|
|
26
|
+ "<SNDR>TXD</SNDR>\n" +
|
|
|
27
|
+ "<DDTM>20200113050339</DDTM>\n" +
|
|
|
28
|
+ "<TYPE>IATA</TYPE>\n" +
|
|
|
29
|
+ "<STYP>FFM</STYP>\n" +
|
|
|
30
|
+ "<SEQN>95205940</SEQN>\n" +
|
|
|
31
|
+ "</META>\n" +
|
|
|
32
|
+ "<FFM>\n";
|
|
|
33
|
+
|
|
|
34
|
+ private final static String FFM_FOOTER = "\n</FFM>\n" +
|
|
|
35
|
+ "</MSG>";
|
|
|
36
|
+
|
|
|
37
|
+ private final static String FWB_HEADER="<MSG>\n" +
|
|
|
38
|
+ "<META>\n" +
|
|
|
39
|
+ "<SNDR>TXD</SNDR>\n" +
|
|
|
40
|
+ "<DDTM>20200113004608</DDTM>\n" +
|
|
|
41
|
+ "<TYPE>IATA</TYPE>\n" +
|
|
|
42
|
+ "<STYP>IFWB</STYP>\n" +
|
|
|
43
|
+ "<SEQN>95203026</SEQN>\n" +
|
|
|
44
|
+ "</META>\n" +
|
|
|
45
|
+ "<FWB>\n";
|
|
|
46
|
+ private final static String FWB_FOOTER="\n</FWB>\n" +
|
|
|
47
|
+ "</MSG>";
|
|
|
48
|
+
|
|
|
49
|
+ private final static String FHL_HEADER="<MSG>\n" +
|
|
|
50
|
+ "<META>\n" +
|
|
|
51
|
+ "<SNDR>TXD</SNDR>\n" +
|
|
|
52
|
+ "<DDTM>20200113003006</DDTM>\n" +
|
|
|
53
|
+ "<TYPE>IATA</TYPE>\n" +
|
|
|
54
|
+ "<STYP>IFHL</STYP>\n" +
|
|
|
55
|
+ "<SEQN>95202782</SEQN>\n" +
|
|
|
56
|
+ "</META>\n" +
|
|
|
57
|
+ "<FHL>\n";
|
|
|
58
|
+ private final static String FHL_FOOTER="\n</FHL>\n" +
|
|
|
59
|
+ "</MSG>";
|
|
|
60
|
+
|
|
|
61
|
+ @PostMapping("ffm")
|
|
|
62
|
+ public int extFFM(String ffmmsg){
|
|
|
63
|
+ ffmmsg = FFM_HEADER + ffmmsg;
|
|
|
64
|
+ ffmmsg = ffmmsg + FFM_FOOTER;
|
|
|
65
|
+ File file = new File(extRedioMsgDir+UUID.randomUUID()+".txt");
|
|
|
66
|
+ try {
|
|
|
67
|
+ FileUtils.writeStringToFile(file,ffmmsg,"UTF-8");
|
|
|
68
|
+ return 1;
|
|
|
69
|
+ }catch (IOException e){
|
|
|
70
|
+ e.printStackTrace();
|
|
|
71
|
+ }
|
|
|
72
|
+ return 0;
|
|
|
73
|
+ }
|
|
|
74
|
+
|
|
|
75
|
+
|
|
|
76
|
+ @PostMapping("fwb")
|
|
|
77
|
+ public int extFWB(String ffmmsg){
|
|
|
78
|
+ ffmmsg = FWB_HEADER + ffmmsg;
|
|
|
79
|
+ ffmmsg = ffmmsg + FWB_FOOTER;
|
|
|
80
|
+ File file = new File(extRedioMsgDir+UUID.randomUUID()+".txt");
|
|
|
81
|
+ try {
|
|
|
82
|
+ FileUtils.writeStringToFile(file,ffmmsg,"UTF-8");
|
|
|
83
|
+ return 1;
|
|
|
84
|
+ }catch (IOException e){
|
|
|
85
|
+ e.printStackTrace();
|
|
|
86
|
+ }
|
|
|
87
|
+ return 0;
|
|
|
88
|
+ }
|
|
|
89
|
+
|
|
|
90
|
+ @PostMapping("fhl")
|
|
|
91
|
+ public int extFHL(String ffmmsg){
|
|
|
92
|
+ ffmmsg = FHL_HEADER + ffmmsg;
|
|
|
93
|
+ ffmmsg = ffmmsg + FHL_FOOTER;
|
|
|
94
|
+ File file = new File(extRedioMsgDir+UUID.randomUUID()+".txt");
|
|
|
95
|
+ try {
|
|
|
96
|
+ FileUtils.writeStringToFile(file,ffmmsg,"UTF-8");
|
|
|
97
|
+ return 1;
|
|
|
98
|
+ }catch (IOException e){
|
|
|
99
|
+ e.printStackTrace();
|
|
|
100
|
+ }
|
|
|
101
|
+ return 0;
|
|
|
102
|
+ }
|
|
|
103
|
+} |