Commit 2194fdd7 by 杨林龙

添加围栏,无在店统计和警情 调用feign

1 parent 252dc1de
package cn.com.glsx.stdinterface.api;
import cn.com.glsx.stdinterface.dto.ChannelRiskDto;
import cn.com.glsx.stdinterface.factory.ChannelRiskFallbackFactory;
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 org.springframework.web.bind.annotation.RequestParam;
/**
* @author zhouhaibao
* @date 2021/5/24 9:49
*/
@FeignClient(name = "ne-shield-standard-interfaces", path = "/stdinterface/channelrisk", fallbackFactory = ChannelRiskFallbackFactory.class, decode404 = true)
public interface ChannelRiskClient {
@GetMapping(value = "/selectbyworkstandsn")
R selectByWorkStandSn(@RequestParam(value = "workorderNo") String workorderNo, @RequestParam(value = "vin") String vin, @RequestParam(value = "sn") String sn);
@PostMapping(value = "/insertchannelriskdata")
R insertChannelRiskData(@RequestBody ChannelRiskDto newData);
@PostMapping(value = "/updatechannelriskdata")
R updateChannelRiskData(@RequestBody ChannelRiskDto newData);
}
package cn.com.glsx.stdinterface.api;
import cn.com.glsx.stdinterface.dto.ElectricFenceDto;
import cn.com.glsx.stdinterface.factory.ElectricFenceFallbackFactory;
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 org.springframework.web.bind.annotation.RequestParam;
/**
* 围栏试驾信息Controller
*/
@FeignClient(name = "ne-shield-standard-interfaces", path = "/stdinterface/fencedriver", fallbackFactory = ElectricFenceFallbackFactory.class, decode404 = true)
public interface ElectricFenceClient {
@GetMapping(value = "/getfencedrive")
R getFenceDrive(@RequestParam Integer fenceId, @RequestParam String sn, @RequestParam String journeyTime);
@PostMapping(value = "/insertfencedrive")
R insertFenceDrive(@RequestBody ElectricFenceDto fenceDrive);
}
package cn.com.glsx.stdinterface.api;
import cn.com.glsx.stdinterface.dto.ElectricInStoreDto;
import cn.com.glsx.stdinterface.factory.ElectricInStoreFallbackFactory;
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 org.springframework.web.bind.annotation.RequestParam;
/**
* 不在店统计 feign
*/
@FeignClient(name = "ne-shield-standard-interfaces", path = "/stdinterface/electricinstore", fallbackFactory = ElectricInStoreFallbackFactory.class, decode404 = true)
public interface ElectricInStoreClient {
@GetMapping(value = "/getelectricinstore")
R getElectricInStore(@RequestParam Integer fenceId, @RequestParam String sn, @RequestParam String gpsTime);
@PostMapping(value = "/insertelectricinstore")
R insertElectricInStore(@RequestBody ElectricInStoreDto electricInStoreDrive);
}
package cn.com.glsx.stdinterface.dto;
import lombok.Data;
import java.util.Date;
/**
* 渠道风险dto
* 数据库映射bean
*/
@Data
public class ChannelRiskDto {
/**
* id
*/
private Long id;
/**
* 工单编号
*/
private String workorderNo;
/**
* 车主姓名
*/
private String ownerName;
/**
* 车架号
*/
private String vin;
/**
* 设备sn
*/
private String sn;
/**
* 激活时间
*/
private Date activeDate;
/**
* 设备类型
*/
private Integer devType;
/**
* gps上点时间
*/
private Date gpsTime;
/**
* 经度
*/
private Double lng;
/**
* 纬度
*/
private Double lat;
/**
* 省份
*/
private String prov;
/**
* 城市
*/
private String city;
/**
* 县区
*/
private String zone;
/**
* 详细地址
*/
private String address;
/**
* 渠道名称
*/
private String shopName;
/**
* 标签标识
*/
private String labels;
/**
* 数据类型:0正常数据,1疑似风险
*/
private Integer type;
/**
* 渠道位置分析半径
*/
private Integer radius;
/**
* 渠道地址县区
*/
private String district;
/**
* 渠道地址街道
*/
private String street;
/**
* 渠道地址街道号
*/
private String streetNumber;
/**
* 渠道分析位置经度
*/
private Double centerLat;
/**
* 渠道分析位置纬度
*/
private Double centerLng;
}
\ No newline at end of file
package cn.com.glsx.stdinterface.dto;
import lombok.Data;
import java.util.Date;
/**
* @Desc:试驾围栏数据表
* @Author huangxc
* @Date 2021/4/19
*/
@Data
public class ElectricFenceDto {
/**
* id
*/
private Integer id;
/**
* 设备号
*/
private String sn;
/**
* 外键:电子围栏表主键
*/
private Integer fenceId;
/**
* 业务渠道标识,旧e盾:11 新E盾:12
*/
private Integer sveSystemId;
/**
* 行程开始时间
*/
private Date journeyTime;
/**
* 重合度(百分百),如值为20,即为20%
*/
private Integer percent;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}
package cn.com.glsx.stdinterface.dto;
import lombok.Data;
import java.util.Date;
/**
* 试驾在店数据dto
*
* @TableName t_electric_inshop_drive
*/
@Data
public class ElectricInStoreDto {
/**
* id
*/
private Integer id;
/**
* 设备号
*/
private String sn;
/**
* 外键:电子围栏表主键
*/
private Integer fenceId;
/**
* 业务渠道标识,默认为 13
*/
private Integer sveSystemId;
/**
* 0 表示不在, 1表示在新疆
*/
private Integer positionState;
/**
* 0:工作时间有进出门店 1:工作时间一直在门店内 2:工作时间内一直在门店外
*/
private Integer gpsState;
/**
* 行程开始时间
*/
private Date gpsTime;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date updatedTime;
}
\ No newline at end of file
......@@ -2,13 +2,11 @@ package cn.com.glsx.stdinterface.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 试驾统计数据
* 试驾统计数据dto
*/
@Data
public class StatisticsDriveDto implements Serializable {
public class StatisticsDriveDto {
/**
* 设备号
*/
......
package cn.com.glsx.stdinterface.factory;
import cn.com.glsx.stdinterface.api.ChannelRiskClient;
import cn.com.glsx.stdinterface.fallback.ChannelRiskFallbackImpl;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
/**
* 项目名:ne-shield-insurancenter-api
* 包名: cn.com.glsx.insurance.factory
* 作者: Yanglinlong
* 日期: 2021/7/5 16:15
*/
@Component
public class ChannelRiskFallbackFactory implements FallbackFactory<ChannelRiskClient> {
@Override
public ChannelRiskClient create(Throwable throwable) {
ChannelRiskFallbackImpl fallback = new ChannelRiskFallbackImpl();
fallback.setCause(throwable);
return fallback;
}
}
package cn.com.glsx.stdinterface.factory;
import cn.com.glsx.stdinterface.api.ElectricFenceClient;
import cn.com.glsx.stdinterface.fallback.ElectricFenceFallbackImpl;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
/**
* 项目名:ne-shield-insurancenter-api
* 包名: cn.com.glsx.insurance.factory
* 作者: Yanglinlong
* 日期: 2021/7/5 16:15
*/
@Component
public class ElectricFenceFallbackFactory implements FallbackFactory<ElectricFenceClient> {
@Override
public ElectricFenceClient create(Throwable throwable) {
ElectricFenceFallbackImpl fallback = new ElectricFenceFallbackImpl();
fallback.setCause(throwable);
return fallback;
}
}
package cn.com.glsx.stdinterface.factory;
import cn.com.glsx.stdinterface.api.ElectricInStoreClient;
import cn.com.glsx.stdinterface.fallback.ElectricInStoreFallbackImpl;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
/**
* 项目名:ne-shield-insurancenter-api
* 包名: cn.com.glsx.insurance.factory
* 作者: Yanglinlong
* 日期: 2021/7/5 16:15
*/
@Component
public class ElectricInStoreFallbackFactory implements FallbackFactory<ElectricInStoreClient> {
@Override
public ElectricInStoreClient create(Throwable throwable) {
ElectricInStoreFallbackImpl fallback = new ElectricInStoreFallbackImpl();
fallback.setCause(throwable);
return fallback;
}
}
......@@ -13,6 +13,7 @@ import org.springframework.stereotype.Component;
*/
@Component
public class StatisticsDriveFallbackFactory implements FallbackFactory<StatisticsDriveClient> {
@Override
public StatisticsDriveClient create(Throwable throwable) {
StatisticsDriveFallbackImpl fallback = new StatisticsDriveFallbackImpl();
......
package cn.com.glsx.stdinterface.fallback;
import cn.com.glsx.stdinterface.api.ChannelRiskClient;
import cn.com.glsx.stdinterface.dto.ChannelRiskDto;
import com.glsx.plat.core.web.R;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 项目名:ne-shield-insurancenter-api
* 包名: cn.com.glsx.insurance.fallback
* 作者: Yanglinlong
* 日期: 2021/7/5 16:16
*/
@Slf4j
@Component
public class ChannelRiskFallbackImpl implements ChannelRiskClient {
@Setter
private Throwable cause;
@Override
public R selectByWorkStandSn(String workorderNo, String vin, String sn) {
log.warn("selectByWorkStandSn 熔断啦 {}", cause.getMessage());
return R.ok("服务异常");
}
@Override
public R insertChannelRiskData(ChannelRiskDto newData) {
log.warn("insertChannelRiskData 熔断啦 {}", cause.getMessage());
return R.ok("服务异常");
}
@Override
public R updateChannelRiskData(ChannelRiskDto newData) {
log.warn("updateChannelRiskData 熔断啦 {}", cause.getMessage());
return R.ok("服务异常");
}
}
package cn.com.glsx.stdinterface.fallback;
import cn.com.glsx.stdinterface.api.ElectricFenceClient;
import cn.com.glsx.stdinterface.dto.ElectricFenceDto;
import com.glsx.plat.core.web.R;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 项目名:ne-shield-insurancenter-api
* 包名: cn.com.glsx.insurance.fallback
* 作者: Yanglinlong
* 日期: 2021/7/5 16:16
*/
@Slf4j
@Component
public class ElectricFenceFallbackImpl implements ElectricFenceClient {
@Setter
private Throwable cause;
@Override
public R getFenceDrive(Integer fenceId, String sn, String journeyTime) {
log.warn("getFenceDrive 熔断啦 {}", cause.getMessage());
return R.ok("服务异常");
}
@Override
public R insertFenceDrive(ElectricFenceDto fenceDrive) {
log.warn("insertFenceDrive 熔断啦 {}", cause.getMessage());
return R.ok("服务异常");
}
}
package cn.com.glsx.stdinterface.fallback;
import cn.com.glsx.stdinterface.api.ElectricInStoreClient;
import cn.com.glsx.stdinterface.dto.ElectricInStoreDto;
import com.glsx.plat.core.web.R;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 项目名:ne-shield-insurancenter-api
* 包名: cn.com.glsx.insurance.fallback
* 作者: Yanglinlong
* 日期: 2021/7/5 16:16
*/
@Slf4j
@Component
public class ElectricInStoreFallbackImpl implements ElectricInStoreClient {
@Setter
private Throwable cause;
@Override
public R getElectricInStore(Integer fenceId, String sn, String gpsTime) {
log.warn("getElectricInStore 熔断啦 {}", cause.getMessage());
return R.ok("服务异常");
}
@Override
public R insertElectricInStore(ElectricInStoreDto electricInStoreDrive) {
log.warn("insertElectricInStore 熔断啦 {}", cause.getMessage());
return R.ok("服务异常");
}
}
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
cn.com.glsx.stdinterface.factory.StatisticsDriveFallbackFactory,\
cn.com.glsx.stdinterface.fallback.StatisticsDriveFallbackImpl,\
cn.com.glsx.stdinterface.factory.StatisticsDriveFallbackFactory
cn.com.glsx.stdinterface.factory.ChannelRiskFallbackFactory,\
cn.com.glsx.stdinterface.fallback.ChannelRiskFallbackImpl,\
cn.com.glsx.stdinterface.factory.ElectricFenceFallbackFactory,\
cn.com.glsx.stdinterface.fallback.ElectricFenceFallbackImpl,\
cn.com.glsx.stdinterface.factory.ElectricInStoreFallbackFactory,\
cn.com.glsx.stdinterface.fallback.ElectricInStoreFallbackImpl
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!