Merge branch 'server_five' of https://gitea.qinmian.online/five-groups/five-groups-couplet into server_five_liuyunhu
commit
cf9727981e
|
@ -4,6 +4,7 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
|||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
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
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||
@ComponentScan(basePackages = {"com.couplet"})
|
||||
public class CoupletAuthApplication {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run(CoupletAuthApplication.class, args);
|
||||
|
|
|
@ -17,11 +17,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.couplet.common.core.utils;
|
||||
|
||||
import com.couplet.common.core.web.page.TableSupport;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.couplet.common.core.utils.sql.SqlUtil;
|
||||
import com.couplet.common.core.web.page.PageDomain;
|
||||
import com.couplet.common.core.web.page.TableSupport;
|
||||
|
||||
/**
|
||||
* 分页工具类
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.couplet.common.redis.service;
|
||||
|
||||
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.data.redis.core.*;
|
||||
|
@ -26,6 +27,19 @@ public class RedisService {
|
|||
return redisTemplate.opsForList().range("coupletMsgData", 0, -1);
|
||||
}
|
||||
|
||||
// ... 其他已有方法 ...
|
||||
|
||||
/**
|
||||
* 向指定集合中添加值,如果值不存在则添加并返回true,否则返回false。
|
||||
*
|
||||
* @param setKey 集合键名
|
||||
* @param value 要添加的值
|
||||
* @return true表示值已成功添加(之前不存在),false表示值已存在
|
||||
*/
|
||||
public boolean addToSetIfNotExists(String setKey, String value) {
|
||||
return redisTemplate.opsForSet().add(setKey, value) == 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
|
@ -167,31 +181,8 @@ public class RedisService {
|
|||
setOperation.add(it.next());
|
||||
}
|
||||
return setOperation;
|
||||
} /**
|
||||
* 缓存Set
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @param dataSet 缓存的数据
|
||||
*
|
||||
* @return 缓存数据的对象
|
||||
*/
|
||||
public <T> BoundSetOperations<String, T> setCacheSet (final String key, final T dataSet) {
|
||||
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
||||
setOperation.add(dataSet);
|
||||
return setOperation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除set
|
||||
* @param key
|
||||
* @param setValue
|
||||
*/
|
||||
public <T> void deleteSet(String key, String setValue) {
|
||||
|
||||
//缓存的键值
|
||||
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
||||
setOperation.remove(setValue); //缓存的数据
|
||||
}
|
||||
/**
|
||||
* 获得缓存的set
|
||||
*
|
||||
|
@ -203,7 +194,6 @@ public class RedisService {
|
|||
return redisTemplate.opsForSet().members(key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 缓存Map
|
||||
*
|
||||
|
@ -286,5 +276,8 @@ public class RedisService {
|
|||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -15,7 +16,7 @@ import java.util.List;
|
|||
* @date 2024/3/27 15:29
|
||||
*/
|
||||
@Slf4j
|
||||
|
||||
@Component
|
||||
public class RemoteDeptFallbackFactory implements FallbackFactory<RemoteDeptService> {
|
||||
@Override
|
||||
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.remote.RemoteEmployeeService;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -14,6 +15,7 @@ import java.util.List;
|
|||
* @description: 员工服务降级处理
|
||||
* @date 2024/3/31 19:43
|
||||
*/
|
||||
@Component
|
||||
public class RemoteEmployeeFallbackFactory implements FallbackFactory<RemoteEmployeeService> {
|
||||
@Override
|
||||
public RemoteEmployeeService create(Throwable cause) {
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -0,0 +1,150 @@
|
|||
package com.couplet.analyze.msg.consumer;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.utils.MsgUtils;
|
||||
import com.couplet.common.domain.CoupletTroubleCode;
|
||||
import com.couplet.common.redis.service.RedisService;
|
||||
import com.couplet.remote.RemoteTroubleService;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* @author DongXiaoDong
|
||||
* @version 1.0
|
||||
* @date 2024/4/6 15:37
|
||||
* @description
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CodeConsumer {
|
||||
// @Autowired
|
||||
// private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
@Autowired
|
||||
private RemoteTroubleService remoteTroubleService;
|
||||
|
||||
@RabbitListener(queuesToDeclare = {@Queue("couplet-code-queue")})
|
||||
public void sendLogQueueConsumer(Message message, CoupletMsgData msgData, Channel channel) {
|
||||
log.info("日志队列:{},接收到的消息:{},开始消费...","couplet-code-queue", JSONObject.toJSONString(msgData));
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
|
||||
try {
|
||||
boolean addToSetIfNotExists = redisService.addToSetIfNotExists("couplet-code-queue", messageId);
|
||||
if (addToSetIfNotExists) {
|
||||
//异步保存记录
|
||||
CompletableFuture.runAsync(() -> {
|
||||
CoupletTroubleCode troubleCode = new CoupletTroubleCode();
|
||||
troubleCode.setTroubleStartTime(new Date());
|
||||
troubleCode.setTroubleVin(msgData.getVin());
|
||||
// 随机生成故障码
|
||||
String faultCode = MsgUtils.generateGTA();
|
||||
troubleCode.setTroubleCode(faultCode);
|
||||
|
||||
// 检查车辆状态,若为0,则设置故障位置为"190"
|
||||
if(msgData.getVehicleStatus() == 0) {
|
||||
troubleCode.setTroublePosition("190");
|
||||
}
|
||||
|
||||
// 检查充电状态,若为0,则设置故障位置为"191"
|
||||
if (msgData.getChargingStatus() == 0) {
|
||||
troubleCode.setTroublePosition("191");
|
||||
}
|
||||
|
||||
// 检查运行状态,若为0,则设置故障位置为"192"
|
||||
if (msgData.getOperatingStatus() == 0) {
|
||||
troubleCode.setTroublePosition("192");
|
||||
}
|
||||
|
||||
// 检查电池荷电状态(SOC), 若为0,则设置故障位置为"193"
|
||||
if (msgData.getSocStatus() == 0) {
|
||||
troubleCode.setTroublePosition("193");
|
||||
}
|
||||
|
||||
// 检查充电能源存储状态,若为0,则设置故障位置为"194"
|
||||
if (msgData.getChargingEnergyStorageStatus() == 0) {
|
||||
troubleCode.setTroublePosition("194");
|
||||
}
|
||||
|
||||
// 检查驱动电机状态,若为0,则设置故障位置为"195"
|
||||
if (msgData.getDriveMotorStatus() == 0) {
|
||||
troubleCode.setTroublePosition("195");
|
||||
}
|
||||
|
||||
// 检查定位状态,若为0,则设置故障位置为"196"
|
||||
if (msgData.getPositionStatus() == 0) {
|
||||
troubleCode.setTroublePosition("196");
|
||||
}
|
||||
|
||||
// 检查电子驻车系统(EAS)状态,若为0,则设置故障位置为"197"
|
||||
if (msgData.getEasStatus() == 0) {
|
||||
troubleCode.setTroublePosition("197");
|
||||
}
|
||||
|
||||
// 检查PTC(正温度系数热敏电阻)状态,若为0,则设置故障位置为"198"
|
||||
if (msgData.getPtcStatus() == 0) {
|
||||
troubleCode.setTroublePosition("198");
|
||||
}
|
||||
|
||||
// 检查电动助力转向系统(EPS)状态,若为0,则设置故障位置为"199"
|
||||
if (msgData.getEpsStatus() == 0) {
|
||||
troubleCode.setTroublePosition("199");
|
||||
}
|
||||
|
||||
// 检查防抱死制动系统(ABS)状态,若为0,则设置故障位置为"200"
|
||||
if (msgData.getAbsStatus() == 0) {
|
||||
troubleCode.setTroublePosition("200");
|
||||
}
|
||||
|
||||
// 检查主控制器(MCU)状态,若为0,则设置故障位置为"201"
|
||||
if (msgData.getMcuStatus() == 0) {
|
||||
troubleCode.setTroublePosition("201");
|
||||
}
|
||||
|
||||
// 检查加热状态,若为0,则设置故障位置为"202"
|
||||
if (msgData.getHeatingStatus() == 0) {
|
||||
troubleCode.setTroublePosition("202");
|
||||
}
|
||||
|
||||
// 检查电池状态,若为0,则设置故障位置为"203"
|
||||
if (msgData.getBatteryStatus() == 0) {
|
||||
troubleCode.setTroublePosition("203");
|
||||
}
|
||||
|
||||
// 检查电池绝缘状态,若为0,则设置故障位置为"204"
|
||||
if (msgData.getBatteryInsulationStatus() == 0) {
|
||||
troubleCode.setTroublePosition("204");
|
||||
}
|
||||
|
||||
// 检查直流-直流转换器(DC/DC)状态,若为0,则设置故障位置为"205"
|
||||
if (msgData.getDcdcStatus() == 0) {
|
||||
troubleCode.setTroublePosition("205");
|
||||
}
|
||||
|
||||
// 检查充电机(CHG)状态,若为0,则设置故障位置为"206"
|
||||
if (msgData.getChgStatus() == 0) {
|
||||
troubleCode.setTroublePosition("206");
|
||||
}
|
||||
remoteTroubleService.newFaultData(troubleCode);
|
||||
});
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
log.info("日志队列:{},接收到的消息:{},消费完成,耗时:{}毫秒","couplet-code-queue", JSONObject.toJSONString(msgData), (end-start));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package com.couplet.analyze.msg.consumer;
|
||||
|
||||
import org.springframework.kafka.annotation.KafkaListener;
|
||||
|
||||
/**
|
||||
* @author DongXiaoDong
|
||||
* @version 1.0
|
||||
* @date 2024/4/6 15:37
|
||||
* @description
|
||||
*/
|
||||
public class KafkaConsumer {
|
||||
@KafkaListener(topics = "test", groupId = "group", properties = {"bootstrap.servers = 39.103.133.136:9092"})
|
||||
public void getMessage(String msg) {
|
||||
System.out.println("接收到消息:" + msg);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.couplet.analyze.msg.model;
|
||||
|
||||
import com.couplet.analyze.common.contents.AnalyzeEventContents;
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
import com.couplet.common.core.exception.vehicle.VehicleException;
|
||||
|
@ -8,15 +9,13 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||
import org.apache.kafka.clients.consumer.ConsumerRecords;
|
||||
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.*;
|
||||
|
||||
import static com.couplet.analyze.msg.utils.MsgUtils.hexToString;
|
||||
import static com.couplet.analyze.msg.utils.MsgUtils.sendMsg;
|
||||
|
@ -43,12 +42,15 @@ public class ModelsKafkaMessage {
|
|||
add("stored-event");
|
||||
}
|
||||
};
|
||||
// @Autowired
|
||||
// private RabbitTemplate rabbitTemplate;
|
||||
|
||||
/**
|
||||
* 消费者配置
|
||||
* @return
|
||||
*/
|
||||
@Scheduled(fixedDelay = 50)
|
||||
private static void consumerMessages() {
|
||||
public void consumerMessages() {
|
||||
Properties props = new Properties();
|
||||
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS);
|
||||
props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group");
|
||||
|
@ -76,6 +78,11 @@ public class ModelsKafkaMessage {
|
|||
IncidentService incidentService = SpringUtils.getBean(string);
|
||||
incidentService.incident(msgData);
|
||||
}
|
||||
//发送消息
|
||||
// rabbitTemplate.convertAndSend("couplet-code-queue",msgData,message -> {
|
||||
// message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||
// return message;
|
||||
// });
|
||||
|
||||
try {
|
||||
sleep(100);
|
||||
|
|
|
@ -41,6 +41,7 @@ public class ElectronicFenceServiceImpl implements IncidentService {
|
|||
|
||||
String fenceKey="fence";
|
||||
|
||||
// redisService.getCacheSet()
|
||||
ArrayList<Fence> fences = new ArrayList<>();
|
||||
if (redisService.hasKey(fenceKey)) {
|
||||
log.info("电子围栏事件redis存在.......");
|
||||
|
|
|
@ -15,6 +15,7 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
|
@ -23,6 +24,7 @@ spring:
|
|||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
rabbitmq:
|
||||
|
|
|
@ -25,21 +25,21 @@ public class ParsingMsg {
|
|||
String hexStringWithoutSpaces = substring.replaceAll("\\s+", "");
|
||||
String asciiString = hexToString(hexStringWithoutSpaces);
|
||||
System.out.println("16进制解析后的数据:"+asciiString);
|
||||
// //截取前17位
|
||||
// String substring1 = asciiString.substring(0, 17);
|
||||
// System.out.println("VIN:"+substring1);
|
||||
// String substring2 = asciiString.substring(17, 30);
|
||||
// System.out.println("时间戳:"+substring2);
|
||||
// String substring3 = asciiString.substring(30, 40);
|
||||
// System.out.println("经度:" +substring3);
|
||||
// String substring4 = asciiString.substring(41, 50);
|
||||
// System.out.println("纬度:"+ substring4);
|
||||
// String substring5 = asciiString.substring(51, 56);
|
||||
// System.out.println("车速:"+ substring5);
|
||||
// String substring6 = asciiString.substring(57, 67);
|
||||
// System.out.println("总里程:"+ substring6);
|
||||
// String substring7 = asciiString.substring(68, 73);
|
||||
// System.out.println("总电压:"+ substring7);
|
||||
//截取前17位
|
||||
String substring1 = asciiString.substring(0, 17);
|
||||
System.out.println("VIN:"+substring1);
|
||||
String substring2 = asciiString.substring(17, 30);
|
||||
System.out.println("时间戳:"+substring2);
|
||||
String substring3 = asciiString.substring(30, 40);
|
||||
System.out.println("经度:" +substring3);
|
||||
String substring4 = asciiString.substring(41, 50);
|
||||
System.out.println("纬度:"+ substring4);
|
||||
String substring5 = asciiString.substring(51, 56);
|
||||
System.out.println("车速:"+ substring5);
|
||||
String substring6 = asciiString.substring(57, 67);
|
||||
System.out.println("总里程:"+ substring6);
|
||||
String substring7 = asciiString.substring(68, 73);
|
||||
System.out.println("总电压:"+ substring7);
|
||||
String pattern = "(.{17})(.{10})(.{9})(.{8})(.{2})";
|
||||
Pattern compile = Pattern.compile(pattern);
|
||||
Matcher matcher = compile.matcher(asciiString);
|
||||
|
|
|
@ -92,7 +92,15 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</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>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -5,7 +5,9 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
|||
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.couplet.common.domain.request.VehicleListParams;
|
|||
import com.couplet.common.log.annotation.Log;
|
||||
import com.couplet.common.log.enums.BusinessType;
|
||||
import com.couplet.common.security.annotation.RequiresPermissions;
|
||||
import com.couplet.common.security.utils.SecurityUtils;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -159,7 +160,7 @@ public class VehicleController extends BaseController {
|
|||
|
||||
@PostMapping
|
||||
public Result<Integer> addVehicle(@RequestBody VehicleMiddle vehicleMiddle){
|
||||
return Result.success(vehicleService.addVehicle(vehicleMiddle));
|
||||
return Result.success(vehicleService.addVehicle(SecurityUtils.getUserId(),vehicleMiddle.getVehicleIds()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.couplet.common.security.utils.SecurityUtils;
|
|||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -26,8 +27,6 @@ import java.util.Objects;
|
|||
@RequestMapping("detection")
|
||||
public class VehicleDetectionController {
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private VehicleDetectionService vehicleDetectionService;
|
||||
@Autowired
|
||||
|
@ -50,20 +49,14 @@ public class VehicleDetectionController {
|
|||
|
||||
/*
|
||||
* @param vin:
|
||||
* @return Result<List<Vehicle>>
|
||||
* @return Result<List<Vehicle>>
|
||||
* @author 付凡芮
|
||||
* @description 根据vin查询车辆信息
|
||||
* @date
|
||||
*/
|
||||
@PostMapping("/monitorinData/{vin}")
|
||||
public void monitorinData(@PathVariable String vin){
|
||||
String exchangeName = "exchangeName"; // 交换机名称
|
||||
String routingKey = "routingKey"; // 路由键
|
||||
RealTimeDataRequest realTimeDataRequest = new RealTimeDataRequest();
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
realTimeDataRequest.setUserId(userId);
|
||||
realTimeDataRequest.setVin(vin);
|
||||
rabbitTemplate.convertAndSend(exchangeName, routingKey, realTimeDataRequest);
|
||||
vehicleDetectionService.monitorinData(vin);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,9 +22,12 @@ public interface VehicleMapper extends BaseMapper<Vehicle> {
|
|||
|
||||
Integer deleteVehicle(Long middleId);
|
||||
|
||||
Integer addVehicle(VehicleMiddle vehicleMiddle);
|
||||
|
||||
|
||||
List<Vehicle> vehicleAll();
|
||||
|
||||
Integer onOrOutLineByVIN(@Param("vin") String vin, @Param("status") int status);
|
||||
|
||||
|
||||
Integer addVehicle(@Param("userId") Long userId, @Param("vehicleIds") List<Long> vehicleIds);
|
||||
}
|
||||
|
|
|
@ -9,4 +9,5 @@ public interface VehicleDetectionService {
|
|||
|
||||
List<Vehicle> detectionList();
|
||||
|
||||
void monitorinData(String vin);
|
||||
}
|
||||
|
|
|
@ -33,10 +33,11 @@ public interface VehicleService extends IService<Vehicle> {
|
|||
|
||||
Integer deleteVehicle(Long middleId);
|
||||
|
||||
Integer addVehicle(VehicleMiddle vehicleMiddle);
|
||||
|
||||
List<Vehicle> vehicleAll();
|
||||
|
||||
Integer onOrOutLineByVIN(String s, int i);
|
||||
|
||||
|
||||
Integer addVehicle(Long userId, List<Long> vehicleIds);
|
||||
}
|
||||
|
|
|
@ -11,10 +11,13 @@ import com.couplet.common.domain.request.FenceRequest;
|
|||
import com.couplet.common.domain.request.FenceUpdateRequest;
|
||||
import com.couplet.common.redis.service.RedisService;
|
||||
import com.couplet.common.security.utils.SecurityUtils;
|
||||
import com.couplet.mq.remote.RemoteFenceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -40,12 +43,12 @@ public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements
|
|||
* 注入redis模板
|
||||
*/
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
private StringRedisTemplate redisTemplate;
|
||||
/**
|
||||
* 远程调用队列服务
|
||||
*/
|
||||
// @Autowired
|
||||
// private RemoteFenceService remoteFenceService;
|
||||
@Autowired
|
||||
private RemoteFenceService remoteFenceService;
|
||||
|
||||
@Override
|
||||
public List<Fence> pageQuery(FenceConfig fenceConfig) {
|
||||
|
@ -54,7 +57,6 @@ public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void changeFenceStatus(FenceUpdateRequest fenceUpdateRequest) {
|
||||
|
||||
String username = SecurityUtils.getUsername();
|
||||
|
@ -63,31 +65,50 @@ public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements
|
|||
/**
|
||||
* 电子围栏发送改变
|
||||
*/
|
||||
// redisService.setCacheObject("fence:info"+fenceUpdateRequest.getFenceId(),fenceUpdateRequest, 10, TimeUnit.MINUTES);
|
||||
redisTemplate.opsForValue().set("changeFenceStatus", JSON.toJSONString(fenceUpdateRequest), 10, TimeUnit.MINUTES);
|
||||
|
||||
remoteFenceService.fenceQueue(fenceUpdateRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fenceInsert(FenceRequest fenceRequest) {
|
||||
|
||||
redisService.setCacheObject("fence:info:"+fenceUpdateRequest.getFenceId(),fenceUpdateRequest);
|
||||
redisService.expire("fence:info:"+fenceUpdateRequest.getFenceId(),10,TimeUnit.MINUTES);
|
||||
// remoteFenceService.fenceQueue(fenceUpdateRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务实现:添加围栏
|
||||
*
|
||||
* @param request
|
||||
* @param fenceRequest
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void fenceInsert(FenceRequest fenceRequest) {
|
||||
String username = SecurityUtils.getUsername();
|
||||
fenceRequest.setCrateName(username);
|
||||
//先添加围栏
|
||||
fenceMapper.insertFence(fenceRequest);
|
||||
fenAndLogoService.addBach(fenceRequest.getFenceId(), fenceRequest.getLogoIds());
|
||||
}
|
||||
// @Override
|
||||
// public void fenceInsert(HttpServletRequest request, FenceRequest fenceRequest) {
|
||||
// String username = SecurityUtils.getUsername();
|
||||
// fenceRequest.setCrateName(username);
|
||||
// //先添加围栏
|
||||
// fenceMapper.insertFence(fenceRequest);
|
||||
// String[] logoIds = fenceRequest.getLogoIds();
|
||||
// String[] parts = new String[0];
|
||||
// for (String logoId : logoIds) {
|
||||
// //把前台传入的字符串分割成数组
|
||||
// parts = logoId.split(",");
|
||||
// //再添加围栏和标识中间表
|
||||
// fenAndLogoService.addBach(fenceRequest.getFenceId(), parts);
|
||||
// }
|
||||
// /**
|
||||
// * 电子围栏发送改变
|
||||
// */
|
||||
// redisTemplate.opsForValue().set("fenceInsert", JSON.toJSONString(fenceRequest), 10, TimeUnit.MINUTES);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void removeByFenceId(Long fenceId) {
|
||||
fenceMapper.removeByFenceId(fenceId);
|
||||
/**
|
||||
* 电子围栏发送改变
|
||||
*/
|
||||
redisTemplate.opsForValue().set("removeByFenceId", JSON.toJSONString(fenceId), 10, TimeUnit.MINUTES);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
package com.couplet.business.server.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.couplet.business.server.mapper.VehicleDetectionMapper;
|
||||
import com.couplet.business.server.service.VehicleDetectionService;
|
||||
import com.couplet.business.server.service.VehicleManageService;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
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.stereotype.Service;
|
||||
import springfox.documentation.spring.web.json.Json;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -21,10 +29,22 @@ public class VehicleDetectionServiceImpl implements VehicleDetectionService{
|
|||
|
||||
@Autowired
|
||||
private VehicleDetectionMapper vehicleDetectionMapper;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Override
|
||||
public List<Vehicle> 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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -292,11 +292,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
return vehicleMapper.deleteVehicle(middleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer addVehicle(VehicleMiddle vehicleMiddle) {
|
||||
|
||||
return vehicleMapper.addVehicle(vehicleMiddle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Vehicle> vehicleAll() {
|
||||
|
@ -311,6 +307,11 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
return vehicleMapper.onOrOutLineByVIN(vin, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer addVehicle(Long userId, List<Long> vehicleIds) {
|
||||
return vehicleMapper.addVehicle(userId,vehicleIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Vehicle> findByVIN(String vin) {
|
||||
|
||||
|
|
|
@ -41,12 +41,11 @@
|
|||
</sql>
|
||||
<insert id="addVehicle">
|
||||
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)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
<update id="onOrOutLineByVIN">
|
||||
UPDATE `couplet-cloud`.`couplet_vehicle`
|
||||
SET `vehicle_state` = #{status}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
|||
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 代码生成
|
||||
|
@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = {"com.couplet"})
|
||||
public class CoupletGenApplication {
|
||||
public static void main (String[] 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 org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 定时任务
|
||||
|
@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = {"com.couplet"})
|
||||
public class CoupletJobApplication {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run(CoupletJobApplication.class, args);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.couplet.job.controller;
|
||||
|
||||
import com.couplet.common.core.constant.Constants;
|
||||
|
||||
import com.couplet.common.core.exception.job.TaskException;
|
||||
import com.couplet.common.core.utils.StringUtils;
|
||||
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 org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* @ProjectName: Default (Template) Project
|
||||
|
@ -16,6 +17,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = {"com.couplet"})
|
||||
public class CoupletMqApplatcaion {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CoupletMqApplatcaion.class, args);
|
||||
|
|
|
@ -130,15 +130,15 @@ public class RabbitMQConfig implements RabbitTemplate.ConfirmCallback, RabbitTem
|
|||
* @Return: 配置好的RabbitTemplate实例。
|
||||
**/
|
||||
@Primary
|
||||
@Bean
|
||||
public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) {
|
||||
RabbitTemplate rabbitTempalte = new RabbitTemplate(connectionFactory);
|
||||
this.rabbitTemplate = rabbitTempalte;
|
||||
rabbitTempalte.setMessageConverter(messageConverter());
|
||||
rabbitTempalte();
|
||||
|
||||
return rabbitTempalte;
|
||||
}
|
||||
// @Bean
|
||||
// public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) {
|
||||
// RabbitTemplate rabbitTempalte = new RabbitTemplate(connectionFactory);
|
||||
// this.rabbitTemplate = rabbitTempalte;
|
||||
// rabbitTempalte.setMessageConverter(messageConverter());
|
||||
// rabbitTempalte();
|
||||
//
|
||||
// return rabbitTempalte;
|
||||
// }
|
||||
|
||||
/*
|
||||
* @Author: LiuYunHu
|
||||
|
@ -147,10 +147,10 @@ public class RabbitMQConfig implements RabbitTemplate.ConfirmCallback, RabbitTem
|
|||
* @Param: []
|
||||
* @Return: void
|
||||
**/
|
||||
public void rabbitTempalte() {
|
||||
rabbitTemplate.setConfirmCallback(this);
|
||||
rabbitTemplate.setReturnsCallback(this);
|
||||
}
|
||||
// public void rabbitTempalte() {
|
||||
// rabbitTemplate.setConfirmCallback(this);
|
||||
// rabbitTemplate.setReturnsCallback(this);
|
||||
// }
|
||||
|
||||
/*
|
||||
* @Author: LiuYunHu
|
||||
|
@ -188,14 +188,14 @@ public class RabbitMQConfig implements RabbitTemplate.ConfirmCallback, RabbitTem
|
|||
* @Param: ack 消息是否被成功处理
|
||||
* @Param: s 附加信息
|
||||
**/
|
||||
@Override
|
||||
public void confirm(CorrelationData correlationData, boolean ack, String s) {
|
||||
if (ack) {
|
||||
log.info("{}消息到达交换机", correlationData.getId());
|
||||
} else {
|
||||
log.error("{}消息丢失", correlationData.getId());
|
||||
}
|
||||
}
|
||||
// @Override
|
||||
// public void confirm(CorrelationData correlationData, boolean ack, String s) {
|
||||
// if (ack) {
|
||||
// log.info("{}消息到达交换机", correlationData.getId());
|
||||
// } else {
|
||||
// log.error("{}消息丢失", correlationData.getId());
|
||||
// }
|
||||
// }
|
||||
|
||||
/*
|
||||
* @Author: LiuYunHu
|
||||
|
@ -209,4 +209,9 @@ public class RabbitMQConfig implements RabbitTemplate.ConfirmCallback, RabbitTem
|
|||
public void returnedMessage(ReturnedMessage returnedMessage) {
|
||||
log.error("{}消息未到达队列", returnedMessage.getMessage().getMessageProperties().getMessageId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirm(CorrelationData correlationData, boolean b, String s) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
|
@ -23,6 +24,7 @@ spring:
|
|||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
logging:
|
||||
|
@ -33,10 +35,10 @@ logging:
|
|||
mqtt:
|
||||
server:
|
||||
broker: tcp://115.159.47.13:1883
|
||||
# broker: mqtt://115.159.47.13:1883
|
||||
# broker: mqtt://115.159.47.13:1883
|
||||
username:
|
||||
password:
|
||||
clientId: xiaoyao
|
||||
clientId: fluxMq
|
||||
qos: 0
|
||||
topic: xiaoyao
|
||||
topic: test
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.couplet.common.security.annotation.EnableMyFeignClients;
|
|||
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* 系统模块
|
||||
|
@ -15,6 +16,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = {"com.couplet"})
|
||||
public class CoupletSystemApplication {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run(CoupletSystemApplication.class, args);
|
||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
Loading…
Reference in New Issue