Explorar el Código

增加接口:INTEST二要素

15810770710@163.com hace 2 años
padre
commit
42d47cc5a2

+ 32 - 0
src/main/java/info/aspirecn/iov/sjjh/supplier10000043/action/ChannelAction.java

@@ -789,4 +789,36 @@ public class ChannelAction {
         request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
         return ret;
     }
+
+    @ApiOperation(value = "INTEST身份证二要素接口-new", notes = "")
+    @PostMapping(value = "/twoElementsCheckV3.do")
+    public ChannelTypeHandleResponseObject twoElementsCheckV3(
+            @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
+            @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime", required = true) int outTime,
+            @ApiParam(value = "请求参数JSON串") @RequestParam(name = "customBody", required = true) String customBody) {
+        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
+                .getRequest();
+
+        //调用servicevalidateCompositeIdentityInfo
+        ChannelTypeHandleResponseObject ret = channelService.twoElementsCheckV3(request, customBody, outTime, SjjhConstant.DECODE_TYPE_COMMON);
+
+        //把接口参数、调用结果和是否收费放入访问日志中
+        if (ret.getCode() != Constant.SUCCESS) {
+            request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_ERROR_CODE);
+        } else {
+            request.setAttribute(SjjhConstant.Charge_Log_ResponseCode, Constant.CHANNEL_LOG_SUCCESS_CODE);
+        }
+        request.setAttribute(SjjhConstant.Charge_Log_Key, ret.getIsCharge());
+
+        try {
+            request.setAttribute(Constant.CHANNEL_LOG_QUERY,
+                    Base64.encodeBase64String(customBody.getBytes(SjjhConstant.PARA_ENCODE)));
+
+        } catch (Exception ex) {
+            ErrorUtils.captureException(ex);
+            log.error("twoElementsCheckV3.encodeBase64String.Exception=", ex);
+        }
+        request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
+        return ret;
+    }
 }

+ 8 - 0
src/main/java/info/aspirecn/iov/sjjh/supplier10000043/constant/SjjhConstant.java

@@ -150,4 +150,12 @@ public class SjjhConstant {
             "x9.;s?/*;7z?d?v?jKlKvXk\\r?x?v\\mQtYjAn?x\\HOHH2F-PC+#]MM6%l?a?ma*)i?v`}LwW[Yj]t?x?vMo[y_d`VSb^kXaUk:bAh(" +
             "t2v?g?g/p?v-c]fVecZCjGjXeYsZp?x?vMbMo?j+q?v%aCw\\hOa_f[lHmCnUy?x?vbX\\t`CRbQrZtTk`8WtKfVt?x$rIh@eLnZp?x*u7" +
             "m5b?f?v*nSqUcKcTj%u?v?jUmV;A;DlQrP;SwXkRiHgKb?x?v$sLzEdYyHf[qYa]r?x";
+    public static String TWO_ELEMENTS_XML_TEMPLATE_V3 = "<ROWS><INFO><SBM>北京英泰思特科技有限公司</SBM></INFO>" +
+            "<ROW><GMSFHM>公民身份号码</GMSFHM><XM>姓名</XM></ROW>" +
+            "<ROW FSD=\"{fsd}\" YWLX=\"{ywlx}\"><GMSFHM>{idCode}</GMSFHM><XM>{name}</XM></ROW></ROWS>";
+    public static final String TWO_ELEMENTS_SECRET_KEY_V3 = "?v>x]4N2J5?[HH0*_=EM.R/F^Z?c8y5b?k?h?obS=%\\Ccz/F)PC9ah1&?c" +
+            "`SMaCxa9.d?z?x?N?vBgBsFnTkTy]gZ[?x?vSmXsUjaV_w];_t` ?x8bX;EfGgUk?x?g=f8g?m?gb#?v?jDhDdPtXi?x0dbLb9b0Jg?x3c8" +
+            ".?/?m$w/[?v?jJ;NmHxc6?x?vZz_eHxHd?xHXGV*$ce0#IXc/LB?.*[*;<g?/?v&/GoQt[lVl?x:mO[BvSzIybNWr_fGv6.Da-i?g?g?g?g" +
+            ":m?jZa]iUmDeD;DsEeKh>z6ab0Ak.x?x?v2oF;KrFvXaWpDaFzMc?x$r\\h@nLpWx`8UwHfDf_kY[Si?x?va6IpRuAn+q5b?g?g.i$r&/b3" +
+            "[dWpFc?x?v?jHuHf_fYhRuHsYiWp];QeMc?x?v?jRpa7RkYiVr_dPq)e";
 }

+ 1 - 0
src/main/java/info/aspirecn/iov/sjjh/supplier10000043/constant/SupplierProperties.java

@@ -25,4 +25,5 @@ public class SupplierProperties {
     private long url5PhotoUp;
     private long url6PhotoUp;
     private long identityInfoV2Up;
+    private long identityInfoV3Up;
 }

+ 10 - 0
src/main/java/info/aspirecn/iov/sjjh/supplier10000043/service/ChannelService.java

@@ -126,4 +126,14 @@ public interface ChannelService {
      * @return
      */
     ChannelTypeHandleResponseObject twoElementsCheckV2(HttpServletRequest request, String customBody, int outTime, String decodeType);
+
+    /**
+     * 二要素cxf调用方式-英泰斯特
+     *
+     * @param request
+     * @param customBody
+     * @param outTime
+     * @return
+     */
+    ChannelTypeHandleResponseObject twoElementsCheckV3(HttpServletRequest request, String customBody, int outTime, String decodeType);
 }

+ 86 - 0
src/main/java/info/aspirecn/iov/sjjh/supplier10000043/service/ChannelServiceImpl.java

@@ -102,6 +102,8 @@ public class ChannelServiceImpl implements ChannelService {
     private String[] sensitive;
     @Value("${supplier.identityInfoV2Url}")
     private String identityInfoV2Url;
+    @Value("${supplier.identityInfoV3Url}")
+    private String identityInfoV3Url;
     @Autowired
     SupplierProperties supplierProperties;
     @Autowired
@@ -1868,4 +1870,88 @@ public class ChannelServiceImpl implements ChannelService {
         request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
         return ret;
     }
+
+    @Override
+    public ChannelTypeHandleResponseObject twoElementsCheckV3(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);
+        String channelId = request.getHeader("channelId");
+        if (StringUtils.isBlank(returnType)) {
+            returnType = Constant.CUSTOMER_RETURN_ZW;
+        }
+        if (outTime <= SjjhConstant.PARA_ZERO) {
+            outTime = Constant.HTTPCLIENT_CONNECTTIMEOUT;
+        }
+        log.info("supplier10000043.twoElementsCheckV3---customBody={},outTime={}", customBody, outTime);
+        String key="identityInfoIntest"+twoElementsMethod;
+        LocalDateTime now = LocalDateTime.now();
+        String ymd = dateTimeFormatter.format(now);
+        String hashKey = "043-"+ymd;
+        boolean flag = checkVisitCount(hashKey,key,supplierProperties.getIdentityInfoV3Up(),channelId);
+        if(!flag){
+            countOver(ret,Constant.CUSTOMER_RETURN_JK);
+            return ret;
+        }
+        if (!decodeType.equals(SjjhConstant.DECODE_TYPE_COMMON)) {
+            customBody = decodeParams(ret, returnType, customBody, decodeType);
+            if (StringUtils.isBlank(customBody)) {
+                ret.setCode(Constant.SUCCESS);
+                reduceVisitCount(hashKey,key);
+                request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
+                return ret;
+            }
+        }
+        try {
+            TwoElementsRequestObject requestObject = objectMapper.readValue(customBody,
+                    TwoElementsRequestObject.class);
+            log.info("supplier10000043.twoElementsCheckV3---requestObject={}", requestObject);
+            // 参数校验
+            if (!validateRequestParams(ret, returnType, requestObject)) {
+                ret.setCode(Constant.SUCCESS);
+                reduceVisitCount(hashKey,key);
+                request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
+                return ret;
+            }
+
+            JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+            factory.setServiceClass(NciicServicesPortType.class);// 设置请求接口
+            factory.setAddress(identityInfoV3Url);
+
+            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_V3
+                    .replace("{fsd}", requestObject.getIdCode().substring(0, 6))
+                    .replace("{ywlx}", SjjhConstant.PARAMETER_YWLX_YTST)
+                    .replace("{idCode}", requestObject.getIdCode())
+                    .replace("{name}", requestObject.getName());
+
+            String result = nciicServices.nciicCheck(SjjhConstant.TWO_ELEMENTS_SECRET_KEY_V3,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);
+            upstreamCode = setTwoElementsCheckResponse(ret, returnType, result);
+        } catch (WebServiceException ste) {
+            log.info("supplier10000043.twoElementsCheckV3接口-SocketTimeoutException:", ste);
+            ErrorUtils.captureException(ste);
+            ret.setCode(Constant.REQUEST_TIMEOUT);
+        } catch (Exception ioe) {
+            log.info("supplier10000043.twoElementsCheckV3接口-Exception:", ioe);
+            ErrorUtils.captureException(ioe);
+            ret.setCode(Constant.FAIL);
+        }
+        request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
+        return ret;
+    }
 }

+ 2 - 0
src/main/resources/config/application.yml

@@ -99,5 +99,7 @@ supplier:
   sensitive:
   identityInfoV2Url: http://8.140.178.39:8888/nciic/nciic_ws/services/NciicServices
   identityInfoV2Up: 49000
+  identityInfoV3Url: http://47.93.191.209:8888/nciic/nciic_ws/services/NciicServices
+  identityInfoV3Up: 98000
 swagger:
   show: true