正在显示
6 个修改的文件
包含
189 行增加
和
3 行删除
@@ -24,6 +24,12 @@ | @@ -24,6 +24,12 @@ | ||
24 | <artifactId>dom4j</artifactId> | 24 | <artifactId>dom4j</artifactId> |
25 | <version>2.1.0</version> | 25 | <version>2.1.0</version> |
26 | </dependency> | 26 | </dependency> |
27 | + <dependency> | ||
28 | + <groupId>oro</groupId> | ||
29 | + <artifactId>oro</artifactId> | ||
30 | + <version>2.0.8</version> | ||
31 | + <scope>test</scope> | ||
32 | + </dependency> | ||
27 | </dependencies> | 33 | </dependencies> |
28 | 34 | ||
29 | <build> | 35 | <build> |
@@ -7,4 +7,40 @@ | @@ -7,4 +7,40 @@ | ||
7 | * 文件存储 (无文件夹自动创建) | 7 | * 文件存储 (无文件夹自动创建) |
8 | * 文件删除 | 8 | * 文件删除 |
9 | * 文件读取 | 9 | * 文件读取 |
10 | -* | ||
10 | +* 航空报文解析 | ||
11 | + | ||
12 | + | ||
13 | + [ZCZC | ||
14 | + QD HKGVICX | ||
15 | + .CGOFD1E 261934 | ||
16 | + FSU/6 | ||
17 | + 043-85718776HKGCGO/T1K11.0 | ||
18 | + DLV/26JUN1934/CGO/T1K11.0 | ||
19 | + | ||
20 | + | ||
21 | + = | ||
22 | + NNNN] | ||
23 | + | ||
24 | + [ZCZC | ||
25 | + QD HKGVICX | ||
26 | + .CGOFD1E 261917 | ||
27 | + FSU/12 | ||
28 | + 160-08065536CGOMAA/T4K762.0 | ||
29 | + FOH/26JUN1917/CGO/T4K762.0/AGILITY LOGISTICS SHANGHAI LIMITED | ||
30 | + /MC5.93DGMC | ||
31 | + | ||
32 | + | ||
33 | + = | ||
34 | + NNNN] | ||
35 | + [ZCZC | ||
36 | + QD CHACSRU | ||
37 | + .CGOFD1E 261815 | ||
38 | + FSU/8 | ||
39 | + 580-20731631CGOORD/T43K6798.0 | ||
40 | + DEP/5X173/26JUN/CGOICN/T43K6798.0/A1811/E1910 | ||
41 | + | ||
42 | + | ||
43 | + = | ||
44 | + NNNN] | ||
45 | + | ||
46 | + |
1 | package com.tianbo.util.Date; | 1 | package com.tianbo.util.Date; |
2 | 2 | ||
3 | +import javafx.util.converter.LocalDateTimeStringConverter; | ||
4 | + | ||
3 | import java.text.ParseException; | 5 | import java.text.ParseException; |
4 | import java.text.SimpleDateFormat; | 6 | import java.text.SimpleDateFormat; |
5 | import java.time.*; | 7 | import java.time.*; |
@@ -23,6 +25,8 @@ public final class DateUtil { | @@ -23,6 +25,8 @@ public final class DateUtil { | ||
23 | 25 | ||
24 | public static String F14 = "yyyyMMddHHmmss"; | 26 | public static String F14 = "yyyyMMddHHmmss"; |
25 | 27 | ||
28 | + public static String F17 = "yyyyMMddHHmmssSSS"; | ||
29 | + | ||
26 | public static String F10 = "yyyy-MM-dd"; | 30 | public static String F10 = "yyyy-MM-dd"; |
27 | 31 | ||
28 | public static String F8 = "yyyyMMdd"; | 32 | public static String F8 = "yyyyMMdd"; |
@@ -31,8 +35,9 @@ public final class DateUtil { | @@ -31,8 +35,9 @@ public final class DateUtil { | ||
31 | 35 | ||
32 | private static Date currentDate = new Date(); | 36 | private static Date currentDate = new Date(); |
33 | private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | 37 | private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
34 | - private static SimpleDateFormat sdf_yyyyMMdd = new SimpleDateFormat("yyyyMMdd"); | ||
35 | - private static SimpleDateFormat timesdf = new SimpleDateFormat("yyyyMMddHHmmss"); | 38 | + private static SimpleDateFormat sdf_yyyyMMdd = new SimpleDateFormat(F8); |
39 | + private static SimpleDateFormat timesdf = new SimpleDateFormat(F14); | ||
40 | + private static SimpleDateFormat timesdfsss = new SimpleDateFormat(F17); | ||
36 | 41 | ||
37 | public static String getToday(){ | 42 | public static String getToday(){ |
38 | return sdf.format(currentDate); | 43 | return sdf.format(currentDate); |
@@ -49,10 +54,40 @@ public final class DateUtil { | @@ -49,10 +54,40 @@ public final class DateUtil { | ||
49 | return date; | 54 | return date; |
50 | } | 55 | } |
51 | 56 | ||
57 | + /** | ||
58 | + * 用localDatetime转毫秒字符串为时间,JAVA8有BUG,改为用simpleDateFormat转换,这个方法暂时不可用 | ||
59 | + * @param dateStr | ||
60 | + * @return | ||
61 | + */ | ||
62 | + public static Date formatByF17(String dateStr){ | ||
63 | + DateTimeFormatter formatter = DateTimeFormatter.ofPattern(F17); | ||
64 | + LocalDateTime beginDateTime = LocalDateTime.parse(dateStr, formatter); | ||
65 | + Date date = convertLDTToDate(beginDateTime);; | ||
66 | + return date; | ||
67 | + } | ||
68 | + | ||
69 | + /** | ||
70 | + * 取当前时间 | ||
71 | + * @return 20190916071330 | ||
72 | + */ | ||
52 | public static String getDDTM(){ | 73 | public static String getDDTM(){ |
53 | return timesdf.format(currentDate); | 74 | return timesdf.format(currentDate); |
54 | } | 75 | } |
55 | 76 | ||
77 | + /** | ||
78 | + * 取当前时间 | ||
79 | + * @return 20190916071330431 | ||
80 | + */ | ||
81 | + public static String getCurrentTime17(){ | ||
82 | + return timesdfsss.format(currentDate); | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * 日期格式转换返回 | ||
87 | + * @param dateStr | ||
88 | + * @return 20190916071330 | ||
89 | + * @throws DateTimeParseException | ||
90 | + */ | ||
56 | public static Date formatByyyyyMMddHHmmss(String dateStr) throws DateTimeParseException{ | 91 | public static Date formatByyyyyMMddHHmmss(String dateStr) throws DateTimeParseException{ |
57 | //毫秒级的去掉 | 92 | //毫秒级的去掉 |
58 | if(dateStr.length()>14){ | 93 | if(dateStr.length()>14){ |
@@ -401,4 +436,13 @@ public final class DateUtil { | @@ -401,4 +436,13 @@ public final class DateUtil { | ||
401 | return date; | 436 | return date; |
402 | } | 437 | } |
403 | 438 | ||
439 | + /**java.time.LocalDateTime --> java.util.Date | ||
440 | + * | ||
441 | + */ | ||
442 | + public void LocalDateTimeToUdate() { | ||
443 | + LocalDateTime localDateTime = LocalDateTime.now(); | ||
444 | + ZoneId zone = ZoneId.systemDefault(); | ||
445 | + Instant instant = localDateTime.atZone(zone).toInstant(); | ||
446 | + java.util.Date date = Date.from(instant); | ||
447 | + } | ||
404 | } | 448 | } |
src/test/java/FFMResolverTest.java
0 → 100644
1 | +import com.tianbo.util.IO.FileTool; | ||
2 | + | ||
3 | +import java.io.File; | ||
4 | +import java.io.IOException; | ||
5 | +import java.util.ArrayList; | ||
6 | +import java.util.List; | ||
7 | +import java.util.regex.Matcher; | ||
8 | +import java.util.regex.Pattern; | ||
9 | + | ||
10 | + | ||
11 | +public class FFMResolverTest { | ||
12 | + | ||
13 | + public static void main(String[] args) { | ||
14 | + | ||
15 | + File ffmfile = new File("/Users/mrz/Documents/java项目/新郑机场/util/ffm1.txt"); | ||
16 | + String qd = "HKGFDXH HKGFGXH HKGFMXH TSNCTXH HKGORXH HKGOPXH HKGFRUD "; | ||
17 | + List<String> list = new ArrayList<>(); | ||
18 | + try { | ||
19 | + String ffmStr = FileTool.readfile(ffmfile); | ||
20 | +// (\d{1,})/([A-Z0-9]+)/([A-Z0-9]+)/([A-Z]{3})(/[A-Z0-9]+)?[\s\S]+TSN[\s\S]+ULD/([A-Z0-9]{10})[\s\S]+(\d{3}-\d{8}[A-Z]{6})/(S|P|T|D|M)(\d+)K(\d+|[1-9]\d*\.\d*|0\.\d*[1-9]\d*)MC(\d+|[1-9]\d*\.\d*|0\.\d*[1-9]\d*)T(\d+)/(.*) | ||
21 | + // 按指定模式在字符串查找 | ||
22 | + String ffm_pattern = "(\\d{1,})/([A-Z0-9]+)/([A-Z0-9]+)/([A-Z]{3})(/[A-Z0-9]+)?[\\s\\S]+TSN[\\s\\S]+ULD/([A-Z0-9]{10})[\\s\\S]+(\\d{3}-\\d{8}[A-Z]{6})/(S|P|T|D|M)(\\d+)K(\\d+|[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*)MC(\\d+|[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*)T(\\d+)/(.*)"; | ||
23 | + //先找出航班信息 | ||
24 | + String pattern1_flght = "ULD/([A-Z0-9]{10})[\\s\\S]+(\\d{3}-\\d{8}[A-Z]{6})/(S|P|T|D|M)(\\d+)K(\\d+|[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*)MC(\\d+|[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*)T(\\d+)/(.*)"; | ||
25 | + //再找出航班下的所有目的地的货 | ||
26 | + String pattern_destination = "([\\t\\r\\n]" + | ||
27 | + "[A-Z]{3}[\\s*]?[\\t\\r\\n])" + | ||
28 | + "(ULD/[A-Z0-9]{10}.*(\\d{3}-\\d{8}[A-Z]{6})/(S|P|T|D|M)(\\d+)K(\\d+|[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*)MC(\\d+|[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*)(T\\d+)?/([\\u4E00-\\u9FA5]+|.*))[\\t\\r\\n]([A-Z]{3})[\\s*]?[\\t\\r\\n]"; | ||
29 | + //取航班所有货物内容列表,取消Pattern.DOTALL,获得所有航站信息 | ||
30 | + String pattern_manifest = "^[A-Z]{3}/?[\\s*]?$"; | ||
31 | + //取运单板箱 | ||
32 | + String pattern_awb = ""; | ||
33 | + // 创建 Pattern 对象 | ||
34 | + Pattern pattern = Pattern.compile(pattern_manifest,Pattern.MULTILINE|Pattern.DOTALL); | ||
35 | + | ||
36 | + // 现在创建 matcher 对象 | ||
37 | + Matcher matcher = pattern.matcher(ffmStr); | ||
38 | + while (matcher.find()) { | ||
39 | + list.add(matcher.group()); | ||
40 | + System.out.println("适配结果: " + matcher.group() ); | ||
41 | + } | ||
42 | + System.out.println(list); | ||
43 | + }catch (Exception e){ | ||
44 | + e.printStackTrace(); | ||
45 | + } | ||
46 | + | ||
47 | + } | ||
48 | +} |
src/test/java/FSUResolverTest.java
0 → 100644
1 | +import com.tianbo.util.IO.FileTool; | ||
2 | + | ||
3 | +import java.io.File; | ||
4 | +import java.util.ArrayList; | ||
5 | +import java.util.List; | ||
6 | +import java.util.regex.Matcher; | ||
7 | +import java.util.regex.Pattern; | ||
8 | + | ||
9 | + | ||
10 | +public class FSUResolverTest { | ||
11 | + | ||
12 | + public static void main(String[] args) { | ||
13 | + | ||
14 | + File file = new File("/Users/mrz/Documents/java项目/新郑机场/util/fsu.txt"); | ||
15 | + List<String> list = new ArrayList<>(); | ||
16 | + try { | ||
17 | + String Str = FileTool.readfile(file); | ||
18 | + // 报文发送地址 | ||
19 | + String pattern_send = "QD\\s(.*)"; | ||
20 | + // 报文接收地址 | ||
21 | + String pattern_recive = ".([A-Z0-9]{7})\\s\\d{6}"; | ||
22 | + //报文类型及版本 | ||
23 | + String pattern_type = "(FSU|FFM|FWB|FHL|UCM|SCM)/(\\d+)"; | ||
24 | + //运单信息 | ||
25 | + String pattern_awb = "(\\d{3}-\\d{8})" + | ||
26 | + "(CGO)(AMS)" + | ||
27 | + "/([TPSDM])(\\d+)" + | ||
28 | + "([K])" + | ||
29 | + "([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*|\\d+)"; | ||
30 | + //FSU_业务类型 | ||
31 | + String pattern_fsu_type = "(RCS|FOH|DEP|RCF|NFD)/(.*)"; | ||
32 | + // 创建 Pattern 对象 | ||
33 | + Pattern pattern = Pattern.compile(pattern_fsu_type,Pattern.MULTILINE); | ||
34 | + | ||
35 | + // 现在创建 matcher 对象 | ||
36 | + Matcher matcher = pattern.matcher(Str); | ||
37 | + while (matcher.find()) { | ||
38 | + list.add(matcher.group()); | ||
39 | + System.out.println("适配结果: " + matcher.group(1) ); | ||
40 | + } | ||
41 | + System.out.println(list); | ||
42 | + }catch (Exception e){ | ||
43 | + e.printStackTrace(); | ||
44 | + } | ||
45 | + | ||
46 | + } | ||
47 | +} |
-
请 注册 或 登录 后发表评论