车辆管理模块 加注释 增删改,触发刷新缓存 增加缓存时间
parent
1b9c777a87
commit
be2e99af0c
|
@ -1,5 +1,6 @@
|
|||
package com.couplet.analyze.msg.model;
|
||||
|
||||
import com.couplet.analyze.common.event.AnalyzeEventCache;
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
import com.couplet.common.core.exception.vehicle.VehicleException;
|
||||
|
|
|
@ -22,9 +22,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @ProjectName: five-groups-couplet
|
||||
|
@ -140,6 +142,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
* @Return: java.lang.String
|
||||
**/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String editById(VehicleEditParams editParams) {
|
||||
String result = "";
|
||||
|
||||
|
@ -200,6 +203,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
* @Return: java.lang.String
|
||||
**/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String insert(VehicleInsertParams insertParams) {
|
||||
String result = "";
|
||||
|
||||
|
@ -303,7 +307,13 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
}
|
||||
|
||||
|
||||
//通过vin修改车辆上下线的状态
|
||||
/*
|
||||
* @Author: LiuYunHu
|
||||
* @Date: 2024/4/8 14:11
|
||||
* @Description: 通过vin修改车辆上下线的状态
|
||||
* @Param: [vin, status]
|
||||
* @Return: java.lang.Integer
|
||||
**/
|
||||
@Override
|
||||
public Integer onOrOutLineByVIN(String vin, int status) {
|
||||
|
||||
|
@ -315,6 +325,13 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
return vehicleMapper.addVehicle(userId, vehicleIds);
|
||||
}
|
||||
|
||||
/*
|
||||
* @Author: LiuYunHu
|
||||
* @Date: 2024/4/8 14:11
|
||||
* @Description: 通过vin查询车辆,因为是plus,所以是List
|
||||
* @Param: [vin]
|
||||
* @Return: java.util.List<com.couplet.common.domain.Vehicle>
|
||||
**/
|
||||
@Override
|
||||
public List<Vehicle> findByVIN(String vin) {
|
||||
|
||||
|
@ -330,19 +347,19 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
}
|
||||
|
||||
|
||||
// @Scheduled(cron = "0/1 * * * * *")
|
||||
// public void aa() {
|
||||
// System.out.println("********************************************************");
|
||||
// }
|
||||
|
||||
//判断车辆是否下线
|
||||
/*
|
||||
* @Author: LiuYunHu
|
||||
* @Date: 2024/4/8 14:12
|
||||
* @Description: 定时执行,查询缓存中下线的车辆,修改其状态
|
||||
* @Param: []
|
||||
* @Return: void
|
||||
**/
|
||||
@Scheduled(cron = "0/1 * * * * *")
|
||||
public void downLine() {
|
||||
log.info("定时器启动");
|
||||
//先查询车辆列表
|
||||
List<Vehicle> list = this.list(new VehicleListParams(null, null, null, null));
|
||||
|
||||
|
||||
list.forEach(vehicle -> {
|
||||
try {
|
||||
//只针对已经上线的车辆
|
||||
|
@ -372,30 +389,43 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
}
|
||||
|
||||
/*
|
||||
* 车辆绑定标识的缓存
|
||||
* */
|
||||
* @Author: LiuYunHu
|
||||
* @Date: 2024/4/8 14:14
|
||||
* @Description: 刷新缓存中 的数据 车辆绑定标识的缓存
|
||||
* @Param: []
|
||||
* @Return: void
|
||||
**/
|
||||
@Scheduled(cron = "0/3 * * * * *")
|
||||
public void reCache() {
|
||||
//先获取所有车辆的信息
|
||||
//刷新缓存执行开始
|
||||
|
||||
//先获取所有车辆的信息
|
||||
List<Vehicle> list = list(new VehicleListParams());
|
||||
|
||||
//通过车辆的id获取对应的标识
|
||||
list.forEach(vehicle -> {
|
||||
//通过车辆的id获取对应的标识集合
|
||||
List<Long> bindLogoById = getBindLogoById(vehicle.getVehicleId());
|
||||
|
||||
//遍历标识集合
|
||||
bindLogoById.forEach(logoId -> {
|
||||
//存标识id
|
||||
|
||||
//存标识id 的set
|
||||
HashSet<Long> logos = new HashSet<>();
|
||||
logos.add(logoId);
|
||||
//存入redis
|
||||
redis.setCacheSet("车辆vin和标识:" + vehicle.getVin(), logos);
|
||||
redis.expire("车辆vin和标识:" + vehicle.getVin(), 2, TimeUnit.MINUTES);
|
||||
|
||||
|
||||
//存围栏id
|
||||
//通过标识id获取标识绑定的电子围栏集合
|
||||
List<Fence> fences = fenAndLogoService.findFencesByLogoId(logoId);
|
||||
//遍历电子围栏集合
|
||||
fences.forEach(fence -> {
|
||||
HashSet<Fence> fanceSet = new HashSet<>();
|
||||
fanceSet.add(fence);
|
||||
//存入redis
|
||||
redis.setCacheSet("车辆vin和电子围栏:" + vehicle.getVin(), fanceSet);
|
||||
redis.expire("车辆vin和电子围栏:" + vehicle.getVin(), 2, TimeUnit.MINUTES);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -35,15 +35,15 @@ logging:
|
|||
com.couplet.system.mapper: DEBUG
|
||||
|
||||
# 订阅端配置
|
||||
mqtt:
|
||||
server:
|
||||
broker: tcp://8.130.181.16:1883
|
||||
# broker: tcp://115.159.47.13:1883
|
||||
username:
|
||||
password:
|
||||
clientid: mqttx
|
||||
qos: 0
|
||||
topic: test
|
||||
#mqtt:
|
||||
# server:
|
||||
# broker: tcp://8.130.181.16:1883
|
||||
## broker: tcp://115.159.47.13:1883
|
||||
# username:
|
||||
# password:
|
||||
# clientid: mqttx
|
||||
# qos: 0
|
||||
# topic: test
|
||||
|
||||
# RabbitMQ配置
|
||||
mq:
|
||||
|
|
Loading…
Reference in New Issue