Merge remote-tracking branch 'origin/dev.template'
# Conflicts: # cloud-modules/cloud-modules-car/pom.xml # cloud-modules/cloud-modules-car/src/main/java/com/muyu/controller/CarTypeController.java # cloud-modules/cloud-modules-car/src/main/java/com/muyu/controller/SysCarController.java # cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/SysCarLog.java # cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/req/SysCarReq.java # cloud-modules/cloud-modules-car/src/main/java/com/muyu/mapper/CarTypeMapper.java # cloud-modules/cloud-modules-car/src/main/java/com/muyu/mapper/SysCarMapper.java # cloud-modules/cloud-modules-car/src/main/java/com/muyu/service/CarTypeService.java # cloud-modules/cloud-modules-car/src/main/java/com/muyu/service/SysCarService.java # cloud-modules/cloud-modules-car/src/main/java/com/muyu/service/impl/CarTypeServiceImpl.java # cloud-modules/cloud-modules-car/src/main/java/com/muyu/service/impl/SysCarServiceImpl.java # cloud-modules/cloud-modules-car/src/main/resources/bootstrap.yml # cloud-modules/cloud-modules-car/src/main/resources/mapper/SysCarMapper.xmldev
commit
ffe75448b9
|
@ -87,7 +87,6 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>${project.artifactId}</finalName>
|
<finalName>${project.artifactId}</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
|
@ -4,9 +4,7 @@ import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.domain.CarType;
|
import com.muyu.domain.CarType;
|
||||||
import com.muyu.service.CarTypeService;
|
import com.muyu.service.CarTypeService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -16,6 +14,10 @@ public class CarTypeController {
|
||||||
private CarTypeService carTypeService;
|
private CarTypeService carTypeService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*车辆类型列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@GetMapping("/selectCarTypeList")
|
@GetMapping("/selectCarTypeList")
|
||||||
public Result selectCarTypeList(){
|
public Result selectCarTypeList(){
|
||||||
return Result.success(carTypeService.selectCarTypeList());
|
return Result.success(carTypeService.selectCarTypeList());
|
||||||
|
@ -23,4 +25,6 @@ public class CarTypeController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,4 +45,6 @@ public class SysCarController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import java.util.Date;
|
||||||
@TableName(value = "sys_car_log",autoResultMap = true)
|
@TableName(value = "sys_car_log",autoResultMap = true)
|
||||||
public class SysCarLog {
|
public class SysCarLog {
|
||||||
|
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String carVin;
|
private String carVin;
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
|
|
@ -15,5 +15,4 @@ public class SysCarReq {
|
||||||
private String carMotorModel;
|
private String carMotorModel;
|
||||||
private String carBatteryManufacturer;
|
private String carBatteryManufacturer;
|
||||||
private String carBatteryModel;
|
private String carBatteryModel;
|
||||||
private String state;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,10 @@ package com.muyu.mapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.domain.CarType;
|
import com.muyu.domain.CarType;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
|
||||||
public interface CarTypeMapper extends BaseMapper<CarType> {
|
public interface CarTypeMapper extends BaseMapper<CarType> {
|
||||||
|
CarType findCarTypeById(@Param("carTypeId") Long carTypeId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,4 +17,6 @@ public interface SysCarMapper extends BaseMapper<SysCar> {
|
||||||
|
|
||||||
SysCarVo selectSysCarVoById(@Param("id") Long id);
|
SysCarVo selectSysCarVoById(@Param("id") Long id);
|
||||||
|
|
||||||
|
SysCar findCarByVin(@Param("carVin") String carVin);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,4 +10,6 @@ import java.util.List;
|
||||||
public interface CarTypeService extends IService<CarType> {
|
public interface CarTypeService extends IService<CarType> {
|
||||||
List<CarType> selectCarTypeList();
|
List<CarType> selectCarTypeList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,4 +16,7 @@ public interface SysCarService {
|
||||||
int deleteSysCarById(Long id);
|
int deleteSysCarById(Long id);
|
||||||
|
|
||||||
int updateSysCar(SysCar sysCar);
|
int updateSysCar(SysCar sysCar);
|
||||||
|
|
||||||
|
SysCar findCarByVin(String carVin);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,4 +19,5 @@ private CarTypeMapper carTypeMapper;
|
||||||
QueryWrapper<CarType> carTypeQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<CarType> carTypeQueryWrapper = new QueryWrapper<>();
|
||||||
return carTypeMapper.selectList(carTypeQueryWrapper);
|
return carTypeMapper.selectList(carTypeQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.muyu.service.impl;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.domain.SysCar;
|
import com.muyu.domain.SysCar;
|
||||||
import com.muyu.domain.req.SysCarReq;
|
import com.muyu.domain.req.SysCarReq;
|
||||||
|
|
||||||
import com.muyu.domain.resp.SysCarVo;
|
import com.muyu.domain.resp.SysCarVo;
|
||||||
import com.muyu.mapper.SysCarMapper;
|
import com.muyu.mapper.SysCarMapper;
|
||||||
import com.muyu.service.SysCarService;
|
import com.muyu.service.SysCarService;
|
||||||
|
@ -40,4 +39,9 @@ public class SysCarServiceImpl extends ServiceImpl<SysCarMapper,SysCar> impleme
|
||||||
public int updateSysCar(SysCar sysCar) {
|
public int updateSysCar(SysCar sysCar) {
|
||||||
return sysCarMapper.updateById(sysCar);
|
return sysCarMapper.updateById(sysCar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysCar findCarByVin(String carVin) {
|
||||||
|
return sysCarMapper.findCarByVin(carVin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?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.mapper.CarTypeMapper">
|
||||||
|
|
||||||
|
<select id="findCarTypeById" resultType="com.muyu.domain.CarType">
|
||||||
|
select * from car_type where id=#{carTypeId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -3,16 +3,6 @@
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.muyu.mapper.SysCarMapper">
|
<mapper namespace="com.muyu.mapper.SysCarMapper">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<select id="selectSysCarVoById" resultType="com.muyu.domain.resp.SysCarVo">
|
|
||||||
SELECT * ,car_type.type_name,tb_fence.fence_name
|
|
||||||
FROM `sys_car`
|
|
||||||
LEFT JOIN car_type ON sys_car.car_type_id=car_type.id
|
|
||||||
LEFT JOIN tb_fence ON sys_car.fence_id=tb_fence.fence_id
|
|
||||||
where sys_car.id=#{id}
|
|
||||||
</select>
|
|
||||||
<select id="selectSysCarVoList" resultType="com.muyu.domain.resp.SysCarVo">
|
<select id="selectSysCarVoList" resultType="com.muyu.domain.resp.SysCarVo">
|
||||||
SELECT * ,car_type.type_name,tb_fence.fence_name
|
SELECT * ,car_type.type_name,tb_fence.fence_name
|
||||||
FROM `sys_car`
|
FROM `sys_car`
|
||||||
|
@ -23,10 +13,10 @@
|
||||||
sys_car.car_vin=#{carVin}
|
sys_car.car_vin=#{carVin}
|
||||||
</if>
|
</if>
|
||||||
<if test="state!=null and state!=''">
|
<if test="state!=null and state!=''">
|
||||||
and sys_car.state=#{state}
|
and sys_car.state=#{state}
|
||||||
</if>
|
</if>
|
||||||
<if test="carMotorManufacturer!=null and carMotorManufacturer!=''">
|
<if test="carMotorManufacturer!=null and carMotorManufacturer!=''">
|
||||||
and sys_car.car_motor_manufacturer=#{carMotorManufacturer}
|
and sys_car.car_motor_manufacturer=#{carMotorManufacturer}
|
||||||
</if>
|
</if>
|
||||||
<if test="carBatteryManufacturer!=null and carBatteryManufacturer!=''">
|
<if test="carBatteryManufacturer!=null and carBatteryManufacturer!=''">
|
||||||
and sys_car.car_battery_manufacturer=#{carBatteryManufacturer}
|
and sys_car.car_battery_manufacturer=#{carBatteryManufacturer}
|
||||||
|
@ -39,4 +29,16 @@
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectSysCarVoById" resultType="com.muyu.domain.resp.SysCarVo">
|
||||||
|
SELECT * ,car_type.type_name,tb_fence.fence_name
|
||||||
|
FROM `sys_car`
|
||||||
|
LEFT JOIN car_type ON sys_car.car_type_id=car_type.id
|
||||||
|
LEFT JOIN tb_fence ON sys_car.fence_id=tb_fence.fence_id
|
||||||
|
where sys_car.id=#{id}
|
||||||
|
</select>
|
||||||
|
<select id="findCarByVin" resultType="com.muyu.domain.SysCar">
|
||||||
|
select * from sys_car where car_vin=#{carVin}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -26,6 +26,41 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!--iotdb依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.iotdb</groupId>
|
||||||
|
<artifactId>iotdb-session</artifactId>
|
||||||
|
<version>0.13.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.iotdb</groupId>
|
||||||
|
<artifactId>iotdb-jdbc</artifactId>
|
||||||
|
<version>0.13.2</version>
|
||||||
|
</dependency>
|
||||||
|
<!--mybatis依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>2.2.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
<version>3.5.5</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>mybatis-spring</artifactId>
|
||||||
|
<groupId>org.mybatis</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis</groupId>
|
||||||
|
<artifactId>mybatis-spring</artifactId>
|
||||||
|
<version>3.0.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Nacos Config -->
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package com.template;
|
package com.template;
|
||||||
|
|
||||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:liuxinyue
|
* @Author:liuxinyue
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.template.controller;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.template.domain.CarType;
|
||||||
|
import com.template.domain.SysCar;
|
||||||
|
import com.template.service.CarService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liuxinyue
|
||||||
|
* @Package:com.template.controller
|
||||||
|
* @Project:cloud-server
|
||||||
|
* @name:CarController
|
||||||
|
* @Date:2024/9/21 9:25
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/car")
|
||||||
|
public class CarController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CarService carService;
|
||||||
|
/**
|
||||||
|
* 根据VIN码查询车信息
|
||||||
|
* @param carVin
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/findCarByVin")
|
||||||
|
public Result<SysCar> findCarByVin(@RequestParam String carVin){
|
||||||
|
return Result.success(carService.findCarByVin(carVin));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据类型ID获取车辆类型
|
||||||
|
* @param carTypeId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/findCarTypeById")
|
||||||
|
public Result<CarType> findCarTypeById(@RequestParam Long carTypeId) {
|
||||||
|
return Result.success(carService.findCarTypeById(carTypeId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -27,6 +27,10 @@ public class DataTypeController {
|
||||||
private DataTypeService dataTypeService;
|
private DataTypeService dataTypeService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据类型列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PostMapping("/dataTypeList")
|
@PostMapping("/dataTypeList")
|
||||||
public Result<List<DataType>> dataTypeList() {
|
public Result<List<DataType>> dataTypeList() {
|
||||||
return Result.success(dataTypeService.dataTypeList());
|
return Result.success(dataTypeService.dataTypeList());
|
||||||
|
|
|
@ -78,4 +78,13 @@ public class MessageTemplateTypeController {
|
||||||
return Result.success(messageTemplateTypeService.finddeviceStatusData(templatedId,code));
|
return Result.success(messageTemplateTypeService.finddeviceStatusData(templatedId,code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据车辆类型查出所对应的模版
|
||||||
|
* @param templateName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/findMessageByTemplateName")
|
||||||
|
public Result<List<MessageTemplateType>> findMessageByTemplateName(@RequestParam("templatedId") Integer templatedId) {
|
||||||
|
return Result.success(messageTemplateTypeService.findMessageByTemplateName(templatedId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,27 @@ public class TemplateController {
|
||||||
private TemplateService templateService;
|
private TemplateService templateService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文模版列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PostMapping("/templateList")
|
@PostMapping("/templateList")
|
||||||
public Result<List<Template>> templateList() {
|
public Result<List<Template>> templateList() {
|
||||||
return Result.success(templateService.templateList());
|
return Result.success(templateService.templateList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析报文
|
||||||
|
* @param templateMessage
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/messageParsing")
|
||||||
|
public Result messageParsing(@RequestParam("templateMessage") String templateMessage){
|
||||||
|
templateService.messageParsing(templateMessage);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.template.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName(value = "car_type",autoResultMap = true)
|
||||||
|
public class CarType {
|
||||||
|
@TableId(value = "id")
|
||||||
|
private Long id;
|
||||||
|
private String typeName;
|
||||||
|
private Long messageId;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
package com.template.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.sql.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liuxinyue
|
||||||
|
* @Package:com.template.domain
|
||||||
|
* @Project:cloud-server
|
||||||
|
* @name:MessageTemplate
|
||||||
|
* @Date:2024/9/21 12:09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
@EqualsAndHashCode(callSuper=false)
|
||||||
|
public class MessageTemplate {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
private Integer messageId;
|
||||||
|
/**
|
||||||
|
* 车辆VIN码
|
||||||
|
*/
|
||||||
|
private String vinCode;
|
||||||
|
/**
|
||||||
|
* 时间戳
|
||||||
|
*/
|
||||||
|
private Date timeStamp;
|
||||||
|
private String longItude;
|
||||||
|
private String latitude;
|
||||||
|
private String speedVehicle;
|
||||||
|
private String totalMileage;
|
||||||
|
private String totalVoltage;
|
||||||
|
private String combinedCurrent;
|
||||||
|
private String insulationResistance;
|
||||||
|
private String gearPosition;
|
||||||
|
private String acceleratorPedalTravelValue;
|
||||||
|
private String brakePedalTravelValue;
|
||||||
|
private String specificFuelConsumption;
|
||||||
|
private String motorControllerTemperature;
|
||||||
|
private String motorSpeed;
|
||||||
|
private String motorTorque;
|
||||||
|
private String motorTemperature;
|
||||||
|
private String motorVoltage;
|
||||||
|
private String motorCurrent;
|
||||||
|
private String powerBatteryRemainingSoc;
|
||||||
|
private String maximumFeedbackPower;
|
||||||
|
private String maximumDischargePower;
|
||||||
|
private String bmsSelfCheckCounter;
|
||||||
|
private String powerBattery;
|
||||||
|
private String totalVoltageLoadSide;
|
||||||
|
private String maximumVoltage;
|
||||||
|
private String minimumVoltage;
|
||||||
|
private String maximumTemperature;
|
||||||
|
private String minimumTemperature;
|
||||||
|
private String availableCapacity;
|
||||||
|
private String vehicleStatus;
|
||||||
|
private String chargingState;
|
||||||
|
private String operationalStatus;
|
||||||
|
private String soc;
|
||||||
|
private String energyStorageDevices;
|
||||||
|
private String driveMotorCondition;
|
||||||
|
private String whetherWorks;
|
||||||
|
private String eas;
|
||||||
|
private String ptc;
|
||||||
|
private String eps;
|
||||||
|
private String abs;
|
||||||
|
private String mcu;
|
||||||
|
private String heatingState;
|
||||||
|
private String powerBatteryStatus;
|
||||||
|
private String stateBatteryInsulation;
|
||||||
|
private String dcdc;
|
||||||
|
private String chg;
|
||||||
|
private String checkDigit;
|
||||||
|
private String cutoffBit;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.template.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName(value = "sys_car",autoResultMap = true)
|
||||||
|
public class SysCar extends BaseEntity {
|
||||||
|
@TableId(value = "id")
|
||||||
|
private Long id;
|
||||||
|
private String carVin;
|
||||||
|
private Long carTypeId;
|
||||||
|
private String state;
|
||||||
|
private Long fenceId;
|
||||||
|
private String carMotorManufacturer;
|
||||||
|
private String carMotorModel;
|
||||||
|
private String carBatteryManufacturer;
|
||||||
|
private String carBatteryModel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.template.mapper;
|
||||||
|
|
||||||
|
import com.template.domain.CarType;
|
||||||
|
import com.template.domain.SysCar;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liuxinyue
|
||||||
|
* @Package:com.template.mapper
|
||||||
|
* @Project:cloud-server
|
||||||
|
* @name:CarMapper
|
||||||
|
* @Date:2024/9/21 9:26
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface CarMapper {
|
||||||
|
|
||||||
|
SysCar findCarByVin(@Param("carVin") String carVin);
|
||||||
|
|
||||||
|
CarType carMapper(@Param("carTypeId") Long carTypeId);
|
||||||
|
|
||||||
|
}
|
|
@ -30,4 +30,6 @@ public interface MessageTemplateTypeMapper {
|
||||||
|
|
||||||
List<MessageTemplateType> findvehicleData(@Param("templatedId") Integer templatedId, @Param("code") String code);
|
List<MessageTemplateType> findvehicleData(@Param("templatedId") Integer templatedId, @Param("code") String code);
|
||||||
|
|
||||||
|
List<MessageTemplateType> findMessageByTemplateName(@Param("templatedId") Integer templatedId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,4 +18,6 @@ public interface TemplateMapper {
|
||||||
List<Template> templateList();
|
List<Template> templateList();
|
||||||
|
|
||||||
|
|
||||||
|
Template findTemplateByName(@Param("typeName") String typeName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.template.service;
|
||||||
|
|
||||||
|
import com.template.domain.CarType;
|
||||||
|
import com.template.domain.SysCar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liuxinyue
|
||||||
|
* @Package:com.template.service
|
||||||
|
* @Project:cloud-server
|
||||||
|
* @name:CarService
|
||||||
|
* @Date:2024/9/21 9:25
|
||||||
|
*/
|
||||||
|
public interface CarService {
|
||||||
|
SysCar findCarByVin(String carVin);
|
||||||
|
|
||||||
|
CarType findCarTypeById(Long carTypeId);
|
||||||
|
|
||||||
|
}
|
|
@ -27,4 +27,6 @@ public interface MessageTemplateTypeService {
|
||||||
|
|
||||||
List<MessageTemplateType> finddeviceStatusData(Integer templatedId, String code);
|
List<MessageTemplateType> finddeviceStatusData(Integer templatedId, String code);
|
||||||
|
|
||||||
|
List<MessageTemplateType> findMessageByTemplateName(Integer templatedId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,4 +15,6 @@ public interface TemplateService {
|
||||||
List<Template> templateList();
|
List<Template> templateList();
|
||||||
|
|
||||||
|
|
||||||
|
void messageParsing(String templateMessage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.template.service.impl;
|
||||||
|
|
||||||
|
import com.template.domain.CarType;
|
||||||
|
import com.template.domain.SysCar;
|
||||||
|
import com.template.mapper.CarMapper;
|
||||||
|
import com.template.service.CarService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liuxinyue
|
||||||
|
* @Package:com.template.service.impl
|
||||||
|
* @Project:cloud-server
|
||||||
|
* @name:CarServiceImpl
|
||||||
|
* @Date:2024/9/21 9:26
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CarServiceImpl implements CarService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CarMapper carMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysCar findCarByVin(String carVin) {
|
||||||
|
return carMapper.findCarByVin(carVin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CarType findCarTypeById(Long carTypeId) {
|
||||||
|
return carMapper.carMapper(carTypeId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,4 +47,9 @@ public class MessageTemplateTypeServiceImpl implements MessageTemplateTypeServi
|
||||||
public List<MessageTemplateType> finddeviceStatusData(Integer templatedId, String code) {
|
public List<MessageTemplateType> finddeviceStatusData(Integer templatedId, String code) {
|
||||||
return messageTemplateTypeMapper.finddeviceStatusData(templatedId,code);
|
return messageTemplateTypeMapper.finddeviceStatusData(templatedId,code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MessageTemplateType> findMessageByTemplateName(Integer templatedId) {
|
||||||
|
return messageTemplateTypeMapper.findMessageByTemplateName(templatedId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
package com.template.service.impl;
|
package com.template.service.impl;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.template.domain.Template;
|
import com.template.domain.*;
|
||||||
import com.template.mapper.TemplateMapper;
|
import com.template.mapper.TemplateMapper;
|
||||||
|
import com.template.service.CarService;
|
||||||
|
import com.template.service.MessageTemplateTypeService;
|
||||||
import com.template.service.TemplateService;
|
import com.template.service.TemplateService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:liuxinyue
|
* @Author:liuxinyue
|
||||||
* @Package:com.template.service.impl
|
* @Package:com.template.service.impl
|
||||||
|
@ -21,9 +23,102 @@ public class TemplateServiceImpl implements TemplateService{
|
||||||
@Autowired
|
@Autowired
|
||||||
private TemplateMapper templateMapper;
|
private TemplateMapper templateMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CarService carService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MessageTemplateTypeService messageTemplateTypeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Template> templateList() {
|
public List<Template> templateList() {
|
||||||
return templateMapper.templateList();
|
return templateMapper.templateList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void messageParsing(String templateMessage) {
|
||||||
|
//新能源车里面有的配置
|
||||||
|
MessageTemplate messageTemplate = new MessageTemplate();
|
||||||
|
//先截取出VIN码 然后根据VIN码查询这个车属于什么类型
|
||||||
|
if(templateMessage.length()<18){
|
||||||
|
throw new RuntimeException("The vehicle message is incorrect");
|
||||||
|
}
|
||||||
|
//将报文进行切割
|
||||||
|
String[] hexArray = templateMessage.split(" ");
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
for (String hex : hexArray) {
|
||||||
|
int decimal = Integer.parseInt(hex, 16);
|
||||||
|
result.append((char) decimal);
|
||||||
|
}
|
||||||
|
//取出VIN码
|
||||||
|
String carVin = result.substring(0, 18-1);
|
||||||
|
System.out.println("carVin码为:"+carVin);
|
||||||
|
//根据VIN码获取车辆信息
|
||||||
|
SysCar carByVin = carService.findCarByVin(carVin);
|
||||||
|
if(carByVin==null){
|
||||||
|
throw new RuntimeException("Check this car!!");
|
||||||
|
}else{
|
||||||
|
//根据车辆类型ID获取车辆类型名称
|
||||||
|
CarType carTypeById = carService.findCarTypeById(carByVin.getCarTypeId());
|
||||||
|
//查询报文模版
|
||||||
|
Template templateDate=templateMapper.findTemplateByName(carTypeById.getTypeName());
|
||||||
|
//根据报文模版的ID查询对应的模版
|
||||||
|
List<MessageTemplateType> messageByTemplateName = messageTemplateTypeService.findMessageByTemplateName(templateDate.getTemplateId());
|
||||||
|
//将模版里面有的配置进行循环
|
||||||
|
for (MessageTemplateType messageTemplateType : messageByTemplateName) {
|
||||||
|
//开始位置
|
||||||
|
Integer startIndex = messageTemplateType.getStartIndex();
|
||||||
|
//结束位置
|
||||||
|
Integer endIndex = messageTemplateType.getEndIndex();
|
||||||
|
//车辆VIN码
|
||||||
|
if(messageTemplateType.getMessageField().equals("vinCode")){
|
||||||
|
messageTemplate.setVinCode(result.substring(startIndex, endIndex-1));
|
||||||
|
}
|
||||||
|
if(messageTemplateType.getMessageField().equals("latitude")){
|
||||||
|
messageTemplate.setLatitude(result.substring(startIndex, endIndex-1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("解析后的报文是:"+messageTemplate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//连接IoTDB数据库并执行插入操作
|
||||||
|
public void addIoTDBTemplate(MessageTemplate messageTemplate) throws ClassNotFoundException {
|
||||||
|
// IoTDB 数据库的连接信息
|
||||||
|
String url = "jdbc:iotdb://47.116.173.119:6667/";
|
||||||
|
String user = "root";
|
||||||
|
String password = "root";
|
||||||
|
// 注册 JDBC 驱动
|
||||||
|
Class.forName("org.apache.iotdb.jdbc.IoTDBDriver");
|
||||||
|
System.out.println("JDBC Driver Registered!");
|
||||||
|
try {
|
||||||
|
// 注册 JDBC 驱动
|
||||||
|
Class.forName("org.apache.iotdb.jdbc.IoTDBDriver");
|
||||||
|
System.out.println("JDBC Driver Registered!");
|
||||||
|
// 数据库连接
|
||||||
|
Connection connection = DriverManager.getConnection(url, user, password);
|
||||||
|
System.out.println("Connected to IoTDB!");
|
||||||
|
// 插入数据的 SQL 语句
|
||||||
|
String insertSQL = "INSERT INTO root.four.message_template ( vin_code, time_stamp, long_itude, latitude, speed_vehicle, total_mileage, total_voltage, combined_current, insulation_resistance, " +
|
||||||
|
"gear_position, accelerator_pedal_travel_value, brake_pedal_travel_value, specific_fuel_consumption, motor_controller_temperature, motor_speed, motor_torque, motor_temperature, motor_voltage, motor_current, " +
|
||||||
|
"power_battery_remaining_soc, maximum_feedback_power, maximum_discharge_power, bms_self_check_counter, power_battery, total_voltage_load_side, maximum_voltage, minimum_voltage, maximum_temperature, minimum_temperature," +
|
||||||
|
" available_capacity, vehicle_status, charging_state, operational_status, soc, energy_storage_devices," +
|
||||||
|
" drive_motor_condition, whether_works, eas, ptc, eps, abs, mcu, heating_state, power_battery_status, state_battery_insulation, dcdc, chg, check_digit, cutoff_bit) VALUES ( ?, ?, ?, ?, ?, ?, ?, " +
|
||||||
|
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ??, ?, ?, ?, ?, ?, ?, ?, ?, " +
|
||||||
|
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
// 使用 PreparedStatement 插入数据
|
||||||
|
PreparedStatement preparedStatement = connection.prepareStatement(insertSQL);
|
||||||
|
// 执行插入
|
||||||
|
preparedStatement.execute();
|
||||||
|
System.out.println("Data inserted successfully!");
|
||||||
|
// 关闭连接
|
||||||
|
preparedStatement.close();
|
||||||
|
connection.close();
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
System.err.println("JDBC Driver not found: " + e.getMessage());
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.template.util;
|
||||||
|
import org.apache.iotdb.rpc.IoTDBConnectionException;
|
||||||
|
import org.apache.iotdb.rpc.StatementExecutionException;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.apache.iotdb.session.Session;
|
||||||
|
import org.apache.iotdb.session.SessionDataSet;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liuxinyue
|
||||||
|
* @Package:com.template.util
|
||||||
|
* @Project:cloud-server
|
||||||
|
* @name:ToIoTDB
|
||||||
|
* @Date:2024/9/20 19:40
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class ToIoTDB {
|
||||||
|
|
||||||
|
// IoTDB连接信息
|
||||||
|
private static final String HOST = "127.0.0.1";
|
||||||
|
private static final int PORT = 6667;
|
||||||
|
private static final String USERNAME = "root";
|
||||||
|
private static final String PASSWORD = "root";
|
||||||
|
|
||||||
|
// 需要创建的schema信息
|
||||||
|
private static final String STORAGE_GROUP = "root.ln";
|
||||||
|
private static final String[] TIMESERIES_PATHS = {
|
||||||
|
"root.ln.wf01.wt01.temperature",
|
||||||
|
"root.ln.wf01.wt01.humidity"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?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.template.mapper.CarMapper">
|
||||||
|
|
||||||
|
<select id="findCarByVin" resultType="com.template.domain.SysCar">
|
||||||
|
select * from sys_car where car_vin=#{carVin}
|
||||||
|
</select>
|
||||||
|
<select id="carMapper" resultType="com.template.domain.CarType">
|
||||||
|
select * from car_type where id=#{carTypeId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -43,4 +43,14 @@
|
||||||
where message_template_type.template_id=#{templatedId} and message_template_type.message_class=#{code}
|
where message_template_type.template_id=#{templatedId} and message_template_type.message_class=#{code}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="findMessageByTemplateName" resultType="com.template.domain.MessageTemplateType">
|
||||||
|
SELECT
|
||||||
|
message_template_type.*,
|
||||||
|
data_type.data_type_name
|
||||||
|
FROM
|
||||||
|
message_template_type
|
||||||
|
LEFT JOIN data_type ON data_type.data_type_id = message_template_type.data_type_id
|
||||||
|
where message_template_type.template_id=#{templatedId}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -8,4 +8,8 @@
|
||||||
select * from t_template
|
select * from t_template
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="findTemplateByName" resultType="com.template.domain.Template">
|
||||||
|
select * from t_template where template_name=#{typeName}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<modules>
|
<modules>
|
||||||
<module>cloud-modules-system</module>
|
<module>cloud-modules-system</module>
|
||||||
<module>cloud-modules-gen</module>
|
<module>cloud-modules-gen</module>
|
||||||
|
<module>cloud-modules-car</module>
|
||||||
<module>cloud-modules-file</module>
|
<module>cloud-modules-file</module>
|
||||||
<module>cloud-modules-template</module>
|
<module>cloud-modules-template</module>
|
||||||
<module>cloud-modules-fence</module>
|
<module>cloud-modules-fence</module>
|
||||||
|
|
Loading…
Reference in New Issue