fix():修复框架bug
parent
2084013449
commit
dd94f2e39e
|
@ -5,16 +5,15 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-server</artifactId>
|
<artifactId>cloud-common</artifactId>
|
||||||
<version>3.6.3</version>
|
<version>3.6.3</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
cloud-common-cache 缓存基准
|
cloud-common-cache 缓存基准
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<artifactId>cloud-common- </artifactId>
|
<artifactId>cloud-common-cache</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>23</maven.compiler.source>
|
<maven.compiler.source>23</maven.compiler.source>
|
||||||
|
|
|
@ -2,13 +2,13 @@ package com.muyu.common.cache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存基础
|
* 缓存基础
|
||||||
* * @className: CacheBasic ️✈️
|
* * @className: CacheBasic ️✈️
|
||||||
* * @author: Yang 鹏 🦅
|
* * @author: Yang 鹏 🦅
|
||||||
* * @date: 2024/9/29 16:08 ⏰
|
* * @date: 2024/9/29 16:08 ⏰
|
||||||
* * @Version: 1.0
|
* * @Version: 1.0
|
||||||
* * @description:
|
* * @description:
|
||||||
*/
|
*/
|
||||||
public interface CacheBasic<K,V> extends PrimaryKeyBasic<K>{
|
public interface CacheBasic<K, V> extends PrimaryKeyBasic<K> {
|
||||||
void put(K key, V value);
|
void put(K key, V value);
|
||||||
|
|
||||||
V get(K key);
|
V get(K key);
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>cloud-common-caffeine</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
cloud-common-caffeine 本地缓存服务
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||||
|
<artifactId>caffeine</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>cloud-common-iotdb</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
cloud-common-iotdb 时序性数据存储服务
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.iotdb</groupId>
|
||||||
|
<artifactId>iotdb-session</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
|
<artifactId>fastjson2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,149 @@
|
||||||
|
|
||||||
|
package com.muyu.common.iotdb.config;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.apache.iotdb.isession.SessionDataSet;
|
||||||
|
import org.apache.iotdb.isession.pool.SessionDataSetWrapper;
|
||||||
|
import org.apache.iotdb.rpc.IoTDBConnectionException;
|
||||||
|
import org.apache.iotdb.rpc.StatementExecutionException;
|
||||||
|
import org.apache.iotdb.session.pool.SessionPool;
|
||||||
|
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
|
||||||
|
import org.apache.iotdb.tsfile.read.common.Field;
|
||||||
|
import org.apache.iotdb.tsfile.read.common.RowRecord;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author WangXin
|
||||||
|
* @Data 2024/9/30
|
||||||
|
* @Description IotDBSessionConfig配置类
|
||||||
|
* @Version 1.0.0
|
||||||
|
*/
|
||||||
|
@Log4j2
|
||||||
|
@Component
|
||||||
|
@Configuration
|
||||||
|
public class IotDBSessionConfig {
|
||||||
|
|
||||||
|
@Value("${spring.iotdb.username:root}")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@Value("${spring.iotdb.password:root}")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@Value("${spring.iotdb.ip:127.0.0.1}")
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
@Value("${spring.iotdb.port:6667}")
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
@Value("${spring.iotdb.maxSize:10}")
|
||||||
|
private int maxSize;
|
||||||
|
|
||||||
|
private static SessionPool sessionPool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取IotDBSession对象
|
||||||
|
* @return iotDBSession对象
|
||||||
|
*/
|
||||||
|
public SessionPool getSessionPool() {
|
||||||
|
if (sessionPool == null) {
|
||||||
|
sessionPool = new SessionPool(ip, port, username, password, maxSize);
|
||||||
|
}
|
||||||
|
return sessionPool;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加数据
|
||||||
|
* @param deviceId
|
||||||
|
* @param time
|
||||||
|
* @param measurements
|
||||||
|
* @param values
|
||||||
|
*/
|
||||||
|
public void insertRecord(SessionPool sessionPool,String deviceId, long time, List<String> measurements, List<String> values) {
|
||||||
|
try {
|
||||||
|
log.info("iotdb数据入库:device_id:[{}], measurements:[{}], values:[{}]", deviceId, measurements, values);
|
||||||
|
sessionPool.insertRecord(deviceId, time, measurements, values);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession insertRecord失败: deviceId={}, time={}, measurements={}, values={}, error={}",
|
||||||
|
deviceId, time, measurements, values, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SessionDataSet selectRecord(SessionPool sessionPool,String sql) {
|
||||||
|
log.info("iotdb数据查询:sql:[{}]",sql);
|
||||||
|
SessionDataSetWrapper sessionDataSetWrapper = null;
|
||||||
|
try {
|
||||||
|
log.info("iotdb SQL查询:sql:[{}]", sql);
|
||||||
|
sessionDataSetWrapper = sessionPool.executeQueryStatement(sql);
|
||||||
|
return sessionDataSetWrapper.getSessionDataSet();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession executeQueryStatement失败:sql:[{}],error={}", sql, e.getMessage());
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SessionPool sessionPool = new SessionPool("127.0.0.1", 6667, "root", "root", 10);
|
||||||
|
String ROOT_DATA_DATAJSON = "root.car.data.datajson";
|
||||||
|
String SELECT_ROOT_DATA_DATAJSON_DATASOURCE = "select * from root.car.data.datajson";
|
||||||
|
|
||||||
|
String jsonValue = """
|
||||||
|
{
|
||||||
|
"name": "张三",
|
||||||
|
"age": 28,
|
||||||
|
"email": "zhangsan@example.com",
|
||||||
|
"isStudent": false,
|
||||||
|
"hobbies": ["阅读", "旅行", "编程"],
|
||||||
|
"address": {
|
||||||
|
"street": "长安街100号",
|
||||||
|
"city": "北京",
|
||||||
|
"postalCode": "100000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""";
|
||||||
|
|
||||||
|
IotDBSessionConfig iotDBSessionConfig = new IotDBSessionConfig();
|
||||||
|
|
||||||
|
List<String> values = new ArrayList<>();
|
||||||
|
values.add(jsonValue);
|
||||||
|
ArrayList<String> objects = new ArrayList<>();
|
||||||
|
objects.add("datasource");
|
||||||
|
iotDBSessionConfig.insertRecord(sessionPool,ROOT_DATA_DATAJSON,System.currentTimeMillis(),objects,values);
|
||||||
|
|
||||||
|
SessionDataSet sessionDataSet = iotDBSessionConfig.selectRecord(sessionPool,SELECT_ROOT_DATA_DATAJSON_DATASOURCE);
|
||||||
|
|
||||||
|
HashMap<Long, Map<String, String>> longMapHashMap = new HashMap<>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
while (sessionDataSet.hasNext()){
|
||||||
|
RowRecord next = sessionDataSet.next();
|
||||||
|
long timestamp = next.getTimestamp();
|
||||||
|
Map<String, String> fieldMap = new HashMap<>();
|
||||||
|
for (Field field : next.getFields()) {
|
||||||
|
TSDataType dataType = field.getDataType();
|
||||||
|
String stringValue = field.getStringValue();
|
||||||
|
fieldMap.put(dataType.name(), stringValue);
|
||||||
|
}
|
||||||
|
longMapHashMap.put(timestamp, fieldMap);
|
||||||
|
}
|
||||||
|
} catch (StatementExecutionException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (IoTDBConnectionException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("数据为:{}", JSONObject.toJSONString(longMapHashMap));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.muyu.common.iotdb.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author WangXin
|
||||||
|
* @Data 2024/9/29
|
||||||
|
* @Description 事件驱动对象
|
||||||
|
* @Version 1.0.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class EventActuate {
|
||||||
|
/**
|
||||||
|
* json数据
|
||||||
|
*/
|
||||||
|
private String jsonData;
|
||||||
|
/**
|
||||||
|
* 事件驱动key集合
|
||||||
|
*/
|
||||||
|
private List<String> eventKeys;
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.muyu.common.iotdb.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class InsertDataDTO {
|
||||||
|
private Float temperature;
|
||||||
|
private String hardware;
|
||||||
|
private Boolean status;
|
||||||
|
|
||||||
|
public InsertDataDTO buildOne() {
|
||||||
|
InsertDataDTO insertDataDTO = new InsertDataDTO();
|
||||||
|
insertDataDTO.setHardware("ss");
|
||||||
|
insertDataDTO.setStatus(true);
|
||||||
|
insertDataDTO.setTemperature(12.0F);
|
||||||
|
return insertDataDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InsertDataDTO> buildList() {
|
||||||
|
List<InsertDataDTO> insertDataDTOS = new ArrayList<>();
|
||||||
|
int buildNum = 10;
|
||||||
|
for (int i = 0; i < buildNum; i++) {
|
||||||
|
InsertDataDTO insertDataDTO = new InsertDataDTO();
|
||||||
|
insertDataDTO.setHardware(i % 2 == 0 ? "pp" + i : null);
|
||||||
|
insertDataDTO.setStatus(i % 2 == 0);
|
||||||
|
insertDataDTO.setTemperature(12.0F + i);
|
||||||
|
insertDataDTOS.add(insertDataDTO);
|
||||||
|
}
|
||||||
|
return insertDataDTOS;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.muyu.common.iotdb.domain;
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.common.iotdb.domain.dto.IotDbRecordAble;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class ResultEntity extends IotDbRecordAble {
|
||||||
|
|
||||||
|
private Float temperature;
|
||||||
|
|
||||||
|
private String hardware;
|
||||||
|
|
||||||
|
private Boolean status;
|
||||||
|
|
||||||
|
private String time;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.muyu.common.iotdb.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class TestDataType {
|
||||||
|
private Float temperature;
|
||||||
|
private String hardware;
|
||||||
|
private Boolean status;
|
||||||
|
private Double testDouble;
|
||||||
|
private Long testLong;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.muyu.common.iotdb.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author WangXin
|
||||||
|
* @Data 2024/9/30
|
||||||
|
* @Description IotDBServiceImpl业务实现层
|
||||||
|
* @Version 1.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class IotDbRecordAble {
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.muyu.common.iotdb.domain.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class MeasurementSchemaValuesDTO {
|
||||||
|
|
||||||
|
private List<MeasurementSchema> schemaList;
|
||||||
|
|
||||||
|
private List<Object> values;
|
||||||
|
|
||||||
|
private List<Integer> valueIsNullIndex;
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
package com.muyu.common.iotdb.service;
|
||||||
|
|
||||||
|
import com.muyu.common.iotdb.domain.dto.IotDbRecordAble;
|
||||||
|
import com.muyu.common.iotdb.domain.dto.MeasurementSchemaValuesDTO;
|
||||||
|
import org.apache.iotdb.common.rpc.thrift.TAggregationType;
|
||||||
|
import org.apache.iotdb.isession.SessionDataSet;
|
||||||
|
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
|
||||||
|
import org.apache.iotdb.tsfile.write.record.Tablet;
|
||||||
|
import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author WangXin
|
||||||
|
* @Data 2024/9/28
|
||||||
|
* @Description IotDBServiceImpl业务层
|
||||||
|
* @Version 1.0.0
|
||||||
|
*/
|
||||||
|
public interface IotDBService {
|
||||||
|
|
||||||
|
void insertTablet(Tablet tablet);
|
||||||
|
|
||||||
|
void insertTablets(Map<String, Tablet> tablets);
|
||||||
|
|
||||||
|
void insertStringRecord(String deviceId, long time, List<String> measurements, List<String> values);
|
||||||
|
|
||||||
|
void insertRecord(String deviceId, long time, List<String> measurements, List<TSDataType> types, List<Object> values);
|
||||||
|
|
||||||
|
void insertStringRecords(List<String> deviceIds, List<Long> times, List<List<String>> measurementsList, List<List<String>> valuesList);
|
||||||
|
|
||||||
|
void insertRecords(List<String> deviceIds, List<Long> times, List<List<String>> measurementsList, List<List<TSDataType>> typesList, List<List<Object>> valuesList);
|
||||||
|
|
||||||
|
void insertStringRecordsOfOneDevice(String deviceId, List<Long> times, List<List<String>> measurementsList, List<List<String>> valuesList);
|
||||||
|
|
||||||
|
void insertRecordsOfOneDevice(String deviceId, List<Long> times, List<List<String>> measurementsList, List<List<TSDataType>> typesList, List<List<Object>> valuesList);
|
||||||
|
|
||||||
|
void deleteData(String path, long endTime);
|
||||||
|
|
||||||
|
void deleteData(List<String> paths, long endTime);
|
||||||
|
|
||||||
|
SessionDataSet executeRawDataQuery(List<String> paths, long startTime, long endTime, long timeOut);
|
||||||
|
|
||||||
|
<T> List<T> executeRawDataQuery(List<String> paths, long startTime, long endTime, long timeOut, Class<? extends IotDbRecordAble> clazz);
|
||||||
|
|
||||||
|
SessionDataSet executeLastDataQuery(List<String> paths, long lastTime);
|
||||||
|
|
||||||
|
<T> List<T> executeLastDataQuery(List<String> paths, long lastTime, Class<? extends IotDbRecordAble> clazz);
|
||||||
|
|
||||||
|
SessionDataSet executeLastDataQueryForOneDevice(String db, String device, List<String> sensors, boolean isLegalPathNodes);
|
||||||
|
|
||||||
|
<T> List<T> executeLastDataQueryForOneDevice(String db, String device, List<String> sensors, boolean isLegalPathNodes, Class<? extends IotDbRecordAble> clazz);
|
||||||
|
|
||||||
|
SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations);
|
||||||
|
|
||||||
|
SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, long startTime, long endTime);
|
||||||
|
|
||||||
|
SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, long startTime, long endTime, long interval);
|
||||||
|
|
||||||
|
SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, long startTime, long endTime, long interval, long slidingStep);
|
||||||
|
|
||||||
|
SessionDataSet executeQueryStatement(String sql);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SQL非查询
|
||||||
|
*
|
||||||
|
* @param sql
|
||||||
|
*/
|
||||||
|
void executeNonQueryStatement(String sql);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 封装处理数据
|
||||||
|
*
|
||||||
|
* @param sessionDataSet
|
||||||
|
* @param titleList
|
||||||
|
*/
|
||||||
|
List<Map<String, Object>> packagingMapData(SessionDataSet sessionDataSet, List<String> columnNames);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 封装处理数据(不支持聚合查询)
|
||||||
|
*
|
||||||
|
* @param sessionDataSet 查询返回的结果集
|
||||||
|
* @param titleList 查询返回的结果集内的字段名
|
||||||
|
* @param clazz 返回数据对应的对象(对象属性必须与字段名对应)
|
||||||
|
* @param <T>
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
<T> List<T> packagingObjectData(SessionDataSet sessionDataSet, List<String> titleList, Class<? extends IotDbRecordAble> clazz);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据对象构建MeasurementSchemas
|
||||||
|
*
|
||||||
|
* @param object 对象
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<MeasurementSchema> buildMeasurementSchemas(Object object);
|
||||||
|
/**
|
||||||
|
* 根据对象构建MeasurementSchemaValuesDTO
|
||||||
|
*
|
||||||
|
* @param object 对象
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
MeasurementSchemaValuesDTO buildMeasurementSchemasAndValues(Object object);
|
||||||
|
}
|
|
@ -0,0 +1,711 @@
|
||||||
|
package com.muyu.common.iotdb.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.muyu.common.iotdb.config.IotDBSessionConfig;
|
||||||
|
import com.muyu.common.iotdb.domain.dto.IotDbRecordAble;
|
||||||
|
import com.muyu.common.iotdb.domain.dto.MeasurementSchemaValuesDTO;
|
||||||
|
import com.muyu.common.iotdb.service.IotDBService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.iotdb.common.rpc.thrift.TAggregationType;
|
||||||
|
import org.apache.iotdb.isession.SessionDataSet;
|
||||||
|
import org.apache.iotdb.isession.pool.SessionDataSetWrapper;
|
||||||
|
import org.apache.iotdb.session.pool.SessionPool;
|
||||||
|
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
|
||||||
|
import org.apache.iotdb.tsfile.read.common.Field;
|
||||||
|
import org.apache.iotdb.tsfile.read.common.RowRecord;
|
||||||
|
import org.apache.iotdb.tsfile.write.record.Tablet;
|
||||||
|
import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author WangXin
|
||||||
|
* @Data 2024/9/28
|
||||||
|
* @Description IotDBServiceImpl业务实现层
|
||||||
|
* @Version 1.0.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class IotDBServiceImpl implements IotDBService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IotDBSessionConfig iotDBSessionConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单设备批量插入数据
|
||||||
|
*
|
||||||
|
* @param tablet
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void insertTablet(Tablet tablet) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
try {
|
||||||
|
log.info("iotdb数据入库:tablet:[{}]", tablet);
|
||||||
|
sessionPool.insertTablet(tablet);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession insertTablet失败: tablet={}, error={}", tablet, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多设备批量插入数据
|
||||||
|
*
|
||||||
|
* @param tablets
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void insertTablets(Map<String, Tablet> tablets) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
try {
|
||||||
|
log.info("iotdb数据入库:tablets:[{}]", tablets);
|
||||||
|
sessionPool.insertTablets(tablets);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession insertTablets失败: tablets={}, error={}", tablets, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单条数据插入(string类型数据项)
|
||||||
|
*
|
||||||
|
* @param deviceId 设备名(表名)root.ln.wf01.wt01
|
||||||
|
* @param time 时间戳
|
||||||
|
* @param measurements 数据项列表
|
||||||
|
* @param values 数据项对应值列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void insertStringRecord(String deviceId, long time, List<String> measurements, List<String> values) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
try {
|
||||||
|
log.info("iotdb数据入库:device_id:[{}], measurements:[{}], values:[{}]", deviceId, measurements, values);
|
||||||
|
sessionPool.insertRecord(deviceId, time, measurements, values);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession insertRecord失败: deviceId={}, time={}, measurements={}, values={}, error={}",
|
||||||
|
deviceId, time, measurements, values, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单条数据插入(不同类型数据项)
|
||||||
|
*
|
||||||
|
* @param deviceId 设备名(表名)root.ln.wf01.wt01
|
||||||
|
* @param time 时间戳
|
||||||
|
* @param measurements 数据项列表
|
||||||
|
* @param types 数据项对应类型列表
|
||||||
|
* @param values 数据项对应值列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void insertRecord(String deviceId, long time, List<String> measurements, List<TSDataType> types, List<Object> values) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
try {
|
||||||
|
log.info("iotdb数据入库:device_id:[{}], measurements:[{}], types:[{}], values:[{}]", deviceId, measurements, types, values);
|
||||||
|
sessionPool.insertRecord(deviceId, time, measurements, types, values);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession insertRecordHasTypes失败: deviceId={}, time={}, measurements={},types={}, values={}, error={}",
|
||||||
|
deviceId, time, measurements, types, values, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多个设备多条数据插入(string类型数据项)
|
||||||
|
*
|
||||||
|
* @param deviceIds 多个设备名(表名)root.ln.wf01.wt01
|
||||||
|
* @param times 时间戳的列表
|
||||||
|
* @param measurementsList 数据项列表的列表
|
||||||
|
* @param valuesList 数据项对应值列表的列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void insertStringRecords(List<String> deviceIds, List<Long> times, List<List<String>> measurementsList, List<List<String>> valuesList) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
try {
|
||||||
|
log.info("iotdb数据入库:deviceIds:[{}], measurementsList:[{}], valuesList:[{}]", deviceIds, measurementsList, valuesList);
|
||||||
|
sessionPool.insertRecords(deviceIds, times, measurementsList, valuesList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession insertRecords失败: deviceIds={}, times={}, measurementsList={}, valuesList={}, error={}",
|
||||||
|
deviceIds, times, measurementsList, valuesList, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多个设备多条数据插入(不同类型数据项)
|
||||||
|
*
|
||||||
|
* @param deviceIds 多个设备名(表名))root.ln.wf01.wt01
|
||||||
|
* @param times 时间戳的列表
|
||||||
|
* @param measurementsList 数据项列表的列表
|
||||||
|
* @param typesList 数据项对应类型列表的列表
|
||||||
|
* @param valuesList 数据项对应值列表的列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void insertRecords(List<String> deviceIds, List<Long> times, List<List<String>> measurementsList, List<List<TSDataType>> typesList, List<List<Object>> valuesList) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
try {
|
||||||
|
log.info("iotdb数据入库:deviceIds:[{}], measurementsList:[{}], typesList:[{}], valuesList:[{}]", deviceIds, measurementsList, typesList, valuesList);
|
||||||
|
sessionPool.insertRecords(deviceIds, times, measurementsList, typesList, valuesList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession insertRecords失败: deviceIds={}, times={}, measurementsList={}, typesList=[],valuesList={}, error={}",
|
||||||
|
deviceIds, times, measurementsList, typesList, valuesList, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单个设备多条数据插入(string类型数据项)
|
||||||
|
*
|
||||||
|
* @param deviceId 单个设备名(表名))root.ln.wf01.wt01
|
||||||
|
* @param times 时间戳的列表
|
||||||
|
* @param measurementsList 数据项列表的列表
|
||||||
|
* @param valuesList 数据项对应值列表的列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void insertStringRecordsOfOneDevice(String deviceId, List<Long> times, List<List<String>> measurementsList, List<List<String>> valuesList) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
try {
|
||||||
|
log.info("iotdb数据入库:deviceId:[{}], measurementsList:[{}], valuesList:[{}]", deviceId, measurementsList, valuesList);
|
||||||
|
sessionPool.insertStringRecordsOfOneDevice(deviceId, times, measurementsList, valuesList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession insertStringRecordsOfOneDevice失败: deviceId={}, times={}, measurementsList={}, valuesList={}, error={}",
|
||||||
|
deviceId, times, measurementsList, valuesList, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单个设备多条数据插入(不同类型数据项)
|
||||||
|
*
|
||||||
|
* @param deviceId 单个设备名(表名))root.ln.wf01.wt01
|
||||||
|
* @param times 时间戳的列表
|
||||||
|
* @param measurementsList 数据项列表的列表
|
||||||
|
* @param typesList 数据项对应类型列表的列表
|
||||||
|
* @param valuesList 数据项对应值列表的列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void insertRecordsOfOneDevice(String deviceId, List<Long> times, List<List<String>> measurementsList, List<List<TSDataType>> typesList, List<List<Object>> valuesList) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
try {
|
||||||
|
log.info("iotdb数据入库:deviceId:[{}], measurementsList:[{}], typesList:[{}], valuesList:[{}]", deviceId, measurementsList, typesList, valuesList);
|
||||||
|
sessionPool.insertRecordsOfOneDevice(deviceId, times, measurementsList, typesList, valuesList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession insertRecordsOfOneDevice失败: deviceId={}, times={}, measurementsList={}, typesList=[],valuesList={}, error={}", deviceId, times, measurementsList, typesList, valuesList, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除数据(删除一个时间序列在某个时间点前或这个时间点的数据)
|
||||||
|
*
|
||||||
|
* @param path 单个字段 root.ln.wf01.wt01.temperature
|
||||||
|
* @param endTime 删除时间点
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteData(String path, long endTime) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
try {
|
||||||
|
log.info("iotdb数据删除:path:[{}], endTime:[{}]", path, endTime);
|
||||||
|
sessionPool.deleteData(path, endTime);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession deleteData失败: deviceId={}, times={},error={}", path, endTime, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除数据(删除多个时间序列在某个时间点前或这个时间点的数据)
|
||||||
|
*
|
||||||
|
* @param paths 多个字段(表名)) root.ln.wf01.wt01.temperature
|
||||||
|
* @param endTime 删除时间点
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteData(List<String> paths, long endTime) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
try {
|
||||||
|
log.info("iotdb数据删除:paths:[{}], endTime:[{}]", paths, endTime);
|
||||||
|
sessionPool.deleteData(paths, endTime);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession deleteData失败: paths={}, times={},error={}", paths, endTime, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据查询(时间序列原始数据范围查询,时间范围为左闭右开区间,包含开始时间但不包含结束时间)
|
||||||
|
*
|
||||||
|
* @param paths 多个字段(表名)) root.ln.wf01.wt01.temperature
|
||||||
|
* @param startTime 开始时间
|
||||||
|
* @param endTime 结束时间
|
||||||
|
* @param outTime 超时时间
|
||||||
|
* @return SessionDataSet (Time,paths)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SessionDataSet executeRawDataQuery(List<String> paths, long startTime, long endTime, long outTime) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
SessionDataSetWrapper sessionDataSetWrapper = null;
|
||||||
|
try {
|
||||||
|
log.info("iotdb数据查询:paths:[{}], startTime:[{}], endTime:[{}],outTime:[{}]", paths, startTime, endTime, outTime);
|
||||||
|
sessionDataSetWrapper = sessionPool.executeRawDataQuery(paths, startTime, endTime, outTime);
|
||||||
|
return sessionDataSetWrapper.getSessionDataSet();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession executeRawDataQuery失败: paths={}, startTime:[{}], endTime:[{}],outTime:[{}],error={}", paths, startTime, endTime, outTime, e.getMessage());
|
||||||
|
} finally {
|
||||||
|
sessionPool.closeResultSet(sessionDataSetWrapper);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据查询(时间序列原始数据范围查询,时间范围为左闭右开区间,包含开始时间但不包含结束时间)
|
||||||
|
*
|
||||||
|
* @param paths 多个字段(表名)) root.ln.wf01.wt01.temperature
|
||||||
|
* @param startTime 开始时间
|
||||||
|
* @param endTime 结束时间
|
||||||
|
* @param outTime 超时时间
|
||||||
|
* @param clazz 返回数据对应的对象(对象属性必须与字段名对应)
|
||||||
|
* @param <T>
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public <T> List<T> executeRawDataQuery(List<String> paths, long startTime, long endTime, long outTime, Class<? extends IotDbRecordAble> clazz) {
|
||||||
|
SessionDataSet sessionDataSet = executeRawDataQuery(paths, startTime, endTime, outTime);
|
||||||
|
List<String> columnNames = sessionDataSet.getColumnNames();
|
||||||
|
List<T> resultEntities = null;
|
||||||
|
try {
|
||||||
|
resultEntities = packagingObjectData(sessionDataSet, columnNames, clazz);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession executeRawDataQuery失败: paths={}, startTime:[{}], endTime:[{}],outTime:[{}],error={}", paths, startTime, endTime, outTime, e.getMessage());
|
||||||
|
}
|
||||||
|
return resultEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最新点查询(查询最后一条时间戳大于等于某个时间点的数据)
|
||||||
|
*
|
||||||
|
* @param paths 多个字段(表名)) root.ln.wf01.wt01.temperature
|
||||||
|
* @param lastTime 结束时间
|
||||||
|
* @return SessionDataSet
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SessionDataSet executeLastDataQuery(List<String> paths, long lastTime) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
SessionDataSetWrapper sessionDataSetWrapper = null;
|
||||||
|
try {
|
||||||
|
log.info("iotdb数据查询:paths:[{}], lastTime:[{}]", paths, lastTime);
|
||||||
|
sessionDataSetWrapper = sessionPool.executeLastDataQuery(paths, lastTime);
|
||||||
|
return sessionDataSetWrapper.getSessionDataSet();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession executeLastDataQuery失败: paths={}, lastTime:[{}], error={}", paths, lastTime, e.getMessage());
|
||||||
|
} finally {
|
||||||
|
sessionPool.closeResultSet(sessionDataSetWrapper);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最新点查询(查询最后一条时间戳大于等于某个时间点的数据)
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
* @param paths 多个字段(表名)) root.ln.wf01.wt01.temperature
|
||||||
|
* @param lastTime 结束时间
|
||||||
|
* @param clazz 返回数据对应的对象(对象属性必须与字段名对应)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public <T> List<T> executeLastDataQuery(List<String> paths, long lastTime, Class<? extends IotDbRecordAble> clazz) {
|
||||||
|
SessionDataSet sessionDataSet = executeLastDataQuery(paths, lastTime);
|
||||||
|
List<String> columnNames = sessionDataSet.getColumnNames();
|
||||||
|
List<T> resultEntities = null;
|
||||||
|
try {
|
||||||
|
resultEntities = packagingObjectData(sessionDataSet, columnNames, clazz);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession executeLastDataQuery失败: paths={}, lastTime:[{}], error={}", paths, lastTime, e.getMessage());
|
||||||
|
}
|
||||||
|
return resultEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最新点查询(快速查询单设备下指定序列最新点)
|
||||||
|
*
|
||||||
|
* @param db root.ln.wf01
|
||||||
|
* @param device root.ln.wf01.wt01
|
||||||
|
* @param sensors temperature,status(字段名)
|
||||||
|
* @param isLegalPathNodes true(避免路径校验)
|
||||||
|
* @return SessionDataSet
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SessionDataSet executeLastDataQueryForOneDevice(String db, String device, List<String> sensors, boolean isLegalPathNodes) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
SessionDataSetWrapper sessionDataSetWrapper = null;
|
||||||
|
try {
|
||||||
|
log.info("iotdb数据查询:db:[{}], device:[{}],sensors:[{}], isLegalPathNodes:[{}]", db, device, sensors, isLegalPathNodes);
|
||||||
|
sessionDataSetWrapper = sessionPool.executeLastDataQueryForOneDevice(db, device, sensors, isLegalPathNodes);
|
||||||
|
return sessionDataSetWrapper.getSessionDataSet();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession executeLastDataQueryForOneDevice失败: db:[{}], device:[{}],sensors:[{}], isLegalPathNodes:[{}], error={}", db, device, sensors, isLegalPathNodes, e.getMessage());
|
||||||
|
} finally {
|
||||||
|
sessionPool.closeResultSet(sessionDataSetWrapper);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param db root.ln.wf01
|
||||||
|
* @param device root.ln.wf01.wt01
|
||||||
|
* @param sensors temperature,status(字段名)
|
||||||
|
* @param isLegalPathNodes true(避免路径校验)
|
||||||
|
* @param clazz 返回数据对应的对象(对象属性必须与字段名对应)
|
||||||
|
* @param <T>
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public <T> List<T> executeLastDataQueryForOneDevice(String db, String device, List<String> sensors, boolean isLegalPathNodes, Class<? extends IotDbRecordAble> clazz) {
|
||||||
|
SessionDataSet sessionDataSet = executeLastDataQueryForOneDevice(db, device, sensors, isLegalPathNodes);
|
||||||
|
List<String> columnNames = sessionDataSet.getColumnNames();
|
||||||
|
List<T> resultEntities = null;
|
||||||
|
try {
|
||||||
|
resultEntities = packagingObjectData(sessionDataSet, columnNames, clazz);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession executeLastDataQueryForOneDevice失败: db:[{}], device:[{}],sensors:[{}], isLegalPathNodes:[{}], error={}", db, device, sensors, isLegalPathNodes, e.getMessage());
|
||||||
|
}
|
||||||
|
return resultEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 聚合查询
|
||||||
|
*
|
||||||
|
* @param paths 多个字段(表名)) root.ln.wf01.wt01.temperature
|
||||||
|
* @param aggregations 聚合操作 TAggregationType.SUM,TAggregationType.COUNT
|
||||||
|
* @return SessionDataSet
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
SessionDataSetWrapper sessionDataSetWrapper = null;
|
||||||
|
try {
|
||||||
|
log.info("iotdb聚合查询:paths:[{}], aggregations:[{}]", paths, aggregations);
|
||||||
|
sessionDataSetWrapper = sessionPool.executeAggregationQuery(paths, aggregations);
|
||||||
|
return sessionDataSetWrapper.getSessionDataSet();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession executeAggregationQuery失败: paths:[{}], aggregations:[{}] ,error={}", paths, aggregations, e.getMessage());
|
||||||
|
} finally {
|
||||||
|
sessionPool.closeResultSet(sessionDataSetWrapper);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 聚合查询(时间序列原始数据范围查询,时间范围为左闭右开区间,包含开始时间但不包含结束时间)
|
||||||
|
*
|
||||||
|
* @param paths 多个字段(表名)) root.ln.wf01.wt01.temperature
|
||||||
|
* @param aggregations 聚合操作 TAggregationType.SUM,TAggregationType.COUNT
|
||||||
|
* @param startTime 开始时间(包含)
|
||||||
|
* @param endTime 结束时间
|
||||||
|
* @return SessionDataSet
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, long startTime, long endTime) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
SessionDataSetWrapper sessionDataSetWrapper = null;
|
||||||
|
try {
|
||||||
|
log.info("iotdb聚合查询:paths:[{}], aggregations:[{}],startTime:[{}], endTime:[{}]", paths, aggregations, startTime, endTime);
|
||||||
|
sessionDataSetWrapper = sessionPool.executeAggregationQuery(paths, aggregations, startTime, endTime);
|
||||||
|
return sessionDataSetWrapper.getSessionDataSet();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession executeAggregationQuery失败: paths:[{}], aggregations:[{}] ,startTime:[{}], endTime:[{}],error={}", paths, aggregations, startTime, endTime, e.getMessage());
|
||||||
|
} finally {
|
||||||
|
sessionPool.closeResultSet(sessionDataSetWrapper);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 聚合查询(支持按照时间区间分段查询)
|
||||||
|
*
|
||||||
|
* @param paths 多个字段(表名)) root.ln.wf01.wt01.temperature
|
||||||
|
* @param aggregations 聚合操作 TAggregationType.SUM,TAggregationType.COUNT
|
||||||
|
* @param startTime 开始时间(包含)
|
||||||
|
* @param endTime 结束时间
|
||||||
|
* @param interval
|
||||||
|
* @return SessionDataSet
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, long startTime, long endTime, long interval) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
SessionDataSetWrapper sessionDataSetWrapper = null;
|
||||||
|
try {
|
||||||
|
log.info("iotdb聚合查询:paths:[{}], aggregations:[{}],startTime:[{}], endTime:[{}] ,interval:[{}]", paths, aggregations, startTime, endTime, interval);
|
||||||
|
sessionDataSetWrapper = sessionPool.executeAggregationQuery(paths, aggregations, startTime, endTime, interval);
|
||||||
|
return sessionDataSetWrapper.getSessionDataSet();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession executeAggregationQuery失败: paths:[{}], aggregations:[{}] ,startTime:[{}], endTime:[{}], interval:[{}], error={}", paths, aggregations, startTime, endTime, interval, e.getMessage());
|
||||||
|
} finally {
|
||||||
|
sessionPool.closeResultSet(sessionDataSetWrapper);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 聚合查询(支持按照时间区间分段查询)
|
||||||
|
*
|
||||||
|
* @param paths 多个字段(表名)) root.ln.wf01.wt01.temperature
|
||||||
|
* @param aggregations 聚合操作 TAggregationType.SUM,TAggregationType.COUNT
|
||||||
|
* @param startTime 开始时间(包含)
|
||||||
|
* @param endTime 结束时间
|
||||||
|
* @param interval
|
||||||
|
* @param slidingStep
|
||||||
|
* @return SessionDataSet
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SessionDataSet executeAggregationQuery(List<String> paths, List<TAggregationType> aggregations, long startTime, long endTime, long interval, long slidingStep) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
SessionDataSetWrapper sessionDataSetWrapper = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.info("iotdb聚合查询:paths:[{}], aggregations:[{}],startTime:[{}], endTime:[{}] ,interval:[{}], slidingStep:[{}]", paths, aggregations, startTime, endTime, interval, slidingStep);
|
||||||
|
sessionDataSetWrapper = sessionPool.executeAggregationQuery(paths, aggregations, startTime, endTime, interval, slidingStep);
|
||||||
|
return sessionDataSetWrapper.getSessionDataSet();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession executeAggregationQuery失败: paths:[{}], aggregations:[{}] ,startTime:[{}], endTime:[{}], interval:[{}], slidingStep:[{}] ,error={}", paths, aggregations, startTime, endTime, interval, slidingStep, e.getMessage());
|
||||||
|
} finally {
|
||||||
|
sessionPool.closeResultSet(sessionDataSetWrapper);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SQL查询
|
||||||
|
*
|
||||||
|
* @param sql
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SessionDataSet executeQueryStatement(String sql) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
SessionDataSetWrapper sessionDataSetWrapper = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.info("iotdb SQL查询:sql:[{}]", sql);
|
||||||
|
sessionDataSetWrapper = sessionPool.executeQueryStatement(sql);
|
||||||
|
return sessionDataSetWrapper.getSessionDataSet();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession executeQueryStatement失败:sql:[{}],error={}", sql, e.getMessage());
|
||||||
|
} finally {
|
||||||
|
sessionPool.closeResultSet(sessionDataSetWrapper);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SQL非查询
|
||||||
|
*
|
||||||
|
* @param sql
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void executeNonQueryStatement(String sql) {
|
||||||
|
SessionPool sessionPool = iotDBSessionConfig.getSessionPool();
|
||||||
|
try {
|
||||||
|
log.info("iotdb SQL无查询:sql:[{}]", sql);
|
||||||
|
sessionPool.executeNonQueryStatement(sql);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("IotDBSession executeNonQueryStatement失败:sql:[{}],error={}", sql, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 封装处理数据
|
||||||
|
*
|
||||||
|
* @param sessionDataSet
|
||||||
|
* @param titleList
|
||||||
|
*/
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> packagingMapData(SessionDataSet sessionDataSet, List<String> titleList) {
|
||||||
|
int fetchSize = sessionDataSet.getFetchSize();
|
||||||
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||||
|
titleList.remove("Time");
|
||||||
|
if (fetchSize > 0) {
|
||||||
|
while (sessionDataSet.hasNext()) {
|
||||||
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
RowRecord next = sessionDataSet.next();
|
||||||
|
List<Field> fields = next.getFields();
|
||||||
|
String timeString = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(next.getTimestamp());
|
||||||
|
resultMap.put("time", timeString);
|
||||||
|
for (int i = 0; i < fields.size(); i++) {
|
||||||
|
Field field = fields.get(i);
|
||||||
|
if (field.getDataType() == null || field.getObjectValue(field.getDataType()) == null) {
|
||||||
|
resultMap.put(splitString(titleList.get(i)), null);
|
||||||
|
} else {
|
||||||
|
resultMap.put(splitString(titleList.get(i)), field.getObjectValue(field.getDataType()).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resultList.add(resultMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 封装处理数据(不支持聚合查询)
|
||||||
|
*
|
||||||
|
* @param sessionDataSet 查询返回的结果集
|
||||||
|
* @param titleList 查询返回的结果集内的字段名
|
||||||
|
* @param clazz 返回数据对应的对象(对象属性必须与字段名对应)
|
||||||
|
* @param <T>
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public <T> List<T> packagingObjectData(SessionDataSet sessionDataSet, List<String> titleList, Class<? extends IotDbRecordAble> clazz) {
|
||||||
|
int fetchSize = sessionDataSet.getFetchSize();
|
||||||
|
List<T> resultList = new ArrayList<>();
|
||||||
|
titleList.remove("Time");
|
||||||
|
if (fetchSize > 0) {
|
||||||
|
while (sessionDataSet.hasNext()) {
|
||||||
|
Map<String, Object> resultMap = new HashMap<>();
|
||||||
|
RowRecord next = sessionDataSet.next();
|
||||||
|
List<Field> fields = next.getFields();
|
||||||
|
String timeString = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(next.getTimestamp());
|
||||||
|
resultMap.put("time", timeString);
|
||||||
|
if (titleList.stream().anyMatch(str -> str.contains("."))) {
|
||||||
|
for (int i = 0; i < fields.size(); i++) {
|
||||||
|
Field field = fields.get(i);
|
||||||
|
String title = titleList.get(i);
|
||||||
|
if (field.getDataType() == null || field.getObjectValue(field.getDataType()) == null) {
|
||||||
|
resultMap.put(splitString(title), null);
|
||||||
|
} else {
|
||||||
|
resultMap.put(splitString(title), field.getObjectValue(field.getDataType()).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Field fieldName = fields.get(0);
|
||||||
|
Field fieldValue = fields.get(1);
|
||||||
|
Field fieldDataType = fields.get(2);
|
||||||
|
if (fieldName.getDataType() != null && fieldName.getObjectValue(fieldName.getDataType()) != null) {
|
||||||
|
String mapKey = fieldName.getObjectValue(fieldName.getDataType()).toString();
|
||||||
|
Object mapValue = convertStringToType(fieldValue.getObjectValue(fieldValue.getDataType()).toString(), fieldDataType.getObjectValue(fieldDataType.getDataType()).toString());
|
||||||
|
resultMap.put(splitString(mapKey), mapValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String jsonString = JSON.toJSONString(resultMap);
|
||||||
|
resultList.add(JSON.parseObject(jsonString, (Type) clazz));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分割获取字段名
|
||||||
|
*
|
||||||
|
* @param str
|
||||||
|
* @return 字段名
|
||||||
|
*/
|
||||||
|
public static String splitString(String str) {
|
||||||
|
String[] parts = str.split("\\.");
|
||||||
|
if (parts.length <= 0) {
|
||||||
|
return str;
|
||||||
|
} else {
|
||||||
|
return parts[parts.length - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据数据值和数据类型返回对应数据类型数据
|
||||||
|
*
|
||||||
|
* @param value 数据值
|
||||||
|
* @param typeName 数据类型
|
||||||
|
* @return 转换后的数据值
|
||||||
|
*/
|
||||||
|
public static Object convertStringToType(String value, String typeName) {
|
||||||
|
String type = typeName.toLowerCase();
|
||||||
|
if (type.isEmpty()) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
if ("boolean".equals(type)) {
|
||||||
|
return Boolean.parseBoolean(value);
|
||||||
|
} else if ("double".equals(type)) {
|
||||||
|
return Double.parseDouble(value);
|
||||||
|
} else if ("int32".equals(type)) {
|
||||||
|
return Integer.parseInt(value);
|
||||||
|
} else if ("int64".equals(type)) {
|
||||||
|
return Long.parseLong(value);
|
||||||
|
} else if ("float".equals(type)) {
|
||||||
|
return Float.parseFloat(value);
|
||||||
|
} else if ("text".equals(type)) {
|
||||||
|
return value;
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据对象属性的数据类型返回对应的TSDataType
|
||||||
|
*
|
||||||
|
* @param type 属性的数据类型
|
||||||
|
* @return TSDataType
|
||||||
|
*/
|
||||||
|
public static TSDataType getTsDataTypeByString(String type) {
|
||||||
|
String typeName = splitString(type).toLowerCase();
|
||||||
|
if ("boolean".equals(typeName)) {
|
||||||
|
return TSDataType.BOOLEAN;
|
||||||
|
} else if ("double".equals(typeName)) {
|
||||||
|
return TSDataType.DOUBLE;
|
||||||
|
} else if ("int".equals(typeName) || "integer".equals(typeName)) {
|
||||||
|
return TSDataType.INT32;
|
||||||
|
} else if ("long".equals(typeName)) {
|
||||||
|
return TSDataType.INT64;
|
||||||
|
} else if ("float".equals(typeName)) {
|
||||||
|
return TSDataType.FLOAT;
|
||||||
|
} else if ("text".equals(typeName)) {
|
||||||
|
return TSDataType.TEXT;
|
||||||
|
} else if ("string".equals(typeName)) {
|
||||||
|
return TSDataType.TEXT;
|
||||||
|
} else {
|
||||||
|
return TSDataType.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据对象构建MeasurementSchemas
|
||||||
|
*
|
||||||
|
* @param obj 对象
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<MeasurementSchema> buildMeasurementSchemas(Object obj) {
|
||||||
|
java.lang.reflect.Field[] fields = obj.getClass().getDeclaredFields();
|
||||||
|
List<MeasurementSchema> schemaList = Arrays.stream(fields).map(field ->
|
||||||
|
new MeasurementSchema(field.getName(),
|
||||||
|
getTsDataTypeByString(
|
||||||
|
field.getType().getName()
|
||||||
|
))).
|
||||||
|
collect(Collectors.toList());
|
||||||
|
return schemaList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据对象构建MeasurementSchemaValuesDTO
|
||||||
|
*
|
||||||
|
* @param obj 对象
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public MeasurementSchemaValuesDTO buildMeasurementSchemasAndValues(Object obj) {
|
||||||
|
MeasurementSchemaValuesDTO measurementSchemaValuesDTO = new MeasurementSchemaValuesDTO();
|
||||||
|
java.lang.reflect.Field[] fields = obj.getClass().getDeclaredFields();
|
||||||
|
List<MeasurementSchema> schemaList = new ArrayList<>();
|
||||||
|
List<Object> values = new ArrayList<>();
|
||||||
|
List<Integer> valuesIsNullIndex = new ArrayList<>();
|
||||||
|
int valueIndex = 0;
|
||||||
|
for (java.lang.reflect.Field field : fields) {
|
||||||
|
MeasurementSchema measurementSchema = new MeasurementSchema(field.getName(), getTsDataTypeByString(field.getType().getName()));
|
||||||
|
schemaList.add(measurementSchema);
|
||||||
|
Object value = field.get(obj);
|
||||||
|
if (value == null) {
|
||||||
|
valuesIsNullIndex.add(valueIndex);
|
||||||
|
}
|
||||||
|
values.add(value);
|
||||||
|
valueIndex++;
|
||||||
|
}
|
||||||
|
measurementSchemaValuesDTO.setSchemaList(schemaList);
|
||||||
|
measurementSchemaValuesDTO.setValues(values);
|
||||||
|
return measurementSchemaValuesDTO;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
com.muyu.data.iotdb.config.IotDBSessionConfig
|
|
@ -17,6 +17,10 @@
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
cloud-common-kafka kafka公共模块
|
||||||
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- 项目公共核心模块 -->
|
<!-- 项目公共核心模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
cloud-common-rabbit 消息队列服务
|
||||||
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- rabbitMq 消息队列 -->
|
<!-- rabbitMq 消息队列 -->
|
||||||
|
@ -28,8 +32,8 @@
|
||||||
<!-- 项目公共核心 -->
|
<!-- 项目公共核心 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.muyu</groupId>
|
<groupId>com.muyu</groupId>
|
||||||
<artifactId>cloud-common-core</artifactId>
|
<artifactId>cloud-common-redis</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
package com.muyu.common.rabbit;
|
|
||||||
|
|
||||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
|
||||||
import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
|
|
||||||
import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class RabbitListenerConfigurer implements org.springframework.amqp.rabbit.annotation.RabbitListenerConfigurer {
|
|
||||||
|
|
||||||
static {
|
|
||||||
System.setProperty("spring.amqp.deserialization.trust.all", "true");
|
|
||||||
}
|
|
||||||
|
|
||||||
//以下配置RabbitMQ消息服务
|
|
||||||
@Autowired
|
|
||||||
public ConnectionFactory connectionFactory;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理器方法工厂
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public DefaultMessageHandlerMethodFactory handlerMethodFactory() {
|
|
||||||
DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
|
|
||||||
// 这里的转换器设置实现了 通过 @Payload 注解 自动反序列化message body
|
|
||||||
factory.setMessageConverter(new MappingJackson2MessageConverter());
|
|
||||||
return factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configureRabbitListeners(RabbitListenerEndpointRegistrar rabbitListenerEndpointRegistrar) {
|
|
||||||
rabbitListenerEndpointRegistrar.setMessageHandlerMethodFactory(handlerMethodFactory());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
package com.muyu.common.rabbit.config;
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.common.rabbit.constants.RabbitmqConstants;
|
||||||
|
import org.springframework.amqp.core.*;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: DelayedQueueConfig
|
||||||
|
* @Description: 延迟队列配置类
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class DelayedQueueConfig {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RabbitAdmin rabbitAdmin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 声明队列
|
||||||
|
* @return 返回队列
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public Queue delayedQueue() {
|
||||||
|
Queue queue = new Queue(RabbitmqConstants.DELAYED_QUEUE_NAME);
|
||||||
|
rabbitAdmin.declareQueue(queue);
|
||||||
|
return queue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 声明交换机
|
||||||
|
* @return 返回交换机
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public Exchange delayedExchange() {
|
||||||
|
HashMap<String, Object> arguments = new HashMap<>(3);
|
||||||
|
|
||||||
|
arguments.put("x-delayed-type", "direct");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 声明自定义交换机
|
||||||
|
* 第一个参数:交换机的名称
|
||||||
|
* 第二个参数:交换机的类型
|
||||||
|
* 第三个参数:是否需要持久化
|
||||||
|
* 第四个参数:是否自动删除
|
||||||
|
* 第五个参数:其他参数
|
||||||
|
*/
|
||||||
|
CustomExchange customExchange = new CustomExchange(
|
||||||
|
RabbitmqConstants.DELAYED_EXCHANGE_NAME,
|
||||||
|
"x-delayed-message",
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
arguments);
|
||||||
|
rabbitAdmin.declareExchange(customExchange);
|
||||||
|
return customExchange;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定交换机
|
||||||
|
* @param delayedQueue 队列对象
|
||||||
|
* @param delayedExchange 交换机对象
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public Binding delayedQueueBindingDelayedExchange(
|
||||||
|
@Qualifier("delayedQueue") Queue delayedQueue,
|
||||||
|
@Qualifier("delayedExchange") Exchange delayedExchange) {
|
||||||
|
|
||||||
|
Binding noargs = BindingBuilder.bind(delayedQueue)
|
||||||
|
.to(delayedExchange)
|
||||||
|
.with(RabbitmqConstants.DELAYED_ROUTING_KEY)
|
||||||
|
.noargs();
|
||||||
|
rabbitAdmin.declareBinding(noargs);
|
||||||
|
return noargs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.muyu.common.rabbit.config;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName:
|
||||||
|
* @Description: 消息发送到 交换机的确认 回调方法
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class MyConfirmCallback implements RabbitTemplate.ConfirmCallback {
|
||||||
|
|
||||||
|
|
||||||
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
// public MyConfirmCallback(RabbitTemplate rabbitTemplate) {
|
||||||
|
// this.rabbitTemplate = rabbitTemplate;
|
||||||
|
// // 设置 消息发送到交换机成功 的回调
|
||||||
|
// this.rabbitTemplate.setConfirmCallback(this);
|
||||||
|
// }
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
this.rabbitTemplate.setConfirmCallback(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送消息到交换机的回调方法 消息发送成功或者失败都会执行
|
||||||
|
*
|
||||||
|
* @param correlationData correlation data for the callback. 消息的元数据
|
||||||
|
* @param ack true for ack, false for nack
|
||||||
|
* @param cause An optional cause, for nack, when available, otherwise null.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
|
||||||
|
if (ack) {
|
||||||
|
System.out.println("消息发送到交换机成功~");
|
||||||
|
} else {
|
||||||
|
System.out.println("消息发送到交换机失败,失败的原因:" + cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.muyu.common.rabbit.config;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
||||||
|
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: RabbitAdminConfig
|
||||||
|
* @Description: RabbitAdmin配置类
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class RabbitAdminConfig {
|
||||||
|
@Value("${spring.rabbitmq.host}")
|
||||||
|
private String host;
|
||||||
|
@Value("${spring.rabbitmq.username}")
|
||||||
|
private String username;
|
||||||
|
@Value("${spring.rabbitmq.password}")
|
||||||
|
private String password;
|
||||||
|
@Value("${spring.rabbitmq.virtualhost}")
|
||||||
|
private String virtualHost;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ConnectionFactory connectionFactory() {
|
||||||
|
CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
|
||||||
|
cachingConnectionFactory.setHost(host);
|
||||||
|
cachingConnectionFactory.setUsername(username);
|
||||||
|
cachingConnectionFactory.setPassword(password);
|
||||||
|
cachingConnectionFactory.setVirtualHost(virtualHost);
|
||||||
|
return cachingConnectionFactory;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RabbitAdmin rabbitAdmin(ConnectionFactory connectionFactory) {
|
||||||
|
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
|
||||||
|
rabbitAdmin.setAutoStartup(true);
|
||||||
|
return rabbitAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.muyu.common.rabbit.config;
|
||||||
|
|
||||||
|
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||||
|
import org.springframework.amqp.support.converter.MessageConverter;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON 消息转换器 自动将发送的消息转换成 json 字符串 并且 消费者接收到消息的时候自动反序列化 成需要的对象
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class RabbitmqConfig {
|
||||||
|
|
||||||
|
|
||||||
|
// 消息转换配置
|
||||||
|
@Bean
|
||||||
|
public MessageConverter jsonMessageConverter() {
|
||||||
|
return new Jackson2JsonMessageConverter();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.muyu.common.rabbit.config;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.amqp.core.ReturnedMessage;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息发送到 队列的确认
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ReturnCallbackConfig implements RabbitTemplate.ReturnsCallback {
|
||||||
|
|
||||||
|
|
||||||
|
private final RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
@PostConstruct // @PostContruct是spring框架的注解,在⽅法上加该注解会在项⽬启动的时候执⾏该⽅法,也可以理解为在spring容器初始化的时候执
|
||||||
|
public void init() {
|
||||||
|
rabbitTemplate.setReturnsCallback(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息发送到 队列失败的时候执行
|
||||||
|
*
|
||||||
|
* @param returnedMessage the returned message and metadata.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void returnedMessage(ReturnedMessage returnedMessage) {
|
||||||
|
System.out.println("消息" + returnedMessage.getMessage().toString() +
|
||||||
|
"被交换机" + returnedMessage.getExchange() + "回退!"
|
||||||
|
+ "退回原因为:" + returnedMessage.getReplyText());
|
||||||
|
// 回退了所有的信息,可做补偿机制 记录发送的日志
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.common.rabbit.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: WangXin
|
||||||
|
* @date: 2024/7/10
|
||||||
|
* @Description: rabbitmq常量
|
||||||
|
* @Version 1.0.0
|
||||||
|
*/
|
||||||
|
public class RabbitmqConstants {
|
||||||
|
|
||||||
|
//普通队列
|
||||||
|
public static final String BASIC_QUEUE_NAME = "BASIC_QUEUE_NAME";
|
||||||
|
|
||||||
|
public static final String lOG_QUEUE_NAME = "LOG_QUEUE_NAME";
|
||||||
|
//延迟队列
|
||||||
|
//队列名称
|
||||||
|
public static final String DELAYED_QUEUE_NAME = "delayed_queue";
|
||||||
|
//交换机名称
|
||||||
|
public static final String DELAYED_EXCHANGE_NAME = "DELAYED_EXCHANGE";
|
||||||
|
//交换机
|
||||||
|
public static final String DELAYED_ROUTING_KEY = "delayed";
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
package com.muyu.common.rabbit.consumer;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.muyu.common.redis.service.RedisService;
|
||||||
|
import com.rabbitmq.client.Channel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.amqp.core.Message;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: RabbitMQConsumerUtil
|
||||||
|
* @Description: rabbitmq消费者
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Log4j2
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class RabbitMQConsumerUtil {
|
||||||
|
|
||||||
|
private final RedisService redisService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 普通消费者
|
||||||
|
* @param data 数据类型
|
||||||
|
* @param message
|
||||||
|
* @param channel
|
||||||
|
*/
|
||||||
|
public void rabbitMQBasicConsumer(Object data ,Message message , Channel channel) {
|
||||||
|
log.info("当前时间:{} :RabbitMQConsumerUtil : {}", new Date(), message);
|
||||||
|
try {
|
||||||
|
// 获取到消息 开始消费
|
||||||
|
log.info("消息消费者接收到消息,消息内容:{}", JSONObject.toJSONString(data));
|
||||||
|
|
||||||
|
|
||||||
|
Long add = redisService.redisTemplate.opsForSet().add(data, message.getMessageProperties().getMessageId());
|
||||||
|
|
||||||
|
if (add != 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -----------------------------------以下为异步业务操作----------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
// 消费消息成功之后需要确认
|
||||||
|
// long deliveryTag 消息投递序号 自增的数字 在整个队列中唯一 拿到这个序号就相当于拿到这条消息
|
||||||
|
// boolean multiple 是否批量确认 true 批量 确认小于等于当前投递序号的消息 false 单个确认
|
||||||
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||||
|
log.info("xxx消费者接收到消息,消息内容:{},消费成功...", message);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("xxx消费者接收到消息,消息内容:{},消费消息异常,异常信息:{}", message, e);
|
||||||
|
// 消息回退 拒绝消费消息
|
||||||
|
// long deliveryTag 消息投递序号 自增的数字 在整个队列中唯一 拿到这个序号就相当于拿到这条消息
|
||||||
|
// boolean requeue 是否回到原来的队列
|
||||||
|
try {
|
||||||
|
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
|
||||||
|
// channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
log.error("xxx消费者接收到消息,消息内容:{},回退消息异常,异常信息:{}", message, ex);
|
||||||
|
}
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
channel.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("xxx消费者关闭Channel异常,消息内容:{},异常信息:{}", message, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,174 @@
|
||||||
|
package com.muyu.common.rabbit.producer;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.rabbit.constants.RabbitmqConstants;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.amqp.core.MessageProperties;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: RabbitMQProducer
|
||||||
|
* @Description: rabbitmq生产者
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Log4j2
|
||||||
|
public class RabbitMQProducerUtil {
|
||||||
|
//redis工具类对象
|
||||||
|
|
||||||
|
//rabbit
|
||||||
|
private final RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 简单模型
|
||||||
|
*
|
||||||
|
* @param param 传递的消息 (如果是对象需要序列化)
|
||||||
|
* @return 结果集
|
||||||
|
* 一对一消费,只有一个消费者能接收到
|
||||||
|
*/
|
||||||
|
public Result<?> basicSendMessage(String queueName, Object param, String msg) {
|
||||||
|
|
||||||
|
log.info("【简单模型mq】 : method: 【 basicSendMessage 】 - ages: 【 String : {}, Object : {}, String : {} 】 ---> 【 消息发送中。。。 】", RabbitmqConstants.BASIC_QUEUE_NAME, param, msg);
|
||||||
|
// 发送简单模型消息
|
||||||
|
// 第一个参数: 绑定规则 相当于 队列名称
|
||||||
|
// 第二个参数:消息内容
|
||||||
|
rabbitTemplate.convertAndSend(queueName, param, message -> {
|
||||||
|
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||||
|
return message;
|
||||||
|
} );
|
||||||
|
|
||||||
|
log.info("【简单模型mq】 : method: 【 basicSendMessage 】- queue: 【 {} 】 ---> 【 消息发送成功 】", RabbitmqConstants.BASIC_QUEUE_NAME);
|
||||||
|
|
||||||
|
return Result.success(msg!=null?msg:"消息发送成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Work queue 工作模型
|
||||||
|
*
|
||||||
|
* @param obj 传递的消息 (如果是对象需要序列化)
|
||||||
|
* @return 结果集
|
||||||
|
* 多个消费者,你一个我一个分配消费消息,有预取机制,默认公平消费,可配置 能者多劳模式(),谁完成的快,谁多做一点
|
||||||
|
*/
|
||||||
|
public Result<?> workSendMessage(String queueName, Object obj, String msg) {
|
||||||
|
|
||||||
|
log.info("【工作模型mq】 : method: 【 workSendMessage 】 - ages: 【 String : {}, Object : {}, String : {} 】 ---> 【 消息发送中。。。 】", queueName, obj, msg);
|
||||||
|
// 发送简单模型消息
|
||||||
|
// 第一个参数: 绑定规则 相当于 队列名称
|
||||||
|
// 第二个参数:消息内容
|
||||||
|
rabbitTemplate.convertAndSend(queueName, obj, message -> {
|
||||||
|
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||||
|
return message;
|
||||||
|
} );
|
||||||
|
|
||||||
|
log.info("【工作模型mq】 : method: 【 workSendMessage 】- queue: 【 {} 】 ---> 【 消息发送成功 】", queueName);
|
||||||
|
|
||||||
|
return Result.success("消息发送成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Publish/Subscribe 发布订阅者模型
|
||||||
|
* 多个消费者,多个消费者可以同时接收到消息 有交换机 类型 fanout
|
||||||
|
*
|
||||||
|
* @param exchange 交换机名称
|
||||||
|
* @param obj 发送的消息Object
|
||||||
|
* @param msg 响应的内容
|
||||||
|
* @return 结果集
|
||||||
|
*/
|
||||||
|
public Result<?> publishSubscribeSendMessage(String exchange, Object obj, String msg) {
|
||||||
|
|
||||||
|
log.info("【订阅模型mq】 : method: 【 workSendMessage 】 - ages: 【 String : {}, Object : {}, String : {} 】 ---> 【 消息发送中。。。 】", exchange, obj, msg);
|
||||||
|
// 发送简单模型消息
|
||||||
|
// 第一个参数: exchange 交换机的名称
|
||||||
|
// 第二个参数: 绑定规则 发布订阅者模型 不写 默认 "" 只要绑定就行 不需要规则
|
||||||
|
// 第三个参数:消息内容
|
||||||
|
rabbitTemplate.convertAndSend(exchange, "", obj, message -> {
|
||||||
|
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||||
|
return message;
|
||||||
|
} );
|
||||||
|
|
||||||
|
log.info("【订阅模型mq】 : method: 【 workSendMessage 】- exchange: 【 {} 】 ---> 【 消息发送成功 】", exchange);
|
||||||
|
|
||||||
|
return Result.success("消息发送成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Routing路由模型
|
||||||
|
* 使用的是 Direct 类型的交换机,会将接收到的消息根据 规则 路由到指定的Queue(队列),因此称为路由模式
|
||||||
|
*
|
||||||
|
* @param exchange 交换机名称
|
||||||
|
* @param rule 绑定规则 一个字符串即可
|
||||||
|
* @param obj 发送的消息Object
|
||||||
|
* @param msg 响应的内容
|
||||||
|
* @return 结果集
|
||||||
|
*/
|
||||||
|
public Result<?> routingSendMessage(String exchange, String rule, Object obj, String msg) {
|
||||||
|
|
||||||
|
log.info("【路由模型mq】 : method: 【 workSendMessage 】 - ages: 【 String : {}, Object : {}, String : {} 】 ---> 【 消息发送中。。。 】", exchange, obj, msg);
|
||||||
|
// 发送简单模型消息
|
||||||
|
// 第一个参数: 绑定规则 相当于 队列名称
|
||||||
|
// 第二个参数:消息内容
|
||||||
|
rabbitTemplate.convertAndSend(exchange, rule, obj, message -> {
|
||||||
|
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||||
|
return message;
|
||||||
|
} );
|
||||||
|
|
||||||
|
log.info("【路由模型mq】 : method: 【 workSendMessage 】- exchange: 【 {} 】 ---> 【 消息发送成功 】", exchange);
|
||||||
|
|
||||||
|
return Result.success("消息发送成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Topic主题模型模型
|
||||||
|
* 使用的是 topic 类型的交换机
|
||||||
|
*
|
||||||
|
* @param exchange 交换机名称
|
||||||
|
* @param rule 绑定规则 可以绑定多个单词以 . 拼接 也可以使用 #(匹配 零个 一个 或 多个 单词) 或 *(匹配 一个 单词) 通配符(例如:name.msg, *.msg, age.# )
|
||||||
|
* @param obj 发送的消息Object
|
||||||
|
* @param msg 响应的内容
|
||||||
|
* @return 结果集
|
||||||
|
*/
|
||||||
|
public Result<?> topicSendMessage(String exchange, String rule, Object obj, String msg) {
|
||||||
|
|
||||||
|
log.info("【主题模型mq】 : method: 【 workSendMessage 】 - ages: 【 String : {}, Object : {}, String : {} 】 ---> 【 消息发送中。。。 】", exchange, obj, msg);
|
||||||
|
// 发送简单模型消息
|
||||||
|
// 第一个参数: 绑定规则 相当于 队列名称
|
||||||
|
// 第二个参数:消息内容
|
||||||
|
rabbitTemplate.convertAndSend(exchange, rule, obj, message -> {
|
||||||
|
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
|
||||||
|
return message;
|
||||||
|
} );
|
||||||
|
|
||||||
|
log.info("【主题模型mq】 : method: 【 workSendMessage 】- exchange: 【 {} 】 ---> 【 消息发送成功 】", exchange);
|
||||||
|
|
||||||
|
return Result.success(obj,"消息发送成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 延迟队列模型
|
||||||
|
* @param param 传输内容
|
||||||
|
* @param delayTime 延迟时间
|
||||||
|
* @return 结果集
|
||||||
|
*/
|
||||||
|
public Result<?> delayedSendMessage(Long delayTime, Object param) {
|
||||||
|
log.info("【延迟队列模型】 : method: 【 delayedSendMessage 】 消息内容:{}---> 【 消息发送中。。。 】",param);
|
||||||
|
|
||||||
|
rabbitTemplate.convertAndSend(RabbitmqConstants.DELAYED_EXCHANGE_NAME, RabbitmqConstants.DELAYED_ROUTING_KEY,param, message -> {
|
||||||
|
MessageProperties messageProperties = message.getMessageProperties();
|
||||||
|
messageProperties.setMessageId(UUID.randomUUID().toString());
|
||||||
|
messageProperties.setDelayLong(delayTime);
|
||||||
|
return message;
|
||||||
|
});
|
||||||
|
log.info("【延迟队列模型】 : method: 【 delayedSendMessage 】 消息内容:{}---> 【 消息发送成功 】",param);
|
||||||
|
|
||||||
|
return Result.success(param,"消息发送成功");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1 +1,7 @@
|
||||||
com.muyu.common.rabbit.RabbitListenerConfigurer
|
com.muyu.rabbitmq.producer.RabbitMQProducerUtil
|
||||||
|
com.muyu.rabbitmq.consumer.RabbitMQConsumerUtil
|
||||||
|
com.muyu.rabbitmq.config.RabbitmqConfig
|
||||||
|
com.muyu.rabbitmq.config.MyConfirmCallback
|
||||||
|
com.muyu.rabbitmq.config.DelayedQueueConfig
|
||||||
|
com.muyu.rabbitmq.config.RabbitAdminConfig
|
||||||
|
com.muyu.rabbitmq.config.ReturnCallbackConfig
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
<module>cloud-common-xxl</module>
|
<module>cloud-common-xxl</module>
|
||||||
<module>cloud-common-rabbit</module>
|
<module>cloud-common-rabbit</module>
|
||||||
<module>cloud-common-kafka</module>
|
<module>cloud-common-kafka</module>
|
||||||
|
<module>cloud-common-cache</module>
|
||||||
|
<module>cloud-common-iotdb</module>
|
||||||
<module>cloud-common-caffeine</module>
|
<module>cloud-common-caffeine</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
package com.muyu;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateTime;
|
|
||||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
|
|
||||||
import javax.xml.crypto.Data;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: SysCarFaultApplication ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/21 11:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
@EnableCustomConfig
|
|
||||||
@EnableMyFeignClients
|
|
||||||
@SpringBootApplication
|
|
||||||
public class SysCarFaultApplication {
|
|
||||||
public static void main (String[] args) throws ParseException {
|
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+08"));
|
|
||||||
String format = simpleDateFormat.format(new Date());
|
|
||||||
System.out.println("故障模块启动成功"+format);
|
|
||||||
SpringApplication.run(SysCarFaultApplication.class, args);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package com.muyu.fault.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.fault.service.CarTypeService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: CarTypeController ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 22:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@RequestMapping("/cartype")
|
|
||||||
@RestController
|
|
||||||
public class CarTypeController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CarTypeService carTypeService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆类型
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
@Operation(summary = "车辆类型",description = "车辆类型信息")
|
|
||||||
public Result carTypeList(){
|
|
||||||
return Result.success(carTypeService.selectcarType());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,92 +0,0 @@
|
||||||
package com.muyu.fault.controller;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.fault.domain.req.FaultCodeAddReq;
|
|
||||||
import com.muyu.fault.domain.req.FaultCodeListReq;
|
|
||||||
import com.muyu.fault.domain.req.FaultCodeUpdReq;
|
|
||||||
import com.muyu.fault.domain.resp.FaultCodeTotalListResp;
|
|
||||||
import com.muyu.fault.service.FaultCodeService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: CarTypeController ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 22:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 车辆故障码
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/faultcode")
|
|
||||||
public class FaultCodeController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FaultCodeService faultCodeService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障码展示(仅故障码单表)
|
|
||||||
* @param faultCodeListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping(path = "/list")
|
|
||||||
@Operation(summary = "故障码列表(单)",description = "展示故障码信息")
|
|
||||||
public Result<FaultCodeTotalListResp> selectlist(@Validated @RequestBody FaultCodeListReq faultCodeListReq){
|
|
||||||
return Result.success(faultCodeService.selectlist(faultCodeListReq));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障码展示(故障码联查)
|
|
||||||
* @param faultCodeListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/faultcodelist")
|
|
||||||
@Operation(summary = "故障码列表(多)",description = "展示故障码信息")
|
|
||||||
public Result<FaultCodeTotalListResp> selectfaultcodelist(@Validated @RequestBody FaultCodeListReq faultCodeListReq){
|
|
||||||
return Result.success(faultCodeService.selectfaultcodelist(faultCodeListReq));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增故障码
|
|
||||||
* @param faultCodeAddReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/faultcodeadd")
|
|
||||||
@Operation(summary = "新增故障码",description = "新增故障码信息")
|
|
||||||
public Result insertfaultcode(@Validated @RequestBody FaultCodeAddReq faultCodeAddReq){
|
|
||||||
faultCodeService.insert(faultCodeAddReq);
|
|
||||||
return Result.success(null,"新增成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改故障码
|
|
||||||
* @param faultCodeUpdReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/faultcodeupd")
|
|
||||||
@Operation(summary = "修改故障码",description = "修改故障码信息")
|
|
||||||
public Result updfaultcode(@Validated @RequestBody FaultCodeUpdReq faultCodeUpdReq){
|
|
||||||
faultCodeService.upd(faultCodeUpdReq);
|
|
||||||
return Result.success(null,"修改成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除故障码
|
|
||||||
* @param messageTypeId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/faultcodedel/{messageTypeId}")
|
|
||||||
@Operation(summary = "删除故障码",description = "删除故障码信息")
|
|
||||||
public Result delfaultcode(@PathVariable("messageTypeId") Integer messageTypeId){
|
|
||||||
faultCodeService.del(messageTypeId);
|
|
||||||
return Result.success(null,"删除成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,92 +0,0 @@
|
||||||
package com.muyu.fault.controller;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.fault.domain.FaultCondition;
|
|
||||||
import com.muyu.fault.domain.req.FaultConditionAddReq;
|
|
||||||
import com.muyu.fault.domain.req.FaultConditionListReq;
|
|
||||||
import com.muyu.fault.domain.req.FaultConditionUpdReq;
|
|
||||||
import com.muyu.fault.service.FaultConditionService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: CarTypeController ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 22:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/faultcondition")
|
|
||||||
public class FaultConditionController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FaultConditionService faultConditionService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障规则
|
|
||||||
* @param faultConditionListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
@Operation(summary = "故障规则列表展示",description = "故障规则列表展示")
|
|
||||||
public Result getfaultrulelist(@RequestBody @Validated FaultConditionListReq faultConditionListReq){
|
|
||||||
return Result.success(faultConditionService.getfaultrulelist(faultConditionListReq));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障规则添加
|
|
||||||
* @param faultConditionAddReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/faultconditionadd")
|
|
||||||
@Operation(summary = "添加规则",description = "添加故障规则")
|
|
||||||
public Result faultconditionadd(@RequestBody FaultConditionAddReq faultConditionAddReq){
|
|
||||||
//判断车辆类型是否已存在所对应的故障规则
|
|
||||||
List<FaultCondition> faultConditionList = faultConditionService.selectBytypeAndlabel(faultConditionAddReq);
|
|
||||||
if (faultConditionList.size()>0){
|
|
||||||
return Result.error("此车辆类型已存在所对应的故障规则,无需重新制定,可在原规则上进行修改");
|
|
||||||
}
|
|
||||||
faultConditionService.save(FaultCondition.faultConditionadd(faultConditionAddReq));
|
|
||||||
return Result.success(null,"规则制定成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障规则修改
|
|
||||||
* @param
|
|
||||||
* @param faultConditionUpdReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/faultconditionupd")
|
|
||||||
@Operation(summary = "修改规则",description = "修改故障规则")
|
|
||||||
public Result faultconditionupd(
|
|
||||||
@RequestBody @Validated FaultConditionUpdReq faultConditionUpdReq){
|
|
||||||
faultConditionService.updateById(FaultCondition.faultConditionupd(faultConditionUpdReq,()->faultConditionUpdReq.getCarconditionId()));
|
|
||||||
return Result.success(null,"规则修改成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障规则删除
|
|
||||||
* @param carconditionId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/faultconditiondel/{carconditionId}")
|
|
||||||
@Operation(summary = "删除规则",description = "删除故障规则")
|
|
||||||
public Result faultconditiondel(@PathVariable("carconditionId") long carconditionId){
|
|
||||||
faultConditionService.removeById(carconditionId);
|
|
||||||
return Result.success(null,"规则删除成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
package com.muyu.fault.controller;
|
|
||||||
|
|
||||||
import com.muyu.fault.service.FaultDetectionStrategyService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultDetectionStrategyController ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 22:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 车辆故障码
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/faultdetectionstrategy")
|
|
||||||
public class FaultDetectionStrategyController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FaultDetectionStrategyService faultDetectionStrategyService;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package com.muyu.fault.controller;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.fault.service.FaultLabelService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障码分类
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/faultlabel")
|
|
||||||
public class FaultLabelController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FaultLabelService faultLabelService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障名称
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
@Operation(summary = "故障名称查询",description = "故障名称信息")
|
|
||||||
public Result findfaulttype(){
|
|
||||||
return Result.success(faultLabelService.select());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package com.muyu.fault.controller;
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.fault.domain.req.FaultLogListReq;
|
|
||||||
import com.muyu.fault.service.FaultLogService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/faultlog")
|
|
||||||
public class FaultLogController {
|
|
||||||
@Autowired
|
|
||||||
private FaultLogService faultLogService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障日志列表
|
|
||||||
* @param faultLogListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
@Operation(summary = "故障日志列表",description = "故障日志列表展示")
|
|
||||||
public Result selectfaultlog(@Validated @RequestBody FaultLogListReq faultLogListReq){
|
|
||||||
return Result.success(faultLogService.selectfaultlog(faultLogListReq));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
package com.muyu.fault.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.fault.domain.CarFaultRule;
|
|
||||||
import com.muyu.fault.domain.FaultRule;
|
|
||||||
import com.muyu.fault.service.FaultRuleService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/faultrule")
|
|
||||||
public class FaultRuleController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FaultRuleService faultRuleService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆故障检测
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/check-faults")
|
|
||||||
@Operation(summary = "检查故障",description = "进行故障检查")
|
|
||||||
public Result checkfault(@Validated FaultRule faultRule){
|
|
||||||
String checkfaults = faultRuleService.checkfaults(faultRule);
|
|
||||||
return Result.success(checkfaults);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/cheakfaults")
|
|
||||||
@Operation(summary = "故障参数匹配检查",description = "获取报文数据与故障参数进行比较")
|
|
||||||
public Result cheakfaults(@Validated @RequestBody CarFaultRule carFaultRule){
|
|
||||||
// faultRuleService.checkfaults(carFaultRule);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
package com.muyu.fault.controller;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.fault.service.FaultTypeService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障码分类
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/faulttype")
|
|
||||||
public class FaultTypeController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FaultTypeService faultTypeService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障码分类查询
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
@Operation(summary = "故障码分类查询",description = "故障码分类信息")
|
|
||||||
public Result findfaulttype(){
|
|
||||||
return Result.success(faultTypeService.select());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,81 +0,0 @@
|
||||||
package com.muyu.fault.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.fault.domain.message.Message;
|
|
||||||
import com.muyu.fault.domain.message.MessageReq;
|
|
||||||
import com.muyu.fault.domain.message.MessageSendReq;
|
|
||||||
import com.muyu.fault.service.MessageService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/message")
|
|
||||||
public class MessageController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MessageService messageService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 消息发送
|
|
||||||
* @param messageSendReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/sendmessage")
|
|
||||||
@Operation(summary = "发送消息",description = "站内信消息发送")
|
|
||||||
public Result sendmessage(@Validated MessageSendReq messageSendReq){
|
|
||||||
messageService.sendmessage(messageSendReq);
|
|
||||||
return Result.success(null,"发送成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 消息查看
|
|
||||||
* @param messageReq
|
|
||||||
* @param
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/messagelist")
|
|
||||||
@Operation(summary = "消息查看(能根据登录人新的信息查看当前登录人的消息栏)",description = "消息查看")
|
|
||||||
public Result selectmessage(@Validated @RequestBody MessageReq messageReq){
|
|
||||||
return Result.success(messageService.selectmessage(messageReq));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看消息改变状态
|
|
||||||
* @param message
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/changestatus")
|
|
||||||
@Operation(summary = "状态改变",description = "状态改变")
|
|
||||||
public Result changestatus(@RequestBody Message message){
|
|
||||||
messageService.changestatus(message);
|
|
||||||
return Result.success(null,"成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看未读的消息
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@PostMapping("/unread")
|
|
||||||
@Operation(summary = "查看未读的消息",description = "查看未读的消息")
|
|
||||||
public Result unread(){
|
|
||||||
return Result.success(messageService.unread());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,112 +0,0 @@
|
||||||
package com.muyu.fault.controller;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
|
||||||
import com.muyu.fault.domain.SysCarFault;
|
|
||||||
import com.muyu.fault.service.ISysCarFaultService;
|
|
||||||
import com.muyu.common.core.web.controller.BaseController;
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆故障Controller
|
|
||||||
*
|
|
||||||
* @author Yang鹏
|
|
||||||
* @date 2024-09-18
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/fault")
|
|
||||||
public class SysCarFaultController extends BaseController
|
|
||||||
{
|
|
||||||
@Resource
|
|
||||||
private ISysCarFaultService sysCarFaultService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询车辆故障列表
|
|
||||||
*/
|
|
||||||
|
|
||||||
@GetMapping("/list")
|
|
||||||
public Result<TableDataInfo<SysCarFault>> list(SysCarFault sysCarFault)
|
|
||||||
{
|
|
||||||
startPage();
|
|
||||||
List<SysCarFault> list = sysCarFaultService.selectSysCarFaultList(sysCarFault);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出车辆故障列表
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("syscarfault:fault:export")
|
|
||||||
@PostMapping("/export")
|
|
||||||
public void export(HttpServletResponse response, SysCarFault sysCarFault)
|
|
||||||
{
|
|
||||||
List<SysCarFault> list = sysCarFaultService.selectSysCarFaultList(sysCarFault);
|
|
||||||
ExcelUtil<SysCarFault> util = new ExcelUtil<SysCarFault>(SysCarFault.class);
|
|
||||||
util.exportExcel(response, list, "车辆故障数据");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取车辆故障详细信息
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("syscarfault:fault:query")
|
|
||||||
@GetMapping(value = "/{id}")
|
|
||||||
public Result<List<SysCarFault>> getInfo(@PathVariable("id") Long id)
|
|
||||||
{
|
|
||||||
return success(sysCarFaultService.selectSysCarFaultById(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增车辆故障
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("syscarfault:fault:add")
|
|
||||||
@PostMapping
|
|
||||||
public Result<Integer> add(
|
|
||||||
@Validated @RequestBody SysCarFault sysCarFault)
|
|
||||||
{
|
|
||||||
if (sysCarFaultService.checkIdUnique(sysCarFault)) {
|
|
||||||
return error("新增 车辆故障 '" + sysCarFault + "'失败,车辆故障已存在");
|
|
||||||
}
|
|
||||||
sysCarFault.setCreateBy(SecurityUtils.getUsername());
|
|
||||||
return toAjax(sysCarFaultService.save(sysCarFault));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改车辆故障
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("syscarfault:fault:edit")
|
|
||||||
@PutMapping
|
|
||||||
public Result<Integer> edit(
|
|
||||||
@Validated @RequestBody SysCarFault sysCarFault)
|
|
||||||
{
|
|
||||||
if (!sysCarFaultService.checkIdUnique(sysCarFault)) {
|
|
||||||
return error("修改 车辆故障 '" + sysCarFault + "'失败,车辆故障不存在");
|
|
||||||
}
|
|
||||||
sysCarFault.setUpdateBy(SecurityUtils.getUsername());
|
|
||||||
return toAjax(sysCarFaultService.updateById(sysCarFault));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除车辆故障
|
|
||||||
*/
|
|
||||||
@RequiresPermissions("syscarfault:fault:remove")
|
|
||||||
@DeleteMapping("/{ids}")
|
|
||||||
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
|
|
||||||
{
|
|
||||||
sysCarFaultService.removeBatchByIds(Arrays.asList(ids));
|
|
||||||
return success();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,206 +0,0 @@
|
||||||
package com.muyu.fault.domain;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
/**
|
|
||||||
* @className: CarFaultRule ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 22:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
public class CarFaultRule {/**
|
|
||||||
* VIN码VIN码VIN码
|
|
||||||
*/
|
|
||||||
private String vin;
|
|
||||||
/**
|
|
||||||
* 时间戳时间戳时间戳
|
|
||||||
*/
|
|
||||||
private long timestamp;
|
|
||||||
/**
|
|
||||||
* 经度经度经度
|
|
||||||
*/
|
|
||||||
private double longitude;
|
|
||||||
/**
|
|
||||||
* 纬度纬度纬度
|
|
||||||
*/
|
|
||||||
private double latitude;
|
|
||||||
/**
|
|
||||||
* 车速车速车速
|
|
||||||
*/
|
|
||||||
private double speed;
|
|
||||||
/**
|
|
||||||
* 总里程总里程总里程
|
|
||||||
*/
|
|
||||||
private long TM;
|
|
||||||
/**
|
|
||||||
* 总电压总电压总电压
|
|
||||||
*/
|
|
||||||
private double TV;
|
|
||||||
/**
|
|
||||||
* 总电流总电流总电流
|
|
||||||
*/
|
|
||||||
private double CC;
|
|
||||||
/**
|
|
||||||
* 绝缘电阻绝缘电阻绝缘电阻
|
|
||||||
*/
|
|
||||||
private double IR;
|
|
||||||
/**
|
|
||||||
* 档位档位档位
|
|
||||||
*/
|
|
||||||
private String GP;
|
|
||||||
/**
|
|
||||||
* 加速踏板行程值加速踏板行程值加速踏板行程值
|
|
||||||
*/
|
|
||||||
private double APTV;
|
|
||||||
/**
|
|
||||||
* 制动踏板行程值制动踏板行程值制动踏板行程值
|
|
||||||
*/
|
|
||||||
private double BPTV;
|
|
||||||
/**
|
|
||||||
* 燃料消耗率燃料消耗率燃料消耗率
|
|
||||||
*/
|
|
||||||
private double SFC;
|
|
||||||
/**
|
|
||||||
* 电机控制器温度电机控制器温度电机控制器温度
|
|
||||||
*/
|
|
||||||
private double MCT;
|
|
||||||
/**
|
|
||||||
* 电机转速电机转速电机转速
|
|
||||||
*/
|
|
||||||
private int MS;
|
|
||||||
/**
|
|
||||||
* 电机转矩电机转矩电机转矩
|
|
||||||
*/
|
|
||||||
private double MTO;
|
|
||||||
/**
|
|
||||||
* 电机温度电机温度电机温度
|
|
||||||
*/
|
|
||||||
private double MTE;
|
|
||||||
/**
|
|
||||||
* 电机电压电机电压电机电压
|
|
||||||
*/
|
|
||||||
private double MV;
|
|
||||||
/**
|
|
||||||
* 电机电流电机电流电机电流
|
|
||||||
*/
|
|
||||||
private double MC;
|
|
||||||
/**
|
|
||||||
* 动力电池剩余电量SOC动力电池剩余电量SOC动力电池剩余电量SOC
|
|
||||||
*/
|
|
||||||
private double PBRSOC;
|
|
||||||
/**
|
|
||||||
* 当前状态允许的最大反馈功率当前状态允许的最大反馈功率当前状态允许的最大反馈功率
|
|
||||||
*/
|
|
||||||
private double MACSFP;
|
|
||||||
/**
|
|
||||||
* 当前状态允许最大放电功率当前状态允许最大放电功率当前状态允许最大放电功率
|
|
||||||
*/
|
|
||||||
private double CSATMDP;
|
|
||||||
/**
|
|
||||||
* BMS自检计数器BMS自检计数器BMS自检计数器
|
|
||||||
*/
|
|
||||||
private int BMS;
|
|
||||||
/**
|
|
||||||
* 动力电池充放电电流动力电池充放电电流动力电池充放电电流
|
|
||||||
*/
|
|
||||||
private double CADC;
|
|
||||||
/**
|
|
||||||
* 动力电池负载端总电压V3动力电池负载端总电压V3动力电池负载端总电压V3
|
|
||||||
*/
|
|
||||||
private double PBLETVV3;
|
|
||||||
/**
|
|
||||||
* 单次最大电压单次最大电压单次最大电压
|
|
||||||
*/
|
|
||||||
private double SMV;
|
|
||||||
/**
|
|
||||||
* 单体电池最低电压单体电池最低电压单体电池最低电压
|
|
||||||
*/
|
|
||||||
private double MVOAB;
|
|
||||||
/**
|
|
||||||
* 单体电池最高温度单体电池最高温度单体电池最高温度
|
|
||||||
*/
|
|
||||||
private double MAXBT;
|
|
||||||
/**
|
|
||||||
* 单体电池最低温度单体电池最低温度单体电池最低温度
|
|
||||||
*/
|
|
||||||
private double MINBT;
|
|
||||||
/**
|
|
||||||
* 动力电池可用容量动力电池可用容量动力电池可用容量
|
|
||||||
*/
|
|
||||||
private double PBAC;
|
|
||||||
/**
|
|
||||||
* 车辆状态车辆状态车辆状态
|
|
||||||
*/
|
|
||||||
private String VS;
|
|
||||||
/**
|
|
||||||
* 充电状态充电状态充电状态
|
|
||||||
*/
|
|
||||||
private String CS;
|
|
||||||
/**
|
|
||||||
* 运行状态运行状态运行状态
|
|
||||||
*/
|
|
||||||
private String RS;
|
|
||||||
/**
|
|
||||||
* SOCSOCSOC
|
|
||||||
*/
|
|
||||||
private double SOC;
|
|
||||||
/**
|
|
||||||
* 可充电储能装置工作状态可充电储能装置工作状态可充电储能装置工作状态
|
|
||||||
*/
|
|
||||||
private String RESDWC;
|
|
||||||
/**
|
|
||||||
* EASEASEAS
|
|
||||||
*/
|
|
||||||
private String EAS;
|
|
||||||
/**
|
|
||||||
* PTCPTCPTC
|
|
||||||
*/
|
|
||||||
private String PTC;
|
|
||||||
/**
|
|
||||||
* EPSEPSEPS
|
|
||||||
*/
|
|
||||||
private String EPS;
|
|
||||||
/**
|
|
||||||
* ABSABSABS
|
|
||||||
*/
|
|
||||||
private String ABS;
|
|
||||||
/**
|
|
||||||
* MCUMCUMCU
|
|
||||||
*/
|
|
||||||
private String MCU;
|
|
||||||
/**
|
|
||||||
* 动力电池加热状态动力电池加热状态动力电池加热状态
|
|
||||||
*/
|
|
||||||
private String PBHS;
|
|
||||||
/**
|
|
||||||
* 动力电池当前状态动力电池当前状态动力电池当前状态
|
|
||||||
*/
|
|
||||||
private String PBCS;
|
|
||||||
/**
|
|
||||||
* 动力电池保温状态动力电池保温状态动力电池保温状态
|
|
||||||
*/
|
|
||||||
private String PBIS;
|
|
||||||
/**
|
|
||||||
* DCDCDCDCDCDC
|
|
||||||
*/
|
|
||||||
private String DCDC;
|
|
||||||
/**
|
|
||||||
* CHGCHGCHG
|
|
||||||
*/
|
|
||||||
private String CHG;
|
|
||||||
/**
|
|
||||||
* 校验位校验位校验位
|
|
||||||
*/
|
|
||||||
private byte CHB;
|
|
||||||
/**
|
|
||||||
* 截止位截止位截止位
|
|
||||||
*/
|
|
||||||
private byte CUB;
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package com.muyu.fault.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: CarType ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 22:01 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
@TableName(value = "car_type",autoResultMap = true)
|
|
||||||
public class CarType {
|
|
||||||
/**
|
|
||||||
* 车辆类型ID
|
|
||||||
*/
|
|
||||||
private long carTypeId;
|
|
||||||
/**
|
|
||||||
* 车辆类型名
|
|
||||||
*/
|
|
||||||
private String carTypeName;
|
|
||||||
/**
|
|
||||||
* 车辆规则外键ID
|
|
||||||
*/
|
|
||||||
private long carTypeRules;
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
package com.muyu.fault.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.muyu.fault.domain.req.FaultCodeAddReq;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultCode ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 22:21 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
@TableName(value = "car_faultcode", autoResultMap = true)
|
|
||||||
public class FaultCode {
|
|
||||||
/**
|
|
||||||
* 故障码Id
|
|
||||||
*/
|
|
||||||
@TableId(value = "faultcode_id", type = IdType.AUTO)
|
|
||||||
private long faultcodeId;
|
|
||||||
/**
|
|
||||||
* 故障名称Id
|
|
||||||
*/
|
|
||||||
private long messageTypeId;
|
|
||||||
/**
|
|
||||||
* 故障码
|
|
||||||
*/
|
|
||||||
private String faultcodeNumber;
|
|
||||||
/**
|
|
||||||
* 故障组
|
|
||||||
*/
|
|
||||||
private String faultGroup;
|
|
||||||
/**
|
|
||||||
* 故障位
|
|
||||||
*/
|
|
||||||
private String faultBit;
|
|
||||||
/**
|
|
||||||
* 故障值
|
|
||||||
*/
|
|
||||||
private String faultValue;
|
|
||||||
/**
|
|
||||||
* 是否警告
|
|
||||||
*/
|
|
||||||
private Integer isWarning;
|
|
||||||
|
|
||||||
private String faulttypeName;
|
|
||||||
private String messageTypeName;
|
|
||||||
private String messageTypeCode;
|
|
||||||
private String messageTypeBelongs;
|
|
||||||
|
|
||||||
public static FaultCode addfaultcode(FaultCodeAddReq faultCodeAddReq) {
|
|
||||||
return FaultCode.builder()
|
|
||||||
.faultcodeId(0)
|
|
||||||
.messageTypeId(faultCodeAddReq.getMessageTypeId())
|
|
||||||
.faultcodeNumber(faultCodeAddReq.getFaultcodeNumber())
|
|
||||||
.faultGroup(faultCodeAddReq.getFaultGroup())
|
|
||||||
.faultBit(faultCodeAddReq.getFaultBit())
|
|
||||||
.faultValue(faultCodeAddReq.getFaultValue())
|
|
||||||
.isWarning(faultCodeAddReq.getIsWarning())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,87 +0,0 @@
|
||||||
package com.muyu.fault.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.muyu.fault.domain.req.FaultConditionAddReq;
|
|
||||||
import com.muyu.fault.domain.req.FaultConditionUpdReq;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultCondition ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:07 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
@TableName(value = "car_fault_condition",autoResultMap = true)
|
|
||||||
public class FaultCondition {
|
|
||||||
/**
|
|
||||||
* 故障规则表Id
|
|
||||||
*/
|
|
||||||
@TableId(value = "carcondition_id",type = IdType.AUTO)
|
|
||||||
private long carconditionId;
|
|
||||||
/**
|
|
||||||
* 车辆类型Id
|
|
||||||
*/
|
|
||||||
private long carTypeId;
|
|
||||||
/**
|
|
||||||
*故障名称Id
|
|
||||||
*/
|
|
||||||
private long messageTypeId;
|
|
||||||
/**
|
|
||||||
* 故障条件
|
|
||||||
*/
|
|
||||||
private String faultconditionIdentification;
|
|
||||||
/**
|
|
||||||
* 故障规则参数
|
|
||||||
*/
|
|
||||||
private BigDecimal faultconditionParameter;
|
|
||||||
/**
|
|
||||||
* 车辆类型名称
|
|
||||||
*/
|
|
||||||
private String carTypeName;
|
|
||||||
/**
|
|
||||||
* 故障名称
|
|
||||||
*/
|
|
||||||
private String messageTypeName;
|
|
||||||
/**
|
|
||||||
* 报文编码
|
|
||||||
*/
|
|
||||||
private String messageTypeCode;
|
|
||||||
|
|
||||||
|
|
||||||
public static FaultCondition faultConditionadd(FaultConditionAddReq faultConditionAddReq){
|
|
||||||
return FaultCondition.builder()
|
|
||||||
.carTypeId(faultConditionAddReq.getCarTypeId())
|
|
||||||
.messageTypeId(faultConditionAddReq.getMessageTypeId())
|
|
||||||
.faultconditionIdentification(faultConditionAddReq.getFaultconditionIdentification())
|
|
||||||
.faultconditionParameter(faultConditionAddReq.getFaultconditionParameter())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FaultCondition faultConditionupd(FaultConditionUpdReq faultConditionUpdReq, Supplier<Long> idSupplier){
|
|
||||||
return FaultCondition.builder()
|
|
||||||
.carconditionId(faultConditionUpdReq.getCarconditionId())
|
|
||||||
.carTypeId(faultConditionUpdReq.getCarTypeId())
|
|
||||||
.messageTypeId(faultConditionUpdReq.getMessageTypeId())
|
|
||||||
.faultconditionIdentification(faultConditionUpdReq.getFaultconditionIdentification())
|
|
||||||
.faultconditionParameter(faultConditionUpdReq.getFaultconditionParameter())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
package com.muyu.fault.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLabel ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:07 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
@TableName(value = "car_fault_label",autoResultMap = true)
|
|
||||||
public class FaultLabel {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*自增主键
|
|
||||||
*/
|
|
||||||
@TableId(value = "message_type_id",type = IdType.AUTO)
|
|
||||||
private String messageTypeId;
|
|
||||||
/**
|
|
||||||
*报文编码
|
|
||||||
*/
|
|
||||||
private String messageTypeCode;
|
|
||||||
/**
|
|
||||||
*报文名称
|
|
||||||
*/
|
|
||||||
private String messageTypeName;
|
|
||||||
/**
|
|
||||||
*报文所属类别
|
|
||||||
*/
|
|
||||||
private String messageTypeBelongs;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
package com.muyu.fault.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
@TableName(value = "car_fault_log",autoResultMap = true)
|
|
||||||
public class FaultLog {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障日志Id
|
|
||||||
*/
|
|
||||||
@TableId(value = "log_id",type = IdType.AUTO)
|
|
||||||
private long logId;
|
|
||||||
/**
|
|
||||||
* 故障码Id
|
|
||||||
*/
|
|
||||||
private long faultcodeId;
|
|
||||||
/**
|
|
||||||
* 车辆Id
|
|
||||||
*/
|
|
||||||
private long carInformationId;
|
|
||||||
/**
|
|
||||||
* 车辆VIN
|
|
||||||
*/
|
|
||||||
private String carVin;
|
|
||||||
/**
|
|
||||||
* 开始报警时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@Excel(description = "开始报警时间",defaultValue = "2024-8-9 10:47:57",type = "Date")
|
|
||||||
private Date startwarningTime;
|
|
||||||
/**
|
|
||||||
* 结束报警时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@Excel(description = "结束报警时间",defaultValue = "2024-8-9 10:47:57",type = "Date")
|
|
||||||
private Date endwarningTime;
|
|
||||||
/**
|
|
||||||
* 故障码
|
|
||||||
*/
|
|
||||||
private String faultcodeNumber;
|
|
||||||
/**
|
|
||||||
* 车辆vin
|
|
||||||
*/
|
|
||||||
private String carInformationVIN;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
package com.muyu.fault.domain;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultReport ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:05 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
public class FaultReport {
|
|
||||||
private String VehicleType;
|
|
||||||
private String FaultDescription;
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
package com.muyu.fault.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultRule ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:05 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
@TableName(value = "car_fault_condition",autoResultMap = true)
|
|
||||||
public class FaultRule {
|
|
||||||
/**
|
|
||||||
* 触发条件Id
|
|
||||||
*/
|
|
||||||
private long conditionId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障码Id
|
|
||||||
*/
|
|
||||||
private long faultcodeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 触发条件描述
|
|
||||||
*/
|
|
||||||
private String conditionContent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单个参数的阈值
|
|
||||||
*/
|
|
||||||
private BigDecimal singleThreshold;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 区间参数的阈值的最小值
|
|
||||||
*/
|
|
||||||
private BigDecimal minThreshold;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 区间参数的阈值的最大值
|
|
||||||
*/
|
|
||||||
private BigDecimal maxThreshold;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 触发条件是否激活
|
|
||||||
*/
|
|
||||||
private Integer isActive;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆数据值
|
|
||||||
*/
|
|
||||||
private BigDecimal Threshold;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
package com.muyu.fault.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultType ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:04 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
@TableName(value = "car_fault_type",autoResultMap = true)
|
|
||||||
public class FaultType {
|
|
||||||
/**
|
|
||||||
*故障类型Id
|
|
||||||
*/
|
|
||||||
@TableId(value = "faulttype_id",type = IdType.AUTO)
|
|
||||||
private long faulttypeId;
|
|
||||||
/**
|
|
||||||
*故障类型名称
|
|
||||||
*/
|
|
||||||
private String faulttypeName;
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package com.muyu.fault.domain;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.message.Message;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: MessageDao ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 20:58 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class MessageDao {
|
|
||||||
private Connection connection;
|
|
||||||
|
|
||||||
public MessageDao(Connection connection){
|
|
||||||
this.connection=connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMessage(Message message) throws Exception{
|
|
||||||
String sql="INSERT INTO `eight`.`car_fault_message` (`id`, `sender`, `receiver`, `content`, `status`, `create_time`, `user_id`) " +
|
|
||||||
"VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL)";
|
|
||||||
try(PreparedStatement pstmt=connection.prepareStatement(sql)){
|
|
||||||
pstmt.setString(1, message.getContent());
|
|
||||||
pstmt.setString(2, message.getSender());
|
|
||||||
pstmt.setString(3, message.getReceiver());
|
|
||||||
pstmt.setObject(4, message.getCreateTime());
|
|
||||||
pstmt.executeUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package com.muyu.fault.domain;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.message.Message;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: MessageService ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:01 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 业务逻辑层将负责实现消息的发送逻辑
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class MessageService {
|
|
||||||
private MessageDao messageDao;
|
|
||||||
|
|
||||||
public MessageService(MessageDao messageDao){
|
|
||||||
this.messageDao=messageDao;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMessage(String content,String sender,String receiver){
|
|
||||||
|
|
||||||
// 定义一个DateTimeFormatter对象,用于格式化日期时间为yyyy-MM-dd HH:mm:ss
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
||||||
// 获取当前日期和时间
|
|
||||||
LocalDateTime now = LocalDateTime.now();
|
|
||||||
// 使用formatter格式化当前日期和时间
|
|
||||||
String formattedDateTime = now.format(formatter);
|
|
||||||
// 使用formatter将字符串解析回LocalDateTime
|
|
||||||
LocalDateTime parsedDateTime = LocalDateTime.parse(formattedDateTime, formatter);
|
|
||||||
// 然后按照上面的步骤将LocalDateTime转换为Date
|
|
||||||
ZonedDateTime zdt = parsedDateTime.atZone(ZoneId.systemDefault());
|
|
||||||
Date date = Date.from(zdt.toInstant());
|
|
||||||
|
|
||||||
|
|
||||||
Message message = new Message();
|
|
||||||
message.setContent(content);
|
|
||||||
message.setSender(sender);
|
|
||||||
message.setReceiver(receiver);
|
|
||||||
message.setCreateTime(date);
|
|
||||||
|
|
||||||
try {
|
|
||||||
messageDao.sendMessage(message);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,102 +0,0 @@
|
||||||
package com.muyu.fault.domain;
|
|
||||||
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
|
||||||
import lombok.*;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆故障对象 sys_car_fault
|
|
||||||
*
|
|
||||||
* @author Yang鹏
|
|
||||||
* @date 2024-09-18
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
@SuperBuilder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@TableName("sys_car_fault")
|
|
||||||
public class SysCarFault extends BaseEntity{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** 自增主键 */
|
|
||||||
@TableId( type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/** 车辆故障编码; */
|
|
||||||
@Excel(name = "车辆故障编码;")
|
|
||||||
private String faultCode;
|
|
||||||
|
|
||||||
/** 车辆故障名称 */
|
|
||||||
@Excel(name = "车辆故障名称")
|
|
||||||
private String faultName;
|
|
||||||
|
|
||||||
/** 车辆故障类型 */
|
|
||||||
@Excel(name = "车辆故障类型")
|
|
||||||
private String faultType;
|
|
||||||
|
|
||||||
/** 故障VIN编码 */
|
|
||||||
@Excel(name = "故障VIN编码")
|
|
||||||
private String carVin;
|
|
||||||
|
|
||||||
/** 车辆故障标签 */
|
|
||||||
@Excel(name = "车辆故障标签")
|
|
||||||
private String faultLabel;
|
|
||||||
|
|
||||||
/** 车辆故障位 */
|
|
||||||
@Excel(name = "车辆故障位")
|
|
||||||
private String faultBit;
|
|
||||||
|
|
||||||
/** 车辆故障值 */
|
|
||||||
@Excel(name = "车辆故障值")
|
|
||||||
private String faultValue;
|
|
||||||
|
|
||||||
/** 故障级别; */
|
|
||||||
@Excel(name = "故障级别;")
|
|
||||||
private String faultWarn;
|
|
||||||
|
|
||||||
/** 报警状态(Y.是,N.否) */
|
|
||||||
@Excel(name = "报警状态", readConverterExp = "Y=.是,N.否")
|
|
||||||
private String warnStatus;
|
|
||||||
|
|
||||||
/** 故障描述信息 */
|
|
||||||
@Excel(name = "故障描述信息")
|
|
||||||
private String faultDesc;
|
|
||||||
|
|
||||||
/** 启用状态(1.待处理 2.处理中 3.已处理 4.忽略) */
|
|
||||||
@Excel(name = "启用状态(1.待处理 2.处理中 3.已处理 4.忽略)")
|
|
||||||
private String state;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("faultCode", getFaultCode())
|
|
||||||
.append("faultName", getFaultName())
|
|
||||||
.append("faultType", getFaultType())
|
|
||||||
.append("carVin", getCarVin())
|
|
||||||
.append("faultLabel", getFaultLabel())
|
|
||||||
.append("faultBit", getFaultBit())
|
|
||||||
.append("faultValue", getFaultValue())
|
|
||||||
.append("faultWarn", getFaultWarn())
|
|
||||||
.append("warnStatus", getWarnStatus())
|
|
||||||
.append("faultDesc", getFaultDesc())
|
|
||||||
.append("state", getState())
|
|
||||||
.append("createBy", getCreateBy())
|
|
||||||
.append("createTime", getCreateTime())
|
|
||||||
.append("updateBy", getUpdateBy())
|
|
||||||
.append("updateTime", getUpdateTime())
|
|
||||||
.append("remark", getRemark())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package com.muyu.fault.domain;
|
|
||||||
|
|
||||||
public enum WarnLevel {
|
|
||||||
LOW, MEDIUM, HIGH
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
package com.muyu.fault.domain.message;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: Message ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/22 10:55 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
@TableName(value = "car_fault_message",autoResultMap = true)
|
|
||||||
public class Message {
|
|
||||||
/**
|
|
||||||
* id
|
|
||||||
*/
|
|
||||||
@TableId(value = "id",type = IdType.AUTO)
|
|
||||||
private long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 发送者
|
|
||||||
*/
|
|
||||||
private String sender;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 接收者
|
|
||||||
*/
|
|
||||||
private String receiver;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 消息内容
|
|
||||||
*/
|
|
||||||
private String content;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 消息状态
|
|
||||||
*/
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@Excel(description = "消息创建时间",defaultValue = "2024-8-9 10:47:57",type = "Date")
|
|
||||||
private Date createTime;
|
|
||||||
/**
|
|
||||||
* 登录人Id
|
|
||||||
*/
|
|
||||||
private long userId;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
package com.muyu.fault.domain.message;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: MessageReq ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 20:59 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
public class MessageReq {
|
|
||||||
/**
|
|
||||||
* 消息状态
|
|
||||||
*/
|
|
||||||
@TableId(type = IdType.AUTO,value = "status")
|
|
||||||
private Integer status;
|
|
||||||
/**
|
|
||||||
* 登录人Id
|
|
||||||
*/
|
|
||||||
@Excel(name = "登录人Id")
|
|
||||||
private long userId;
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package com.muyu.fault.domain.message;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: MessageSendReq ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:00 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class MessageSendReq {
|
|
||||||
/**
|
|
||||||
* 发送者
|
|
||||||
*/
|
|
||||||
@TableId(type = IdType.AUTO,value = "id")
|
|
||||||
private String sender;
|
|
||||||
/**
|
|
||||||
* 接收者
|
|
||||||
*/
|
|
||||||
@Excel(name = "接收者")
|
|
||||||
private String receiver;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 消息内容
|
|
||||||
*/
|
|
||||||
@Excel(name = "消息内容")
|
|
||||||
private String content;
|
|
||||||
/**
|
|
||||||
* 登录人Id
|
|
||||||
*/
|
|
||||||
@Excel(name = "登录人Id")
|
|
||||||
private long userId;
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@Excel(description = "消息创建时间",defaultValue = "2024-8-9 10:47:57",type = "String")
|
|
||||||
private Date createTime;
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
package com.muyu.fault.domain.message;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: User ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 20:56 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
public class User {
|
|
||||||
/**
|
|
||||||
* 用户id
|
|
||||||
*/
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
private Integer id;
|
|
||||||
/**
|
|
||||||
* 用户名
|
|
||||||
*/
|
|
||||||
@Excel(name = "用户名")
|
|
||||||
private String username;
|
|
||||||
/**
|
|
||||||
* 邮箱
|
|
||||||
*/
|
|
||||||
@Excel(name="邮箱")
|
|
||||||
private String email;
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
package com.muyu.fault.domain.req;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class FaultCodeAddReq {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*故障名称Id
|
|
||||||
*/
|
|
||||||
private long messageTypeId;
|
|
||||||
/**
|
|
||||||
* 故障名称
|
|
||||||
*/
|
|
||||||
private String messageTypeName;
|
|
||||||
/**
|
|
||||||
* 报文编码
|
|
||||||
*/
|
|
||||||
private String messageTypeCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障码
|
|
||||||
*/
|
|
||||||
private String faultcodeNumber;
|
|
||||||
/**
|
|
||||||
* 故障分类Id
|
|
||||||
*/
|
|
||||||
private long faulttypeId;
|
|
||||||
/**
|
|
||||||
* 是否产生报警
|
|
||||||
*/
|
|
||||||
private Integer isWarning;
|
|
||||||
/**
|
|
||||||
* 故障描述
|
|
||||||
*/
|
|
||||||
private String faultContent;
|
|
||||||
/**
|
|
||||||
*故障组
|
|
||||||
*/
|
|
||||||
private String faultGroup;
|
|
||||||
/**
|
|
||||||
*故障位
|
|
||||||
*/
|
|
||||||
private String faultBit;
|
|
||||||
/**
|
|
||||||
*故障值
|
|
||||||
*/
|
|
||||||
private String faultValue;
|
|
||||||
/**
|
|
||||||
*报文所属类别
|
|
||||||
*/
|
|
||||||
private String messageTypeBelongs;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
package com.muyu.fault.domain.req;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Tag(name = "故障码列表请求对象")
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class FaultCodeListReq {
|
|
||||||
/**
|
|
||||||
*故障码
|
|
||||||
*/
|
|
||||||
private String faultcodeNumber;
|
|
||||||
/**
|
|
||||||
*故障位
|
|
||||||
*/
|
|
||||||
private String faultBit;
|
|
||||||
/**
|
|
||||||
* 页码,从1开始
|
|
||||||
*/
|
|
||||||
private Integer pageNum=1;
|
|
||||||
/**
|
|
||||||
* 每页大小
|
|
||||||
*/
|
|
||||||
private Integer pageSize=10;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,78 +0,0 @@
|
||||||
package com.muyu.fault.domain.req;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class FaultCodeUpdReq {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*故障码Id
|
|
||||||
*/
|
|
||||||
private long faultcodeId;
|
|
||||||
/**
|
|
||||||
*故障名称Id
|
|
||||||
*/
|
|
||||||
private long messageTypeId;
|
|
||||||
/**
|
|
||||||
* 故障名称
|
|
||||||
*/
|
|
||||||
private String messageTypeName;
|
|
||||||
/**
|
|
||||||
* 报文编码
|
|
||||||
*/
|
|
||||||
private String messageTypeCode;
|
|
||||||
/**
|
|
||||||
* 故障码
|
|
||||||
*/
|
|
||||||
private String faultcodeNumber;
|
|
||||||
/**
|
|
||||||
* 故障分类Id
|
|
||||||
*/
|
|
||||||
private long faulttypeId;
|
|
||||||
/**
|
|
||||||
* 是否产生报警
|
|
||||||
*/
|
|
||||||
private Integer isWarning;
|
|
||||||
/**
|
|
||||||
* 故障描述
|
|
||||||
*/
|
|
||||||
private String faultContent;
|
|
||||||
/**
|
|
||||||
*故障状态
|
|
||||||
*/
|
|
||||||
private Integer faultStatus;
|
|
||||||
/**
|
|
||||||
*故障组
|
|
||||||
*/
|
|
||||||
private String faultGroup;
|
|
||||||
/**
|
|
||||||
*故障位
|
|
||||||
*/
|
|
||||||
private String faultBit;
|
|
||||||
/**
|
|
||||||
*故障值
|
|
||||||
*/
|
|
||||||
private String faultValue;
|
|
||||||
/**
|
|
||||||
*报文所属类别
|
|
||||||
*/
|
|
||||||
private String messageTypeBelongs;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
package com.muyu.fault.domain.req;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class FaultConditionAddReq {
|
|
||||||
/**
|
|
||||||
* 故障规则表Id
|
|
||||||
*/
|
|
||||||
private long carconditionId;
|
|
||||||
/**
|
|
||||||
* 车辆类型Id
|
|
||||||
*/
|
|
||||||
private long carTypeId;
|
|
||||||
/**
|
|
||||||
*故障名称Id
|
|
||||||
*/
|
|
||||||
private long messageTypeId;
|
|
||||||
/**
|
|
||||||
* 故障条件
|
|
||||||
*/
|
|
||||||
private String faultconditionIdentification;
|
|
||||||
/**
|
|
||||||
* 故障规则参数
|
|
||||||
*/
|
|
||||||
private BigDecimal faultconditionParameter;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
package com.muyu.fault.domain.req;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
@Tag(name = "故障规则列表请求对象")
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class FaultConditionListReq {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆类型Id
|
|
||||||
*/
|
|
||||||
private long carTypeId;
|
|
||||||
/**
|
|
||||||
*故障名称Id
|
|
||||||
*/
|
|
||||||
private long messageTypeId;
|
|
||||||
/**
|
|
||||||
* 页码,从1开始
|
|
||||||
*/
|
|
||||||
private Integer pageNum=1;
|
|
||||||
/**
|
|
||||||
* 每页大小
|
|
||||||
*/
|
|
||||||
private Integer pageSize=10;
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
package com.muyu.fault.domain.req;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class FaultConditionUpdReq {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障规则表Id
|
|
||||||
*/
|
|
||||||
private long carconditionId;
|
|
||||||
/**
|
|
||||||
* 车辆类型Id
|
|
||||||
*/
|
|
||||||
private long carTypeId;
|
|
||||||
/**
|
|
||||||
*故障名称Id
|
|
||||||
*/
|
|
||||||
private long messageTypeId;
|
|
||||||
/**
|
|
||||||
* 故障条件
|
|
||||||
*/
|
|
||||||
private String faultconditionIdentification;
|
|
||||||
/**
|
|
||||||
* 故障规则参数
|
|
||||||
*/
|
|
||||||
private BigDecimal faultconditionParameter;
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
package com.muyu.fault.domain.req;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
@Tag(name = "故障日志列表请求对象")
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class FaultLogListReq {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障码Id
|
|
||||||
*/
|
|
||||||
private long faultcodeId;
|
|
||||||
/**
|
|
||||||
* 车辆VIN
|
|
||||||
*/
|
|
||||||
private String carVin;
|
|
||||||
/**
|
|
||||||
* 开始报警时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@Excel(description = "开始报警时间",defaultValue = "2024-8-9 10:47:57",type = "Date")
|
|
||||||
private Date startwarningTime;
|
|
||||||
/**
|
|
||||||
* 结束报警时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@Excel(description = "结束报警时间",defaultValue = "2024-8-9 10:47:57",type = "Date")
|
|
||||||
private Date endwarningTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页码,从1开始
|
|
||||||
*/
|
|
||||||
private Integer pageNum=1;
|
|
||||||
/**
|
|
||||||
* 每页大小
|
|
||||||
*/
|
|
||||||
private Integer pageSize=10;
|
|
||||||
}
|
|
|
@ -1,88 +0,0 @@
|
||||||
package com.muyu.fault.domain.resp;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.vo.FaultCodeVo;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: Messages ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/22 10:55 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Tag(name="故障码信息响应对象",description = "故障码查询的响应结果")
|
|
||||||
public class FaultCodeListResp {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*故障码Id
|
|
||||||
*/
|
|
||||||
private long faultcodeId;
|
|
||||||
/**
|
|
||||||
*故障名称Id
|
|
||||||
*/
|
|
||||||
private long messageTypeId;
|
|
||||||
/**
|
|
||||||
*故障码
|
|
||||||
*/
|
|
||||||
private String faultcodeNumber;
|
|
||||||
/**
|
|
||||||
*故障组
|
|
||||||
*/
|
|
||||||
private String faultGroup;
|
|
||||||
/**
|
|
||||||
*故障位
|
|
||||||
*/
|
|
||||||
private String faultBit;
|
|
||||||
/**
|
|
||||||
*故障值
|
|
||||||
*/
|
|
||||||
private String faultValue;
|
|
||||||
/**
|
|
||||||
*是否警告
|
|
||||||
*/
|
|
||||||
private Integer isWarning;
|
|
||||||
/**
|
|
||||||
*故障类型名称
|
|
||||||
*/
|
|
||||||
private String faulttypeName;
|
|
||||||
/**
|
|
||||||
* 故障名称
|
|
||||||
*/
|
|
||||||
private String messageTypeName;
|
|
||||||
/**
|
|
||||||
* 报文编码
|
|
||||||
*/
|
|
||||||
private String messageTypeCode;
|
|
||||||
/**
|
|
||||||
*报文所属类别
|
|
||||||
*/
|
|
||||||
private String messageTypeBelongs;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库对象构建为返回结果对象
|
|
||||||
* @param faultCodeVO
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static FaultCodeListResp faultCodeListResp(FaultCodeVo faultCodeVO){
|
|
||||||
return FaultCodeListResp.builder()
|
|
||||||
.faultcodeId(faultCodeVO.getFaultcodeId())
|
|
||||||
.messageTypeId(faultCodeVO.getMessageTypeId())
|
|
||||||
.faultcodeNumber(faultCodeVO.getFaultcodeNumber())
|
|
||||||
.faultGroup(faultCodeVO.getFaultGroup())
|
|
||||||
.faultBit(faultCodeVO.getFaultBit())
|
|
||||||
.faultValue(faultCodeVO.getFaultValue())
|
|
||||||
.isWarning(faultCodeVO.getIsWarning())
|
|
||||||
.faulttypeName(faultCodeVO.getFaulttypeName())
|
|
||||||
.messageTypeName(faultCodeVO.getMessageTypeName())
|
|
||||||
.messageTypeCode(faultCodeVO.getMessageTypeCode())
|
|
||||||
.messageTypeBelongs(faultCodeVO.getMessageTypeBelongs())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
package com.muyu.fault.domain.resp;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: Messages ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/22 10:55 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Tag(name="数据总数列表",description = "数据和总数的响应")
|
|
||||||
public class FaultCodeTotalListResp {
|
|
||||||
|
|
||||||
|
|
||||||
private List<FaultCodeListResp> faultCodeListRespList;
|
|
||||||
|
|
||||||
private long total;
|
|
||||||
|
|
||||||
public static FaultCodeTotalListResp faultCodeTotalListResp(List<FaultCodeListResp> faultCodeListRespList,long total){
|
|
||||||
FaultCodeTotalListResp faultCodeTotalListResp = new FaultCodeTotalListResp();
|
|
||||||
faultCodeTotalListResp.setFaultCodeListRespList(faultCodeListRespList);
|
|
||||||
faultCodeTotalListResp.setTotal(total);
|
|
||||||
return faultCodeTotalListResp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,76 +0,0 @@
|
||||||
package com.muyu.fault.domain.resp;
|
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.FaultCondition;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Tag(name="故障规则信息响应对象",description = "故障规则查询的响应结果")
|
|
||||||
public class FaultConditionListResp {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障规则表Id
|
|
||||||
*/
|
|
||||||
private long carconditionId;
|
|
||||||
/**
|
|
||||||
* 车辆类型Id
|
|
||||||
*/
|
|
||||||
private long carTypeId;
|
|
||||||
/**
|
|
||||||
*故障名称Id
|
|
||||||
*/
|
|
||||||
private long messageTypeId;
|
|
||||||
/**
|
|
||||||
* 故障条件
|
|
||||||
*/
|
|
||||||
private String faultconditionIdentification;
|
|
||||||
/**
|
|
||||||
* 故障规则参数
|
|
||||||
*/
|
|
||||||
private BigDecimal faultconditionParameter;
|
|
||||||
/**
|
|
||||||
* 车辆类型名称
|
|
||||||
*/
|
|
||||||
private String carTypeName;
|
|
||||||
/**
|
|
||||||
* 故障名称
|
|
||||||
*/
|
|
||||||
private String messageTypeName;
|
|
||||||
/**
|
|
||||||
* 报文编码
|
|
||||||
*/
|
|
||||||
private String messageTypeCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库对象构建为返回结果对象
|
|
||||||
* @param faultCondition
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static FaultConditionListResp faultConditionListResp(FaultCondition faultCondition){
|
|
||||||
return FaultConditionListResp.builder()
|
|
||||||
.carconditionId(faultCondition.getCarconditionId())
|
|
||||||
.carTypeId(faultCondition.getCarTypeId())
|
|
||||||
.messageTypeId(faultCondition.getMessageTypeId())
|
|
||||||
.faultconditionParameter(faultCondition.getFaultconditionParameter())
|
|
||||||
.faultconditionIdentification(faultCondition.getFaultconditionIdentification())
|
|
||||||
.carTypeName(faultCondition.getCarTypeName())
|
|
||||||
.messageTypeName(faultCondition.getMessageTypeName())
|
|
||||||
.messageTypeCode(faultCondition.getMessageTypeCode())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package com.muyu.fault.domain.resp;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Tag(name="故障规则数据总数列表",description = "数据和总数的响应")
|
|
||||||
public class FaultConditionTotalListResp {
|
|
||||||
|
|
||||||
private List<FaultConditionListResp> faultConditionListRespList;
|
|
||||||
|
|
||||||
private long total;
|
|
||||||
|
|
||||||
public static FaultConditionTotalListResp faultConditionTotalListResp(List<FaultConditionListResp> faultConditionListRespList,long total){
|
|
||||||
FaultConditionTotalListResp faultConditionTotalListResp = new FaultConditionTotalListResp();
|
|
||||||
faultConditionTotalListResp.setFaultConditionListRespList(faultConditionListRespList);
|
|
||||||
faultConditionTotalListResp.setTotal(total);
|
|
||||||
return faultConditionTotalListResp;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,83 +0,0 @@
|
||||||
package com.muyu.fault.domain.resp;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.FaultLog;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: Messages ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/22 10:55 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Tag(name="故障日志信息响应对象",description = "故障日志的响应结果")
|
|
||||||
public class FaultLogListResp {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障日志Id
|
|
||||||
*/
|
|
||||||
private long logId;
|
|
||||||
/**
|
|
||||||
* 故障码Id
|
|
||||||
*/
|
|
||||||
private long faultcodeId;
|
|
||||||
/**
|
|
||||||
* 车辆Id
|
|
||||||
*/
|
|
||||||
private long carInformationId;
|
|
||||||
/**
|
|
||||||
* 车辆VIN
|
|
||||||
*/
|
|
||||||
private String carVin;
|
|
||||||
/**
|
|
||||||
* 开始报警时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@Excel(description = "开始报警时间",defaultValue = "2024-8-9 10:47:57",type = "Date")
|
|
||||||
private Date startwarningTime;
|
|
||||||
/**
|
|
||||||
* 结束报警时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@Excel(description = "结束报警时间",defaultValue = "2024-8-9 10:47:57",type = "Date")
|
|
||||||
private Date endwarningTime;
|
|
||||||
/**
|
|
||||||
* 故障码
|
|
||||||
*/
|
|
||||||
private String faultcodeNumber;
|
|
||||||
/**
|
|
||||||
* 车辆vin
|
|
||||||
*/
|
|
||||||
private String carInformationVIN;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库对象构建为返回结果对象
|
|
||||||
* @param faultLog
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static FaultLogListResp faultLogListResp(FaultLog faultLog){
|
|
||||||
return FaultLogListResp.builder()
|
|
||||||
.logId(faultLog.getLogId())
|
|
||||||
.faultcodeId(faultLog.getFaultcodeId())
|
|
||||||
.carInformationId(faultLog.getCarInformationId())
|
|
||||||
.carVin(faultLog.getCarVin())
|
|
||||||
.startwarningTime(faultLog.getStartwarningTime())
|
|
||||||
.endwarningTime(faultLog.getEndwarningTime())
|
|
||||||
.faultcodeNumber(faultLog.getFaultcodeNumber())
|
|
||||||
.carInformationVIN(faultLog.getCarInformationVIN())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package com.muyu.fault.domain.resp;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: Messages ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/22 10:55 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Tag(name="故障日志数据总数列表",description = "数据和总数的响应")
|
|
||||||
public class FaultLogTotalListResp {
|
|
||||||
|
|
||||||
private List<FaultLogListResp> faultLogListRespList;
|
|
||||||
|
|
||||||
private long total;
|
|
||||||
|
|
||||||
public static FaultLogTotalListResp faultLogTotalListResp(List<FaultLogListResp> faultLogListRespList,long total){
|
|
||||||
FaultLogTotalListResp faultLogTotalListResp = new FaultLogTotalListResp();
|
|
||||||
faultLogTotalListResp.setFaultLogListRespList(faultLogListRespList);
|
|
||||||
faultLogTotalListResp.setTotal(total);
|
|
||||||
return faultLogTotalListResp;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package com.muyu.fault.domain.vo;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.FaultCode;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
/**
|
|
||||||
* @className: FaultCodeVo ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 22:18 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
public class FaultCodeVo extends FaultCode {
|
|
||||||
/**
|
|
||||||
*故障类型名称
|
|
||||||
*/
|
|
||||||
private String faulttypeName;
|
|
||||||
/**
|
|
||||||
* 故障名称
|
|
||||||
*/
|
|
||||||
private String messageTypeName;
|
|
||||||
/**
|
|
||||||
* 报文编码
|
|
||||||
*/
|
|
||||||
private String messageTypeCode;
|
|
||||||
/**
|
|
||||||
*报文所属类别
|
|
||||||
*/
|
|
||||||
private String messageTypeBelongs;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package com.muyu.fault.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.muyu.fault.domain.CarType;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: CarTypeMapper ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CarTypeMapper extends BaseMapper<CarType> {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
package com.muyu.fault.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.FaultCode;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.FaultLabel;
|
|
||||||
import com.muyu.fault.domain.req.FaultCodeAddReq;
|
|
||||||
import com.muyu.fault.domain.req.FaultCodeListReq;
|
|
||||||
import com.muyu.fault.domain.req.FaultCodeUpdReq;
|
|
||||||
import com.muyu.fault.domain.vo.FaultCodeVo;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultCodeMapper ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface FaultCodeMapper extends BaseMapper<FaultCodeVo> {
|
|
||||||
|
|
||||||
List<FaultCodeVo> selectfaultcodelist(FaultCodeListReq faultCodeListReq);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//新增故障码
|
|
||||||
FaultLabel selectfaultName(@Param("messageTypeName") String messageTypeName);
|
|
||||||
FaultCode selectfaultCode(@Param("faultcodeNumber") String faultcodeNumber);
|
|
||||||
Integer insertfaultlabel(FaultCodeAddReq faultCodeAddReq);
|
|
||||||
Integer insertfaultcode(FaultCodeAddReq faultCodeAddReq);
|
|
||||||
|
|
||||||
//修改故障码
|
|
||||||
Integer updfaultlabel(FaultCodeUpdReq faultCodeUpdReq);
|
|
||||||
Integer updfaultcode(FaultCodeUpdReq faultCodeUpdReq);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Integer delfaultcode(@Param("messageTypeId") long messageTypeId);
|
|
||||||
Integer delfaultlabel(@Param("messageTypeId") long messageTypeId);
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package com.muyu.fault.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.FaultCondition;
|
|
||||||
import com.muyu.fault.domain.req.FaultConditionAddReq;
|
|
||||||
import com.muyu.fault.domain.req.FaultConditionListReq;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultConditionMapper ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface FaultConditionMapper extends BaseMapper<FaultCondition> {
|
|
||||||
|
|
||||||
List<FaultCondition> selectfaultconditionlist(FaultConditionListReq faultConditionListReq);
|
|
||||||
|
|
||||||
|
|
||||||
List<FaultCondition> selectBytypeAndlabel(FaultConditionAddReq faultConditionAddReq);
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
package com.muyu.fault.mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultDetectionStrategyMapper ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 23:59 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
public interface FaultDetectionStrategyMapper {
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package com.muyu.fault.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.muyu.fault.domain.FaultLabel;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLabelMapper ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface FaultLabelMapper extends BaseMapper<FaultLabel> {
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package com.muyu.fault.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.FaultLog;
|
|
||||||
import com.muyu.fault.domain.req.FaultLogListReq;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface FaultLogMapper extends BaseMapper<FaultLog> {
|
|
||||||
|
|
||||||
|
|
||||||
List<FaultLog> selectfaultLogMapper(FaultLogListReq faultLogListReq);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package com.muyu.fault.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.muyu.fault.domain.FaultRule;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultRuleMapper ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface FaultRuleMapper extends BaseMapper<FaultRule> {
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
package com.muyu.fault.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.FaultType;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultTypeMapper ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface FaultTypeMapper extends BaseMapper<FaultType> {
|
|
||||||
Integer add(FaultType faultType);
|
|
||||||
|
|
||||||
Integer update(FaultType faultType);
|
|
||||||
|
|
||||||
Integer delete(Integer id);
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package com.muyu.fault.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.message.Message;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: MessageMapper ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface MessageMapper extends BaseMapper<Message> {
|
|
||||||
void changestatus(Message message);
|
|
||||||
|
|
||||||
List<Message> unread();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package com.muyu.fault.mapper;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.SysCarFault;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: MessageMapper ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024-09-18 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 车辆故障Mapper接口
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface SysCarFaultMapper extends BaseMapper<SysCarFault>{
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package com.muyu.fault.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.muyu.fault.domain.CarType;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: CarTypeService ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
public interface CarTypeService extends IService<CarType> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆类型
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<CarType> selectcarType();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
package com.muyu.fault.service;
|
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.muyu.fault.domain.req.FaultCodeAddReq;
|
|
||||||
import com.muyu.fault.domain.req.FaultCodeListReq;
|
|
||||||
import com.muyu.fault.domain.req.FaultCodeUpdReq;
|
|
||||||
import com.muyu.fault.domain.resp.FaultCodeTotalListResp;
|
|
||||||
import com.muyu.fault.domain.vo.FaultCodeVo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultCodeService ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
public interface FaultCodeService extends IService<FaultCodeVo> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障码展示
|
|
||||||
* @param faultCodeListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
FaultCodeTotalListResp selectlist(FaultCodeListReq faultCodeListReq);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障码展示(故障码联查)
|
|
||||||
* @param faultCodeListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
FaultCodeTotalListResp selectfaultcodelist(FaultCodeListReq faultCodeListReq);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增故障码
|
|
||||||
* @param faultCodeAddReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void insert(FaultCodeAddReq faultCodeAddReq);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改故障码
|
|
||||||
* @param faultCodeUpdReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void upd(FaultCodeUpdReq faultCodeUpdReq);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除故障码
|
|
||||||
* @param messageTypeId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void del(Integer messageTypeId);
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package com.muyu.fault.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.muyu.fault.domain.FaultCondition;
|
|
||||||
import com.muyu.fault.domain.req.FaultConditionAddReq;
|
|
||||||
import com.muyu.fault.domain.req.FaultConditionListReq;
|
|
||||||
import com.muyu.fault.domain.resp.FaultConditionTotalListResp;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultConditionService ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
public interface FaultConditionService extends IService<FaultCondition> {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障规则
|
|
||||||
* @param faultConditionListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
FaultConditionTotalListResp getfaultrulelist(FaultConditionListReq faultConditionListReq);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障规则添加
|
|
||||||
* @param faultConditionAddReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<FaultCondition> selectBytypeAndlabel(FaultConditionAddReq faultConditionAddReq);
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package com.muyu.fault.service;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.CarFaultRule;
|
|
||||||
import com.muyu.fault.domain.FaultReport;
|
|
||||||
/**
|
|
||||||
* @className: FaultDetectionStrategy ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测策略的接口
|
|
||||||
*/
|
|
||||||
public interface FaultDetectionStrategy {
|
|
||||||
|
|
||||||
FaultReport detectFaults(CarFaultRule carFaultRule);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
package com.muyu.fault.service;
|
|
||||||
|
|
||||||
public interface FaultDetectionStrategyService {
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package com.muyu.fault.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.muyu.fault.domain.FaultLabel;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLabelService ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
public interface FaultLabelService extends IService<FaultLabel> {
|
|
||||||
/**
|
|
||||||
* 故障名称
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<FaultLabel> select();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package com.muyu.fault.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.muyu.fault.domain.FaultLog;
|
|
||||||
import com.muyu.fault.domain.req.FaultLogListReq;
|
|
||||||
import com.muyu.fault.domain.resp.FaultLogTotalListResp;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLogService ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
public interface FaultLogService extends IService<FaultLog> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障日志列表
|
|
||||||
* @param faultLogListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
FaultLogTotalListResp selectfaultlog(FaultLogListReq faultLogListReq);
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package com.muyu.fault.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.muyu.fault.domain.FaultRule;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultRuleService ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
public interface FaultRuleService extends IService<FaultRule> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆故障检测
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
String checkfaults(FaultRule faultRule);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package com.muyu.fault.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.muyu.fault.domain.FaultType;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultTypeService ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
public interface FaultTypeService extends IService<FaultType> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障码分类查询
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<FaultType> select();
|
|
||||||
|
|
||||||
Integer add(FaultType faultType);
|
|
||||||
|
|
||||||
Integer update(FaultType faultType);
|
|
||||||
|
|
||||||
Integer delete(Integer id);
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package com.muyu.fault.service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import com.muyu.fault.domain.SysCarFault;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆故障Service接口
|
|
||||||
*
|
|
||||||
* @author Yang鹏
|
|
||||||
* @date 2024-09-18
|
|
||||||
*/
|
|
||||||
public interface ISysCarFaultService extends IService<SysCarFault> {
|
|
||||||
/**
|
|
||||||
* 精确查询车辆故障
|
|
||||||
*
|
|
||||||
* @param id 车辆故障主键
|
|
||||||
* @return 车辆故障
|
|
||||||
*/
|
|
||||||
public SysCarFault selectSysCarFaultById(Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询车辆故障列表
|
|
||||||
*
|
|
||||||
* @param sysCarFault 车辆故障
|
|
||||||
* @return 车辆故障集合
|
|
||||||
*/
|
|
||||||
public List<SysCarFault> selectSysCarFaultList(SysCarFault sysCarFault);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断 车辆故障 id是否唯一
|
|
||||||
* @param sysCarFault 车辆故障
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
Boolean checkIdUnique(SysCarFault sysCarFault);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
package com.muyu.fault.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.muyu.fault.domain.message.Message;
|
|
||||||
import com.muyu.fault.domain.message.MessageReq;
|
|
||||||
import com.muyu.fault.domain.message.MessageSendReq;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: MessageService ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
public interface MessageService extends IService<Message> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 消息发送
|
|
||||||
* @param messageSendReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void sendmessage(MessageSendReq messageSendReq);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 消息查看
|
|
||||||
* @param messageReq
|
|
||||||
* @param
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<Message> selectmessage(MessageReq messageReq);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看消息改变状态
|
|
||||||
* @param message
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void changestatus(Message message);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看未读的消息
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<Message> unread();
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
package com.muyu.fault.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.CarType;
|
|
||||||
import com.muyu.fault.mapper.CarTypeMapper;
|
|
||||||
import com.muyu.fault.service.CarTypeService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: CarFaultRule ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 22:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class CarTypeServiceImpl extends ServiceImpl<CarTypeMapper, CarType> implements CarTypeService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CarTypeMapper carTypeMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆类型
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<CarType> selectcarType() {
|
|
||||||
LambdaQueryWrapper<CarType> carTypeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
List<CarType> list = this.list(carTypeLambdaQueryWrapper);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,122 +0,0 @@
|
||||||
package com.muyu.fault.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
|
||||||
import com.muyu.fault.domain.FaultCode;
|
|
||||||
import com.muyu.fault.domain.FaultLabel;
|
|
||||||
import com.muyu.fault.domain.req.FaultCodeAddReq;
|
|
||||||
import com.muyu.fault.domain.req.FaultCodeListReq;
|
|
||||||
import com.muyu.fault.domain.req.FaultCodeUpdReq;
|
|
||||||
import com.muyu.fault.domain.resp.FaultCodeListResp;
|
|
||||||
import com.muyu.fault.domain.resp.FaultCodeTotalListResp;
|
|
||||||
import com.muyu.fault.domain.vo.FaultCodeVo;
|
|
||||||
import com.muyu.fault.mapper.FaultCodeMapper;
|
|
||||||
import com.muyu.fault.service.FaultCodeService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class FaultCodeServiceImpl extends ServiceImpl<FaultCodeMapper, FaultCodeVo> implements FaultCodeService {
|
|
||||||
@Autowired
|
|
||||||
private FaultCodeMapper faultCodeMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障码展示
|
|
||||||
* @param faultCodeListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public FaultCodeTotalListResp selectlist(FaultCodeListReq faultCodeListReq) {
|
|
||||||
Integer pageNum = faultCodeListReq.getPageNum();
|
|
||||||
Integer pageSize = faultCodeListReq.getPageSize();
|
|
||||||
LambdaQueryWrapper<FaultCodeVo> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
queryWrapper.eq(StringUtils.isNotEmpty(faultCodeListReq.getFaultcodeNumber()),
|
|
||||||
FaultCodeVo::getFaultcodeNumber,faultCodeListReq.getFaultcodeNumber());
|
|
||||||
queryWrapper.eq(StringUtils.isNotEmpty(faultCodeListReq.getFaultBit()),
|
|
||||||
FaultCodeVo::getFaultBit,faultCodeListReq.getFaultBit());
|
|
||||||
long count = this.count(queryWrapper);
|
|
||||||
queryWrapper.last("LIMIT "+ ((pageNum-1)*pageSize)+", "+pageSize);
|
|
||||||
List<FaultCodeVo> faultCodeVOList = this.list(queryWrapper);
|
|
||||||
List<FaultCodeListResp> faultCodeListRespList = faultCodeVOList.stream()
|
|
||||||
.map(FaultCodeListResp::faultCodeListResp)
|
|
||||||
.toList();
|
|
||||||
return FaultCodeTotalListResp.faultCodeTotalListResp(faultCodeListRespList,count);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障码展示(故障码联查)
|
|
||||||
* @param faultCodeListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public FaultCodeTotalListResp selectfaultcodelist(FaultCodeListReq faultCodeListReq) {
|
|
||||||
LambdaQueryWrapper<FaultCodeVo> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
long count = this.count(queryWrapper);
|
|
||||||
int offset = (faultCodeListReq.getPageNum() - 1) * faultCodeListReq.getPageSize();
|
|
||||||
faultCodeListReq.setPageNum(offset);
|
|
||||||
List<FaultCodeVo> selectfaultcodelist = faultCodeMapper.selectfaultcodelist(faultCodeListReq);
|
|
||||||
List<FaultCodeListResp> faultCodeListRespList = selectfaultcodelist.stream()
|
|
||||||
.map(FaultCodeListResp::faultCodeListResp)
|
|
||||||
.toList();
|
|
||||||
return FaultCodeTotalListResp.faultCodeTotalListResp(faultCodeListRespList,count);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增故障码
|
|
||||||
* @param faultCodeAddReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void insert(FaultCodeAddReq faultCodeAddReq) {
|
|
||||||
//判断故障名称或故障码是否存在,若都不存在先添加故障名称表,在添加故障码表
|
|
||||||
//1.判断故障名称是否存在
|
|
||||||
String messageTypeName = faultCodeAddReq.getMessageTypeName();
|
|
||||||
FaultLabel faultLabel = faultCodeMapper.selectfaultName(messageTypeName);
|
|
||||||
//2.判断故障码是否存在
|
|
||||||
String faultcodeNumber = faultCodeAddReq.getFaultcodeNumber();
|
|
||||||
FaultCode faultCode = faultCodeMapper.selectfaultCode(faultcodeNumber);
|
|
||||||
if (faultLabel==null && faultCode==null){
|
|
||||||
faultCodeMapper.insertfaultlabel(faultCodeAddReq);
|
|
||||||
faultCodeMapper.insertfaultcode(faultCodeAddReq);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改故障码
|
|
||||||
* @param faultCodeUpdReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void upd(FaultCodeUpdReq faultCodeUpdReq) {
|
|
||||||
//修改故障名称表信息和故障码表信息
|
|
||||||
// faultCodeMapper.updfaultlabel(faultCodeUpdReq);
|
|
||||||
faultCodeMapper.updfaultcode(faultCodeUpdReq);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除故障码
|
|
||||||
* @param messageTypeId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void del(Integer messageTypeId) {
|
|
||||||
|
|
||||||
//删除故障码表信息
|
|
||||||
faultCodeMapper.delfaultcode(messageTypeId);
|
|
||||||
//删除对应的故障名称表信息
|
|
||||||
faultCodeMapper.delfaultlabel(messageTypeId);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
package com.muyu.fault.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.muyu.fault.domain.FaultCondition;
|
|
||||||
import com.muyu.fault.domain.req.FaultConditionAddReq;
|
|
||||||
import com.muyu.fault.domain.req.FaultConditionListReq;
|
|
||||||
import com.muyu.fault.domain.resp.FaultConditionListResp;
|
|
||||||
import com.muyu.fault.domain.resp.FaultConditionTotalListResp;
|
|
||||||
import com.muyu.fault.mapper.FaultConditionMapper;
|
|
||||||
import com.muyu.fault.service.FaultConditionService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class FaultConditionServiceImpl extends ServiceImpl<FaultConditionMapper, FaultCondition> implements FaultConditionService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FaultConditionMapper faultConditionMapper;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障规则
|
|
||||||
* @param faultConditionListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public FaultConditionTotalListResp getfaultrulelist(FaultConditionListReq faultConditionListReq) {
|
|
||||||
LambdaQueryWrapper<FaultCondition> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
long count = this.count(queryWrapper);
|
|
||||||
int offset = (faultConditionListReq.getPageNum() - 1) * faultConditionListReq.getPageSize();
|
|
||||||
faultConditionListReq.setPageNum(offset);
|
|
||||||
|
|
||||||
List<FaultCondition> selectfaultconditionlist = faultConditionMapper.selectfaultconditionlist(faultConditionListReq);
|
|
||||||
List<FaultConditionListResp> faultConditionListRespList = selectfaultconditionlist.stream()
|
|
||||||
.map(FaultConditionListResp::faultConditionListResp)
|
|
||||||
.toList();
|
|
||||||
return FaultConditionTotalListResp.faultConditionTotalListResp(faultConditionListRespList,count);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障规则添加 判断故障规则是否存在
|
|
||||||
* @param faultConditionAddReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<FaultCondition> selectBytypeAndlabel(FaultConditionAddReq faultConditionAddReq) {
|
|
||||||
List<FaultCondition> faultConditionList = faultConditionMapper.selectBytypeAndlabel(faultConditionAddReq);
|
|
||||||
return faultConditionList;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package com.muyu.fault.service.impl;
|
|
||||||
|
|
||||||
import com.muyu.fault.mapper.FaultDetectionStrategyMapper;
|
|
||||||
import com.muyu.fault.service.FaultDetectionStrategyService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultDetectionStrategyServiceImpl ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 23:58 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description:
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class FaultDetectionStrategyServiceImpl implements FaultDetectionStrategyService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FaultDetectionStrategyMapper faultDetectionStrategyMapper;
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package com.muyu.fault.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.FaultLabel;
|
|
||||||
import com.muyu.fault.mapper.FaultLabelMapper;
|
|
||||||
import com.muyu.fault.service.FaultLabelService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class FaultLabelServiceImpl extends ServiceImpl<FaultLabelMapper, FaultLabel> implements FaultLabelService {
|
|
||||||
@Autowired
|
|
||||||
private FaultLabelMapper faultLabelMapper;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障信息查询
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<FaultLabel> select() {
|
|
||||||
LambdaQueryWrapper<FaultLabel> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
List<FaultLabel> list = this.list(queryWrapper);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
package com.muyu.fault.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.FaultLog;
|
|
||||||
import com.muyu.fault.domain.req.FaultLogListReq;
|
|
||||||
import com.muyu.fault.domain.resp.FaultLogListResp;
|
|
||||||
import com.muyu.fault.domain.resp.FaultLogTotalListResp;
|
|
||||||
import com.muyu.fault.mapper.FaultLogMapper;
|
|
||||||
import com.muyu.fault.service.FaultLogService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class FaultLogServiceImpl extends ServiceImpl<FaultLogMapper, FaultLog> implements FaultLogService {
|
|
||||||
@Autowired
|
|
||||||
private FaultLogMapper faultLogMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障日志列表
|
|
||||||
* @param faultLogListReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public FaultLogTotalListResp selectfaultlog(FaultLogListReq faultLogListReq) {
|
|
||||||
LambdaQueryWrapper<FaultLog> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
long count = this.count(queryWrapper);
|
|
||||||
int offset = (faultLogListReq.getPageNum() - 1) * faultLogListReq.getPageSize();
|
|
||||||
faultLogListReq.setPageNum(offset);
|
|
||||||
List<FaultLog> faultLogListResps = faultLogMapper.selectfaultLogMapper(faultLogListReq);
|
|
||||||
List<FaultLogListResp> faultLogListRespList = faultLogListResps.stream()
|
|
||||||
.map(FaultLogListResp::faultLogListResp)
|
|
||||||
.toList();
|
|
||||||
return FaultLogTotalListResp.faultLogTotalListResp(faultLogListRespList,count);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
package com.muyu.fault.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.FaultRule;
|
|
||||||
import com.muyu.fault.mapper.FaultRuleMapper;
|
|
||||||
import com.muyu.fault.service.FaultRuleService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, FaultRule> implements FaultRuleService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FaultRuleMapper faultRuleMapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆故障检测
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String checkfaults(FaultRule faultRule) {
|
|
||||||
//获取触发条件
|
|
||||||
LambdaQueryWrapper<FaultRule> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
if (Long.valueOf(faultRule.getFaultcodeId())!=null && faultRule.getFaultcodeId()!=0){
|
|
||||||
queryWrapper.eq(FaultRule::getFaultcodeId, faultRule.getFaultcodeId());
|
|
||||||
}
|
|
||||||
List<FaultRule> faultRuleList = this.list(queryWrapper);
|
|
||||||
for (FaultRule rule : faultRuleList) {
|
|
||||||
//单个值比较
|
|
||||||
if (faultRule.getSingleThreshold()!=null && faultRule.getMaxThreshold()==null && faultRule.getMinThreshold()==null){
|
|
||||||
//大于阈值
|
|
||||||
if (faultRule.getConditionContent().contains(">") || faultRule.getConditionContent().contains("大于")){
|
|
||||||
if (faultRule.getThreshold().compareTo(rule.getSingleThreshold())>0){
|
|
||||||
return "数据超过阈值,出现异常";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//小于阈值
|
|
||||||
if (faultRule.getConditionContent().contains("<") || faultRule.getConditionContent().contains("小于")){
|
|
||||||
if (faultRule.getThreshold().compareTo(rule.getSingleThreshold())<0){
|
|
||||||
return "数据过低,出现异常";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else { //区间值比较
|
|
||||||
if (faultRule.getThreshold().compareTo(rule.getMinThreshold())<0 || faultRule.getThreshold().compareTo(rule.getMaxThreshold())>0){
|
|
||||||
return "数据不在可控范围内,出现异常";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "判断出现异常";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
package com.muyu.fault.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
|
|
||||||
import com.muyu.fault.domain.FaultType;
|
|
||||||
import com.muyu.fault.mapper.FaultTypeMapper;
|
|
||||||
import com.muyu.fault.service.FaultTypeService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class FaultTypeServiceImpl extends ServiceImpl<FaultTypeMapper, FaultType> implements FaultTypeService {
|
|
||||||
@Autowired
|
|
||||||
private FaultTypeMapper faultTypeMapper;
|
|
||||||
/**
|
|
||||||
* 故障码分类查询
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<FaultType> select() {
|
|
||||||
LambdaQueryWrapper<FaultType> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
List<FaultType> list = this.list(queryWrapper);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer add(FaultType faultType) {
|
|
||||||
return faultTypeMapper.add(faultType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer update(FaultType faultType) {
|
|
||||||
return faultTypeMapper.update(faultType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer delete(Integer id) {
|
|
||||||
return faultTypeMapper.delete(id);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,126 +0,0 @@
|
||||||
package com.muyu.fault.service.impl;
|
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.muyu.common.security.service.TokenService;
|
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
|
||||||
import com.muyu.fault.domain.message.Message;
|
|
||||||
import com.muyu.fault.domain.message.MessageReq;
|
|
||||||
import com.muyu.fault.domain.message.MessageSendReq;
|
|
||||||
import com.muyu.fault.mapper.MessageMapper;
|
|
||||||
import com.muyu.fault.service.MessageService;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @className: FaultLog ️✈️
|
|
||||||
* @author: Yang 鹏 🦅
|
|
||||||
* @date: 2024/9/23 21:06 ⏰
|
|
||||||
* @Version: 1.0
|
|
||||||
* @description: 故障检测
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> implements MessageService {
|
|
||||||
@Autowired
|
|
||||||
private TokenService tokenService;
|
|
||||||
@Autowired
|
|
||||||
private HttpServletRequest request;
|
|
||||||
@Autowired
|
|
||||||
private MessageMapper messageMapper;
|
|
||||||
/**
|
|
||||||
* 消息发送
|
|
||||||
* @param messageSendReq
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void sendmessage(MessageSendReq messageSendReq) {
|
|
||||||
String token = SecurityUtils.getToken();// 获取当前Token
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(token); // 获取当前登录用户
|
|
||||||
if (loginUser == null) {
|
|
||||||
throw new RuntimeException("用户未登录或Token无效");
|
|
||||||
}
|
|
||||||
Long userid = loginUser.getUserid();
|
|
||||||
messageSendReq.setUserId(userid);
|
|
||||||
|
|
||||||
// 定义一个DateTimeFormatter对象,用于格式化日期时间为yyyy-MM-dd HH:mm:ss
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
||||||
// 获取当前日期和时间
|
|
||||||
LocalDateTime now = LocalDateTime.now();
|
|
||||||
// 使用formatter格式化当前日期和时间
|
|
||||||
String formattedDateTime = now.format(formatter);
|
|
||||||
// 使用formatter将字符串解析回LocalDateTime
|
|
||||||
LocalDateTime parsedDateTime = LocalDateTime.parse(formattedDateTime, formatter);
|
|
||||||
// 然后按照上面的步骤将LocalDateTime转换为Date
|
|
||||||
ZonedDateTime zdt = parsedDateTime.atZone(ZoneId.systemDefault());
|
|
||||||
Date date = Date.from(zdt.toInstant());
|
|
||||||
// 现在date是一个包含了字符串中日期和时间的Date对象
|
|
||||||
messageSendReq.setCreateTime(date);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 消息查看
|
|
||||||
* @param messageReq
|
|
||||||
* @param
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Message> selectmessage(MessageReq messageReq) {
|
|
||||||
String token = SecurityUtils.getToken();// 获取当前Token
|
|
||||||
LoginUser loginUser = tokenService.getLoginUser(token); // 获取当前登录用户
|
|
||||||
if (loginUser == null) {
|
|
||||||
throw new RuntimeException("用户未登录或Token无效");
|
|
||||||
}
|
|
||||||
Long userid = loginUser.getUserid();
|
|
||||||
messageReq.setUserId(userid);
|
|
||||||
LambdaQueryWrapper<Message> queryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
// queryWrapper.eq(StringUtils.isNotEmpty(String.valueOf(messageReq.getStatus())),
|
|
||||||
// Message::getStatus,messageReq.getStatus());
|
|
||||||
// queryWrapper.eq(StringUtils.isNotEmpty(String.valueOf(messageReq.getUserId())),
|
|
||||||
// Message::getUserId,messageReq.getUserId());
|
|
||||||
if (messageReq.getStatus() != null) {
|
|
||||||
queryWrapper.eq(Message::getStatus, messageReq.getStatus());
|
|
||||||
}
|
|
||||||
queryWrapper.eq(Message::getUserId, messageReq.getUserId());
|
|
||||||
List<Message> list = this.list(queryWrapper);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看消息改变状态
|
|
||||||
* @param message
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void changestatus(Message message) {
|
|
||||||
messageMapper.changestatus(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看未读的消息
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Message> unread() {
|
|
||||||
// return messageMapper.unread();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue