文件系统,设备升级
This commit is contained in:
@@ -75,7 +75,15 @@ public enum AccessResponseEnum {
|
||||
FILE_CHECK_ERROR("A0312","文件校验码不一致!"),
|
||||
|
||||
CLD_MODEL_EXIST("A0313","云前置模板已存在,请先删除再录入!"),
|
||||
;
|
||||
|
||||
/**
|
||||
* A3001 ~ A3099 用于zlevent模块的枚举
|
||||
* <p>
|
||||
*/
|
||||
FILE_DOWNLOAD_FAIL("A3002", "文件下载失败!"),
|
||||
UNKNOWN_BUSINESS_TYPE_CODE("A3003", "未知业务type码"),
|
||||
FILE_UPLOAD_FAIL("A3004", "文件上传失败!"),
|
||||
TIME_OUT("A3005", "前置响应超时!"),;
|
||||
|
||||
private final String code;
|
||||
|
||||
|
||||
@@ -45,6 +45,19 @@ public enum TypeEnum {
|
||||
TYPE_29("9217","设备心跳请求"),
|
||||
TYPE_30("4865","设备数据主动上送"),
|
||||
TYPE_31("8503","设备控制命令"),
|
||||
READ_FILE_DIR("1101", "读取文件目录"),
|
||||
FILE_DOWNLOAD("1102", "文件下载"),
|
||||
FIXED_VALUE("1103", "定值读取/写入"),
|
||||
INNER_FIXED_VALUE("1104", "内部定值读取/写入"),
|
||||
|
||||
WORKING_LOG("1111","设备运行日志"),
|
||||
DEVICE_VERSION("1112","设备版本信息"),
|
||||
DEVICE_REBOOT("1114","设备重启"),
|
||||
DEVICE_UPGRADE("1115","设备升级"),
|
||||
FILE_UPLOAD("1116","文件上传"),
|
||||
FILE_DELETE("1117","文件删除"),
|
||||
MKDIR("1118","目录创建"),
|
||||
DIR_DELETE("1119","目录删除"),
|
||||
|
||||
/**
|
||||
* 数据类型
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.njcn.access.utils;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.pojo.dto.NoticeUserDto;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -25,6 +29,7 @@ import java.nio.charset.StandardCharsets;
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
public class SendMessageUtil {
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
@Value("${app.sendUrl:https://fc-mp-ff7b310f-94c9-4468-8260-109111c0a6b2.next.bspapp.com/push}")
|
||||
private String appSendUrl;
|
||||
@@ -67,4 +72,27 @@ public class SendMessageUtil {
|
||||
e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 轮询 Redis 等待响应
|
||||
*/
|
||||
public String waitForResponse(String guid, int timeoutSeconds) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
while (System.currentTimeMillis() - startTime < timeoutSeconds * 1000L) {
|
||||
String response = redisUtil.getStringByKey(AppRedisKey.COMMON_RESOPNSE + guid);
|
||||
if (response != null) {
|
||||
redisUtil.delete(AppRedisKey.COMMON_REQUEST + guid);
|
||||
redisUtil.delete(AppRedisKey.COMMON_RESOPNSE + guid);
|
||||
return response;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(100); // 100ms 轮询一次
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
throw new BusinessException(AccessResponseEnum.TIME_OUT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.tocrhz</groupId>
|
||||
<artifactId>mqtt-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
|
||||
Reference in New Issue
Block a user