初始化

dev
Number7 2024-09-21 11:51:09 +08:00
parent 66ea9aeb3d
commit 66aced7a75
31 changed files with 430 additions and 7 deletions

View File

@ -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
@ -21,6 +19,17 @@ public class CarTypeController {
return Result.success(carTypeService.selectCarTypeList()); return Result.success(carTypeService.selectCarTypeList());
} }
/**
* ID
* @param carTypeId
* @return
*/
@PostMapping("/findCarTypeById")
public Result<CarType> findCarTypeById(@RequestParam Long carTypeId) {
return Result.success(carTypeService.findCarTypeById(carTypeId));
}
} }

View File

@ -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));
}
} }

View File

@ -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);
} }

View File

@ -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);
} }

View File

@ -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();
CarType findCarTypeById(Long carTypeId);
} }

View File

@ -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);
} }

View File

@ -19,4 +19,9 @@ private CarTypeMapper carTypeMapper;
QueryWrapper<CarType> carTypeQueryWrapper = new QueryWrapper<>(); QueryWrapper<CarType> carTypeQueryWrapper = new QueryWrapper<>();
return carTypeMapper.selectList(carTypeQueryWrapper); return carTypeMapper.selectList(carTypeQueryWrapper);
} }
@Override
public CarType findCarTypeById(Long carTypeId) {
return carTypeMapper.findCarTypeById(carTypeId);
}
} }

View File

@ -39,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);
}
} }

View File

@ -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>

View File

@ -38,4 +38,7 @@
LEFT JOIN tb_fence ON sys_car.fence_id=tb_fence.fence_id LEFT JOIN tb_fence ON sys_car.fence_id=tb_fence.fence_id
where sys_car.id=#{id} where sys_car.id=#{id}
</select> </select>
<select id="findCarByVin" resultType="com.muyu.domain.SysCar">
select * from sys_car where car_vin=#{carVin}
</select>
</mapper> </mapper>

View File

@ -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>

View File

@ -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;
/** /**
* @Authorliuxinyue * @Authorliuxinyue

View File

@ -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;
/**
* @Authorliuxinyue
* @Packagecom.template.controller
* @Projectcloud-server
* @nameCarController
* @Date2024/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));
}
}

View File

@ -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());

View File

@ -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("templateName") String templateName) {
return Result.success(messageTemplateTypeService.findMessageByTemplateName(templateName));
}
} }

View File

@ -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 String templateMessage){
templateService.messageParsing(templateMessage);
return Result.success();
}
} }

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
/**
* @Authorliuxinyue
* @Packagecom.template.mapper
* @Projectcloud-server
* @nameCarMapper
* @Date2024/9/21 9:26
*/
@Mapper
public interface CarMapper {
SysCar findCarByVin(@Param("carVin") String carVin);
CarType carMapper(@Param("carTypeId") Long carTypeId);
}

View File

@ -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("templateName") String templateName);
} }

View File

@ -18,4 +18,6 @@ public interface TemplateMapper {
List<Template> templateList(); List<Template> templateList();
Template findTemplateByName(@Param("typeName") String typeName);
} }

View File

@ -0,0 +1,18 @@
package com.template.service;
import com.template.domain.CarType;
import com.template.domain.SysCar;
/**
* @Authorliuxinyue
* @Packagecom.template.service
* @Projectcloud-server
* @nameCarService
* @Date2024/9/21 9:25
*/
public interface CarService {
SysCar findCarByVin(String carVin);
CarType findCarTypeById(Long carTypeId);
}

View File

@ -27,4 +27,6 @@ public interface MessageTemplateTypeService {
List<MessageTemplateType> finddeviceStatusData(Integer templatedId, String code); List<MessageTemplateType> finddeviceStatusData(Integer templatedId, String code);
List<MessageTemplateType> findMessageByTemplateName(String templateName);
} }

View File

@ -15,4 +15,6 @@ public interface TemplateService {
List<Template> templateList(); List<Template> templateList();
void messageParsing(String templateMessage);
} }

View File

@ -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;
/**
* @Authorliuxinyue
* @Packagecom.template.service.impl
* @Projectcloud-server
* @nameCarServiceImpl
* @Date2024/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);
}
}

View File

@ -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(String templateName) {
return messageTemplateTypeMapper.findMessageByTemplateName(templateName);
}
} }

View File

@ -1,13 +1,16 @@
package com.template.service.impl; 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.domain.Template;
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.util.List; import java.util.List;
/** /**
* @Authorliuxinyue * @Authorliuxinyue
* @Packagecom.template.service.impl * @Packagecom.template.service.impl
@ -21,9 +24,59 @@ 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) {
//先截取出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));
}
} }

View File

@ -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;
/**
* @Authorliuxinyue
* @Packagecom.template.util
* @Projectcloud-server
* @nameToIoTDB
* @Date2024/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"
};
}

View File

@ -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>

View File

@ -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_name=#{templateName}
</select>
</mapper> </mapper>

View File

@ -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>