优化更新:更新
parent
4b015fc830
commit
f12e4019cd
|
@ -21,17 +21,7 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
<!-- 这个依赖是监听用的-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
<version>2.8.1</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.kafka</groupId>-->
|
||||
<!-- <artifactId>kafka-clients</artifactId>-->
|
||||
<!-- <version>2.8.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
|
@ -116,12 +106,12 @@
|
|||
<artifactId>muyu-common-event</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!--MQ-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-amqp</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!--MQ-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
|
||||
public class MuYuAnalyzeApplication
|
||||
{
|
||||
public static void main(String[] args)
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package com.muyu.analyze.config;
|
||||
|
||||
|
||||
import com.muyu.common.core.constant.*;
|
||||
import org.springframework.amqp.core.*;
|
||||
import org.springframework.context.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 声明队列绑定交换机
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Configuration
|
||||
public class TutConfig {
|
||||
|
||||
@Bean
|
||||
public Queue fault() {
|
||||
return new Queue(MQQueueConstants.ALARM_QUEUE,true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue alarm() {
|
||||
return new Queue(MQQueueConstants.FAULT_QUEUE, true);
|
||||
}
|
||||
}
|
|
@ -1,22 +1,22 @@
|
|||
package com.muyu.analyze.consumer;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.muyu.analyze.mapper.VehicleMapper;
|
||||
import com.muyu.analyze.service.VehicleService;
|
||||
import com.muyu.analyze.utils.AnalyzeUtils;
|
||||
import com.muyu.common.core.utils.SpringUtils;
|
||||
import com.muyu.common.event.cache.VehicleEventCache;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.kafka.annotation.KafkaListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 类说明
|
||||
*
|
||||
|
@ -41,17 +41,21 @@ public class Consumer {
|
|||
*/
|
||||
// @KafkaListener(topics = "test", groupId = "group", properties = {"bootstrap.servers = 10.10.26.4:9092"})
|
||||
@KafkaListener(topics = "test")
|
||||
public void getMessage(String msg) {
|
||||
VehicleData analyze = AnalyzeUtils.analyze(msg);
|
||||
log.info("。。。。。。。。。。。。非静止画面");
|
||||
public void getMessage(String msg) throws JsonProcessingException {
|
||||
|
||||
Set<String> eventList = vehicleEventCache.getEventList(analyze.getVin());
|
||||
//json转对象
|
||||
VehicleData vehicleData = JSON.parseObject(msg, VehicleData.class);
|
||||
|
||||
log.info("。。。。。。。。。。。。非静止画面");
|
||||
|
||||
// List<Fence> fenceVin=vehicleMapper.selectFenceList();
|
||||
|
||||
//工厂加策略模式 获取每辆车的事件集
|
||||
Set<String> eventList = vehicleEventCache.getEventList(vehicleData.getVin());
|
||||
|
||||
for (String s : eventList) {
|
||||
VehicleService vehicleService = SpringUtils.getBean(s);
|
||||
vehicleService.eventResolution(analyze);
|
||||
vehicleService.eventResolution(vehicleData);
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,6 +64,7 @@ public class Consumer {
|
|||
|
||||
|
||||
|
||||
|
||||
// @RabbitHandler
|
||||
// public void take(String msg, Channel channel, Message message) throws IOException {
|
||||
//// String messageId = message.getMessageProperties().getMessageId();
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
//package com.muyu.analyze.consumer;
|
||||
//
|
||||
///**
|
||||
// * @ProjectName: cloud-vehicles
|
||||
// * @PackageName: com.muyu.analyze.consumer
|
||||
// * @Description TODO
|
||||
// * @Author HuangDaJu
|
||||
// * @Date 2024/4/8 21:43
|
||||
// * @Version 1.0
|
||||
// */
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//import com.muyu.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.StringRedisTemplate;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//
|
||||
//
|
||||
//@Component
|
||||
//@RabbitListener(queues = "queue")
|
||||
//@Log4j2
|
||||
//public class RabbitMqConsumer {
|
||||
//
|
||||
//
|
||||
// @Autowired
|
||||
// private RedisService redisService;
|
||||
//
|
||||
// @RabbitHandler
|
||||
// public void take(String msg, Channel channel, Message message) throws IOException {
|
||||
//
|
||||
//
|
||||
// long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||
// System.out.println("MQ消费:"+msg);
|
||||
// channel.basicAck(deliveryTag,false);
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
//}
|
||||
//
|
|
@ -28,4 +28,7 @@ public interface VehicleMapper{
|
|||
Car selectCarList(String vin);
|
||||
|
||||
|
||||
List<String> selectCarMarking(Integer markingId);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.analyze.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
|
||||
|
||||
|
@ -14,7 +15,7 @@ import com.muyu.system.common.domain.VehicleData;
|
|||
*/
|
||||
public interface VehicleService {
|
||||
|
||||
void eventResolution(VehicleData analyze);
|
||||
void eventResolution(VehicleData analyze) throws JsonProcessingException;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
package com.muyu.analyze.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
import com.muyu.analyze.service.VehicleService;
|
||||
import com.muyu.analyze.utils.StateConstant;
|
||||
|
||||
|
||||
import com.muyu.business.domain.FaultLogs;
|
||||
import com.muyu.common.core.constant.MQQueueConstants;
|
||||
import com.muyu.common.core.utils.uuid.IdUtils;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -28,8 +26,14 @@ import java.util.concurrent.TimeUnit;
|
|||
*/
|
||||
@Service("breakdown")
|
||||
@Slf4j
|
||||
|
||||
public class BreakdownImpl implements VehicleService{
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
@ -221,6 +225,27 @@ public class BreakdownImpl implements VehicleService{
|
|||
// 设置过期时间
|
||||
redisService.expire(key, 20, TimeUnit.MINUTES);
|
||||
|
||||
|
||||
|
||||
|
||||
// log.info("功能描述: xx,请求URI:{},请求方式: {},请求参数: {}",
|
||||
// request.getRequestURI(),request.getMethod(),user);
|
||||
// rabbitTemplate.convertAndSend(RabbitMQConfig.delExchange,RabbitMQConfig.routingKey,user,message -> {
|
||||
// message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||
// return message;
|
||||
// },new CorrelationData(UUID.randomUUID().toString()));
|
||||
|
||||
|
||||
rabbitTemplate.convertAndSend(MQQueueConstants.FAULT_QUEUE, faultLogsAddReq, message -> {
|
||||
message.getMessageProperties().setMessageId(IdUtils.fastSimpleUUID());
|
||||
return message;
|
||||
});
|
||||
|
||||
log.info("车辆VIN:"+vehicleData.getVin()+"故障事件已记录");
|
||||
log.info("故障事件结束");
|
||||
|
||||
|
||||
|
||||
log.info("车辆VIN:"+vehicleData.getVin()+"故障事件已记录");
|
||||
log.info("故障事件结束");
|
||||
}else{
|
||||
|
@ -230,5 +255,9 @@ public class BreakdownImpl implements VehicleService{
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
package com.muyu.analyze.service.impl;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.muyu.analyze.mapper.VehicleMapper;
|
||||
import com.muyu.analyze.service.VehicleService;
|
||||
import com.muyu.business.domain.AlarmLogs;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.business.domain.FaultLogs;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.common.core.constant.MQQueueConstants;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.common.core.utils.uuid.IdUtils;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.system.common.domain.Car;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -38,10 +44,11 @@ public class FenceAlarmImpl implements VehicleService {
|
|||
@Autowired
|
||||
private VehicleMapper vehicleMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Override
|
||||
public void eventResolution(VehicleData analyze) {
|
||||
public void eventResolution(VehicleData analyze) throws JsonProcessingException {
|
||||
Fence fence = new Fence();
|
||||
//车的vin
|
||||
String vin = analyze.getVin();
|
||||
|
@ -52,16 +59,95 @@ public class FenceAlarmImpl implements VehicleService {
|
|||
//纬度
|
||||
double pointLat = parseDouble(analyze.getLatitude());
|
||||
|
||||
//这里修改为1对多的 电子围栏 目前是一对一
|
||||
//存set的围栏
|
||||
Map<String, Object> fence1 = redisService.getCacheMap("fence");
|
||||
|
||||
//这里修改为1对多的 电子围栏 目前是一对一
|
||||
Car car =vehicleMapper.selectCarList(vin);
|
||||
|
||||
String carFenceId = car.getCarFenceId();
|
||||
|
||||
//车的标识
|
||||
String carFenceId = car.getCarMarking();
|
||||
String[] split1 = carFenceId.split(",");
|
||||
|
||||
|
||||
Map<String, Object> fence1 = redisService.getCacheMap("fence");
|
||||
//车的查询对应的围栏
|
||||
for (String markingId : split1) {
|
||||
|
||||
List<String> carMarking = vehicleMapper.selectCarMarking(Integer.valueOf(markingId));
|
||||
|
||||
for (String markingFenceIds : carMarking) {
|
||||
|
||||
String[] split = markingFenceIds.split(",");
|
||||
|
||||
|
||||
for (Map.Entry<String, Object> entry : fence1.entrySet()) {
|
||||
for (String s : split) {
|
||||
String key = entry.getKey();
|
||||
if (s.equals(key)){
|
||||
String value = (String) entry.getValue();
|
||||
|
||||
String[] split2 = value.split(";");
|
||||
|
||||
boolean withinFence = isWithinFence(pointLat, pointLng, Arrays.asList(split2));
|
||||
|
||||
if (withinFence){
|
||||
log.info("车辆vin:"+vin+"------在电子围栏"+key+"---正常行驶---");
|
||||
}else {
|
||||
log.info("车辆vin:"+vin+"------驶出电子围栏"+key+"---报警---");
|
||||
|
||||
String key1 = "fenceType1";
|
||||
|
||||
HashSet<Fence> hashSet = new HashSet<>();
|
||||
fence.setCarVin(vin);
|
||||
fence.setFenceType("驶出");
|
||||
fence.setFenceId(Integer.valueOf(key));
|
||||
|
||||
hashSet.add(fence);
|
||||
redisService.setCacheSet(key1,hashSet);
|
||||
redisService.expire(key1, 20, TimeUnit.MINUTES); // 设置过期时间
|
||||
}
|
||||
|
||||
|
||||
FaultLogs faultLogs = new FaultLogs();
|
||||
faultLogs.setCarVin(vin);
|
||||
faultLogs.setFaultCode("WEILAN");
|
||||
faultLogs.setStartAlarmTime(DateUtils.getNowDate());
|
||||
faultLogs.setAlarmFlag("Y");
|
||||
faultLogs.setDisposeStatus("1");
|
||||
|
||||
//对象变json
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String faultLog = objectMapper.writeValueAsString(faultLogs);
|
||||
|
||||
rabbitTemplate.convertAndSend(MQQueueConstants.ALARM_QUEUE, faultLog , message -> {
|
||||
message.getMessageProperties().setMessageId(IdUtils.fastSimpleUUID());
|
||||
return message;
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
System.out.println(carMarking);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -92,21 +178,22 @@ public class FenceAlarmImpl implements VehicleService {
|
|||
redisService.expire(key1, 20, TimeUnit.MINUTES); // 设置过期时间
|
||||
}
|
||||
|
||||
// if (withinFence){
|
||||
// log.info("车辆vin:"+vin+"------驶入禁行区----报警");
|
||||
//
|
||||
// String key1 = "fenceType1";
|
||||
// HashSet<Fence> hashSet = new HashSet<>();
|
||||
// fence.setCarVin(vin);
|
||||
// fence.setFenceType("驶入");
|
||||
// fence.setFenceId(Integer.valueOf(key));
|
||||
// hashSet.add(fence);
|
||||
// redisService.setCacheSet(key1,hashSet);
|
||||
// redisService.expire(key1, 20, TimeUnit.MINUTES); // 设置过期时间
|
||||
//
|
||||
// }else{
|
||||
// log.info("车辆vin:"+vin+"------在安全区");
|
||||
// }
|
||||
|
||||
FaultLogs faultLogs = new FaultLogs();
|
||||
faultLogs.setCarVin(vin);
|
||||
faultLogs.setFaultCode("GTX007");
|
||||
faultLogs.setStartAlarmTime(DateUtils.getNowDate());
|
||||
faultLogs.setAlarmFlag("Y");
|
||||
faultLogs.setDisposeStatus("1");
|
||||
|
||||
|
||||
rabbitTemplate.convertAndSend(MQQueueConstants.ALARM_QUEUE, faultLogs , message -> {
|
||||
message.getMessageProperties().setMessageId(IdUtils.fastSimpleUUID());
|
||||
return message;
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public class StoredEventImpl implements VehicleService {
|
|||
|
||||
@Autowired
|
||||
private VehicleMapper vehicleMapper;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
|
|
|
@ -18,9 +18,14 @@ import java.util.Stack;
|
|||
|
||||
public class AnalyzeUtils {
|
||||
|
||||
public static VehicleData analyze(String aa) {
|
||||
public static VehicleData analyze(String msg) {
|
||||
|
||||
VehicleData vehicleData = new VehicleData();
|
||||
|
||||
|
||||
String aa = msg.substring(1).substring(0, msg.substring(1).length() - 2);
|
||||
|
||||
|
||||
/**
|
||||
* 车辆VIN private String vin;
|
||||
*/
|
||||
|
|
|
@ -3,12 +3,6 @@ server:
|
|||
port: 9008
|
||||
# Spring
|
||||
spring:
|
||||
kafka:
|
||||
bootstrap-servers: 10.10.26.4:9092
|
||||
consumer:
|
||||
group-id: group
|
||||
auto-offset-reset: earliest
|
||||
|
||||
|
||||
application:
|
||||
# 应用名称
|
||||
|
@ -30,3 +24,8 @@ spring:
|
|||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
|
||||
kafka:
|
||||
bootstrap-servers: 10.10.26.4:9092
|
||||
consumer:
|
||||
group-id: group
|
||||
auto-offset-reset: earliest
|
||||
|
|
|
@ -17,6 +17,12 @@
|
|||
select car_vin,fence_encoding,fence_id,fence_type,fence_radius from car left join fence on car.car_fence_id=fence.fence_id
|
||||
</select>
|
||||
<select id="selectCarList" resultType="com.muyu.system.common.domain.Car">
|
||||
select car_fence_id from car where car_vin=#{vin}
|
||||
select car_marking from car where car_vin=#{vin}
|
||||
</select>
|
||||
<select id="selectCarMarking" resultType="java.lang.String">
|
||||
|
||||
select marking_fence_ids from marking where marking_id=#{markingId}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -16,7 +16,12 @@
|
|||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 这个依赖是监听用的-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
<version>2.8.1</version>
|
||||
</dependency>
|
||||
<!-- SpringCloud Openfeign -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.muyu.common.core.constant;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* MQ常量
|
||||
* @author LiYongJie
|
||||
* @date 2024/4/9
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MQQueueConstants {
|
||||
/**
|
||||
* 报警队列
|
||||
*/
|
||||
public static final String ALARM_QUEUE = "alarm";
|
||||
|
||||
/**
|
||||
* 故障队列
|
||||
*/
|
||||
public static final String FAULT_QUEUE = "fault";
|
||||
}
|
|
@ -2,15 +2,14 @@ package com.muyu.common.redis.service;
|
|||
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.BoundSetOperations;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static net.sf.jsqlparser.parser.feature.Feature.setOperation;
|
||||
|
||||
/**
|
||||
* spring redis 工具类
|
||||
*
|
||||
|
@ -174,6 +173,19 @@ public class RedisService
|
|||
}
|
||||
return setOperation;
|
||||
}
|
||||
/**
|
||||
* 缓存zSet
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @param setValue 缓存的数据
|
||||
* @param score 缓存的数据
|
||||
* @return 缓存数据的对象
|
||||
*/
|
||||
public <T> BoundZSetOperations<String, T> setCacheZSet(final String key, final T setValue, double score) {
|
||||
BoundZSetOperations boundZSetOperations = redisTemplate.boundZSetOps(key);
|
||||
boundZSetOperations.add(setValue, score);
|
||||
return boundZSetOperations;
|
||||
}
|
||||
/**
|
||||
* 缓存Set
|
||||
*
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
<?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.muyu</groupId>
|
||||
<artifactId>muyu</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-load-center</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>20</maven.compiler.source>
|
||||
<maven.compiler.target>20</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
<!-- 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>
|
||||
|
||||
<!-- RuoYi Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-file-remote</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-ecs</artifactId>
|
||||
<version>4.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>4.5.10</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
|
||||
</project>
|
|
@ -0,0 +1,73 @@
|
|||
package com.aliyun.sample;
|
||||
|
||||
import com.aliyuncs.DefaultAcsClient;
|
||||
import com.aliyuncs.IAcsClient;
|
||||
import com.aliyuncs.ecs.model.v20140526.CreateInstanceRequest;
|
||||
import com.aliyuncs.ecs.model.v20140526.CreateInstanceResponse;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.aliyuncs.profile.DefaultProfile;
|
||||
|
||||
/**
|
||||
* 阿里云ECS实例创建器示例类。
|
||||
* 本类用于演示如何通过阿里云SDK在Java中创建一个ECS实例。
|
||||
*/
|
||||
public class AliyunEcsInstanceCreator {
|
||||
|
||||
/**
|
||||
* 主函数:创建一个阿里云ECS实例。
|
||||
*
|
||||
* @param args 命令行参数(未使用)
|
||||
*
|
||||
* 注意:本示例中使用的AccessKeyId、AccessKeySecret、regionId、imageId、instanceType等信息为示意,
|
||||
* 实际使用时需要替换为有效的阿里云账号信息。
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// 设置阿里云账号的认证信息
|
||||
String accessKeyId = "LTAI5tANGefs2gi8nsu4AoSZ";
|
||||
String accessKeySecret = "Ut5RaJvvG7dP8hgK82qjdtvyUA6x8g";
|
||||
String regionId = "cn-zhangjiakou"; // 实例所在的地域ID
|
||||
String instanceName = "Test"; // 实例名称
|
||||
String imageId = "m-8vb1u2bhootky8sgg2ft"; // 镜像ID
|
||||
String instanceType = "ecs.t6-c2m1.large"; // 实例规格
|
||||
|
||||
// 初始化阿里云客户端
|
||||
DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
|
||||
IAcsClient client = new DefaultAcsClient(profile);
|
||||
|
||||
// 配置创建实例的请求参数
|
||||
CreateInstanceRequest request = new CreateInstanceRequest();
|
||||
request.setImageId(imageId); // 设置使用的镜像ID
|
||||
request.setInstanceName(instanceName); // 设置实例名称
|
||||
request.setInstanceType(instanceType); // 设置实例规格
|
||||
|
||||
// 配置抢占式实例的属性
|
||||
request.setInstanceChargeType("PostPaid"); // 实例付费类型,此处为按量付费
|
||||
request.setSpotStrategy("SpotWithPriceLimit"); // 抢占式实例的出价策略,设置为有限价格
|
||||
|
||||
|
||||
request.setImageId(imageId); // 设置使用的镜像ID
|
||||
request.setInstanceName(instanceName); // 设置实例名称
|
||||
request.setInstanceType(instanceType); // 设置实例规格
|
||||
|
||||
|
||||
// 配置网络和公网带宽
|
||||
request.setVSwitchId("vpc-8vbbw0obosvd5p5i2y5nq"); // 设置实例所在的子网ID
|
||||
request.setInternetMaxBandwidthOut(5); // 设置公网出带宽上限,单位为Mbps
|
||||
|
||||
|
||||
// 配置抢占式实例的属性
|
||||
request.setInstanceChargeType("PostPaid"); // 实例付费类型,此处为按量付费
|
||||
request.setSpotStrategy("SpotWithPriceLimit"); // 抢占式实例的出价策略,设置为有限价格
|
||||
|
||||
request.setSpotPriceLimit(1F); // 设置抢占式实例的最高每小时价格限制
|
||||
|
||||
|
||||
// 发送创建实例的请求并处理响应
|
||||
try {
|
||||
CreateInstanceResponse response = client.getAcsResponse(request);
|
||||
System.out.println("Instance Created: " + response.getInstanceId());
|
||||
} catch (ClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.muyu.loadCenter;
|
||||
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableRyFeignClients;
|
||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* 系统模块
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class MuYuLoadCenterApplication
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
SpringApplication.run(MuYuLoadCenterApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 负载中心模块启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||
" .-------. ____ __ \n" +
|
||||
" | _ _ \\ \\ \\ / / \n" +
|
||||
" | ( ' ) | \\ _. / ' \n" +
|
||||
" |(_ o _) / _( )_ .' \n" +
|
||||
" | (_,_).' __ ___(_ o _)' \n" +
|
||||
" | |\\ \\ | || |(_,_)' \n" +
|
||||
" | | \\ `' /| `-' / \n" +
|
||||
" | | \\ / \\ / \n" +
|
||||
" ''-' `'-' `-..-' ");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.muyu.loadCenter.Service;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.ip.IpUtils;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu
|
||||
* @Description TODO
|
||||
* @Author HuangDaJu
|
||||
* @Date 2024/4/10 09:01
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("/reg")
|
||||
public class ClientRegController {
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
HashSet<String> tokenSet=new HashSet<>();
|
||||
|
||||
/**
|
||||
* 申请注册
|
||||
* http://muyu。
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/apply-for")
|
||||
public Result applyForRegistration(){
|
||||
//生成令牌
|
||||
String token = UUID.randomUUID().toString().replace("-", "");
|
||||
tokenSet.add(token);
|
||||
log.info("程序生成令牌:{}",token);
|
||||
return Result.success(token);
|
||||
|
||||
}
|
||||
/**
|
||||
* 注册收集节点
|
||||
*/
|
||||
@PostMapping
|
||||
public Result reg(@RequestBody NodeRegReq nodeRegReq){
|
||||
log.info("客户端-[{}] 注册:{}", IpUtils.getIpAddr(request),nodeRegReq);
|
||||
redisService.setCacheZSet("负载key",nodeRegReq.getClientId(),0.0);
|
||||
//基本信息存储
|
||||
redisService.setCacheObject("客户端id","客户端基本信息:ip、端口、负载......");
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/test")
|
||||
public Result test(){
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Result getConnectionOption(@RequestParam("token") String token){
|
||||
//验证token
|
||||
|
||||
// ZSetOperations.TypedTuple key = redisTemplate.opsForZSet().popMin("负载key");
|
||||
|
||||
// String clientId = (String)key.getValue();
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.muyu.loadCenter.Service;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.loadCenter.Service
|
||||
* @Description TODO
|
||||
* @Author HuangDaJu
|
||||
* @Date 2024/4/10 09:16
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class NodeRegReq {
|
||||
|
||||
/**
|
||||
* 客户端ID
|
||||
*/
|
||||
private String clientId;
|
||||
/**
|
||||
* 令牌
|
||||
*/
|
||||
private String token;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.muyu.loadCenter.kafka;
|
||||
|
||||
import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||
import org.apache.kafka.clients.producer.ProducerConfig;
|
||||
import org.apache.kafka.common.serialization.StringDeserializer;
|
||||
import org.apache.kafka.common.serialization.StringSerializer;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
@Configuration
|
||||
@Component
|
||||
public class KafkaConfig {
|
||||
|
||||
// Kafka Bootstrap Servers
|
||||
public static final String BOOTSTRAP_SERVERS = "10.10.26.4:9092";
|
||||
|
||||
// 默认主题
|
||||
public static final String DEFAULT_TOPIC = "test";
|
||||
|
||||
public static final String DEFAULT_KEY = "10001";
|
||||
|
||||
|
||||
public static Properties properties1(){
|
||||
// 1;构建 Properties 对象 存放 kafka 生产者配置信息
|
||||
Properties properties1 = new Properties();
|
||||
// 设置 kafka 连接地址(从配置文件/环境变量获取)
|
||||
properties1.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, KafkaConfig.BOOTSTRAP_SERVERS);
|
||||
// 设置 键值 序列化
|
||||
properties1.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer .class.getName());
|
||||
properties1.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
|
||||
return properties1;
|
||||
}
|
||||
|
||||
|
||||
public static Properties properties2(){
|
||||
Properties properties2 = new Properties();
|
||||
properties2.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "10.10.26.4:9092");
|
||||
properties2.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
|
||||
properties2.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
|
||||
properties2.setProperty(ConsumerConfig.GROUP_ID_CONFIG, "group");
|
||||
|
||||
return properties2;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package com.muyu.loadCenter.mqttx;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class ConversionUtil {
|
||||
|
||||
/**
|
||||
* 字符串转化成为16进制字符串
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
public static String strToSixteen(String s) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int length = s.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
int ch = s.charAt(i);
|
||||
String s4 = Integer.toHexString(ch);
|
||||
sb.append(s4 + " ");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static void main (String[] args) {
|
||||
// String str = "<?xml version=\"1.0\"?>\n" +
|
||||
// "<monitorRoot type=\"param\"><synchronizeSyptom event=\"0\" initial=\"true\"><Action_ECG><Rhythm>Sinus</Rhythm><HR>80</HR><EMD>No Change</EMD><Conduct>0</Conduct></Action_ECG><Action_Osat value=\"94\" isRelativePercent=\"false\"/><Action_BP isRelativePercent=\"false\"><Shrink value=\"120\"/><Stretch value=\"80\"/></Action_BP><Action_Resp breathType=\"Normal\" value=\"14\" isRelativePercent=\"false\"/><Action_etCO2 value=\"34\" isRelativePercent=\"false\"/><Action_Temperature value=\"35.2\"/><Action_CVP value=\"6.0\"/><Action_PAPDia value=\"10\"/><Action_PAPSys value=\"25\"/><Action_WP value=\"9\"/></synchronizeSyptom></monitorRoot>";
|
||||
// String strToSixteen = strToSixteen(str);
|
||||
// System.out.println(str);
|
||||
// System.out.println(str.length());
|
||||
// System.out.println(strToSixteen);
|
||||
// System.out.println(strToSixteen.replace(" ", "").length());
|
||||
|
||||
String hexStr = "7E 76 69 6e 33 39 35 34 64 30 62 32 30 64 32 35 34 31 31 37 31 32 37 32 30 32 36 38 36 32 37 31 31 36 2e 36 37 38 38 39 30 30 33 39 2e 35 32 32 37 39 33 30 37 32 2e 30 30 30 38 2e 36 36 30 30 30 30 30 30 30 35 30 34 30 30 30 33 37 30 30 30 32 33 37 36 37 30 30 30 30 44 33 30 36 30 39 2e 36 30 30 31 30 30 30 30 30 31 34 32 39 34 37 33 32 30 31 30 36 30 30 30 32 35 34 30 30 31 31 37 35 36 30 30 30 36 38 31 39 34 2e 31 38 30 30 30 30 34 37 30 30 30 30 31 33 39 30 30 30 30 35 38 32 30 30 30 34 30 30 30 33 30 30 30 31 37 30 30 30 30 37 38 30 30 30 30 36 30 30 30 30 30 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 d4 7E";
|
||||
String hexStringToString = hexStringToString(hexStr);
|
||||
|
||||
|
||||
System.out.println(hexStringToString);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 16进制转换成为string类型字符串
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
public static String hexStringToString(String s) {
|
||||
if (s == null || s.equals("")) {
|
||||
return null;
|
||||
}
|
||||
s = s.replace(" ", "");
|
||||
byte[] baKeyword = new byte[s.length() / 2];
|
||||
for (int i = 0; i < baKeyword.length; i++) {
|
||||
try {
|
||||
baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
s = new String(baKeyword, StandardCharsets.UTF_8);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
package com.muyu.loadCenter.mqttx;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.muyu.loadCenter.kafka.KafkaConfig;
|
||||
import com.muyu.loadCenter.utils.AnalyzeUtils;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Properties;
|
||||
|
||||
import static com.muyu.loadCenter.mqttx.ConversionUtil.hexStringToString;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.system.mqtt
|
||||
* @Description TODO
|
||||
* @Author XiaoFan
|
||||
* @Date 2024/3/31 19:49
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Component
|
||||
public class MqttSubscriber {
|
||||
//MQTT服务器地址
|
||||
|
||||
private static String broker="tcp://10.10.26.5:1883";
|
||||
//客户端ID,可根据实际情况自定义
|
||||
private static String clientId="mqttx_1c945161";
|
||||
//订阅的主题
|
||||
private static String topic="test";
|
||||
//消息服务质量
|
||||
private static int qos=1;
|
||||
private static Thread daemonThread;
|
||||
|
||||
// @PostConstruct
|
||||
// public void init() {
|
||||
// daemonThread = new Thread(() -> {
|
||||
// sendCode();
|
||||
// });
|
||||
// daemonThread.setDaemon(true);
|
||||
// daemonThread.start();
|
||||
|
||||
|
||||
@Scheduled(cron = "0/1 * * * * * ")
|
||||
// @PostConstruct
|
||||
public void sendCode(){
|
||||
|
||||
//消息持久化方式,这里选择内存持久化
|
||||
MemoryPersistence persistence=new MemoryPersistence();
|
||||
|
||||
try {
|
||||
//创建MQTT客户端实例
|
||||
MqttClient sampleClient = new MqttClient(broker, clientId, persistence);
|
||||
//设置连接选项
|
||||
MqttConnectOptions connOpts = new MqttConnectOptions();
|
||||
connOpts.setCleanSession(true);
|
||||
//打印连接信息
|
||||
System.out.println("Connecting to broker:" +broker);
|
||||
//连接到MQTT代理
|
||||
sampleClient.connect(connOpts);
|
||||
//打印连接成功信息
|
||||
System.out.println("Connected");
|
||||
//打印订阅信息
|
||||
System.out.println("Subscribing to topic:" +topic);
|
||||
//订阅指定主题
|
||||
sampleClient.subscribe(topic,qos);
|
||||
|
||||
//设置消息到打的回调函数
|
||||
sampleClient.setCallback(new MqttCallback() {
|
||||
@Override
|
||||
public void connectionLost(Throwable throwable) {
|
||||
//连接丢失时的处理逻辑
|
||||
System.out.println("Connection lost!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageArrived(String topic, MqttMessage message) throws Exception {
|
||||
String hexString = new String(message.getPayload());
|
||||
|
||||
//数据编译
|
||||
String msg1 = hexStringToString(hexString);
|
||||
|
||||
//切割成对象
|
||||
VehicleData analyze = AnalyzeUtils.analyze(msg1);
|
||||
|
||||
//对象变json
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String msg = objectMapper.writeValueAsString(analyze);
|
||||
|
||||
//接收到消息时的处理逻辑
|
||||
|
||||
Properties properties1 = KafkaConfig.properties1();
|
||||
KafkaProducer<String, String> kafkaProducer = new KafkaProducer<>(properties1);
|
||||
// 3: 发送消息
|
||||
// 封装发送消息对象
|
||||
ProducerRecord<String, String> record = new ProducerRecord<>(KafkaConfig.DEFAULT_TOPIC, KafkaConfig.DEFAULT_KEY, msg);
|
||||
|
||||
// 异步发送并处理结果
|
||||
kafkaProducer.send(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||||
|
||||
System.out.println("我是发送成功后要注册到车辆网关的"+iMqttDeliveryToken.toString());
|
||||
System.out.println("我是发送成功后要注册到车辆网关的"+iMqttDeliveryToken.getMessageId());
|
||||
System.out.println("我是发送成功后要注册到车辆网关的"+iMqttDeliveryToken.getActionCallback());
|
||||
|
||||
|
||||
//消息发送完成后的处理逻辑
|
||||
//在这个示例中不做处理
|
||||
}
|
||||
});
|
||||
|
||||
//循环等待接收消息
|
||||
while (true){
|
||||
Thread.sleep(1000);//每隔一秒检查一次是否有新消息
|
||||
}
|
||||
}catch (MqttException | InterruptedException me){
|
||||
System.out.println("msg"+me.getMessage());
|
||||
System.out.println("loc"+me.getLocalizedMessage());
|
||||
System.out.println("cause"+me.getCause());
|
||||
System.out.println("excep"+me);
|
||||
me.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,324 @@
|
|||
package com.muyu.loadCenter.utils;
|
||||
|
||||
|
||||
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.analyze.config
|
||||
* @Description TODO
|
||||
* @Author HuangDaJu
|
||||
* @Date 2024/4/2 21:33
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
public class AnalyzeUtils {
|
||||
|
||||
public static VehicleData analyze(String msg) {
|
||||
|
||||
VehicleData vehicleData = new VehicleData();
|
||||
|
||||
|
||||
String aa = msg.substring(1).substring(0, msg.substring(1).length() - 2);
|
||||
|
||||
|
||||
/**
|
||||
* 车辆VIN private String vin;
|
||||
*/
|
||||
String vin = aa.substring(0, 17);
|
||||
vehicleData.setVin(vin);
|
||||
|
||||
/**
|
||||
* 毫秒值 private String dateTime;
|
||||
*/
|
||||
String time = aa.substring(17, 30);
|
||||
vehicleData.setDateTime(time);
|
||||
|
||||
/**
|
||||
* 行驶路线 private String drivingRoute;
|
||||
*/
|
||||
|
||||
/**
|
||||
* 经度 private String longitude;
|
||||
*/
|
||||
|
||||
String longitude = aa.substring(30, 41);
|
||||
vehicleData.setLongitude(longitude);
|
||||
|
||||
/**
|
||||
* 纬度 private String latitude;
|
||||
*/
|
||||
|
||||
String latitude = aa.substring(41, 51);
|
||||
vehicleData.setLatitude(latitude);
|
||||
|
||||
/**
|
||||
* 速度 private String speed;
|
||||
*/
|
||||
|
||||
String speed = aa.substring(51, 57);
|
||||
vehicleData.setSpeed(speed);
|
||||
|
||||
/**
|
||||
* 里程 private BigDecimal mileage;
|
||||
*/
|
||||
|
||||
String mileage = aa.substring(57, 68);
|
||||
vehicleData.setMileage(new BigDecimal(mileage));
|
||||
|
||||
/**
|
||||
* 总电压 private String voltage;
|
||||
*/
|
||||
|
||||
String voltage = aa.substring(68, 74);
|
||||
vehicleData.setVoltage(voltage);
|
||||
|
||||
/**
|
||||
* 总电流 private String current;
|
||||
*/
|
||||
|
||||
String current = aa.substring(74, 79);
|
||||
vehicleData.setCurrent(current);
|
||||
|
||||
|
||||
/**
|
||||
* 绝缘电阻 private String resistance;
|
||||
*/
|
||||
String resistance = aa.substring(79, 88);
|
||||
vehicleData.setResistance(resistance);
|
||||
|
||||
/**
|
||||
* 档位 private String gear = "P";
|
||||
*/
|
||||
|
||||
String gear = aa.substring(88, 89);
|
||||
vehicleData.setGear(gear);
|
||||
|
||||
|
||||
/**
|
||||
* 加速踏板行程值 private String accelerationPedal;
|
||||
*/
|
||||
|
||||
String accelerationPedal = aa.substring(89, 91);
|
||||
vehicleData.setAccelerationPedal(accelerationPedal);
|
||||
|
||||
|
||||
/**
|
||||
* 制动踏板行程值 private String brakePedal;
|
||||
*/
|
||||
|
||||
String brakePedal =aa.substring(91,93);
|
||||
vehicleData.setBrakePedal(brakePedal);
|
||||
|
||||
/**
|
||||
* 燃料消耗率 private String fuelConsumptionRate;
|
||||
*/
|
||||
|
||||
String fuelConsumptionRate =aa.substring(93,98);
|
||||
vehicleData.setFuelConsumptionRate(fuelConsumptionRate);
|
||||
|
||||
/**
|
||||
* 电机控制器温度private String motorControllerTemperature;
|
||||
*/
|
||||
|
||||
String motorControllerTemperature =aa.substring(98,104);
|
||||
vehicleData.setMotorControllerTemperature(motorControllerTemperature);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 电机转速 private String motorSpeed;
|
||||
*/
|
||||
|
||||
String motorSpeed =aa.substring(104,109);
|
||||
vehicleData.setMotorSpeed(motorSpeed);
|
||||
|
||||
|
||||
/**
|
||||
* 电机转矩 private String motorTorque;
|
||||
*/
|
||||
String motorTorque = aa.substring(109, 113);
|
||||
vehicleData.setMotorTorque(motorTorque);
|
||||
|
||||
/**
|
||||
* 电机温度 private String motorTemperature;
|
||||
*/
|
||||
String motorTemperature = aa.substring(113, 119);
|
||||
vehicleData.setMotorTemperature(motorTemperature);
|
||||
|
||||
/**
|
||||
* 电机电压 private String motorVoltage;
|
||||
*/
|
||||
|
||||
String motorVoltage = aa.substring(119, 124);
|
||||
vehicleData.setMotorVoltage(motorVoltage);
|
||||
|
||||
/**
|
||||
* 电机电流private String motorCurrent;
|
||||
*/
|
||||
|
||||
|
||||
// 电机电流: 10446000
|
||||
String motorCurrent = aa.substring(124, 132);
|
||||
vehicleData.setMotorCurrent(motorCurrent);
|
||||
|
||||
// 动力电池剩余电量 SOC: 44103.
|
||||
/**
|
||||
* 动力电池剩余电量SOC private BigDecimal remainingBattery;
|
||||
*/
|
||||
|
||||
String remainingBattery = aa.substring(132, 138);
|
||||
vehicleData.setRemainingBattery(remainingBattery);
|
||||
|
||||
|
||||
// 当前状态允许的最大反馈功率: 400000
|
||||
/**
|
||||
* 当前状态允许的最大反馈功率private String maximumFeedbackPower;
|
||||
*/
|
||||
String maximumFeedbackPower = aa.substring(138, 144);
|
||||
vehicleData.setMaximumFeedbackPower(maximumFeedbackPower);
|
||||
|
||||
|
||||
// 当前状态允许最大放电功率: 130000
|
||||
/**
|
||||
* 当前状态允许最大放电功率 private String maximumDischargePower;
|
||||
*/
|
||||
|
||||
String maximumDischargePower = aa.substring(144, 150);
|
||||
vehicleData.setMaximumDischargePower(maximumDischargePower);
|
||||
|
||||
|
||||
// BMS 自检计数器: 20
|
||||
/**
|
||||
* BMS自检计数器private String selfCheckCounter;
|
||||
*/
|
||||
|
||||
String selfCheckCounter = aa.substring(150, 152);
|
||||
vehicleData.setSelfCheckCounter(selfCheckCounter);
|
||||
// 动力电池充放电电流: 00000
|
||||
/**
|
||||
* 动力电池充放电电流 private String totalBatteryCurrent;
|
||||
*/
|
||||
String totalBatteryCurrent = aa.substring(152, 157);
|
||||
vehicleData.setTotalBatteryCurrent(totalBatteryCurrent);
|
||||
|
||||
|
||||
// 动力电池负载端总电压 V3: 605000
|
||||
/**
|
||||
* 动力电池负载端总电压V3 private String totalBatteryVoltage;
|
||||
*/
|
||||
String totalBatteryVoltage = aa.substring(157, 163);
|
||||
vehicleData.setTotalBatteryVoltage(totalBatteryVoltage);
|
||||
|
||||
// 单次最大电压: 4000
|
||||
/**
|
||||
* 单次最大电压 private String singleBatteryMaxVoltage;
|
||||
*/
|
||||
|
||||
String singleBatteryMaxVoltage = aa.substring(163, 167);
|
||||
vehicleData.setSingleBatteryMaxVoltage(singleBatteryMaxVoltage);
|
||||
|
||||
// 单体电池最低电压: 3000
|
||||
/**
|
||||
* 单体电池最低电压 private String singleBatteryMinVoltage;
|
||||
*/
|
||||
|
||||
String singleBatteryMinVoltage = aa.substring(167, 171);
|
||||
vehicleData.setSingleBatteryMinVoltage(singleBatteryMinVoltage);
|
||||
|
||||
// 单体电池最高温度: 650000
|
||||
/**
|
||||
* 单体电池最高温度 private String singleBatteryMaxTemperature;
|
||||
*/
|
||||
String singleBatteryMaxTemperature = aa.substring(171, 177);
|
||||
vehicleData.setSingleBatteryMaxTemperature(singleBatteryMaxTemperature);
|
||||
|
||||
// 单体电池最低温度: 600000
|
||||
/**
|
||||
* 单体电池最低温度 private String singleBatteryMinTemperature;
|
||||
*/
|
||||
String singleBatteryMinTemperature = aa.substring(177, 183);
|
||||
vehicleData.setSingleBatteryMinTemperature(singleBatteryMinTemperature);
|
||||
|
||||
// 动力电池可用容量: 530000
|
||||
/**
|
||||
* 动力电池可用容量 private String availableBatteryCapacity;
|
||||
*/
|
||||
String availableBatteryCapacity = aa.substring(183, 189);
|
||||
vehicleData.setAvailableBatteryCapacity(availableBatteryCapacity);
|
||||
|
||||
|
||||
|
||||
// 车辆状态: 0
|
||||
String vehicleStatus = aa.substring(189, 190);
|
||||
vehicleData.setVehicleStatus(Integer.parseInt(vehicleStatus));
|
||||
|
||||
// 充电状态: 1
|
||||
String chargingStatus = aa.substring(190, 191);
|
||||
vehicleData.setChargingStatus(Integer.parseInt(chargingStatus));
|
||||
// 运行状态: 1
|
||||
String operatingStatus = aa.substring(191, 192);
|
||||
vehicleData.setOperatingStatus(Integer.parseInt(operatingStatus));
|
||||
|
||||
// SOC: 1
|
||||
String socStatus = aa.substring(192, 193);
|
||||
vehicleData.setSocStatus(Integer.parseInt(socStatus));
|
||||
|
||||
// 可充电储能装置工作状态: 0
|
||||
String chargingEnergyStorageStatus = aa.substring(193, 194);
|
||||
vehicleData.setChargingEnergyStorageStatus(Integer.parseInt(chargingEnergyStorageStatus));
|
||||
|
||||
// 驱动电机状态: 1
|
||||
String driveMotorStatus = aa.substring(194, 195);
|
||||
vehicleData.setDriveMotorStatus(Integer.parseInt(driveMotorStatus));
|
||||
|
||||
// 定位是否有效: 1
|
||||
String positionStatus = aa.substring(195, 196);
|
||||
vehicleData.setPositionStatus(Integer.parseInt(positionStatus));
|
||||
|
||||
// EAS: 1
|
||||
String easStatus = aa.substring(196, 197);
|
||||
vehicleData.setEasStatus(Integer.parseInt(easStatus));
|
||||
|
||||
// PTC: 1
|
||||
String ptcStatus = aa.substring(197, 198);
|
||||
vehicleData.setPtcStatus(Integer.parseInt(ptcStatus));
|
||||
|
||||
// EPS: 1
|
||||
String epsStatus = aa.substring(198, 199);
|
||||
vehicleData.setEpsStatus(Integer.parseInt(epsStatus));
|
||||
|
||||
// ABS: 1
|
||||
String absStatus = aa.substring(199, 200);
|
||||
vehicleData.setAbsStatus(Integer.parseInt(absStatus));
|
||||
|
||||
// MCU: 1
|
||||
String mcuStatus = aa.substring(200, 201);
|
||||
vehicleData.setMcuStatus(Integer.parseInt(mcuStatus));
|
||||
|
||||
// 动力电池加热状态: 1
|
||||
String heatingStatus = aa.substring(201, 202);
|
||||
vehicleData.setHeatingStatus(Integer.parseInt(heatingStatus));
|
||||
|
||||
// 动力电池当前状态: 1
|
||||
String batteryStatus = aa.substring(202, 203);
|
||||
vehicleData.setBatteryStatus(Integer.parseInt(batteryStatus));
|
||||
|
||||
// 动力电池保温状态: 1
|
||||
String batteryInsulationStatus = aa.substring(203, 204);
|
||||
vehicleData.setBatteryInsulationStatus(Integer.parseInt(batteryInsulationStatus));
|
||||
|
||||
// DCDC: 1
|
||||
String dcdcStatus = aa.substring(204, 205);
|
||||
vehicleData.setDcdcStatus(Integer.parseInt(dcdcStatus));
|
||||
|
||||
// CHG: 1
|
||||
String chgStatus = aa.substring(205, 206);
|
||||
vehicleData.setChgStatus(Integer.parseInt(chgStatus));
|
||||
|
||||
return vehicleData;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9009
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-load-center
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.26.1:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.26.1:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
|
|
@ -1,18 +1,22 @@
|
|||
package com.muyu.business.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import io.swagger.annotations.*;
|
||||
import lombok.*;
|
||||
import lombok.experimental.*;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.format.annotation.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.business.domain.req.AlarmLogsAddReq;
|
||||
import com.muyu.business.domain.req.AlarmLogsUpdReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 报警记录对象
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.*;
|
|||
@ApiModel("故障日志对象")
|
||||
@TableName("fault_logs")
|
||||
public class FaultLogs implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 故障日志主键*/
|
||||
|
|
|
@ -85,6 +85,11 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-file-remote</artifactId>
|
||||
</dependency>
|
||||
<!--MQ-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -1,21 +1,31 @@
|
|||
package com.muyu.business.controller;
|
||||
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.muyu.business.domain.res.*;
|
||||
import com.muyu.business.service.*;
|
||||
import com.muyu.common.core.domain.*;
|
||||
import com.muyu.common.core.web.controller.*;
|
||||
import com.muyu.common.core.web.page.*;
|
||||
import com.muyu.common.log.annotation.*;
|
||||
import com.muyu.common.log.enums.*;
|
||||
import com.muyu.common.security.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import com.muyu.business.domain.AlarmLogs;
|
||||
import com.muyu.business.domain.req.AlarmLogsReq;
|
||||
import com.muyu.business.domain.req.AlarmLogsUpdReq;
|
||||
import com.muyu.business.domain.res.AlarmLogsResponse;
|
||||
import com.muyu.business.service.AlarmLogsService;
|
||||
import com.muyu.common.core.constant.MQQueueConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
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.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 报警日志Controller
|
||||
|
@ -25,6 +35,7 @@ import java.util.*;
|
|||
@Api(tags = "报警日志")
|
||||
@ApiModel(description = "报警日志Controller")
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("/alarmLogs")
|
||||
public class AlarmLogsController extends BaseController {
|
||||
|
||||
|
@ -33,6 +44,9 @@ public class AlarmLogsController extends BaseController {
|
|||
*/
|
||||
@Autowired
|
||||
private AlarmLogsService alarmLogsService;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
|
||||
/**
|
||||
* 实时报警日志列表
|
||||
|
@ -42,20 +56,20 @@ public class AlarmLogsController extends BaseController {
|
|||
@GetMapping("/list")
|
||||
public Result<TableDataInfo> realtime(AlarmLogsReq alarmLogsReq) {
|
||||
startPage();
|
||||
List<AlarmLogs> list = alarmLogsService.selectAlarmLogsList(alarmLogsReq);
|
||||
List<AlarmLogsResponse> list = alarmLogsService.selectAlarmLogsList(alarmLogsReq);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增报警日志
|
||||
*/
|
||||
@ApiOperation("新增报警日志")
|
||||
@RequiresPermissions("business:alarmLogs:add")
|
||||
@Log(title = "报警日志", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result add(@RequestBody AlarmLogsAddReq alarmLogsAddReq) {
|
||||
return toAjax(alarmLogsService.insertAlarmLogs(AlarmLogs.alarmLogsAddReq(alarmLogsAddReq)));
|
||||
}
|
||||
// @ApiOperation("新增报警日志")
|
||||
//// @RequiresPermissions("business:alarmLogs:add")
|
||||
//// @Log(title = "报警日志", businessType = BusinessType.INSERT)
|
||||
// @PostMapping
|
||||
// public Result add(@RequestBody AlarmLogsAddReq alarmLogsAddReq) {
|
||||
// return toAjax(alarmLogsService.insertAlarmLogs(AlarmLogs.alarmLogsAddReq(alarmLogsAddReq)));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取报警日志详细信息
|
||||
|
@ -88,8 +102,41 @@ public class AlarmLogsController extends BaseController {
|
|||
public Result remove(@PathVariable Long[] alarmIds) {
|
||||
return toAjax(alarmLogsService.deleteAlarmLogsByIds(alarmIds));
|
||||
}
|
||||
@Scheduled(cron = "0/10 * * * * ?")
|
||||
public void alarmLogsService(){
|
||||
alarmLogsService.alarmLogsService();
|
||||
|
||||
|
||||
|
||||
|
||||
@RabbitListener(queuesToDeclare = {@Queue(value = MQQueueConstants.ALARM_QUEUE, declare = "true")})
|
||||
public void sendSms(String alarmLog, Message message, Channel channel) {
|
||||
log.info("消息队列:【{}】,收到报警日志:【{}】",MQQueueConstants.ALARM_QUEUE,alarmLog);
|
||||
try {
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
Long count = redisTemplate.opsForSet().add(MQQueueConstants.ALARM_QUEUE, messageId);
|
||||
if (count.intValue() > 0){
|
||||
alarmLogsService.alarmLogsService(alarmLog);
|
||||
// 消息确认
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||
log.info("消息队列:【{}】,收到报警日志:【{}】,消费成功...",MQQueueConstants.ALARM_QUEUE,alarmLog);
|
||||
}else {
|
||||
log.error("消息队列:【{}】,收到报警日志:【{}】,消费重复...",MQQueueConstants.ALARM_QUEUE,alarmLog);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("消息队列:【{}】,收到报警日志:【{}】,消费异常:【{}】",MQQueueConstants.ALARM_QUEUE,alarmLog,e.getMessage());
|
||||
// 消息回退
|
||||
try {
|
||||
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
|
||||
} catch (IOException ex) {
|
||||
log.error("消息队列:【{}】,收到报警日志:【{}】,消息退回异常:【{}】",MQQueueConstants.ALARM_QUEUE,alarmLog,e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
package com.muyu.business.controller;
|
||||
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.muyu.business.service.*;
|
||||
import com.muyu.common.core.domain.*;
|
||||
import com.muyu.common.core.web.controller.*;
|
||||
import com.muyu.common.core.web.page.*;
|
||||
import com.muyu.common.log.annotation.*;
|
||||
import com.muyu.common.log.enums.*;
|
||||
import com.muyu.common.security.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import org.springframework.validation.annotation.*;
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
import com.muyu.business.domain.req.FaultCodeReq;
|
||||
import com.muyu.business.domain.req.FaultCodesAddReq;
|
||||
import com.muyu.business.domain.req.FaultCodesUpdReq;
|
||||
import com.muyu.business.service.FaultCodesService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 故障码Controller
|
||||
|
|
|
@ -1,22 +1,35 @@
|
|||
package com.muyu.business.controller;
|
||||
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.muyu.business.domain.res.*;
|
||||
import com.muyu.business.service.*;
|
||||
import com.muyu.common.core.domain.*;
|
||||
import com.muyu.common.core.web.controller.*;
|
||||
import com.muyu.common.core.web.page.*;
|
||||
import com.muyu.common.log.annotation.*;
|
||||
import com.muyu.common.log.enums.*;
|
||||
import com.muyu.common.security.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.validation.annotation.*;
|
||||
import com.muyu.business.domain.FaultLogs;
|
||||
import com.muyu.business.domain.req.FaultLogsAddReq;
|
||||
import com.muyu.business.domain.req.FaultLogsReq;
|
||||
import com.muyu.business.domain.req.FaultLogsUpdReq;
|
||||
import com.muyu.business.domain.res.FaultLogsResponse;
|
||||
import com.muyu.business.service.AlarmLogsService;
|
||||
import com.muyu.business.service.FaultLogsService;
|
||||
import com.muyu.common.core.constant.MQQueueConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.Message;
|
||||
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.StringRedisTemplate;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 故障码日志Controller
|
||||
|
@ -25,6 +38,7 @@ import java.util.*;
|
|||
* @Date 2024/3/30
|
||||
*/
|
||||
@Api(tags = "故障日志管理")
|
||||
@Slf4j
|
||||
@ApiModel(description = "故障日志Controller")
|
||||
@RestController
|
||||
@RequestMapping("/faultLogs")
|
||||
|
@ -35,6 +49,19 @@ public class FaultLogsController extends BaseController {
|
|||
*/
|
||||
@Autowired
|
||||
private FaultLogsService faultLogsService;
|
||||
/**
|
||||
* 注入redis工具类
|
||||
*/
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
/**
|
||||
* 注入报警日志服务
|
||||
*/
|
||||
@Autowired
|
||||
private AlarmLogsService alarmLogsService;
|
||||
|
||||
|
||||
|
||||
@ApiOperation("故障日志列表")
|
||||
@RequiresPermissions("business:faultLogs:list")
|
||||
|
@ -49,7 +76,7 @@ public class FaultLogsController extends BaseController {
|
|||
* 新增故障日志
|
||||
*/
|
||||
@ApiOperation("新增故障日志")
|
||||
@RequiresPermissions("business:faultLogs:add")
|
||||
// @RequiresPermissions("business:faultLogs:add")
|
||||
@Log(title = "故障日志", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result add(@RequestBody @Validated FaultLogsAddReq faultLogsAddReq) {
|
||||
|
@ -59,12 +86,12 @@ public class FaultLogsController extends BaseController {
|
|||
/**
|
||||
* 故障日志详情
|
||||
*/
|
||||
@ApiOperation(value = "故障日志详情",hidden = true)
|
||||
@RequiresPermissions("business:faultLogs:query")
|
||||
@GetMapping("/{logId}")
|
||||
public Result detail(@ApiParam(value = "故障日志主键") @PathVariable("logId") Long logId) {
|
||||
return Result.success(faultLogsService.selectFaultLogsById(logId));
|
||||
}
|
||||
// @ApiOperation(value = "故障日志详情",hidden = true)
|
||||
// @RequiresPermissions("business:faultLogs:query")
|
||||
// @GetMapping("/{logId}")
|
||||
// public Result detail(@ApiParam(value = "故障日志主键") @PathVariable("logId") Long logId) {
|
||||
// return Result.success(faultLogsService.selectFaultLogsById(logId));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 修改故障日志
|
||||
|
@ -88,8 +115,29 @@ public class FaultLogsController extends BaseController {
|
|||
return toAjax(faultLogsService.deleteFaultLogsByIds(logIds));
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0/10 * * * * * ")
|
||||
public void faultLogsService() {
|
||||
faultLogsService.faultLogsService();
|
||||
@RabbitListener(queuesToDeclare = {@Queue(value = MQQueueConstants.FAULT_QUEUE, declare = "true")})
|
||||
public void sendSms(FaultLogs faultLogs, Message message, Channel channel) {
|
||||
log.info("消息队列:【{}】,收到故障日志:【{}】",MQQueueConstants.FAULT_QUEUE,faultLogs);
|
||||
try {
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
Long count = redisTemplate.opsForSet().add(MQQueueConstants.FAULT_QUEUE, messageId);
|
||||
if (count.intValue() > 0){
|
||||
faultLogsService.insertFaultLogs(faultLogs);
|
||||
// 消息确认
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||
log.info("消息队列:【{}】,收到故障日志:【{}】,消费成功...",MQQueueConstants.FAULT_QUEUE,faultLogs);
|
||||
}else {
|
||||
log.error("消息队列:【{}】,收到故障日志:【{}】,消费重复...",MQQueueConstants.FAULT_QUEUE,faultLogs);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("消息队列:【{}】,收到故障日志:【{}】,消费异常:【{}】",MQQueueConstants.FAULT_QUEUE,faultLogs,e.getMessage());
|
||||
// 消息回退
|
||||
try {
|
||||
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
|
||||
} catch (IOException ex) {
|
||||
log.error("消息队列:【{}】,收到故障日志:【{}】,消息退回异常:【{}】",MQQueueConstants.FAULT_QUEUE,faultLogs,e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.muyu.business.controller;
|
||||
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.business.domain.request.FenceAddRequest;
|
||||
import com.muyu.business.domain.request.FenceListRequest;
|
||||
import com.muyu.business.domain.request.FenceUpdateRequest;
|
||||
import com.muyu.business.domain.request.MapRequest;
|
||||
|
||||
import com.muyu.business.service.IFenceInfoService;
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
@ -12,7 +12,6 @@ import com.muyu.common.core.web.controller.BaseController;
|
|||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
|
@ -2,17 +2,19 @@ package com.muyu.business.controller;
|
|||
|
||||
import com.muyu.business.domain.Records;
|
||||
import com.muyu.business.domain.request.RecordsListRequest;
|
||||
|
||||
import com.muyu.business.service.IRecordsService;
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 车辆历史轨迹Controller
|
||||
*
|
||||
|
@ -25,6 +27,9 @@ public class RecordsController extends BaseController
|
|||
{
|
||||
@Autowired
|
||||
private IRecordsService recordsService;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询车辆历史轨迹列表
|
||||
|
@ -53,10 +58,15 @@ public class RecordsController extends BaseController
|
|||
return Result.success(recordsService.insert(vin));
|
||||
}
|
||||
|
||||
@PostMapping("/update/{recordsId}")
|
||||
@PostMapping("/update/{vin}")
|
||||
@Log(title = "车辆历史轨迹", businessType = BusinessType.UPDATE)
|
||||
public Result update(@PathVariable("recordsId") Integer recordsId) {
|
||||
return toAjax(recordsService.updateRecords(recordsId));
|
||||
public Result update(@PathVariable("vin") String vin) {
|
||||
Set<Object> cacheSet = redisService.getCacheSet("records:info:" + vin);
|
||||
Integer recordsId = (Integer) cacheSet.toArray()[0];
|
||||
Result ajax = toAjax(recordsService.updateRecords(recordsId));
|
||||
redisService.deleteObject("records:info:" + vin);
|
||||
|
||||
return ajax;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.muyu.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.*;
|
||||
import com.baomidou.mybatisplus.core.mapper.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.business.domain.AlarmLogs;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.business.domain.res.AlarmLogsResponse;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 报警日志Mapper接口
|
||||
|
@ -20,10 +21,12 @@ public interface AlarmLogsMapper extends BaseMapper<AlarmLogs> {
|
|||
* @param wrapper 查询条件
|
||||
* @return 报警日志集合
|
||||
*/
|
||||
List<AlarmLogs> selectAlarmLogsList(LambdaQueryWrapper<AlarmLogs> wrapper);
|
||||
List<AlarmLogsResponse> selectAlarmLogsList(LambdaQueryWrapper<AlarmLogs> wrapper);
|
||||
|
||||
void alarmLogsService(Fence fence);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.muyu.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
|
||||
/**
|
||||
* 故障码Mapper接口
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package com.muyu.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.*;
|
||||
import com.baomidou.mybatisplus.core.mapper.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
import com.muyu.business.domain.FaultLogs;
|
||||
import com.muyu.business.domain.req.FaultLogsAddReq;
|
||||
import com.muyu.business.domain.res.*;
|
||||
import com.muyu.business.domain.res.FaultLogsResponse;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 故障日志Mapper接口
|
||||
|
@ -26,4 +27,11 @@ public interface FaultLogsMapper extends BaseMapper<FaultLogs> {
|
|||
void FaultLogsService(FaultLogsAddReq faultLogsAddReq);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
FaultCodeInfo selectFaultCode(String faultCode);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package com.muyu.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.business.domain.AlarmLogs;
|
||||
import com.muyu.business.domain.req.AlarmLogsReq;
|
||||
import com.muyu.business.domain.res.AlarmLogsResponse;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 报警日志Service接口
|
||||
|
@ -19,7 +20,7 @@ public interface AlarmLogsService extends IService<AlarmLogs> {
|
|||
* @param alarmLogsReq 报警日志
|
||||
* @return 报警日志
|
||||
*/
|
||||
List<AlarmLogs> selectAlarmLogsList(AlarmLogsReq alarmLogsReq);
|
||||
List<AlarmLogsResponse> selectAlarmLogsList(AlarmLogsReq alarmLogsReq);
|
||||
|
||||
/**
|
||||
* 新增报警日志
|
||||
|
@ -27,7 +28,7 @@ public interface AlarmLogsService extends IService<AlarmLogs> {
|
|||
* @param alarmLogs 报警日志
|
||||
* @return 结果
|
||||
*/
|
||||
int insertAlarmLogs(AlarmLogs alarmLogs);
|
||||
// int insertAlarmLogs(AlarmLogs alarmLogs);
|
||||
|
||||
/**
|
||||
* 报警日志详情
|
||||
|
@ -60,7 +61,9 @@ public interface AlarmLogsService extends IService<AlarmLogs> {
|
|||
*/
|
||||
int deleteAlarmLogsByIds(Long[] alarmIds);
|
||||
|
||||
void alarmLogsService();
|
||||
|
||||
void alarmLogsService(String alarmLog);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.muyu.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
import com.muyu.business.domain.req.FaultCodeReq;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 故障码Service接口
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.muyu.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.muyu.business.domain.res.*;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
import com.muyu.business.domain.FaultLogs;
|
||||
import com.muyu.business.domain.req.FaultLogsReq;
|
||||
import com.muyu.business.domain.res.FaultLogsResponse;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 故障日志Service接口
|
||||
|
@ -36,7 +37,7 @@ public interface FaultLogsService extends IService<FaultLogs> {
|
|||
* @param logId
|
||||
* @return
|
||||
*/
|
||||
FaultLogs selectFaultLogsById(Long logId);
|
||||
|
||||
|
||||
/**
|
||||
* 编辑故障日志
|
||||
|
@ -65,5 +66,8 @@ public interface FaultLogsService extends IService<FaultLogs> {
|
|||
void faultLogsService();
|
||||
|
||||
|
||||
FaultCodeInfo selectFaultLogsById(String faultCode);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package com.muyu.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.business.domain.request.FenceListRequest;
|
||||
import com.muyu.business.domain.request.MapRequest;
|
||||
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.business.domain.Fence;
|
||||
|
||||
/**
|
||||
* 电子围栏Service接口
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.muyu.business.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.business.domain.Records;
|
||||
import com.muyu.business.domain.request.RecordsListRequest;
|
||||
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@ package com.muyu.business.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.business.domain.Vehicle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @className: VehicleDataService
|
||||
* @author: YinYuYang
|
||||
|
|
|
@ -1,18 +1,24 @@
|
|||
package com.muyu.business.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.*;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.muyu.business.mapper.*;
|
||||
import com.muyu.business.service.*;
|
||||
import com.muyu.common.core.utils.*;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.business.domain.AlarmLogs;
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
import com.muyu.business.domain.req.AlarmLogsReq;
|
||||
import com.muyu.business.domain.res.AlarmLogsResponse;
|
||||
import com.muyu.business.mapper.AlarmLogsMapper;
|
||||
import com.muyu.business.service.AlarmLogsService;
|
||||
import com.muyu.business.service.FaultLogsService;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import org.springframework.stereotype.*;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 报警日志Service业务层处理
|
||||
|
@ -31,11 +37,26 @@ public class AlarmLogsServiceImpl extends ServiceImpl<AlarmLogsMapper, AlarmLogs
|
|||
@Autowired
|
||||
private AlarmLogsMapper alarmLogsMapper;
|
||||
|
||||
/**
|
||||
* 注入fault接口
|
||||
*/
|
||||
@Autowired
|
||||
private FaultLogsService faultLogsService;
|
||||
|
||||
/**
|
||||
* 注入redis工具类
|
||||
*/
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 注入rabbitmq
|
||||
*/
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Override
|
||||
public List<AlarmLogs> selectAlarmLogsList(AlarmLogsReq alarmLogsReq) {
|
||||
public List<AlarmLogsResponse> selectAlarmLogsList(AlarmLogsReq alarmLogsReq) {
|
||||
LambdaQueryWrapper<AlarmLogs> wrapper = new LambdaQueryWrapper<>();
|
||||
// wrapper.like(StringUtils.isNotEmpty(alarmLogsReq.getCarVin()),AlarmLogs::getCarVin, alarmLogsReq.getCarVin());
|
||||
// wrapper.like(StringUtils.isNotEmpty(alarmLogsReq.getFaultCode()),AlarmLogs::getFaultCode, alarmLogsReq.getFaultCode());
|
||||
|
@ -47,10 +68,16 @@ public class AlarmLogsServiceImpl extends ServiceImpl<AlarmLogsMapper, AlarmLogs
|
|||
return alarmLogsMapper.selectAlarmLogsList(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertAlarmLogs(AlarmLogs alarmLogs) {
|
||||
return alarmLogsMapper.insert(alarmLogs);
|
||||
}
|
||||
// @Override
|
||||
// public int insertAlarmLogs(AlarmLogs alarmLogs) {
|
||||
//
|
||||
//
|
||||
// rabbitTemplate.convertAndSend(MQQueueConstants.ALARM_QUEUE, alarmLogs, message -> {
|
||||
// message.getMessageProperties().setMessageId(IdUtils.fastSimpleUUID());
|
||||
// return message;
|
||||
// });
|
||||
// return alarmLogsMapper.insert(alarmLogs);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public AlarmLogs selectAlarmLogsById(Integer alarmId) {
|
||||
|
@ -73,20 +100,30 @@ public class AlarmLogsServiceImpl extends ServiceImpl<AlarmLogsMapper, AlarmLogs
|
|||
}
|
||||
|
||||
@Override
|
||||
public void alarmLogsService() {
|
||||
// String key = "fenceType1";
|
||||
// Set<Object> cacheSet = redisService.getCacheSet(key);
|
||||
// for (Object o : cacheSet) {
|
||||
// Fence fence = JSON.parseObject((String) o, Fence.class);
|
||||
//
|
||||
//
|
||||
// //报警逻辑处理 处理完毕存放入数据库
|
||||
//
|
||||
//
|
||||
// alarmLogsMapper.alarmLogsService(fence);
|
||||
// }
|
||||
public void alarmLogsService(String alarmLog) {
|
||||
|
||||
AlarmLogs alarmLogs = JSON.parseObject(alarmLog, AlarmLogs.class);
|
||||
|
||||
|
||||
//json转对象
|
||||
FaultCodeInfo faultLogs = faultLogsService.selectFaultLogsById(alarmLogs.getFaultCode());
|
||||
|
||||
switch (faultLogs.getFaultLevel()){
|
||||
case 1:
|
||||
log.info("发送短信");
|
||||
alarmLogsMapper.insert(alarmLogs);
|
||||
case 2:
|
||||
log.info("发邮件");
|
||||
alarmLogsMapper.insert(alarmLogs);
|
||||
|
||||
default:
|
||||
|
||||
alarmLogsMapper.insert(alarmLogs);
|
||||
}
|
||||
log.info("报警日志");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
package com.muyu.business.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.*;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.muyu.business.mapper.*;
|
||||
import com.muyu.business.service.*;
|
||||
import com.muyu.common.core.utils.*;
|
||||
import com.muyu.common.security.utils.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import org.springframework.stereotype.*;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
import com.muyu.business.domain.req.FaultCodeReq;
|
||||
import com.muyu.business.mapper.FaultCodesMapper;
|
||||
import com.muyu.business.service.FaultCodesService;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 故障码Service业务层处理
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
package com.muyu.business.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.*;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.muyu.business.domain.res.*;
|
||||
import com.muyu.business.mapper.*;
|
||||
import com.muyu.business.service.*;
|
||||
import com.muyu.common.core.utils.*;
|
||||
import lombok.extern.slf4j.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import org.springframework.stereotype.*;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
import com.muyu.business.domain.FaultLogs;
|
||||
import com.muyu.business.domain.req.FaultCodeReq;
|
||||
import com.muyu.business.domain.req.FaultCodesUpdReq;
|
||||
import com.muyu.business.domain.req.FaultLogsReq;
|
||||
import com.muyu.business.domain.res.FaultLogsResponse;
|
||||
import com.muyu.business.mapper.FaultLogsMapper;
|
||||
import com.muyu.business.service.FaultCodesService;
|
||||
import com.muyu.business.service.FaultLogsService;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 故障日志Service业务层处理
|
||||
|
@ -68,10 +73,7 @@ public class FaultLogsServiceImpl extends ServiceImpl<FaultLogsMapper, FaultLogs
|
|||
return faultLogsMapper.insert(faultLogs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaultLogs selectFaultLogsById(Long logId) {
|
||||
return faultLogsMapper.selectById(logId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int updateFaultLogs(FaultLogs faultLogs) {
|
||||
|
@ -106,4 +108,9 @@ public class FaultLogsServiceImpl extends ServiceImpl<FaultLogsMapper, FaultLogs
|
|||
log.info("添加了故障日志数据库");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaultCodeInfo selectFaultLogsById(String faultCode) {
|
||||
return faultLogsMapper.selectFaultCode(faultCode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,23 +5,20 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.business.domain.request.FenceListRequest;
|
||||
import com.muyu.business.domain.request.MapRequest;
|
||||
|
||||
import com.muyu.business.mapper.FenceInfoMapper;
|
||||
import com.muyu.business.service.IFenceInfoService;
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.utils.uuid.IdUtils;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.cache.CacheProperties;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,12 +7,12 @@ import com.github.pagehelper.PageHelper;
|
|||
import com.github.pagehelper.PageInfo;
|
||||
import com.muyu.business.domain.Records;
|
||||
import com.muyu.business.domain.request.RecordsListRequest;
|
||||
|
||||
import com.muyu.business.mapper.RecordsMapper;
|
||||
import com.muyu.business.service.IRecordsService;
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -32,6 +32,8 @@ public class RecordsServiceImpl extends ServiceImpl<RecordsMapper,Records>
|
|||
|
||||
@Autowired
|
||||
private RecordsMapper recordsMapper;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* @author YinYuYang
|
||||
|
@ -85,9 +87,13 @@ public class RecordsServiceImpl extends ServiceImpl<RecordsMapper,Records>
|
|||
|
||||
records.setStartTime(new Date());
|
||||
|
||||
|
||||
recordsMapper.insert(records);
|
||||
|
||||
return records.getRecordsId();
|
||||
Integer recordsId = records.getRecordsId();
|
||||
redisService.setCacheSet("records:info:"+vin,recordsId);
|
||||
|
||||
return recordsId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,19 +3,15 @@ package com.muyu.business.service.impl;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.business.domain.Vehicle;
|
||||
import com.muyu.business.mapper.VehicleDataMapper;
|
||||
import com.muyu.business.service.VehicleDataService;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
//package com.muyu.business.sms;
|
||||
//
|
||||
//import com.muyu.business.service.AlarmLogsService;
|
||||
//import com.muyu.business.service.FaultLogsService;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//@Slf4j
|
||||
//@Component
|
||||
//public class SendSmsConfig {
|
||||
//
|
||||
// /**
|
||||
// * 注入redis工具类
|
||||
// */
|
||||
// @Autowired
|
||||
// private StringRedisTemplate redisTemplate;
|
||||
//
|
||||
// /**
|
||||
// * 注入报警日志服务
|
||||
// */
|
||||
// @Autowired
|
||||
// private AlarmLogsService alarmLogsService;
|
||||
//
|
||||
// /**
|
||||
// * 注入故障日志服务
|
||||
// */
|
||||
// @Autowired
|
||||
// private FaultLogsService faultLogsService;
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
|
@ -44,6 +44,7 @@
|
|||
left join fault_code_info c on l.fault_code = c.fault_code
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="selectAlarmLogsList" resultMap="AlarmLogsResult">
|
||||
<include refid="selectAlarmLogs"/>
|
||||
</select>
|
||||
|
|
|
@ -44,4 +44,10 @@
|
|||
<select id="selectFaultLogsList" resultMap="FaultLogsResult">
|
||||
<include refid="selectFaultLogsVo"/>
|
||||
</select>
|
||||
|
||||
<select id="selectFaultCode" resultType="com.muyu.business.domain.FaultCodeInfo">
|
||||
select * from fault_code_info where fault_code = #{faultCode}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -44,7 +44,7 @@ public class Car {
|
|||
/**
|
||||
* 电子围栏ID
|
||||
*/
|
||||
private String carFenceId;
|
||||
private String carMarking;
|
||||
/**
|
||||
* 车辆状态
|
||||
*/
|
||||
|
@ -92,7 +92,7 @@ public class Car {
|
|||
return Car.builder()
|
||||
.carVin(carAddReq.getCarVin())
|
||||
.carType(carAddReq.getCarType())
|
||||
.carFenceId(carAddReq.getCarFenceId())
|
||||
.carMarking(carAddReq.getCarFenceId())
|
||||
.state(carAddReq.getState())
|
||||
.carElectricalmachiney(carAddReq.getCarElectricalmachiney())
|
||||
.carBattery(carAddReq.getCarBattery())
|
||||
|
@ -107,7 +107,7 @@ public class Car {
|
|||
.carId(carUpdateReq.getCarId())
|
||||
.carVin(carUpdateReq.getCarVin())
|
||||
.carType(carUpdateReq.getCarType())
|
||||
.carFenceId(carUpdateReq.getCarFenceId())
|
||||
.carMarking(carUpdateReq.getCarFenceId())
|
||||
.state(carUpdateReq.getState())
|
||||
.carElectricalmachiney(carUpdateReq.getCarElectricalmachiney())
|
||||
.carBattery(carUpdateReq.getCarBattery())
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package com.muyu.system.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 标识表 marking
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.system.common.domain
|
||||
* @Description TODO
|
||||
* @Author XiaoFan
|
||||
* @Date 2024/4/10 19:58
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Marking {
|
||||
/**
|
||||
* 标识ID
|
||||
*/
|
||||
private Integer markingId;
|
||||
/**
|
||||
* 标识名称
|
||||
*/
|
||||
private String markingName;
|
||||
/**
|
||||
* 电子围栏ID
|
||||
*/
|
||||
private String markingFenceIds;
|
||||
}
|
|
@ -1,10 +1,14 @@
|
|||
package com.muyu.system.controller;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.system.common.domain.Car;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.system.common.domain.req.CarAddReq;
|
||||
import com.muyu.system.common.domain.req.CarUpdateReq;
|
||||
import com.muyu.system.common.domain.vo.CarVo;
|
||||
|
@ -14,10 +18,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -133,14 +135,14 @@ public class CarController extends BaseController
|
|||
|
||||
/**
|
||||
* 车辆下线(连接车联模拟数据)
|
||||
* @param carVin
|
||||
* @param vin
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/close/{carVin}")
|
||||
@RequiresPermissions("system:car:edit")
|
||||
@PostMapping("/close/{vin}")
|
||||
// @RequiresPermissions("system:car:edit")
|
||||
@Log(title = "车辆管理")
|
||||
public Result<String> close(@PathVariable String carVin){
|
||||
Result<String> result=carService.callVehicleClientClose(carVin);
|
||||
public Result<String> close(@PathVariable String vin){
|
||||
Result<String> result=carService.callVehicleClientClose(vin);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,4 +59,8 @@ public interface CarMapper extends BaseMapper<Car>
|
|||
|
||||
|
||||
int deleteByVin(String carVin);
|
||||
|
||||
void updateVin(String carVin);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
package com.muyu.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
|
@ -20,18 +16,19 @@ import com.muyu.common.redis.service.RedisService;
|
|||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.system.common.VehicleCreateAddReq;
|
||||
import com.muyu.system.common.domain.Car;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.system.common.domain.req.CarInfoAddReq;
|
||||
import com.muyu.system.common.domain.vo.CarVo;
|
||||
import com.muyu.system.feign.RecordsFeign;
|
||||
import com.muyu.system.mapper.CarMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.muyu.system.service.CarService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆信息Service业务层处理
|
||||
*
|
||||
|
@ -136,7 +133,7 @@ public class CarServiceImpl extends ServiceImpl<CarMapper,Car> implements CarSer
|
|||
//使用RestTemplate发送post请求
|
||||
Result<String> result=restTemplate.postForObject(url,vehicleCreateAddReq,Result.class);
|
||||
|
||||
if (null!=car.getCarFenceId()){
|
||||
if (null!=car.getCarMarking()){
|
||||
|
||||
// redisTemplate.opsForSet().add(car.getCarVin(),"fenceAlarm");
|
||||
|
||||
|
@ -168,7 +165,7 @@ public class CarServiceImpl extends ServiceImpl<CarMapper,Car> implements CarSer
|
|||
car.setUpdateTime(DateUtils.getNowDate());
|
||||
|
||||
|
||||
if (null!=car.getCarFenceId()){
|
||||
if (null!=car.getCarMarking()){
|
||||
vehicleEventCache.addEvent(car.getCarVin(), VehicleEventConstants.WEI_LAN);
|
||||
|
||||
}else {
|
||||
|
@ -231,12 +228,7 @@ public class CarServiceImpl extends ServiceImpl<CarMapper,Car> implements CarSer
|
|||
carInfoAddReq.setInfoOpenDate(new Date());
|
||||
carMapper.insertCarInfo(carInfoAddReq);
|
||||
|
||||
// 修改
|
||||
if (!redisService.hasKey("records:info:"+carVin)){
|
||||
Result<Integer> insert = recordsFeign.insert(carVin);
|
||||
Integer recordsId = insert.getData();
|
||||
redisService.setCacheObject("records:info:"+carVin,recordsId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
|
@ -244,36 +236,38 @@ public class CarServiceImpl extends ServiceImpl<CarMapper,Car> implements CarSer
|
|||
|
||||
/**
|
||||
* 车辆下线
|
||||
* @param carVin
|
||||
* @param vin
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result<String> callVehicleClientClose(String carVin) {
|
||||
String url="http://127.0.0.1:81/vehicle/instance/client/close/" +carVin;
|
||||
Result<String> result=restTemplate.postForObject(url,null,Result.class);
|
||||
carMapper.updateVinClose(carVin);
|
||||
Car car = carMapper.selectByVin(carVin);
|
||||
CarInfoAddReq carInfoAddReq = new CarInfoAddReq();
|
||||
carInfoAddReq.setVin(car.getCarVin());
|
||||
carInfoAddReq.setInfoCloseDate(new Date());
|
||||
carMapper.insertCarInfo(carInfoAddReq);
|
||||
// String url="http://127.0.0.1:81/vehicle/instance/client/close/" +carVin;
|
||||
// Result<String> result=restTemplate.postForObject(url,null,Result.class);
|
||||
|
||||
|
||||
if (redisService.hasKey("records:info:"+carVin)){
|
||||
Object cacheObject = redisService.getCacheObject("records:info:" + carVin);
|
||||
if (cacheObject != null){
|
||||
Integer recordsId = (Integer) cacheObject;
|
||||
recordsFeign.update(recordsId);
|
||||
}
|
||||
redisService.deleteObject("records:info:"+carVin);
|
||||
}
|
||||
// carMapper.updateVinClose(carVin);
|
||||
// Car car = carMapper.selectByVin(carVin);
|
||||
// CarInfoAddReq carInfoAddReq = new CarInfoAddReq();
|
||||
// carInfoAddReq.setVin(car.getCarVin());
|
||||
// carInfoAddReq.setInfoCloseDate(new Date());
|
||||
carMapper.updateVin(carVin);
|
||||
|
||||
|
||||
// if (redisService.hasKey("records:info:"+carVin)){
|
||||
// Object cacheObject = redisService.getCacheObject("records:info:" + carVin);
|
||||
// if (cacheObject != null){
|
||||
// Integer recordsId = (Integer) cacheObject;
|
||||
// recordsFeign.update(recordsId);
|
||||
// }
|
||||
// redisService.deleteObject("records:info:"+carVin);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
return Result.success();
|
||||
}
|
||||
@Override
|
||||
public int deleteByVin(String carVin) {
|
||||
|
|
|
@ -30,6 +30,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<update id="updateVinClose">
|
||||
update car set state=1 where car_vin=#{carVin}
|
||||
</update>
|
||||
<update id="updateVin">
|
||||
update car set over_time=now() where car_vin=#{carVin}
|
||||
</update>
|
||||
<delete id="deleteByVin">
|
||||
delete from car where car_vin=#{carVin}
|
||||
</delete>
|
||||
|
|
12
pom.xml
12
pom.xml
|
@ -35,6 +35,7 @@
|
|||
<minio.version>8.2.2</minio.version>
|
||||
<poi.version>4.1.2</poi.version>
|
||||
<transmittable-thread-local.version>2.14.4</transmittable-thread-local.version>
|
||||
<transmittable-thread-local.version>2.14.4</transmittable-thread-local.version>
|
||||
|
||||
<muyu-file-common.version>3.6.3</muyu-file-common.version>
|
||||
<muyu-file-remote.version>3.6.3</muyu-file-remote.version>
|
||||
|
@ -49,6 +50,8 @@
|
|||
<muyu-business-server.version>3.6.3</muyu-business-server.version>
|
||||
<muyu-analyze.version>3.6.3</muyu-analyze.version>
|
||||
|
||||
<muyu-common-redis.version>3.6.3</muyu-common-redis.version>
|
||||
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
|
@ -282,7 +285,12 @@
|
|||
<artifactId>muyu-analyze</artifactId>
|
||||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>ecs20140526</artifactId>
|
||||
<version>5.0.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<modules>
|
||||
|
@ -292,7 +300,7 @@
|
|||
<module>muyu-modules</module>
|
||||
<module>muyu-common</module>
|
||||
<module>muyu-analyze</module>
|
||||
|
||||
<module>muyu-load-center</module>
|
||||
|
||||
|
||||
</modules>
|
||||
|
|
Loading…
Reference in New Issue