package com.prolog.rdc.tms.rmi.hystrix;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.product.core.tools.util.LogUtils;
import com.prolog.rdc.tms.model.dto.e6.*;
import com.prolog.rdc.tms.model.dto.g7.*;
import com.prolog.rdc.tms.model.vo.BillDownloadVO;
import com.prolog.rdc.tms.model.vo.e6.*;
import com.prolog.rdc.tms.model.vo.g7.ColdchainAlarmVO;
import com.prolog.rdc.tms.model.vo.g7.CurrentLocationVO;
import com.prolog.rdc.tms.model.vo.g7.CurrentTemperatureVO;
import com.prolog.rdc.tms.model.vo.g7.HistoryLocationByGpsnoVO;
import com.prolog.rdc.tms.rmi.feign.InterfaceFeign;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * @author hongbo.pan
 */
@Component
public class InterfaceHystrix implements FallbackFactory<InterfaceFeign> {

	private final Logger logger = LoggerFactory.getLogger(InterfaceHystrix.class);

	@Override
	public InterfaceFeign create(Throwable cause) {
		if (null != cause && StringUtils.hasLength(cause.getMessage())) {
			LogUtils.error(logger, cause.getMessage(), cause);
		}

		return new InterfaceFeign() {

			@Override
			public RestMessage<List<VehicleInfoDTO>> getVehicleInfo(VehicleInfoVO vo) {
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-interface-service|易流|getVehicleInfo】请求服务失败！", null);
			}

			@Override
			public RestMessage<List<TrackDetailDTO>> getTrackDetail(TrackDetailVO vo) {
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-interface-service|易流|getTrackDetail】请求服务失败！", null);
			}

			@Override
			public RestMessage<List<VehicleTemperatureInfoDTO>> getVehicleTemperatureInfo(VehicleTemperatureInfoVO vo) {
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-interface-service|易流|getVehicleTemperatureInfo】请求服务失败！", null);
			}

			@Override
			public RestMessage<List<VehiclesAllAlarmInfoDTO>> getVechilesAllAlarmInfo(VehiclesAllAlarmInfoVO vo) {
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-interface-service|易流|getVechilesAllAlarmInfo】请求服务失败！", null);
			}

			/**
			 * g7车辆当前定位
			 * @param vos
			 * @return
			 */
			public RestMessage<List<CurrentLocationDTO>> currentLocationExecute(List<CurrentLocationVO> vos){
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-interface-service|G7车辆当前定位|currentLocationExecute】请求服务失败！", null);
			}

			/**
			 * g7车辆历史轨迹
			 * @param vo
			 * @return
			 */
			public RestMessage<List<HistoryLocationByGpsnoDTO>> historyLocationByVehExecute(HistoryLocationByGpsnoVO vo){
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-interface-service|G7车辆历史轨迹|historyLocationByVehExecute】请求服务失败！", null);
			}

			/**
			 * G7冷链报警列表接口
			 * @param vo
			 * @return
			 */
			@Override
			public RestMessage<List<ColdchainAlarmDTO>> coldchainAlarmExecute(ColdchainAlarmVO vo) {
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-interface-service|G7冷链报警|coldchainAlarmExecute】请求服务失败！", null);
			}

			/**
			 * 设备车辆当前温度查询接口
			 * @param vo
			 * @return
			 */
			@Override
			public RestMessage<List<CurrentTemperatureDTO>> currentTemperatureExecute(CurrentTemperatureVO vo) {
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-interface-service|G7车辆当前温度|currentTemperatureExecute】请求服务失败！", null);
			}

			@Override
			public RestMessage<List<EquipInfoDTO>> getEquipInfoReal(EquipInfoVO vo) {
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-interface-service|E6设备信息|getEquipInfoReal】请求服务失败！", null);
			}

			@Override
			public RestMessage<List<EquipInfoHistoryDTO>> getEquipInfoHistory(EquipInfoHistoryVO vo) {
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-interface-service|E6设备轨迹|getEquipInfoHistory】请求服务失败！", null);
			}

			@Override
			public RestMessage<List<HistoryLocationByGpsnoDTO>> historyLocationByGpsnoCall(HistoryLocationByGpsnoVO vo) {
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-interface-service|G7设备轨迹|historyLocationByGpsnoCall】请求服务失败！", null);
			}

			@Override
			public RestMessage<List<CurrentGpsLocationDTO>> simpleCurrentsByGpsnos(CurrentTemperatureVO vo) {
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-interface-service|G7设备位置和状态查询|simpleCurrentsByGpsnos】请求服务失败！", null);
			}

			@Override
			public RestMessage<Object> saveShipbillBmsExecute(List<BillDownloadVO> billDownloadVO) {
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-interface-service|TMS运单同步BMS接口|saveShipbillBmsExecute|服务请求失败！", null);
			}
		};
	}
}
