package com.jkcredit.invoice.service.upservice.impl;

import cn.com.taiji.common.manager.net.http.binclient.ApiRequestException;
import cn.com.taiji.sdk.comm.ETCCommHelper;
import cn.com.taiji.sdk.model.comm.protocol.eoms.EomsServiceType;
import cn.com.taiji.sdk.model.comm.protocol.eoms.company.CompanyDetailAddRequest;
import cn.com.taiji.sdk.model.comm.protocol.eoms.company.CompanyDetailAddResponse;
import cn.com.taiji.sdk.model.comm.protocol.eoms.company.OperatorEditConfirmRequest;
import cn.com.taiji.sdk.model.comm.protocol.eoms.company.OperatorEditConfirmResponse;
import cn.com.taiji.sdk.model.comm.protocol.eoms.company.OperatorEditRequest;
import cn.com.taiji.sdk.model.comm.protocol.eoms.company.OperatorEditResponse;
import cn.com.taiji.sdk.model.comm.protocol.eoms.company.OperatorEvidenceRequest;
import cn.com.taiji.sdk.model.comm.protocol.eoms.company.OperatorEvidenceResponse;
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.OperatorSendCodeRequest;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.OperatorSendCodeResponse;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.OperatorValidCodeRequest;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.OperatorValidCodeResponse;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillCountPageRequest;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillCountQueryRequest;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillCountQueryResponse;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillEndRequest;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillEndResponse;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillHistoryEndRequest;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillHistoryEndResponse;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillHistoryStartRequest;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillHistoryStartResponse;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillInvoiceRedQueryRequest;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillInvoiceRedQueryResponse;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillNumFindInvoiceRequest;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillNumFindInvoiceResponse;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillOriginEndRequest;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillOriginEndResponse;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillStartRequest;
import cn.com.taiji.sdk.model.comm.protocol.tts.waybill.WaybillStartResponse;
import com.jkcredit.invoice.service.upservice.NoCarInterface;
import com.jkcredit.invoice.util.DateUtil;
import com.jkcredit.invoice.util.RespR;
import com.jkcredit.invoice.util.StringUtil;
import etc.com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author mumuxigua
 */
@Service("noCarInterface")
@Slf4j
public class NoCarInterfaceImpl implements NoCarInterface {


    @Override
    public RespR<VehicleRegisterResponse> vehicleRegister(VehicleRegisterRequest registerRequest) {
        String fileName = registerRequest.getFilename();
        long startTime = System.currentTimeMillis();
        try {
            log.info("NoCarInterfaceImpl.vehicleRegister,请求参数：{}", registerRequest.toString());
            VehicleRegisterResponse response = ETCCommHelper.upload(fileName, registerRequest, VehicleRegisterResponse.class);
            log.info("NoCarInterfaceImpl.vehicleRegister上游接口返回：{},请求参数：{},cost={}ms", response.toString(), registerRequest.toString(), System.currentTimeMillis() - startTime);

            return new RespR<>(response);
        } catch (IOException e) {
            e.printStackTrace();
            log.error(e.getMessage() + " ,请求参数：" + registerRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            apie.printStackTrace();
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + registerRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            return new RespR(false, apie.getMessage());
        }
    }

    @Override
    public RespR<VehicleQueryResponse> vehicleQuery(VehicleQueryRequest vehicleQueryRequest) {
        String fileName = vehicleQueryRequest.getFilename();
        long startTime = System.currentTimeMillis();
        try {
            log.info("NoCarInterfaceImpl.vehicleQuery上游请求参数：{}", vehicleQueryRequest.toString());
            //(4)指定协议的响应模型（IssuerUploadResponse），调用upload 发送数据
            VehicleQueryResponse response = ETCCommHelper.upload(fileName, vehicleQueryRequest, VehicleQueryResponse.class);
            log.info("NoCarInterfaceImpl.vehicleQuery上游接口返回：{},请求参数：{},cost={}ms", response.toString(), vehicleQueryRequest.toString(), System.currentTimeMillis() - startTime);

            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + vehicleQueryRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + vehicleQueryRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();

            return new RespR(false, apie.getMessage());
        }
    }

    @Override
    public RespR<WaybillStartResponse> waybillStart(WaybillStartRequest waybillStartRequest) {
        String fileName = waybillStartRequest.getFilename();
        long startTime = System.currentTimeMillis();

        try {
            log.info("NoCarInterfaceImpl.waybillStart上游请求参数：{}", waybillStartRequest.toString());
            WaybillStartResponse response = ETCCommHelper.upload(fileName, waybillStartRequest, WaybillStartResponse.class);
            log.info("NoCarInterfaceImpl.waybillStart上游接口返回：{},请求参数：{},cost={}ms", response.toString(), StringUtil.removeJSonField(waybillStartRequest.toString(),"base64Str"), System.currentTimeMillis() - startTime);
            //TODO 如果数据源调整，需要优化返回值
            if(null == response.getInfo() && null == response.getReceiveTime()){
                response.setInfo("成功");
                response.setReceiveTime(DateUtil.getCurrentDateStrFormat());
            }
            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + StringUtil.removeJSonField(waybillStartRequest.toString(),"base64Str") + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + StringUtil.removeJSonField(waybillStartRequest.toString(),"base64Str") + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();
            return new RespR(false, apie.getMessage());
        }
    }

    @Override
    public RespR<WaybillEndResponse> waybillEnd(WaybillEndRequest waybillEndRequest) {
        long startTime = System.currentTimeMillis();

        String fileName = waybillEndRequest.getFilename();
        try {
            log.info("NoCarInterfaceImpl.waybillEnd请求参数：{}", waybillEndRequest.toString());
            WaybillEndResponse response = ETCCommHelper.upload(fileName, waybillEndRequest, WaybillEndResponse.class);
            log.info("NoCarInterfaceImpl.waybillEnd上游接口返回：{},请求参数：{},cost={}ms", response.toString(), waybillEndRequest.toString(), System.currentTimeMillis() - startTime);

            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + waybillEndRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + waybillEndRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();
            return new RespR(false, apie.getMessage());
        }
    }

    @Override
    public RespR<WaybillHistoryStartResponse> waybillHistoryStart(WaybillHistoryStartRequest waybillHistoryStartRequest) {
        String fileName = waybillHistoryStartRequest.getFilename();
        long startTime = System.currentTimeMillis();

        try {
            log.info("NoCarInterfaceImpl.waybillHistoryStart上游接口请求参数：{}", waybillHistoryStartRequest.toString());

            //(4)指定协议的响应模型（IssuerUploadResponse），调用upload 发送数据
            WaybillHistoryStartResponse response = ETCCommHelper.upload(fileName, waybillHistoryStartRequest, WaybillHistoryStartResponse.class);
            log.info("NoCarInterfaceImpl.waybillHistoryStart上游接口返回：{},请求参数：{},cost={}ms", response.toString(), StringUtil.removeJSonField(waybillHistoryStartRequest.toString(),"base64Str"), System.currentTimeMillis() - startTime);
            //TODO 如果数据源调整，需要优化返回值
            if(null == response.getInfo() && null == response.getReceiveTime()){
                response.setInfo("成功");
                response.setReceiveTime(DateUtil.getCurrentDateStrFormat());
            }
            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + StringUtil.removeJSonField(waybillHistoryStartRequest.toString(),"base64Str") + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + StringUtil.removeJSonField(waybillHistoryStartRequest.toString(),"base64Str") + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();
            return new RespR(false, apie.getMessage());
        }
    }
    @Override
    public RespR<WaybillOriginEndResponse> waybillOrgEnd(WaybillOriginEndRequest waybillOriginEndRequest) {
        String fileName = waybillOriginEndRequest.getFilename();
        long startTime = System.currentTimeMillis();
        try {
            log.info("NoCarInterfaceImpl.waybillOrgEnd请求参数：{}", StringUtil.removeJSonField(waybillOriginEndRequest.toString(),"base64Str"));
            //(4)指定协议的响应模型（IssuerUploadResponse），调用upload 发送数据
            WaybillOriginEndResponse response = ETCCommHelper.upload(fileName, waybillOriginEndRequest, WaybillOriginEndResponse.class);
            log.info("NoCarInterfaceImpl.waybillOrgEnd上游接口返回：{},请求参数：{},cost={}ms", response.toString(), StringUtil.removeJSonField(waybillOriginEndRequest.toString(),"base64Str"), System.currentTimeMillis() - startTime);

            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + StringUtil.removeJSonField(waybillOriginEndRequest.toString(),"base64Str") + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + StringUtil.removeJSonField(waybillOriginEndRequest.toString(),"base64Str") + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();
            return new RespR(false, apie.getMessage());
        }
    }
    @Override
    public RespR<WaybillHistoryEndResponse> waybillHistoryEnd(WaybillHistoryEndRequest waybillHistoryEndRequest) {
        String fileName = waybillHistoryEndRequest.getFilename();
        long startTime = System.currentTimeMillis();

        try {
            log.info("NoCarInterfaceImpl.waybillHistoryEnd请求参数：{}", waybillHistoryEndRequest.toString());
            //(4)指定协议的响应模型（IssuerUploadResponse），调用upload 发送数据
            WaybillHistoryEndResponse response = ETCCommHelper.upload(fileName, waybillHistoryEndRequest, WaybillHistoryEndResponse.class);
            log.info("NoCarInterfaceImpl.waybillHistoryEnd上游接口返回：{},请求参数：{},cost={}ms", response.toString(), waybillHistoryEndRequest.toString(), System.currentTimeMillis() - startTime);

            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + waybillHistoryEndRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + waybillHistoryEndRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();
            return new RespR(false, apie.getMessage());
        }
    }

    @Override
    public RespR<WaybillNumFindInvoiceResponse> waybillNumFindInvoice(WaybillNumFindInvoiceRequest waybillNumFindInvoiceRequest) {
        String fileName = waybillNumFindInvoiceRequest.getFilename();
        long startTime = System.currentTimeMillis();

        try {
            log.info("NoCarInterfaceImpl.waybillNumFindInvoice请求参数：{}", waybillNumFindInvoiceRequest.toString());
            //(4)指定协议的响应模型（IssuerUploadResponse），调用upload 发送数据
            WaybillNumFindInvoiceResponse response = ETCCommHelper.upload(fileName, waybillNumFindInvoiceRequest, WaybillNumFindInvoiceResponse.class);
            log.info("NoCarInterfaceImpl.waybillNumFindInvoice上游接口返回：{},请求参数：{},cost={}ms", response.toString(), waybillNumFindInvoiceRequest.toString(), System.currentTimeMillis() - startTime);

            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + waybillNumFindInvoiceRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + waybillNumFindInvoiceRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();
            return new RespR(false, apie.getMessage());
        }
    }

    @Override
    public RespR<WaybillInvoiceRedQueryResponse> waybillInvoiceRedQuery(WaybillInvoiceRedQueryRequest waybillInvoiceRedQueryRequest) {
        String fileName = waybillInvoiceRedQueryRequest.getFilename();
        long startTime = System.currentTimeMillis();

        try {
            //(4)指定协议的响应模型（IssuerUploadResponse），调用upload 发送数据
            log.info("NoCarInterfaceImpl.waybillInvoiceRedQuery请求参数：{}", waybillInvoiceRedQueryRequest.toString());
            WaybillInvoiceRedQueryResponse response = ETCCommHelper.upload(fileName, waybillInvoiceRedQueryRequest, WaybillInvoiceRedQueryResponse.class);
            log.info("NoCarInterfaceImpl.waybillInvoiceRedQuery上游接口返回：{},请求参数：{},cost={}ms", response.toString(), waybillInvoiceRedQueryRequest.toString(), System.currentTimeMillis() - startTime);

            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + waybillInvoiceRedQueryRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + waybillInvoiceRedQueryRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();
            return new RespR(false, apie.getMessage());
        }
    }

    @Override
    public RespR<WaybillCountQueryResponse> waybillCountQuery(WaybillCountQueryRequest waybillCountQueryRequest) {
        String fileName = waybillCountQueryRequest.getFilename();
        long startTime = System.currentTimeMillis();

        try {
            log.info("NoCarInterfaceImpl.waybillCountQuery上游请求参数：{}", waybillCountQueryRequest.toString());
            //(4)指定协议的响应模型（IssuerUploadResponse），调用upload 发送数据
            WaybillCountQueryResponse response = ETCCommHelper.upload(fileName, waybillCountQueryRequest, WaybillCountQueryResponse.class);
            log.info("NoCarInterfaceImpl.waybillCountQuery上游接口返回：{},请求参数：{},cost={}ms", response.toString(), waybillCountQueryRequest.toString(), System.currentTimeMillis() - startTime);

            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + waybillCountQueryRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + waybillCountQueryRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();
            return new RespR(false, apie.getMessage());
        }
    }

    @Override
    public RespR<WaybillCountQueryResponse> waybillCountQuery(WaybillCountPageRequest waybillCountQueryRequest) {
        String fileName = waybillCountQueryRequest.getFilename();
        long startTime = System.currentTimeMillis();

        try {
            log.info("NoCarInterfaceImpl.waybillCountQuery上游请求参数：{}", waybillCountQueryRequest.toString());
            //(4)指定协议的响应模型（IssuerUploadResponse），调用upload 发送数据
            WaybillCountQueryResponse response = ETCCommHelper.upload(fileName, waybillCountQueryRequest, WaybillCountQueryResponse.class);
            log.info("NoCarInterfaceImpl.waybillCountQuery上游接口返回：{},请求参数：{},cost={}ms", response.toString(), waybillCountQueryRequest.toString(), System.currentTimeMillis() - startTime);

            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + waybillCountQueryRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + waybillCountQueryRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();
            return new RespR(false, apie.getMessage());
        }
    }


    @Override
    public RespR<CompanyDetailAddResponse> companyDetailAdd(CompanyDetailAddRequest companyDetailAddRequest) {
        String fileName = EomsServiceType.COMPANY + "_" + CompanyCmd.COMPANYDETAILADD + "_REQ_" + this.getTimeMillStr() + ".json";
        long startTime = System.currentTimeMillis();

        try {
            log.info("NoCarInterfaceImpl.companyDetailAddRequest上游请求参数：{}", companyDetailAddRequest.toString());
            //(4)指定协议的响应模型（IssuerUploadResponse），调用upload 发送数据
            CompanyDetailAddResponse response = ETCCommHelper.upload(fileName, companyDetailAddRequest, CompanyDetailAddResponse.class);
            log.info("NoCarInterfaceImpl.companyDetailAddRequest上游接口返回：{},请求参数：{},cost={}ms", response.toString(), companyDetailAddRequest.toString(), System.currentTimeMillis() - startTime);

            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + companyDetailAddRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + companyDetailAddRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();
            return new RespR(false, apie.getMessage());
        }
    }

    @Override
    public RespR<OperatorEditResponse> operatorEdit(OperatorEditRequest operatorEditRequest) {
        String fileName = EomsServiceType.COMPANY + "_" + CompanyCmd.COMPANYOPERATOREDIT + "_REQ_" + this.getTimeMillStr() + ".json";
        long startTime = System.currentTimeMillis();

        try {
            log.info("NoCarInterfaceImpl.operatorEditRequest上游请求参数：{}", operatorEditRequest.toString());
            //(4)指定协议的响应模型（IssuerUploadResponse），调用upload 发送数据
            OperatorEditResponse response = ETCCommHelper.upload(fileName, operatorEditRequest, OperatorEditResponse.class);
            log.info("NoCarInterfaceImpl.operatorEditRequest上游接口返回：{},请求参数：{},cost={}ms", response.toString(), operatorEditRequest.toString(), System.currentTimeMillis() - startTime);

            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + operatorEditRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + operatorEditRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();
            return new RespR(false, apie.getMessage());
        }
    }

    @Override
    public RespR<OperatorEditConfirmResponse> operatorEditConfirm(OperatorEditConfirmRequest operatorEditConfirmRequest) {
        String fileName = EomsServiceType.COMPANY + "_" + CompanyCmd.COMPANYOPERATOREDITCONFIRM + "_REQ_" + this.getTimeMillStr() + ".json";
        ;
        long startTime = System.currentTimeMillis();

        try {
            log.info("NoCarInterfaceImpl.operatorEditConfirmRequest上游请求参数：{}", operatorEditConfirmRequest.toString());
            //(4)指定协议的响应模型（IssuerUploadResponse），调用upload 发送数据
            OperatorEditConfirmResponse response = ETCCommHelper.upload(fileName, operatorEditConfirmRequest, OperatorEditConfirmResponse.class);
            log.info("NoCarInterfaceImpl.operatorEditConfirmRequest上游接口返回：{},请求参数：{},cost={}ms", response.toString(), operatorEditConfirmRequest.toString(), System.currentTimeMillis() - startTime);

            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + operatorEditConfirmRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + operatorEditConfirmRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();
            return new RespR(false, apie.getMessage());
        }
    }

    @Override
    public RespR<OperatorEvidenceResponse> operatorEvidence(OperatorEvidenceRequest operatorEvidenceRequest) {
        String fileName = EomsServiceType.COMPANY + "_" + CompanyCmd.UPLOADOPERATOREVIDENCE + "_REQ_" + this.getTimeMillStr() + ".json";
        long startTime = System.currentTimeMillis();

        try {
            log.info("NoCarInterfaceImpl.operatorEvidenceRequest上游请求参数：{}", operatorEvidenceRequest.toString());
            //(4)指定协议的响应模型（IssuerUploadResponse），调用upload 发送数据
            OperatorEvidenceResponse response = ETCCommHelper.upload(fileName, operatorEvidenceRequest, OperatorEvidenceResponse.class);
            log.info("NoCarInterfaceImpl.operatorEvidenceRequest上游接口返回：{},请求参数：{},cost={}ms", response.toString(), operatorEvidenceRequest.toString(), System.currentTimeMillis() - startTime);

            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + operatorEvidenceRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + operatorEvidenceRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();
            return new RespR(false, apie.getMessage());
        }
    }

    @Override
    public RespR<OperatorSendCodeResponse> operatorSendCode(OperatorSendCodeRequest operatorSendCodeRequest) {
        String fileName = operatorSendCodeRequest.getFilename();
        long startTime = System.currentTimeMillis();

        try {
            log.info("NoCarInterfaceImpl.operatorSendCodeRequest上游请求参数：{}", operatorSendCodeRequest.toString());
            //(4)指定协议的响应模型（IssuerUploadResponse），调用upload 发送数据
            OperatorSendCodeResponse response = ETCCommHelper.upload(fileName, operatorSendCodeRequest, OperatorSendCodeResponse.class);
            log.info("NoCarInterfaceImpl.operatorSendCodeRequest上游接口返回：{},请求参数：{},cost={}ms", response.toString(), operatorSendCodeRequest.toString(), System.currentTimeMillis() - startTime);

            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + operatorSendCodeRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + operatorSendCodeRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();
            return new RespR(false, apie.getMessage());
        }
    }

    @Override
    public RespR<OperatorValidCodeResponse> operatorValidCode(OperatorValidCodeRequest operatorValidCodeRequest) {
        String fileName = operatorValidCodeRequest.getFilename();
        long startTime = System.currentTimeMillis();

        try {
            log.info("NoCarInterfaceImpl.operatorValidCodeRequest上游请求参数：{}", operatorValidCodeRequest.toString());
            //(4)指定协议的响应模型（IssuerUploadResponse），调用upload 发送数据
            OperatorValidCodeResponse response = ETCCommHelper.upload(fileName, operatorValidCodeRequest, OperatorValidCodeResponse.class);
            log.info("NoCarInterfaceImpl.operatorValidCodeRequest上游接口返回：{},请求参数：{},cost={}ms", response.toString(), operatorValidCodeRequest.toString(), System.currentTimeMillis() - startTime);

            return new RespR<>(response);
        } catch (IOException e) {
            log.error(e.getMessage() + " ,请求参数：" + operatorValidCodeRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            e.printStackTrace();
            return new RespR(false, "网络异常,请联系管理人员");
        } catch (ApiRequestException apie) {
            log.error(apie.getMessage().replaceAll("[\r\n]", "") + " ,请求参数：" + operatorValidCodeRequest.toString() + " ,cost=" + (System.currentTimeMillis() - startTime) + "ms");
            apie.printStackTrace();
            return new RespR(false, apie.getMessage());
        }
    }


    @JsonIgnore
    protected String getTimeMillStr() {
        return (new SimpleDateFormat("yyyyMMddHHmmssSSS")).format(new Date());
    }

}
