三個類:web
SaleTrackThread 線程類json
private void excute(TrackServiceBean trackBean){
String method = "doSaveTrack"; // 方法名
Service service = new Service();
String RequestXML="";
try {
RequestXML = TrackUtil.GenXML(trackBean);
try {
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(webserviceAddress); //調用該接口
call.setOperationName(method); //調用該方法
call.setReturnClass(String.class);
call.addParameter("xmlStr", XMLType.XSD_STRING, ParameterMode.IN);
try {
String data = (String) call.invoke(new Object[] {RequestXML});
logger.info("銷售軌跡平臺返回報文:"+ data );
} catch (RemoteException e) {
logger.error("銷售軌跡平臺鏈接不通",e);
e.printStackTrace();
} catch (Exception e) {
logger.error("銷售軌跡平臺調用失敗",e);
e.printStackTrace();
}
} catch (ServiceException e) {
logger.error("銷售軌跡平臺調用失敗",e);
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
logger.debug("寫入銷售軌跡失敗,數據爲:" + RequestXML);
}
}
public void run() {
try{
if(trackBean==null){
logger.info("銷售軌跡平臺調用報文爲空,不調用銷售軌跡接口");
}else{
excute(trackBean);
}
}catch (Exception e) {
logger.error("銷售軌跡平臺調用失敗",e);
}
}ide
工具類:TrackUtil函數
public static void excuteOnlineTrack(String OrderId,String ProcessType, Object RequestObject){
if(OrderId==null){
OrderId="";
}
if(ProcessType==null){
ProcessType="";
}
if(RequestObject==null){
RequestObject="";
}
logger.debug("excuteOnlineTrack02寫入銷售軌跡。");
JsonConfig jsonConfig = new JsonConfig();
DoubleJsonValueProcessor doubleJsonValueProcessor = new DoubleJsonValueProcessor(2);
jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
jsonConfig.registerJsonValueProcessor(Double.class, doubleJsonValueProcessor);
JsonDateProcessor jd = new ECSJsonUtils.JsonDateProcessor("yyyy-MM-dd");
jsonConfig.registerJsonValueProcessor(Date.class, jd);
TrackServiceBean trackBean = new TrackServiceBean();
try{ //兩個try catch確保不會影響主線程,有問題只會生成一句日誌。
logger.error("用RequestObject生成銷售軌跡TrackServiceBean開始。");
String tempOrderId = OrderId;
String tempProcessType = ProcessType;
String tempRequestXml = ECSJsonUtils.convertObject(RequestObject,jsonConfig);
trackBean.setClientID("EB");
trackBean.setOrderId(tempOrderId);
trackBean.setPolicyId("");
trackBean.setProcessType(tempProcessType);
if(StringUtils.isNotBlank(tempRequestXml) && StringUtils.isNotEmpty(tempRequestXml)){
trackBean.setRequestXml(tempRequestXml);
}else{
trackBean.setRequestXml("excuteOnlineTrack寫入銷售軌跡:RequestXml爲空");
}
trackBean.setResponseXml("");
trackBean.setRemark("");
logger.error("用RequestObject生成銷售軌跡TrackServiceBean成功。");
}catch(Exception ex){
logger.error("用RequestObject生成銷售軌跡TrackServiceBean時發生異常,不會寫入銷售軌跡!",ex);
return;
}
try{ //trackBean 生成實體類bean
logger.debug("excuteOnlineTrack寫入銷售軌跡,數據爲trackBean:"+trackBean.toString());
SaleTrackThread tSaleTrackThread =new SaleTrackThread(trackBean);
Thread t1=new Thread(tSaleTrackThread); //調用線程,對主線程無影響
t1.start();
}catch(Exception ex){
logger.error("生成銷售軌跡接口xml文檔時發生異常!",ex);
return;
}
}工具
public static void excuteOnlineTrack(String OrderId,String ProcessType,String RequestXml){spa
重載函數。。。。線程
}debug
實體類:TrackServiceBean日誌
public class TrackServiceBean implements Serializable {xml
private static final long serialVersionUID = 5574793367633922241L;
private String ClientID;
private String ProcessType;
private String OrderId;
private String PolicyId;
private String requestXml;
private String responseXml;
private String Remark;
。。。。
@Override
public String toString() {
return "TrackServiceBean [ClientID=" + ClientID + ", EncryptString="
+ ", ProcessType=" + ProcessType + ", OrderId="
+ OrderId + ", PolicyId=" + PolicyId + ", requestXml="
+ requestXml + ", responseXml=" + responseXml + ", Remark="
+ Remark + "]";
}
}