|
|
package com.tianbo.analysis.handle;
|
|
|
|
|
|
import com.tianbo.analysis.model.*;
|
|
|
import com.tianbo.analysis.service.CustomMessageService;
|
|
|
import com.tianbo.analysis.tools.AWBTools;
|
|
|
import com.tianbo.util.Date.DateUtil;
|
|
|
import com.tianbo.util.XML.XMLXPath;
|
...
|
...
|
@@ -43,6 +44,7 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
private String errBakDir;
|
|
|
|
|
|
private File xmlfile;
|
|
|
|
|
|
private static CustomXmlHandleThread customXmlHandle;
|
|
|
//海关新舱单回执报头
|
|
|
public final static String MessageID = "//Manifest/Head/MessageID";
|
...
|
...
|
@@ -60,8 +62,8 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
public final static String JourneyID = "//Manifest/Response/BorderTransportMeans/JourneyID";
|
|
|
public final static String WaybillMaster = "//Manifest/Response/Consignment/TransportContractDocument/ID";
|
|
|
public final static String WaybillSecond = "//Manifest/Response/Consignment/AssociatedTransportDocument/ID";
|
|
|
public final static String ResponseCode = "//Manifest/Response/Consignment/ResponseType/Code";
|
|
|
public final static String ResponseText = "//Manifest/Response/Consignment/ResponseType/Text";
|
|
|
public final static String ResponseCode = "//ResponseType/Code";
|
|
|
public final static String ResponseText = "//ResponseType/Text";
|
|
|
|
|
|
/**
|
|
|
* 海关国际转运业务回执报体
|
...
|
...
|
@@ -70,8 +72,10 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
public final static String ImportWaybillMaster = "//Manifest/Response/ImportInformation/Consignment/TransportContractDocument/ID";
|
|
|
public final static String ExportJourneyID = "//Manifest/Response/ExportInformation/BorderTransportMeans/JourneyID";
|
|
|
public final static String ExportWaybillMaster = "//Manifest/Response/ExportInformation/Consignment/TransportContractDocument/ID";
|
|
|
public final static String TransResponseCode = "//Manifest/Response/ResponseType/Code";
|
|
|
public final static String TransResponseText = "//Manifest/Response/ResponseType/Text";
|
|
|
// public final static String TransResponseCode = "//Manifest/Response/ResponseType/Code";
|
|
|
// public final static String TransResponseText = "//Manifest/Response/ResponseType/Text";
|
|
|
public final static String TransResponseCode = "//ResponseType/Code";
|
|
|
public final static String TransResponseText = "//ResponseType/Text";
|
|
|
|
|
|
|
|
|
//通过@PostConstruct实现初始化bean之前进行的操作,解决service调用空指针问题
|
...
|
...
|
@@ -96,7 +100,6 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
//操作成功,则转移剪切解析文件到备份目录,否则转移到error目录备份
|
|
|
if(i>0){
|
|
|
File bakupDirectory = new File(backdireByDay);
|
|
|
//复制一份到转发目录
|
|
|
//解析成功备份一份到备份目录
|
|
|
FileUtils.moveFileToDirectory(xmlfile,bakupDirectory,true);
|
|
|
}else {
|
...
|
...
|
@@ -113,7 +116,6 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
log.info("线程:{}结束",xmlfile.getName());
|
|
|
latch.countDown();
|
|
|
log.info("剩余线程数量{}",latch.getCount());
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
*
|
...
|
...
|
@@ -132,24 +134,14 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
Document document = saxReader.read(xmlfile);
|
|
|
Element contentRoot = document.getRootElement();
|
|
|
|
|
|
String flightNo = "";
|
|
|
String flightDate = "";
|
|
|
String flightNo = "UNKONW";
|
|
|
String flightDate = "20101010";
|
|
|
|
|
|
//开始解析
|
|
|
String msgType = XMLXPath.getSingleValueByPath(document,MessageType);
|
|
|
String journeyid = XMLXPath.getSingleValueByPath(document,JourneyID);
|
|
|
// XMLXPath.getSingleValueByPath(document, )
|
|
|
|
|
|
if(!StringUtils.isEmpty(journeyid)){
|
|
|
|
|
|
String[] flightList = journeyid.split("/");
|
|
|
if(flightList.length > 0){
|
|
|
flightNo = flightList[0];
|
|
|
flightDate = flightList[1];
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
String awbA = XMLXPath.getSingleValueByPath(document,WaybillMaster);
|
|
|
//全格式的分单 如 17212345678_ADBD
|
...
|
...
|
@@ -163,6 +155,8 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
String version = XMLXPath.getSingleValueByPath(document,Version);
|
|
|
String functionCode = XMLXPath.getSingleValueByPath(document,FunctionCode);
|
|
|
|
|
|
|
|
|
|
|
|
CustomReception customReception = new CustomReception( msgType,
|
|
|
flightNo,
|
|
|
flightDate,
|
...
|
...
|
@@ -176,6 +170,25 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
reciveId,
|
|
|
version,
|
|
|
functionCode);
|
|
|
|
|
|
/**
|
|
|
* 如果回执中没有携带航班信息节点,说明是出错报文
|
|
|
* 到发送日志表根据messageid 找到相应的发送日志报文的航班及运单信息,再进行解析
|
|
|
*/
|
|
|
if(!StringUtils.isEmpty(journeyid)){
|
|
|
|
|
|
String[] flightList = journeyid.split("/");
|
|
|
if(flightList.length > 0){
|
|
|
flightNo = flightList[0];
|
|
|
flightDate = flightList[1];
|
|
|
customReception.setFlightNo(flightNo);
|
|
|
customReception.setFlightDate(flightDate);
|
|
|
}
|
|
|
}else {
|
|
|
CUSTOMSMESSAGE customsmessage = new CUSTOMSMESSAGE();
|
|
|
customReception = customsmessage.getWaybillInfoByCutomResponse(customReception);
|
|
|
}
|
|
|
|
|
|
switch (msgType){
|
|
|
case "MT9999":
|
|
|
ORIGINMANIFESTMASTER originmanifestmaster = new ORIGINMANIFESTMASTER(customReception);
|
...
|
...
|
@@ -254,6 +267,7 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
|
|
|
}
|
|
|
|
|
|
updateCustomMessage(customReception);
|
|
|
return i;
|
|
|
|
|
|
}
|
...
|
...
|
@@ -268,7 +282,7 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
|
|
|
String importJourneyID = XMLXPath.getSingleValueByPath(document,ImportJourneyID);
|
|
|
String importFlightNo = "UNKONW";
|
|
|
String importFlightDate = "00000000";
|
|
|
String importFlightDate = "20101010";
|
|
|
if(!StringUtils.isEmpty(importJourneyID)){
|
|
|
importFlightNo = AWBTools.splitFlightAndDate(importJourneyID)[0];
|
|
|
importFlightDate = AWBTools.splitFlightAndDate(importJourneyID)[1];
|
...
|
...
|
@@ -298,6 +312,11 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
|
|
|
}
|
|
|
|
|
|
private int updateCustomMessage(CustomReception customReception){
|
|
|
CUSTOMSMESSAGE customsmessage = new CUSTOMSMESSAGE(customReception);
|
|
|
return customsmessage.updateMessageByMessageid();
|
|
|
}
|
|
|
|
|
|
private void errBak(File file){
|
|
|
try {
|
|
|
String today = DateUtil.getTodayBy_yyyyMMdd();
|
...
|
...
|
|