package com.e6yun.project.sdk.api;


import com.e6yun.project.sdk.api.constant.ParamConstant;
import com.e6yun.project.sdk.api.core.E6SdkCore;
import com.e6yun.project.sdk.api.exception.ApiException;
import com.e6yun.project.sdk.api.pojo.basevo.basic.AreaListByLonLat;
import com.e6yun.project.sdk.api.pojo.basevo.basic.EquipInfoReal;
import com.e6yun.project.sdk.api.pojo.basevo.business.AiPictureVOList;
import com.e6yun.project.sdk.api.pojo.basevo.business.DownVideo;
import com.e6yun.project.sdk.api.pojo.basevo.business.GBVideo;
import com.e6yun.project.sdk.api.pojo.basevo.business.OverTemp;
import com.e6yun.project.sdk.api.pojo.basevo.cold.PointTempHumList;
import com.e6yun.project.sdk.api.pojo.basevo.cold.StorePointTempHumList;
import com.e6yun.project.sdk.api.pojo.basevo.iot.HumidityList;
import com.e6yun.project.sdk.api.pojo.basevo.iot.OilCalList;
import com.e6yun.project.sdk.api.pojo.basevo.iot.TemperatureList;
import com.e6yun.project.sdk.api.pojo.basevo.iot.TrackByDataTerminalId;
import com.e6yun.project.sdk.api.pojo.basevo.logistics.Bill;
import com.e6yun.project.sdk.api.pojo.basevo.logistics.PBill;
import com.e6yun.project.sdk.api.pojo.basevo.saftey.ActiveSafetyEventForSt;
import com.e6yun.project.sdk.api.pojo.basevo.smart.UpdateDriverVO;
import com.e6yun.project.sdk.api.pojo.basevo.smart.UpdateVehicleVO;
import com.e6yun.project.sdk.api.pojo.basic.*;
import com.e6yun.project.sdk.api.pojo.business.*;
import com.e6yun.project.sdk.api.pojo.cold.*;
import com.e6yun.project.sdk.api.pojo.function.SendFlashDirectiveVO;
import com.e6yun.project.sdk.api.pojo.function.SendVechileVoiceVO;
import com.e6yun.project.sdk.api.pojo.function.SendVoiceDirectiveVO;
import com.e6yun.project.sdk.api.pojo.iot.GetHumidityListVO;
import com.e6yun.project.sdk.api.pojo.iot.GetOilCalListVO;
import com.e6yun.project.sdk.api.pojo.iot.GetTemperatureListVO;
import com.e6yun.project.sdk.api.pojo.iot.GetTrackByDataTerminalIdVO;
import com.e6yun.project.sdk.api.pojo.logistics.GetDriverLimitVO;
import com.e6yun.project.sdk.api.pojo.logistics.PayBillVO;
import com.e6yun.project.sdk.api.pojo.logistics.RechargeMoneyVO;
import com.e6yun.project.sdk.api.pojo.logistics.RevokeBillVO;
import com.e6yun.project.sdk.api.pojo.saftey.*;
import com.e6yun.project.sdk.api.pojo.smart.*;
import com.google.gson.Gson;
import org.apache.commons.lang3.StringUtils;

import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * V4接口SDK
 * @author xuexiang@e6yun.com
 */
public class E6SdkApi extends E6SdkCore {

    /**
     * 构造函数
     *
     * @param address
     * @param appKey
     * @param secretKey
     * @throws IllegalArgumentException
     */
    public E6SdkApi(String address, String appKey, String secretKey) throws IllegalArgumentException {
        super(address, appKey, secretKey);
    }


    //成功
    public GetVehicleInfoVO GetVehcileInfo(String  vehicleNo) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"GetVehcileInfo");
        param.put("vehicleNo", vehicleNo);
        param.put("sessionId", "");
        param.put("isOffsetLonLat", "1");
        param.put("vehicleNoType", "0");
        return this.callPost("/public/v4/MONITOR/api/vehicleMonitor/getVehicleInfo",param, GetVehicleInfoVO.class);
    }


    /**
     * @Description //BUSINESS
     **/
    public LeaveAreaRealDataVO leaveAreaRealData(String vehicles, String CategoryCode, String btime, String etime, String timestamp) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"leaveAreaRealData");
        param.put("vehicles", vehicles);
        param.put("categoryCode", CategoryCode);
        param.put("btime", btime);
        param.put("etime", etime);
        param.put("timestamp", timestamp);
        return this.callGet("/public/v4/BUSINESS/api/leaveAreaRealData/getData",param, LeaveAreaRealDataVO.class);
    }

    /**
     * 车辆回放 新
     **/
    public PlaybackVideoUrlVO getPlaybackVideoUrl(String vehicle, String channelIds, String startTime, String endTime,
                                                    String videoQuality) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getPlaybackVideoUrl");
        param.put("vehicle", vehicle);
        param.put("channelIds", channelIds);
        param.put("startTime", startTime);
        param.put("endTime", endTime);
        param.put("videoQuality", videoQuality);
        return this.callGet("/public/v4/BUSINESS/api/media/video/getPlaybackVideoUrl",param, PlaybackVideoUrlVO.class);
    }

    /**
     * 车辆实时视频 新
     **/
    public GetNewVideoUrlVO getNewVideoUrl(String vehicle, String channelIds, String expiry, String videoQuality) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getOpenVideoUrl");
        param.put("vehicle", vehicle);
        param.put("channelIds", channelIds);
        param.put("expiry", expiry);
        param.put("videoQuality", videoQuality);
        return this.callGet("/public/v4/BUSINESS/api/media/video/getNewVideoUrl",param, GetNewVideoUrlVO.class);
    }


    //成功
    public FindRenewAudioVO findRenewAudio(String  vehicle, String channelIds) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getRenewAudio");
        param.put("vehicle",vehicle);
        param.put("channelIds",channelIds);
        return this.callPost("/public/v4/BUSINESS/api/audio/findRenewAudio",param, FindRenewAudioVO.class);
    }

    //未查询到任何视频文件
    public DownloadVideoVO downloadVideo(DownVideo downVideo) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"downloadVideoManual");
        param.put("vehicle",downVideo.getVehicle());
        param.put("channelIds",downVideo.getChannelIds());
        param.put("startTime",downVideo.getStartTime());
        param.put("endTime",downVideo.getEndTime());
        param.put("callbackUrl",downVideo.getCallbackUrl());
        return this.callPost("/public/v4/BUSINESS/api/media/video/downloadVideo",param, DownloadVideoVO.class);
    }

    //成功
    public GetRealTimeVideoFlowUrlVO getRealTimeVideoFlowUrl(String vehicle, String channelIds) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getRealTimeVideoFlowUrl");
        param.put("vehicle",vehicle);
        param.put("channelIds",channelIds);
        return this.callPost("/public/v4/BUSINESS/api/media/video/getRealTimeVideoFlowUrl",param, GetRealTimeVideoFlowUrlVO.class);
    }

    //成功没有数据
    public GetAlarmVideoUrlVO getAlarmVideoUrl(String vehicleNo,String startTime,String endTime,String type) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getAlarmVideoUrl");
        param.put("vehicleNo",vehicleNo);
        param.put("startTime",startTime);
        param.put("endTime",endTime);
        param.put("type",type);
        return this.callGet("/public/v4/BUSINESS/api/media/video/getAlarmVideoUrl",param,GetAlarmVideoUrlVO.class);
    }

    //ok
    public FindFlashInfoVO findFlashInfo(String vehicle,String startTime,String endTime) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"findFlashInfo");
        param.put("vehicle",vehicle);
        param.put("startTime",startTime);
        param.put("endTime",endTime);
        return this.callPost("/public/v4/BUSINESS/media/vehicleFlash/findFlashInfo",param,FindFlashInfoVO.class);
    }

   //ok
    public FindVideosVO findVideos(String vehicle,String channelIds,String startTime,String endTime) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"findVideos");
        param.put("vehicle",vehicle);
        param.put("channelIds",channelIds);
        param.put("startTime",startTime);
        param.put("endTime",endTime);
        return this.callPost("/public/v4/BUSINESS/replay/video/findVideos",param,FindVideosVO.class);
    }

    //ok
    public OpenIntercomVO openIntercom(String vehicle,String channelIds) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"openAudio");
        param.put("vehicle",vehicle);
        param.put("channelIds",channelIds);
        return this.callPost("/public/v4/BUSINESS/api/audio/openIntercom",param,OpenIntercomVO.class);
    }

    //ok
    public FindIntercomUrlVO findIntercomUrl(String vehicle,String channelIds) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getAudioUrl");
        param.put("vehicle",vehicle);
        param.put("channelIds",channelIds);
        return this.callPost("/public/v4/BUSINESS/api/audio/findIntercomUrl",param,FindIntercomUrlVO.class);
    }

    //成功
    public CloseIntercomVO closeIntercom(String vehicle,String channelIds) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getCloseAudio");
        param.put("vehicle",vehicle);
        param.put("channelIds",channelIds);
        return this.callPost("/public/v4/BUSINESS/api/audio/closeIntercom",param,CloseIntercomVO.class);
    }

//    GetAiPictureVOListVO{super=ApiResponse{code=0, message=请求参数不能为空, data=null}}，原因：请求参数不能为空，接口bug，自建项目使用，暂时跳过
    public GetAiPictureVOListVO getAiPictureVOList(AiPictureVOList aiPictureVOList) throws ApiException {
        Map<String, String> param = new HashMap<>();
        Gson gson = new Gson();
        param.put(ParamConstant.METHOD,"getAiPictureVOList");
//        param.put("aiPictureVOListVO", gson.toJson(aiPictureVOListVO));
        param.put("startTime",aiPictureVOList.getStartTime());
        param.put("endTime",aiPictureVOList.getEndTime());
        param.put("firstType",String.valueOf(aiPictureVOList.getFirstType()));
        param.put("secondType",String.valueOf(aiPictureVOList.getSecondType()));
        param.put("DataType",String.valueOf(aiPictureVOList.getDataType()));
        param.put("curPage",String.valueOf(aiPictureVOList.getCurPage()));
        param.put("pageSize",String.valueOf(aiPictureVOList.getPageSize()));
        param.put("sortIndx",aiPictureVOList.getSortIndx());
        param.put("sortDir",aiPictureVOList.getSortDir());
        param.put("vehicleId", String.valueOf(aiPictureVOList.getVehicleId()));
        return this.callPost("/public/v4/BUSINESS/media/picture/getAiPictureVOList",param,GetAiPictureVOListVO.class);
    }


    /**
     * @Description //IOT
     **/

//    GetHumidityListVO{super=ApiResponse{code=0, message=请求的参数错误, data=null}}原因：接口bug，取缓存的dataterminalid不对
    public GetHumidityListVO getHumidityList(HumidityList humidityList) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getHumidityList");
        param.put("vehicleId",String.valueOf(humidityList.getVehicleId()));
        param.put("carId",String.valueOf(humidityList.getCarId()));
        param.put("bTime",humidityList.getbTime());
        param.put("eTime",humidityList.geteTime());
        param.put("intervalTime",String.valueOf(humidityList.getIntervalTime()));
        return this.callPost("/public/v4/IOT-TRACK/tempAndHumidity/getHumidityList",param,GetHumidityListVO.class);
    }

//    GetOilCalListVO{super=ApiResponse{code=0, message=请求dataTerminalId为空, data=null}}原因：接口bug，取缓存的dataterminalid不对
    public GetOilCalListVO getOilCalList(OilCalList oilCalList) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getOilCalList");
        param.put("vehicleId",String.valueOf(oilCalList.getVehicleId()));
        param.put("carId",String.valueOf(oilCalList.getCarId()));
        param.put("sTime",oilCalList.getsTime());
        param.put("eTime",oilCalList.geteTime());
        param.put("second",String.valueOf(oilCalList.getSecond()));
        param.put("oilStatus",String.valueOf(oilCalList.getOilStatus()));
        return this.callPost("/public/v4/IOT-TRACK/oilConnect/getOilCalList",param,GetOilCalListVO.class);
    }

    /**
     * @Description //FUNCTION
     **/

    //ok
    public SendVoiceDirectiveVO sendVoiceDirective(String vehicles,String content) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"sendVoiceDirective");
        param.put("vehicles",vehicles);
        param.put("content",content);
        return this.callPost("/public/v4/FUNCTION/instruction/sendVoiceDirective",param,SendVoiceDirectiveVO.class);
    }


    //ok
    public SendFlashDirectiveVO sendFlashDirective(String vehicle,String channelIds) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"sendFlashDirective");
        param.put("vehicle",vehicle);
        param.put("channelIds",channelIds);
        return this.callPost("/public/v4/FUNCTION/instruction/sendFlashDirective",param,SendFlashDirectiveVO.class);
    }

    //ok
    public SendVechileVoiceVO sendVechileVoice(String vehicles, String content, String format) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"sendVechileVoice");
        param.put("vehicles",vehicles);
        param.put("content",content);
        param.put("format",format);
        return this.callPost("/public/v4/FUNCTION/api/lcdcmd/sendVechileVoice",param,SendVechileVoiceVO.class);
    }

    /**
     * @Description //SAFETY
     **/

    // ok
    public ListActiveSafetyEventVO listActiveSafetyEvent(String startTime,String endTime,String vehicle,Integer isoffsetlonlat) throws ApiException {
        Map<String, String> param2 = new HashMap<>();
        Map<String, Object> param = new HashMap<>();
        param2.put(ParamConstant.METHOD,"listActiveSafetyEvent");
        param2.put("starttime",startTime);
        param2.put("endtime",endTime);
        param2.put("vehicle",vehicle);
        param2.put("isoffsetlonlat",String.valueOf(isoffsetlonlat));
        param.put("starttime",Long.valueOf(startTime));
        param.put("endtime",Long.valueOf(endTime));
        param.put("vehicle",vehicle);
        param.put("isoffsetlonlat",isoffsetlonlat);
        return this.callPostJson("/public/v4/BL-MODULE-ACTIVE-SAFETY-WEB/api/activeSafetyEvent/listActiveSafetyEvent", param, param2,ListActiveSafetyEventVO.class);
    }

    //ok
    public GetStatStatementVO getStatStatement(String startTime,String endTime) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getStatStatement");
        param.put("startTime",startTime);
        param.put("endTime",endTime);
        return this.callPost("/public/v4/BL-MODULE-ACTIVE-SAFETY-WEB/api/drivingBehavior/getStatStatement",param,GetStatStatementVO.class);
    }

    //ok
    public GetTravelListVO getTravelList(String starttime, String endtime) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getTravelList");
        param.put("starttime",starttime);
        param.put("endtime",endtime);
        return this.callPost("/public/v4/BL-MODULE-ACTIVE-SAFETY-WEB/api/vehicleTravel/getTravelList",param,GetTravelListVO.class);
    }

//{"code":104,"message":"没有权限访问该接口"}
    public GetDrivingTimeListVO getDrivingTimeList(String vehicleNo, String startTime, String endTime, String format) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getDrivingTimeList");
        param.put("vehicleNo",vehicleNo);
        param.put("endTime",endTime);
        param.put("format",format);
        param.put("startTime",startTime);
        return this.callGet("/public/v4/BL-MODULE-ACTIVE-SAFETY-WEB/api/drivingTimeRecord/getDrivingTimeList",param, GetDrivingTimeListVO.class);
    }

    /**
     * @Description //BASIC
     **/

    /**
     * @Description //COLD
     **/
//    ok
    public GetStorePointTempHumListVO getStorePointTempHumList(StorePointTempHumList storeName) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getStorePointTempHumList");
        param.put("storeName",storeName.getStoreName());
        param.put("storeCode",storeName.getStoreCode());
        param.put("freezerName",storeName.getFreezerName());
        param.put("pointName",storeName.getPointName());
        param.put("btime",storeName.getBtime());
        param.put("etime",storeName.getEtime());
        return this.callPost("/public/v4/BL-MODULE-COLD-CHAIN-WEB/api/cold/storeTempHum/getStorePointTempHumList",param,GetStorePointTempHumListVO.class);
    }
//    ok
    public GetStoreTempHumVO getStoreTempHum(String storeName, String storeCode, String freezerName, String pointNames) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getStoreTempHum");
        param.put("storeName",storeName);
        param.put("storeCode",storeCode);
        param.put("freezerName",freezerName);
        param.put("pointNames",pointNames);
        return this.callPost("/public/v4/BL-MODULE-COLD-CHAIN-WEB/api/cold/storeTempHum/getStoreTempHum",param,GetStoreTempHumVO.class);
    }
//    ok
    public GetStoreInfoListVO getStoreInfoList(String storeName, String storeCode) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getStoreInfoList");
        param.put("storeName",storeName);
        param.put("storeCode",storeCode);
        return this.callPost("/public/v4/BL-MODULE-COLD-CHAIN-WEB/api/cold/storeManage/getStoreInfoList",param,GetStoreInfoListVO.class);
    }
//    ok
    public GetPointTempHumListVO getPointTempHumList(PointTempHumList pointName) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getPointTempHumList");
        param.put("storageName",pointName.getStorageName());
        param.put("storageCode",pointName.getStorageCode());
        param.put("locationName",pointName.getLocationName());
        param.put("pointName",pointName.getPointName());
        param.put("btime",pointName.getBtime());
        param.put("etime",pointName.getEtime());
        return this.callPost("/public/v4/BL-MODULE-COLD-CHAIN-WEB/api/cold/storageTempHum/getPointTempHumList",param,GetPointTempHumListVO.class);
    }
//    ok
    public GetStorageTempHumVO getStorageTempHum(String storageName, String storageCode, String locationName, String pointNames) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getStorageTempHum");
        param.put("storageName",storageName);
        param.put("storageCode",storageCode);
        param.put("locationName",locationName);
        param.put("pointNames",pointNames);
        return this.callPost("/public/v4/BL-MODULE-COLD-CHAIN-WEB/api/cold/storageTempHum/getStorageTempHum",param,GetStorageTempHumVO.class);
    }
//    ok
    public GetStorageInfoListVO getStorageInfoList(String storageName, String storageCode) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getStorageInfoList");
        param.put("storageName",storageName);
        param.put("storageCode",storageCode);
        return this.callPost("/public/v4/BL-MODULE-COLD-CHAIN-WEB/api/cold/storageManage/getStorageInfoList",param,GetStorageInfoListVO.class);
    }


    /**
     * @Description //COMMON
     **/
//    ok
    public GetTerBasicInfoVO getTerBasicInfo(String vehicleNo) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getTerBasicInfo");
        param.put("vehicleNo", vehicleNo);
        return this.callPost("/public/v4/COMMON-MODULE-TERMINAL-WEB/api/terBasicInfo/getTerBasicInfo",param, GetTerBasicInfoVO.class);
    }
// ok
    public FindAllTerminalVO findAllTerminal() throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"findAllTerminal");
        return this.callGet("/public/v4/COMMON-MODULE-TERMINAL-WEB/api/terBasicInfo/findAllTerminal",param, FindAllTerminalVO.class);
    }
//ok
    public GetNewVideoUrlVO getNewVideoUrl(String vehicle, String expiry, String videoQuality) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getOpenVideoUrl");
        param.put("vehicle", vehicle);
        param.put("expiry", expiry);
        param.put("videoQuality", videoQuality);
        return this.callGet("/public/v4/COMMON-MODULE-MEDIA-WEB/api/media/video/getNewVideoUrl",param, GetNewVideoUrlVO.class);
    }
//ok
    public CloseVideoUrlVO closeVideoUrl(String guid) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"closeVideoUrl");
        param.put("guid", guid);
        return this.callGet("/public/v4/COMMON-MODULE-MEDIA-WEB/api/media/video/closeVideoUrl",param, CloseVideoUrlVO.class);
    }
//    数据对 但解析失败 原因：gson date 接 long失败  和 fastjson 有区别
    public FindAllTerminalAndVehicleVO findAllTerminalAndVehicle(String synTime) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"findAllTerminalAndVehicle");
        param.put("synTime", synTime);
        return this.callGet("/public/v4/COMMON-MODULE-TERMINAL-WEB/api/terAndVeInfo/findAllTerminalAndVehicle",param, FindAllTerminalAndVehicleVO.class);
    }

//    ok
    public GetAreaListByLonLatVO getAreaListByLonLat(AreaListByLonLat areaListByLonLat) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getAreaListByLonLat");
        param.put("vehicleNo", areaListByLonLat.getVehicleNo());
        param.put("format", areaListByLonLat.getFormat());
        param.put("offSetLonLat", areaListByLonLat.getOffSetLonLat());
        param.put("lon", areaListByLonLat.getLon());
        param.put("lat", areaListByLonLat.getLat());
        return this.callGet("/public/v4/COMMON-MODULE-BASIC-ELEMENT-WEB/api/area/getAreaListByLonLat",param,GetAreaListByLonLatVO.class);
    }

    //没有权限
    public GetPlaybackVideoVO getPlaybackVideo(String  vehicle, String channelIds,String startTime, String endTime) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getRenewAudio");
        param.put("vehicle",vehicle);
        param.put("channelIds",channelIds);
        param.put("startTime",startTime);
        param.put("endTime",endTime);
        return this.callPost("/public/v4/BUSINESS/api/media/video/getPlaybackVideoUrl",param, GetPlaybackVideoVO.class);
    }

// ok
    public SetOverTempVO setOverTemp(OverTemp overTemp, TempSetting tempSetting, NotifyLinkman NotifyLinkman) throws ApiException {
        Map<String, String> param = new HashMap<>();
        Gson gson = new Gson();
        param.put(ParamConstant.METHOD,"setOverTemp");
        param.put("vehicleNos", overTemp.getVehicleNos());
        param.put("isApply", overTemp.getIsApply());
        param.put("tempSetting", gson.toJson(tempSetting));
        param.put("isNotifyLinkman",overTemp.getIsNotifyLinkman());
        param.put("notifyLinkman", gson.toJson(NotifyLinkman));
        param.put("isPlatformShow", overTemp.getIsPlatformShow());
        param.put("isAlarmSound", overTemp.getIsAlarmSound());
        param.put("remark", overTemp.getRemark());
        return this.callPost("/public/v4/COMMON-MODULE-ALARM-WEB/alarm/api/setOverTemp",param,SetOverTempVO.class);
    }

//} 原因：接口返回的是result 不是 data
    public GetEquipInfoHistoryVO getEquipInfoHistory(EquipInfoReal equipcode) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getEquipInfoHistory");
        param.put("equipcode",equipcode.getEquipcode());
        param.put("sessionid",equipcode.getSessionid());
        param.put("isoffsetlonlat",equipcode.getIsoffsetlonlat());
        param.put("btime",equipcode.getBtime());
        param.put("etime",equipcode.getEtime());
        param.put("second",equipcode.getSecond());
        return this.callPost("/public/v4/COMMON-MODULE-TERMINAL-WEB/api/getEquipInfoHistory",param,GetEquipInfoHistoryVO.class);
    }

//} 原因：接口返回的是result 不是 data
    public GetEquipInfoRealVO getEquipInfoReal(EquipInfoReal equipcode) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getEquipInfoReal");
        param.put("equipcode",equipcode.getEquipcode());
        param.put("sessionid",equipcode.getSessionid());
        param.put("isoffsetlonlat",equipcode.getIsoffsetlonlat());
        param.put("btime",equipcode.getBtime());
        param.put("etime",equipcode.getEtime());
        param.put("second",equipcode.getSecond());

        return this.callPost("/public/v4/COMMON-MODULE-TERMINAL-WEB/api/getEquipInfoReal",param,GetEquipInfoRealVO.class);
    }

//} OK
    public OpenAudioVO openAudio(GBVideo gbVideo) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"openAudio");
        param.put("vehicleid",String.valueOf(gbVideo.getVehicleid()));
        param.put("wid", gbVideo.getWid());
        param.put("channelids", gbVideo.getChannelids());
        param.put("videoqualitystr", gbVideo.getVideoqualitystr());
        param.put("balarmtime", gbVideo.getBalarmtime());
        param.put("eventtype",String.valueOf(gbVideo.getEventtype()));
        param.put("guid",String.valueOf(gbVideo.getGuid()));
        return this.callPostJson("/public/v4/BUSINESS/api/media/Audio/openAudio",gbVideo,param,OpenAudioVO.class);
    }

//    OK
    public GetAudioUrlVO getAudioUrl(GBVideo gbVideo) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getAudioUrl");
        param.put("vehicleid",String.valueOf(gbVideo.getVehicleid()));
        param.put("wid", gbVideo.getWid());
        param.put("channelids", gbVideo.getChannelids());
        param.put("videoqualitystr", gbVideo.getVideoqualitystr());
        param.put("balarmtime", gbVideo.getBalarmtime());
        param.put("eventtype",String.valueOf(gbVideo.getEventtype()));
        param.put("guid",String.valueOf(gbVideo.getGuid()));
        return this.callPostJson("/public/v4/COMMON-MODULE-MEDIA-WEB/api/media/Audio/getAudioUrl",gbVideo,param,GetAudioUrlVO.class);
    }


    //} OK
    public GetRenewAudioVO getRenewAudio(GBVideo gbVideo) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getRenewAudio");
        param.put("vehicleid",String.valueOf(gbVideo.getVehicleid()));
        param.put("wid", gbVideo.getWid());
        param.put("channelids", gbVideo.getChannelids());
        param.put("videoqualitystr", gbVideo.getVideoqualitystr());
        param.put("balarmtime", gbVideo.getBalarmtime());
        param.put("eventtype",String.valueOf(gbVideo.getEventtype()));
        param.put("guid",String.valueOf(gbVideo.getGuid()));
        return this.callPostJson("/public/v4/COMMON-MODULE-MEDIA-WEB/api/media/Audio/getRenewAudio",gbVideo,param,GetRenewAudioVO.class);
    }


//} OK
    public GetCloseAudioVO getCloseAudio(GBVideo gbVideo) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getCloseAudio");
        param.put("vehicleid",String.valueOf(gbVideo.getVehicleid()));
        param.put("wid", gbVideo.getWid());
        param.put("channelids", gbVideo.getChannelids());
        param.put("videoqualitystr", gbVideo.getVideoqualitystr());
        param.put("balarmtime", gbVideo.getBalarmtime());
        param.put("eventtype",String.valueOf(gbVideo.getEventtype()));
        param.put("guid",String.valueOf(gbVideo.getGuid()));
        return this.callPostJson("/public/v4/COMMON-MODULE-MEDIA-WEB/api/media/Audio/getCloseAudio",gbVideo,param,GetCloseAudioVO.class);
    }
//ok
    public GetRenewVideoVO getRenewVideo(String vehicle, String channelIds) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getRenewVideo");
        param.put("vehicle",vehicle);
        param.put("channelIds",channelIds);

        return this.callPost("/public/v4/COMMON-MODULE-MEDIA-WEB/api/media/video/getRenewVideo",param,GetRenewVideoVO.class);
    }
    //ok
    public GetCloseVideoVO getCloseVideo(String vehicle, String channelIds) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getCloseVideo");
        param.put("vehicle",vehicle);
        param.put("channelIds",channelIds);
        return this.callGet("/public/v4/COMMON-MODULE-MEDIA-WEB/api/media/video/getCloseVideo",param,GetCloseVideoVO.class);
    }

    // ok
    public ChangeVideoQualityVO changeVideoQuality( String vehicle, String channelIds, Integer videoQuality) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"changeVideoQuality");
        param.put("vehicle",String.valueOf(vehicle));
        param.put("channelIds",channelIds);
        param.put("videoQuality",String.valueOf(videoQuality));
        return this.callGet("/public/v4/COMMON-MODULE-MEDIA-WEB/api/media/video/changeVideoQuality",param,ChangeVideoQualityVO.class);
    }

//ok
    public GetOpenVideoVO getOpenVideo( String vehicle, String channelIds, Integer videoQuality) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"getOpenVideo");
        param.put("vehicle",String.valueOf(vehicle));
        param.put("channelIds",channelIds);
        param.put("videoQuality",String.valueOf(videoQuality));
        return this.callPost("/public/v4/COMMON-MODULE-MEDIA-WEB/api/media/video/getOpenVideo",param,GetOpenVideoVO.class);
    }

    /**
     * @Description //SMART
     **/
//ok
    public QueryElockOperateRecordVO queryElockOperateRecord(String bTimeStr, String eTimeStr, List<String> equipCodeList) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"queryElockOperateRecord");
        param.put("startTime", bTimeStr);
        param.put("endTime", eTimeStr);
        param.put("equipCodeList", StringUtils.join(equipCodeList, ","));
        return this.callPost("/public/v4/BL-MODULE-SMART-TRACE-WEB/api/trace/bluetoothElock/queryElockOperateRecord",param, QueryElockOperateRecordVO.class);
    }


    //}ok
    public QueryBluetoothElockVO queryBluetoothElock(Integer deviceType, String sdkVersion) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"queryBluetoothElock");
        param.put("deviceType", String.valueOf(deviceType));
        param.put("sdkVersion", sdkVersion);
        return this.callGet("/public/v4/BL-MODULE-SMART-TRACE-WEB/api/sdk/trace/bluetoothElock/queryBluetoothElock", param, QueryBluetoothElockVO.class);
    }

    //} ok
    public UploadOperateRecordVO uploadOperateRecord(List<Integer> dataTerminalIdList, Integer operateType,String operateTime,
                                                     Integer lon, Integer lat, String commids) throws ApiException {
        Map<String, String> paramMap = new HashMap<>();
        String json = "{\"dataTerminalIdList\":"+dataTerminalIdList.toString()+",\"operateType\":\""+operateType+"\",\"operateTime\":\""+operateTime+"\",\"lon\":"+lon+",\"lat\":"+lat+",\"commids\":\""+commids+"\"}";
        paramMap.put(ParamConstant.METHOD,"uploadOperateRecord");
        paramMap.put("param", json);
        return this.callGet("/public/v4/BL-MODULE-SMART-TRACE-WEB/api/sdk/trace/bluetoothElock/uploadOperateRecord", paramMap, UploadOperateRecordVO.class);
    }


    //} ok
    public SaveBluetoothleLockErrorOprRecordVO saveBluetoothleLockErrorOprRecord(String commids,Integer lon, Integer lat,Integer operateType,
                                                                                 Integer errorCode,String errorMsg) throws ApiException {
        Map<String, String> paramMap = new HashMap<>();
        String json = "{\"commids\":\""+commids+"\",\"lon\":"+lon+",\"lat\":"+lat+",\"operateType\":"+operateType+",\"errorCode\":"+errorCode+",\"errorMsg\":\""+errorMsg+"\"}";
        System.out.println(json);
        paramMap.put(ParamConstant.METHOD,"saveBluetoothleLockErrorOprRecord");
        paramMap.put("param", json);
        return this.callGet("/public/v4/BL-MODULE-SMART-TRACE-WEB/api/sdk/trace/bluetoothElock/saveBluetoothleLockErrorOprRecord",paramMap, SaveBluetoothleLockErrorOprRecordVO.class);
    }

    //没有权限
    public VehicleUpdateVO vehicleUpdate(UpdateVehicleVO updateVehicleVO) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"vehicleUpdate");
        param.put("timestamp", updateVehicleVO.getTimestamp());
        param.put("vehicleNo", updateVehicleVO.getVehicleNo());
        param.put("motorcade", updateVehicleVO.getMotorcade());
        param.put("brand", updateVehicleVO.getBrand());
        param.put("regDate", updateVehicleVO.getRegDate());
        param.put("length", String.valueOf(updateVehicleVO.getLength()));
        param.put("volume", String.valueOf(updateVehicleVO.getVolume()));
        param.put("load", String.valueOf(updateVehicleVO.getLoad()));
        param.put("isValid", String.valueOf(updateVehicleVO.getIsValid()));
        return this.callPost("/public/v4/E6-CUSTOMER-WEB/sto/vehicleBase/vehicleUpdate", param, VehicleUpdateVO.class);
    }

    public PushVehicleDepartureVO pushVehicleDepartureStatus(String vehicleNo, Integer departureStatus, Integer taskId,  String format) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"pushVehicleDepartureStatus");
        param.put("vehicleNo", vehicleNo);
        param.put("departureStatus", String.valueOf(departureStatus));
        param.put("taskId", String.valueOf(taskId));
        param.put("format", format);
        return this.callPost("/public/v4/E6-CUSTOMER-WEB/renfu/departure/pushVehicleDepartureStatus", param, PushVehicleDepartureVO.class);
    }

    //   //  这个 底层返回格式为
    //                //      private Integer code;
    //                //    /**
    //                //     * 返回消息
    //                //     */
    //                //    private String msg;
    //                //    /**
    //                //     * 返回对象
    //                //     */
    //                //    protected T data;
    public DriverUpdateVO driverUpdate(UpdateDriverVO updateDriverVO) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"driverUpdate");
        param.put("driverName", updateDriverVO.getDriverName());
        param.put("phone", updateDriverVO.getPhone());
        param.put("driverLn", updateDriverVO.getDriverLn());
        param.put("isValid", updateDriverVO.getIsValid());
        param.put("motorcade", updateDriverVO.getMotorcade());
        param.put("vehicleNo", updateDriverVO.getVehicleNo());
        param.put("entryDate", updateDriverVO.getEntryDate());
        return this.callGet("/public/v4/E6-CUSTOMER-WEB/sto/driverBase/driverUpdate",param, DriverUpdateVO.class);
    }

    /**
     * @Description //LOGISTICS
     **/
    // {"code":104,"message":"没有权限"}
    public GetDriverLimitVO getDriverLimit(String drivercode, String corpcode, String paytype) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"GetDriverLimit");
        param.put("drivercode", drivercode);
        param.put("corpcode", corpcode);
        param.put("paytype", paytype);
        return this.callGet("/public/v4/LOGISTICS-ECOLOGICAL/api/Interface/Call/GetDriverLimit",param, GetDriverLimitVO.class);
    }
    // 权限
    public PayBillVO payBill(PBill pBill) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"PayBill");
        param.put("billno", pBill.getBillno());
        param.put("drivercode", pBill.getDrivercode());
        param.put("corpcode", pBill.getCorpcode());
        param.put("gasstation", pBill.getBillno());
        param.put("oilid", pBill.getOilid());
        param.put("gunno", pBill.getGunno());
        param.put("addtime", pBill.getAddtime());
        param.put("standardprice", pBill.getStandardprice());
        param.put("payprice", pBill.getPayprice());
        param.put("volume", pBill.getVolume());
        param.put("money", pBill.getMoney());
        param.put("driverpayprice", pBill.getDriverpayprice());
        param.put("driverpaymoney", pBill.getDriverpaymoney());
        param.put("nationalstandardprice", pBill.getNationalstandardprice());
        param.put("paytype", pBill.getPaytype());
        param.put("remark", pBill.getRemark());
        param.put("stationAddr", pBill.getStationAddr());
        return this.callPost("/public/v4/LOGISTICS-ECOLOGICAL/api/Interface/Call/PayBill",param, PayBillVO.class);
    }
    // 权限
    public RechargeMoneyVO rechargeMoney(String rechargeno,String corpcode,String money,String remark) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"RechargeMoney");
        param.put("rechargeno", rechargeno);
        param.put("corpcode", corpcode);
        param.put("money", money);
        param.put("remark", remark);
        return this.callGet("/public/v4/LOGISTICS-ECOLOGICAL/api/Interface/Call/RechargeMoney",param, RechargeMoneyVO.class);
    }

    // 权限
    public RevokeBillVO revokeBill(Bill billno) throws ApiException {
        Map<String, String> param = new HashMap<>();
        param.put(ParamConstant.METHOD,"RevokeBill");
        param.put("billno", billno.getBillno());
        param.put("drivercode", billno.getDrivercode());
        param.put("corpcode", billno.getCorpcode());
        param.put("paytype", billno.getPaytype());
        param.put("remark", billno.getRemark());
        return this.callGet("/public/v4/LOGISTICS-ECOLOGICAL/api/Interface/Call/RevokeBill",param, RevokeBillVO.class);
    }



}
