...
|
...
|
@@ -397,11 +397,9 @@ public class MessageBusProcessor { |
|
|
/**
|
|
|
* feigin从服务直接获取消息
|
|
|
*/
|
|
|
@Scheduled(fixedRate = 5000)
|
|
|
// @Scheduled(fixedRate = 5000)
|
|
|
public void getDataFromFeigin(){
|
|
|
|
|
|
try{
|
|
|
|
|
|
//初始化数据库
|
|
|
CUSTOM_RESPONSE test = custom_response_service.selectByPrimaryKey("111");
|
|
|
log.info("1-开始执行获取任务,获取账号为:{}",USER_NAME);
|
...
|
...
|
@@ -429,101 +427,128 @@ public class MessageBusProcessor { |
|
|
log.info("@[一]@消息为舱单回执");
|
|
|
CUSTOM_RESPONSE custom_response_nmms2 = new CUSTOM_RESPONSE();
|
|
|
//判断回执类型
|
|
|
JSONObject Manifest = body.getJSONObject("Manifest");
|
|
|
JSONObject head = Manifest.getJSONObject("Head");
|
|
|
String messageType = head.getString("MessageType");
|
|
|
String messageID = head.getString("MessageID");
|
|
|
String sendTime = head.getString("SendTime");
|
|
|
String senderID = head.getString("SenderID");
|
|
|
String receiverID = head.getString("ReceiverID");
|
|
|
Integer version = head.getInteger("Version");
|
|
|
Integer functionCode = head.getInteger("FunctionCode");
|
|
|
|
|
|
|
|
|
if("MT2201".equals(messageType) || "MT9999".equals(messageType)){
|
|
|
log.info("@[二]@开始解析:{}",messageType);
|
|
|
// 航班信息
|
|
|
JSONObject response = Manifest.getJSONObject("Response");
|
|
|
JSONObject borderTransportMeans = response.getJSONObject("BorderTransportMeans");
|
|
|
|
|
|
String flightNo = "UNKONW";
|
|
|
String flightDate = "20101010";
|
|
|
|
|
|
String journeyid = borderTransportMeans.getString("JourneyID");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//运单信息
|
|
|
JSONObject consignment = response.getJSONObject("Consignment");
|
|
|
|
|
|
JSONObject responseType = consignment.getJSONObject("ResponseType");
|
|
|
JSONObject transportContractDocument = consignment.getJSONObject("TransportContractDocument");
|
|
|
JSONObject associatedTransportDocument = consignment.getJSONObject("AssociatedTransportDocument");
|
|
|
|
|
|
//回执代码
|
|
|
Integer responseCode = responseType.getIntValue("Code");
|
|
|
//回执内容
|
|
|
String responseText = responseType.getString("Text");
|
|
|
|
|
|
Long waybillMaster = transportContractDocument.getLong("ID");
|
|
|
|
|
|
String waybillSecond="";
|
|
|
|
|
|
if (associatedTransportDocument!=null){
|
|
|
waybillSecond = associatedTransportDocument.getString("ID");
|
|
|
}
|
|
|
|
|
|
|
|
|
CustomReception customReception = new CustomReception( messageType,
|
|
|
flightNo,
|
|
|
flightDate,
|
|
|
waybillMaster.toString(),
|
|
|
waybillSecond,
|
|
|
responseCode.toString(),
|
|
|
responseText,
|
|
|
messageID,
|
|
|
sendTime,
|
|
|
senderID,
|
|
|
receiverID,
|
|
|
version.toString(),
|
|
|
functionCode.toString());
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 如果回执中没有携带航班信息节点,说明是出错报文
|
|
|
* 到发送日志表根据messageid 找到相应的发送日志报文的航班及运单信息,再进行解析
|
|
|
*/
|
|
|
if(!org.apache.commons.lang.StringUtils.isEmpty(journeyid)){
|
|
|
|
|
|
String[] flightList = journeyid.split("/");
|
|
|
if(flightList.length > 0){
|
|
|
flightNo = flightList[0];
|
|
|
flightDate = flightList[1];
|
|
|
|
|
|
log.info("@[三]@航班信息为:{}",journeyid);
|
|
|
customReception.setFlightNo(flightNo);
|
|
|
customReception.setFlightDate(flightDate);
|
|
|
JSONObject manifest = body.getJSONObject("Manifest");
|
|
|
JSONObject head = manifest.getJSONObject("Head");
|
|
|
|
|
|
if(head != null){
|
|
|
log.info("@[.]开始回执报头解析");
|
|
|
String messageType = head.getString("MessageType");
|
|
|
String messageID = head.getString("MessageID");
|
|
|
String sendTime = head.getString("SendTime");
|
|
|
String senderID = head.getString("SenderID");
|
|
|
String receiverID = head.getString("ReceiverID");
|
|
|
Integer version = head.getInteger("Version");
|
|
|
Integer functionCode = head.getInteger("FunctionCode");
|
|
|
log.info("@[MessageType:{}]回执报头解析完毕",messageType);
|
|
|
|
|
|
if("MT2201".equals(messageType) || "MT9999".equals(messageType) || "MT3201".equals(messageType)){
|
|
|
log.info("@[二]@开始解析:{}",messageType);
|
|
|
messageType = "MT2201";
|
|
|
// 航班信息
|
|
|
JSONObject response = manifest.getJSONObject("Response");
|
|
|
if (response!=null){
|
|
|
JSONObject borderTransportMeans = response.getJSONObject("BorderTransportMeans");
|
|
|
if (borderTransportMeans!=null ){
|
|
|
String flightNo = "UNKONW";
|
|
|
String flightDate = "20101010";
|
|
|
|
|
|
String journeyid = borderTransportMeans.getString("JourneyID");
|
|
|
|
|
|
//运单信息
|
|
|
JSONObject consignment = response.getJSONObject("Consignment");
|
|
|
if (consignment!=null){
|
|
|
JSONObject responseType = consignment.getJSONObject("ResponseType");
|
|
|
JSONObject transportContractDocument = consignment.getJSONObject("TransportContractDocument");
|
|
|
JSONObject associatedTransportDocument = consignment.getJSONObject("AssociatedTransportDocument");
|
|
|
|
|
|
Integer responseCode = 3;
|
|
|
String responseText = "回执报文未有信息";
|
|
|
|
|
|
if (responseType!=null){
|
|
|
//回执代码
|
|
|
responseCode = responseType.getIntValue("Code");
|
|
|
//回执内容
|
|
|
responseText = responseType.getString("Text");
|
|
|
|
|
|
}
|
|
|
String waybillMaster = "00000000000";
|
|
|
if (transportContractDocument!=null){
|
|
|
waybillMaster = transportContractDocument.getString("ID");
|
|
|
}
|
|
|
|
|
|
|
|
|
String waybillSecond="";
|
|
|
|
|
|
if (associatedTransportDocument!=null){
|
|
|
waybillSecond = associatedTransportDocument.getString("ID");
|
|
|
}
|
|
|
|
|
|
|
|
|
CustomReception customReception = new CustomReception( messageType,
|
|
|
flightNo,
|
|
|
flightDate,
|
|
|
waybillMaster.toString(),
|
|
|
waybillSecond,
|
|
|
responseCode.toString(),
|
|
|
responseText,
|
|
|
messageID,
|
|
|
sendTime,
|
|
|
senderID,
|
|
|
receiverID,
|
|
|
version.toString(),
|
|
|
functionCode.toString());
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 如果回执中没有携带航班信息节点,说明是出错报文
|
|
|
* 到发送日志表根据messageid 找到相应的发送日志报文的航班及运单信息,再进行解析
|
|
|
*/
|
|
|
if(!org.apache.commons.lang.StringUtils.isEmpty(journeyid)){
|
|
|
|
|
|
String[] flightList = journeyid.split("/");
|
|
|
if(flightList.length > 0){
|
|
|
flightNo = flightList[0];
|
|
|
flightDate = flightList[1];
|
|
|
|
|
|
log.info("@[三]@航班信息为:{}",journeyid);
|
|
|
customReception.setFlightNo(flightNo);
|
|
|
customReception.setFlightDate(flightDate);
|
|
|
}
|
|
|
custom_response_nmms2 = new CUSTOM_RESPONSE(customReception);
|
|
|
}else {
|
|
|
custom_response_nmms2 = new CUSTOM_RESPONSE(customReception);
|
|
|
custom_response_nmms2 = custom_response_service.getWaybillInfoByCutomResponse(custom_response_nmms2);
|
|
|
}
|
|
|
log.info("[(三.一)]{{}",custom_response_nmms2);
|
|
|
|
|
|
int ii = custom_response_service.secondAnalysisReception(custom_response_nmms2);
|
|
|
|
|
|
log.info("@[四]@回执解析完毕[{}]\n@@^PARSE SUCCESS^@@",ii);
|
|
|
}else {
|
|
|
log.info("@[四零零]@回执报文没有运单节点,解析失败.");
|
|
|
}
|
|
|
}else {
|
|
|
log.info("@[四零三]缺少航班信息节点,解析失败");
|
|
|
}
|
|
|
|
|
|
|
|
|
}else {
|
|
|
log.info("@[四零二]缺少回执内容节点,解析失败");
|
|
|
}
|
|
|
custom_response_nmms2 = new CUSTOM_RESPONSE(customReception);
|
|
|
}else {
|
|
|
custom_response_nmms2 = new CUSTOM_RESPONSE(customReception);
|
|
|
custom_response_nmms2 = custom_response_service.getWaybillInfoByCutomResponse(custom_response_nmms2);
|
|
|
|
|
|
}
|
|
|
log.info("[(三.一)]{{}",custom_response_nmms2);
|
|
|
}else {
|
|
|
log.info("@[四零一]@缺少Manifest或Head节点");
|
|
|
}
|
|
|
|
|
|
int ii = custom_response_service.secondAnalysisReception(custom_response_nmms2);
|
|
|
|
|
|
log.info("@[四]@回执解析完毕[{}]\n@@^PARSE SUCCESS^@@",ii);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
log.info("!!!回执解析异常:{}!!!",e.toString());
|
|
|
log.error("!!!处理消息出错:{}!!!",e.toString());
|
|
|
e.printStackTrace();
|
|
|
}
|
...
|
...
|
|