Compare commits
1 Commits
master
...
vehicle-xi
Author | SHA1 | Date |
---|---|---|
|
1a943c0ea1 |
|
@ -1,279 +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>muyu</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
<properties>
|
||||
<maven.compiler.source>20</maven.compiler.source>
|
||||
<maven.compiler.target>20</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
|
||||
|
||||
<artifactId>aliyun-api</artifactId>
|
||||
|
||||
<groupId>com.aliyun</groupId>
|
||||
|
||||
<version>1.0.0</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>sample</name>
|
||||
<description>Alibaba Cloud SDK Code Sample for Java
|
||||
</description>
|
||||
<url>https://github.com/aliyun/alibabacloud-code-sample</url>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
|
||||
<developer>
|
||||
<id>aliyundeveloper</id>
|
||||
<name>Aliyun SDK</name>
|
||||
<email>aliyunsdk@aliyun.com</email>
|
||||
</developer>
|
||||
</developers>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>sonatype-nexus-snapshots</id>
|
||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>sonatype-nexus-staging</id>
|
||||
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<scm>
|
||||
<connection></connection>
|
||||
<developerConnection></developerConnection>
|
||||
<url></url>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>4.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>ecs20140526</artifactId>
|
||||
<version>3.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-openapi</artifactId>
|
||||
<version>0.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-util</artifactId>
|
||||
<version>0.2.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-console</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>darabonba-env</artifactId>
|
||||
<version>0.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea</artifactId>
|
||||
<version>1.1.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
<!-- 引入swagger-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
<version>3.0.0</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>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-file-remote</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-event</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.3</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>sonatype-nexus-staging</serverId>
|
||||
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<doclint>none</doclint>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.4.1</version>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<mainClass>com.aliyun.sample.Sample1</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
|
||||
</build>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</project>
|
|
@ -1,31 +0,0 @@
|
|||
package com.aliyun.demo.config;
|
||||
|
||||
/**
|
||||
* @BelongsProject: com.aliyun.demo
|
||||
* @BelongsPackage: com.aliyun.demo.config
|
||||
* @Author: HuangDaJu
|
||||
* @CreateTime: 2024-04-11 22:10
|
||||
* @Description: 阿里云客户端配置类
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class ClientConfig {
|
||||
|
||||
/**
|
||||
* 使用AK&SK初始化账号Client
|
||||
* @return Client
|
||||
* @throws Exception
|
||||
*/
|
||||
public static com.aliyun.ecs20140526.Client createClient() throws Exception {
|
||||
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
||||
// 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html。
|
||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||
.setAccessKeyId("LTAI5tANGefs2gi8nsu4Ao")
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||
.setAccessKeySecret("Ut5RaJvvG7dP8hgK82qjdtvyUA6x");
|
||||
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
||||
config.endpoint = "ecs.cn-zhangjiakou.aliyuncs.com";
|
||||
return new com.aliyun.ecs20140526.Client(config);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
package com.aliyun.demo.create;
|
||||
|
||||
import com.aliyun.demo.config.ClientConfig;
|
||||
import com.aliyun.ecs20140526.models.CreateInstanceResponse;
|
||||
import com.aliyun.ecs20140526.models.CreateInstanceResponseBody;
|
||||
import com.aliyun.tea.TeaException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 创建一台或多台按量收费的ECS实例。
|
||||
*
|
||||
* @BelongsProject: aliyun-api
|
||||
* @BelongsPackage: com.aliyun.demo.create
|
||||
* @Author: HuangDaJu
|
||||
* @CreateTime: 2024-04-11 21:23
|
||||
* @Description: 主要用于创建ECS实例的示例代码。
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class CreateServer {
|
||||
|
||||
/**
|
||||
* 主函数入口。
|
||||
* @throws Exception 可能抛出的异常。
|
||||
*/
|
||||
public static void main(String[] args_) throws Exception {
|
||||
List<String> args = java.util.Arrays.asList(args_); // 将命令行参数转换为List<String>格式
|
||||
com.aliyun.ecs20140526.Client client = ClientConfig.createClient(); // 创建ECS客户端
|
||||
|
||||
// 设置系统盘参数
|
||||
com.aliyun.ecs20140526.models.CreateInstanceRequest.CreateInstanceRequestSystemDisk systemDisk =
|
||||
new com.aliyun.ecs20140526.models.CreateInstanceRequest.CreateInstanceRequestSystemDisk()
|
||||
.setCategory("cloud_efficiency")
|
||||
.setSize(20);
|
||||
|
||||
// 创建实例请求对象,并设置相关参数
|
||||
com.aliyun.ecs20140526.models.CreateInstanceRequest createInstanceRequest =
|
||||
new com.aliyun.ecs20140526.models.CreateInstanceRequest()
|
||||
.setRegionId("cn-zhangjiakou") // 地域ID
|
||||
.setImageId("m-8vb8z0ygyrzgqt54k3wi") // 镜像ID
|
||||
.setInstanceType("ecs.t6-c1m1.large") // 实例规格
|
||||
.setSecurityGroupId("sg-8vbfx0e48cekrpzgsa72") // 安全组ID
|
||||
.setInstanceName("huangdaju-hdj") // 实例名称
|
||||
.setInternetChargeType("PayByTraffic") // 上网计费方式
|
||||
.setAutoRenew(false) // 是否自动续费
|
||||
.setInternetMaxBandwidthIn(5) // 公网入带宽最大值
|
||||
.setInternetMaxBandwidthOut(5) // 公网出带宽最大值
|
||||
.setPassword("Huangdaju520.") // 实例密码
|
||||
.setZoneId("cn-zhangjiakou-c") // 可用区ID
|
||||
.setSystemDisk(systemDisk) // 系统盘设置
|
||||
.setVSwitchId("vsw-8vbn6cq2uy0mmw69l6ryq") // 交换机ID
|
||||
.setPrivateIpAddress("10.101.0.1") // 私网IP地址
|
||||
.setPeriod(1) // 购买资源的时长
|
||||
.setPeriodUnit("Month") // 购买资源的时长单位
|
||||
.setCreditSpecification("Standard") // 性能模式
|
||||
.setDeletionProtection(false); // 是否开启删除保护
|
||||
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions(); // 创建运行时选项
|
||||
|
||||
try {
|
||||
// 发起创建实例的请求,并处理响应
|
||||
CreateInstanceResponse instanceWithOptions = client.createInstanceWithOptions(createInstanceRequest, runtime);
|
||||
Integer statusCode = instanceWithOptions.getStatusCode(); // 获取状态码
|
||||
CreateInstanceResponseBody body = instanceWithOptions.getBody(); // 获取响应体
|
||||
String instanceId = body.getInstanceId(); // 获取实例ID
|
||||
System.out.println("创建返回码:" + statusCode);
|
||||
System.out.println("创建的实例ID:" + instanceId);
|
||||
} catch (TeaException error) {
|
||||
// 处理ECS客户端抛出的异常
|
||||
// 打印异常信息和推荐的诊断地址
|
||||
System.out.println(error.getMessage());
|
||||
System.out.println(error.getData().get("Recommend"));
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
} catch (Exception _error) {
|
||||
// 处理其他异常
|
||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
System.out.println(error.getMessage());
|
||||
System.out.println(error.getData().get("Recommend"));
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package com.aliyun.demo.delete;
|
||||
|
||||
import com.aliyun.demo.config.ClientConfig;
|
||||
import com.aliyun.tea.TeaException;
|
||||
|
||||
public class DeleteEsc {
|
||||
|
||||
/**
|
||||
* 使用AK&SK初始化账号Client
|
||||
|
||||
* @return Client
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void main(String[] args_) throws Exception {
|
||||
java.util.List<String> args = java.util.Arrays.asList(args_);
|
||||
com.aliyun.ecs20140526.Client client = ClientConfig.createClient();
|
||||
com.aliyun.ecs20140526.models.DeleteInstancesRequest deleteInstancesRequest = new com.aliyun.ecs20140526.models.DeleteInstancesRequest()
|
||||
.setRegionId("cn-zhangjiakou")
|
||||
.setDryRun(false)
|
||||
.setForce(true)
|
||||
.setTerminateSubscription(false)
|
||||
.setInstanceId(java.util.Arrays.asList( "i-8vb4iyv1xa4qcn426ts7"));
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
try {
|
||||
// 复制代码运行请自行打印 API 的返回值
|
||||
client.deleteInstancesWithOptions(deleteInstancesRequest, runtime);
|
||||
} catch (TeaException error) {
|
||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// 错误 message
|
||||
System.out.println(error);
|
||||
// 诊断地址
|
||||
System.out.println(error.getData().get("Recommend"));
|
||||
com.aliyun.teautil.Common.assertAsString(error);
|
||||
} catch (Exception _error) {
|
||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// 错误 message
|
||||
System.out.println(error);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
package com.aliyun.demo.query;
|
||||
|
||||
import com.aliyun.demo.config.ClientConfig;
|
||||
import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
|
||||
import com.aliyun.ecs20140526.models.DescribeInstancesResponseBody;
|
||||
import com.aliyun.tea.TeaException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @BelongsProject: aliyun-api
|
||||
* @BelongsPackage: com.aliyun.demo.query
|
||||
* @Author: HuangDaJu
|
||||
* @CreateTime: 2024-04-11 22:20
|
||||
* @Description: 查询一台或多台ECS实例的详细信息
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class SelectServerInfo {
|
||||
|
||||
static int i = 1;
|
||||
|
||||
public static void main(String[] args_) throws Exception {
|
||||
List<String> args = java.util.Arrays.asList(args_);
|
||||
com.aliyun.ecs20140526.Client client = ClientConfig.createClient();
|
||||
com.aliyun.ecs20140526.models.DescribeInstancesRequest describeInstancesRequest = new com.aliyun.ecs20140526.models.DescribeInstancesRequest()
|
||||
.setRegionId("cn-zhangjiakou")
|
||||
.setInstanceName("Test-huangdaju")
|
||||
.setPageSize(10);
|
||||
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
|
||||
try {
|
||||
// 复制代码运行请自行打印 API 的返回值
|
||||
DescribeInstancesResponse describeInstancesResponse = client.describeInstancesWithOptions(describeInstancesRequest, runtime);
|
||||
DescribeInstancesResponseBody body = describeInstancesResponse.getBody();
|
||||
DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstances instances = body.getInstances();
|
||||
List<DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance> instance = instances.getInstance();
|
||||
instance.stream().forEach(item->{
|
||||
System.out.println("实例{" + i + "}的ID:" + item.getInstanceId());
|
||||
System.out.println("名称:" + item.getInstanceName());
|
||||
System.out.println("地域ID:" + item.getRegionId());
|
||||
System.out.println("状态:" + item.getStatus());
|
||||
System.out.println("类型:" + item.getInstanceType());
|
||||
System.out.println("CPU核心数:" + item.getCpu());
|
||||
System.out.println("内存大小:" + item.getMemory() + "MB");
|
||||
System.out.println("磁盘大小:" + item.getLocalStorageCapacity() + "G");
|
||||
System.out.println("操作系统:" + item.getOSName());
|
||||
System.out.println("网络类型:" + item.getInstanceNetworkType());
|
||||
System.out.println("公网出带宽值:" + item.getInternetMaxBandwidthOut() + "Mbit/s");
|
||||
System.out.println("公网入带宽值:" + item.getInternetMaxBandwidthIn() + "Mbit/s");
|
||||
System.out.println("公网IP:" + item.getPublicIpAddress().getIpAddress());
|
||||
System.out.println("私网IP:" + item.getVpcAttributes().getPrivateIpAddress().ipAddress);
|
||||
System.out.println("专有网络VPCID:" + item.getVpcAttributes().getVpcId());
|
||||
System.out.println("安全组ID:" + item.getSecurityGroupIds().getSecurityGroupId());
|
||||
System.out.println("创建时间:" + item.getCreationTime());
|
||||
System.out.println("到期时间:" + item.getExpiredTime());
|
||||
System.out.println("是否可以回收:" + (item.getRecyclable()?"是":"否") + "\n\n");
|
||||
i++;
|
||||
|
||||
});
|
||||
} catch (TeaException error) {
|
||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// 错误 message
|
||||
System.out.println(error.getMessage());
|
||||
// 诊断地址
|
||||
System.out.println(error.getData().get("Recommend"));
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
} catch (Exception _error) {
|
||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// 错误 message
|
||||
System.out.println(error.getMessage());
|
||||
// 诊断地址
|
||||
System.out.println(error.getData().get("Recommend"));
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,7 +21,17 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 这个依赖是监听用的-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
<version>2.8.1</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.kafka</groupId>-->
|
||||
<!-- <artifactId>kafka-clients</artifactId>-->
|
||||
<!-- <version>2.8.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
|
@ -106,6 +116,11 @@
|
|||
<artifactId>muyu-common-event</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!--MQ-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-amqp</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
|
||||
public class MuYuAnalyzeApplication
|
||||
{
|
||||
public static void main(String[] args)
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
package com.muyu.analyze.consumer;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.muyu.analyze.mapper.VehicleMapper;
|
||||
import com.muyu.analyze.service.VehicleService;
|
||||
import com.muyu.analyze.utils.AnalyzeUtils;
|
||||
import com.muyu.common.core.utils.SpringUtils;
|
||||
import com.muyu.common.event.cache.VehicleEventCache;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.kafka.annotation.KafkaListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 类说明
|
||||
*
|
||||
|
@ -41,21 +41,17 @@ public class Consumer {
|
|||
*/
|
||||
// @KafkaListener(topics = "test", groupId = "group", properties = {"bootstrap.servers = 10.10.26.4:9092"})
|
||||
@KafkaListener(topics = "test")
|
||||
public void getMessage(String msg) throws JsonProcessingException {
|
||||
|
||||
//json转对象
|
||||
VehicleData vehicleData = JSON.parseObject(msg, VehicleData.class);
|
||||
|
||||
public void getMessage(String msg) {
|
||||
VehicleData analyze = AnalyzeUtils.analyze(msg);
|
||||
log.info("。。。。。。。。。。。。非静止画面");
|
||||
|
||||
Set<String> eventList = vehicleEventCache.getEventList(analyze.getVin());
|
||||
|
||||
// List<Fence> fenceVin=vehicleMapper.selectFenceList();
|
||||
|
||||
//工厂加策略模式 获取每辆车的事件集
|
||||
Set<String> eventList = vehicleEventCache.getEventList(vehicleData.getVin());
|
||||
|
||||
for (String s : eventList) {
|
||||
VehicleService vehicleService = SpringUtils.getBean(s);
|
||||
vehicleService.eventResolution(vehicleData);
|
||||
vehicleService.eventResolution(analyze);
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,7 +60,6 @@ public class Consumer {
|
|||
|
||||
|
||||
|
||||
|
||||
// @RabbitHandler
|
||||
// public void take(String msg, Channel channel, Message message) throws IOException {
|
||||
//// String messageId = message.getMessageProperties().getMessageId();
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
//package com.muyu.analyze.consumer;
|
||||
//
|
||||
///**
|
||||
// * @ProjectName: cloud-vehicles
|
||||
// * @PackageName: com.muyu.analyze.consumer
|
||||
// * @Description TODO
|
||||
// * @Author HuangDaJu
|
||||
// * @Date 2024/4/8 21:43
|
||||
// * @Version 1.0
|
||||
// */
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//import com.muyu.common.redis.service.RedisService;
|
||||
//import com.rabbitmq.client.Channel;
|
||||
//import lombok.extern.log4j.Log4j2;
|
||||
//import org.springframework.amqp.core.Message;
|
||||
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//
|
||||
//
|
||||
//@Component
|
||||
//@RabbitListener(queues = "queue")
|
||||
//@Log4j2
|
||||
//public class RabbitMqConsumer {
|
||||
//
|
||||
//
|
||||
// @Autowired
|
||||
// private RedisService redisService;
|
||||
//
|
||||
// @RabbitHandler
|
||||
// public void take(String msg, Channel channel, Message message) throws IOException {
|
||||
//
|
||||
//
|
||||
// long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||
// System.out.println("MQ消费:"+msg);
|
||||
// channel.basicAck(deliveryTag,false);
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
//}
|
||||
//
|
|
@ -39,13 +39,10 @@ public class RealTimeDataController {
|
|||
|
||||
@PostMapping("/realTimeDataTwo/{vin}")
|
||||
public ResponseEntity<VehicleData> getRealTimeDataByVin(@PathVariable String vin) {
|
||||
|
||||
vehicleEventCache.addEvent(vin, VehicleEventConstants.SHI_SHI);
|
||||
|
||||
// 假设这里调用实时数据处理服务的某个方法来根据 VIN 获取实时数据
|
||||
// 根据 VIN 获取实时数据
|
||||
VehicleData realTimeData = realTimeDataEvent.getRealTimeDataByVin(vin);
|
||||
System.out.println("VIN为" + vin + "的实时数据为:" + realTimeData);
|
||||
// 实现这个方法需要根据你的具体业务逻辑
|
||||
// 返回实时数据
|
||||
return ResponseEntity.ok().body(realTimeData);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,4 @@ public interface VehicleMapper{
|
|||
Car selectCarList(String vin);
|
||||
|
||||
|
||||
List<String> selectCarMarking(Integer markingId);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.muyu.analyze.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
|
||||
|
||||
|
@ -15,7 +14,7 @@ import com.muyu.system.common.domain.VehicleData;
|
|||
*/
|
||||
public interface VehicleService {
|
||||
|
||||
void eventResolution(VehicleData analyze) throws JsonProcessingException;
|
||||
void eventResolution(VehicleData analyze);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
package com.muyu.analyze.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
import com.muyu.analyze.service.VehicleService;
|
||||
import com.muyu.analyze.utils.StateConstant;
|
||||
|
||||
|
||||
import com.muyu.business.domain.FaultLogs;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -24,14 +28,9 @@ import java.util.concurrent.TimeUnit;
|
|||
*/
|
||||
@Service("breakdown")
|
||||
@Slf4j
|
||||
|
||||
public class BreakdownImpl implements VehicleService{
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
|
@ -214,7 +213,7 @@ public class BreakdownImpl implements VehicleService{
|
|||
faultLogsAddReq.setFaultLevel(1);
|
||||
}
|
||||
|
||||
// 进入这里的都是有故障的,存入hashset 放入redis
|
||||
//进入这里的都是有故障的,存入hashset 放入redis
|
||||
String key = "breakdown";
|
||||
HashSet<FaultLogs> hashSet = new HashSet<>();
|
||||
hashSet.add(faultLogsAddReq);
|
||||
|
@ -222,27 +221,6 @@ public class BreakdownImpl implements VehicleService{
|
|||
// 设置过期时间
|
||||
redisService.expire(key, 20, TimeUnit.MINUTES);
|
||||
|
||||
|
||||
|
||||
|
||||
// log.info("功能描述: xx,请求URI:{},请求方式: {},请求参数: {}",
|
||||
// request.getRequestURI(),request.getMethod(),user);
|
||||
// rabbitTemplate.convertAndSend(RabbitMQConfig.delExchange,RabbitMQConfig.routingKey,user,message -> {
|
||||
// message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||
// return message;
|
||||
// },new CorrelationData(UUID.randomUUID().toString()));
|
||||
|
||||
|
||||
// rabbitTemplate.convertAndSend(MQQueueConstants.FAULT_QUEUE, faultLogsAddReq, message -> {
|
||||
// message.getMessageProperties().setMessageId(IdUtils.fastSimpleUUID());
|
||||
// return message;
|
||||
// });
|
||||
|
||||
log.info("车辆VIN:"+vehicleData.getVin()+"故障事件已记录");
|
||||
log.info("故障事件结束");
|
||||
|
||||
|
||||
|
||||
log.info("车辆VIN:"+vehicleData.getVin()+"故障事件已记录");
|
||||
log.info("故障事件结束");
|
||||
}else{
|
||||
|
@ -252,9 +230,5 @@ public class BreakdownImpl implements VehicleService{
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package com.muyu.analyze.service.impl;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.muyu.analyze.mapper.VehicleMapper;
|
||||
import com.muyu.analyze.service.VehicleService;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.business.domain.AlarmLogs;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.system.common.domain.Car;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -39,8 +39,9 @@ public class FenceAlarmImpl implements VehicleService {
|
|||
private VehicleMapper vehicleMapper;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void eventResolution(VehicleData analyze) throws JsonProcessingException {
|
||||
public void eventResolution(VehicleData analyze) {
|
||||
Fence fence = new Fence();
|
||||
//车的vin
|
||||
String vin = analyze.getVin();
|
||||
|
@ -51,80 +52,67 @@ public class FenceAlarmImpl implements VehicleService {
|
|||
//纬度
|
||||
double pointLat = parseDouble(analyze.getLatitude());
|
||||
|
||||
//存set的围栏
|
||||
Map<String, Object> fence1 = redisService.getCacheMap("fence");
|
||||
|
||||
//这里修改为1对多的 电子围栏 目前是一对一
|
||||
|
||||
Car car =vehicleMapper.selectCarList(vin);
|
||||
|
||||
//车的标识
|
||||
String carFenceId = car.getCarMarking();
|
||||
|
||||
String[] split1 = carFenceId.split(",");
|
||||
|
||||
|
||||
//车的查询对应的围栏
|
||||
for (String markingId : split1) {
|
||||
|
||||
List<String> carMarking = vehicleMapper.selectCarMarking(Integer.valueOf(markingId));
|
||||
|
||||
for (String markingFenceIds : carMarking) {
|
||||
|
||||
String[] split = markingFenceIds.split(",");
|
||||
|
||||
|
||||
for (Map.Entry<String, Object> entry : fence1.entrySet()) {
|
||||
for (String s : split) {
|
||||
String key = entry.getKey();
|
||||
if (s.equals(key)){
|
||||
String value = (String) entry.getValue();
|
||||
|
||||
String[] split2 = value.split(";");
|
||||
|
||||
boolean withinFence = isWithinFence(pointLat, pointLng, Arrays.asList(split2));
|
||||
|
||||
if (withinFence){
|
||||
log.info("车辆vin:"+vin+"------在电子围栏"+key+"---正常行驶---");
|
||||
}else {
|
||||
log.info("车辆vin:"+vin+"------驶出电子围栏"+key+"---报警---");
|
||||
|
||||
String key1 = "fenceType1";
|
||||
|
||||
HashSet<Fence> hashSet = new HashSet<>();
|
||||
fence.setCarVin(vin);
|
||||
fence.setFenceType("驶出");
|
||||
fence.setFenceId(Integer.valueOf(key));
|
||||
|
||||
hashSet.add(fence);
|
||||
redisService.setCacheSet(key1,hashSet);
|
||||
redisService.expire(key1, 20, TimeUnit.MINUTES); // 设置过期时间
|
||||
}
|
||||
|
||||
|
||||
// FaultLogs faultLogs = new FaultLogs();
|
||||
// faultLogs.setCarVin(vin);
|
||||
// faultLogs.setFaultCode("WEILAN");
|
||||
// faultLogs.setStartAlarmTime(DateUtils.getNowDate());
|
||||
// faultLogs.setAlarmFlag("Y");
|
||||
// faultLogs.setDisposeStatus("1");
|
||||
|
||||
//对象变json
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
// String faultLog = objectMapper.writeValueAsString(faultLogs);
|
||||
|
||||
// rabbitTemplate.convertAndSend(MQQueueConstants.ALARM_QUEUE, faultLog , message -> {
|
||||
// message.getMessageProperties().setMessageId(IdUtils.fastSimpleUUID());
|
||||
// return message;
|
||||
// });
|
||||
Map<String, Object> fence1 = redisService.getCacheMap("fence");
|
||||
|
||||
|
||||
|
||||
for (Map.Entry<String, Object> entry : fence1.entrySet()) {
|
||||
for (String s : split1) {
|
||||
String key = entry.getKey();
|
||||
if (s.equals(key)){
|
||||
String value = (String) entry.getValue();
|
||||
|
||||
String[] split = value.split(";");
|
||||
|
||||
boolean withinFence = isWithinFence(pointLat, pointLng, Arrays.asList(split));
|
||||
|
||||
if (withinFence){
|
||||
log.info("车辆vin:"+vin+"------在电子围栏"+key+"---正常行驶---");
|
||||
}else {
|
||||
log.info("车辆vin:"+vin+"------驶出电子围栏"+key+"---报警---");
|
||||
|
||||
String key1 = "fenceType1";
|
||||
|
||||
HashSet<Fence> hashSet = new HashSet<>();
|
||||
fence.setCarVin(vin);
|
||||
fence.setFenceType("驶出");
|
||||
fence.setFenceId(Integer.valueOf(key));
|
||||
|
||||
hashSet.add(fence);
|
||||
redisService.setCacheSet(key1,hashSet);
|
||||
redisService.expire(key1, 20, TimeUnit.MINUTES); // 设置过期时间
|
||||
}
|
||||
|
||||
// if (withinFence){
|
||||
// log.info("车辆vin:"+vin+"------驶入禁行区----报警");
|
||||
//
|
||||
// String key1 = "fenceType1";
|
||||
// HashSet<Fence> hashSet = new HashSet<>();
|
||||
// fence.setCarVin(vin);
|
||||
// fence.setFenceType("驶入");
|
||||
// fence.setFenceId(Integer.valueOf(key));
|
||||
// hashSet.add(fence);
|
||||
// redisService.setCacheSet(key1,hashSet);
|
||||
// redisService.expire(key1, 20, TimeUnit.MINUTES); // 设置过期时间
|
||||
//
|
||||
// }else{
|
||||
// log.info("车辆vin:"+vin+"------在安全区");
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//false是除了围栏要报警
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
package com.muyu.analyze.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import com.muyu.analyze.mapper.VehicleMapper;
|
||||
import com.muyu.analyze.service.VehicleService;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
|
@ -24,7 +29,6 @@ public class StoredEventImpl implements VehicleService {
|
|||
|
||||
@Autowired
|
||||
private VehicleMapper vehicleMapper;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
|
@ -34,9 +38,9 @@ public class StoredEventImpl implements VehicleService {
|
|||
@Override
|
||||
public void eventResolution(VehicleData analyze) {
|
||||
|
||||
Integer cacheObject = redisService.getCacheObject("records:info:" + analyze.getVin());
|
||||
|
||||
analyze.setRecordsId(cacheObject);
|
||||
Integer id = (Integer)redisService.getCacheObject("records:info:" + analyze.getVin());
|
||||
analyze.setRecordsId(id);
|
||||
|
||||
|
||||
list.add(analyze);
|
||||
|
|
|
@ -18,14 +18,9 @@ import java.util.Stack;
|
|||
|
||||
public class AnalyzeUtils {
|
||||
|
||||
public static VehicleData analyze(String msg) {
|
||||
public static VehicleData analyze(String aa) {
|
||||
|
||||
VehicleData vehicleData = new VehicleData();
|
||||
|
||||
|
||||
String aa = msg.substring(1).substring(0, msg.substring(1).length() - 2);
|
||||
|
||||
|
||||
/**
|
||||
* 车辆VIN private String vin;
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
//package com.muyu.analyze.utils;
|
||||
//
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||
//import org.apache.kafka.clients.consumer.ConsumerRecords;
|
||||
//import org.apache.kafka.clients.consumer.KafkaConsumer;
|
||||
//import org.apache.kafka.clients.producer.KafkaProducer;
|
||||
//import org.apache.kafka.clients.producer.ProducerConfig;
|
||||
//import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import javax.annotation.PostConstruct;
|
||||
//import java.time.Duration;
|
||||
//import java.util.Collections;
|
||||
//import java.util.Properties;
|
||||
//
|
||||
///**
|
||||
// * @ProjectName: cloud-vehicles
|
||||
// * @PackageName: com.muyu.analyze.utils
|
||||
// * @Description TODO
|
||||
// * @Author HuangDaJu
|
||||
// * @Date 2024/4/8 12:41
|
||||
// * @Version 1.0
|
||||
// */
|
||||
//@Component
|
||||
//@Slf4j
|
||||
//public class Test {
|
||||
//
|
||||
// private static final String TOPIC_NAME = "online";
|
||||
// private static final String BOOTSTRAP_SERVERS = "10.10.26.4:9092";
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
// //生产者示例
|
||||
// produceMessage();
|
||||
//
|
||||
// //消费者示例
|
||||
// consumerMessages();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// //生产者
|
||||
// @PostConstruct
|
||||
// private static void produceMessage() {
|
||||
// Properties props = new Properties();
|
||||
// props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS);
|
||||
// props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
|
||||
// props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
|
||||
//
|
||||
// KafkaProducer<String, String> producer = new KafkaProducer<>(props);
|
||||
// //创建生产者
|
||||
// try {
|
||||
//
|
||||
// //发送消息
|
||||
// for (int i = 0; i < 10000; i++) {
|
||||
// String message = "佳佳来喽" + (i + 1);
|
||||
// producer.send(new ProducerRecord<>(TOPIC_NAME, message));
|
||||
//
|
||||
// System.out.println("发送消息:" + message);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// producer.close();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //消费者
|
||||
// private static void consumerMessages() {
|
||||
// Properties props = new Properties();
|
||||
// props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS);
|
||||
// props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group");
|
||||
// props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
|
||||
// props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
|
||||
//
|
||||
// //创建消费者
|
||||
// KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
|
||||
//
|
||||
// try {
|
||||
//
|
||||
// //订阅主题
|
||||
// consumer.subscribe(Collections.singletonList(TOPIC_NAME));
|
||||
//
|
||||
// //持续消费消息
|
||||
// while (true) {
|
||||
// ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(100));
|
||||
// records.forEach(record -> {
|
||||
// System.out.println("消费者接受到的消息值:" + record.value());
|
||||
// });
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// consumer.close();
|
||||
// }
|
||||
// }
|
||||
//}
|
|
@ -3,6 +3,12 @@ server:
|
|||
port: 9008
|
||||
# Spring
|
||||
spring:
|
||||
kafka:
|
||||
bootstrap-servers: 10.10.26.4:9092
|
||||
consumer:
|
||||
group-id: group
|
||||
auto-offset-reset: earliest
|
||||
|
||||
|
||||
application:
|
||||
# 应用名称
|
||||
|
@ -24,8 +30,3 @@ spring:
|
|||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
|
||||
kafka:
|
||||
bootstrap-servers: 10.10.26.4:9092
|
||||
consumer:
|
||||
group-id: group
|
||||
auto-offset-reset: earliest
|
||||
|
|
|
@ -17,12 +17,6 @@
|
|||
select car_vin,fence_encoding,fence_id,fence_type,fence_radius from car left join fence on car.car_fence_id=fence.fence_id
|
||||
</select>
|
||||
<select id="selectCarList" resultType="com.muyu.system.common.domain.Car">
|
||||
select car_marking from car where car_vin=#{vin}
|
||||
select car_fence_id from car where car_vin=#{vin}
|
||||
</select>
|
||||
<select id="selectCarMarking" resultType="java.lang.String">
|
||||
|
||||
select marking_fence_ids from marking where marking_id=#{markingId}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -16,12 +16,7 @@
|
|||
</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- 这个依赖是监听用的-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
<version>2.8.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Openfeign -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
package com.muyu.common.core.constant;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* MQ常量
|
||||
* @author LiYongJie
|
||||
* @date 2024/4/9
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MQQueueConstants {
|
||||
/**
|
||||
* 报警队列
|
||||
*/
|
||||
public static final String ALARM_QUEUE = "alarm";
|
||||
|
||||
/**
|
||||
* 故障队列
|
||||
*/
|
||||
public static final String FAULT_QUEUE = "fault";
|
||||
}
|
|
@ -2,14 +2,15 @@ package com.muyu.common.redis.service;
|
|||
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.data.redis.core.BoundSetOperations;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static net.sf.jsqlparser.parser.feature.Feature.setOperation;
|
||||
|
||||
/**
|
||||
* spring redis 工具类
|
||||
*
|
||||
|
@ -173,19 +174,6 @@ public class RedisService
|
|||
}
|
||||
return setOperation;
|
||||
}
|
||||
/**
|
||||
* 缓存zSet
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @param setValue 缓存的数据
|
||||
* @param score 缓存的数据
|
||||
* @return 缓存数据的对象
|
||||
*/
|
||||
public <T> BoundZSetOperations<String, T> setCacheZSet(final String key, final T setValue, double score) {
|
||||
BoundZSetOperations boundZSetOperations = redisTemplate.boundZSetOps(key);
|
||||
boundZSetOperations.add(setValue, score);
|
||||
return boundZSetOperations;
|
||||
}
|
||||
/**
|
||||
* 缓存Set
|
||||
*
|
||||
|
|
|
@ -1,120 +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>muyu</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-load-center</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>20</maven.compiler.source>
|
||||
<maven.compiler.target>20</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-core</artifactId>
|
||||
</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>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-file-remote</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-ecs</artifactId>
|
||||
<version>4.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>4.5.10</version>
|
||||
</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>
|
|
@ -1,36 +0,0 @@
|
|||
package com.muyu.loadCenter;
|
||||
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableRyFeignClients;
|
||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* 系统模块
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class MuYuLoadCenterApplication
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
SpringApplication.run(MuYuLoadCenterApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 负载中心模块启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||
" .-------. ____ __ \n" +
|
||||
" | _ _ \\ \\ \\ / / \n" +
|
||||
" | ( ' ) | \\ _. / ' \n" +
|
||||
" |(_ o _) / _( )_ .' \n" +
|
||||
" | (_,_).' __ ___(_ o _)' \n" +
|
||||
" | |\\ \\ | || |(_,_)' \n" +
|
||||
" | | \\ `' /| `-' / \n" +
|
||||
" | | \\ / \\ / \n" +
|
||||
" ''-' `'-' `-..-' ");
|
||||
}
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
package com.muyu.loadCenter.Service;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.ip.IpUtils;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu
|
||||
* @Description TODO
|
||||
* @Author HuangDaJu
|
||||
* @Date 2024/4/10 09:01
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("/reg")
|
||||
public class ClientRegController {
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
HashSet<String> tokenSet=new HashSet<>();
|
||||
|
||||
/**
|
||||
* 申请注册
|
||||
* http://muyu。
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/apply-for")
|
||||
public Result applyForRegistration(){
|
||||
//生成令牌
|
||||
String token = UUID.randomUUID().toString().replace("-", "");
|
||||
tokenSet.add(token);
|
||||
log.info("程序生成令牌:{}",token);
|
||||
return Result.success(token);
|
||||
|
||||
}
|
||||
/**
|
||||
* 注册收集节点
|
||||
*/
|
||||
@PostMapping
|
||||
public Result reg(@RequestBody NodeRegReq nodeRegReq){
|
||||
log.info("客户端-[{}] 注册:{}", IpUtils.getIpAddr(request),nodeRegReq);
|
||||
redisService.setCacheZSet("负载key",nodeRegReq.getClientId(),0.0);
|
||||
//基本信息存储
|
||||
redisService.setCacheObject("客户端id","客户端基本信息:ip、端口、负载......");
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/test")
|
||||
public Result test(){
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Result getConnectionOption(@RequestParam("token") String token){
|
||||
//验证token
|
||||
|
||||
// ZSetOperations.TypedTuple key = redisTemplate.opsForZSet().popMin("负载key");
|
||||
|
||||
// String clientId = (String)key.getValue();
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package com.muyu.loadCenter.Service;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.loadCenter.Service
|
||||
* @Description TODO
|
||||
* @Author HuangDaJu
|
||||
* @Date 2024/4/10 09:16
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class NodeRegReq {
|
||||
|
||||
/**
|
||||
* 客户端ID
|
||||
*/
|
||||
private String clientId;
|
||||
/**
|
||||
* 令牌
|
||||
*/
|
||||
private String token;
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package com.muyu.loadCenter.kafka;
|
||||
|
||||
import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||
import org.apache.kafka.clients.producer.ProducerConfig;
|
||||
import org.apache.kafka.common.serialization.StringDeserializer;
|
||||
import org.apache.kafka.common.serialization.StringSerializer;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
@Configuration
|
||||
@Component
|
||||
public class KafkaConfig {
|
||||
|
||||
// Kafka Bootstrap Servers
|
||||
public static final String BOOTSTRAP_SERVERS = "10.10.26.4:9092";
|
||||
|
||||
// 默认主题
|
||||
public static final String DEFAULT_TOPIC = "test";
|
||||
|
||||
public static final String DEFAULT_KEY = "10001";
|
||||
|
||||
|
||||
public static Properties properties1(){
|
||||
// 1;构建 Properties 对象 存放 kafka 生产者配置信息
|
||||
Properties properties1 = new Properties();
|
||||
// 设置 kafka 连接地址(从配置文件/环境变量获取)
|
||||
properties1.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, KafkaConfig.BOOTSTRAP_SERVERS);
|
||||
// 设置 键值 序列化
|
||||
properties1.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer .class.getName());
|
||||
properties1.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
|
||||
return properties1;
|
||||
}
|
||||
|
||||
|
||||
public static Properties properties2(){
|
||||
Properties properties2 = new Properties();
|
||||
properties2.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "10.10.26.4:9092");
|
||||
properties2.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
|
||||
properties2.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
|
||||
properties2.setProperty(ConsumerConfig.GROUP_ID_CONFIG, "group");
|
||||
|
||||
return properties2;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package com.muyu.loadCenter.mqttx;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class ConversionUtil {
|
||||
|
||||
/**
|
||||
* 字符串转化成为16进制字符串
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
public static String strToSixteen(String s) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int length = s.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
int ch = s.charAt(i);
|
||||
String s4 = Integer.toHexString(ch);
|
||||
sb.append(s4 + " ");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static void main (String[] args) {
|
||||
// String str = "<?xml version=\"1.0\"?>\n" +
|
||||
// "<monitorRoot type=\"param\"><synchronizeSyptom event=\"0\" initial=\"true\"><Action_ECG><Rhythm>Sinus</Rhythm><HR>80</HR><EMD>No Change</EMD><Conduct>0</Conduct></Action_ECG><Action_Osat value=\"94\" isRelativePercent=\"false\"/><Action_BP isRelativePercent=\"false\"><Shrink value=\"120\"/><Stretch value=\"80\"/></Action_BP><Action_Resp breathType=\"Normal\" value=\"14\" isRelativePercent=\"false\"/><Action_etCO2 value=\"34\" isRelativePercent=\"false\"/><Action_Temperature value=\"35.2\"/><Action_CVP value=\"6.0\"/><Action_PAPDia value=\"10\"/><Action_PAPSys value=\"25\"/><Action_WP value=\"9\"/></synchronizeSyptom></monitorRoot>";
|
||||
// String strToSixteen = strToSixteen(str);
|
||||
// System.out.println(str);
|
||||
// System.out.println(str.length());
|
||||
// System.out.println(strToSixteen);
|
||||
// System.out.println(strToSixteen.replace(" ", "").length());
|
||||
|
||||
String hexStr = "7E 76 69 6e 33 39 35 34 64 30 62 32 30 64 32 35 34 31 31 37 31 32 37 32 30 32 36 38 36 32 37 31 31 36 2e 36 37 38 38 39 30 30 33 39 2e 35 32 32 37 39 33 30 37 32 2e 30 30 30 38 2e 36 36 30 30 30 30 30 30 30 35 30 34 30 30 30 33 37 30 30 30 32 33 37 36 37 30 30 30 30 44 33 30 36 30 39 2e 36 30 30 31 30 30 30 30 30 31 34 32 39 34 37 33 32 30 31 30 36 30 30 30 32 35 34 30 30 31 31 37 35 36 30 30 30 36 38 31 39 34 2e 31 38 30 30 30 30 34 37 30 30 30 30 31 33 39 30 30 30 30 35 38 32 30 30 30 34 30 30 30 33 30 30 30 31 37 30 30 30 30 37 38 30 30 30 30 36 30 30 30 30 30 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 d4 7E";
|
||||
String hexStringToString = hexStringToString(hexStr);
|
||||
|
||||
|
||||
System.out.println(hexStringToString);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 16进制转换成为string类型字符串
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
public static String hexStringToString(String s) {
|
||||
if (s == null || s.equals("")) {
|
||||
return null;
|
||||
}
|
||||
s = s.replace(" ", "");
|
||||
byte[] baKeyword = new byte[s.length() / 2];
|
||||
for (int i = 0; i < baKeyword.length; i++) {
|
||||
try {
|
||||
baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
s = new String(baKeyword, StandardCharsets.UTF_8);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
package com.muyu.loadCenter.mqttx;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.muyu.loadCenter.kafka.KafkaConfig;
|
||||
import com.muyu.loadCenter.utils.AnalyzeUtils;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Properties;
|
||||
|
||||
import static com.muyu.loadCenter.mqttx.ConversionUtil.hexStringToString;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.system.mqtt
|
||||
* @Description TODO
|
||||
* @Author XiaoFan
|
||||
* @Date 2024/3/31 19:49
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Component
|
||||
public class MqttSubscriber {
|
||||
//MQTT服务器地址
|
||||
|
||||
private static String broker="tcp://10.10.26.5:1883";
|
||||
//客户端ID,可根据实际情况自定义
|
||||
private static String clientId="mqttx_1c945161";
|
||||
//订阅的主题
|
||||
private static String topic="test";
|
||||
//消息服务质量
|
||||
private static int qos=1;
|
||||
private static Thread daemonThread;
|
||||
|
||||
// @PostConstruct
|
||||
// public void init() {
|
||||
// daemonThread = new Thread(() -> {
|
||||
// sendCode();
|
||||
// });
|
||||
// daemonThread.setDaemon(true);
|
||||
// daemonThread.start();
|
||||
|
||||
|
||||
@Scheduled(cron = "0/1 * * * * * ")
|
||||
// @PostConstruct
|
||||
public void sendCode(){
|
||||
|
||||
//消息持久化方式,这里选择内存持久化
|
||||
MemoryPersistence persistence=new MemoryPersistence();
|
||||
|
||||
try {
|
||||
//创建MQTT客户端实例
|
||||
MqttClient sampleClient = new MqttClient(broker, clientId, persistence);
|
||||
//设置连接选项
|
||||
MqttConnectOptions connOpts = new MqttConnectOptions();
|
||||
connOpts.setCleanSession(true);
|
||||
//打印连接信息
|
||||
System.out.println("Connecting to broker:" +broker);
|
||||
//连接到MQTT代理
|
||||
sampleClient.connect(connOpts);
|
||||
//打印连接成功信息
|
||||
System.out.println("Connected");
|
||||
//打印订阅信息
|
||||
System.out.println("Subscribing to topic:" +topic);
|
||||
//订阅指定主题
|
||||
sampleClient.subscribe(topic,qos);
|
||||
|
||||
//设置消息到打的回调函数
|
||||
sampleClient.setCallback(new MqttCallback() {
|
||||
@Override
|
||||
public void connectionLost(Throwable throwable) {
|
||||
//连接丢失时的处理逻辑
|
||||
System.out.println("Connection lost!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageArrived(String topic, MqttMessage message) throws Exception {
|
||||
String hexString = new String(message.getPayload());
|
||||
|
||||
//数据编译
|
||||
String msg1 = hexStringToString(hexString);
|
||||
|
||||
//切割成对象
|
||||
VehicleData analyze = AnalyzeUtils.analyze(msg1);
|
||||
|
||||
//对象变json
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String msg = objectMapper.writeValueAsString(analyze);
|
||||
|
||||
//接收到消息时的处理逻辑
|
||||
|
||||
Properties properties1 = KafkaConfig.properties1();
|
||||
KafkaProducer<String, String> kafkaProducer = new KafkaProducer<>(properties1);
|
||||
// 3: 发送消息
|
||||
// 封装发送消息对象
|
||||
ProducerRecord<String, String> record = new ProducerRecord<>(KafkaConfig.DEFAULT_TOPIC, KafkaConfig.DEFAULT_KEY, msg);
|
||||
|
||||
// 异步发送并处理结果
|
||||
kafkaProducer.send(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||||
|
||||
System.out.println("我是发送成功后要注册到车辆网关的"+iMqttDeliveryToken.toString());
|
||||
System.out.println("我是发送成功后要注册到车辆网关的"+iMqttDeliveryToken.getMessageId());
|
||||
System.out.println("我是发送成功后要注册到车辆网关的"+iMqttDeliveryToken.getActionCallback());
|
||||
|
||||
|
||||
//消息发送完成后的处理逻辑
|
||||
//在这个示例中不做处理
|
||||
}
|
||||
});
|
||||
|
||||
//循环等待接收消息
|
||||
while (true){
|
||||
Thread.sleep(1000);//每隔一秒检查一次是否有新消息
|
||||
}
|
||||
}catch (MqttException | InterruptedException me){
|
||||
System.out.println("msg"+me.getMessage());
|
||||
System.out.println("loc"+me.getLocalizedMessage());
|
||||
System.out.println("cause"+me.getCause());
|
||||
System.out.println("excep"+me);
|
||||
me.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,324 +0,0 @@
|
|||
package com.muyu.loadCenter.utils;
|
||||
|
||||
|
||||
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @ProjectName: cloud-vehicles
|
||||
* @PackageName: com.muyu.analyze.config
|
||||
* @Description TODO
|
||||
* @Author HuangDaJu
|
||||
* @Date 2024/4/2 21:33
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
public class AnalyzeUtils {
|
||||
|
||||
public static VehicleData analyze(String msg) {
|
||||
|
||||
VehicleData vehicleData = new VehicleData();
|
||||
|
||||
|
||||
String aa = msg.substring(1).substring(0, msg.substring(1).length() - 2);
|
||||
|
||||
|
||||
/**
|
||||
* 车辆VIN private String vin;
|
||||
*/
|
||||
String vin = aa.substring(0, 17);
|
||||
vehicleData.setVin(vin);
|
||||
|
||||
/**
|
||||
* 毫秒值 private String dateTime;
|
||||
*/
|
||||
String time = aa.substring(17, 30);
|
||||
vehicleData.setDateTime(time);
|
||||
|
||||
/**
|
||||
* 行驶路线 private String drivingRoute;
|
||||
*/
|
||||
|
||||
/**
|
||||
* 经度 private String longitude;
|
||||
*/
|
||||
|
||||
String longitude = aa.substring(30, 41);
|
||||
vehicleData.setLongitude(longitude);
|
||||
|
||||
/**
|
||||
* 纬度 private String latitude;
|
||||
*/
|
||||
|
||||
String latitude = aa.substring(41, 51);
|
||||
vehicleData.setLatitude(latitude);
|
||||
|
||||
/**
|
||||
* 速度 private String speed;
|
||||
*/
|
||||
|
||||
String speed = aa.substring(51, 57);
|
||||
vehicleData.setSpeed(speed);
|
||||
|
||||
/**
|
||||
* 里程 private BigDecimal mileage;
|
||||
*/
|
||||
|
||||
String mileage = aa.substring(57, 68);
|
||||
vehicleData.setMileage(new BigDecimal(mileage));
|
||||
|
||||
/**
|
||||
* 总电压 private String voltage;
|
||||
*/
|
||||
|
||||
String voltage = aa.substring(68, 74);
|
||||
vehicleData.setVoltage(voltage);
|
||||
|
||||
/**
|
||||
* 总电流 private String current;
|
||||
*/
|
||||
|
||||
String current = aa.substring(74, 79);
|
||||
vehicleData.setCurrent(current);
|
||||
|
||||
|
||||
/**
|
||||
* 绝缘电阻 private String resistance;
|
||||
*/
|
||||
String resistance = aa.substring(79, 88);
|
||||
vehicleData.setResistance(resistance);
|
||||
|
||||
/**
|
||||
* 档位 private String gear = "P";
|
||||
*/
|
||||
|
||||
String gear = aa.substring(88, 89);
|
||||
vehicleData.setGear(gear);
|
||||
|
||||
|
||||
/**
|
||||
* 加速踏板行程值 private String accelerationPedal;
|
||||
*/
|
||||
|
||||
String accelerationPedal = aa.substring(89, 91);
|
||||
vehicleData.setAccelerationPedal(accelerationPedal);
|
||||
|
||||
|
||||
/**
|
||||
* 制动踏板行程值 private String brakePedal;
|
||||
*/
|
||||
|
||||
String brakePedal =aa.substring(91,93);
|
||||
vehicleData.setBrakePedal(brakePedal);
|
||||
|
||||
/**
|
||||
* 燃料消耗率 private String fuelConsumptionRate;
|
||||
*/
|
||||
|
||||
String fuelConsumptionRate =aa.substring(93,98);
|
||||
vehicleData.setFuelConsumptionRate(fuelConsumptionRate);
|
||||
|
||||
/**
|
||||
* 电机控制器温度private String motorControllerTemperature;
|
||||
*/
|
||||
|
||||
String motorControllerTemperature =aa.substring(98,104);
|
||||
vehicleData.setMotorControllerTemperature(motorControllerTemperature);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 电机转速 private String motorSpeed;
|
||||
*/
|
||||
|
||||
String motorSpeed =aa.substring(104,109);
|
||||
vehicleData.setMotorSpeed(motorSpeed);
|
||||
|
||||
|
||||
/**
|
||||
* 电机转矩 private String motorTorque;
|
||||
*/
|
||||
String motorTorque = aa.substring(109, 113);
|
||||
vehicleData.setMotorTorque(motorTorque);
|
||||
|
||||
/**
|
||||
* 电机温度 private String motorTemperature;
|
||||
*/
|
||||
String motorTemperature = aa.substring(113, 119);
|
||||
vehicleData.setMotorTemperature(motorTemperature);
|
||||
|
||||
/**
|
||||
* 电机电压 private String motorVoltage;
|
||||
*/
|
||||
|
||||
String motorVoltage = aa.substring(119, 124);
|
||||
vehicleData.setMotorVoltage(motorVoltage);
|
||||
|
||||
/**
|
||||
* 电机电流private String motorCurrent;
|
||||
*/
|
||||
|
||||
|
||||
// 电机电流: 10446000
|
||||
String motorCurrent = aa.substring(124, 132);
|
||||
vehicleData.setMotorCurrent(motorCurrent);
|
||||
|
||||
// 动力电池剩余电量 SOC: 44103.
|
||||
/**
|
||||
* 动力电池剩余电量SOC private BigDecimal remainingBattery;
|
||||
*/
|
||||
|
||||
String remainingBattery = aa.substring(132, 138);
|
||||
vehicleData.setRemainingBattery(remainingBattery);
|
||||
|
||||
|
||||
// 当前状态允许的最大反馈功率: 400000
|
||||
/**
|
||||
* 当前状态允许的最大反馈功率private String maximumFeedbackPower;
|
||||
*/
|
||||
String maximumFeedbackPower = aa.substring(138, 144);
|
||||
vehicleData.setMaximumFeedbackPower(maximumFeedbackPower);
|
||||
|
||||
|
||||
// 当前状态允许最大放电功率: 130000
|
||||
/**
|
||||
* 当前状态允许最大放电功率 private String maximumDischargePower;
|
||||
*/
|
||||
|
||||
String maximumDischargePower = aa.substring(144, 150);
|
||||
vehicleData.setMaximumDischargePower(maximumDischargePower);
|
||||
|
||||
|
||||
// BMS 自检计数器: 20
|
||||
/**
|
||||
* BMS自检计数器private String selfCheckCounter;
|
||||
*/
|
||||
|
||||
String selfCheckCounter = aa.substring(150, 152);
|
||||
vehicleData.setSelfCheckCounter(selfCheckCounter);
|
||||
// 动力电池充放电电流: 00000
|
||||
/**
|
||||
* 动力电池充放电电流 private String totalBatteryCurrent;
|
||||
*/
|
||||
String totalBatteryCurrent = aa.substring(152, 157);
|
||||
vehicleData.setTotalBatteryCurrent(totalBatteryCurrent);
|
||||
|
||||
|
||||
// 动力电池负载端总电压 V3: 605000
|
||||
/**
|
||||
* 动力电池负载端总电压V3 private String totalBatteryVoltage;
|
||||
*/
|
||||
String totalBatteryVoltage = aa.substring(157, 163);
|
||||
vehicleData.setTotalBatteryVoltage(totalBatteryVoltage);
|
||||
|
||||
// 单次最大电压: 4000
|
||||
/**
|
||||
* 单次最大电压 private String singleBatteryMaxVoltage;
|
||||
*/
|
||||
|
||||
String singleBatteryMaxVoltage = aa.substring(163, 167);
|
||||
vehicleData.setSingleBatteryMaxVoltage(singleBatteryMaxVoltage);
|
||||
|
||||
// 单体电池最低电压: 3000
|
||||
/**
|
||||
* 单体电池最低电压 private String singleBatteryMinVoltage;
|
||||
*/
|
||||
|
||||
String singleBatteryMinVoltage = aa.substring(167, 171);
|
||||
vehicleData.setSingleBatteryMinVoltage(singleBatteryMinVoltage);
|
||||
|
||||
// 单体电池最高温度: 650000
|
||||
/**
|
||||
* 单体电池最高温度 private String singleBatteryMaxTemperature;
|
||||
*/
|
||||
String singleBatteryMaxTemperature = aa.substring(171, 177);
|
||||
vehicleData.setSingleBatteryMaxTemperature(singleBatteryMaxTemperature);
|
||||
|
||||
// 单体电池最低温度: 600000
|
||||
/**
|
||||
* 单体电池最低温度 private String singleBatteryMinTemperature;
|
||||
*/
|
||||
String singleBatteryMinTemperature = aa.substring(177, 183);
|
||||
vehicleData.setSingleBatteryMinTemperature(singleBatteryMinTemperature);
|
||||
|
||||
// 动力电池可用容量: 530000
|
||||
/**
|
||||
* 动力电池可用容量 private String availableBatteryCapacity;
|
||||
*/
|
||||
String availableBatteryCapacity = aa.substring(183, 189);
|
||||
vehicleData.setAvailableBatteryCapacity(availableBatteryCapacity);
|
||||
|
||||
|
||||
|
||||
// 车辆状态: 0
|
||||
String vehicleStatus = aa.substring(189, 190);
|
||||
vehicleData.setVehicleStatus(Integer.parseInt(vehicleStatus));
|
||||
|
||||
// 充电状态: 1
|
||||
String chargingStatus = aa.substring(190, 191);
|
||||
vehicleData.setChargingStatus(Integer.parseInt(chargingStatus));
|
||||
// 运行状态: 1
|
||||
String operatingStatus = aa.substring(191, 192);
|
||||
vehicleData.setOperatingStatus(Integer.parseInt(operatingStatus));
|
||||
|
||||
// SOC: 1
|
||||
String socStatus = aa.substring(192, 193);
|
||||
vehicleData.setSocStatus(Integer.parseInt(socStatus));
|
||||
|
||||
// 可充电储能装置工作状态: 0
|
||||
String chargingEnergyStorageStatus = aa.substring(193, 194);
|
||||
vehicleData.setChargingEnergyStorageStatus(Integer.parseInt(chargingEnergyStorageStatus));
|
||||
|
||||
// 驱动电机状态: 1
|
||||
String driveMotorStatus = aa.substring(194, 195);
|
||||
vehicleData.setDriveMotorStatus(Integer.parseInt(driveMotorStatus));
|
||||
|
||||
// 定位是否有效: 1
|
||||
String positionStatus = aa.substring(195, 196);
|
||||
vehicleData.setPositionStatus(Integer.parseInt(positionStatus));
|
||||
|
||||
// EAS: 1
|
||||
String easStatus = aa.substring(196, 197);
|
||||
vehicleData.setEasStatus(Integer.parseInt(easStatus));
|
||||
|
||||
// PTC: 1
|
||||
String ptcStatus = aa.substring(197, 198);
|
||||
vehicleData.setPtcStatus(Integer.parseInt(ptcStatus));
|
||||
|
||||
// EPS: 1
|
||||
String epsStatus = aa.substring(198, 199);
|
||||
vehicleData.setEpsStatus(Integer.parseInt(epsStatus));
|
||||
|
||||
// ABS: 1
|
||||
String absStatus = aa.substring(199, 200);
|
||||
vehicleData.setAbsStatus(Integer.parseInt(absStatus));
|
||||
|
||||
// MCU: 1
|
||||
String mcuStatus = aa.substring(200, 201);
|
||||
vehicleData.setMcuStatus(Integer.parseInt(mcuStatus));
|
||||
|
||||
// 动力电池加热状态: 1
|
||||
String heatingStatus = aa.substring(201, 202);
|
||||
vehicleData.setHeatingStatus(Integer.parseInt(heatingStatus));
|
||||
|
||||
// 动力电池当前状态: 1
|
||||
String batteryStatus = aa.substring(202, 203);
|
||||
vehicleData.setBatteryStatus(Integer.parseInt(batteryStatus));
|
||||
|
||||
// 动力电池保温状态: 1
|
||||
String batteryInsulationStatus = aa.substring(203, 204);
|
||||
vehicleData.setBatteryInsulationStatus(Integer.parseInt(batteryInsulationStatus));
|
||||
|
||||
// DCDC: 1
|
||||
String dcdcStatus = aa.substring(204, 205);
|
||||
vehicleData.setDcdcStatus(Integer.parseInt(dcdcStatus));
|
||||
|
||||
// CHG: 1
|
||||
String chgStatus = aa.substring(205, 206);
|
||||
vehicleData.setChgStatus(Integer.parseInt(chgStatus));
|
||||
|
||||
return vehicleData;
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9009
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-load-center
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 10.10.26.1:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 10.10.26.1:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
|
|
@ -1,22 +1,18 @@
|
|||
package com.muyu.business.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
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.business.domain.req.AlarmLogsAddReq;
|
||||
import com.muyu.business.domain.req.AlarmLogsUpdReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import io.swagger.annotations.*;
|
||||
import lombok.*;
|
||||
import lombok.experimental.*;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.format.annotation.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 报警记录对象
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.*;
|
|||
@ApiModel("故障日志对象")
|
||||
@TableName("fault_logs")
|
||||
public class FaultLogs implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 故障日志主键*/
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
package com.muyu.business.domain.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @ClassName MarkingListRequest
|
||||
* @Description TODO
|
||||
* @Author YinYuYang
|
||||
* @Date 2024/4/10 20:46
|
||||
* Version 1.0
|
||||
*/
|
||||
@Data
|
||||
public class MarkingListRequest {
|
||||
|
||||
private String markingName;
|
||||
|
||||
private Integer pageNum;
|
||||
|
||||
private Integer pageSize;
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
package com.muyu.business.domain.request;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
|
@ -18,7 +20,7 @@ import javax.validation.constraints.Pattern;
|
|||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FenceListRequest {
|
||||
public class FenceListRequest{
|
||||
|
||||
/**
|
||||
* 围栏名称
|
||||
|
|
|
@ -86,7 +86,6 @@
|
|||
<artifactId>muyu-file-remote</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -1,25 +1,21 @@
|
|||
package com.muyu.business.controller;
|
||||
|
||||
import com.muyu.business.domain.AlarmLogs;
|
||||
import com.muyu.business.domain.req.AlarmLogsReq;
|
||||
import com.muyu.business.domain.req.AlarmLogsUpdReq;
|
||||
import com.muyu.business.domain.res.AlarmLogsResponse;
|
||||
import com.muyu.business.service.AlarmLogsService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.muyu.business.domain.res.*;
|
||||
import com.muyu.business.service.*;
|
||||
import com.muyu.common.core.domain.*;
|
||||
import com.muyu.common.core.web.controller.*;
|
||||
import com.muyu.common.core.web.page.*;
|
||||
import com.muyu.common.log.annotation.*;
|
||||
import com.muyu.common.log.enums.*;
|
||||
import com.muyu.common.security.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 报警日志Controller
|
||||
|
@ -29,7 +25,6 @@ import java.util.List;
|
|||
@Api(tags = "报警日志")
|
||||
@ApiModel(description = "报警日志Controller")
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("/alarmLogs")
|
||||
public class AlarmLogsController extends BaseController {
|
||||
|
||||
|
@ -38,9 +33,6 @@ public class AlarmLogsController extends BaseController {
|
|||
*/
|
||||
@Autowired
|
||||
private AlarmLogsService alarmLogsService;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
|
||||
/**
|
||||
* 实时报警日志列表
|
||||
|
@ -50,20 +42,20 @@ public class AlarmLogsController extends BaseController {
|
|||
@GetMapping("/list")
|
||||
public Result<TableDataInfo> realtime(AlarmLogsReq alarmLogsReq) {
|
||||
startPage();
|
||||
List<AlarmLogsResponse> list = alarmLogsService.selectAlarmLogsList(alarmLogsReq);
|
||||
List<AlarmLogs> list = alarmLogsService.selectAlarmLogsList(alarmLogsReq);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增报警日志
|
||||
*/
|
||||
// @ApiOperation("新增报警日志")
|
||||
//// @RequiresPermissions("business:alarmLogs:add")
|
||||
//// @Log(title = "报警日志", businessType = BusinessType.INSERT)
|
||||
// @PostMapping
|
||||
// public Result add(@RequestBody AlarmLogsAddReq alarmLogsAddReq) {
|
||||
// return toAjax(alarmLogsService.insertAlarmLogs(AlarmLogs.alarmLogsAddReq(alarmLogsAddReq)));
|
||||
// }
|
||||
@ApiOperation("新增报警日志")
|
||||
@RequiresPermissions("business:alarmLogs:add")
|
||||
@Log(title = "报警日志", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result add(@RequestBody AlarmLogsAddReq alarmLogsAddReq) {
|
||||
return toAjax(alarmLogsService.insertAlarmLogs(AlarmLogs.alarmLogsAddReq(alarmLogsAddReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取报警日志详细信息
|
||||
|
@ -96,41 +88,8 @@ public class AlarmLogsController extends BaseController {
|
|||
public Result remove(@PathVariable Long[] alarmIds) {
|
||||
return toAjax(alarmLogsService.deleteAlarmLogsByIds(alarmIds));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// @RabbitListener(queuesToDeclare = {@Queue(value = MQQueueConstants.ALARM_QUEUE, declare = "true")})
|
||||
// public void sendSms(String alarmLog, Message message, Channel channel) {
|
||||
// log.info("消息队列:【{}】,收到报警日志:【{}】",MQQueueConstants.ALARM_QUEUE,alarmLog);
|
||||
// try {
|
||||
// String messageId = message.getMessageProperties().getMessageId();
|
||||
// Long count = redisTemplate.opsForSet().add(MQQueueConstants.ALARM_QUEUE, messageId);
|
||||
// if (count.intValue() > 0){
|
||||
// alarmLogsService.alarmLogsService(alarmLog);
|
||||
// // 消息确认
|
||||
// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||
// log.info("消息队列:【{}】,收到报警日志:【{}】,消费成功...",MQQueueConstants.ALARM_QUEUE,alarmLog);
|
||||
// }else {
|
||||
// log.error("消息队列:【{}】,收到报警日志:【{}】,消费重复...",MQQueueConstants.ALARM_QUEUE,alarmLog);
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// log.error("消息队列:【{}】,收到报警日志:【{}】,消费异常:【{}】",MQQueueConstants.ALARM_QUEUE,alarmLog,e.getMessage());
|
||||
// // 消息回退
|
||||
// try {
|
||||
// channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
|
||||
// } catch (IOException ex) {
|
||||
// log.error("消息队列:【{}】,收到报警日志:【{}】,消息退回异常:【{}】",MQQueueConstants.ALARM_QUEUE,alarmLog,e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Scheduled(cron = "0/10 * * * * ?")
|
||||
public void alarmLogsService(){
|
||||
alarmLogsService.alarmLogsService();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,20 @@
|
|||
package com.muyu.business.controller;
|
||||
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
import com.muyu.business.domain.req.FaultCodeReq;
|
||||
import com.muyu.business.domain.req.FaultCodesAddReq;
|
||||
import com.muyu.business.domain.req.FaultCodesUpdReq;
|
||||
import com.muyu.business.service.FaultCodesService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.muyu.business.service.*;
|
||||
import com.muyu.common.core.domain.*;
|
||||
import com.muyu.common.core.web.controller.*;
|
||||
import com.muyu.common.core.web.page.*;
|
||||
import com.muyu.common.log.annotation.*;
|
||||
import com.muyu.common.log.enums.*;
|
||||
import com.muyu.common.security.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import org.springframework.validation.annotation.*;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 故障码Controller
|
||||
|
|
|
@ -1,29 +1,22 @@
|
|||
package com.muyu.business.controller;
|
||||
|
||||
import com.muyu.business.domain.FaultLogs;
|
||||
import com.muyu.business.domain.req.FaultLogsAddReq;
|
||||
import com.muyu.business.domain.req.FaultLogsReq;
|
||||
import com.muyu.business.domain.req.FaultLogsUpdReq;
|
||||
import com.muyu.business.domain.res.FaultLogsResponse;
|
||||
import com.muyu.business.service.AlarmLogsService;
|
||||
import com.muyu.business.service.FaultLogsService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.muyu.business.domain.res.*;
|
||||
import com.muyu.business.service.*;
|
||||
import com.muyu.common.core.domain.*;
|
||||
import com.muyu.common.core.web.controller.*;
|
||||
import com.muyu.common.core.web.page.*;
|
||||
import com.muyu.common.log.annotation.*;
|
||||
import com.muyu.common.log.enums.*;
|
||||
import com.muyu.common.security.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.validation.annotation.*;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 故障码日志Controller
|
||||
|
@ -32,7 +25,6 @@ import java.util.List;
|
|||
* @Date 2024/3/30
|
||||
*/
|
||||
@Api(tags = "故障日志管理")
|
||||
@Slf4j
|
||||
@ApiModel(description = "故障日志Controller")
|
||||
@RestController
|
||||
@RequestMapping("/faultLogs")
|
||||
|
@ -43,19 +35,6 @@ public class FaultLogsController extends BaseController {
|
|||
*/
|
||||
@Autowired
|
||||
private FaultLogsService faultLogsService;
|
||||
/**
|
||||
* 注入redis工具类
|
||||
*/
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
/**
|
||||
* 注入报警日志服务
|
||||
*/
|
||||
@Autowired
|
||||
private AlarmLogsService alarmLogsService;
|
||||
|
||||
|
||||
|
||||
@ApiOperation("故障日志列表")
|
||||
@RequiresPermissions("business:faultLogs:list")
|
||||
|
@ -70,7 +49,7 @@ public class FaultLogsController extends BaseController {
|
|||
* 新增故障日志
|
||||
*/
|
||||
@ApiOperation("新增故障日志")
|
||||
// @RequiresPermissions("business:faultLogs:add")
|
||||
@RequiresPermissions("business:faultLogs:add")
|
||||
@Log(title = "故障日志", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result add(@RequestBody @Validated FaultLogsAddReq faultLogsAddReq) {
|
||||
|
@ -80,12 +59,12 @@ public class FaultLogsController extends BaseController {
|
|||
/**
|
||||
* 故障日志详情
|
||||
*/
|
||||
// @ApiOperation(value = "故障日志详情",hidden = true)
|
||||
// @RequiresPermissions("business:faultLogs:query")
|
||||
// @GetMapping("/{logId}")
|
||||
// public Result detail(@ApiParam(value = "故障日志主键") @PathVariable("logId") Long logId) {
|
||||
// return Result.success(faultLogsService.selectFaultLogsById(logId));
|
||||
// }
|
||||
@ApiOperation(value = "故障日志详情",hidden = true)
|
||||
@RequiresPermissions("business:faultLogs:query")
|
||||
@GetMapping("/{logId}")
|
||||
public Result detail(@ApiParam(value = "故障日志主键") @PathVariable("logId") Long logId) {
|
||||
return Result.success(faultLogsService.selectFaultLogsById(logId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改故障日志
|
||||
|
@ -109,28 +88,8 @@ public class FaultLogsController extends BaseController {
|
|||
return toAjax(faultLogsService.deleteFaultLogsByIds(logIds));
|
||||
}
|
||||
|
||||
// @RabbitListener(queuesToDeclare = {@Queue(value = MQQueueConstants.FAULT_QUEUE, declare = "true")})
|
||||
// public void sendSms(FaultLogs faultLogs, Message message, Channel channel) {
|
||||
// log.info("消息队列:【{}】,收到故障日志:【{}】",MQQueueConstants.FAULT_QUEUE,faultLogs);
|
||||
// try {
|
||||
// String messageId = message.getMessageProperties().getMessageId();
|
||||
// Long count = redisTemplate.opsForSet().add(MQQueueConstants.FAULT_QUEUE, messageId);
|
||||
// if (count.intValue() > 0){
|
||||
// faultLogsService.insertFaultLogs(faultLogs);
|
||||
// // 消息确认
|
||||
// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||
// log.info("消息队列:【{}】,收到故障日志:【{}】,消费成功...",MQQueueConstants.FAULT_QUEUE,faultLogs);
|
||||
// }else {
|
||||
// log.error("消息队列:【{}】,收到故障日志:【{}】,消费重复...",MQQueueConstants.FAULT_QUEUE,faultLogs);
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// log.error("消息队列:【{}】,收到故障日志:【{}】,消费异常:【{}】",MQQueueConstants.FAULT_QUEUE,faultLogs,e.getMessage());
|
||||
// // 消息回退
|
||||
// try {
|
||||
// channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
|
||||
// } catch (IOException ex) {
|
||||
// log.error("消息队列:【{}】,收到故障日志:【{}】,消息退回异常:【{}】",MQQueueConstants.FAULT_QUEUE,faultLogs,e.getMessage());
|
||||
// }
|
||||
|
||||
@Scheduled(cron = "0/10 * * * * * ")
|
||||
public void faultLogsService() {
|
||||
faultLogsService.faultLogsService();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.muyu.business.controller;
|
||||
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.business.domain.request.FenceAddRequest;
|
||||
import com.muyu.business.domain.request.FenceListRequest;
|
||||
import com.muyu.business.domain.request.FenceUpdateRequest;
|
||||
import com.muyu.business.domain.request.MapRequest;
|
||||
|
||||
import com.muyu.business.service.IFenceInfoService;
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
@ -12,11 +12,10 @@ import com.muyu.common.core.web.controller.BaseController;
|
|||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName BusinessFenceController
|
||||
* @Description 电子围栏控制层
|
||||
|
@ -123,11 +122,4 @@ public class FenceInfoController extends BaseController
|
|||
{
|
||||
return toAjax(fenceInfoService.savePolygon(mapRequest));
|
||||
}
|
||||
|
||||
@RequiresPermissions("business:fence:query")
|
||||
@GetMapping("/findFence")
|
||||
public List<Fence> findFence()
|
||||
{
|
||||
return fenceInfoService.findFence();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
package com.muyu.business.controller;
|
||||
|
||||
import com.muyu.business.domain.Marking;
|
||||
import com.muyu.business.domain.req.MarkingListRequest;
|
||||
import com.muyu.business.service.IMarkingService;
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 标识列表Controller
|
||||
*
|
||||
* @author yinyuyang
|
||||
* @date 2024-04-10
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/marking")
|
||||
public class MarkingController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IMarkingService markingService;
|
||||
|
||||
/**
|
||||
* 查询标识列表列表
|
||||
*/
|
||||
@RequiresPermissions("business:marking:list")
|
||||
@GetMapping("/list")
|
||||
public Result<PageResult<Marking>> list(MarkingListRequest markingListRequest)
|
||||
{
|
||||
return markingService.findList(markingListRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标识列表详细信息
|
||||
*/
|
||||
@RequiresPermissions("business:marking:query")
|
||||
@GetMapping(value = "/findById/{markingId}")
|
||||
public Marking getInfo(@PathVariable("markingId") Integer markingId)
|
||||
{
|
||||
return markingService.findById(markingId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增标识列表
|
||||
*/
|
||||
@RequiresPermissions("business:marking:add")
|
||||
@Log(title = "标识列表", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/insert")
|
||||
public Result add(@RequestBody Marking marking)
|
||||
{
|
||||
return toAjax(markingService.insertMarking(marking));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改标识列表
|
||||
*/
|
||||
@RequiresPermissions("business:marking:edit")
|
||||
@Log(title = "标识列表", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
public Result edit(@RequestBody Marking marking)
|
||||
{
|
||||
return toAjax(markingService.updateMarking(marking));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除标识列表
|
||||
*/
|
||||
@RequiresPermissions("business:marking:remove")
|
||||
@Log(title = "标识列表", businessType = BusinessType.DELETE)
|
||||
@PostMapping("delete/{markingId}")
|
||||
public Result remove(@PathVariable Integer markingId)
|
||||
{
|
||||
return toAjax(markingService.delete(markingId));
|
||||
}
|
||||
}
|
|
@ -2,19 +2,17 @@ package com.muyu.business.controller;
|
|||
|
||||
import com.muyu.business.domain.Records;
|
||||
import com.muyu.business.domain.request.RecordsListRequest;
|
||||
|
||||
import com.muyu.business.service.IRecordsService;
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 车辆历史轨迹Controller
|
||||
*
|
||||
|
@ -27,9 +25,6 @@ public class RecordsController extends BaseController
|
|||
{
|
||||
@Autowired
|
||||
private IRecordsService recordsService;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询车辆历史轨迹列表
|
||||
|
@ -58,15 +53,10 @@ public class RecordsController extends BaseController
|
|||
return Result.success(recordsService.insert(vin));
|
||||
}
|
||||
|
||||
@PostMapping("/update/{vin}")
|
||||
@PostMapping("/update/{recordsId}")
|
||||
@Log(title = "车辆历史轨迹", businessType = BusinessType.UPDATE)
|
||||
public Result update(@PathVariable("vin") String vin) {
|
||||
Set<Object> cacheSet = redisService.getCacheSet("records:info:" + vin);
|
||||
Integer recordsId = (Integer) cacheSet.toArray()[0];
|
||||
Result ajax = toAjax(recordsService.updateRecords(recordsId));
|
||||
redisService.deleteObject("records:info:" + vin);
|
||||
|
||||
return ajax;
|
||||
public Result update(@PathVariable("recordsId") Integer recordsId) {
|
||||
return toAjax(recordsService.updateRecords(recordsId));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package com.muyu.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.business.domain.AlarmLogs;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.*;
|
||||
import com.baomidou.mybatisplus.core.mapper.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.business.domain.res.AlarmLogsResponse;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 报警日志Mapper接口
|
||||
|
@ -21,12 +20,10 @@ public interface AlarmLogsMapper extends BaseMapper<AlarmLogs> {
|
|||
* @param wrapper 查询条件
|
||||
* @return 报警日志集合
|
||||
*/
|
||||
List<AlarmLogsResponse> selectAlarmLogsList(LambdaQueryWrapper<AlarmLogs> wrapper);
|
||||
List<AlarmLogs> selectAlarmLogsList(LambdaQueryWrapper<AlarmLogs> wrapper);
|
||||
|
||||
void alarmLogsService(Fence fence);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.muyu.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.*;
|
||||
import com.muyu.business.domain.*;
|
||||
|
||||
/**
|
||||
* 故障码Mapper接口
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package com.muyu.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
import com.muyu.business.domain.FaultLogs;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.*;
|
||||
import com.baomidou.mybatisplus.core.mapper.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.FaultLogsAddReq;
|
||||
import com.muyu.business.domain.res.FaultLogsResponse;
|
||||
import com.muyu.business.domain.res.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 故障日志Mapper接口
|
||||
|
@ -27,11 +26,4 @@ public interface FaultLogsMapper extends BaseMapper<FaultLogs> {
|
|||
void FaultLogsService(FaultLogsAddReq faultLogsAddReq);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
FaultCodeInfo selectFaultCode(String faultCode);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
package com.muyu.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.business.domain.Marking;
|
||||
|
||||
/**
|
||||
* 标识列表Mapper接口
|
||||
*
|
||||
* @author yinyuyang
|
||||
* @date 2024-04-10
|
||||
*/
|
||||
public interface MarkingMapper extends BaseMapper<Marking>
|
||||
{
|
||||
|
||||
}
|
|
@ -1,11 +1,10 @@
|
|||
package com.muyu.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.business.domain.AlarmLogs;
|
||||
import com.muyu.business.domain.req.AlarmLogsReq;
|
||||
import com.muyu.business.domain.res.AlarmLogsResponse;
|
||||
import com.baomidou.mybatisplus.extension.service.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 报警日志Service接口
|
||||
|
@ -20,7 +19,7 @@ public interface AlarmLogsService extends IService<AlarmLogs> {
|
|||
* @param alarmLogsReq 报警日志
|
||||
* @return 报警日志
|
||||
*/
|
||||
List<AlarmLogsResponse> selectAlarmLogsList(AlarmLogsReq alarmLogsReq);
|
||||
List<AlarmLogs> selectAlarmLogsList(AlarmLogsReq alarmLogsReq);
|
||||
|
||||
/**
|
||||
* 新增报警日志
|
||||
|
@ -28,7 +27,7 @@ public interface AlarmLogsService extends IService<AlarmLogs> {
|
|||
* @param alarmLogs 报警日志
|
||||
* @return 结果
|
||||
*/
|
||||
// int insertAlarmLogs(AlarmLogs alarmLogs);
|
||||
int insertAlarmLogs(AlarmLogs alarmLogs);
|
||||
|
||||
/**
|
||||
* 报警日志详情
|
||||
|
@ -61,9 +60,7 @@ public interface AlarmLogsService extends IService<AlarmLogs> {
|
|||
*/
|
||||
int deleteAlarmLogsByIds(Long[] alarmIds);
|
||||
|
||||
|
||||
void alarmLogsService(String alarmLog);
|
||||
|
||||
void alarmLogsService();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.muyu.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
import com.muyu.business.domain.req.FaultCodeReq;
|
||||
import com.baomidou.mybatisplus.extension.service.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 故障码Service接口
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package com.muyu.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
import com.muyu.business.domain.FaultLogs;
|
||||
import com.muyu.business.domain.req.FaultLogsReq;
|
||||
import com.muyu.business.domain.res.FaultLogsResponse;
|
||||
import com.baomidou.mybatisplus.extension.service.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.muyu.business.domain.res.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 故障日志Service接口
|
||||
|
@ -37,7 +36,7 @@ public interface FaultLogsService extends IService<FaultLogs> {
|
|||
* @param logId
|
||||
* @return
|
||||
*/
|
||||
|
||||
FaultLogs selectFaultLogsById(Long logId);
|
||||
|
||||
/**
|
||||
* 编辑故障日志
|
||||
|
@ -66,8 +65,5 @@ public interface FaultLogsService extends IService<FaultLogs> {
|
|||
void faultLogsService();
|
||||
|
||||
|
||||
FaultCodeInfo selectFaultLogsById(String faultCode);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package com.muyu.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.business.domain.request.FenceListRequest;
|
||||
import com.muyu.business.domain.request.MapRequest;
|
||||
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
||||
import java.util.List;
|
||||
import com.muyu.business.domain.Fence;
|
||||
|
||||
/**
|
||||
* 电子围栏Service接口
|
||||
|
@ -48,5 +47,4 @@ public interface IFenceInfoService extends IService<Fence>
|
|||
Fence selectFenceByFenceId(Integer fenceId);
|
||||
|
||||
int savePolygon(MapRequest mapRequest);
|
||||
List<Fence> findFence();
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
package com.muyu.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.business.domain.Marking;
|
||||
import com.muyu.business.domain.req.MarkingListRequest;
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
||||
/**
|
||||
* 标识列表Service接口
|
||||
*
|
||||
* @author yinyuyang
|
||||
* @date 2024-04-10
|
||||
*/
|
||||
public interface IMarkingService extends IService<Marking>
|
||||
{
|
||||
|
||||
Result<PageResult<Marking>> findList(MarkingListRequest markingListRequest);
|
||||
|
||||
int insertMarking(Marking marking);
|
||||
|
||||
int updateMarking(Marking marking);
|
||||
|
||||
Marking findById(Integer markingId);
|
||||
|
||||
int delete(Integer markingId);
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.muyu.business.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.business.domain.Records;
|
||||
import com.muyu.business.domain.request.RecordsListRequest;
|
||||
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.muyu.business.service;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.business.domain.Vehicle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @className: VehicleDataService
|
||||
* @author: YinYuYang
|
||||
|
|
|
@ -1,24 +1,18 @@
|
|||
package com.muyu.business.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.business.domain.AlarmLogs;
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
import com.muyu.business.domain.req.AlarmLogsReq;
|
||||
import com.muyu.business.domain.res.AlarmLogsResponse;
|
||||
import com.muyu.business.mapper.AlarmLogsMapper;
|
||||
import com.muyu.business.service.AlarmLogsService;
|
||||
import com.muyu.business.service.FaultLogsService;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.*;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.muyu.business.mapper.*;
|
||||
import com.muyu.business.service.*;
|
||||
import com.muyu.common.core.utils.*;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import org.springframework.stereotype.*;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 报警日志Service业务层处理
|
||||
|
@ -37,25 +31,11 @@ public class AlarmLogsServiceImpl extends ServiceImpl<AlarmLogsMapper, AlarmLogs
|
|||
@Autowired
|
||||
private AlarmLogsMapper alarmLogsMapper;
|
||||
|
||||
/**
|
||||
* 注入fault接口
|
||||
*/
|
||||
@Autowired
|
||||
private FaultLogsService faultLogsService;
|
||||
|
||||
/**
|
||||
* 注入redis工具类
|
||||
*/
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 注入rabbitmq
|
||||
*/
|
||||
|
||||
|
||||
@Override
|
||||
public List<AlarmLogsResponse> selectAlarmLogsList(AlarmLogsReq alarmLogsReq) {
|
||||
public List<AlarmLogs> selectAlarmLogsList(AlarmLogsReq alarmLogsReq) {
|
||||
LambdaQueryWrapper<AlarmLogs> wrapper = new LambdaQueryWrapper<>();
|
||||
// wrapper.like(StringUtils.isNotEmpty(alarmLogsReq.getCarVin()),AlarmLogs::getCarVin, alarmLogsReq.getCarVin());
|
||||
// wrapper.like(StringUtils.isNotEmpty(alarmLogsReq.getFaultCode()),AlarmLogs::getFaultCode, alarmLogsReq.getFaultCode());
|
||||
|
@ -67,16 +47,10 @@ public class AlarmLogsServiceImpl extends ServiceImpl<AlarmLogsMapper, AlarmLogs
|
|||
return alarmLogsMapper.selectAlarmLogsList(wrapper);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public int insertAlarmLogs(AlarmLogs alarmLogs) {
|
||||
//
|
||||
//
|
||||
// rabbitTemplate.convertAndSend(MQQueueConstants.ALARM_QUEUE, alarmLogs, message -> {
|
||||
// message.getMessageProperties().setMessageId(IdUtils.fastSimpleUUID());
|
||||
// return message;
|
||||
// });
|
||||
// return alarmLogsMapper.insert(alarmLogs);
|
||||
// }
|
||||
@Override
|
||||
public int insertAlarmLogs(AlarmLogs alarmLogs) {
|
||||
return alarmLogsMapper.insert(alarmLogs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlarmLogs selectAlarmLogsById(Integer alarmId) {
|
||||
|
@ -99,30 +73,20 @@ public class AlarmLogsServiceImpl extends ServiceImpl<AlarmLogsMapper, AlarmLogs
|
|||
}
|
||||
|
||||
@Override
|
||||
public void alarmLogsService(String alarmLog) {
|
||||
|
||||
AlarmLogs alarmLogs = JSON.parseObject(alarmLog, AlarmLogs.class);
|
||||
|
||||
|
||||
//json转对象
|
||||
FaultCodeInfo faultLogs = faultLogsService.selectFaultLogsById(alarmLogs.getFaultCode());
|
||||
|
||||
switch (faultLogs.getFaultLevel()){
|
||||
case 1:
|
||||
log.info("发送短信");
|
||||
alarmLogsMapper.insert(alarmLogs);
|
||||
case 2:
|
||||
log.info("发邮件");
|
||||
alarmLogsMapper.insert(alarmLogs);
|
||||
|
||||
default:
|
||||
|
||||
alarmLogsMapper.insert(alarmLogs);
|
||||
}
|
||||
public void alarmLogsService() {
|
||||
// String key = "fenceType1";
|
||||
// Set<Object> cacheSet = redisService.getCacheSet(key);
|
||||
// for (Object o : cacheSet) {
|
||||
// Fence fence = JSON.parseObject((String) o, Fence.class);
|
||||
//
|
||||
//
|
||||
// //报警逻辑处理 处理完毕存放入数据库
|
||||
//
|
||||
//
|
||||
// alarmLogsMapper.alarmLogsService(fence);
|
||||
// }
|
||||
log.info("报警日志");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
package com.muyu.business.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
import com.muyu.business.domain.req.FaultCodeReq;
|
||||
import com.muyu.business.mapper.FaultCodesMapper;
|
||||
import com.muyu.business.service.FaultCodesService;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.*;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.muyu.business.mapper.*;
|
||||
import com.muyu.business.service.*;
|
||||
import com.muyu.common.core.utils.*;
|
||||
import com.muyu.common.security.utils.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import org.springframework.stereotype.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 故障码Service业务层处理
|
||||
|
|
|
@ -1,23 +1,18 @@
|
|||
package com.muyu.business.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.business.domain.FaultCodeInfo;
|
||||
import com.muyu.business.domain.FaultLogs;
|
||||
import com.muyu.business.domain.req.FaultCodeReq;
|
||||
import com.muyu.business.domain.req.FaultCodesUpdReq;
|
||||
import com.muyu.business.domain.req.FaultLogsReq;
|
||||
import com.muyu.business.domain.res.FaultLogsResponse;
|
||||
import com.muyu.business.mapper.FaultLogsMapper;
|
||||
import com.muyu.business.service.FaultCodesService;
|
||||
import com.muyu.business.service.FaultLogsService;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.*;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.*;
|
||||
import com.muyu.business.domain.*;
|
||||
import com.muyu.business.domain.req.*;
|
||||
import com.muyu.business.domain.res.*;
|
||||
import com.muyu.business.mapper.*;
|
||||
import com.muyu.business.service.*;
|
||||
import com.muyu.common.core.utils.*;
|
||||
import lombok.extern.slf4j.*;
|
||||
import org.springframework.beans.factory.annotation.*;
|
||||
import org.springframework.stereotype.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 故障日志Service业务层处理
|
||||
|
@ -73,7 +68,10 @@ public class FaultLogsServiceImpl extends ServiceImpl<FaultLogsMapper, FaultLogs
|
|||
return faultLogsMapper.insert(faultLogs);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FaultLogs selectFaultLogsById(Long logId) {
|
||||
return faultLogsMapper.selectById(logId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateFaultLogs(FaultLogs faultLogs) {
|
||||
|
@ -108,9 +106,4 @@ public class FaultLogsServiceImpl extends ServiceImpl<FaultLogsMapper, FaultLogs
|
|||
log.info("添加了故障日志数据库");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaultCodeInfo selectFaultLogsById(String faultCode) {
|
||||
return faultLogsMapper.selectFaultCode(faultCode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,20 +5,23 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.business.domain.request.FenceListRequest;
|
||||
import com.muyu.business.domain.request.MapRequest;
|
||||
|
||||
import com.muyu.business.mapper.FenceInfoMapper;
|
||||
import com.muyu.business.service.IFenceInfoService;
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.utils.uuid.IdUtils;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.cache.CacheProperties;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -160,13 +163,4 @@ public class FenceInfoServiceImpl extends ServiceImpl<FenceInfoMapper, Fence>
|
|||
|
||||
return fenceInfoMapper.update(fence,updateWrapper);
|
||||
}
|
||||
@Override
|
||||
public List<Fence> findFence() {
|
||||
|
||||
LambdaQueryWrapper<Fence> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
queryWrapper.select(Fence::getFenceId,Fence::getFenceName);
|
||||
|
||||
return fenceInfoMapper.selectList(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
package com.muyu.business.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.muyu.business.domain.Marking;
|
||||
import com.muyu.business.domain.req.MarkingListRequest;
|
||||
import com.muyu.business.mapper.MarkingMapper;
|
||||
import com.muyu.business.service.IMarkingService;
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 标识列表Service业务层处理
|
||||
*
|
||||
* @author yinyuyang
|
||||
* @date 2024-04-10
|
||||
*/
|
||||
@Service
|
||||
public class MarkingServiceImpl extends ServiceImpl<MarkingMapper, Marking>
|
||||
implements IMarkingService
|
||||
{
|
||||
@Autowired
|
||||
private MarkingMapper markingMapper;
|
||||
|
||||
@Override
|
||||
public Result<PageResult<Marking>> findList(MarkingListRequest markingListRequest) {
|
||||
|
||||
PageHelper.startPage(markingListRequest.getPageNum(),markingListRequest.getPageSize());
|
||||
|
||||
LambdaQueryWrapper<Marking> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
queryWrapper.like(StringUtils.isNotEmpty(markingListRequest.getMarkingName()),Marking::getMarkingName,
|
||||
markingListRequest.getMarkingName());
|
||||
|
||||
List<Marking> list = this.list(queryWrapper);
|
||||
|
||||
PageInfo<Marking> pageInfo = new PageInfo<>(list);
|
||||
|
||||
return PageResult.toResult(pageInfo.getTotal(),list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertMarking(Marking marking) {
|
||||
|
||||
return markingMapper.insert(marking);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateMarking(Marking marking) {
|
||||
|
||||
return markingMapper.updateById(marking);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Marking findById(Integer markingId) {
|
||||
|
||||
return markingMapper.selectById(markingId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Integer markingId) {
|
||||
|
||||
return markingMapper.deleteById(markingId);
|
||||
}
|
||||
}
|
|
@ -7,12 +7,12 @@ import com.github.pagehelper.PageHelper;
|
|||
import com.github.pagehelper.PageInfo;
|
||||
import com.muyu.business.domain.Records;
|
||||
import com.muyu.business.domain.request.RecordsListRequest;
|
||||
|
||||
import com.muyu.business.mapper.RecordsMapper;
|
||||
import com.muyu.business.service.IRecordsService;
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -32,9 +32,6 @@ public class RecordsServiceImpl extends ServiceImpl<RecordsMapper,Records>
|
|||
|
||||
@Autowired
|
||||
private RecordsMapper recordsMapper;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
|
||||
/**
|
||||
* @author YinYuYang
|
||||
|
@ -88,17 +85,9 @@ public class RecordsServiceImpl extends ServiceImpl<RecordsMapper,Records>
|
|||
|
||||
records.setStartTime(new Date());
|
||||
|
||||
|
||||
recordsMapper.insert(records);
|
||||
|
||||
Integer recordsId = records.getRecordsId();
|
||||
|
||||
/*
|
||||
*上线缓存id,为历史轨迹做准备
|
||||
*/
|
||||
redisService.setCacheObject("records:info:"+vin,recordsId);
|
||||
|
||||
return recordsId;
|
||||
return records.getRecordsId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,15 +3,19 @@ package com.muyu.business.service.impl;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.business.domain.Vehicle;
|
||||
import com.muyu.business.mapper.VehicleDataMapper;
|
||||
import com.muyu.business.service.VehicleDataService;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.system.common.domain.VehicleData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
left join fault_code_info c on l.fault_code = c.fault_code
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="selectAlarmLogsList" resultMap="AlarmLogsResult">
|
||||
<include refid="selectAlarmLogs"/>
|
||||
</select>
|
||||
|
|
|
@ -44,10 +44,4 @@
|
|||
<select id="selectFaultLogsList" resultMap="FaultLogsResult">
|
||||
<include refid="selectFaultLogsVo"/>
|
||||
</select>
|
||||
|
||||
<select id="selectFaultCode" resultType="com.muyu.business.domain.FaultCodeInfo">
|
||||
select * from fault_code_info where fault_code = #{faultCode}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -42,7 +42,7 @@ public class Car {
|
|||
*/
|
||||
private String carType;
|
||||
/**
|
||||
* 电子围栏ID
|
||||
* 车辆标识
|
||||
*/
|
||||
private String carMarking;
|
||||
/**
|
||||
|
@ -92,7 +92,7 @@ public class Car {
|
|||
return Car.builder()
|
||||
.carVin(carAddReq.getCarVin())
|
||||
.carType(carAddReq.getCarType())
|
||||
.carMarking(carAddReq.getCarFenceId())
|
||||
.carMarking(carAddReq.getCarMarking())
|
||||
.state(carAddReq.getState())
|
||||
.carElectricalmachiney(carAddReq.getCarElectricalmachiney())
|
||||
.carBattery(carAddReq.getCarBattery())
|
||||
|
@ -107,7 +107,7 @@ public class Car {
|
|||
.carId(carUpdateReq.getCarId())
|
||||
.carVin(carUpdateReq.getCarVin())
|
||||
.carType(carUpdateReq.getCarType())
|
||||
.carMarking(carUpdateReq.getCarFenceId())
|
||||
.carMarking(carUpdateReq.getCarMarking())
|
||||
.state(carUpdateReq.getState())
|
||||
.carElectricalmachiney(carUpdateReq.getCarElectricalmachiney())
|
||||
.carBattery(carUpdateReq.getCarBattery())
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.business.domain;
|
||||
package com.muyu.system.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
|
@ -39,12 +39,12 @@ public class CarAddReq {
|
|||
@ApiModelProperty(value = "车辆类型")
|
||||
private String carType;
|
||||
/**
|
||||
* 电子围栏ID
|
||||
* 车辆标识
|
||||
*/
|
||||
@NotNull
|
||||
@Length(max = 255)
|
||||
@ApiModelProperty(value = "电子围栏ID")
|
||||
private String carFenceId;
|
||||
@ApiModelProperty(value = "车辆标识")
|
||||
private String carMarking;
|
||||
/**
|
||||
* 车辆状态
|
||||
*/
|
||||
|
|
|
@ -46,12 +46,12 @@ public class CarUpdateReq {
|
|||
@ApiModelProperty(value = "车辆类型")
|
||||
private String carType;
|
||||
/**
|
||||
* 电子围栏ID
|
||||
* 车辆标识
|
||||
*/
|
||||
@NotNull
|
||||
@Length(max = 255)
|
||||
@ApiModelProperty(value = "电子围栏ID")
|
||||
private String carFenceId;
|
||||
@ApiModelProperty(value = "车辆标识")
|
||||
private String carMarking;
|
||||
/**
|
||||
* 车辆状态
|
||||
*/
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package com.muyu.system.controller;
|
||||
|
||||
import com.muyu.business.domain.Fence;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.system.common.domain.Car;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.system.common.domain.Marking;
|
||||
import com.muyu.system.common.domain.req.CarAddReq;
|
||||
import com.muyu.system.common.domain.req.CarUpdateReq;
|
||||
import com.muyu.system.common.domain.vo.CarVo;
|
||||
|
@ -18,8 +15,10 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -120,6 +119,19 @@ public class CarController extends BaseController
|
|||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询标识表
|
||||
*/
|
||||
@GetMapping("selectMarking")
|
||||
@RequiresPermissions("system:car:query")
|
||||
@Log(title = "查询标识表")
|
||||
public Result<List<Marking>> selectMarking(){
|
||||
List<Marking> list=carService.selectMarking();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 车辆上线(连接车联模拟数据)
|
||||
* @param carVin
|
||||
|
@ -135,14 +147,14 @@ public class CarController extends BaseController
|
|||
|
||||
/**
|
||||
* 车辆下线(连接车联模拟数据)
|
||||
* @param vin
|
||||
* @param carVin
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/close/{vin}")
|
||||
// @RequiresPermissions("system:car:edit")
|
||||
@PostMapping("/close/{carVin}")
|
||||
@RequiresPermissions("system:car:edit")
|
||||
@Log(title = "车辆管理")
|
||||
public Result<String> close(@PathVariable String vin){
|
||||
Result<String> result=carService.callVehicleClientClose(vin);
|
||||
public Result<String> close(@PathVariable String carVin){
|
||||
Result<String> result=carService.callVehicleClientClose(carVin);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.system.mapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.system.common.domain.Car;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.system.common.domain.Marking;
|
||||
import com.muyu.system.common.domain.req.CarInfoAddReq;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -60,7 +61,7 @@ public interface CarMapper extends BaseMapper<Car>
|
|||
|
||||
int deleteByVin(String carVin);
|
||||
|
||||
void updateVin(String carVin);
|
||||
List<Marking> selectMarking();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.muyu.common.core.domain.PageResult;
|
|||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.system.common.domain.Car;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.system.common.domain.Marking;
|
||||
import com.muyu.system.common.domain.vo.CarVo;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -70,4 +71,6 @@ public interface CarService extends IService<Car>
|
|||
int deleteByVin(String carVin);
|
||||
|
||||
|
||||
List<Marking> selectMarking();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package com.muyu.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.common.core.domain.PageResult;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
|
@ -16,18 +20,18 @@ import com.muyu.common.redis.service.RedisService;
|
|||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.system.common.VehicleCreateAddReq;
|
||||
import com.muyu.system.common.domain.Car;
|
||||
import com.muyu.business.domain.Fence;
|
||||
import com.muyu.system.common.domain.Marking;
|
||||
import com.muyu.system.common.domain.req.CarInfoAddReq;
|
||||
import com.muyu.system.common.domain.vo.CarVo;
|
||||
import com.muyu.system.feign.RecordsFeign;
|
||||
import com.muyu.system.mapper.CarMapper;
|
||||
import com.muyu.system.service.CarService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.muyu.system.service.CarService;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* 车辆信息Service业务层处理
|
||||
|
@ -228,7 +232,12 @@ public class CarServiceImpl extends ServiceImpl<CarMapper,Car> implements CarSer
|
|||
carInfoAddReq.setInfoOpenDate(new Date());
|
||||
carMapper.insertCarInfo(carInfoAddReq);
|
||||
|
||||
|
||||
// 修改
|
||||
if (!redisService.hasKey("records:info:"+carVin)){
|
||||
Result<Integer> insert = recordsFeign.insert(carVin);
|
||||
Integer recordsId = insert.getData();
|
||||
redisService.setCacheObject("records:info:"+carVin,recordsId);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
|
@ -236,53 +245,48 @@ public class CarServiceImpl extends ServiceImpl<CarMapper,Car> implements CarSer
|
|||
|
||||
/**
|
||||
* 车辆下线
|
||||
* @param vin
|
||||
* @param carVin
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result<String> callVehicleClientClose(String carVin) {
|
||||
// String url="http://127.0.0.1:81/vehicle/instance/client/close/" +carVin;
|
||||
// Result<String> result=restTemplate.postForObject(url,null,Result.class);
|
||||
String url="http://127.0.0.1:81/vehicle/instance/client/close/" +carVin;
|
||||
Result<String> result=restTemplate.postForObject(url,null,Result.class);
|
||||
carMapper.updateVinClose(carVin);
|
||||
Car car = carMapper.selectByVin(carVin);
|
||||
CarInfoAddReq carInfoAddReq = new CarInfoAddReq();
|
||||
carInfoAddReq.setVin(car.getCarVin());
|
||||
carInfoAddReq.setInfoCloseDate(new Date());
|
||||
carMapper.insertCarInfo(carInfoAddReq);
|
||||
|
||||
|
||||
// carMapper.updateVinClose(carVin);
|
||||
// Car car = carMapper.selectByVin(carVin);
|
||||
// CarInfoAddReq carInfoAddReq = new CarInfoAddReq();
|
||||
// carInfoAddReq.setVin(car.getCarVin());
|
||||
// carInfoAddReq.setInfoCloseDate(new Date());
|
||||
carMapper.updateVin(carVin);
|
||||
|
||||
|
||||
// if (redisService.hasKey("records:info:"+carVin)){
|
||||
// Object cacheObject = redisService.getCacheObject("records:info:" + carVin);
|
||||
// if (cacheObject != null){
|
||||
// Integer recordsId = (Integer) cacheObject;
|
||||
// recordsFeign.update(recordsId);
|
||||
// }
|
||||
// redisService.deleteObject("records:info:"+carVin);
|
||||
// }
|
||||
if (redisService.hasKey("records:info:"+carVin)){
|
||||
Object cacheObject = redisService.getCacheObject("records:info:" + carVin);
|
||||
if (cacheObject != null){
|
||||
Integer recordsId = (Integer) cacheObject;
|
||||
recordsFeign.update(recordsId);
|
||||
}
|
||||
redisService.deleteObject("records:info:"+carVin);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return Result.success();
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public int deleteByVin(String carVin) {
|
||||
String url="http://127.0.0.1:81/vehicle/" +carVin;
|
||||
restTemplate.delete(url);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return carMapper.deleteByVin(carVin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Marking> selectMarking() {
|
||||
return carMapper.selectMarking();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<mapper namespace="com.muyu.system.mapper.CarMapper">
|
||||
|
||||
<sql id="list">
|
||||
select car_id,car_vin,car_type,car_fence_id,state,
|
||||
select car_id,car_vin,car_type,car_marking,state,
|
||||
car_electricalmachiney,car_battery,
|
||||
car_electricalmachiney_id,car_battery_id,
|
||||
create_by,create_time,update_by,update_time,
|
||||
|
@ -30,9 +30,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<update id="updateVinClose">
|
||||
update car set state=1 where car_vin=#{carVin}
|
||||
</update>
|
||||
<update id="updateVin">
|
||||
update car set over_time=now() where car_vin=#{carVin}
|
||||
</update>
|
||||
<delete id="deleteByVin">
|
||||
delete from car where car_vin=#{carVin}
|
||||
</delete>
|
||||
|
@ -51,4 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="selectFenceList" resultType="com.muyu.business.domain.Fence">
|
||||
select * from fence where fence_state=0
|
||||
</select>
|
||||
<select id="selectMarking" resultType="com.muyu.system.common.domain.Marking">
|
||||
select marking_id,marking_name from marking
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
12
pom.xml
12
pom.xml
|
@ -35,7 +35,6 @@
|
|||
<minio.version>8.2.2</minio.version>
|
||||
<poi.version>4.1.2</poi.version>
|
||||
<transmittable-thread-local.version>2.14.4</transmittable-thread-local.version>
|
||||
<transmittable-thread-local.version>2.14.4</transmittable-thread-local.version>
|
||||
|
||||
<muyu-file-common.version>3.6.3</muyu-file-common.version>
|
||||
<muyu-file-remote.version>3.6.3</muyu-file-remote.version>
|
||||
|
@ -50,8 +49,6 @@
|
|||
<muyu-business-server.version>3.6.3</muyu-business-server.version>
|
||||
<muyu-analyze.version>3.6.3</muyu-analyze.version>
|
||||
|
||||
<muyu-common-redis.version>3.6.3</muyu-common-redis.version>
|
||||
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
|
@ -285,12 +282,7 @@
|
|||
<artifactId>muyu-analyze</artifactId>
|
||||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>ecs20140526</artifactId>
|
||||
<version>5.0.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<modules>
|
||||
|
@ -300,8 +292,6 @@
|
|||
<module>muyu-modules</module>
|
||||
<module>muyu-common</module>
|
||||
<module>muyu-analyze</module>
|
||||
<module>muyu-load-center</module>
|
||||
<module>aliyun-api</module>
|
||||
|
||||
|
||||
</modules>
|
||||
|
|
Loading…
Reference in New Issue