fast()指标预警,报文添加

car-ser
王熙朝 2024-06-26 21:43:58 +08:00
parent 9b0a07484a
commit 8ec657dd1a
25 changed files with 786 additions and 51 deletions

View File

@ -44,10 +44,12 @@ public class TokenService {
String token = IdUtils.fastUUID(); String token = IdUtils.fastUUID();
Long userId = loginUser.getSysUser().getUserId(); Long userId = loginUser.getSysUser().getUserId();
String userName = loginUser.getSysUser().getUserName(); String userName = loginUser.getSysUser().getUserName();
Long firm = loginUser.getSysUser().getFirm();
loginUser.setToken(token); loginUser.setToken(token);
loginUser.setUserId(userId); loginUser.setUserId(userId);
loginUser.setUsername(userName); loginUser.setUsername(userName);
loginUser.setIpaddr(IpUtils.getIpAddr()); loginUser.setIpaddr(IpUtils.getIpAddr());
loginUser.setFirm(firm);
refreshToken(loginUser); refreshToken(loginUser);
// Jwt存储信息 // Jwt存储信息

View File

@ -0,0 +1,42 @@
package com.business.common.dev;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* @ClassName DataFormat
* @Author GuanTieLin
* @Date 2024/6/26 14:15
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DataFormatDev {
/**
*
*/
private String vin;
/**
*
*/
private String dataCode;
/**
*
*/
private String label;
/**
*
*/
private Integer start;
/**
*
*/
private Integer end;
}

View File

@ -38,10 +38,6 @@ public class Car extends BaseEntity
@Excel(name = "生产年份") @Excel(name = "生产年份")
private Long manufactureYear; private Long manufactureYear;
/** 车身类型 */
@Excel(name = "车身类型")
private String bodyType;
/** 车辆颜色 */ /** 车辆颜色 */
@Excel(name = "车辆颜色") @Excel(name = "车辆颜色")
private String color; private String color;
@ -62,10 +58,6 @@ public class Car extends BaseEntity
@Excel(name = "驱动类型") @Excel(name = "驱动类型")
private String driveType; private String driveType;
/** 行驶里程 */
@Excel(name = "行驶里程")
private Long mileage;
/** 注册日期 */ /** 注册日期 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "注册日期", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "注册日期", width = 30, dateFormat = "yyyy-MM-dd")
@ -79,6 +71,12 @@ public class Car extends BaseEntity
@Excel(name = "所有者") @Excel(name = "所有者")
private Long ownerId; private Long ownerId;
@Excel(name = "是否报文")
private String message;
public void setCarId(Long carId) public void setCarId(Long carId)
{ {
this.carId = carId; this.carId = carId;
@ -124,15 +122,7 @@ public class Car extends BaseEntity
{ {
return manufactureYear; return manufactureYear;
} }
public void setBodyType(String bodyType)
{
this.bodyType = bodyType;
}
public String getBodyType()
{
return bodyType;
}
public void setColor(String color) public void setColor(String color)
{ {
this.color = color; this.color = color;
@ -178,15 +168,8 @@ public class Car extends BaseEntity
{ {
return driveType; return driveType;
} }
public void setMileage(Long mileage)
{
this.mileage = mileage;
}
public Long getMileage()
{
return mileage;
}
public void setRegistrationDate(Date registrationDate) public void setRegistrationDate(Date registrationDate)
{ {
this.registrationDate = registrationDate; this.registrationDate = registrationDate;
@ -215,6 +198,14 @@ public class Car extends BaseEntity
return ownerId; return ownerId;
} }
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -223,16 +214,15 @@ public class Car extends BaseEntity
.append("brand", getBrand()) .append("brand", getBrand())
.append("model", getModel()) .append("model", getModel())
.append("manufactureYear", getManufactureYear()) .append("manufactureYear", getManufactureYear())
.append("bodyType", getBodyType())
.append("color", getColor()) .append("color", getColor())
.append("engineCapacity", getEngineCapacity()) .append("engineCapacity", getEngineCapacity())
.append("fuelType", getFuelType()) .append("fuelType", getFuelType())
.append("transmission", getTransmission()) .append("transmission", getTransmission())
.append("driveType", getDriveType()) .append("driveType", getDriveType())
.append("mileage", getMileage())
.append("registrationDate", getRegistrationDate()) .append("registrationDate", getRegistrationDate())
.append("registrationNumber", getRegistrationNumber()) .append("registrationNumber", getRegistrationNumber())
.append("ownerId", getOwnerId()) .append("ownerId", getOwnerId())
.append("message",getMessage())
.toString(); .toString();
} }
} }

View File

@ -0,0 +1,32 @@
package com.business.common.domain;
import lombok.Data;
/**
*
* @ClassName DataFormat
* @Author GuanTieLin
* @Date 2024/6/26 14:15
*/
@Data
public class DataFormat {
/**
*
*/
private String dataCode;
/**
*
*/
private String label;
/**
*
*/
private Integer start;
/**
*
*/
private Integer end;
}

View File

@ -0,0 +1,183 @@
//package com.business.common.domain;
//
//import com.gtl.protocolParsing.domain.VehicleInfo;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import java.util.Arrays;
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * 报文解析工具
// * @ClassName MessageParsingUtils
// * @Author GuanTieLin
// * @Date 2024/5/30 13:47
// */
//@Component
//public class MessageParsingUtil {
//
// @Autowired
// private LocalCacheUtils localCacheUtils;
//
// public static Map<String,String> newParsing(String msg){
// HashMap<String, String> map = new HashMap<>();
// String[] part = msg.split(" ");
//
// return map;
// }
//
// public static VehicleInfo parsing(String msg){
// String[] part = msg.split(" ");
// //下标1-17是vin
// String vin = ConversionUtil.hexStringToString(splicing(part,1,18));
// //下标18-27是时间
// String time = ConversionUtil.hexStringToString(splicing(part,18,28));
// //下标31-40是经度
// String longitude = ConversionUtil.hexStringToString(splicing(part,31,41));
// //下标41-50是纬度
// String latitude = ConversionUtil.hexStringToString(splicing(part,41,51));
// //下标52-57是车速
// String speed = ConversionUtil.hexStringToString(splicing(part,52,58));
// //下标58-68是总里程
// String totalMileage = ConversionUtil.hexStringToString(splicing(part,58,69));
// //下标69-75是总电压
// String totalVoltage = ConversionUtil.hexStringToString(splicing(part,69,75));
// //下标75-79是总电流
// String totalCurrent = ConversionUtil.hexStringToString(splicing(part,75,80));
// //下标80-87是绝缘电阻
// String insulationResistance = ConversionUtil.hexStringToString(splicing(part,80,89));
// //下标89是档位
// String gears = ConversionUtil.hexStringToString(part[89]);
// //下标90-91是加速踏板行程值
// String acceleratorPedal = ConversionUtil.hexStringToString(splicing(part,90,92));
// //下标92-93是制动踏板行程值
// String brakePedal = ConversionUtil.hexStringToString(splicing(part,92,94));
// //下标94-98是燃料消耗率
// String fuelConsumptionRate = ConversionUtil.hexStringToString(splicing(part,94,99));
// //下标99-104是电机控制器温度
// String MotorControllerTemperature = ConversionUtil.hexStringToString(splicing(part,99,105));
// //下标104-109是电机转速
// String motorSpeed = ConversionUtil.hexStringToString(splicing(part,105,110));
// //下标110-113是电机转矩
// String motorTorque = ConversionUtil.hexStringToString(splicing(part,110,114));
// //下标114-119是电机温度
// String motorTemperature = ConversionUtil.hexStringToString(splicing(part,114,120));
// //下标120-124是电机电压
// String motorVoltage = ConversionUtil.hexStringToString(splicing(part,120,125));
// //下标125-132是电机电流
// String motorCurrent = ConversionUtil.hexStringToString(splicing(part,125,133));
// //下标133-138是动力电池剩余电量SOC
// String remainingPower = ConversionUtil.hexStringToString(splicing(part,133,139));
// //下标139-144是当前状态允许的最大反馈功率
// String maximumFeedbackPower = ConversionUtil.hexStringToString(splicing(part,139,145));
// //下标145-150是当前状态允许最大放电功率
// String maximumDischargePower = ConversionUtil.hexStringToString(splicing(part,145,151));
// //下标151-152是BMS自检计数器
// String selfTestCounter = ConversionUtil.hexStringToString(splicing(part,151,153));
// //下标153-157是动力电池充放电电流
// String batteryChargeOrDischargeCurrent = ConversionUtil.hexStringToString(splicing(part,153,158));
// //下标158-163是动力电池负载端总电压V3
// String totalVoltageV3 = ConversionUtil.hexStringToString(splicing(part,158,164));
// //下标164-167是单次最大电压
// String maximumVoltage = ConversionUtil.hexStringToString(splicing(part,164,168));
// //下标168-171是单体电池最低电压
// String minimumBatteryVoltage = ConversionUtil.hexStringToString(splicing(part,168,172));
// //下标172-177是单体电池最高温度
// String maximumBatteryTemperature = ConversionUtil.hexStringToString(splicing(part,172,178));
// //下标178-183是单体电池最低温度
// String minimumBatteryTemperature = ConversionUtil.hexStringToString(splicing(part,178,184));
// //下标184-189是动力电池可用容量
// String usableBatteryCapacity = ConversionUtil.hexStringToString(splicing(part,184,190));
// //下标190是车辆状态
// String vehicleStatus = ConversionUtil.hexStringToString(part[190]);
// //下标191是充电状态
// String chargeStatus = ConversionUtil.hexStringToString(part[191]);
// //下标192是运行状态
// String operationalStatus = ConversionUtil.hexStringToString(part[192]);
// //下标193是SOC
// String soc = ConversionUtil.hexStringToString(part[193]);
// //下标194是可充电储能装置工作状态
// String energyStorageDeviceWorkingStatus = ConversionUtil.hexStringToString(part[194]);
// //下标195是驱动电机状态
// String driveMotorStatus = ConversionUtil.hexStringToString(part[195]);
// //下标196是定位是否有效
// String positioningIsOrNotEffective = ConversionUtil.hexStringToString(part[196]);
// //下标197是EAS
// String eas = ConversionUtil.hexStringToString(part[197]);
// //下标198是PTC
// String ptc = ConversionUtil.hexStringToString(part[198]);
// //下标199是EPS
// String eps = ConversionUtil.hexStringToString(part[199]);
// //下标200是ABS
// String abs = ConversionUtil.hexStringToString(part[200]);
// //下标201是MCU
// String mcu = ConversionUtil.hexStringToString(part[201]);
// //下标202是动力电池加热状态
// String batteryHeatingStatus = ConversionUtil.hexStringToString(part[202]);
// //下标203是动力电池当前状态
// String batteryCurrentStatus = ConversionUtil.hexStringToString(part[203]);
// //下标204是动力电池保温状态
// String batteryInsulationStatus = ConversionUtil.hexStringToString(part[204]);
// //下标205是DCDC
// String dcdc = ConversionUtil.hexStringToString(part[205]);
// //下标206是CHG
// String chg = ConversionUtil.hexStringToString(part[206]);
// //下标207是校验位
// String checkDigit = ConversionUtil.hexStringToString(part[207]);
// return VehicleInfo.builder()
// .vin(vin)
// .time(time)
// .longitude(longitude)
// .latitude(latitude)
// .speed(speed)
// .totalMileage(totalMileage)
// .totalVoltage(totalVoltage)
// .totalCurrent(totalCurrent)
// .insulationResistance(insulationResistance)
// .gears(gears)
// .acceleratorPedal(acceleratorPedal)
// .brakePedal(brakePedal)
// .fuelConsumptionRate(fuelConsumptionRate)
// .MotorControllerTemperature(MotorControllerTemperature)
// .motorSpeed(motorSpeed)
// .motorTorque(motorTorque)
// .motorTemperature(motorTemperature)
// .motorVoltage(motorVoltage)
// .motorCurrent(motorCurrent)
// .remainingPower(remainingPower)
// .maximumFeedbackPower(maximumFeedbackPower)
// .maximumDischargePower(maximumDischargePower)
// .selfTestCounter(selfTestCounter)
// .batteryChargeOrDischargeCurrent(batteryChargeOrDischargeCurrent)
// .totalVoltageV3(totalVoltageV3)
// .maximumVoltage(maximumVoltage)
// .minimumBatteryVoltage(minimumBatteryVoltage)
// .maximumBatteryTemperature(maximumBatteryTemperature)
// .minimumBatteryTemperature(minimumBatteryTemperature)
// .usableBatteryCapacity(usableBatteryCapacity)
// .vehicleStatus(vehicleStatus)
// .chargeStatus(chargeStatus)
// .operationalStatus(operationalStatus)
// .soc(soc)
// .energyStorageDeviceWorkingStatus(energyStorageDeviceWorkingStatus)
// .driveMotorStatus(driveMotorStatus)
// .positioningIsOrNotEffective(positioningIsOrNotEffective)
// .eas(eas)
// .ptc(ptc)
// .eps(eps)
// .abs(abs)
// .mcu(mcu)
// .batteryHeatingStatus(batteryHeatingStatus)
// .batteryCurrentStatus(batteryCurrentStatus)
// .batteryInsulationStatus(batteryInsulationStatus)
// .dcdc(dcdc)
// .chg(chg)
// .checkDigit(checkDigit)
// .build();
// }
//
// public static String splicing(String[] part,int start,int end){
// return String.join("", Arrays.stream(Arrays.copyOfRange(part, start, end)).toList());
// }
//
//}

View File

@ -17,27 +17,27 @@ import lombok.experimental.SuperBuilder;
@AllArgsConstructor @AllArgsConstructor
public class VehicleInfo { public class VehicleInfo {
/** /**
* vin * vin1
*/ */
private String vin; private String vin;
/** /**
* * 1
*/ */
private String time; private String time;
/** /**
* * 1
*/ */
private String longitude; private String longitude;
/** /**
* * 1
*/ */
private String latitude; private String latitude;
/** /**
* * 1
*/ */
private String speed; private String speed;
/** /**
* * 1
*/ */
private String totalMileage; private String totalMileage;
/** /**
@ -53,7 +53,7 @@ public class VehicleInfo {
*/ */
private String insulationResistance; private String insulationResistance;
/** /**
* * 1
*/ */
private String gears; private String gears;
/** /**
@ -137,7 +137,7 @@ public class VehicleInfo {
*/ */
private String usableBatteryCapacity; private String usableBatteryCapacity;
/** /**
* * 3
*/ */
private String vehicleStatus; private String vehicleStatus;
/** /**

View File

@ -0,0 +1,22 @@
package com.business.common.domain.event;
import jdk.jfr.BooleanFlag;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Length {
/**
*
*/
private String lengthName;
/**
*
*/
private Double length;
}

View File

@ -0,0 +1,21 @@
package com.business.common.domain.event;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Radius {
/**
*
*/
private String radiusName;
/**
*
*/
private Integer radius;
}

View File

@ -0,0 +1,44 @@
package com.business.common.domain.event;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Window {
/**
*
*/
private Long id;
/**
*
*/
private String vin;
/**
*
*/
private String point;
/**
*
*/
private Integer standard;
/**
*
*/
private Date windowStartTime;
/**
*
*/
private Date windowEndTime;
/**
*
*/
private String result;
}

View File

@ -119,6 +119,11 @@
<artifactId>forest-spring-boot-starter</artifactId> <artifactId>forest-spring-boot-starter</artifactId>
<version>1.5.36</version> <version>1.5.36</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -0,0 +1,35 @@
package com.muyu.goods.Domain;
import jdk.jfr.BooleanFlag;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WindowDonain {
/**
*
*/
private String vin;
/**
*
*/
private String speed;
/**
*
*/
private Integer windowRadius;
/**
*
*/
private Double windowDistance;
/**
*
*/
private Integer windowStandard;
}

View File

@ -12,8 +12,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
@EnableMyFeignClients @EnableMyFeignClients
@EnableCustomConfig @EnableCustomConfig
@EnableAsync @EnableAsync
public class public class MuyuGoodsBusinessApplication {
MuyuGoodsBusinessApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(MuyuGoodsBusinessApplication.class,args); SpringApplication.run(MuyuGoodsBusinessApplication.class,args);
} }

View File

@ -0,0 +1,51 @@
package com.muyu.goods.controller;
import com.business.common.dev.DataFormatDev;
import com.business.common.domain.DataFormat;
import com.business.common.domain.event.Window;
import com.dtflys.forest.annotation.Post;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.LoginUser;
import com.muyu.goods.Domain.WindowDonain;
import com.muyu.goods.event.consumer.WindowListener;
import com.muyu.goods.service.IForewarnService;
import org.apache.kafka.common.protocol.types.Field;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@RequestMapping("forewarn")
public class ForewarnController extends BaseController {
@Autowired
private IForewarnService forewarnService;
@PostMapping("list")
public Result<List<Window>> list() {
return success(forewarnService.list());
}
//全部报文
@GetMapping("listDataFormat")
public Result<List<DataFormatDev>> listDataFormat() {
return success(forewarnService.listDataFormat());
}
//新增报文
@PostMapping("indexDataFormat")
public Result indexDataFormat(@RequestBody List<DataFormat> dataFormat,@RequestParam String vin) {
return success(forewarnService.indexDataFormat(dataFormat,vin));
}
//查询报文
@PostMapping("selectDataFormatById")
public Result<List<DataFormat>> selectDataFormatById(@RequestParam String vin) {
return success(forewarnService.selectDataFormatById(vin));
}
//删除报文
@PostMapping("deleteDataFormatById/{vin}")
public Result deleteDataFormatById(@PathVariable String vin) {
return success(forewarnService.deleteDataFormatById(vin));
}
}

View File

@ -0,0 +1,21 @@
package com.muyu.goods.event.consumer;
import lombok.Data;
import org.springframework.context.ApplicationEvent;
public class Consumer extends ApplicationEvent{
// 展示内容
private String name;
public Consumer(Object source) {
super(source);
}
public Consumer(Object source,String name) {
super(source);
this.name = name;
}
public String getName() {
return name;
}
}

View File

@ -0,0 +1,18 @@
package com.muyu.goods.event.consumer;
import com.muyu.goods.Domain.WindowDonain;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
@Component
@Log4j2
public class WindowListener {
@SneakyThrows
@EventListener(WindowDonain.class)
public void sendMsh(WindowDonain windowDonain){
log.info("启动:{}",windowDonain);
}
}

View File

@ -0,0 +1,16 @@
package com.muyu.goods.event.producer;
import com.muyu.goods.event.consumer.Consumer;
import lombok.extern.log4j.Log4j2;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
@Service
@Log4j2
public class CouponService {
@EventListener
public void addCoupon(Consumer consumer) {
log.info("addCoupon发布消息给{}",consumer.getName());
}
}

View File

@ -0,0 +1,18 @@
package com.muyu.goods.event.producer;
import com.muyu.goods.event.consumer.Consumer;
import lombok.extern.log4j.Log4j2;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@Service
@Log4j2
public class EmailService implements ApplicationListener<Consumer> {
@Override
@Async
public void onApplicationEvent(Consumer consumer) {
log.info("EmailService发送信息给{}",consumer);
}
}

View File

@ -0,0 +1,25 @@
package com.muyu.goods.event.producer;
import com.muyu.goods.event.consumer.Consumer;
import lombok.extern.log4j.Log4j2;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
@Service
@Log4j2
public class UserService implements ApplicationEventPublisherAware {
private ApplicationEventPublisher applicationEventPublisher;
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.applicationEventPublisher = applicationEventPublisher;
}
public void register(String name) {
//执行逻辑
log.info("执行user逻辑");
//发布
applicationEventPublisher.publishEvent(new Consumer(this,name));
}
}

View File

@ -0,0 +1,20 @@
package com.muyu.goods.mapper;
import com.business.common.dev.DataFormatDev;
import com.business.common.domain.DataFormat;
import com.business.common.domain.event.Window;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ForewarnMapper {
List<Window> list();
List<DataFormatDev> listDataFormat();
Integer indexDataFormat(@Param("dataFormat") List<DataFormatDev> dataFormat);
Integer deleteDataFormatById(@Param("vin") String vin);
List<DataFormat> selectDataFormatById(@Param("vin") String vin);
}

View File

@ -0,0 +1,37 @@
package com.muyu.goods.service;
import com.business.common.dev.DataFormatDev;
import com.business.common.domain.DataFormat;
import com.business.common.domain.event.Window;
import java.util.List;
public interface IForewarnService {
List<Window> list();
/**
*
* @return
*/
List<DataFormatDev> listDataFormat();
/**
*
* @return
*/
List<DataFormat> selectDataFormatById(String vin);
/**
*
* @param dataFormat
* @return
*/
Integer indexDataFormat(List<DataFormat> dataFormat,String vin);
/**
*
* @return
*/
Integer deleteDataFormatById(String vin);
}

View File

@ -94,7 +94,6 @@ public class CarServiceImpl implements ICarService
} }
System.out.println(enterprise); System.out.println(enterprise);
car.setOwnerId(enterprise.getId()); car.setOwnerId(enterprise.getId());
car.setVin(UUID.randomUUID().toString().replaceAll("-",""));
int i = carMapper.insertCar(car); int i = carMapper.insertCar(car);
if (i>0) { if (i>0) {
Car car1 = carMapper.carByCar(); Car car1 = carMapper.carByCar();
@ -172,10 +171,6 @@ public class CarServiceImpl implements ICarService
if (rightPopAndLeftPush != null){ if (rightPopAndLeftPush != null){
String parse = JSON.parse(rightPopAndLeftPush).toString(); String parse = JSON.parse(rightPopAndLeftPush).toString();
VehicleInfo vehicleInfo = JSON.parseObject(parse, VehicleInfo.class); VehicleInfo vehicleInfo = JSON.parseObject(parse, VehicleInfo.class);
// LongitudeAndLatitude longitudeAndLatitude = LongitudeAndLatitude.builder()
// .latitude(latitude)
// .longitude(longitude)
// .build();
return vehicleInfo; return vehicleInfo;
}else{ }else{
return null; return null;

View File

@ -0,0 +1,103 @@
package com.muyu.goods.service.impl;
import com.business.common.dev.DataFormatDev;
import com.business.common.domain.DataFormat;
import com.business.common.domain.event.Window;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.goods.mapper.ForewarnMapper;
import com.muyu.goods.service.IForewarnService;
import org.apache.kafka.common.protocol.types.Field;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class ForewarnService implements IForewarnService {
@Autowired
private ForewarnMapper forewarnMapper;
@Autowired
private RedisTemplate<String,String> redisTemplate;
@Override
public List<Window> list() {
return forewarnMapper.list();
}
/**
*
* @return
*/
@Override
public List<DataFormatDev> listDataFormat() {
Map<String, String> map = new HashMap<>();
List<DataFormatDev> list = forewarnMapper.listDataFormat();
Map<String, List<DataFormatDev>> collect = list.stream().collect(Collectors.groupingBy(DataFormatDev::getVin));
collect.forEach((a,b) -> {
String name = "";
for (DataFormatDev dataFormatDev : b) {
name+= dataFormatDev.getDataCode()+"-"+dataFormatDev.getLabel()+"-"+dataFormatDev.getStart()+"-"+dataFormatDev.getEnd()+",";
}
name = name.substring(0,name.length()-1);
map.put(a,name);
});
map.forEach((key,val) -> {
redisTemplate.opsForHash().put("protocol_parsing:data_format",key,val);
});
return list;
}
/**
*
* @return
*/
@Override
public List<DataFormat> selectDataFormatById(String vin) {
List<DataFormat> dataFormatList = forewarnMapper.selectDataFormatById(vin);
if (dataFormatList.size()>0){
return dataFormatList;
}
return null;
}
/**
*
* @param dataFormat
* @return
*/
@Override
public Integer indexDataFormat(List<DataFormat> dataFormat, String vin) {
deleteDataFormatById(vin);
List<DataFormatDev> list = new ArrayList<>();
for (DataFormat format : dataFormat) {
DataFormatDev dataFormatDev = DataFormatDev.builder()
.vin(vin)
.dataCode(format.getDataCode())
.label(format.getLabel())
.start(format.getStart())
.end(format.getEnd())
.build();
list.add(dataFormatDev);
}
//再添加新报文
return forewarnMapper.indexDataFormat(list);
}
/**
*
* @return
*/
@Override
public Integer deleteDataFormatById(String vin) {
return forewarnMapper.deleteDataFormatById(vin);
}
}

View File

@ -72,7 +72,7 @@ public class MapService implements IMapService {
/** /**
* *
* @param pences * @param list
* @return * @return
*/ */
@Override @Override

View File

@ -10,20 +10,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="brand" column="brand" /> <result property="brand" column="brand" />
<result property="model" column="model" /> <result property="model" column="model" />
<result property="manufactureYear" column="manufacture_year" /> <result property="manufactureYear" column="manufacture_year" />
<result property="bodyType" column="body_type" />
<result property="color" column="color" /> <result property="color" column="color" />
<result property="engineCapacity" column="engine_capacity" /> <result property="engineCapacity" column="engine_capacity" />
<result property="fuelType" column="fuel_type" /> <result property="fuelType" column="fuel_type" />
<result property="transmission" column="transmission" /> <result property="transmission" column="transmission" />
<result property="driveType" column="drive_type" /> <result property="driveType" column="drive_type" />
<result property="mileage" column="mileage" />
<result property="registrationDate" column="registration_date" /> <result property="registrationDate" column="registration_date" />
<result property="registrationNumber" column="registration_number" /> <result property="registrationNumber" column="registration_number" />
<result property="ownerId" column="owner_id" /> <result property="ownerId" column="owner_id" />
</resultMap> </resultMap>
<sql id="selectCarVo"> <sql id="selectCarVo">
select car_id, vin, brand, model, manufacture_year, body_type, color, engine_capacity, fuel_type, transmission, drive_type, mileage, registration_date, registration_number, owner_id from car select car_id, vin, brand, model, manufacture_year, color, engine_capacity, fuel_type, transmission, drive_type, registration_date, registration_number, owner_id from car
</sql> </sql>
<select id="selectCarList" parameterType="com.business.common.domain.Car" resultMap="CarResult"> <select id="selectCarList" parameterType="com.business.common.domain.Car" resultMap="CarResult">
@ -57,13 +55,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="brand != null">brand,</if> <if test="brand != null">brand,</if>
<if test="model != null">model,</if> <if test="model != null">model,</if>
<if test="manufactureYear != null">manufacture_year,</if> <if test="manufactureYear != null">manufacture_year,</if>
<if test="bodyType != null">body_type,</if>
<if test="color != null">color,</if> <if test="color != null">color,</if>
<if test="engineCapacity != null">engine_capacity,</if> <if test="engineCapacity != null">engine_capacity,</if>
<if test="fuelType != null">fuel_type,</if> <if test="fuelType != null">fuel_type,</if>
<if test="transmission != null">transmission,</if> <if test="transmission != null">transmission,</if>
<if test="driveType != null">drive_type,</if> <if test="driveType != null">drive_type,</if>
<if test="mileage != null">mileage,</if>
<if test="registrationDate != null">registration_date,</if> <if test="registrationDate != null">registration_date,</if>
<if test="registrationNumber != null">registration_number,</if> <if test="registrationNumber != null">registration_number,</if>
<if test="ownerId != null">owner_id,</if> <if test="ownerId != null">owner_id,</if>
@ -73,13 +69,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="brand != null">#{brand},</if> <if test="brand != null">#{brand},</if>
<if test="model != null">#{model},</if> <if test="model != null">#{model},</if>
<if test="manufactureYear != null">#{manufactureYear},</if> <if test="manufactureYear != null">#{manufactureYear},</if>
<if test="bodyType != null">#{bodyType},</if>
<if test="color != null">#{color},</if> <if test="color != null">#{color},</if>
<if test="engineCapacity != null">#{engineCapacity},</if> <if test="engineCapacity != null">#{engineCapacity},</if>
<if test="fuelType != null">#{fuelType},</if> <if test="fuelType != null">#{fuelType},</if>
<if test="transmission != null">#{transmission},</if> <if test="transmission != null">#{transmission},</if>
<if test="driveType != null">#{driveType},</if> <if test="driveType != null">#{driveType},</if>
<if test="mileage != null">#{mileage},</if>
<if test="registrationDate != null">#{registrationDate},</if> <if test="registrationDate != null">#{registrationDate},</if>
<if test="registrationNumber != null">#{registrationNumber},</if> <if test="registrationNumber != null">#{registrationNumber},</if>
<if test="ownerId != null">#{ownerId},</if> <if test="ownerId != null">#{ownerId},</if>
@ -93,13 +87,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="brand != null">brand = #{brand},</if> <if test="brand != null">brand = #{brand},</if>
<if test="model != null">model = #{model},</if> <if test="model != null">model = #{model},</if>
<if test="manufactureYear != null">manufacture_year = #{manufactureYear},</if> <if test="manufactureYear != null">manufacture_year = #{manufactureYear},</if>
<if test="bodyType != null">body_type = #{bodyType},</if>
<if test="color != null">color = #{color},</if> <if test="color != null">color = #{color},</if>
<if test="engineCapacity != null">engine_capacity = #{engineCapacity},</if> <if test="engineCapacity != null">engine_capacity = #{engineCapacity},</if>
<if test="fuelType != null">fuel_type = #{fuelType},</if> <if test="fuelType != null">fuel_type = #{fuelType},</if>
<if test="transmission != null">transmission = #{transmission},</if> <if test="transmission != null">transmission = #{transmission},</if>
<if test="driveType != null">drive_type = #{driveType},</if> <if test="driveType != null">drive_type = #{driveType},</if>
<if test="mileage != null">mileage = #{mileage},</if>
<if test="registrationDate != null">registration_date = #{registrationDate},</if> <if test="registrationDate != null">registration_date = #{registrationDate},</if>
<if test="registrationNumber != null">registration_number = #{registrationNumber},</if> <if test="registrationNumber != null">registration_number = #{registrationNumber},</if>
</trim> </trim>

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.goods.mapper.ForewarnMapper">
<resultMap type="com.business.common.domain.event.Window" id="WindowResult">
<result property="id" column="id" />
<result property="vin" column="vin" />
<result property="point" column="point" />
<result property="standard" column="standard" />
<result property="windowStartTime" column="window_start_time" />
<result property="windowEndTime" column="window_end_time" />
<result property="result" column="result" />
</resultMap>
<resultMap id="RadiusResult" type="com.business.common.domain.event.Radius">
<result property="radiusName" column="radius_name" />
<result property="radius" column="radius" />
</resultMap>
<resultMap id="LengthResult" type="com.business.common.domain.event.Length">
<result property="lengthName" column="length_name" />
<result property="length" column="length" />
</resultMap>
<resultMap id="dataFormat" type="com.business.common.domain.DataFormat">
<result property="dataCode" column="data_code"></result>
<result property="label" column="label"></result>
<result property="start" column="start"></result>
<result property="end" column="end"></result>
</resultMap>
<sql id="selectWindowVo">
select id, vin, point, standard, window_start_time, window_end_time, result from window
</sql>
<sql id="selectDataFormat">
select data_code, label, start,end from data_format
</sql>
<insert id="indexDataFormat" >
insert into data_format
values
<foreach collection="dataFormat" item="list" separator=",">
(#{list.vin},#{list.dataCode},#{list.label},#{list.start},#{list.end})
</foreach>
</insert>
<delete id="deleteDataFormatById">
delete
from data_format
where vin = #{vin};
</delete>
<select id="list" resultType="com.business.common.domain.event.Window">
<include refid="selectWindowVo"></include>
</select>
<select id="listDataFormat" resultType="com.business.common.dev.DataFormatDev">
select * from data_format
</select>
<select id="selectDataFormatById" resultType="com.business.common.domain.DataFormat">
<include refid="selectDataFormat"></include>
where vin = #{vin}
</select>
</mapper>