修改bug
parent
3fc01c4102
commit
bc8558576f
|
@ -6,6 +6,7 @@ import lombok.NoArgsConstructor;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author fufanrui
|
* @author fufanrui
|
||||||
|
@ -20,7 +21,7 @@ import java.io.Serializable;
|
||||||
public class RealTimeDataRequest implements Serializable {
|
public class RealTimeDataRequest implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
private Long userId;
|
private List<Long> userId;
|
||||||
|
|
||||||
private String vin;
|
private String vin;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ public class RedisService {
|
||||||
public RedisTemplate redisTemplate;
|
public RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ... 其他已有方法 ...
|
// ... 其他已有方法 ...
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +64,6 @@ public class RedisService {
|
||||||
*
|
*
|
||||||
* @param key Redis键
|
* @param key Redis键
|
||||||
* @param timeout 超时时间
|
* @param timeout 超时时间
|
||||||
*
|
|
||||||
* @return true=设置成功;false=设置失败
|
* @return true=设置成功;false=设置失败
|
||||||
*/
|
*/
|
||||||
public boolean expire(final String key, final long timeout) {
|
public boolean expire(final String key, final long timeout) {
|
||||||
|
@ -78,7 +76,6 @@ public class RedisService {
|
||||||
* @param key Redis键
|
* @param key Redis键
|
||||||
* @param timeout 超时时间
|
* @param timeout 超时时间
|
||||||
* @param unit 时间单位
|
* @param unit 时间单位
|
||||||
*
|
|
||||||
* @return true=设置成功;false=设置失败
|
* @return true=设置成功;false=设置失败
|
||||||
*/
|
*/
|
||||||
public boolean expire(final String key, final long timeout, final TimeUnit unit) {
|
public boolean expire(final String key, final long timeout, final TimeUnit unit) {
|
||||||
|
@ -89,7 +86,6 @@ public class RedisService {
|
||||||
* 获取有效时间
|
* 获取有效时间
|
||||||
*
|
*
|
||||||
* @param key Redis键
|
* @param key Redis键
|
||||||
*
|
|
||||||
* @return 有效时间
|
* @return 有效时间
|
||||||
*/
|
*/
|
||||||
public long getExpire(final String key) {
|
public long getExpire(final String key) {
|
||||||
|
@ -100,7 +96,6 @@ public class RedisService {
|
||||||
* 判断 key是否存在
|
* 判断 key是否存在
|
||||||
*
|
*
|
||||||
* @param key 键
|
* @param key 键
|
||||||
*
|
|
||||||
* @return true 存在 false不存在
|
* @return true 存在 false不存在
|
||||||
*/
|
*/
|
||||||
public Boolean hasKey(String key) {
|
public Boolean hasKey(String key) {
|
||||||
|
@ -111,7 +106,6 @@ public class RedisService {
|
||||||
* 获得缓存的基本对象。
|
* 获得缓存的基本对象。
|
||||||
*
|
*
|
||||||
* @param key 缓存键值
|
* @param key 缓存键值
|
||||||
*
|
|
||||||
* @return 缓存键值对应的数据
|
* @return 缓存键值对应的数据
|
||||||
*/
|
*/
|
||||||
public <T> T getCacheObject(final String key) {
|
public <T> T getCacheObject(final String key) {
|
||||||
|
@ -132,7 +126,6 @@ public class RedisService {
|
||||||
* 删除集合对象
|
* 删除集合对象
|
||||||
*
|
*
|
||||||
* @param collection 多个对象
|
* @param collection 多个对象
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean deleteObject(final Collection collection) {
|
public boolean deleteObject(final Collection collection) {
|
||||||
|
@ -144,7 +137,6 @@ public class RedisService {
|
||||||
*
|
*
|
||||||
* @param key 缓存的键值
|
* @param key 缓存的键值
|
||||||
* @param dataList 待缓存的List数据
|
* @param dataList 待缓存的List数据
|
||||||
*
|
|
||||||
* @return 缓存的对象
|
* @return 缓存的对象
|
||||||
*/
|
*/
|
||||||
public <T> long setCacheList(final String key, final List<T> dataList) {
|
public <T> long setCacheList(final String key, final List<T> dataList) {
|
||||||
|
@ -156,7 +148,6 @@ public class RedisService {
|
||||||
* 获得缓存的list对象
|
* 获得缓存的list对象
|
||||||
*
|
*
|
||||||
* @param key 缓存的键值
|
* @param key 缓存的键值
|
||||||
*
|
|
||||||
* @return 缓存键值对应的数据
|
* @return 缓存键值对应的数据
|
||||||
*/
|
*/
|
||||||
public <T> List<T> getCacheList(final String key) {
|
public <T> List<T> getCacheList(final String key) {
|
||||||
|
@ -168,7 +159,6 @@ public class RedisService {
|
||||||
*
|
*
|
||||||
* @param key 缓存键值
|
* @param key 缓存键值
|
||||||
* @param dataSet 缓存的数据
|
* @param dataSet 缓存的数据
|
||||||
*
|
|
||||||
* @return 缓存数据的对象
|
* @return 缓存数据的对象
|
||||||
*/
|
*/
|
||||||
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) {
|
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) {
|
||||||
|
@ -179,12 +169,12 @@ public class RedisService {
|
||||||
}
|
}
|
||||||
return setOperation;
|
return setOperation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存Set
|
* 缓存Set
|
||||||
*
|
*
|
||||||
* @param key 缓存键值
|
* @param key 缓存键值
|
||||||
* @param setValue 缓存的数据
|
* @param setValue 缓存的数据
|
||||||
*
|
|
||||||
* @return 缓存数据的对象
|
* @return 缓存数据的对象
|
||||||
*/
|
*/
|
||||||
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final T setValue) {
|
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final T setValue) {
|
||||||
|
@ -192,12 +182,12 @@ public class RedisService {
|
||||||
setOperation.add(setValue);
|
setOperation.add(setValue);
|
||||||
return setOperation;
|
return setOperation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存Set
|
* 缓存Set
|
||||||
*
|
*
|
||||||
* @param key 缓存键值
|
* @param key 缓存键值
|
||||||
* @param setValue 缓存的数据
|
* @param setValue 缓存的数据
|
||||||
*
|
|
||||||
* @return 缓存数据的对象
|
* @return 缓存数据的对象
|
||||||
*/
|
*/
|
||||||
public <T> void deleteSet(String key, String setValue) {
|
public <T> void deleteSet(String key, String setValue) {
|
||||||
|
@ -205,11 +195,11 @@ public class RedisService {
|
||||||
BoundSetOperations setOperations = redisTemplate.boundSetOps(key);
|
BoundSetOperations setOperations = redisTemplate.boundSetOps(key);
|
||||||
setOperations.remove(setValue);
|
setOperations.remove(setValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得缓存的set
|
* 获得缓存的set
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public <T> Set<T> getCacheSet(final String key) {
|
public <T> Set<T> getCacheSet(final String key) {
|
||||||
|
@ -217,7 +207,6 @@ public class RedisService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存Map
|
* 缓存Map
|
||||||
*
|
*
|
||||||
|
@ -234,7 +223,6 @@ public class RedisService {
|
||||||
* 获得缓存的Map
|
* 获得缓存的Map
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public <T> Map<String, T> getCacheMap(final String key) {
|
public <T> Map<String, T> getCacheMap(final String key) {
|
||||||
|
@ -257,7 +245,6 @@ public class RedisService {
|
||||||
*
|
*
|
||||||
* @param key Redis键
|
* @param key Redis键
|
||||||
* @param hKey Hash键
|
* @param hKey Hash键
|
||||||
*
|
|
||||||
* @return Hash中的对象
|
* @return Hash中的对象
|
||||||
*/
|
*/
|
||||||
public <T> T getCacheMapValue(final String key, final String hKey) {
|
public <T> T getCacheMapValue(final String key, final String hKey) {
|
||||||
|
@ -270,7 +257,6 @@ public class RedisService {
|
||||||
*
|
*
|
||||||
* @param key Redis键
|
* @param key Redis键
|
||||||
* @param hKeys Hash键集合
|
* @param hKeys Hash键集合
|
||||||
*
|
|
||||||
* @return Hash对象集合
|
* @return Hash对象集合
|
||||||
*/
|
*/
|
||||||
public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) {
|
public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) {
|
||||||
|
@ -282,7 +268,6 @@ public class RedisService {
|
||||||
*
|
*
|
||||||
* @param key Redis键
|
* @param key Redis键
|
||||||
* @param hKey Hash键
|
* @param hKey Hash键
|
||||||
*
|
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
public boolean deleteCacheMapValue(final String key, final String hKey) {
|
public boolean deleteCacheMapValue(final String key, final String hKey) {
|
||||||
|
@ -293,7 +278,6 @@ public class RedisService {
|
||||||
* 获得缓存的基本对象列表
|
* 获得缓存的基本对象列表
|
||||||
*
|
*
|
||||||
* @param pattern 字符串前缀
|
* @param pattern 字符串前缀
|
||||||
*
|
|
||||||
* @return 对象列表
|
* @return 对象列表
|
||||||
*/
|
*/
|
||||||
public Collection<String> keys(final String pattern) {
|
public Collection<String> keys(final String pattern) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ import static java.lang.Thread.sleep;
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ModelsKafkaMessage {
|
public class ModelsKafkaMessage {
|
||||||
private static final String TOPIC_NAME = "xy";
|
private static final String TOPIC_NAME = "topic_lyh";
|
||||||
private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092";
|
private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092";
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.couplet.analyze.common.contents.AnalyzeEventContents;
|
||||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||||
import com.couplet.analyze.msg.service.IncidentService;
|
import com.couplet.analyze.msg.service.IncidentService;
|
||||||
import com.couplet.common.core.text.Convert;
|
import com.couplet.common.core.text.Convert;
|
||||||
|
import com.couplet.common.core.utils.StringUtils;
|
||||||
import com.couplet.common.domain.Fence;
|
import com.couplet.common.domain.Fence;
|
||||||
import com.couplet.common.domain.request.FenceAndLogeRequest;
|
import com.couplet.common.domain.request.FenceAndLogeRequest;
|
||||||
import com.couplet.common.redis.service.RedisService;
|
import com.couplet.common.redis.service.RedisService;
|
||||||
|
@ -48,6 +49,9 @@ public class ElectronicFenceServiceImpl implements IncidentService {
|
||||||
log.info("电子围栏事件redis存在.......");
|
log.info("电子围栏事件redis存在.......");
|
||||||
for (Fence fence : cacheSet) {
|
for (Fence fence : cacheSet) {
|
||||||
String fenceLongitudeLatitude = fence.getFenceLongitudeLatitude();
|
String fenceLongitudeLatitude = fence.getFenceLongitudeLatitude();
|
||||||
|
if (!StringUtils.isEmpty(fenceLongitudeLatitude)){
|
||||||
|
log.info("电子围栏没有数据鸭...");
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 先通过;后切割
|
* 先通过;后切割
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,29 +43,16 @@ public class RealTimeDataServiceImpl implements IncidentService {
|
||||||
@Override
|
@Override
|
||||||
public void incident(CoupletMsgData coupletMsgData) {
|
public void incident(CoupletMsgData coupletMsgData) {
|
||||||
log.info("实时数据事件开始.....");
|
log.info("实时数据事件开始.....");
|
||||||
Set<Set<String, HashSet<>>> cacheSet = redisService.getCacheSet("vin:" + coupletMsgData.getVin());
|
|
||||||
// //判断是否有缓存数据
|
if (redisService.hasKey("实时轨迹vin:"+ coupletMsgData.getVin())){
|
||||||
// if (redisService.hasKey("vin:query:" + coupletMsgData.getVin())){
|
boolean a= ("实时轨迹vin:" + coupletMsgData.getVin()).equals("实时轨迹vin:"+ coupletMsgData.getVin());
|
||||||
// redisService.deleteObject("vin:query:" + coupletMsgData.getVin());
|
if (a){
|
||||||
// }
|
log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据一致,开始传输实时数据", coupletMsgData.getVin(), coupletMsgData);
|
||||||
// if (RealTimeJudge.isJudge(coupletMsgData.getVin())) {
|
|
||||||
if (StringUtils.isArray(cacheObject)){
|
|
||||||
if (coupletMsgData.getVin().equals(cacheObject.getVin())){
|
|
||||||
// log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin());
|
|
||||||
//判断数据是否一致,
|
|
||||||
// if (RealTimeJudge.addRealTime(cacheObject)) {
|
|
||||||
log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject);
|
|
||||||
redisService.setCacheSet("vin:query:" + coupletMsgData.getVin(), coupletMsgData);
|
redisService.setCacheSet("vin:query:" + coupletMsgData.getVin(), coupletMsgData);
|
||||||
redisService.expire("vin:"+coupletMsgData.getVin(),10, TimeUnit.MINUTES);
|
redisService.expire("vin:"+coupletMsgData.getVin(),10, TimeUnit.MINUTES);
|
||||||
// } else {
|
|
||||||
// log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据不一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("实时数据事件结束.....");
|
log.info("实时数据事件结束.....");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class RealTimeJudge {
|
||||||
userIds = new HashSet<>();
|
userIds = new HashSet<>();
|
||||||
setMap.put(realTimeDataRequest.getVin(),userIds);
|
setMap.put(realTimeDataRequest.getVin(),userIds);
|
||||||
}
|
}
|
||||||
userIds.add(realTimeDataRequest.getUserId());
|
// userIds.add(realTimeDataRequest.getUserId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,7 @@ import org.springframework.stereotype.Service;
|
||||||
import springfox.documentation.spring.web.json.Json;
|
import springfox.documentation.spring.web.json.Json;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,13 +60,19 @@ public class VehicleDetectionServiceImpl implements VehicleDetectionService{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void monitorinData(String vin) {
|
public void monitorinData(String vin) {
|
||||||
|
//创建对象
|
||||||
RealTimeDataRequest realTimeDataRequest = new RealTimeDataRequest();
|
RealTimeDataRequest realTimeDataRequest = new RealTimeDataRequest();
|
||||||
|
//获取用户id
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
//设置车辆vin
|
||||||
realTimeDataRequest.setVin(vin);
|
realTimeDataRequest.setVin(vin);
|
||||||
realTimeDataRequest.setUserId(userId);
|
//创建hashSet集合
|
||||||
// analyzeEventCache.queryEvent("查询实时数据"+vin,realTimeDataRequest);
|
HashSet<Long> objects = new HashSet<>();
|
||||||
// redisService.expire("查询实时数据"+vin,4,TimeUnit.MINUTES);
|
//添加车辆id
|
||||||
redisService.setVinAndUserId(realTimeDataRequest);
|
objects.add(userId);
|
||||||
|
//把对象放入hashSet集合中
|
||||||
|
//存储的对象是:key:业务+vin value: hashSet集合类型的对象
|
||||||
|
redisService.setCacheSet("实时轨迹vin:"+ vin,objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,11 +16,9 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class MqController {
|
||||||
RealTimeDataRequest realTimeDataRequest = new RealTimeDataRequest();
|
RealTimeDataRequest realTimeDataRequest = new RealTimeDataRequest();
|
||||||
realTimeDataRequest.setVin(vin);
|
realTimeDataRequest.setVin(vin);
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
realTimeDataRequest.setUserId(userId);
|
|
||||||
rabbitTemplate.convertAndSend(RabbitMQConfig.VinExchangeName, RabbitMQConfig.VinRoutingKey, realTimeDataRequest,
|
rabbitTemplate.convertAndSend(RabbitMQConfig.VinExchangeName, RabbitMQConfig.VinRoutingKey, realTimeDataRequest,
|
||||||
message -> {
|
message -> {
|
||||||
message.getMessageProperties().setMessageId(IdUtils.randomUUID());
|
message.getMessageProperties().setMessageId(IdUtils.randomUUID());
|
||||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
Loading…
Reference in New Issue