|
@@ -7,11 +7,7 @@ import info.aspirecn.iov.sjjh.commons.lang.ChannelTypeHandleResponseObject;
|
|
import info.aspirecn.iov.sjjh.commons.lang.Constant;
|
|
import info.aspirecn.iov.sjjh.commons.lang.Constant;
|
|
import info.aspirecn.iov.sjjh.config.SupplierConfig;
|
|
import info.aspirecn.iov.sjjh.config.SupplierConfig;
|
|
import info.aspirecn.iov.sjjh.constant.Constants;
|
|
import info.aspirecn.iov.sjjh.constant.Constants;
|
|
-import info.aspirecn.iov.sjjh.entity.RequestObject;
|
|
|
|
-import info.aspirecn.iov.sjjh.entity.Response;
|
|
|
|
-import info.aspirecn.iov.sjjh.entity.VehicleHistoryPositionRequestParam;
|
|
|
|
-import info.aspirecn.iov.sjjh.entity.VehicleHistoryPositionResponse;
|
|
|
|
-import info.aspirecn.iov.sjjh.entity.geocoding.GeocodingResponseObject;
|
|
|
|
|
|
+import info.aspirecn.iov.sjjh.entity.*;
|
|
import info.aspirecn.iov.sjjh.enums.VehicleHistoryPositionQueryType;
|
|
import info.aspirecn.iov.sjjh.enums.VehicleHistoryPositionQueryType;
|
|
import info.aspirecn.iov.sjjh.service.VehicleService;
|
|
import info.aspirecn.iov.sjjh.service.VehicleService;
|
|
import info.aspirecn.iov.sjjh.util.DateUtil;
|
|
import info.aspirecn.iov.sjjh.util.DateUtil;
|
|
@@ -20,7 +16,6 @@ import info.aspirecn.iov.sjjh.util.ValidateParamUtil;
|
|
import info.aspirecn.rdc.aspirecloud.node.except.utils.ErrorUtils;
|
|
import info.aspirecn.rdc.aspirecloud.node.except.utils.ErrorUtils;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import okhttp3.OkHttpClient;
|
|
import okhttp3.OkHttpClient;
|
|
-import okhttp3.Request;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -28,10 +23,7 @@ import org.springframework.stereotype.Service;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
-import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.Map;
|
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author xusonglin
|
|
* @author xusonglin
|
|
@@ -75,7 +67,6 @@ public class VehicleServiceImpl implements VehicleService {
|
|
|
|
|
|
// 参数校验
|
|
// 参数校验
|
|
if (!ValidateParamUtil.validateRequestParams(requestParam)) {
|
|
if (!ValidateParamUtil.validateRequestParams(requestParam)) {
|
|
- ret.setCode(Constant.FAIL);
|
|
|
|
ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
|
|
ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
|
|
ret.setResultBody(Constant.INVALID_PARAMETER);
|
|
ret.setResultBody(Constant.INVALID_PARAMETER);
|
|
ret.setResultDesc(Constant.INVALID_PARAMETER);
|
|
ret.setResultDesc(Constant.INVALID_PARAMETER);
|
|
@@ -200,7 +191,7 @@ public class VehicleServiceImpl implements VehicleService {
|
|
}
|
|
}
|
|
|
|
|
|
boolean checkResultA = false;
|
|
boolean checkResultA = false;
|
|
- // todo 这个集合为了查看位置是否正确
|
|
|
|
|
|
+ // 这个集合为了查看位置是否正确
|
|
List<VehicleHistoryPositionResponse.Data> verificationPositionListA = new ArrayList<>();
|
|
List<VehicleHistoryPositionResponse.Data> verificationPositionListA = new ArrayList<>();
|
|
for (int i = 0; i < checkTimeListA.size()-1; i++) {
|
|
for (int i = 0; i < checkTimeListA.size()-1; i++) {
|
|
for (VehicleHistoryPositionResponse.Data position : positionList) {
|
|
for (VehicleHistoryPositionResponse.Data position : positionList) {
|
|
@@ -222,7 +213,7 @@ public class VehicleServiceImpl implements VehicleService {
|
|
}
|
|
}
|
|
|
|
|
|
boolean checkResultB = false;
|
|
boolean checkResultB = false;
|
|
- // todo 这个集合为了查看位置是否正确
|
|
|
|
|
|
+ // 这个集合为了查看位置是否正确
|
|
List<VehicleHistoryPositionResponse.Data> verificationPositionListB = new ArrayList<>();
|
|
List<VehicleHistoryPositionResponse.Data> verificationPositionListB = new ArrayList<>();
|
|
for (int i = 0; i < checkTimeListB.size()-1; i++) {
|
|
for (int i = 0; i < checkTimeListB.size()-1; i++) {
|
|
for (VehicleHistoryPositionResponse.Data position : positionList) {
|
|
for (VehicleHistoryPositionResponse.Data position : positionList) {
|
|
@@ -258,7 +249,7 @@ public class VehicleServiceImpl implements VehicleService {
|
|
upstreamCode = positionResponse.getResultCode();
|
|
upstreamCode = positionResponse.getResultCode();
|
|
if (positionResponse.getResultCode().equals(Constants.RESULT_CODE_0)) {
|
|
if (positionResponse.getResultCode().equals(Constants.RESULT_CODE_0)) {
|
|
if (positionResponse.getData() != null && positionResponse.getData().size() > 0) {
|
|
if (positionResponse.getData() != null && positionResponse.getData().size() > 0) {
|
|
- String result = vehiclePositionConsistencyCheck(positionResponse.getData(), requestParam);
|
|
|
|
|
|
+ String result = vehicleHistoryPositionQuery(positionResponse.getData(), requestParam);
|
|
if (StringUtils.isBlank(result)) {
|
|
if (StringUtils.isBlank(result)) {
|
|
ret.setResultCode(Constant.MATCH_CODE);
|
|
ret.setResultCode(Constant.MATCH_CODE);
|
|
ret.setResultBody(Constant.MATCH);
|
|
ret.setResultBody(Constant.MATCH);
|
|
@@ -323,7 +314,7 @@ public class VehicleServiceImpl implements VehicleService {
|
|
tempStartTime = DateUtil.addMinutes(tempStartTime, 30);
|
|
tempStartTime = DateUtil.addMinutes(tempStartTime, 30);
|
|
}
|
|
}
|
|
|
|
|
|
- // todo 这个集合为了查看位置是否正确
|
|
|
|
|
|
+ // 这个集合为了查看位置是否正确
|
|
List<VehicleHistoryPositionResponse.Data> verificationPositionListA = new ArrayList<>();
|
|
List<VehicleHistoryPositionResponse.Data> verificationPositionListA = new ArrayList<>();
|
|
for (int i = 0; i < checkTimeListA.size()-1; i++) {
|
|
for (int i = 0; i < checkTimeListA.size()-1; i++) {
|
|
for (VehicleHistoryPositionResponse.Data position : positionList) {
|
|
for (VehicleHistoryPositionResponse.Data position : positionList) {
|
|
@@ -338,7 +329,7 @@ public class VehicleServiceImpl implements VehicleService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // todo 这个集合为了查看位置是否正确
|
|
|
|
|
|
+ // 这个集合为了查看位置是否正确
|
|
List<VehicleHistoryPositionResponse.Data> verificationPositionListB = new ArrayList<>();
|
|
List<VehicleHistoryPositionResponse.Data> verificationPositionListB = new ArrayList<>();
|
|
for (int i = 0; i < checkTimeListB.size()-1; i++) {
|
|
for (int i = 0; i < checkTimeListB.size()-1; i++) {
|
|
for (VehicleHistoryPositionResponse.Data position : positionList) {
|
|
for (VehicleHistoryPositionResponse.Data position : positionList) {
|
|
@@ -354,4 +345,377 @@ public class VehicleServiceImpl implements VehicleService {
|
|
}
|
|
}
|
|
return "";
|
|
return "";
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ChannelTypeHandleResponseObject checkVehicleRoadTransport(HttpServletRequest request, String customBody, int outTime) {
|
|
|
|
+ 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);
|
|
|
|
+ if (outTime <= Constants.PARA_ZERO) {
|
|
|
|
+ outTime = Constant.HTTPCLIENT_CONNECTTIMEOUT;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ log.info("supplier-vehicle.checkVehicleRoadTransport---customBody={},outTime={}", customBody, outTime);
|
|
|
|
+ // 解析参数
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
+ VehicleRoadTransportPermitRequestParam requestParam;
|
|
|
|
+ try {
|
|
|
|
+ requestParam = objectMapper.readValue(customBody, VehicleRoadTransportPermitRequestParam.class);
|
|
|
|
+ } catch (IOException ioe) {
|
|
|
|
+ log.info("supplier-vehicle.checkVehicleRoadTransport-解析参数Exception:{}", ioe);
|
|
|
|
+ ErrorUtils.captureException(ioe);
|
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
|
+ ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
|
|
|
|
+ ret.setResultBody(Constant.INVALID_PARAMETER);
|
|
|
|
+ ret.setResultDesc(Constant.INVALID_PARAMETER);
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 参数校验
|
|
|
|
+ if (!ValidateParamUtil.validateRequestParams(requestParam)) {
|
|
|
|
+ ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
|
|
|
|
+ ret.setResultBody(Constant.INVALID_PARAMETER);
|
|
|
|
+ ret.setResultDesc(Constant.INVALID_PARAMETER);
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 接口调用
|
|
|
|
+ String responseContext = "";
|
|
|
|
+ try {
|
|
|
|
+ okhttp3.Response response = PostUtil.postString(supplierConfig.getVehicleRoadTransportUrl(), JSON.toJSONString(requestParam), outTime);
|
|
|
|
+ if (response.body() != null) {
|
|
|
|
+ responseContext = response.body().string();
|
|
|
|
+ upstreamCode = setVehicleRoadTransportResponse(ret, responseContext);
|
|
|
|
+ } else {
|
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
|
+ }
|
|
|
|
+ log.info("responseContext:{}", responseContext);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ log.info("supplier-vehicle.vehicleHistoryPositionQuery-IOException:{}", e);
|
|
|
|
+ ErrorUtils.captureException(e);
|
|
|
|
+ ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.info("supplier-vehicle.vehicleHistoryPositionQuery-Exception:{}", e);
|
|
|
|
+ ErrorUtils.captureException(e);
|
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String setVehicleRoadTransportResponse(ChannelTypeHandleResponseObject ret, String responseContext) {
|
|
|
|
+ String upstreamCode = "" + Constant.LOG_UPSTREAM_DEFAULT_RESPONSE_CODE;
|
|
|
|
+ RoadTransportPermitResponse responseObject = JSON.toJavaObject(JSON.parseObject(responseContext),
|
|
|
|
+ RoadTransportPermitResponse.class);
|
|
|
|
+ if (responseObject == null) {
|
|
|
|
+ ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
|
+ ret.setResultBody(Constant.OTHER_ERROR);
|
|
|
|
+ ret.setResultDesc(Constant.OTHER_ERROR);
|
|
|
|
+ return upstreamCode;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String resultCode = responseObject.getResultCode();
|
|
|
|
+ upstreamCode = resultCode;
|
|
|
|
+ List<String> errorList = new ArrayList<>();
|
|
|
|
+ if (resultCode.equals(Constants.CERTIFICATE_CHECK_RESULT_CODE_0)) {
|
|
|
|
+ if (responseObject.getData().getVerifyResultSet().get(0).getResult().equals("0")) {
|
|
|
|
+ // 一致
|
|
|
|
+ ret.setResultCode(Constant.MATCH_CODE);
|
|
|
|
+ ret.setResultBody(Constant.MATCH);
|
|
|
|
+ ret.setResultDesc(Constant.QUERY_SUCCESS);
|
|
|
|
+ } else {
|
|
|
|
+ // 不一致,返回具体不一致项
|
|
|
|
+ String errorInfo = responseObject.getData().getVerifyResultSet().get(0).getErrorInfo();
|
|
|
|
+ if (errorInfo.contains(Constants.UN_MATCH_VEHICLE_NUMBER)) {
|
|
|
|
+ errorList.add("vehicleNumber");
|
|
|
|
+ }
|
|
|
|
+ if (errorInfo.contains(Constants.UN_MATCH_ROAD_TRANSPORT_CERTIFICATE_NUMBER)) {
|
|
|
|
+ errorList.add("roadTransportCertificateNumber");
|
|
|
|
+ }
|
|
|
|
+ if (errorInfo.contains(Constants.UN_MATCH_CERTIFICATE_VALID_PERIOD_FROM)) {
|
|
|
|
+ errorList.add("roadTransportCertificateValidPeriodFrom");
|
|
|
|
+ }
|
|
|
|
+ if (errorInfo.contains(Constants.UN_MATCH_CERTIFICATE_VALID_PERIOD_TO)){
|
|
|
|
+ errorList.add("roadTransportCertificateValidPeriodTo");
|
|
|
|
+ }
|
|
|
|
+ ret.setResultCode(Constant.UN_MATCH_CODE);
|
|
|
|
+ ret.setResultBody(errorList);
|
|
|
|
+ ret.setResultDesc(Constant.QUERY_SUCCESS);
|
|
|
|
+ }
|
|
|
|
+ // 查询成功
|
|
|
|
+ ret.setIsCharge(Constant.IS_CHARGE);
|
|
|
|
+ upstreamCode = resultCode + "-" + responseObject.getData().getVerifyResultSet().get(0).getResult();
|
|
|
|
+ } else if (resultCode.equals(Constants.CERTIFICATE_CHECK_RESULT_CODE_110000)) {
|
|
|
|
+ // 库无
|
|
|
|
+ ret.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
|
+ ret.setResultBody(Constants.NO_RESULT);
|
|
|
|
+ ret.setResultDesc(Constants.NO_RESULT);
|
|
|
|
+ } else if (resultCode.equals(Constants.CERTIFICATE_CHECK_RESULT_CODE_140001)
|
|
|
|
+ || resultCode.equals(Constants.CERTIFICATE_CHECK_RESULT_CODE_140002)) {
|
|
|
|
+ // 参数错误
|
|
|
|
+ ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
|
|
|
|
+ ret.setResultBody(Constant.INVALID_PARAMETER);
|
|
|
|
+ ret.setResultDesc(Constant.INVALID_PARAMETER);
|
|
|
|
+ } else {
|
|
|
|
+ // 其他错误
|
|
|
|
+ ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
|
+ ret.setResultBody(Constant.OTHER_ERROR);
|
|
|
|
+ ret.setResultDesc(Constant.OTHER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ return upstreamCode;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ChannelTypeHandleResponseObject checkPersonQualificationCertificate(HttpServletRequest request, String customBody, int outTime) {
|
|
|
|
+ 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);
|
|
|
|
+ if (outTime <= Constants.PARA_ZERO) {
|
|
|
|
+ outTime = Constant.HTTPCLIENT_CONNECTTIMEOUT;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ log.info("supplier-vehicle.checkPersonQualificationCertificate---customBody={},outTime={}", customBody, outTime);
|
|
|
|
+ // 解析参数
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
+ PersonQualificationCertificateRequestParam requestParam;
|
|
|
|
+ try {
|
|
|
|
+ PersonQualificationCertificateRequestParam jsonObject = JSON.toJavaObject(JSON.parseObject(customBody), PersonQualificationCertificateRequestParam.class);
|
|
|
|
+ requestParam = objectMapper.readValue(customBody, PersonQualificationCertificateRequestParam.class);
|
|
|
|
+ } catch (IOException ioe) {
|
|
|
|
+ log.info("supplier-vehicle.checkPersonQualificationCertificate-解析参数Exception:{}", ioe);
|
|
|
|
+ ErrorUtils.captureException(ioe);
|
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
|
+ ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
|
|
|
|
+ ret.setResultBody(Constant.INVALID_PARAMETER);
|
|
|
|
+ ret.setResultDesc(Constant.INVALID_PARAMETER);
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 参数校验
|
|
|
|
+ if (!ValidateParamUtil.validateRequestParams(requestParam)) {
|
|
|
|
+ ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
|
|
|
|
+ ret.setResultBody(Constant.INVALID_PARAMETER);
|
|
|
|
+ ret.setResultDesc(Constant.INVALID_PARAMETER);
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 接口调用
|
|
|
|
+ String responseContext = "";
|
|
|
|
+ try {
|
|
|
|
+ okhttp3.Response response = PostUtil.postString(supplierConfig.getPersonQualificationUrl(), JSON.toJSONString(requestParam), outTime);
|
|
|
|
+ if (response.body() != null) {
|
|
|
|
+ responseContext = response.body().string();
|
|
|
|
+ upstreamCode = setPersonQualificationCertificateResponse(ret, responseContext);
|
|
|
|
+ } else {
|
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
|
+ }
|
|
|
|
+ log.info("responseContext:{}", responseContext);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ log.info("supplier-vehicle.checkPersonQualificationCertificate-IOException:{}", e);
|
|
|
|
+ ErrorUtils.captureException(e);
|
|
|
|
+ ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.info("supplier-vehicle.checkPersonQualificationCertificate-Exception:{}", e);
|
|
|
|
+ ErrorUtils.captureException(e);
|
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String setPersonQualificationCertificateResponse(ChannelTypeHandleResponseObject ret, String responseContext) {
|
|
|
|
+ String upstreamCode = "" + Constant.LOG_UPSTREAM_DEFAULT_RESPONSE_CODE;
|
|
|
|
+ RoadTransportPermitResponse responseObject = JSON.toJavaObject(JSON.parseObject(responseContext),
|
|
|
|
+ RoadTransportPermitResponse.class);
|
|
|
|
+ if (responseObject == null) {
|
|
|
|
+ ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
|
+ ret.setResultBody(Constant.OTHER_ERROR);
|
|
|
|
+ ret.setResultDesc(Constant.OTHER_ERROR);
|
|
|
|
+ return upstreamCode;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String resultCode = responseObject.getResultCode();
|
|
|
|
+ upstreamCode = resultCode;
|
|
|
|
+ List<String> errorList = new ArrayList<>();
|
|
|
|
+ if (resultCode.equals(Constants.CERTIFICATE_CHECK_RESULT_CODE_0)) {
|
|
|
|
+ if (responseObject.getData().getVerifyResultSet().get(0).getResult().equals("0")) {
|
|
|
|
+ // 一致
|
|
|
|
+ ret.setResultCode(Constant.MATCH_CODE);
|
|
|
|
+ ret.setResultBody(Constant.MATCH);
|
|
|
|
+ ret.setResultDesc(Constant.QUERY_SUCCESS);
|
|
|
|
+ } else {
|
|
|
|
+ // 不一致,返回具体不一致项
|
|
|
|
+ String errorInfo = responseObject.getData().getVerifyResultSet().get(0).getErrorInfo();
|
|
|
|
+ if (errorInfo.contains(Constants.UN_MATCH_DRIVER_NAME)) {
|
|
|
|
+ errorList.add("driverName");
|
|
|
|
+ }
|
|
|
|
+ if (errorInfo.contains(Constants.UN_MATCH_DRIVING_LICENSE)) {
|
|
|
|
+ errorList.add("drivingLicense");
|
|
|
|
+ }
|
|
|
|
+ if (errorInfo.contains(Constants.UN_MATCH_PROVINCE_CODE)) {
|
|
|
|
+ errorList.add("provinceCode");
|
|
|
|
+ }
|
|
|
|
+ if (errorInfo.contains(Constants.UN_MATCH_QUALIFICATION_CERTIFICATE)){
|
|
|
|
+ errorList.add("qualificationCertificate");
|
|
|
|
+ }
|
|
|
|
+ if (errorInfo.contains(Constants.UN_MATCH_QUALIFICATION_CERTIFICATE_FROM)){
|
|
|
|
+ errorList.add("qualificationCertificateValidPeriodFrom");
|
|
|
|
+ }
|
|
|
|
+ if (errorInfo.contains(Constants.UN_MATCH_QUALIFICATION_CERTIFICATE_TO)){
|
|
|
|
+ errorList.add("qualificationCertificateValidPeriodTo");
|
|
|
|
+ }
|
|
|
|
+ ret.setResultCode(Constant.UN_MATCH_CODE);
|
|
|
|
+ ret.setResultBody(errorList);
|
|
|
|
+ ret.setResultDesc(Constant.QUERY_SUCCESS);
|
|
|
|
+ }
|
|
|
|
+ // 查询成功
|
|
|
|
+ ret.setIsCharge(Constant.IS_CHARGE);
|
|
|
|
+ upstreamCode = resultCode + "-" + responseObject.getData().getVerifyResultSet().get(0).getResult();
|
|
|
|
+ } else if (resultCode.equals(Constants.CERTIFICATE_CHECK_RESULT_CODE_110000)) {
|
|
|
|
+ // 库无
|
|
|
|
+ ret.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
|
+ ret.setResultBody(Constants.NO_RESULT);
|
|
|
|
+ ret.setResultDesc(Constants.NO_RESULT);
|
|
|
|
+ } else if (resultCode.equals(Constants.CERTIFICATE_CHECK_RESULT_CODE_140001)
|
|
|
|
+ || resultCode.equals(Constants.CERTIFICATE_CHECK_RESULT_CODE_140002)) {
|
|
|
|
+ // 参数错误
|
|
|
|
+ ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
|
|
|
|
+ ret.setResultBody(Constant.INVALID_PARAMETER);
|
|
|
|
+ ret.setResultDesc(Constant.INVALID_PARAMETER);
|
|
|
|
+ } else {
|
|
|
|
+ // 其他错误
|
|
|
|
+ ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
|
+ ret.setResultBody(Constant.OTHER_ERROR);
|
|
|
|
+ ret.setResultDesc(Constant.OTHER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ return upstreamCode;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ChannelTypeHandleResponseObject checkEnterpriseRoadTransport(HttpServletRequest request, String customBody, int outTime) {
|
|
|
|
+ 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);
|
|
|
|
+ if (outTime <= Constants.PARA_ZERO) {
|
|
|
|
+ outTime = Constant.HTTPCLIENT_CONNECTTIMEOUT;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ log.info("supplier-vehicle.checkEnterpriseRoadTransport---customBody={},outTime={}", customBody, outTime);
|
|
|
|
+ // 解析参数
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
+ EnterpriseRoadTransportPermitRequestParam requestParam;
|
|
|
|
+ try {
|
|
|
|
+ requestParam = objectMapper.readValue(customBody, EnterpriseRoadTransportPermitRequestParam.class);
|
|
|
|
+ } catch (IOException ioe) {
|
|
|
|
+ log.info("supplier-vehicle.checkEnterpriseRoadTransport-解析参数Exception:{}", ioe);
|
|
|
|
+ ErrorUtils.captureException(ioe);
|
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
|
+ ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
|
|
|
|
+ ret.setResultBody(Constant.INVALID_PARAMETER);
|
|
|
|
+ ret.setResultDesc(Constant.INVALID_PARAMETER);
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 参数校验
|
|
|
|
+ if (!ValidateParamUtil.validateRequestParams(requestParam)) {
|
|
|
|
+ ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
|
|
|
|
+ ret.setResultBody(Constant.INVALID_PARAMETER);
|
|
|
|
+ ret.setResultDesc(Constant.INVALID_PARAMETER);
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 接口调用
|
|
|
|
+ String responseContext = "";
|
|
|
|
+ try {
|
|
|
|
+ okhttp3.Response response = PostUtil.postString(supplierConfig.getEnterpriseRoadTransportUrl(), JSON.toJSONString(requestParam), outTime);
|
|
|
|
+ if (response.body() != null) {
|
|
|
|
+ responseContext = response.body().string();
|
|
|
|
+ upstreamCode = setEnterpriseRoadTransportResponse(ret, responseContext);
|
|
|
|
+ } else {
|
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
|
+ }
|
|
|
|
+ log.info("responseContext:{}", responseContext);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ log.info("supplier-vehicle.checkEnterpriseRoadTransport-IOException:{}", e);
|
|
|
|
+ ErrorUtils.captureException(e);
|
|
|
|
+ ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.info("supplier-vehicle.checkEnterpriseRoadTransport-Exception:{}", e);
|
|
|
|
+ ErrorUtils.captureException(e);
|
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String setEnterpriseRoadTransportResponse(ChannelTypeHandleResponseObject ret, String responseContext) {
|
|
|
|
+ String upstreamCode = "" + Constant.LOG_UPSTREAM_DEFAULT_RESPONSE_CODE;
|
|
|
|
+ RoadTransportPermitResponse responseObject = JSON.toJavaObject(JSON.parseObject(responseContext),
|
|
|
|
+ RoadTransportPermitResponse.class);
|
|
|
|
+ if (responseObject == null) {
|
|
|
|
+ ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
|
+ ret.setResultBody(Constant.OTHER_ERROR);
|
|
|
|
+ ret.setResultDesc(Constant.OTHER_ERROR);
|
|
|
|
+ return upstreamCode;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String resultCode = responseObject.getResultCode();
|
|
|
|
+ upstreamCode = resultCode;
|
|
|
|
+ List<String> errorList = new ArrayList<>();
|
|
|
|
+ if (resultCode.equals(Constants.CERTIFICATE_CHECK_RESULT_CODE_0)) {
|
|
|
|
+ if (responseObject.getData().getVerifyResultSet().get(0).getResult().equals("0")) {
|
|
|
|
+ // 一致
|
|
|
|
+ ret.setResultCode(Constant.MATCH_CODE);
|
|
|
|
+ ret.setResultBody(Constant.MATCH);
|
|
|
|
+ ret.setResultDesc(Constant.QUERY_SUCCESS);
|
|
|
|
+ } else {
|
|
|
|
+ // 不一致,返回具体不一致项
|
|
|
|
+ String errorInfo = responseObject.getData().getVerifyResultSet().get(0).getErrorInfo();
|
|
|
|
+ if (errorInfo.contains(Constants.UN_MATCH_CARRIER)) {
|
|
|
|
+ errorList.add("carrier");
|
|
|
|
+ }
|
|
|
|
+ if (errorInfo.contains(Constants.UN_MATCH_PERMIT_NUMBER)) {
|
|
|
|
+ errorList.add("permitNumber");
|
|
|
|
+ }
|
|
|
|
+ if (errorInfo.contains(Constants.UN_MATCH_PERMIT_VALID_PERIOD_FROM)) {
|
|
|
|
+ errorList.add("permitValidPeriodFrom");
|
|
|
|
+ }
|
|
|
|
+ if (errorInfo.contains(Constants.UN_MATCH_PERMIT_VALID_PERIOD_TO)){
|
|
|
|
+ errorList.add("permitValidPeriodTo");
|
|
|
|
+ }
|
|
|
|
+ ret.setResultCode(Constant.UN_MATCH_CODE);
|
|
|
|
+ ret.setResultBody(errorList);
|
|
|
|
+ ret.setResultDesc(Constant.QUERY_SUCCESS);
|
|
|
|
+ }
|
|
|
|
+ // 查询成功
|
|
|
|
+ ret.setIsCharge(Constant.IS_CHARGE);
|
|
|
|
+ upstreamCode = resultCode + "-" + responseObject.getData().getVerifyResultSet().get(0).getResult();
|
|
|
|
+ } else if (resultCode.equals(Constants.CERTIFICATE_CHECK_RESULT_CODE_110000)) {
|
|
|
|
+ // 库无
|
|
|
|
+ ret.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
|
+ ret.setResultBody(Constants.NO_RESULT);
|
|
|
|
+ ret.setResultDesc(Constants.NO_RESULT);
|
|
|
|
+ } else if (resultCode.equals(Constants.CERTIFICATE_CHECK_RESULT_CODE_140001)
|
|
|
|
+ || resultCode.equals(Constants.CERTIFICATE_CHECK_RESULT_CODE_140002)) {
|
|
|
|
+ // 参数错误
|
|
|
|
+ ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
|
|
|
|
+ ret.setResultBody(Constant.INVALID_PARAMETER);
|
|
|
|
+ ret.setResultDesc(Constant.INVALID_PARAMETER);
|
|
|
|
+ } else {
|
|
|
|
+ // 其他错误
|
|
|
|
+ ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
|
+ ret.setResultBody(Constant.OTHER_ERROR);
|
|
|
|
+ ret.setResultDesc(Constant.OTHER_ERROR);
|
|
|
|
+ }
|
|
|
|
+ return upstreamCode;
|
|
|
|
+ }
|
|
}
|
|
}
|