Compare commits
11 Commits
57c31b68c3
...
663111d885
Author | SHA1 | Date |
---|---|---|
|
663111d885 | |
|
1c6cebb2cc | |
|
16d72968d4 | |
|
8bbaadea94 | |
|
78afcf9ecc | |
|
b4ad3e4f47 | |
|
c4eb443372 | |
|
b3bc515135 | |
|
4e021d316b | |
|
0569099b02 | |
|
0774e29edd |
|
@ -4,6 +4,7 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 认证授权中心
|
* 认证授权中心
|
||||||
|
@ -12,6 +13,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
*/
|
*/
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||||
|
@ComponentScan(basePackages = {"com.couplet"})
|
||||||
public class CoupletAuthApplication {
|
public class CoupletAuthApplication {
|
||||||
public static void main (String[] args) {
|
public static void main (String[] args) {
|
||||||
SpringApplication.run(CoupletAuthApplication.class, args);
|
SpringApplication.run(CoupletAuthApplication.class, args);
|
||||||
|
|
|
@ -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
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.couplet.common.domain.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/4/7
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FenceAndLogeRequest {
|
||||||
|
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private Long[] logoIds;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
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.common.domain.request.FenceAndLogeRequest;
|
||||||
|
import com.couplet.remote.factory.RemoteFenceAndLogFallbackFactory;
|
||||||
|
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 = "remoteFenceAndLogService" ,
|
||||||
|
value = ServiceNameConstants.BUSINESS_SERVICE,
|
||||||
|
fallbackFactory = RemoteFenceAndLogFallbackFactory.class
|
||||||
|
)
|
||||||
|
public interface RemoteFenceAndLogService {
|
||||||
|
|
||||||
|
@PostMapping("/queryByFenceAndLogoIds")
|
||||||
|
public Result<?> queryByFenceAndLogoIds(@RequestBody FenceAndLogeRequest fenceAndLogeRequest);
|
||||||
|
|
||||||
|
}
|
|
@ -4,7 +4,9 @@ import com.couplet.common.core.constant.ServiceNameConstants;
|
||||||
import com.couplet.common.core.domain.Result;
|
import com.couplet.common.core.domain.Result;
|
||||||
import com.couplet.common.domain.Vehicle;
|
import com.couplet.common.domain.Vehicle;
|
||||||
import com.couplet.common.domain.VehicleMiddle;
|
import com.couplet.common.domain.VehicleMiddle;
|
||||||
|
import com.couplet.common.domain.request.VehicleListParams;
|
||||||
import com.couplet.remote.factory.RemoteVehicleFallbackFactory;
|
import com.couplet.remote.factory.RemoteVehicleFallbackFactory;
|
||||||
|
import lombok.extern.java.Log;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@ -54,5 +56,15 @@ public interface RemoteVehicleService {
|
||||||
@GetMapping("onOrOutLineByVIN")
|
@GetMapping("onOrOutLineByVIN")
|
||||||
public Integer onOrOutLineByVIN(@RequestParam("params") String params);
|
public Integer onOrOutLineByVIN(@RequestParam("params") String params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据车辆id查询绑定的标识
|
||||||
|
* @param vehicleId
|
||||||
|
* @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,34 @@
|
||||||
|
package com.couplet.remote.factory;
|
||||||
|
|
||||||
|
import com.couplet.common.core.domain.Result;
|
||||||
|
import com.couplet.common.domain.CoupletTroubleCode;
|
||||||
|
import com.couplet.common.domain.request.FenceAndLogeRequest;
|
||||||
|
import com.couplet.remote.RemoteFenceAndLogService;
|
||||||
|
import com.couplet.remote.RemoteTroubleService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author fufanrui
|
||||||
|
* @version 1.0
|
||||||
|
* @description: TODO
|
||||||
|
* @date 2024/4/2 14:46
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RemoteFenceAndLogFallbackFactory implements FallbackFactory<RemoteFenceAndLogService> {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(RemoteFenceAndLogFallbackFactory.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RemoteFenceAndLogService create(Throwable cause) {
|
||||||
|
return new RemoteFenceAndLogService() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<?> queryByFenceAndLogoIds(FenceAndLogeRequest fenceAndLogeRequest) {
|
||||||
|
|
||||||
|
return Result.error(cause.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package com.couplet.remote.factory;
|
||||||
import com.couplet.common.core.domain.Result;
|
import com.couplet.common.core.domain.Result;
|
||||||
import com.couplet.common.domain.Vehicle;
|
import com.couplet.common.domain.Vehicle;
|
||||||
import com.couplet.common.domain.VehicleMiddle;
|
import com.couplet.common.domain.VehicleMiddle;
|
||||||
|
import com.couplet.common.domain.request.VehicleListParams;
|
||||||
import com.couplet.remote.RemoteVehicleService;
|
import com.couplet.remote.RemoteVehicleService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -56,6 +57,16 @@ public class RemoteVehicleFallbackFactory implements FallbackFactory<RemoteVehic
|
||||||
log.error("车辆服务调用失败:" + cause.getMessage());
|
log.error("车辆服务调用失败:" + cause.getMessage());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<Long>> queryByLogoIds(Long vehicleId) {
|
||||||
|
return Result.error("车辆服务调用失败:"+cause.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result list(VehicleListParams listParams) {
|
||||||
|
return Result.error("车辆服务调用失败:"+cause.getMessage());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
com.couplet.remote.factory.RemoteTroubleFallbackFactory
|
|
||||||
com.couplet.remote.factory.RemoteVehicleFallbackFactory
|
com.couplet.remote.factory.RemoteVehicleFallbackFactory
|
||||||
|
com.couplet.remote.factory.RemoteTroubleFallbackFactory
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.couplet.common.core.utils;
|
package com.couplet.common.core.utils;
|
||||||
|
|
||||||
|
import com.couplet.common.core.web.page.TableSupport;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.couplet.common.core.utils.sql.SqlUtil;
|
import com.couplet.common.core.utils.sql.SqlUtil;
|
||||||
import com.couplet.common.core.web.page.PageDomain;
|
import com.couplet.common.core.web.page.PageDomain;
|
||||||
import com.couplet.common.core.web.page.TableSupport;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页工具类
|
* 分页工具类
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>couplet-common-event</artifactId>
|
||||||
|
|
||||||
|
<description>事件系统</description>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.couplet.analyze.common.contents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/4/7
|
||||||
|
* @Description: 事件内容
|
||||||
|
*/
|
||||||
|
public class AnalyzeEventContents {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障
|
||||||
|
*/
|
||||||
|
String BREAKDOWN = "breakdown";
|
||||||
|
/**
|
||||||
|
* 电子围栏
|
||||||
|
*/
|
||||||
|
String ELECTRONIC_FENCE = "electronic-fence";
|
||||||
|
/**
|
||||||
|
* 实时数据
|
||||||
|
*/
|
||||||
|
String REAL_TIME_DATA = "real-time-data";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储
|
||||||
|
*/
|
||||||
|
String STORED_EVENT = "stored-event";
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.couplet.analyze.common.event;
|
||||||
|
|
||||||
|
import com.couplet.common.redis.service.RedisService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/4/7
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class AnalyzeEventCache {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisService redisService;
|
||||||
|
|
||||||
|
public String encode(String vin){
|
||||||
|
return "event:arr"+vin;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 添加事件
|
||||||
|
*/
|
||||||
|
public void addEvent(String vin, String eventValue) {
|
||||||
|
redisService.setCacheSet(encode(vin), eventValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改事件
|
||||||
|
*/
|
||||||
|
public void updateEvent(String vin,String eventValue){
|
||||||
|
redisService.setCacheSet(encode(vin), eventValue);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 删除事件
|
||||||
|
*/
|
||||||
|
public void removeEvent(String vin,String eventName){
|
||||||
|
redisService.deleteSet(encode(vin), eventName);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取事件集合
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Set<Object> getEventList(String vin){
|
||||||
|
|
||||||
|
return redisService.getCacheSet(encode(vin));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
com.couplet.analyze.common.event.AnalyzeEventCache
|
|
@ -1,6 +1,8 @@
|
||||||
package com.couplet.common.redis.service;
|
package com.couplet.common.redis.service;
|
||||||
|
|
||||||
import com.couplet.common.domain.CoupletVehicleData;
|
import com.couplet.common.domain.CoupletVehicleData;
|
||||||
|
import com.couplet.common.domain.request.RealTimeDataRequest;
|
||||||
|
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.*;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -260,4 +262,9 @@ public class RedisService {
|
||||||
public Collection<String> keys (final String pattern) {
|
public Collection<String> keys (final String pattern) {
|
||||||
return redisTemplate.keys(pattern);
|
return redisTemplate.keys(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setVinAndUserId(RealTimeDataRequest realTimeDataRequest) {
|
||||||
|
String key = "vin:"+realTimeDataRequest.getVin()+"userId:"+realTimeDataRequest.getUserId();
|
||||||
|
redisTemplate.opsForValue().set(key, realTimeDataRequest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.couplet.common.system.domain.SysDept;
|
||||||
import com.couplet.common.system.remote.RemoteDeptService;
|
import com.couplet.common.system.remote.RemoteDeptService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ import java.util.List;
|
||||||
* @date 2024/3/27 15:29
|
* @date 2024/3/27 15:29
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Component
|
||||||
public class RemoteDeptFallbackFactory implements FallbackFactory<RemoteDeptService> {
|
public class RemoteDeptFallbackFactory implements FallbackFactory<RemoteDeptService> {
|
||||||
@Override
|
@Override
|
||||||
public RemoteDeptService create(Throwable cause) {
|
public RemoteDeptService create(Throwable cause) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.couplet.common.core.web.page.TableDataInfo;
|
||||||
import com.couplet.common.system.domain.SysUser;
|
import com.couplet.common.system.domain.SysUser;
|
||||||
import com.couplet.common.system.remote.RemoteEmployeeService;
|
import com.couplet.common.system.remote.RemoteEmployeeService;
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ import java.util.List;
|
||||||
* @description: 员工服务降级处理
|
* @description: 员工服务降级处理
|
||||||
* @date 2024/3/31 19:43
|
* @date 2024/3/31 19:43
|
||||||
*/
|
*/
|
||||||
|
@Component
|
||||||
public class RemoteEmployeeFallbackFactory implements FallbackFactory<RemoteEmployeeService> {
|
public class RemoteEmployeeFallbackFactory implements FallbackFactory<RemoteEmployeeService> {
|
||||||
@Override
|
@Override
|
||||||
public RemoteEmployeeService create(Throwable cause) {
|
public RemoteEmployeeService create(Throwable cause) {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
<module>couplet-common-datasource</module>
|
<module>couplet-common-datasource</module>
|
||||||
<module>couplet-common-system</module>
|
<module>couplet-common-system</module>
|
||||||
<module>couplet-common-business</module>
|
<module>couplet-common-business</module>
|
||||||
|
<module>couplet-common-event</module>
|
||||||
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
<artifactId>couplet-analyze-msg</artifactId>
|
<artifactId>couplet-analyze-msg</artifactId>
|
||||||
|
|
||||||
|
<description>解析系统</description>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
@ -86,13 +87,14 @@
|
||||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
<version>1.2.5</version>
|
<version>1.2.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- 事件核心配置 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.couplet</groupId>
|
<groupId>com.couplet</groupId>
|
||||||
<artifactId>couplet-modules-mq</artifactId>
|
<artifactId>couplet-common-event</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.couplet</groupId>
|
<groupId>org.springframework.kafka</groupId>
|
||||||
<artifactId>couplet-common-business</artifactId>
|
<artifactId>spring-kafka</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -1,81 +1,84 @@
|
||||||
package com.couplet.analyze.msg.consumer;
|
//package com.couplet.analyze.msg.consumer;
|
||||||
|
//
|
||||||
|
//import com.couplet.common.core.text.Convert;
|
||||||
import com.alibaba.fastjson.JSON;
|
//import com.couplet.common.domain.request.FenceUpdateRequest;
|
||||||
import com.couplet.common.domain.request.FenceUpdateRequest;
|
//import com.couplet.common.redis.service.RedisService;
|
||||||
import com.rabbitmq.client.Channel;
|
//import com.rabbitmq.client.Channel;
|
||||||
import lombok.extern.log4j.Log4j2;
|
//import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.amqp.core.Message;
|
//import org.springframework.amqp.core.Message;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
//import org.springframework.data.redis.core.BoundSetOperations;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.util.HashMap;
|
//import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
//import java.util.HashSet;
|
||||||
import java.util.concurrent.TimeUnit;
|
//import java.util.Set;
|
||||||
|
//import java.util.concurrent.TimeUnit;
|
||||||
/**
|
//
|
||||||
* @Author: LiJiaYao
|
///**
|
||||||
* @Date: 2024/4/4
|
// * @Author: LiJiaYao
|
||||||
* @Description:
|
// * @Date: 2024/4/4
|
||||||
*/
|
// * @Description:
|
||||||
@Log4j2
|
// */
|
||||||
@Component
|
//@Log4j2
|
||||||
@RabbitListener(queues = "fenceQueue")
|
//@Component
|
||||||
public class FenceConsumer {
|
//@RabbitListener(queues = "fenceQueue")
|
||||||
@Autowired
|
//public class FenceConsumer {
|
||||||
private StringRedisTemplate redisTemplate;
|
// @Autowired
|
||||||
|
// private RedisService redisService;
|
||||||
@RabbitHandler
|
//
|
||||||
public void fenceConsumer(FenceUpdateRequest fenceUpdateRequest, Channel channel, Message message) throws IOException {
|
// @RabbitHandler
|
||||||
|
// public void fenceConsumer(FenceUpdateRequest fenceUpdateRequest, Channel channel, Message message) throws IOException {
|
||||||
log.info("消息进入队列,传入的数据是:[{}]", fenceUpdateRequest);
|
//
|
||||||
|
// log.info("电子围栏消息进入队列,传入的数据是:[{}]", fenceUpdateRequest);
|
||||||
String messageId = message.getMessageProperties().getMessageId();
|
//
|
||||||
long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
// String messageId = message.getMessageProperties().getMessageId();
|
||||||
if (!redisTemplate.hasKey("消息不丢失:" + messageId)) {
|
// long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||||
redisTemplate.opsForValue().set("消息不丢失:" + messageId, "" + deliveryTag, 1, TimeUnit.MINUTES);
|
// if (!redisService.hasKey("电子围栏消息不丢失:" + messageId)) {
|
||||||
}
|
// redisService.setCacheObject("电子围栏消息不丢失:" + messageId, "" + deliveryTag);
|
||||||
if (redisTemplate.hasKey("fence")){
|
// }
|
||||||
redisTemplate.delete("fence");
|
//// if (redisService.hasKey("fence")){
|
||||||
}
|
//// redisService.deleteObject("fence");
|
||||||
|
//// }
|
||||||
Long add = redisTemplate.opsForSet().add("消息不重复:" + messageId, messageId);
|
//
|
||||||
redisTemplate.expire("消息不重复:" + messageId, 5, TimeUnit.MINUTES);
|
// HashSet<String> objects = new HashSet<>();
|
||||||
try {
|
// objects.add(messageId);
|
||||||
if (0 < add) {
|
//
|
||||||
HashMap<String, Object> hashMap = new HashMap<>();
|
// BoundSetOperations<String, String> set = redisService.setCacheSet("电子围栏消息不重复:" + messageId, objects);
|
||||||
HashSet<FenceUpdateRequest> hashSet = new HashSet<>();
|
// redisService.expire("电子围栏消息不重复:" + messageId, 5, TimeUnit.MINUTES);
|
||||||
hashSet.add(fenceUpdateRequest);
|
// try {
|
||||||
hashMap.put(fenceUpdateRequest.getFenceId()+"",fenceUpdateRequest);
|
// if (set != null) {
|
||||||
// redisTemplate.opsForH("fence", JSON.toJSONString(hashMap),10,TimeUnit.MINUTES);
|
// HashMap<String, Object> hashMap = new HashMap<>();
|
||||||
// redisTemplate.opsForHash().put("fence", fenceUpdateRequest.getFenceId()+"", JSON.toJSONString(hashMap));
|
// HashSet<FenceUpdateRequest> hashSet = new HashSet<>();
|
||||||
redisTemplate.opsForList().rightPush("fence",JSON.toJSONString(hashMap));
|
// hashSet.add(fenceUpdateRequest);
|
||||||
redisTemplate.expire("fence", 10, TimeUnit.MINUTES);
|
// hashMap.put(fenceUpdateRequest.getFenceId()+"",fenceUpdateRequest);
|
||||||
//判断车辆是否有实时数据,如果没有则删除数据
|
//// redisTemplate.opsForH("fence", JSON.toJSONString(hashMap),10,TimeUnit.MINUTES);
|
||||||
channel.basicAck(deliveryTag, false);
|
//// redisTemplate.opsForHash().put("fence", fenceUpdateRequest.getFenceId()+"", JSON.toJSONString(hashMap));
|
||||||
} else {
|
//
|
||||||
log.error("消息不能重复消费:[{}]", fenceUpdateRequest);
|
// String key = Convert.toStr(fenceUpdateRequest.getFenceId());
|
||||||
channel.basicReject(deliveryTag, false);
|
// redisService.setCacheObject(key,fenceUpdateRequest);
|
||||||
}
|
// redisService.expire(key, 10, TimeUnit.MINUTES);
|
||||||
} catch (IOException e) {
|
// //判断车辆是否有实时数据,如果没有则删除数据
|
||||||
log.error("消息未进入队列,传入的信息是:【{}】", fenceUpdateRequest);
|
// channel.basicAck(deliveryTag, false);
|
||||||
String s = redisTemplate.opsForValue().get("消息不丢失:" + messageId);
|
// } else {
|
||||||
|
// log.error("电子围栏消息不能重复消费:[{}]", fenceUpdateRequest);
|
||||||
Long o = Long.valueOf(s);
|
// channel.basicReject(deliveryTag, false);
|
||||||
if (deliveryTag == o + 2) {
|
// }
|
||||||
log.error("消息已丢失,无法传入的信息是:【{}】", fenceUpdateRequest);
|
// } catch (IOException e) {
|
||||||
channel.basicNack(deliveryTag, false, false);
|
// log.error("电子围栏消息未进入队列,传入的信息是:【{}】", fenceUpdateRequest);
|
||||||
} else {
|
// String s = redisService.getCacheObject("电子围栏消息不丢失:" + messageId);
|
||||||
log.error("消息已丢失,已再次传入的信息是:【{}】", fenceUpdateRequest);
|
//
|
||||||
channel.basicNack(deliveryTag, true, false);
|
// Long o = Long.valueOf(s);
|
||||||
}
|
// if (deliveryTag == o + 2) {
|
||||||
}
|
// log.error("电子围栏消息已丢失,无法传入的信息是:【{}】", fenceUpdateRequest);
|
||||||
|
// channel.basicNack(deliveryTag, false, false);
|
||||||
|
// } else {
|
||||||
}
|
// log.error("电子围栏消息已丢失,已再次传入的信息是:【{}】", fenceUpdateRequest);
|
||||||
|
// channel.basicNack(deliveryTag, true, false);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
|
@ -1,91 +1,91 @@
|
||||||
package com.couplet.analyze.msg.consumer;
|
//package com.couplet.analyze.msg.consumer;
|
||||||
|
//
|
||||||
import com.alibaba.fastjson.JSON;
|
//import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
//import com.alibaba.fastjson.JSONObject;
|
||||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
//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.impl.realTimeData.RealTimeJudge;
|
//import com.couplet.analyze.msg.service.impl.realTimeData.RealTimeJudge;
|
||||||
import com.couplet.common.domain.request.RealTimeDataRequest;
|
//import com.couplet.common.domain.request.RealTimeDataRequest;
|
||||||
import com.rabbitmq.client.Channel;
|
//import com.rabbitmq.client.Channel;
|
||||||
import lombok.extern.log4j.Log4j2;
|
//import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.amqp.core.Message;
|
//import org.springframework.amqp.core.Message;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
//import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.util.concurrent.TimeUnit;
|
//import java.util.concurrent.TimeUnit;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* @Author: LiJiaYao
|
// * @Author: LiJiaYao
|
||||||
* @Date: 2024/4/4
|
// * @Date: 2024/4/4
|
||||||
* @Description:
|
// * @Description:
|
||||||
*/
|
// */
|
||||||
@Log4j2
|
//@Log4j2
|
||||||
@Component
|
//@Component
|
||||||
@RabbitListener(queues = "finByVinQueueName")
|
//@RabbitListener(queues = "finByVinQueueName")
|
||||||
public class MsgConsumer {
|
//public class MsgConsumer {
|
||||||
@Autowired
|
// @Autowired
|
||||||
private StringRedisTemplate redisTemplate;
|
// private StringRedisTemplate redisTemplate;
|
||||||
@Autowired
|
// @Autowired
|
||||||
private IncidentMapper incidentMapper;
|
// private IncidentMapper incidentMapper;
|
||||||
|
//
|
||||||
@RabbitHandler
|
// @RabbitHandler
|
||||||
public void realTimeDataConsumer(RealTimeDataRequest realTimeDataRequest, Channel channel, Message message) throws IOException {
|
// public void realTimeDataConsumer(RealTimeDataRequest realTimeDataRequest, Channel channel, Message message) throws IOException {
|
||||||
|
//
|
||||||
log.info("消息进入队列,传入的数据是:[{}]", realTimeDataRequest);
|
// log.info("消息进入队列,传入的数据是:[{}]", realTimeDataRequest);
|
||||||
|
//
|
||||||
String messageId = message.getMessageProperties().getMessageId();
|
// String messageId = message.getMessageProperties().getMessageId();
|
||||||
long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
// long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||||
if (!redisTemplate.hasKey("消息不丢失:" + messageId)) {
|
// if (!redisTemplate.hasKey("消息不丢失:" + messageId)) {
|
||||||
redisTemplate.opsForValue().set("消息不丢失:" + messageId, "" + deliveryTag, 1, TimeUnit.MINUTES);
|
// redisTemplate.opsForValue().set("消息不丢失:" + messageId, "" + deliveryTag, 1, TimeUnit.MINUTES);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Long add = redisTemplate.opsForSet().add("消息不重复:" + messageId, messageId);
|
// Long add = redisTemplate.opsForSet().add("消息不重复:" + messageId, messageId);
|
||||||
redisTemplate.expire("消息不重复:" + messageId, 5, TimeUnit.MINUTES);
|
// redisTemplate.expire("消息不重复:" + messageId, 5, TimeUnit.MINUTES);
|
||||||
try {
|
// try {
|
||||||
if (0 < add) {
|
// if (0 < add) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(String.valueOf(realTimeDataRequest));
|
// JSONObject jsonObject = JSONObject.parseObject(String.valueOf(realTimeDataRequest));
|
||||||
Long userId = jsonObject.getLong("userId");
|
// Long userId = jsonObject.getLong("userId");
|
||||||
String vin = jsonObject.getString("vin");
|
// String vin = jsonObject.getString("vin");
|
||||||
RealTimeDataRequest request = new RealTimeDataRequest();
|
// RealTimeDataRequest request = new RealTimeDataRequest();
|
||||||
request.setVin(vin);
|
// request.setVin(vin);
|
||||||
request.setUserId(userId);
|
// request.setUserId(userId);
|
||||||
RealTimeJudge.addRealTime(request);
|
// RealTimeJudge.addRealTime(request);
|
||||||
//判断车辆是否有实时数据,如果没有则删除数据
|
// //判断车辆是否有实时数据,如果没有则删除数据
|
||||||
if (RealTimeJudge.isJudge(realTimeDataRequest.getVin())){
|
// if (RealTimeJudge.isJudge(realTimeDataRequest.getVin())){
|
||||||
log.info("开始实时数据传输:[{}]",realTimeDataRequest.getVin());
|
// log.info("开始实时数据传输:[{}]",realTimeDataRequest.getVin());
|
||||||
}
|
// }
|
||||||
CoupletMsgData incident = incidentMapper.queryByIncident(realTimeDataRequest.getVin());
|
// CoupletMsgData incident = incidentMapper.queryByIncident(realTimeDataRequest.getVin());
|
||||||
if (incident == null){
|
// if (incident == null){
|
||||||
log.error("没有数据......");
|
// log.error("没有数据......");
|
||||||
}
|
// }
|
||||||
redisTemplate.opsForList().rightPush("coupletMsgData", JSON.toJSONString(incident));
|
// redisTemplate.opsForList().rightPush("coupletMsgData", JSON.toJSONString(incident));
|
||||||
|
//
|
||||||
channel.basicAck(deliveryTag, false);
|
// channel.basicAck(deliveryTag, false);
|
||||||
} else {
|
// } else {
|
||||||
log.error("消息不能重复消费:[{}]", realTimeDataRequest);
|
// log.error("消息不能重复消费:[{}]", realTimeDataRequest);
|
||||||
channel.basicReject(deliveryTag, false);
|
// channel.basicReject(deliveryTag, false);
|
||||||
}
|
// }
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
|
//
|
||||||
log.error("消息未进入队列,传入的信息是:【{}】", realTimeDataRequest);
|
// log.error("消息未进入队列,传入的信息是:【{}】", realTimeDataRequest);
|
||||||
String s = redisTemplate.opsForValue().get("消息不丢失:" + messageId);
|
// String s = redisTemplate.opsForValue().get("消息不丢失:" + messageId);
|
||||||
|
//
|
||||||
Long o = Long.valueOf(s);
|
// Long o = Long.valueOf(s);
|
||||||
if (deliveryTag == o + 2) {
|
// if (deliveryTag == o + 2) {
|
||||||
log.error("消息已丢失,无法传入的信息是:【{}】", realTimeDataRequest);
|
// log.error("消息已丢失,无法传入的信息是:【{}】", realTimeDataRequest);
|
||||||
channel.basicNack(deliveryTag, false, false);
|
// channel.basicNack(deliveryTag, false, false);
|
||||||
} else {
|
// } else {
|
||||||
log.error("消息已丢失,已再次传入的信息是:【{}】", realTimeDataRequest);
|
// log.error("消息已丢失,已再次传入的信息是:【{}】", realTimeDataRequest);
|
||||||
channel.basicNack(deliveryTag, true, false);
|
// channel.basicNack(deliveryTag, true, false);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
//package com.couplet.analyze.msg.consumer;
|
||||||
|
//
|
||||||
|
//import com.couplet.common.core.text.Convert;
|
||||||
|
//import com.couplet.common.redis.service.RedisService;
|
||||||
|
//import com.rabbitmq.client.Channel;
|
||||||
|
//import lombok.extern.log4j.Log4j2;
|
||||||
|
//import org.springframework.amqp.core.Message;
|
||||||
|
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
|
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
//import org.springframework.data.redis.core.BoundSetOperations;
|
||||||
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
|
//import java.io.IOException;
|
||||||
|
//import java.util.HashSet;
|
||||||
|
//import java.util.List;
|
||||||
|
//import java.util.concurrent.TimeUnit;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * @Author: LiJiaYao
|
||||||
|
// * @Date: 2024/4/4
|
||||||
|
// * @Description:
|
||||||
|
// */
|
||||||
|
//@Log4j2
|
||||||
|
//@Component
|
||||||
|
//@RabbitListener(queues = "vehicleQueue")
|
||||||
|
//public class VehicleConsumer {
|
||||||
|
// @Autowired
|
||||||
|
// private RedisService redisService;
|
||||||
|
// @RabbitHandler
|
||||||
|
// public void vehicleConsumer(String vehicleAndLogo, Channel channel, Message message) throws IOException {
|
||||||
|
// log.info("车辆消息进入队列,传入的数据是:[{}]", vehicleAndLogo);
|
||||||
|
// String messageId = message.getMessageProperties().getMessageId();
|
||||||
|
// long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||||
|
// if (!redisService.hasKey("车辆消息不丢失:" + messageId)) {
|
||||||
|
// redisService.setCacheObject("车辆消息不丢失:" + messageId, "" + deliveryTag);
|
||||||
|
// }
|
||||||
|
// HashSet<String> objects = new HashSet<>();
|
||||||
|
// objects.add(messageId);
|
||||||
|
// BoundSetOperations<String, String> set = redisService.setCacheSet("车辆信息消息不重复:" + messageId, objects);
|
||||||
|
// redisService.expire("车辆信息消息不重复:" + messageId, 5, TimeUnit.MINUTES);
|
||||||
|
// try {
|
||||||
|
// if (set != null) {
|
||||||
|
//// String key = Convert.toStr(id);
|
||||||
|
//
|
||||||
|
// String key = "id";
|
||||||
|
// redisService.setCacheObject(key, vehicleAndLogo);
|
||||||
|
// redisService.expire(key, 10, TimeUnit.MINUTES);
|
||||||
|
// //判断车辆是否有实时数据,如果没有则删除数据
|
||||||
|
// channel.basicAck(deliveryTag, false);
|
||||||
|
// } else {
|
||||||
|
// log.error("车辆消息不能重复消费:[{}]", vehicleAndLogo);
|
||||||
|
// channel.basicReject(deliveryTag, false);
|
||||||
|
// }
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// log.error("车辆消息未进入队列,传入的信息是:【{}】", vehicleAndLogo);
|
||||||
|
// String s = redisService.getCacheObject("车辆消息不丢失:" + messageId);
|
||||||
|
// Long o = Long.valueOf(s);
|
||||||
|
// if (deliveryTag == o + 2) {
|
||||||
|
// log.error("车辆消息已丢失,无法传入的信息是:【{}】", vehicleAndLogo);
|
||||||
|
// channel.basicNack(deliveryTag, false, false);
|
||||||
|
// } else {
|
||||||
|
// log.error("车辆消息已丢失,已再次传入的信息是:【{}】", vehicleAndLogo);
|
||||||
|
// channel.basicNack(deliveryTag, true, false);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -2,6 +2,7 @@ package com.couplet.analyze.msg.model;
|
||||||
|
|
||||||
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.exception.vehicle.VehicleException;
|
||||||
import com.couplet.common.core.utils.SpringUtils;
|
import com.couplet.common.core.utils.SpringUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.kafka.clients.consumer.ConsumerConfig;
|
import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||||
|
@ -19,6 +20,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
import static com.couplet.analyze.msg.utils.MsgUtils.hexToString;
|
import static com.couplet.analyze.msg.utils.MsgUtils.hexToString;
|
||||||
import static com.couplet.analyze.msg.utils.MsgUtils.sendMsg;
|
import static com.couplet.analyze.msg.utils.MsgUtils.sendMsg;
|
||||||
|
import static java.lang.Thread.sleep;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,6 +76,12 @@ public class ModelsKafkaMessage {
|
||||||
IncidentService incidentService = SpringUtils.getBean(string);
|
IncidentService incidentService = SpringUtils.getBean(string);
|
||||||
incidentService.incident(msgData);
|
incidentService.incident(msgData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
sleep(100);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new VehicleException("睡眠失败"+e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,16 +6,17 @@ import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||||
import com.couplet.analyze.msg.service.IncidentService;
|
import com.couplet.analyze.msg.service.IncidentService;
|
||||||
import com.couplet.analyze.msg.utils.MsgUtils;
|
import com.couplet.analyze.msg.utils.MsgUtils;
|
||||||
import com.couplet.common.domain.CoupletTroubleCode;
|
import com.couplet.common.domain.CoupletTroubleCode;
|
||||||
|
import com.couplet.common.redis.service.RedisService;
|
||||||
import com.couplet.remote.RemoteTroubleService;
|
import com.couplet.remote.RemoteTroubleService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
||||||
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
|
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
|
||||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ public class BreakdownServiceImpl extends KeyExpirationEventMessageListener impl
|
||||||
* 设置redis存储
|
* 设置redis存储
|
||||||
*/
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
private StringRedisTemplate redisTemplate;
|
private RedisService redisService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RemoteTroubleService remoteTroubleService;
|
private RemoteTroubleService remoteTroubleService;
|
||||||
|
|
||||||
|
@ -73,19 +74,16 @@ public class BreakdownServiceImpl extends KeyExpirationEventMessageListener impl
|
||||||
//获取过期的key
|
//获取过期的key
|
||||||
String key = "breakdown";
|
String key = "breakdown";
|
||||||
log.debug("失效+key is:"+ key);
|
log.debug("失效+key is:"+ key);
|
||||||
String value = JSON.toJSONString(coupletMsgData);
|
redisService.setCacheSet(key, coupletMsgData);
|
||||||
redisTemplate.opsForSet().add(key, value);
|
|
||||||
long expireTime = 30;
|
long expireTime = 30;
|
||||||
redisTemplate.expire(key, expireTime, TimeUnit.MINUTES);
|
redisService.expire(key, expireTime, TimeUnit.MINUTES);
|
||||||
long timeMillis = System.currentTimeMillis();
|
|
||||||
scheduledRedis();
|
scheduledRedis();
|
||||||
|
long timeMillis = System.currentTimeMillis();
|
||||||
log.info("故障事件结束时间:"+timeMillis);
|
log.info("故障事件结束时间:"+timeMillis);
|
||||||
log.info("故障事件检测结束.....");
|
log.info("故障事件检测结束.....");
|
||||||
log.info("故障事件结束.....");
|
|
||||||
}
|
}
|
||||||
long timeMillis = System.currentTimeMillis();
|
long timeMillis = System.currentTimeMillis();
|
||||||
log.info("故障事件结束时间:"+timeMillis);
|
log.info("故障事件结束时间:"+timeMillis);
|
||||||
log.info("故障事件检测结束.....");
|
|
||||||
log.info("故障事件结束.....");
|
log.info("故障事件结束.....");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,110 +96,108 @@ public class BreakdownServiceImpl extends KeyExpirationEventMessageListener impl
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scheduledRedis() {
|
public void scheduledRedis() {
|
||||||
|
|
||||||
// Get all members of the set
|
// Get all members of the set
|
||||||
Set<String> members = redisTemplate.opsForSet().members("breakdown");
|
String key = "breakdown";
|
||||||
if (members.size()!=0){
|
Set<CoupletMsgData> members = redisService.getCacheSet(key);
|
||||||
for (String member : members){
|
if (members.size()>0){
|
||||||
CoupletMsgData code = JSON.parseObject(member, CoupletMsgData.class);
|
for (CoupletMsgData member : members) {
|
||||||
Set<String> breakdownIds = redisTemplate.opsForSet().members(code.getVin());
|
Set<String> breakdownIds = redisService.getCacheSet(member.getVin()+":"+key);
|
||||||
if (breakdownIds.size()==0){
|
if (breakdownIds.size()==0){
|
||||||
CoupletTroubleCode troubleCode = new CoupletTroubleCode();
|
CoupletTroubleCode troubleCode = new CoupletTroubleCode();
|
||||||
troubleCode.setTroubleStartTime(new Date());
|
troubleCode.setTroubleStartTime(new Date());
|
||||||
troubleCode.setTroubleVin(code.getVin());
|
troubleCode.setTroubleVin(member.getVin());
|
||||||
// 随机生成故障码
|
// 随机生成故障码
|
||||||
String faultCode = MsgUtils.generateGTA();
|
String faultCode = MsgUtils.generateGTA();
|
||||||
troubleCode.setTroubleCode(faultCode);
|
troubleCode.setTroubleCode(faultCode);
|
||||||
|
|
||||||
// 检查车辆状态,若为0,则设置故障位置为"190"
|
// 检查车辆状态,若为0,则设置故障位置为"190"
|
||||||
if(code.getVehicleStatus() == 0) {
|
if(member.getVehicleStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("190");
|
troubleCode.setTroublePosition("190");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查充电状态,若为0,则设置故障位置为"191"
|
// 检查充电状态,若为0,则设置故障位置为"191"
|
||||||
if (code.getChargingStatus() == 0) {
|
if (member.getChargingStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("191");
|
troubleCode.setTroublePosition("191");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查运行状态,若为0,则设置故障位置为"192"
|
// 检查运行状态,若为0,则设置故障位置为"192"
|
||||||
if (code.getOperatingStatus() == 0) {
|
if (member.getOperatingStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("192");
|
troubleCode.setTroublePosition("192");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查电池荷电状态(SOC), 若为0,则设置故障位置为"193"
|
// 检查电池荷电状态(SOC), 若为0,则设置故障位置为"193"
|
||||||
if (code.getSocStatus() == 0) {
|
if (member.getSocStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("193");
|
troubleCode.setTroublePosition("193");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查充电能源存储状态,若为0,则设置故障位置为"194"
|
// 检查充电能源存储状态,若为0,则设置故障位置为"194"
|
||||||
if (code.getChargingEnergyStorageStatus() == 0) {
|
if (member.getChargingEnergyStorageStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("194");
|
troubleCode.setTroublePosition("194");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查驱动电机状态,若为0,则设置故障位置为"195"
|
// 检查驱动电机状态,若为0,则设置故障位置为"195"
|
||||||
if (code.getDriveMotorStatus() == 0) {
|
if (member.getDriveMotorStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("195");
|
troubleCode.setTroublePosition("195");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查定位状态,若为0,则设置故障位置为"196"
|
// 检查定位状态,若为0,则设置故障位置为"196"
|
||||||
if (code.getPositionStatus() == 0) {
|
if (member.getPositionStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("196");
|
troubleCode.setTroublePosition("196");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查电子驻车系统(EAS)状态,若为0,则设置故障位置为"197"
|
// 检查电子驻车系统(EAS)状态,若为0,则设置故障位置为"197"
|
||||||
if (code.getEasStatus() == 0) {
|
if (member.getEasStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("197");
|
troubleCode.setTroublePosition("197");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查PTC(正温度系数热敏电阻)状态,若为0,则设置故障位置为"198"
|
// 检查PTC(正温度系数热敏电阻)状态,若为0,则设置故障位置为"198"
|
||||||
if (code.getPtcStatus() == 0) {
|
if (member.getPtcStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("198");
|
troubleCode.setTroublePosition("198");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查电动助力转向系统(EPS)状态,若为0,则设置故障位置为"199"
|
// 检查电动助力转向系统(EPS)状态,若为0,则设置故障位置为"199"
|
||||||
if (code.getEpsStatus() == 0) {
|
if (member.getEpsStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("199");
|
troubleCode.setTroublePosition("199");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查防抱死制动系统(ABS)状态,若为0,则设置故障位置为"200"
|
// 检查防抱死制动系统(ABS)状态,若为0,则设置故障位置为"200"
|
||||||
if (code.getAbsStatus() == 0) {
|
if (member.getAbsStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("200");
|
troubleCode.setTroublePosition("200");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查主控制器(MCU)状态,若为0,则设置故障位置为"201"
|
// 检查主控制器(MCU)状态,若为0,则设置故障位置为"201"
|
||||||
if (code.getMcuStatus() == 0) {
|
if (member.getMcuStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("201");
|
troubleCode.setTroublePosition("201");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查加热状态,若为0,则设置故障位置为"202"
|
// 检查加热状态,若为0,则设置故障位置为"202"
|
||||||
if (code.getHeatingStatus() == 0) {
|
if (member.getHeatingStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("202");
|
troubleCode.setTroublePosition("202");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查电池状态,若为0,则设置故障位置为"203"
|
// 检查电池状态,若为0,则设置故障位置为"203"
|
||||||
if (code.getBatteryStatus() == 0) {
|
if (member.getBatteryStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("203");
|
troubleCode.setTroublePosition("203");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查电池绝缘状态,若为0,则设置故障位置为"204"
|
// 检查电池绝缘状态,若为0,则设置故障位置为"204"
|
||||||
if (code.getBatteryInsulationStatus() == 0) {
|
if (member.getBatteryInsulationStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("204");
|
troubleCode.setTroublePosition("204");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查直流-直流转换器(DC/DC)状态,若为0,则设置故障位置为"205"
|
// 检查直流-直流转换器(DC/DC)状态,若为0,则设置故障位置为"205"
|
||||||
if (code.getDcdcStatus() == 0) {
|
if (member.getDcdcStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("205");
|
troubleCode.setTroublePosition("205");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查充电机(CHG)状态,若为0,则设置故障位置为"206"
|
// 检查充电机(CHG)状态,若为0,则设置故障位置为"206"
|
||||||
if (code.getChgStatus() == 0) {
|
if (member.getChgStatus() == 0) {
|
||||||
troubleCode.setTroublePosition("206");
|
troubleCode.setTroublePosition("206");
|
||||||
}
|
}
|
||||||
remoteTroubleService.newFaultData(troubleCode);
|
remoteTroubleService.newFaultData(troubleCode);
|
||||||
redisTemplate.opsForSet().add(code.getVin(), code.getVin()+":"+code);
|
redisService.setCacheSet(member.getVin()+":"+key, member.getVin()+":"+member);
|
||||||
long expireTime = 30;
|
long expireTime = 30;
|
||||||
redisTemplate.expire(code.getVin(), expireTime, TimeUnit.MINUTES);
|
redisService.expire(member.getVin()+":"+key, expireTime, TimeUnit.MINUTES);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,17 @@ package com.couplet.analyze.msg.service.impl;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
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.domain.Fence;
|
import com.couplet.common.domain.Fence;
|
||||||
|
import com.couplet.common.domain.request.FenceAndLogeRequest;
|
||||||
|
import com.couplet.common.redis.service.RedisService;
|
||||||
|
import com.couplet.remote.RemoteFenceAndLogService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: LiJiaYao
|
* @Author: LiJiaYao
|
||||||
|
@ -23,7 +25,9 @@ import java.util.Map;
|
||||||
public class ElectronicFenceServiceImpl implements IncidentService {
|
public class ElectronicFenceServiceImpl implements IncidentService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private StringRedisTemplate redisTemplate;
|
private RedisService redisService;
|
||||||
|
@Autowired
|
||||||
|
private RemoteFenceAndLogService remoteFenceAndLogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 电子围栏事件
|
* 电子围栏事件
|
||||||
|
@ -34,16 +38,17 @@ public class ElectronicFenceServiceImpl implements IncidentService {
|
||||||
public void incident(CoupletMsgData coupletMsgData) {
|
public void incident(CoupletMsgData coupletMsgData) {
|
||||||
|
|
||||||
log.info("电子围栏事件开始.......");
|
log.info("电子围栏事件开始.......");
|
||||||
|
|
||||||
String fenceKey="fence";
|
String fenceKey="fence";
|
||||||
|
|
||||||
ArrayList<Fence> fences = new ArrayList<>();
|
ArrayList<Fence> fences = new ArrayList<>();
|
||||||
if (redisTemplate.hasKey(fenceKey)) {
|
if (redisService.hasKey(fenceKey)) {
|
||||||
log.info("电子围栏事件redis存在.......");
|
log.info("电子围栏事件redis存在.......");
|
||||||
List<String> fence = redisTemplate.opsForList().range(fenceKey, 0, -1);
|
// redisService.getCacheObject();
|
||||||
for (String s : fence) {
|
// for (String s : fence) {
|
||||||
Fence parseObject = JSON.parseObject(s, Fence.class);
|
// Fence parseObject = JSON.parseObject(s, Fence.class);
|
||||||
fences.add(parseObject);
|
// fences.add(parseObject);
|
||||||
}
|
// }
|
||||||
// jingdu;
|
// jingdu;
|
||||||
// longitude;
|
// longitude;
|
||||||
// weidu;
|
// weidu;
|
||||||
|
@ -59,10 +64,12 @@ public class ElectronicFenceServiceImpl implements IncidentService {
|
||||||
|
|
||||||
String[] strings = s.split(",");
|
String[] strings = s.split(",");
|
||||||
if (strings.length == 2){
|
if (strings.length == 2){
|
||||||
|
// 经度
|
||||||
Double trim = Double.valueOf(strings[0].trim());
|
Double trim = Double.valueOf(strings[0].trim());
|
||||||
|
// 纬度
|
||||||
Double trim1 = Double.valueOf(strings[1].trim());
|
Double trim1 = Double.valueOf(strings[1].trim());
|
||||||
boolean a = trim<= Double.valueOf(coupletMsgData.getLongitude());
|
boolean a = trim <= Double.valueOf(coupletMsgData.getLongitude());
|
||||||
boolean b = trim1 < Double.valueOf(coupletMsgData.getLatitude());
|
boolean b = trim1 <= Double.valueOf(coupletMsgData.getLatitude());
|
||||||
if (a && b){
|
if (a && b){
|
||||||
log.info("电子围栏报警啦!!!!您的车驶出范围啦!!!");
|
log.info("电子围栏报警啦!!!!您的车驶出范围啦!!!");
|
||||||
}else {
|
}else {
|
||||||
|
@ -73,12 +80,9 @@ public class ElectronicFenceServiceImpl implements IncidentService {
|
||||||
}else {
|
}else {
|
||||||
throw new RuntimeException("电子围栏经纬度格式错误"+strings);
|
throw new RuntimeException("电子围栏经纬度格式错误"+strings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
log.info("更改的电子围栏内容是:"+fence);
|
// log.info("更改的电子围栏内容是:"+fence);
|
||||||
log.info("电子围栏事件结束.......");
|
log.info("电子围栏事件结束.......");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,4 +97,25 @@ public class ElectronicFenceServiceImpl implements IncidentService {
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "electronic-fence";
|
return "electronic-fence";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void ifFence() {
|
||||||
|
String key = "id";
|
||||||
|
/**
|
||||||
|
* redisService中的object类型获取到数据
|
||||||
|
*/
|
||||||
|
String cacheObject = redisService.getCacheObject(key);
|
||||||
|
String[] split = cacheObject.split("-");
|
||||||
|
Long id = Convert.toLong(split[0]);
|
||||||
|
Long[] longArray = Convert.toLongArray(split[1]);
|
||||||
|
// for (Long aLong : longArray) {
|
||||||
|
// aLong.wait(",");
|
||||||
|
// }
|
||||||
|
FenceAndLogeRequest fenceAndLogeRequest = new FenceAndLogeRequest();
|
||||||
|
fenceAndLogeRequest.setId(id);
|
||||||
|
fenceAndLogeRequest.setLogoIds(longArray);
|
||||||
|
remoteFenceAndLogService.queryByFenceAndLogoIds(fenceAndLogeRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.couplet.analyze.msg.service.impl.breakdown;
|
package com.couplet.analyze.msg.service.impl.breakdown;
|
||||||
|
|
||||||
|
import com.couplet.common.redis.service.RedisService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -12,7 +13,7 @@ import org.springframework.stereotype.Component;
|
||||||
@Component
|
@Component
|
||||||
public class BreakdownEvent {
|
public class BreakdownEvent {
|
||||||
@Autowired
|
@Autowired
|
||||||
private StringRedisTemplate redisTemplate;
|
private RedisService redisService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,73 +21,4 @@
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Nacos -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Nacos Config -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Sentinel -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- SpringBoot Actuator -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Swagger UI -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
|
||||||
<version>${swagger.fox.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Mysql Connector -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MuYu Common DataSource -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.couplet</groupId>
|
|
||||||
<artifactId>couplet-common-datasource</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MuYu Common DataScope -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.couplet</groupId>
|
|
||||||
<artifactId>couplet-common-datascope</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MuYu Common Log -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.couplet</groupId>
|
|
||||||
<artifactId>couplet-common-log</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MuYu Common Swagger -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.couplet</groupId>
|
|
||||||
<artifactId>couplet-common-swagger</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.kafka</groupId>
|
|
||||||
<artifactId>spring-kafka</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -87,17 +87,20 @@
|
||||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.couplet</groupId>
|
|
||||||
<artifactId>couplet-analyze-msg</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- RabbitMQ依赖-->
|
<!-- RabbitMQ依赖-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.minio</groupId>
|
||||||
|
<artifactId>minio</artifactId>
|
||||||
|
<version>7.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-modules-mq</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -5,7 +5,9 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
||||||
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: LiJiaYao
|
* @Author: LiJiaYao
|
||||||
|
@ -15,10 +17,10 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
@EnableCustomConfig
|
@EnableCustomConfig
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableMyFeignClients(basePackages = ("com.couplet"))
|
@EnableMyFeignClients(basePackages = ("com.couplet"))
|
||||||
@SpringBootApplication(scanBasePackages = {"com.couplet"})
|
@SpringBootApplication(scanBasePackages = {"com.couplet", "com.couplet.mq.remote"})
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
public class CoupletBusinessApplication {
|
public class CoupletBusinessApplication {
|
||||||
public static void main (String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(CoupletBusinessApplication.class, args);
|
SpringApplication.run(CoupletBusinessApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.couplet.business.server.controller;
|
||||||
|
|
||||||
|
import com.couplet.business.server.service.FenAndLogoService;
|
||||||
|
import com.couplet.business.server.service.VehicleAndLogoService;
|
||||||
|
import com.couplet.common.core.domain.Result;
|
||||||
|
import com.couplet.common.core.web.controller.BaseController;
|
||||||
|
import com.couplet.common.domain.Fence;
|
||||||
|
import com.couplet.common.domain.request.FenceAndLogeRequest;
|
||||||
|
import com.couplet.common.log.annotation.Log;
|
||||||
|
import com.couplet.common.log.enums.BusinessType;
|
||||||
|
import com.couplet.common.security.annotation.RequiresPermissions;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/4/7
|
||||||
|
* @Description: 车辆和标识中间信息
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Log4j2
|
||||||
|
@RequestMapping("/fenceAndLogo")
|
||||||
|
public class FenceAndLogoController extends BaseController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用车辆logo接口
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private FenAndLogoService fenAndLogoService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据车辆id查询绑定的标识
|
||||||
|
* @param aLong
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Log(title = "查找车辆绑定的电子围栏", businessType = BusinessType.OTHER)
|
||||||
|
@PostMapping("/queryByFenceAndLogoIds")
|
||||||
|
public Result<?> queryByFenceAndLogoIds(@RequestBody FenceAndLogeRequest request){
|
||||||
|
List<Fence> bindLogoById = fenAndLogoService.queryByFenceAndLogoIds(request);
|
||||||
|
return success(bindLogoById);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -51,11 +51,11 @@ public class FenceController extends BaseController {
|
||||||
@PostMapping("/fenceAdd")
|
@PostMapping("/fenceAdd")
|
||||||
@RequiresPermissions("couplet:fence:fenceAdd")
|
@RequiresPermissions("couplet:fence:fenceAdd")
|
||||||
@Log(title = "电子围栏新增",businessType = BusinessType.INSERT)
|
@Log(title = "电子围栏新增",businessType = BusinessType.INSERT)
|
||||||
public Result<?> fenceInsert(HttpServletRequest request, @RequestBody FenceRequest fenceRequest){
|
public Result<?> fenceInsert(@RequestBody FenceRequest fenceRequest){
|
||||||
// if (!fenceService.checkFenceKeyUnique(fenceRequest.getFenceName())) {
|
// if (!fenceService.checkFenceKeyUnique(fenceRequest.getFenceName())) {
|
||||||
// return error("新增参数'" + fenceRequest.getFenceName() + "'失败,参数键名已存在");
|
// return error("新增参数'" + fenceRequest.getFenceName() + "'失败,参数键名已存在");
|
||||||
// }
|
// }
|
||||||
fenceService.fenceInsert(request,fenceRequest);
|
fenceService.fenceInsert(fenceRequest);
|
||||||
return Result.success("新增成功");
|
return Result.success("新增成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.couplet.business.server.controller;
|
||||||
|
|
||||||
|
import com.couplet.business.server.service.VehicleAndLogoService;
|
||||||
|
import com.couplet.common.core.domain.Result;
|
||||||
|
import com.couplet.common.core.web.controller.BaseController;
|
||||||
|
import com.couplet.common.log.annotation.Log;
|
||||||
|
import com.couplet.common.log.enums.BusinessType;
|
||||||
|
import com.couplet.common.security.annotation.RequiresPermissions;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/4/7
|
||||||
|
* @Description: 车辆和标识中间信息
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Log4j2
|
||||||
|
@RequestMapping("/vehicleAndLogo")
|
||||||
|
public class VehicleAndLogoController extends BaseController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用车辆logo接口
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private VehicleAndLogoService vehicleAndLogoService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据车辆id查询绑定的标识
|
||||||
|
* @param vehicleId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Log(title = "查询车辆id绑定的标识", businessType = BusinessType.OTHER)
|
||||||
|
@PostMapping("/queryByLogoIds/{vehicleId}")
|
||||||
|
public Result<?> queryByLogoIds(@PathVariable("vehicleId") Long vehicleId){
|
||||||
|
List<Long> bindLogoById = vehicleAndLogoService.getBindLogoById(vehicleId);
|
||||||
|
return success(bindLogoById);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import com.couplet.common.domain.request.VehicleListParams;
|
||||||
import com.couplet.common.log.annotation.Log;
|
import com.couplet.common.log.annotation.Log;
|
||||||
import com.couplet.common.log.enums.BusinessType;
|
import com.couplet.common.log.enums.BusinessType;
|
||||||
import com.couplet.common.security.annotation.RequiresPermissions;
|
import com.couplet.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.couplet.common.security.utils.SecurityUtils;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -159,7 +160,7 @@ public class VehicleController extends BaseController {
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public Result<Integer> addVehicle(@RequestBody VehicleMiddle vehicleMiddle){
|
public Result<Integer> addVehicle(@RequestBody VehicleMiddle vehicleMiddle){
|
||||||
return Result.success(vehicleService.addVehicle(vehicleMiddle));
|
return Result.success(vehicleService.addVehicle(SecurityUtils.getUserId(),vehicleMiddle.getVehicleIds()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,13 +57,7 @@ public class VehicleDetectionController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/monitorinData/{vin}")
|
@PostMapping("/monitorinData/{vin}")
|
||||||
public void monitorinData(@PathVariable String vin){
|
public void monitorinData(@PathVariable String vin){
|
||||||
String exchangeName = "exchangeName"; // 交换机名称
|
vehicleDetectionService.monitorinData(vin);
|
||||||
String routingKey = "routingKey"; // 路由键
|
|
||||||
RealTimeDataRequest realTimeDataRequest = new RealTimeDataRequest();
|
|
||||||
Long userId = SecurityUtils.getUserId();
|
|
||||||
realTimeDataRequest.setUserId(userId);
|
|
||||||
realTimeDataRequest.setVin(vin);
|
|
||||||
rabbitTemplate.convertAndSend(exchangeName, routingKey, realTimeDataRequest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,12 @@ package com.couplet.business.server.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.couplet.common.domain.Fence;
|
import com.couplet.common.domain.Fence;
|
||||||
|
import com.couplet.common.domain.request.FenceAndLogeRequest;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: LiJiaYao
|
* @Author: LiJiaYao
|
||||||
* @Date: 2024/3/28
|
* @Date: 2024/3/28
|
||||||
|
@ -19,4 +22,10 @@ public interface FenAndLogoMapper extends BaseMapper<Fence> {
|
||||||
* @param logoIds
|
* @param logoIds
|
||||||
*/
|
*/
|
||||||
void addBach(@Param("fenceId") Integer fenceId, @Param("logoIds") String[] logoIds);
|
void addBach(@Param("fenceId") Integer fenceId, @Param("logoIds") String[] logoIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param aLong
|
||||||
|
*/
|
||||||
|
List<Fence> queryByFenceAndLogoIds(FenceAndLogeRequest aLong);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,12 @@ public interface VehicleMapper extends BaseMapper<Vehicle> {
|
||||||
|
|
||||||
Integer deleteVehicle(Long middleId);
|
Integer deleteVehicle(Long middleId);
|
||||||
|
|
||||||
Integer addVehicle(VehicleMiddle vehicleMiddle);
|
|
||||||
|
|
||||||
List<Vehicle> vehicleAll();
|
List<Vehicle> vehicleAll();
|
||||||
|
|
||||||
Integer onOrOutLineByVIN(@Param("vin") String vin, @Param("status") int status);
|
Integer onOrOutLineByVIN(@Param("vin") String vin, @Param("status") int status);
|
||||||
|
|
||||||
|
|
||||||
|
Integer addVehicle(@Param("userId") Long userId, @Param("vehicleIds") List<Long> vehicleIds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@ package com.couplet.business.server.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.couplet.common.domain.Fence;
|
import com.couplet.common.domain.Fence;
|
||||||
|
import com.couplet.common.domain.request.FenceAndLogeRequest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,4 +19,13 @@ public interface FenAndLogoService extends IService<Fence> {
|
||||||
* @param logoIds
|
* @param logoIds
|
||||||
*/
|
*/
|
||||||
void addBach(Integer fenceId, String[] logoIds);
|
void addBach(Integer fenceId, String[] logoIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据标识id和车辆id查询电子围栏
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Fence> queryByFenceAndLogoIds(FenceAndLogeRequest request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.couplet.common.domain.request.FenceConfig;
|
||||||
import com.couplet.common.domain.request.FenceRequest;
|
import com.couplet.common.domain.request.FenceRequest;
|
||||||
import com.couplet.common.domain.request.FenceUpdateRequest;
|
import com.couplet.common.domain.request.FenceUpdateRequest;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +26,7 @@ public interface FenceService extends IService<Fence> {
|
||||||
*
|
*
|
||||||
* @param fenceRequest
|
* @param fenceRequest
|
||||||
*/
|
*/
|
||||||
void fenceInsert(HttpServletRequest request, FenceRequest fenceRequest);
|
void fenceInsert(FenceRequest fenceRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除电子围栏
|
* 删除电子围栏
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.couplet.business.server.service;
|
package com.couplet.business.server.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.couplet.common.domain.Fence;
|
||||||
import com.couplet.common.domain.VehicleAndLogo;
|
import com.couplet.common.domain.VehicleAndLogo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -18,4 +19,6 @@ public interface VehicleAndLogoService extends IService<VehicleAndLogo> {
|
||||||
int deleteByVehicleId(Long vehicleId);
|
int deleteByVehicleId(Long vehicleId);
|
||||||
|
|
||||||
List<Long> getBindLogoById(Long vehicleId);
|
List<Long> getBindLogoById(Long vehicleId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,4 +9,5 @@ public interface VehicleDetectionService {
|
||||||
|
|
||||||
List<Vehicle> detectionList();
|
List<Vehicle> detectionList();
|
||||||
|
|
||||||
|
void monitorinData(String vin);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,11 @@ public interface VehicleService extends IService<Vehicle> {
|
||||||
|
|
||||||
Integer deleteVehicle(Long middleId);
|
Integer deleteVehicle(Long middleId);
|
||||||
|
|
||||||
Integer addVehicle(VehicleMiddle vehicleMiddle);
|
|
||||||
|
|
||||||
List<Vehicle> vehicleAll();
|
List<Vehicle> vehicleAll();
|
||||||
|
|
||||||
Integer onOrOutLineByVIN(String s, int i);
|
Integer onOrOutLineByVIN(String s, int i);
|
||||||
|
|
||||||
|
|
||||||
|
Integer addVehicle(Long userId, List<Long> vehicleIds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.couplet.business.server.mapper.FenAndLogoMapper;
|
import com.couplet.business.server.mapper.FenAndLogoMapper;
|
||||||
import com.couplet.business.server.service.FenAndLogoService;
|
import com.couplet.business.server.service.FenAndLogoService;
|
||||||
import com.couplet.common.domain.Fence;
|
import com.couplet.common.domain.Fence;
|
||||||
|
import com.couplet.common.domain.request.FenceAndLogeRequest;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: LiJiaYao
|
* @Author: LiJiaYao
|
||||||
* @Date: 2024/3/28
|
* @Date: 2024/3/28
|
||||||
|
@ -38,4 +41,10 @@ public class FenAndLogoServiceImpl extends ServiceImpl<FenAndLogoMapper, Fence>
|
||||||
fenAndLogoMapper.addBach(fenceId,logoIds);
|
fenAndLogoMapper.addBach(fenceId,logoIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Fence> queryByFenceAndLogoIds(FenceAndLogeRequest request) {
|
||||||
|
|
||||||
|
return fenAndLogoMapper.queryByFenceAndLogoIds(request);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,13 @@ import com.couplet.common.domain.Fence;
|
||||||
import com.couplet.common.domain.request.FenceConfig;
|
import com.couplet.common.domain.request.FenceConfig;
|
||||||
import com.couplet.common.domain.request.FenceRequest;
|
import com.couplet.common.domain.request.FenceRequest;
|
||||||
import com.couplet.common.domain.request.FenceUpdateRequest;
|
import com.couplet.common.domain.request.FenceUpdateRequest;
|
||||||
|
import com.couplet.common.redis.service.RedisService;
|
||||||
import com.couplet.common.security.utils.SecurityUtils;
|
import com.couplet.common.security.utils.SecurityUtils;
|
||||||
import com.couplet.mq.remote.RemoteFenceService;
|
import com.couplet.mq.remote.RemoteFenceService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -68,31 +70,36 @@ public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements
|
||||||
remoteFenceService.fenceQueue(fenceUpdateRequest);
|
remoteFenceService.fenceQueue(fenceUpdateRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fenceInsert(FenceRequest fenceRequest) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务实现:添加围栏
|
* 业务实现:添加围栏
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @param fenceRequest
|
* @param fenceRequest
|
||||||
*/
|
*/
|
||||||
@Override
|
// @Override
|
||||||
public void fenceInsert(HttpServletRequest request, FenceRequest fenceRequest) {
|
// public void fenceInsert(HttpServletRequest request, FenceRequest fenceRequest) {
|
||||||
String username = SecurityUtils.getUsername();
|
// String username = SecurityUtils.getUsername();
|
||||||
fenceRequest.setCrateName(username);
|
// fenceRequest.setCrateName(username);
|
||||||
//先添加围栏
|
// //先添加围栏
|
||||||
fenceMapper.insertFence(fenceRequest);
|
// fenceMapper.insertFence(fenceRequest);
|
||||||
String[] logoIds = fenceRequest.getLogoIds();
|
// String[] logoIds = fenceRequest.getLogoIds();
|
||||||
String[] parts = new String[0];
|
// String[] parts = new String[0];
|
||||||
for (String logoId : logoIds) {
|
// for (String logoId : logoIds) {
|
||||||
//把前台传入的字符串分割成数组
|
// //把前台传入的字符串分割成数组
|
||||||
parts = logoId.split(",");
|
// parts = logoId.split(",");
|
||||||
//再添加围栏和标识中间表
|
// //再添加围栏和标识中间表
|
||||||
fenAndLogoService.addBach(fenceRequest.getFenceId(), parts);
|
// 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) {
|
||||||
|
|
|
@ -68,8 +68,6 @@ public class VehicleAndLogoServiceImpl extends ServiceImpl<VehicleAndLogoMapper,
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public List<Long> getBindLogoById(Long vehicleId) {
|
public List<Long> getBindLogoById(Long vehicleId) {
|
||||||
|
|
||||||
|
|
||||||
return mapper.getBindLogoById(vehicleId);
|
return mapper.getBindLogoById(vehicleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,20 @@
|
||||||
package com.couplet.business.server.service.impl;
|
package com.couplet.business.server.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.couplet.business.server.mapper.VehicleDetectionMapper;
|
import com.couplet.business.server.mapper.VehicleDetectionMapper;
|
||||||
import com.couplet.business.server.service.VehicleDetectionService;
|
import com.couplet.business.server.service.VehicleDetectionService;
|
||||||
import com.couplet.business.server.service.VehicleManageService;
|
import com.couplet.business.server.service.VehicleManageService;
|
||||||
import com.couplet.common.core.domain.Result;
|
import com.couplet.common.core.domain.Result;
|
||||||
import com.couplet.common.domain.Vehicle;
|
import com.couplet.common.domain.Vehicle;
|
||||||
|
import com.couplet.common.domain.request.RealTimeDataRequest;
|
||||||
|
import com.couplet.common.redis.service.RedisService;
|
||||||
|
import com.couplet.common.security.utils.SecurityUtils;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.mysql.cj.xdevapi.JsonString;
|
||||||
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 springfox.documentation.spring.web.json.Json;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -21,10 +29,22 @@ public class VehicleDetectionServiceImpl implements VehicleDetectionService{
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private VehicleDetectionMapper vehicleDetectionMapper;
|
private VehicleDetectionMapper vehicleDetectionMapper;
|
||||||
|
@Autowired
|
||||||
|
private RedisService redisService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Vehicle> detectionList() {
|
public List<Vehicle> detectionList() {
|
||||||
return vehicleDetectionMapper.detectionList();
|
return vehicleDetectionMapper.detectionList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void monitorinData(String vin) {
|
||||||
|
RealTimeDataRequest realTimeDataRequest = new RealTimeDataRequest();
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
realTimeDataRequest.setVin(vin);
|
||||||
|
realTimeDataRequest.setUserId(userId);
|
||||||
|
redisService.setVinAndUserId(realTimeDataRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,10 @@ import com.couplet.common.domain.VehicleType;
|
||||||
import com.couplet.common.domain.request.VehicleEditParams;
|
import com.couplet.common.domain.request.VehicleEditParams;
|
||||||
import com.couplet.common.domain.request.VehicleInsertParams;
|
import com.couplet.common.domain.request.VehicleInsertParams;
|
||||||
import com.couplet.common.domain.request.VehicleListParams;
|
import com.couplet.common.domain.request.VehicleListParams;
|
||||||
|
import com.couplet.common.redis.service.RedisService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -35,6 +37,12 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
//车辆mapper
|
//车辆mapper
|
||||||
@Autowired
|
@Autowired
|
||||||
private VehicleMapper vehicleMapper;
|
private VehicleMapper vehicleMapper;
|
||||||
|
@Autowired
|
||||||
|
private RedisService redis;
|
||||||
|
|
||||||
|
//远程发送mq
|
||||||
|
// @Autowired
|
||||||
|
// private RemoteFenceService remoteFenceService;
|
||||||
|
|
||||||
//车辆类型服务
|
//车辆类型服务
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -128,7 +136,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
String result = "";
|
String result = "";
|
||||||
|
|
||||||
if ((editParams.getLogoIds() == null || editParams.getLogoIds().isEmpty())) {
|
if ((editParams.getLogoIds() == null || editParams.getLogoIds().isEmpty())) {
|
||||||
result = "未选择电子围栏";
|
result = "未选择标识";
|
||||||
Result.error(result);
|
Result.error(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +174,19 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
//删除绑定之后,再添加新的绑定
|
//删除绑定之后,再添加新的绑定
|
||||||
vehicleAndLogoService.vehicleBindLogo(editParams.getVehicleId(), editParams.getLogoIds());
|
vehicleAndLogoService.vehicleBindLogo(editParams.getVehicleId(), editParams.getLogoIds());
|
||||||
|
|
||||||
|
|
||||||
|
// //mq
|
||||||
|
// List<Long> logoList = getBindLogoById(editParams.getVehicleId());
|
||||||
|
// if (0 != logoList.size()) {
|
||||||
|
// String ids = "";
|
||||||
|
// for (Long l : logoList) {
|
||||||
|
// ids = "," + l;
|
||||||
|
// }
|
||||||
|
// ids = ids.substring(1);
|
||||||
|
// remoteFenceService.vehicleQueue(editParams.getVehicleId() + "-" + ids);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
result = "编辑成功!";
|
result = "编辑成功!";
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -183,7 +204,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
String result = "";
|
String result = "";
|
||||||
|
|
||||||
if ((insertParams.getLogoIds() == null || insertParams.getLogoIds().isEmpty())) {
|
if ((insertParams.getLogoIds() == null || insertParams.getLogoIds().isEmpty())) {
|
||||||
result = "未选择电子围栏";
|
result = "未选择标识";
|
||||||
Result.error(result);
|
Result.error(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,6 +254,17 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
//执行添加电子围栏
|
//执行添加电子围栏
|
||||||
int i = vehicleAndLogoService.vehicleBindLogo(vehicle.getVehicleId(), insertParams.getLogoIds());
|
int i = vehicleAndLogoService.vehicleBindLogo(vehicle.getVehicleId(), insertParams.getLogoIds());
|
||||||
|
|
||||||
|
//
|
||||||
|
// List<Long> logoList = getBindLogoById(vehicle.getVehicleId());
|
||||||
|
// if (0 != logoList.size()) {
|
||||||
|
// String ids = "";
|
||||||
|
// for (Long l : logoList) {
|
||||||
|
// ids = "," + l;
|
||||||
|
// }
|
||||||
|
// ids = ids.substring(1);
|
||||||
|
// remoteFenceService.vehicleQueue(vehicle.getVehicleId() + "-" + ids);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
result = "新增成功!";
|
result = "新增成功!";
|
||||||
|
|
||||||
|
@ -256,7 +288,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @param userId:
|
* @param userId:
|
||||||
* @return List<Vehicle>
|
* @return List<Vehicle>
|
||||||
* @author 付凡芮
|
* @author 付凡芮
|
||||||
* @description 根据登入人id查询管理车辆
|
* @description 根据登入人id查询管理车辆
|
||||||
*
|
*
|
||||||
|
@ -271,11 +303,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
return vehicleMapper.deleteVehicle(middleId);
|
return vehicleMapper.deleteVehicle(middleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer addVehicle(VehicleMiddle vehicleMiddle) {
|
|
||||||
|
|
||||||
return vehicleMapper.addVehicle(vehicleMiddle);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Vehicle> vehicleAll() {
|
public List<Vehicle> vehicleAll() {
|
||||||
|
@ -290,6 +318,11 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
return vehicleMapper.onOrOutLineByVIN(vin, status);
|
return vehicleMapper.onOrOutLineByVIN(vin, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer addVehicle(Long userId, List<Long> vehicleIds) {
|
||||||
|
return vehicleMapper.addVehicle(userId,vehicleIds);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Vehicle> findByVIN(String vin) {
|
public List<Vehicle> findByVIN(String vin) {
|
||||||
|
|
||||||
|
@ -304,4 +337,47 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
||||||
return this.list(queryWrapper);
|
return this.list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Scheduled(cron = "0/1 * * * * *")
|
||||||
|
public void aa() {
|
||||||
|
System.out.println("********************************************************");
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断车辆是否下线
|
||||||
|
@Scheduled(cron = "0/1 * * * * *")
|
||||||
|
public void downLine() {
|
||||||
|
log.info("定时器启动");
|
||||||
|
//先查询车辆列表
|
||||||
|
List<Vehicle> list = this.list(new VehicleListParams(null, null, null, null));
|
||||||
|
|
||||||
|
|
||||||
|
list.forEach(vehicle -> {
|
||||||
|
try {
|
||||||
|
//只针对已经上线的车辆
|
||||||
|
if (redis.hasKey(vehicle.getVin())) {
|
||||||
|
|
||||||
|
//如果vin的缓存 时间还剩一秒,则判断为已经下线
|
||||||
|
if (redis.getExpire(vehicle.getVin()) <= 3) {
|
||||||
|
log.info(vehicle.getVin() + "的车辆已经下线");
|
||||||
|
|
||||||
|
//执行修改下线状态的方法
|
||||||
|
// Integer i = this.onOrOutLineByVIN(vehicle.getVin() + "," + 0);
|
||||||
|
Integer i = this.onOrOutLineByVIN(vehicle.getVin() , 0);
|
||||||
|
|
||||||
|
if (0 == i) {
|
||||||
|
log.error("下线状态修改失败");
|
||||||
|
} else {
|
||||||
|
log.info("下线状态修改成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
package com.couplet.business.server.time;
|
|
||||||
|
|
||||||
import com.couplet.business.server.service.VehicleService;
|
|
||||||
import com.couplet.common.domain.Vehicle;
|
|
||||||
import com.couplet.common.domain.request.VehicleListParams;
|
|
||||||
import com.couplet.common.redis.service.RedisService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ProjectName: five-groups-couplet
|
|
||||||
* @Author: LiuYunHu
|
|
||||||
* @CreateTime: 2024/4/4
|
|
||||||
* @Description: 车辆定时器
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class Timer {
|
|
||||||
//redis
|
|
||||||
@Autowired
|
|
||||||
private StringRedisTemplate redis;
|
|
||||||
//查询车辆列表
|
|
||||||
@Autowired
|
|
||||||
private VehicleService vehicleService;
|
|
||||||
|
|
||||||
|
|
||||||
//判断车辆是否下线
|
|
||||||
@Scheduled(cron = "* * * * * *")
|
|
||||||
public void outLine() {
|
|
||||||
log.info("定时器启动");
|
|
||||||
|
|
||||||
//先查询车辆列表
|
|
||||||
List<Vehicle> list = vehicleService.list(new VehicleListParams(null, null, null, null));
|
|
||||||
for (Vehicle vehicle : list) {
|
|
||||||
//只针对已经上线的车辆
|
|
||||||
if (redis.hasKey(vehicle.getVin())) {
|
|
||||||
|
|
||||||
//如果vin的缓存 时间还剩一秒,则判断为已经下线
|
|
||||||
if (redis.getExpire(vehicle.getVin()) <= 3) {
|
|
||||||
log.info(vehicle.getVin() + "的车辆已经下线");
|
|
||||||
|
|
||||||
//执行修改下线状态的方法
|
|
||||||
Integer i = vehicleService.onOrOutLineByVIN(vehicle.getVin(), 0);
|
|
||||||
|
|
||||||
// if (0 == 1) {
|
|
||||||
// log.error("下线状态修改失败");
|
|
||||||
// }
|
|
||||||
|
|
||||||
log.info("下线状态修改成功");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
com.couplet.business.server.time.Timer
|
|
|
@ -29,4 +29,18 @@
|
||||||
(#{fenceId}, #{item})
|
(#{fenceId}, #{item})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
<select id="queryByFenceAndLogoIds" resultType="com.couplet.common.domain.Fence">
|
||||||
|
|
||||||
|
SELECT fence_id,
|
||||||
|
fence_name,
|
||||||
|
fence_longitude_latitude,
|
||||||
|
logo_name
|
||||||
|
FROM couplet_fences_and_logo a
|
||||||
|
INNER JOIN couplet_fence_info f on a.fences_id=f.fence_id
|
||||||
|
INNER JOIN couplet_logo_info l on l.logo_id=a.logo_id
|
||||||
|
left JOIN couplet_vehicle_and_logo c on l.logo_id=c.logo_id
|
||||||
|
WHERE l.logo_id=#{logoIds} and c.vehicle_id=#{id}
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<select id="getBindLogoById" resultType="java.lang.Long">
|
<select id="getBindLogoById" resultType="java.lang.Long">
|
||||||
SELECT val.logo_id
|
SELECT val.logo_id,val.vehicle_id
|
||||||
FROM `couplet_vehicle_and_logo` val
|
FROM `couplet_vehicle_and_logo` val
|
||||||
WHERE val.vehicle_id = #{vehicleId}
|
WHERE val.vehicle_id = #{vehicleId}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -41,12 +41,11 @@
|
||||||
</sql>
|
</sql>
|
||||||
<insert id="addVehicle">
|
<insert id="addVehicle">
|
||||||
INSERT INTO `couplet-cloud`.`couplet_middle` (`user_id`, `vehicle_id`, `del_flag`) VALUES
|
INSERT INTO `couplet-cloud`.`couplet_middle` (`user_id`, `vehicle_id`, `del_flag`) VALUES
|
||||||
<foreach collection="vehicleId" item="vehicleId" separator=",">
|
<foreach collection="vehicleIds" item="vehicleId" separator=",">
|
||||||
(#{userId}, #{vehicleId}, 0)
|
(#{userId}, #{vehicleId}, 0)
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
<update id="onOrOutLineByVIN">
|
<update id="onOrOutLineByVIN">
|
||||||
UPDATE `couplet-cloud`.`couplet_vehicle`
|
UPDATE `couplet-cloud`.`couplet_vehicle`
|
||||||
SET `vehicle_state` = #{status}
|
SET `vehicle_state` = #{status}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
||||||
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代码生成
|
* 代码生成
|
||||||
|
@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@ComponentScan(basePackages = {"com.couplet"})
|
||||||
public class CoupletGenApplication {
|
public class CoupletGenApplication {
|
||||||
public static void main (String[] args) {
|
public static void main (String[] args) {
|
||||||
SpringApplication.run(CoupletGenApplication.class, args);
|
SpringApplication.run(CoupletGenApplication.class, args);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
||||||
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时任务
|
* 定时任务
|
||||||
|
@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@ComponentScan(basePackages = {"com.couplet"})
|
||||||
public class CoupletJobApplication {
|
public class CoupletJobApplication {
|
||||||
public static void main (String[] args) {
|
public static void main (String[] args) {
|
||||||
SpringApplication.run(CoupletJobApplication.class, args);
|
SpringApplication.run(CoupletJobApplication.class, args);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.couplet.job.controller;
|
package com.couplet.job.controller;
|
||||||
|
|
||||||
import com.couplet.common.core.constant.Constants;
|
import com.couplet.common.core.constant.Constants;
|
||||||
|
|
||||||
import com.couplet.common.core.exception.job.TaskException;
|
import com.couplet.common.core.exception.job.TaskException;
|
||||||
import com.couplet.common.core.utils.StringUtils;
|
import com.couplet.common.core.utils.StringUtils;
|
||||||
import com.couplet.common.core.utils.poi.ExcelUtil;
|
import com.couplet.common.core.utils.poi.ExcelUtil;
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
package com.couplet.job.task;
|
|
||||||
|
|
||||||
import com.couplet.common.core.utils.StringUtils;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务调度测试
|
|
||||||
*
|
|
||||||
* @author couplet
|
|
||||||
*/
|
|
||||||
@Component("myTask")
|
|
||||||
public class MyTask {
|
|
||||||
public void ryMultipleParams (String s, Boolean b, Long l, Double d, Integer i) {
|
|
||||||
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ryParams (String params) {
|
|
||||||
System.out.println("执行有参方法:" + params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ryNoParams () {
|
|
||||||
System.out.println("执行无参方法");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,6 +5,7 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
||||||
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ProjectName: Default (Template) Project
|
* @ProjectName: Default (Template) Project
|
||||||
|
@ -16,6 +17,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@ComponentScan(basePackages = {"com.couplet"})
|
||||||
public class CoupletMqApplatcaion {
|
public class CoupletMqApplatcaion {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(CoupletMqApplatcaion.class, args);
|
SpringApplication.run(CoupletMqApplatcaion.class, args);
|
||||||
|
|
|
@ -27,15 +27,18 @@ public class RabbitMQConfig implements RabbitTemplate.ConfirmCallback, RabbitTem
|
||||||
@Value("queueName")
|
@Value("queueName")
|
||||||
public String queueName;
|
public String queueName;
|
||||||
//队列名
|
//队列名
|
||||||
public static final String finByVinQueueName="finByVinQueueName";
|
public static final String finByVinQueueName = "finByVinQueueName";
|
||||||
public static final String FENCE_QUEUE ="fenceQueue";
|
public static final String FENCE_QUEUE = "fenceQueue";
|
||||||
|
public static final String vehicleQueue = "vehicleQueue";
|
||||||
//交换机
|
//交换机
|
||||||
public static final String VinExchangeName="vinExchangeName";
|
public static final String VinExchangeName = "vinExchangeName";
|
||||||
public static final String FENCE_EXCHANGE="fenceExchange";
|
public static final String FENCE_EXCHANGE = "fenceExchange";
|
||||||
|
public static final String vehicleQueueExchange = "vehicleQueueExchange";
|
||||||
|
|
||||||
//路由键
|
//路由键
|
||||||
public static final String VinRoutingKey="vinRoutingKey";
|
public static final String VinRoutingKey = "vinRoutingKey";
|
||||||
public static final String FENCE_ROUTINGKEY="fenceRoutingKey";
|
public static final String FENCE_ROUTINGKEY = "fenceRoutingKey";
|
||||||
|
public static final String VehicleQueue_ROUTINGKEY = "VehicleQueueRoutingKey";
|
||||||
//队列名
|
//队列名
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,15 +77,23 @@ public class RabbitMQConfig implements RabbitTemplate.ConfirmCallback, RabbitTem
|
||||||
public Queue queue() {
|
public Queue queue() {
|
||||||
return new Queue(queueName, true);
|
return new Queue(queueName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean("fenceQueue")
|
@Bean("fenceQueue")
|
||||||
public Queue queue2() {
|
public Queue queue2() {
|
||||||
return new Queue(FENCE_QUEUE, true);
|
return new Queue(FENCE_QUEUE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean("finByVinQueueName")
|
@Bean("finByVinQueueName")
|
||||||
public Queue finByVinQueueName() {
|
public Queue finByVinQueueName() {
|
||||||
return new Queue(finByVinQueueName, true);
|
return new Queue(finByVinQueueName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//当增删改车辆的时候,发送当前车辆的id到"vehicleQueue"队列
|
||||||
|
@Bean("vehicleQueue")
|
||||||
|
public Queue vehicleQueue() {
|
||||||
|
return new Queue("vehicleQueue", true);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @Author: LiuYunHu
|
* @Author: LiuYunHu
|
||||||
* @Date: 2024/3/29 21:26
|
* @Date: 2024/3/29 21:26
|
||||||
|
@ -100,11 +111,16 @@ public class RabbitMQConfig implements RabbitTemplate.ConfirmCallback, RabbitTem
|
||||||
return new DirectExchange(FENCE_EXCHANGE);
|
return new DirectExchange(FENCE_EXCHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean("vinExchangeName")
|
@Bean("vinExchangeName")
|
||||||
public DirectExchange vinExchangeName() {
|
public DirectExchange vinExchangeName() {
|
||||||
return new DirectExchange(VinExchangeName);
|
return new DirectExchange(VinExchangeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean("vehicleQueueExchange")
|
||||||
|
public DirectExchange vehicleQueueExchange() {
|
||||||
|
return new DirectExchange("vehicleQueueExchange");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @Author: LiuYunHu
|
* @Author: LiuYunHu
|
||||||
|
@ -152,11 +168,17 @@ public class RabbitMQConfig implements RabbitTemplate.ConfirmCallback, RabbitTem
|
||||||
public Binding binding2() {
|
public Binding binding2() {
|
||||||
return BindingBuilder.bind(queue2()).to(directExchange2()).with(FENCE_ROUTINGKEY);
|
return BindingBuilder.bind(queue2()).to(directExchange2()).with(FENCE_ROUTINGKEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean("vinRoutingKey")
|
@Bean("vinRoutingKey")
|
||||||
public Binding binding3() {
|
public Binding binding3() {
|
||||||
return BindingBuilder.bind(finByVinQueueName()).to(vinExchangeName()).with(VinRoutingKey);
|
return BindingBuilder.bind(finByVinQueueName()).to(vinExchangeName()).with(VinRoutingKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean("VehicleQueueRoutingKey")
|
||||||
|
public Binding binding4() {
|
||||||
|
return BindingBuilder.bind(vehicleQueue()).to(vehicleQueueExchange()).with(VehicleQueue_ROUTINGKEY);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @Author: LiuYunHu
|
* @Author: LiuYunHu
|
||||||
* @Date: 2024/3/29 21:28
|
* @Date: 2024/3/29 21:28
|
||||||
|
|
|
@ -90,4 +90,13 @@ public class MqController {
|
||||||
}, new CorrelationData(IdUtils.randomUUID())
|
}, new CorrelationData(IdUtils.randomUUID())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/vehicleQueue/{msg}")
|
||||||
|
public void vehicleQueue(@PathVariable("msg") String msg){
|
||||||
|
rabbitTemplate.convertAndSend(RabbitMQConfig.vehicleQueueExchange, RabbitMQConfig.VehicleQueue_ROUTINGKEY, msg, message -> {
|
||||||
|
message.getMessageProperties().setMessageId(IdUtils.randomUUID());
|
||||||
|
return message;
|
||||||
|
}, new CorrelationData(IdUtils.randomUUID())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,12 @@ import com.couplet.common.core.constant.ServiceNameConstants;
|
||||||
import com.couplet.common.domain.request.FenceUpdateRequest;
|
import com.couplet.common.domain.request.FenceUpdateRequest;
|
||||||
import com.couplet.mq.remote.factory.RemoteFenceFallbackFactory;
|
import com.couplet.mq.remote.factory.RemoteFenceFallbackFactory;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
@FeignClient(contextId = "remoteVehicleService" ,
|
@FeignClient(contextId = "remoteFenceService" ,
|
||||||
value = ServiceNameConstants.BUSINESS_SERVICE,
|
value = ServiceNameConstants.BUSINESS_SERVICE,
|
||||||
fallbackFactory = RemoteFenceFallbackFactory.class
|
fallbackFactory = RemoteFenceFallbackFactory.class
|
||||||
)
|
)
|
||||||
|
@ -16,4 +18,7 @@ public interface RemoteFenceService {
|
||||||
@PostMapping("/mq/fenceQueue")
|
@PostMapping("/mq/fenceQueue")
|
||||||
public void fenceQueue(@RequestBody FenceUpdateRequest teRequest);
|
public void fenceQueue(@RequestBody FenceUpdateRequest teRequest);
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/mq/vehicleQueue/{msg}")
|
||||||
|
public void vehicleQueue(@PathVariable("msg") String msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,11 @@ public class RemoteFenceFallbackFactory implements FallbackFactory<RemoteFenceSe
|
||||||
public void fenceQueue(FenceUpdateRequest fenceUpdateRequest) {
|
public void fenceQueue(FenceUpdateRequest fenceUpdateRequest) {
|
||||||
error("调用失败...."+cause.getMessage());
|
error("调用失败...."+cause.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void vehicleQueue(String msg) {
|
||||||
|
log.error("调取失败:"+cause.getMessage());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,164 +1,165 @@
|
||||||
package com.couplet.mq.service;
|
//package com.couplet.mq.service;
|
||||||
|
//
|
||||||
import com.couplet.mq.domain.User;
|
//import com.couplet.common.redis.service.RedisService;
|
||||||
import com.rabbitmq.client.Channel;
|
//import com.couplet.mq.domain.User;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
//import com.rabbitmq.client.Channel;
|
||||||
import org.springframework.amqp.core.Message;
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
//import org.springframework.amqp.core.Message;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
//import org.springframework.stereotype.Component;
|
||||||
import java.io.IOException;
|
//
|
||||||
import java.util.concurrent.TimeUnit;
|
//import java.io.IOException;
|
||||||
|
//import java.util.concurrent.TimeUnit;
|
||||||
/**
|
//
|
||||||
* @ProjectName: five-groups-couplet
|
///**
|
||||||
* @Author: LiuYunHu
|
// * @ProjectName: five-groups-couplet
|
||||||
* @CreateTime: 2024/3/28
|
// * @Author: LiuYunHu
|
||||||
* @Description: MQ消费者类
|
// * @CreateTime: 2024/3/28
|
||||||
*/
|
// * @Description: MQ消费者类
|
||||||
|
// */
|
||||||
@Component
|
//
|
||||||
@Slf4j
|
//@Component
|
||||||
@SuppressWarnings("all")
|
//@Slf4j
|
||||||
@RabbitListener(queues = "queueName")
|
//@SuppressWarnings("all")
|
||||||
public class MqConsumer {
|
//@RabbitListener(queues = "queueName")
|
||||||
@Autowired
|
//public class MqConsumer {
|
||||||
private StringRedisTemplate redis;
|
// @Autowired
|
||||||
|
// private RedisService redis;
|
||||||
/* 线程池执行
|
//
|
||||||
|
// /* 线程池执行
|
||||||
//创建一个定长线程池
|
//
|
||||||
private final Executor executor = Executors.newFixedThreadPool(5);
|
// //创建一个定长线程池
|
||||||
|
// private final Executor executor = Executors.newFixedThreadPool(5);
|
||||||
@Async
|
//
|
||||||
@RabbitHandler
|
// @Async
|
||||||
public void process(User param, Channel channel, Message message) {
|
// @RabbitHandler
|
||||||
executor.execute(() -> {
|
// public void process(User param, Channel channel, Message message) {
|
||||||
try {
|
// executor.execute(() -> {
|
||||||
handleMessage(param, channel, message);
|
// try {
|
||||||
} catch (IOException e) {
|
// handleMessage(param, channel, message);
|
||||||
log.error("处理消息失败:{}", e);
|
// } catch (IOException e) {
|
||||||
}
|
// log.error("处理消息失败:{}", e);
|
||||||
});
|
// }
|
||||||
}
|
// });
|
||||||
|
// }
|
||||||
//处理信息的方法
|
//
|
||||||
private void handleMessage(User param, Channel channel, Message message) throws IOException {
|
// //处理信息的方法
|
||||||
log.info("消费者收到消息为:{},{}" + param, message.getMessageProperties().getDeliveryTag());
|
// private void handleMessage(User param, Channel channel, Message message) throws IOException {
|
||||||
|
// log.info("消费者收到消息为:{},{}" + param, message.getMessageProperties().getDeliveryTag());
|
||||||
long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
//
|
||||||
String messageId = message.getMessageProperties().getMessageId();
|
// long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||||
|
// String messageId = message.getMessageProperties().getMessageId();
|
||||||
if (!redis.hasKey("value:" + messageId)) {
|
//
|
||||||
redis.opsForValue().set("value:" + messageId, "" + deliveryTag, 5, TimeUnit.MINUTES);
|
// if (!redis.hasKey("value:" + messageId)) {
|
||||||
}
|
// redis.opsForValue().set("value:" + messageId, "" + deliveryTag, 5, TimeUnit.MINUTES);
|
||||||
|
// }
|
||||||
// 1 添加成功新数据 0已有重复值,不允许再添加
|
//
|
||||||
Long add = redis.opsForSet().add("set:" + messageId, "set:" + messageId);
|
// // 1 添加成功新数据 0已有重复值,不允许再添加
|
||||||
//过期时间
|
// Long add = redis.opsForSet().add("set:" + messageId, "set:" + messageId);
|
||||||
redis.expire("set:" + messageId, 5, TimeUnit.MINUTES);
|
// //过期时间
|
||||||
|
// redis.expire("set:" + messageId, 5, TimeUnit.MINUTES);
|
||||||
|
//
|
||||||
try {
|
//
|
||||||
if (add == 1) {
|
// try {
|
||||||
//第一次 消费
|
// if (add == 1) {
|
||||||
System.out.println("*****************************");
|
// //第一次 消费
|
||||||
System.out.println("消费者收到消息:" + param);
|
// System.out.println("*****************************");
|
||||||
System.out.println("*****************************");
|
// System.out.println("消费者收到消息:" + param);
|
||||||
log.info("消费结束");
|
// System.out.println("*****************************");
|
||||||
|
// log.info("消费结束");
|
||||||
channel.basicAck(deliveryTag, false);
|
//
|
||||||
|
// channel.basicAck(deliveryTag, false);
|
||||||
} else {
|
//
|
||||||
//重复消费
|
// } else {
|
||||||
log.error("重复消费");
|
// //重复消费
|
||||||
channel.basicReject(deliveryTag, false);
|
// log.error("重复消费");
|
||||||
|
// channel.basicReject(deliveryTag, false);
|
||||||
//删除缓存
|
//
|
||||||
redis.opsForSet().remove("set:" + messageId, "set:" + messageId);
|
// //删除缓存
|
||||||
}
|
// redis.opsForSet().remove("set:" + messageId, "set:" + messageId);
|
||||||
|
// }
|
||||||
|
//
|
||||||
} catch (Exception e) {
|
//
|
||||||
log.error("消息没有成功消费!");
|
// } catch (Exception e) {
|
||||||
|
// log.error("消息没有成功消费!");
|
||||||
String s = redis.opsForValue().get("value:" + messageId);
|
//
|
||||||
|
// String s = redis.opsForValue().get("value:" + messageId);
|
||||||
long oldTag = Long.parseLong(s);
|
//
|
||||||
|
// long oldTag = Long.parseLong(s);
|
||||||
if (deliveryTag == (oldTag + 2)) {
|
//
|
||||||
log.error("确实消费不了,不入队了!");
|
// if (deliveryTag == (oldTag + 2)) {
|
||||||
channel.basicNack(deliveryTag, false, false);
|
// log.error("确实消费不了,不入队了!");
|
||||||
} else {
|
// channel.basicNack(deliveryTag, false, false);
|
||||||
log.info("消息消费失败,重新入队");
|
// } else {
|
||||||
channel.basicNack(deliveryTag, false, true);
|
// log.info("消息消费失败,重新入队");
|
||||||
}
|
// channel.basicNack(deliveryTag, false, true);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
**/
|
//
|
||||||
|
//**/
|
||||||
@RabbitHandler
|
//
|
||||||
public void process(User param, Channel channel, Message message) throws IOException {
|
// @RabbitHandler
|
||||||
log.info("消费者收到消息为:{},{}" + param, message.getMessageProperties().getDeliveryTag());
|
// public void process(User param, Channel channel, Message message) throws IOException {
|
||||||
|
// log.info("消费者收到消息为:{},{}" + param, message.getMessageProperties().getDeliveryTag());
|
||||||
long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
//
|
||||||
String messageId = message.getMessageProperties().getMessageId();
|
// long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||||
|
// String messageId = message.getMessageProperties().getMessageId();
|
||||||
if (!redis.hasKey("value:" + messageId)) {
|
//
|
||||||
redis.opsForValue().set("value:" + messageId, "" + deliveryTag, 5, TimeUnit.MINUTES);
|
// if (!redis.hasKey("value:" + messageId)) {
|
||||||
}
|
// redis.setCacheObject("value:" + messageId, "" + deliveryTag, 5, TimeUnit.MINUTES);
|
||||||
|
// }
|
||||||
// 1 添加成功新数据 0已有重复值,不允许再添加
|
//
|
||||||
Long add = redis.opsForSet().add("set:" + messageId, "set:" + messageId);
|
// // 1 添加成功新数据 0已有重复值,不允许再添加
|
||||||
//过期时间
|
// Long add = redis.opsForSet().add("set:" + messageId, "set:" + messageId);
|
||||||
redis.expire("set:" + messageId, 5, TimeUnit.MINUTES);
|
// //过期时间
|
||||||
|
// redis.expire("set:" + messageId, 5, TimeUnit.MINUTES);
|
||||||
|
//
|
||||||
try {
|
//
|
||||||
if (add == 1) {
|
// try {
|
||||||
//第一次 消费
|
// if (add == 1) {
|
||||||
System.out.println("*****************************");
|
// //第一次 消费
|
||||||
System.out.println("消费者收到消息:" + param);
|
// System.out.println("*****************************");
|
||||||
System.out.println("*****************************");
|
// System.out.println("消费者收到消息:" + param);
|
||||||
log.info("消费结束");
|
// System.out.println("*****************************");
|
||||||
|
// log.info("消费结束");
|
||||||
//确认消费
|
//
|
||||||
channel.basicAck(deliveryTag, false);
|
// //确认消费
|
||||||
|
// channel.basicAck(deliveryTag, false);
|
||||||
} else {
|
//
|
||||||
//重复消费
|
// } else {
|
||||||
log.error("重复消费");
|
// //重复消费
|
||||||
//拒绝消费
|
// log.error("重复消费");
|
||||||
channel.basicReject(deliveryTag, false);
|
// //拒绝消费
|
||||||
|
// channel.basicReject(deliveryTag, false);
|
||||||
//删除缓存
|
//
|
||||||
redis.opsForSet().remove("set:" + messageId, "set:" + messageId);
|
// //删除缓存
|
||||||
}
|
// redis.opsForSet().remove("set:" + messageId, "set:" + messageId);
|
||||||
|
// }
|
||||||
|
//
|
||||||
} catch (Exception e) {
|
//
|
||||||
log.error("消息没有成功消费!");
|
// } catch (Exception e) {
|
||||||
|
// log.error("消息没有成功消费!");
|
||||||
String s = redis.opsForValue().get("value:" + messageId);
|
//
|
||||||
|
// String s = redis.opsForValue().get("value:" + messageId);
|
||||||
long oldTag = Long.parseLong(s);
|
//
|
||||||
|
// long oldTag = Long.parseLong(s);
|
||||||
if (deliveryTag == (oldTag + 2)) {
|
//
|
||||||
log.error("确实消费不了,不入队了!");
|
// if (deliveryTag == (oldTag + 2)) {
|
||||||
|
// log.error("确实消费不了,不入队了!");
|
||||||
|
//
|
||||||
//拒绝消费
|
//
|
||||||
channel.basicNack(deliveryTag, false, false);
|
// //拒绝消费
|
||||||
} else {
|
// channel.basicNack(deliveryTag, false, false);
|
||||||
log.info("消息消费失败,重新入队");
|
// } else {
|
||||||
//重新入队
|
// log.info("消息消费失败,重新入队");
|
||||||
channel.basicNack(deliveryTag, false, true);
|
// //重新入队
|
||||||
}
|
// channel.basicNack(deliveryTag, false, true);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.couplet.online.utils;
|
package com.couplet.online.utils;
|
||||||
|
|
||||||
import com.couplet.common.domain.Vehicle;
|
import com.couplet.common.domain.Vehicle;
|
||||||
|
import com.couplet.common.redis.service.RedisService;
|
||||||
import com.couplet.remote.RemoteVehicleService;
|
import com.couplet.remote.RemoteVehicleService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||||
|
@ -72,7 +73,7 @@ public class MqttMonitor {
|
||||||
|
|
||||||
//redis
|
//redis
|
||||||
@Autowired
|
@Autowired
|
||||||
private StringRedisTemplate redis;
|
private RedisService redis;
|
||||||
|
|
||||||
|
|
||||||
//Kafka生产者配置
|
//Kafka生产者配置
|
||||||
|
@ -187,7 +188,7 @@ public class MqttMonitor {
|
||||||
|
|
||||||
|
|
||||||
//如果不存在这个车
|
//如果不存在这个车
|
||||||
if (0 == vehicles.size()) {
|
if (0 == vehicles.size() || null == vehicles) {
|
||||||
//将不属于自己系统的车辆存入缓存,便于提前进行拒绝提示
|
//将不属于自己系统的车辆存入缓存,便于提前进行拒绝提示
|
||||||
// redis.setCacheObject("不存在的车辆VIN" + start17, start17);
|
// redis.setCacheObject("不存在的车辆VIN" + start17, start17);
|
||||||
log.error("未找到vin码为" + start17 + "的车辆信息");
|
log.error("未找到vin码为" + start17 + "的车辆信息");
|
||||||
|
@ -197,7 +198,7 @@ public class MqttMonitor {
|
||||||
log.info("远程调用查询到的车辆数据:" + vehicle);
|
log.info("远程调用查询到的车辆数据:" + vehicle);
|
||||||
|
|
||||||
//上线车辆存入redis 6秒 用于判断车辆是否下线,还要写定时器,定时查询
|
//上线车辆存入redis 6秒 用于判断车辆是否下线,还要写定时器,定时查询
|
||||||
redis.opsForValue().set(start17, start17, 6L, TimeUnit.SECONDS);
|
redis.setCacheObject(start17, start17, 6L, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
|
||||||
log.info("vin码为" + start17 + "的车辆属于本系统,允许上线!");
|
log.info("vin码为" + start17 + "的车辆属于本系统,允许上线!");
|
||||||
|
|
|
@ -33,10 +33,10 @@ logging:
|
||||||
mqtt:
|
mqtt:
|
||||||
server:
|
server:
|
||||||
broker: tcp://115.159.47.13:1883
|
broker: tcp://115.159.47.13:1883
|
||||||
# broker: mqtt://115.159.47.13:1883
|
# broker: mqtt://115.159.47.13:1883
|
||||||
username:
|
username:
|
||||||
password:
|
password:
|
||||||
clientId: fluxmq
|
clientId: xiaoyao
|
||||||
qos: 0
|
qos: 0
|
||||||
topic: test
|
topic: xiaoyao
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
||||||
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统模块
|
* 系统模块
|
||||||
|
@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@ComponentScan(basePackages = {"com.couplet"})
|
||||||
public class CoupletSystemApplication {
|
public class CoupletSystemApplication {
|
||||||
public static void main (String[] args) {
|
public static void main (String[] args) {
|
||||||
SpringApplication.run(CoupletSystemApplication.class, args);
|
SpringApplication.run(CoupletSystemApplication.class, args);
|
||||||
|
|
|
@ -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
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
51
pom.xml
51
pom.xml
|
@ -211,63 +211,18 @@
|
||||||
<artifactId>couplet-modules-system</artifactId>
|
<artifactId>couplet-modules-system</artifactId>
|
||||||
<version>${couplet.version}</version>
|
<version>${couplet.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.couplet</groupId>-->
|
|
||||||
<!-- <artifactId>couplet-trouble</artifactId>-->
|
|
||||||
<!-- <version>${couplet.version}</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.couplet</groupId>-->
|
|
||||||
<!-- <artifactId>couplet-electronic-fence-server</artifactId>-->
|
|
||||||
<!-- <version>${couplet.version}</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.couplet</groupId>-->
|
|
||||||
<!-- <artifactId>couplet-electronic-fence-common</artifactId>-->
|
|
||||||
<!-- <version>${couplet.version}</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.couplet</groupId>-->
|
|
||||||
<!-- <artifactId>couplet-electronic-fence-remote</artifactId>-->
|
|
||||||
<!-- <version>${couplet.version}</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<!-- <!– 企业服务 模块 公共依赖 –>-->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.couplet</groupId>-->
|
|
||||||
<!-- <artifactId>couplet-enterprisemanagement-common</artifactId>-->
|
|
||||||
<!-- <version>${couplet.version}</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<!-- <!– 企业服务 模块 远程调用依赖 –>-->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.couplet</groupId>-->
|
|
||||||
<!-- <artifactId>couplet-enterprisemanagement-remote</artifactId>-->
|
|
||||||
<!-- <version>${couplet.version}</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<!-- <!– 车辆管理模块 –>-->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.couplet</groupId>-->
|
|
||||||
<!-- <artifactId>couplet-modules-vehicle</artifactId>-->
|
|
||||||
<!-- <version>${couplet.version}</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<!-- RabbitMq模块 -->
|
<!-- RabbitMq模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.couplet</groupId>
|
<groupId>com.couplet</groupId>
|
||||||
<artifactId>couplet-modules-mq</artifactId>
|
<artifactId>couplet-modules-mq</artifactId>
|
||||||
<version>${couplet.version}</version>
|
<version>${couplet.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- 业务系统核心模块 -->
|
<!-- 业务系统核心模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.couplet</groupId>
|
<groupId>com.couplet</groupId>
|
||||||
<artifactId>couplet-common-business</artifactId>
|
<artifactId>couplet-common-business</artifactId>
|
||||||
<version>${couplet.version}</version>
|
<version>${couplet.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 车辆上线模块-->
|
<!-- 车辆上线模块-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.couplet</groupId>
|
<groupId>com.couplet</groupId>
|
||||||
|
@ -281,6 +236,12 @@
|
||||||
<artifactId>couplet-analyze-msg</artifactId>
|
<artifactId>couplet-analyze-msg</artifactId>
|
||||||
<version>${couplet.version}</version>
|
<version>${couplet.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--车辆解析核心模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-event</artifactId>
|
||||||
|
<version>${couplet.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
Loading…
Reference in New Issue