初始化
parent
66ea9aeb3d
commit
66aced7a75
|
@ -4,9 +4,7 @@ import com.muyu.common.core.domain.Result;
|
|||
import com.muyu.domain.CarType;
|
||||
import com.muyu.service.CarTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
@RestController
|
||||
|
@ -21,6 +19,17 @@ public class CarTypeController {
|
|||
return Result.success(carTypeService.selectCarTypeList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型ID获取车辆类型
|
||||
* @param carTypeId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/findCarTypeById")
|
||||
public Result<CarType> findCarTypeById(@RequestParam Long carTypeId) {
|
||||
return Result.success(carTypeService.findCarTypeById(carTypeId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -45,4 +45,15 @@ public class SysCarController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据VIN码查询车信息
|
||||
* @param carVin
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/findCarByVin")
|
||||
public Result<SysCar> findCarByVin(@RequestParam String carVin){
|
||||
return Result.success(sysCarService.findCarByVin(carVin));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,10 @@ package com.muyu.mapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.domain.CarType;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
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);
|
||||
|
||||
SysCar findCarByVin(@Param("carVin") String carVin);
|
||||
|
||||
}
|
||||
|
|
|
@ -10,4 +10,6 @@ import java.util.List;
|
|||
public interface CarTypeService extends IService<CarType> {
|
||||
List<CarType> selectCarTypeList();
|
||||
|
||||
CarType findCarTypeById(Long carTypeId);
|
||||
|
||||
}
|
||||
|
|
|
@ -16,4 +16,7 @@ public interface SysCarService {
|
|||
int deleteSysCarById(Long id);
|
||||
|
||||
int updateSysCar(SysCar sysCar);
|
||||
|
||||
SysCar findCarByVin(String carVin);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,4 +19,9 @@ private CarTypeMapper carTypeMapper;
|
|||
QueryWrapper<CarType> carTypeQueryWrapper = new QueryWrapper<>();
|
||||
return carTypeMapper.selectList(carTypeQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarType findCarTypeById(Long carTypeId) {
|
||||
return carTypeMapper.findCarTypeById(carTypeId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,4 +39,9 @@ public class SysCarServiceImpl extends ServiceImpl<SysCarMapper,SysCar> impleme
|
|||
public int updateSysCar(SysCar 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>
|
|
@ -38,4 +38,7 @@
|
|||
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>
|
||||
|
|
|
@ -26,6 +26,41 @@
|
|||
</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 -->
|
||||
<dependency>
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.template;
|
||||
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
|
||||
/**
|
||||
* 数据类型列表
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/dataTypeList")
|
||||
public Result<List<DataType>> dataTypeList() {
|
||||
return Result.success(dataTypeService.dataTypeList());
|
||||
|
|
|
@ -78,4 +78,13 @@ public class MessageTemplateTypeController {
|
|||
return Result.success(messageTemplateTypeService.finddeviceStatusData(templatedId,code));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据车辆类型查出所对应的模版
|
||||
* @param templateName
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/findMessageByTemplateName")
|
||||
public Result<List<MessageTemplateType>> findMessageByTemplateName(@RequestParam("templateName") String templateName) {
|
||||
return Result.success(messageTemplateTypeService.findMessageByTemplateName(templateName));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,11 +26,27 @@ public class TemplateController {
|
|||
private TemplateService templateService;
|
||||
|
||||
|
||||
/**
|
||||
* 报文模版列表
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/templateList")
|
||||
public Result<List<Template>> templateList() {
|
||||
return Result.success(templateService.templateList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解析报文
|
||||
* @param templateMessage
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/messageParsing")
|
||||
public Result messageParsing(@RequestParam 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,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> findMessageByTemplateName(@Param("templateName") String templateName);
|
||||
|
||||
}
|
||||
|
|
|
@ -18,4 +18,6 @@ public interface TemplateMapper {
|
|||
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> findMessageByTemplateName(String templateName);
|
||||
|
||||
}
|
||||
|
|
|
@ -15,4 +15,6 @@ public interface TemplateService {
|
|||
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) {
|
||||
return messageTemplateTypeMapper.finddeviceStatusData(templatedId,code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MessageTemplateType> findMessageByTemplateName(String templateName) {
|
||||
return messageTemplateTypeMapper.findMessageByTemplateName(templateName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
package com.template.service.impl;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.template.domain.CarType;
|
||||
import com.template.domain.MessageTemplateType;
|
||||
import com.template.domain.SysCar;
|
||||
import com.template.domain.Template;
|
||||
import com.template.mapper.TemplateMapper;
|
||||
import com.template.service.CarService;
|
||||
import com.template.service.MessageTemplateTypeService;
|
||||
import com.template.service.TemplateService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
* @Package:com.template.service.impl
|
||||
|
@ -21,9 +24,59 @@ public class TemplateServiceImpl implements TemplateService{
|
|||
@Autowired
|
||||
private TemplateMapper templateMapper;
|
||||
|
||||
@Autowired
|
||||
private CarService carService;
|
||||
|
||||
@Autowired
|
||||
private MessageTemplateTypeService messageTemplateTypeService;
|
||||
|
||||
@Override
|
||||
public List<Template> templateList() {
|
||||
return templateMapper.templateList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageParsing(String templateMessage) {
|
||||
//先截取出VIN码 然后根据VIN码查询这个车属于什么类型
|
||||
if(templateMessage.length()<18){
|
||||
throw new RuntimeException("The vehicle message is incorrect");
|
||||
}
|
||||
//取出VIN码
|
||||
String carVin = templateMessage.substring(1, 18-1);
|
||||
//根据VIN码获取车辆信息
|
||||
SysCar carByVin = carService.findCarByVin(carVin);
|
||||
//根据车辆类型ID获取车辆类型名称
|
||||
CarType carTypeById = carService.findCarTypeById(carByVin.getCarTypeId());
|
||||
//查询报文模版
|
||||
Template templateDate=templateMapper.findTemplateByName(carTypeById.getTypeName());
|
||||
//根据报文模版的ID查询对应的模版
|
||||
List<MessageTemplateType> messageByTemplateName = messageTemplateTypeService.findMessageByTemplateName(templateDate.getTemplateName());
|
||||
for (MessageTemplateType messageTemplateType : messageByTemplateName) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String character="1A 2B 3C 4D 5E 6F";
|
||||
//将这个报文去除空格
|
||||
String[] split = character.split(" ");
|
||||
|
||||
//字符数组
|
||||
char[] asciiChars = new char[split.length];
|
||||
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
// 将16进制字符串转换为整数(字节值)
|
||||
int decimal = Integer.parseInt(split[i], 16);
|
||||
|
||||
asciiChars[i] = (char) decimal;
|
||||
|
||||
}
|
||||
|
||||
System.out.println(new String(asciiChars));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
</mapper>
|
|
@ -43,4 +43,14 @@
|
|||
where message_template_type.template_id=#{templatedId} and message_template_type.message_class=#{code}
|
||||
</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_name=#{templateName}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -8,4 +8,8 @@
|
|||
select * from t_template
|
||||
</select>
|
||||
|
||||
<select id="findTemplateByName" resultType="com.template.domain.Template">
|
||||
select * from t_template where template_name=#{typeName}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue