|
@@ -12,20 +12,14 @@
|
|
|
*/
|
|
|
package com.behosoft.edi.ws.processor.logisticsInfomation;
|
|
|
|
|
|
-import java.nio.charset.Charset;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import org.apache.commons.logging.Log;
|
|
|
-import org.apache.commons.logging.LogFactory;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
import com.behosoft.edi.dtomodel.common.FetchMailNoRequestDto;
|
|
|
import com.behosoft.edi.dtomodel.common.FetchMailNoResponseDto;
|
|
|
import com.behosoft.edi.dtomodel.ems.EmsFetchMailNoResponseDto;
|
|
|
import com.behosoft.edi.dtomodel.ws.xiangjia.CallOutServiceHeaderDto;
|
|
|
import com.behosoft.edi.dtomodel.ws.xiangjia.CallOutWsStandardDto;
|
|
|
+import com.behosoft.edi.dtomodel.ws.xiangjia.LisWsReqDataDto;
|
|
|
+import com.behosoft.edi.ws.factory.OutWsClientFactory;
|
|
|
import com.behosoft.edi.ws.processor.AbstractCallWsProcessor;
|
|
|
import com.behosoft.util.Base64Util;
|
|
|
import com.behosoft.util.ChineseNumber;
|
|
@@ -33,6 +27,14 @@ import com.behosoft.util.DtoXmlUtils;
|
|
|
import com.ibm.icu.text.DecimalFormat;
|
|
|
import com.wondersgroup.framework.security.encoder.impl.MD5PasswordEncoderImpl;
|
|
|
import com.wondersgroup.framework.util.preloadutil.AppContextUtils;
|
|
|
+import org.apache.commons.logging.Log;
|
|
|
+import org.apache.commons.logging.LogFactory;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.xml.bind.JAXBException;
|
|
|
+import java.nio.charset.Charset;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -97,7 +99,7 @@ public class EmsFetchMailNoProcessor extends AbstractCallWsProcessor {
|
|
|
//double total_weight = countTotalWeight(content.getWeight());
|
|
|
String receiverAddress = subReceiverAddress(content.getReceiverAddress());
|
|
|
|
|
|
- //int businessType = 1;
|
|
|
+ int businessType = 1;
|
|
|
MD5PasswordEncoderImpl md5PasswordEncoder =
|
|
|
(MD5PasswordEncoderImpl) AppContextUtils.getApplicationContext().getBean("md5PasswordEncoder");
|
|
|
StringBuffer sb = new StringBuffer();
|
|
@@ -105,11 +107,11 @@ public class EmsFetchMailNoProcessor extends AbstractCallWsProcessor {
|
|
|
sb.append("<XMLInfo>");
|
|
|
sb.append("<sysAccount>" + dto.getBody().getLogisticsFetchMailNo().getContent().getBigaccountid()
|
|
|
+ "</sysAccount>");
|
|
|
- //sb.append("<businessType>" + businessType + "</businessType>");
|
|
|
+ sb.append("<businessType>" + businessType + "</businessType>");
|
|
|
sb.append("<passWord>"
|
|
|
+ md5PasswordEncoder.encodePassword(dto.getBody().getLogisticsFetchMailNo().getContent().getPassword(),
|
|
|
null) + "</passWord>");
|
|
|
- //sb.append("<billNoAmount>" + 1 + "</billNoAmount>");
|
|
|
+ sb.append("<billNoAmount>" + 1 + "</billNoAmount>");
|
|
|
sb.append("<mailType>1</mailType>");
|
|
|
|
|
|
if ("VE131106000000200".equals(content.getCarrierId()) || "VE131106000000300".equals(content.getCarrierId())){
|
|
@@ -172,6 +174,13 @@ public class EmsFetchMailNoProcessor extends AbstractCallWsProcessor {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public static String getEMSFetchParamStringNew(String dto,String mailNo) {
|
|
|
+ String sb = dto.replaceAll("</procdate>", "</procdate><billno>" + mailNo + "</billno><businessType>1</businessType>");
|
|
|
+ String str = Base64Util.encode(sb.toString().getBytes(Charset.forName("utf-8")));
|
|
|
+ logger.info(str);
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
* (non-Javadoc)
|
|
|
* @see com.behosoft.edi.ws.processor.AbstractCallWsProcessor#getRequestUrl()
|
|
@@ -264,4 +273,95 @@ public class EmsFetchMailNoProcessor extends AbstractCallWsProcessor {
|
|
|
|
|
|
return Double.parseDouble(df.format(total_weight));
|
|
|
}
|
|
|
+
|
|
|
+ public Object callWs(String reqData) throws Exception {
|
|
|
+ long startTime = new Date().getTime();
|
|
|
+ Object response = null;
|
|
|
+ // 把请求的xml转传成LisRequestDataDto
|
|
|
+ LisWsReqDataDto lisWsReqData = null;
|
|
|
+ try {
|
|
|
+ Object obj = DtoXmlUtils.xmlToDto(reqData, LisWsReqDataDto.class);
|
|
|
+ lisWsReqData = (LisWsReqDataDto) obj;
|
|
|
+ }
|
|
|
+ catch (JAXBException e) {
|
|
|
+ log.error("报文格式不合法", e);
|
|
|
+ throw new Exception("报文格式不合法");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<LisWsReqDataDto.MethodParameter> paramList = lisWsReqData.getBody().getParamList();
|
|
|
+
|
|
|
+ Class[] argsClass = new Class[lisWsReqData.getBody().getParamList().size()];
|
|
|
+ Object[] args = new Object[paramList.size()];
|
|
|
+ // param参数进行排序
|
|
|
+ for (int i = 0; i < paramList.size(); i++) {
|
|
|
+ if ("String".equalsIgnoreCase(paramList.get(i).getParamType())) {
|
|
|
+ argsClass[i] = String.class;
|
|
|
+ args[i] = paramList.get(i).getParamValue();
|
|
|
+ }
|
|
|
+ else if ("Integer".equalsIgnoreCase(paramList.get(i).getParamType())) {
|
|
|
+ argsClass[i] = Integer.class;
|
|
|
+ args[i] = Integer.valueOf(paramList.get(i).getParamValue());
|
|
|
+ }
|
|
|
+ else if ("int".equalsIgnoreCase(paramList.get(i).getParamType())) {
|
|
|
+ argsClass[i] = int.class;
|
|
|
+ args[i] = Integer.valueOf(paramList.get(i).getParamValue()).intValue();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ long tmptotal = new Date().getTime() - startTime;
|
|
|
+ System.out.println("调用外部ws组装耗时" + tmptotal);
|
|
|
+ log.info("调用外部ws组装耗时" + tmptotal);
|
|
|
+ try {
|
|
|
+ startTime = new Date().getTime();
|
|
|
+ OutWsClientFactory outWsClientFactory =
|
|
|
+ (OutWsClientFactory) AppContextUtils.getApplicationContext().getBean("outWsClientFactory");
|
|
|
+ log.info("==========开始调用外部WS:"+ args);
|
|
|
+ Object wsClient = outWsClientFactory.getOutWsClient(lisWsReqData.getHeader().getAnalyzeType());
|
|
|
+
|
|
|
+ //todo此处调用获取邮政单号
|
|
|
+ for(int i = 0; i < paramList.size(); i++) {
|
|
|
+ LisWsReqDataDto.MethodParameter methodParameter = paramList.get(i);
|
|
|
+ String paramValue = methodParameter.getParamValue();
|
|
|
+ //获取单号
|
|
|
+ String url = "http://ebi.ems.com.cn/ext-web/a/chinapost/thermalforward";//指定URL
|
|
|
+ Map map = new HashMap<String, Object>();//存放参数
|
|
|
+ map.put("method", "getBillNumBySys");
|
|
|
+ map.put("xml", paramValue);
|
|
|
+ log.info("获取单号请求报文:" + paramValue);
|
|
|
+ response = HttpUtil.get(url, map);
|
|
|
+ logger.error("获取单号响应报文:"+response);
|
|
|
+
|
|
|
+ String responseXML = new String(Base64Util.decode(response.toString()), Charset.forName("UTF-8"));
|
|
|
+ EmsFetchMailNoResponseDto fetchMailNoResponseDto = (EmsFetchMailNoResponseDto)DtoXmlUtils.xmlToDto(responseXML, EmsFetchMailNoResponseDto.class);
|
|
|
+ String mailNo = fetchMailNoResponseDto.getAssignIds().getAssignId().get(0).getBillNo();
|
|
|
+
|
|
|
+ String paramValueXML = new String(Base64Util.decode(paramValue.toString()), Charset.forName("UTF-8"));
|
|
|
+ String emsFetchParamString = getEMSFetchParamStringNew(paramValueXML,mailNo);
|
|
|
+
|
|
|
+ Map map2 = new HashMap<String, Object>();
|
|
|
+ map2.put("method", "updatePrintDatas");
|
|
|
+ map2.put("xml", emsFetchParamString);
|
|
|
+ log.error("回传订单(已打印),将详情单打印信息更新到自助服务系统请求报文:" + emsFetchParamString);
|
|
|
+ String response2 = "";
|
|
|
+ response2 = HttpUtil.get(url, map2);
|
|
|
+ log.error("回传订单(已打印),将详情单打印信息更新到自助服务系统响应报文:"+response2);
|
|
|
+
|
|
|
+ Map map3 = new HashMap<String, Object>();
|
|
|
+ map3.put("method", "getPrintDatas");
|
|
|
+ map3.put("xml", emsFetchParamString);
|
|
|
+ String response3 = "";
|
|
|
+ response3 = HttpUtil.get(url, map3);
|
|
|
+ log.error("回传订单(客户端打印)唯一传未打印订单接口响应报文:"+response3);
|
|
|
+ }
|
|
|
+
|
|
|
+ tmptotal = new Date().getTime() - startTime;
|
|
|
+ log.info("动态调用外部ws耗时" + tmptotal +","+wsClient.getClass());
|
|
|
+ }
|
|
|
+ catch (Exception e) {
|
|
|
+ log.error("调用第三方web服务报错", e);
|
|
|
+ throw new Exception("调用第三方web服务报错");
|
|
|
+ }
|
|
|
+ return response;
|
|
|
+
|
|
|
+ }
|
|
|
}
|