...
|
...
|
@@ -13,6 +13,7 @@ import org.apache.commons.lang.StringUtils; |
|
|
import org.dom4j.Document;
|
|
|
import org.dom4j.DocumentException;
|
|
|
import org.dom4j.Element;
|
|
|
import org.dom4j.Node;
|
|
|
import org.dom4j.io.SAXReader;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
...
|
...
|
@@ -23,6 +24,7 @@ import java.io.File; |
|
|
import java.io.FileNotFoundException;
|
|
|
import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -66,6 +68,15 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
|
|
|
|
|
|
/**
|
|
|
* 批量发送时的回执解析,运单节点
|
|
|
*/
|
|
|
public final static String Consignment = "//Manifest/Response/Consignment";
|
|
|
public final static String WaybillMaster_NODE = "TransportContractDocument/ID";
|
|
|
public final static String WaybillSecond_NODE = "AssociatedTransportDocument/ID";
|
|
|
public final static String ResponseCode_NODE = "ResponseType/Code";
|
|
|
public final static String ResponseText_NODE = "ResponseType/Text";
|
|
|
|
|
|
/**
|
|
|
* 海关普通业务新舱单回执报体
|
|
|
*/
|
|
|
public final static String JourneyID = "//Manifest/Response/BorderTransportMeans/JourneyID";
|
...
|
...
|
@@ -154,9 +165,7 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
* @throws FileNotFoundException
|
|
|
*/
|
|
|
private int handelXmlDocument() throws DocumentException,UnsupportedEncodingException,SAXParseException,FileNotFoundException {
|
|
|
|
|
|
int i = 0;
|
|
|
String secondSplit = "_";
|
|
|
SAXReader saxReader = new SAXReader();
|
|
|
Document document = saxReader.read(xmlfile);
|
|
|
Element contentRoot = document.getRootElement();
|
...
|
...
|
@@ -164,39 +173,109 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
String flightNo = "UNKONW";
|
|
|
String flightDate = "20101010";
|
|
|
|
|
|
//开始解析
|
|
|
String msgType = XMLXPath.getSingleValueByPath(document,MessageType);
|
|
|
String journeyid = XMLXPath.getSingleValueByPath(document,JourneyID);
|
|
|
// XMLXPath.getSingleValueByPath(document, )
|
|
|
|
|
|
|
|
|
String awbA = XMLXPath.getSingleValueByPath(document,WaybillMaster);
|
|
|
//全格式的分单 如 17212345678_ADBD
|
|
|
String awbH = XMLXPath.getSingleValueByPath(document,WaybillSecond);
|
|
|
String resCode = XMLXPath.getSingleValueByPath(document,ResponseCode);
|
|
|
String resText = XMLXPath.getSingleValueByPath(document,ResponseText);
|
|
|
String messageId = XMLXPath.getSingleValueByPath(document, MessageID);
|
|
|
String sendTime = XMLXPath.getSingleValueByPath(document,SendTime);
|
|
|
String sendId = XMLXPath.getSingleValueByPath(document,SenderID);
|
|
|
String reciveId = XMLXPath.getSingleValueByPath(document,ReceiverID);
|
|
|
String version = XMLXPath.getSingleValueByPath(document,Version);
|
|
|
|
|
|
String functionCode = XMLXPath.getSingleValueByPath(document,FunctionCode);
|
|
|
//开始解析
|
|
|
String msgType = XMLXPath.getSingleValueByPath(document,MessageType);
|
|
|
String journeyid = XMLXPath.getSingleValueByPath(document,JourneyID);
|
|
|
|
|
|
List<Node> ConsignmentNodes = XMLXPath.getPathValues(document,Consignment);
|
|
|
|
|
|
String awbA = "",awbH="",resCode="",resText="";
|
|
|
|
|
|
//说明有带运单的回执
|
|
|
if (!ConsignmentNodes.isEmpty()){
|
|
|
for (Node node: ConsignmentNodes ) {
|
|
|
awbA = node.selectSingleNode(WaybillMaster_NODE).getStringValue();
|
|
|
//全格式的分单 如 17212345678_ADBD
|
|
|
awbH = node.selectSingleNode(WaybillSecond_NODE).getStringValue();
|
|
|
resCode = node.selectSingleNode(ResponseCode_NODE).getStringValue();
|
|
|
resText = node.selectSingleNode(ResponseText_NODE).getStringValue();
|
|
|
log.info("主单:{}-分单:{}-回执代码:{}-回执内容:{}",awbA,awbH,resCode,resText);
|
|
|
i =+ normalXmlHandel(msgType,
|
|
|
flightNo,
|
|
|
flightDate,
|
|
|
awbA,
|
|
|
awbH,
|
|
|
resCode,
|
|
|
resText,
|
|
|
messageId,
|
|
|
sendTime,
|
|
|
sendId,
|
|
|
reciveId,
|
|
|
version,
|
|
|
functionCode,
|
|
|
journeyid,
|
|
|
document);
|
|
|
}
|
|
|
return i;
|
|
|
}else{//国际转运回执在这里处理
|
|
|
awbA = XMLXPath.getSingleValueByPath(document,WaybillMaster);
|
|
|
//全格式的分单 如 17212345678_ADBD
|
|
|
awbH = XMLXPath.getSingleValueByPath(document,WaybillSecond);
|
|
|
resCode = XMLXPath.getSingleValueByPath(document,ResponseCode);
|
|
|
resText = XMLXPath.getSingleValueByPath(document,ResponseText);
|
|
|
i =+ normalXmlHandel(msgType,
|
|
|
flightNo,
|
|
|
flightDate,
|
|
|
awbA,
|
|
|
awbH,
|
|
|
resCode,
|
|
|
resText,
|
|
|
messageId,
|
|
|
sendTime,
|
|
|
sendId,
|
|
|
reciveId,
|
|
|
version,
|
|
|
functionCode,
|
|
|
journeyid,
|
|
|
document);
|
|
|
return i;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
private int normalXmlHandel(String msgType,
|
|
|
String flightNo,
|
|
|
String flightDate,
|
|
|
String awbA,
|
|
|
String awbH,
|
|
|
String resCode,
|
|
|
String resText,
|
|
|
String messageId,
|
|
|
String sendTime,
|
|
|
String sendId,
|
|
|
String reciveId,
|
|
|
String version,
|
|
|
String functionCode,
|
|
|
String journeyid,
|
|
|
Document document
|
|
|
){
|
|
|
String secondSplit = "_";
|
|
|
int i = 0;
|
|
|
CustomReception customReception = new CustomReception( msgType,
|
|
|
flightNo,
|
|
|
flightDate,
|
|
|
awbA,
|
|
|
awbH,
|
|
|
resCode,
|
|
|
resText,
|
|
|
messageId,
|
|
|
sendTime,
|
|
|
sendId,
|
|
|
reciveId,
|
|
|
version,
|
|
|
functionCode);
|
|
|
flightNo,
|
|
|
flightDate,
|
|
|
awbA,
|
|
|
awbH,
|
|
|
resCode,
|
|
|
resText,
|
|
|
messageId,
|
|
|
sendTime,
|
|
|
sendId,
|
|
|
reciveId,
|
|
|
version,
|
|
|
functionCode);
|
|
|
|
|
|
/**
|
|
|
* 如果回执中没有携带航班信息节点,说明是出错报文
|
...
|
...
|
@@ -332,7 +411,6 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
|
|
|
updateCustomMessage(customReception);
|
|
|
return i;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -356,7 +434,7 @@ public class CustomXmlHandleThread implements Runnable{ |
|
|
String importWaybillSecond= XMLXPath.getSingleValueByPath(document,ImportWaybillSecond);
|
|
|
String transResponseCode=XMLXPath.getSingleValueByPath(document,TransResponseCode);
|
|
|
String transResponseText=XMLXPath.getSingleValueByPath(document,TransResponseText);
|
|
|
CustomReception transCustomReception = new CustomReception( customReception.getMessageType(),
|
|
|
CustomReception transCustomReception = new CustomReception(customReception.getMessageType(),
|
|
|
importFlightNo,
|
|
|
importFlightDate,
|
|
|
importWaybillMaster,
|
...
|
...
|
|