feat: 电子围栏报警
parent
de71107fe0
commit
adc2b87792
|
@ -0,0 +1,19 @@
|
|||
package com.couplet.remote;
|
||||
|
||||
import com.couplet.common.core.constant.ServiceNameConstants;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.domain.CoupletTroubleCode;
|
||||
import com.couplet.remote.factory.RemoteRealTimeFallbackFactory;
|
||||
import com.couplet.remote.factory.RemoteTroubleFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient(contextId = "remoteRealTimeService" ,
|
||||
value = ServiceNameConstants.BUSINESS_SERVICE,
|
||||
fallbackFactory = RemoteRealTimeFallbackFactory.class
|
||||
)
|
||||
public interface RemoteRealTimeService {
|
||||
|
||||
|
||||
}
|
|
@ -63,13 +63,6 @@ public interface RemoteVehicleService {
|
|||
*/
|
||||
@PostMapping("/vehicleAndLogo/queryByLogoIds/{vehicleId}")
|
||||
public Result<List<Long>> queryByLogoIds(@PathVariable("vehicleId") Long vehicleId);
|
||||
/**
|
||||
* 根据车辆id查询绑定的标识
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
// @PostMapping("/vehicleAndLogo/queryByLogoIds/{vehicleId}")
|
||||
// public Result<List<Long>> queryByLogoIds(@PathVariable("vehicleId") Long vehicleId);
|
||||
|
||||
@PostMapping("/list")
|
||||
public Result list(@RequestBody VehicleListParams listParams);
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.couplet.remote.factory;
|
||||
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.domain.CoupletTroubleCode;
|
||||
import com.couplet.remote.RemoteRealTimeService;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/8
|
||||
* @Description:
|
||||
*/
|
||||
@Component
|
||||
public class RemoteRealTimeFallbackFactory implements FallbackFactory<RemoteRealTimeService> {
|
||||
|
||||
@Override
|
||||
public RemoteRealTimeService create(Throwable cause) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.couplet.analyze.common.contents;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
|
@ -8,8 +9,7 @@ import org.springframework.stereotype.Component;
|
|||
* @Description: 事件内容
|
||||
*/
|
||||
|
||||
@Component
|
||||
public class AnalyzeEventContents {
|
||||
public interface AnalyzeEventContents {
|
||||
|
||||
/**
|
||||
* 故障
|
||||
|
|
|
@ -2,6 +2,9 @@ package com.couplet.analyze.msg.mapper;
|
|||
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
|
@ -20,6 +23,6 @@ public interface IncidentMapper {
|
|||
* 查询是否存在该vin
|
||||
*/
|
||||
// CoupletMsgData queryByIncident(RealTimeDataRequest realTimeDataRequest);
|
||||
CoupletMsgData queryByIncident(String vin);
|
||||
CoupletMsgData queryByIncident(@Param("vin") String vin, @Param("createTime") Date createTime);
|
||||
|
||||
}
|
||||
|
|
|
@ -35,12 +35,8 @@ public class ModelsKafkaMessage {
|
|||
private static final String TOPIC_NAME = "online";
|
||||
private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092";
|
||||
|
||||
@Autowired
|
||||
private AnalyzeEventContents analyzeEventContents;
|
||||
@Autowired
|
||||
private AnalyzeEventCache analyzeEventCache;
|
||||
// @Autowired
|
||||
// private RabbitTemplate rabbitTemplate;
|
||||
|
||||
/**
|
||||
* 消费者配置
|
||||
|
|
|
@ -7,11 +7,14 @@ import com.couplet.analyze.msg.service.impl.realTimeData.RealTimeJudge;
|
|||
import com.couplet.common.core.utils.StringUtils;
|
||||
import com.couplet.common.domain.request.RealTimeDataRequest;
|
||||
import com.couplet.common.redis.service.RedisService;
|
||||
import com.couplet.remote.RemoteRealTimeService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/2
|
||||
|
@ -29,6 +32,8 @@ public class RealTimeDataServiceImpl implements IncidentService {
|
|||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
@Autowired
|
||||
private RemoteRealTimeService remoteRealTimeService;
|
||||
|
||||
/**
|
||||
* 实时数据事件
|
||||
|
@ -41,11 +46,15 @@ public class RealTimeDataServiceImpl implements IncidentService {
|
|||
log.info("实时数据事件开始.....");
|
||||
|
||||
RealTimeDataRequest cacheObject = redisService.getCacheObject("vin:" + coupletMsgData.getVin());
|
||||
if (StringUtils.isArray(cacheObject)){
|
||||
log.info("[{}]有缓存数据,值为:[{}]", coupletMsgData.getVin(), cacheObject);
|
||||
|
||||
if (RealTimeJudge.addRealTime(cacheObject)) {
|
||||
log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject);
|
||||
CoupletMsgData query = incidentMapper.queryByIncident(coupletMsgData.getVin(), new Date());
|
||||
redisService.setCacheObject("vin:" + cacheObject.getVin(), query);
|
||||
} else {
|
||||
log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据不一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject);
|
||||
}
|
||||
if (RealTimeJudge.isJudge(coupletMsgData.getVin())){
|
||||
if (RealTimeJudge.isJudge(coupletMsgData.getVin())) {
|
||||
log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin());
|
||||
}
|
||||
log.info("[{}]开始传输实时数据", coupletMsgData.getVin());
|
||||
|
@ -56,6 +65,7 @@ public class RealTimeDataServiceImpl implements IncidentService {
|
|||
|
||||
/**
|
||||
* 实时数据事件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
</insert>
|
||||
<select id="queryByIncident" resultType="com.couplet.analyze.msg.domain.CoupletMsgData"
|
||||
parameterType="com.couplet.common.domain.request.RealTimeDataRequest">
|
||||
SELECT * FROM couplet_msg_data WHERE vin =#{vin}
|
||||
SELECT * FROM couplet_msg_data WHERE vin=#{vin} and create_time = #{createTime}
|
||||
</select>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue