事件处理:车辆驶入驶出围栏报警
parent
fc291b12f0
commit
938d1fe41a
|
@ -122,6 +122,14 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>10</source>
|
||||
<target>10</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.analyze.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import com.muyu.system.common.domain.Fence;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
@ -22,6 +23,7 @@ public interface VehicleMapper{
|
|||
Boolean addVehicleStoredEvent(ArrayList<VehicleData> list);
|
||||
|
||||
|
||||
List<Fence> selectFenceList();
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -37,197 +37,197 @@ public class BreakdownImpl implements VehicleService{
|
|||
@Override
|
||||
public void eventResolution(VehicleData vehicleData) {
|
||||
|
||||
log.info("故障事件解析");
|
||||
if (StateConstant.VEHICLE_STATUS != vehicleData.getVehicleStatus()
|
||||
|| StateConstant.CHARGING_STATUS!=vehicleData.getChgStatus()
|
||||
|| StateConstant.OPERATING_STATUS!=vehicleData.getOperatingStatus()
|
||||
|| StateConstant.SOC_STATUS!=vehicleData.getSocStatus()
|
||||
|| StateConstant.CHARGING_ENERGY_STORAGE_STATUS != vehicleData.getChargingEnergyStorageStatus()
|
||||
|| StateConstant.DRIVE_MOTOR_STATUS != vehicleData.getDriveMotorStatus()
|
||||
|| StateConstant.POSITION_STATUS != vehicleData.getPositionStatus()
|
||||
|| StateConstant.EAS_STATUS != vehicleData.getEasStatus()
|
||||
|| StateConstant.PTC_STATUS != vehicleData.getPtcStatus()
|
||||
|| StateConstant.ABS_STATUS != vehicleData.getAbsStatus()
|
||||
|| StateConstant.MCU_STATUS != vehicleData.getMcuStatus()
|
||||
|| StateConstant.HEATING_STATUS != vehicleData.getHeatingStatus()
|
||||
|| StateConstant.BATTERY_STATUS != vehicleData.getBatteryStatus()
|
||||
|| StateConstant.BATTERY_INSULATION_STATUS != vehicleData.getBatteryInsulationStatus()
|
||||
|| StateConstant.DCDC_STATUS != vehicleData.getDcdcStatus()
|
||||
|| StateConstant.CHG_STATUS != vehicleData.getChgStatus()){
|
||||
|
||||
|
||||
FaultLogs faultLogsAddReq = new FaultLogs();
|
||||
faultLogsAddReq.setCarVin(vehicleData.getVin());
|
||||
|
||||
// /**
|
||||
|
||||
|
||||
// * 车辆状态
|
||||
// */
|
||||
// private int vehicleStatus ;
|
||||
|
||||
if (vehicleData.getVehicleStatus()==0){
|
||||
faultLogsAddReq.setFaultCode("GTB001");
|
||||
faultLogsAddReq.setFaultLevel(3);
|
||||
}
|
||||
// /**
|
||||
// * 充电状态
|
||||
// */
|
||||
// private int chargingStatus;
|
||||
if (vehicleData.getChargingStatus()==0){
|
||||
faultLogsAddReq.setFaultCode("GTB002");
|
||||
faultLogsAddReq.setFaultLevel(3);
|
||||
}
|
||||
// /**
|
||||
// * 运行状态
|
||||
// */
|
||||
// private int operatingStatus;
|
||||
if (vehicleData.getOperatingStatus()==0){
|
||||
faultLogsAddReq.setFaultCode("GTB003");
|
||||
faultLogsAddReq.setFaultLevel(3);
|
||||
}
|
||||
// /**
|
||||
// * SOC
|
||||
// */
|
||||
// private int socStatus;
|
||||
if (vehicleData.getSocStatus()==0){
|
||||
faultLogsAddReq.setFaultCode("GTO001");
|
||||
faultLogsAddReq.setFaultLevel(2);
|
||||
}
|
||||
//
|
||||
//
|
||||
//GTO003
|
||||
|
||||
// /**
|
||||
// * 可充电储能装置工作状态
|
||||
// */
|
||||
// private int chargingEnergyStorageStatus ;
|
||||
if (vehicleData.getChargingEnergyStorageStatus()==0){
|
||||
faultLogsAddReq.setFaultCode("GTO002");
|
||||
faultLogsAddReq.setFaultLevel(2);
|
||||
}
|
||||
// /**
|
||||
// * 驱动电机状态
|
||||
// */
|
||||
// private int driveMotorStatus ;
|
||||
if (vehicleData.getDriveMotorStatus()==0){
|
||||
faultLogsAddReq.setFaultCode("GT0003");
|
||||
faultLogsAddReq.setFaultLevel(2);
|
||||
}
|
||||
// /**
|
||||
// * 定位是否有效
|
||||
// */
|
||||
// private int positionStatus ;
|
||||
if (vehicleData.getPositionStatus()==0){
|
||||
faultLogsAddReq.setFaultCode("GT0004");
|
||||
faultLogsAddReq.setFaultLevel(2);
|
||||
} //GTO004
|
||||
//GTO005
|
||||
//GTO006
|
||||
//GTO007
|
||||
// /**
|
||||
// * EAS(汽车防盗系统)状态
|
||||
// */
|
||||
// private int easStatus ;
|
||||
if (vehicleData.getEasStatus()==0){
|
||||
faultLogsAddReq.setFaultCode("GTO005");
|
||||
faultLogsAddReq.setFaultLevel(2);
|
||||
}
|
||||
// /**
|
||||
// * PTC(电动加热器)状态
|
||||
// */
|
||||
// private int ptcStatus ;
|
||||
if (vehicleData.getPtcStatus()==0){
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTO006");
|
||||
faultLogsAddReq.setFaultLevel(2);
|
||||
}
|
||||
// /**
|
||||
// * EPS(电动助力系统)状态
|
||||
// */
|
||||
// private int epsStatus ;
|
||||
if (vehicleData.getEpsStatus()==0){
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTO007");
|
||||
faultLogsAddReq.setFaultLevel(2);
|
||||
}
|
||||
// /**
|
||||
// * ABS(防抱死)状态
|
||||
// */
|
||||
// private int absStatus ;
|
||||
if (vehicleData.getAbsStatus()==0){
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTX001");
|
||||
faultLogsAddReq.setFaultLevel(1);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * MCU(电机/逆变器)状态
|
||||
// */
|
||||
// private int mcuStatus ;
|
||||
if (vehicleData.getMcuStatus()==0){
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTX002");
|
||||
faultLogsAddReq.setFaultLevel(1);
|
||||
}
|
||||
// /**
|
||||
// * 动力电池加热状态
|
||||
// */
|
||||
// private int heatingStatus ;
|
||||
if (vehicleData.getHeatingStatus()==0){
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTX003");
|
||||
faultLogsAddReq.setFaultLevel(1);
|
||||
}
|
||||
// /**
|
||||
// * 动力电池当前状态
|
||||
// */
|
||||
// private int batteryStatus ;
|
||||
if (vehicleData.getBatteryStatus()==0){
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTX004");
|
||||
faultLogsAddReq.setFaultLevel(1);
|
||||
}
|
||||
// /**
|
||||
// * 动力电池保温状态
|
||||
// */
|
||||
// private int batteryInsulationStatus ;
|
||||
if (vehicleData.getBatteryInsulationStatus()==0){
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTX005");
|
||||
faultLogsAddReq.setFaultLevel(1);
|
||||
}
|
||||
// /**
|
||||
// * DCDC(电力交换系统)状态
|
||||
// */
|
||||
// private int dcdcStatus ;
|
||||
if (vehicleData.getDcdcStatus()==0){
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTX006");
|
||||
faultLogsAddReq.setFaultLevel(1);
|
||||
}
|
||||
// /**
|
||||
// * CHG(充电机)状态
|
||||
// */
|
||||
// private int chgStatus ;
|
||||
if (vehicleData.getChgStatus()==0){
|
||||
|
||||
faultLogsAddReq.setFaultCode("GTX007");
|
||||
faultLogsAddReq.setFaultLevel(1);
|
||||
}
|
||||
// rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE, RabbitMqConfig.KEY,faultLogsAddReq, message -> {
|
||||
// message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||
// return message;
|
||||
// } ,new CorrelationData(UUID.randomUUID().toString()));
|
||||
|
||||
|
||||
|
||||
String key = "breakdown";
|
||||
String value = JSON.toJSONString(faultLogsAddReq);
|
||||
redisTemplate.opsForSet().add(key, value);
|
||||
long expireTime = 30;
|
||||
redisTemplate.expire(key, expireTime, TimeUnit.MINUTES);
|
||||
}
|
||||
// log.info("故障事件解析");
|
||||
// if (StateConstant.VEHICLE_STATUS != vehicleData.getVehicleStatus()
|
||||
// || StateConstant.CHARGING_STATUS!=vehicleData.getChgStatus()
|
||||
// || StateConstant.OPERATING_STATUS!=vehicleData.getOperatingStatus()
|
||||
// || StateConstant.SOC_STATUS!=vehicleData.getSocStatus()
|
||||
// || StateConstant.CHARGING_ENERGY_STORAGE_STATUS != vehicleData.getChargingEnergyStorageStatus()
|
||||
// || StateConstant.DRIVE_MOTOR_STATUS != vehicleData.getDriveMotorStatus()
|
||||
// || StateConstant.POSITION_STATUS != vehicleData.getPositionStatus()
|
||||
// || StateConstant.EAS_STATUS != vehicleData.getEasStatus()
|
||||
// || StateConstant.PTC_STATUS != vehicleData.getPtcStatus()
|
||||
// || StateConstant.ABS_STATUS != vehicleData.getAbsStatus()
|
||||
// || StateConstant.MCU_STATUS != vehicleData.getMcuStatus()
|
||||
// || StateConstant.HEATING_STATUS != vehicleData.getHeatingStatus()
|
||||
// || StateConstant.BATTERY_STATUS != vehicleData.getBatteryStatus()
|
||||
// || StateConstant.BATTERY_INSULATION_STATUS != vehicleData.getBatteryInsulationStatus()
|
||||
// || StateConstant.DCDC_STATUS != vehicleData.getDcdcStatus()
|
||||
// || StateConstant.CHG_STATUS != vehicleData.getChgStatus()){
|
||||
//
|
||||
//
|
||||
// FaultLogs faultLogsAddReq = new FaultLogs();
|
||||
// faultLogsAddReq.setCarVin(vehicleData.getVin());
|
||||
//
|
||||
// // /**
|
||||
//
|
||||
//
|
||||
// // * 车辆状态
|
||||
// // */
|
||||
// // private int vehicleStatus ;
|
||||
//
|
||||
// if (vehicleData.getVehicleStatus()==0){
|
||||
// faultLogsAddReq.setFaultCode("GTB001");
|
||||
// faultLogsAddReq.setFaultLevel(3);
|
||||
// }
|
||||
// // /**
|
||||
// // * 充电状态
|
||||
// // */
|
||||
// // private int chargingStatus;
|
||||
// if (vehicleData.getChargingStatus()==0){
|
||||
// faultLogsAddReq.setFaultCode("GTB002");
|
||||
// faultLogsAddReq.setFaultLevel(3);
|
||||
// }
|
||||
// // /**
|
||||
// // * 运行状态
|
||||
// // */
|
||||
// // private int operatingStatus;
|
||||
// if (vehicleData.getOperatingStatus()==0){
|
||||
// faultLogsAddReq.setFaultCode("GTB003");
|
||||
// faultLogsAddReq.setFaultLevel(3);
|
||||
// }
|
||||
// // /**
|
||||
// // * SOC
|
||||
// // */
|
||||
// // private int socStatus;
|
||||
// if (vehicleData.getSocStatus()==0){
|
||||
// faultLogsAddReq.setFaultCode("GTO001");
|
||||
// faultLogsAddReq.setFaultLevel(2);
|
||||
// }
|
||||
// //
|
||||
// //
|
||||
// //GTO003
|
||||
//
|
||||
// // /**
|
||||
// // * 可充电储能装置工作状态
|
||||
// // */
|
||||
// // private int chargingEnergyStorageStatus ;
|
||||
// if (vehicleData.getChargingEnergyStorageStatus()==0){
|
||||
// faultLogsAddReq.setFaultCode("GTO002");
|
||||
// faultLogsAddReq.setFaultLevel(2);
|
||||
// }
|
||||
// // /**
|
||||
// // * 驱动电机状态
|
||||
// // */
|
||||
// // private int driveMotorStatus ;
|
||||
// if (vehicleData.getDriveMotorStatus()==0){
|
||||
// faultLogsAddReq.setFaultCode("GT0003");
|
||||
// faultLogsAddReq.setFaultLevel(2);
|
||||
// }
|
||||
// // /**
|
||||
// // * 定位是否有效
|
||||
// // */
|
||||
// // private int positionStatus ;
|
||||
// if (vehicleData.getPositionStatus()==0){
|
||||
// faultLogsAddReq.setFaultCode("GT0004");
|
||||
// faultLogsAddReq.setFaultLevel(2);
|
||||
// } //GTO004
|
||||
// //GTO005
|
||||
// //GTO006
|
||||
// //GTO007
|
||||
// // /**
|
||||
// // * EAS(汽车防盗系统)状态
|
||||
// // */
|
||||
// // private int easStatus ;
|
||||
// if (vehicleData.getEasStatus()==0){
|
||||
// faultLogsAddReq.setFaultCode("GTO005");
|
||||
// faultLogsAddReq.setFaultLevel(2);
|
||||
// }
|
||||
// // /**
|
||||
// // * PTC(电动加热器)状态
|
||||
// // */
|
||||
// // private int ptcStatus ;
|
||||
// if (vehicleData.getPtcStatus()==0){
|
||||
//
|
||||
// faultLogsAddReq.setFaultCode("GTO006");
|
||||
// faultLogsAddReq.setFaultLevel(2);
|
||||
// }
|
||||
// // /**
|
||||
// // * EPS(电动助力系统)状态
|
||||
// // */
|
||||
// // private int epsStatus ;
|
||||
// if (vehicleData.getEpsStatus()==0){
|
||||
//
|
||||
// faultLogsAddReq.setFaultCode("GTO007");
|
||||
// faultLogsAddReq.setFaultLevel(2);
|
||||
// }
|
||||
// // /**
|
||||
// // * ABS(防抱死)状态
|
||||
// // */
|
||||
// // private int absStatus ;
|
||||
// if (vehicleData.getAbsStatus()==0){
|
||||
//
|
||||
// faultLogsAddReq.setFaultCode("GTX001");
|
||||
// faultLogsAddReq.setFaultLevel(1);
|
||||
// }
|
||||
//
|
||||
// // /**
|
||||
// // * MCU(电机/逆变器)状态
|
||||
// // */
|
||||
// // private int mcuStatus ;
|
||||
// if (vehicleData.getMcuStatus()==0){
|
||||
//
|
||||
// faultLogsAddReq.setFaultCode("GTX002");
|
||||
// faultLogsAddReq.setFaultLevel(1);
|
||||
// }
|
||||
// // /**
|
||||
// // * 动力电池加热状态
|
||||
// // */
|
||||
// // private int heatingStatus ;
|
||||
// if (vehicleData.getHeatingStatus()==0){
|
||||
//
|
||||
// faultLogsAddReq.setFaultCode("GTX003");
|
||||
// faultLogsAddReq.setFaultLevel(1);
|
||||
// }
|
||||
// // /**
|
||||
// // * 动力电池当前状态
|
||||
// // */
|
||||
// // private int batteryStatus ;
|
||||
// if (vehicleData.getBatteryStatus()==0){
|
||||
//
|
||||
// faultLogsAddReq.setFaultCode("GTX004");
|
||||
// faultLogsAddReq.setFaultLevel(1);
|
||||
// }
|
||||
// // /**
|
||||
// // * 动力电池保温状态
|
||||
// // */
|
||||
// // private int batteryInsulationStatus ;
|
||||
// if (vehicleData.getBatteryInsulationStatus()==0){
|
||||
//
|
||||
// faultLogsAddReq.setFaultCode("GTX005");
|
||||
// faultLogsAddReq.setFaultLevel(1);
|
||||
// }
|
||||
// // /**
|
||||
// // * DCDC(电力交换系统)状态
|
||||
// // */
|
||||
// // private int dcdcStatus ;
|
||||
// if (vehicleData.getDcdcStatus()==0){
|
||||
//
|
||||
// faultLogsAddReq.setFaultCode("GTX006");
|
||||
// faultLogsAddReq.setFaultLevel(1);
|
||||
// }
|
||||
// // /**
|
||||
// // * CHG(充电机)状态
|
||||
// // */
|
||||
// // private int chgStatus ;
|
||||
// if (vehicleData.getChgStatus()==0){
|
||||
//
|
||||
// faultLogsAddReq.setFaultCode("GTX007");
|
||||
// faultLogsAddReq.setFaultLevel(1);
|
||||
// }
|
||||
//// rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE, RabbitMqConfig.KEY,faultLogsAddReq, message -> {
|
||||
//// message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||
//// return message;
|
||||
//// } ,new CorrelationData(UUID.randomUUID().toString()));
|
||||
//
|
||||
//
|
||||
//
|
||||
// String key = "breakdown";
|
||||
// String value = JSON.toJSONString(faultLogsAddReq);
|
||||
// redisTemplate.opsForSet().add(key, value);
|
||||
// long expireTime = 30;
|
||||
// redisTemplate.expire(key, expireTime, TimeUnit.MINUTES);
|
||||
// }
|
||||
|
||||
log.info("故障事件结束");
|
||||
}
|
||||
|
|
|
@ -1,10 +1,22 @@
|
|||
package com.muyu.analyze.service.impl;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.muyu.analyze.mapper.VehicleMapper;
|
||||
import com.muyu.analyze.service.VehicleService;
|
||||
import com.muyu.system.common.domain.Car;
|
||||
import com.muyu.system.common.domain.Fence;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static java.lang.Double.parseDouble;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.analyze.service.impl
|
||||
|
@ -16,15 +28,99 @@ import org.springframework.stereotype.Service;
|
|||
@Service("fenceAlarm")
|
||||
public class FenceAlarmImpl implements VehicleService {
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
@Autowired
|
||||
private VehicleMapper vehicleMapper;
|
||||
|
||||
@Override
|
||||
public void eventResolution(VehicleData analyze) {
|
||||
|
||||
System.out.println("电子围栏报警事件开启");
|
||||
//车的vin
|
||||
String vin = analyze.getVin();
|
||||
System.out.println("vin:"+vin);
|
||||
|
||||
//经度
|
||||
double pointLng = parseDouble(analyze.getLongitude());
|
||||
|
||||
//纬度
|
||||
double pointLat = parseDouble(analyze.getLatitude());
|
||||
|
||||
|
||||
List<Fence> list=vehicleMapper.selectFenceList();
|
||||
|
||||
for (Fence fence : list) {
|
||||
if (fence.getCarVin().equals(vin)){
|
||||
|
||||
//fenceRadius
|
||||
//39.958897, 116.179075; 39.950476,116.330823; 39.865149,116.290311; 39.881485,116.083631
|
||||
String[] split = fence.getFenceRadius().split(";");
|
||||
|
||||
boolean withinFence = isWithinFence(pointLat, pointLng, Arrays.asList(split));
|
||||
|
||||
|
||||
//false是除了围栏要报警
|
||||
|
||||
if (fence.getFenceType().equals("驶出")){
|
||||
if (withinFence){
|
||||
System.out.println("车辆vin:"+vin+"------在安全区");
|
||||
}else {
|
||||
System.out.println("车辆vin:"+vin+"------驶出围栏---报警");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (fence.getFenceType().equals("驶入")){
|
||||
if (withinFence){
|
||||
System.out.println("车辆vin:"+vin+"------驶入禁行区----报警");
|
||||
}else{
|
||||
System.out.println("车辆vin:"+vin+"------在安全区");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean isWithinFence(double pointLat, double pointLng, List<String> split) {
|
||||
// 确保split列表至少包含四个经纬度对
|
||||
if (split.size() < 4) {
|
||||
throw new IllegalArgumentException("不符合条件");
|
||||
}
|
||||
|
||||
// 解析矩形的四个顶点
|
||||
double[] latitudes = new double[4];
|
||||
double[] longitudes = new double[4];
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
String[] coordinates = split.get(i).split(",");
|
||||
latitudes[i] = Double.parseDouble(coordinates[0]);
|
||||
longitudes[i] = Double.parseDouble(coordinates[1]);
|
||||
}
|
||||
|
||||
// 检查点是否在矩形内
|
||||
return isPointInRectangle(pointLat, pointLng, latitudes, longitudes);
|
||||
}
|
||||
|
||||
private boolean isPointInRectangle(double pointLat, double pointLng, double[] latitudes, double[] longitudes) {
|
||||
// 根据矩形顶点顺序确定最小和最大纬度、经度
|
||||
double minLatitude = Arrays.stream(latitudes).min().orElseThrow();
|
||||
double maxLatitude = Arrays.stream(latitudes).max().orElseThrow();
|
||||
double minLongitude = Arrays.stream(longitudes).min().orElseThrow();
|
||||
double maxLongitude = Arrays.stream(longitudes).max().orElseThrow();
|
||||
|
||||
return pointLat >= minLatitude && pointLat <= maxLatitude &&
|
||||
pointLng >= minLongitude && pointLng <= maxLongitude;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ public class RealTimeDataEventImpl implements VehicleService {
|
|||
|
||||
@Override
|
||||
public void eventResolution(VehicleData analyze) {
|
||||
System.out.println("我是实时数据");
|
||||
System.out.println(analyze);
|
||||
// System.out.println("我是实时数据");
|
||||
// System.out.println(analyze);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -36,18 +36,18 @@ public class StoredEventImpl implements VehicleService {
|
|||
public void eventResolution(VehicleData analyze) {
|
||||
|
||||
|
||||
list.add(analyze);
|
||||
if (list.size() >= 50) {
|
||||
log.info("集合满50,存储事件开始");
|
||||
Boolean i= vehicleMapper.addVehicleStoredEvent(list);
|
||||
|
||||
if (i) {
|
||||
list.clear();
|
||||
log.info("存储事件结束");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// list.add(analyze);
|
||||
// if (list.size() >= 50) {
|
||||
// log.info("集合满50,存储事件开始");
|
||||
// Boolean i= vehicleMapper.addVehicleStoredEvent(list);
|
||||
//
|
||||
// if (i) {
|
||||
// list.clear();
|
||||
// log.info("存储事件结束");
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -13,4 +13,7 @@
|
|||
</foreach>
|
||||
|
||||
</insert>
|
||||
<select id="selectFenceList" resultType="com.muyu.system.common.domain.Fence">
|
||||
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>
|
||||
</mapper>
|
||||
|
|
|
@ -62,6 +62,8 @@ public class Fence{
|
|||
@TableField("fence_radius")
|
||||
private String fenceRadius;
|
||||
|
||||
private String carVin;
|
||||
|
||||
public static Fence addReqBuild(FenceAddRequest fenceAddRequest) {
|
||||
return Fence.builder()
|
||||
.fenceEncoding(fenceAddRequest.getFenceEncoding())
|
||||
|
|
|
@ -58,4 +58,9 @@ public interface CarMapper extends BaseMapper<Car>
|
|||
* @return
|
||||
*/
|
||||
Car selectByVin(String carVin);
|
||||
|
||||
List<Fence> selectFenceList();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@ package com.muyu.system.service.impl;
|
|||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
|
@ -20,6 +23,7 @@ import com.muyu.system.common.domain.req.CarInfoAddReq;
|
|||
import com.muyu.system.common.domain.vo.CarVo;
|
||||
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;
|
||||
|
@ -38,13 +42,20 @@ public class CarServiceImpl extends ServiceImpl<CarMapper,Car> implements CarSer
|
|||
private CarMapper carMapper;
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
/**
|
||||
* 查询车辆信息
|
||||
* @param carVo
|
||||
*/
|
||||
@Override
|
||||
public Result<PageResult<Car>> list(CarVo carVo) {
|
||||
|
||||
List<Fence> list1 = carMapper.selectFenceList();
|
||||
for (Fence fence : list1) {
|
||||
redisTemplate.opsForList().rightPush("fenceKey:", JSON.toJSONString(fence));
|
||||
}
|
||||
|
||||
PageHelper.startPage(carVo.getPageNum(),carVo.getPageSize());
|
||||
LambdaQueryWrapper<Car> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// VIN码条件查询
|
||||
|
@ -76,6 +87,13 @@ public class CarServiceImpl extends ServiceImpl<CarMapper,Car> implements CarSer
|
|||
lambdaQueryWrapper.like(Car::getCarBatteryId,carVo.getCarBatteryId());
|
||||
}
|
||||
List<Car> list=this.list(lambdaQueryWrapper);
|
||||
|
||||
for (Car car : list) {
|
||||
redisTemplate.opsForSet().add("carKey:", JSON.toJSONString(car));
|
||||
}
|
||||
|
||||
|
||||
|
||||
PageInfo<Car> info = new PageInfo<>(list);
|
||||
return PageResult.toResult(info.getTotal(),info.getList());
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.muyu.system.service.ISysUserService;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
@ -55,6 +56,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
@Autowired
|
||||
protected Validator validator;
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
|
@ -65,8 +67,9 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
public List<SysUser> selectUserList(SysUser user)
|
||||
{
|
||||
//获取登录人信息
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return userMapper.selectUserList(user);
|
||||
|
|
|
@ -42,4 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
car_vin=#{carVin}
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectFenceList" resultType="com.muyu.system.common.domain.Fence">
|
||||
select * from fence where fence_state=0
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue