作者 朱兆平

运抵解析OK

... ... @@ -24,6 +24,12 @@
<artifactId>dom4j</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>oro</groupId>
<artifactId>oro</artifactId>
<version>2.0.8</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
... ...
... ... @@ -7,4 +7,40 @@
* 文件存储 (无文件夹自动创建)
* 文件删除
* 文件读取
*
\ No newline at end of file
* 航空报文解析
[ZCZC
QD HKGVICX
.CGOFD1E 261934
FSU/6
043-85718776HKGCGO/T1K11.0
DLV/26JUN1934/CGO/T1K11.0
=
NNNN]
[ZCZC
QD HKGVICX
.CGOFD1E 261917
FSU/12
160-08065536CGOMAA/T4K762.0
FOH/26JUN1917/CGO/T4K762.0/AGILITY LOGISTICS SHANGHAI LIMITED
/MC5.93DGMC
=
NNNN]
[ZCZC
QD CHACSRU
.CGOFD1E 261815
FSU/8
580-20731631CGOORD/T43K6798.0
DEP/5X173/26JUN/CGOICN/T43K6798.0/A1811/E1910
=
NNNN]
\ No newline at end of file
... ...
package com.tianbo.util.Date;
import javafx.util.converter.LocalDateTimeStringConverter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
... ... @@ -23,6 +25,8 @@ public final class DateUtil {
public static String F14 = "yyyyMMddHHmmss";
public static String F17 = "yyyyMMddHHmmssSSS";
public static String F10 = "yyyy-MM-dd";
public static String F8 = "yyyyMMdd";
... ... @@ -31,8 +35,9 @@ public final class DateUtil {
private static Date currentDate = new Date();
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
private static SimpleDateFormat sdf_yyyyMMdd = new SimpleDateFormat("yyyyMMdd");
private static SimpleDateFormat timesdf = new SimpleDateFormat("yyyyMMddHHmmss");
private static SimpleDateFormat sdf_yyyyMMdd = new SimpleDateFormat(F8);
private static SimpleDateFormat timesdf = new SimpleDateFormat(F14);
private static SimpleDateFormat timesdfsss = new SimpleDateFormat(F17);
public static String getToday(){
return sdf.format(currentDate);
... ... @@ -49,10 +54,40 @@ public final class DateUtil {
return date;
}
/**
* 用localDatetime转毫秒字符串为时间,JAVA8有BUG,改为用simpleDateFormat转换,这个方法暂时不可用
* @param dateStr
* @return
*/
public static Date formatByF17(String dateStr){
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(F17);
LocalDateTime beginDateTime = LocalDateTime.parse(dateStr, formatter);
Date date = convertLDTToDate(beginDateTime);;
return date;
}
/**
* 取当前时间
* @return 20190916071330
*/
public static String getDDTM(){
return timesdf.format(currentDate);
}
/**
* 取当前时间
* @return 20190916071330431
*/
public static String getCurrentTime17(){
return timesdfsss.format(currentDate);
}
/**
* 日期格式转换返回
* @param dateStr
* @return 20190916071330
* @throws DateTimeParseException
*/
public static Date formatByyyyyMMddHHmmss(String dateStr) throws DateTimeParseException{
//毫秒级的去掉
if(dateStr.length()>14){
... ... @@ -401,4 +436,13 @@ public final class DateUtil {
return date;
}
/**java.time.LocalDateTime --> java.util.Date
*
*/
public void LocalDateTimeToUdate() {
LocalDateTime localDateTime = LocalDateTime.now();
ZoneId zone = ZoneId.systemDefault();
Instant instant = localDateTime.atZone(zone).toInstant();
java.util.Date date = Date.from(instant);
}
}
... ...
package com.tianbo.util.Flight.resolver;
public class FFMResolver {
}
... ...
import com.tianbo.util.IO.FileTool;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FFMResolverTest {
public static void main(String[] args) {
File ffmfile = new File("/Users/mrz/Documents/java项目/新郑机场/util/ffm1.txt");
String qd = "HKGFDXH HKGFGXH HKGFMXH TSNCTXH HKGORXH HKGOPXH HKGFRUD ";
List<String> list = new ArrayList<>();
try {
String ffmStr = FileTool.readfile(ffmfile);
// (\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+)/(.*)
// 按指定模式在字符串查找
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+)/(.*)";
//先找出航班信息
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+)/(.*)";
//再找出航班下的所有目的地的货
String pattern_destination = "([\\t\\r\\n]" +
"[A-Z]{3}[\\s*]?[\\t\\r\\n])" +
"(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]";
//取航班所有货物内容列表,取消Pattern.DOTALL,获得所有航站信息
String pattern_manifest = "^[A-Z]{3}/?[\\s*]?$";
//取运单板箱
String pattern_awb = "";
// 创建 Pattern 对象
Pattern pattern = Pattern.compile(pattern_manifest,Pattern.MULTILINE|Pattern.DOTALL);
// 现在创建 matcher 对象
Matcher matcher = pattern.matcher(ffmStr);
while (matcher.find()) {
list.add(matcher.group());
System.out.println("适配结果: " + matcher.group() );
}
System.out.println(list);
}catch (Exception e){
e.printStackTrace();
}
}
}
... ...
import com.tianbo.util.IO.FileTool;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FSUResolverTest {
public static void main(String[] args) {
File file = new File("/Users/mrz/Documents/java项目/新郑机场/util/fsu.txt");
List<String> list = new ArrayList<>();
try {
String Str = FileTool.readfile(file);
// 报文发送地址
String pattern_send = "QD\\s(.*)";
// 报文接收地址
String pattern_recive = ".([A-Z0-9]{7})\\s\\d{6}";
//报文类型及版本
String pattern_type = "(FSU|FFM|FWB|FHL|UCM|SCM)/(\\d+)";
//运单信息
String pattern_awb = "(\\d{3}-\\d{8})" +
"(CGO)(AMS)" +
"/([TPSDM])(\\d+)" +
"([K])" +
"([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*|\\d+)";
//FSU_业务类型
String pattern_fsu_type = "(RCS|FOH|DEP|RCF|NFD)/(.*)";
// 创建 Pattern 对象
Pattern pattern = Pattern.compile(pattern_fsu_type,Pattern.MULTILINE);
// 现在创建 matcher 对象
Matcher matcher = pattern.matcher(Str);
while (matcher.find()) {
list.add(matcher.group());
System.out.println("适配结果: " + matcher.group(1) );
}
System.out.println(list);
}catch (Exception e){
e.printStackTrace();
}
}
}
... ...