Compare commits
No commits in common. "f3c90ada2a260cc9b2d5ba44c54cc37e2bee73cd" and "735e7f56e0c636324e5fdc2d9b408eab4a6b5d77" have entirely different histories.
f3c90ada2a
...
735e7f56e0
|
@ -30,10 +30,6 @@ public class RegisterBody extends LoginBody {
|
||||||
/**
|
/**
|
||||||
* 手机号
|
* 手机号
|
||||||
*/
|
*/
|
||||||
private String phonenumber;
|
private String phoneNumber;
|
||||||
/**
|
|
||||||
* 公司注册人名称
|
|
||||||
*/
|
|
||||||
private String nickName;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,18 +127,10 @@ public class SysLoginService {
|
||||||
|
|
||||||
// 注册用户信息
|
// 注册用户信息
|
||||||
SysUser sysUser = new SysUser();
|
SysUser sysUser = new SysUser();
|
||||||
//公司账号
|
|
||||||
sysUser.setUserName(registerBody.getUsername());
|
sysUser.setUserName(registerBody.getUsername());
|
||||||
//公司邮箱
|
|
||||||
sysUser.setEmail(registerBody.getEmail());
|
sysUser.setEmail(registerBody.getEmail());
|
||||||
//公司号码
|
sysUser.setPhonenumber(registerBody.getPhoneNumber());
|
||||||
sysUser.setPhonenumber(registerBody.getPhonenumber());
|
|
||||||
//密码
|
|
||||||
sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
|
sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
|
||||||
//公司注册人名称
|
|
||||||
sysUser.setNickName(registerBody.getNickName());
|
|
||||||
//企业名称
|
|
||||||
sysUser.setFirmName(registerBody.getFirmName());
|
|
||||||
Result<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
|
Result<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER);
|
||||||
|
|
||||||
if (Result.FAIL == registerResult.getCode()) {
|
if (Result.FAIL == registerResult.getCode()) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 159.75.188.178:8848
|
addr: 127.0.0.1:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: xxy
|
namespace: xxy
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
<?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-common</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>cloud-common-kafka</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.apache.kafka</groupId>
|
|
||||||
<artifactId>kafka-clients</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 项目公共核心 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,54 +0,0 @@
|
||||||
package com.muyu.common.kafka.config;
|
|
||||||
|
|
||||||
import com.muyu.common.kafka.constants.KafkaConstants;
|
|
||||||
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
|
||||||
import org.apache.kafka.common.serialization.Deserializer;
|
|
||||||
import org.apache.kafka.common.serialization.StringDeserializer;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.boot.SpringBootConfiguration;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* kafka 消息的消费者 配置类
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class KafkaConsumerConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public KafkaConsumer kafkaConsumer() {
|
|
||||||
Map<String, Object> configs = new HashMap<>();
|
|
||||||
//kafka服务端的IP和端口,格式:(ip:port)
|
|
||||||
configs.put("bootstrap.servers", "60.204.221.52:9092");
|
|
||||||
//开启consumer的偏移量(offset)自动提交到Kafka
|
|
||||||
configs.put("enable.auto.commit", true);
|
|
||||||
//consumer的偏移量(offset) 自动提交的时间间隔,单位毫秒
|
|
||||||
configs.put("auto.commit.interval", 5000);
|
|
||||||
//在Kafka中没有初始化偏移量或者当前偏移量不存在情况
|
|
||||||
//earliest, 在偏移量无效的情况下, 自动重置为最早的偏移量
|
|
||||||
//latest, 在偏移量无效的情况下, 自动重置为最新的偏移量
|
|
||||||
//none, 在偏移量无效的情况下, 抛出异常.
|
|
||||||
configs.put("auto.offset.reset", "latest");
|
|
||||||
//请求阻塞的最大时间(毫秒)
|
|
||||||
configs.put("fetch.max.wait", 500);
|
|
||||||
//请求应答的最小字节数
|
|
||||||
configs.put("fetch.min.size", 1);
|
|
||||||
//心跳间隔时间(毫秒)
|
|
||||||
configs.put("heartbeat-interval", 3000);
|
|
||||||
//一次调用poll返回的最大记录条数
|
|
||||||
configs.put("max.poll.records", 500);
|
|
||||||
//指定消费组
|
|
||||||
configs.put("group.id", KafkaConstants.KafkaGrop);
|
|
||||||
//指定key使用的反序列化类
|
|
||||||
Deserializer keyDeserializer = new StringDeserializer();
|
|
||||||
//指定value使用的反序列化类
|
|
||||||
Deserializer valueDeserializer = new StringDeserializer();
|
|
||||||
//创建Kafka消费者
|
|
||||||
KafkaConsumer kafkaConsumer = new KafkaConsumer(configs, keyDeserializer, valueDeserializer);
|
|
||||||
return kafkaConsumer;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
package com.muyu.common.kafka.config;
|
|
||||||
|
|
||||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
|
||||||
import org.apache.kafka.common.serialization.Serializer;
|
|
||||||
import org.apache.kafka.common.serialization.StringSerializer;
|
|
||||||
import org.springframework.boot.SpringBootConfiguration;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* kafka 消息的生产者 配置类
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class KafkaProviderConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public KafkaProducer kafkaProducer() {
|
|
||||||
Map<String, Object> configs = new HashMap<>();
|
|
||||||
//#kafka服务端的IP和端口,格式:(ip:port)
|
|
||||||
configs.put("bootstrap.servers", "47.116.173.119:9092");
|
|
||||||
//客户端发送服务端失败的重试次数
|
|
||||||
configs.put("retries", 2);
|
|
||||||
//多个记录被发送到同一个分区时,生产者将尝试将记录一起批处理成更少的请求.
|
|
||||||
//此设置有助于提高客户端和服务器的性能,配置控制默认批量大小(以字节为单位)
|
|
||||||
configs.put("batch.size", 16384);
|
|
||||||
//生产者可用于缓冲等待发送到服务器的记录的总内存字节数(以字节为单位)
|
|
||||||
configs.put("buffer-memory", 33554432);
|
|
||||||
//生产者producer要求leader节点在考虑完成请求之前收到的确认数,用于控制发送记录在服务端的持久化
|
|
||||||
//acks=0,设置为0,则生产者producer将不会等待来自服务器的任何确认.该记录将立即添加到套接字(socket)缓冲区并视为已发送.在这种情况下,无法保证服务器已收到记录,并且重试配置(retries)将不会生效(因为客户端通常不会知道任何故障),每条记录返回的偏移量始终设置为-1.
|
|
||||||
//acks=1,设置为1,leader节点会把记录写入本地日志,不需要等待所有follower节点完全确认就会立即应答producer.在这种情况下,在follower节点复制前,leader节点确认记录后立即失败的话,记录将会丢失.
|
|
||||||
//acks=all,acks=-1,leader节点将等待所有同步复制副本完成再确认记录,这保证了只要至少有一个同步复制副本存活,记录就不会丢失.
|
|
||||||
configs.put("acks", "-1");
|
|
||||||
//指定key使用的序列化类
|
|
||||||
Serializer keySerializer = new StringSerializer();
|
|
||||||
//指定value使用的序列化类
|
|
||||||
Serializer valueSerializer = new StringSerializer();
|
|
||||||
//创建Kafka生产者
|
|
||||||
KafkaProducer kafkaProducer = new KafkaProducer(configs, keySerializer, valueSerializer);
|
|
||||||
return kafkaProducer;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package com.muyu.common.kafka.constants;
|
|
||||||
|
|
||||||
|
|
||||||
public class KafkaConstants {
|
|
||||||
|
|
||||||
public final static String KafkaTopic = "carJsons";
|
|
||||||
|
|
||||||
// public final static String KafkaGrop = "kafka_grop";
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
com.muyu.kafkaconfig.KafkaConfig
|
|
|
@ -87,6 +87,7 @@ public class SysUser extends BaseEntity {
|
||||||
* 企业ID
|
* 企业ID
|
||||||
*/
|
*/
|
||||||
private Integer firmId;
|
private Integer firmId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所属数据库
|
* 所属数据库
|
||||||
*/
|
*/
|
||||||
|
@ -144,12 +145,6 @@ public class SysUser extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司名称
|
|
||||||
* @param userId
|
|
||||||
*/
|
|
||||||
private String firmName;
|
|
||||||
|
|
||||||
public SysUser (Long userId) {
|
public SysUser (Long userId) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 159.75.188.178:8848
|
addr: 127.0.0.1:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: xxy
|
namespace: xxy
|
||||||
|
|
|
@ -11,10 +11,6 @@
|
||||||
|
|
||||||
<artifactId>cloud-modules-carData</artifactId>
|
<artifactId>cloud-modules-carData</artifactId>
|
||||||
|
|
||||||
<description>
|
|
||||||
数据处理模块
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
@ -87,17 +83,14 @@
|
||||||
<version>2.9.3</version>
|
<version>2.9.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>org.apache.kafka</groupId>
|
||||||
<artifactId>cloud-common-kafka</artifactId>
|
<artifactId>kafka-clients</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.iotdb</groupId>
|
<groupId>org.apache.iotdb</groupId>
|
||||||
<artifactId>iotdb-session</artifactId>
|
<artifactId>iotdb-session</artifactId>
|
||||||
<version>0.13.1</version>
|
<version>0.13.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-rabbit</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package com.muyu.carData;
|
package com.muyu.carData;
|
||||||
|
|
||||||
import com.muyu.carData.listener.MyListener;
|
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
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;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:张腾
|
* @Author:张腾
|
||||||
|
@ -17,8 +19,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
public class CarDataApplication {
|
public class CarDataApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication application = new SpringApplication(CarDataApplication.class);
|
SpringApplication.run(CarDataApplication.class,args);
|
||||||
application.addListeners(new MyListener());
|
System.out.println("caused: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;;caused: java.nio.ByteBuffer.flip()Ljava/nio/ByteBuffer;");
|
||||||
application.run(args);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.muyu.carData.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张腾
|
||||||
|
* @Package:com.muyu.carData.annotation
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:IoTTableName
|
||||||
|
* @Date:2024/9/27 19:29
|
||||||
|
*/
|
||||||
|
@Documented
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
|
||||||
|
public @interface IoTTableName {
|
||||||
|
|
||||||
|
String value() default "";
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.kafkaconfig;
|
package com.muyu.carData.config.kafkaconfig;
|
||||||
|
|
||||||
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
||||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||||
|
@ -28,7 +28,7 @@ public class KafkaConfig {
|
||||||
//生产者可用于缓冲等待发送到服务器的记录的总内存字节数
|
//生产者可用于缓冲等待发送到服务器的记录的总内存字节数
|
||||||
configs.put("buffer-memory",3554432);
|
configs.put("buffer-memory",3554432);
|
||||||
/**
|
/**
|
||||||
* ,用于控制发送记录在服务端的持久化
|
*生产者producer要求leader节点在考虑完成请求之前收到的确认数,用于控制发送记录在服务端的持久化
|
||||||
*acks=0,设置为0,则生产者producer将不会等待来自服务器的任何确认.该记录将立即添加到套接字(socket)缓冲区并视为已发送
|
*acks=0,设置为0,则生产者producer将不会等待来自服务器的任何确认.该记录将立即添加到套接字(socket)缓冲区并视为已发送
|
||||||
* .在这种情况下,无法保证服务器已收到记录,并且重试配置(retries)将不会生效(因为客户端通常不会知道任何故障),每条记录返回的偏移量始终设置为-1.
|
* .在这种情况下,无法保证服务器已收到记录,并且重试配置(retries)将不会生效(因为客户端通常不会知道任何故障),每条记录返回的偏移量始终设置为-1.
|
||||||
*acks=1,设置为1,leader节点会把记录写入本地日志,不需要等待所有follower节点完全确认就会立即应答producer.在这种情况下,
|
*acks=1,设置为1,leader节点会把记录写入本地日志,不需要等待所有follower节点完全确认就会立即应答producer.在这种情况下,
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.muyu.carData.constract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张腾
|
||||||
|
* @Package:com.muyu.carData.constract
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:IoTDBTableParam
|
||||||
|
* @Date:2024/9/27 20:02
|
||||||
|
*/
|
||||||
|
public class IoTDBTableParam {
|
||||||
|
|
||||||
|
public static final String SYSLOG_IOT_TABLE = "student";
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ import org.springframework.stereotype.Component;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
/**卡夫卡消费者
|
/**
|
||||||
* @Author:张腾
|
* @Author:张腾
|
||||||
* @Package:com.muyu.carData.consumer
|
* @Package:com.muyu.carData.consumer
|
||||||
* @Project:cloud-server-8
|
* @Project:cloud-server-8
|
||||||
|
@ -29,7 +29,7 @@ public class MyKafkaConsumer implements InitializingBean {
|
||||||
@Autowired
|
@Autowired
|
||||||
private KafkaConsumer kafkaConsumer;
|
private KafkaConsumer kafkaConsumer;
|
||||||
|
|
||||||
private final String topicName = "carJsons";
|
private final String topicName = "test";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
@ -43,14 +43,13 @@ public class MyKafkaConsumer implements InitializingBean {
|
||||||
for (ConsumerRecord<String, String> consumerRecord : consumerRecords) {
|
for (ConsumerRecord<String, String> consumerRecord : consumerRecords) {
|
||||||
//从consumerRecord中获取消费数据
|
//从consumerRecord中获取消费数据
|
||||||
String value = consumerRecord.value();
|
String value = consumerRecord.value();
|
||||||
log.info("从Kafka中消费的原始数据===============>>:{}",value);
|
log.info("从Kafka中消费的原始数据:{}",value);
|
||||||
|
//转换为java对象
|
||||||
|
Student stu = JSONUtil.toBean(value, Student.class);
|
||||||
|
log.info("消费数据转换为Java对象:{}",stu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
||||||
log.info("启动线程结束监听topic:{}",topicName);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.muyu.carData.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张腾
|
||||||
|
* @Package:com.muyu.carData.domain
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:IoTDBRecord
|
||||||
|
* @Date:2024/9/27 19:25
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class IoTDBRecord {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点路径
|
||||||
|
*/
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间戳
|
||||||
|
*/
|
||||||
|
private long time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性
|
||||||
|
*/
|
||||||
|
private List<String> measurementList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性值
|
||||||
|
*/
|
||||||
|
private List<Object> valueList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据类型
|
||||||
|
*/
|
||||||
|
private List<String> typeList;
|
||||||
|
}
|
|
@ -1,22 +0,0 @@
|
||||||
package com.muyu.carData.event;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import org.springframework.context.ApplicationEvent;
|
|
||||||
|
|
||||||
/**自定义事件
|
|
||||||
* @Author:张腾
|
|
||||||
* @Package:com.muyu.carData.event
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:EsSaveEvent
|
|
||||||
* @Date:2024/9/29 21:15
|
|
||||||
*/
|
|
||||||
public class EsSaveEvent extends ApplicationEvent {
|
|
||||||
|
|
||||||
private JSONObject data;
|
|
||||||
|
|
||||||
|
|
||||||
public EsSaveEvent(JSONObject source) {
|
|
||||||
super(source);
|
|
||||||
this.data = source;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.muyu.carData.interfaces;
|
||||||
|
|
||||||
|
import com.muyu.carData.annotation.IoTTableName;
|
||||||
|
import com.muyu.carData.domain.IoTDBRecord;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:张腾
|
||||||
|
* @Package:com.muyu.carData.interfaces
|
||||||
|
* @Project:cloud-server-8
|
||||||
|
* @name:IoTDBRecordable
|
||||||
|
* @Date:2024/9/27 19:22
|
||||||
|
* iot基类
|
||||||
|
*/
|
||||||
|
public interface IoTDBRecordable {
|
||||||
|
|
||||||
|
Logger logger = LoggerFactory.getLogger(IoTDBRecordable.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据载入方法
|
||||||
|
* @return Record
|
||||||
|
*/
|
||||||
|
default IoTDBRecord toRecord() throws Exception {
|
||||||
|
IoTDBRecord ioTDBRecord = new IoTDBRecord();
|
||||||
|
Object getIoTDBTime = this.getClass().getMethod("getIoTDBTime").invoke(this);
|
||||||
|
if (null != getIoTDBTime){
|
||||||
|
ioTDBRecord.setTime((Long) getIoTDBTime);
|
||||||
|
}
|
||||||
|
Class aClass = this.getClass();
|
||||||
|
IoTTableName name = this.getClass().getAnnotation(IoTTableName.class);
|
||||||
|
ioTDBRecord.setDeviceId(name.value());
|
||||||
|
Field[] declaredFields = aClass.getDeclaredFields();
|
||||||
|
ArrayList<String> measurements = new ArrayList<>();
|
||||||
|
ArrayList<Object> records = new ArrayList<>();
|
||||||
|
ArrayList<String> types = new ArrayList<>();
|
||||||
|
for (Field declaredField : declaredFields) {
|
||||||
|
measurements.add(declaredField.getName());
|
||||||
|
String methodNamePro = declaredField.getName().substring(0, 1).toUpperCase() + declaredField.getName().substring(1);
|
||||||
|
Method methodName = this.getClass().getMethod("get" + methodNamePro);
|
||||||
|
records.add(methodName.invoke(this));
|
||||||
|
types.add(methodName.getReturnType().getName());
|
||||||
|
}
|
||||||
|
ioTDBRecord.setMeasurementList(measurements);
|
||||||
|
ioTDBRecord.setValueList(records);
|
||||||
|
ioTDBRecord.setTypeList(types);
|
||||||
|
return ioTDBRecord;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,22 +0,0 @@
|
||||||
package com.muyu.carData.listener;
|
|
||||||
|
|
||||||
import com.muyu.carData.event.EsSaveEvent;
|
|
||||||
import org.springframework.context.event.EventListener;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:张腾
|
|
||||||
* @Package:com.muyu.carData.listener
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:CustomEventListener
|
|
||||||
* @Date:2024/9/29 23:49
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class CustomEventListener {
|
|
||||||
|
|
||||||
@EventListener
|
|
||||||
public void handMyEvent(EsSaveEvent event){
|
|
||||||
//处理事件详情
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package com.muyu.carData.listener;
|
|
||||||
|
|
||||||
import com.muyu.carData.event.EsSaveEvent;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.springframework.context.ApplicationListener;
|
|
||||||
|
|
||||||
/**自定义监听器
|
|
||||||
* @Author:张腾
|
|
||||||
* @Package:com.muyu.carData.listener
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:MyListener
|
|
||||||
* @Date:2024/9/29 21:18
|
|
||||||
*/
|
|
||||||
@Log4j2
|
|
||||||
public class MyListener implements ApplicationListener<EsSaveEvent> {
|
|
||||||
@Override
|
|
||||||
public void onApplicationEvent(EsSaveEvent event) {
|
|
||||||
log.info("监听到自定义事件........");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
package com.muyu.carData.pulisher;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.muyu.carData.event.EsSaveEvent;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**事件发布测试
|
|
||||||
* @Author:张腾
|
|
||||||
* @Package:com.muyu.carData.pulisher
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:CustomEventPublisher
|
|
||||||
* @Date:2024/9/29 23:51
|
|
||||||
*/
|
|
||||||
@Log4j2
|
|
||||||
@Component
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class CustomEventPublisher {
|
|
||||||
|
|
||||||
private ApplicationEventPublisher applicationEventPublisher;
|
|
||||||
|
|
||||||
public void publish(JSONObject data){
|
|
||||||
EsSaveEvent esSaveEvent = new EsSaveEvent(data);
|
|
||||||
applicationEventPublisher.publishEvent(esSaveEvent);
|
|
||||||
log.info("事件发布成功 - 消息是:{}",data);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.carData.controller;
|
package com.muyu.carData.testcontroller;
|
||||||
|
|
||||||
import com.github.benmanes.caffeine.cache.Cache;
|
import com.github.benmanes.caffeine.cache.Cache;
|
||||||
import com.muyu.carData.config.cacheconfig.CaffeineConfig;
|
import com.muyu.carData.config.cacheconfig.CaffeineConfig;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.muyu.carData.controller;
|
package com.muyu.carData.testcontroller;
|
||||||
|
|
||||||
import com.muyu.carData.config.lotdbconfig.IotDBSessionConfig;
|
import com.muyu.carData.config.lotdbconfig.IotDBSessionConfig;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
@ -44,13 +44,11 @@ public class IotDBController {
|
||||||
@GetMapping("/insertData/{insertSize}/{count}")
|
@GetMapping("/insertData/{insertSize}/{count}")
|
||||||
public String insert(@PathVariable(name = "insertSize") int insertSize,@PathVariable(name = "count") int count) throws IoTDBConnectionException, StatementExecutionException {
|
public String insert(@PathVariable(name = "insertSize") int insertSize,@PathVariable(name = "count") int count) throws IoTDBConnectionException, StatementExecutionException {
|
||||||
Session session = iotDBSessionConfig.iotSession();
|
Session session = iotDBSessionConfig.iotSession();
|
||||||
//schemaList 属性及类型
|
|
||||||
List<MeasurementSchema> schemaList = new ArrayList<>();
|
List<MeasurementSchema> schemaList = new ArrayList<>();
|
||||||
schemaList.add(new MeasurementSchema("id", TSDataType.INT32));
|
schemaList.add(new MeasurementSchema("id", TSDataType.INT32));
|
||||||
schemaList.add(new MeasurementSchema("name", TSDataType.TEXT));
|
schemaList.add(new MeasurementSchema("name", TSDataType.TEXT));
|
||||||
schemaList.add(new MeasurementSchema("sex", TSDataType.TEXT));
|
schemaList.add(new MeasurementSchema("sex", TSDataType.TEXT));
|
||||||
|
|
||||||
//tablet 封装数据
|
|
||||||
Tablet tablet = new Tablet("root.yang.baling", schemaList);
|
Tablet tablet = new Tablet("root.yang.baling", schemaList);
|
||||||
|
|
||||||
//以当前时间戳作为插入的起始时间戳
|
//以当前时间戳作为插入的起始时间戳
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muyu.carData.controller;
|
package com.muyu.carData.testcontroller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.muyu.carData.pojo.Student;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||||
|
@ -24,15 +25,21 @@ public class KafkaProducerController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private KafkaProducer kafkaProducer;
|
private KafkaProducer kafkaProducer;
|
||||||
|
|
||||||
private final String topicName = "carJsons";
|
private final String topicName = "test";
|
||||||
|
|
||||||
@GetMapping("/producer")
|
@GetMapping("/produceTest")
|
||||||
public String produceTest(JSONObject data) {
|
public String produceTest() {
|
||||||
try {
|
try {
|
||||||
|
Student stu = Student.builder().id(2)
|
||||||
|
.name("杨闪闪")
|
||||||
|
.sex("男")
|
||||||
|
.build();
|
||||||
|
String stuStr = JSONObject.toJSONString(stu);
|
||||||
log.info("Topic:{}", topicName);
|
log.info("Topic:{}", topicName);
|
||||||
log.info("转换为JSON:{}",data);
|
log.info("Java对象:{}",stu);
|
||||||
|
log.info("转换为JSON:{}",stuStr);
|
||||||
//使用KafkaProducer发送消息
|
//使用KafkaProducer发送消息
|
||||||
ProducerRecord<String, String> stringProducerRecord = new ProducerRecord(topicName, data);
|
ProducerRecord<String, String> stringProducerRecord = new ProducerRecord<>(topicName, stuStr);
|
||||||
kafkaProducer.send(stringProducerRecord);
|
kafkaProducer.send(stringProducerRecord);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error("Producer写入Topic异常,异常信息是:{}",e.getMessage());
|
log.error("Producer写入Topic异常,异常信息是:{}",e.getMessage());
|
||||||
|
@ -40,6 +47,4 @@ public class KafkaProducerController {
|
||||||
return "消息发送成功";
|
return "消息发送成功";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,63 +0,0 @@
|
||||||
# Tomcat
|
|
||||||
server:
|
|
||||||
port: 9702
|
|
||||||
|
|
||||||
# nacos线上地址
|
|
||||||
nacos:
|
|
||||||
addr: 159.75.188.178:8848
|
|
||||||
user-name: nacos
|
|
||||||
password: nacos
|
|
||||||
namespace: eight
|
|
||||||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
|
||||||
# Spring
|
|
||||||
spring:
|
|
||||||
iotdb:
|
|
||||||
username: root
|
|
||||||
password: root
|
|
||||||
ip: 60.204.221.52
|
|
||||||
port: 6667
|
|
||||||
maxSize: 100
|
|
||||||
fetchSize: 10000
|
|
||||||
main:
|
|
||||||
allow-bean-definition-overriding: true
|
|
||||||
application:
|
|
||||||
# 应用名称
|
|
||||||
name: cloud-carData
|
|
||||||
profiles:
|
|
||||||
# 环境配置
|
|
||||||
active: dev
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
# 服务注册地址
|
|
||||||
server-addr: ${nacos.addr}
|
|
||||||
# nacos用户名
|
|
||||||
username: ${nacos.user-name}
|
|
||||||
# nacos密码
|
|
||||||
password: ${nacos.password}
|
|
||||||
# 命名空间
|
|
||||||
namespace: ${nacos.namespace}
|
|
||||||
config:
|
|
||||||
# 服务注册地址
|
|
||||||
server-addr: ${nacos.addr}
|
|
||||||
# nacos用户名
|
|
||||||
username: ${nacos.user-name}
|
|
||||||
# nacos密码
|
|
||||||
password: ${nacos.password}
|
|
||||||
# 命名空间
|
|
||||||
namespace: ${nacos.namespace}
|
|
||||||
# 配置文件格式
|
|
||||||
file-extension: yml
|
|
||||||
# 共享配置
|
|
||||||
shared-configs:
|
|
||||||
# 系统共享配置
|
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
# 系统环境Config共享配置
|
|
||||||
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
# xxl-job 配置文件
|
|
||||||
- application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
# rabbit 配置文件
|
|
||||||
- application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
com.muyu.system.mapper: DEBUG
|
|
|
@ -54,9 +54,5 @@
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>1.2.83</version>
|
<version>1.2.83</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-system</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -5,11 +5,13 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import com.muyu.domain.req.CarInformationAddReq;
|
import com.muyu.domain.req.CarInformationAddReq;
|
||||||
import com.muyu.domain.req.CarInformationUpdReq;
|
import com.muyu.domain.req.CarInformationUpdReq;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
@ -133,7 +135,7 @@ public class CarInformation {
|
||||||
|
|
||||||
public static CarInformation carInformationAddBuilder(CarInformationAddReq carInformation) {
|
public static CarInformation carInformationAddBuilder(CarInformationAddReq carInformation) {
|
||||||
return CarInformation.builder()
|
return CarInformation.builder()
|
||||||
.carInformationVIN(carInformation.getCarInformationVIN())
|
.carInformationVIN(carInformation.getCarInformationVin())
|
||||||
.carInformationLicensePlate(carInformation.getCarInformationLicensePlate())
|
.carInformationLicensePlate(carInformation.getCarInformationLicensePlate())
|
||||||
.carInformationBrand(carInformation.getCarInformationBrand())
|
.carInformationBrand(carInformation.getCarInformationBrand())
|
||||||
.carInformationColor(carInformation.getCarInformationColor())
|
.carInformationColor(carInformation.getCarInformationColor())
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.muyu.domain;
|
package com.muyu.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.domain.req.FaultCodeAddReq;
|
import com.muyu.domain.req.FaultCodeAddReq;
|
||||||
|
@ -64,22 +63,18 @@ public class FaultCode {
|
||||||
/**
|
/**
|
||||||
*故障类型名称
|
*故障类型名称
|
||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
|
||||||
private String faulttypeName;
|
private String faulttypeName;
|
||||||
/**
|
/**
|
||||||
* 故障名称
|
* 故障名称
|
||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
|
||||||
private String messageTypeName;
|
private String messageTypeName;
|
||||||
/**
|
/**
|
||||||
* 报文编码
|
* 报文编码
|
||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
|
||||||
private String messageTypeCode;
|
private String messageTypeCode;
|
||||||
/**
|
/**
|
||||||
*报文所属类别
|
*报文所属类别
|
||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
|
||||||
private String messageTypeBelongs;
|
private String messageTypeBelongs;
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,15 +103,10 @@ public class FaultCode {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static FaultCode faultCodeBuilder(FaultCode faultCode) {
|
|
||||||
return FaultCode.builder()
|
|
||||||
.faultcodeId(faultCode.getFaultcodeId())
|
|
||||||
.messageTypeId(faultCode.getMessageTypeId())
|
|
||||||
.faultcodeNumber(faultCode.getFaultcodeNumber())
|
|
||||||
.faultGroup(faultCode.faultGroup)
|
|
||||||
.faultBit(faultCode.faultBit)
|
|
||||||
.faultValue(faultCode.faultValue)
|
|
||||||
.isWarning(faultCode.isWarning)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.muyu.domain;
|
package com.muyu.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.domain.req.FaultConditionAddReq;
|
import com.muyu.domain.req.FaultConditionAddReq;
|
||||||
|
@ -55,17 +54,14 @@ public class FaultCondition {
|
||||||
/**
|
/**
|
||||||
* 车辆类型名称
|
* 车辆类型名称
|
||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
|
||||||
private String carTypeName;
|
private String carTypeName;
|
||||||
/**
|
/**
|
||||||
* 故障名称
|
* 故障名称
|
||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
|
||||||
private String messageTypeName;
|
private String messageTypeName;
|
||||||
/**
|
/**
|
||||||
* 报文编码
|
* 报文编码
|
||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
|
||||||
private String messageTypeCode;
|
private String messageTypeCode;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
package com.muyu.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 企业名称
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.domain
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:Firm
|
|
||||||
* @Date:2024/9/27 12:29
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
public class Firm {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 企业ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "firm_id")
|
|
||||||
private Long firmId;
|
|
||||||
/**
|
|
||||||
* 企业名称
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String firmName;
|
|
||||||
/**
|
|
||||||
* 数据库名称
|
|
||||||
*/
|
|
||||||
private String databaseName;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,119 +0,0 @@
|
||||||
package com.muyu.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户信息
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.domain
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:SysUser
|
|
||||||
* @Date:2024/9/28 22:37
|
|
||||||
*/
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
@Tag(name = "用户信息")
|
|
||||||
@TableName("sys_user")
|
|
||||||
public class SysUser extends BaseEntity {
|
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
*/
|
|
||||||
@TableId(value = "user_id")
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门ID
|
|
||||||
*/
|
|
||||||
private Long deptId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户账号
|
|
||||||
*/
|
|
||||||
private String userName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户昵称
|
|
||||||
*/
|
|
||||||
private String nickName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户类型(00系统用户)
|
|
||||||
*/
|
|
||||||
private String userType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户邮箱
|
|
||||||
*/
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号码
|
|
||||||
*/
|
|
||||||
private String phonenumber;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户性别(0男 1女 2未知)
|
|
||||||
*/
|
|
||||||
private Integer sex;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 头像地址
|
|
||||||
*/
|
|
||||||
private String avatar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码
|
|
||||||
*/
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 帐号状态(0正常 1停用)
|
|
||||||
*/
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除标志(0代表存在 2代表删除)
|
|
||||||
*/
|
|
||||||
private String delFlag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后登录IP
|
|
||||||
*/
|
|
||||||
private String loginIp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后登录时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date loginDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库名称
|
|
||||||
*/
|
|
||||||
private String databaseName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 企业ID
|
|
||||||
*/
|
|
||||||
private Long firmId;
|
|
||||||
/**
|
|
||||||
* 企业名称
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String firmName;
|
|
||||||
}
|
|
|
@ -21,7 +21,7 @@ public class CarInformationAddReq {
|
||||||
/**
|
/**
|
||||||
* 车辆唯一VIN
|
* 车辆唯一VIN
|
||||||
*/
|
*/
|
||||||
private String carInformationVIN;
|
private String carInformationVin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车牌号
|
* 车牌号
|
||||||
|
|
|
@ -26,6 +26,7 @@ public class FenceGroupReq {
|
||||||
/**
|
/**
|
||||||
* 车辆
|
* 车辆
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private List<CarFence> carFences;
|
private List<CarFence> carFences;
|
||||||
/**
|
/**
|
||||||
* 围栏组
|
* 围栏组
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
package com.muyu.domain.req;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司信息请求对象
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.domain.req
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmListReq
|
|
||||||
* @Date:2024/9/27 19:19
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
@Tag(name = "公司信息请求对象",description = "公司信息请求对象")
|
|
||||||
public class FirmListReq {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司名称
|
|
||||||
*/
|
|
||||||
private String firmName;
|
|
||||||
/**
|
|
||||||
* 页码,从1开始
|
|
||||||
*/
|
|
||||||
private Integer pageNum=1;
|
|
||||||
/**
|
|
||||||
* 每页大小
|
|
||||||
*/
|
|
||||||
private Integer pageSize=10;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,138 +0,0 @@
|
||||||
package com.muyu.domain.resp;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.muyu.domain.SysUser;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 企业信息响应对象
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.domain.resp
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmListResp
|
|
||||||
* @Date:2024/9/27 19:33
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
@Tag(name="企业信息响应对象",description = "企业信息响应对象")
|
|
||||||
public class FirmListResp {
|
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
*/
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门ID
|
|
||||||
*/
|
|
||||||
private Long deptId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户账号
|
|
||||||
*/
|
|
||||||
private String userName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户昵称
|
|
||||||
*/
|
|
||||||
private String nickName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户类型(00系统用户)
|
|
||||||
*/
|
|
||||||
private String userType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户邮箱
|
|
||||||
*/
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 手机号码
|
|
||||||
*/
|
|
||||||
private String phonenumber;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户性别(0男 1女 2未知)
|
|
||||||
*/
|
|
||||||
private Integer sex;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 头像地址
|
|
||||||
*/
|
|
||||||
private String avatar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码
|
|
||||||
*/
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 帐号状态(0正常 1停用)
|
|
||||||
*/
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除标志(0代表存在 2代表删除)
|
|
||||||
*/
|
|
||||||
private String delFlag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后登录IP
|
|
||||||
*/
|
|
||||||
private String loginIp;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后登录时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date loginDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库名称
|
|
||||||
*/
|
|
||||||
private String databaseName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 企业ID
|
|
||||||
*/
|
|
||||||
private Long firmId;
|
|
||||||
/**
|
|
||||||
* 企业名称
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String firmName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库对象构建为返回结果对象
|
|
||||||
*/
|
|
||||||
public static FirmListResp firmListResp(SysUser sysUser){
|
|
||||||
return FirmListResp.builder()
|
|
||||||
.userId(sysUser.getUserId())
|
|
||||||
.deptId(sysUser.getDeptId())
|
|
||||||
.userName(sysUser.getUserName())
|
|
||||||
.nickName(sysUser.getNickName())
|
|
||||||
.userType((sysUser.getUserType()))
|
|
||||||
.email(sysUser.getEmail())
|
|
||||||
.phonenumber(sysUser.getPhonenumber())
|
|
||||||
.sex(sysUser.getSex())
|
|
||||||
.avatar(sysUser.getAvatar())
|
|
||||||
.password(sysUser.getPassword())
|
|
||||||
.status(sysUser.getStatus())
|
|
||||||
.delFlag(sysUser.getDelFlag())
|
|
||||||
.loginDate(sysUser.getLoginDate())
|
|
||||||
.databaseName(sysUser.getDatabaseName())
|
|
||||||
.firmId(sysUser.getFirmId())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package com.muyu.domain.resp;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司数据总数响应对象
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.domain.resp.firmlist
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmTotalListResp
|
|
||||||
* @Date:2024/9/27 19:42
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
@Tag(name = "公司数据总数列表",description = "数据总数响应")
|
|
||||||
public class FirmTotalListResp {
|
|
||||||
|
|
||||||
private List<FirmListResp> firmListRespList;
|
|
||||||
|
|
||||||
private long total;
|
|
||||||
|
|
||||||
public static FirmTotalListResp firmTotalListResp(List<FirmListResp> firmListRespList,long toal){
|
|
||||||
FirmTotalListResp firmTotalListResp = new FirmTotalListResp();
|
|
||||||
firmTotalListResp.setFirmListRespList(firmListRespList);
|
|
||||||
firmTotalListResp.setTotal(toal);
|
|
||||||
return firmTotalListResp;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,7 +8,10 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -42,8 +45,8 @@ public class CarMessageController {
|
||||||
@PostMapping("/insertCarMessage")
|
@PostMapping("/insertCarMessage")
|
||||||
@Operation(summary = "添加报文信息")
|
@Operation(summary = "添加报文信息")
|
||||||
public Result<Integer> insertCarMessage(@Validated @RequestBody CarMessage carMessage){
|
public Result<Integer> insertCarMessage(@Validated @RequestBody CarMessage carMessage){
|
||||||
int inserted = carMessageService.insertCarMessage(carMessage);
|
boolean inserted = carMessageService.insertCarMessage(carMessage);
|
||||||
if (inserted>0){
|
if (inserted){
|
||||||
return Result.success(200,"添加成功");
|
return Result.success(200,"添加成功");
|
||||||
}
|
}
|
||||||
return Result.error(402,"添加失败");
|
return Result.error(402,"添加失败");
|
||||||
|
@ -55,9 +58,9 @@ public class CarMessageController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/delectByCarMessageId")
|
@PostMapping("/delectByCarMessageId")
|
||||||
@Operation(summary = "删除报文信息")
|
@Operation(summary = "删除报文信息")
|
||||||
public Result<Integer> delectByCarMessageId(@RequestParam(name = "carMessageId") Integer carMessageId){
|
public Result<Integer> delectByCarMessageId(Integer carMessageId){
|
||||||
int deleteByCarMessageId = carMessageService.delectByCarMessageId(carMessageId);
|
boolean deleteByCarMessageId = carMessageService.delectByCarMessageId(carMessageId);
|
||||||
if (deleteByCarMessageId>0){
|
if (deleteByCarMessageId){
|
||||||
return Result.success(200,"删除成功");
|
return Result.success(200,"删除成功");
|
||||||
}
|
}
|
||||||
return Result.error(402,"删除失败");
|
return Result.error(402,"删除失败");
|
||||||
|
@ -69,8 +72,8 @@ public class CarMessageController {
|
||||||
@PostMapping("/updateCarMessage")
|
@PostMapping("/updateCarMessage")
|
||||||
@Operation(summary = "修改报文信息")
|
@Operation(summary = "修改报文信息")
|
||||||
public Result<Integer> updateCarMessage(@Validated @RequestBody CarMessage carMessage){
|
public Result<Integer> updateCarMessage(@Validated @RequestBody CarMessage carMessage){
|
||||||
int updateCarMessage = carMessageService.updateCarMessage(carMessage);
|
boolean updateCarMessage = carMessageService.updateCarMessage(carMessage);
|
||||||
if(updateCarMessage>0)
|
if(updateCarMessage)
|
||||||
{
|
{
|
||||||
return Result.success(200,"修改成功");
|
return Result.success(200,"修改成功");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
package com.muyu.server.controller;
|
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.domain.req.FirmListReq;
|
|
||||||
import com.muyu.domain.resp.FirmTotalListResp;
|
|
||||||
import com.muyu.server.service.FirmManageService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 企业信息控制层
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.controller
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmManageController
|
|
||||||
* @Date:2024/9/27 12:27
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/firmmanage")
|
|
||||||
@Tag(name = "公司相关事务",description = "公司相关事务操作")
|
|
||||||
public class FirmManageController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FirmManageService firmManageService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司列表信息展示
|
|
||||||
* @param firmListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/firmmessageList")
|
|
||||||
@Operation(summary = "公司信息列表展示",description = "展示公司信息的列表")
|
|
||||||
public Result firmmessageList(@Validated @RequestBody FirmListReq firmListReq){
|
|
||||||
FirmTotalListResp firmTotalListResp = firmManageService.firmmessageList(firmListReq);
|
|
||||||
return Result.success(firmTotalListResp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -8,8 +8,8 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报文模板展示列表持久层
|
* 报文模板展示列表持久层
|
||||||
* @author 17353
|
|
||||||
*/
|
*/
|
||||||
|
@Mapper
|
||||||
public interface CarMessageMapper extends MPJBaseMapper<CarMessage> {
|
public interface CarMessageMapper extends MPJBaseMapper<CarMessage> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
package com.muyu.server.mapper;
|
|
||||||
|
|
||||||
import com.github.yulichang.base.MPJBaseMapper;
|
|
||||||
import com.muyu.domain.Firm;
|
|
||||||
import com.muyu.domain.SysUser;
|
|
||||||
import com.muyu.domain.req.FirmListReq;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司+员工持久层
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.mapper
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmManageMapper
|
|
||||||
* @Date:2024/9/27 12:28
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface FirmManageMapper extends MPJBaseMapper<SysUser> {
|
|
||||||
|
|
||||||
List<Firm> firmmessageList(FirmListReq firmListReq);
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package com.muyu.server.mapper;
|
|
||||||
|
|
||||||
import com.github.yulichang.base.MPJBaseMapper;
|
|
||||||
import com.muyu.domain.Firm;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司表持久层
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.mapper
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmMapper
|
|
||||||
* @Date:2024/9/29 16:56
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface FirmMapper extends MPJBaseMapper<Firm> {
|
|
||||||
}
|
|
|
@ -24,19 +24,19 @@ public interface CarMessageService extends IService<CarMessage> {
|
||||||
/**
|
/**
|
||||||
* 添加车辆报文规则
|
* 添加车辆报文规则
|
||||||
*/
|
*/
|
||||||
int insertCarMessage(CarMessage carMessage);
|
boolean insertCarMessage(CarMessage carMessage);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除车辆报文规则
|
* 删除车辆报文规则
|
||||||
*/
|
*/
|
||||||
int delectByCarMessageId(Integer carMessageId);
|
boolean delectByCarMessageId(Integer carMessageId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改车辆报文规则
|
* 修改车辆报文规则
|
||||||
*/
|
*/
|
||||||
int updateCarMessage(CarMessage carMessage);
|
boolean updateCarMessage(CarMessage carMessage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询
|
* 查询
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
package com.muyu.server.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.muyu.domain.SysUser;
|
|
||||||
import com.muyu.domain.req.FirmListReq;
|
|
||||||
import com.muyu.domain.resp.FirmTotalListResp;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司+员工业务层
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.service
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmManageService
|
|
||||||
* @Date:2024/9/27 12:28
|
|
||||||
*/
|
|
||||||
public interface FirmManageService extends IService<SysUser> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司列表信息展示
|
|
||||||
* @param firmListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
FirmTotalListResp firmmessageList(FirmListReq firmListReq);
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package com.muyu.server.service;
|
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.muyu.domain.Firm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司业务层
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.service
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmService
|
|
||||||
* @Date:2024/9/29 16:57
|
|
||||||
*/
|
|
||||||
public interface FirmService extends IService<Firm> {
|
|
||||||
/**
|
|
||||||
* 查询公司数目
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
long findcount();
|
|
||||||
}
|
|
|
@ -1,8 +1,12 @@
|
||||||
package com.muyu.server.service.impl;
|
package com.muyu.server.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.domain.CarFence;
|
import com.muyu.domain.CarFence;
|
||||||
import com.muyu.domain.CarInformation;
|
import com.muyu.domain.CarInformation;
|
||||||
|
@ -148,5 +152,4 @@ public class CarInformationServiceImpl
|
||||||
});
|
});
|
||||||
return carInformationResps;
|
return carInformationResps;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,24 +67,24 @@ public class CarMessageServiceImpl
|
||||||
* 添加车辆报文规则
|
* 添加车辆报文规则
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertCarMessage(CarMessage carMessage) {
|
public boolean insertCarMessage(CarMessage carMessage) {
|
||||||
return carMessageMapper.insert(CarMessage.carMessageAddBuilder(carMessage));
|
return this.save(CarMessage.carMessageAddBuilder(carMessage));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 删除车辆报文规则
|
* 删除车辆报文规则
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int delectByCarMessageId(Integer carMessageId) {
|
public boolean delectByCarMessageId(Integer carMessageId) {
|
||||||
return carMessageMapper.deleteById(carMessageId);
|
return this.removeById(carMessageId);
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 修改车辆报文规则
|
* 修改车辆报文规则
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateCarMessage(CarMessage carMessage) {
|
public boolean updateCarMessage(CarMessage carMessage) {
|
||||||
// Integer integer = carMessageMapper.updateCarMessage(carMessage);
|
// Integer integer = carMessageMapper.updateCarMessage(carMessage);
|
||||||
return carMessageMapper.updateById(CarMessage.carMessageUpdBuilder(carMessage, carMessage::getMessageTypeId));
|
return this.updateById(CarMessage.carMessageUpdBuilder(carMessage, carMessage::getMessageTypeId));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 查询
|
* 查询
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class FaultCodeServiceImpl extends ServiceImpl<FaultCodeMapper, FaultCode
|
||||||
LambdaQueryWrapper<FaultCode> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<FaultCode> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(StringUtils.isNotEmpty(faultcodeNumber),
|
queryWrapper.eq(StringUtils.isNotEmpty(faultcodeNumber),
|
||||||
FaultCode::getFaultcodeNumber, faultcodeNumber);
|
FaultCode::getFaultcodeNumber, faultcodeNumber);
|
||||||
List<FaultCode> list = this.list(queryWrapper).stream().map(FaultCode::faultCodeBuilder).toList();
|
List<FaultCode> list = this.list(queryWrapper);
|
||||||
FaultCode faultCode=null;
|
FaultCode faultCode=null;
|
||||||
if (!list.isEmpty()){
|
if (!list.isEmpty()){
|
||||||
faultCode=list.get(0);
|
faultCode=list.get(0);
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package com.muyu.server.service.impl;
|
package com.muyu.server.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.domain.CarInformation;
|
import com.muyu.domain.CarInformation;
|
||||||
import com.muyu.domain.FaultCode;
|
import com.muyu.domain.FaultCode;
|
||||||
|
import com.muyu.domain.FaultCondition;
|
||||||
import com.muyu.domain.FaultLog;
|
import com.muyu.domain.FaultLog;
|
||||||
import com.muyu.domain.req.FaultLogListReq;
|
import com.muyu.domain.req.FaultLogListReq;
|
||||||
import com.muyu.domain.resp.FaultLogListResp;
|
import com.muyu.domain.resp.FaultLogListResp;
|
||||||
|
|
|
@ -1,25 +1,20 @@
|
||||||
package com.muyu.server.service.impl;
|
package com.muyu.server.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.github.yulichang.query.MPJLambdaQueryWrapper;
|
import com.github.yulichang.query.MPJLambdaQueryWrapper;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
|
||||||
import com.muyu.domain.*;
|
import com.muyu.domain.*;
|
||||||
import com.muyu.domain.resp.FaultConditionResp;
|
import com.muyu.domain.resp.FaultConditionResp;
|
||||||
import com.muyu.server.mapper.CarFenceMapper;
|
import com.muyu.server.mapper.CarFenceMapper;
|
||||||
import com.muyu.server.mapper.CarInformationMapper;
|
import com.muyu.server.mapper.CarInformationMapper;
|
||||||
import com.muyu.server.mapper.FaultConditionMapper;
|
import com.muyu.server.mapper.FaultConditionMapper;
|
||||||
import com.muyu.server.mapper.FaultRuleMapper;
|
import com.muyu.server.mapper.FaultRuleMapper;
|
||||||
import com.muyu.server.service.CarInformationService;
|
|
||||||
import com.muyu.server.service.FaultRuleService;
|
import com.muyu.server.service.FaultRuleService;
|
||||||
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.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,8 +29,6 @@ import java.util.List;
|
||||||
@Service
|
@Service
|
||||||
public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, CarFaultRule> implements FaultRuleService {
|
public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, CarFaultRule> implements FaultRuleService {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CarInformationService carInformationService;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CarInformationMapper carInformationMapper;
|
private CarInformationMapper carInformationMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -50,15 +43,9 @@ public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, CarFaultR
|
||||||
public List<Vehicle> checkfault(CarFaultRule carFaultRule) {
|
public List<Vehicle> checkfault(CarFaultRule carFaultRule) {
|
||||||
List<Vehicle> vehicles = new ArrayList<>();
|
List<Vehicle> vehicles = new ArrayList<>();
|
||||||
//根据车辆VIN判断它属于什么类型的车辆
|
//根据车辆VIN判断它属于什么类型的车辆
|
||||||
List<CarInformation> carInformationList = carInformationMapper.selectList(
|
CarInformation carInformation = carInformationMapper.selectById(carFaultRule.getVin());
|
||||||
new LambdaQueryWrapper<CarInformation>()
|
Integer carInformationType = carInformation.getCarInformationType();
|
||||||
.eq(CarInformation::getCarInformationVIN, carFaultRule.getVin()));
|
|
||||||
//根据车辆类型,查询表获取对应的类型的故障规则
|
//根据车辆类型,查询表获取对应的类型的故障规则
|
||||||
Integer carInformationType = null;
|
|
||||||
for (CarInformation carInformation : carInformationList) {
|
|
||||||
carInformationType= carInformation.getCarInformationType();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
List<FaultConditionResp> faultConditionResps = faultConditionMapper.selectJoinList(FaultConditionResp.class, new MPJLambdaWrapper<FaultCondition>()
|
List<FaultConditionResp> faultConditionResps = faultConditionMapper.selectJoinList(FaultConditionResp.class, new MPJLambdaWrapper<FaultCondition>()
|
||||||
.selectAll(FaultCondition.class)
|
.selectAll(FaultCondition.class)
|
||||||
|
@ -66,8 +53,7 @@ public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, CarFaultR
|
||||||
.select(FaultLabel::getMessageTypeName)
|
.select(FaultLabel::getMessageTypeName)
|
||||||
.select(FaultLabel::getMessageTypeCode)
|
.select(FaultLabel::getMessageTypeCode)
|
||||||
.leftJoin(CarType.class, CarType::getCarTypeId, FaultCondition::getCarTypeId)
|
.leftJoin(CarType.class, CarType::getCarTypeId, FaultCondition::getCarTypeId)
|
||||||
.leftJoin(FaultLabel.class, FaultLabel::getMessageTypeId, FaultCondition::getMessageTypeId)
|
.leftJoin(FaultLabel.class, FaultLabel::getMessageTypeId, FaultCondition::getMessageTypeId));
|
||||||
.eq(FaultCondition::getCarTypeId,carInformationType));
|
|
||||||
//获取当前类的所有字段,不包括继承的
|
//获取当前类的所有字段,不包括继承的
|
||||||
Class<? extends CarFaultRule> carFaultRuleClass = carFaultRule.getClass();
|
Class<? extends CarFaultRule> carFaultRuleClass = carFaultRule.getClass();
|
||||||
Field[] declaredFields = carFaultRuleClass.getDeclaredFields();
|
Field[] declaredFields = carFaultRuleClass.getDeclaredFields();
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
package com.muyu.server.service.impl;
|
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
|
||||||
import com.muyu.domain.Firm;
|
|
||||||
import com.muyu.domain.SysUser;
|
|
||||||
import com.muyu.domain.req.FirmListReq;
|
|
||||||
import com.muyu.domain.resp.FirmListResp;
|
|
||||||
import com.muyu.domain.resp.FirmTotalListResp;
|
|
||||||
import com.muyu.server.mapper.FirmManageMapper;
|
|
||||||
import com.muyu.server.service.FirmManageService;
|
|
||||||
import com.muyu.server.service.FirmService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司+员工业务实现层
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.service.impl
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmManageServiceImpl
|
|
||||||
* @Date:2024/9/27 12:28
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class FirmManageServiceImpl extends ServiceImpl<FirmManageMapper, SysUser> implements FirmManageService {
|
|
||||||
@Autowired
|
|
||||||
private FirmManageMapper firmManageMapper;
|
|
||||||
@Autowired
|
|
||||||
private FirmService firmService;
|
|
||||||
/**
|
|
||||||
* 公司列表信息展示
|
|
||||||
* @param firmListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public FirmTotalListResp firmmessageList(FirmListReq firmListReq) {
|
|
||||||
long findcount = firmService.findcount();
|
|
||||||
MPJLambdaWrapper<SysUser> wrapper = new MPJLambdaWrapper<>();
|
|
||||||
wrapper.selectAll(SysUser.class)
|
|
||||||
.selectAll(Firm.class)
|
|
||||||
.leftJoin(Firm.class,Firm::getFirmId,SysUser::getFirmId)
|
|
||||||
.eq(StringUtils.isNotEmpty(firmListReq.getFirmName()),
|
|
||||||
Firm::getFirmName, firmListReq.getFirmName());
|
|
||||||
wrapper.last("LIMIT "+((firmListReq.getPageNum()-1)*firmListReq.getPageSize())+","+firmListReq.getPageSize());
|
|
||||||
List<FirmListResp> firmListResps = firmManageMapper.selectJoinList(FirmListResp.class, wrapper);
|
|
||||||
return FirmTotalListResp.firmTotalListResp(firmListResps,findcount);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package com.muyu.server.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.muyu.domain.Firm;
|
|
||||||
import com.muyu.server.mapper.FirmMapper;
|
|
||||||
import com.muyu.server.service.FirmService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公司业务实现层
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.firmmanage.service.impl
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:FirmServiceImpl
|
|
||||||
* @Date:2024/9/29 16:57
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class FirmServiceImpl extends ServiceImpl<FirmMapper, Firm> implements FirmService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询公司数目
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public long findcount() {
|
|
||||||
LambdaQueryWrapper<Firm> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
long count = this.count(queryWrapper);
|
|
||||||
return count;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,7 +4,7 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 159.75.188.178:8848
|
addr: 127.0.0.1:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: xxy
|
namespace: xxy
|
||||||
|
|
|
@ -4,7 +4,7 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 159.75.188.178:8848
|
addr: 127.0.0.1:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: xxy
|
namespace: xxy
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package com.muyu.server.mqtt;
|
package com.muyu.mqtt;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.muyu.common.kafka.constants.KafkaConstants;
|
||||||
|
|
||||||
import com.muyu.domain.CarMessage;
|
import com.muyu.domain.CarMessage;
|
||||||
import com.muyu.server.service.CarMessageService;
|
import com.muyu.service.CarMessageService;
|
||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||||
import org.eclipse.paho.client.mqttv3.*;
|
import org.eclipse.paho.client.mqttv3.*;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -16,7 +16,7 @@ import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
|
||||||
@Component
|
//@Component
|
||||||
public class Demo {
|
public class Demo {
|
||||||
@Resource
|
@Resource
|
||||||
private CarMessageService service;
|
private CarMessageService service;
|
||||||
|
@ -24,11 +24,10 @@ public class Demo {
|
||||||
private KafkaProducer<String, String> kafkaProducer;
|
private KafkaProducer<String, String> kafkaProducer;
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void test() {
|
public void test() {
|
||||||
|
|
||||||
String topic = "vehicle";
|
String topic = "vehicle";
|
||||||
String content = "Message from MqttPublishSample";
|
String content = "Message from MqttPublishSample";
|
||||||
int qos = 2;
|
int qos = 2;
|
||||||
String broker = "tcp://106.15.136.7:1883";
|
String broker = "tcp://60.204.221.52:1883";
|
||||||
String clientId = "JavaSample";
|
String clientId = "JavaSample";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -49,7 +48,7 @@ public class Demo {
|
||||||
@Override
|
@Override
|
||||||
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
|
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
|
||||||
|
|
||||||
List<CarMessage> list= service.selectCarMessageList(1,2);
|
List<CarMessage> list= service.selectCarMessage(1);
|
||||||
String str = new String( mqttMessage.getPayload() );
|
String str = new String( mqttMessage.getPayload() );
|
||||||
System.out.println(str);
|
System.out.println(str);
|
||||||
String[] test = str.split(" ");
|
String[] test = str.split(" ");
|
||||||
|
@ -82,7 +81,7 @@ public class Demo {
|
||||||
results[i] = futures.get(i).get();
|
results[i] = futures.get(i).get();
|
||||||
}
|
}
|
||||||
String jsonString = JSONObject.toJSONString( results );
|
String jsonString = JSONObject.toJSONString( results );
|
||||||
ProducerRecord<String, String> producerRecord = new ProducerRecord<>( "carJsons", jsonString);
|
ProducerRecord<String, String> producerRecord = new ProducerRecord<>( KafkaConstants.KafkaTopic, jsonString);
|
||||||
kafkaProducer.send(producerRecord);
|
kafkaProducer.send(producerRecord);
|
||||||
}
|
}
|
||||||
// 接收信息
|
// 接收信息
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
# Tomcat
|
|
||||||
server:
|
|
||||||
port: 9112
|
|
||||||
|
|
||||||
# nacos线上地址
|
|
||||||
nacos:
|
|
||||||
addr: 159.75.188.178:8848
|
|
||||||
user-name: nacos
|
|
||||||
password: nacos
|
|
||||||
namespace: xxy
|
|
||||||
|
|
||||||
# Spring
|
|
||||||
spring:
|
|
||||||
application:
|
|
||||||
# 应用名称
|
|
||||||
name: cloud-electronic
|
|
||||||
profiles:
|
|
||||||
# 环境配置
|
|
||||||
active: dev
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
# 服务注册地址
|
|
||||||
server-addr: ${nacos.addr}
|
|
||||||
# nacos用户名
|
|
||||||
username: ${nacos.user-name}
|
|
||||||
# nacos密码
|
|
||||||
password: ${nacos.password}
|
|
||||||
# 命名空间
|
|
||||||
namespace: ${nacos.namespace}
|
|
||||||
config:
|
|
||||||
# 服务注册地址
|
|
||||||
server-addr: ${nacos.addr}
|
|
||||||
# nacos用户名
|
|
||||||
username: ${nacos.user-name}
|
|
||||||
# nacos密码
|
|
||||||
password: ${nacos.password}
|
|
||||||
# 命名空间
|
|
||||||
namespace: ${nacos.namespace}
|
|
||||||
# 配置文件格式
|
|
||||||
file-extension: yml
|
|
||||||
# 共享配置
|
|
||||||
shared-configs:
|
|
||||||
# 系统共享配置
|
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
# 系统环境Config共享配置
|
|
||||||
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
|
@ -142,11 +142,4 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||||
|
|
||||||
List<SysUser> companyList();
|
List<SysUser> companyList();
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加公司名称
|
|
||||||
* @param firmName
|
|
||||||
* @param datbaseName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer insertFirm(@Param("firmName") String firmName, @Param("datbaseName") String datbaseName);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package com.muyu.system.service;
|
|
||||||
|
|
||||||
import com.muyu.common.system.domain.SysUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.system.service
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:DataBaseCreator
|
|
||||||
* @Date:2024/9/26 20:40
|
|
||||||
*/
|
|
||||||
public interface DataBaseCreator {
|
|
||||||
|
|
||||||
|
|
||||||
String createDatbase(SysUser user);
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
package com.muyu.system.service.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.RandomUtil;
|
|
||||||
import com.muyu.common.system.domain.SysUser;
|
|
||||||
import com.muyu.system.service.DataBaseCreator;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.Statement;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author:weiran
|
|
||||||
* @Package:com.muyu.system.service.impl
|
|
||||||
* @Project:cloud-server-8
|
|
||||||
* @name:DataBaseCreatorImpl
|
|
||||||
* @Date:2024/9/26 20:40
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class DataBaseCreatorImpl implements DataBaseCreator {
|
|
||||||
|
|
||||||
|
|
||||||
private static final String DB_URL="jdbc:mysql://159.75.188.178:3306?useSSL=false";
|
|
||||||
private static final String USER="root";
|
|
||||||
private static final String PASS="bwie-8666";
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String createDatbase(SysUser user) {
|
|
||||||
try {
|
|
||||||
Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
|
|
||||||
Statement statement = conn.createStatement();
|
|
||||||
String datbaseName="company"+RandomUtil.randomNumbers(5);
|
|
||||||
//创建数据库
|
|
||||||
String sqlCreateDatabase ="CREATE DATABASE IF NOT EXISTS "+datbaseName;
|
|
||||||
String sqlUseDatabase="USE "+datbaseName;
|
|
||||||
String sqlCreateTable="CREATE TABLE user ("+
|
|
||||||
"user_id INT AUTO_INCREMENT PRIMARY KEY,"+
|
|
||||||
"user_name VARCHAR(50) NOT NULL )";
|
|
||||||
statement.execute(sqlCreateDatabase);
|
|
||||||
statement.execute(sqlUseDatabase);
|
|
||||||
statement.execute(sqlCreateTable);
|
|
||||||
return datbaseName;
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException("数据库创建失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -14,7 +14,6 @@ import com.muyu.system.domain.SysPost;
|
||||||
import com.muyu.system.domain.SysUserPost;
|
import com.muyu.system.domain.SysUserPost;
|
||||||
import com.muyu.system.domain.SysUserRole;
|
import com.muyu.system.domain.SysUserRole;
|
||||||
import com.muyu.system.mapper.*;
|
import com.muyu.system.mapper.*;
|
||||||
import com.muyu.system.service.DataBaseCreator;
|
|
||||||
import com.muyu.system.service.SysUserService;
|
import com.muyu.system.service.SysUserService;
|
||||||
import com.muyu.system.service.SysConfigService;
|
import com.muyu.system.service.SysConfigService;
|
||||||
import jakarta.validation.Validator;
|
import jakarta.validation.Validator;
|
||||||
|
@ -51,8 +50,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
private SysUserPostMapper userPostMapper;
|
private SysUserPostMapper userPostMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysConfigService configService;
|
private SysConfigService configService;
|
||||||
@Autowired
|
|
||||||
private DataBaseCreator baseCreator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询用户列表
|
* 根据条件分页查询用户列表
|
||||||
|
@ -257,24 +254,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean registerUser (SysUser user) {
|
public boolean registerUser (SysUser user) {
|
||||||
//根据新注册的用户创建对应数据库
|
return userMapper.insertUser(user) > 0;
|
||||||
String datbaseName = baseCreator.createDatbase(user);
|
|
||||||
//添加公司名称
|
|
||||||
userMapper.insertFirm(user.getFirmName(),datbaseName);
|
|
||||||
Integer firmId = user.getFirmId();
|
|
||||||
user.setFirmId(firmId);
|
|
||||||
//添加用户表
|
|
||||||
int i = userMapper.insertUser(user);
|
|
||||||
List<SysUser> userList = userMapper.selectUserList(user);
|
|
||||||
Long userId = userList.get(0).getUserId();
|
|
||||||
ArrayList<SysUserRole> list = new ArrayList<>();
|
|
||||||
//将用户和角色进行关联
|
|
||||||
SysUserRole userRole = new SysUserRole();
|
|
||||||
userRole.setUserId(userId);
|
|
||||||
userRole.setRoleId(2L);
|
|
||||||
list.add(userRole);
|
|
||||||
userRoleMapper.batchUserRole(list);
|
|
||||||
return i > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,7 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 159.75.188.178:8848
|
addr: 127.0.0.1:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: xxy
|
namespace: xxy
|
||||||
|
|
|
@ -222,11 +222,6 @@
|
||||||
sysdate()
|
sysdate()
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertFirm" useGeneratedKeys="true" keyProperty="firmId">
|
|
||||||
INSERT INTO `eight`.`firm`
|
|
||||||
(`firm_id`, `firm_name`, `database_name`) VALUES
|
|
||||||
(0, #{firmName}, #{datbaseName});
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<update id="updateUser" parameterType="com.muyu.common.system.domain.SysUser">
|
<update id="updateUser" parameterType="com.muyu.common.system.domain.SysUser">
|
||||||
update sys_user
|
update sys_user
|
||||||
|
|
|
@ -4,7 +4,7 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 159.75.188.178:8848
|
addr: 127.0.0.1:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: xxy
|
namespace: xxy
|
||||||
|
|
10
pom.xml
10
pom.xml
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<name>muyu</name>
|
<name>muyu</name>
|
||||||
<url>http://www.muyu.vip</url>
|
<url>http://www.muyu.vip</url>
|
||||||
<description>智能车联系统</description>
|
<description>若依微服务系统</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<muyu.version>3.6.3</muyu.version>
|
<muyu.version>3.6.3</muyu.version>
|
||||||
|
@ -42,7 +42,6 @@
|
||||||
<hutool.version>5.8.27</hutool.version>
|
<hutool.version>5.8.27</hutool.version>
|
||||||
<knife4j-openapi3.version>4.1.0</knife4j-openapi3.version>
|
<knife4j-openapi3.version>4.1.0</knife4j-openapi3.version>
|
||||||
<xxl-job-core.version>2.4.1</xxl-job-core.version>
|
<xxl-job-core.version>2.4.1</xxl-job-core.version>
|
||||||
<kafka.version>3.6.3</kafka.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 依赖声明 -->
|
<!-- 依赖声明 -->
|
||||||
|
@ -219,13 +218,6 @@
|
||||||
<version>${muyu.version}</version>
|
<version>${muyu.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--kafka-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-kafka</artifactId>
|
|
||||||
<version>${kafka.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 分布式事务 -->
|
<!-- 分布式事务 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
|
|
Loading…
Reference in New Issue