|
@@ -81,7 +81,7 @@ public class VehicleServiceImpl implements VehicleService {
|
|
|
|
|
|
} else {
|
|
|
// 车辆线上线下一致性验证
|
|
|
- upstreamCode = vehiclePositionConsistencyTwoCheck(ret, outTime, requestParam);
|
|
|
+ upstreamCode = vehiclePositionConsistencyCheck(ret, outTime, requestParam);
|
|
|
}
|
|
|
|
|
|
request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
@@ -91,255 +91,230 @@ public class VehicleServiceImpl implements VehicleService {
|
|
|
/*----------------------------------------------------新增开始----------------------------------------------------*/
|
|
|
|
|
|
private String setVehicleHistoryPositionQueryResponse(ChannelTypeHandleResponseObject ret, int outTime,
|
|
|
- VehicleHistoryPositionRequestParam requestParam){
|
|
|
- String upstreamCode = "";
|
|
|
- String result = vehiclePositionConsistencyTwoCheck(ret, outTime, requestParam);
|
|
|
- if (Constants.RESULT_CODE_0.equals(result)) {
|
|
|
- // 接口调用
|
|
|
- Response response = new Response();
|
|
|
- try {
|
|
|
- RequestObject requestObject = new RequestObject();
|
|
|
- requestObject.setVehicleNumber(requestParam.getPlateNumber());
|
|
|
- requestObject.setLicensePlateTypeCode(requestParam.getPlateColor());
|
|
|
- requestObject.setStartTime(DateUtil.addHours(requestParam.getStartTime(), supplierConfig.getReduceHours()));
|
|
|
- requestObject.setEndTime(DateUtil.addHours(requestParam.getEndTime(), supplierConfig.getAddHours()));
|
|
|
- requestObject.setPartyFunctionCode(supplierConfig.getPartyFunctionCode());
|
|
|
- response = PostUtil.postString(supplierConfig.getHistoryPositionUrl(), JSON.toJSONString(requestObject),
|
|
|
- supplierConfig.getAppKey(), supplierConfig.getAppSecret(), outTime);
|
|
|
- log.info("supplier-vehicle.vehicleHistoryPositionQuery-responseStatus:{}", response.getStatusCode());
|
|
|
- log.info("supplier-vehicle.vehicleHistoryPositionQuery-responseBody:{}", response.getBody());
|
|
|
- if (response.getStatusCode() == Constants.STATUS_CODE_200) {
|
|
|
- VehicleHistoryPositionResponse positionResponse = JSON.toJavaObject(JSON.parseObject(response.getBody()),
|
|
|
- VehicleHistoryPositionResponse.class);
|
|
|
- upstreamCode = positionResponse.getResultCode();
|
|
|
- if (positionResponse.getResultCode().equals(Constants.RESULT_CODE_0)) {
|
|
|
- if (positionResponse.getData() != null && positionResponse.getData().size() > 0) {
|
|
|
- JSONObject vehicleLocationInfo = new JSONObject();
|
|
|
- vehicleLocationInfo.put("vehicleLocationInfo", positionResponse.getData());
|
|
|
- ret.setResultCode(Constant.MATCH_CODE);
|
|
|
- ret.setResultBody(vehicleLocationInfo);
|
|
|
- ret.setResultDesc(Constant.QUERY_SUCCESS);
|
|
|
- } else {
|
|
|
- ret.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
- ret.setResultBody(Constants.NO_RESULT);
|
|
|
- ret.setResultDesc(Constants.NO_RESULT);
|
|
|
- }
|
|
|
- ret.setIsCharge(Constant.IS_CHARGE);
|
|
|
- } else if (positionResponse.getResultCode().equals(Constants.RESULT_CODE_110000)) {
|
|
|
- ret.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
- ret.setResultBody(Constants.NO_RESULT);
|
|
|
- ret.setResultDesc(Constants.NO_RESULT);
|
|
|
- } else {
|
|
|
- ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
- ret.setResultBody(Constant.OTHER_ERROR);
|
|
|
- ret.setResultDesc(Constant.OTHER_ERROR);
|
|
|
- }
|
|
|
- } else {
|
|
|
- ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
- ret.setResultBody(Constant.OTHER_ERROR);
|
|
|
- ret.setResultDesc(Constant.OTHER_ERROR);
|
|
|
- upstreamCode += response.getStatusCode();
|
|
|
- }
|
|
|
- } 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);
|
|
|
- }
|
|
|
+ VehicleHistoryPositionRequestParam requestParam) {
|
|
|
+ String upstreamCode = vehiclePositionConsistencyCheck(ret, outTime, requestParam);
|
|
|
+ if (ret.getResultCode() != Constant.MATCH_CODE) {
|
|
|
+ return upstreamCode;
|
|
|
}
|
|
|
- return upstreamCode;
|
|
|
- }
|
|
|
-
|
|
|
- private String vehiclePositionConsistencyTwoCheck(ChannelTypeHandleResponseObject ret, int outTime,
|
|
|
- VehicleHistoryPositionRequestParam requestParam){
|
|
|
- ChannelTypeHandleResponseObject retA = new ChannelTypeHandleResponseObject();
|
|
|
- ChannelTypeHandleResponseObject retB = new ChannelTypeHandleResponseObject();
|
|
|
- String upstreamCodeA = "";
|
|
|
- String upstreamCodeB = "";
|
|
|
- String errMsgA = "loadingCountrySubdivisionCode";
|
|
|
- String errMsgB = "receiptCountrySubdivisionCode";
|
|
|
- /**
|
|
|
- * 1、云雁分调取A-到A+和B-到B+的轨迹,并取这两段轨迹中的每个点的行政区划代码合集X和合集Y
|
|
|
- * 2、将合集X分别与A点行政区划进行比对,只要有一点比对一致则视为此点核验通过
|
|
|
- * 3、将合集Y分别与B点行政区划进行比对,只要有一点比对一致则视为此点核验通过
|
|
|
- * 4、A点和B点均核验通过视为此核验项通过
|
|
|
- */
|
|
|
- // A-
|
|
|
- String startTimeA = DateUtil.addHours(requestParam.getStartTime(), supplierConfig.getReduceHours());
|
|
|
- // A+
|
|
|
- String endTimeA = DateUtil.addHours(requestParam.getStartTime(), supplierConfig.getAddHours());
|
|
|
-
|
|
|
- // B-
|
|
|
- String startTimeB = DateUtil.addHours(requestParam.getEndTime(), supplierConfig.getReduceHours());
|
|
|
- // B+
|
|
|
- String endTimeB = DateUtil.addHours(requestParam.getEndTime(), supplierConfig.getAddHours());
|
|
|
-
|
|
|
- // A段接口调用
|
|
|
- Response responseA = new Response();
|
|
|
+ // 接口调用
|
|
|
+ Response response;
|
|
|
try {
|
|
|
RequestObject requestObject = new RequestObject();
|
|
|
requestObject.setVehicleNumber(requestParam.getPlateNumber());
|
|
|
requestObject.setLicensePlateTypeCode(requestParam.getPlateColor());
|
|
|
- requestObject.setStartTime(startTimeA);
|
|
|
- requestObject.setEndTime(endTimeA);
|
|
|
+ requestObject.setStartTime(DateUtil.addHours(requestParam.getStartTime(), supplierConfig.getReduceHours()));
|
|
|
+ requestObject.setEndTime(DateUtil.addHours(requestParam.getEndTime(), supplierConfig.getAddHours()));
|
|
|
requestObject.setPartyFunctionCode(supplierConfig.getPartyFunctionCode());
|
|
|
- responseA = PostUtil.postString(supplierConfig.getHistoryPositionUrl(), JSON.toJSONString(requestObject),
|
|
|
+ response = PostUtil.postString(supplierConfig.getHistoryPositionUrl(), JSON.toJSONString(requestObject),
|
|
|
supplierConfig.getAppKey(), supplierConfig.getAppSecret(), outTime);
|
|
|
+ log.info("supplier-vehicle.vehicleHistoryPositionQuery-responseStatus:{}", response.getStatusCode());
|
|
|
+ log.info("supplier-vehicle.vehicleHistoryPositionQuery-responseBody:{}", response.getBody());
|
|
|
+ if (response.getStatusCode() == Constants.STATUS_CODE_200) {
|
|
|
+ VehicleHistoryPositionResponse positionResponse = JSON.toJavaObject(JSON.parseObject(response.getBody()),
|
|
|
+ VehicleHistoryPositionResponse.class);
|
|
|
+ upstreamCode = positionResponse.getResultCode();
|
|
|
+ if (positionResponse.getResultCode().equals(Constants.RESULT_CODE_0)) {
|
|
|
+ if (positionResponse.getData() != null && positionResponse.getData().size() > 0) {
|
|
|
+ JSONObject vehicleLocationInfo = new JSONObject();
|
|
|
+ vehicleLocationInfo.put("vehicleLocationInfo", positionResponse.getData());
|
|
|
+ ret.setResultBody(vehicleLocationInfo);
|
|
|
+ }
|
|
|
+ ret.setIsCharge(Constant.IS_CHARGE);
|
|
|
+ } else {
|
|
|
+ ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
+ ret.setResultBody(Constant.OTHER_ERROR);
|
|
|
+ ret.setResultDesc(Constant.OTHER_ERROR);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
+ ret.setResultBody(Constant.OTHER_ERROR);
|
|
|
+ ret.setResultDesc(Constant.OTHER_ERROR);
|
|
|
+ }
|
|
|
} catch (IOException e) {
|
|
|
- log.info("supplier-vehicle.vehicleHistoryAPositionQuery-IOException:{}", e);
|
|
|
+ log.info("supplier-vehicle.vehicleHistoryPositionQuery-IOException:{}", e);
|
|
|
ErrorUtils.captureException(e);
|
|
|
ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
} catch (Exception e) {
|
|
|
- log.info("supplier-vehicle.vehicleHistoryAPositionQuery-Exception:{}", e);
|
|
|
+ log.info("supplier-vehicle.vehicleHistoryPositionQuery-Exception:{}", e);
|
|
|
ErrorUtils.captureException(e);
|
|
|
ret.setCode(Constant.FAIL);
|
|
|
}
|
|
|
- List<String> errList = new ArrayList<>();
|
|
|
- if (responseA.getStatusCode() == Constants.STATUS_CODE_200) {
|
|
|
- VehicleHistoryPositionResponse positionResponseA = JSON.toJavaObject(JSON.parseObject(responseA.getBody()),
|
|
|
- VehicleHistoryPositionResponse.class);
|
|
|
- upstreamCodeA = positionResponseA.getResultCode();
|
|
|
- if (positionResponseA.getResultCode().equals(Constants.RESULT_CODE_0)) {
|
|
|
- if (positionResponseA.getData() != null && positionResponseA.getData().size() > 0) {
|
|
|
- String resultA = vehiclePositionConsistencyACheck(positionResponseA.getData(), requestParam);
|
|
|
- if (StringUtils.isBlank(resultA)) {
|
|
|
- retA.setResultCode(Constant.MATCH_CODE);
|
|
|
- retA.setResultBody(Constant.MATCH);
|
|
|
- retA.setResultDesc(Constant.QUERY_SUCCESS);
|
|
|
- } else {
|
|
|
- errList.add(resultA);
|
|
|
- retA.setResultCode(Constant.UN_MATCH_CODE);
|
|
|
- retA.setResultBody(errList);
|
|
|
- retA.setResultDesc(Constant.QUERY_SUCCESS);
|
|
|
- }
|
|
|
- } else {
|
|
|
- errList.add(errMsgA);
|
|
|
- retA.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
- retA.setResultBody(Constants.NO_RESULT);
|
|
|
- retA.setResultDesc(Constants.NO_RESULT);
|
|
|
- }
|
|
|
- retA.setIsCharge(Constant.IS_CHARGE);
|
|
|
- } else if (positionResponseA.getResultCode().equals(Constants.RESULT_CODE_110000)) {
|
|
|
- errList.add(errMsgA);
|
|
|
- retA.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
- retA.setResultBody(Constants.NO_RESULT);
|
|
|
- retA.setResultDesc(Constants.NO_RESULT);
|
|
|
- } else {
|
|
|
- retA.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
- retA.setResultBody(Constant.OTHER_ERROR);
|
|
|
- retA.setResultDesc(Constant.OTHER_ERROR);
|
|
|
- }
|
|
|
+ return upstreamCode;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer subdivisionCodeCheck(VehicleHistoryPositionRequestParam requestParam, String subdivisionCodeType, Integer outTime
|
|
|
+ , String upstreamCode) {
|
|
|
+ String startTime;
|
|
|
+ String endTime;
|
|
|
+ if (subdivisionCodeType.equals("loadingCountrySubdivisionCode")) {
|
|
|
+ // A-
|
|
|
+ startTime = DateUtil.addHours(requestParam.getStartTime(), supplierConfig.getReduceHours());
|
|
|
+ // A+
|
|
|
+ endTime = DateUtil.addHours(requestParam.getStartTime(), supplierConfig.getAddHours());
|
|
|
} else {
|
|
|
- retA.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
- retA.setResultBody(Constant.OTHER_ERROR);
|
|
|
- retA.setResultDesc(Constant.OTHER_ERROR);
|
|
|
- upstreamCodeA = Integer.toString(responseA.getStatusCode());
|
|
|
+ // B-
|
|
|
+ startTime = DateUtil.addHours(requestParam.getEndTime(), supplierConfig.getReduceHours());
|
|
|
+ // B+
|
|
|
+ endTime = DateUtil.addHours(requestParam.getEndTime(), supplierConfig.getAddHours());
|
|
|
}
|
|
|
- // B段接口调用
|
|
|
- Response responseB = new Response();
|
|
|
+ Response response;
|
|
|
try {
|
|
|
RequestObject requestObject = new RequestObject();
|
|
|
requestObject.setVehicleNumber(requestParam.getPlateNumber());
|
|
|
requestObject.setLicensePlateTypeCode(requestParam.getPlateColor());
|
|
|
- requestObject.setStartTime(startTimeB);
|
|
|
- requestObject.setEndTime(endTimeB);
|
|
|
+ requestObject.setStartTime(startTime);
|
|
|
+ requestObject.setEndTime(endTime);
|
|
|
requestObject.setPartyFunctionCode(supplierConfig.getPartyFunctionCode());
|
|
|
- responseB = PostUtil.postString(supplierConfig.getHistoryPositionUrl(), JSON.toJSONString(requestObject),
|
|
|
+ response = PostUtil.postString(supplierConfig.getHistoryPositionUrl(), JSON.toJSONString(requestObject),
|
|
|
supplierConfig.getAppKey(), supplierConfig.getAppSecret(), outTime);
|
|
|
} catch (IOException e) {
|
|
|
log.info("supplier-vehicle.vehicleHistoryAPositionQuery-IOException:{}", e);
|
|
|
ErrorUtils.captureException(e);
|
|
|
- ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
+ return Constants.REQUEST_TIMEOUT;
|
|
|
} catch (Exception e) {
|
|
|
log.info("supplier-vehicle.vehicleHistoryAPositionQuery-Exception:{}", e);
|
|
|
ErrorUtils.captureException(e);
|
|
|
- ret.setCode(Constant.FAIL);
|
|
|
+ return Constant.FAIL;
|
|
|
}
|
|
|
-
|
|
|
- if (responseB.getStatusCode() == Constants.STATUS_CODE_200) {
|
|
|
- VehicleHistoryPositionResponse positionResponseB = JSON.toJavaObject(JSON.parseObject(responseB.getBody()),
|
|
|
+ if (response.getStatusCode() == Constants.STATUS_CODE_200) {
|
|
|
+ VehicleHistoryPositionResponse positionResponse = JSON.toJavaObject(JSON.parseObject(response.getBody()),
|
|
|
VehicleHistoryPositionResponse.class);
|
|
|
- upstreamCodeB = positionResponseB.getResultCode();
|
|
|
- if (positionResponseB.getResultCode().equals(Constants.RESULT_CODE_0)) {
|
|
|
- if (positionResponseB.getData() != null && positionResponseB.getData().size() > 0) {
|
|
|
- String resultB = vehiclePositionConsistencyBCheck(positionResponseB.getData(), requestParam);
|
|
|
- if (StringUtils.isBlank(resultB)) {
|
|
|
- retB.setResultCode(Constant.MATCH_CODE);
|
|
|
- retB.setResultBody(Constant.MATCH);
|
|
|
- retB.setResultDesc(Constant.QUERY_SUCCESS);
|
|
|
+ upstreamCode = positionResponse.getResultCode();
|
|
|
+ if (positionResponse.getResultCode().equals(Constants.RESULT_CODE_0)) {
|
|
|
+ if (positionResponse.getData() != null && positionResponse.getData().size() > 0) {
|
|
|
+ boolean result;
|
|
|
+ if (subdivisionCodeType.equals("loadingCountrySubdivisionCode")) {
|
|
|
+ result = vehiclePositionConsistencyCheck(positionResponse.getData(), requestParam.getLoadingCountrySubdivisionCode());
|
|
|
} else {
|
|
|
- errList.add(resultB);
|
|
|
- retB.setResultCode(Constant.UN_MATCH_CODE);
|
|
|
- retB.setResultBody(errList);
|
|
|
- retB.setResultDesc(Constant.QUERY_SUCCESS);
|
|
|
+ result = vehiclePositionConsistencyCheck(positionResponse.getData(), requestParam.getReceiptCountrySubdivisionCode());
|
|
|
+ }
|
|
|
+ if (result) {
|
|
|
+ return Constant.MATCH_CODE;
|
|
|
+ } else {
|
|
|
+ return Constant.UN_MATCH_CODE;
|
|
|
}
|
|
|
} else {
|
|
|
- errList.add(errMsgB);
|
|
|
- retB.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
- retB.setResultBody(Constants.NO_RESULT);
|
|
|
- retB.setResultDesc(Constants.NO_RESULT);
|
|
|
+ return Constant.UN_FIND_NUM_CODE;
|
|
|
}
|
|
|
- ret.setIsCharge(Constant.IS_CHARGE);
|
|
|
- } else if (positionResponseB.getResultCode().equals(Constants.RESULT_CODE_110000)) {
|
|
|
- errList.add(errMsgB);
|
|
|
- retB.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
- retB.setResultBody(Constants.NO_RESULT);
|
|
|
- retB.setResultDesc(Constants.NO_RESULT);
|
|
|
+// retA.setIsCharge(Constant.IS_CHARGE);
|
|
|
+ } else if (positionResponse.getResultCode().equals(Constants.RESULT_CODE_110000)) {
|
|
|
+ return Constant.UN_FIND_NUM_CODE;
|
|
|
} else {
|
|
|
- retB.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
- retB.setResultBody(Constant.OTHER_ERROR);
|
|
|
- retB.setResultDesc(Constant.OTHER_ERROR);
|
|
|
+ return Constant.OTHER_ERROR_CODE;
|
|
|
}
|
|
|
} else {
|
|
|
- retB.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
- retB.setResultBody(Constant.OTHER_ERROR);
|
|
|
- retB.setResultDesc(Constant.OTHER_ERROR);
|
|
|
- upstreamCodeB = Integer.toString(responseA.getStatusCode());
|
|
|
+ return Constant.OTHER_ERROR_CODE;
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ private String vehiclePositionConsistencyCheck(ChannelTypeHandleResponseObject ret, int outTime,
|
|
|
+ VehicleHistoryPositionRequestParam requestParam) {
|
|
|
+ /**
|
|
|
+ * 1、云雁分调取A-到A+和B-到B+的轨迹,并取这两段轨迹中的每个点的行政区划代码合集X和合集Y
|
|
|
+ * 2、将合集X分别与A点行政区划进行比对,只要有一点比对一致则视为此点核验通过
|
|
|
+ * 3、将合集Y分别与B点行政区划进行比对,只要有一点比对一致则视为此点核验通过
|
|
|
+ * 4、A点和B点均核验通过视为此核验项通过
|
|
|
+ */
|
|
|
+ String upstreamCode = "" + Constant.LOG_UPSTREAM_DEFAULT_RESPONSE_CODE;
|
|
|
+ Integer loadingCountryResult = subdivisionCodeCheck(requestParam, "loadingCountrySubdivisionCode", outTime, upstreamCode);
|
|
|
|
|
|
- // A、B两点都比对通过
|
|
|
- if(retA.getResultCode()==Constant.MATCH_CODE&&retB.getResultCode()==Constant.MATCH_CODE){
|
|
|
+ if (loadingCountryResult == Constants.REQUEST_TIMEOUT) {
|
|
|
+ // 请求超时
|
|
|
+ ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
+ return upstreamCode;
|
|
|
+ }
|
|
|
+ if (loadingCountryResult == Constant.FAIL) {
|
|
|
+ // 请求异常
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
+ return upstreamCode;
|
|
|
+ }
|
|
|
+ if (loadingCountryResult == Constant.OTHER_ERROR_CODE) {
|
|
|
+ // 装货点(A点)调用失败
|
|
|
+ ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
+ ret.setResultBody(Constant.OTHER_ERROR);
|
|
|
+ ret.setResultDesc(Constant.OTHER_ERROR);
|
|
|
+ return upstreamCode;
|
|
|
+ }
|
|
|
+ Integer receiptCountryResult = subdivisionCodeCheck(requestParam, "receiptCountrySubdivisionCode", outTime, upstreamCode);
|
|
|
+ if (receiptCountryResult == Constants.REQUEST_TIMEOUT) {
|
|
|
+ // 请求超时
|
|
|
+ ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
+ return upstreamCode;
|
|
|
+ }
|
|
|
+ if (receiptCountryResult == Constant.FAIL) {
|
|
|
+ // 请求异常
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
+ return upstreamCode;
|
|
|
+ }
|
|
|
+ if (receiptCountryResult == Constant.OTHER_ERROR_CODE) {
|
|
|
+ // 卸货点(B点)调用失败
|
|
|
+ ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
+ ret.setResultBody(Constant.OTHER_ERROR);
|
|
|
+ ret.setResultDesc(Constant.OTHER_ERROR);
|
|
|
+ return upstreamCode;
|
|
|
+ }
|
|
|
+ if (loadingCountryResult == Constant.MATCH_CODE && receiptCountryResult == Constant.MATCH_CODE) {
|
|
|
+ // 装货点(A点)一致 且 卸货点(B点)一致;返回一致
|
|
|
ret.setResultCode(Constant.MATCH_CODE);
|
|
|
ret.setResultBody(Constant.MATCH);
|
|
|
- ret.setResultDesc(Constant.QUERY_SUCCESS);
|
|
|
- return upstreamCodeA;
|
|
|
+ ret.setResultDesc(Constant.MATCH);
|
|
|
+ ret.setIsCharge(Constant.IS_CHARGE);
|
|
|
+ return upstreamCode;
|
|
|
}
|
|
|
+ List<String> errorList = new ArrayList<>();
|
|
|
|
|
|
- // A点其他错误,直接返回A点错误
|
|
|
- if(retA.getResultCode()==Constant.OTHER_ERROR_CODE){
|
|
|
- ret.setResultCode(retA.getResultCode());
|
|
|
- ret.setResultDesc(retA.getResultDesc());
|
|
|
- ret.setResultBody(retA.getResultBody());
|
|
|
- return upstreamCodeA;
|
|
|
+ if (loadingCountryResult == Constant.UN_MATCH_CODE && receiptCountryResult == Constant.UN_MATCH_CODE) {
|
|
|
+ // 装货点(A点)结果为空 且 卸货点(B点)结果为空;返回查无
|
|
|
+ errorList.add("loadingCountrySubdivisionCode");
|
|
|
+ errorList.add("receiptCountrySubdivisionCode");
|
|
|
+ ret.setResultCode(Constant.UN_MATCH_CODE);
|
|
|
+ ret.setResultBody(errorList);
|
|
|
+ ret.setResultDesc(Constant.QUERY_SUCCESS);
|
|
|
+ return upstreamCode;
|
|
|
}
|
|
|
-
|
|
|
- // B点其他错误,直接返回B点错误
|
|
|
- if(retB.getResultCode()==Constant.OTHER_ERROR_CODE){
|
|
|
- ret.setResultCode(retB.getResultCode());
|
|
|
- ret.setResultDesc(retB.getResultDesc());
|
|
|
- ret.setResultBody(retB.getResultBody());
|
|
|
- return upstreamCodeB;
|
|
|
+ if (loadingCountryResult == Constant.UN_MATCH_CODE) {
|
|
|
+ // 装货点(A点)不一致
|
|
|
+ errorList.add("loadingCountrySubdivisionCode");
|
|
|
}
|
|
|
-
|
|
|
- // A、B点为无返回结果,状态码4
|
|
|
- if(retA.getResultCode()==Constant.UN_FIND_NUM_CODE && retB.getResultCode()==Constant.UN_FIND_NUM_CODE){
|
|
|
- ret.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
- ret.setResultBody(errList);
|
|
|
+ if (receiptCountryResult == Constant.UN_MATCH_CODE) {
|
|
|
+ // 卸货点(B点)不一致
|
|
|
+ errorList.add("receiptCountrySubdivisionCode");
|
|
|
+ }
|
|
|
+ if (errorList.size() > 0) {
|
|
|
+ // 装货点(A点)一致 或 卸货点(B点)不一致;返回不一致
|
|
|
+ ret.setResultCode(Constant.UN_MATCH_CODE);
|
|
|
+ ret.setResultBody(errorList);
|
|
|
ret.setResultDesc(Constant.QUERY_SUCCESS);
|
|
|
- return upstreamCodeA;
|
|
|
+ ret.setIsCharge(Constant.IS_CHARGE);
|
|
|
+ return upstreamCode;
|
|
|
}
|
|
|
|
|
|
- // errList有数据时,状态码2
|
|
|
- if(errList.size()>0){
|
|
|
+ if (loadingCountryResult == Constant.UN_FIND_NUM_CODE) {
|
|
|
+ // 装货点(A点)为空
|
|
|
+ errorList.add("loadingCountrySubdivisionCode");
|
|
|
+ }
|
|
|
+ if (receiptCountryResult == Constant.UN_FIND_NUM_CODE) {
|
|
|
+ // 卸货点(B点)为空
|
|
|
+ errorList.add("receiptCountrySubdivisionCode");
|
|
|
+ }
|
|
|
+ if (errorList.size() > 0) {
|
|
|
+ // 装货点(A点)为空 或 卸货点(B点)为空;返回不一致
|
|
|
ret.setResultCode(Constant.UN_MATCH_CODE);
|
|
|
- ret.setResultBody(errList);
|
|
|
+ ret.setResultBody(errorList);
|
|
|
ret.setResultDesc(Constant.QUERY_SUCCESS);
|
|
|
- return upstreamCodeA;
|
|
|
+ return upstreamCode;
|
|
|
}
|
|
|
- return "";
|
|
|
+ return upstreamCode;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean vehiclePositionConsistencyCheck(List<VehicleHistoryPositionResponse.Data> positionList,
|
|
|
+ String subdivisionCode) {
|
|
|
+ for (VehicleHistoryPositionResponse.Data position : positionList) {
|
|
|
+ if (subdivisionCode.equals(position.getPositionDescribe())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
private String vehiclePositionConsistencyACheck(List<VehicleHistoryPositionResponse.Data> positionList,
|
|
@@ -359,6 +334,7 @@ public class VehicleServiceImpl implements VehicleService {
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private String vehiclePositionConsistencyBCheck(List<VehicleHistoryPositionResponse.Data> positionList,
|
|
|
VehicleHistoryPositionRequestParam requestParam) {
|
|
|
boolean checkResultB = false;
|
|
@@ -446,21 +422,21 @@ public class VehicleServiceImpl implements VehicleService {
|
|
|
String endTimeB = DateUtil.addHours(requestParam.getEndTime(), supplierConfig.getAddHours());
|
|
|
|
|
|
// 4小时*2=8小时(A-A+间隔),8小时*2=16个点(每半个小时取1个点)
|
|
|
- int pointNumber = supplierConfig.getAddHours()*2*2;
|
|
|
+ int pointNumber = supplierConfig.getAddHours() * 2 * 2;
|
|
|
|
|
|
/**
|
|
|
* A点,装货点,8小时16个点,进行处理各个点的时间点
|
|
|
*/
|
|
|
List<String> checkTimeListA = new ArrayList<>();
|
|
|
String tempStartTime = startTimeA;
|
|
|
- for (int i = 0; i < pointNumber+1; i++) {
|
|
|
+ for (int i = 0; i < pointNumber + 1; i++) {
|
|
|
checkTimeListA.add(tempStartTime);
|
|
|
tempStartTime = DateUtil.addMinutes(tempStartTime, 30);
|
|
|
}
|
|
|
|
|
|
List<String> checkTimeListB = new ArrayList<>();
|
|
|
tempStartTime = startTimeB;
|
|
|
- for (int i = 0; i < pointNumber+1; i++) {
|
|
|
+ for (int i = 0; i < pointNumber + 1; i++) {
|
|
|
checkTimeListB.add(tempStartTime);
|
|
|
tempStartTime = DateUtil.addMinutes(tempStartTime, 30);
|
|
|
}
|
|
@@ -468,10 +444,10 @@ public class VehicleServiceImpl implements VehicleService {
|
|
|
boolean checkResultA = false;
|
|
|
// 这个集合为了查看位置是否正确
|
|
|
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) {
|
|
|
if (Long.parseLong(position.getPositionTime()) > Long.parseLong(checkTimeListA.get(i))
|
|
|
- && Long.parseLong(position.getPositionTime()) <= Long.parseLong(checkTimeListA.get(i+1))) {
|
|
|
+ && Long.parseLong(position.getPositionTime()) <= Long.parseLong(checkTimeListA.get(i + 1))) {
|
|
|
verificationPositionListA.add(position);
|
|
|
if (requestParam.getLoadingCountrySubdivisionCode().equals(position.getPositionDescribe())) {
|
|
|
checkResultA = true;
|
|
@@ -490,10 +466,10 @@ public class VehicleServiceImpl implements VehicleService {
|
|
|
boolean checkResultB = false;
|
|
|
// 这个集合为了查看位置是否正确
|
|
|
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) {
|
|
|
if (Long.parseLong(position.getPositionTime()) > Long.parseLong(checkTimeListB.get(i))
|
|
|
- && Long.parseLong(position.getPositionTime()) <= Long.parseLong(checkTimeListB.get(i+1))) {
|
|
|
+ && Long.parseLong(position.getPositionTime()) <= Long.parseLong(checkTimeListB.get(i + 1))) {
|
|
|
verificationPositionListB.add(position);
|
|
|
if (requestParam.getReceiptCountrySubdivisionCode().equals(position.getPositionDescribe())) {
|
|
|
checkResultB = true;
|
|
@@ -509,7 +485,7 @@ public class VehicleServiceImpl implements VehicleService {
|
|
|
if (checkResultA && checkResultB) {
|
|
|
return "";
|
|
|
} else {
|
|
|
- return "receiptCountrySubdivisionCode与数据源不一致";
|
|
|
+ return "receiptCountrySubdivisionCode与数据源不一致";
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -573,28 +549,28 @@ public class VehicleServiceImpl implements VehicleService {
|
|
|
String startTimeB = DateUtil.addHours(requestParam.getEndTime(), supplierConfig.getReduceHours());
|
|
|
|
|
|
// 4小时*2=8小时(A-A+间隔),8小时*2=16个点(每半个小时取1个点)
|
|
|
- int pointNumber = supplierConfig.getAddHours()*2*2;
|
|
|
+ int pointNumber = supplierConfig.getAddHours() * 2 * 2;
|
|
|
|
|
|
List<String> checkTimeListA = new ArrayList<>();
|
|
|
String tempStartTime = startTimeA;
|
|
|
- for (int i = 0; i < pointNumber+1; i++) {
|
|
|
+ for (int i = 0; i < pointNumber + 1; i++) {
|
|
|
checkTimeListA.add(tempStartTime);
|
|
|
tempStartTime = DateUtil.addMinutes(tempStartTime, 30);
|
|
|
}
|
|
|
|
|
|
List<String> checkTimeListB = new ArrayList<>();
|
|
|
tempStartTime = startTimeB;
|
|
|
- for (int i = 0; i < pointNumber+1; i++) {
|
|
|
+ for (int i = 0; i < pointNumber + 1; i++) {
|
|
|
checkTimeListB.add(tempStartTime);
|
|
|
tempStartTime = DateUtil.addMinutes(tempStartTime, 30);
|
|
|
}
|
|
|
|
|
|
// 这个集合为了查看位置是否正确
|
|
|
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) {
|
|
|
if (Long.parseLong(position.getPositionTime()) > Long.parseLong(checkTimeListA.get(i))
|
|
|
- && Long.parseLong(position.getPositionTime()) <= Long.parseLong(checkTimeListA.get(i+1))) {
|
|
|
+ && Long.parseLong(position.getPositionTime()) <= Long.parseLong(checkTimeListA.get(i + 1))) {
|
|
|
verificationPositionListA.add(position);
|
|
|
if (!requestParam.getLoadingCountrySubdivisionCode().equals(position.getPositionDescribe())) {
|
|
|
return "loadingCountrySubdivisionCode";
|
|
@@ -606,10 +582,10 @@ public class VehicleServiceImpl implements VehicleService {
|
|
|
|
|
|
// 这个集合为了查看位置是否正确
|
|
|
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) {
|
|
|
if (Long.parseLong(position.getPositionTime()) > Long.parseLong(checkTimeListB.get(i))
|
|
|
- && Long.parseLong(position.getPositionTime()) <= Long.parseLong(checkTimeListB.get(i+1))) {
|
|
|
+ && Long.parseLong(position.getPositionTime()) <= Long.parseLong(checkTimeListB.get(i + 1))) {
|
|
|
verificationPositionListB.add(position);
|
|
|
if (!requestParam.getReceiptCountrySubdivisionCode().equals(position.getPositionDescribe())) {
|
|
|
return "receiptCountrySubdivisionCode";
|
|
@@ -713,7 +689,7 @@ public class VehicleServiceImpl implements VehicleService {
|
|
|
if (errorInfo.equals(Constants.UN_MATCH_CERTIFICATE_VALID_PERIOD_FROM)) {
|
|
|
errorList.add("roadTransportCertificateValidPeriodFrom");
|
|
|
}
|
|
|
- if (errorInfo.equals(Constants.UN_MATCH_CERTIFICATE_VALID_PERIOD_TO)){
|
|
|
+ if (errorInfo.equals(Constants.UN_MATCH_CERTIFICATE_VALID_PERIOD_TO)) {
|
|
|
errorList.add("roadTransportCertificateValidPeriodTo");
|
|
|
}
|
|
|
ret.setResultCode(Constant.UN_MATCH_CODE);
|
|
@@ -835,13 +811,13 @@ public class VehicleServiceImpl implements VehicleService {
|
|
|
if (errorInfo.equals(Constants.UN_MATCH_PROVINCE_CODE)) {
|
|
|
errorList.add("provinceCode");
|
|
|
}
|
|
|
- if (errorInfo.equals(Constants.UN_MATCH_QUALIFICATION_CERTIFICATE)){
|
|
|
+ if (errorInfo.equals(Constants.UN_MATCH_QUALIFICATION_CERTIFICATE)) {
|
|
|
errorList.add("qualificationCertificate");
|
|
|
}
|
|
|
- if (errorInfo.equals(Constants.UN_MATCH_QUALIFICATION_CERTIFICATE_FROM)){
|
|
|
+ if (errorInfo.equals(Constants.UN_MATCH_QUALIFICATION_CERTIFICATE_FROM)) {
|
|
|
errorList.add("qualificationCertificateValidPeriodFrom");
|
|
|
}
|
|
|
- if (errorInfo.equals(Constants.UN_MATCH_QUALIFICATION_CERTIFICATE_TO)){
|
|
|
+ if (errorInfo.equals(Constants.UN_MATCH_QUALIFICATION_CERTIFICATE_TO)) {
|
|
|
errorList.add("qualificationCertificateValidPeriodTo");
|
|
|
}
|
|
|
ret.setResultCode(Constant.UN_MATCH_CODE);
|
|
@@ -963,7 +939,7 @@ public class VehicleServiceImpl implements VehicleService {
|
|
|
if (errorInfo.equals(Constants.UN_MATCH_PERMIT_VALID_PERIOD_FROM)) {
|
|
|
errorList.add("permitValidPeriodFrom");
|
|
|
}
|
|
|
- if (errorInfo.equals(Constants.UN_MATCH_PERMIT_VALID_PERIOD_TO)){
|
|
|
+ if (errorInfo.equals(Constants.UN_MATCH_PERMIT_VALID_PERIOD_TO)) {
|
|
|
errorList.add("permitValidPeriodTo");
|
|
|
}
|
|
|
ret.setResultCode(Constant.UN_MATCH_CODE);
|