Commit 04e860fb by 杨林龙

开发大数据研判报警消费逻辑

1 parent 728193bc
package cn.com.glsx.stdinterface.api;
import cn.com.glsx.stdinterface.dto.VehicleDeviceDto;
import cn.com.glsx.stdinterface.factory.VehicleDeviceFallbackFactory;
import com.glsx.plat.core.web.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* Vehicle feign
*
* @author yangll
*/
@FeignClient(name = "ne-shield-standard-interfaces", path = "/nesi/vehicledevice", fallbackFactory = VehicleDeviceFallbackFactory.class, decode404 = true)
public interface VehicleDeviceClient {
/**
* 通过设备号获取车辆设备绑定关系
*
* @param sn 设备号
* @return
*/
@GetMapping(value = "/getVehicleDeviceBySn")
R<VehicleDeviceDto> getVehicleDeviceBySn(@RequestParam String sn);
}
......@@ -10,8 +10,12 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = "ne-shield-standard-interfaces", path = "/nesi/vehicle",
fallbackFactory = VehicleServiceFallbackFactory.class, decode404 = true)
/**
* Vehicle feign
*
* @author yangll
*/
@FeignClient(name = "ne-shield-standard-interfaces", path = "/nesi/vehicle", fallbackFactory = VehicleServiceFallbackFactory.class, decode404 = true)
public interface VehicleServiceClient {
/**
......@@ -21,7 +25,7 @@ public interface VehicleServiceClient {
* @return
*/
@GetMapping(value = "/bysn")
public R<VehicleDto> getVehicleBySn(@RequestParam String sn);
R<VehicleDto> getVehicleBySn(@RequestParam String sn);
/**
* 验证设备组合接口
......@@ -30,6 +34,5 @@ public interface VehicleServiceClient {
* @return
*/
@PostMapping(value = "/verifyDevicesCompose")
public R verifyDevicesCompose(@RequestBody DevicesComposeVerifyBO verifyBO);
R verifyDevicesCompose(@RequestBody DevicesComposeVerifyBO verifyBO);
}
package cn.com.glsx.stdinterface.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
/**
* 车辆设备绑定关系
*/
@Data
public class VehicleDeviceDto {
/**
* id
*/
private Long id;
/**
* 车辆id
*/
private Long vehicleId;
/**
* 设备sn
*/
private String sn;
/**
* 绑定状态:1绑定,2解绑
*/
private Integer bindStatus;
/**
* 试驾类型 0:非试驾设备, 1,试驾设备
*/
private Integer trialType;
/**
* 历史试驾类型 0:曾经不是试驾设备; 1:曾经是试驾设备
*/
private Integer hisType;
/**
* 有线无线类型:1有线,0无线
*/
private Integer wireType;
/**
* 激活上点时间
*/
private Date activeLocationDate;
/**
* 激活上点经度
*/
private String activeLocationLng;
/**
* 激活上点纬度
*/
private String activeLocationLat;
/**
* 激活上点类型 0、GPS,1、基站
*/
private Integer activeLocationType;
/**
* 激活上点地址
*/
private String activeLocationAddress;
/**
* 删除标识
*/
private Integer delFlag;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createdDate;
private Long createdBy;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updatedDate;
private Long updatedBy;
}
\ No newline at end of file
package cn.com.glsx.stdinterface.factory;
import cn.com.glsx.stdinterface.api.VehicleDeviceClient;
import cn.com.glsx.stdinterface.fallback.VehicleDeviceFallbackImpl;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
/**
* VehicleDevice 工厂类
*
* @author yangll
*/
@Component
public class VehicleDeviceFallbackFactory implements FallbackFactory<VehicleDeviceClient> {
@Override
public VehicleDeviceClient create(Throwable throwable) {
VehicleDeviceFallbackImpl fallback = new VehicleDeviceFallbackImpl();
fallback.setCause(throwable);
return fallback;
}
}
package cn.com.glsx.stdinterface.fallback;
import cn.com.glsx.stdinterface.api.VehicleDeviceClient;
import cn.com.glsx.stdinterface.dto.VehicleDeviceDto;
import com.glsx.plat.core.web.R;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class VehicleDeviceFallbackImpl implements VehicleDeviceClient {
@Setter
private Throwable cause;
@Override
public R<VehicleDeviceDto> getVehicleDeviceBySn(String sn) {
log.warn("getVehicleDeviceBySn 熔断啦 {}", cause.getMessage());
return R.ok("服务异常");
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!