Commit 87e1ce94 by 杨林龙

开发新E盾gps基站调用基础接口

1 parent b337f055
package cn.com.glsx.stdinterface.api;
import cn.com.glsx.stdinterface.dto.DeviceLocationDto;
import cn.com.glsx.stdinterface.factory.DeviceLocationFallbackFactory;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Collection;
import java.util.List;
/**
* 设备上点表调用Feign
*
* @author yll
*/
@FeignClient(name = "ne-shield-standard-interfaces", path = "/stdinterface/devicelocation", fallbackFactory = DeviceLocationFallbackFactory.class, decode404 = true)
public interface DeviceLocationClient {
/**
* 插入或者更新设备上点数据
*
* @param deviceLocationDtos 设备上点集合
* @return
*/
@PostMapping(value = "/saveorupdatedevicelocationdata")
R<Integer> saveOrUpdateDeviceLocationData(@RequestBody Collection<DeviceLocationDto> deviceLocationDtos);
/**
* 获取E盾中的所有设备号集合
*/
@GetMapping(value = "getallsninneweshield")
R<List<String>> getAllSnInNewEshield();
}
package cn.com.glsx.stdinterface.dto;
import lombok.Data;
import java.util.Date;
/**
* 设备gps和基站报警时间表
*
* @author yll
*/
@Data
public class DeviceLocationDto {
/**
* 主键id
*/
private Integer id;
/**
* 设备号
*/
private String sn;
/**
* 最后gps时间
*/
private Date lastGpsTime;
/**
* 最后基站时间
*/
private Date lastBsTime;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date updatedTime;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.stdinterface.factory;
import cn.com.glsx.stdinterface.api.ChannelRiskClient;
import cn.com.glsx.stdinterface.api.DeviceLocationClient;
import cn.com.glsx.stdinterface.fallback.ChannelRiskFallbackImpl;
import cn.com.glsx.stdinterface.fallback.DeviceLocationFallbackImpl;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
/**
* 设备上点服务调用异常处理工厂类
*
* @author yll
*/
@Component
public class DeviceLocationFallbackFactory implements FallbackFactory<DeviceLocationClient> {
@Override
public DeviceLocationClient create(Throwable throwable) {
DeviceLocationFallbackImpl fallback = new DeviceLocationFallbackImpl();
fallback.setCause(throwable);
return fallback;
}
}
package cn.com.glsx.stdinterface.fallback;
import cn.com.glsx.stdinterface.api.DeviceLocationClient;
import cn.com.glsx.stdinterface.dto.DeviceLocationDto;
import com.glsx.plat.core.web.R;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.List;
/**
* 设备上点服务异常处理实现类
*
* @author yll
*/
@Slf4j
@Component
public class DeviceLocationFallbackImpl implements DeviceLocationClient {
@Setter
private Throwable cause;
@Override
public R<Integer> saveOrUpdateDeviceLocationData(Collection<DeviceLocationDto> deviceLocationDtos) {
log.warn("saveOrUpdateDeviceLocationData===熔断啦 {}", cause.getMessage());
return R.ok("服务异常");
}
@Override
public R<List<String>> getAllSnInNewEshield() {
log.warn("getAllSnInNewEshield===熔断啦 {}", 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!