|
@@ -0,0 +1,438 @@
|
|
|
|
+package info.aspirecn.rdc.iov.sjjh.servicenode.supplier.jk.service.impl;
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
+import com.google.common.base.Preconditions;
|
|
|
|
+import info.aspirecn.iov.sjjh.commons.lang.ChannelTypeHandleResponseObject;
|
|
|
|
+import info.aspirecn.iov.sjjh.commons.lang.Constant;
|
|
|
|
+import info.aspirecn.iov.sjjh.commons.lang.Md5Util;
|
|
|
|
+import info.aspirecn.iov.sjjh.commons.lang.PatternTools;
|
|
|
|
+import info.aspirecn.rdc.aspirecloud.node.except.utils.ErrorUtils;
|
|
|
|
+import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.jk.SjjhConstant;
|
|
|
|
+import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.jk.service.JKChannelService;
|
|
|
|
+import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.jk.utils.SupplierProperties;
|
|
|
|
+import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.jk.vo.*;
|
|
|
|
+import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.jk_interface.vo.CustomBodyObject;
|
|
|
|
+import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.jk_interface.vo.EncryptionMobileCheckResponseObject;
|
|
|
|
+import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.jk_interface.vo.EncryptionResponseObject;
|
|
|
|
+import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.jk_interface.vo.ResponseObject;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import okhttp3.*;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.StopWatch;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import javax.validation.ConstraintViolation;
|
|
|
|
+import javax.validation.Validation;
|
|
|
|
+import javax.validation.Validator;
|
|
|
|
+import javax.validation.ValidatorFactory;
|
|
|
|
+import java.net.SocketTimeoutException;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author jianggang
|
|
|
|
+ * @Date 2018/10/24 14:40:13
|
|
|
|
+ * @Description
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+@Slf4j
|
|
|
|
+public class JKChannelServiceImpl implements JKChannelService {
|
|
|
|
+ @Autowired
|
|
|
|
+ private ObjectMapper objectMapper;
|
|
|
|
+ @Value("${custom.url}")
|
|
|
|
+ private String url;
|
|
|
|
+ @Value("${custom.api}")
|
|
|
|
+ private String api;
|
|
|
|
+ @Value("${custom.appKey}")
|
|
|
|
+ private String appKey;
|
|
|
|
+ @Value("${custom.secretKey}")
|
|
|
|
+ private String sKey;
|
|
|
|
+ @Value("${custom.mortgage-api}")
|
|
|
|
+ private String mortgageApi;
|
|
|
|
+ @Value("${custom.url-new}")
|
|
|
|
+ private String newUrl;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private SupplierProperties supplierProperties;
|
|
|
|
+
|
|
|
|
+ private static final ConnectionPool POOL = new ConnectionPool(4000,
|
|
|
|
+ 5, TimeUnit.MINUTES);
|
|
|
|
+ private OkHttpClient client = new OkHttpClient.Builder().build();
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseObject sendTwoParamIdCardRequest(String channelId,Integer outTime,String customBody) {
|
|
|
|
+ StopWatch watch = new StopWatch();
|
|
|
|
+ watch.start();
|
|
|
|
+ TwoParamIdCardResponseObject responseObject = new TwoParamIdCardResponseObject();
|
|
|
|
+ ResponseObject res = new ResponseObject();
|
|
|
|
+ OkHttpClient okHttpClient;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Preconditions.checkNotNull(channelId,"通道id为空");
|
|
|
|
+ Preconditions.checkNotNull(customBody,"请求json字符串为空");
|
|
|
|
+
|
|
|
|
+// //通道id匹配错误
|
|
|
|
+// if (!channelId.equals(Constant.JK_IDCARD_CHANNEL_ID)) {
|
|
|
|
+// res.setCode(Constant.CHANNEL_ID_NO_MATCH);
|
|
|
|
+// res.setIsCharge(Constant.INTERFACE_QUERY_NO_FEE);
|
|
|
|
+// return res;
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+ /**模拟返回*/
|
|
|
|
+ if(Integer.valueOf(supplierProperties.getSleepTime())==50000){
|
|
|
|
+ res.setIsCharge(Constant.INTERFACE_QUERY_FEE);
|
|
|
|
+ res.setCode(Constant.SUCCESS);
|
|
|
|
+ TwoParamIdCardResponseObject twoParamIdCardResponseObject = new TwoParamIdCardResponseObject();
|
|
|
|
+ twoParamIdCardResponseObject.setCode(200);
|
|
|
|
+ twoParamIdCardResponseObject.setResult("101");
|
|
|
|
+ res.setResultBody(twoParamIdCardResponseObject);
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**模拟错误*/
|
|
|
|
+ if(Integer.valueOf(supplierProperties.getSleepTime())==20000){
|
|
|
|
+ throw new IllegalArgumentException();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**模拟超时*/
|
|
|
|
+ if(outTime < Integer.valueOf(supplierProperties.getSleepTime())){
|
|
|
|
+ log.error("simulation SocketTimeoutException--->outTime:{}--->sleepTime:{}",outTime,supplierProperties.getSleepTime());
|
|
|
|
+ throw new SocketTimeoutException();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
|
+ CustomBodyObject customBodyObject = mapper.readValue(customBody,CustomBodyObject.class);
|
|
|
|
+ Preconditions.checkNotNull(customBodyObject.getName(),"姓名不能为空");
|
|
|
|
+ Preconditions.checkNotNull(customBodyObject.getIdCode(),"身份证不能为空");
|
|
|
|
+
|
|
|
|
+ if(outTime == null && outTime <= 0){
|
|
|
|
+ outTime = Constant.HTTPCLIENT_CONNECTTIMEOUT;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ okHttpClient = client.newBuilder()
|
|
|
|
+ .connectTimeout(outTime,TimeUnit.MILLISECONDS)
|
|
|
|
+ .writeTimeout(outTime,TimeUnit.MILLISECONDS)
|
|
|
|
+ .readTimeout(outTime,TimeUnit.MILLISECONDS)
|
|
|
|
+ .connectionPool(POOL)
|
|
|
|
+ .build();
|
|
|
|
+ res.setIsCharge(Constant.INTERFACE_QUERY_NO_FEE);
|
|
|
|
+ res.setCode(Constant.FAIL);
|
|
|
|
+ String url = supplierProperties.getUrl()+"?cname="+customBodyObject.getName()+"&cid="+customBodyObject.getIdCode();
|
|
|
|
+ Request request = new Request.Builder()
|
|
|
|
+ .url(url)
|
|
|
|
+ .build();
|
|
|
|
+ StopWatch watch1 = new StopWatch();
|
|
|
|
+ watch1.start();
|
|
|
|
+ Response response = okHttpClient.newCall(request).execute();
|
|
|
|
+ String responseJson = response.body().string();
|
|
|
|
+ log.info("---->上游返回结果{}",responseJson);
|
|
|
|
+ watch1.stop();
|
|
|
|
+ log.info("upStream request time : {}",watch1.getTotalTimeSeconds());
|
|
|
|
+ if(response.code()==200){
|
|
|
|
+ res.setCode(Constant.SUCCESS);
|
|
|
|
+ responseObject = mapper.readValue(responseJson, TwoParamIdCardResponseObject.class);
|
|
|
|
+ res.setResultBody(responseObject);
|
|
|
|
+ //判断是否计费
|
|
|
|
+ if (responseObject.getCode() == 200) {
|
|
|
|
+ res.setIsCharge(Constant.INTERFACE_QUERY_FEE);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }catch (SocketTimeoutException e) {
|
|
|
|
+ log.error("SocketTimeoutException message:{}",e);
|
|
|
|
+ ErrorUtils.captureException(e);
|
|
|
|
+ res.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
|
+ res.setIsCharge(Constant.INTERFACE_QUERY_NO_FEE);
|
|
|
|
+ return res;
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ log.error("Exception message:{}",e);
|
|
|
|
+ ErrorUtils.captureException(e);
|
|
|
|
+ res.setCode(Constant.FAIL);
|
|
|
|
+ res.setIsCharge(Constant.INTERFACE_QUERY_NO_FEE);
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+ watch.stop();
|
|
|
|
+ log.info("service request time : {}",watch.getTotalTimeSeconds());
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public EncryptionResponseObject encryptionMobileCheck(String customBody,int outTime){
|
|
|
|
+ EncryptionResponseObject ret = new EncryptionResponseObject();
|
|
|
|
+ try {
|
|
|
|
+ if(outTime <= 0) {
|
|
|
|
+ outTime = Constant.HTTPCLIENT_CONNECTTIMEOUT;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ log.info("encryptionMobileCheck---customBody={},outTime={}",customBody,outTime);
|
|
|
|
+ JsonResolveObject jsonResolveObject = objectMapper.readValue(customBody,
|
|
|
|
+ JsonResolveObject.class);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ log.info("encryptionMobileCheck---requestObject={}",jsonResolveObject);
|
|
|
|
+ String name = jsonResolveObject.getName();
|
|
|
|
+ String idCode = jsonResolveObject.getIdCode();
|
|
|
|
+ String mobile = jsonResolveObject.getMobile();
|
|
|
|
+
|
|
|
|
+ EncryptionMobileCheckRequestObject requestObject = new EncryptionMobileCheckRequestObject();
|
|
|
|
+ requestObject.setApi(api);
|
|
|
|
+ requestObject.setAppKey(appKey);
|
|
|
|
+ requestObject.setAppSecret(sKey);
|
|
|
|
+
|
|
|
|
+ EncryptionMobileCheckRequestChildObject requestChildObject = new EncryptionMobileCheckRequestChildObject();
|
|
|
|
+ requestChildObject.setEncrypt(SjjhConstant.ENCRYPTION_SHA256);
|
|
|
|
+ requestChildObject.setId_number(idCode);
|
|
|
|
+ requestChildObject.setMobile(mobile);
|
|
|
|
+ requestChildObject.setName(name);
|
|
|
|
+ String sign = Md5Util.encrypt32("appSecret="+ sKey +"&enctype=" + SjjhConstant.ENCRYPTION_SHA256
|
|
|
|
+ +"&id_number="+ idCode +"&mobile="+ mobile +"&name="+ name);
|
|
|
|
+ requestChildObject.setSign(sign);
|
|
|
|
+ requestObject.setData(objectMapper.writeValueAsString(requestChildObject));
|
|
|
|
+ String jsonStr = objectMapper.writeValueAsString(requestObject);
|
|
|
|
+ log.info("调用三要素加密接口时传的JSON:"+jsonStr);
|
|
|
|
+ MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
|
|
|
|
+ RequestBody requestBody = RequestBody.create(mediaType, jsonStr);
|
|
|
|
+
|
|
|
|
+ Request request = new Request.Builder().post(requestBody).url(url).build();
|
|
|
|
+ OkHttpClient httpClient = client.newBuilder()
|
|
|
|
+ .connectTimeout(outTime, TimeUnit.MILLISECONDS)
|
|
|
|
+ .readTimeout(outTime, TimeUnit.MILLISECONDS)
|
|
|
|
+ .writeTimeout(outTime, TimeUnit.MILLISECONDS)
|
|
|
|
+ .build();
|
|
|
|
+ Response response = httpClient.newCall(request).execute();
|
|
|
|
+ String responseContext = response.body().string();
|
|
|
|
+ log.info("三要素加密版responseContext={}",responseContext);
|
|
|
|
+
|
|
|
|
+ EncryptionMobileCheckResponseObject responseObject = objectMapper.readValue(responseContext,
|
|
|
|
+ EncryptionMobileCheckResponseObject.class);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //返回结果中的code为200时,data为1或0时收费
|
|
|
|
+ if(responseObject != null) {
|
|
|
|
+ boolean bool = SjjhConstant.RETURN_SUCCESS.equals(responseObject.getCode())
|
|
|
|
+ && (SjjhConstant.QUERY_IDENTICAL.equalsIgnoreCase(responseObject.getData())
|
|
|
|
+ || SjjhConstant.QUERY_NO_IDENTICAL.equalsIgnoreCase(responseObject.getData()));
|
|
|
|
+ if(bool) {
|
|
|
|
+ ret.setIsCharge(Constant.INTERFACE_QUERY_FEE);
|
|
|
|
+ }
|
|
|
|
+ ret.setCode(Constant.SUCCESS);
|
|
|
|
+ ret.setMessage("查询成功");
|
|
|
|
+ ret.setResultBody(responseObject);
|
|
|
|
+ response.close();
|
|
|
|
+ } else {
|
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
|
+ ret.setIsCharge(Constant.INTERFACE_QUERY_NO_FEE);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } catch(SocketTimeoutException ste) {
|
|
|
|
+ ErrorUtils.captureException(ste);
|
|
|
|
+ ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
|
+ ret.setMessage("接口调用超时");
|
|
|
|
+ ret.setIsCharge(Constant.INTERFACE_QUERY_NO_FEE);
|
|
|
|
+ } catch(Exception ioe) {
|
|
|
|
+ ErrorUtils.captureException(ioe);
|
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
|
+ ret.setMessage("接口调用失败");
|
|
|
|
+ ret.setIsCharge(Constant.INTERFACE_QUERY_NO_FEE);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ChannelTypeHandleResponseObject vehicleMortgage(HttpServletRequest request, String customBody, int outTime) {
|
|
|
|
+ ChannelTypeHandleResponseObject ret = new ChannelTypeHandleResponseObject();
|
|
|
|
+ ret.setIsCharge(Constant.INTERFACE_QUERY_NO_FEE);
|
|
|
|
+ String upstreamCode = Constant.LOG_UPSTREAM_DEFAULT_RESPONSE_CODE;
|
|
|
|
+ String returnType = request.getHeader(Constant.CUSTOMER_RETURN_TYPE_PARA);
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isBlank(returnType)) {
|
|
|
|
+ returnType = Constant.CUSTOMER_RETURN_ZW;
|
|
|
|
+ }
|
|
|
|
+ if (outTime <= 0) {
|
|
|
|
+ outTime = Constant.HTTPCLIENT_CONNECTTIMEOUT;
|
|
|
|
+ }
|
|
|
|
+ log.info("vehicleMortgage---customBody={},outTime={}", customBody, outTime);
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ VehicleMortgageJsonResolveObject jsonResolveObject = objectMapper.readValue(customBody, VehicleMortgageJsonResolveObject.class);
|
|
|
|
+ //参数校验
|
|
|
|
+ if (!validateVehicleMortgageParams(ret, returnType, jsonResolveObject)) {
|
|
|
|
+ ret.setCode(Constant.SUCCESS);
|
|
|
|
+ request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(jsonResolveObject));
|
|
|
|
+ jsonObject.put("vehicleIdentificationNumber", jsonResolveObject.getVin().substring(jsonResolveObject.getVin().length()-6));
|
|
|
|
+ VehicleMortgageRequestObject requestObject = new VehicleMortgageRequestObject();
|
|
|
|
+ requestObject.setApi(mortgageApi);
|
|
|
|
+ requestObject.setAppKey(appKey);
|
|
|
|
+ requestObject.setAppSecret(sKey);
|
|
|
|
+ requestObject.setData(jsonObject.toJSONString());
|
|
|
|
+
|
|
|
|
+ MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
|
|
|
|
+ RequestBody requestBody = RequestBody.create(mediaType, JSON.toJSONString(requestObject));
|
|
|
|
+ Request okRequest = new Request.Builder()
|
|
|
|
+ .post(requestBody)
|
|
|
|
+ .url(newUrl)
|
|
|
|
+ .build();
|
|
|
|
+ OkHttpClient client = new OkHttpClient.Builder()
|
|
|
|
+ .connectTimeout(outTime, TimeUnit.MILLISECONDS)
|
|
|
|
+ .readTimeout(outTime, TimeUnit.MILLISECONDS)
|
|
|
|
+ .writeTimeout(outTime, TimeUnit.MILLISECONDS)
|
|
|
|
+ .build();
|
|
|
|
+ Response response = client.newCall(okRequest).execute();
|
|
|
|
+ String responseContext = "";
|
|
|
|
+ if (response.body() != null) {
|
|
|
|
+ responseContext = response.body().string();
|
|
|
|
+ }
|
|
|
|
+ log.info("supplier10000001.vehicleMortgage接口responseContext={}", responseContext);
|
|
|
|
+ JKResponseObject responseObject = objectMapper.readValue(responseContext, JKResponseObject.class);
|
|
|
|
+ log.info("supplier10000001.vehicleMortgage接口responseObject={}", responseObject);
|
|
|
|
+ if (responseObject != null) {
|
|
|
|
+ ret.setCode(Constant.SUCCESS);
|
|
|
|
+ setVehicleMortgageResponse(ret, returnType, responseObject);
|
|
|
|
+ upstreamCode = String.valueOf(responseObject.getCode());
|
|
|
|
+ response.close();
|
|
|
|
+ } else {
|
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
|
+ }
|
|
|
|
+ } catch (SocketTimeoutException ste) {
|
|
|
|
+ ErrorUtils.captureException(ste);
|
|
|
|
+ log.info("supplier10000001.vehicleMortgage接口SocketTimeoutException={}", ste);
|
|
|
|
+ ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
|
+ } catch (Exception ioe) {
|
|
|
|
+ ErrorUtils.captureException(ioe);
|
|
|
|
+ log.info("supplier10000001.vehicleMortgage接口Exception={}", ioe);
|
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //上游返回码
|
|
|
|
+ request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+ private void setVehicleMortgageResponse(ChannelTypeHandleResponseObject ret, String returnType, JKResponseObject responseObject) {
|
|
|
|
+ boolean isCharge = responseObject != null
|
|
|
|
+ && (responseObject.getCode().equals(SjjhConstant.RETURN_SUCCESS)
|
|
|
|
+ && (responseObject.getData().equals(SjjhConstant.RESPONSE_DATA_1)
|
|
|
|
+ || responseObject.getData().equals(SjjhConstant.RESPONSE_DATA_2)));
|
|
|
|
+ if (isCharge) {
|
|
|
|
+ ret.setIsCharge(Constant.INTERFACE_QUERY_FEE);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (Constant.CUSTOMER_RETURN_JK.equals(returnType)) {
|
|
|
|
+ if (responseObject.getCode().equals(SjjhConstant.RETURN_SUCCESS) && responseObject.getData().equals(SjjhConstant.RESPONSE_DATA_1)) {
|
|
|
|
+ JSONObject msgObject = JSONObject.parseObject(responseObject.getMsg());
|
|
|
|
+ String mortgageFlag = String.valueOf(msgObject.get("DYBJ"));
|
|
|
|
+ if (mortgageFlag.equals(SjjhConstant.RESPONSE_DYBJ_0)) {
|
|
|
|
+ // 未抵押
|
|
|
|
+ ret.setResultCode(Constant.JK_RETURN_CODE_1171);
|
|
|
|
+ ret.setResultBody(Constant.RETURN_MESSAGE_111);
|
|
|
|
+ ret.setResultDesc(Constant.RETURN_MESSAGE_111);
|
|
|
|
+ } else if (mortgageFlag.equals(SjjhConstant.RESPONSE_DYBJ_1)) {
|
|
|
|
+ // 抵押
|
|
|
|
+ ret.setResultCode(Constant.JK_RETURN_CODE_1172);
|
|
|
|
+ ret.setResultBody(Constant.RETURN_MESSAGE_112);
|
|
|
|
+ ret.setResultDesc(Constant.RETURN_MESSAGE_112);
|
|
|
|
+ } else {
|
|
|
|
+ // 质押
|
|
|
|
+ ret.setResultCode(Constant.JK_RETURN_CODE_1173);
|
|
|
|
+ ret.setResultBody(Constant.RETURN_MESSAGE_113);
|
|
|
|
+ ret.setResultDesc(Constant.RETURN_MESSAGE_113);
|
|
|
|
+ }
|
|
|
|
+ } else if (responseObject.getCode().equals(SjjhConstant.RETURN_SUCCESS) && responseObject.getData().equals(SjjhConstant.RESPONSE_DATA_2)) {
|
|
|
|
+ // 库无
|
|
|
|
+ ret.setResultCode(Constant.JK_RETURN_CODE_NO_INFO);
|
|
|
|
+ ret.setResultBody(Constant.UN_FIND_NUM);
|
|
|
|
+ ret.setResultDesc(Constant.UN_FIND_NUM);
|
|
|
|
+ } else {
|
|
|
|
+ // 查询错误
|
|
|
|
+ ret.setResultCode(Constant.JK_RETURN_CODE_OTHER_ERROR);
|
|
|
|
+ ret.setResultBody(Constant.OTHER_ERROR);
|
|
|
|
+ ret.setResultDesc(Constant.OTHER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (responseObject.getCode().equals(SjjhConstant.RETURN_SUCCESS) && responseObject.getData().equals(SjjhConstant.RESPONSE_DATA_1)) {
|
|
|
|
+ JSONObject msgObject = JSONObject.parseObject(responseObject.getMsg());
|
|
|
|
+ String mortgageFlag = String.valueOf(msgObject.get("DYBJ"));
|
|
|
|
+ if (mortgageFlag.equals(SjjhConstant.RESPONSE_DYBJ_0)) {
|
|
|
|
+ // 未抵押
|
|
|
|
+ ret.setResultCode(Constant.ZW_RETURN_CODE_111);
|
|
|
|
+ ret.setResultBody(Constant.RETURN_MESSAGE_111);
|
|
|
|
+ ret.setResultDesc(Constant.RETURN_MESSAGE_111);
|
|
|
|
+ } else if (mortgageFlag.equals(SjjhConstant.RESPONSE_DYBJ_1)) {
|
|
|
|
+ // 抵押
|
|
|
|
+ ret.setResultCode(Constant.ZW_RETURN_CODE_112);
|
|
|
|
+ ret.setResultBody(Constant.RETURN_MESSAGE_112);
|
|
|
|
+ ret.setResultDesc(Constant.RETURN_MESSAGE_112);
|
|
|
|
+ } else {
|
|
|
|
+ // 质押
|
|
|
|
+ ret.setResultCode(Constant.ZW_RETURN_CODE_113);
|
|
|
|
+ ret.setResultBody(Constant.RETURN_MESSAGE_113);
|
|
|
|
+ ret.setResultDesc(Constant.RETURN_MESSAGE_113);
|
|
|
|
+ }
|
|
|
|
+ } else if (responseObject.getCode().equals(SjjhConstant.RETURN_SUCCESS) && responseObject.getData().equals(SjjhConstant.RESPONSE_DATA_2)) {
|
|
|
|
+ // 库无
|
|
|
|
+ ret.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
|
+ ret.setResultBody(Constant.UN_FIND_NUM);
|
|
|
|
+ ret.setResultDesc(Constant.UN_FIND_NUM);
|
|
|
|
+ } else {
|
|
|
|
+ // 查询错误
|
|
|
|
+ ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
|
+ ret.setResultBody(Constant.OTHER_ERROR);
|
|
|
|
+ ret.setResultDesc(Constant.OTHER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean validateVehicleMortgageParams(ChannelTypeHandleResponseObject ret, String returnType, VehicleMortgageJsonResolveObject jsonResolveObject) {
|
|
|
|
+ if (!validateParamNullValue(jsonResolveObject)) {
|
|
|
|
+ // 参数名错误
|
|
|
|
+ if (Constant.CUSTOMER_RETURN_ZW.equals(returnType)) {
|
|
|
|
+ ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
|
|
|
|
+ } else {
|
|
|
|
+ ret.setResultCode(Constant.JK_RETURN_CODE_INVALID_PARAMETER);
|
|
|
|
+ }
|
|
|
|
+ ret.setResultBody(Constant.PARAMETER_NAME_ERROR);
|
|
|
|
+ ret.setResultDesc(Constant.PARAMETER_NAME_ERROR);
|
|
|
|
+ return false;
|
|
|
|
+ } else if (StringUtils.isBlank(jsonResolveObject.getPlateNumber())
|
|
|
|
+ || StringUtils.isBlank(jsonResolveObject.getEngineNumber())
|
|
|
|
+ || StringUtils.isBlank(jsonResolveObject.getVin())
|
|
|
|
+ || !PatternTools.checkResult(Constant.PATTERN_CAR_NUMBER_REGEX, jsonResolveObject.getPlateNumber())
|
|
|
|
+ || !Pattern.compile("[a-zA-Z0-9]{17}").matcher(jsonResolveObject.getVin()).matches()
|
|
|
|
+ || !Pattern.compile("^[A-Za-z0-9]+$").matcher(jsonResolveObject.getEngineNumber()).matches()) {
|
|
|
|
+ if (Constant.CUSTOMER_RETURN_ZW.equals(returnType)) {
|
|
|
|
+ ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
|
|
|
|
+ } else {
|
|
|
|
+ ret.setResultCode(Constant.JK_RETURN_CODE_INVALID_PARAMETER);
|
|
|
|
+ }
|
|
|
|
+ ret.setResultDesc(Constant.INVALID_PARAMETER);
|
|
|
|
+ ret.setResultBody(Constant.INVALID_PARAMETER);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean validateParamNullValue(Object jsonResolveObject) {
|
|
|
|
+ ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
|
|
|
|
+ Validator validator = vf.getValidator();
|
|
|
|
+ Set<ConstraintViolation<Object>> set = validator.validate(jsonResolveObject);
|
|
|
|
+ for (ConstraintViolation<Object> con : set) {
|
|
|
|
+ if (StringUtils.isNotBlank(con.getMessage())) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+}
|