|
@@ -1,6 +1,5 @@
|
|
|
package info.aspirecn.iov.sjjh.supplier10000043.service;
|
|
|
import brave.Tracer;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
import info.aspirecn.iov.sjjh.channel.inter.platform.ChannelActionInterface;
|
|
|
import info.aspirecn.iov.sjjh.service.sms.action.SmsActionInterface;
|
|
|
import info.aspirecn.iov.sjjh.supplier10000043.constant.SupplierProperties;
|
|
@@ -25,7 +24,9 @@ import org.apache.axis.AxisProperties;
|
|
|
import org.apache.cxf.frontend.ClientProxy;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.cxf.endpoint.Client;
|
|
|
+import org.apache.cxf.message.Message;
|
|
|
import org.apache.cxf.transport.http.HTTPConduit;
|
|
|
+import org.apache.cxf.transports.http.configuration.ConnectionType;
|
|
|
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
|
|
|
import org.apache.tomcat.util.codec.binary.Base64;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -49,9 +50,7 @@ import java.net.SocketTimeoutException;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
-import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
|
|
/**
|
|
|
* @description:
|
|
@@ -65,6 +64,8 @@ public class ChannelServiceImpl implements ChannelService {
|
|
|
@Autowired
|
|
|
private Tracer tracer;
|
|
|
|
|
|
+ private final String headerTraceId="x-b3-traceid";
|
|
|
+ private final String headerchannelId="channelId";
|
|
|
@Value("${supplier.url}")
|
|
|
private String url;
|
|
|
@Autowired
|
|
@@ -93,6 +94,8 @@ public class ChannelServiceImpl implements ChannelService {
|
|
|
private String urlV3;
|
|
|
@Value("${supplier.urlV4}")
|
|
|
private String urlV4;
|
|
|
+ @Value("${supplier.urlV5}")
|
|
|
+ private String urlV5;
|
|
|
@Autowired
|
|
|
SupplierProperties supplierProperties;
|
|
|
@Autowired
|
|
@@ -161,6 +164,7 @@ public class ChannelServiceImpl implements ChannelService {
|
|
|
call.setTargetEndpointAddress(url);
|
|
|
call.setOperationName(twoElementsMethod);// WSDL里面描述的接口名称
|
|
|
call.setTimeout(outTime);
|
|
|
+
|
|
|
call.addParameter(SjjhConstant.PARAMETER_INLICENSE,
|
|
|
XMLType.XSD_STRING,
|
|
|
javax.xml.rpc.ParameterMode.IN);// 接口的参数
|
|
@@ -173,6 +177,7 @@ public class ChannelServiceImpl implements ChannelService {
|
|
|
.replace("{ywlx}", SjjhConstant.PARAMETER_YWLX)
|
|
|
.replace("{idCode}", requestObject.getIdCode())
|
|
|
.replace("{name}", requestObject.getName());
|
|
|
+
|
|
|
String result = (String) call.invoke(new Object[]{SjjhConstant.TWO_ELEMENTS_SECRET_KEY, paramXml});
|
|
|
// String result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><RESPONSE errorcode=\"-20\" code=\"0\" countrows=\"1\"><ROWS><ROW><ErrorCode>-20</ErrorCode><ErrorMsg>计费失败,请与管理员联系(errorcode=-20)!</ErrorMsg></ROW></ROWS></RESPONSE>";
|
|
|
log.info("twoElementsCheck上游返回xml:{}", result);
|
|
@@ -244,19 +249,24 @@ public class ChannelServiceImpl implements ChannelService {
|
|
|
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
|
|
|
factory.setServiceClass(NciicServicesPortType.class);// 设置请求接口
|
|
|
factory.setAddress(url);
|
|
|
+
|
|
|
NciicServicesPortType nciicServices = (NciicServicesPortType) factory.create(); // 创建客户端对象
|
|
|
// 设置客户端的配置信息,超时等.
|
|
|
Client proxy = ClientProxy.getClient(nciicServices);
|
|
|
+ common(request,proxy);
|
|
|
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
|
|
|
+
|
|
|
HTTPClientPolicy policy = new HTTPClientPolicy();
|
|
|
policy.setConnectionTimeout(outTime); // 连接超时时间
|
|
|
policy.setReceiveTimeout(outTime);// 请求超时时间.
|
|
|
+ policy.setConnection(ConnectionType.CLOSE);
|
|
|
conduit.setClient(policy);
|
|
|
String paramXml = SjjhConstant.TWO_ELEMENTS_XML_TEMPLATE
|
|
|
.replace("{fsd}", requestObject.getIdCode().substring(0, 6))
|
|
|
.replace("{ywlx}", SjjhConstant.PARAMETER_YWLX)
|
|
|
.replace("{idCode}", requestObject.getIdCode())
|
|
|
.replace("{name}", requestObject.getName());
|
|
|
+
|
|
|
String result = nciicServices.nciicCheck(SjjhConstant.TWO_ELEMENTS_SECRET_KEY,paramXml);
|
|
|
// String result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><RESPONSE errorcode=\"-20\" code=\"0\" countrows=\"1\"><ROWS><ROW><ErrorCode>-20</ErrorCode><ErrorMsg>计费失败,请与管理员联系(errorcode=-20)!</ErrorMsg></ROW></ROWS></RESPONSE>";
|
|
|
log.info("twoElementsCheck上游返回xml:{}", result);
|
|
@@ -633,10 +643,12 @@ public class ChannelServiceImpl implements ChannelService {
|
|
|
NciicServicesPortType nciicServices = (NciicServicesPortType) factory.create(); // 创建客户端对象
|
|
|
// 设置客户端的配置信息,超时等.
|
|
|
Client proxy = ClientProxy.getClient(nciicServices);
|
|
|
+ common(request,proxy);
|
|
|
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
|
|
|
HTTPClientPolicy policy = new HTTPClientPolicy();
|
|
|
policy.setConnectionTimeout(outTime); // 连接超时时间
|
|
|
policy.setReceiveTimeout(outTime);// 请求超时时间.
|
|
|
+ policy.setConnection(ConnectionType.CLOSE);
|
|
|
conduit.setClient(policy);
|
|
|
String paramXml = SjjhConstant.PHOTO_IDENTITY_XML_TEMPLATE
|
|
|
.replace("{fsd}", idCode.substring(0, 6))
|
|
@@ -785,10 +797,12 @@ public class ChannelServiceImpl implements ChannelService {
|
|
|
NciicServicesPortType nciicServices = (NciicServicesPortType) factory.create(); // 创建客户端对象
|
|
|
// 设置客户端的配置信息,超时等.
|
|
|
Client proxy = ClientProxy.getClient(nciicServices);
|
|
|
+ common(request,proxy);
|
|
|
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
|
|
|
HTTPClientPolicy policy = new HTTPClientPolicy();
|
|
|
policy.setConnectionTimeout(outTime); // 连接超时时间
|
|
|
policy.setReceiveTimeout(outTime);// 请求超时时间.
|
|
|
+ policy.setConnection(ConnectionType.CLOSE);
|
|
|
conduit.setClient(policy);
|
|
|
String paramXml = SjjhConstant.PHOTO_IDENTITY_XML_TEMPLATE
|
|
|
.replace("{fsd}", idCode.substring(0, 6))
|
|
@@ -1056,10 +1070,12 @@ public class ChannelServiceImpl implements ChannelService {
|
|
|
NciicServicesPortType nciicServices = (NciicServicesPortType) factory.create(); // 创建客户端对象
|
|
|
// 设置客户端的配置信息,超时等.
|
|
|
Client proxy = ClientProxy.getClient(nciicServices);
|
|
|
+ common(request,proxy);
|
|
|
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
|
|
|
HTTPClientPolicy policy = new HTTPClientPolicy();
|
|
|
policy.setConnectionTimeout(outTime); // 连接超时时间
|
|
|
policy.setReceiveTimeout(outTime);// 请求超时时间.
|
|
|
+ policy.setConnection(ConnectionType.CLOSE);
|
|
|
conduit.setClient(policy);
|
|
|
|
|
|
|
|
@@ -1149,10 +1165,12 @@ public class ChannelServiceImpl implements ChannelService {
|
|
|
NciicServicesPortType nciicServices = (NciicServicesPortType) factory.create(); // 创建客户端对象
|
|
|
// 设置客户端的配置信息,超时等.
|
|
|
Client proxy = ClientProxy.getClient(nciicServices);
|
|
|
+ common(request,proxy);
|
|
|
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
|
|
|
HTTPClientPolicy policy = new HTTPClientPolicy();
|
|
|
policy.setConnectionTimeout(outTime); // 连接超时时间
|
|
|
policy.setReceiveTimeout(outTime);// 请求超时时间.
|
|
|
+ policy.setConnection(ConnectionType.CLOSE);
|
|
|
conduit.setClient(policy);
|
|
|
|
|
|
|
|
@@ -1299,7 +1317,7 @@ public class ChannelServiceImpl implements ChannelService {
|
|
|
notifySms.setCount(0);
|
|
|
Timer timer =new Timer();
|
|
|
log.info("test..................,notify:{}",notifySms);
|
|
|
- timer.schedule(new NotifyThread(notifySms),1*60*1000);
|
|
|
+ timer.schedule(new NotifyThread(notifySms),1*60*1000L);
|
|
|
}
|
|
|
/* public void norify(String channelId,int type){
|
|
|
boolean flag = stringRedisTemplate.boundHashOps(Constant.rx_warn_key).putIfAbsent("sign","1");
|
|
@@ -1364,10 +1382,12 @@ public class ChannelServiceImpl implements ChannelService {
|
|
|
NciicServicesPortType nciicServices = (NciicServicesPortType) factory.create(); // 创建客户端对象
|
|
|
// 设置客户端的配置信息,超时等.
|
|
|
Client proxy = ClientProxy.getClient(nciicServices);
|
|
|
+ common(request,proxy);
|
|
|
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
|
|
|
HTTPClientPolicy policy = new HTTPClientPolicy();
|
|
|
policy.setConnectionTimeout(outTime); // 连接超时时间
|
|
|
policy.setReceiveTimeout(outTime);// 请求超时时间.
|
|
|
+ policy.setConnection(ConnectionType.CLOSE);
|
|
|
conduit.setClient(policy);
|
|
|
|
|
|
String paramXml = SjjhConstant.PHOTO_IDENTITY_XML_TEMPLATE_V3
|
|
@@ -1450,12 +1470,16 @@ public class ChannelServiceImpl implements ChannelService {
|
|
|
NciicServicesPortType nciicServices = (NciicServicesPortType) factory.create(); // 创建客户端对象
|
|
|
// 设置客户端的配置信息,超时等.
|
|
|
Client proxy = ClientProxy.getClient(nciicServices);
|
|
|
+
|
|
|
+ common(request,proxy);
|
|
|
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
|
|
|
HTTPClientPolicy policy = new HTTPClientPolicy();
|
|
|
policy.setConnectionTimeout(outTime); // 连接超时时间
|
|
|
policy.setReceiveTimeout(outTime);// 请求超时时间.
|
|
|
+ policy.setConnection(ConnectionType.CLOSE);
|
|
|
conduit.setClient(policy);
|
|
|
|
|
|
+
|
|
|
String paramXml = SjjhConstant.PHOTO_IDENTITY_XML_TEMPLATE_V4
|
|
|
.replace("{fsd}", idCode.substring(0, 6))
|
|
|
.replace("{ywlx}", SjjhConstant.PARAMETER_YWLX_YTST)
|
|
@@ -1477,4 +1501,127 @@ public class ChannelServiceImpl implements ChannelService {
|
|
|
request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
return ret;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ChannelTypeHandleResponseObject photoIdentityCheckV5New(HttpServletRequest request, String customBody, int outTime, String decodeType) {
|
|
|
+ ChannelTypeHandleResponseObject ret = new ChannelTypeHandleResponseObject();
|
|
|
+ ret.setIsCharge(Constant.INTERFACE_QUERY_NO_FEE);
|
|
|
+ ret.setCode(Constant.SUCCESS);
|
|
|
+ String upstreamCode = "" + Constant.LOG_UPSTREAM_DEFAULT_RESPONSE_CODE;
|
|
|
+ request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
+ String returnType = request.getHeader(Constant.CUSTOMER_RETURN_TYPE_PARA);
|
|
|
+ if (StringUtils.isBlank(returnType)) {
|
|
|
+ returnType = Constant.CUSTOMER_RETURN_ZW;
|
|
|
+ }
|
|
|
+ if (outTime <= SjjhConstant.PARA_ZERO) {
|
|
|
+ outTime = Constant.HTTPCLIENT_CONNECTTIMEOUT;
|
|
|
+ }
|
|
|
+ log.info("supplier10000043.photoIdentityCheckV5New---customBody={},outTime={}", customBody, outTime);
|
|
|
+ if (!decodeType.equals(SjjhConstant.DECODE_TYPE_COMMON)) {
|
|
|
+ customBody = decodeParams(ret, returnType, customBody, decodeType);
|
|
|
+ if (StringUtils.isBlank(customBody)) {
|
|
|
+ ret.setCode(Constant.SUCCESS);
|
|
|
+ request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ JSONObject jsonObject = JSON.parseObject(customBody);
|
|
|
+ String name = jsonObject.getString("name");//requestObject.getName();
|
|
|
+ String idCode = jsonObject.getString("idCode");
|
|
|
+ String photo = jsonObject.getString("photo");
|
|
|
+ customBody = null;
|
|
|
+ jsonObject.put("photo", "图片base64");
|
|
|
+ request.setAttribute(Constant.CHANNEL_LOG_QUERY,
|
|
|
+ Base64.encodeBase64String(jsonObject.toJSONString().getBytes(SjjhConstant.PARA_ENCODE)));
|
|
|
+ jsonObject = null;
|
|
|
+
|
|
|
+
|
|
|
+ if(!checkParm(name,idCode,returnType,ret)){
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
|
|
|
+ factory.setServiceClass(NciicServicesPortType.class);// 设置请求接口
|
|
|
+ factory.setAddress(urlV5);
|
|
|
+ NciicServicesPortType nciicServices = (NciicServicesPortType) factory.create(); // 创建客户端对象
|
|
|
+ // 设置客户端的配置信息,超时等.
|
|
|
+ Client proxy = ClientProxy.getClient(nciicServices);
|
|
|
+
|
|
|
+ common(request,proxy);
|
|
|
+ HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
|
|
|
+ HTTPClientPolicy policy = new HTTPClientPolicy();
|
|
|
+ policy.setConnectionTimeout(outTime); // 连接超时时间
|
|
|
+ policy.setReceiveTimeout(outTime);// 请求超时时间.
|
|
|
+ policy.setConnection(ConnectionType.CLOSE);
|
|
|
+ conduit.setClient(policy);
|
|
|
+
|
|
|
+
|
|
|
+ String paramXml = SjjhConstant.PHOTO_IDENTITY_XML_TEMPLATE_V5
|
|
|
+ .replace("{fsd}", idCode.substring(0, 6))
|
|
|
+ .replace("{ywlx}", SjjhConstant.PARAMETER_YWLX_RS)
|
|
|
+ .replace("{idCode}", idCode)
|
|
|
+ .replace("{name}", name)
|
|
|
+ .replace("{photo}", photo);
|
|
|
+ String result = nciicServices.nciicCompare(SjjhConstant.PHOTO_IDENTITY_SECRET_KEY_V5,paramXml);
|
|
|
+ log.info("photoIdentityCheck上游返回xml:{}", result);
|
|
|
+ upstreamCode = setPhotoIdentityCheckResponse(ret, returnType, result);
|
|
|
+ }catch (WebServiceException exception){
|
|
|
+ log.info("supplier10000043.photoIdentityCheckV5New接口-WebServiceException:{}", exception);
|
|
|
+ ErrorUtils.captureException(exception);
|
|
|
+ ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
+ } catch (Exception ioe) {
|
|
|
+ log.info("supplier10000043.photoIdentityCheckV5New接口-Exception:{}", ioe);
|
|
|
+ ErrorUtils.captureException(ioe);
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
+ }
|
|
|
+ request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String setPhotoIdentityCheckResponse(ChannelTypeHandleResponseObject ret, String returnType, String responseXml) {
|
|
|
+ String resultCode;
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (responseXml.contains(SjjhConstant.RESULT_NOT_FIND)) {
|
|
|
+ resultCode = SjjhConstant.REQUEST_NOT_FIND;
|
|
|
+ setNotFindResponse(ret, returnType);
|
|
|
+ }else if (responseXml.contains(SjjhConstant.ERROR_CODE)) {
|
|
|
+ resultCode = setErrorResponse(ret, returnType, responseXml);
|
|
|
+ } else if (responseXml.contains(SjjhConstant.ERROR_MESSAGE)) {
|
|
|
+ resultCode = SjjhConstant.REQUEST_ERROR;
|
|
|
+ setPhotoIdentityErrorResponse(ret, returnType, responseXml);
|
|
|
+ } else {
|
|
|
+ resultCode = SjjhConstant.REQUEST_SUCCESS;
|
|
|
+ setPhotoIdentityCheckSuccessResponse(ret, returnType, responseXml);
|
|
|
+ }
|
|
|
+ ret.setCode(Constant.SUCCESS);
|
|
|
+ } catch (JAXBException jaxb) {
|
|
|
+ resultCode = SjjhConstant.PARSE_FAILURE;
|
|
|
+ log.info("supplier10000043.setPhotoIdentityCheckResponse接口-解析上游返回xml失败:{}", jaxb.getMessage());
|
|
|
+ ErrorUtils.captureException(jaxb);
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
+ if (Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
|
|
|
+ ret.setResultCode(Constant.JK_RETURN_CODE_OTHER_ERROR);
|
|
|
+ } else {
|
|
|
+ ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
+ }
|
|
|
+ ret.setResultBody(Constant.OTHER_ERROR);
|
|
|
+ ret.setResultDesc(Constant.OTHER_ERROR);
|
|
|
+ }
|
|
|
+ return resultCode;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void common(HttpServletRequest request,Client proxy){
|
|
|
+ String traceId = request.getHeader(headerTraceId);
|
|
|
+ String channelId = request.getHeader(headerchannelId);
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, List<String>> headers = new HashMap<>();
|
|
|
+ headers.put(headerTraceId, Arrays.asList(traceId));
|
|
|
+ headers.put(headerchannelId, Arrays.asList(channelId));
|
|
|
+
|
|
|
+ proxy.getRequestContext().put(Message.PROTOCOL_HEADERS, headers);
|
|
|
+ }
|
|
|
}
|