Compare commits
11 Commits
b8a8373ba5
...
3ce339dbf9
Author | SHA1 | Date |
---|---|---|
|
3ce339dbf9 | |
|
bbebab923a | |
|
9672c880aa | |
|
61e8d5903a | |
|
26fded7ed6 | |
|
208f5e5e20 | |
|
d2d43a9457 | |
|
50f9dcbff5 | |
|
7a97351e0f | |
|
eacd2806b8 | |
|
23018acef8 |
|
@ -0,0 +1,112 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-modules</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>cloud-data</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 接口模块 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-api-doc</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
package com.muyu.data;
|
||||
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableMyFeignClients
|
||||
public class DataApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DataApplication.class,args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
package com.muyu.data.config;
|
||||
|
||||
|
||||
import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
|
||||
import org.springframework.kafka.config.KafkaListenerContainerFactory;
|
||||
import org.springframework.kafka.core.ConsumerFactory;
|
||||
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
|
||||
import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
|
||||
import org.springframework.kafka.listener.ContainerProperties;
|
||||
import org.springframework.kafka.support.serializer.JsonDeserializer;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 徐一杰
|
||||
* @date 2022/10/31 18:05
|
||||
* kafka配置,也可以写在yml,这个文件会覆盖yml
|
||||
*/
|
||||
@SpringBootConfiguration
|
||||
public class KafkaConsumerConfig {
|
||||
|
||||
/**
|
||||
* 配置 Kafka的 主机地址
|
||||
*/
|
||||
@Value("${spring.kafka.consumer.bootstrap-servers}")
|
||||
private String bootstrapServers;
|
||||
/**
|
||||
* 配置分分组
|
||||
*/
|
||||
@Value("${spring.kafka.consumer.group-id}")
|
||||
private String groupId;
|
||||
/**
|
||||
* 是否自动提交 偏移量
|
||||
*/
|
||||
@Value("${spring.kafka.consumer.enable-auto-commit}")
|
||||
private boolean enableAutoCommit;
|
||||
/**
|
||||
* 消费者与Kafka的心跳续约的会话超时时间
|
||||
*/
|
||||
@Value("${spring.kafka.properties.session.timeout.ms}")
|
||||
private String sessionTimeout;
|
||||
/**
|
||||
* 两次poll之间的最大间隔,默认值为5分钟。如果超过这个间隔会触发reBalance
|
||||
*/
|
||||
@Value("${spring.kafka.properties.max.poll.interval.ms}")
|
||||
private String maxPollIntervalTime;
|
||||
|
||||
@Value("${spring.kafka.consumer.max-poll-records}")
|
||||
private String maxPollRecords;
|
||||
|
||||
@Value("${spring.kafka.consumer.auto-offset-reset}")
|
||||
private String autoOffsetReset;
|
||||
|
||||
@Value("${spring.kafka.listener.concurrency}")
|
||||
private Integer concurrency;
|
||||
|
||||
@Value("${spring.kafka.listener.missing-topics-fatal}")
|
||||
private boolean missingTopicsFatal;
|
||||
|
||||
@Value("${spring.kafka.listener.poll-timeout}")
|
||||
private long pollTimeout;
|
||||
|
||||
@Bean
|
||||
public Map<String, Object> consumerConfigs() {
|
||||
Map<String, Object> propsMap = new HashMap<>(16);
|
||||
propsMap.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
|
||||
propsMap.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
|
||||
//是否自动提交偏移量,默认值是true,为了避免出现重复数据和数据丢失,可以把它设置为false,然后手动提交偏移量
|
||||
propsMap.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, enableAutoCommit);
|
||||
//自动提交的时间间隔,自动提交开启时生效
|
||||
propsMap.put(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, "2000");
|
||||
//该属性指定了消费者在读取一个没有偏移量的分区或者偏移量无效的情况下该作何处理:
|
||||
//earliest:当各分区下有已提交的offset时,从提交的offset开始消费;无提交的offset时,从头开始消费分区的记录
|
||||
//latest:当各分区下有已提交的offset时,从提交的offset开始消费;无提交的offset时,消费新产生的该分区下的数据(在消费者启动之后生成的记录)
|
||||
//none:当各分区都存在已提交的offset时,从提交的offset开始消费;只要有一个分区不存在已提交的offset,则抛出异常
|
||||
propsMap.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, autoOffsetReset);
|
||||
//两次poll之间的最大间隔,默认值为5分钟。如果超过这个间隔会触发reBalance
|
||||
propsMap.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, maxPollIntervalTime);
|
||||
//这个参数定义了poll方法最多可以拉取多少条消息,默认值为500。如果在拉取消息的时候新消息不足500条,那有多少返回多少;如果超过500条,每次只返回500。
|
||||
//这个默认值在有些场景下太大,有些场景很难保证能够在5min内处理完500条消息,
|
||||
//如果消费者无法在5分钟内处理完500条消息的话就会触发reBalance,
|
||||
//然后这批消息会被分配到另一个消费者中,还是会处理不完,这样这批消息就永远也处理不完。
|
||||
//要避免出现上述问题,提前评估好处理一条消息最长需要多少时间,然后覆盖默认的max.poll.records参数
|
||||
//注:需要开启BatchListener批量监听才会生效,如果不开启BatchListener则不会出现reBalance情况
|
||||
propsMap.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, maxPollRecords);
|
||||
//当broker多久没有收到consumer的心跳请求后就触发reBalance,默认值是10s
|
||||
propsMap.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, sessionTimeout);
|
||||
//序列化(建议使用Json,这种序列化方式可以无需额外配置传输实体类)
|
||||
propsMap.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);
|
||||
propsMap.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);
|
||||
return propsMap;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ConsumerFactory<Object, Object> consumerFactory() {
|
||||
// 配置消费者的 Json 反序列化的可信赖包,反序列化实体类需要
|
||||
try (JsonDeserializer<Object> deserializer = new JsonDeserializer<>()) {
|
||||
deserializer.trustedPackages("*");
|
||||
return new DefaultKafkaConsumerFactory<>(consumerConfigs(), new JsonDeserializer<>(), deserializer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* kafka监听容器工厂 负责 从 Kafka的主题中 取出消息进行消费 可以设置消费者的配置
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<Object, Object>> kafkaListenerContainerFactory() {
|
||||
ConcurrentKafkaListenerContainerFactory<Object, Object> factory = new ConcurrentKafkaListenerContainerFactory<>();
|
||||
factory.setConsumerFactory(consumerFactory());
|
||||
//在侦听器容器中运行的线程数,一般设置为 机器数*分区数
|
||||
factory.setConcurrency(concurrency);
|
||||
// 消费监听接口监听的主题不存在时,默认会报错,所以设置为false忽略错误
|
||||
factory.setMissingTopicsFatal(missingTopicsFatal);
|
||||
// 自动提交关闭,需要设置手动消息确认
|
||||
factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL_IMMEDIATE);
|
||||
factory.getContainerProperties().setPollTimeout(pollTimeout);
|
||||
// 设置为批量监听,需要用List接收
|
||||
// factory.setBatchListener(true);
|
||||
return factory;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
package com.muyu.data.config;
|
||||
|
||||
import org.apache.kafka.clients.producer.ProducerConfig;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.kafka.core.ProducerFactory;
|
||||
import org.springframework.kafka.transaction.KafkaTransactionManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 主题生产者的配置类
|
||||
*/
|
||||
@Configuration
|
||||
public class KafkaProviderConfig {
|
||||
|
||||
/**
|
||||
* kafka 的主机地址
|
||||
*/
|
||||
@Value("${spring.kafka.producer.bootstrap-servers}")
|
||||
private String bootstrapServers;
|
||||
/**
|
||||
* 配置 Kafka的事务
|
||||
*/
|
||||
@Value("${spring.kafka.producer.transaction-id-prefix}")
|
||||
private String transactionIdPrefix;
|
||||
/**
|
||||
* 发送确认机制
|
||||
*/
|
||||
@Value("${spring.kafka.producer.acks}")
|
||||
private String acks;
|
||||
/**
|
||||
* 发送重试
|
||||
*/
|
||||
@Value("${spring.kafka.producer.retries}")
|
||||
private String retries;
|
||||
/**
|
||||
* 发送消息的批次大小
|
||||
*/
|
||||
@Value("${spring.kafka.producer.batch-size}")
|
||||
private String batchSize;
|
||||
/**
|
||||
* 消息的缓冲区内存大小
|
||||
*/
|
||||
@Value("${spring.kafka.producer.buffer-memory}")
|
||||
private String bufferMemory;
|
||||
|
||||
/**
|
||||
* 设置 健的序列化方式
|
||||
*/
|
||||
@Value("${spring.kafka.producer.key-serializer}")
|
||||
private String keySerializer;
|
||||
|
||||
/**
|
||||
* 设置 值的序列化方式
|
||||
*/
|
||||
@Value("${spring.kafka.producer.value-serializer}")
|
||||
private String valueSerializer;
|
||||
|
||||
/**
|
||||
* 构建 map 配置消息生产者对象的配置
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Map<String, Object> producerConfigs() {
|
||||
Map<String, Object> props = new HashMap<>(16);
|
||||
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
|
||||
//acks=0 : 生产者在成功写入消息之前不会等待任何来自服务器的响应。
|
||||
//acks=1 : 只要集群的首领节点收到消息,生产者就会收到一个来自服务器成功响应。
|
||||
//acks=all :只有当所有参与复制的节点全部收到消息时,生产者才会收到一个来自服务器的成功响应。
|
||||
//开启事务必须设为all
|
||||
props.put(ProducerConfig.ACKS_CONFIG, acks);
|
||||
//发生错误后,消息重发的次数,开启事务必须大于0
|
||||
props.put(ProducerConfig.RETRIES_CONFIG, retries);
|
||||
//当多个消息发送到相同分区时,生产者会将消息打包到一起,以减少请求交互. 而不是一条条发送
|
||||
//批次的大小可以通过batch.size 参数设置.默认是16KB
|
||||
//较小的批次大小有可能降低吞吐量(批次大小为0则完全禁用批处理)。
|
||||
//比如说,kafka里的消息5秒钟Batch才凑满了16KB,才能发送出去。那这些消息的延迟就是5秒钟
|
||||
//实测batchSize这个参数没有用
|
||||
props.put(ProducerConfig.BATCH_SIZE_CONFIG, batchSize);
|
||||
//有的时刻消息比较少,过了很久,比如5min也没有凑够16KB,这样延时就很大,所以需要一个参数. 再设置一个时间,到了这个时间,
|
||||
//即使数据没达到16KB,也将这个批次发送出去
|
||||
props.put(ProducerConfig.LINGER_MS_CONFIG, "5000");
|
||||
//生产者内存缓冲区的大小
|
||||
props.put(ProducerConfig.BUFFER_MEMORY_CONFIG, bufferMemory);
|
||||
//反序列化,和生产者的序列化方式对应
|
||||
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, keySerializer);
|
||||
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, valueSerializer);
|
||||
return props;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建 主题生产者工厂
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public ProducerFactory<Object, Object> producerFactory() {
|
||||
DefaultKafkaProducerFactory<Object, Object> factory = new DefaultKafkaProducerFactory<>(producerConfigs());
|
||||
//开启事务,会导致 LINGER_MS_CONFIG 配置失效
|
||||
factory.setTransactionIdPrefix(transactionIdPrefix);
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置 Kafka的事务管理器
|
||||
* @param producerFactory
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public KafkaTransactionManager<Object, Object> kafkaTransactionManager(ProducerFactory<Object, Object> producerFactory) {
|
||||
return new KafkaTransactionManager<>(producerFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建 KafkaTemplate
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public KafkaTemplate<Object, Object> kafkaTemplate() {
|
||||
return new KafkaTemplate<>(producerFactory());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package com.muyu.data.config;
|
||||
|
||||
import jakarta.annotation.Nullable;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.apache.kafka.clients.producer.RecordMetadata;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.kafka.support.ProducerListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Component
|
||||
public class KafkaSendResultHandler implements ProducerListener<Object,Object> {
|
||||
|
||||
@Autowired
|
||||
private KafkaTemplate<Object,Object> kafkaTemplate;
|
||||
|
||||
/**
|
||||
* bean 初始化方法
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
this.kafkaTemplate.setProducerListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息发送到Kafka成功的回调
|
||||
* @param producerRecord
|
||||
* @param recordMetadata
|
||||
*/
|
||||
@Override
|
||||
public void onSuccess(ProducerRecord producerRecord, RecordMetadata recordMetadata){
|
||||
System.out.println("信息发送成功:"+ producerRecord.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 息发送到 Kafka 失败的回调
|
||||
* @param producerRecord the failed record
|
||||
* @param recordMetadata The metadata for the record that was sent (i.e. the partition
|
||||
* and offset). If an error occurred, metadata will contain only valid topic and maybe
|
||||
* the partition. If the partition is not provided in the ProducerRecord and an error
|
||||
* occurs before partition is assigned, then the partition will be set to
|
||||
* RecordMetadata.UNKNOWN_PARTITION.
|
||||
* @param exception the exception thrown
|
||||
*/
|
||||
@Override
|
||||
public void onError(ProducerRecord producerRecord, @Nullable RecordMetadata recordMetadata,
|
||||
Exception exception){
|
||||
System.out.println("消息发送失败: "+ producerRecord.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -16,7 +16,7 @@ public class SysCarVo extends SysCar {
|
|||
@Excel(name = "车辆类型名称")
|
||||
private String typeName;
|
||||
@Excel(name = "策略名称")
|
||||
private Long strategyName;
|
||||
private String strategyName;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -21,4 +21,10 @@ public interface SysCarMapper extends BaseMapper<SysCar> {
|
|||
|
||||
List<SysCarFaultLogVo> findFenceByCarVin(@Param("carVin") String carVin);
|
||||
|
||||
//修改车辆
|
||||
Integer updSysCarById(SysCar sysCar);
|
||||
|
||||
//添加车辆信息
|
||||
Integer addSysCar(SysCar sysCar);
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class SysCarServiceImpl extends ServiceImpl<SysCarMapper,SysCar> impleme
|
|||
|
||||
@Override
|
||||
public int addSysCar(SysCar sysCar) {
|
||||
return sysCarMapper.insert(sysCar);
|
||||
return sysCarMapper.addSysCar(sysCar);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,7 +40,7 @@ public class SysCarServiceImpl extends ServiceImpl<SysCarMapper,SysCar> impleme
|
|||
|
||||
@Override
|
||||
public int updateSysCar(SysCar sysCar) {
|
||||
return sysCarMapper.updateById(sysCar);
|
||||
return sysCarMapper.updSysCarById(sysCar);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,29 @@
|
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.mapper.SysCarMapper">
|
||||
<insert id="addSysCar">
|
||||
INSERT INTO `four`.`sys_car`
|
||||
( `car_vin`, `car_type_id`, `state`, `car_motor_manufacturer`, `car_motor_model`,
|
||||
`car_battery_manufacturer`, `car_battery_model`, `strategy_id`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
|
||||
VALUES (#{carVin}, #{carTypeId}, '1', #{carMotorManufacturer}, #{carMotorModel},
|
||||
#{carBatteryManufacturer}, #{carBatteryModel}, #{strategyId},#{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{remark})
|
||||
</insert>
|
||||
<update id="updSysCarById">
|
||||
UPDATE `four`.`sys_car`
|
||||
SET `car_vin` = #{carVin},
|
||||
`car_type_id` = #{carTypeId},
|
||||
`state` = #{state},
|
||||
`car_motor_manufacturer` = #{carMotorManufacturer},
|
||||
`car_motor_model` = #{carMotorModel},
|
||||
`car_battery_manufacturer` = #{carBatteryManufacturer},
|
||||
`car_battery_model` = #{carBatteryModel},
|
||||
`strategy_id` = #{strategyId},
|
||||
`create_by` = #{createBy},
|
||||
`create_time` = #{createTime},
|
||||
`update_by` = #{updateBy},
|
||||
`update_time` = #{updateTime},
|
||||
`remark` = #{remark} WHERE `id` = #{id}
|
||||
</update>
|
||||
<select id="selectSysCarVoList" resultType="com.muyu.domain.resp.SysCarVo">
|
||||
SELECT * ,car_type.type_name,warn_strategy.strategy_name
|
||||
FROM `sys_car`
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
|||
DruidDataSourceAutoConfigure.class,
|
||||
DynamicDataSourceAutoConfiguration.class
|
||||
})
|
||||
|
||||
public class CloudElectronicFenceApplication {
|
||||
public static void main (String[] args) {
|
||||
SpringApplication.run(CloudElectronicFenceApplication.class, args);
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
package com.template.controller;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
* @Package:com.template.controller
|
||||
* @Project:cloud-server
|
||||
* @name:ServiceController
|
||||
* @Date:2024/9/22 22:12
|
||||
*/
|
||||
@Log4j2
|
||||
public class ServiceController {
|
||||
|
||||
private final String IOTDB_DRIVER="org.apache.iotdb.jdbc.IoTDBDriver";
|
||||
private static final String url="jdbc:iotdb://47.116.173.119:6667/";
|
||||
private static final String userName="root";
|
||||
private static final String passWord="root";
|
||||
|
||||
public void ToIoTDB(String url, String userName, String passWord){
|
||||
log.info("Connecting to IoTDB");
|
||||
log.info("地址是:"+url);
|
||||
log.info("用户名是:"+userName);
|
||||
log.info("密码是:"+passWord);
|
||||
log.info("红红火火恍恍惚惚");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try{
|
||||
Class.forName("org.apache.iotdb.jdbc.IoTDBDriver");
|
||||
DriverManager.getConnection(url,userName,passWord);
|
||||
}catch(SQLException e){
|
||||
log.error("SQLException: " + e.getMessage());
|
||||
log.error("SQLState: " + e.getSQLState());
|
||||
log.error("VendorError: " + e.getErrorCode());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void createConnection() throws ClassNotFoundException, SQLException {
|
||||
|
||||
try{
|
||||
Class.forName(IOTDB_DRIVER);
|
||||
DriverManager.getConnection(url,userName,passWord);
|
||||
}catch(SQLException e){
|
||||
log.error("SQLException: " + e.getMessage());
|
||||
log.error("SQLState: " + e.getSQLState());
|
||||
log.error("VendorError: " + e.getErrorCode());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.template.domain.resp;
|
||||
|
||||
import com.template.domain.CarType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
* @Package:com.template.domain.resp
|
||||
* @Project:cloud-server
|
||||
* @name:CarTypeResp
|
||||
* @Date:2024/9/25 22:09
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CarTypeResp extends CarType{
|
||||
|
||||
private String templateName;
|
||||
|
||||
}
|
|
@ -2,9 +2,12 @@ package com.template.mapper;
|
|||
|
||||
import com.template.domain.CarType;
|
||||
import com.template.domain.SysCar;
|
||||
import com.template.domain.resp.CarTypeResp;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
* @Package:com.template.mapper
|
||||
|
@ -19,4 +22,5 @@ public interface CarMapper {
|
|||
|
||||
CarType carMapper(@Param("carTypeId") Long carTypeId);
|
||||
|
||||
List<CarTypeResp> findAllCars();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.template.mapper;
|
||||
|
||||
import com.template.domain.MessageTemplateType;
|
||||
import com.template.domain.Template;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
@ -20,4 +21,6 @@ public interface TemplateMapper {
|
|||
|
||||
Template findTemplateByName(@Param("typeName") String typeName);
|
||||
|
||||
List<MessageTemplateType> findTemplateById(@Param("templateId") Integer templateId);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@ package com.template.service;
|
|||
|
||||
import com.template.domain.CarType;
|
||||
import com.template.domain.SysCar;
|
||||
import com.template.domain.resp.CarTypeResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
|
@ -15,4 +18,7 @@ public interface CarService {
|
|||
|
||||
CarType findCarTypeById(Long carTypeId);
|
||||
|
||||
List<CarTypeResp> findAllCars();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.template.service;
|
||||
|
||||
import com.template.domain.MessageTemplateType;
|
||||
import com.template.domain.Template;
|
||||
import org.apache.iotdb.rpc.IoTDBConnectionException;
|
||||
import org.apache.iotdb.rpc.StatementExecutionException;
|
||||
|
@ -20,4 +21,6 @@ public interface TemplateService {
|
|||
|
||||
void messageParsing(String templateMessage) throws SQLException, IoTDBConnectionException, ClassNotFoundException, StatementExecutionException;
|
||||
|
||||
List<MessageTemplateType> findTemplateById(Integer templateId);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,11 +2,14 @@ package com.template.service.impl;
|
|||
|
||||
import com.template.domain.CarType;
|
||||
import com.template.domain.SysCar;
|
||||
import com.template.domain.resp.CarTypeResp;
|
||||
import com.template.mapper.CarMapper;
|
||||
import com.template.service.CarService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
* @Package:com.template.service.impl
|
||||
|
@ -31,4 +34,10 @@ public class CarServiceImpl implements CarService {
|
|||
return carMapper.carMapper(carTypeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CarTypeResp> findAllCars() {
|
||||
return carMapper.findAllCars();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.template.mapper.TemplateMapper;
|
|||
import com.template.service.CarService;
|
||||
import com.template.service.MessageTemplateTypeService;
|
||||
import com.template.service.TemplateService;
|
||||
import com.template.util.ToIoTDB;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.iotdb.rpc.IoTDBConnectionException;
|
||||
import org.apache.iotdb.rpc.StatementExecutionException;
|
||||
|
@ -14,6 +14,7 @@ import org.apache.iotdb.session.SessionDataSet;
|
|||
import org.apache.iotdb.session.util.Version;
|
||||
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
|
@ -40,7 +41,7 @@ public class TemplateServiceImpl implements TemplateService{
|
|||
private MessageTemplateTypeService messageTemplateTypeService;
|
||||
|
||||
@Autowired
|
||||
private ToIoTDB toIoTDB;
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public List<Template> templateList() {
|
||||
|
@ -74,6 +75,11 @@ public class TemplateServiceImpl implements TemplateService{
|
|||
CarType carTypeById = carService.findCarTypeById(carByVin.getCarTypeId());
|
||||
//查询报文模版
|
||||
Template templateDate=templateMapper.findTemplateByName(carTypeById.getTypeName());
|
||||
log.info("取出Redis中对象报文模版信息");
|
||||
List range = redisTemplate.opsForList().range("VehicleType", 0, -1);
|
||||
range.forEach(o -> {
|
||||
|
||||
});
|
||||
//根据报文模版的ID查询对应的模版
|
||||
List<MessageTemplateType> messageByTemplateName = messageTemplateTypeService.findMessageByTemplateName(templateDate.getTemplateId());
|
||||
//将模版里面有的配置进行循环
|
||||
|
@ -91,6 +97,10 @@ public class TemplateServiceImpl implements TemplateService{
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MessageTemplateType> findTemplateById(Integer templateId) {
|
||||
return templateMapper.findTemplateById(templateId);
|
||||
}
|
||||
|
||||
|
||||
public void insertIoTDB(JSONObject jsonObject) throws SQLException, ClassNotFoundException, IoTDBConnectionException, StatementExecutionException {
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package com.template.util;
|
||||
import java.sql.Connection;
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
* @Package:com.template.util
|
||||
* @Project:cloud-server
|
||||
* @name:IOTDBConnectionTets
|
||||
* @Date:2024/9/24 10:34
|
||||
*/
|
||||
public class IOTDBConnectionTets {
|
||||
|
||||
private static final String url = "jdbc:iotdb://47.116.173.119:6667/";
|
||||
private static final String username = "root";
|
||||
private static final String password = "root";
|
||||
|
||||
public static void main(String[] args) {
|
||||
Connection conn = new IOTdbJDBCUtils(url, username, password).getConnection();
|
||||
System.out.println(conn != null ? "打开连接成功!" : "打开连接失败!");
|
||||
IOTdbJDBCUtils.close(conn);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package com.template.util;
|
||||
|
||||
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
* @Package:com.template.util
|
||||
* @Project:cloud-server
|
||||
* @name:IOTdbJDBCUtils
|
||||
* @Date:2024/9/24 10:18
|
||||
*/
|
||||
public class IOTdbJDBCUtils {
|
||||
private static final String driver = "org.apache.iotdb.jdbc.IoTDBDriver";
|
||||
private final String url;
|
||||
private final String username;
|
||||
private final String password;
|
||||
|
||||
public IOTdbJDBCUtils(String url, String username, String password) {
|
||||
this.url = url;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
Class.forName(driver);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
System.out.println("当前加载的驱动不存在........,请检查后重试!");
|
||||
}
|
||||
}
|
||||
|
||||
public Connection getConnection() {
|
||||
Connection connection = null;
|
||||
try {
|
||||
connection = DriverManager.getConnection(url, username, password);
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
public static void close(Connection conn) {
|
||||
if (conn != null) {
|
||||
try {
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.template.util;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
* @Package:com.template.util
|
||||
* @Project:cloud-server
|
||||
* @name:StringCutterUtils
|
||||
* @Date:2024/9/25 21:18
|
||||
*/
|
||||
@Log4j2
|
||||
public class StringCutterUtils {
|
||||
|
||||
public static String hexadecimalCharacter(String s){
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
int len = s.length();
|
||||
for (int i = 0; i < len; i++) {
|
||||
char c = s.charAt(i);
|
||||
String hexString = Integer.toHexString(c);
|
||||
stringBuilder.append(hexString+" ");
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String s = hexadecimalCharacter("3C3F786D6C2076657273696F6E3D22312E30223F3E0D0A3C6D6F6E69746F72526F6F7420747970653D22706172616D223E3C73796E6368726F6E697A65537970746F6D206576656E743D22302220696E697469616C3D2274727565223E3C416374696F6E5F4543473E3C52687974686D3E53696E75733C2F52687974686D3E3C48523E38303C2F48523E3C454D443E4E6F204368616E67653C2F454D443E3C436F6E647563743E303C2F436F6E647563743E3C2F416374696F6E5F4543473E3C416374696F6E5F4F7361742076616C75653D2239342220697352656C617469766550657263656E743D2266616C7365222F3E3C416374696F6E5F425020697352656C617469766550657263656E743D2266616C7365223E3C536872696E6B2076616C75653D22313230222F3E3C537472657463682076616C75653D223830222F3E3C2F416374696F6E5F42503E3C416374696F6E5F5265737020627265617468547970653D224E6F726D616C222076616C75653D2231342220697352656C617469766550657263656E743D2266616C7365222F3E3C416374696F6E5F6574434F322076616C75653D2233342220697352656C617469766550657263656E743D2266616C7365222F3E3C416374696F6E5F54656D70657261747572652076616C75653D2233352E32222F3E3C416374696F6E5F4356502076616C75653D22362E30222F3E3C416374696F6E5F5041504469612076616C75653D223130222F3E3C416374696F6E5F5041505379732076616C75653D223235222F3E3C416374696F6E5F57502076616C75653D2239222F3E3C2F73796E6368726F6E697A65537970746F6D3E3C2F6D6F6E69746F72526F6F743E0D0A");
|
||||
String string = toString(s);
|
||||
log.info(string);
|
||||
}
|
||||
|
||||
public static String toString(String s){
|
||||
|
||||
if(s==null || s.equals("")){
|
||||
return null;
|
||||
}
|
||||
log.info("将字符串中的空格去除");
|
||||
s = s.replace(" ", "");
|
||||
byte[] bytes = new byte[s.length() / 2];
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
bytes[i] = (byte) (0xff & Integer.parseInt(s.substring(i*2,i*2+2), 16));
|
||||
}
|
||||
|
||||
s=new String(bytes, StandardCharsets.UTF_8);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.template.util;
|
||||
import com.template.domain.MessageTemplateType;
|
||||
import com.template.domain.SysCar;
|
||||
import com.template.domain.Template;
|
||||
import com.template.domain.resp.CarTypeResp;
|
||||
import com.template.service.CarService;
|
||||
import com.template.service.TemplateService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.ListOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
* @Package:com.template.util
|
||||
* @Project:cloud-server
|
||||
* @name:SynchronizingTemplate
|
||||
* @Date:2024/9/25 20:03
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class SynchronizingTemplate {
|
||||
|
||||
|
||||
//调用报文模版列表接口
|
||||
@Resource
|
||||
private TemplateService templateService;
|
||||
|
||||
//redis
|
||||
@Resource
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private CarService carService;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void synchronizeTemplate() {
|
||||
//获取所有报文模版的ID
|
||||
log.info("获取所有报文模版的ID");
|
||||
List<Template> templates = templateService.templateList();
|
||||
templates.forEach(template -> {
|
||||
Integer templateId = template.getTemplateId(); //报文模版ID
|
||||
List<MessageTemplateType> list=templateService.findTemplateById(templateId); //根据报文模版ID查询所有的报文模版
|
||||
ListOperations<String,Object> listOperations = redisTemplate.opsForList(); //将报文信息存储到redis中
|
||||
redisTemplate.delete(template.getTemplateName());//因为每一次添加缓存的时候不会覆盖之前的数据 所有将数据先清空
|
||||
List<CarTypeResp> allCars = carService.findAllCars();//查询所有车辆 里面有模版名称
|
||||
redisTemplate.opsForList().leftPushAll("VehicleType", allCars);//将车辆类型放入列表
|
||||
listOperations.leftPushAll(template.getTemplateName(), list); //将报文信息存储到redis中
|
||||
List range = redisTemplate.opsForList().range("VehicleType", 0, -1);
|
||||
range.forEach(o -> {
|
||||
log.info("数据为:"+o);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package com.template.util;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
* @Package:com.template.util
|
||||
* @Project:cloud-server
|
||||
* @name:ToIoTDB 连接IoTDB数据库
|
||||
* @Date:2024/9/20 19:40
|
||||
*/
|
||||
@Log4j2
|
||||
@Configuration
|
||||
public class ToIoTDB {
|
||||
|
||||
private final String IOTDB_DRIVER="org.apache.iotdb.jdbc.IoTDBDriver";
|
||||
private static final String url="jdbc:iotdb://47.116.173.119:6667/";
|
||||
private static final String userName="root";
|
||||
private static final String passWord="root";
|
||||
|
||||
public Connection getConnection() throws ClassNotFoundException, SQLException {
|
||||
Connection connection=null;
|
||||
try{
|
||||
Class.forName(IOTDB_DRIVER);
|
||||
connection = DriverManager.getConnection(url, userName, passWord);
|
||||
}catch(SQLException e){
|
||||
log.error("SQLException: " + e.getMessage());
|
||||
log.error("SQLState: " + e.getSQLState());
|
||||
log.error("VendorError: " + e.getErrorCode());
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
package com.template.util;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
* @Package:com.template.util
|
||||
* @Project:cloud-server
|
||||
* @name:ToIoTDBTest
|
||||
* @Date:2024/9/24 10:12
|
||||
*/
|
||||
public class ToIoTDBTest {
|
||||
|
||||
private static final String host = "47.116.173.119";
|
||||
private static final String url = "jdbc:iotdb://" + host + ":6667/";
|
||||
private static final String username = "root";
|
||||
private static final String password = "root";
|
||||
|
||||
|
||||
public static void main(String[] args) throws SQLException, ClassNotFoundException {
|
||||
|
||||
ToIoTDB toIoTDB = new ToIoTDB();
|
||||
Connection connection = toIoTDB.getConnection();
|
||||
// Connection connection = (Connection) new IOTdbJDBCUtils(url, username, password).getConnection();
|
||||
System.out.println(connection!=null?"打开连接成功!":"打开连接失败!");
|
||||
|
||||
ResultSet rs=null;
|
||||
String storgeGroup="root.test";
|
||||
Statement statement = connection.createStatement();
|
||||
String sql=String.format("set storage group to %s",storgeGroup);
|
||||
statement = connection.createStatement();
|
||||
int i = statement.executeUpdate(sql);
|
||||
System.out.println("当前创建组的结果为:"+i);
|
||||
|
||||
//查看创建的组是否存在
|
||||
sql="SHOW STORAGE GROUPS"; //查看所有的存储组
|
||||
rs= statement.executeQuery(sql);
|
||||
outputResult(rs);
|
||||
|
||||
sql=String.format("show storage group %s",storgeGroup);
|
||||
rs=statement.executeQuery(sql);
|
||||
outputResult(rs);
|
||||
//统计存在的数量
|
||||
sql=String.format("count storage group %s",storgeGroup);
|
||||
rs=statement.executeQuery(sql);
|
||||
outputResult(rs);
|
||||
}
|
||||
|
||||
private static void outputResult(ResultSet resultSet) throws SQLException {
|
||||
if (resultSet != null) {
|
||||
System.out.println("--------------------------");
|
||||
final ResultSetMetaData metaData = resultSet.getMetaData();
|
||||
final int columnCount = metaData.getColumnCount();
|
||||
for (int i = 0; i < columnCount; i++) {
|
||||
System.out.print(metaData.getColumnLabel(i + 1) + ", ");
|
||||
}
|
||||
System.out.println();
|
||||
while (resultSet.next()) {
|
||||
for (int i = 1;; i++) {
|
||||
System.out.print(resultSet.getString(i));
|
||||
if (i < columnCount) {
|
||||
System.out.print(", ");
|
||||
} else {
|
||||
System.out.println();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("--------------------------\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -10,4 +10,14 @@
|
|||
<select id="carMapper" resultType="com.template.domain.CarType">
|
||||
select * from car_type where id=#{carTypeId}
|
||||
</select>
|
||||
<select id="findAllCars" resultType="com.template.domain.resp.CarTypeResp">
|
||||
SELECT
|
||||
car_type.*,
|
||||
t_template.template_name
|
||||
FROM
|
||||
car_type
|
||||
LEFT JOIN t_template ON car_type.template_id = t_template.template_id
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -11,5 +11,13 @@
|
|||
<select id="findTemplateByName" resultType="com.template.domain.Template">
|
||||
select * from t_template where template_name=#{typeName}
|
||||
</select>
|
||||
<select id="findTemplateById" resultType="com.template.domain.MessageTemplateType">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
message_template_type
|
||||
WHERE
|
||||
template_id = #{templateId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<module>cloud-modules-breakdown</module>
|
||||
<module>cloud-modules-warn</module>
|
||||
<module>cloud-saas</module>
|
||||
<module>cloud-data</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>cloud-modules</artifactId>
|
||||
|
|
Loading…
Reference in New Issue