Compare commits
10 Commits
9822f2f548
...
b293555663
Author | SHA1 | Date |
---|---|---|
|
b293555663 | |
|
0b3ed78d08 | |
|
802c97682c | |
|
bc8558576f | |
|
3fc01c4102 | |
|
36c5923bba | |
|
db23137c38 | |
|
f9ce3da77e | |
|
036db4cd79 | |
|
4101e76188 |
|
@ -17,9 +17,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package com.couplet.common.redis.service;
|
package com.couplet.common.redis.service;
|
||||||
|
|
||||||
|
import ch.qos.logback.core.BasicStatusManager;
|
||||||
import com.couplet.common.domain.CoupletVehicleData;
|
import com.couplet.common.domain.CoupletVehicleData;
|
||||||
import com.couplet.common.domain.request.RealTimeDataRequest;
|
import com.couplet.common.domain.request.RealTimeDataRequest;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.apache.poi.ss.formula.functions.T;
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.*;
|
import org.springframework.data.redis.core.*;
|
||||||
|
@ -301,8 +304,21 @@ public class RedisService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVinAndUserId(RealTimeDataRequest realTimeDataRequest) {
|
public void setVinAndUserId(RealTimeDataRequest realTimeDataRequest) {
|
||||||
String key = "vin:" + realTimeDataRequest.getVin();
|
String key = "vin"+realTimeDataRequest.getVin();
|
||||||
redisTemplate.opsForSet().add(key,realTimeDataRequest);
|
SetOperations setOperations = redisTemplate.opsForSet();
|
||||||
|
// 序列化RealTimeDataRequest对象为JSON字符串
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
String jsonStr;
|
||||||
|
try {
|
||||||
|
jsonStr = mapper.writeValueAsString(realTimeDataRequest);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new RuntimeException(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> wrappedJson = Collections.singletonList(jsonStr);
|
||||||
|
|
||||||
|
// 将List作为Set的唯一元素添加到Redis中
|
||||||
|
setOperations.add(key, wrappedJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopViewingData(String vin) {
|
public void stopViewingData(String vin) {
|
||||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -17,12 +17,10 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@EnableFeignClients(basePackages = "com.couplet")
|
@EnableFeignClients(basePackages = "com.couplet")
|
||||||
public class CoupletMsgApplication {
|
public class CoupletMsgApplication {
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(CoupletMsgApplication.class);
|
SpringApplication.run(CoupletMsgApplication.class);
|
||||||
System.out.println("解析系统启动成功");
|
System.out.println("解析系统启动成功");
|
||||||
// new ModelsKafkaMessage().initKafkaConsumer();
|
new ModelsKafkaMessage().initKafkaConsumer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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 = "online";
|
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";
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,13 +52,16 @@ public class ModelsKafkaMessage {
|
||||||
private AnalyzeEventCache analyzeEventCache;
|
private AnalyzeEventCache analyzeEventCache;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//kafka消费者初始化
|
//kafka消费者初始化
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void initKafkaConsumer() {
|
public void initKafkaConsumer() {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS);
|
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS);
|
||||||
// props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group");
|
// props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group");
|
||||||
props.put(ConsumerConfig.GROUP_ID_CONFIG, "ddd");
|
props.put(ConsumerConfig.GROUP_ID_CONFIG, "group");
|
||||||
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
|
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
|
||||||
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
|
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
|
||||||
|
|
||||||
|
@ -88,7 +91,7 @@ public class ModelsKafkaMessage {
|
||||||
while (true) {
|
while (true) {
|
||||||
ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(100));
|
ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(100));
|
||||||
records.forEach(record -> {
|
records.forEach(record -> {
|
||||||
System.out.println("接收到的数据:" + record.value());
|
log.info("接收到的数据:" + record.value());
|
||||||
String str = hexToString(record.value());
|
String str = hexToString(record.value());
|
||||||
List<CoupletMsgData> coupletMsgDataList = sendMsg(str);
|
List<CoupletMsgData> coupletMsgDataList = sendMsg(str);
|
||||||
for (CoupletMsgData msgData : coupletMsgDataList) {
|
for (CoupletMsgData msgData : coupletMsgDataList) {
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -46,12 +47,11 @@ public class ElectronicFenceServiceImpl implements IncidentService {
|
||||||
if (redisService.hasKey(fenceKey)) {
|
if (redisService.hasKey(fenceKey)) {
|
||||||
Set<Fence> cacheSet = redisService.getCacheSet(fenceKey);
|
Set<Fence> cacheSet = redisService.getCacheSet(fenceKey);
|
||||||
log.info("电子围栏事件redis存在.......");
|
log.info("电子围栏事件redis存在.......");
|
||||||
//jingdu;
|
|
||||||
//longitude;
|
|
||||||
//weidu;
|
|
||||||
//latitude;
|
|
||||||
for (Fence fence : cacheSet) {
|
for (Fence fence : cacheSet) {
|
||||||
String fenceLongitudeLatitude = fence.getFenceLongitudeLatitude();
|
String fenceLongitudeLatitude = fence.getFenceLongitudeLatitude();
|
||||||
|
if (!StringUtils.isEmpty(fenceLongitudeLatitude)){
|
||||||
|
log.info("电子围栏没有数据鸭...");
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 先通过;后切割
|
* 先通过;后切割
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||||
import com.couplet.analyze.msg.mapper.IncidentMapper;
|
import com.couplet.analyze.msg.mapper.IncidentMapper;
|
||||||
import com.couplet.analyze.msg.service.IncidentService;
|
import com.couplet.analyze.msg.service.IncidentService;
|
||||||
import com.couplet.analyze.msg.service.impl.realTimeData.RealTimeJudge;
|
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.domain.request.RealTimeDataRequest;
|
||||||
import com.couplet.common.redis.service.RedisService;
|
import com.couplet.common.redis.service.RedisService;
|
||||||
import com.couplet.remote.RemoteRealTimeService;
|
import com.couplet.remote.RemoteRealTimeService;
|
||||||
|
@ -12,6 +13,8 @@ import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,12 +26,6 @@ import java.util.concurrent.TimeUnit;
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class RealTimeDataServiceImpl implements IncidentService {
|
public class RealTimeDataServiceImpl implements IncidentService {
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询传入的数据是否存在
|
|
||||||
*/
|
|
||||||
@Autowired
|
|
||||||
private IncidentMapper incidentMapper;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
|
@ -40,28 +37,16 @@ public class RealTimeDataServiceImpl implements IncidentService {
|
||||||
@Override
|
@Override
|
||||||
public void incident(CoupletMsgData coupletMsgData) {
|
public void incident(CoupletMsgData coupletMsgData) {
|
||||||
log.info("实时数据事件开始.....");
|
log.info("实时数据事件开始.....");
|
||||||
RealTimeDataRequest cacheObject = redisService.getCacheObject("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())) {
|
redisService.setCacheSet("vin:query:" + coupletMsgData.getVin(), coupletMsgData);
|
||||||
if (coupletMsgData.getVin().equals(cacheObject.getVin())){
|
redisService.expire("vin:"+coupletMsgData.getVin(),10, TimeUnit.MINUTES);
|
||||||
// log.info("有实时数据,值为:[{}]开始传输实时数据", coupletMsgData.getVin());
|
}
|
||||||
//判断数据是否一致,
|
|
||||||
// if (RealTimeJudge.addRealTime(cacheObject)) {
|
|
||||||
log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject);
|
|
||||||
redisService.setCacheSet("vin:query:" + coupletMsgData.getVin(), coupletMsgData);
|
|
||||||
redisService.expire("vin:"+coupletMsgData.getVin(),10, TimeUnit.MINUTES);
|
|
||||||
// } else {
|
|
||||||
// log.info("[{}]有缓存数据,值为:[{}],且缓存数据与实时数据不一致,开始传输实时数据", coupletMsgData.getVin(), cacheObject);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("[{}]开始传输实时数据", coupletMsgData.getVin());
|
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,17 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
|
||||||
main:
|
main:
|
||||||
allow-bean-definition-overriding: true
|
allow-bean-definition-overriding: true
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
|
@ -48,3 +51,4 @@ logging:
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
configuration:
|
configuration:
|
||||||
map-underscore-to-camel-case: true
|
map-underscore-to-camel-case: true
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,6 @@
|
||||||
<groupId>com.couplet</groupId>
|
<groupId>com.couplet</groupId>
|
||||||
<artifactId>couplet-analyze-msg</artifactId>
|
<artifactId>couplet-analyze-msg</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
|
||||||
@EnableCustomConfig
|
@EnableCustomConfig
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableMyFeignClients(basePackages = ("com.couplet"))
|
@EnableMyFeignClients(basePackages = ("com.couplet"))
|
||||||
@SpringBootApplication(scanBasePackages = {"com.couplet", "com.couplet.mq.remote"})
|
@SpringBootApplication(scanBasePackages = {"com.couplet"})
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
public class CoupletBusinessApplication {
|
public class CoupletBusinessApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author fufanrui
|
* @author fufanrui
|
||||||
|
@ -67,9 +68,9 @@ public class VehicleDetectionController {
|
||||||
* @date
|
* @date
|
||||||
*/
|
*/
|
||||||
@PostMapping("/monitorinDataList/{vin}")
|
@PostMapping("/monitorinDataList/{vin}")
|
||||||
public Result<List<CoupletMsgData>> monitorinDataList(@PathVariable String vin){
|
public Result<Set<CoupletMsgData>> monitorinDataList(@PathVariable String vin){
|
||||||
List<CoupletMsgData> monitorinDataList = vehicleDetectionService.monitorinDataList(vin);
|
Set<CoupletMsgData> monitorinDataList = vehicleDetectionService.monitorinDataList(vin);
|
||||||
Result<List<CoupletMsgData>> success = Result.success(monitorinDataList);
|
Result<Set<CoupletMsgData>> success = Result.success(monitorinDataList);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.couplet.common.domain.CoupletVehicleData;
|
||||||
import com.couplet.common.domain.Vehicle;
|
import com.couplet.common.domain.Vehicle;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public interface VehicleDetectionService {
|
public interface VehicleDetectionService {
|
||||||
|
|
||||||
|
@ -13,7 +14,9 @@ public interface VehicleDetectionService {
|
||||||
|
|
||||||
void stopViewingData(String vin);
|
void stopViewingData(String vin);
|
||||||
|
|
||||||
List<CoupletMsgData> monitorinDataList(String vin);
|
|
||||||
|
|
||||||
void monitorinData(String vin);
|
void monitorinData(String vin);
|
||||||
|
|
||||||
|
Set<CoupletMsgData> monitorinDataList(String vin);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,12 +44,12 @@ public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements
|
||||||
*/
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
private StringRedisTemplate redisTemplate;
|
private StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 远程调用队列服务
|
* 远程调用队列服务
|
||||||
*/
|
*/
|
||||||
// @Autowired
|
// @Autowired
|
||||||
// private RemoteFenceService remoteFenceService;
|
// private RemoteFenceService remoteFenceService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Fence> pageQuery(FenceConfig fenceConfig) {
|
public List<Fence> pageQuery(FenceConfig fenceConfig) {
|
||||||
List<Fence> list = fenceMapper.pageQuery(fenceConfig);
|
List<Fence> list = fenceMapper.pageQuery(fenceConfig);
|
||||||
|
@ -70,36 +70,26 @@ public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements
|
||||||
// remoteFenceService.fenceQueue(fenceUpdateRequest);
|
// remoteFenceService.fenceQueue(fenceUpdateRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fenceInsert(FenceRequest fenceRequest) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务实现:添加围栏
|
* 业务实现:添加围栏
|
||||||
*
|
*
|
||||||
* @param request
|
* @param
|
||||||
* @param fenceRequest
|
* @param fenceRequest
|
||||||
*/
|
*/
|
||||||
// @Override
|
@Override
|
||||||
// public void fenceInsert(HttpServletRequest request, FenceRequest fenceRequest) {
|
public void fenceInsert(FenceRequest fenceRequest) {
|
||||||
// String username = SecurityUtils.getUsername();
|
String username = SecurityUtils.getUsername();
|
||||||
// fenceRequest.setCrateName(username);
|
fenceRequest.setCrateName(username);
|
||||||
// //先添加围栏
|
fenceRequest.setMaintainerName(username);
|
||||||
// fenceMapper.insertFence(fenceRequest);
|
//先添加围栏
|
||||||
// String[] logoIds = fenceRequest.getLogoIds();
|
fenceMapper.insertFence(fenceRequest);
|
||||||
// String[] parts = new String[0];
|
|
||||||
// for (String logoId : logoIds) {
|
fenAndLogoService.addBach(fenceRequest.getFenceId(), fenceRequest.getLogoIds());
|
||||||
// //把前台传入的字符串分割成数组
|
/**
|
||||||
// parts = logoId.split(",");
|
* 电子围栏发送改变
|
||||||
// //再添加围栏和标识中间表
|
*/
|
||||||
// fenAndLogoService.addBach(fenceRequest.getFenceId(), parts);
|
redisTemplate.opsForValue().set("fenceInsert", JSON.toJSONString(fenceRequest), 10, TimeUnit.MINUTES);
|
||||||
// }
|
}
|
||||||
// /**
|
|
||||||
// * 电子围栏发送改变
|
|
||||||
// */
|
|
||||||
// redisTemplate.opsForValue().set("fenceInsert", JSON.toJSONString(fenceRequest), 10, TimeUnit.MINUTES);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeByFenceId(Long fenceId) {
|
public void removeByFenceId(Long fenceId) {
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,23 +50,29 @@ public class VehicleDetectionServiceImpl implements VehicleDetectionService{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CoupletMsgData> monitorinDataList(String vin) {
|
public Set<CoupletMsgData> monitorinDataList(String vin) {
|
||||||
String key = "vin:query:" + vin;
|
String key = "vin:query:" + vin;
|
||||||
log.info("key为:"+key);
|
log.info("key为:"+key);
|
||||||
Set<CoupletMsgData> cacheSet = redisService.getCacheSet(key);
|
Set<CoupletMsgData> cacheSet = redisService.getCacheSet(key);
|
||||||
ArrayList<CoupletMsgData> coupletMsgData = new ArrayList<>(cacheSet);
|
|
||||||
return coupletMsgData;
|
return cacheSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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
|
||||||
|
|
|
@ -423,11 +423,12 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
bindLogoById.forEach(logoId -> {
|
bindLogoById.forEach(logoId -> {
|
||||||
|
|
||||||
//存标识id 的set
|
//存标识id 的set
|
||||||
HashSet<Long> logos = new HashSet<>();
|
// HashSet<Long> logos = new HashSet<>();
|
||||||
logos.add(logoId);
|
// logos.add(logoId);
|
||||||
//存入redis
|
// //存入redis
|
||||||
redis.setCacheSet("车辆vin和标识:" + vehicle.getVin(), logos);
|
// redis.setCacheSet("车辆vin和标识:" + vehicle.getVin(), logos);
|
||||||
redis.expire("车辆vin和标识:" + vehicle.getVin(), 2, TimeUnit.MINUTES);
|
|
||||||
|
// redis.expire("车辆vin和标识:" + vehicle.getVin(), 5, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
|
||||||
//通过标识id获取标识绑定的电子围栏集合
|
//通过标识id获取标识绑定的电子围栏集合
|
||||||
|
@ -438,7 +439,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
fanceSet.add(fence);
|
fanceSet.add(fence);
|
||||||
//存入redis
|
//存入redis
|
||||||
redis.setCacheSet("车辆vin和电子围栏:" + vehicle.getVin(), fanceSet);
|
redis.setCacheSet("车辆vin和电子围栏:" + vehicle.getVin(), fanceSet);
|
||||||
redis.expire("车辆vin和电子围栏:" + vehicle.getVin(), 2, TimeUnit.MINUTES);
|
// redis.expire("车辆vin和电子围栏:" + vehicle.getVin(), 5, TimeUnit.MINUTES);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,11 +16,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
namespace: 172469
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
namespace: 172469
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -57,11 +57,10 @@
|
||||||
</sql>
|
</sql>
|
||||||
<insert id="insertFence" parameterType="com.couplet.common.domain.request.FenceRequest" keyProperty="fenceId"
|
<insert id="insertFence" parameterType="com.couplet.common.domain.request.FenceRequest" keyProperty="fenceId"
|
||||||
useGeneratedKeys="true">
|
useGeneratedKeys="true">
|
||||||
INSERT INTO `couplet-cloud`.`couplet_fence_info`
|
INSERT INTO `couplet-cloud`.`couplet_fence_info`
|
||||||
(`fence_name`, `fence_longitude_latitude`, `fence_description`, `is_delete`, `fence_state`, `create_time`,
|
(`fence_name`,`fence_longitude_latitude`, `fence_description`, `is_delete`, `fence_state`, `create_time`,
|
||||||
`update_time`, `create_name`, `maintainer_name`, `alarm_status`,`fence_condition`)
|
`update_time`, `create_name`, `maintainer_name`, `alarm_status`, `fence_condition`)
|
||||||
VALUES
|
VALUES (#{fenceName}, NULL, #{fenceDescription} , 0, 0, now(), NULL, #{crateName}, #{maintainerName}, 0, 1)
|
||||||
(#{fenceName}, null, #{fenceDescription}, 0, 0, now(), null, null, #{maintainerName}, 0 ,0)
|
|
||||||
|
|
||||||
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -17,9 +17,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -15,11 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
namespace: 172469
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
namespace: 172469
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
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,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class MqttMonitor {
|
||||||
|
|
||||||
|
|
||||||
//Kafka生产者配置
|
//Kafka生产者配置
|
||||||
private static final String TOPIC_NAME = "fufanrui";
|
private static final String TOPIC_NAME = "topic_lhy";
|
||||||
private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092";
|
private static final String BOOTSTRAP_SERVERS = "39.103.133.136:9092";
|
||||||
|
|
||||||
//线程池,用于异步处理消息到来时的业务逻辑
|
//线程池,用于异步处理消息到来时的业务逻辑
|
||||||
|
|
|
@ -36,7 +36,7 @@ mqtt:
|
||||||
# broker: mqtt://115.159.47.13:1883
|
# broker: mqtt://115.159.47.13:1883
|
||||||
username:
|
username:
|
||||||
password:
|
password:
|
||||||
clientId: fufanrui44
|
clientId: aaaaaad
|
||||||
qos: 0
|
qos: 0
|
||||||
topic: test898
|
topic: xiaoYao
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
namespace: 172469
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
namespace: 172469
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -15,11 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
namespace: 172469
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
namespace: 172469
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
Loading…
Reference in New Issue