|
@@ -0,0 +1,239 @@
|
|
|
+package com.jkcredit.invoice.hub.service.apiCarFree;
|
|
|
+
|
|
|
+import cn.com.taiji.sdk.comm.ETCCommHelper;
|
|
|
+import cn.com.taiji.sdk.model.comm.protocol.eoms.company.CompanyQueryRequest;
|
|
|
+import cn.com.taiji.sdk.model.comm.protocol.eoms.company.CompanyQueryResponse;
|
|
|
+import cn.com.taiji.sdk.model.comm.protocol.tts.vehicle.VehicleQueryRequest;
|
|
|
+import cn.com.taiji.sdk.model.comm.protocol.tts.vehicle.VehicleQueryResponse;
|
|
|
+import cn.com.taiji.sdk.model.comm.protocol.tts.vehicle.VehicleRegisterRequest;
|
|
|
+import cn.com.taiji.sdk.model.comm.protocol.tts.vehicle.VehicleRegisterResponse;
|
|
|
+import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.*;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.jkcredit.invoice.hub.constant.CommonConstant;
|
|
|
+import com.jkcredit.invoice.hub.service.base.BaseService;
|
|
|
+import com.jkcredit.invoice.hub.spi.lang.exception.ServiceException;
|
|
|
+import com.jkcredit.invoice.hub.spi.rest.data.ApiResponseData;
|
|
|
+import io.netty.util.internal.StringUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description: 无车api接口
|
|
|
+ * @author: xusonglin
|
|
|
+ * @create: 2020/1/16 21:52
|
|
|
+ * @version: V1.0
|
|
|
+ **/
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class ApiCarFreeServiceImpl extends BaseService implements ApiCarFreeService {
|
|
|
+ @Override
|
|
|
+ public ApiResponseData vehicleRegisterQuery(JSONObject param) {
|
|
|
+ long costTimeStart = System.currentTimeMillis();
|
|
|
+ String result;
|
|
|
+
|
|
|
+ VehicleQueryRequest request = new VehicleQueryRequest();
|
|
|
+ request.setPlateNum(param.getString("plateNumber").trim());
|
|
|
+ request.setPlateColor(param.getInteger("PlateColor"));
|
|
|
+ request.setCompanyNum(CommonConstant.COMPANY_NUMBER);
|
|
|
+ request.setWaybillSource(CommonConstant.WAYBILL_SOURCE_1);
|
|
|
+ String fileName = request.getFilename();
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 调用upload 发送数据
|
|
|
+ VehicleQueryResponse response = ETCCommHelper.upload(fileName, request, VehicleQueryResponse.class);
|
|
|
+
|
|
|
+ result = response.toJson();
|
|
|
+ long costTimeEnd = System.currentTimeMillis();
|
|
|
+ log.info("[-vehicleRegisterQuery-] result is " + result.replaceAll("\r|\n", "") + " , request is "
|
|
|
+ + param + ",costtime=" + (costTimeEnd - costTimeStart) + ",startTime=" + costTimeStart
|
|
|
+ + ",endTime=" + costTimeEnd);
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("[-vehicleRegisterQuery-] 网络异常 " + e);
|
|
|
+ throw new ServiceException(CommonConstant.QUERY_FAILED);
|
|
|
+ } catch (Exception apie) {
|
|
|
+ log.error("[-vehicleRegisterQuery-] 错误信息:" + apie.getMessage());
|
|
|
+ throw new ServiceException(CommonConstant.QUERY_FAILED);
|
|
|
+ }
|
|
|
+ return analyzeApiResult(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApiResponseData vehicleRegister(JSONObject param) {
|
|
|
+ long costTimeStart = System.currentTimeMillis();
|
|
|
+ String result;
|
|
|
+
|
|
|
+ VehicleRegisterRequest request = new VehicleRegisterRequest();
|
|
|
+ request.setPlateNum(param.getString("plateNumber").trim());
|
|
|
+ request.setPlateColor(param.getInteger("PlateColor"));
|
|
|
+ request.setCompanyNum(CommonConstant.COMPANY_NUMBER);
|
|
|
+ String fileName = request.getFilename();
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 调用upload 发送数据
|
|
|
+ VehicleRegisterResponse response = ETCCommHelper.upload(fileName, request, VehicleRegisterResponse.class);
|
|
|
+
|
|
|
+ result = response.toJson();
|
|
|
+ long costTimeEnd = System.currentTimeMillis();
|
|
|
+ log.info("[-vehicleRegister-] result is " + result.replaceAll("\r|\n", "") + " , request is "
|
|
|
+ + param + ",costtime=" + (costTimeEnd - costTimeStart) + ",startTime=" + costTimeStart
|
|
|
+ + ",endTime=" + costTimeEnd);
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("[-vehicleRegister-] 网络异常 " + e);
|
|
|
+ throw new ServiceException(CommonConstant.QUERY_FAILED);
|
|
|
+ } catch (Exception apie) {
|
|
|
+ log.error("[-vehicleRegister-] 错误信息:" + apie.getMessage());
|
|
|
+ throw new ServiceException(CommonConstant.QUERY_FAILED);
|
|
|
+ }
|
|
|
+ return analyzeApiResult(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApiResponseData wayBillStart(JSONObject param) {
|
|
|
+ long costTimeStart = System.currentTimeMillis();
|
|
|
+ // todo 入库 入库失败则返回失败,不调接口
|
|
|
+ String result;
|
|
|
+
|
|
|
+ WaybillStartRequest request = new WaybillStartRequest();
|
|
|
+ request.setCompanyNum(CommonConstant.COMPANY_NUMBER);
|
|
|
+ request.setNum(param.getString("num").trim());
|
|
|
+ request.setPlateNum(param.getString("plateNumber").trim());
|
|
|
+ request.setPlateColor(param.getInteger("PlateColor"));
|
|
|
+ request.setStartTime(param.getString("startTime").trim());
|
|
|
+ request.setSourceAddr(param.getString("sourceAddr").trim());
|
|
|
+ request.setDestAddr(param.getString("destAddr").trim());
|
|
|
+ request.setPredictEndTime(param.getString("predictEndTime").trim());
|
|
|
+ request.setFee(param.getLong("fee"));
|
|
|
+ request.setTitleType(param.getInteger("titleType"));
|
|
|
+
|
|
|
+ if (!StringUtil.isNullOrEmpty(param.getString("taxplayerCode"))) {
|
|
|
+ request.setTaxplayerCode(param.getString("taxplayerCode").trim());
|
|
|
+ }
|
|
|
+ String fileName = request.getFilename();
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 调用upload 发送数据
|
|
|
+ WaybillStartResponse response = ETCCommHelper.upload(fileName, request, WaybillStartResponse.class);
|
|
|
+
|
|
|
+ result = response.toJson();
|
|
|
+ long costTimeEnd = System.currentTimeMillis();
|
|
|
+ log.info("[-wayBillStart-] result is " + result.replaceAll("\r|\n", "") + " , request is "
|
|
|
+ + param + ",costtime=" + (costTimeEnd - costTimeStart) + ",startTime=" + costTimeStart
|
|
|
+ + ",endTime=" + costTimeEnd);
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("[-wayBillStart-] 网络异常 " + e);
|
|
|
+ throw new ServiceException(CommonConstant.QUERY_FAILED);
|
|
|
+ } catch (Exception apie) {
|
|
|
+ log.error("[-wayBillStart-] 错误信息:" + apie.getMessage());
|
|
|
+ throw new ServiceException(CommonConstant.QUERY_FAILED);
|
|
|
+ }
|
|
|
+ return analyzeApiResult(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApiResponseData wayBillEnd(JSONObject param) {
|
|
|
+ long costTimeStart = System.currentTimeMillis();
|
|
|
+ // todo 入库 入库失败则返回失败,不调接口
|
|
|
+ String result;
|
|
|
+
|
|
|
+ WaybillEndRequest request = new WaybillEndRequest();
|
|
|
+ request.setCompanyNum(CommonConstant.COMPANY_NUMBER);
|
|
|
+ request.setNum(param.getString("num").trim());
|
|
|
+ request.setRealDestAddr(param.getString("realDestAddr").trim());
|
|
|
+ request.setEndTime(param.getString("endTime").trim());
|
|
|
+ String fileName = request.getFilename();
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 调用upload 发送数据
|
|
|
+ WaybillEndResponse response = ETCCommHelper.upload(fileName, request, WaybillEndResponse.class);
|
|
|
+
|
|
|
+ result = response.toJson();
|
|
|
+ long costTimeEnd = System.currentTimeMillis();
|
|
|
+ log.info("[-waybillEnd-] result is " + result.replaceAll("\r|\n", "") + " , request is "
|
|
|
+ + param + ",costtime=" + (costTimeEnd - costTimeStart) + ",startTime=" + costTimeStart
|
|
|
+ + ",endTime=" + costTimeEnd);
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("[-waybillEnd-] 网络异常 " + e);
|
|
|
+ throw new ServiceException(CommonConstant.QUERY_FAILED);
|
|
|
+ } catch (Exception apie) {
|
|
|
+ log.error("[-waybillEnd-] 错误信息:" + apie.getMessage());
|
|
|
+ throw new ServiceException(CommonConstant.QUERY_FAILED);
|
|
|
+ }
|
|
|
+ return analyzeApiResult(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApiResponseData wayBillHistoryStart(JSONObject param) {
|
|
|
+ long costTimeStart = System.currentTimeMillis();
|
|
|
+ // todo 入库 入库失败则返回失败,不调接口
|
|
|
+ String result;
|
|
|
+
|
|
|
+ WaybillHistoryStartRequest request = new WaybillHistoryStartRequest();
|
|
|
+ request.setCompanyNum(CommonConstant.COMPANY_NUMBER);
|
|
|
+ request.setNum(param.getString("num").trim());
|
|
|
+ request.setPlateNum(param.getString("plateNumber").trim());
|
|
|
+ request.setPlateColor(param.getInteger("PlateColor"));
|
|
|
+ request.setStartTime(param.getString("startTime").trim());
|
|
|
+ request.setSourceAddr(param.getString("sourceAddr").trim());
|
|
|
+ request.setDestAddr(param.getString("destAddr").trim());
|
|
|
+ request.setPredictEndTime(param.getString("predictEndTime").trim());
|
|
|
+ request.setFee(param.getLong("fee"));
|
|
|
+ request.setTitleType(param.getInteger("titleType"));
|
|
|
+
|
|
|
+ if (!StringUtil.isNullOrEmpty(param.getString("taxplayerCode"))) {
|
|
|
+ request.setTaxplayerCode(param.getString("taxplayerCode").trim());
|
|
|
+ }
|
|
|
+ String fileName = request.getFilename();
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 调用upload 发送数据
|
|
|
+ WaybillHistoryStartResponse response = ETCCommHelper.upload(fileName, request, WaybillHistoryStartResponse.class);
|
|
|
+
|
|
|
+ result = response.toJson();
|
|
|
+ long costTimeEnd = System.currentTimeMillis();
|
|
|
+ log.info("[-wayBillHistoryStart-] result is " + result.replaceAll("\r|\n", "") + " , request is "
|
|
|
+ + param + ",costtime=" + (costTimeEnd - costTimeStart) + ",startTime=" + costTimeStart
|
|
|
+ + ",endTime=" + costTimeEnd);
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("[-wayBillHistoryStart-] 网络异常 " + e);
|
|
|
+ throw new ServiceException(CommonConstant.QUERY_FAILED);
|
|
|
+ } catch (Exception apie) {
|
|
|
+ log.error("[-wayBillHistoryStart-] 错误信息:" + apie.getMessage());
|
|
|
+ throw new ServiceException(CommonConstant.QUERY_FAILED);
|
|
|
+ }
|
|
|
+ return analyzeApiResult(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApiResponseData wayBillHistoryEnd(JSONObject param) {
|
|
|
+ long costTimeStart = System.currentTimeMillis();
|
|
|
+ // todo 入库 入库失败则返回失败,不调接口
|
|
|
+ String result;
|
|
|
+
|
|
|
+ WaybillHistoryEndRequest request = new WaybillHistoryEndRequest();
|
|
|
+ request.setCompanyNum(CommonConstant.COMPANY_NUMBER);
|
|
|
+ request.setNum(param.getString("num").trim());
|
|
|
+ request.setRealDestAddr(param.getString("realDestAddr").trim());
|
|
|
+ request.setEndTime(param.getString("endTime").trim());
|
|
|
+ String fileName = request.getFilename();
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 调用upload 发送数据
|
|
|
+ WaybillHistoryEndResponse response = ETCCommHelper.upload(fileName, request, WaybillHistoryEndResponse.class);
|
|
|
+
|
|
|
+ result = response.toJson();
|
|
|
+ long costTimeEnd = System.currentTimeMillis();
|
|
|
+ log.info("[-wayBillHistoryEnd-] result is " + result.replaceAll("\r|\n", "") + " , request is "
|
|
|
+ + param + ",costtime=" + (costTimeEnd - costTimeStart) + ",startTime=" + costTimeStart
|
|
|
+ + ",endTime=" + costTimeEnd);
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("[-wayBillHistoryEnd-] 网络异常 " + e);
|
|
|
+ throw new ServiceException(CommonConstant.QUERY_FAILED);
|
|
|
+ } catch (Exception apie) {
|
|
|
+ log.error("[-wayBillHistoryEnd-] 错误信息:" + apie.getMessage());
|
|
|
+ throw new ServiceException(CommonConstant.QUERY_FAILED);
|
|
|
+ }
|
|
|
+ return analyzeApiResult(result);
|
|
|
+ }
|
|
|
+}
|