diff --git a/das/pom.xml b/das/pom.xml
index 61fde9d6..df873674 100644
--- a/das/pom.xml
+++ b/das/pom.xml
@@ -31,6 +31,8 @@
3.2.10
3.4.4
5.4.3
+ 8.4.3
+ 1.5.3
@@ -201,6 +203,17 @@
+
+
+ io.minio
+ minio
+ ${minio.version}
+
+
+ org.jfree
+ jfreechart
+ ${jfreechart.version}
+
diff --git a/das/src/main/java/com/das/common/config/WebsocketConfig.java b/das/src/main/java/com/das/common/config/WebsocketConfig.java
index f28aee31..95361632 100644
--- a/das/src/main/java/com/das/common/config/WebsocketConfig.java
+++ b/das/src/main/java/com/das/common/config/WebsocketConfig.java
@@ -1,10 +1,9 @@
package com.das.common.config;
-import com.das.modules.node.handler.NodeHandshakeInterceptor;
-import com.das.modules.node.handler.NodeMessageHandler;
+import com.das.modules.node.handler.NodeWebsocketHandshakeInterceptor;
+import com.das.modules.node.service.impl.NodeMessageServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
-import org.springframework.stereotype.Component;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
@@ -12,15 +11,13 @@ import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry
@EnableWebSocket
@Configuration
public class WebsocketConfig implements WebSocketConfigurer {
- @Autowired
- NodeHandshakeInterceptor nodeHandshakeInterceptor;
@Autowired
- NodeMessageHandler nodeMessageHandler;
+ NodeMessageServiceImpl nodeMessageService;
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
- registry.addHandler(nodeMessageHandler, "/node/{nodeId}/{version}")
+ registry.addHandler(nodeMessageService, "/node/{nodeId}/{version}")
.setAllowedOrigins("*")
- .addInterceptors(nodeHandshakeInterceptor);
+ .addInterceptors(new NodeWebsocketHandshakeInterceptor());
}
}
diff --git a/das/src/main/java/com/das/common/constant/FileConstants.java b/das/src/main/java/com/das/common/constant/FileConstants.java
new file mode 100644
index 00000000..656d425c
--- /dev/null
+++ b/das/src/main/java/com/das/common/constant/FileConstants.java
@@ -0,0 +1,27 @@
+package com.das.common.constant;
+
+/**
+ * @Author liuyuxia
+ * @ClassName FilesvrConstants
+ * @Date 2018/12/10 0010 11:02
+ * @Version 2.5
+ * @Description 文件服务基础常量
+ **/
+public class FileConstants {
+
+ public static final String FILE_SEPARATOR = "/";
+
+ public static final String FILE_CHARSET = "UTF-8";
+
+ /**
+ * 递归
+ */
+ public static final Integer YES_RECURSIVE=1;
+ public static final Integer NO_RECURSIVE=0;
+
+ public static final int META_R = 1001;
+ public static final int META_W = 1002;
+
+ public static final String META_R_NAME = "读";
+ public static final String META_W_NAME = "写";
+}
diff --git a/das/src/main/java/com/das/modules/equipment/entity/SysEquipment.java b/das/src/main/java/com/das/modules/equipment/entity/SysEquipment.java
index 53f888db..8b1a83f6 100644
--- a/das/src/main/java/com/das/modules/equipment/entity/SysEquipment.java
+++ b/das/src/main/java/com/das/modules/equipment/entity/SysEquipment.java
@@ -137,4 +137,10 @@ public class SysEquipment extends BaseEntity {
*/
@TableField(value = "nominal_capacity")
private Double nominalCapacity;
+
+ /**
+ * 故障录波格式
+ */
+ @TableField(value = "fdr_format")
+ private String fdrFormat;
}
diff --git a/das/src/main/java/com/das/modules/equipment/service/impl/SysIotModelServiceImpl.java b/das/src/main/java/com/das/modules/equipment/service/impl/SysIotModelServiceImpl.java
index 67750e0c..0476b8c3 100644
--- a/das/src/main/java/com/das/modules/equipment/service/impl/SysIotModelServiceImpl.java
+++ b/das/src/main/java/com/das/modules/equipment/service/impl/SysIotModelServiceImpl.java
@@ -469,7 +469,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
addModelFieldCache(highCreateList.get(i));
}
}
- for (SysIotModelField item : calCreateList){
+ for (SysIotModelField item : calCreateList) {
createTdStableOrColumn(item);
addModelFieldCache(item);
}
@@ -582,7 +582,7 @@ public class SysIotModelServiceImpl implements SysIotModelService {
if (sysIotModelField.getAttributeType() == 199) {
Long iotModelId = sysIotModelField.getIotModelId();
String modelCode = dataService.iotModelMap.get(iotModelId.toString());
- tdEngineService.deleteStable("c_" + modelCode +"_"+ sysIotModelField.getAttributeCode());
+ tdEngineService.deleteStable("c_" + modelCode + "_" + sysIotModelField.getAttributeCode());
} else {
String stableName = null;
SysIotModel sysIotModel = sysIotModelMapper.selectById(sysIotModelField.getIotModelId());
@@ -611,6 +611,15 @@ public class SysIotModelServiceImpl implements SysIotModelService {
private void addModelFieldCache(SysIotModelField sysIotModelField) {
//获取物模型编码
String modelCode = dataService.iotModelMap.get(sysIotModelField.getIotModelId().toString());
+ Map fieldCodeNameMap = dataService.fieldCodeNameMap.get(modelCode);
+ if (fieldCodeNameMap == null) {
+ Map fieldCodeName = new HashMap<>();
+ fieldCodeName.put(sysIotModelField.getAttributeCode(),sysIotModelField.getAttributeName());
+ dataService.fieldCodeNameMap.put(modelCode,fieldCodeName);
+ }
+ else {
+ fieldCodeNameMap.put(sysIotModelField.getAttributeCode(), sysIotModelField.getAttributeName());
+ }
if (sysIotModelField.getAttributeType() == 199) {
Map map = dataService.calculateIotFieldMap.get(modelCode);
if (map == null) {
@@ -657,10 +666,12 @@ public class SysIotModelServiceImpl implements SysIotModelService {
private void deleteModelFieldCache(SysIotModelField sysIotModelField) {
//获取物模型编码
String modelCode = dataService.iotModelMap.get(sysIotModelField.getIotModelId().toString());
- if (sysIotModelField.getAttributeType() == 199){
+ Map fieldCodeName = dataService.fieldCodeNameMap.get(modelCode);
+ fieldCodeName.remove(sysIotModelField.getAttributeCode());
+ if (sysIotModelField.getAttributeType() == 199) {
Map map = dataService.calculateIotFieldMap.get(modelCode);
map.remove(sysIotModelField.getAttributeCode());
- }else {
+ } else {
if (sysIotModelField.getHighSpeed() == 0) {
Map map = dataService.lowIotFieldMap.get(modelCode);
map.remove(sysIotModelField.getAttributeCode());
diff --git a/das/src/main/java/com/das/modules/fdr/config/MinioConfig.java b/das/src/main/java/com/das/modules/fdr/config/MinioConfig.java
new file mode 100644
index 00000000..92941ef5
--- /dev/null
+++ b/das/src/main/java/com/das/modules/fdr/config/MinioConfig.java
@@ -0,0 +1,71 @@
+package com.das.modules.fdr.config;
+
+import io.minio.*;
+import io.minio.errors.*;
+import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+
+@Slf4j
+@Configuration
+@ConditionalOnClass(MinioClient.class)
+public class MinioConfig {
+
+ @Resource
+ private MinioProperties minioAutoProperties;
+ @Bean
+ public MinioClient minioClient() {
+ log.info("开始初始化MinioClient, url为{}, accessKey为:{}", minioAutoProperties.getUrl(), minioAutoProperties.getAccessKey());
+ MinioClient minioClient = MinioClient
+ .builder()
+ .endpoint(minioAutoProperties.getUrl())
+ .credentials(minioAutoProperties.getAccessKey(), minioAutoProperties.getSecretKey())
+ .build();
+
+ minioClient.setTimeout(
+ minioAutoProperties.getConnectTimeout(),
+ minioAutoProperties.getWriteTimeout(),
+ minioAutoProperties.getReadTimeout()
+ );
+ // Start detection
+ if (minioAutoProperties.isCheckBucket()) {
+ log.info("checkBucket为{}, 开始检测桶是否存在", minioAutoProperties.isCheckBucket());
+ String bucketName = minioAutoProperties.getBucket();
+ if (!checkBucket(bucketName, minioClient)) {
+ log.info("文件桶[{}]不存在, 开始检查是否可以新建桶", bucketName);
+ if (minioAutoProperties.isCreateBucket()) {
+ log.info("createBucket为{},开始新建文件桶", minioAutoProperties.isCreateBucket());
+ createBucket(bucketName, minioClient);
+ }
+ }
+ log.info("文件桶[{}]已存在, minio客户端连接成功!", bucketName);
+ } else {
+ throw new RuntimeException("桶不存在, 请检查桶名称是否正确或者将checkBucket属性改为false");
+ }
+ return minioClient;
+ }
+
+ private boolean checkBucket(String bucketName, MinioClient minioClient) {
+ boolean isExists = false;
+ try {
+ isExists = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build());
+ } catch (Exception e) {
+ throw new RuntimeException("failed to check if the bucket exists", e);
+ }
+ return isExists;
+ }
+
+ private void createBucket(String bucketName, MinioClient minioClient) {
+ try {
+ minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build());
+ log.info("文件桶[{}]新建成功, minio客户端已连接", bucketName);
+ } catch (Exception e) {
+ throw new RuntimeException("failed to create default bucket", e);
+ }
+ }
+
+}
diff --git a/das/src/main/java/com/das/modules/fdr/config/MinioProperties.java b/das/src/main/java/com/das/modules/fdr/config/MinioProperties.java
new file mode 100644
index 00000000..3ce7cfed
--- /dev/null
+++ b/das/src/main/java/com/das/modules/fdr/config/MinioProperties.java
@@ -0,0 +1,70 @@
+package com.das.modules.fdr.config;
+
+import jakarta.validation.constraints.NotEmpty;
+import lombok.Data;
+import org.hibernate.validator.constraints.URL;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Component;
+import org.springframework.validation.annotation.Validated;
+
+@Data
+@Validated
+@Component
+public class MinioProperties {
+ /**
+ * 服务地址
+ */
+ @NotEmpty(message = "minio服务地址不可为空")
+ @URL(message = "minio服务地址格式错误")
+ @Value("${minio.url}")
+ private String url;
+
+ /**
+ * 认证账户
+ */
+ @NotEmpty(message = "minio认证账户不可为空")
+ @Value("${minio.accessKey}")
+ private String accessKey;
+
+ /**
+ * 认证密码
+ */
+ @NotEmpty(message = "minio认证密码不可为空")
+ @Value("${minio.secretKey}")
+ private String secretKey;
+
+ /**
+ * 桶名称, 优先级最低
+ */
+ @Value("${minio.bucket}")
+ private String bucket;
+
+ /**
+ * 桶不在的时候是否新建桶
+ */
+ private boolean createBucket = true;
+
+ /**
+ * 启动的时候检查桶是否存在
+ */
+ private boolean checkBucket = true;
+
+ /**
+ * 设置HTTP连接、写入和读取超时。值为0意味着没有超时
+ * HTTP连接超时,以毫秒为单位。
+ */
+ private long connectTimeout;
+
+ /**
+ * 设置HTTP连接、写入和读取超时。值为0意味着没有超时
+ * HTTP写超时,以毫秒为单位。
+ */
+ private long writeTimeout;
+
+ /**
+ * 设置HTTP连接、写入和读取超时。值为0意味着没有超时
+ * HTTP读取超时,以毫秒为单位。
+ */
+ private long readTimeout;
+}
diff --git a/das/src/main/java/com/das/modules/fdr/controller/FaultRecorderController.java b/das/src/main/java/com/das/modules/fdr/controller/FaultRecorderController.java
new file mode 100644
index 00000000..17e22d98
--- /dev/null
+++ b/das/src/main/java/com/das/modules/fdr/controller/FaultRecorderController.java
@@ -0,0 +1,48 @@
+package com.das.modules.fdr.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.das.common.result.R;
+import com.das.modules.equipment.entity.SysEquipment;
+import com.das.modules.fdr.domain.FileNode;
+import com.das.modules.fdr.service.FaultRecorderService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 故障录波controller
+ */
+@Slf4j
+@RequestMapping("/api/fdr")
+@RestController
+public class FaultRecorderController {
+
+ @Autowired
+ private FaultRecorderService faultRecorderService;
+
+ @RequestMapping(value = "/files", method = RequestMethod.POST)
+ public R> findList(@RequestBody JSONObject jsonObject) {
+ String code = jsonObject.getString("deviceCode");
+ String startTime = jsonObject.getString("startTime");
+ String endTime = jsonObject.getString("endTime");
+ List result = faultRecorderService.getDirOrFileList(code,startTime,endTime);
+ return R.success(result);
+ }
+
+ @RequestMapping(value = "/parseData", method = RequestMethod.POST)
+ public R