|
@@ -10,9 +10,11 @@ import info.aspirecn.iov.sjjh.commons.lang.PatternTools;
|
|
|
import info.aspirecn.iov.sjjh.service.sms.action.SmsActionInterface;
|
|
|
import info.aspirecn.rdc.aspirecloud.node.except.utils.ErrorUtils;
|
|
|
import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.constant.ChannelConstant;
|
|
|
+import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.service.TrafficRecordService;
|
|
|
import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.service.WycChannelService;
|
|
|
import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.utils.DESedeUtil;
|
|
|
import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.utils.SupplierProperties;
|
|
|
+import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.utils.VehicleJsonHelper;
|
|
|
import info.aspirecn.rdc.iov.sjjh.servicenode.supplier.vo.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import okhttp3.*;
|
|
@@ -52,6 +54,11 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
SupplierProperties supplierProperties;
|
|
|
@Autowired
|
|
|
SmsActionInterface smsActionInterface;
|
|
|
+ @Autowired
|
|
|
+ TrafficRecordService trafficRecordService;
|
|
|
+ @Autowired
|
|
|
+ VehicleJsonHelper vehicleJsonHelper;
|
|
|
+
|
|
|
private OkHttpClient okHttpClient = new OkHttpClient.Builder().build();
|
|
|
@Autowired
|
|
|
StringRedisTemplate stringTemplate;
|
|
@@ -78,11 +85,11 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
String upstreamCode = Constant.LOG_UPSTREAM_DEFAULT_RESPONSE_CODE;
|
|
|
|
|
|
try {
|
|
|
- if(outTime <= 0) {
|
|
|
+ if (outTime <= 0) {
|
|
|
outTime = Constant.HTTPCLIENT_CONNECTTIMEOUT;
|
|
|
}
|
|
|
|
|
|
- log.info("WycInfoRequest---customBody={},outTime={}",customBody,outTime);
|
|
|
+ log.info("WycInfoRequest---customBody={},outTime={}", customBody, outTime);
|
|
|
WycInfoRequestObject wycInfoRequestObject = objectMapper.readValue(customBody,
|
|
|
WycInfoRequestObject.class);
|
|
|
if (StringUtils.isBlank(wycInfoRequestObject.getName()) ||
|
|
@@ -101,8 +108,6 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
// 创建一个请求 Builder
|
|
|
Request.Builder builder = new Request.Builder();
|
|
|
Request okRequest = new Request.Builder()
|
|
@@ -110,9 +115,9 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
.url(supplierProperties.getUrl())
|
|
|
.build();
|
|
|
HttpUrl.Builder urlBuilder = okRequest.url().newBuilder();
|
|
|
- urlBuilder.addQueryParameter("company_id",supplierProperties.getCompany_id());
|
|
|
- urlBuilder.addQueryParameter("dri_name",wycInfoRequestObject.getName());
|
|
|
- urlBuilder.addQueryParameter("idcard",wycInfoRequestObject.getIdCode());
|
|
|
+ urlBuilder.addQueryParameter("company_id", supplierProperties.getCompany_id());
|
|
|
+ urlBuilder.addQueryParameter("dri_name", wycInfoRequestObject.getName());
|
|
|
+ urlBuilder.addQueryParameter("idcard", wycInfoRequestObject.getIdCode());
|
|
|
builder.url(urlBuilder.build());
|
|
|
|
|
|
OkHttpClient client = okHttpClient.newBuilder()
|
|
@@ -124,21 +129,21 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
Response response = client.newCall(builder.build()).execute();
|
|
|
String responseContext = response.body().string();
|
|
|
//
|
|
|
- log.info("supplier10000036.WycInfoRequest接口responseContext={}",responseContext);
|
|
|
+ log.info("supplier10000036.WycInfoRequest接口responseContext={}", responseContext);
|
|
|
|
|
|
WycInfoResponseObject wycInfoResponseObject = objectMapper.readValue(responseContext, WycInfoResponseObject.class);
|
|
|
- if(wycInfoResponseObject !=null){
|
|
|
+ if (wycInfoResponseObject != null) {
|
|
|
upstreamCode = String.valueOf(wycInfoResponseObject.getCode());
|
|
|
- if(wycInfoResponseObject.getCode()==1 && wycInfoResponseObject.getState()==0){//库无
|
|
|
+ if (wycInfoResponseObject.getCode() == 1 && wycInfoResponseObject.getState() == 0) {//库无
|
|
|
ret.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
ret.setResultBody("查询成功,查无结果");
|
|
|
ret.setResultDesc("查询成功,查无结果");
|
|
|
- }else if(wycInfoResponseObject.getCode()==0 && wycInfoResponseObject.getState()==0){//计费分析
|
|
|
+ } else if (wycInfoResponseObject.getCode() == 0 && wycInfoResponseObject.getState() == 0) {//计费分析
|
|
|
ret.setIsCharge(Constant.IS_CHARGE);
|
|
|
ret.setResultCode(Constant.MATCH_CODE);
|
|
|
String message = wycInfoResponseObject.getMessage();
|
|
|
//ret.setResultBody(message);
|
|
|
- if(secondMoney!=0) {
|
|
|
+ if (secondMoney != 0) {
|
|
|
String[] result = message.substring(1, message.length()).substring(0, message.length() - 2).split(",");
|
|
|
int index = 0;
|
|
|
for (; index < result.length; index++) {
|
|
@@ -154,36 +159,36 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- Map<String,String> mapResult = new HashMap<String,String>();
|
|
|
+ Map<String, String> mapResult = new HashMap<String, String>();
|
|
|
String[] result = message.substring(1, message.length()).substring(0, message.length() - 2).split(",");
|
|
|
for (int index = 0; index < result.length; index++) {
|
|
|
String[] details = result[index].split("=");
|
|
|
- mapResult.put(details[0],details[1]);
|
|
|
+ mapResult.put(details[0], details[1]);
|
|
|
}
|
|
|
String resultBody = objectMapper.writeValueAsString(mapResult);
|
|
|
- resultBody = resultBody.replace("'","");
|
|
|
+ resultBody = resultBody.replace("'", "");
|
|
|
ret.setResultBody(resultBody);
|
|
|
ret.setJfFree(money);
|
|
|
ret.setJflx(3);
|
|
|
ret.setResultDesc("查询成功,查有结果");
|
|
|
- }else{//其他
|
|
|
+ } else {//其他
|
|
|
ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
ret.setResultBody("查询错误");
|
|
|
ret.setResultDesc("查询错误");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
ret.setResultBody("查询错误");
|
|
|
ret.setResultDesc("查询错误");
|
|
|
}
|
|
|
- request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
+ request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
|
|
|
|
|
|
- } catch(SocketTimeoutException ste) {
|
|
|
+ } catch (SocketTimeoutException ste) {
|
|
|
ErrorUtils.captureException(ste);
|
|
|
log.info("supplier10000036.WycInfoRequest接口SocketTimeoutException={}", ste);
|
|
|
ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
- } catch(Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
ErrorUtils.captureException(e);
|
|
|
log.info("supplier10000036.WycInfoRequest接口Exception={}", e);
|
|
|
ret.setCode(Constant.FAIL);
|
|
@@ -193,6 +198,7 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
return ret;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public ChannelTypeHandleResponseObject onlineCarHailingQuery(HttpServletRequest request, Integer outTime, String customBody) {
|
|
|
ChannelTypeHandleResponseObject ret = new ChannelTypeHandleResponseObject();
|
|
@@ -225,9 +231,9 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
.url(supplierProperties.getUrl())
|
|
|
.build();
|
|
|
HttpUrl.Builder urlBuilder = okRequest.url().newBuilder();
|
|
|
- urlBuilder.addQueryParameter("company_id",supplierProperties.getCompany_id());
|
|
|
- urlBuilder.addQueryParameter("dri_name",jsonResolveObject.getName());
|
|
|
- urlBuilder.addQueryParameter("idcard",jsonResolveObject.getIdCode());
|
|
|
+ urlBuilder.addQueryParameter("company_id", supplierProperties.getCompany_id());
|
|
|
+ urlBuilder.addQueryParameter("dri_name", jsonResolveObject.getName());
|
|
|
+ urlBuilder.addQueryParameter("idcard", jsonResolveObject.getIdCode());
|
|
|
builder.url(urlBuilder.build());
|
|
|
|
|
|
OkHttpClient client = okHttpClient.newBuilder()
|
|
@@ -238,7 +244,7 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
.build();
|
|
|
Response response = client.newCall(builder.build()).execute();
|
|
|
String responseContext = response.body().string();
|
|
|
- log.info("supplier10000036.onlineCarHailingQuery接口responseContext={}",responseContext);
|
|
|
+ log.info("supplier10000036.onlineCarHailingQuery接口responseContext={}", responseContext);
|
|
|
|
|
|
WycInfoResponseObject responseObject = objectMapper.readValue(responseContext, WycInfoResponseObject.class);
|
|
|
|
|
@@ -279,7 +285,7 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
if (code == 0 && state == 0 && StringUtils.isNotBlank(message)) {
|
|
|
// 查询成功,返回结果
|
|
|
// 解析返回结果
|
|
|
- String[] results = message.substring(1).substring(0,message.length()-2).replace("'", "").split(",");
|
|
|
+ String[] results = message.substring(1).substring(0, message.length() - 2).replace("'", "").split(",");
|
|
|
Map<String, String> messageMap = new HashMap<>();
|
|
|
for (String r : results) {
|
|
|
String[] arr = r.split("=");
|
|
@@ -384,7 +390,7 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
//每一分执行一下定时任务
|
|
|
|
|
|
@Scheduled(cron = "${vpn.heartbeat}")
|
|
|
- public void refresh(){
|
|
|
+ public void refresh() {
|
|
|
//查询这个时间减去当前时间小于25分钟,
|
|
|
try {
|
|
|
log.info("----------------");
|
|
@@ -442,10 +448,9 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
stringTemplate.boundValueOps("wyc_refre").set(String.valueOf(currentTime));
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
- } catch(IOException e){
|
|
|
+ } catch (IOException e) {
|
|
|
log.error("exception:{}", e);
|
|
|
}
|
|
|
|
|
@@ -491,9 +496,9 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
.url(supplierProperties.getUrl())
|
|
|
.build();
|
|
|
HttpUrl.Builder urlBuilder = okRequest.url().newBuilder();
|
|
|
- urlBuilder.addQueryParameter("company_id",supplierProperties.getCompany_id());
|
|
|
- urlBuilder.addQueryParameter("dri_name",jsonResolveObject.getName());
|
|
|
- urlBuilder.addQueryParameter("idcard",jsonResolveObject.getIdCode());
|
|
|
+ urlBuilder.addQueryParameter("company_id", supplierProperties.getCompany_id());
|
|
|
+ urlBuilder.addQueryParameter("dri_name", jsonResolveObject.getName());
|
|
|
+ urlBuilder.addQueryParameter("idcard", jsonResolveObject.getIdCode());
|
|
|
builder.url(urlBuilder.build());
|
|
|
|
|
|
OkHttpClient client = okHttpClient.newBuilder()
|
|
@@ -504,7 +509,7 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
.build();
|
|
|
Response response = client.newCall(builder.build()).execute();
|
|
|
String responseContext = response.body().string();
|
|
|
- log.info("supplier10000036.onlineCarHailingQuery接口responseContext={}",responseContext);
|
|
|
+ log.info("supplier10000036.onlineCarHailingQuery接口responseContext={}", responseContext);
|
|
|
|
|
|
WycInfoResponseObject responseObject = objectMapper.readValue(responseContext, WycInfoResponseObject.class);
|
|
|
|
|
@@ -571,11 +576,11 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
String upstreamCode = Constant.LOG_UPSTREAM_DEFAULT_RESPONSE_CODE;
|
|
|
|
|
|
try {
|
|
|
- if(outTime <= 0) {
|
|
|
+ if (outTime <= 0) {
|
|
|
outTime = Constant.HTTPCLIENT_CONNECTTIMEOUT;
|
|
|
}
|
|
|
|
|
|
- log.info("WycInfoDecodeRequest---customBody={},outTime={}",customBody,outTime);
|
|
|
+ log.info("WycInfoDecodeRequest---customBody={},outTime={}", customBody, outTime);
|
|
|
|
|
|
WycInfoRequestObject wycInfoRequestObject = objectMapper.readValue(customBody,
|
|
|
WycInfoRequestObject.class);
|
|
@@ -649,9 +654,9 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
.url(supplierProperties.getUrl())
|
|
|
.build();
|
|
|
HttpUrl.Builder urlBuilder = okRequest.url().newBuilder();
|
|
|
- urlBuilder.addQueryParameter("company_id",supplierProperties.getCompany_id());
|
|
|
- urlBuilder.addQueryParameter("dri_name",wycInfoRequestObject.getName());
|
|
|
- urlBuilder.addQueryParameter("idcard",idCode);
|
|
|
+ urlBuilder.addQueryParameter("company_id", supplierProperties.getCompany_id());
|
|
|
+ urlBuilder.addQueryParameter("dri_name", wycInfoRequestObject.getName());
|
|
|
+ urlBuilder.addQueryParameter("idcard", idCode);
|
|
|
builder.url(urlBuilder.build());
|
|
|
|
|
|
OkHttpClient client = okHttpClient.newBuilder()
|
|
@@ -663,21 +668,21 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
Response response = client.newCall(builder.build()).execute();
|
|
|
String responseContext = response.body().string();
|
|
|
//
|
|
|
- log.info("supplier10000036.WycInfoDecodeRequest接口responseContext={}",responseContext);
|
|
|
+ log.info("supplier10000036.WycInfoDecodeRequest接口responseContext={}", responseContext);
|
|
|
|
|
|
WycInfoResponseObject wycInfoResponseObject = objectMapper.readValue(responseContext, WycInfoResponseObject.class);
|
|
|
- if(wycInfoResponseObject !=null){
|
|
|
+ if (wycInfoResponseObject != null) {
|
|
|
upstreamCode = String.valueOf(wycInfoResponseObject.getCode());
|
|
|
- if(wycInfoResponseObject.getCode()==1 && wycInfoResponseObject.getState()==0){//库无
|
|
|
+ if (wycInfoResponseObject.getCode() == 1 && wycInfoResponseObject.getState() == 0) {//库无
|
|
|
ret.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
ret.setResultBody("查询成功,查无结果");
|
|
|
ret.setResultDesc("查询成功,查无结果");
|
|
|
- }else if(wycInfoResponseObject.getCode()==0 && wycInfoResponseObject.getState()==0){//计费分析
|
|
|
+ } else if (wycInfoResponseObject.getCode() == 0 && wycInfoResponseObject.getState() == 0) {//计费分析
|
|
|
ret.setIsCharge(Constant.IS_CHARGE);
|
|
|
ret.setResultCode(Constant.MATCH_CODE);
|
|
|
String message = wycInfoResponseObject.getMessage();
|
|
|
//ret.setResultBody(message);
|
|
|
- if(secondMoney!=0) {
|
|
|
+ if (secondMoney != 0) {
|
|
|
String[] result = message.substring(1, message.length()).substring(0, message.length() - 2).split(",");
|
|
|
int index = 0;
|
|
|
for (; index < result.length; index++) {
|
|
@@ -693,36 +698,36 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- Map<String,String> mapResult = new HashMap<String,String>();
|
|
|
+ Map<String, String> mapResult = new HashMap<String, String>();
|
|
|
String[] result = message.substring(1, message.length()).substring(0, message.length() - 2).split(",");
|
|
|
for (int index = 0; index < result.length; index++) {
|
|
|
String[] details = result[index].split("=");
|
|
|
- mapResult.put(details[0],details[1]);
|
|
|
+ mapResult.put(details[0], details[1]);
|
|
|
}
|
|
|
String resultBody = objectMapper.writeValueAsString(mapResult);
|
|
|
- resultBody = resultBody.replace("'","");
|
|
|
+ resultBody = resultBody.replace("'", "");
|
|
|
ret.setResultBody(resultBody);
|
|
|
ret.setJfFree(money);
|
|
|
ret.setJflx(3);
|
|
|
ret.setResultDesc("查询成功,查有结果");
|
|
|
- }else{//其他
|
|
|
+ } else {//其他
|
|
|
ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
ret.setResultBody("查询错误");
|
|
|
ret.setResultDesc("查询错误");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
ret.setResultBody("查询错误");
|
|
|
ret.setResultDesc("查询错误");
|
|
|
}
|
|
|
- request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
+ request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
|
|
|
|
|
|
- } catch(SocketTimeoutException ste) {
|
|
|
+ } catch (SocketTimeoutException ste) {
|
|
|
ErrorUtils.captureException(ste);
|
|
|
log.info("supplier10000036.WycInfoDecodeRequest接口SocketTimeoutException={}", ste);
|
|
|
ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
- } catch(Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
ErrorUtils.captureException(e);
|
|
|
log.info("supplier10000036.WycInfoDecodeRequest接口Exception={}", e);
|
|
|
ret.setCode(Constant.FAIL);
|
|
@@ -807,8 +812,8 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
.url(vehicleFigureUrl)
|
|
|
.build();
|
|
|
HttpUrl.Builder urlBuilder = okRequest.url().newBuilder();
|
|
|
- urlBuilder.addQueryParameter("company_id",supplierProperties.getCompany_id());
|
|
|
- urlBuilder.addQueryParameter("veh_no",jsonResolveObject.getPlateNum());
|
|
|
+ urlBuilder.addQueryParameter("company_id", supplierProperties.getCompany_id());
|
|
|
+ urlBuilder.addQueryParameter("veh_no", jsonResolveObject.getPlateNum());
|
|
|
builder.url(urlBuilder.build());
|
|
|
|
|
|
OkHttpClient client = okHttpClient.newBuilder()
|
|
@@ -819,7 +824,7 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
.build();
|
|
|
Response response = client.newCall(builder.build()).execute();
|
|
|
String responseContext = response.body().string();
|
|
|
- log.info("supplier10000036.vehicleInfoQuery接口responseContext={}",responseContext);
|
|
|
+ log.info("supplier10000036.vehicleInfoQuery接口responseContext={}", responseContext);
|
|
|
WycInfoResponseObject responseObject = objectMapper.readValue(responseContext, WycInfoResponseObject.class);
|
|
|
|
|
|
if (responseObject != null) {
|
|
@@ -879,36 +884,36 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
int state = responseObject.getState();
|
|
|
int chargeMoney = 0;
|
|
|
|
|
|
- if(responseObject != null){
|
|
|
- if(code == 1 && state == 0){//库无
|
|
|
+ if (responseObject != null) {
|
|
|
+ if (code == 1 && state == 0) {//库无
|
|
|
ret.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
ret.setResultBody("查询成功,查无结果");
|
|
|
ret.setResultDesc("查询成功,查无结果");
|
|
|
|
|
|
chargeMoney = Integer.parseInt(request.getHeader(Constant.ROUTE_SECOND_PRICE));
|
|
|
ret.setIsCharge(Constant.IS_CHARGE);
|
|
|
- }else if(code == 0 && state == 0){//计费分析
|
|
|
+ } else if (code == 0 && state == 0) {//计费分析
|
|
|
String message = responseObject.getMessage();
|
|
|
- Map<String,String> mapResult = new HashMap<String,String>();
|
|
|
+ Map<String, String> mapResult = new HashMap<String, String>();
|
|
|
String[] result = message.substring(12, message.length()).substring(0, message.length() - 13).split(",");
|
|
|
for (int index = 0; index < result.length; index++) {
|
|
|
String[] details = result[index].split("=");
|
|
|
- mapResult.put(details[0],details[1]);
|
|
|
+ mapResult.put(details[0], details[1]);
|
|
|
}
|
|
|
String resultBody = JSON.toJSONString(mapResult);
|
|
|
- resultBody = resultBody.replace("'","");
|
|
|
+ resultBody = resultBody.replace("'", "");
|
|
|
|
|
|
chargeMoney = Integer.parseInt(request.getHeader(Constant.ROUTE_PRICE));
|
|
|
ret.setIsCharge(Constant.IS_CHARGE);
|
|
|
ret.setResultCode(Constant.MATCH_CODE);
|
|
|
ret.setResultBody(resultBody);
|
|
|
ret.setResultDesc("查询成功,查有结果");
|
|
|
- }else{//其他
|
|
|
+ } else {//其他
|
|
|
ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
ret.setResultBody("查询错误");
|
|
|
ret.setResultDesc("查询错误");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
ret.setResultBody("查询错误");
|
|
|
ret.setResultDesc("查询错误");
|
|
@@ -932,11 +937,11 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
String upstreamCode = Constant.LOG_UPSTREAM_DEFAULT_RESPONSE_CODE;
|
|
|
|
|
|
try {
|
|
|
- if(outTime <= 0) {
|
|
|
+ if (outTime <= 0) {
|
|
|
outTime = Constant.HTTPCLIENT_CONNECTTIMEOUT;
|
|
|
}
|
|
|
|
|
|
- log.info("WycInfoDecodeRequestV2---customBody={},outTime={}",customBody,outTime);
|
|
|
+ log.info("WycInfoDecodeRequestV2---customBody={},outTime={}", customBody, outTime);
|
|
|
|
|
|
WycInfoRequestObject wycInfoRequestObject = objectMapper.readValue(customBody,
|
|
|
WycInfoRequestObject.class);
|
|
@@ -964,9 +969,9 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
.url(supplierProperties.getUrl())
|
|
|
.build();
|
|
|
HttpUrl.Builder urlBuilder = okRequest.url().newBuilder();
|
|
|
- urlBuilder.addQueryParameter("company_id",supplierProperties.getCompany_id());
|
|
|
+ urlBuilder.addQueryParameter("company_id", supplierProperties.getCompany_id());
|
|
|
urlBuilder.addQueryParameter("dri_name", name);
|
|
|
- urlBuilder.addQueryParameter("idcard",idCode);
|
|
|
+ urlBuilder.addQueryParameter("idcard", idCode);
|
|
|
builder.url(urlBuilder.build());
|
|
|
|
|
|
OkHttpClient client = okHttpClient.newBuilder()
|
|
@@ -978,21 +983,21 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
Response response = client.newCall(builder.build()).execute();
|
|
|
String responseContext = response.body().string();
|
|
|
//
|
|
|
- log.info("supplier10000036.WycInfoDecodeRequestV2接口responseContext={}",responseContext);
|
|
|
+ log.info("supplier10000036.WycInfoDecodeRequestV2接口responseContext={}", responseContext);
|
|
|
|
|
|
WycInfoResponseObject wycInfoResponseObject = objectMapper.readValue(responseContext, WycInfoResponseObject.class);
|
|
|
- if(wycInfoResponseObject !=null){
|
|
|
+ if (wycInfoResponseObject != null) {
|
|
|
upstreamCode = String.valueOf(wycInfoResponseObject.getCode());
|
|
|
- if(wycInfoResponseObject.getCode()==1 && wycInfoResponseObject.getState()==0){//库无
|
|
|
+ if (wycInfoResponseObject.getCode() == 1 && wycInfoResponseObject.getState() == 0) {//库无
|
|
|
ret.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
ret.setResultBody("查询成功,查无结果");
|
|
|
ret.setResultDesc("查询成功,查无结果");
|
|
|
- }else if(wycInfoResponseObject.getCode()==0 && wycInfoResponseObject.getState()==0){//计费分析
|
|
|
+ } else if (wycInfoResponseObject.getCode() == 0 && wycInfoResponseObject.getState() == 0) {//计费分析
|
|
|
ret.setIsCharge(Constant.IS_CHARGE);
|
|
|
ret.setResultCode(Constant.MATCH_CODE);
|
|
|
String message = wycInfoResponseObject.getMessage();
|
|
|
//ret.setResultBody(message);
|
|
|
- if(secondMoney!=0) {
|
|
|
+ if (secondMoney != 0) {
|
|
|
String[] result = message.substring(1, message.length()).substring(0, message.length() - 2).split(",");
|
|
|
int index = 0;
|
|
|
for (; index < result.length; index++) {
|
|
@@ -1008,36 +1013,36 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- Map<String,String> mapResult = new HashMap<String,String>();
|
|
|
+ Map<String, String> mapResult = new HashMap<String, String>();
|
|
|
String[] result = message.substring(1, message.length()).substring(0, message.length() - 2).split(",");
|
|
|
for (int index = 0; index < result.length; index++) {
|
|
|
String[] details = result[index].split("=");
|
|
|
- mapResult.put(details[0],details[1]);
|
|
|
+ mapResult.put(details[0], details[1]);
|
|
|
}
|
|
|
String resultBody = objectMapper.writeValueAsString(mapResult);
|
|
|
- resultBody = resultBody.replace("'","");
|
|
|
+ resultBody = resultBody.replace("'", "");
|
|
|
ret.setResultBody(resultBody);
|
|
|
ret.setJfFree(money);
|
|
|
ret.setJflx(3);
|
|
|
ret.setResultDesc("查询成功,查有结果");
|
|
|
- }else{//其他
|
|
|
+ } else {//其他
|
|
|
ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
ret.setResultBody("查询错误");
|
|
|
ret.setResultDesc("查询错误");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
ret.setResultBody("查询错误");
|
|
|
ret.setResultDesc("查询错误");
|
|
|
}
|
|
|
- request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
+ request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
|
|
|
|
|
|
- } catch(SocketTimeoutException ste) {
|
|
|
+ } catch (SocketTimeoutException ste) {
|
|
|
ErrorUtils.captureException(ste);
|
|
|
log.info("supplier10000036.WycInfoDecodeRequestV2接口SocketTimeoutException={}", ste);
|
|
|
ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
- } catch(Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
ErrorUtils.captureException(e);
|
|
|
log.info("supplier10000036.WycInfoDecodeRequestV2接口Exception={}", e);
|
|
|
ret.setCode(Constant.FAIL);
|
|
@@ -1105,7 +1110,7 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
return false;
|
|
|
} else if (encryptType.equals("MD5")
|
|
|
&& (wycInfoRequestObject.getIdCode().length() != 32
|
|
|
- || wycInfoRequestObject.getName().length() !=32)) {
|
|
|
+ || wycInfoRequestObject.getName().length() != 32)) {
|
|
|
ret.setResultCode(Constant.INVALID_PARAMETER_CODE);
|
|
|
ret.setResultBody(Constant.INVALID_PARAMETER);
|
|
|
ret.setResultDesc(Constant.INVALID_PARAMETER);
|
|
@@ -1167,6 +1172,210 @@ public class WycChannelServiceImpl implements WycChannelService {
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ChannelTypeHandleResponseObject vehicleInfoQueryV3(HttpServletRequest request, String channelId, Integer outTime, String customBody) {
|
|
|
+ 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("vehicleInfoQueryV3---customBody={},outTime={}", customBody, outTime);
|
|
|
+
|
|
|
+ try {
|
|
|
+ VehicleInfoQueryV3RequestObject jsonResolveObject = objectMapper.readValue(customBody,
|
|
|
+ VehicleInfoQueryV3RequestObject.class);
|
|
|
+ // 参数校验
|
|
|
+ if (!validateRequestParams(ret, returnType, jsonResolveObject)
|
|
|
+ || !validateVehicleInfoRequestParams(ret, returnType, jsonResolveObject)) {
|
|
|
+ ret.setCode(Constant.SUCCESS);
|
|
|
+ request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ Request.Builder builder = new Request.Builder();
|
|
|
+ Request okRequest = new Request.Builder()
|
|
|
+ .get()
|
|
|
+ .url(vehicleFigureUrl)
|
|
|
+ .build();
|
|
|
+ HttpUrl.Builder urlBuilder = okRequest.url().newBuilder();
|
|
|
+ urlBuilder.addQueryParameter("company_id", supplierProperties.getCompany_id());
|
|
|
+ urlBuilder.addQueryParameter("veh_no", jsonResolveObject.getPlateNum());
|
|
|
+ builder.url(urlBuilder.build());
|
|
|
+
|
|
|
+ OkHttpClient client = okHttpClient.newBuilder()
|
|
|
+ .connectTimeout(outTime, TimeUnit.MILLISECONDS)
|
|
|
+ .readTimeout(outTime, TimeUnit.MILLISECONDS)
|
|
|
+ .writeTimeout(outTime, TimeUnit.MILLISECONDS)
|
|
|
+ .build();
|
|
|
+ Response response = client.newCall(builder.build()).execute();
|
|
|
+ String responseContext = response.body().string();
|
|
|
+// String responseContext = "{\"code\":0,\"message\":\"VehicleInfo{vehNO='豫F7K381',earliestOrderMonth='C',totalMile='C',mile1='A',mile3='B',mile6='B',salary1='B',salary3='B',salary6='B'}\",\"state\":0}";
|
|
|
+ log.info("supplier10000036.vehicleInfoQueryV3接口responseContext={}", responseContext);
|
|
|
+ WycInfoResponseObject responseObject = objectMapper.readValue(responseContext, WycInfoResponseObject.class);
|
|
|
+
|
|
|
+ if (responseObject != null) {
|
|
|
+ ret.setCode(Constant.SUCCESS);
|
|
|
+ setVehicleInfoQueryV3Response(ret, jsonResolveObject, responseObject);
|
|
|
+ upstreamCode = responseObject.getCode() + "," + responseObject.getState();
|
|
|
+ } else {
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
+ }
|
|
|
+ } catch (SocketTimeoutException ste) {
|
|
|
+ ErrorUtils.captureException(ste);
|
|
|
+ log.info("supplier10000036.vehicleInfoQueryV3接口SocketTimeoutException=", ste);
|
|
|
+ ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
+ } catch (SocketException se) {
|
|
|
+ ErrorUtils.captureException(se);
|
|
|
+ log.info("supplier10000036.vehicleInfoQueryV3接口SocketException=", se);
|
|
|
+ ret.setCode(Constant.REQUEST_TIMEOUT);
|
|
|
+ } catch (Exception ioe) {
|
|
|
+ ErrorUtils.captureException(ioe);
|
|
|
+ log.info("supplier10000036.vehicleInfoQueryV3接口Exception=", ioe);
|
|
|
+ ret.setCode(Constant.FAIL);
|
|
|
+ }
|
|
|
+ //上游返回码
|
|
|
+ request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer getVehicleInfoQueryV3Score(Map<String, String> responseObject) {
|
|
|
+ // 总行驶里程
|
|
|
+ String totalMile = responseObject.get("totalMile");
|
|
|
+ // 近3个月车辆运营总里程
|
|
|
+ String mile3 = responseObject.get("mile3");
|
|
|
+ // 车辆从事年限
|
|
|
+ String earliestOrderMonth = responseObject.get("earliestOrderMonth");
|
|
|
+
|
|
|
+ int totalMileValue = vehicleJsonHelper.getTotalMile().get(totalMile);
|
|
|
+ double earliestOrderMonthValue = vehicleJsonHelper.getEarliestOrderMonthMap().getDoubleValue(earliestOrderMonth);
|
|
|
+ double averageValue = totalMileValue / earliestOrderMonthValue;
|
|
|
+
|
|
|
+ String totalMileTag;
|
|
|
+ if (averageValue < 10000) {
|
|
|
+ totalMileTag = "t1";
|
|
|
+ } else {
|
|
|
+ totalMileTag = "t2";
|
|
|
+ }
|
|
|
+
|
|
|
+ String mileTag;
|
|
|
+ if (mile3.equals("A")) {
|
|
|
+ mileTag = "m1";
|
|
|
+ } else {
|
|
|
+ mileTag = "m2";
|
|
|
+ }
|
|
|
+
|
|
|
+ String earliestOrderMonthTag;
|
|
|
+ if (earliestOrderMonth.equals("A") || earliestOrderMonth.equals("B")) {
|
|
|
+ earliestOrderMonthTag = "e1";
|
|
|
+ } else {
|
|
|
+ earliestOrderMonthTag = "e2";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 年化里程 近3个月车辆运营总里程 车辆从事年限 分值 标识
|
|
|
+ * (0-10000] 0-500 3年-5年 100 t1m1e2
|
|
|
+ * (0-10000] 0-500 0-2年 200 t1m1e1
|
|
|
+ * (0-10000] 500-30000 3年-5年 300 t1m2e2
|
|
|
+ * (0-10000] 500-30000 0-2年 400 t1m2e1
|
|
|
+ * (10000-inf] 0-500 3年-5年 500 t2m1e2
|
|
|
+ * (10000-inf] 0-500 0-2年 600 t2m1e1
|
|
|
+ * (10000-inf] 500-30000 3年-5年 700 t2m2e2
|
|
|
+ * (10000-inf] 500-30000 0-2年 800 t2m2e1
|
|
|
+ */
|
|
|
+ int score;
|
|
|
+ String totalTag = totalMileTag + mileTag + earliestOrderMonthTag;
|
|
|
+ switch (totalTag) {
|
|
|
+ case "t1m1e2":
|
|
|
+ score = 100;
|
|
|
+ break;
|
|
|
+ case "t1m1e1":
|
|
|
+ score = 200;
|
|
|
+ break;
|
|
|
+ case "t1m2e2":
|
|
|
+ score = 300;
|
|
|
+ break;
|
|
|
+ case "t1m2e1":
|
|
|
+ score = 400;
|
|
|
+ break;
|
|
|
+ case "t2m1e2":
|
|
|
+ score = 500;
|
|
|
+ break;
|
|
|
+ case "t2m1e1":
|
|
|
+ score = 600;
|
|
|
+ break;
|
|
|
+ case "t2m2e2":
|
|
|
+ score = 700;
|
|
|
+ break;
|
|
|
+ case "t2m2e1":
|
|
|
+ score = 800;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ score = 0;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return score;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setVehicleInfoQueryV3Response(ChannelTypeHandleResponseObject ret,
|
|
|
+ VehicleInfoQueryV3RequestObject jsonResolveObject,
|
|
|
+ WycInfoResponseObject responseObject) {
|
|
|
+ int code = responseObject.getCode();
|
|
|
+ int state = responseObject.getState();
|
|
|
+
|
|
|
+ if (responseObject != null) {
|
|
|
+ if (code == 1 && state == 0) {
|
|
|
+ //库无
|
|
|
+ ret.setResultCode(Constant.UN_FIND_NUM_CODE);
|
|
|
+ ret.setResultBody("查询成功,查无结果");
|
|
|
+ ret.setResultDesc("查询成功,查无结果");
|
|
|
+ } else if (code == 0 && state == 0) {//计费分析
|
|
|
+ String message = responseObject.getMessage();
|
|
|
+ Map<String, String> mapResult = new HashMap<String, String>();
|
|
|
+ String[] result = message.substring(12, message.length()).substring(0, message.length() - 13).split(",");
|
|
|
+ for (int index = 0; index < result.length; index++) {
|
|
|
+ String[] details = result[index].split("=");
|
|
|
+ mapResult.put(details[0], details[1].replace("'", ""));
|
|
|
+ }
|
|
|
+ int vehicleInfoScore = getVehicleInfoQueryV3Score(mapResult);
|
|
|
+ int trafficRecordScore = trafficRecordService.trafficRecordQuery(jsonResolveObject.getPlateNum(),
|
|
|
+ jsonResolveObject.getPlateColor());
|
|
|
+
|
|
|
+ ret.setIsCharge(Constant.IS_CHARGE);
|
|
|
+ ret.setResultCode(Constant.MATCH_CODE);
|
|
|
+ ret.setResultBody(vehicleInfoScore + trafficRecordScore);
|
|
|
+ ret.setResultDesc("查询成功,查有结果");
|
|
|
+ } else {//其他
|
|
|
+ ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
+ ret.setResultBody("查询错误");
|
|
|
+ ret.setResultDesc("查询错误");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ret.setResultCode(Constant.OTHER_ERROR_CODE);
|
|
|
+ ret.setResultBody("查询错误");
|
|
|
+ ret.setResultDesc("查询错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean validateVehicleInfoRequestParams(ChannelTypeHandleResponseObject ret, String returnType,
|
|
|
+ VehicleInfoQueryV3RequestObject jsonResolveObject) {
|
|
|
+ if (StringUtils.isBlank(jsonResolveObject.getPlateColor())
|
|
|
+ || !ArrayUtils.contains(ChannelConstant.PLATE_COLOR, jsonResolveObject.getPlateColor())) {
|
|
|
+ ret.setResultCode(Constant.JK_RETURN_CODE_INVALID_PARAMETER);
|
|
|
+ ret.setResultDesc(Constant.INVALID_PARAMETER);
|
|
|
+ ret.setResultBody(Constant.INVALID_PARAMETER);
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private boolean validateVehicleInfoRequestParams(ChannelTypeHandleResponseObject ret, String returnType,
|
|
|
VehicleInfoQueryV2RequestObject jsonResolveObject) {
|
|
|
if (StringUtils.isBlank(jsonResolveObject.getVin())
|