Commit 68fba004 by 杨林龙

开发设备激活同步位置点数据功能

1 parent 20237920
package cn.com.glsx.stdinterface.api;
import cn.com.glsx.stdinterface.dto.DeviceActiveDto;
import cn.com.glsx.stdinterface.factory.DeviceActiveFallbackFactory;
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.List;
/**
* @author xiangyanlin
* @date 2022/4/12
*/
@FeignClient(name = "ne-shield-standard-interfaces", path = "/nesi/deviceactive", fallbackFactory = DeviceActiveFallbackFactory.class, decode404 = true)
public interface DeviceActiveClient {
/**
* 保存激活信息
*
* @param deviceActiveDto 激活实体类
*/
@PostMapping(value = "/saveActiveInfo")
R saveActiveInfo(@RequestBody DeviceActiveDto deviceActiveDto);
/**
* 获取七天内没有设备激活数据的设备号集合
*
* @return 设备号集合
*/
@GetMapping("/getUnActiveInfoSnList")
R<List<String>> getUnActiveInfoSnList();
}
package cn.com.glsx.stdinterface.dto;
import lombok.Data;
import java.util.List;
/**
* 设备激活观察者模式类
*/
@Data
public class DeviceActiveDto {
/**
* 设备列表
*/
private List<String> snList;
}
package cn.com.glsx.stdinterface.factory;
import cn.com.glsx.stdinterface.api.DeviceActiveClient;
import cn.com.glsx.stdinterface.fallback.DeviceActiveFallbackImpl;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
/**
* @author 杨林龙
* @date 2022/4/12
*/
@Component
public class DeviceActiveFallbackFactory implements FallbackFactory<DeviceActiveClient> {
@Override
public DeviceActiveClient create(Throwable throwable) {
DeviceActiveFallbackImpl fallback = new DeviceActiveFallbackImpl();
fallback.setCause(throwable);
return fallback;
}
}
package cn.com.glsx.stdinterface.fallback;
import cn.com.glsx.stdinterface.api.DeviceActiveClient;
import cn.com.glsx.stdinterface.dto.DeviceActiveDto;
import com.glsx.plat.core.web.R;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author xiangyanlin
* @date 2022/4/12
*/
@Slf4j
@Component
public class DeviceActiveFallbackImpl implements DeviceActiveClient {
@Setter
private Throwable cause;
@Override
public R saveActiveInfo(DeviceActiveDto deviceActiveDto) {
log.warn("saveActiveInfo 熔断啦 {}", cause.getMessage());
return R.ok("服务异常");
}
@Override
public R<List<String>> getUnActiveInfoSnList() {
log.warn("getUnActiveSnList 熔断啦 {}", 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!