Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9fc3e126d9 | |||
| 498fbe930e | |||
| 200004913e | |||
| 71107fe36d | |||
| 216225f0cb | |||
| 2eeabddf5c | |||
| 6983cd39fe | |||
| 15f84c1bc0 | |||
| 2cad107c29 | |||
| 0f532033b0 | |||
| b418855d02 | |||
|
|
9774172c0b | ||
| da75f74218 | |||
|
|
7670793d5e | ||
|
|
6f87784ddf | ||
| 6dcee1f6c3 | |||
| 02d321d4d4 | |||
| f5b97d83b3 | |||
| 8041c5f27e | |||
| 48c79b721e | |||
| eaacce339e | |||
| fafcaf3bf0 | |||
| c2b48d6830 | |||
| 6b24e49651 | |||
| b3d2727a64 | |||
| 441b5d04fe | |||
| 292e8b58a5 | |||
| d20c869bad | |||
| 71b9bee182 | |||
| f227fe3c3f |
@@ -20,6 +20,15 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.njcn</groupId>
|
||||||
|
<artifactId>common-mq</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.tocrhz</groupId>
|
||||||
|
<artifactId>mqtt-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.njcn</groupId>
|
<groupId>com.njcn</groupId>
|
||||||
<artifactId>common-core</artifactId>
|
<artifactId>common-core</artifactId>
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.njcn.access.api;
|
||||||
|
|
||||||
|
import com.njcn.access.api.fallback.CsDeviceClientFallbackFactory;
|
||||||
|
import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@FeignClient(value = ServerInfo.ACCESS_BOOT, path = "/device", fallbackFactory = CsDeviceClientFallbackFactory.class,contextId = "device")
|
||||||
|
|
||||||
|
public interface CsDeviceFeignClient {
|
||||||
|
|
||||||
|
@PostMapping("/updateRunStatus")
|
||||||
|
HttpResult<String> updateRunStatus(@RequestParam("nDid") String nDid, @RequestParam("runStatus") Integer runStatus);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.njcn.access.api;
|
||||||
|
|
||||||
|
import com.njcn.access.api.fallback.CsHeartbeatClientFallbackFactory;
|
||||||
|
import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.mq.message.HeartbeatTimeoutMessage;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@FeignClient(value = ServerInfo.ACCESS_BOOT, path = "/heartbeat", fallbackFactory = CsHeartbeatClientFallbackFactory.class,contextId = "heartbeat")
|
||||||
|
public interface CsHeartbeatFeignClient {
|
||||||
|
|
||||||
|
@PostMapping("/handleHeartbeat")
|
||||||
|
@ApiOperation("处理物联设备心跳")
|
||||||
|
HttpResult<String> handleHeartbeat(@RequestBody HeartbeatTimeoutMessage message);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.njcn.access.api.fallback;
|
||||||
|
|
||||||
|
import com.njcn.access.api.CsDeviceFeignClient;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import feign.hystrix.FallbackFactory;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class CsDeviceClientFallbackFactory implements FallbackFactory<CsDeviceFeignClient> {
|
||||||
|
@Override
|
||||||
|
public CsDeviceFeignClient create(Throwable cause) {
|
||||||
|
//判断抛出异常是否为解码器抛出的业务异常
|
||||||
|
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||||
|
if (cause.getCause() instanceof BusinessException) {
|
||||||
|
BusinessException businessException = (BusinessException) cause.getCause();
|
||||||
|
}
|
||||||
|
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||||
|
return new CsDeviceFeignClient() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<String> updateRunStatus(String nDid, Integer runStatus) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","云设备状态调整异常",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.njcn.access.api.fallback;
|
||||||
|
|
||||||
|
import com.njcn.access.api.CsHeartbeatFeignClient;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.mq.message.HeartbeatTimeoutMessage;
|
||||||
|
import feign.hystrix.FallbackFactory;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class CsHeartbeatClientFallbackFactory implements FallbackFactory<CsHeartbeatFeignClient> {
|
||||||
|
@Override
|
||||||
|
public CsHeartbeatFeignClient create(Throwable cause) {
|
||||||
|
//判断抛出异常是否为解码器抛出的业务异常
|
||||||
|
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||||
|
if (cause.getCause() instanceof BusinessException) {
|
||||||
|
BusinessException businessException = (BusinessException) cause.getCause();
|
||||||
|
}
|
||||||
|
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||||
|
return new CsHeartbeatFeignClient() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<String> handleHeartbeat(HeartbeatTimeoutMessage message) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","处理物联设备心跳数据异常",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,7 +30,7 @@ public enum AccessResponseEnum {
|
|||||||
DEV_MODEL_NOT_FIND("A0303","装置型号未找到!"),
|
DEV_MODEL_NOT_FIND("A0303","装置型号未找到!"),
|
||||||
DEV_IS_NOT_ZL("A0303","注册装置不是直连装置!"),
|
DEV_IS_NOT_ZL("A0303","注册装置不是直连装置!"),
|
||||||
DEV_IS_NOT_WG("A0303","注册装置不是网关!"),
|
DEV_IS_NOT_WG("A0303","注册装置不是网关!"),
|
||||||
DEV_IS_NOT_PORTABLE("A0303","注册装置不是便携式装置!"),
|
DEV_IS_NOT_PORTABLE("A0303","注册装置不是便携式装置或者在线监测设备!"),
|
||||||
|
|
||||||
REGISTER_RESPONSE_ERROR("A0304","装置注册,装置侧应答失败!"),
|
REGISTER_RESPONSE_ERROR("A0304","装置注册,装置侧应答失败!"),
|
||||||
ACCESS_RESPONSE_ERROR("A0304","装置注册,装置侧应答失败!"),
|
ACCESS_RESPONSE_ERROR("A0304","装置注册,装置侧应答失败!"),
|
||||||
@@ -75,7 +75,15 @@ public enum AccessResponseEnum {
|
|||||||
FILE_CHECK_ERROR("A0312","文件校验码不一致!"),
|
FILE_CHECK_ERROR("A0312","文件校验码不一致!"),
|
||||||
|
|
||||||
CLD_MODEL_EXIST("A0313","云前置模板已存在,请先删除再录入!"),
|
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;
|
private final String code;
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,19 @@ public enum TypeEnum {
|
|||||||
TYPE_29("9217","设备心跳请求"),
|
TYPE_29("9217","设备心跳请求"),
|
||||||
TYPE_30("4865","设备数据主动上送"),
|
TYPE_30("4865","设备数据主动上送"),
|
||||||
TYPE_31("8503","设备控制命令"),
|
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","目录删除"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据类型
|
* 数据类型
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import lombok.Data;
|
|||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,6 +17,11 @@ import java.util.List;
|
|||||||
@Data
|
@Data
|
||||||
public class DevAccessParam implements Serializable {
|
public class DevAccessParam implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("工程id")
|
||||||
|
private String engineeringId;
|
||||||
|
|
||||||
@ApiModelProperty("项目id")
|
@ApiModelProperty("项目id")
|
||||||
@NotNull(message = "项目id不能为空")
|
@NotNull(message = "项目id不能为空")
|
||||||
private String projectId;
|
private String projectId;
|
||||||
@@ -68,6 +72,9 @@ public class DevAccessParam implements Serializable {
|
|||||||
@ApiModelProperty("中心点纬度")
|
@ApiModelProperty("中心点纬度")
|
||||||
@NotNull(message = "中心点纬度不能为空")
|
@NotNull(message = "中心点纬度不能为空")
|
||||||
private Double lat;
|
private Double lat;
|
||||||
|
|
||||||
|
@ApiModelProperty("拓扑图指标id")
|
||||||
|
private String target;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public class FileCommonUtils {
|
|||||||
*/
|
*/
|
||||||
public void cleanRedisData(String nDid, String fileName) {
|
public void cleanRedisData(String nDid, String fileName) {
|
||||||
redisUtil.deleteKeysByString("downloadFilePath:"+ nDid);
|
redisUtil.deleteKeysByString("downloadFilePath:"+ nDid);
|
||||||
|
redisUtil.deleteKeysByString("isWeb:"+ nDid);
|
||||||
redisUtil.delete("fileDowning:"+nDid);
|
redisUtil.delete("fileDowning:"+nDid);
|
||||||
redisUtil.delete("fileCheck" + nDid + fileName);
|
redisUtil.delete("fileCheck" + nDid + fileName);
|
||||||
redisUtil.delete(AppRedisKey.FILE_PART_TIME.concat(fileName));
|
redisUtil.delete(AppRedisKey.FILE_PART_TIME.concat(fileName));
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
package com.njcn.access.utils;
|
package com.njcn.access.utils;
|
||||||
|
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
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.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.AllArgsConstructor;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -20,13 +26,18 @@ import java.nio.charset.StandardCharsets;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@AllArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SendMessageUtil {
|
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;
|
||||||
|
|
||||||
|
//App客户端消息推送
|
||||||
public void sendEventToUser(NoticeUserDto noticeUserDto) {
|
public void sendEventToUser(NoticeUserDto noticeUserDto) {
|
||||||
try {
|
try {
|
||||||
// 创建一个URL对象,指定目标HTTPS接口地址
|
// 创建一个URL对象,指定目标HTTPS接口地址
|
||||||
URL url = new URL("https://fc-mp-ff7b310f-94c9-4468-8260-109111c0a6b2.next.bspapp.com/push");
|
URL url = new URL(appSendUrl);
|
||||||
// 打开HTTPS连接
|
// 打开HTTPS连接
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
// 设置请求方法为POST
|
// 设置请求方法为POST
|
||||||
@@ -60,4 +71,27 @@ public class SendMessageUtil {
|
|||||||
e.getMessage();
|
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>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.tocrhz</groupId>
|
||||||
|
<artifactId>mqtt-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.paho</groupId>
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.njcn.access.controller;
|
|||||||
|
|
||||||
import com.njcn.access.param.DevAccessParam;
|
import com.njcn.access.param.DevAccessParam;
|
||||||
import com.njcn.access.service.ICsDeviceService;
|
import com.njcn.access.service.ICsDeviceService;
|
||||||
|
import com.njcn.access.service.ICsEquipmentDeliveryService;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
@@ -34,6 +35,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
public class CsDeviceController extends BaseController {
|
public class CsDeviceController extends BaseController {
|
||||||
|
|
||||||
private final ICsDeviceService csDeviceService;
|
private final ICsDeviceService csDeviceService;
|
||||||
|
private final ICsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
@@ -120,4 +122,42 @@ public class CsDeviceController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/autoPortableLedger")
|
||||||
|
@ApiOperation("调整便携式设备的台账信息")
|
||||||
|
@ReturnMsg
|
||||||
|
public HttpResult<String> autoPortableLedger(){
|
||||||
|
String methodDescribe = getMethodDescribe("autoPortableLedger");
|
||||||
|
csDeviceService.autoPortableLedger();
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/updateRunStatus")
|
||||||
|
@ApiOperation("设备状态调整")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "nDid", value = "设备识别码", required = true),
|
||||||
|
@ApiImplicitParam(name = "runStatus", value = "状态", required = true)
|
||||||
|
})
|
||||||
|
public HttpResult<String> updateRunStatus(@RequestParam String nDid, @RequestParam Integer runStatus){
|
||||||
|
String methodDescribe = getMethodDescribe("updateRunStatus");
|
||||||
|
csEquipmentDeliveryService.updateRunStatusBynDid(nDid,runStatus);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/onlineRegister")
|
||||||
|
@ApiOperation("监测设备接入")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "projectId", value = "项目id", required = true),
|
||||||
|
@ApiImplicitParam(name = "nDid", value = "设备识别码", required = true)
|
||||||
|
})
|
||||||
|
@ReturnMsg
|
||||||
|
public HttpResult<String> onlineRegister(@RequestParam("projectId") String projectId,@RequestParam("nDid") String nDid){
|
||||||
|
String methodDescribe = getMethodDescribe("onlineRegister");
|
||||||
|
String result = csDeviceService.onlineRegister(projectId,nDid);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.njcn.access.controller;
|
||||||
|
|
||||||
|
import com.njcn.access.service.ICsHeartService;
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
|
import com.njcn.mq.message.HeartbeatTimeoutMessage;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/9/6 11:07
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/heartbeat")
|
||||||
|
@Api(tags = "心跳")
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ApiIgnore
|
||||||
|
public class CsHeartController extends BaseController {
|
||||||
|
|
||||||
|
private final ICsHeartService csHeartService;
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/handleHeartbeat")
|
||||||
|
@ApiOperation("处理物联设备心跳")
|
||||||
|
@ApiImplicitParam(name = "message", value = "message", required = true)
|
||||||
|
public HttpResult<String> handleHeartbeat(@RequestBody HeartbeatTimeoutMessage message){
|
||||||
|
String methodDescribe = getMethodDescribe("handleHeartbeat");
|
||||||
|
csHeartService.handleHeartbeat(message);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/csLineLatestData")
|
@RequestMapping("/csLineLatestData")
|
||||||
@Api(tags = "暂降事件")
|
@Api(tags = "治理设备模块运行状态记录")
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class CsLineLatestDataController extends BaseController {
|
public class CsLineLatestDataController extends BaseController {
|
||||||
|
|
||||||
|
|||||||
@@ -22,10 +22,7 @@ import com.njcn.access.pojo.dto.file.FileRedisDto;
|
|||||||
import com.njcn.access.pojo.param.ReqAndResParam;
|
import com.njcn.access.pojo.param.ReqAndResParam;
|
||||||
import com.njcn.access.pojo.po.CsLineModel;
|
import com.njcn.access.pojo.po.CsLineModel;
|
||||||
import com.njcn.access.pojo.po.CsTopic;
|
import com.njcn.access.pojo.po.CsTopic;
|
||||||
import com.njcn.access.service.ICsDeviceOnlineLogsService;
|
import com.njcn.access.service.*;
|
||||||
import com.njcn.access.service.ICsEquipmentDeliveryService;
|
|
||||||
import com.njcn.access.service.ICsLineModelService;
|
|
||||||
import com.njcn.access.service.ICsTopicService;
|
|
||||||
import com.njcn.access.utils.ChannelObjectUtil;
|
import com.njcn.access.utils.ChannelObjectUtil;
|
||||||
import com.njcn.common.pojo.dto.DeviceLogDTO;
|
import com.njcn.common.pojo.dto.DeviceLogDTO;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
@@ -59,7 +56,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import javax.validation.ConstraintViolation;
|
import javax.validation.ConstraintViolation;
|
||||||
import javax.validation.Validator;
|
import javax.validation.Validator;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.Instant;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.DateTimeFormatterBuilder;
|
import java.time.format.DateTimeFormatterBuilder;
|
||||||
@@ -103,6 +99,7 @@ public class MqttMessageHandler {
|
|||||||
private final WaveFeignClient waveFeignClient;
|
private final WaveFeignClient waveFeignClient;
|
||||||
private final RtFeignClient rtFeignClient;
|
private final RtFeignClient rtFeignClient;
|
||||||
private final CsCommunicateFeignClient csCommunicateFeignClient;
|
private final CsCommunicateFeignClient csCommunicateFeignClient;
|
||||||
|
private final IHeartbeatService heartbeatService;
|
||||||
@Autowired
|
@Autowired
|
||||||
Validator validator;
|
Validator validator;
|
||||||
|
|
||||||
@@ -312,7 +309,7 @@ public class MqttMessageHandler {
|
|||||||
if (Objects.equals(res.getCode(),AccessEnum.SUCCESS.getCode())){
|
if (Objects.equals(res.getCode(),AccessEnum.SUCCESS.getCode())){
|
||||||
int mid = 1;
|
int mid = 1;
|
||||||
//修改装置状态
|
//修改装置状态
|
||||||
csEquipmentDeliveryService.updateStatusBynDid(nDid,AccessEnum.ACCESS.getCode());
|
csEquipmentDeliveryService.updateStatusBynDid(nDid,AccessEnum.ACCESS.getCode(),null,null);
|
||||||
csEquipmentDeliveryService.updateRunStatusBynDid(nDid,AccessEnum.ONLINE.getCode());
|
csEquipmentDeliveryService.updateRunStatusBynDid(nDid,AccessEnum.ONLINE.getCode());
|
||||||
//记录设备上线
|
//记录设备上线
|
||||||
PqsCommunicateDto dto = new PqsCommunicateDto();
|
PqsCommunicateDto dto = new PqsCommunicateDto();
|
||||||
@@ -328,7 +325,7 @@ public class MqttMessageHandler {
|
|||||||
//更新电网侧、负载侧监测点信息
|
//更新电网侧、负载侧监测点信息
|
||||||
askDevData(nDid,version,3,(res.getMid()+1));
|
askDevData(nDid,version,3,(res.getMid()+1));
|
||||||
//接入后系统重置装置心跳
|
//接入后系统重置装置心跳
|
||||||
redisUtil.saveByKeyWithExpire("MQTT:" + nDid, Instant.now().toEpochMilli(),180L);
|
heartbeatService.receiveHeartbeat(nDid);
|
||||||
//修改redis的mid
|
//修改redis的mid
|
||||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,1);
|
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,1);
|
||||||
//接入成功标识
|
//接入成功标识
|
||||||
@@ -349,7 +346,6 @@ public class MqttMessageHandler {
|
|||||||
if (!Objects.isNull(rspDataDto.getDataType())) {
|
if (!Objects.isNull(rspDataDto.getDataType())) {
|
||||||
switch (rspDataDto.getDataType()){
|
switch (rspDataDto.getDataType()){
|
||||||
case 1:
|
case 1:
|
||||||
log.info("{},设备数据应答--->更新设备软件信息", nDid);
|
|
||||||
logDto.setOperate(nDid + "更新设备软件信息");
|
logDto.setOperate(nDid + "更新设备软件信息");
|
||||||
RspDataDto.SoftInfo softInfo = JSON.parseObject(JSON.toJSONString(rspDataDto.getDataArray()), RspDataDto.SoftInfo.class);
|
RspDataDto.SoftInfo softInfo = JSON.parseObject(JSON.toJSONString(rspDataDto.getDataArray()), RspDataDto.SoftInfo.class);
|
||||||
//记录设备软件信息
|
//记录设备软件信息
|
||||||
@@ -380,7 +376,6 @@ public class MqttMessageHandler {
|
|||||||
List<RspDataDto.LdevInfo> devInfo = JSON.parseArray(JSON.toJSONString(rspDataDto.getDataArray()), RspDataDto.LdevInfo.class);
|
List<RspDataDto.LdevInfo> devInfo = JSON.parseArray(JSON.toJSONString(rspDataDto.getDataArray()), RspDataDto.LdevInfo.class);
|
||||||
if (CollectionUtil.isNotEmpty(devInfo)){
|
if (CollectionUtil.isNotEmpty(devInfo)){
|
||||||
if (Objects.equals(res.getDid(),1)){
|
if (Objects.equals(res.getDid(),1)){
|
||||||
log.info("{},设备数据应答--->更新治理监测点信息和设备容量", nDid);
|
|
||||||
List<CsDevCapacityPO> list3 = new ArrayList<>();
|
List<CsDevCapacityPO> list3 = new ArrayList<>();
|
||||||
boolean hasZeroClDid = devInfo.stream().anyMatch(item -> item.getClDid() == 0);
|
boolean hasZeroClDid = devInfo.stream().anyMatch(item -> item.getClDid() == 0);
|
||||||
//治理设备
|
//治理设备
|
||||||
@@ -409,7 +404,6 @@ public class MqttMessageHandler {
|
|||||||
equipmentFeignClient.updateModuleNumber(nDid,(devInfo.size()-1));
|
equipmentFeignClient.updateModuleNumber(nDid,(devInfo.size()-1));
|
||||||
}
|
}
|
||||||
} else if (Objects.equals(res.getDid(),2)) {
|
} else if (Objects.equals(res.getDid(),2)) {
|
||||||
log.info("{},设备数据应答--->更新电网侧、负载侧监测点信息", nDid);
|
|
||||||
logDto.setOperate(nDid + "更新电网侧、负载侧监测点信息");
|
logDto.setOperate(nDid + "更新电网侧、负载侧监测点信息");
|
||||||
//1.更新电网侧、负载侧监测点相关信息
|
//1.更新电网侧、负载侧监测点相关信息
|
||||||
devInfo.forEach(item->{
|
devInfo.forEach(item->{
|
||||||
@@ -419,14 +413,12 @@ public class MqttMessageHandler {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
log.info("{}模块{}:处理实时数据", nDid, rspDataDto.getClDid());
|
|
||||||
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(res));
|
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(res));
|
||||||
AppAutoDataMessage appAutoDataMessage = JSONObject.toJavaObject(jsonObject, AppAutoDataMessage.class);
|
AppAutoDataMessage appAutoDataMessage = JSONObject.toJavaObject(jsonObject, AppAutoDataMessage.class);
|
||||||
appAutoDataMessage.setId(nDid);
|
appAutoDataMessage.setId(nDid);
|
||||||
rtFeignClient.apfRtAnalysis(appAutoDataMessage);
|
rtFeignClient.apfRtAnalysis(appAutoDataMessage);
|
||||||
break;
|
break;
|
||||||
case 48:
|
case 48:
|
||||||
log.info("询问装置项目列表");
|
|
||||||
logDto.setUserName("运维管理员");
|
logDto.setUserName("运维管理员");
|
||||||
logDto.setOperate("监测点:" + (nDid + rspDataDto.getClDid()) + "询问项目列表");
|
logDto.setOperate("监测点:" + (nDid + rspDataDto.getClDid()) + "询问项目列表");
|
||||||
List<RspDataDto.ProjectInfo> projectInfoList = JSON.parseArray(JSON.toJSONString(rspDataDto.getDataArray()), RspDataDto.ProjectInfo.class);
|
List<RspDataDto.ProjectInfo> projectInfoList = JSON.parseArray(JSON.toJSONString(rspDataDto.getDataArray()), RspDataDto.ProjectInfo.class);
|
||||||
@@ -439,7 +431,6 @@ public class MqttMessageHandler {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4663:
|
case 4663:
|
||||||
log.info("装置操作应答");
|
|
||||||
if (Objects.equals(res.getCode(),AccessEnum.SUCCESS.getCode())){
|
if (Objects.equals(res.getCode(),AccessEnum.SUCCESS.getCode())){
|
||||||
String key4 = AppRedisKey.CONTROL + nDid;
|
String key4 = AppRedisKey.CONTROL + nDid;
|
||||||
redisUtil.saveByKeyWithExpire(key4,"success",10L);
|
redisUtil.saveByKeyWithExpire(key4,"success",10L);
|
||||||
@@ -492,33 +483,37 @@ public class MqttMessageHandler {
|
|||||||
//响应请求
|
//响应请求
|
||||||
switch (res.getType()){
|
switch (res.getType()){
|
||||||
case 4865:
|
case 4865:
|
||||||
//设置心跳时间,超时改为掉线
|
heartbeatService.receiveHeartbeat(nDid);
|
||||||
redisUtil.saveByKeyWithExpire("MQTT:" + nDid, Instant.now().toEpochMilli(),180L);
|
|
||||||
//有心跳,则将装置改成在线
|
//有心跳,则将装置改成在线
|
||||||
//csEquipmentDeliveryService.updateRunStatusBynDid(nDid,AccessEnum.ONLINE.getCode());
|
//csEquipmentDeliveryService.updateRunStatusBynDid(nDid,AccessEnum.ONLINE.getCode());
|
||||||
//处理心跳
|
//处理心跳 判断设备是否接入,如果设备已经接入则响应,不然忽略
|
||||||
ReqAndResDto.Res reqAndResParam = new ReqAndResDto.Res();
|
CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(nDid).getData();
|
||||||
reqAndResParam.setMid(res.getMid());
|
if (Objects.nonNull(po)) {
|
||||||
reqAndResParam.setDid(0);
|
if (po.getUsageStatus() == 1 && po.getRunStatus() == 2 && po.getStatus() == 3) {
|
||||||
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
ReqAndResDto.Res reqAndResParam = new ReqAndResDto.Res();
|
||||||
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_29.getCode()));
|
reqAndResParam.setMid(res.getMid());
|
||||||
reqAndResParam.setCode(200);
|
reqAndResParam.setDid(0);
|
||||||
//fixme 前置处理的时间应该是UTC时间,所以需要加8小时。
|
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||||
String json = "{Time:"+(System.currentTimeMillis()/1000+8*3600)+"}";
|
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_29.getCode()));
|
||||||
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(json);
|
reqAndResParam.setCode(200);
|
||||||
reqAndResParam.setMsg(jsonObject);
|
//fixme 前置处理的时间应该是UTC时间,所以需要加8小时。
|
||||||
publisher.send("/Dev/DataRsp/"+version+"/"+nDid,gson.toJson(reqAndResParam),1,false);
|
String json = "{Time:"+(System.currentTimeMillis()/1000+8*3600)+"}";
|
||||||
//处理业务逻辑
|
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(json);
|
||||||
Object object = res.getMsg();
|
reqAndResParam.setMsg(jsonObject);
|
||||||
if (!Objects.isNull(object)){
|
publisher.send("/Dev/DataRsp/"+version+"/"+nDid,gson.toJson(reqAndResParam),1,false);
|
||||||
List<String> abnormalList = new ArrayList<>();
|
//处理业务逻辑
|
||||||
if (object instanceof ArrayList<?>){
|
Object object = res.getMsg();
|
||||||
abnormalList.addAll((List<String>) object);
|
if (!Objects.isNull(object)){
|
||||||
|
List<String> abnormalList = new ArrayList<>();
|
||||||
|
if (object instanceof ArrayList<?>){
|
||||||
|
abnormalList.addAll((List<String>) object);
|
||||||
|
}
|
||||||
|
//todo APF设备不存在逻辑设备掉线的情况,网关下的设备会存在
|
||||||
|
abnormalList.forEach(item->{
|
||||||
|
System.out.println("异常设备ID:"+item);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//todo APF设备不存在逻辑设备掉线的情况,网关下的设备会存在
|
|
||||||
abnormalList.forEach(item->{
|
|
||||||
System.out.println("异常设备ID:"+item);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4866:
|
case 4866:
|
||||||
@@ -531,15 +526,12 @@ public class MqttMessageHandler {
|
|||||||
response.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
response.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||||
response.setType(Integer.parseInt(TypeEnum.TYPE_15.getCode()));
|
response.setType(Integer.parseInt(TypeEnum.TYPE_15.getCode()));
|
||||||
response.setCode(200);
|
response.setCode(200);
|
||||||
log.info("应答事件:{}", new Gson().toJson(response));
|
|
||||||
publisher.send("/Dev/DataRsp/"+version+"/"+nDid,new Gson().toJson(response),1,false);
|
publisher.send("/Dev/DataRsp/"+version+"/"+nDid,new Gson().toJson(response),1,false);
|
||||||
}
|
}
|
||||||
//判断事件类型
|
//判断事件类型
|
||||||
switch (dataDto.getMsg().getDataAttr()) {
|
switch (dataDto.getMsg().getDataAttr()) {
|
||||||
//暂态事件、录波处理、工程信息
|
//暂态事件、录波处理、工程信息
|
||||||
case 0:
|
case 0:
|
||||||
log.info("{}处理事件", nDid);
|
|
||||||
//log.info(nDid + "事件报文为:" + new String(message.getPayload(), StandardCharsets.UTF_8));
|
|
||||||
EventDto eventDto = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), EventDto.class);
|
EventDto eventDto = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), EventDto.class);
|
||||||
JSONObject jsonObject0 = JSONObject.parseObject(JSON.toJSONString(eventDto));
|
JSONObject jsonObject0 = JSONObject.parseObject(JSON.toJSONString(eventDto));
|
||||||
AppEventMessage appEventMessage = JSONObject.toJavaObject(jsonObject0, AppEventMessage.class);
|
AppEventMessage appEventMessage = JSONObject.toJavaObject(jsonObject0, AppEventMessage.class);
|
||||||
@@ -548,7 +540,6 @@ public class MqttMessageHandler {
|
|||||||
break;
|
break;
|
||||||
//实时数据
|
//实时数据
|
||||||
case 1:
|
case 1:
|
||||||
log.info("{}处理实时数据", nDid);
|
|
||||||
JSONObject jsonObject2 = JSONObject.parseObject(JSON.toJSONString(dataDto));
|
JSONObject jsonObject2 = JSONObject.parseObject(JSON.toJSONString(dataDto));
|
||||||
AppAutoDataMessage appAutoDataMessage = JSONObject.toJavaObject(jsonObject2, AppAutoDataMessage.class);
|
AppAutoDataMessage appAutoDataMessage = JSONObject.toJavaObject(jsonObject2, AppAutoDataMessage.class);
|
||||||
appAutoDataMessage.setId(nDid);
|
appAutoDataMessage.setId(nDid);
|
||||||
@@ -559,9 +550,6 @@ public class MqttMessageHandler {
|
|||||||
JSONObject jsonObject3 = JSONObject.parseObject(JSON.toJSONString(dataDto));
|
JSONObject jsonObject3 = JSONObject.parseObject(JSON.toJSONString(dataDto));
|
||||||
AppAutoDataMessage appAutoDataMessage2 = JSONObject.toJavaObject(jsonObject3, AppAutoDataMessage.class);
|
AppAutoDataMessage appAutoDataMessage2 = JSONObject.toJavaObject(jsonObject3, AppAutoDataMessage.class);
|
||||||
appAutoDataMessage2.setId(nDid);
|
appAutoDataMessage2.setId(nDid);
|
||||||
appAutoDataMessage2.getMsg().getDataArray().forEach(item->{
|
|
||||||
log.info("{}处理统计数据{}", nDid, item.getDataAttr());
|
|
||||||
});
|
|
||||||
appAutoDataMessageTemplate.sendMember(appAutoDataMessage2);
|
appAutoDataMessageTemplate.sendMember(appAutoDataMessage2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -593,7 +581,6 @@ public class MqttMessageHandler {
|
|||||||
//响应请求
|
//响应请求
|
||||||
switch (fileDto.getType()){
|
switch (fileDto.getType()){
|
||||||
case 4657:
|
case 4657:
|
||||||
log.info("获取文件信息{}", fileDto);
|
|
||||||
if (Objects.equals(fileDto.getCode(),AccessEnum.SUCCESS.getCode())) {
|
if (Objects.equals(fileDto.getCode(),AccessEnum.SUCCESS.getCode())) {
|
||||||
String key = AppRedisKey.PROJECT_INFO + nDid;
|
String key = AppRedisKey.PROJECT_INFO + nDid;
|
||||||
if (Objects.isNull(fileDto.getMsg().getType())) {
|
if (Objects.isNull(fileDto.getMsg().getType())) {
|
||||||
@@ -626,7 +613,6 @@ public class MqttMessageHandler {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4658:
|
case 4658:
|
||||||
log.info("获取文件流信息");
|
|
||||||
FileRedisDto dto = new FileRedisDto();
|
FileRedisDto dto = new FileRedisDto();
|
||||||
dto.setCode(fileDto.getCode());
|
dto.setCode(fileDto.getCode());
|
||||||
redisUtil.saveByKeyWithExpire(AppRedisKey.DOWNLOAD + fileDto.getMsg().getName() + fileDto.getMid(),dto,60L);
|
redisUtil.saveByKeyWithExpire(AppRedisKey.DOWNLOAD + fileDto.getMsg().getName() + fileDto.getMid(),dto,60L);
|
||||||
|
|||||||
@@ -1,29 +1,14 @@
|
|||||||
package com.njcn.access.listener;
|
package com.njcn.access.listener;
|
||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||||
import com.njcn.access.enums.AccessEnum;
|
|
||||||
import com.njcn.access.pojo.dto.NoticeUserDto;
|
|
||||||
import com.njcn.access.pojo.po.CsDeviceOnlineLogs;
|
|
||||||
import com.njcn.access.service.ICsDeviceOnlineLogsService;
|
|
||||||
import com.njcn.access.service.ICsEquipmentDeliveryService;
|
import com.njcn.access.service.ICsEquipmentDeliveryService;
|
||||||
import com.njcn.access.service.impl.CsDeviceServiceImpl;
|
|
||||||
import com.njcn.access.utils.MqttUtil;
|
|
||||||
import com.njcn.access.utils.RedisSetUtil;
|
import com.njcn.access.utils.RedisSetUtil;
|
||||||
import com.njcn.access.utils.SendMessageUtil;
|
import com.njcn.access.utils.SendMessageUtil;
|
||||||
import com.njcn.common.pojo.dto.DeviceLogDTO;
|
|
||||||
import com.njcn.csdevice.api.*;
|
import com.njcn.csdevice.api.*;
|
||||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
|
||||||
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
|
|
||||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
|
||||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
|
||||||
import com.njcn.redis.utils.RedisUtil;
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
import com.njcn.rt.pojo.dto.BaseRealDataSet;
|
import com.njcn.rt.pojo.dto.BaseRealDataSet;
|
||||||
import com.njcn.user.api.AppUserFeignClient;
|
|
||||||
import com.njcn.user.api.UserFeignClient;
|
|
||||||
import com.njcn.user.pojo.po.User;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.data.redis.connection.Message;
|
import org.springframework.data.redis.connection.Message;
|
||||||
@@ -32,15 +17,7 @@ import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xy
|
* @author xy
|
||||||
@@ -54,24 +31,12 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
|||||||
@Resource
|
@Resource
|
||||||
private ICsEquipmentDeliveryService csEquipmentDeliveryService;
|
private ICsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||||
@Resource
|
@Resource
|
||||||
private CsDeviceServiceImpl csDeviceService;
|
|
||||||
@Resource
|
|
||||||
private CsLogsFeignClient csLogsFeignClient;
|
private CsLogsFeignClient csLogsFeignClient;
|
||||||
@Resource
|
@Resource
|
||||||
private ICsDeviceOnlineLogsService onlineLogsService;
|
|
||||||
@Resource
|
|
||||||
private MqttUtil mqttUtil;
|
|
||||||
@Resource
|
|
||||||
private CsLedgerFeignClient csLedgerFeignclient;
|
private CsLedgerFeignClient csLedgerFeignclient;
|
||||||
@Resource
|
@Resource
|
||||||
private EquipmentFeignClient equipmentFeignClient;
|
private EquipmentFeignClient equipmentFeignClient;
|
||||||
@Resource
|
@Resource
|
||||||
private AppUserFeignClient appUserFeignClient;
|
|
||||||
@Resource
|
|
||||||
private CsDeviceUserFeignClient csDeviceUserFeignClient;
|
|
||||||
@Resource
|
|
||||||
private UserFeignClient userFeignClient;
|
|
||||||
@Resource
|
|
||||||
private RedisUtil redisUtil;
|
private RedisUtil redisUtil;
|
||||||
@Resource
|
@Resource
|
||||||
private SendMessageUtil sendMessageUtil;
|
private SendMessageUtil sendMessageUtil;
|
||||||
@@ -81,16 +46,13 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
|||||||
private MqttPublisher publisher;
|
private MqttPublisher publisher;
|
||||||
@Resource
|
@Resource
|
||||||
private RedisSetUtil redisSetUtil;
|
private RedisSetUtil redisSetUtil;
|
||||||
|
@Resource
|
||||||
private final Object lock = new Object();
|
private DeviceMessageFeignClient deviceMessageFeignClient;
|
||||||
|
|
||||||
public RedisKeyExpirationListener(RedisMessageListenerContainer listenerContainer) {
|
public RedisKeyExpirationListener(RedisMessageListenerContainer listenerContainer) {
|
||||||
super(listenerContainer);
|
super(listenerContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
//最大告警次数
|
|
||||||
private static int MAX_WARNING_TIMES = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 针对redis数据失效事件,进行数据处理
|
* 针对redis数据失效事件,进行数据处理
|
||||||
* 注意message.toString()可以获取失效的key
|
* 注意message.toString()可以获取失效的key
|
||||||
@@ -102,10 +64,10 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
|||||||
}
|
}
|
||||||
//判断失效的key是否为MQTT消费端存入的
|
//判断失效的key是否为MQTT消费端存入的
|
||||||
String expiredKey = message.toString();
|
String expiredKey = message.toString();
|
||||||
if(expiredKey.startsWith("MQTT:")){
|
// if(expiredKey.startsWith("MQTT:")){
|
||||||
String nDid = expiredKey.split(":")[1];
|
// String nDid = expiredKey.split(":")[1];
|
||||||
executeMainTask(nDid);
|
// executeMainTask(nDid);
|
||||||
}
|
// }
|
||||||
if(expiredKey.startsWith("cldRtDataOverTime:")){
|
if(expiredKey.startsWith("cldRtDataOverTime:")){
|
||||||
String lineId = expiredKey.split(":")[1];
|
String lineId = expiredKey.split(":")[1];
|
||||||
Object redisObject = redisUtil.getObjectByKey("rtDataUserId:"+lineId);
|
Object redisObject = redisUtil.getObjectByKey("rtDataUserId:"+lineId);
|
||||||
@@ -120,161 +82,77 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//云前置设备心跳丢失处理
|
}
|
||||||
// if(expiredKey.startsWith(RedisKeyEnum.CLD_HEART_BEAT_KEY.getKey())){
|
|
||||||
// String node = expiredKey.split(":")[1];
|
// //主任务
|
||||||
// String nodeId = node.substring(0, node.length() - 1);
|
// //1.装置心跳断连
|
||||||
// int processNo = Integer.parseInt(node.substring(node.length() - 1));
|
// //2.MQTT客户端不在线
|
||||||
// equipmentFeignClient.updateCldDevStatus(nodeId,processNo);
|
// private void executeMainTask(String nDid) {
|
||||||
|
// log.info("{}->装置离线", nDid);
|
||||||
|
// DeviceLogDTO logDto = new DeviceLogDTO();
|
||||||
|
// logDto.setUserName("运维管理员");
|
||||||
|
// logDto.setLoginName("njcnyw");
|
||||||
|
// //装置下线
|
||||||
|
// csEquipmentDeliveryService.updateRunStatusBynDid(nDid, AccessEnum.OFFLINE.getCode());
|
||||||
|
// //装置调整为注册状态
|
||||||
|
// csEquipmentDeliveryService.updateStatusBynDid(nDid,AccessEnum.REGISTERED.getCode(),null,null);
|
||||||
|
// logDto.setOperate(nDid +"装置离线");
|
||||||
|
// sendMessage(nDid);
|
||||||
|
// //记录装置掉线时间
|
||||||
|
// PqsCommunicateDto dto = new PqsCommunicateDto();
|
||||||
|
// dto.setTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||||
|
// dto.setDevId(nDid);
|
||||||
|
// dto.setType(0);
|
||||||
|
// dto.setDescription("通讯中断");
|
||||||
|
// csCommunicateFeignClient.insertion(dto);
|
||||||
|
// csLogsFeignClient.addUserLog(logDto);
|
||||||
|
// //清空缓存
|
||||||
|
// redisUtil.deleteKeysByString(AppRedisKey.LINE_POSITION+nDid);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //判断设备型号发送数据
|
||||||
|
// private void sendMessage(String nDid) {
|
||||||
|
// boolean devModel = equipmentFeignClient.judgeDevModel(nDid).getData();
|
||||||
|
// if (devModel) {
|
||||||
|
// NoticeUserDto dto = sendOffLine(nDid);
|
||||||
|
// if (CollectionUtil.isNotEmpty(dto.getPushClientId())) {
|
||||||
|
// sendMessageUtil.sendEventToUser(dto);
|
||||||
|
// addLogs(dto);
|
||||||
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
//主任务
|
// //掉线通知
|
||||||
//1.装置心跳断连
|
// private NoticeUserDto sendOffLine(String nDid) {
|
||||||
//2.MQTT客户端不在线
|
// NoticeUserDto dto = new NoticeUserDto();
|
||||||
private void executeMainTask(String nDid) {
|
// dto.setTitle("设备离线");
|
||||||
log.info("{}->装置离线", nDid);
|
// CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(nDid).getData();
|
||||||
DeviceLogDTO logDto = new DeviceLogDTO();
|
// DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(po.getId()).getData();
|
||||||
logDto.setUserName("运维管理员");
|
// DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
logDto.setLoginName("njcnyw");
|
// LocalDateTime localDateTime = LocalDateTime.now();
|
||||||
//装置下线
|
// String dateStr = localDateTime.format(fmt);
|
||||||
csEquipmentDeliveryService.updateRunStatusBynDid(nDid, AccessEnum.OFFLINE.getCode());
|
// String content = String.format(devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName() + "于" + dateStr + "离线");
|
||||||
//装置调整为注册状态
|
// dto.setContent(content);
|
||||||
csEquipmentDeliveryService.updateStatusBynDid(nDid,AccessEnum.REGISTERED.getCode());
|
// //获取设备关联的用户
|
||||||
logDto.setOperate(nDid +"装置离线");
|
// List<String> eventUser = deviceMessageFeignClient.getEventUserByDeviceId(po.getId(),true).getData();
|
||||||
sendMessage(nDid);
|
// DeviceMessageParam param1 = new DeviceMessageParam();
|
||||||
//记录装置掉线时间
|
// param1.setUserList(eventUser);
|
||||||
PqsCommunicateDto dto = new PqsCommunicateDto();
|
// param1.setEventType(2);
|
||||||
dto.setTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
// //获取打开推送的用户
|
||||||
dto.setDevId(nDid);
|
// List<User> users = deviceMessageFeignClient.getSendUserByType(param1).getData();
|
||||||
dto.setType(0);
|
// if (CollectionUtil.isNotEmpty(users)){
|
||||||
dto.setDescription("通讯中断");
|
// dto.setPushClientId(
|
||||||
csCommunicateFeignClient.insertion(dto);
|
// users.stream().filter(Objects::nonNull).map(User::getDevCode).filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList()));
|
||||||
csLogsFeignClient.addUserLog(logDto);
|
// }
|
||||||
}
|
// return dto;
|
||||||
|
// }
|
||||||
private void startScheduledTask(ScheduledExecutorService scheduler, String nDid, String version) {
|
//
|
||||||
synchronized (lock) {
|
// //日志记录
|
||||||
//判断是否推送消息
|
// private void addLogs(NoticeUserDto noticeUserDto) {
|
||||||
boolean devModel = equipmentFeignClient.judgeDevModel(nDid).getData();
|
// DeviceLogDTO dto = new DeviceLogDTO();
|
||||||
if (devModel) {
|
// dto.setUserName("运维管理员");
|
||||||
NoticeUserDto dto = sendOffLine(nDid);
|
// dto.setLoginName("njcnyw");
|
||||||
sendMessageUtil.sendEventToUser(dto);
|
// dto.setOperate(noticeUserDto.getContent());
|
||||||
addLogs(dto);
|
// csLogsFeignClient.addUserLog(dto);
|
||||||
}
|
// }
|
||||||
String clientName = "NJCN-" + nDid.substring(nDid.length() - 6);
|
|
||||||
ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(() -> {
|
|
||||||
log.info(nDid + "执行重连定时任务...");
|
|
||||||
DeviceLogDTO logDto = new DeviceLogDTO();
|
|
||||||
logDto.setOperate(nDid + "重连定时任务");
|
|
||||||
//判断客户端
|
|
||||||
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
|
||||||
if (mqttClient) {
|
|
||||||
csDeviceService.devAccessAskTemplate(nDid,version,1);
|
|
||||||
try {
|
|
||||||
Thread.sleep(5000);
|
|
||||||
Integer status = csEquipmentDeliveryService.queryEquipmentBynDid(nDid).getRunStatus();
|
|
||||||
if (Objects.equals(status,AccessEnum.ONLINE.getCode())){
|
|
||||||
logDto.setResult(1);
|
|
||||||
scheduler.shutdown();
|
|
||||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,1);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
logDto.setResult(0);
|
|
||||||
//一个小时未连接上,则推送告警消息
|
|
||||||
MAX_WARNING_TIMES++;
|
|
||||||
if (MAX_WARNING_TIMES == 30 && devModel) {
|
|
||||||
NoticeUserDto dto2 = sendConnectFail(nDid);
|
|
||||||
sendMessageUtil.sendEventToUser(dto2);
|
|
||||||
addLogs(dto2);
|
|
||||||
}
|
|
||||||
//记录装置掉线时间
|
|
||||||
CsDeviceOnlineLogs record = onlineLogsService.findLastData(nDid);
|
|
||||||
record.setOfflineTime(LocalDateTime.now());
|
|
||||||
onlineLogsService.updateById(record);
|
|
||||||
}
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//一个小时未连接上,则推送告警消息
|
|
||||||
MAX_WARNING_TIMES++;
|
|
||||||
if (MAX_WARNING_TIMES == 30 && devModel) {
|
|
||||||
NoticeUserDto dto2 = sendConnectFail(nDid);
|
|
||||||
sendMessageUtil.sendEventToUser(dto2);
|
|
||||||
addLogs(dto2);
|
|
||||||
}
|
|
||||||
logDto.setResult(0);
|
|
||||||
//记录装置掉线时间
|
|
||||||
CsDeviceOnlineLogs record = onlineLogsService.findLastData(nDid);
|
|
||||||
record.setOfflineTime(LocalDateTime.now());
|
|
||||||
onlineLogsService.updateById(record);
|
|
||||||
}
|
|
||||||
csLogsFeignClient.addUserLog(logDto);
|
|
||||||
}, 0, 2, TimeUnit.MINUTES);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//判断设备型号发送数据
|
|
||||||
private void sendMessage(String nDid) {
|
|
||||||
boolean devModel = equipmentFeignClient.judgeDevModel(nDid).getData();
|
|
||||||
if (devModel) {
|
|
||||||
NoticeUserDto dto = sendOffLine(nDid);
|
|
||||||
sendMessageUtil.sendEventToUser(dto);
|
|
||||||
addLogs(dto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//掉线通知
|
|
||||||
private NoticeUserDto sendOffLine(String nDid) {
|
|
||||||
NoticeUserDto dto = new NoticeUserDto();
|
|
||||||
dto.setTitle("设备离线");
|
|
||||||
CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(nDid).getData();
|
|
||||||
DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(po.getId()).getData();
|
|
||||||
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
||||||
LocalDateTime localDateTime = LocalDateTime.now();
|
|
||||||
String dateStr = localDateTime.format(fmt);
|
|
||||||
String content = String.format(devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName() + "于" + dateStr + "离线");
|
|
||||||
dto.setContent(content);
|
|
||||||
dto.setPushClientId(getEventUser(po.getId(),true));
|
|
||||||
return dto;
|
|
||||||
}
|
|
||||||
|
|
||||||
//重连失败通知
|
|
||||||
private NoticeUserDto sendConnectFail(String nDid) {
|
|
||||||
NoticeUserDto dto = new NoticeUserDto();
|
|
||||||
dto.setTitle("设备接入失败");
|
|
||||||
CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(nDid).getData();
|
|
||||||
DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(po.getId()).getData();
|
|
||||||
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
||||||
LocalDateTime localDateTime = LocalDateTime.now();
|
|
||||||
String dateStr = localDateTime.format(fmt);
|
|
||||||
String content = String.format(devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName() + "于" + dateStr + "多次接入失败");
|
|
||||||
dto.setContent(content);
|
|
||||||
dto.setPushClientId(getEventUser(po.getId(),false));
|
|
||||||
return dto;
|
|
||||||
}
|
|
||||||
|
|
||||||
//日志记录
|
|
||||||
private void addLogs(NoticeUserDto noticeUserDto) {
|
|
||||||
DeviceLogDTO dto = new DeviceLogDTO();
|
|
||||||
dto.setUserName("运维管理员");
|
|
||||||
dto.setLoginName("njcnyw");
|
|
||||||
dto.setOperate(noticeUserDto.getContent());
|
|
||||||
csLogsFeignClient.addUserLog(dto);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取所有需要推送的用户id
|
|
||||||
*/
|
|
||||||
public List<String> getEventUser(String devId, boolean isAdmin) {
|
|
||||||
List<User> adminUser = appUserFeignClient.getAdminInfo().getData();
|
|
||||||
List<String> adminList = adminUser.stream().map(User::getId).collect(Collectors.toList());
|
|
||||||
if (isAdmin) {
|
|
||||||
List<String> list = csDeviceUserFeignClient.findUserById(devId).getData();
|
|
||||||
adminList.addAll(list);
|
|
||||||
}
|
|
||||||
List<User> users = userFeignClient.appuserByIdList(adminList).getData();
|
|
||||||
return users.stream().map(User::getDevCode).filter(Objects::nonNull).filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,74 +161,4 @@ public class AutoAccessTimer implements ApplicationRunner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void run(ApplicationArguments args) {
|
|
||||||
// if (scheduler.isShutdown() || scheduler.isTerminated()) {
|
|
||||||
// scheduler = Executors.newScheduledThreadPool(1);
|
|
||||||
// }
|
|
||||||
// Runnable task = () -> {
|
|
||||||
// log.info("轮询定时任务执行中!");
|
|
||||||
// List<CsEquipmentDeliveryPO> list = csEquipmentDeliveryService.getOfflineDev();
|
|
||||||
// if (CollUtil.isNotEmpty(list)) {
|
|
||||||
// ExecutorService executor = Executors.newFixedThreadPool(10);
|
|
||||||
// // 将任务平均分配给10个子列表
|
|
||||||
// List<List<CsEquipmentDeliveryPO>> subLists = CollUtil.split(list, 10);
|
|
||||||
// // 创建一个ExecutorService来处理这些任务
|
|
||||||
// List<Future<Void>> futures = new ArrayList<>();
|
|
||||||
// for (List<CsEquipmentDeliveryPO> subList : subLists) {
|
|
||||||
// futures.add(executor.submit(() -> {
|
|
||||||
// try {
|
|
||||||
// accessDev(subList);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// log.error("处理设备子列表异常,但继续处理其他任务", e);
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }));
|
|
||||||
// }
|
|
||||||
// // 等待所有任务完成
|
|
||||||
// for (Future<Void> future : futures) {
|
|
||||||
// try {
|
|
||||||
// future.get();
|
|
||||||
// } catch (InterruptedException e) {
|
|
||||||
// Thread.currentThread().interrupt();
|
|
||||||
// log.error("任务被中断", e);
|
|
||||||
// } catch (ExecutionException e) {
|
|
||||||
// log.error("任务执行异常", e.getCause());
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// log.error("系统异常", e.getCause());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // 关闭ExecutorService
|
|
||||||
// executor.shutdown();
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// //第一次执行的时间为120s,然后在前一个任务执行完毕后,等待120s再执行下一个任务
|
|
||||||
// scheduler.scheduleWithFixedDelay(task, AUTO_TIME, AUTO_TIME, TimeUnit.SECONDS);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void accessDev(List<CsEquipmentDeliveryPO> list) {
|
|
||||||
// if (CollUtil.isNotEmpty(list)) {
|
|
||||||
// try {
|
|
||||||
// list.forEach(item -> {
|
|
||||||
// System.out.println(Thread.currentThread().getName() + ": auto : nDid : " + item.getNdid());
|
|
||||||
// //判断设备类型 便携式设备需要特殊处理 未注册的要先注册、再接入;已注册的直接重新接入
|
|
||||||
// String code = dictTreeFeignClient.queryById(item.getDevType()).getData().getCode();
|
|
||||||
// if (Objects.equals(code, DicDataEnum.PORTABLE.getCode()) && Objects.equals(item.getStatus(), 1)) {
|
|
||||||
// //csDeviceService.wlDevRegister(item.getNdid());
|
|
||||||
// log.info("请先手动注册、接入");
|
|
||||||
// } else {
|
|
||||||
// String version = csTopicService.getVersion(item.getNdid());
|
|
||||||
// if (Objects.isNull(version)) {
|
|
||||||
// version = "V1";
|
|
||||||
// }
|
|
||||||
// csDeviceService.autoAccess(item.getNdid(), version, 1);
|
|
||||||
// }
|
|
||||||
// redisUtil.saveByKey(AppRedisKey.DEVICE_MID + item.getNdid(), 1);
|
|
||||||
// });
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// log.error(e.getMessage());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,4 +54,8 @@ public interface ICsDeviceService {
|
|||||||
* @param nDid 设备识别码
|
* @param nDid 设备识别码
|
||||||
*/
|
*/
|
||||||
void wlAccess(String nDid);
|
void wlAccess(String nDid);
|
||||||
|
|
||||||
|
String autoPortableLedger();
|
||||||
|
|
||||||
|
String onlineRegister(String projectId,String nDid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public interface ICsEquipmentDeliveryService extends IService<CsEquipmentDeliver
|
|||||||
* 根据网关id修改装置的状态
|
* 根据网关id修改装置的状态
|
||||||
* @param nDid 网关id
|
* @param nDid 网关id
|
||||||
*/
|
*/
|
||||||
void updateStatusBynDid(String nDid,Integer status);
|
void updateStatusBynDid(String nDid,Integer status,String engineeringId, String projectId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据网关id修改软件信息
|
* 根据网关id修改软件信息
|
||||||
@@ -65,6 +65,11 @@ public interface ICsEquipmentDeliveryService extends IService<CsEquipmentDeliver
|
|||||||
*/
|
*/
|
||||||
List<CsEquipmentDeliveryPO> getOnlineDev();
|
List<CsEquipmentDeliveryPO> getOnlineDev();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取启用、系统在线、MQTT接入的装置
|
||||||
|
*/
|
||||||
|
List<CsEquipmentDeliveryPO> getUseOnlineDevice();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取离线、启用、客户端在线的装置
|
* 获取离线、启用、客户端在线的装置
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.njcn.access.service;
|
||||||
|
|
||||||
|
import com.njcn.mq.message.HeartbeatTimeoutMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
public interface ICsHeartService {
|
||||||
|
|
||||||
|
void handleHeartbeat(HeartbeatTimeoutMessage message);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -24,4 +24,6 @@ public interface ICsLedgerService extends IService<CsLedger> {
|
|||||||
*/
|
*/
|
||||||
CsLedger addLedgerTree(CsLedgerParam csLedgerParam);
|
CsLedger addLedgerTree(CsLedgerParam csLedgerParam);
|
||||||
|
|
||||||
|
void updatePortableLedger(String engineeringId, String projectId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,5 +28,5 @@ public interface ICsTopicService extends IService<CsTopic> {
|
|||||||
*/
|
*/
|
||||||
String getVersion(String nDid);
|
String getVersion(String nDid);
|
||||||
|
|
||||||
|
void deleteByNDid(String nDid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.njcn.access.service;
|
||||||
|
|
||||||
|
public interface IHeartbeatService {
|
||||||
|
|
||||||
|
void receiveHeartbeat(String nDid);
|
||||||
|
|
||||||
|
Boolean isHeartbeatUpdated(String nDid, Long sendTime);
|
||||||
|
}
|
||||||
@@ -87,6 +87,7 @@ public class AskDeviceDataServiceImpl implements AskDeviceDataService {
|
|||||||
public boolean downloadFile(String nDid, String name, Integer size, String fileCheck) {
|
public boolean downloadFile(String nDid, String name, Integer size, String fileCheck) {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
try {
|
try {
|
||||||
|
redisUtil.saveByKeyWithExpire("isWeb:"+nDid,name,30L);
|
||||||
redisUtil.saveByKeyWithExpire("fileDowning:"+nDid,"fileDowning",300L);
|
redisUtil.saveByKeyWithExpire("fileDowning:"+nDid,"fileDowning",300L);
|
||||||
redisUtil.saveByKey("fileCheck"+nDid+name,fileCheck);
|
redisUtil.saveByKey("fileCheck"+nDid+name,fileCheck);
|
||||||
Object object = getDeviceMid(nDid);
|
Object object = getDeviceMid(nDid);
|
||||||
@@ -104,6 +105,7 @@ public class AskDeviceDataServiceImpl implements AskDeviceDataService {
|
|||||||
redisUtil.delete("fileDowning:"+nDid);
|
redisUtil.delete("fileDowning:"+nDid);
|
||||||
redisUtil.delete("fileCheck"+nDid+name);
|
redisUtil.delete("fileCheck"+nDid+name);
|
||||||
redisUtil.delete("fileDownUserId"+nDid+name);
|
redisUtil.delete("fileDownUserId"+nDid+name);
|
||||||
|
redisUtil.deleteKeysByString("isWeb:"+ nDid);
|
||||||
throw new BusinessException(AlgorithmResponseEnum.FILE_DOWNLOAD_ERROR);
|
throw new BusinessException(AlgorithmResponseEnum.FILE_DOWNLOAD_ERROR);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
eleEpdPqdParam.setStatMethod(apf.getStatMethod());
|
eleEpdPqdParam.setStatMethod(apf.getStatMethod());
|
||||||
eleEpdPqdParam.setDataType(id);
|
eleEpdPqdParam.setDataType(id);
|
||||||
if (Objects.isNull(apf.getPhase())){
|
if (Objects.isNull(apf.getPhase())){
|
||||||
eleEpdPqdParam.setPhase("M");
|
eleEpdPqdParam.setPhase("T");
|
||||||
} else {
|
} else {
|
||||||
eleEpdPqdParam.setPhase(apf.getPhase());
|
eleEpdPqdParam.setPhase(apf.getPhase());
|
||||||
}
|
}
|
||||||
@@ -433,7 +433,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
eleEpdPqdParam.setEventType(evt.getEventType());
|
eleEpdPqdParam.setEventType(evt.getEventType());
|
||||||
eleEpdPqdParam.setDataType(id);
|
eleEpdPqdParam.setDataType(id);
|
||||||
if (Objects.isNull(evt.getPhase())){
|
if (Objects.isNull(evt.getPhase())){
|
||||||
eleEpdPqdParam.setPhase("M");
|
eleEpdPqdParam.setPhase("T");
|
||||||
} else {
|
} else {
|
||||||
eleEpdPqdParam.setPhase(evt.getPhase());
|
eleEpdPqdParam.setPhase(evt.getPhase());
|
||||||
}
|
}
|
||||||
@@ -494,7 +494,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
//告警code,到时候推送给用户告警码+事件时间
|
//告警code,到时候推送给用户告警码+事件时间
|
||||||
eleEpdPqdParam.setDefaultValue(alm.getCode());
|
eleEpdPqdParam.setDefaultValue(alm.getCode());
|
||||||
if (Objects.isNull(alm.getPhase())){
|
if (Objects.isNull(alm.getPhase())){
|
||||||
eleEpdPqdParam.setPhase("M");
|
eleEpdPqdParam.setPhase("T");
|
||||||
} else {
|
} else {
|
||||||
eleEpdPqdParam.setPhase(alm.getPhase());
|
eleEpdPqdParam.setPhase(alm.getPhase());
|
||||||
}
|
}
|
||||||
@@ -521,7 +521,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
eleEpdPqdParam.setTranRule(sts.getTranRule());
|
eleEpdPqdParam.setTranRule(sts.getTranRule());
|
||||||
eleEpdPqdParam.setDataType(id);
|
eleEpdPqdParam.setDataType(id);
|
||||||
if (Objects.isNull(sts.getPhase())){
|
if (Objects.isNull(sts.getPhase())){
|
||||||
eleEpdPqdParam.setPhase("M");
|
eleEpdPqdParam.setPhase("T");
|
||||||
} else {
|
} else {
|
||||||
eleEpdPqdParam.setPhase(sts.getPhase());
|
eleEpdPqdParam.setPhase(sts.getPhase());
|
||||||
}
|
}
|
||||||
@@ -553,7 +553,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
eleEpdPqdParam.setDefaultValue(parm.getDefaultValue());
|
eleEpdPqdParam.setDefaultValue(parm.getDefaultValue());
|
||||||
eleEpdPqdParam.setDataType(id);
|
eleEpdPqdParam.setDataType(id);
|
||||||
if (Objects.isNull(parm.getPhase())){
|
if (Objects.isNull(parm.getPhase())){
|
||||||
eleEpdPqdParam.setPhase("M");
|
eleEpdPqdParam.setPhase("T");
|
||||||
} else {
|
} else {
|
||||||
eleEpdPqdParam.setPhase(parm.getPhase());
|
eleEpdPqdParam.setPhase(parm.getPhase());
|
||||||
}
|
}
|
||||||
@@ -582,7 +582,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
eleEpdPqdParam.setUnit(set.getUnit());
|
eleEpdPqdParam.setUnit(set.getUnit());
|
||||||
eleEpdPqdParam.setDataType(id);
|
eleEpdPqdParam.setDataType(id);
|
||||||
if (Objects.isNull(set.getPhase())){
|
if (Objects.isNull(set.getPhase())){
|
||||||
eleEpdPqdParam.setPhase("M");
|
eleEpdPqdParam.setPhase("T");
|
||||||
} else {
|
} else {
|
||||||
eleEpdPqdParam.setPhase(set.getPhase());
|
eleEpdPqdParam.setPhase(set.getPhase());
|
||||||
}
|
}
|
||||||
@@ -614,7 +614,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
eleEpdPqdParam.setMinNum(ctrl.getMinNum());
|
eleEpdPqdParam.setMinNum(ctrl.getMinNum());
|
||||||
eleEpdPqdParam.setDataType(id);
|
eleEpdPqdParam.setDataType(id);
|
||||||
if (Objects.isNull(ctrl.getPhase())){
|
if (Objects.isNull(ctrl.getPhase())){
|
||||||
eleEpdPqdParam.setPhase("M");
|
eleEpdPqdParam.setPhase("T");
|
||||||
} else {
|
} else {
|
||||||
eleEpdPqdParam.setPhase(ctrl.getPhase());
|
eleEpdPqdParam.setPhase(ctrl.getPhase());
|
||||||
}
|
}
|
||||||
@@ -638,7 +638,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
eleEpdPqdParam.setSort(epd.getIdx());
|
eleEpdPqdParam.setSort(epd.getIdx());
|
||||||
eleEpdPqdParam.setType(epd.getType());
|
eleEpdPqdParam.setType(epd.getType());
|
||||||
if (Objects.isNull(epd.getPhase())){
|
if (Objects.isNull(epd.getPhase())){
|
||||||
eleEpdPqdParam.setPhase("M");
|
eleEpdPqdParam.setPhase("T");
|
||||||
} else {
|
} else {
|
||||||
eleEpdPqdParam.setPhase(epd.getPhase());
|
eleEpdPqdParam.setPhase(epd.getPhase());
|
||||||
}
|
}
|
||||||
@@ -674,7 +674,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
eleEpdPqdParam.setSort(pqd.getIdx());
|
eleEpdPqdParam.setSort(pqd.getIdx());
|
||||||
eleEpdPqdParam.setType(pqd.getType());
|
eleEpdPqdParam.setType(pqd.getType());
|
||||||
if (Objects.isNull(pqd.getPhase())){
|
if (Objects.isNull(pqd.getPhase())){
|
||||||
eleEpdPqdParam.setPhase("M");
|
eleEpdPqdParam.setPhase("T");
|
||||||
} else {
|
} else {
|
||||||
eleEpdPqdParam.setPhase(pqd.getPhase());
|
eleEpdPqdParam.setPhase(pqd.getPhase());
|
||||||
}
|
}
|
||||||
@@ -710,7 +710,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
eleEpdPqdParam.setSort(bmd.getIdx());
|
eleEpdPqdParam.setSort(bmd.getIdx());
|
||||||
eleEpdPqdParam.setType(bmd.getType());
|
eleEpdPqdParam.setType(bmd.getType());
|
||||||
if (Objects.isNull(bmd.getPhase())){
|
if (Objects.isNull(bmd.getPhase())){
|
||||||
eleEpdPqdParam.setPhase("M");
|
eleEpdPqdParam.setPhase("T");
|
||||||
} else {
|
} else {
|
||||||
eleEpdPqdParam.setPhase(bmd.getPhase());
|
eleEpdPqdParam.setPhase(bmd.getPhase());
|
||||||
}
|
}
|
||||||
@@ -741,7 +741,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
eleEpdPqdParam.setTranFlag(di.getTranFlag());
|
eleEpdPqdParam.setTranFlag(di.getTranFlag());
|
||||||
eleEpdPqdParam.setTranRule(di.getTranRule());
|
eleEpdPqdParam.setTranRule(di.getTranRule());
|
||||||
if (Objects.isNull(di.getPhase())){
|
if (Objects.isNull(di.getPhase())){
|
||||||
eleEpdPqdParam.setPhase("M");
|
eleEpdPqdParam.setPhase("T");
|
||||||
} else {
|
} else {
|
||||||
eleEpdPqdParam.setPhase(di.getPhase());
|
eleEpdPqdParam.setPhase(di.getPhase());
|
||||||
}
|
}
|
||||||
@@ -767,7 +767,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
eleEpdPqdParam.setCurSts(dto.getCurSts());
|
eleEpdPqdParam.setCurSts(dto.getCurSts());
|
||||||
eleEpdPqdParam.setCtlSts(dto.getCtlSts());
|
eleEpdPqdParam.setCtlSts(dto.getCtlSts());
|
||||||
if (Objects.isNull(dto.getPhase())){
|
if (Objects.isNull(dto.getPhase())){
|
||||||
eleEpdPqdParam.setPhase("M");
|
eleEpdPqdParam.setPhase("T");
|
||||||
} else {
|
} else {
|
||||||
eleEpdPqdParam.setPhase(dto.getPhase());
|
eleEpdPqdParam.setPhase(dto.getPhase());
|
||||||
}
|
}
|
||||||
@@ -797,7 +797,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
eleEpdPqdParam.setUnit(inSet.getUnit());
|
eleEpdPqdParam.setUnit(inSet.getUnit());
|
||||||
eleEpdPqdParam.setDataType(id);
|
eleEpdPqdParam.setDataType(id);
|
||||||
if (Objects.isNull(inSet.getPhase())){
|
if (Objects.isNull(inSet.getPhase())){
|
||||||
eleEpdPqdParam.setPhase("M");
|
eleEpdPqdParam.setPhase("T");
|
||||||
} else {
|
} else {
|
||||||
eleEpdPqdParam.setPhase(inSet.getPhase());
|
eleEpdPqdParam.setPhase(inSet.getPhase());
|
||||||
}
|
}
|
||||||
@@ -820,7 +820,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
eleEpdPqdParam.setShowName(wave.getName());
|
eleEpdPqdParam.setShowName(wave.getName());
|
||||||
eleEpdPqdParam.setSort(wave.getIdx());
|
eleEpdPqdParam.setSort(wave.getIdx());
|
||||||
eleEpdPqdParam.setDataType(id);
|
eleEpdPqdParam.setDataType(id);
|
||||||
eleEpdPqdParam.setPhase("M");
|
eleEpdPqdParam.setPhase("T");
|
||||||
eleEpdPqdParam.setClassId(classId);
|
eleEpdPqdParam.setClassId(classId);
|
||||||
EleEpdPqd po = epdFeignClient.add(eleEpdPqdParam).getData();
|
EleEpdPqd po = epdFeignClient.add(eleEpdPqdParam).getData();
|
||||||
if (CollectionUtil.isNotEmpty(wave.getParam())){
|
if (CollectionUtil.isNotEmpty(wave.getParam())){
|
||||||
@@ -1025,91 +1025,91 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
List<ApfDto> apfList = templateDto.getApfDto();
|
List<ApfDto> apfList = templateDto.getApfDto();
|
||||||
ApfDto apfDto = apfList.get(idx);
|
ApfDto apfDto = apfList.get(idx);
|
||||||
name = apfDto.getName();
|
name = apfDto.getName();
|
||||||
phase = apfDto.getPhase() == null ? "M":apfDto.getPhase();
|
phase = apfDto.getPhase() == null ? "T":apfDto.getPhase();
|
||||||
break;
|
break;
|
||||||
case DataModel.EVT:
|
case DataModel.EVT:
|
||||||
log.info("查询evt字典数据");
|
log.info("查询evt字典数据");
|
||||||
List<EvtDto> evtList = templateDto.getEvtDto();
|
List<EvtDto> evtList = templateDto.getEvtDto();
|
||||||
EvtDto evtDto = evtList.get(idx);
|
EvtDto evtDto = evtList.get(idx);
|
||||||
name = evtDto.getName();
|
name = evtDto.getName();
|
||||||
phase = evtDto.getPhase() == null ? "M":evtDto.getPhase();
|
phase = evtDto.getPhase() == null ? "T":evtDto.getPhase();
|
||||||
break;
|
break;
|
||||||
case DataModel.ALM:
|
case DataModel.ALM:
|
||||||
log.info("查询alm字典数据");
|
log.info("查询alm字典数据");
|
||||||
List<AlmDto> almList = templateDto.getAlmDto();
|
List<AlmDto> almList = templateDto.getAlmDto();
|
||||||
AlmDto almDto = almList.get(idx);
|
AlmDto almDto = almList.get(idx);
|
||||||
name = almDto.getName();
|
name = almDto.getName();
|
||||||
phase = almDto.getPhase() == null ? "M":almDto.getPhase();
|
phase = almDto.getPhase() == null ? "T":almDto.getPhase();
|
||||||
break;
|
break;
|
||||||
case DataModel.STS:
|
case DataModel.STS:
|
||||||
log.info("查询sts字典数据");
|
log.info("查询sts字典数据");
|
||||||
List<StsDto> stsList = templateDto.getStsDto();
|
List<StsDto> stsList = templateDto.getStsDto();
|
||||||
StsDto stsDto = stsList.get(idx);
|
StsDto stsDto = stsList.get(idx);
|
||||||
name = stsDto.getName();
|
name = stsDto.getName();
|
||||||
phase = stsDto.getPhase() == null ? "M":stsDto.getPhase();
|
phase = stsDto.getPhase() == null ? "T":stsDto.getPhase();
|
||||||
break;
|
break;
|
||||||
case DataModel.PARM:
|
case DataModel.PARM:
|
||||||
log.info("查询parm字典数据");
|
log.info("查询parm字典数据");
|
||||||
List<ParmDto> parmList = templateDto.getParmDto();
|
List<ParmDto> parmList = templateDto.getParmDto();
|
||||||
ParmDto parmDto = parmList.get(idx);
|
ParmDto parmDto = parmList.get(idx);
|
||||||
name = parmDto.getName();
|
name = parmDto.getName();
|
||||||
phase = parmDto.getPhase() == null ? "M":parmDto.getPhase();
|
phase = parmDto.getPhase() == null ? "T":parmDto.getPhase();
|
||||||
break;
|
break;
|
||||||
case DataModel.SET:
|
case DataModel.SET:
|
||||||
log.info("查询set字典数据");
|
log.info("查询set字典数据");
|
||||||
List<SetDto> setList = templateDto.getSetDto();
|
List<SetDto> setList = templateDto.getSetDto();
|
||||||
SetDto setDto = setList.get(idx);
|
SetDto setDto = setList.get(idx);
|
||||||
name = setDto.getName();
|
name = setDto.getName();
|
||||||
phase = setDto.getPhase() == null ? "M":setDto.getPhase();
|
phase = setDto.getPhase() == null ? "T":setDto.getPhase();
|
||||||
break;
|
break;
|
||||||
case DataModel.CTRL:
|
case DataModel.CTRL:
|
||||||
log.info("查询ctrl字典数据");
|
log.info("查询ctrl字典数据");
|
||||||
List<CtrlDto> ctrlList = templateDto.getCtrlDto();
|
List<CtrlDto> ctrlList = templateDto.getCtrlDto();
|
||||||
CtrlDto ctrlDto = ctrlList.get(idx);
|
CtrlDto ctrlDto = ctrlList.get(idx);
|
||||||
name = ctrlDto.getName();
|
name = ctrlDto.getName();
|
||||||
phase = ctrlDto.getPhase() == null ? "M":ctrlDto.getPhase();
|
phase = ctrlDto.getPhase() == null ? "T":ctrlDto.getPhase();
|
||||||
break;
|
break;
|
||||||
case DataModel.EPD:
|
case DataModel.EPD:
|
||||||
log.info("查询epd字典数据");
|
log.info("查询epd字典数据");
|
||||||
List<EpdPqdDto> epdList = templateDto.getEpdDto();
|
List<EpdPqdDto> epdList = templateDto.getEpdDto();
|
||||||
EpdPqdDto epdDto = epdList.get(idx);
|
EpdPqdDto epdDto = epdList.get(idx);
|
||||||
name = epdDto.getName();
|
name = epdDto.getName();
|
||||||
phase = epdDto.getPhase() == null ? "M":epdDto.getPhase();
|
phase = epdDto.getPhase() == null ? "T":epdDto.getPhase();
|
||||||
break;
|
break;
|
||||||
case DataModel.PQD:
|
case DataModel.PQD:
|
||||||
log.info("查询pqd字典数据");
|
log.info("查询pqd字典数据");
|
||||||
List<EpdPqdDto> pqdList = templateDto.getPqdDto();
|
List<EpdPqdDto> pqdList = templateDto.getPqdDto();
|
||||||
EpdPqdDto pqdDto = pqdList.get(idx);
|
EpdPqdDto pqdDto = pqdList.get(idx);
|
||||||
name = pqdDto.getName();
|
name = pqdDto.getName();
|
||||||
phase = pqdDto.getPhase() == null ? "M":pqdDto.getPhase();
|
phase = pqdDto.getPhase() == null ? "T":pqdDto.getPhase();
|
||||||
break;
|
break;
|
||||||
case DataModel.BMD:
|
case DataModel.BMD:
|
||||||
log.info("查询bmd字典数据");
|
log.info("查询bmd字典数据");
|
||||||
List<BmdDto> bmdList = templateDto.getBmdDto();
|
List<BmdDto> bmdList = templateDto.getBmdDto();
|
||||||
BmdDto bmdDto = bmdList.get(idx);
|
BmdDto bmdDto = bmdList.get(idx);
|
||||||
name = bmdDto.getName();
|
name = bmdDto.getName();
|
||||||
phase = bmdDto.getPhase() == null ? "M":bmdDto.getPhase();
|
phase = bmdDto.getPhase() == null ? "T":bmdDto.getPhase();
|
||||||
break;
|
break;
|
||||||
case DataModel.DI:
|
case DataModel.DI:
|
||||||
log.info("查询di字典数据");
|
log.info("查询di字典数据");
|
||||||
List<DiDto> diList = templateDto.getDiDto();
|
List<DiDto> diList = templateDto.getDiDto();
|
||||||
DiDto diDto = diList.get(idx);
|
DiDto diDto = diList.get(idx);
|
||||||
name = diDto.getName();
|
name = diDto.getName();
|
||||||
phase = diDto.getPhase() == null ? "M":diDto.getPhase();
|
phase = diDto.getPhase() == null ? "T":diDto.getPhase();
|
||||||
break;
|
break;
|
||||||
case DataModel.DO:
|
case DataModel.DO:
|
||||||
log.info("查询do字典数据");
|
log.info("查询do字典数据");
|
||||||
List<DoDto> doList = templateDto.getDoDto();
|
List<DoDto> doList = templateDto.getDoDto();
|
||||||
DoDto doDto = doList.get(idx);
|
DoDto doDto = doList.get(idx);
|
||||||
name = doDto.getName();
|
name = doDto.getName();
|
||||||
phase = doDto.getPhase() == null ? "M":doDto.getPhase();
|
phase = doDto.getPhase() == null ? "T":doDto.getPhase();
|
||||||
break;
|
break;
|
||||||
case DataModel.INSET:
|
case DataModel.INSET:
|
||||||
log.info("查询inset字典数据");
|
log.info("查询inset字典数据");
|
||||||
List<InSetDto> inSetList = templateDto.getInSetDto();
|
List<InSetDto> inSetList = templateDto.getInSetDto();
|
||||||
InSetDto inSetDto = inSetList.get(idx);
|
InSetDto inSetDto = inSetList.get(idx);
|
||||||
name = inSetDto.getName();
|
name = inSetDto.getName();
|
||||||
phase = inSetDto.getPhase() == null ? "M":inSetDto.getPhase();
|
phase = inSetDto.getPhase() == null ? "T":inSetDto.getPhase();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -1119,7 +1119,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
log.info("指标名称:"+name+",数据类型:"+id+",相别:"+phase);
|
log.info("指标名称:"+name+",数据类型:"+id+",相别:"+phase);
|
||||||
throw new BusinessException(AccessResponseEnum.DICT_MISSING);
|
throw new BusinessException(AccessResponseEnum.DICT_MISSING);
|
||||||
}
|
}
|
||||||
// M 代表没有数据,因为influxDB要录入数据,此字段是主键,给个默认值
|
// T 代表没有数据,因为influxDB要录入数据,此字段是主键,给个默认值
|
||||||
if (!Objects.isNull(eleEpdPqd.getHarmStart()) && !Objects.isNull(eleEpdPqd.getHarmEnd())){
|
if (!Objects.isNull(eleEpdPqd.getHarmStart()) && !Objects.isNull(eleEpdPqd.getHarmEnd())){
|
||||||
if (Objects.equals(eleEpdPqd.getHarmStart(),1)){
|
if (Objects.equals(eleEpdPqd.getHarmStart(),1)){
|
||||||
for (int i = eleEpdPqd.getHarmStart(); i <= eleEpdPqd.getHarmEnd(); i++) {
|
for (int i = eleEpdPqd.getHarmStart(); i <= eleEpdPqd.getHarmEnd(); i++) {
|
||||||
@@ -1142,7 +1142,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
CsDataArray.setDataId(eleEpdPqd.getId());
|
CsDataArray.setDataId(eleEpdPqd.getId());
|
||||||
CsDataArray.setName(eleEpdPqd.getName() + "_" + i);
|
CsDataArray.setName(eleEpdPqd.getName() + "_" + i);
|
||||||
CsDataArray.setAnotherName((i-0.5) + "次" +eleEpdPqd.getShowName());
|
CsDataArray.setAnotherName((i-0.5) + "次" +eleEpdPqd.getShowName());
|
||||||
CsDataArray.setStatMethod("M");
|
CsDataArray.setStatMethod("T");
|
||||||
CsDataArray.setDataType(eleEpdPqd.getType());
|
CsDataArray.setDataType(eleEpdPqd.getType());
|
||||||
CsDataArray.setPhase(eleEpdPqd.getPhase());
|
CsDataArray.setPhase(eleEpdPqd.getPhase());
|
||||||
list.add(CsDataArray);
|
list.add(CsDataArray);
|
||||||
@@ -1169,7 +1169,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
CsDataArray.setDataId(eleEpdPqd.getId());
|
CsDataArray.setDataId(eleEpdPqd.getId());
|
||||||
CsDataArray.setName(eleEpdPqd.getName() + "_" + i);
|
CsDataArray.setName(eleEpdPqd.getName() + "_" + i);
|
||||||
CsDataArray.setAnotherName(i + "次" +eleEpdPqd.getShowName());
|
CsDataArray.setAnotherName(i + "次" +eleEpdPqd.getShowName());
|
||||||
CsDataArray.setStatMethod("M");
|
CsDataArray.setStatMethod("T");
|
||||||
CsDataArray.setDataType(eleEpdPqd.getType());
|
CsDataArray.setDataType(eleEpdPqd.getType());
|
||||||
CsDataArray.setPhase(eleEpdPqd.getPhase());
|
CsDataArray.setPhase(eleEpdPqd.getPhase());
|
||||||
list.add(CsDataArray);
|
list.add(CsDataArray);
|
||||||
@@ -1196,7 +1196,7 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
|||||||
CsDataArray.setDataId(eleEpdPqd.getId());
|
CsDataArray.setDataId(eleEpdPqd.getId());
|
||||||
CsDataArray.setName(eleEpdPqd.getName());
|
CsDataArray.setName(eleEpdPqd.getName());
|
||||||
CsDataArray.setAnotherName(eleEpdPqd.getShowName());
|
CsDataArray.setAnotherName(eleEpdPqd.getShowName());
|
||||||
CsDataArray.setStatMethod("M");
|
CsDataArray.setStatMethod("T");
|
||||||
CsDataArray.setDataType(eleEpdPqd.getType());
|
CsDataArray.setDataType(eleEpdPqd.getType());
|
||||||
CsDataArray.setPhase(eleEpdPqd.getPhase());
|
CsDataArray.setPhase(eleEpdPqd.getPhase());
|
||||||
list.add(CsDataArray);
|
list.add(CsDataArray);
|
||||||
|
|||||||
@@ -22,17 +22,20 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.csdevice.api.*;
|
import com.njcn.csdevice.api.*;
|
||||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||||
import com.njcn.csdevice.pojo.param.CsDevModelRelationAddParm;
|
import com.njcn.csdevice.param.LineInfoParam;
|
||||||
import com.njcn.csdevice.pojo.param.CsLedgerParam;
|
import com.njcn.csdevice.pojo.param.*;
|
||||||
import com.njcn.csdevice.pojo.param.CsLineParam;
|
|
||||||
import com.njcn.csdevice.pojo.po.*;
|
import com.njcn.csdevice.pojo.po.*;
|
||||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||||
|
import com.njcn.csharmonic.api.CsHarmonicPlanLineFeignClient;
|
||||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||||
import com.njcn.redis.utils.RedisUtil;
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
import com.njcn.system.api.DictTreeFeignClient;
|
import com.njcn.system.api.DictTreeFeignClient;
|
||||||
import com.njcn.system.enums.DicDataEnum;
|
import com.njcn.system.enums.DicDataEnum;
|
||||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||||
|
import com.njcn.user.api.UserFeignClient;
|
||||||
|
import com.njcn.user.enums.AppRoleEnum;
|
||||||
|
import com.njcn.user.pojo.vo.UserVO;
|
||||||
import com.njcn.web.utils.RequestUtil;
|
import com.njcn.web.utils.RequestUtil;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -80,6 +83,12 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
private final ChannelObjectUtil channelObjectUtil;
|
private final ChannelObjectUtil channelObjectUtil;
|
||||||
private final CsLineFeignClient csLineFeignClient;
|
private final CsLineFeignClient csLineFeignClient;
|
||||||
private final DataSetFeignClient dataSetFeignClient;
|
private final DataSetFeignClient dataSetFeignClient;
|
||||||
|
private final CsMarketDataFeignClient csMarketDataFeignClient;
|
||||||
|
private final UserFeignClient userFeignClient;
|
||||||
|
private final EngineeringFeignClient engineeringFeignClient;
|
||||||
|
private final AppProjectFeignClient appProjectFeignClient;
|
||||||
|
private final DeviceMessageFeignClient deviceMessageFeignClient;
|
||||||
|
private final CsHarmonicPlanLineFeignClient csHarmonicPlanLineFeignClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
@@ -130,15 +139,16 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
throw new BusinessException(AccessResponseEnum.MISSING_CLIENT);
|
throw new BusinessException(AccessResponseEnum.MISSING_CLIENT);
|
||||||
}
|
}
|
||||||
//5.判断当前流程是否是合法的
|
//5.判断当前流程是否是合法的
|
||||||
if (csEquipmentDeliveryVO.getProcess() > type){
|
//note(重要说明) 这边流程原先是三个阶段,在实际应用中嫌麻烦,简化为一个流程
|
||||||
logDto.setResult(0);
|
// if (csEquipmentDeliveryVO.getProcess() > type){
|
||||||
logDto.setFailReason(AccessResponseEnum.PROCESS_SAME_ERROR.getMessage());
|
// logDto.setResult(0);
|
||||||
throw new BusinessException(AccessResponseEnum.PROCESS_SAME_ERROR);
|
// logDto.setFailReason(AccessResponseEnum.PROCESS_SAME_ERROR.getMessage());
|
||||||
} else if (csEquipmentDeliveryVO.getProcess() < type){
|
// throw new BusinessException(AccessResponseEnum.PROCESS_SAME_ERROR);
|
||||||
logDto.setResult(0);
|
// } else if (csEquipmentDeliveryVO.getProcess() < type){
|
||||||
logDto.setFailReason(AccessResponseEnum.PROCESS_MISSING_ERROR.getMessage());
|
// logDto.setResult(0);
|
||||||
throw new BusinessException(AccessResponseEnum.PROCESS_MISSING_ERROR);
|
// logDto.setFailReason(AccessResponseEnum.PROCESS_MISSING_ERROR.getMessage());
|
||||||
}
|
// throw new BusinessException(AccessResponseEnum.PROCESS_MISSING_ERROR);
|
||||||
|
// }
|
||||||
//6.询问设备支持的主题信息
|
//6.询问设备支持的主题信息
|
||||||
//将支持的主题入库
|
//将支持的主题入库
|
||||||
askTopic(nDid);
|
askTopic(nDid);
|
||||||
@@ -184,6 +194,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
|
//fixme 这边事务不起作用,中途出错会导致数据部分录入,再次接入会报主键冲突,所以暂时加了个重置按钮,清空台账数据的
|
||||||
public void devAccess(DevAccessParam devAccessParam) {
|
public void devAccess(DevAccessParam devAccessParam) {
|
||||||
//日志实体
|
//日志实体
|
||||||
DeviceLogDTO logDto = new DeviceLogDTO();
|
DeviceLogDTO logDto = new DeviceLogDTO();
|
||||||
@@ -268,6 +279,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
appLineTopologyDiagramPo.setLat(item.getLat());
|
appLineTopologyDiagramPo.setLat(item.getLat());
|
||||||
appLineTopologyDiagramPo.setLng(item.getLng());
|
appLineTopologyDiagramPo.setLng(item.getLng());
|
||||||
appLineTopologyDiagramPo.setStatus("1");
|
appLineTopologyDiagramPo.setStatus("1");
|
||||||
|
appLineTopologyDiagramPo.setTarget(item.getTarget());
|
||||||
appLineTopologyDiagramPoList.add(appLineTopologyDiagramPo);
|
appLineTopologyDiagramPoList.add(appLineTopologyDiagramPo);
|
||||||
}
|
}
|
||||||
List<String> position = csLinePoList.stream().map(CsLinePO::getPosition).collect(Collectors.toList());
|
List<String> position = csLinePoList.stream().map(CsLinePO::getPosition).collect(Collectors.toList());
|
||||||
@@ -278,8 +290,17 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
csLogsFeignClient.addUserLog(logDto);
|
csLogsFeignClient.addUserLog(logDto);
|
||||||
throw new BusinessException(AccessResponseEnum.LINE_POSITION_REPEAT);
|
throw new BusinessException(AccessResponseEnum.LINE_POSITION_REPEAT);
|
||||||
}
|
}
|
||||||
|
//删除监测点稳态指标告警的默认指标配置
|
||||||
|
List<String> lineIdList = csLinePoList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
||||||
|
csHarmonicPlanLineFeignClient.deleteByLineIds(lineIdList);
|
||||||
csLineService.saveBatch(csLinePoList);
|
csLineService.saveBatch(csLinePoList);
|
||||||
|
|
||||||
redisUtil.saveByKeyWithExpire("accessLineInfo:" + devAccessParam.getNDid(),csLinePoList,30L);
|
redisUtil.saveByKeyWithExpire("accessLineInfo:" + devAccessParam.getNDid(),csLinePoList,30L);
|
||||||
|
//缓存监测点信息
|
||||||
|
LineInfoParam param = new LineInfoParam();
|
||||||
|
param.setNDid(devAccessParam.getNDid());
|
||||||
|
param.setList(csLinePoList);
|
||||||
|
deviceMessageFeignClient.getLineInfo(param);
|
||||||
//4.监测点拓扑图表录入关系
|
//4.监测点拓扑图表录入关系
|
||||||
appLineTopologyDiagramService.saveBatch(appLineTopologyDiagramPoList);
|
appLineTopologyDiagramService.saveBatch(appLineTopologyDiagramPoList);
|
||||||
//5.绑定装置和人的关系
|
//5.绑定装置和人的关系
|
||||||
@@ -289,16 +310,16 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
po.setSubUserId(RequestUtil.getUserIndex());
|
po.setSubUserId(RequestUtil.getUserIndex());
|
||||||
po.setDeviceId(vo.getId());
|
po.setDeviceId(vo.getId());
|
||||||
csDeviceUserService.saveBatch(Collections.singletonList(po));
|
csDeviceUserService.saveBatch(Collections.singletonList(po));
|
||||||
//6.修改装置状态
|
//6.修改装置状态;修改设备接入的工程、项目
|
||||||
csEquipmentDeliveryService.updateStatusBynDid(devAccessParam.getNDid(), AccessEnum.REGISTERED.getCode());
|
csEquipmentDeliveryService.updateStatusBynDid(devAccessParam.getNDid(), AccessEnum.REGISTERED.getCode(),devAccessParam.getEngineeringId(), devAccessParam.getProjectId());
|
||||||
//7.发起自动接入请求
|
//7.发起自动接入请求
|
||||||
devAccessAskTemplate(devAccessParam.getNDid(),version,1);
|
devAccessAskTemplate(devAccessParam.getNDid(),version,1);
|
||||||
//8.删除redis监测点模板信息
|
//8.删除redis监测点模板信息
|
||||||
redisUtil.delete(AppRedisKey.MODEL + devAccessParam.getNDid());
|
redisUtil.delete(AppRedisKey.MODEL + devAccessParam.getNDid());
|
||||||
redisUtil.delete(AppRedisKey.LINE + devAccessParam.getNDid());
|
redisUtil.delete(AppRedisKey.LINE + devAccessParam.getNDid());
|
||||||
//存储日志
|
//9.存储日志
|
||||||
csLogsFeignClient.addUserLog(logDto);
|
csLogsFeignClient.addUserLog(logDto);
|
||||||
//存储设备调试日志表
|
//10.存储设备调试日志表
|
||||||
CsEquipmentProcessPO csEquipmentProcess = new CsEquipmentProcessPO();
|
CsEquipmentProcessPO csEquipmentProcess = new CsEquipmentProcessPO();
|
||||||
csEquipmentProcess.setDevId(devAccessParam.getNDid());
|
csEquipmentProcess.setDevId(devAccessParam.getNDid());
|
||||||
csEquipmentProcess.setOperator(RequestUtil.getUserIndex());
|
csEquipmentProcess.setOperator(RequestUtil.getUserIndex());
|
||||||
@@ -309,6 +330,14 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
csEquipmentProcess.setStatus(1);
|
csEquipmentProcess.setStatus(1);
|
||||||
}
|
}
|
||||||
processFeignClient.add(csEquipmentProcess);
|
processFeignClient.add(csEquipmentProcess);
|
||||||
|
//11.这里会出现工程用户接入设备时,如果当前工程用户并没有关注,接入之后应该将用户和工程关联起来
|
||||||
|
List<UserVO> users = userFeignClient.getUserVOByIdList(Collections.singletonList(RequestUtil.getUserIndex())).getData();
|
||||||
|
if (CollectionUtil.isNotEmpty(users)) {
|
||||||
|
UserVO userVO = users.get(0);
|
||||||
|
if (CollectionUtil.isNotEmpty(userVO.getRoleCode()) && userVO.getRoleCode().contains(AppRoleEnum.ENGINEERING_USER.getCode())) {
|
||||||
|
csMarketDataFeignClient.insertData(userVO.getId(), devAccessParam.getEngineeringId());
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logDto.setResult(0);
|
logDto.setResult(0);
|
||||||
logDto.setFailReason(e.getMessage());
|
logDto.setFailReason(e.getMessage());
|
||||||
@@ -327,12 +356,13 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
param.setNDid(nDid);
|
param.setNDid(nDid);
|
||||||
param.setStatus(1);
|
param.setStatus(1);
|
||||||
param.setRunStatus(1);
|
param.setRunStatus(1);
|
||||||
boolean isConnectDev = DicDataEnum.CONNECT_DEV.getCode().equals(dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevType()).getData().getCode());
|
// boolean isConnectDev = DicDataEnum.CONNECT_DEV.getCode().equals(dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevType()).getData().getCode());
|
||||||
if (isConnectDev) {
|
// if (isConnectDev) {
|
||||||
param.setProcess(2);
|
// param.setProcess(2);
|
||||||
} else {
|
// } else {
|
||||||
param.setProcess(4);
|
// param.setProcess(4);
|
||||||
}
|
// }
|
||||||
|
param.setProcess(4);
|
||||||
csEquipmentDeliveryService.devResetFactory(param);
|
csEquipmentDeliveryService.devResetFactory(param);
|
||||||
//清除关系表
|
//清除关系表
|
||||||
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper<>();
|
||||||
@@ -365,6 +395,10 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
appLineTopologyDiagramPOQueryWrapper.in("line_id",collect);
|
appLineTopologyDiagramPOQueryWrapper.in("line_id",collect);
|
||||||
appLineTopologyDiagramService.remove(appLineTopologyDiagramPOQueryWrapper);
|
appLineTopologyDiagramService.remove(appLineTopologyDiagramPOQueryWrapper);
|
||||||
}
|
}
|
||||||
|
//删除topic表
|
||||||
|
csTopicService.deleteByNDid(nDid);
|
||||||
|
//清空缓存
|
||||||
|
redisUtil.deleteKeysByString(AppRedisKey.LINE_POSITION+nDid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -396,9 +430,13 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||||
List<CsLinePO> csLinePoList = new ArrayList<>();
|
List<CsLinePO> csLinePoList = new ArrayList<>();
|
||||||
//1.录入装置台账信息
|
//1.录入装置台账信息
|
||||||
|
//note 1、这边发现便携式设备注册时,如果没有工程 项目,后期特殊处理非常的麻烦,这边接入时,先查询工程 项目,如果没有则创建;如果存在则直接使用;
|
||||||
|
//note 2、查询之前已经接入过的便携式设备,如果存在修改台账信息,添加工程、项目
|
||||||
|
String projectId = this.autoPortableLedger();
|
||||||
|
//新增便携式设备
|
||||||
CsLedgerParam csLedgerParam = new CsLedgerParam();
|
CsLedgerParam csLedgerParam = new CsLedgerParam();
|
||||||
csLedgerParam.setId(vo.getId());
|
csLedgerParam.setId(vo.getId());
|
||||||
csLedgerParam.setPid("0");
|
csLedgerParam.setPid(projectId);
|
||||||
csLedgerParam.setName(vo.getName());
|
csLedgerParam.setName(vo.getName());
|
||||||
csLedgerParam.setLevel(2);
|
csLedgerParam.setLevel(2);
|
||||||
csLedgerParam.setSort(0);
|
csLedgerParam.setSort(0);
|
||||||
@@ -436,6 +474,11 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
});
|
});
|
||||||
csLineService.saveBatch(csLinePoList);
|
csLineService.saveBatch(csLinePoList);
|
||||||
redisUtil.saveByKeyWithExpire("accessLineInfo:" + nDid,csLinePoList,30L);
|
redisUtil.saveByKeyWithExpire("accessLineInfo:" + nDid,csLinePoList,30L);
|
||||||
|
//缓存监测点信息
|
||||||
|
LineInfoParam param = new LineInfoParam();
|
||||||
|
param.setNDid(nDid);
|
||||||
|
param.setList(csLinePoList);
|
||||||
|
deviceMessageFeignClient.getLineInfo(param);
|
||||||
//4.生成装置和模板的关系表
|
//4.生成装置和模板的关系表
|
||||||
CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm();
|
CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm();
|
||||||
csDevModelRelationAddParm.setDevId(vo.getId());
|
csDevModelRelationAddParm.setDevId(vo.getId());
|
||||||
@@ -445,7 +488,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
//5.发起自动接入请求
|
//5.发起自动接入请求
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
//先获取版本
|
//先获取版本
|
||||||
// String version = csTopicService.getVersion(nDid);
|
//String version = csTopicService.getVersion(nDid);
|
||||||
String version = "V1";
|
String version = "V1";
|
||||||
devAccessAskTemplate(nDid,version,1);
|
devAccessAskTemplate(nDid,version,1);
|
||||||
//6.修改流程,便携式设备接入成功即为实际环境
|
//6.修改流程,便携式设备接入成功即为实际环境
|
||||||
@@ -481,6 +524,149 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
this.devAccessAskTemplate(nDid,version,1);
|
this.devAccessAskTemplate(nDid,version,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String autoPortableLedger() {
|
||||||
|
CsEngineeringPO csEngineeringPO = engineeringFeignClient.getEngineeringByName("便携式工程").getData();
|
||||||
|
if (csEngineeringPO == null) {
|
||||||
|
//新增便携式工程
|
||||||
|
CsEngineeringAddParm param = new CsEngineeringAddParm();
|
||||||
|
param.setName("便携式工程");
|
||||||
|
param.setProvince("320000000000");
|
||||||
|
param.setCity("320100000000");
|
||||||
|
param.setDescription("便携式工程");
|
||||||
|
param.setSort(Integer.MAX_VALUE);
|
||||||
|
csEngineeringPO = engineeringFeignClient.addEngineering(param).getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
AppProjectPO csProjectPO = appProjectFeignClient.getProjectByName("便携式项目").getData();
|
||||||
|
if (csProjectPO == null) {
|
||||||
|
//新增便携式项目
|
||||||
|
AppProjectAddParm param = new AppProjectAddParm();
|
||||||
|
param.setEngineeringId(csEngineeringPO.getId());
|
||||||
|
param.setName("便携式项目");
|
||||||
|
param.setArea("园区");
|
||||||
|
param.setDescription("便携式项目");
|
||||||
|
param.setTopoIds(Collections.singletonList("99ed9b9c8cf9007cc4d2ac4c7127b7e4"));
|
||||||
|
param.setSort(Integer.MAX_VALUE);
|
||||||
|
csProjectPO = appProjectFeignClient.addPortableProject(param).getData();
|
||||||
|
}
|
||||||
|
//修改已存在的便携式设备
|
||||||
|
csLedgerService.updatePortableLedger(csEngineeringPO.getId(),csProjectPO.getId());
|
||||||
|
return csProjectPO.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public String onlineRegister(String projectId,String nDid) {
|
||||||
|
String result = "fail";
|
||||||
|
// 根据模板接入设备
|
||||||
|
DeviceLogDTO logDto = new DeviceLogDTO();
|
||||||
|
logDto.setUserName(RequestUtil.getUserNickname());
|
||||||
|
logDto.setLoginName(RequestUtil.getUsername());
|
||||||
|
logDto.setOperate("监测设备"+nDid+"注册、接入");
|
||||||
|
logDto.setResult(1);
|
||||||
|
try {
|
||||||
|
// 设备状态判断
|
||||||
|
checkDeviceStatus(nDid);
|
||||||
|
// 询问设备支持的主题信息,并将支持的主题入库
|
||||||
|
askAndStoreTopics(nDid);
|
||||||
|
Thread.sleep(2000);
|
||||||
|
// MQTT询问装置用的模板,并判断库中是否存在模板
|
||||||
|
checkDeviceModel(nDid);
|
||||||
|
Thread.sleep(2000);
|
||||||
|
CsEquipmentDeliveryVO vo = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||||
|
List<CsLinePO> csLinePoList = new ArrayList<>();
|
||||||
|
//1.录入装置台账信息
|
||||||
|
//新增监测设备
|
||||||
|
CsLedgerParam csLedgerParam = new CsLedgerParam();
|
||||||
|
csLedgerParam.setId(vo.getId());
|
||||||
|
csLedgerParam.setPid(projectId);
|
||||||
|
csLedgerParam.setName(vo.getName());
|
||||||
|
csLedgerParam.setLevel(2);
|
||||||
|
csLedgerParam.setSort(0);
|
||||||
|
csLedgerService.addLedgerTree(csLedgerParam);
|
||||||
|
//2.根据模板获取监测点个数,插入监测点表
|
||||||
|
Thread.sleep(2000);
|
||||||
|
List<CsModelDto> modelList = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + nDid),CsModelDto.class);
|
||||||
|
if (CollUtil.isEmpty(modelList)) {
|
||||||
|
throwExceptionAndLog(nDid,AccessResponseEnum.MODEL_ERROR, logDto);
|
||||||
|
}
|
||||||
|
List<CsDataSet> list = csDataSetService.getDataSetData(modelList.get(0).getModelId());
|
||||||
|
list.forEach(item->{
|
||||||
|
CsLinePO po = new CsLinePO();
|
||||||
|
po.setLineId(nDid + item.getClDev().toString());
|
||||||
|
po.setName(item.getClDev().toString() + "#监测点");
|
||||||
|
po.setStatus(1);
|
||||||
|
po.setClDid(item.getClDev());
|
||||||
|
po.setLineNo(item.getClDev());
|
||||||
|
po.setRunStatus(0);
|
||||||
|
po.setDeviceId(vo.getId());
|
||||||
|
po.setDataSetId(item.getId());
|
||||||
|
po.setDataModelId(item.getPid());
|
||||||
|
//防止主键重复
|
||||||
|
QueryWrapper<CsLinePO> qw = new QueryWrapper<>();
|
||||||
|
qw.eq("line_id",po.getLineId());
|
||||||
|
if(csLineService.getBaseMapper().selectList(qw).isEmpty()){
|
||||||
|
csLinePoList.add(po);
|
||||||
|
}
|
||||||
|
//3.生成台账树监测点数据
|
||||||
|
CsLedgerParam param = new CsLedgerParam();
|
||||||
|
param.setId(nDid + item.getClDev().toString());
|
||||||
|
param.setPid(vo.getId());
|
||||||
|
param.setName(item.getClDev().toString() + "#监测点");
|
||||||
|
param.setLevel(3);
|
||||||
|
param.setSort(0);
|
||||||
|
csLedgerService.addLedgerTree(param);
|
||||||
|
});
|
||||||
|
csLineService.saveBatch(csLinePoList);
|
||||||
|
redisUtil.saveByKeyWithExpire("accessLineInfo:" + nDid,csLinePoList,30L);
|
||||||
|
//缓存监测点信息
|
||||||
|
LineInfoParam param = new LineInfoParam();
|
||||||
|
param.setNDid(nDid);
|
||||||
|
param.setList(csLinePoList);
|
||||||
|
deviceMessageFeignClient.getLineInfo(param);
|
||||||
|
//4.生成装置和模板的关系表
|
||||||
|
CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm();
|
||||||
|
csDevModelRelationAddParm.setDevId(vo.getId());
|
||||||
|
csDevModelRelationAddParm.setModelId(modelList.get(0).getModelId());
|
||||||
|
csDevModelRelationAddParm.setDid(modelList.get(0).getDid());
|
||||||
|
csDevModelRelationService.addDevModelRelation(csDevModelRelationAddParm);
|
||||||
|
//5.绑定装置和人的关系
|
||||||
|
CsDeviceUserPO po = new CsDeviceUserPO();
|
||||||
|
po.setPrimaryUserId(RequestUtil.getUserIndex());
|
||||||
|
po.setStatus("1");
|
||||||
|
po.setSubUserId(RequestUtil.getUserIndex());
|
||||||
|
po.setDeviceId(vo.getId());
|
||||||
|
csDeviceUserService.saveBatch(Collections.singletonList(po));
|
||||||
|
|
||||||
|
//发起自动接入请求
|
||||||
|
Thread.sleep(2000);
|
||||||
|
//先获取版本
|
||||||
|
String version = "V1";
|
||||||
|
devAccessAskTemplate(nDid,version,1);
|
||||||
|
//6.修改流程,接入成功即为实际环境
|
||||||
|
csEquipmentDeliveryService.updateProcessBynDid(nDid,4);
|
||||||
|
//7.存储日志
|
||||||
|
csLogsFeignClient.addUserLog(logDto);
|
||||||
|
//9.删除redis监测点模板信息
|
||||||
|
redisUtil.delete(AppRedisKey.MODEL + nDid);
|
||||||
|
redisUtil.delete(AppRedisKey.LINE + nDid);
|
||||||
|
//判断接入状态
|
||||||
|
Thread.sleep(5000);
|
||||||
|
Object object = redisUtil.getObjectByKey("online" + nDid);
|
||||||
|
if (Objects.nonNull(object)) {
|
||||||
|
result = "success";
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logDto.setResult(0);
|
||||||
|
logDto.setFailReason(e.getMessage());
|
||||||
|
csLogsFeignClient.addUserLog(logDto);
|
||||||
|
resetFactory(nDid);
|
||||||
|
throw new BusinessException(e.getMessage());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private void checkDeviceStatus(String nDid) {
|
private void checkDeviceStatus(String nDid) {
|
||||||
DeviceLogDTO logDto = createLogDto("当前设备"+nDid+"状态判断");
|
DeviceLogDTO logDto = createLogDto("当前设备"+nDid+"状态判断");
|
||||||
CsEquipmentDeliveryVO csEquipmentDeliveryVO = csEquipmentDeliveryService.queryEquipmentBynDid(nDid);
|
CsEquipmentDeliveryVO csEquipmentDeliveryVO = csEquipmentDeliveryService.queryEquipmentBynDid(nDid);
|
||||||
@@ -492,7 +678,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
throwExceptionAndLog(nDid,AccessResponseEnum.DEV_NOT_FIND, logDto);
|
throwExceptionAndLog(nDid,AccessResponseEnum.DEV_NOT_FIND, logDto);
|
||||||
}
|
}
|
||||||
String code = sysDicTreePo.getCode();
|
String code = sysDicTreePo.getCode();
|
||||||
if (!Objects.equals(code, DicDataEnum.PORTABLE.getCode())) {
|
if (!Objects.equals(code, DicDataEnum.PORTABLE.getCode()) && !Objects.equals(code, DicDataEnum.DEV_CLD.getCode())) {
|
||||||
throwExceptionAndLog(nDid,AccessResponseEnum.DEV_IS_NOT_PORTABLE, logDto);
|
throwExceptionAndLog(nDid,AccessResponseEnum.DEV_IS_NOT_PORTABLE, logDto);
|
||||||
}
|
}
|
||||||
if (!mqttUtil.judgeClientOnline("NJCN-" + nDid.substring(nDid.length() - 6))) {
|
if (!mqttUtil.judgeClientOnline("NJCN-" + nDid.substring(nDid.length() - 6))) {
|
||||||
@@ -721,20 +907,13 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
csDevModelRelationService.addRelation(po);
|
csDevModelRelationService.addRelation(po);
|
||||||
modelMap.put(item.getType(), item.getModelId());
|
modelMap.put(item.getType(), item.getModelId());
|
||||||
}
|
}
|
||||||
List<CsLinePO> lineList;
|
|
||||||
Object object = redisUtil.getObjectByKey("accessLineInfo:" + nDid);
|
Object object = redisUtil.getObjectByKey("accessLineInfo:" + nDid);
|
||||||
if (Objects.isNull(object)) {
|
if (Objects.isNull(object)) {
|
||||||
lineList = csLineFeignClient.findByNdid(nDid).getData();
|
LineInfoParam param = new LineInfoParam();
|
||||||
for (CsLinePO item : lineList) {
|
param.setNDid(nDid);
|
||||||
if (item.getClDid() == 0) {
|
deviceMessageFeignClient.getLineInfo(param);
|
||||||
updateLineIds(modelMap.get(0), item.getClDid(), nDid);
|
|
||||||
} else {
|
|
||||||
updateLineIds(modelMap.get(1), item.getClDid(), nDid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
publisher.send("/Pfm/DevCmd/"+version+"/"+nDid, new Gson().toJson(getJson(mid,TypeEnum.TYPE_5.getCode())), 1, false);
|
publisher.send("/Pfm/DevCmd/"+version+"/"+nDid, new Gson().toJson(getJson(mid,TypeEnum.TYPE_5.getCode())), 1, false);
|
||||||
// redisUtil.saveByKeyWithExpire("startFile:" + nDid, null, 60L);
|
|
||||||
result = true;
|
result = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
DeviceLogDTO logDto = new DeviceLogDTO();
|
DeviceLogDTO logDto = new DeviceLogDTO();
|
||||||
|
|||||||
@@ -17,10 +17,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,9 +38,15 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
|||||||
private final CsLogsFeignClient csLogsFeignClient;
|
private final CsLogsFeignClient csLogsFeignClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatusBynDid(String nDid,Integer status) {
|
public void updateStatusBynDid(String nDid,Integer status,String engineeringId, String projectId) {
|
||||||
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||||
lambdaUpdateWrapper.set(CsEquipmentDeliveryPO::getStatus,status).eq(CsEquipmentDeliveryPO::getNdid,nDid);
|
lambdaUpdateWrapper.set(CsEquipmentDeliveryPO::getStatus,status).eq(CsEquipmentDeliveryPO::getNdid,nDid);
|
||||||
|
if (engineeringId != null && !engineeringId.isEmpty()) {
|
||||||
|
lambdaUpdateWrapper.set(CsEquipmentDeliveryPO::getAssociatedEngineering,engineeringId);
|
||||||
|
}
|
||||||
|
if (projectId != null && !projectId.isEmpty()) {
|
||||||
|
lambdaUpdateWrapper.set(CsEquipmentDeliveryPO::getAssociatedProject,projectId);
|
||||||
|
}
|
||||||
this.update(lambdaUpdateWrapper);
|
this.update(lambdaUpdateWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +123,15 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CsEquipmentDeliveryPO> getUseOnlineDevice() {
|
||||||
|
return this.lambdaQuery()
|
||||||
|
.eq(CsEquipmentDeliveryPO::getRunStatus,AccessEnum.ONLINE.getCode())
|
||||||
|
.eq(CsEquipmentDeliveryPO::getDevAccessMethod,"MQTT")
|
||||||
|
.eq(CsEquipmentDeliveryPO::getUsageStatus,1)
|
||||||
|
.list();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CsEquipmentDeliveryPO> getOfflineDev() {
|
public List<CsEquipmentDeliveryPO> getOfflineDev() {
|
||||||
List<CsEquipmentDeliveryPO> result = new ArrayList<>();
|
List<CsEquipmentDeliveryPO> result = new ArrayList<>();
|
||||||
|
|||||||
@@ -0,0 +1,146 @@
|
|||||||
|
package com.njcn.access.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import com.njcn.access.enums.AccessEnum;
|
||||||
|
import com.njcn.access.pojo.dto.NoticeUserDto;
|
||||||
|
import com.njcn.access.service.ICsEquipmentDeliveryService;
|
||||||
|
import com.njcn.access.service.ICsHeartService;
|
||||||
|
import com.njcn.access.service.IHeartbeatService;
|
||||||
|
import com.njcn.access.utils.SendMessageUtil;
|
||||||
|
import com.njcn.common.pojo.dto.DeviceLogDTO;
|
||||||
|
import com.njcn.csdevice.api.*;
|
||||||
|
import com.njcn.csdevice.param.DeviceMessageParam;
|
||||||
|
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||||
|
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||||
|
import com.njcn.mq.message.HeartbeatTimeoutMessage;
|
||||||
|
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||||
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
|
import com.njcn.user.api.AppUserFeignClient;
|
||||||
|
import com.njcn.user.api.UserFeignClient;
|
||||||
|
import com.njcn.user.pojo.po.User;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 数据集表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-08-01
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class CsHeartServiceImpl implements ICsHeartService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ICsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||||
|
@Resource
|
||||||
|
private CsLogsFeignClient csLogsFeignClient;
|
||||||
|
@Resource
|
||||||
|
private EquipmentFeignClient equipmentFeignClient;
|
||||||
|
@Resource
|
||||||
|
private SendMessageUtil sendMessageUtil;
|
||||||
|
@Resource
|
||||||
|
private CsLedgerFeignClient csLedgerFeignclient;
|
||||||
|
@Resource
|
||||||
|
private AppUserFeignClient appUserFeignClient;
|
||||||
|
@Resource
|
||||||
|
private CsDeviceUserFeignClient csDeviceUserFeignClient;
|
||||||
|
@Resource
|
||||||
|
private UserFeignClient userFeignClient;
|
||||||
|
@Resource
|
||||||
|
private IHeartbeatService heartbeatService;
|
||||||
|
@Resource
|
||||||
|
private CsCommunicateFeignClient csCommunicateFeignClient;
|
||||||
|
@Resource
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
@Resource
|
||||||
|
private DeviceMessageFeignClient deviceMessageFeignClient;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleHeartbeat(HeartbeatTimeoutMessage message) {
|
||||||
|
String nDid = message.getNDid();
|
||||||
|
Long sendTime = message.getTimestamp();
|
||||||
|
if (heartbeatService.isHeartbeatUpdated(nDid, sendTime)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.info("{}->装置离线,执行业务处理", nDid);
|
||||||
|
handleDeviceOffline(nDid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleDeviceOffline(String nDid) {
|
||||||
|
DeviceLogDTO logDto = new DeviceLogDTO();
|
||||||
|
logDto.setUserName("运维管理员");
|
||||||
|
logDto.setLoginName("njcnyw");
|
||||||
|
//装置下线
|
||||||
|
csEquipmentDeliveryService.updateRunStatusBynDid(nDid, AccessEnum.OFFLINE.getCode());
|
||||||
|
//装置调整为注册状态
|
||||||
|
csEquipmentDeliveryService.updateStatusBynDid(nDid,AccessEnum.REGISTERED.getCode(),null,null);
|
||||||
|
logDto.setOperate(nDid +"装置离线");
|
||||||
|
sendMessage(nDid);
|
||||||
|
//记录装置掉线时间
|
||||||
|
PqsCommunicateDto dto = new PqsCommunicateDto();
|
||||||
|
dto.setTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||||
|
dto.setDevId(nDid);
|
||||||
|
dto.setType(0);
|
||||||
|
dto.setDescription("通讯中断");
|
||||||
|
csCommunicateFeignClient.insertion(dto);
|
||||||
|
csLogsFeignClient.addUserLog(logDto);
|
||||||
|
//清空缓存
|
||||||
|
redisUtil.deleteKeysByString(AppRedisKey.LINE_POSITION+nDid);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendMessage(String nDid) {
|
||||||
|
boolean devModel = equipmentFeignClient.judgeDevModel(nDid).getData();
|
||||||
|
if (devModel) {
|
||||||
|
NoticeUserDto dto = sendOffLine(nDid);
|
||||||
|
if (CollectionUtil.isNotEmpty(dto.getPushClientId())) {
|
||||||
|
sendMessageUtil.sendEventToUser(dto);
|
||||||
|
addLogs(dto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//掉线通知
|
||||||
|
private NoticeUserDto sendOffLine(String nDid) {
|
||||||
|
NoticeUserDto dto = new NoticeUserDto();
|
||||||
|
dto.setTitle("设备离线");
|
||||||
|
CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(nDid).getData();
|
||||||
|
DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(po.getId()).getData();
|
||||||
|
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
LocalDateTime localDateTime = LocalDateTime.now();
|
||||||
|
String dateStr = localDateTime.format(fmt);
|
||||||
|
String content = String.format(devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName() + "于" + dateStr + "离线");
|
||||||
|
dto.setContent(content);
|
||||||
|
//获取设备关联的用户
|
||||||
|
List<String> eventUser = deviceMessageFeignClient.getEventUserByDeviceId(po.getId(),true).getData();
|
||||||
|
DeviceMessageParam param1 = new DeviceMessageParam();
|
||||||
|
param1.setUserList(eventUser);
|
||||||
|
param1.setEventType(2);
|
||||||
|
//获取打开推送的用户
|
||||||
|
List<User> users = deviceMessageFeignClient.getSendUserByType(param1).getData();
|
||||||
|
if (CollectionUtil.isNotEmpty(users)){
|
||||||
|
dto.setPushClientId(
|
||||||
|
users.stream().filter(Objects::nonNull).map(User::getDevCode).filter(org.apache.commons.lang3.StringUtils::isNotBlank).distinct().collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addLogs(NoticeUserDto noticeUserDto) {
|
||||||
|
DeviceLogDTO dto = new DeviceLogDTO();
|
||||||
|
dto.setUserName("运维管理员");
|
||||||
|
dto.setLoginName("njcnyw");
|
||||||
|
dto.setOperate(noticeUserDto.getContent());
|
||||||
|
csLogsFeignClient.addUserLog(dto);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.njcn.access.service.impl;
|
package com.njcn.access.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.access.mapper.CsLedgerMapper;
|
import com.njcn.access.mapper.CsLedgerMapper;
|
||||||
import com.njcn.access.service.ICsLedgerService;
|
import com.njcn.access.service.ICsLedgerService;
|
||||||
@@ -8,8 +10,11 @@ import com.njcn.csdevice.pojo.po.CsLedger;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -24,6 +29,7 @@ import java.util.Objects;
|
|||||||
public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> implements ICsLedgerService {
|
public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> implements ICsLedgerService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public CsLedger addLedgerTree(CsLedgerParam csLedgerParam) {
|
public CsLedger addLedgerTree(CsLedgerParam csLedgerParam) {
|
||||||
CsLedger fatherCsLedger = this.lambdaQuery().eq(CsLedger::getId,csLedgerParam.getPid()).eq(CsLedger::getState,1).one();
|
CsLedger fatherCsLedger = this.lambdaQuery().eq(CsLedger::getId,csLedgerParam.getPid()).eq(CsLedger::getState,1).one();
|
||||||
CsLedger csLedger = new CsLedger();
|
CsLedger csLedger = new CsLedger();
|
||||||
@@ -43,4 +49,35 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
|||||||
return csLedger;
|
return csLedger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
|
public void updatePortableLedger(String engineeringId, String projectId) {
|
||||||
|
//先查询有没有历史的便携式设备
|
||||||
|
List<CsLedger> portableDevices = this.list(
|
||||||
|
new LambdaQueryWrapper<CsLedger>()
|
||||||
|
.eq(CsLedger::getPid, "0")
|
||||||
|
.eq(CsLedger::getLevel, 2)
|
||||||
|
.eq(CsLedger::getState, 1));
|
||||||
|
if (CollectionUtil.isNotEmpty(portableDevices)) {
|
||||||
|
portableDevices.forEach(item->{
|
||||||
|
item.setPid(projectId);
|
||||||
|
item.setPids("0," + engineeringId + "," + projectId);
|
||||||
|
});
|
||||||
|
this.updateBatchById(portableDevices);
|
||||||
|
//获取监测点id
|
||||||
|
List<String> devList = portableDevices.stream().map(CsLedger::getId).collect(Collectors.toList());
|
||||||
|
LambdaQueryWrapper<CsLedger> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.in(CsLedger::getPid, devList).eq(CsLedger::getState,1).eq(CsLedger::getLevel,3);
|
||||||
|
List<CsLedger> pointList = this.list(queryWrapper);
|
||||||
|
if (CollectionUtil.isNotEmpty(pointList)) {
|
||||||
|
pointList.forEach(item->{
|
||||||
|
String pidS = item.getPids();
|
||||||
|
String devPid = pidS.split(",")[1];
|
||||||
|
item.setPids("0," + engineeringId + "," + projectId + "," + devPid);
|
||||||
|
});
|
||||||
|
this.updateBatchById(pointList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import com.njcn.access.mapper.CsTopicMapper;
|
|||||||
import com.njcn.access.pojo.po.CsTopic;
|
import com.njcn.access.pojo.po.CsTopic;
|
||||||
import com.njcn.access.service.ICsTopicService;
|
import com.njcn.access.service.ICsTopicService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -42,4 +41,11 @@ public class CsTopicServiceImpl extends ServiceImpl<CsTopicMapper, CsTopic> impl
|
|||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByNDid(String nDid) {
|
||||||
|
LambdaQueryWrapper<CsTopic> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(CsTopic::getNDid,nDid);
|
||||||
|
this.remove(lambdaQueryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.njcn.access.service.impl;
|
||||||
|
|
||||||
|
import com.njcn.access.service.IHeartbeatService;
|
||||||
|
import com.njcn.mq.message.HeartbeatTimeoutMessage;
|
||||||
|
import com.njcn.mq.template.HeartbeatTimeoutMessageTemplate;
|
||||||
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class HeartbeatServiceImpl implements IHeartbeatService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private HeartbeatTimeoutMessageTemplate heartbeatTimeoutMessageTemplate;
|
||||||
|
@Resource
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
private static final String HEARTBEAT_REDIS_KEY_PREFIX = "HEARTBEAT:";
|
||||||
|
private static final int DELAY_LEVEL_4MIN = 7;
|
||||||
|
private static final long HEARTBEAT_EXPIRE_SECONDS = 180;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receiveHeartbeat(String nDid) {
|
||||||
|
String redisKey = HEARTBEAT_REDIS_KEY_PREFIX + nDid;
|
||||||
|
long currentTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
redisUtil.saveByKey(redisKey, currentTime);
|
||||||
|
redisUtil.expire(redisKey, HEARTBEAT_EXPIRE_SECONDS);
|
||||||
|
|
||||||
|
HeartbeatTimeoutMessage message = new HeartbeatTimeoutMessage();
|
||||||
|
|
||||||
|
message.setNDid(nDid);
|
||||||
|
message.setTimestamp(currentTime);
|
||||||
|
message.setDelayLevel(DELAY_LEVEL_4MIN);
|
||||||
|
heartbeatTimeoutMessageTemplate.sendMember(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isHeartbeatUpdated(String nDid, Long sendTime) {
|
||||||
|
String redisKey = HEARTBEAT_REDIS_KEY_PREFIX + nDid;
|
||||||
|
Object lastHeartbeat = redisUtil.getObjectByKey(redisKey);
|
||||||
|
|
||||||
|
if (lastHeartbeat == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
long lastUpdateTime = Long.parseLong(lastHeartbeat.toString());
|
||||||
|
return lastUpdateTime > sendTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -45,6 +45,7 @@ logging:
|
|||||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||||
level:
|
level:
|
||||||
root: info
|
root: info
|
||||||
|
com.njcn.middle.rocket.template.RocketMQEnhanceTemplate: ERROR
|
||||||
|
|
||||||
|
|
||||||
#mybatis配置信息
|
#mybatis配置信息
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.tocrhz</groupId>
|
||||||
|
<artifactId>mqtt-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.njcn</groupId>
|
<groupId>com.njcn</groupId>
|
||||||
<artifactId>common-web</artifactId>
|
<artifactId>common-web</artifactId>
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ import com.njcn.common.utils.PubUtils;
|
|||||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||||
import com.njcn.csdevice.api.DataArrayFeignClient;
|
import com.njcn.csdevice.api.DataArrayFeignClient;
|
||||||
import com.njcn.csdevice.api.DataSetFeignClient;
|
import com.njcn.csdevice.api.DataSetFeignClient;
|
||||||
|
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
import com.njcn.csdevice.pojo.po.CsDataSet;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||||
import com.njcn.mq.message.AppAutoDataMessage;
|
import com.njcn.mq.message.AppAutoDataMessage;
|
||||||
import com.njcn.redis.utils.RedisUtil;
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
@@ -21,7 +23,6 @@ import com.njcn.rt.pojo.dto.BaseRealDataSet;
|
|||||||
import com.njcn.rt.pojo.dto.HarmData;
|
import com.njcn.rt.pojo.dto.HarmData;
|
||||||
import com.njcn.rt.pojo.dto.HarmRealDataSet;
|
import com.njcn.rt.pojo.dto.HarmRealDataSet;
|
||||||
import com.njcn.rt.service.IRtService;
|
import com.njcn.rt.service.IRtService;
|
||||||
import com.njcn.web.utils.FloatUtils;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -51,6 +52,7 @@ public class RtServiceImpl implements IRtService {
|
|||||||
private final ChannelObjectUtil channelObjectUtil;
|
private final ChannelObjectUtil channelObjectUtil;
|
||||||
private final MqttPublisher publisher;
|
private final MqttPublisher publisher;
|
||||||
private final RedisSetUtil redisSetUtil;
|
private final RedisSetUtil redisSetUtil;
|
||||||
|
private final EquipmentFeignClient equipmentFeignClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analysis(AppAutoDataMessage appAutoDataMessage) {
|
public void analysis(AppAutoDataMessage appAutoDataMessage) {
|
||||||
@@ -74,35 +76,42 @@ public class RtServiceImpl implements IRtService {
|
|||||||
}
|
}
|
||||||
//根据dataArray解析数据
|
//根据dataArray解析数据
|
||||||
AppAutoDataMessage.DataArray item = appAutoDataMessage.getMsg().getDataArray().get(0);
|
AppAutoDataMessage.DataArray item = appAutoDataMessage.getMsg().getDataArray().get(0);
|
||||||
|
//获取设备类型
|
||||||
|
CsEquipmentDeliveryPO po1 =equipmentFeignClient.getDevByLineId(lineId).getData();
|
||||||
|
Float ct = po.getCtRatio().floatValue() / (po.getCt2Ratio() == null ? 1.0f:po.getCt2Ratio().floatValue());
|
||||||
|
Float pt = po.getPtRatio().floatValue() / (po.getPt2Ratio() == null ? 1.0f:po.getPt2Ratio().floatValue());
|
||||||
//fixme 这边先根据数据集的名称来返回对应实体,这边感觉不太合适,后期有好方案再调整
|
//fixme 这边先根据数据集的名称来返回对应实体,这边感觉不太合适,后期有好方案再调整
|
||||||
//基础数据
|
//基础数据
|
||||||
if (dataSet.getName().contains("Ds$Pqd$Rt$Basic$")) {
|
if (dataSet.getName().contains("Ds$Pqd$Rt$Basic$")) {
|
||||||
//用户Id
|
//用户Id
|
||||||
String userId = redisUtil.getObjectByKey("rtDataUserId:"+lineId).toString();
|
Object redisObject = redisUtil.getObjectByKey("rtDataUserId:"+lineId);
|
||||||
BaseRealDataSet baseRealDataSet = assembleData(dataArrayList,item,po.getConType());
|
if (ObjectUtil.isNotNull(redisObject)) {
|
||||||
baseRealDataSet.setUserId(userId);
|
String userId = redisObject.toString();
|
||||||
baseRealDataSet.setLineId(lineId);
|
BaseRealDataSet baseRealDataSet = assembleData(dataArrayList,item,po.getConType(),po1.getDevAccessMethod());
|
||||||
baseRealDataSet.setPt(po.getPtRatio().floatValue());
|
baseRealDataSet.setUserId(userId);
|
||||||
baseRealDataSet.setCt(po.getCtRatio().floatValue());
|
baseRealDataSet.setLineId(lineId);
|
||||||
baseRealDataSet.setDataLevel(dataSet.getDataLevel());
|
baseRealDataSet.setPt(pt);
|
||||||
long timestamp = item.getDataTimeSec() - 8*3600;
|
baseRealDataSet.setCt(ct);
|
||||||
baseRealDataSet.setDataTime(getTime(timestamp));
|
baseRealDataSet.setDataLevel(dataSet.getDataLevel());
|
||||||
publisher.send("/Web/RealData/" + lineId, new Gson().toJson(baseRealDataSet), 1, false);
|
long timestamp = item.getDataTimeSec() - 8*3600;
|
||||||
|
baseRealDataSet.setDataTime(getTime(timestamp));
|
||||||
|
publisher.send("/Web/RealData/" + lineId, new Gson().toJson(baseRealDataSet), 1, false);
|
||||||
|
}
|
||||||
} else if (dataSet.getName().contains("实时数据") || dataSet.getName().contains("Ds$Pqd$Rt$01")) {
|
} else if (dataSet.getName().contains("实时数据") || dataSet.getName().contains("Ds$Pqd$Rt$01")) {
|
||||||
//用户Id
|
//用户Id
|
||||||
Object redisObject = redisUtil.getObjectByKey("rtDataUserId:"+lineId);
|
Object redisObject = redisUtil.getObjectByKey("rtDataUserId:"+lineId);
|
||||||
if (ObjectUtil.isNotNull(redisObject)) {
|
if (ObjectUtil.isNotNull(redisObject)) {
|
||||||
Set<String> userSet = redisSetUtil.convertToSet(redisObject);
|
Set<String> userSet = redisSetUtil.convertToSet(redisObject);
|
||||||
userSet.forEach(userId->{
|
userSet.forEach(userId->{
|
||||||
BaseRealDataSet baseRealDataSet = assembleData(dataArrayList,item,po.getConType());
|
BaseRealDataSet baseRealDataSet = assembleData(dataArrayList,item,po.getConType(),po1.getDevAccessMethod());
|
||||||
baseRealDataSet.setUserId(userId);
|
baseRealDataSet.setUserId(userId);
|
||||||
baseRealDataSet.setLineId(lineId);
|
baseRealDataSet.setLineId(lineId);
|
||||||
baseRealDataSet.setPt(po.getPtRatio().floatValue());
|
baseRealDataSet.setPt(pt);
|
||||||
baseRealDataSet.setCt(po.getCtRatio().floatValue());
|
baseRealDataSet.setCt(ct);
|
||||||
baseRealDataSet.setDataLevel(dataSet.getDataLevel());
|
baseRealDataSet.setDataLevel(dataSet.getDataLevel());
|
||||||
long timestamp = item.getDataTimeSec();
|
long timestamp = item.getDataTimeSec();
|
||||||
baseRealDataSet.setDataTime(getTime(timestamp));
|
baseRealDataSet.setDataTime(getTime(timestamp));
|
||||||
publisher.send("/Web/RealData/" + userId, new Gson().toJson(baseRealDataSet), 1, false);
|
publisher.send("/Web/RealData/" + lineId, new Gson().toJson(baseRealDataSet), 1, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,20 +119,23 @@ public class RtServiceImpl implements IRtService {
|
|||||||
else {
|
else {
|
||||||
long timestamp;
|
long timestamp;
|
||||||
//用户Id
|
//用户Id
|
||||||
String userId = redisUtil.getObjectByKey("rtDataUserId:"+lineId).toString();
|
Object redisObject = redisUtil.getObjectByKey("rtDataUserId:"+lineId);
|
||||||
HarmRealDataSet harmRealDataSet = harmData(dataArrayList,item,dataSet.getDataLevel(),po.getCtRatio());
|
if (ObjectUtil.isNotNull(redisObject)) {
|
||||||
harmRealDataSet.setUserId(userId);
|
String userId = redisObject.toString();
|
||||||
harmRealDataSet.setLineId(lineId);
|
HarmRealDataSet harmRealDataSet = harmData(dataArrayList,item,dataSet.getDataLevel(),po.getCtRatio());
|
||||||
harmRealDataSet.setPt(po.getPtRatio().floatValue());
|
harmRealDataSet.setUserId(userId);
|
||||||
harmRealDataSet.setCt(po.getCtRatio().floatValue());
|
harmRealDataSet.setLineId(lineId);
|
||||||
harmRealDataSet.setDataLevel(dataSet.getDataLevel());
|
harmRealDataSet.setPt(pt);
|
||||||
if (ObjectUtil.isNotNull(po.getLineNo())) {
|
harmRealDataSet.setCt(ct);
|
||||||
timestamp = item.getDataTimeSec();
|
harmRealDataSet.setDataLevel(dataSet.getDataLevel());
|
||||||
} else {
|
if (ObjectUtil.isNotNull(po.getLineNo())) {
|
||||||
timestamp = item.getDataTimeSec() - 8*3600;
|
timestamp = item.getDataTimeSec();
|
||||||
|
} else {
|
||||||
|
timestamp = item.getDataTimeSec() - 8*3600;
|
||||||
|
}
|
||||||
|
harmRealDataSet.setDataTime(getTime(timestamp));
|
||||||
|
publisher.send("/Web/RealData/" + lineId, new Gson().toJson(harmRealDataSet), 1, false);
|
||||||
}
|
}
|
||||||
harmRealDataSet.setDataTime(getTime(timestamp));
|
|
||||||
publisher.send("/Web/RealData/" + lineId, new Gson().toJson(harmRealDataSet), 1, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,114 +213,194 @@ public class RtServiceImpl implements IRtService {
|
|||||||
return dataMap;
|
return dataMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseRealDataSet assembleData(List<CsDataArray> dataArrayList,AppAutoDataMessage.DataArray dataArray,Integer conType) {
|
public BaseRealDataSet assembleData(List<CsDataArray> dataArrayList,AppAutoDataMessage.DataArray dataArray,Integer conType,String accessMethod) {
|
||||||
Map<String,Float> dataMap = getData(dataArrayList,dataArray);
|
Map<String,Float> dataMap = getData(dataArrayList,dataArray);
|
||||||
return channelData(dataMap,conType);
|
if (Objects.equals("CLD",accessMethod)) {
|
||||||
|
return channelData(dataMap,conType);
|
||||||
|
} else {
|
||||||
|
return channelData2(dataMap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseRealDataSet channelData(Map<String,Float> map,Integer conType) {
|
public BaseRealDataSet channelData(Map<String,Float> map,Integer conType) {
|
||||||
BaseRealDataSet baseRealDataSet = new BaseRealDataSet();
|
BaseRealDataSet baseRealDataSet = new BaseRealDataSet();
|
||||||
//频率
|
//频率
|
||||||
baseRealDataSet.setFreq(FloatUtils.get2Float(map.get("Pq_FreqM")));
|
baseRealDataSet.setFreq(map.get("Pq_FreqT"));
|
||||||
//频率偏差
|
//频率偏差
|
||||||
baseRealDataSet.setFreqDev(FloatUtils.get2Float(map.get("Pq_FreqDevM")));
|
baseRealDataSet.setFreqDev(map.get("Pq_FreqDevT"));
|
||||||
//判断监测点的接线方式,不同接线方式电压有效值取值不同
|
//判断监测点的接线方式,不同接线方式电压有效值取值不同
|
||||||
//星型-相电压 角形、V型-线电压
|
//星型-相电压 角形、V型-线电压
|
||||||
//电压有效值
|
//电压有效值
|
||||||
if (conType == 0) {
|
if (conType == 0) {
|
||||||
baseRealDataSet.setVRmsA(FloatUtils.get2Float(map.get("Pq_RmsUA")));
|
baseRealDataSet.setVRmsA(map.get("Pq_RmsUA"));
|
||||||
baseRealDataSet.setVRmsB(FloatUtils.get2Float(map.get("Pq_RmsUB")));
|
baseRealDataSet.setVRmsB(map.get("Pq_RmsUB"));
|
||||||
baseRealDataSet.setVRmsC(FloatUtils.get2Float(map.get("Pq_RmsUC")));
|
baseRealDataSet.setVRmsC(map.get("Pq_RmsUC"));
|
||||||
} else {
|
} else {
|
||||||
baseRealDataSet.setVRmsA(FloatUtils.get2Float(map.get("Pq_RmsLUAB")));
|
baseRealDataSet.setVRmsA(map.get("Pq_RmsLUAB"));
|
||||||
baseRealDataSet.setVRmsB(FloatUtils.get2Float(map.get("Pq_RmsLUBC")));
|
baseRealDataSet.setVRmsB(map.get("Pq_RmsLUBC"));
|
||||||
baseRealDataSet.setVRmsC(FloatUtils.get2Float(map.get("Pq_RmsLUCA")));
|
baseRealDataSet.setVRmsC(map.get("Pq_RmsLUCA"));
|
||||||
}
|
}
|
||||||
//基波电压幅值
|
//基波电压幅值
|
||||||
if (conType == 0) {
|
if (conType == 0) {
|
||||||
baseRealDataSet.setV1A(FloatUtils.get2Float(map.get("Pq_RmsFundUA")));
|
baseRealDataSet.setV1A(map.get("Pq_RmsFundUA"));
|
||||||
baseRealDataSet.setV1B(FloatUtils.get2Float(map.get("Pq_RmsFundUB")));
|
baseRealDataSet.setV1B(map.get("Pq_RmsFundUB"));
|
||||||
baseRealDataSet.setV1C(FloatUtils.get2Float(map.get("Pq_RmsFundUC")));
|
baseRealDataSet.setV1C(map.get("Pq_RmsFundUC"));
|
||||||
} else {
|
} else {
|
||||||
baseRealDataSet.setV1A(FloatUtils.get2Float(map.get("Pq_RmsFundLUAB")));
|
baseRealDataSet.setV1A(map.get("Pq_RmsFundLUAB"));
|
||||||
baseRealDataSet.setV1B(FloatUtils.get2Float(map.get("Pq_RmsFundLUBC")));
|
baseRealDataSet.setV1B(map.get("Pq_RmsFundLUBC"));
|
||||||
baseRealDataSet.setV1C(FloatUtils.get2Float(map.get("Pq_RmsFundLUCA")));
|
baseRealDataSet.setV1C(map.get("Pq_RmsFundLUCA"));
|
||||||
}
|
}
|
||||||
//电流有效值
|
//电流有效值
|
||||||
baseRealDataSet.setIRmsA(FloatUtils.get2Float(map.get("Pq_RmsIA")));
|
baseRealDataSet.setIRmsA(map.get("Pq_RmsIA"));
|
||||||
baseRealDataSet.setIRmsB(FloatUtils.get2Float(map.get("Pq_RmsIB")));
|
baseRealDataSet.setIRmsB(map.get("Pq_RmsIB"));
|
||||||
baseRealDataSet.setIRmsC(FloatUtils.get2Float(map.get("Pq_RmsIC")));
|
baseRealDataSet.setIRmsC(map.get("Pq_RmsIC"));
|
||||||
//基波电流幅值
|
//基波电流幅值
|
||||||
baseRealDataSet.setI1A(FloatUtils.get2Float(map.get("Pq_RmsFundIA")));
|
baseRealDataSet.setI1A(map.get("Pq_RmsFundIA"));
|
||||||
baseRealDataSet.setI1B(FloatUtils.get2Float(map.get("Pq_RmsFundIB")));
|
baseRealDataSet.setI1B(map.get("Pq_RmsFundIB"));
|
||||||
baseRealDataSet.setI1C(FloatUtils.get2Float(map.get("Pq_RmsFundIC")));
|
baseRealDataSet.setI1C(map.get("Pq_RmsFundIC"));
|
||||||
//电压偏差
|
//电压偏差
|
||||||
if (conType == 0) {
|
if (conType == 0) {
|
||||||
baseRealDataSet.setVDevA(FloatUtils.get2Float(map.get("Pq_UDevA")));
|
baseRealDataSet.setVDevA(map.get("Pq_UDevA"));
|
||||||
baseRealDataSet.setVDevB(FloatUtils.get2Float(map.get("Pq_UDevB")));
|
baseRealDataSet.setVDevB(map.get("Pq_UDevB"));
|
||||||
baseRealDataSet.setVDevC(FloatUtils.get2Float(map.get("Pq_UDevC")));
|
baseRealDataSet.setVDevC(map.get("Pq_UDevC"));
|
||||||
} else {
|
} else {
|
||||||
baseRealDataSet.setVDevA(FloatUtils.get2Float(map.get("Pq_LUDevAB")));
|
baseRealDataSet.setVDevA(map.get("Pq_LUDevAB"));
|
||||||
baseRealDataSet.setVDevB(FloatUtils.get2Float(map.get("Pq_LUDevBC")));
|
baseRealDataSet.setVDevB(map.get("Pq_LUDevBC"));
|
||||||
baseRealDataSet.setVDevC(FloatUtils.get2Float(map.get("Pq_LUDevCA")));
|
baseRealDataSet.setVDevC(map.get("Pq_LUDevCA"));
|
||||||
}
|
}
|
||||||
//基波电压相位
|
//基波电压相位
|
||||||
if (conType == 0) {
|
if (conType == 0) {
|
||||||
baseRealDataSet.setV1AngA(FloatUtils.get2Float(map.get("Pq_FundUAngA")));
|
baseRealDataSet.setV1AngA(map.get("Pq_FundUAngA"));
|
||||||
baseRealDataSet.setV1AngB(FloatUtils.get2Float(map.get("Pq_FundUAngB")));
|
baseRealDataSet.setV1AngB(map.get("Pq_FundUAngB"));
|
||||||
baseRealDataSet.setV1AngC(FloatUtils.get2Float(map.get("Pq_FundUAngC")));
|
baseRealDataSet.setV1AngC(map.get("Pq_FundUAngC"));
|
||||||
} else {
|
} else {
|
||||||
baseRealDataSet.setV1AngA(FloatUtils.get2Float(map.get("Pq_FundLUAngAB")));
|
baseRealDataSet.setV1AngA(map.get("Pq_FundLUAngAB"));
|
||||||
baseRealDataSet.setV1AngB(FloatUtils.get2Float(map.get("Pq_FundLUAngBC")));
|
baseRealDataSet.setV1AngB(map.get("Pq_FundLUAngBC"));
|
||||||
baseRealDataSet.setV1AngC(FloatUtils.get2Float(map.get("Pq_FundLUAngCA")));
|
baseRealDataSet.setV1AngC(map.get("Pq_FundLUAngCA"));
|
||||||
}
|
}
|
||||||
//基波电流相位
|
//基波电流相位
|
||||||
baseRealDataSet.setI1AngA(FloatUtils.get2Float(map.get("Pq_FundIAngA")));
|
baseRealDataSet.setI1AngA(map.get("Pq_FundIAngA"));
|
||||||
baseRealDataSet.setI1AngB(FloatUtils.get2Float(map.get("Pq_FundIAngB")));
|
baseRealDataSet.setI1AngB(map.get("Pq_FundIAngB"));
|
||||||
baseRealDataSet.setI1AngC(FloatUtils.get2Float(map.get("Pq_FundIAngC")));
|
baseRealDataSet.setI1AngC(map.get("Pq_FundIAngC"));
|
||||||
//电压总谐波畸变率
|
//电压总谐波畸变率
|
||||||
if (conType == 0) {
|
if (conType == 0) {
|
||||||
baseRealDataSet.setVThdA(FloatUtils.get2Float(map.get("Pq_ThdUA")));
|
baseRealDataSet.setVThdA(map.get("Pq_ThdUA"));
|
||||||
baseRealDataSet.setVThdB(FloatUtils.get2Float(map.get("Pq_ThdUB")));
|
baseRealDataSet.setVThdB(map.get("Pq_ThdUB"));
|
||||||
baseRealDataSet.setVThdC(FloatUtils.get2Float(map.get("Pq_ThdUC")));
|
baseRealDataSet.setVThdC(map.get("Pq_ThdUC"));
|
||||||
} else {
|
} else {
|
||||||
baseRealDataSet.setVThdA(FloatUtils.get2Float(map.get("Pq_ThdLUAB")));
|
baseRealDataSet.setVThdA(map.get("Pq_ThdLUAB"));
|
||||||
baseRealDataSet.setVThdB(FloatUtils.get2Float(map.get("Pq_ThdLUBC")));
|
baseRealDataSet.setVThdB(map.get("Pq_ThdLUBC"));
|
||||||
baseRealDataSet.setVThdC(FloatUtils.get2Float(map.get("Pq_ThdLUCA")));
|
baseRealDataSet.setVThdC(map.get("Pq_ThdLUCA"));
|
||||||
}
|
}
|
||||||
//电流总谐波畸变率
|
//电流总谐波畸变率
|
||||||
baseRealDataSet.setIThdA(FloatUtils.get2Float(map.get("Pq_ThdIA")));
|
baseRealDataSet.setIThdA(map.get("Pq_ThdIA"));
|
||||||
baseRealDataSet.setIThdB(FloatUtils.get2Float(map.get("Pq_ThdIB")));
|
baseRealDataSet.setIThdB(map.get("Pq_ThdIB"));
|
||||||
baseRealDataSet.setIThdC(FloatUtils.get2Float(map.get("Pq_ThdIC")));
|
baseRealDataSet.setIThdC(map.get("Pq_ThdIC"));
|
||||||
//电压不平衡度
|
//电压不平衡度
|
||||||
baseRealDataSet.setVUnbalance(FloatUtils.get2Float(map.get("Pq_UnbalNegUM")));
|
baseRealDataSet.setVUnbalance(map.get("Pq_UnbalNegUT"));
|
||||||
//电流不平衡度
|
//电流不平衡度
|
||||||
baseRealDataSet.setIUnbalance(FloatUtils.get2Float(map.get("Pq_UnbalNegIM")));
|
baseRealDataSet.setIUnbalance(map.get("Pq_UnbalNegIT"));
|
||||||
//有功功率
|
//有功功率
|
||||||
baseRealDataSet.setPA(FloatUtils.get2Float(map.get("Pq_PA")));
|
baseRealDataSet.setPA(map.get("Pq_PA"));
|
||||||
baseRealDataSet.setPB(FloatUtils.get2Float(map.get("Pq_PB")));
|
baseRealDataSet.setPB(map.get("Pq_PB"));
|
||||||
baseRealDataSet.setPC(FloatUtils.get2Float(map.get("Pq_PC")));
|
baseRealDataSet.setPC(map.get("Pq_PC"));
|
||||||
baseRealDataSet.setPTot(FloatUtils.get2Float(map.get("Pq_TotPM")));
|
baseRealDataSet.setPTot(map.get("Pq_TotPT"));
|
||||||
//无功功率
|
//无功功率
|
||||||
baseRealDataSet.setQA(FloatUtils.get2Float(map.get("Pq_QA")));
|
baseRealDataSet.setQA(map.get("Pq_QA"));
|
||||||
baseRealDataSet.setQB(FloatUtils.get2Float(map.get("Pq_QB")));
|
baseRealDataSet.setQB(map.get("Pq_QB"));
|
||||||
baseRealDataSet.setQC(FloatUtils.get2Float(map.get("Pq_QC")));
|
baseRealDataSet.setQC(map.get("Pq_QC"));
|
||||||
baseRealDataSet.setQTot(FloatUtils.get2Float(map.get("Pq_TotQM")));
|
baseRealDataSet.setQTot(map.get("Pq_TotQT"));
|
||||||
//视在功率
|
//视在功率
|
||||||
baseRealDataSet.setSA(FloatUtils.get2Float(map.get("Pq_SA")));
|
baseRealDataSet.setSA(map.get("Pq_SA"));
|
||||||
baseRealDataSet.setSB(FloatUtils.get2Float(map.get("Pq_SB")));
|
baseRealDataSet.setSB(map.get("Pq_SB"));
|
||||||
baseRealDataSet.setSC(FloatUtils.get2Float(map.get("Pq_SC")));
|
baseRealDataSet.setSC(map.get("Pq_SC"));
|
||||||
baseRealDataSet.setSTot(FloatUtils.get2Float(map.get("Pq_TotSM")));
|
baseRealDataSet.setSTot(map.get("Pq_TotST"));
|
||||||
//功率因数
|
//视在功率因数
|
||||||
baseRealDataSet.setPfA(FloatUtils.get2Float(map.get("Pq_PFA")));
|
baseRealDataSet.setPfA(map.get("Pq_PFA"));
|
||||||
baseRealDataSet.setPfB(FloatUtils.get2Float(map.get("Pq_PFB")));
|
baseRealDataSet.setPfB(map.get("Pq_PFB"));
|
||||||
baseRealDataSet.setPfC(FloatUtils.get2Float(map.get("Pq_PFC")));
|
baseRealDataSet.setPfC(map.get("Pq_PFC"));
|
||||||
baseRealDataSet.setPfTot(FloatUtils.get2Float(map.get("Pq_TotPFM")));
|
baseRealDataSet.setPfTot(map.get("Pq_TotPFT"));
|
||||||
//基波功率因数
|
//位移功率因数
|
||||||
baseRealDataSet.setDpfA(FloatUtils.get2Float(map.get("Pq_DFA")));
|
baseRealDataSet.setDpfA(map.get("Pq_DFA"));
|
||||||
baseRealDataSet.setDpfB(FloatUtils.get2Float(map.get("Pq_DFB")));
|
baseRealDataSet.setDpfB(map.get("Pq_DFB"));
|
||||||
baseRealDataSet.setDpfC(FloatUtils.get2Float(map.get("Pq_DFC")));
|
baseRealDataSet.setDpfC(map.get("Pq_DFC"));
|
||||||
baseRealDataSet.setDpfTot(FloatUtils.get2Float(map.get("Pq_TotDFM")));
|
baseRealDataSet.setDpfTot(map.get("Pq_TotDFT"));
|
||||||
|
return baseRealDataSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseRealDataSet channelData2(Map<String,Float> map) {
|
||||||
|
BaseRealDataSet baseRealDataSet = new BaseRealDataSet();
|
||||||
|
//频率
|
||||||
|
baseRealDataSet.setFreq(map.get("Pq_FreqT"));
|
||||||
|
//频率偏差
|
||||||
|
baseRealDataSet.setFreqDev(map.get("Pq_FreqDevT"));
|
||||||
|
//判断监测点的接线方式,不同接线方式电压有效值取值不同
|
||||||
|
//星型-相电压 角形、V型-线电压
|
||||||
|
//电压有效值
|
||||||
|
baseRealDataSet.setVRmsA(map.get("Pq_RmsUA"));
|
||||||
|
baseRealDataSet.setVRmsB(map.get("Pq_RmsUB"));
|
||||||
|
baseRealDataSet.setVRmsC(map.get("Pq_RmsUC"));
|
||||||
|
//基波电压幅值
|
||||||
|
baseRealDataSet.setV1A(map.get("Pq_RmsFundUA"));
|
||||||
|
baseRealDataSet.setV1B(map.get("Pq_RmsFundUB"));
|
||||||
|
baseRealDataSet.setV1C(map.get("Pq_RmsFundUC"));
|
||||||
|
//电流有效值
|
||||||
|
baseRealDataSet.setIRmsA(map.get("Pq_RmsIA"));
|
||||||
|
baseRealDataSet.setIRmsB(map.get("Pq_RmsIB"));
|
||||||
|
baseRealDataSet.setIRmsC(map.get("Pq_RmsIC"));
|
||||||
|
//基波电流幅值
|
||||||
|
baseRealDataSet.setI1A(map.get("Pq_RmsFundIA"));
|
||||||
|
baseRealDataSet.setI1B(map.get("Pq_RmsFundIB"));
|
||||||
|
baseRealDataSet.setI1C(map.get("Pq_RmsFundIC"));
|
||||||
|
//电压偏差
|
||||||
|
baseRealDataSet.setVDevA(map.get("Pq_UDevA"));
|
||||||
|
baseRealDataSet.setVDevB(map.get("Pq_UDevB"));
|
||||||
|
baseRealDataSet.setVDevC(map.get("Pq_UDevC"));
|
||||||
|
//基波电压相位
|
||||||
|
baseRealDataSet.setV1AngA(map.get("Pq_FundUAngA"));
|
||||||
|
baseRealDataSet.setV1AngB(map.get("Pq_FundUAngB"));
|
||||||
|
baseRealDataSet.setV1AngC(map.get("Pq_FundUAngC"));
|
||||||
|
//基波电流相位
|
||||||
|
baseRealDataSet.setI1AngA(map.get("Pq_FundIAngA"));
|
||||||
|
baseRealDataSet.setI1AngB(map.get("Pq_FundIAngB"));
|
||||||
|
baseRealDataSet.setI1AngC(map.get("Pq_FundIAngC"));
|
||||||
|
//电压总谐波畸变率
|
||||||
|
baseRealDataSet.setVThdA(map.get("Pq_ThdUA"));
|
||||||
|
baseRealDataSet.setVThdB(map.get("Pq_ThdUB"));
|
||||||
|
baseRealDataSet.setVThdC(map.get("Pq_ThdUC"));
|
||||||
|
//电流总谐波畸变率
|
||||||
|
baseRealDataSet.setIThdA(map.get("Pq_ThdIA"));
|
||||||
|
baseRealDataSet.setIThdB(map.get("Pq_ThdIB"));
|
||||||
|
baseRealDataSet.setIThdC(map.get("Pq_ThdIC"));
|
||||||
|
//电压不平衡度
|
||||||
|
baseRealDataSet.setVUnbalance(map.get("Pq_UnbalNegUT"));
|
||||||
|
//电流不平衡度
|
||||||
|
baseRealDataSet.setIUnbalance(map.get("Pq_UnbalNegIT"));
|
||||||
|
//有功功率
|
||||||
|
baseRealDataSet.setPA(map.get("Pq_PA"));
|
||||||
|
baseRealDataSet.setPB(map.get("Pq_PB"));
|
||||||
|
baseRealDataSet.setPC(map.get("Pq_PC"));
|
||||||
|
baseRealDataSet.setPTot(map.get("Pq_TotPT"));
|
||||||
|
//无功功率
|
||||||
|
baseRealDataSet.setQA(map.get("Pq_QA"));
|
||||||
|
baseRealDataSet.setQB(map.get("Pq_QB"));
|
||||||
|
baseRealDataSet.setQC(map.get("Pq_QC"));
|
||||||
|
baseRealDataSet.setQTot(map.get("Pq_TotQT"));
|
||||||
|
//视在功率
|
||||||
|
baseRealDataSet.setSA(map.get("Pq_SA"));
|
||||||
|
baseRealDataSet.setSB(map.get("Pq_SB"));
|
||||||
|
baseRealDataSet.setSC(map.get("Pq_SC"));
|
||||||
|
baseRealDataSet.setSTot(map.get("Pq_TotST"));
|
||||||
|
//视在功率因数
|
||||||
|
baseRealDataSet.setPfA(map.get("Pq_PFA"));
|
||||||
|
baseRealDataSet.setPfB(map.get("Pq_PFB"));
|
||||||
|
baseRealDataSet.setPfC(map.get("Pq_PFC"));
|
||||||
|
baseRealDataSet.setPfTot(map.get("Pq_TotPFT"));
|
||||||
|
//位移功率因数
|
||||||
|
baseRealDataSet.setDpfA(map.get("Pq_DFA"));
|
||||||
|
baseRealDataSet.setDpfB(map.get("Pq_DFB"));
|
||||||
|
baseRealDataSet.setDpfC(map.get("Pq_DFC"));
|
||||||
|
baseRealDataSet.setDpfTot(map.get("Pq_TotDFT"));
|
||||||
return baseRealDataSet;
|
return baseRealDataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,14 +438,14 @@ public class RtServiceImpl implements IRtService {
|
|||||||
if (Objects.equals(item.getHarmName(),"Pq_RmsFundI")) {
|
if (Objects.equals(item.getHarmName(),"Pq_RmsFundI")) {
|
||||||
if ("Secondary".equals(dataLevel)) {
|
if ("Secondary".equals(dataLevel)) {
|
||||||
double data = item.getData() * ct;
|
double data = item.getData() * ct;
|
||||||
harmRealDataSet.setData1(FloatUtils.get2Float((float)data));
|
harmRealDataSet.setData1((float)data);
|
||||||
} else {
|
} else {
|
||||||
harmRealDataSet.setData1(FloatUtils.get2Float(item.getData()));
|
harmRealDataSet.setData1(item.getData());
|
||||||
}
|
}
|
||||||
} else if (Objects.equals(item.getHarmName(),"Pq_RmsFundU")) {
|
} else if (Objects.equals(item.getHarmName(),"Pq_RmsFundU")) {
|
||||||
harmRealDataSet.setData1(FloatUtils.get2Float(item.getData()));
|
harmRealDataSet.setData1(item.getData());
|
||||||
} else if (Objects.equals(item.getHarmName(),"Pq_ThdU")) {
|
} else if (Objects.equals(item.getHarmName(),"Pq_ThdU")) {
|
||||||
harmRealDataSet.setData1(FloatUtils.get2Float(item.getData()));
|
harmRealDataSet.setData1(item.getData());
|
||||||
} else {
|
} else {
|
||||||
String numberStr = item.getHarmName().substring(item.getHarmName().lastIndexOf('_') + 1);
|
String numberStr = item.getHarmName().substring(item.getHarmName().lastIndexOf('_') + 1);
|
||||||
String fieldName = "data" + numberStr;
|
String fieldName = "data" + numberStr;
|
||||||
@@ -363,12 +455,12 @@ public class RtServiceImpl implements IRtService {
|
|||||||
if (item.getHarmName().contains("Pq_HarmI_")) {
|
if (item.getHarmName().contains("Pq_HarmI_")) {
|
||||||
if ("Secondary".equals(dataLevel)) {
|
if ("Secondary".equals(dataLevel)) {
|
||||||
double data = item.getData() * ct;
|
double data = item.getData() * ct;
|
||||||
field.set(harmRealDataSet,FloatUtils.get2Float((float)data));
|
field.set(harmRealDataSet,(float)data);
|
||||||
} else {
|
} else {
|
||||||
field.set(harmRealDataSet,FloatUtils.get2Float(item.getData()));
|
field.set(harmRealDataSet,item.getData());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
field.set(harmRealDataSet,FloatUtils.get2Float(item.getData()));
|
field.set(harmRealDataSet,item.getData());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@@ -378,26 +470,4 @@ public class RtServiceImpl implements IRtService {
|
|||||||
return harmRealDataSet;
|
return harmRealDataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> convertObjectToSetSafe(Object obj) {
|
|
||||||
if (obj == null) {
|
|
||||||
return new HashSet<>();
|
|
||||||
}
|
|
||||||
if (obj instanceof Set) {
|
|
||||||
// 类型安全的转换
|
|
||||||
Set<?> rawSet = (Set<?>) obj;
|
|
||||||
return rawSet.stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.map(Object::toString)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
} else if (obj instanceof Collection) {
|
|
||||||
return ((Collection<?>) obj).stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.map(Object::toString)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
} else {
|
|
||||||
log.warn("Redis中的对象类型不是Set或Collection: {}", obj.getClass().getName());
|
|
||||||
return new HashSet<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.tocrhz</groupId>
|
||||||
|
<artifactId>mqtt-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.njcn</groupId>
|
<groupId>com.njcn</groupId>
|
||||||
<artifactId>common-web</artifactId>
|
<artifactId>common-web</artifactId>
|
||||||
|
|||||||
@@ -1,18 +1,24 @@
|
|||||||
package com.njcn.stat.service.impl;
|
package com.njcn.stat.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||||
|
import com.njcn.access.api.CsDeviceFeignClient;
|
||||||
import com.njcn.access.api.CsLineLatestDataFeignClient;
|
import com.njcn.access.api.CsLineLatestDataFeignClient;
|
||||||
|
import com.njcn.access.enums.AccessEnum;
|
||||||
import com.njcn.access.pojo.po.CsLineLatestData;
|
import com.njcn.access.pojo.po.CsLineLatestData;
|
||||||
import com.njcn.access.utils.ChannelObjectUtil;
|
import com.njcn.access.utils.ChannelObjectUtil;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.common.utils.PubUtils;
|
import com.njcn.common.utils.PubUtils;
|
||||||
|
import com.njcn.csdevice.api.CsCommunicateFeignClient;
|
||||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||||
import com.njcn.csdevice.api.DataArrayFeignClient;
|
import com.njcn.csdevice.api.DataArrayFeignClient;
|
||||||
|
import com.njcn.csdevice.api.DeviceMessageFeignClient;
|
||||||
|
import com.njcn.csdevice.param.LineInfoParam;
|
||||||
|
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
|
||||||
import com.njcn.csdevice.pojo.param.DataArrayParam;
|
import com.njcn.csdevice.pojo.param.DataArrayParam;
|
||||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
|
||||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||||
import com.njcn.influx.utils.InfluxDbUtils;
|
import com.njcn.influx.utils.InfluxDbUtils;
|
||||||
import com.njcn.mq.message.AppAutoDataMessage;
|
import com.njcn.mq.message.AppAutoDataMessage;
|
||||||
@@ -20,9 +26,7 @@ import com.njcn.redis.pojo.enums.AppRedisKey;
|
|||||||
import com.njcn.redis.utils.RedisUtil;
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
import com.njcn.stat.enums.StatResponseEnum;
|
import com.njcn.stat.enums.StatResponseEnum;
|
||||||
import com.njcn.stat.service.IStatService;
|
import com.njcn.stat.service.IStatService;
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
|
||||||
import com.njcn.system.enums.DicDataEnum;
|
import com.njcn.system.enums.DicDataEnum;
|
||||||
import com.njcn.system.pojo.po.DictData;
|
|
||||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -35,6 +39,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -51,17 +56,14 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class StatServiceImpl implements IStatService {
|
public class StatServiceImpl implements IStatService {
|
||||||
|
|
||||||
private final DataArrayFeignClient dataArrayFeignClient;
|
private final DataArrayFeignClient dataArrayFeignClient;
|
||||||
private final DicDataFeignClient dicDataFeignClient;
|
|
||||||
private final InfluxDbUtils influxDbUtils;
|
private final InfluxDbUtils influxDbUtils;
|
||||||
private final CsLineFeignClient csLineFeignClient;
|
|
||||||
private final RedisUtil redisUtil;
|
private final RedisUtil redisUtil;
|
||||||
private final ChannelObjectUtil channelObjectUtil;
|
private final ChannelObjectUtil channelObjectUtil;
|
||||||
private final CsLineLatestDataFeignClient csLineLatestDataFeignClient;
|
private final CsLineLatestDataFeignClient csLineLatestDataFeignClient;
|
||||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
private final CsDeviceFeignClient csDeviceFeignClient;
|
||||||
put("AB", "A");
|
private final DeviceMessageFeignClient deviceMessageFeignClient;
|
||||||
put("BC", "B");
|
private final CsCommunicateFeignClient csCommunicateFeignClient;
|
||||||
put("CA", "C");
|
private final CsLineFeignClient csLineFeignClient;
|
||||||
}};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@@ -83,7 +85,9 @@ public class StatServiceImpl implements IStatService {
|
|||||||
String lineId = null;
|
String lineId = null;
|
||||||
Object object1 = redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION+appAutoDataMessage.getId());
|
Object object1 = redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION+appAutoDataMessage.getId());
|
||||||
if (Objects.isNull(object1)){
|
if (Objects.isNull(object1)){
|
||||||
lineInfo(appAutoDataMessage.getId());
|
LineInfoParam param = new LineInfoParam();
|
||||||
|
param.setNDid(appAutoDataMessage.getId());
|
||||||
|
deviceMessageFeignClient.getLineInfo(param);
|
||||||
}
|
}
|
||||||
//获取当前设备信息判断装置型号,来筛选监测点
|
//获取当前设备信息判断装置型号,来筛选监测点
|
||||||
List<CsEquipmentDeliveryPO> poList = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.DEVICE_LIST),CsEquipmentDeliveryPO.class);
|
List<CsEquipmentDeliveryPO> poList = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.DEVICE_LIST),CsEquipmentDeliveryPO.class);
|
||||||
@@ -106,11 +110,11 @@ public class StatServiceImpl implements IStatService {
|
|||||||
//云前置设备
|
//云前置设备
|
||||||
else if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),code)) {
|
else if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),code)) {
|
||||||
lineId = appAutoDataMessage.getId() + appAutoDataMessage.getMsg().getClDid();
|
lineId = appAutoDataMessage.getId() + appAutoDataMessage.getMsg().getClDid();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取当前设备信息
|
//获取当前设备信息
|
||||||
if (CollectionUtil.isNotEmpty(list)) {
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
|
Map<String,String> map = new Gson().fromJson(String.valueOf(redisUtil.getObjectByKey(AppRedisKey.ELE_EPD_PQD)), Map.class);
|
||||||
List<String> recordList = new ArrayList<>();
|
List<String> recordList = new ArrayList<>();
|
||||||
for (AppAutoDataMessage.DataArray item : list) {
|
for (AppAutoDataMessage.DataArray item : list) {
|
||||||
switch (item.getDataAttr()) {
|
switch (item.getDataAttr()) {
|
||||||
@@ -133,8 +137,10 @@ public class StatServiceImpl implements IStatService {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int clDid = Objects.equals(DicDataEnum.DEV_CLD.getCode(),code)?1:appAutoDataMessage.getMsg().getClDid();
|
boolean flag = Objects.equals(DicDataEnum.DEV_CLD.getCode(), code) && Objects.equals(po.getDevAccessMethod(), "CLD");
|
||||||
String key = AppRedisKey.DEV_MODEL.concat(dataArrayParam.getId() + dataArrayParam.getDid() + clDid + dataArrayParam.getStatMethod() + dataArrayParam.getIdx());
|
int clDid = flag?1:appAutoDataMessage.getMsg().getClDid();
|
||||||
|
// String key = AppRedisKey.DEV_MODEL.concat(dataArrayParam.getId() + dataArrayParam.getDid() + clDid + dataArrayParam.getStatMethod() + dataArrayParam.getIdx());
|
||||||
|
String key = AppRedisKey.DEV_MODEL.concat(dataArrayParam.getId() + dataArrayParam.getDid() + clDid + dataArrayParam.getIdx());
|
||||||
Object object = redisUtil.getObjectByKey(key);
|
Object object = redisUtil.getObjectByKey(key);
|
||||||
List<CsDataArray> dataArrayList;
|
List<CsDataArray> dataArrayList;
|
||||||
if (Objects.isNull(object)){
|
if (Objects.isNull(object)){
|
||||||
@@ -142,50 +148,37 @@ public class StatServiceImpl implements IStatService {
|
|||||||
} else {
|
} else {
|
||||||
dataArrayList = objectToList(object);
|
dataArrayList = objectToList(object);
|
||||||
}
|
}
|
||||||
List<String> result = assembleData(lineId,dataArrayList,item,appAutoDataMessage.getMsg().getClDid(),dataArrayParam.getStatMethod(),po.getProcess(),code);
|
List<String> result = assembleData(lineId,dataArrayList,item,appAutoDataMessage.getMsg().getClDid(),dataArrayParam.getStatMethod(),po.getProcess(),code,po.getDevAccessMethod(),map);
|
||||||
recordList.addAll(result);
|
recordList.addAll(result);
|
||||||
//获取时间
|
//获取时间
|
||||||
long devTime = Objects.equals(DicDataEnum.DEV_CLD.getCode(),code)?item.getDataTimeSec():item.getDataTimeSec()-8*3600;
|
boolean timeFlag = Objects.equals(DicDataEnum.DEV_CLD.getCode(), code) && Objects.equals(po.getDevAccessMethod(), "CLD");
|
||||||
|
long devTime = timeFlag?item.getDataTimeSec():item.getDataTimeSec()-8*3600;
|
||||||
time = Instant.ofEpochSecond(devTime)
|
time = Instant.ofEpochSecond(devTime)
|
||||||
.atZone(ZoneId.systemDefault())
|
.atZone(ZoneId.systemDefault())
|
||||||
.toLocalDateTime();
|
.toLocalDateTime();
|
||||||
}
|
}
|
||||||
if (CollectionUtil.isNotEmpty(recordList)){
|
if (CollectionUtil.isNotEmpty(recordList)){
|
||||||
//influx数据批量入库
|
//influx数据批量入库
|
||||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, recordList);
|
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.SECONDS, recordList);
|
||||||
//记录监测点最新数据时间
|
//记录监测点最新数据时间
|
||||||
CsLineLatestData csLineLatestData = new CsLineLatestData();
|
CsLineLatestData csLineLatestData = new CsLineLatestData();
|
||||||
csLineLatestData.setLineId(lineId);
|
csLineLatestData.setLineId(lineId);
|
||||||
csLineLatestData.setTimeId(Objects.isNull(time) ? LocalDateTime.now() : time);
|
csLineLatestData.setTimeId(Objects.isNull(time) ? LocalDateTime.now() : time);
|
||||||
csLineLatestDataFeignClient.addData(csLineLatestData);
|
csLineLatestDataFeignClient.addData(csLineLatestData);
|
||||||
}
|
}
|
||||||
}
|
//判断设备运行状态
|
||||||
}
|
if (!Objects.isNull(po.getRunStatus()) && po.getRunStatus() == 1) {
|
||||||
|
csDeviceFeignClient.updateRunStatus(appAutoDataMessage.getId(), AccessEnum.ONLINE.getCode());
|
||||||
/**
|
//记录设备上线
|
||||||
* 缓存监测点相关信息
|
PqsCommunicateDto dto = new PqsCommunicateDto();
|
||||||
*/
|
dto.setTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||||
public void lineInfo(String id) {
|
dto.setDevId(appAutoDataMessage.getId());
|
||||||
Map<Integer,String> map = new HashMap<>();
|
dto.setType(1);
|
||||||
List<CsLinePO> lineList = csLineFeignClient.findByNdid(id).getData();
|
dto.setDescription("通讯正常");
|
||||||
if (CollectionUtil.isEmpty(lineList)){
|
csCommunicateFeignClient.insertion(dto);
|
||||||
throw new BusinessException(StatResponseEnum.LINE_NULL);
|
|
||||||
}
|
|
||||||
for (CsLinePO item : lineList) {
|
|
||||||
if (Objects.isNull(item.getPosition())){
|
|
||||||
map.put(item.getClDid(),item.getLineId());
|
|
||||||
} else {
|
|
||||||
DictData dictData = dicDataFeignClient.getDicDataById(item.getPosition()).getData();
|
|
||||||
if (Objects.equals(dictData.getCode(), DicDataEnum.OUTPUT_SIDE.getCode())){
|
|
||||||
map.put(0,item.getLineId());
|
|
||||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.GRID_SIDE.getCode())){
|
|
||||||
map.put(1,item.getLineId());
|
|
||||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){
|
|
||||||
map.put(2,item.getLineId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
redisUtil.saveByKeyWithExpire(AppRedisKey.LINE_POSITION+id,map,30L);
|
System.gc();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -204,35 +197,55 @@ public class StatServiceImpl implements IStatService {
|
|||||||
/**
|
/**
|
||||||
* influxDB数据组装
|
* influxDB数据组装
|
||||||
*/
|
*/
|
||||||
public List<String> assembleData(String lineId,List<CsDataArray> dataArrayList,AppAutoDataMessage.DataArray item,Integer clDid,String statMethod,Integer process,String devType) {
|
public List<String> assembleData(String lineId,List<CsDataArray> dataArrayList,AppAutoDataMessage.DataArray item,Integer clDid,String statMethod,Integer process,String devType,String accessMethod, Map<String,String> map) {
|
||||||
List<String> records = new ArrayList<String>();
|
List<String> records = new ArrayList<String>();
|
||||||
//解码
|
|
||||||
List<Float> floats = PubUtils.byteArrayToFloatList(Base64.getDecoder().decode(item.getData()));
|
List<Float> floats = PubUtils.byteArrayToFloatList(Base64.getDecoder().decode(item.getData()));
|
||||||
if (CollectionUtil.isEmpty(floats)){
|
if (CollectionUtil.isEmpty(floats)){
|
||||||
throw new BusinessException(StatResponseEnum.AUTO_DATA_NULL);
|
throw new BusinessException(StatResponseEnum.AUTO_DATA_NULL);
|
||||||
}
|
}
|
||||||
//校验模板和解码数据数量能否对应上
|
|
||||||
if (!Objects.equals(dataArrayList.size(),floats.size())){
|
if (!Objects.equals(dataArrayList.size(),floats.size())){
|
||||||
throw new BusinessException(StatResponseEnum.ARRAY_DATA_NOT_MATCH);
|
throw new BusinessException(StatResponseEnum.ARRAY_DATA_NOT_MATCH);
|
||||||
}
|
}
|
||||||
Map<String,String> map = new Gson().fromJson(String.valueOf(redisUtil.getObjectByKey(AppRedisKey.ELE_EPD_PQD)), Map.class);
|
|
||||||
|
boolean flag = Objects.equals(DicDataEnum.DEV_CLD.getCode(), devType) && Objects.equals(accessMethod, "CLD");
|
||||||
|
//fixme 捂脸设备上送的是北京时间,时序数据库录入时 需要utc时间,减去8小时
|
||||||
|
long originalTimeSec = flag ? item.getDataTimeSec() : item.getDataTimeSec() - 8 * 3600;
|
||||||
|
|
||||||
for (int i = 0; i < dataArrayList.size(); i++) {
|
for (int i = 0; i < dataArrayList.size(); i++) {
|
||||||
String tableName = map.get(dataArrayList.get(i).getName());
|
String tableName = map.get(dataArrayList.get(i).getName());
|
||||||
|
long adjustedTimeSec;
|
||||||
|
|
||||||
|
//短时闪变 || 电压波动 10分钟
|
||||||
|
if (Objects.equals(tableName,"data_flicker") || Objects.equals(tableName,"data_fluc")) {
|
||||||
|
adjustedTimeSec = (originalTimeSec / 600) * 600;
|
||||||
|
}
|
||||||
|
//长时闪变 2小时
|
||||||
|
else if (Objects.equals(tableName,"data_plt")) {
|
||||||
|
adjustedTimeSec = (originalTimeSec / 7200) * 7200;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
adjustedTimeSec = originalTimeSec;
|
||||||
|
}
|
||||||
Map<String, String> tags = new HashMap<>();
|
Map<String, String> tags = new HashMap<>();
|
||||||
tags.put(InfluxDBTableConstant.LINE_ID,lineId);
|
tags.put(InfluxDBTableConstant.LINE_ID,lineId);
|
||||||
tags.put(InfluxDBTableConstant.PHASIC_TYPE,dataArrayList.get(i).getPhase());
|
tags.put(InfluxDBTableConstant.PHASIC_TYPE,dataArrayList.get(i).getPhase());
|
||||||
//todo 不清楚之前为啥要修改相别,这边按字典配置相别无法查询到数据,先改回来
|
tags.put(InfluxDBTableConstant.VALUE_TYPE,statMethod.toUpperCase());
|
||||||
//tags.put(InfluxDBTableConstant.PHASIC_TYPE,Objects.isNull(PHASE_MAPPING.get(dataArrayList.get(i).getPhase()))?dataArrayList.get(i).getPhase():PHASE_MAPPING.get(dataArrayList.get(i).getPhase()));
|
if (Objects.isNull(item.getDataTag())) {
|
||||||
tags.put(InfluxDBTableConstant.VALUE_TYPE,statMethod);
|
tags.put(InfluxDBTableConstant.QUALITY_FLAG,"0");
|
||||||
tags.put(InfluxDBTableConstant.CL_DID,clDid.toString());
|
} else {
|
||||||
tags.put(InfluxDBTableConstant.PROCESS,process.toString());
|
tags.put(InfluxDBTableConstant.QUALITY_FLAG,String.valueOf(item.getDataTag()));
|
||||||
tags.put(InfluxDBTableConstant.QUALITY_FLAG,"0");
|
}
|
||||||
Map<String,Object> fields = new HashMap<>();
|
Map<String,Object> fields = new HashMap<>();
|
||||||
//这边特殊处理,如果数据为3.14159,则将数据置为null
|
//这边特殊处理,如果数据为3.14159,则将数据置为null
|
||||||
fields.put(dataArrayList.get(i).getName(),Objects.equals(floats.get(i),3.14159f) ? null:floats.get(i));
|
if (Objects.isNull(dataArrayList.get(i).getInfluxDbName())) {
|
||||||
fields.put(InfluxDBTableConstant.IS_ABNORMAL,item.getDataTag());
|
fields.put(dataArrayList.get(i).getName(),Objects.equals(floats.get(i),3.14159f) ? null:floats.get(i));
|
||||||
//fixme 这边前置传递的应该是UTC时间,但是前置说是传递的北京时间,讨论了一下没太理解。这边暂时先这样处理,influx入库处理成北京时间,减去8小时。
|
} else {
|
||||||
Point point = influxDbUtils.pointBuilder(tableName, Objects.equals(DicDataEnum.DEV_CLD.getCode(),devType)?item.getDataTimeSec():item.getDataTimeSec()-8*3600, TimeUnit.SECONDS, tags, fields);
|
fields.put(dataArrayList.get(i).getInfluxDbName(),Objects.equals(floats.get(i),3.14159f) ? null:floats.get(i));
|
||||||
|
}
|
||||||
|
fields.put(InfluxDBTableConstant.CL_DID,clDid.toString());
|
||||||
|
fields.put(InfluxDBTableConstant.PROCESS,process.toString());
|
||||||
|
|
||||||
|
Point point = influxDbUtils.pointBuilder(tableName, adjustedTimeSec, TimeUnit.SECONDS, tags, fields);
|
||||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||||
batchPoints.point(point);
|
batchPoints.point(point);
|
||||||
records.add(batchPoints.lineProtocol());
|
records.add(batchPoints.lineProtocol());
|
||||||
@@ -251,4 +264,5 @@ public class StatServiceImpl implements IStatService {
|
|||||||
}
|
}
|
||||||
return urlList;
|
return urlList;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ public interface ZlConstant {
|
|||||||
*/
|
*/
|
||||||
String EVT_PARAM_TM = "Evt_Param_Tm";
|
String EVT_PARAM_TM = "Evt_Param_Tm";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 幅值
|
||||||
|
*/
|
||||||
|
String EVT_PARAM_VVADEPTH = "Evt_Param_VVaDepth";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.njcn.middle.rocket.domain.BaseMessage;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-31
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CommonBaseMessage extends BaseMessage {
|
||||||
|
/**
|
||||||
|
* 消息请求的唯一标识
|
||||||
|
*/
|
||||||
|
@JsonProperty("guid")
|
||||||
|
@JsonAlias({"guid"})
|
||||||
|
private String guid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备Mac
|
||||||
|
*/
|
||||||
|
@JsonProperty("devMac")
|
||||||
|
@JsonAlias({"Dev_mac"})
|
||||||
|
private String devMac;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置Id
|
||||||
|
*/
|
||||||
|
@JsonProperty("frontId")
|
||||||
|
@JsonAlias({"FrontId"})
|
||||||
|
private String frontId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置进程号
|
||||||
|
*/
|
||||||
|
@JsonProperty("node")
|
||||||
|
@JsonAlias({"Node"})
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
@JsonProperty("detail")
|
||||||
|
@JsonAlias({"Detail"})
|
||||||
|
private Object detail;
|
||||||
|
}
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-16
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DevVersionResponeDTO extends CommonBaseMessage {
|
||||||
|
|
||||||
|
@JsonProperty("Detail")
|
||||||
|
private DevVersionResponeDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JsonProperty("Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@JsonProperty("Msg")
|
||||||
|
private DevVersionResponeDTO.Msg msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Msg {
|
||||||
|
|
||||||
|
@JsonProperty("Code")
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("VersionInfo")
|
||||||
|
private VersionInfo versionInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class VersionInfo {
|
||||||
|
/**
|
||||||
|
* 装置基础型号(只用于程序升级鉴别)
|
||||||
|
*/
|
||||||
|
@JsonProperty("BaseModel")
|
||||||
|
private String baseModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云服务协议版本
|
||||||
|
*/
|
||||||
|
@JsonProperty("CloudProtocolVer")
|
||||||
|
private String cloudProtocolVer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用程序版本号
|
||||||
|
*/
|
||||||
|
@JsonProperty("AppVersion")
|
||||||
|
private String appVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用程序版本日期
|
||||||
|
*/
|
||||||
|
@JsonProperty("AppDate")
|
||||||
|
private LocalDate appDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用程序校验码
|
||||||
|
*/
|
||||||
|
@JsonProperty("AppChecksum")
|
||||||
|
private String appChecksum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电压接线方式(0-星1-三角2-V)
|
||||||
|
*/
|
||||||
|
@JsonProperty("VoltageWiring")
|
||||||
|
private String voltageWiring;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电流B相是否合成(0-否1-是)
|
||||||
|
*/
|
||||||
|
@JsonProperty("CurrentBSynthetic")
|
||||||
|
private String currentBSynthetic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据统计时间间隔(单位分钟)
|
||||||
|
*/
|
||||||
|
@JsonProperty("DataStatInterval")
|
||||||
|
private Integer dataStatInterval;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 额定电压(二次值,单位V)
|
||||||
|
*/
|
||||||
|
@JsonProperty("RatedVoltage")
|
||||||
|
private Double ratedVoltage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PT变比
|
||||||
|
*/
|
||||||
|
@JsonProperty("PTRatio")
|
||||||
|
private Integer ptRatio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CT变比
|
||||||
|
*/
|
||||||
|
@JsonProperty("CTRatio")
|
||||||
|
private Integer ctRatio;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sntp对时IP
|
||||||
|
*/
|
||||||
|
@JsonProperty("SntpIP")
|
||||||
|
private String sntpIP;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sntp对时端口
|
||||||
|
*/
|
||||||
|
@JsonProperty("SntpPort")
|
||||||
|
private Integer sntpPort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sntp对时间隔(单位分钟)
|
||||||
|
*/
|
||||||
|
@JsonProperty("SntpInterval")
|
||||||
|
private Integer sntpInterval;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Web端口
|
||||||
|
*/
|
||||||
|
@JsonProperty("WebPort")
|
||||||
|
private Integer webPort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FTP端口
|
||||||
|
*/
|
||||||
|
@JsonProperty("FtpPort")
|
||||||
|
private Integer ftpPort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pqdif文件时间间隔(单位小时)
|
||||||
|
*/
|
||||||
|
@JsonProperty("PqdifInterval")
|
||||||
|
private Integer pqdifInterval;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 录波文件包含文件类型数
|
||||||
|
*/
|
||||||
|
@JsonProperty("WaveFileTypeCount")
|
||||||
|
private Integer waveFileTypeCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 特殊程序版本信息
|
||||||
|
*/
|
||||||
|
@JsonProperty("SpecialVersion")
|
||||||
|
private String specialVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装置型号(具体型号全称)
|
||||||
|
*/
|
||||||
|
@JsonProperty("DeviceModel")
|
||||||
|
private String deviceModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 谐波电度版本标志(0-否1-是)
|
||||||
|
*/
|
||||||
|
@JsonProperty("HarmonicEnergyFlag")
|
||||||
|
private Integer harmonicEnergyFlag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物理设备名称(仅用于上位机录波文件拼接)
|
||||||
|
*/
|
||||||
|
@JsonProperty("PhysicalName")
|
||||||
|
private String physicalName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 录波LD名称(仅用于上位机录波文件拼接)
|
||||||
|
*/
|
||||||
|
@JsonProperty("WaveLDName")
|
||||||
|
private String waveLDName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 高频谐波功能标志(0-否1-是)
|
||||||
|
*/
|
||||||
|
@JsonProperty("HighFreqHarmonicFlag")
|
||||||
|
private Integer highFreqHarmonicFlag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 投入的通讯协议(2字节十六进制数)
|
||||||
|
*/
|
||||||
|
@JsonProperty("CommProtocols")
|
||||||
|
private Integer commProtocols;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 投入的对时方式选择(2字节十六进制数)
|
||||||
|
*/
|
||||||
|
@JsonProperty("TimeSyncMethods")
|
||||||
|
private Integer timeSyncMethods;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装置功能配置(2字节十六进制数)
|
||||||
|
*/
|
||||||
|
@JsonProperty("DeviceFunctions")
|
||||||
|
private Integer deviceFunctions;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-04-01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DeviceVersionRequestDTO {
|
||||||
|
/**
|
||||||
|
* 消息请求的唯一标识
|
||||||
|
*/
|
||||||
|
@JSONField(name = "guid")
|
||||||
|
private String guid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备ID
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Dev_id")
|
||||||
|
private String devId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置Id
|
||||||
|
*/
|
||||||
|
@JSONField(name = "FrontId")
|
||||||
|
private String frontId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置进程号
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Node")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
@JSONField(name = "Detail")
|
||||||
|
private DeviceVersionRequestDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Msg")
|
||||||
|
private Map<String, Object> msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-16
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FileDownloadRequestDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息请求的唯一标识
|
||||||
|
*/
|
||||||
|
@JSONField(name = "guid")
|
||||||
|
private String guid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备ID
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Dev_id")
|
||||||
|
private String devId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置Id
|
||||||
|
*/
|
||||||
|
@JSONField(name = "FrontId")
|
||||||
|
private String frontId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置进程号
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Node")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
@JSONField(name = "Detail")
|
||||||
|
private FileDownloadRequestDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@JSONField(name = "Msg")
|
||||||
|
private FileDownloadRequestDTO.Msg msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Msg {
|
||||||
|
/**
|
||||||
|
* 设备的文件名,例如:/etc/vol1_stat.txt
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Name")
|
||||||
|
private String name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-16
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FileDownloadResponeDTO extends CommonBaseMessage {
|
||||||
|
|
||||||
|
@JsonProperty("Detail")
|
||||||
|
private FileDownloadResponeDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JsonProperty("Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@JsonProperty("Msg")
|
||||||
|
private FileDownloadResponeDTO.Msg msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Msg {
|
||||||
|
/**
|
||||||
|
* 文件名称,例如 /etc/vol1_stat.txt
|
||||||
|
*/
|
||||||
|
@JsonProperty("Name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 远端文件名,例如 /download/vol1_stat.txt
|
||||||
|
*/
|
||||||
|
@JsonProperty("RemoteName")
|
||||||
|
private String remoteName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FileInfoRequestDTO {
|
||||||
|
/**
|
||||||
|
* 消息请求的唯一标识
|
||||||
|
*/
|
||||||
|
@JSONField(name = "guid")
|
||||||
|
private String guid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备ID
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Dev_id")
|
||||||
|
private String devId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置Id
|
||||||
|
*/
|
||||||
|
@JSONField(name = "FrontId")
|
||||||
|
private String frontId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置进程号
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Node")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
@JSONField(name = "Detail")
|
||||||
|
private FileInfoRequestDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@JSONField(name = "Msg")
|
||||||
|
private FileInfoRequestDTO.Msg msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Msg {
|
||||||
|
|
||||||
|
@JSONField(name = "Name")
|
||||||
|
private String name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FileInfoResponseDTO extends CommonBaseMessage {
|
||||||
|
|
||||||
|
@JsonProperty("detail")
|
||||||
|
@JsonAlias({"Detail"})
|
||||||
|
private FileInfoResponseDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JsonProperty("type")
|
||||||
|
@JsonAlias({"Type"})
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息主体
|
||||||
|
*/
|
||||||
|
@JsonProperty("msg")
|
||||||
|
@JsonAlias({"Msg"})
|
||||||
|
private FileInfoResponseDTO.Msg msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应码
|
||||||
|
*/
|
||||||
|
@JsonProperty("code")
|
||||||
|
@JsonAlias({"Code"})
|
||||||
|
private Integer code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Msg {
|
||||||
|
/**
|
||||||
|
* 目录信息数组
|
||||||
|
*/
|
||||||
|
@JsonProperty("dirInfo")
|
||||||
|
@JsonAlias({"DirInfo"})
|
||||||
|
private List<FileInfoResponseDTO.ResourceElement> dirInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class ResourceElement {
|
||||||
|
/**
|
||||||
|
* 文件名/文件夹名称
|
||||||
|
*/
|
||||||
|
@JsonProperty("name")
|
||||||
|
@JsonAlias({"Name"})
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型,文件/文件夹
|
||||||
|
*/
|
||||||
|
@JsonProperty("type")
|
||||||
|
@JsonAlias({"Type"})
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 目录信息数组单个元素的数据成员大小
|
||||||
|
*/
|
||||||
|
@JsonProperty("size")
|
||||||
|
@JsonAlias({"Size"})
|
||||||
|
private Integer size;
|
||||||
|
|
||||||
|
private String prjDataPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-04-01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FileOrDirDeleteRequestDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息请求的唯一标识
|
||||||
|
*/
|
||||||
|
@JSONField(name = "guid")
|
||||||
|
private String guid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备ID
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Dev_id")
|
||||||
|
private String devId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置Id
|
||||||
|
*/
|
||||||
|
@JSONField(name = "FrontId")
|
||||||
|
private String frontId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置进程号
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Node")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
@JSONField(name = "Detail")
|
||||||
|
private FileOrDirDeleteRequestDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@JSONField(name = "Msg")
|
||||||
|
private FileOrDirDeleteRequestDTO.Msg msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Msg {
|
||||||
|
|
||||||
|
@JSONField(name = "Name")
|
||||||
|
private String name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FileOrDirDeleteResponeDTO extends CommonBaseMessage {
|
||||||
|
|
||||||
|
@JsonProperty("Detail")
|
||||||
|
private FileOrDirDeleteResponeDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JsonProperty("Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应主体
|
||||||
|
*/
|
||||||
|
@JsonProperty("Msg")
|
||||||
|
private Map<String, Object> msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应码
|
||||||
|
*/
|
||||||
|
@JsonProperty("Code")
|
||||||
|
private Integer code;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FileUploadRequestDTO {
|
||||||
|
/**
|
||||||
|
* 消息请求的唯一标识
|
||||||
|
*/
|
||||||
|
@JSONField(name = "guid")
|
||||||
|
private String guid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备ID
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Dev_id")
|
||||||
|
private String devId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置Id
|
||||||
|
*/
|
||||||
|
@JSONField(name = "FrontId")
|
||||||
|
private String frontId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置进程号
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Node")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
@JSONField(name = "Detail")
|
||||||
|
private FileUploadRequestDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@JSONField(name = "Msg")
|
||||||
|
private FileUploadRequestDTO.Msg msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Msg {
|
||||||
|
|
||||||
|
@JSONField(name = "Name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@JSONField(name = "RemoteName")
|
||||||
|
private String remoteName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FileUploadResponeDTO extends CommonBaseMessage {
|
||||||
|
|
||||||
|
@JsonProperty("Detail")
|
||||||
|
private FileUploadResponeDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JsonProperty("Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应主体
|
||||||
|
*/
|
||||||
|
@JsonProperty("Msg")
|
||||||
|
private Map<String, Object> msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应码
|
||||||
|
*/
|
||||||
|
@JsonProperty("Code")
|
||||||
|
private Integer code;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MkdirRequestDTO {
|
||||||
|
/**
|
||||||
|
* 消息请求的唯一标识
|
||||||
|
*/
|
||||||
|
@JSONField(name = "guid")
|
||||||
|
private String guid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备ID
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Dev_id")
|
||||||
|
private String devId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置Id
|
||||||
|
*/
|
||||||
|
@JSONField(name = "FrontId")
|
||||||
|
private String frontId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置进程号
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Node")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
@JSONField(name = "Detail")
|
||||||
|
private MkdirRequestDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
@JSONField(name = "Msg")
|
||||||
|
private MkdirRequestDTO.Msg msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Msg {
|
||||||
|
|
||||||
|
@JSONField(name = "Name")
|
||||||
|
private String name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MkdirResponeDTO extends CommonBaseMessage {
|
||||||
|
|
||||||
|
@JsonProperty("Detail")
|
||||||
|
private MkdirResponeDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JsonProperty("Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应主体
|
||||||
|
*/
|
||||||
|
@JsonProperty("Msg")
|
||||||
|
private Map<String, Object> msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应码
|
||||||
|
*/
|
||||||
|
@JsonProperty("Code")
|
||||||
|
private Integer code;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-04-01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RebootRequestDTO {
|
||||||
|
/**
|
||||||
|
* 消息请求的唯一标识
|
||||||
|
*/
|
||||||
|
@JSONField(name = "guid")
|
||||||
|
private String guid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备ID
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Dev_id")
|
||||||
|
private String devId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置Id
|
||||||
|
*/
|
||||||
|
@JSONField(name = "FrontId")
|
||||||
|
private String frontId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置进程号
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Node")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
@JSONField(name = "Detail")
|
||||||
|
private RebootRequestDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Msg")
|
||||||
|
private Map<String, Object> msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RebootResponeDTO extends CommonBaseMessage {
|
||||||
|
|
||||||
|
@JsonProperty("Detail")
|
||||||
|
private RebootResponeDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JsonProperty("Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应主体
|
||||||
|
*/
|
||||||
|
@JsonProperty("Msg")
|
||||||
|
private Map<String, Object> msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应码
|
||||||
|
*/
|
||||||
|
@JsonProperty("Code")
|
||||||
|
private Integer code;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-04-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TimeSyncRequestDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息请求的唯一标识
|
||||||
|
*/
|
||||||
|
@JSONField(name = "guid")
|
||||||
|
private String guid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备ID
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Dev_id")
|
||||||
|
private String devId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置Id
|
||||||
|
*/
|
||||||
|
@JSONField(name = "FrontId")
|
||||||
|
private String frontId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置进程号
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Node")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
@JSONField(name = "Detail")
|
||||||
|
private TimeSyncRequestDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Msg")
|
||||||
|
private Map<String, Object> msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-04-01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UpgradeRequestDTO {
|
||||||
|
/**
|
||||||
|
* 消息请求的唯一标识
|
||||||
|
*/
|
||||||
|
@JSONField(name = "guid")
|
||||||
|
private String guid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备ID
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Dev_id")
|
||||||
|
private String devId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置Id
|
||||||
|
*/
|
||||||
|
@JSONField(name = "FrontId")
|
||||||
|
private String frontId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置进程号
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Node")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
@JSONField(name = "Detail")
|
||||||
|
private UpgradeRequestDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Msg")
|
||||||
|
private UpgradeRequestDTO.Msg msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Msg {
|
||||||
|
@JSONField(name = "Name")
|
||||||
|
private String name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UpgradeResponeDTO extends CommonBaseMessage {
|
||||||
|
|
||||||
|
@JsonProperty("Detail")
|
||||||
|
private UpgradeResponeDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JsonProperty("Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应主体
|
||||||
|
*/
|
||||||
|
@JsonProperty("Msg")
|
||||||
|
private Map<String, Object> msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应码
|
||||||
|
*/
|
||||||
|
@JsonProperty("Code")
|
||||||
|
private Integer code;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class WorkingLogRequestDTO {
|
||||||
|
/**
|
||||||
|
* 消息请求的唯一标识
|
||||||
|
*/
|
||||||
|
@JSONField(name = "guid")
|
||||||
|
private String guid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备ID
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Dev_id")
|
||||||
|
private String devId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置Id
|
||||||
|
*/
|
||||||
|
@JSONField(name = "FrontId")
|
||||||
|
private String frontId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置进程号
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Node")
|
||||||
|
private Integer node;
|
||||||
|
|
||||||
|
@JSONField(name = "Detail")
|
||||||
|
private WorkingLogRequestDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情
|
||||||
|
*/
|
||||||
|
@JSONField(name = "Msg")
|
||||||
|
private Map<String, Object> msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package com.njcn.zlevent.pojo.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class WorkingLogResponeDTO extends CommonBaseMessage {
|
||||||
|
|
||||||
|
@JsonProperty("Detail")
|
||||||
|
private WorkingLogResponeDTO.Detail detail;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Detail {
|
||||||
|
/**
|
||||||
|
* 数据类型,代表特定功能
|
||||||
|
*/
|
||||||
|
@JsonProperty("Type")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应主体
|
||||||
|
*/
|
||||||
|
@JsonProperty("Msg")
|
||||||
|
private WorkingLogResponeDTO.Msg msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应码
|
||||||
|
*/
|
||||||
|
@JsonProperty("Code")
|
||||||
|
private Integer code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Msg {
|
||||||
|
/**
|
||||||
|
* 时标
|
||||||
|
*/
|
||||||
|
@JsonProperty("Time")
|
||||||
|
private LocalDateTime time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CPU负荷(单位%) 39_38(双核,单核的为一个)
|
||||||
|
*/
|
||||||
|
@JsonProperty("CpuLoad")
|
||||||
|
private String cpuLoad;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装置剩余内存(单位MB)
|
||||||
|
*/
|
||||||
|
@JsonProperty("FreeMemory")
|
||||||
|
private String freeMemory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装置总内存(单位MB)
|
||||||
|
*/
|
||||||
|
@JsonProperty("TotalMemory")
|
||||||
|
private String totalMemory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装置主存储器剩余空间(单位GB)
|
||||||
|
*/
|
||||||
|
@JsonProperty("FreeStorage")
|
||||||
|
private String freeStorage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装置主存储器总空间(单位GB)
|
||||||
|
*/
|
||||||
|
@JsonProperty("TotalStorage")
|
||||||
|
private String totalStorage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 硬对时最后时标(B码或秒秒冲)
|
||||||
|
*/
|
||||||
|
@JsonProperty("HardTimeSync")
|
||||||
|
private LocalDateTime hardTimeSync;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sntp对时最后时标
|
||||||
|
*/
|
||||||
|
@JsonProperty("SntpTimeSync")
|
||||||
|
private LocalDateTime sntpTimeSync;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 云服务协议对时最后时标
|
||||||
|
*/
|
||||||
|
@JsonProperty("CloudTimeSync")
|
||||||
|
private LocalDateTime cloudTimeSync;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 无线模块信号强度
|
||||||
|
*/
|
||||||
|
@JsonProperty("SignalStrength")
|
||||||
|
private String signalStrength;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.njcn.zlevent.pojo.param;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FileParam {
|
||||||
|
private String filePath;
|
||||||
|
private String devId;
|
||||||
|
}
|
||||||
@@ -20,6 +20,10 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.tocrhz</groupId>
|
||||||
|
<artifactId>mqtt-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||||
@@ -73,6 +77,11 @@
|
|||||||
<artifactId>system-api</artifactId>
|
<artifactId>system-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.njcn</groupId>
|
||||||
|
<artifactId>cs-system-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.njcn</groupId>
|
<groupId>com.njcn</groupId>
|
||||||
<artifactId>cs-harmonic-api</artifactId>
|
<artifactId>cs-harmonic-api</artifactId>
|
||||||
@@ -94,6 +103,16 @@
|
|||||||
<artifactId>common-oss</artifactId>
|
<artifactId>common-oss</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.njcn</groupId>
|
||||||
|
<artifactId>event-common</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
|
<version>2.7.12</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.springframework.boot.SpringApplication;
|
|||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
import org.springframework.context.annotation.DependsOn;
|
import org.springframework.context.annotation.DependsOn;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,6 +19,7 @@ import org.springframework.context.annotation.DependsOn;
|
|||||||
@MapperScan("com.njcn.**.mapper")
|
@MapperScan("com.njcn.**.mapper")
|
||||||
@EnableFeignClients(basePackages = "com.njcn")
|
@EnableFeignClients(basePackages = "com.njcn")
|
||||||
@SpringBootApplication(scanBasePackages = "com.njcn")
|
@SpringBootApplication(scanBasePackages = "com.njcn")
|
||||||
|
@EnableAsync
|
||||||
public class ZlEventBootApplication {
|
public class ZlEventBootApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.njcn.zlevent.config;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@Slf4j
|
||||||
|
public class AsyncConfig implements AsyncConfigurer {
|
||||||
|
|
||||||
|
@Bean("eventNotificationExecutor")
|
||||||
|
public Executor eventNotificationExecutor() {
|
||||||
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||||
|
executor.setCorePoolSize(10);
|
||||||
|
executor.setMaxPoolSize(20);
|
||||||
|
executor.setQueueCapacity(200);
|
||||||
|
executor.setThreadNamePrefix("event-notify-");
|
||||||
|
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
|
executor.initialize();
|
||||||
|
return executor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean("smsNotificationExecutor")
|
||||||
|
public Executor smsNotificationExecutor() {
|
||||||
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||||
|
executor.setCorePoolSize(5);
|
||||||
|
executor.setMaxPoolSize(10);
|
||||||
|
executor.setQueueCapacity(100);
|
||||||
|
executor.setThreadNamePrefix("sms-notify-");
|
||||||
|
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
|
executor.initialize();
|
||||||
|
return executor;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package com.njcn.zlevent.config;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.njcn.zlevent.service.IDeviceService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.scheduling.TaskScheduler;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Configuration
|
||||||
|
public class TaskSchedulerConfig {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IDeviceService deviceService;
|
||||||
|
|
||||||
|
private final Map<String, ScheduledFuture<?>> scheduledTasks = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
private final TaskScheduler taskScheduler;
|
||||||
|
|
||||||
|
public TaskSchedulerConfig() {
|
||||||
|
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
||||||
|
scheduler.setPoolSize(3);
|
||||||
|
scheduler.setThreadNamePrefix("device-task-");
|
||||||
|
scheduler.setWaitForTasksToCompleteOnShutdown(true);
|
||||||
|
scheduler.initialize();
|
||||||
|
this.taskScheduler = scheduler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startTask(String devId, long intervalSeconds) {
|
||||||
|
if (scheduledTasks.containsKey(devId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScheduledFuture<?> future = taskScheduler.schedule(
|
||||||
|
() -> deviceService.getWorkingLog(devId),
|
||||||
|
triggerContext -> Date.from(Instant.now().plusSeconds(intervalSeconds))
|
||||||
|
);
|
||||||
|
|
||||||
|
scheduledTasks.put(devId, future);
|
||||||
|
log.info("启动设备 {} 的定时任务成功,间隔={}秒", devId, intervalSeconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopTask(String devId) {
|
||||||
|
ScheduledFuture<?> future = scheduledTasks.remove(devId);
|
||||||
|
if (ObjectUtil.isNotNull(future)) {
|
||||||
|
future.cancel(false);
|
||||||
|
log.info("停止设备 {} 的定时任务成功", devId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTaskRunning(String devId) {
|
||||||
|
ScheduledFuture<?> future = scheduledTasks.get(devId);
|
||||||
|
return ObjectUtil.isNotNull(future) && !future.isDone() && !future.isCancelled();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package com.njcn.zlevent.controller;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import com.njcn.zlevent.service.IDeviceService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-20
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/device")
|
||||||
|
@Api(tags = "操作设备")
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DeviceController extends BaseController {
|
||||||
|
|
||||||
|
private IDeviceService deviceService;
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@GetMapping("/workingLog")
|
||||||
|
@ApiOperation("开始获取装置运行日志")
|
||||||
|
public HttpResult<Boolean> startWorkingLog(@RequestParam("devId") String devId) {
|
||||||
|
String methodDescribe = getMethodDescribe("startWorkingLog");
|
||||||
|
deviceService.startWorkingLog(devId);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@GetMapping("/stopWorkingLog")
|
||||||
|
@ApiOperation("停止获取装置运行日志")
|
||||||
|
public HttpResult<Boolean> stopWorkingLog(@RequestParam("devId") String devId) {
|
||||||
|
String methodDescribe = getMethodDescribe("stopWorkingLog");
|
||||||
|
deviceService.stopWorkingLogTask(devId);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@GetMapping("/upgrade")
|
||||||
|
@ApiOperation("装置升级")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "devId", value = "设备ID", required = true),
|
||||||
|
@ApiImplicitParam(name = "edDataId", value = "程序版本Id", required = true)
|
||||||
|
})
|
||||||
|
public HttpResult<Boolean> upgrade(@RequestParam("devId") String devId, @RequestParam("edDataId") String edDataId) {
|
||||||
|
String methodDescribe = getMethodDescribe("upgrade");
|
||||||
|
boolean res = deviceService.upgrade(devId, edDataId);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(res ? CommonResponseEnum.SUCCESS : CommonResponseEnum.FAIL, res, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@GetMapping("/reboot")
|
||||||
|
@ApiOperation("装置重启")
|
||||||
|
public HttpResult<Boolean> reboot(@RequestParam("devId") String devId) {
|
||||||
|
String methodDescribe = getMethodDescribe("reboot");
|
||||||
|
boolean res = deviceService.reboot(devId);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(res ? CommonResponseEnum.SUCCESS : CommonResponseEnum.FAIL, res, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@GetMapping("/timeSync")
|
||||||
|
@ApiOperation("装置对时")
|
||||||
|
public HttpResult<Boolean> timeSync(@RequestParam("devId") String devId) {
|
||||||
|
String methodDescribe = getMethodDescribe("listDir");
|
||||||
|
boolean res = deviceService.timeSync(devId);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(res ? CommonResponseEnum.SUCCESS : CommonResponseEnum.FAIL, res, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,13 +7,20 @@ import com.njcn.common.pojo.response.HttpResult;
|
|||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
import com.njcn.mq.message.AppFileMessage;
|
import com.njcn.mq.message.AppFileMessage;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import com.njcn.zlevent.pojo.dto.FileInfoResponseDTO;
|
||||||
|
import com.njcn.zlevent.pojo.param.FileParam;
|
||||||
import com.njcn.zlevent.service.IFileService;
|
import com.njcn.zlevent.service.IFileService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类的介绍:
|
* 类的介绍:
|
||||||
@@ -35,7 +42,7 @@ public class FileController extends BaseController {
|
|||||||
@PostMapping("/fileInfo")
|
@PostMapping("/fileInfo")
|
||||||
@ApiOperation("文件信息")
|
@ApiOperation("文件信息")
|
||||||
@ApiImplicitParam(name = "appFileMessage", value = "数据实体", required = true)
|
@ApiImplicitParam(name = "appFileMessage", value = "数据实体", required = true)
|
||||||
public HttpResult<String> fileInfo(@RequestBody AppFileMessage appFileMessage){
|
public HttpResult<String> fileInfo(@RequestBody AppFileMessage appFileMessage) {
|
||||||
String methodDescribe = getMethodDescribe("fileInfo");
|
String methodDescribe = getMethodDescribe("fileInfo");
|
||||||
fileService.analysisFileInfo(appFileMessage);
|
fileService.analysisFileInfo(appFileMessage);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
@@ -45,7 +52,7 @@ public class FileController extends BaseController {
|
|||||||
@PostMapping("/fileStream")
|
@PostMapping("/fileStream")
|
||||||
@ApiOperation("解析文件")
|
@ApiOperation("解析文件")
|
||||||
@ApiImplicitParam(name = "appFileMessage", value = "数据实体", required = true)
|
@ApiImplicitParam(name = "appFileMessage", value = "数据实体", required = true)
|
||||||
public HttpResult<String> fileStream(@RequestBody AppFileMessage appFileMessage){
|
public HttpResult<String> fileStream(@RequestBody AppFileMessage appFileMessage) {
|
||||||
String methodDescribe = getMethodDescribe("fileStream");
|
String methodDescribe = getMethodDescribe("fileStream");
|
||||||
fileService.analysisFileStream(appFileMessage);
|
fileService.analysisFileStream(appFileMessage);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
@@ -55,10 +62,59 @@ public class FileController extends BaseController {
|
|||||||
@PostMapping("/downloadMakeUpFile")
|
@PostMapping("/downloadMakeUpFile")
|
||||||
@ApiOperation("下载补召文件")
|
@ApiOperation("下载补召文件")
|
||||||
@ApiImplicitParam(name = "nDid", value = "nDid", required = true)
|
@ApiImplicitParam(name = "nDid", value = "nDid", required = true)
|
||||||
public HttpResult<String> downloadMakeUpFile(@RequestParam("nDid") String nDid){
|
public HttpResult<String> downloadMakeUpFile(@RequestParam("nDid") String nDid) {
|
||||||
String methodDescribe = getMethodDescribe("downloadMakeUpFile");
|
String methodDescribe = getMethodDescribe("downloadMakeUpFile");
|
||||||
fileService.downloadMakeUpFile(nDid);
|
fileService.downloadMakeUpFile(nDid);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/listDir")
|
||||||
|
@ApiOperation("获取目录列表")
|
||||||
|
@ApiImplicitParam(name = "fileParam", value = "文件路径", required = true)
|
||||||
|
public HttpResult<List<FileInfoResponseDTO.ResourceElement>> listDir(@RequestBody FileParam fileParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("listDir");
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, fileService.listDir(fileParam.getFilePath(), fileParam.getDevId()), methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/downloadFileFromFront")
|
||||||
|
@ApiOperation("下载文件")
|
||||||
|
@ApiImplicitParam(name = "fileParam", value = "文件参数", required = true)
|
||||||
|
public void downloadFileFromFront(@RequestBody FileParam fileParam, HttpServletResponse response) {
|
||||||
|
fileService.downloadFileFromFront(fileParam.getFilePath(), fileParam.getDevId(), response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/mkdir")
|
||||||
|
@ApiOperation("创建目录")
|
||||||
|
@ApiImplicitParam(name = "fileParam", value = "文件参数", required = true)
|
||||||
|
public HttpResult<Boolean> mkdir(@RequestBody FileParam fileParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("mkdir");
|
||||||
|
boolean res = fileService.mkdir(fileParam.getFilePath(), fileParam.getDevId());
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(res ? CommonResponseEnum.SUCCESS : CommonResponseEnum.FAIL, res, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/uploadFileToFront")
|
||||||
|
@ApiOperation("上传文件")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "file", value = "文件", required = true),
|
||||||
|
@ApiImplicitParam(name = "devId", value = "设备ID", required = true),
|
||||||
|
@ApiImplicitParam(name = "dirPath", value = "文件所在路径", required = true)
|
||||||
|
})
|
||||||
|
public HttpResult<Boolean> uploadFileToFront(@RequestPart("file") MultipartFile file, @RequestParam("devId") String devId, @RequestParam("dirPath") String dirPath) {
|
||||||
|
boolean res = fileService.uploadFileToFront(file, devId, dirPath);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(res ? CommonResponseEnum.SUCCESS : CommonResponseEnum.FAIL, res, getMethodDescribe("uploadFileToFront"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/delete")
|
||||||
|
@ApiOperation("删除文件/目录")
|
||||||
|
@ApiImplicitParam(name = "fileParam", value = "文件参数", required = true)
|
||||||
|
public HttpResult<Boolean> delete(@RequestBody FileParam fileParam) {
|
||||||
|
boolean res = fileService.delete(fileParam.getFilePath(), fileParam.getDevId());
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(res ? CommonResponseEnum.SUCCESS : CommonResponseEnum.FAIL, res, getMethodDescribe("delete"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
package com.njcn.zlevent.mapper;
|
//package com.njcn.zlevent.mapper;
|
||||||
|
//
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
//import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* <p>
|
// * <p>
|
||||||
* 暂态事件表 Mapper 接口
|
// * 暂态事件表 Mapper 接口
|
||||||
* </p>
|
// * </p>
|
||||||
*
|
// *
|
||||||
* @author xuyang
|
// * @author xuyang
|
||||||
* @since 2023-08-23
|
// * @since 2023-08-23
|
||||||
*/
|
// */
|
||||||
public interface CsEventUserMapper extends BaseMapper<CsEventUserPO> {
|
//public interface CsEventUserMapper extends BaseMapper<CsEventUserPO> {
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.njcn.zlevent.producer;
|
||||||
|
|
||||||
|
import com.njcn.middle.rocket.domain.BaseMessage;
|
||||||
|
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
|
||||||
|
import com.njcn.mq.constant.BusinessTopic;
|
||||||
|
import org.apache.rocketmq.client.producer.SendResult;
|
||||||
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-16
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class CommonProducer extends RocketMQEnhanceTemplate {
|
||||||
|
|
||||||
|
|
||||||
|
public CommonProducer(RocketMQTemplate template) {
|
||||||
|
super(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message
|
||||||
|
* @param frontId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public SendResult send(BaseMessage message, String frontId) {
|
||||||
|
return send(BusinessTopic.CLOUD_TOPIC, frontId, message);
|
||||||
|
}
|
||||||
|
public SendResult send(BaseMessage message) {
|
||||||
|
return send(BusinessTopic.CLOUD_REPLY_TOPIC, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,239 @@
|
|||||||
|
//package com.njcn.zlevent.service;
|
||||||
|
//
|
||||||
|
//import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
//import cn.hutool.core.date.DatePattern;
|
||||||
|
//import com.njcn.access.pojo.dto.NoticeUserDto;
|
||||||
|
//import com.njcn.access.utils.SendMessageUtil;
|
||||||
|
//import com.njcn.csdevice.api.CsLedgerFeignClient;
|
||||||
|
//import com.njcn.csdevice.api.DeviceMessageFeignClient;
|
||||||
|
//import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||||
|
//import com.njcn.csdevice.api.EventLogsFeignClient;
|
||||||
|
//import com.njcn.csdevice.param.DeviceMessageParam;
|
||||||
|
//import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||||
|
//import com.njcn.csdevice.pojo.po.CsEventSendMsg;
|
||||||
|
//import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||||
|
//import com.njcn.system.api.EpdFeignClient;
|
||||||
|
//import com.njcn.user.pojo.po.User;
|
||||||
|
//import lombok.RequiredArgsConstructor;
|
||||||
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
|
//import org.springframework.scheduling.annotation.Async;
|
||||||
|
//import org.springframework.stereotype.Service;
|
||||||
|
//
|
||||||
|
//import java.time.LocalDateTime;
|
||||||
|
//import java.util.ArrayList;
|
||||||
|
//import java.util.List;
|
||||||
|
//import java.util.Objects;
|
||||||
|
//import java.util.stream.Collectors;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * @author xy
|
||||||
|
// */
|
||||||
|
//@Service
|
||||||
|
//@Slf4j
|
||||||
|
//@RequiredArgsConstructor
|
||||||
|
//public class AppNotificationService {
|
||||||
|
//
|
||||||
|
// private final DeviceMessageFeignClient deviceMessageFeignClient;
|
||||||
|
// private final EquipmentFeignClient equipmentFeignClient;
|
||||||
|
// private final EpdFeignClient epdFeignClient;
|
||||||
|
// private final ICsEventUserService csEventUserService;
|
||||||
|
// private final SendMessageUtil sendMessageUtil;
|
||||||
|
// private final EventLogsFeignClient eventLogsFeignClient;
|
||||||
|
// private final CsLedgerFeignClient csLedgerFeignClient;
|
||||||
|
//
|
||||||
|
// @Async("eventNotificationExecutor")
|
||||||
|
// public void sendAppNotification(Integer eventType, String type, String devId,
|
||||||
|
// String eventName, LocalDateTime eventTime,
|
||||||
|
// String id, String nDid, Double amplitude, Double persistTime,String dropZone) {
|
||||||
|
// int code;
|
||||||
|
// List<User> users = new ArrayList<>();
|
||||||
|
// List<String> eventUser;
|
||||||
|
// List<String> devCodeList;
|
||||||
|
// List<String> userList = new ArrayList<>();
|
||||||
|
// List<CsEventSendMsg> csEventSendMsgList = new ArrayList<>();
|
||||||
|
// NoticeUserDto noticeUserDto = new NoticeUserDto();
|
||||||
|
// NoticeUserDto.Payload payload = new NoticeUserDto.Payload();
|
||||||
|
// String content = null;
|
||||||
|
// List<CsEventUserPO> result = new ArrayList<>();
|
||||||
|
// //获取设备类型 true:治理设备 false:其他类型的设备
|
||||||
|
// boolean devModel = equipmentFeignClient.judgeDevModel(nDid).getData();
|
||||||
|
// if (devModel) {
|
||||||
|
// DevDetailDTO devDetailDto = csLedgerFeignClient.queryDevDetail(devId).getData();
|
||||||
|
// //事件处理
|
||||||
|
// if (eventType == 1){
|
||||||
|
// eventName = epdFeignClient.findByName(eventName).getData().getShowName();
|
||||||
|
// switch (type) {
|
||||||
|
// case "1":
|
||||||
|
// code = 3;
|
||||||
|
// //设备自身事件 不推送给用户,推送给业务管理
|
||||||
|
// eventUser = deviceMessageFeignClient.getEventUserByDeviceId(devId,false).getData();
|
||||||
|
// if (CollectionUtil.isNotEmpty(eventUser)) {
|
||||||
|
// eventUser.forEach(item->{
|
||||||
|
// CsEventUserPO csEventUser = new CsEventUserPO();
|
||||||
|
// csEventUser.setUserId(item);
|
||||||
|
// csEventUser.setStatus(0);
|
||||||
|
// csEventUser.setEventId(id);
|
||||||
|
// result.add(csEventUser);
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// DeviceMessageParam param1 = new DeviceMessageParam();
|
||||||
|
// param1.setUserList(eventUser);
|
||||||
|
// param1.setEventType(2);
|
||||||
|
// users = deviceMessageFeignClient.getSendUserByType(param1).getData();
|
||||||
|
// if (CollectionUtil.isNotEmpty(users)){
|
||||||
|
// for (User user : users){
|
||||||
|
// userList.add(user.getDevCode());
|
||||||
|
// }
|
||||||
|
// noticeUserDto.setPushClientId(userList);
|
||||||
|
// noticeUserDto.setTitle("运行事件");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
// case "2":
|
||||||
|
// code = 0;
|
||||||
|
// //暂态事件
|
||||||
|
// eventUser = deviceMessageFeignClient.getEventUserByDeviceId(devId,true).getData();
|
||||||
|
// if (CollectionUtil.isNotEmpty(eventUser)) {
|
||||||
|
// eventUser.forEach(item->{
|
||||||
|
// CsEventUserPO csEventUser = new CsEventUserPO();
|
||||||
|
// csEventUser.setUserId(item);
|
||||||
|
// csEventUser.setStatus(0);
|
||||||
|
// csEventUser.setEventId(id);
|
||||||
|
// result.add(csEventUser);
|
||||||
|
// });
|
||||||
|
// DeviceMessageParam param1 = new DeviceMessageParam();
|
||||||
|
// param1.setUserList(eventUser);
|
||||||
|
// param1.setEventType(0);
|
||||||
|
// users = deviceMessageFeignClient.getSendUserByType(param1).getData();
|
||||||
|
// if (CollectionUtil.isNotEmpty(users)){
|
||||||
|
// devCodeList = users.stream().map(User::getDevCode).distinct().collect(Collectors.toList());
|
||||||
|
// noticeUserDto.setPushClientId(devCodeList);
|
||||||
|
// noticeUserDto.setTitle("暂态事件");
|
||||||
|
// content = devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName()
|
||||||
|
// + "于" + eventTime.format(DatePattern.NORM_DATETIME_MS_FORMATTER) + "发生暂态事件,事件类型:"
|
||||||
|
// + eventName
|
||||||
|
// + ",特征幅值:" + amplitude + "%"
|
||||||
|
// + ",持续时间:" + persistTime + "s"
|
||||||
|
// + ",落点区域:" + (Objects.isNull(dropZone)?"未知":dropZone);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
//// case "3":
|
||||||
|
//// code = 1;
|
||||||
|
//// //稳态事件
|
||||||
|
//// eventUser = getEventUser(devId,true);
|
||||||
|
//// if (CollectionUtil.isNotEmpty(eventUser)) {
|
||||||
|
//// eventUser.forEach(item->{
|
||||||
|
//// CsEventUserPO csEventUser = new CsEventUserPO();
|
||||||
|
//// csEventUser.setUserId(item);
|
||||||
|
//// csEventUser.setStatus(0);
|
||||||
|
//// csEventUser.setEventId(id);
|
||||||
|
//// result.add(csEventUser);
|
||||||
|
//// });
|
||||||
|
//// users = getSendUser(eventUser,1);
|
||||||
|
//// if (CollectionUtil.isNotEmpty(users)){
|
||||||
|
//// devCodeList = users.stream().map(User::getDevCode).distinct().collect(Collectors.toList());
|
||||||
|
//// noticeUserDto.setPushClientId(devCodeList);
|
||||||
|
//// noticeUserDto.setTitle("稳态事件");
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
//// break;
|
||||||
|
// default:
|
||||||
|
// code = 0;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// //获取台账信息
|
||||||
|
// if (Objects.isNull(content)) {
|
||||||
|
// content = devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName() + "于" + eventTime.format(DatePattern.NORM_DATETIME_MS_FORMATTER) + "发生" + eventName;
|
||||||
|
// }
|
||||||
|
// noticeUserDto.setContent(content);
|
||||||
|
// payload.setType(code);
|
||||||
|
// payload.setPath("/pages/index/message1?type="+payload.getType());
|
||||||
|
// noticeUserDto.setPayload(payload);
|
||||||
|
// }
|
||||||
|
//// //告警处理
|
||||||
|
//// else if (eventType == 2){
|
||||||
|
//// switch (type) {
|
||||||
|
//// case "1":
|
||||||
|
//// //Ⅰ级告警 不推送给用户,推送给业务管理
|
||||||
|
//// eventUser = getEventUser(devId,false);
|
||||||
|
//// if (CollectionUtil.isNotEmpty(eventUser)) {
|
||||||
|
//// eventUser.forEach(item->{
|
||||||
|
//// CsEventUserPO csEventUser = new CsEventUserPO();
|
||||||
|
//// csEventUser.setUserId(item);
|
||||||
|
//// csEventUser.setStatus(0);
|
||||||
|
//// csEventUser.setEventId(id);
|
||||||
|
//// result.add(csEventUser);
|
||||||
|
//// });
|
||||||
|
//// users = getSendUser(eventUser,3);
|
||||||
|
//// if (CollectionUtil.isNotEmpty(users)){
|
||||||
|
//// eventName = epdFeignClient.findByName(eventName).getData().getShowName();
|
||||||
|
//// devCodeList = users.stream().map(User::getDevCode).distinct().collect(Collectors.toList());
|
||||||
|
//// noticeUserDto.setPushClientId(devCodeList);
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
//// break;
|
||||||
|
//// case "2":
|
||||||
|
//// eventName = epdFeignClient.findByName(eventName).getData().getShowName();
|
||||||
|
//// case "3":
|
||||||
|
//// //Ⅱ、Ⅲ级告警推送相关用户及业务管理员
|
||||||
|
//// eventUser = getEventUser(devId,true);
|
||||||
|
//// if (CollectionUtil.isNotEmpty(eventUser)) {
|
||||||
|
//// eventUser.forEach(item->{
|
||||||
|
//// CsEventUserPO csEventUser = new CsEventUserPO();
|
||||||
|
//// csEventUser.setUserId(item);
|
||||||
|
//// csEventUser.setStatus(0);
|
||||||
|
//// csEventUser.setEventId(id);
|
||||||
|
//// result.add(csEventUser);
|
||||||
|
//// });
|
||||||
|
//// users = getSendUser(eventUser,3);
|
||||||
|
//// if (CollectionUtil.isNotEmpty(users)){
|
||||||
|
//// devCodeList = users.stream().map(User::getDevCode).distinct().collect(Collectors.toList());
|
||||||
|
//// noticeUserDto.setPushClientId(devCodeList);
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
//// break;
|
||||||
|
//// default:
|
||||||
|
//// break;
|
||||||
|
//// }
|
||||||
|
//// noticeUserDto.setTitle("告警事件");
|
||||||
|
//// DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(devId).getData();
|
||||||
|
//// content = devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName() + "于" + eventTime.format(DatePattern.NORM_DATETIME_MS_FORMATTER) + "发生告警,告警信息:" + eventName;
|
||||||
|
//// noticeUserDto.setContent(content);
|
||||||
|
//// payload.setType(3);
|
||||||
|
//// payload.setPath("/pages/message/message?type="+payload.getType());
|
||||||
|
//// noticeUserDto.setPayload(payload);
|
||||||
|
//// }
|
||||||
|
// if (CollectionUtil.isNotEmpty(noticeUserDto.getPushClientId())) {
|
||||||
|
// List<String> filteredList = noticeUserDto.getPushClientId().stream()
|
||||||
|
// .filter(Objects::nonNull)
|
||||||
|
// .distinct()
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
// if (CollectionUtil.isNotEmpty(filteredList)) {
|
||||||
|
// noticeUserDto.setPushClientId(filteredList);
|
||||||
|
// sendMessageUtil.sendEventToUser(noticeUserDto);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// //记录推送日志
|
||||||
|
// for (User item : users) {
|
||||||
|
// CsEventSendMsg csEventSendMsg = new CsEventSendMsg();
|
||||||
|
// csEventSendMsg.setUserId(item.getId());
|
||||||
|
// csEventSendMsg.setEventId(id);
|
||||||
|
// csEventSendMsg.setSendTime(LocalDateTime.now());
|
||||||
|
// if (Objects.isNull(item.getDevCode())){
|
||||||
|
// csEventSendMsg.setStatus(0);
|
||||||
|
// csEventSendMsg.setRemark("用户设备识别码为空");
|
||||||
|
// } else {
|
||||||
|
// csEventSendMsg.setDevCode(item.getDevCode());
|
||||||
|
// csEventSendMsg.setStatus(1);
|
||||||
|
// }
|
||||||
|
// csEventSendMsgList.add(csEventSendMsg);
|
||||||
|
// }
|
||||||
|
// eventLogsFeignClient.addLogs(csEventSendMsgList);
|
||||||
|
// //事件用户关系入库
|
||||||
|
// if (CollectionUtil.isNotEmpty(result)){
|
||||||
|
// csEventUserService.saveBatch(result);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@@ -19,6 +19,14 @@ public interface ICsEventService extends IService<CsEventPO> {
|
|||||||
/**
|
/**
|
||||||
* 事件添加波形文件地址
|
* 事件添加波形文件地址
|
||||||
*/
|
*/
|
||||||
List<String> updateCsEvent(CsEventParam csEventParam);
|
List<CsEventPO> updateCsEvent(CsEventParam csEventParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂降事件添加原因和类型
|
||||||
|
* 暂降原因(0:未知 1:短路故障 2:电压调节器 3:感动电机 4:电压跌落)
|
||||||
|
* 暂降类型(0:BC相间故障 1:C相接地故障 2:AC相间故障 3:A相接地故障 4:AB相间故障
|
||||||
|
* 5:B相接地故障 6:BC相间接地 7:AC相间接地 8:AB相间接地 9:三相故障 10:未知)
|
||||||
|
*/
|
||||||
|
void updateEventCauseAndType(String id, Integer cause, Integer type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
package com.njcn.zlevent.service;
|
//package com.njcn.zlevent.service;
|
||||||
|
//
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
//import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
//import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* <p>
|
// * <p>
|
||||||
* 暂态事件表 服务类
|
// * 暂态事件表 服务类
|
||||||
* </p>
|
// * </p>
|
||||||
*
|
// *
|
||||||
* @author xuyang
|
// * @author xuyang
|
||||||
* @since 2023-08-23
|
// * @since 2023-08-23
|
||||||
*/
|
// */
|
||||||
public interface ICsEventUserService extends IService<CsEventUserPO> {
|
//public interface ICsEventUserService extends IService<CsEventUserPO> {
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.njcn.zlevent.service;
|
||||||
|
|
||||||
|
import com.njcn.zlevent.pojo.dto.DevVersionResponeDTO;
|
||||||
|
import com.njcn.zlevent.pojo.dto.DeviceVersionRequestDTO;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-20
|
||||||
|
*/
|
||||||
|
public interface IDeviceService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始运行日志任务
|
||||||
|
*
|
||||||
|
* @param devId 设备id
|
||||||
|
*/
|
||||||
|
void startWorkingLog(String devId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停止运行日志任务
|
||||||
|
*
|
||||||
|
* @param devId
|
||||||
|
*/
|
||||||
|
void stopWorkingLogTask(String devId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行日志任务是否正在运行
|
||||||
|
*
|
||||||
|
* @param devId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean isWorkingLogTaskRunning(String devId);
|
||||||
|
|
||||||
|
void getWorkingLog(String devId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备对时
|
||||||
|
*
|
||||||
|
* @param devId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean timeSync(String devId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备版本信息
|
||||||
|
*
|
||||||
|
* @param devId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
DevVersionResponeDTO.VersionInfo getDeviceVersion(String devId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备升级
|
||||||
|
*
|
||||||
|
* @param devId
|
||||||
|
* @param edDataId
|
||||||
|
*/
|
||||||
|
boolean upgrade(String devId, String edDataId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重启设备
|
||||||
|
*
|
||||||
|
* @param devId
|
||||||
|
*/
|
||||||
|
boolean reboot(String devId);
|
||||||
|
}
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
package com.njcn.zlevent.service;
|
package com.njcn.zlevent.service;
|
||||||
|
|
||||||
import com.njcn.mq.message.AppFileMessage;
|
import com.njcn.mq.message.AppFileMessage;
|
||||||
|
import com.njcn.zlevent.pojo.dto.FileInfoResponseDTO;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类的介绍:
|
* 类的介绍:
|
||||||
@@ -16,12 +21,14 @@ public interface IFileService {
|
|||||||
* 解析文件流之前需要获取文件的信息,可能要特殊处理
|
* 解析文件流之前需要获取文件的信息,可能要特殊处理
|
||||||
* 1.文件过大要分片获取(单次请求文件大小不超过50k)
|
* 1.文件过大要分片获取(单次请求文件大小不超过50k)
|
||||||
* 2.校验文件(md5或者crc)
|
* 2.校验文件(md5或者crc)
|
||||||
|
*
|
||||||
* @param appFileMessage
|
* @param appFileMessage
|
||||||
*/
|
*/
|
||||||
void analysisFileInfo(AppFileMessage appFileMessage);
|
void analysisFileInfo(AppFileMessage appFileMessage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件流,解析文件
|
* 获取文件流,解析文件
|
||||||
|
*
|
||||||
* @param appFileMessage
|
* @param appFileMessage
|
||||||
*/
|
*/
|
||||||
void analysisFileStream(AppFileMessage appFileMessage);
|
void analysisFileStream(AppFileMessage appFileMessage);
|
||||||
@@ -30,4 +37,35 @@ public interface IFileService {
|
|||||||
* 下载补召文件
|
* 下载补召文件
|
||||||
*/
|
*/
|
||||||
void downloadMakeUpFile(String nDid);
|
void downloadMakeUpFile(String nDid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取目录列表
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @param devId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<FileInfoResponseDTO.ResourceElement> listDir(String filePath, String devId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从前置下载文件
|
||||||
|
*
|
||||||
|
* @param filePath
|
||||||
|
* @param devId
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
void downloadFileFromFront(String filePath, String devId, HttpServletResponse response);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件到文件服务器
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @param devId
|
||||||
|
* @param dirPath
|
||||||
|
*/
|
||||||
|
boolean uploadFileToFront(MultipartFile file, String devId, String dirPath);
|
||||||
|
|
||||||
|
boolean mkdir(String filePath, String devId);
|
||||||
|
|
||||||
|
boolean delete(String filePath, String devId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
//package com.njcn.zlevent.service;
|
||||||
|
//
|
||||||
|
//import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
//import cn.hutool.core.date.DatePattern;
|
||||||
|
//import cn.hutool.core.util.StrUtil;
|
||||||
|
//import com.njcn.csdevice.api.CsLedgerFeignClient;
|
||||||
|
//import com.njcn.csdevice.api.SmsSendFeignClient;
|
||||||
|
//import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||||
|
//import com.njcn.cssystem.api.AppMsgSetFeignClient;
|
||||||
|
//import com.njcn.user.api.UserFeignClient;
|
||||||
|
//import com.njcn.user.pojo.po.User;
|
||||||
|
//import lombok.RequiredArgsConstructor;
|
||||||
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
|
//import org.springframework.beans.factory.annotation.Value;
|
||||||
|
//import org.springframework.scheduling.annotation.Async;
|
||||||
|
//import org.springframework.stereotype.Service;
|
||||||
|
//
|
||||||
|
//import java.time.LocalDateTime;
|
||||||
|
//import java.util.List;
|
||||||
|
//import java.util.Objects;
|
||||||
|
//import java.util.stream.Collectors;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * @author xy
|
||||||
|
// */
|
||||||
|
//@Service
|
||||||
|
//@Slf4j
|
||||||
|
//@RequiredArgsConstructor
|
||||||
|
//public class SmsNotificationService {
|
||||||
|
//
|
||||||
|
// private final AppMsgSetFeignClient appMsgSetFeignClient;
|
||||||
|
// private final UserFeignClient userFeignClient;
|
||||||
|
// private final SmsSendFeignClient smsSendFeignClient;
|
||||||
|
// private final CsLedgerFeignClient csLedgerFeignclient;
|
||||||
|
//
|
||||||
|
// @Value("${msg.msg_sign:南京灿能电力}")
|
||||||
|
// private String msgSign;
|
||||||
|
//
|
||||||
|
// @Async("smsNotificationExecutor")
|
||||||
|
// public void sendSmsForDipEvent(String deviceId, LocalDateTime eventTime,double amplitude,double persistTime,String dropZone) {
|
||||||
|
// try {
|
||||||
|
// List<String> userIdList = appMsgSetFeignClient.queryUserIdsByDeviceId(deviceId).getData();
|
||||||
|
// if (CollectionUtil.isNotEmpty(userIdList)) {
|
||||||
|
// List<User> userList = userFeignClient.getUserListByIds(userIdList).getData();
|
||||||
|
// if (CollectionUtil.isNotEmpty(userList)) {
|
||||||
|
// List<User> userList1 = userList.stream()
|
||||||
|
// .filter(item -> StrUtil.isNotBlank(item.getPhone()) && Objects.equals(item.getSmsNotice(), 1))
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
// if (CollectionUtil.isNotEmpty(userList1)) {
|
||||||
|
// DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(deviceId).getData();
|
||||||
|
// String msgContent = "【" + msgSign + "】" + devDetailDto.getEngineeringName()
|
||||||
|
// + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName()
|
||||||
|
// + "于" + eventTime.format(DatePattern.NORM_DATETIME_MS_FORMATTER) + "发生暂降事件"
|
||||||
|
// + ",特征幅值:" + amplitude + "%"
|
||||||
|
// + ",持续时间:" + persistTime + "s"
|
||||||
|
// + ",落点区域:" + (Objects.isNull(dropZone)?"未知":dropZone);
|
||||||
|
// userList1.forEach(item -> {
|
||||||
|
// try {
|
||||||
|
// smsSendFeignClient.sendSmsSimple(item.getPhone(), msgContent, "verify_code");
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// log.error("发送短信失败,手机号: {}", item.getPhone(), e);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// log.error("异步发送暂降事件短信失败,设备ID: {}", deviceId, e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@@ -3,14 +3,14 @@ package com.njcn.zlevent.service.impl;
|
|||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.access.pojo.po.CsDeviceOnlineLogs;
|
|
||||||
import com.njcn.access.utils.ChannelObjectUtil;
|
import com.njcn.access.utils.ChannelObjectUtil;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||||
|
import com.njcn.cssystem.api.MsgSendFeignClient;
|
||||||
|
import com.njcn.cssystem.pojo.param.MsgSendParam;
|
||||||
import com.njcn.mq.message.AppEventMessage;
|
import com.njcn.mq.message.AppEventMessage;
|
||||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||||
import com.njcn.redis.utils.RedisUtil;
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
@@ -21,10 +21,10 @@ import com.njcn.system.pojo.po.EleEpdPqd;
|
|||||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||||
import com.njcn.zlevent.mapper.CsEventMapper;
|
import com.njcn.zlevent.mapper.CsEventMapper;
|
||||||
import com.njcn.zlevent.pojo.po.CsEventLogs;
|
import com.njcn.zlevent.pojo.po.CsEventLogs;
|
||||||
|
//import com.njcn.zlevent.service.AppNotificationService;
|
||||||
import com.njcn.zlevent.service.ICsAlarmService;
|
import com.njcn.zlevent.service.ICsAlarmService;
|
||||||
import com.njcn.zlevent.service.ICsEventLogsService;
|
import com.njcn.zlevent.service.ICsEventLogsService;
|
||||||
import com.njcn.zlevent.service.ICsEventService;
|
import com.njcn.zlevent.service.ICsEventService;
|
||||||
import com.njcn.zlevent.utils.SendEventUtils;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -52,11 +52,12 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> im
|
|||||||
private final EquipmentFeignClient equipmentFeignClient;
|
private final EquipmentFeignClient equipmentFeignClient;
|
||||||
private final EventServiceImpl eventService;
|
private final EventServiceImpl eventService;
|
||||||
private final ICsEventService csEventService;
|
private final ICsEventService csEventService;
|
||||||
private final SendEventUtils sendEventUtils;
|
|
||||||
private final ICsEventLogsService csEventLogsService;
|
private final ICsEventLogsService csEventLogsService;
|
||||||
private final EpdFeignClient epdFeignClient;
|
private final EpdFeignClient epdFeignClient;
|
||||||
private final RedisUtil redisUtil;
|
private final RedisUtil redisUtil;
|
||||||
private final ChannelObjectUtil channelObjectUtil;
|
private final ChannelObjectUtil channelObjectUtil;
|
||||||
|
// private final AppNotificationService appNotificationService;
|
||||||
|
private final MsgSendFeignClient msgSendFeignClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@@ -127,10 +128,21 @@ public class CsAlarmServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> im
|
|||||||
csEventService.saveBatch(list1);
|
csEventService.saveBatch(list1);
|
||||||
//推送事件逻辑处理 && cs_event_user入库 && 修改字典中告警事件的编码
|
//推送事件逻辑处理 && cs_event_user入库 && 修改字典中告警事件的编码
|
||||||
for (AppEventMessage.DataArray item : dataArray) {
|
for (AppEventMessage.DataArray item : dataArray) {
|
||||||
|
MsgSendParam msgSendParam = new MsgSendParam();
|
||||||
|
msgSendParam.setEventType(2);
|
||||||
|
msgSendParam.setType(item.getType());
|
||||||
|
msgSendParam.setDevId(po.getId());
|
||||||
|
msgSendParam.setEventTime(eventTime);
|
||||||
|
msgSendParam.setId(id);
|
||||||
|
msgSendParam.setNDid(po.getNdid());
|
||||||
if (Objects.isNull(item.getCode())){
|
if (Objects.isNull(item.getCode())){
|
||||||
sendEventUtils.sendUser(2,item.getType(),po.getId(),item.getName(),eventTime,id,po.getNdid());
|
msgSendParam.setEventName(item.getName());
|
||||||
|
msgSendFeignClient.appMsgSend(msgSendParam);
|
||||||
|
// appNotificationService.sendAppNotification(2,item.getType(),po.getId(),item.getName(),eventTime,id,po.getNdid(),null,null,null);
|
||||||
} else {
|
} else {
|
||||||
sendEventUtils.sendUser(2,item.getType(),po.getId(),item.getCode(),eventTime,id,po.getNdid());
|
msgSendParam.setEventName(item.getCode());
|
||||||
|
msgSendFeignClient.appMsgSend(msgSendParam);
|
||||||
|
// appNotificationService.sendAppNotification(2,item.getType(),po.getId(),item.getCode(),eventTime,id,po.getNdid(),null, null,null);
|
||||||
//更新字典信息
|
//更新字典信息
|
||||||
EleEpdPqd eleEpdPqd = epdFeignClient.findByName(item.getName()).getData();
|
EleEpdPqd eleEpdPqd = epdFeignClient.findByName(item.getName()).getData();
|
||||||
EleEpdPqdParam.EleEpdPqdUpdateParam updateParam = new EleEpdPqdParam.EleEpdPqdUpdateParam();
|
EleEpdPqdParam.EleEpdPqdUpdateParam updateParam = new EleEpdPqdParam.EleEpdPqdUpdateParam();
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.njcn.zlevent.service.impl;
|
package com.njcn.zlevent.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||||
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
|
import com.njcn.system.enums.DicDataTypeEnum;
|
||||||
|
import com.njcn.system.pojo.po.DictData;
|
||||||
import com.njcn.zlevent.mapper.CsEventMapper;
|
import com.njcn.zlevent.mapper.CsEventMapper;
|
||||||
import com.njcn.zlevent.param.CsEventParam;
|
import com.njcn.zlevent.param.CsEventParam;
|
||||||
import com.njcn.zlevent.service.ICsEventService;
|
import com.njcn.zlevent.service.ICsEventService;
|
||||||
@@ -11,11 +13,11 @@ import lombok.AllArgsConstructor;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
import java.util.stream.Collectors;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -29,11 +31,11 @@ import java.util.stream.Collectors;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class CsEventServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> implements ICsEventService {
|
public class CsEventServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> implements ICsEventService {
|
||||||
|
|
||||||
|
private final DicDataFeignClient dicDataFeignClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public List<String> updateCsEvent(CsEventParam csEventParam) {
|
public List<CsEventPO> updateCsEvent(CsEventParam csEventParam) {
|
||||||
List<String> eventList = new ArrayList<>();
|
|
||||||
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
|
||||||
LocalDateTime dateTime = LocalDateTime.parse(csEventParam.getStartTime(), formatter);
|
LocalDateTime dateTime = LocalDateTime.parse(csEventParam.getStartTime(), formatter);
|
||||||
// 减去1毫秒
|
// 减去1毫秒
|
||||||
@@ -50,10 +52,30 @@ public class CsEventServiceImpl extends ServiceImpl<CsEventMapper, CsEventPO> im
|
|||||||
lambdaUpdateWrapper.eq(CsEventPO::getLocation, csEventParam.getLocation());
|
lambdaUpdateWrapper.eq(CsEventPO::getLocation, csEventParam.getLocation());
|
||||||
}
|
}
|
||||||
this.update(lambdaUpdateWrapper);
|
this.update(lambdaUpdateWrapper);
|
||||||
List<CsEventPO> list = this.baseMapper.selectList(lambdaUpdateWrapper);
|
return this.baseMapper.selectList(lambdaUpdateWrapper);
|
||||||
if (CollectionUtil.isNotEmpty(list)){
|
|
||||||
eventList = list.stream().map(CsEventPO::getId).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
return eventList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEventCauseAndType(String id, Integer cause, Integer type) {
|
||||||
|
List<DictData> list1 = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_REASON.getCode()).getData();
|
||||||
|
String id1 = list1.stream()
|
||||||
|
.filter(item -> Objects.equals(item.getAlgoDescribe(), cause))
|
||||||
|
.map(DictData::getId)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
List<DictData> list2 = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_TYPE.getCode()).getData();
|
||||||
|
String id2 = list2.stream()
|
||||||
|
.filter(item -> Objects.equals(item.getAlgoDescribe(), type))
|
||||||
|
.map(DictData::getId)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
LambdaUpdateWrapper<CsEventPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
lambdaUpdateWrapper.set(CsEventPO::getAdvanceReason,id1)
|
||||||
|
.set(CsEventPO::getAdvanceType,id2)
|
||||||
|
.eq(CsEventPO::getId,id);
|
||||||
|
this.update(lambdaUpdateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,20 @@
|
|||||||
package com.njcn.zlevent.service.impl;
|
//package com.njcn.zlevent.service.impl;
|
||||||
|
//
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
//import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
//import com.njcn.zlevent.mapper.CsEventUserMapper;
|
||||||
import com.njcn.zlevent.mapper.CsEventUserMapper;
|
//import com.njcn.zlevent.service.ICsEventUserService;
|
||||||
import com.njcn.zlevent.service.ICsEventUserService;
|
//import org.springframework.stereotype.Service;
|
||||||
import org.springframework.stereotype.Service;
|
//
|
||||||
|
///**
|
||||||
/**
|
// * <p>
|
||||||
* <p>
|
// * 暂态事件表 服务实现类
|
||||||
* 暂态事件表 服务实现类
|
// * </p>
|
||||||
* </p>
|
// *
|
||||||
*
|
// * @author xuyang
|
||||||
* @author xuyang
|
// * @since 2023-08-23
|
||||||
* @since 2023-08-23
|
// */
|
||||||
*/
|
//@Service
|
||||||
@Service
|
//public class CsEventUserServiceImpl extends ServiceImpl<CsEventUserMapper, CsEventUserPO> implements ICsEventUserService {
|
||||||
public class CsEventUserServiceImpl extends ServiceImpl<CsEventUserMapper, CsEventUserPO> implements ICsEventUserService {
|
//
|
||||||
|
//}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,33 +1,29 @@
|
|||||||
package com.njcn.zlevent.service.impl;
|
package com.njcn.zlevent.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
|
||||||
import com.njcn.access.api.CsTopicFeignClient;
|
|
||||||
import com.njcn.access.utils.ChannelObjectUtil;
|
import com.njcn.access.utils.ChannelObjectUtil;
|
||||||
import com.njcn.access.utils.FileCommonUtils;
|
import com.njcn.access.utils.FileCommonUtils;
|
||||||
import com.njcn.access.utils.MqttUtil;
|
import com.njcn.access.utils.MqttUtil;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
import com.njcn.csdevice.api.DeviceMessageFeignClient;
|
||||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
import com.njcn.csdevice.param.LineInfoParam;
|
||||||
import com.njcn.mq.message.AppEventMessage;
|
import com.njcn.mq.message.AppEventMessage;
|
||||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||||
import com.njcn.redis.utils.RedisUtil;
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
import com.njcn.stat.enums.StatResponseEnum;
|
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
|
||||||
import com.njcn.system.enums.DicDataEnum;
|
|
||||||
import com.njcn.system.pojo.po.DictData;
|
|
||||||
import com.njcn.zlevent.pojo.constant.ZlConstant;
|
import com.njcn.zlevent.pojo.constant.ZlConstant;
|
||||||
import com.njcn.zlevent.pojo.dto.WaveTimeDto;
|
import com.njcn.zlevent.pojo.dto.WaveTimeDto;
|
||||||
import com.njcn.zlevent.service.ICsWaveAnalysisService;
|
import com.njcn.zlevent.service.ICsWaveAnalysisService;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,14 +39,11 @@ import java.util.stream.Collectors;
|
|||||||
public class CsWaveAnalysisServiceImpl implements ICsWaveAnalysisService {
|
public class CsWaveAnalysisServiceImpl implements ICsWaveAnalysisService {
|
||||||
|
|
||||||
private final EquipmentFeignClient equipmentFeignClient;
|
private final EquipmentFeignClient equipmentFeignClient;
|
||||||
private final MqttPublisher publisher;
|
|
||||||
private final CsTopicFeignClient csTopicFeignClient;
|
|
||||||
private final RedisUtil redisUtil;
|
private final RedisUtil redisUtil;
|
||||||
private final CsLineFeignClient csLineFeignClient;
|
|
||||||
private final DicDataFeignClient dicDataFeignClient;
|
|
||||||
private final ChannelObjectUtil channelObjectUtil;
|
private final ChannelObjectUtil channelObjectUtil;
|
||||||
private final MqttUtil mqttUtil;
|
private final MqttUtil mqttUtil;
|
||||||
private final FileCommonUtils fileCommonUtils;
|
private final FileCommonUtils fileCommonUtils;
|
||||||
|
private final DeviceMessageFeignClient deviceMessageFeignClient;
|
||||||
private static Integer mid = 1;
|
private static Integer mid = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -59,7 +52,9 @@ public class CsWaveAnalysisServiceImpl implements ICsWaveAnalysisService {
|
|||||||
List<WaveTimeDto> list = new ArrayList<>();
|
List<WaveTimeDto> list = new ArrayList<>();
|
||||||
Object object1 = redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION+appEventMessage.getId());
|
Object object1 = redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION+appEventMessage.getId());
|
||||||
if (Objects.isNull(object1)){
|
if (Objects.isNull(object1)){
|
||||||
lineInfo(appEventMessage.getId());
|
LineInfoParam param = new LineInfoParam();
|
||||||
|
param.setNDid(appEventMessage.getId());
|
||||||
|
deviceMessageFeignClient.getLineInfo(param);
|
||||||
}
|
}
|
||||||
//获取装置id
|
//获取装置id
|
||||||
String deviceId = equipmentFeignClient.findDevByNDid(appEventMessage.getId()).getData().getId();
|
String deviceId = equipmentFeignClient.findDevByNDid(appEventMessage.getId()).getData().getId();
|
||||||
@@ -161,29 +156,4 @@ public class CsWaveAnalysisServiceImpl implements ICsWaveAnalysisService {
|
|||||||
waveTimeDto.setLocation(location);
|
waveTimeDto.setLocation(location);
|
||||||
return waveTimeDto;
|
return waveTimeDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 缓存监测点相关信息
|
|
||||||
*/
|
|
||||||
public void lineInfo(String id) {
|
|
||||||
Map<Integer,String> map = new HashMap<>();
|
|
||||||
List<CsLinePO> lineList = csLineFeignClient.findByNdid(id).getData();
|
|
||||||
if (CollectionUtil.isEmpty(lineList)){
|
|
||||||
throw new BusinessException(StatResponseEnum.LINE_NULL);
|
|
||||||
}
|
|
||||||
for (CsLinePO item : lineList) {
|
|
||||||
DictData dictData = dicDataFeignClient.getDicDataById(item.getPosition()).getData();
|
|
||||||
if (Objects.isNull(dictData)){
|
|
||||||
throw new BusinessException(StatResponseEnum.DICT_NULL);
|
|
||||||
}
|
|
||||||
if (Objects.equals(dictData.getCode(), DicDataEnum.OUTPUT_SIDE.getCode())){
|
|
||||||
map.put(0,item.getLineId());
|
|
||||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.GRID_SIDE.getCode())){
|
|
||||||
map.put(1,item.getLineId());
|
|
||||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){
|
|
||||||
map.put(2,item.getLineId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
redisUtil.saveByKeyWithExpire(AppRedisKey.LINE_POSITION+id,map,30L);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,288 @@
|
|||||||
|
package com.njcn.zlevent.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||||
|
import com.njcn.access.enums.TypeEnum;
|
||||||
|
import com.njcn.access.utils.SendMessageUtil;
|
||||||
|
import com.njcn.csdevice.api.CsEdDataFeignClient;
|
||||||
|
import com.njcn.csdevice.api.CsSoftInfoFeignClient;
|
||||||
|
import com.njcn.csdevice.api.CsUpgradeLogsFeignClient;
|
||||||
|
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||||
|
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsEdDataPO;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsSoftInfoPO;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsUpgradeLogs;
|
||||||
|
import com.njcn.middle.rocket.domain.BaseMessage;
|
||||||
|
import com.njcn.oss.utils.FileStorageUtil;
|
||||||
|
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||||
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
|
import com.njcn.zlevent.config.TaskSchedulerConfig;
|
||||||
|
import com.njcn.zlevent.pojo.dto.*;
|
||||||
|
import com.njcn.zlevent.producer.CommonProducer;
|
||||||
|
import com.njcn.zlevent.service.IDeviceService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-20
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DeviceServiceImpl implements IDeviceService {
|
||||||
|
|
||||||
|
private final EquipmentFeignClient equipmentFeignClient;
|
||||||
|
private final CsSoftInfoFeignClient csSoftInfoFeignClient;
|
||||||
|
private final CsEdDataFeignClient csEdDataFeignClient;
|
||||||
|
|
||||||
|
private final CommonProducer commonProducer;
|
||||||
|
private final SendMessageUtil sendMessageUtil;
|
||||||
|
private final TaskSchedulerConfig taskSchedulerConfig;
|
||||||
|
private final RedisUtil redisUtil;
|
||||||
|
private final MqttPublisher publisher;
|
||||||
|
private final FileStorageUtil fileStorageUtil;
|
||||||
|
private final CsUpgradeLogsFeignClient csUpgradeLogsFeignClient;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startWorkingLog(String devId) {
|
||||||
|
taskSchedulerConfig.startTask(devId, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stopWorkingLogTask(String devId) {
|
||||||
|
taskSchedulerConfig.stopTask(devId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWorkingLogTaskRunning(String devId) {
|
||||||
|
return taskSchedulerConfig.isTaskRunning(devId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getWorkingLog(String devId) {
|
||||||
|
List<CsEquipmentDeliveryDTO> listHttpResult = equipmentFeignClient.queryDeviceById(Collections.singletonList(devId)).getData();
|
||||||
|
|
||||||
|
WorkingLogRequestDTO requestDTO = new WorkingLogRequestDTO();
|
||||||
|
requestDTO.setDevId(devId);
|
||||||
|
requestDTO.setGuid(IdUtil.simpleUUID());
|
||||||
|
requestDTO.setNode(listHttpResult.get(0).getNodeProcess());
|
||||||
|
requestDTO.setFrontId(listHttpResult.get(0).getNodeId());
|
||||||
|
|
||||||
|
WorkingLogRequestDTO.Detail detail = new WorkingLogRequestDTO.Detail();
|
||||||
|
detail.setType(Integer.valueOf(TypeEnum.WORKING_LOG.getCode()));
|
||||||
|
detail.setMsg(new HashMap<>());
|
||||||
|
|
||||||
|
requestDTO.setDetail(detail);
|
||||||
|
BaseMessage message = new BaseMessage();
|
||||||
|
message.setMessageBody(JSON.toJSONString(requestDTO));
|
||||||
|
|
||||||
|
// 使用 Redis 存储 guid 用于后续查询
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.COMMON_REQUEST + requestDTO.getGuid(), "pending", 120L);
|
||||||
|
|
||||||
|
// 发送
|
||||||
|
commonProducer.send(message, requestDTO.getFrontId());
|
||||||
|
|
||||||
|
// 轮询 Redis 等待响应
|
||||||
|
WorkingLogResponeDTO workingLogResponeDTO = JSON.parseObject(sendMessageUtil.waitForResponse(requestDTO.getGuid(), 10), WorkingLogResponeDTO.class);
|
||||||
|
|
||||||
|
WorkingLogResponeDTO.Detail detail1 = workingLogResponeDTO.getDetail();
|
||||||
|
WorkingLogResponeDTO.Msg msg1 = detail1.getMsg();
|
||||||
|
|
||||||
|
//mqtt推送给前端
|
||||||
|
publisher.send("/afafaidfasd", JSON.toJSONString(msg1), 1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean timeSync(String devId) {
|
||||||
|
List<CsEquipmentDeliveryDTO> listHttpResult = equipmentFeignClient.queryDeviceById(Collections.singletonList(devId)).getData();
|
||||||
|
|
||||||
|
BaseMessage message = new BaseMessage();
|
||||||
|
// FileDownloadRequestDTO requestDTO = new FileDownloadRequestDTO();
|
||||||
|
// requestDTO.setGuid(listHttpResult.get(0).getNodeId());
|
||||||
|
// requestDTO.setNode(listHttpResult.get(0).getNodeProcess());
|
||||||
|
|
||||||
|
|
||||||
|
// BaseRequestDTO message = new BaseRequestDTO<>();
|
||||||
|
// message.setGuid(IdUtil.simpleUUID());
|
||||||
|
// message.setFrontId(listHttpResult.get(0).getNodeId());
|
||||||
|
// message.setNode(listHttpResult.get(0).getNodeProcess());
|
||||||
|
// message.setDevId(devId);
|
||||||
|
// BaseRequestDTO.Detail<FileInfoRequestDTO> detail = new BaseRequestDTO.Detail<>();
|
||||||
|
// detail.setType(1113);
|
||||||
|
// detail.setMsg(null);
|
||||||
|
// message.setDetail(detail);
|
||||||
|
|
||||||
|
// pendingResponsesMap.put(message.getGuid(), new CompletableFuture<>());
|
||||||
|
|
||||||
|
// 发送
|
||||||
|
//deviceProducer.send(message);
|
||||||
|
|
||||||
|
// BaseMessage baseMessage = null;
|
||||||
|
// CompletableFuture<BaseMessage> future = pendingResponsesMap.get(message.getGuid());
|
||||||
|
// try {
|
||||||
|
// baseMessage = future.get(5, TimeUnit.SECONDS);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// throw new BusinessException(ZleventResoponseEnum.RESPONSE_ERROR);
|
||||||
|
// } finally {
|
||||||
|
// pendingResponsesMap.remove(message.getGuid());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Integer code = baseMessage.getDetail().getCode();
|
||||||
|
|
||||||
|
// return code == 200;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DevVersionResponeDTO.VersionInfo getDeviceVersion(String devId) {
|
||||||
|
List<CsEquipmentDeliveryDTO> listHttpResult = equipmentFeignClient.queryDeviceById(Collections.singletonList(devId)).getData();
|
||||||
|
CsEquipmentDeliveryDTO csEquipmentDeliveryDTO = listHttpResult.get(0);
|
||||||
|
// 先询问一下旧的版本信息
|
||||||
|
DeviceVersionRequestDTO deviceVersionRequestDTO = new DeviceVersionRequestDTO();
|
||||||
|
deviceVersionRequestDTO.setDevId(devId);
|
||||||
|
deviceVersionRequestDTO.setGuid(IdUtil.simpleUUID());
|
||||||
|
deviceVersionRequestDTO.setNode(csEquipmentDeliveryDTO.getNodeProcess());
|
||||||
|
deviceVersionRequestDTO.setFrontId(csEquipmentDeliveryDTO.getNodeId());
|
||||||
|
|
||||||
|
DeviceVersionRequestDTO.Detail detail1 = new DeviceVersionRequestDTO.Detail();
|
||||||
|
detail1.setMsg(new HashMap<>());
|
||||||
|
detail1.setType(Integer.parseInt(TypeEnum.DEVICE_VERSION.getCode()));
|
||||||
|
deviceVersionRequestDTO.setDetail(detail1);
|
||||||
|
|
||||||
|
BaseMessage message = new BaseMessage();
|
||||||
|
message.setMessageBody(JSON.toJSONString(deviceVersionRequestDTO));
|
||||||
|
|
||||||
|
// 使用 Redis 存储 guid 用于后续查询
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.COMMON_REQUEST + deviceVersionRequestDTO.getGuid(), "pending", 120L);
|
||||||
|
|
||||||
|
// 发送
|
||||||
|
commonProducer.send(message, deviceVersionRequestDTO.getFrontId());
|
||||||
|
|
||||||
|
// 轮询 Redis 等待响应
|
||||||
|
DevVersionResponeDTO responseDTO = JSON.parseObject(sendMessageUtil.waitForResponse(deviceVersionRequestDTO.getGuid(), 10), DevVersionResponeDTO.class);
|
||||||
|
DevVersionResponeDTO.Detail detail2 = responseDTO.getDetail();
|
||||||
|
|
||||||
|
if (detail2.getMsg().getCode() == 200) {
|
||||||
|
DevVersionResponeDTO.VersionInfo versionInfo = detail2.getMsg().getVersionInfo();
|
||||||
|
return versionInfo;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean upgrade(String devId, String edDataId) {
|
||||||
|
// 先获取旧的版本信息
|
||||||
|
//DevVersionResponeDTO.VersionInfo oldVersionInfo = this.getDeviceVersion(devId);
|
||||||
|
|
||||||
|
List<CsEquipmentDeliveryDTO> listHttpResult = equipmentFeignClient.queryDeviceById(Collections.singletonList(devId)).getData();
|
||||||
|
CsEquipmentDeliveryDTO csEquipmentDeliveryDTO = listHttpResult.get(0);
|
||||||
|
|
||||||
|
CsEdDataPO csEdDataPO = csEdDataFeignClient.getById(edDataId).getData();
|
||||||
|
String filePath = csEdDataPO.getFilePath();
|
||||||
|
|
||||||
|
// 装置升级日志
|
||||||
|
CsUpgradeLogs csUpgradeLogs = new CsUpgradeLogs();
|
||||||
|
csUpgradeLogs.setDevId(devId);
|
||||||
|
csUpgradeLogs.setVersionNo(csEdDataPO.getVersionNo());
|
||||||
|
csUpgradeLogs.setResult(0);
|
||||||
|
|
||||||
|
UpgradeRequestDTO requestDTO = new UpgradeRequestDTO();
|
||||||
|
requestDTO.setDevId(devId);
|
||||||
|
requestDTO.setGuid(IdUtil.simpleUUID());
|
||||||
|
requestDTO.setNode(csEquipmentDeliveryDTO.getNodeProcess());
|
||||||
|
requestDTO.setFrontId(csEquipmentDeliveryDTO.getNodeId());
|
||||||
|
|
||||||
|
UpgradeRequestDTO.Detail detail1 = new UpgradeRequestDTO.Detail();
|
||||||
|
detail1.setType(Integer.valueOf(TypeEnum.DEVICE_UPGRADE.getCode()));
|
||||||
|
UpgradeRequestDTO.Msg msg = new UpgradeRequestDTO.Msg();
|
||||||
|
msg.setName(filePath);
|
||||||
|
detail1.setMsg(msg);
|
||||||
|
requestDTO.setDetail(detail1);
|
||||||
|
|
||||||
|
BaseMessage message = new BaseMessage();
|
||||||
|
message.setMessageBody(JSON.toJSONString(requestDTO));
|
||||||
|
|
||||||
|
// 使用 Redis 存储 guid 用于后续查询
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.COMMON_REQUEST + requestDTO.getGuid(), "pending", 120L);
|
||||||
|
|
||||||
|
// 发送
|
||||||
|
commonProducer.send(message, requestDTO.getFrontId());
|
||||||
|
|
||||||
|
// 轮询 Redis 等待响应
|
||||||
|
UpgradeResponeDTO responeDTO = JSON.parseObject(sendMessageUtil.waitForResponse(requestDTO.getGuid(), 10), UpgradeResponeDTO.class);
|
||||||
|
UpgradeResponeDTO.Detail detail2 = responeDTO.getDetail();
|
||||||
|
|
||||||
|
if (detail2.getCode() == 200) {
|
||||||
|
// 修改数据库记录
|
||||||
|
String softinfoId = csEquipmentDeliveryDTO.getSoftinfoId();
|
||||||
|
|
||||||
|
if (StrUtil.isNotBlank(softinfoId)) {
|
||||||
|
csSoftInfoFeignClient.removeSoftInfo(softinfoId);
|
||||||
|
}
|
||||||
|
CsSoftInfoPO softInfoPO = new CsSoftInfoPO();
|
||||||
|
softInfoPO.setId(IdUtil.fastSimpleUUID());
|
||||||
|
softInfoPO.setAppCheck(csEdDataPO.getCrc());
|
||||||
|
softInfoPO.setAppDate(csEdDataPO.getVersionDate());
|
||||||
|
softInfoPO.setAppVersion(csEdDataPO.getVersionNo());
|
||||||
|
softInfoPO.setOpAttr("r");
|
||||||
|
softInfoPO.setOsName("VxWorks");
|
||||||
|
softInfoPO.setOsVersion("VxWorks");
|
||||||
|
softInfoPO.setSoftUpdate("yes");
|
||||||
|
csSoftInfoFeignClient.saveSoftInfo(softInfoPO);
|
||||||
|
equipmentFeignClient.updateSoftInfo(csEquipmentDeliveryDTO.getNdid(), softInfoPO.getId());
|
||||||
|
|
||||||
|
// 重新获取升级后的版本信息
|
||||||
|
DevVersionResponeDTO.VersionInfo newVersionInfo = this.getDeviceVersion(devId);
|
||||||
|
if (newVersionInfo.getAppVersion().equals(csEdDataPO.getVersionNo()) && newVersionInfo.getCloudProtocolVer().equals(csEdDataPO.getVersionAgreement())) {
|
||||||
|
// 修改数据库记录
|
||||||
|
equipmentFeignClient.updateSoftInfo(csEquipmentDeliveryDTO.getNdid(), softInfoPO.getId());
|
||||||
|
csUpgradeLogs.setResult(1);
|
||||||
|
|
||||||
|
csUpgradeLogsFeignClient.add(csUpgradeLogs);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
csUpgradeLogsFeignClient.add(csUpgradeLogs);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
csUpgradeLogsFeignClient.add(csUpgradeLogs);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean reboot(String devId) {
|
||||||
|
List<CsEquipmentDeliveryDTO> listHttpResult = equipmentFeignClient.queryDeviceById(Collections.singletonList(devId)).getData();
|
||||||
|
|
||||||
|
RebootRequestDTO requestDTO = new RebootRequestDTO();
|
||||||
|
requestDTO.setDevId(devId);
|
||||||
|
requestDTO.setGuid(IdUtil.simpleUUID());
|
||||||
|
requestDTO.setNode(listHttpResult.get(0).getNodeProcess());
|
||||||
|
requestDTO.setFrontId(listHttpResult.get(0).getNodeId());
|
||||||
|
|
||||||
|
RebootRequestDTO.Detail detail1 = new RebootRequestDTO.Detail();
|
||||||
|
detail1.setType(Integer.parseInt(TypeEnum.DEVICE_REBOOT.getCode()));
|
||||||
|
detail1.setMsg(new HashMap<>());
|
||||||
|
requestDTO.setDetail(detail1);
|
||||||
|
|
||||||
|
BaseMessage message = new BaseMessage();
|
||||||
|
message.setMessageBody(JSON.toJSONString(requestDTO));
|
||||||
|
|
||||||
|
// 使用 Redis 存储 guid 用于后续查询
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.COMMON_REQUEST + requestDTO.getGuid(), "pending", 120L);
|
||||||
|
|
||||||
|
// 发送
|
||||||
|
commonProducer.send(message, requestDTO.getFrontId());
|
||||||
|
|
||||||
|
// 轮询 Redis 等待响应
|
||||||
|
RebootResponeDTO responeDTO = JSON.parseObject(sendMessageUtil.waitForResponse(requestDTO.getGuid(), 10), RebootResponeDTO.class);
|
||||||
|
if (responeDTO.getDetail().getCode() == 200) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,18 +2,27 @@ package com.njcn.zlevent.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||||
|
import com.njcn.csdevice.api.DeviceMessageFeignClient;
|
||||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||||
import com.njcn.csdevice.api.WlRecordFeignClient;
|
import com.njcn.csdevice.api.WlRecordFeignClient;
|
||||||
|
import com.njcn.csdevice.param.LineInfoParam;
|
||||||
import com.njcn.csdevice.pojo.param.WlRecordParam;
|
import com.njcn.csdevice.pojo.param.WlRecordParam;
|
||||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||||
import com.njcn.csdevice.pojo.po.WlRecord;
|
import com.njcn.csdevice.pojo.po.WlRecord;
|
||||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||||
|
import com.njcn.cssystem.api.MsgSendFeignClient;
|
||||||
|
import com.njcn.cssystem.pojo.param.MsgSendParam;
|
||||||
|
import com.njcn.event.common.mapper.WlRmpEventDetailMapper;
|
||||||
|
import com.njcn.event.common.service.EventAnalysisService;
|
||||||
|
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||||
import com.njcn.influx.utils.InfluxDbUtils;
|
import com.njcn.influx.utils.InfluxDbUtils;
|
||||||
import com.njcn.mq.message.AppEventMessage;
|
import com.njcn.mq.message.AppEventMessage;
|
||||||
@@ -22,17 +31,17 @@ import com.njcn.redis.pojo.enums.AppRedisKey;
|
|||||||
import com.njcn.redis.utils.RedisUtil;
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
import com.njcn.stat.enums.StatResponseEnum;
|
import com.njcn.stat.enums.StatResponseEnum;
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
|
import com.njcn.system.api.DictTreeFeignClient;
|
||||||
import com.njcn.system.api.EpdFeignClient;
|
import com.njcn.system.api.EpdFeignClient;
|
||||||
import com.njcn.system.enums.DicDataEnum;
|
import com.njcn.system.enums.DicDataEnum;
|
||||||
import com.njcn.system.pojo.dto.EpdDTO;
|
import com.njcn.system.pojo.dto.EpdDTO;
|
||||||
import com.njcn.system.pojo.po.DictData;
|
import com.njcn.system.pojo.po.DictData;
|
||||||
import com.njcn.zlevent.pojo.constant.ZlConstant;
|
import com.njcn.zlevent.pojo.constant.ZlConstant;
|
||||||
import com.njcn.zlevent.pojo.po.CsEventLogs;
|
//import com.njcn.zlevent.service.AppNotificationService;
|
||||||
import com.njcn.zlevent.service.ICsEventLogsService;
|
|
||||||
import com.njcn.zlevent.service.ICsEventService;
|
import com.njcn.zlevent.service.ICsEventService;
|
||||||
import com.njcn.zlevent.service.IEventService;
|
import com.njcn.zlevent.service.IEventService;
|
||||||
import com.njcn.zlevent.utils.SendEventUtils;
|
//import com.njcn.zlevent.service.SmsNotificationService;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.influxdb.InfluxDB;
|
import org.influxdb.InfluxDB;
|
||||||
import org.influxdb.dto.BatchPoints;
|
import org.influxdb.dto.BatchPoints;
|
||||||
@@ -49,6 +58,7 @@ import java.time.ZoneId;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类的介绍:
|
* 类的介绍:
|
||||||
@@ -59,7 +69,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@AllArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class EventServiceImpl implements IEventService {
|
public class EventServiceImpl implements IEventService {
|
||||||
|
|
||||||
private final CsLineFeignClient csLineFeignClient;
|
private final CsLineFeignClient csLineFeignClient;
|
||||||
@@ -69,12 +79,17 @@ public class EventServiceImpl implements IEventService {
|
|||||||
private final ICsEventService csEventService;
|
private final ICsEventService csEventService;
|
||||||
private final EquipmentFeignClient equipmentFeignClient;
|
private final EquipmentFeignClient equipmentFeignClient;
|
||||||
private final InfluxDbUtils influxDbUtils;
|
private final InfluxDbUtils influxDbUtils;
|
||||||
private final ICsEventLogsService csEventLogsService;
|
|
||||||
private final SendEventUtils sendEventUtils;
|
|
||||||
private final WlRecordFeignClient wlRecordFeignClient;
|
private final WlRecordFeignClient wlRecordFeignClient;
|
||||||
|
private final WlRmpEventDetailMapper wlRmpEventDetailMapper;
|
||||||
|
private final DictTreeFeignClient dictTreeFeignClient;
|
||||||
|
private final DeviceMessageFeignClient deviceMessageFeignClient;
|
||||||
|
// private final AppNotificationService appNotificationService;
|
||||||
|
// private final SmsNotificationService smsNotificationService;
|
||||||
|
private final EventAnalysisService eventAnalysisService;
|
||||||
|
private final MsgSendFeignClient msgSendFeignClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@DSTransactional
|
||||||
public void analysis(AppEventMessage appEventMessage) {
|
public void analysis(AppEventMessage appEventMessage) {
|
||||||
List<CsEventPO> list1 = new ArrayList<>();
|
List<CsEventPO> list1 = new ArrayList<>();
|
||||||
List<String> records = new ArrayList<String>();
|
List<String> records = new ArrayList<String>();
|
||||||
@@ -87,21 +102,32 @@ public class EventServiceImpl implements IEventService {
|
|||||||
}
|
}
|
||||||
//判断监测点是否存在
|
//判断监测点是否存在
|
||||||
if (Objects.isNull(object1)){
|
if (Objects.isNull(object1)){
|
||||||
lineInfo(appEventMessage.getId());
|
LineInfoParam param = new LineInfoParam();
|
||||||
|
param.setNDid(appEventMessage.getId());
|
||||||
|
deviceMessageFeignClient.getLineInfo(param);
|
||||||
}
|
}
|
||||||
//获取装置id
|
//获取装置id
|
||||||
CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(appEventMessage.getId()).getData();
|
CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(appEventMessage.getId()).getData();
|
||||||
//获取设备类型 true:治理设备 false:其他类型的设备
|
//判断设备型号
|
||||||
boolean devModel = equipmentFeignClient.judgeDevModel(appEventMessage.getId()).getData();
|
String code = dictTreeFeignClient.queryById(po.getDevType()).getData().getCode();
|
||||||
try {
|
try {
|
||||||
if (devModel) {
|
if (Objects.equals(DicDataEnum.CONNECT_DEV.getCode(),code)) {
|
||||||
if (Objects.equals(appEventMessage.getDid(),1)){
|
if (Objects.equals(appEventMessage.getDid(),1)){
|
||||||
lineId = new Gson().fromJson(String.valueOf(redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION+appEventMessage.getId())), Map.class).get("0").toString();
|
Object object = new Gson().fromJson(String.valueOf(redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION+appEventMessage.getId())), Map.class).get("0");
|
||||||
|
if (ObjectUtil.isNotNull(object)) {
|
||||||
|
lineId = object.toString();
|
||||||
|
}
|
||||||
} else if (Objects.equals(appEventMessage.getDid(),2)){
|
} else if (Objects.equals(appEventMessage.getDid(),2)){
|
||||||
lineId = new Gson().fromJson(String.valueOf(redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION+appEventMessage.getId())), Map.class).get(appEventMessage.getMsg().getClDid().toString()).toString();
|
Object object = new Gson().fromJson(String.valueOf(redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION+appEventMessage.getId())), Map.class).get(appEventMessage.getMsg().getClDid().toString());
|
||||||
|
if (ObjectUtil.isNotNull(object)) {
|
||||||
|
lineId = object.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lineId = new Gson().fromJson(String.valueOf(redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION+appEventMessage.getId())), Map.class).get(appEventMessage.getMsg().getClDid().toString()).toString();
|
Object object = new Gson().fromJson(String.valueOf(redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION+appEventMessage.getId())), Map.class).get(appEventMessage.getMsg().getClDid().toString());
|
||||||
|
if (ObjectUtil.isNotNull(object)) {
|
||||||
|
lineId = object.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//处理事件数据
|
//处理事件数据
|
||||||
@@ -111,9 +137,9 @@ public class EventServiceImpl implements IEventService {
|
|||||||
//判断事件是否存在,如果存在则不处理
|
//判断事件是否存在,如果存在则不处理
|
||||||
LambdaQueryWrapper<CsEventPO> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<CsEventPO> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(CsEventPO::getDeviceId,po.getId())
|
queryWrapper.eq(CsEventPO::getDeviceId,po.getId())
|
||||||
.eq(CsEventPO::getTag,tag)
|
.eq(CsEventPO::getTag,item.getName())
|
||||||
.eq(CsEventPO::getStartTime,eventTime)
|
.eq(CsEventPO::getStartTime,eventTime)
|
||||||
.eq(CsEventPO::getLineId,lineId);
|
.eq(ObjectUtil.isNotNull(lineId),CsEventPO::getLineId,lineId);
|
||||||
List<CsEventPO> eventList = csEventService.list(queryWrapper);
|
List<CsEventPO> eventList = csEventService.list(queryWrapper);
|
||||||
if (CollectionUtil.isEmpty(eventList)) {
|
if (CollectionUtil.isEmpty(eventList)) {
|
||||||
id = IdUtil.fastSimpleUUID();
|
id = IdUtil.fastSimpleUUID();
|
||||||
@@ -150,10 +176,16 @@ public class EventServiceImpl implements IEventService {
|
|||||||
if (Objects.equals(param.getName(),ZlConstant.EVT_PARAM_TM)){
|
if (Objects.equals(param.getName(),ZlConstant.EVT_PARAM_TM)){
|
||||||
csEvent.setPersistTime(Double.parseDouble(param.getData().toString()));
|
csEvent.setPersistTime(Double.parseDouble(param.getData().toString()));
|
||||||
}
|
}
|
||||||
|
if (Objects.equals(param.getName(),ZlConstant.EVT_PARAM_VVADEPTH)) {
|
||||||
|
csEvent.setAmplitude(Double.parseDouble(param.getData().toString()));
|
||||||
|
}
|
||||||
|
if (Objects.equals(param.getName(),"Evt_Param_Phase")) {
|
||||||
|
csEvent.setPhase(param.getData().toString());
|
||||||
|
}
|
||||||
fields.put(param.getName(),param.getData());
|
fields.put(param.getName(),param.getData());
|
||||||
}
|
}
|
||||||
//只有治理型号的设备有监测位置
|
//只有治理型号的设备有监测位置
|
||||||
if (devModel) {
|
if (Objects.equals(DicDataEnum.CONNECT_DEV.getCode(),code)) {
|
||||||
if (appEventMessage.getMsg().getClDid() == 1) {
|
if (appEventMessage.getMsg().getClDid() == 1) {
|
||||||
fields.put("Evt_Param_Position","电网侧");
|
fields.put("Evt_Param_Position","电网侧");
|
||||||
csEvent.setLocation("grid");
|
csEvent.setLocation("grid");
|
||||||
@@ -162,49 +194,138 @@ public class EventServiceImpl implements IEventService {
|
|||||||
csEvent.setLocation("load");
|
csEvent.setLocation("load");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fixme 这边前置传递的应该是UTC时间,但是前置说是传递的北京时间,讨论了一下没太理解。这边暂时先这样处理,influx入库处理成北京时间,减去8小时。
|
String dropZone = eventAnalysisService.determineDropZone(String.valueOf(csEvent.getAmplitude()),String.valueOf(csEvent.getPersistTime()));
|
||||||
|
csEvent.setLandPoint(dropZone);
|
||||||
|
AppEventMessage.Param param = new AppEventMessage.Param();
|
||||||
|
param.setName("Evt_Param_DropZone");
|
||||||
|
param.setData(dropZone);
|
||||||
|
params.add(param);
|
||||||
|
//fixme 设备上送的是北京时间,时序数据库录入时 需要utc时间,减去8小时
|
||||||
Point point = influxDbUtils.pointBuilder(tableName, item.getDataTimeSec()-8*3600, TimeUnit.SECONDS, tags, fields);
|
Point point = influxDbUtils.pointBuilder(tableName, item.getDataTimeSec()-8*3600, TimeUnit.SECONDS, tags, fields);
|
||||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||||
batchPoints.point(point);
|
batchPoints.point(point);
|
||||||
records.add(batchPoints.lineProtocol());
|
records.add(batchPoints.lineProtocol());
|
||||||
}
|
}
|
||||||
|
|
||||||
list1.add(csEvent);
|
list1.add(csEvent);
|
||||||
//事件处理日志库
|
|
||||||
CsEventLogs csEventLogs = new CsEventLogs();
|
|
||||||
csEventLogs.setLineId(lineId);
|
|
||||||
csEventLogs.setDeviceId(po.getId());
|
|
||||||
csEventLogs.setStartTime(timeFormat(item.getDataTimeSec(),item.getDataTimeUSec()));
|
|
||||||
csEventLogs.setTag(item.getName());
|
|
||||||
csEventLogs.setStatus(1);
|
|
||||||
csEventLogs.setTime(LocalDateTime.now());
|
|
||||||
csEventLogsService.save(csEventLogs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//cs_event入库
|
|
||||||
if (CollectionUtil.isNotEmpty(list1)){
|
|
||||||
csEventService.saveBatch(list1);
|
|
||||||
//推送事件逻辑处理 && cs_event_user入库
|
|
||||||
for (AppEventMessage.DataArray item : dataArray) {
|
|
||||||
sendEventUtils.sendUser(1,item.getType(),po.getId(),item.getName(),eventTime,id,po.getNdid());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//evt_data入库
|
//evt_data入库
|
||||||
if (CollectionUtil.isNotEmpty(records)) {
|
if (CollectionUtil.isNotEmpty(records)) {
|
||||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, records);
|
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, records);
|
||||||
}
|
}
|
||||||
|
//cs_event入库
|
||||||
|
if (CollectionUtil.isNotEmpty(list1)){
|
||||||
|
csEventService.saveBatch(list1);
|
||||||
|
//同步数据到 r_mp_event_detail 只有暂态事件再同步
|
||||||
|
List<CsEventPO> filterList = list1.stream().filter(csEvent -> Objects.equals(csEvent.getType(), 0)).collect(Collectors.toList());
|
||||||
|
if (CollectionUtil.isNotEmpty(filterList)) {
|
||||||
|
filterList.forEach(this::insertEvent);
|
||||||
|
}
|
||||||
|
//异步推送事件逻辑处理 && cs_event_user入库
|
||||||
|
for (AppEventMessage.DataArray item : dataArray) {
|
||||||
|
double amplitude = 0.0;
|
||||||
|
double persistTime = 0.0;
|
||||||
|
String dropZone = null;
|
||||||
|
List<AppEventMessage.Param> params = item.getParam();
|
||||||
|
if (CollectionUtil.isNotEmpty(params)) {
|
||||||
|
for (AppEventMessage.Param param : params) {
|
||||||
|
if (Objects.equals(param.getName(),ZlConstant.EVT_PARAM_VVADEPTH)) {
|
||||||
|
amplitude = Double.parseDouble(String.format("%.2f", Double.parseDouble(param.getData().toString())));
|
||||||
|
}
|
||||||
|
if (Objects.equals(param.getName(),ZlConstant.EVT_PARAM_TM)) {
|
||||||
|
persistTime = Double.parseDouble(String.format("%.2f", Double.parseDouble(param.getData().toString())));
|
||||||
|
}
|
||||||
|
if (Objects.equals(param.getName(),"Evt_Param_DropZone")) {
|
||||||
|
dropZone = param.getData().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MsgSendParam msgSendParam = new MsgSendParam();
|
||||||
|
msgSendParam.setEventType(1);
|
||||||
|
msgSendParam.setType("2");
|
||||||
|
msgSendParam.setDevId(po.getId());
|
||||||
|
msgSendParam.setEventName(item.getName());
|
||||||
|
msgSendParam.setEventTime(eventTime);
|
||||||
|
msgSendParam.setId(id);
|
||||||
|
msgSendParam.setNDid(po.getNdid());
|
||||||
|
msgSendParam.setAmplitude(amplitude);
|
||||||
|
msgSendParam.setPersistTime(persistTime);
|
||||||
|
msgSendParam.setDropZone(dropZone);
|
||||||
|
// appNotificationService.sendAppNotification(1, item.getType(), po.getId(), item.getName(), eventTime, id, po.getNdid(),amplitude,persistTime,dropZone);
|
||||||
|
msgSendFeignClient.appMsgSend(msgSendParam);
|
||||||
|
//如果是暂降事件,则异步发送短信
|
||||||
|
if (Objects.equals(item.getName(), "Evt_Sys_DipStr")) {
|
||||||
|
MsgSendParam msgSendParam2 = new MsgSendParam();
|
||||||
|
msgSendParam2.setDevId(po.getId());
|
||||||
|
msgSendParam2.setEventTime(eventTime);
|
||||||
|
msgSendParam2.setAmplitude(amplitude);
|
||||||
|
msgSendParam2.setPersistTime(persistTime);
|
||||||
|
msgSendParam2.setDropZone(dropZone);
|
||||||
|
msgSendFeignClient.smsMsgSend(msgSendParam2);
|
||||||
|
// smsNotificationService.sendSmsForDipEvent(po.getId(), eventTime,amplitude,persistTime,dropZone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CsEventLogs csEventLogs = new CsEventLogs();
|
log.error("事件入库异常:{}",e.getMessage());
|
||||||
csEventLogs.setLineId(lineId);
|
|
||||||
csEventLogs.setDeviceId(po.getId());
|
|
||||||
csEventLogs.setStartTime(eventTime);
|
|
||||||
csEventLogs.setTag(tag);
|
|
||||||
csEventLogs.setStatus(0);
|
|
||||||
csEventLogs.setTime(LocalDateTime.now());
|
|
||||||
csEventLogs.setRemark(e.getMessage());
|
|
||||||
csEventLogsService.save(csEventLogs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void insertEvent(CsEventPO item) {
|
||||||
|
RmpEventDetailPO rmpEventDetailPo = new RmpEventDetailPO();
|
||||||
|
rmpEventDetailPo.setEventId(item.getId());
|
||||||
|
rmpEventDetailPo.setMeasurementPointId(item.getLineId());
|
||||||
|
rmpEventDetailPo.setStartTime(item.getStartTime());
|
||||||
|
rmpEventDetailPo.setEventType(getEventType(item.getTag()));
|
||||||
|
rmpEventDetailPo.setFeatureAmplitude(item.getAmplitude());
|
||||||
|
rmpEventDetailPo.setDuration(item.getPersistTime());
|
||||||
|
rmpEventDetailPo.setEventDescribe(getTag(item.getTag()));
|
||||||
|
rmpEventDetailPo.setDealFlag(0);
|
||||||
|
rmpEventDetailPo.setFileFlag(0);
|
||||||
|
rmpEventDetailPo.setPhase(item.getPhase());
|
||||||
|
wlRmpEventDetailMapper.insert(rmpEventDetailPo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEventType(String tag) {
|
||||||
|
switch (tag) {
|
||||||
|
case "Evt_Sys_DipStr":
|
||||||
|
DictData dip = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
|
||||||
|
tag = dip.getId();
|
||||||
|
break;
|
||||||
|
case "Evt_Sys_SwlStr":
|
||||||
|
DictData rise = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_RISE.getCode()).getData();
|
||||||
|
tag = rise.getId();
|
||||||
|
break;
|
||||||
|
case "Evt_Sys_IntrStr":
|
||||||
|
DictData interruptions = dicDataFeignClient.getDicDataByCode(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getData();
|
||||||
|
tag = interruptions.getId();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
tag = "Un_Know";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTag(String tag) {
|
||||||
|
switch (tag) {
|
||||||
|
case "Evt_Sys_DipStr":
|
||||||
|
tag = DicDataEnum.VOLTAGE_DIP.getCode();
|
||||||
|
break;
|
||||||
|
case "Evt_Sys_SwlStr":
|
||||||
|
tag = DicDataEnum.VOLTAGE_RISE.getCode();
|
||||||
|
break;
|
||||||
|
case "Evt_Sys_IntrStr":
|
||||||
|
tag = DicDataEnum.SHORT_INTERRUPTIONS.getCode();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
tag = "Un_Know";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void getPortableData(AppEventMessage appEventMessage) {
|
public void getPortableData(AppEventMessage appEventMessage) {
|
||||||
@@ -348,31 +469,6 @@ public class EventServiceImpl implements IEventService {
|
|||||||
return Objects.isNull(result)?null:result;
|
return Objects.isNull(result)?null:result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 缓存监测点相关信息
|
|
||||||
*/
|
|
||||||
public void lineInfo(String id) {
|
|
||||||
Map<Integer,String> map = new HashMap<>();
|
|
||||||
List<CsLinePO> lineList = csLineFeignClient.findByNdid(id).getData();
|
|
||||||
if (CollectionUtil.isEmpty(lineList)){
|
|
||||||
throw new BusinessException(StatResponseEnum.LINE_NULL);
|
|
||||||
}
|
|
||||||
for (CsLinePO item : lineList) {
|
|
||||||
DictData dictData = dicDataFeignClient.getDicDataById(item.getPosition()).getData();
|
|
||||||
if (Objects.isNull(dictData)){
|
|
||||||
throw new BusinessException(StatResponseEnum.DICT_NULL);
|
|
||||||
}
|
|
||||||
if (Objects.equals(dictData.getCode(), DicDataEnum.OUTPUT_SIDE.getCode())){
|
|
||||||
map.put(0,item.getLineId());
|
|
||||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.GRID_SIDE.getCode())){
|
|
||||||
map.put(1,item.getLineId());
|
|
||||||
} else if (Objects.equals(dictData.getCode(), DicDataEnum.LOAD_SIDE.getCode())){
|
|
||||||
map.put(2,item.getLineId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
redisUtil.saveByKeyWithExpire(AppRedisKey.LINE_POSITION+id,map,30L);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存字典和influxDB表关系
|
* 缓存字典和influxDB表关系
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.njcn.zlevent.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.text.StrPool;
|
import cn.hutool.core.text.StrPool;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||||
@@ -12,32 +13,32 @@ import com.njcn.access.enums.AccessResponseEnum;
|
|||||||
import com.njcn.access.enums.TypeEnum;
|
import com.njcn.access.enums.TypeEnum;
|
||||||
import com.njcn.access.pojo.dto.ReqAndResDto;
|
import com.njcn.access.pojo.dto.ReqAndResDto;
|
||||||
import com.njcn.access.pojo.dto.file.FileDto;
|
import com.njcn.access.pojo.dto.file.FileDto;
|
||||||
import com.njcn.access.utils.CRC32Utils;
|
import com.njcn.access.utils.*;
|
||||||
import com.njcn.access.utils.ChannelObjectUtil;
|
import com.njcn.advance.api.EventCauseFeignClient;
|
||||||
import com.njcn.access.utils.FileCommonUtils;
|
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||||
import com.njcn.access.utils.MqttUtil;
|
|
||||||
import com.njcn.common.config.GeneralInfo;
|
import com.njcn.common.config.GeneralInfo;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.csdevice.api.DeviceFtpFeignClient;
|
import com.njcn.csdevice.api.DeviceFtpFeignClient;
|
||||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||||
import com.njcn.csdevice.api.PortableOffLogFeignClient;
|
import com.njcn.csdevice.api.PortableOffLogFeignClient;
|
||||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||||
|
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||||
import com.njcn.csharmonic.api.WavePicFeignClient;
|
import com.njcn.csharmonic.api.WavePicFeignClient;
|
||||||
import com.njcn.csharmonic.enums.CsHarmonicResponseEnum;
|
import com.njcn.csharmonic.enums.CsHarmonicResponseEnum;
|
||||||
import com.njcn.csharmonic.pojo.dto.DownloadMakeUpDto;
|
import com.njcn.csharmonic.pojo.dto.DownloadMakeUpDto;
|
||||||
|
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||||
|
import com.njcn.middle.rocket.domain.BaseMessage;
|
||||||
import com.njcn.mq.message.AppFileMessage;
|
import com.njcn.mq.message.AppFileMessage;
|
||||||
import com.njcn.oss.constant.GeneralConstant;
|
import com.njcn.oss.constant.GeneralConstant;
|
||||||
import com.njcn.oss.constant.OssPath;
|
import com.njcn.oss.constant.OssPath;
|
||||||
import com.njcn.oss.utils.FileStorageUtil;
|
import com.njcn.oss.utils.FileStorageUtil;
|
||||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||||
import com.njcn.redis.utils.RedisUtil;
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
import com.njcn.user.api.UserFeignClient;
|
|
||||||
import com.njcn.zlevent.param.CsEventParam;
|
import com.njcn.zlevent.param.CsEventParam;
|
||||||
import com.njcn.zlevent.pojo.dto.FileInfoDto;
|
import com.njcn.zlevent.pojo.dto.*;
|
||||||
import com.njcn.zlevent.pojo.dto.FileStreamDto;
|
|
||||||
import com.njcn.zlevent.pojo.dto.WaveTimeDto;
|
|
||||||
import com.njcn.zlevent.pojo.po.CsEventFileLogs;
|
import com.njcn.zlevent.pojo.po.CsEventFileLogs;
|
||||||
import com.njcn.zlevent.pojo.po.CsWave;
|
import com.njcn.zlevent.pojo.po.CsWave;
|
||||||
|
import com.njcn.zlevent.producer.CommonProducer;
|
||||||
import com.njcn.zlevent.service.ICsEventFileLogsService;
|
import com.njcn.zlevent.service.ICsEventFileLogsService;
|
||||||
import com.njcn.zlevent.service.ICsEventService;
|
import com.njcn.zlevent.service.ICsEventService;
|
||||||
import com.njcn.zlevent.service.ICsWaveService;
|
import com.njcn.zlevent.service.ICsWaveService;
|
||||||
@@ -47,12 +48,16 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sf.json.JSONObject;
|
import net.sf.json.JSONObject;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类的介绍:
|
* 类的介绍:
|
||||||
@@ -83,18 +88,24 @@ public class FileServiceImpl implements IFileService {
|
|||||||
private final FileCommonUtils fileCommonUtils;
|
private final FileCommonUtils fileCommonUtils;
|
||||||
private final DeviceFtpFeignClient deviceFtpFeignClient;
|
private final DeviceFtpFeignClient deviceFtpFeignClient;
|
||||||
private final PortableOffLogFeignClient portableOffLogFeignClient;
|
private final PortableOffLogFeignClient portableOffLogFeignClient;
|
||||||
|
private final EventCauseFeignClient eventCauseFeignClient;
|
||||||
|
|
||||||
|
private final CommonProducer commonProducer;
|
||||||
|
private final SendMessageUtil sendMessageUtil;
|
||||||
|
public final static String UPLOAD_PATH = "upload";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void analysisFileInfo(AppFileMessage appFileMessage) {
|
public void analysisFileInfo(AppFileMessage appFileMessage) {
|
||||||
if (Objects.equals(appFileMessage.getCode(), AccessEnum.SUCCESS.getCode())){
|
if (Objects.equals(appFileMessage.getCode(), AccessEnum.SUCCESS.getCode())) {
|
||||||
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
|
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
|
||||||
int range = 51200;
|
int range = 51200;
|
||||||
String fileName = appFileMessage.getMsg().getFileInfo().getName();
|
String fileName = appFileMessage.getMsg().getFileInfo().getName();
|
||||||
//缓存文件信息用于文件流拼接
|
//缓存文件信息用于文件流拼接
|
||||||
FileInfoDto fileInfoDto = new FileInfoDto();
|
FileInfoDto fileInfoDto = new FileInfoDto();
|
||||||
List<WaveTimeDto> list = channelObjectUtil.objectToList(redisUtil.getObjectByKey("eventFile:" + appFileMessage.getId()),WaveTimeDto.class);
|
List<WaveTimeDto> list = channelObjectUtil.objectToList(redisUtil.getObjectByKey("eventFile:" + appFileMessage.getId()), WaveTimeDto.class);
|
||||||
if (CollectionUtil.isNotEmpty(list)) {
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
WaveTimeDto waveTimeDto = channelObjectUtil.objectToList(redisUtil.getObjectByKey("eventFile:" + appFileMessage.getId()),WaveTimeDto.class).get(0);
|
WaveTimeDto waveTimeDto = channelObjectUtil.objectToList(redisUtil.getObjectByKey("eventFile:" + appFileMessage.getId()), WaveTimeDto.class).get(0);
|
||||||
fileInfoDto.setStartTime(waveTimeDto.getStartTime());
|
fileInfoDto.setStartTime(waveTimeDto.getStartTime());
|
||||||
fileInfoDto.setEndTime(waveTimeDto.getEndTime());
|
fileInfoDto.setEndTime(waveTimeDto.getEndTime());
|
||||||
fileInfoDto.setDeviceId(waveTimeDto.getDeviceId());
|
fileInfoDto.setDeviceId(waveTimeDto.getDeviceId());
|
||||||
@@ -124,14 +135,14 @@ public class FileServiceImpl implements IFileService {
|
|||||||
mid = (Integer) object;
|
mid = (Integer) object;
|
||||||
}
|
}
|
||||||
//请求当前文件的数据
|
//请求当前文件的数据
|
||||||
askFileStream(appFileMessage.getId(),mid,fileName,-1,range);
|
askFileStream(appFileMessage.getId(), mid, fileName, -1, range);
|
||||||
redisUtil.saveByKey(AppRedisKey.RMQ_FILE_CONSUME_KEY.concat(fileInfoDto.getName()), fileInfoDto);
|
redisUtil.saveByKey(AppRedisKey.RMQ_FILE_CONSUME_KEY.concat(fileInfoDto.getName()), fileInfoDto);
|
||||||
redisUtil.delete(AppRedisKey.TIME+fileName);
|
redisUtil.delete(AppRedisKey.TIME + fileName);
|
||||||
mid = mid + 1;
|
mid = mid + 1;
|
||||||
if (mid > 10000) {
|
if (mid > 10000) {
|
||||||
mid = 1;
|
mid = 1;
|
||||||
}
|
}
|
||||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + appFileMessage.getId(),mid);
|
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + appFileMessage.getId(), mid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new BusinessException(AccessResponseEnum.RESPONSE_ERROR);
|
throw new BusinessException(AccessResponseEnum.RESPONSE_ERROR);
|
||||||
@@ -162,16 +173,16 @@ public class FileServiceImpl implements IFileService {
|
|||||||
File lsFile = new File(generalInfo.getBusinessTempPath());
|
File lsFile = new File(generalInfo.getBusinessTempPath());
|
||||||
//如果文件夹不存在则创建
|
//如果文件夹不存在则创建
|
||||||
if (!lsFile.exists() && !lsFile.isDirectory()) {
|
if (!lsFile.exists() && !lsFile.isDirectory()) {
|
||||||
lsFile .mkdirs();
|
lsFile.mkdirs();
|
||||||
}
|
}
|
||||||
//获取缓存的文件信息
|
//获取缓存的文件信息
|
||||||
Object fileInfo = redisUtil.getObjectByKey(AppRedisKey.RMQ_FILE_CONSUME_KEY.concat(fileName));
|
Object fileInfo = redisUtil.getObjectByKey(AppRedisKey.RMQ_FILE_CONSUME_KEY.concat(fileName));
|
||||||
FileInfoDto fileInfoDto = JSON.parseObject(JSON.toJSONString(fileInfo), FileInfoDto.class);
|
FileInfoDto fileInfoDto = JSON.parseObject(JSON.toJSONString(fileInfo), FileInfoDto.class);
|
||||||
if (Objects.isNull(fileInfoDto)) {
|
if (Objects.isNull(fileInfoDto)) {
|
||||||
String fileCheck = redisUtil.getObjectByKey("fileCheck"+appFileMessage.getId()+fileName).toString();
|
String fileCheck = redisUtil.getObjectByKey("fileCheck" + appFileMessage.getId() + fileName).toString();
|
||||||
if (appFileMessage.getMsg().getFrameTotal() == 1) {
|
if (appFileMessage.getMsg().getFrameTotal() == 1) {
|
||||||
//解析文件入库
|
//解析文件入库
|
||||||
filePath = fileStream(1,null,appFileMessage.getMsg().getData(),fileName,appFileMessage.getId(),fileCheck,"download");
|
filePath = fileStream(1, null, appFileMessage.getMsg().getData(), fileName, appFileMessage.getId(), fileCheck, "download");
|
||||||
csEventLogs.setStatus(1);
|
csEventLogs.setStatus(1);
|
||||||
csEventLogs.setRemark("当前文件1帧,全部收到,解析成功!");
|
csEventLogs.setRemark("当前文件1帧,全部收到,解析成功!");
|
||||||
csEventLogs.setNowStep(1);
|
csEventLogs.setNowStep(1);
|
||||||
@@ -189,29 +200,29 @@ public class FileServiceImpl implements IFileService {
|
|||||||
String key = AppRedisKey.MAKE_UP_FILES + appFileMessage.getId();
|
String key = AppRedisKey.MAKE_UP_FILES + appFileMessage.getId();
|
||||||
Object object = redisUtil.getObjectByKey(key);
|
Object object = redisUtil.getObjectByKey(key);
|
||||||
//清空redis缓存
|
//清空redis缓存
|
||||||
fileCommonUtils.cleanRedisData(appFileMessage.getId(),fileName);
|
fileCommonUtils.cleanRedisData(appFileMessage.getId(), fileName);
|
||||||
if (Objects.nonNull(object)) {
|
if (Objects.nonNull(object)) {
|
||||||
DownloadMakeUpDto dto = channelObjectUtil.objectToSingleObject(object, DownloadMakeUpDto.class);
|
DownloadMakeUpDto dto = channelObjectUtil.objectToSingleObject(object, DownloadMakeUpDto.class);
|
||||||
channelMakeUpFile(dto,appFileMessage.getId(),fileName,filePath,lsFileName);
|
channelMakeUpFile(dto, appFileMessage.getId(), fileName, filePath, lsFileName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//收到数据就刷新缓存值
|
//收到数据就刷新缓存值
|
||||||
redisUtil.saveByKeyWithExpire(AppRedisKey.FILE_DOWN_TIME.concat(appFileMessage.getMsg().getName()), null, 60L);
|
redisUtil.saveByKeyWithExpire(AppRedisKey.FILE_DOWN_TIME.concat(appFileMessage.getMsg().getName()), null, 60L);
|
||||||
Object object1 = redisUtil.getObjectByKey(AppRedisKey.FILE_PART.concat(fileName));
|
Object object1 = redisUtil.getObjectByKey(AppRedisKey.FILE_PART.concat(fileName));
|
||||||
if (Objects.isNull(object1)){
|
if (Objects.isNull(object1)) {
|
||||||
fileStreamDto.setTotal(appFileMessage.getMsg().getFrameTotal());
|
fileStreamDto.setTotal(appFileMessage.getMsg().getFrameTotal());
|
||||||
fileStreamDto.setNDid(appFileMessage.getId());
|
fileStreamDto.setNDid(appFileMessage.getId());
|
||||||
fileStreamDto.setFrameLen(appFileMessage.getMsg().getFrameLen());
|
fileStreamDto.setFrameLen(appFileMessage.getMsg().getFrameLen());
|
||||||
list.add(appFileMessage.getMsg().getFrameCurr());
|
list.add(appFileMessage.getMsg().getFrameCurr());
|
||||||
fileStreamDto.setList(list);
|
fileStreamDto.setList(list);
|
||||||
csEventLogs.setStatus(1);
|
csEventLogs.setStatus(1);
|
||||||
csEventLogs.setRemark("当前文件"+appFileMessage.getMsg().getFrameTotal()+"帧,这是第"+appFileMessage.getMsg().getFrameCurr()+"帧,记录成功!");
|
csEventLogs.setRemark("当前文件" + appFileMessage.getMsg().getFrameTotal() + "帧,这是第" + appFileMessage.getMsg().getFrameCurr() + "帧,记录成功!");
|
||||||
csEventLogs.setNowStep(appFileMessage.getMsg().getFrameCurr());
|
csEventLogs.setNowStep(appFileMessage.getMsg().getFrameCurr());
|
||||||
csEventLogs.setAllStep(appFileMessage.getMsg().getFrameTotal());
|
csEventLogs.setAllStep(appFileMessage.getMsg().getFrameTotal());
|
||||||
csEventLogs.setIsAll(0);
|
csEventLogs.setIsAll(0);
|
||||||
redisUtil.saveByKey(AppRedisKey.FILE_PART.concat(appFileMessage.getMsg().getName()), fileStreamDto);
|
redisUtil.saveByKey(AppRedisKey.FILE_PART.concat(appFileMessage.getMsg().getName()), fileStreamDto);
|
||||||
//将数据写入临时文件
|
//将数据写入临时文件
|
||||||
appendFile(lsFileName,appFileMessage.getMsg().getFrameCurr(),appFileMessage.getMsg().getData());
|
appendFile(lsFileName, appFileMessage.getMsg().getFrameCurr(), appFileMessage.getMsg().getData());
|
||||||
log.info("当前文件 {} 帧,这是第 {} 帧报文,记录成功", appFileMessage.getMsg().getFrameTotal(), appFileMessage.getMsg().getFrameCurr());
|
log.info("当前文件 {} 帧,这是第 {} 帧报文,记录成功", appFileMessage.getMsg().getFrameTotal(), appFileMessage.getMsg().getFrameCurr());
|
||||||
} else {
|
} else {
|
||||||
FileStreamDto dto = JSON.parseObject(JSON.toJSONString(object1), FileStreamDto.class);
|
FileStreamDto dto = JSON.parseObject(JSON.toJSONString(object1), FileStreamDto.class);
|
||||||
@@ -222,7 +233,7 @@ public class FileServiceImpl implements IFileService {
|
|||||||
Map<Integer, String> filePartMap = readFile(lsFileName);
|
Map<Integer, String> filePartMap = readFile(lsFileName);
|
||||||
filePartMap.put(appFileMessage.getMsg().getFrameCurr(), appFileMessage.getMsg().getData());
|
filePartMap.put(appFileMessage.getMsg().getFrameCurr(), appFileMessage.getMsg().getData());
|
||||||
//解析文件入库
|
//解析文件入库
|
||||||
filePath = fileStream(dto.getTotal(), filePartMap, null, fileName, appFileMessage.getId(),fileCheck,"download");
|
filePath = fileStream(dto.getTotal(), filePartMap, null, fileName, appFileMessage.getId(), fileCheck, "download");
|
||||||
csEventLogs.setStatus(1);
|
csEventLogs.setStatus(1);
|
||||||
csEventLogs.setRemark("当前文件" + appFileMessage.getMsg().getFrameTotal() + "帧,这是第" + appFileMessage.getMsg().getFrameCurr() + "帧,全部收到,解析成功!");
|
csEventLogs.setRemark("当前文件" + appFileMessage.getMsg().getFrameTotal() + "帧,这是第" + appFileMessage.getMsg().getFrameCurr() + "帧,全部收到,解析成功!");
|
||||||
csEventLogs.setNowStep(appFileMessage.getMsg().getFrameCurr());
|
csEventLogs.setNowStep(appFileMessage.getMsg().getFrameCurr());
|
||||||
@@ -238,10 +249,10 @@ public class FileServiceImpl implements IFileService {
|
|||||||
String key = AppRedisKey.MAKE_UP_FILES + appFileMessage.getId();
|
String key = AppRedisKey.MAKE_UP_FILES + appFileMessage.getId();
|
||||||
Object object = redisUtil.getObjectByKey(key);
|
Object object = redisUtil.getObjectByKey(key);
|
||||||
//清空redis缓存
|
//清空redis缓存
|
||||||
fileCommonUtils.cleanRedisData(appFileMessage.getId(),fileName);
|
fileCommonUtils.cleanRedisData(appFileMessage.getId(), fileName);
|
||||||
if (Objects.nonNull(object)) {
|
if (Objects.nonNull(object)) {
|
||||||
DownloadMakeUpDto dto2 = channelObjectUtil.objectToSingleObject(object, DownloadMakeUpDto.class);
|
DownloadMakeUpDto dto2 = channelObjectUtil.objectToSingleObject(object, DownloadMakeUpDto.class);
|
||||||
channelMakeUpFile(dto2,appFileMessage.getId(),fileName,filePath,lsFileName);
|
channelMakeUpFile(dto2, appFileMessage.getId(), fileName, filePath, lsFileName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
csEventLogs.setStatus(1);
|
csEventLogs.setStatus(1);
|
||||||
@@ -263,14 +274,14 @@ public class FileServiceImpl implements IFileService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String userIndex = redisUtil.getObjectByKey("fileDownUserId"+appFileMessage.getId()+appFileMessage.getMsg().getName()).toString();
|
String userIndex = redisUtil.getObjectByKey("fileDownUserId" + appFileMessage.getId() + appFileMessage.getMsg().getName()).toString();
|
||||||
//推送mqtt
|
//推送mqtt
|
||||||
String json = "{fileName:" + appFileMessage.getMsg().getName()
|
String json = "{fileName:" + appFileMessage.getMsg().getName()
|
||||||
+ ",allStep:" + appFileMessage.getMsg().getFrameTotal()
|
+ ",allStep:" + appFileMessage.getMsg().getFrameTotal()
|
||||||
+ ",nowStep:" + appFileMessage.getMsg().getFrameCurr()
|
+ ",nowStep:" + appFileMessage.getMsg().getFrameCurr()
|
||||||
+ ",userId:" + userIndex
|
+ ",userId:" + userIndex
|
||||||
+"}";
|
+"}";
|
||||||
publisher.send("/Web/Progress/" + appFileMessage.getId(), new Gson().toJson(json), 1, false);
|
publisher.send("/Web/Progress/" + appFileMessage.getId(), new Gson().toJson(json), 2, false);
|
||||||
if (!Objects.isNull(filePath)){
|
if (!Objects.isNull(filePath)){
|
||||||
redisUtil.saveByKeyWithExpire("downloadFilePath:" + appFileMessage.getId() + appFileMessage.getMsg().getName(),filePath,60L);
|
redisUtil.saveByKeyWithExpire("downloadFilePath:" + appFileMessage.getId() + appFileMessage.getMsg().getName(),filePath,60L);
|
||||||
}
|
}
|
||||||
@@ -280,44 +291,59 @@ public class FileServiceImpl implements IFileService {
|
|||||||
//2.缓存了判断收到的报文个数是否和总个数一致,一致则解析文件;不一致则更新缓存
|
//2.缓存了判断收到的报文个数是否和总个数一致,一致则解析文件;不一致则更新缓存
|
||||||
//3.超时判断: 30s未收到相关文件信息,核查文件个数,看丢失哪些帧,重新请求
|
//3.超时判断: 30s未收到相关文件信息,核查文件个数,看丢失哪些帧,重新请求
|
||||||
else {
|
else {
|
||||||
|
Object isWeb = redisUtil.getObjectByKey("isWeb:" + appFileMessage.getId());
|
||||||
redisUtil.saveByKey("handleEvent:" + appFileMessage.getId(),"doing");
|
redisUtil.saveByKey("handleEvent:" + appFileMessage.getId(),"doing");
|
||||||
if (appFileMessage.getMsg().getFrameTotal() == 1){
|
if (appFileMessage.getMsg().getFrameTotal() == 1){
|
||||||
//解析文件入库
|
//解析文件入库
|
||||||
filePath = fileStream(1,null,appFileMessage.getMsg().getData(),fileName,appFileMessage.getId(),fileInfoDto.getFileCheck(),"event");
|
filePath = fileStream(1, null, appFileMessage.getMsg().getData(), fileName, appFileMessage.getId(), fileInfoDto.getFileCheck(), "event");
|
||||||
csEventLogs.setStatus(1);
|
csEventLogs.setStatus(1);
|
||||||
csEventLogs.setRemark("当前文件1帧,全部收到,解析成功!");
|
csEventLogs.setRemark("当前文件1帧,全部收到,解析成功!");
|
||||||
csEventLogs.setNowStep(1);
|
csEventLogs.setNowStep(1);
|
||||||
csEventLogs.setAllStep(1);
|
csEventLogs.setAllStep(1);
|
||||||
csEventLogs.setIsAll(1);
|
csEventLogs.setIsAll(1);
|
||||||
//更新文件信息
|
if (Objects.isNull(isWeb)) {
|
||||||
csWaveService.updateCsWave(fileName);
|
//更新文件信息
|
||||||
//波形文件关联事件
|
csWaveService.updateCsWave(fileName);
|
||||||
filePath = filePath.replaceAll(GeneralConstant.CFG,"").replaceAll(GeneralConstant.DAT,"");
|
//波形文件关联事件
|
||||||
List<String> eventList = correlateEvents(fileInfoDto,filePath,fileName);
|
filePath = filePath.replaceAll(GeneralConstant.CFG,"").replaceAll(GeneralConstant.DAT,"");
|
||||||
//波形文件解析成图片
|
List<CsEventPO> eventList = correlateEvents(fileInfoDto,filePath,fileName);
|
||||||
if (CollectionUtil.isNotEmpty(eventList) && devModel){
|
if (CollectionUtil.isNotEmpty(eventList) && devModel){
|
||||||
eventList.forEach(wavePicFeignClient::getWavePics);
|
String finalFilePath = filePath;
|
||||||
|
eventList.forEach(item -> {
|
||||||
|
//波形文件解析成图片
|
||||||
|
wavePicFeignClient.getWavePics(item.getId());
|
||||||
|
//如果是暂降则计算暂降类型和暂降原因
|
||||||
|
if (Objects.equals(item.getTag(),"Evt_Sys_DipStr")) {
|
||||||
|
EventAnalysisDTO var1 = new EventAnalysisDTO();
|
||||||
|
var1.setWlFilePath(finalFilePath);
|
||||||
|
EventAnalysisDTO dto = eventCauseFeignClient.analysisCauseAndType(var1).getData();
|
||||||
|
csEventService.updateEventCauseAndType(item.getId(),dto.getCause(),dto.getType());
|
||||||
|
}
|
||||||
|
//同步更新r_mp_event_detail,将波形路径录入
|
||||||
|
wavePicFeignClient.updateEventById(item.getId());
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//解析完删除、处理缓存
|
//解析完删除、处理缓存
|
||||||
removeInfoUtils.deleteEventInfo(appFileMessage.getId(),fileName);
|
removeInfoUtils.deleteEventInfo(appFileMessage.getId(), fileName);
|
||||||
} else {
|
} else {
|
||||||
//收到数据就刷新缓存值
|
//收到数据就刷新缓存值
|
||||||
redisUtil.saveByKeyWithExpire(AppRedisKey.FILE_PART_TIME.concat(appFileMessage.getMsg().getName()), null, 60L);
|
redisUtil.saveByKeyWithExpire(AppRedisKey.FILE_PART_TIME.concat(appFileMessage.getMsg().getName()), null, 60L);
|
||||||
Object object1 = redisUtil.getObjectByKey(AppRedisKey.FILE_PART.concat(fileName));
|
Object object1 = redisUtil.getObjectByKey(AppRedisKey.FILE_PART.concat(fileName));
|
||||||
if (Objects.isNull(object1)){
|
if (Objects.isNull(object1)) {
|
||||||
fileStreamDto.setTotal(appFileMessage.getMsg().getFrameTotal());
|
fileStreamDto.setTotal(appFileMessage.getMsg().getFrameTotal());
|
||||||
fileStreamDto.setNDid(appFileMessage.getId());
|
fileStreamDto.setNDid(appFileMessage.getId());
|
||||||
fileStreamDto.setFrameLen(appFileMessage.getMsg().getFrameLen());
|
fileStreamDto.setFrameLen(appFileMessage.getMsg().getFrameLen());
|
||||||
list.add(appFileMessage.getMsg().getFrameCurr());
|
list.add(appFileMessage.getMsg().getFrameCurr());
|
||||||
fileStreamDto.setList(list);
|
fileStreamDto.setList(list);
|
||||||
csEventLogs.setStatus(1);
|
csEventLogs.setStatus(1);
|
||||||
csEventLogs.setRemark("当前文件"+appFileMessage.getMsg().getFrameTotal()+"帧,这是第"+appFileMessage.getMsg().getFrameCurr()+"帧,记录成功!");
|
csEventLogs.setRemark("当前文件" + appFileMessage.getMsg().getFrameTotal() + "帧,这是第" + appFileMessage.getMsg().getFrameCurr() + "帧,记录成功!");
|
||||||
csEventLogs.setNowStep(appFileMessage.getMsg().getFrameCurr());
|
csEventLogs.setNowStep(appFileMessage.getMsg().getFrameCurr());
|
||||||
csEventLogs.setAllStep(appFileMessage.getMsg().getFrameTotal());
|
csEventLogs.setAllStep(appFileMessage.getMsg().getFrameTotal());
|
||||||
csEventLogs.setIsAll(0);
|
csEventLogs.setIsAll(0);
|
||||||
redisUtil.saveByKey(AppRedisKey.FILE_PART.concat(appFileMessage.getMsg().getName()), fileStreamDto);
|
redisUtil.saveByKey(AppRedisKey.FILE_PART.concat(appFileMessage.getMsg().getName()), fileStreamDto);
|
||||||
//将数据写入临时文件
|
//将数据写入临时文件
|
||||||
appendFile(lsFileName,appFileMessage.getMsg().getFrameCurr(),appFileMessage.getMsg().getData());
|
appendFile(lsFileName, appFileMessage.getMsg().getFrameCurr(), appFileMessage.getMsg().getData());
|
||||||
log.info("当前文件 {} 帧,这是第 {} 帧报文,记录成功", appFileMessage.getMsg().getFrameTotal(), appFileMessage.getMsg().getFrameCurr());
|
log.info("当前文件 {} 帧,这是第 {} 帧报文,记录成功", appFileMessage.getMsg().getFrameTotal(), appFileMessage.getMsg().getFrameCurr());
|
||||||
} else {
|
} else {
|
||||||
FileStreamDto dto = JSON.parseObject(JSON.toJSONString(object1), FileStreamDto.class);
|
FileStreamDto dto = JSON.parseObject(JSON.toJSONString(object1), FileStreamDto.class);
|
||||||
@@ -328,26 +354,40 @@ public class FileServiceImpl implements IFileService {
|
|||||||
Map<Integer, String> filePartMap = readFile(lsFileName);
|
Map<Integer, String> filePartMap = readFile(lsFileName);
|
||||||
filePartMap.put(appFileMessage.getMsg().getFrameCurr(), appFileMessage.getMsg().getData());
|
filePartMap.put(appFileMessage.getMsg().getFrameCurr(), appFileMessage.getMsg().getData());
|
||||||
//解析文件
|
//解析文件
|
||||||
filePath = fileStream(appFileMessage.getMsg().getFrameTotal(), filePartMap, null, fileName, appFileMessage.getId(),fileInfoDto.getFileCheck(),"event");
|
filePath = fileStream(appFileMessage.getMsg().getFrameTotal(), filePartMap, null, fileName, appFileMessage.getId(), fileInfoDto.getFileCheck(), "event");
|
||||||
csEventLogs.setStatus(1);
|
csEventLogs.setStatus(1);
|
||||||
csEventLogs.setRemark("当前文件" + appFileMessage.getMsg().getFrameTotal() + "帧,这是第" + appFileMessage.getMsg().getFrameCurr() + "帧,全部收到,解析成功!");
|
csEventLogs.setRemark("当前文件" + appFileMessage.getMsg().getFrameTotal() + "帧,这是第" + appFileMessage.getMsg().getFrameCurr() + "帧,全部收到,解析成功!");
|
||||||
csEventLogs.setNowStep(appFileMessage.getMsg().getFrameCurr());
|
csEventLogs.setNowStep(appFileMessage.getMsg().getFrameCurr());
|
||||||
csEventLogs.setAllStep(appFileMessage.getMsg().getFrameTotal());
|
csEventLogs.setAllStep(appFileMessage.getMsg().getFrameTotal());
|
||||||
csEventLogs.setIsAll(1);
|
csEventLogs.setIsAll(1);
|
||||||
log.info("当前文件 {} 帧,这是第 {} 帧报文,全部收到,解析成功!", appFileMessage.getMsg().getFrameTotal(), appFileMessage.getMsg().getFrameCurr());
|
log.info("当前文件 {} 帧,这是第 {} 帧报文,全部收到,解析成功!", appFileMessage.getMsg().getFrameTotal(), appFileMessage.getMsg().getFrameCurr());
|
||||||
//修改文件信息
|
if (Objects.isNull(isWeb)) {
|
||||||
csWaveService.updateCsWave(fileName);
|
//修改文件信息
|
||||||
//波形文件关联事件
|
csWaveService.updateCsWave(fileName);
|
||||||
filePath = filePath.replaceAll(GeneralConstant.CFG, "").replaceAll(GeneralConstant.DAT, "");
|
//波形文件关联事件
|
||||||
List<String> eventList = correlateEvents(fileInfoDto, filePath, fileName);
|
filePath = filePath.replaceAll(GeneralConstant.CFG, "").replaceAll(GeneralConstant.DAT, "");
|
||||||
//波形文件解析成图片
|
List<CsEventPO> eventList = correlateEvents(fileInfoDto, filePath, fileName);
|
||||||
if (CollectionUtil.isNotEmpty(eventList) && devModel) {
|
if (CollectionUtil.isNotEmpty(eventList) && devModel){
|
||||||
eventList.forEach(wavePicFeignClient::getWavePics);
|
String finalFilePath = filePath;
|
||||||
|
eventList.forEach(item -> {
|
||||||
|
//波形文件解析成图片
|
||||||
|
wavePicFeignClient.getWavePics(item.getId());
|
||||||
|
//如果是暂降则计算暂降类型和暂降原因
|
||||||
|
if (Objects.equals(item.getTag(),"Evt_Sys_DipStr")) {
|
||||||
|
EventAnalysisDTO var1 = new EventAnalysisDTO();
|
||||||
|
var1.setWlFilePath(finalFilePath);
|
||||||
|
EventAnalysisDTO dto2 = eventCauseFeignClient.analysisCauseAndType(var1).getData();
|
||||||
|
csEventService.updateEventCauseAndType(item.getId(),dto2.getCause(),dto2.getType());
|
||||||
|
}
|
||||||
|
//同步更新r_mp_event_detail,将波形路径录入
|
||||||
|
wavePicFeignClient.updateEventById(item.getId());
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
redisUtil.delete(AppRedisKey.FILE_PART_TIME.concat(appFileMessage.getMsg().getName()));
|
redisUtil.delete(AppRedisKey.FILE_PART_TIME.concat(appFileMessage.getMsg().getName()));
|
||||||
redisUtil.delete(AppRedisKey.FILE_PART.concat(appFileMessage.getMsg().getName()));
|
redisUtil.delete(AppRedisKey.FILE_PART.concat(appFileMessage.getMsg().getName()));
|
||||||
//解析完删除、处理缓存
|
//解析完删除、处理缓存
|
||||||
removeInfoUtils.deleteEventInfo(appFileMessage.getId(),fileName);
|
removeInfoUtils.deleteEventInfo(appFileMessage.getId(), fileName);
|
||||||
//删除临时文件
|
//删除临时文件
|
||||||
File file = new File(lsFileName);
|
File file = new File(lsFileName);
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
@@ -380,7 +420,7 @@ public class FileServiceImpl implements IFileService {
|
|||||||
//记录日志
|
//记录日志
|
||||||
csEventLogsService.save(csEventLogs);
|
csEventLogsService.save(csEventLogs);
|
||||||
}
|
}
|
||||||
} catch (Exception e){
|
} catch (Exception e) {
|
||||||
csEventLogs.setStatus(0);
|
csEventLogs.setStatus(0);
|
||||||
csEventLogs.setRemark("文件解析失败,失败原因:" + e.getMessage());
|
csEventLogs.setRemark("文件解析失败,失败原因:" + e.getMessage());
|
||||||
csEventLogs.setCompleteTime(LocalDateTime.now());
|
csEventLogs.setCompleteTime(LocalDateTime.now());
|
||||||
@@ -394,9 +434,9 @@ public class FileServiceImpl implements IFileService {
|
|||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
//继续消费
|
//继续消费
|
||||||
removeInfoUtils.deleteEventInfo(appFileMessage.getId(),appFileMessage.getMsg().getName());
|
removeInfoUtils.deleteEventInfo(appFileMessage.getId(), appFileMessage.getMsg().getName());
|
||||||
//清空redis缓存
|
//清空redis缓存
|
||||||
fileCommonUtils.cleanRedisData(appFileMessage.getId(),fileName);
|
fileCommonUtils.cleanRedisData(appFileMessage.getId(), fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,27 +446,27 @@ public class FileServiceImpl implements IFileService {
|
|||||||
//判断客户端是否在线,在线再处理文件
|
//判断客户端是否在线,在线再处理文件
|
||||||
String clientName = "NJCN-" + nDid.substring(nDid.length() - 6);
|
String clientName = "NJCN-" + nDid.substring(nDid.length() - 6);
|
||||||
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
||||||
if (mqttClient){
|
if (mqttClient) {
|
||||||
String key = AppRedisKey.MAKE_UP_FILES + nDid;
|
String key = AppRedisKey.MAKE_UP_FILES + nDid;
|
||||||
Object object = redisUtil.getObjectByKey(key);
|
Object object = redisUtil.getObjectByKey(key);
|
||||||
if (Objects.nonNull(object)) {
|
if (Objects.nonNull(object)) {
|
||||||
DownloadMakeUpDto dto = channelObjectUtil.objectToSingleObject(object, DownloadMakeUpDto.class);
|
DownloadMakeUpDto dto = channelObjectUtil.objectToSingleObject(object, DownloadMakeUpDto.class);
|
||||||
if (CollectionUtil.isNotEmpty(dto.getFileList())){
|
if (CollectionUtil.isNotEmpty(dto.getFileList())) {
|
||||||
Object object1 = channelObjectUtil.getDeviceMid(nDid);
|
Object object1 = channelObjectUtil.getDeviceMid(nDid);
|
||||||
if (!Objects.isNull(object1)) {
|
if (!Objects.isNull(object1)) {
|
||||||
mid = (Integer) object1;
|
mid = (Integer) object1;
|
||||||
}
|
}
|
||||||
String file = dto.getFileList().get(0);
|
String file = dto.getFileList().get(0);
|
||||||
fileCommonUtils.askFileInfo(nDid,mid,file);
|
fileCommonUtils.askFileInfo(nDid, mid, file);
|
||||||
mid = mid + 1;
|
mid = mid + 1;
|
||||||
if (mid > 10000) {
|
if (mid > 10000) {
|
||||||
mid = 1;
|
mid = 1;
|
||||||
}
|
}
|
||||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,mid);
|
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid, mid);
|
||||||
Thread.sleep(10000);
|
Thread.sleep(10000);
|
||||||
String infoKey = AppRedisKey.PROJECT_INFO + nDid;
|
String infoKey = AppRedisKey.PROJECT_INFO + nDid;
|
||||||
FileDto.FileInfo info = channelObjectUtil.objectToSingleObject(redisUtil.getObjectByKey(infoKey), FileDto.FileInfo.class);
|
FileDto.FileInfo info = channelObjectUtil.objectToSingleObject(redisUtil.getObjectByKey(infoKey), FileDto.FileInfo.class);
|
||||||
deviceFtpFeignClient.downloadFile(nDid,file,info.getFileSize(),info.getFileCheck()).getData();
|
deviceFtpFeignClient.downloadFile(nDid, file, info.getFileSize(), info.getFileCheck()).getData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -438,21 +478,347 @@ public class FileServiceImpl implements IFileService {
|
|||||||
Object object = redisUtil.getObjectByKey(AppRedisKey.MAKE_UP_FILES + nDid);
|
Object object = redisUtil.getObjectByKey(AppRedisKey.MAKE_UP_FILES + nDid);
|
||||||
if (Objects.nonNull(object)) {
|
if (Objects.nonNull(object)) {
|
||||||
DownloadMakeUpDto dto = channelObjectUtil.objectToSingleObject(object, DownloadMakeUpDto.class);
|
DownloadMakeUpDto dto = channelObjectUtil.objectToSingleObject(object, DownloadMakeUpDto.class);
|
||||||
if (CollectionUtil.isNotEmpty(dto.getFileList())){
|
if (CollectionUtil.isNotEmpty(dto.getFileList())) {
|
||||||
String file = dto.getFileList().get(0);
|
String file = dto.getFileList().get(0);
|
||||||
fileCommonUtils.cleanRedisData(nDid,file);
|
fileCommonUtils.cleanRedisData(nDid, file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FileInfoResponseDTO.ResourceElement> listDir(String filePath, String devId) {
|
||||||
|
List<CsEquipmentDeliveryDTO> listHttpResult = equipmentFeignClient.queryDeviceById(Collections.singletonList(devId)).getData();
|
||||||
|
|
||||||
|
FileInfoRequestDTO requestDTO = new FileInfoRequestDTO();
|
||||||
|
requestDTO.setGuid(IdUtil.simpleUUID());
|
||||||
|
requestDTO.setFrontId(listHttpResult.get(0).getNodeId());
|
||||||
|
requestDTO.setNode(listHttpResult.get(0).getNodeProcess());
|
||||||
|
requestDTO.setDevId(devId);
|
||||||
|
|
||||||
|
FileInfoRequestDTO.Detail detail = new FileInfoRequestDTO.Detail();
|
||||||
|
detail.setType(Integer.parseInt(TypeEnum.READ_FILE_DIR.getCode()));
|
||||||
|
|
||||||
|
FileInfoRequestDTO.Msg msg = new FileInfoRequestDTO.Msg();
|
||||||
|
msg.setName(filePath);
|
||||||
|
detail.setMsg(msg);
|
||||||
|
|
||||||
|
requestDTO.setDetail(detail);
|
||||||
|
|
||||||
|
BaseMessage message = new BaseMessage();
|
||||||
|
message.setMessageBody(JSON.toJSONString(requestDTO));
|
||||||
|
|
||||||
|
// 使用 Redis 存储 guid 用于后续查询
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.COMMON_REQUEST + requestDTO.getGuid(), "pending", 120L);
|
||||||
|
|
||||||
|
// 发送
|
||||||
|
commonProducer.send(message, requestDTO.getFrontId());
|
||||||
|
//this.simulation1(requestDTO.getGuid());
|
||||||
|
|
||||||
|
// 轮询 Redis 等待响应
|
||||||
|
FileInfoResponseDTO responseDTO = JSON.parseObject(sendMessageUtil.waitForResponse(requestDTO.getGuid(), 10), FileInfoResponseDTO.class);
|
||||||
|
|
||||||
|
FileInfoResponseDTO.Detail detail1 = responseDTO.getDetail();
|
||||||
|
FileInfoResponseDTO.Msg msg1 = detail1.getMsg();
|
||||||
|
msg1.getDirInfo().forEach(resourceElement -> {
|
||||||
|
resourceElement.setPrjDataPath(StrUtil.SLASH.equals(filePath) ? resourceElement.getName() : filePath + StrUtil.SLASH + resourceElement.getName());
|
||||||
|
});
|
||||||
|
|
||||||
|
return msg1.getDirInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void simulation1(String guid) {
|
||||||
|
// 模拟异步处理,实际场景中应由消息队列或回调触发
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
// 模拟耗时操作,例如等待设备响应
|
||||||
|
try {
|
||||||
|
Thread.sleep(3000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
FileInfoResponseDTO message = new FileInfoResponseDTO();
|
||||||
|
List<FileInfoResponseDTO.ResourceElement> dirInfo = new ArrayList<>();
|
||||||
|
|
||||||
|
FileInfoResponseDTO.ResourceElement resourceElement1 = new FileInfoResponseDTO.ResourceElement();
|
||||||
|
resourceElement1.setName("/ram0");
|
||||||
|
resourceElement1.setType("dir");
|
||||||
|
resourceElement1.setSize(1);
|
||||||
|
dirInfo.add(resourceElement1);
|
||||||
|
|
||||||
|
FileInfoResponseDTO.ResourceElement resourceElement2 = new FileInfoResponseDTO.ResourceElement();
|
||||||
|
resourceElement2.setName("/etc");
|
||||||
|
resourceElement2.setType("dir");
|
||||||
|
resourceElement2.setSize(1);
|
||||||
|
dirInfo.add(resourceElement2);
|
||||||
|
|
||||||
|
FileInfoResponseDTO.ResourceElement resourceElement3 = new FileInfoResponseDTO.ResourceElement();
|
||||||
|
resourceElement3.setName("/sd0:1");
|
||||||
|
resourceElement3.setType("dir");
|
||||||
|
resourceElement3.setSize(1);
|
||||||
|
dirInfo.add(resourceElement3);
|
||||||
|
|
||||||
|
FileInfoResponseDTO.ResourceElement resourceElement4 = new FileInfoResponseDTO.ResourceElement();
|
||||||
|
resourceElement4.setName("1773986668375094.xls");
|
||||||
|
resourceElement4.setType("file");
|
||||||
|
resourceElement4.setSize(1000);
|
||||||
|
dirInfo.add(resourceElement4);
|
||||||
|
|
||||||
|
FileInfoResponseDTO.Detail detail = new FileInfoResponseDTO.Detail();
|
||||||
|
FileInfoResponseDTO.Msg msg = new FileInfoResponseDTO.Msg();
|
||||||
|
msg.setDirInfo(dirInfo);
|
||||||
|
detail.setMsg(msg);
|
||||||
|
detail.setCode(200);
|
||||||
|
detail.setType(4657);
|
||||||
|
detail.setMsg(msg);
|
||||||
|
|
||||||
|
message.setGuid(guid);
|
||||||
|
message.setFrontId("sdghsfdhfdhdfhdfghd234234534534");
|
||||||
|
message.setNode(1);
|
||||||
|
message.setDevMac("A0BC7B4A5D8A");
|
||||||
|
message.setDetail(detail);
|
||||||
|
|
||||||
|
|
||||||
|
BaseMessage baseMessage = new BaseMessage();
|
||||||
|
baseMessage.setSendTime(LocalDateTime.now());
|
||||||
|
baseMessage.setMessageBody(JSON.toJSONString(message));
|
||||||
|
commonProducer.send(baseMessage);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void simulation2(String guid) {
|
||||||
|
// 模拟异步处理,实际场景中应由消息队列或回调触发
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
// 模拟耗时操作,例如等待设备响应
|
||||||
|
try {
|
||||||
|
Thread.sleep(3000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
FileDownloadResponeDTO message = new FileDownloadResponeDTO();
|
||||||
|
message.setGuid(guid);
|
||||||
|
message.setFrontId("sdghsfdhfdhdfhdfghd234234534534");
|
||||||
|
message.setNode(1);
|
||||||
|
message.setDevMac("A0BC7B4A5D8A");
|
||||||
|
|
||||||
|
FileDownloadResponeDTO.Detail detail = new FileDownloadResponeDTO.Detail();
|
||||||
|
detail.setType(Integer.parseInt(TypeEnum.FILE_DOWNLOAD.getCode()));
|
||||||
|
FileDownloadResponeDTO.Msg msg = new FileDownloadResponeDTO.Msg();
|
||||||
|
msg.setName("a.txt");
|
||||||
|
msg.setRemoteName("https://www.jswsrc.com.cn/data/upload/ueditor/file/20260320/1773986668375094.xls");
|
||||||
|
detail.setMsg(msg);
|
||||||
|
|
||||||
|
message.setDetail(detail);
|
||||||
|
|
||||||
|
BaseMessage baseMessage = new BaseMessage();
|
||||||
|
baseMessage.setSendTime(LocalDateTime.now());
|
||||||
|
baseMessage.setMessageBody(JSON.toJSONString(message));
|
||||||
|
commonProducer.send(baseMessage);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void downloadFileFromFront(String filePath, String devId, HttpServletResponse response) {
|
||||||
|
List<CsEquipmentDeliveryDTO> listHttpResult = equipmentFeignClient.queryDeviceById(Collections.singletonList(devId)).getData();
|
||||||
|
|
||||||
|
FileDownloadRequestDTO requestDTO = new FileDownloadRequestDTO();
|
||||||
|
requestDTO.setGuid(IdUtil.simpleUUID());
|
||||||
|
requestDTO.setFrontId(listHttpResult.get(0).getNodeId());
|
||||||
|
requestDTO.setNode(listHttpResult.get(0).getNodeProcess());
|
||||||
|
requestDTO.setDevId(devId);
|
||||||
|
|
||||||
|
FileDownloadRequestDTO.Detail detail = new FileDownloadRequestDTO.Detail();
|
||||||
|
detail.setType(Integer.parseInt(TypeEnum.FILE_DOWNLOAD.getCode()));
|
||||||
|
|
||||||
|
FileDownloadRequestDTO.Msg msg = new FileDownloadRequestDTO.Msg();
|
||||||
|
msg.setName(filePath);
|
||||||
|
detail.setMsg(msg);
|
||||||
|
|
||||||
|
requestDTO.setDetail(detail);
|
||||||
|
|
||||||
|
BaseMessage message = new BaseMessage();
|
||||||
|
message.setMessageBody(JSON.toJSONString(requestDTO));
|
||||||
|
|
||||||
|
// 使用 Redis 存储 guid 用于后续查询
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.COMMON_REQUEST + requestDTO.getGuid(), "pending", 120L);
|
||||||
|
|
||||||
|
// 发送
|
||||||
|
commonProducer.send(message, requestDTO.getFrontId());
|
||||||
|
//this.simulation2(requestDTO.getGuid());
|
||||||
|
|
||||||
|
// 轮询 Redis 等待响应
|
||||||
|
FileDownloadResponeDTO responseDTO = JSON.parseObject(sendMessageUtil.waitForResponse(requestDTO.getGuid(), 10), FileDownloadResponeDTO.class);
|
||||||
|
|
||||||
|
|
||||||
|
String remoteName = responseDTO.getDetail().getMsg().getRemoteName();
|
||||||
|
// String remoteName = "https://yunpan.360.cn/uploads/20230710/037ca576a421eb0bc23d717a7b076c5f.jpg";
|
||||||
|
// String remoteName = "/PQ_PQLD1_001429_20251010_143805_792.dat";
|
||||||
|
String fileName = remoteName.substring(remoteName.lastIndexOf(StrUtil.SLASH) + 1);
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8") + "\";filename*=UTF-8''" + URLEncoder.encode(fileName, "UTF-8"));
|
||||||
|
fileStorageUtil.downloadStream(response, remoteName);
|
||||||
|
// 下载完后删除文件
|
||||||
|
//fileStorageUtil.deleteFile(filePath);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BusinessException(AccessResponseEnum.FILE_DOWNLOAD_FAIL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean uploadFileToFront(MultipartFile file, String devId, String dirPath) {
|
||||||
|
dirPath = (dirPath.endsWith(StrUtil.SLASH) ? dirPath : dirPath + StrUtil.SLASH);
|
||||||
|
String remotePath = StrUtil.SLASH + UPLOAD_PATH + StrUtil.SLASH + devId + dirPath;
|
||||||
|
List<CsEquipmentDeliveryDTO> listHttpResult = equipmentFeignClient.queryDeviceById(Collections.singletonList(devId)).getData();
|
||||||
|
String frontId = listHttpResult.get(0).getNodeId();
|
||||||
|
try {
|
||||||
|
fileStorageUtil.uploadMultipart(file, remotePath, true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BusinessException(AccessResponseEnum.FILE_UPLOAD_FAIL);
|
||||||
|
}
|
||||||
|
// 告诉前置上传文件所在的路径、设备等信息
|
||||||
|
FileUploadRequestDTO requestDTO = new FileUploadRequestDTO();
|
||||||
|
requestDTO.setGuid(IdUtil.simpleUUID());
|
||||||
|
requestDTO.setFrontId(frontId);
|
||||||
|
requestDTO.setNode(listHttpResult.get(0).getNodeProcess());
|
||||||
|
requestDTO.setDevId(devId);
|
||||||
|
|
||||||
|
FileUploadRequestDTO.Detail detail = new FileUploadRequestDTO.Detail();
|
||||||
|
detail.setType(Integer.parseInt(TypeEnum.FILE_UPLOAD.getCode()));
|
||||||
|
|
||||||
|
FileUploadRequestDTO.Msg msg = new FileUploadRequestDTO.Msg();
|
||||||
|
msg.setName(remotePath + file.getOriginalFilename());
|
||||||
|
msg.setRemoteName(dirPath + file.getOriginalFilename());
|
||||||
|
detail.setMsg(msg);
|
||||||
|
|
||||||
|
requestDTO.setDetail(detail);
|
||||||
|
|
||||||
|
BaseMessage message = new BaseMessage();
|
||||||
|
message.setMessageBody(JSON.toJSONString(requestDTO));
|
||||||
|
|
||||||
|
// 使用 Redis 存储 guid 用于后续查询
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.COMMON_REQUEST + requestDTO.getGuid(), "pending", 120L);
|
||||||
|
|
||||||
|
// 发送
|
||||||
|
commonProducer.send(message, requestDTO.getFrontId());
|
||||||
|
|
||||||
|
// 轮询 Redis 等待响应
|
||||||
|
FileUploadResponeDTO responseDTO = JSON.parseObject(sendMessageUtil.waitForResponse(requestDTO.getGuid(), 10), FileUploadResponeDTO.class);
|
||||||
|
|
||||||
|
FileUploadResponeDTO.Detail detail1 = responseDTO.getDetail();
|
||||||
|
|
||||||
|
return detail1.getCode()==200;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mkdir(String filePath, String devId) {
|
||||||
|
List<CsEquipmentDeliveryDTO> listHttpResult = equipmentFeignClient.queryDeviceById(Collections.singletonList(devId)).getData();
|
||||||
|
String frontId = listHttpResult.get(0).getNodeId();
|
||||||
|
|
||||||
|
// 告诉前置上传文件所在的路径、设备等信息
|
||||||
|
MkdirRequestDTO requestDTO = new MkdirRequestDTO();
|
||||||
|
requestDTO.setGuid(IdUtil.simpleUUID());
|
||||||
|
requestDTO.setFrontId(frontId);
|
||||||
|
requestDTO.setNode(listHttpResult.get(0).getNodeProcess());
|
||||||
|
requestDTO.setDevId(devId);
|
||||||
|
|
||||||
|
MkdirRequestDTO.Detail detail = new MkdirRequestDTO.Detail();
|
||||||
|
detail.setType(Integer.parseInt(TypeEnum.MKDIR.getCode()));
|
||||||
|
|
||||||
|
MkdirRequestDTO.Msg msg = new MkdirRequestDTO.Msg();
|
||||||
|
msg.setName(filePath.endsWith(StrUtil.SLASH) ? filePath : filePath + StrUtil.SLASH);
|
||||||
|
detail.setMsg(msg);
|
||||||
|
|
||||||
|
requestDTO.setDetail(detail);
|
||||||
|
|
||||||
|
BaseMessage message = new BaseMessage();
|
||||||
|
message.setMessageBody(JSON.toJSONString(requestDTO));
|
||||||
|
|
||||||
|
// 使用 Redis 存储 guid 用于后续查询
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.COMMON_REQUEST + requestDTO.getGuid(), "pending", 120L);
|
||||||
|
|
||||||
|
// 发送
|
||||||
|
commonProducer.send(message, requestDTO.getFrontId());
|
||||||
|
|
||||||
|
// 轮询 Redis 等待响应
|
||||||
|
MkdirResponeDTO responseDTO = JSON.parseObject(sendMessageUtil.waitForResponse(requestDTO.getGuid(), 10), MkdirResponeDTO.class);
|
||||||
|
|
||||||
|
MkdirResponeDTO.Detail detail1 = responseDTO.getDetail();
|
||||||
|
|
||||||
|
return detail1.getCode()==200;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean delete(String filePath, String devId) {
|
||||||
|
boolean isDir = isDirectory(filePath);
|
||||||
|
|
||||||
|
List<CsEquipmentDeliveryDTO> listHttpResult = equipmentFeignClient.queryDeviceById(Collections.singletonList(devId)).getData();
|
||||||
|
String frontId = listHttpResult.get(0).getNodeId();
|
||||||
|
|
||||||
|
// 告诉前置上传文件所在的路径、设备等信息
|
||||||
|
FileOrDirDeleteRequestDTO requestDTO = new FileOrDirDeleteRequestDTO();
|
||||||
|
requestDTO.setGuid(IdUtil.simpleUUID());
|
||||||
|
requestDTO.setFrontId(frontId);
|
||||||
|
requestDTO.setNode(listHttpResult.get(0).getNodeProcess());
|
||||||
|
requestDTO.setDevId(devId);
|
||||||
|
|
||||||
|
FileOrDirDeleteRequestDTO.Detail detail = new FileOrDirDeleteRequestDTO.Detail();
|
||||||
|
detail.setType(Integer.parseInt(isDir ? TypeEnum.DIR_DELETE.getCode() : TypeEnum.FILE_DELETE.getCode()));
|
||||||
|
|
||||||
|
FileOrDirDeleteRequestDTO.Msg msg = new FileOrDirDeleteRequestDTO.Msg();
|
||||||
|
msg.setName(isDir ? (filePath.endsWith(StrUtil.SLASH) ? filePath : filePath + StrUtil.SLASH) : filePath);
|
||||||
|
detail.setMsg(msg);
|
||||||
|
|
||||||
|
requestDTO.setDetail(detail);
|
||||||
|
|
||||||
|
BaseMessage message = new BaseMessage();
|
||||||
|
message.setMessageBody(JSON.toJSONString(requestDTO));
|
||||||
|
|
||||||
|
// 使用 Redis 存储 guid 用于后续查询
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.COMMON_REQUEST + requestDTO.getGuid(), "pending", 120L);
|
||||||
|
|
||||||
|
// 发送
|
||||||
|
commonProducer.send(message, requestDTO.getFrontId());
|
||||||
|
|
||||||
|
// 轮询 Redis 等待响应
|
||||||
|
FileOrDirDeleteResponeDTO responseDTO = JSON.parseObject(sendMessageUtil.waitForResponse(requestDTO.getGuid(), 10), FileOrDirDeleteResponeDTO.class);
|
||||||
|
|
||||||
|
FileOrDirDeleteResponeDTO.Detail detail1 = responseDTO.getDetail();
|
||||||
|
|
||||||
|
return detail1.getCode()==200;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据文件扩展名判断是文件还是目录
|
||||||
|
* 规则:包含小数点的是文件,否则是目录
|
||||||
|
*
|
||||||
|
* @param filePath 文件路径
|
||||||
|
* @return true=目录,false=文件
|
||||||
|
*/
|
||||||
|
private boolean isDirectory(String filePath) {
|
||||||
|
String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
|
||||||
|
|
||||||
|
// 判断文件名中是否包含小数点(从第二个字符开始,排除隐藏文件的情况)
|
||||||
|
// 例如:.gitignore 是文件,不是目录
|
||||||
|
if (fileName.startsWith(".")) {
|
||||||
|
// 隐藏文件/目录:判断除第一个点外是否还有其他点
|
||||||
|
return !fileName.substring(1).contains(".");
|
||||||
|
} else {
|
||||||
|
// 普通文件/目录:直接判断是否包含点
|
||||||
|
return !fileName.contains(".");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理补召文件
|
* 处理补召文件
|
||||||
*/
|
*/
|
||||||
public void channelMakeUpFile(DownloadMakeUpDto dto, String nDid, String fileName, String oldPath, String lsFileName){
|
public void channelMakeUpFile(DownloadMakeUpDto dto, String nDid, String fileName, String oldPath, String lsFileName) {
|
||||||
try {
|
try {
|
||||||
//如果是补召文件,则将文件复制到补召目录下
|
//如果是补召文件,则将文件复制到补召目录下
|
||||||
moveFile(oldPath,getFilePath(fileName,nDid),lsFileName);
|
moveFile(oldPath, getFilePath(fileName, nDid), lsFileName);
|
||||||
//删除临时文件
|
//删除临时文件
|
||||||
File file = new File(lsFileName);
|
File file = new File(lsFileName);
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
@@ -463,9 +829,9 @@ public class FileServiceImpl implements IFileService {
|
|||||||
List<String> list = dto.getFileList();
|
List<String> list = dto.getFileList();
|
||||||
list.removeIf(item -> item.equals(fileName));
|
list.removeIf(item -> item.equals(fileName));
|
||||||
dto.setFileList(list);
|
dto.setFileList(list);
|
||||||
redisUtil.saveByKey(AppRedisKey.MAKE_UP_FILES + nDid,dto);
|
redisUtil.saveByKey(AppRedisKey.MAKE_UP_FILES + nDid, dto);
|
||||||
//判断是否还有缓存的文件
|
//判断是否还有缓存的文件
|
||||||
if (CollectionUtil.isNotEmpty(list)){
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
//推送进度条
|
//推送进度条
|
||||||
String json = "{allStep:" + dto.getAllStep() * 2 + ",nowStep:" + (dto.getAllStep() - list.size()) + "}";
|
String json = "{allStep:" + dto.getAllStep() * 2 + ",nowStep:" + (dto.getAllStep() - list.size()) + "}";
|
||||||
publisher.send("/dataOnlineRecruitment/Progress/" + dto.getLineId(), new Gson().toJson(json), 1, false);
|
publisher.send("/dataOnlineRecruitment/Progress/" + dto.getLineId(), new Gson().toJson(json), 1, false);
|
||||||
@@ -479,12 +845,12 @@ public class FileServiceImpl implements IFileService {
|
|||||||
String json = "{allStep:" + dto.getAllStep() * 2 + ",nowStep:" + dto.getAllStep() + "}";
|
String json = "{allStep:" + dto.getAllStep() * 2 + ",nowStep:" + dto.getAllStep() + "}";
|
||||||
publisher.send("/dataOnlineRecruitment/Progress/" + dto.getLineId(), new Gson().toJson(json), 1, false);
|
publisher.send("/dataOnlineRecruitment/Progress/" + dto.getLineId(), new Gson().toJson(json), 1, false);
|
||||||
//调用方法
|
//调用方法
|
||||||
portableOffLogFeignClient.dataOnlineRecruitment(dto.getDevId(),dto.getLineId(),dto.getEngineeringName());
|
portableOffLogFeignClient.dataOnlineRecruitment(dto.getDevId(), dto.getLineId(), dto.getEngineeringName());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String key = AppRedisKey.MAKE_UP_FILES + nDid;
|
String key = AppRedisKey.MAKE_UP_FILES + nDid;
|
||||||
redisUtil.delete(key);
|
redisUtil.delete(key);
|
||||||
fileCommonUtils.cleanRedisData(nDid,fileName);
|
fileCommonUtils.cleanRedisData(nDid, fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,20 +865,20 @@ public class FileServiceImpl implements IFileService {
|
|||||||
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||||
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_9.getCode()));
|
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_9.getCode()));
|
||||||
reqAndResParam.setExpire(-1);
|
reqAndResParam.setExpire(-1);
|
||||||
String json = "{Name:\""+fileName+"\",Offset:"+offset+",Len:"+len+"}";
|
String json = "{Name:\"" + fileName + "\",Offset:" + offset + ",Len:" + len + "}";
|
||||||
JSONObject jsonObject = JSONObject.fromObject(json);
|
JSONObject jsonObject = JSONObject.fromObject(json);
|
||||||
reqAndResParam.setMsg(jsonObject);
|
reqAndResParam.setMsg(jsonObject);
|
||||||
publisher.send("/Pfm/DevFileCmd/"+version+"/"+nDid,new Gson().toJson(reqAndResParam),1,false);
|
publisher.send("/Pfm/DevFileCmd/" + version + "/" + nDid, new Gson().toJson(reqAndResParam), 1, false);
|
||||||
log.info("请求文件流报文:" + new Gson().toJson(reqAndResParam));
|
log.info("请求文件流报文:" + new Gson().toJson(reqAndResParam));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组装文件
|
* 组装文件
|
||||||
*/
|
*/
|
||||||
public String fileStream(Integer number, Map<Integer,String> map, String data, String fileName, String nDid, String fileCheck,String type) {
|
public String fileStream(Integer number, Map<Integer, String> map, String data, String fileName, String nDid, String fileCheck, String type) {
|
||||||
String filePath;
|
String filePath;
|
||||||
if (number == 1){
|
if (number == 1) {
|
||||||
filePath = stream(true,data,nDid,fileName,null,fileCheck,type);
|
filePath = stream(true, data, nDid, fileName, null, fileCheck, type);
|
||||||
} else {
|
} else {
|
||||||
int lengthByte = 0;
|
int lengthByte = 0;
|
||||||
for (int i = 1; i <= number; i++) {
|
for (int i = 1; i <= number; i++) {
|
||||||
@@ -526,39 +892,39 @@ public class FileServiceImpl implements IFileService {
|
|||||||
System.arraycopy(byteArray, 0, allByte, countLength, byteArray.length);
|
System.arraycopy(byteArray, 0, allByte, countLength, byteArray.length);
|
||||||
countLength += byteArray.length;
|
countLength += byteArray.length;
|
||||||
}
|
}
|
||||||
filePath = stream(false,null,nDid,fileName,allByte,fileCheck,type);
|
filePath = stream(false, null, nDid, fileName, allByte, fileCheck, type);
|
||||||
}
|
}
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析存储文件信息
|
* 解析存储文件信息
|
||||||
*/
|
*/
|
||||||
public String stream(boolean bool, String stream, String folder, String fileName, byte[] bytes, String fileCheck, String type) {
|
public String stream(boolean bool, String stream, String folder, String fileName, byte[] bytes, String fileCheck, String type) {
|
||||||
String path;
|
String path;
|
||||||
byte[] byteArray = null;
|
byte[] byteArray = null;
|
||||||
//将文件后缀替换成大写
|
//将文件后缀替换成大写
|
||||||
String[] parts = fileName.split(StrUtil.SLASH);
|
String[] parts = fileName.split(StrUtil.SLASH);
|
||||||
fileName = parts[parts.length - 1].replaceAll(".cfg", GeneralConstant.CFG).replaceAll(".dat",GeneralConstant.DAT);
|
fileName = parts[parts.length - 1].replaceAll(".cfg", GeneralConstant.CFG).replaceAll(".dat", GeneralConstant.DAT);
|
||||||
//处理文件层级
|
//处理文件层级
|
||||||
folder = createPath(folder);
|
folder = createPath(folder);
|
||||||
//解析二进制流成byte数组
|
//解析二进制流成byte数组
|
||||||
if (bool){
|
if (bool) {
|
||||||
byteArray = Base64.getDecoder().decode(stream);
|
byteArray = Base64.getDecoder().decode(stream);
|
||||||
} else {
|
} else {
|
||||||
byteArray = bytes;
|
byteArray = bytes;
|
||||||
}
|
}
|
||||||
//文件校验
|
//文件校验
|
||||||
int crc = CRC32Utils.calculateCRC32(byteArray,byteArray.length,0xffffffff);
|
int crc = CRC32Utils.calculateCRC32(byteArray, byteArray.length, 0xffffffff);
|
||||||
String hexString = String.format("%08X", crc);
|
String hexString = String.format("%08X", crc);
|
||||||
if (!Objects.equals(hexString,fileCheck)) {
|
if (!Objects.equals(hexString, fileCheck)) {
|
||||||
throw new BusinessException(AccessResponseEnum.FILE_CHECK_ERROR);
|
throw new BusinessException(AccessResponseEnum.FILE_CHECK_ERROR);
|
||||||
}
|
}
|
||||||
InputStream inputStream = new ByteArrayInputStream(byteArray);
|
InputStream inputStream = new ByteArrayInputStream(byteArray);
|
||||||
if (Objects.equals(type,"download")) {
|
if (Objects.equals(type, "download")) {
|
||||||
path = fileStorageUtil.uploadStreamSpecifyName(inputStream, OssPath.DOWNLOAD_DIR + folder + StrUtil.SLASH,fileName);
|
path = fileStorageUtil.uploadStreamSpecifyName(inputStream, OssPath.DOWNLOAD_DIR + folder + StrUtil.SLASH, fileName);
|
||||||
} else {
|
} else {
|
||||||
path = fileStorageUtil.uploadStreamSpecifyName(inputStream, OssPath.WAVE_DIR + folder + StrUtil.SLASH,fileName);
|
path = fileStorageUtil.uploadStreamSpecifyName(inputStream, OssPath.WAVE_DIR + folder + StrUtil.SLASH, fileName);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
@@ -595,12 +961,12 @@ public class FileServiceImpl implements IFileService {
|
|||||||
/**
|
/**
|
||||||
* 波形文件关联事件
|
* 波形文件关联事件
|
||||||
*/
|
*/
|
||||||
public List<String> correlateEvents(FileInfoDto fileInfoDto, String path, String fileName) {
|
public List<CsEventPO> correlateEvents(FileInfoDto fileInfoDto, String path, String fileName) {
|
||||||
List<String> list = new ArrayList<>();
|
List<CsEventPO> list = new ArrayList<>();
|
||||||
String[] parts = fileName.split(StrUtil.SLASH);
|
String[] parts = fileName.split(StrUtil.SLASH);
|
||||||
fileName = parts[parts.length - 1].split("\\.")[0];
|
fileName = parts[parts.length - 1].split("\\.")[0];
|
||||||
boolean result = csWaveService.findCountByName(fileName);
|
boolean result = csWaveService.findCountByName(fileName);
|
||||||
if (result){
|
if (result) {
|
||||||
CsEventParam csEventParam = new CsEventParam();
|
CsEventParam csEventParam = new CsEventParam();
|
||||||
csEventParam.setLineId(fileInfoDto.getLineId());
|
csEventParam.setLineId(fileInfoDto.getLineId());
|
||||||
csEventParam.setDeviceId(fileInfoDto.getDeviceId());
|
csEventParam.setDeviceId(fileInfoDto.getDeviceId());
|
||||||
@@ -654,7 +1020,7 @@ public class FileServiceImpl implements IFileService {
|
|||||||
}
|
}
|
||||||
for (Map<Integer, String> map : mapList) {
|
for (Map<Integer, String> map : mapList) {
|
||||||
for (Map.Entry<Integer, String> entry : map.entrySet()) {
|
for (Map.Entry<Integer, String> entry : map.entrySet()) {
|
||||||
readMap.put(entry.getKey(),entry.getValue());
|
readMap.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return readMap;
|
return readMap;
|
||||||
@@ -668,6 +1034,7 @@ public class FileServiceImpl implements IFileService {
|
|||||||
public MyObjectOutputStream(OutputStream out) throws IOException {
|
public MyObjectOutputStream(OutputStream out) throws IOException {
|
||||||
super(out);
|
super(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void writeStreamHeader() throws IOException {
|
protected void writeStreamHeader() throws IOException {
|
||||||
//重写读取头部信息方法:不写入头部信息
|
//重写读取头部信息方法:不写入头部信息
|
||||||
@@ -679,6 +1046,7 @@ public class FileServiceImpl implements IFileService {
|
|||||||
public MyObjectInputStream(InputStream in) throws IOException {
|
public MyObjectInputStream(InputStream in) throws IOException {
|
||||||
super(in);
|
super(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void readStreamHeader() throws IOException {
|
protected void readStreamHeader() throws IOException {
|
||||||
//重写读取头部信息方法:什么也不做
|
//重写读取头部信息方法:什么也不做
|
||||||
@@ -706,7 +1074,7 @@ public class FileServiceImpl implements IFileService {
|
|||||||
File src = new File(lsPath);
|
File src = new File(lsPath);
|
||||||
src.getParentFile().mkdirs();
|
src.getParentFile().mkdirs();
|
||||||
InputStream is = Files.newInputStream(src.toPath());
|
InputStream is = Files.newInputStream(src.toPath());
|
||||||
fileStorageUtil.uploadStreamSpecifyName(is, OssPath.DEV_MAKE_UP_PATH,newPath);
|
fileStorageUtil.uploadStreamSpecifyName(is, OssPath.DEV_MAKE_UP_PATH, newPath);
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
fileOutputStream.close();
|
fileOutputStream.close();
|
||||||
is.close();
|
is.close();
|
||||||
|
|||||||
@@ -1,305 +0,0 @@
|
|||||||
package com.njcn.zlevent.utils;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
|
||||||
import com.njcn.access.pojo.dto.NoticeUserDto;
|
|
||||||
import com.njcn.access.utils.SendMessageUtil;
|
|
||||||
import com.njcn.csdevice.api.CsDeviceUserFeignClient;
|
|
||||||
import com.njcn.csdevice.api.CsLedgerFeignClient;
|
|
||||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
|
||||||
import com.njcn.csdevice.api.EventLogsFeignClient;
|
|
||||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
|
||||||
import com.njcn.csdevice.pojo.po.CsEventSendMsg;
|
|
||||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
|
||||||
import com.njcn.system.api.EpdFeignClient;
|
|
||||||
import com.njcn.user.api.AppInfoSetFeignClient;
|
|
||||||
import com.njcn.user.api.AppUserFeignClient;
|
|
||||||
import com.njcn.user.api.UserFeignClient;
|
|
||||||
import com.njcn.user.pojo.po.User;
|
|
||||||
import com.njcn.user.pojo.po.app.AppInfoSet;
|
|
||||||
import com.njcn.zlevent.service.ICsEventUserService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类的介绍:
|
|
||||||
*
|
|
||||||
* @author xuyang
|
|
||||||
* @version 1.0.0
|
|
||||||
* @createTime 2023/9/25 16:08
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
public class SendEventUtils {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private UserFeignClient userFeignClient;
|
|
||||||
@Resource
|
|
||||||
private AppUserFeignClient appUserFeignClient;
|
|
||||||
@Resource
|
|
||||||
private CsDeviceUserFeignClient csDeviceUserFeignClient;
|
|
||||||
@Resource
|
|
||||||
private AppInfoSetFeignClient appInfoSetFeignClient;
|
|
||||||
@Resource
|
|
||||||
private EventLogsFeignClient eventLogsFeignClient;
|
|
||||||
@Resource
|
|
||||||
private EpdFeignClient epdFeignClient;
|
|
||||||
@Resource
|
|
||||||
private ICsEventUserService csEventUserService;
|
|
||||||
@Resource
|
|
||||||
private CsLedgerFeignClient csLedgerFeignclient;
|
|
||||||
@Resource
|
|
||||||
private SendMessageUtil sendMessageUtil;
|
|
||||||
@Resource
|
|
||||||
private EquipmentFeignClient equipmentFeignClient;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 事件推送给相关用户
|
|
||||||
* @param eventType 事件类型 1:事件 2:告警
|
|
||||||
* @param type 等级 事件分为设备事件、暂态事件、稳态事件 告警分为Ⅰ级告警、Ⅱ级告警、Ⅲ级告警
|
|
||||||
* @param devId 设备id
|
|
||||||
* @param eventName 事件名称
|
|
||||||
* @param eventTime 事件发生事件
|
|
||||||
* @param id 事件id
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void sendUser(Integer eventType,String type,String devId, String eventName, LocalDateTime eventTime, String id, String nDid) {
|
|
||||||
int code;
|
|
||||||
List<User> users = new ArrayList<>();
|
|
||||||
List<String> eventUser;
|
|
||||||
List<String> devCodeList;
|
|
||||||
List<String> userList = new ArrayList<>();
|
|
||||||
List<CsEventSendMsg> csEventSendMsgList = new ArrayList<>();
|
|
||||||
NoticeUserDto noticeUserDto = new NoticeUserDto();
|
|
||||||
NoticeUserDto.Payload payload = new NoticeUserDto.Payload();
|
|
||||||
String content;
|
|
||||||
List<CsEventUserPO> result = new ArrayList<>();
|
|
||||||
//获取设备类型 true:治理设备 false:其他类型的设备
|
|
||||||
boolean devModel = equipmentFeignClient.judgeDevModel(nDid).getData();
|
|
||||||
if (devModel) {
|
|
||||||
//事件处理
|
|
||||||
if (eventType == 1){
|
|
||||||
eventName = epdFeignClient.findByName(eventName).getData().getShowName();
|
|
||||||
switch (type) {
|
|
||||||
case "1":
|
|
||||||
code = 2;
|
|
||||||
//设备自身事件 不推送给用户,推送给业务管理
|
|
||||||
eventUser = getEventUser(devId,false);
|
|
||||||
if (CollectionUtil.isNotEmpty(eventUser)) {
|
|
||||||
eventUser.forEach(item->{
|
|
||||||
CsEventUserPO csEventUser = new CsEventUserPO();
|
|
||||||
csEventUser.setUserId(item);
|
|
||||||
csEventUser.setStatus(0);
|
|
||||||
csEventUser.setEventId(id);
|
|
||||||
result.add(csEventUser);
|
|
||||||
});
|
|
||||||
|
|
||||||
users = getSendUser(eventUser,2);
|
|
||||||
if (CollectionUtil.isNotEmpty(users)){
|
|
||||||
for (User user : users){
|
|
||||||
userList.add(user.getDevCode());
|
|
||||||
}
|
|
||||||
noticeUserDto.setPushClientId(userList);
|
|
||||||
noticeUserDto.setTitle("设备事件");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "2":
|
|
||||||
code = 0;
|
|
||||||
//暂态事件
|
|
||||||
eventUser = getEventUser(devId,true);
|
|
||||||
if (CollectionUtil.isNotEmpty(eventUser)) {
|
|
||||||
eventUser.forEach(item->{
|
|
||||||
CsEventUserPO csEventUser = new CsEventUserPO();
|
|
||||||
csEventUser.setUserId(item);
|
|
||||||
csEventUser.setStatus(0);
|
|
||||||
csEventUser.setEventId(id);
|
|
||||||
result.add(csEventUser);
|
|
||||||
});
|
|
||||||
users = getSendUser(eventUser,0);
|
|
||||||
if (CollectionUtil.isNotEmpty(users)){
|
|
||||||
devCodeList = users.stream().map(User::getDevCode).distinct().collect(Collectors.toList());
|
|
||||||
noticeUserDto.setPushClientId(devCodeList);
|
|
||||||
noticeUserDto.setTitle("暂态事件");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "3":
|
|
||||||
code = 1;
|
|
||||||
//稳态事件
|
|
||||||
eventUser = getEventUser(devId,true);
|
|
||||||
if (CollectionUtil.isNotEmpty(eventUser)) {
|
|
||||||
eventUser.forEach(item->{
|
|
||||||
CsEventUserPO csEventUser = new CsEventUserPO();
|
|
||||||
csEventUser.setUserId(item);
|
|
||||||
csEventUser.setStatus(0);
|
|
||||||
csEventUser.setEventId(id);
|
|
||||||
result.add(csEventUser);
|
|
||||||
});
|
|
||||||
users = getSendUser(eventUser,1);
|
|
||||||
if (CollectionUtil.isNotEmpty(users)){
|
|
||||||
devCodeList = users.stream().map(User::getDevCode).distinct().collect(Collectors.toList());
|
|
||||||
noticeUserDto.setPushClientId(devCodeList);
|
|
||||||
noticeUserDto.setTitle("稳态事件");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
code = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//获取台账信息
|
|
||||||
DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(devId).getData();
|
|
||||||
content = devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName() + "于" + eventTime.format(DatePattern.NORM_DATETIME_MS_FORMATTER) + "发生" + eventName;
|
|
||||||
noticeUserDto.setContent(content);
|
|
||||||
payload.setType(code);
|
|
||||||
payload.setPath("/pages/message/message?type="+payload.getType());
|
|
||||||
noticeUserDto.setPayload(payload);
|
|
||||||
}
|
|
||||||
//告警处理
|
|
||||||
else if (eventType == 2){
|
|
||||||
switch (type) {
|
|
||||||
case "1":
|
|
||||||
//Ⅰ级告警 不推送给用户,推送给业务管理
|
|
||||||
eventUser = getEventUser(devId,false);
|
|
||||||
if (CollectionUtil.isNotEmpty(eventUser)) {
|
|
||||||
eventUser.forEach(item->{
|
|
||||||
CsEventUserPO csEventUser = new CsEventUserPO();
|
|
||||||
csEventUser.setUserId(item);
|
|
||||||
csEventUser.setStatus(0);
|
|
||||||
csEventUser.setEventId(id);
|
|
||||||
result.add(csEventUser);
|
|
||||||
});
|
|
||||||
users = getSendUser(eventUser,3);
|
|
||||||
if (CollectionUtil.isNotEmpty(users)){
|
|
||||||
eventName = epdFeignClient.findByName(eventName).getData().getShowName();
|
|
||||||
devCodeList = users.stream().map(User::getDevCode).distinct().collect(Collectors.toList());
|
|
||||||
noticeUserDto.setPushClientId(devCodeList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "2":
|
|
||||||
eventName = epdFeignClient.findByName(eventName).getData().getShowName();
|
|
||||||
case "3":
|
|
||||||
//Ⅱ、Ⅲ级告警推送相关用户及业务管理员
|
|
||||||
eventUser = getEventUser(devId,true);
|
|
||||||
if (CollectionUtil.isNotEmpty(eventUser)) {
|
|
||||||
eventUser.forEach(item->{
|
|
||||||
CsEventUserPO csEventUser = new CsEventUserPO();
|
|
||||||
csEventUser.setUserId(item);
|
|
||||||
csEventUser.setStatus(0);
|
|
||||||
csEventUser.setEventId(id);
|
|
||||||
result.add(csEventUser);
|
|
||||||
});
|
|
||||||
users = getSendUser(eventUser,3);
|
|
||||||
if (CollectionUtil.isNotEmpty(users)){
|
|
||||||
devCodeList = users.stream().map(User::getDevCode).distinct().collect(Collectors.toList());
|
|
||||||
noticeUserDto.setPushClientId(devCodeList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
noticeUserDto.setTitle("告警事件");
|
|
||||||
DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(devId).getData();
|
|
||||||
content = devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName() + "于" + eventTime.format(DatePattern.NORM_DATETIME_MS_FORMATTER) + "发生告警,告警信息:" + eventName;
|
|
||||||
noticeUserDto.setContent(content);
|
|
||||||
payload.setType(3);
|
|
||||||
payload.setPath("/pages/message/message?type="+payload.getType());
|
|
||||||
noticeUserDto.setPayload(payload);
|
|
||||||
}
|
|
||||||
if (CollectionUtil.isNotEmpty(noticeUserDto.getPushClientId())) {
|
|
||||||
List<String> filteredList = noticeUserDto.getPushClientId().stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.distinct()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (CollectionUtil.isNotEmpty(filteredList)) {
|
|
||||||
noticeUserDto.setPushClientId(filteredList);
|
|
||||||
sendMessageUtil.sendEventToUser(noticeUserDto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//记录推送日志
|
|
||||||
for (User item : users) {
|
|
||||||
CsEventSendMsg csEventSendMsg = new CsEventSendMsg();
|
|
||||||
csEventSendMsg.setUserId(item.getId());
|
|
||||||
csEventSendMsg.setEventId(id);
|
|
||||||
csEventSendMsg.setSendTime(LocalDateTime.now());
|
|
||||||
if (Objects.isNull(item.getDevCode())){
|
|
||||||
csEventSendMsg.setStatus(0);
|
|
||||||
csEventSendMsg.setRemark("用户设备识别码为空");
|
|
||||||
} else {
|
|
||||||
csEventSendMsg.setDevCode(item.getDevCode());
|
|
||||||
csEventSendMsg.setStatus(1);
|
|
||||||
}
|
|
||||||
csEventSendMsgList.add(csEventSendMsg);
|
|
||||||
}
|
|
||||||
eventLogsFeignClient.addLogs(csEventSendMsgList);
|
|
||||||
//事件用户关系入库
|
|
||||||
if (CollectionUtil.isNotEmpty(result)){
|
|
||||||
csEventUserService.saveBatch(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取所有需要推送的用户id
|
|
||||||
*/
|
|
||||||
public List<String> getEventUser(String devId,boolean isAdmin) {
|
|
||||||
List<User> adminUser = appUserFeignClient.getAdminInfo().getData();
|
|
||||||
List<String> adminList = adminUser.stream().map(User::getId).collect(Collectors.toList());
|
|
||||||
if (isAdmin) {
|
|
||||||
List<String> list = csDeviceUserFeignClient.findUserById(devId).getData();
|
|
||||||
adminList.addAll(list);
|
|
||||||
}
|
|
||||||
return adminList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取所有打开推送的用户信息
|
|
||||||
*/
|
|
||||||
public List<User> getSendUser(List<String> userList,Integer type) {
|
|
||||||
List<User> users = new ArrayList<>();
|
|
||||||
List<String> result = new ArrayList<>();
|
|
||||||
List<AppInfoSet> appInfoSet = appInfoSetFeignClient.getListById(userList).getData();
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case 0:
|
|
||||||
result = appInfoSet.stream()
|
|
||||||
.filter(person -> person.getEventInfo() == 1)
|
|
||||||
.map(AppInfoSet::getUserId).collect(Collectors.toList());
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
result = appInfoSet.stream()
|
|
||||||
.filter(person -> person.getHarmonicInfo() == 1)
|
|
||||||
.map(AppInfoSet::getUserId).collect(Collectors.toList());
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
result = appInfoSet.stream()
|
|
||||||
.filter(person -> person.getRunInfo() == 1)
|
|
||||||
.map(AppInfoSet::getUserId).collect(Collectors.toList());
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
result = appInfoSet.stream()
|
|
||||||
.filter(person -> person.getAlarmInfo() == 1)
|
|
||||||
.map(AppInfoSet::getUserId).collect(Collectors.toList());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (CollectionUtil.isNotEmpty(result)){
|
|
||||||
users = userFeignClient.appuserByIdList(result).getData();
|
|
||||||
}
|
|
||||||
return users;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.njcn.zlevent;
|
||||||
|
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-17
|
||||||
|
*/
|
||||||
|
@SpringBootTest
|
||||||
|
public class FileDownloadTest {
|
||||||
|
|
||||||
|
// @Resource
|
||||||
|
// private FileDownloadProducer fileDownloadProducer;
|
||||||
|
//
|
||||||
|
// @Test
|
||||||
|
// public void testSend() {
|
||||||
|
// BaseRequestDTO<FileDownloadRequestDTO> message = new BaseRequestDTO<>();
|
||||||
|
// message.setGuid(IdUtil.simpleUUID());
|
||||||
|
// message.setNode(1);
|
||||||
|
// message.setDevId("167456737637374567");
|
||||||
|
// message.setFrontId("dhdfhdfghd2342");
|
||||||
|
// // 设置 detail(重要!)
|
||||||
|
// BaseRequestDTO.Detail<FileDownloadRequestDTO> detail = new BaseRequestDTO.Detail<>();
|
||||||
|
// detail.setType(8498); // 设置类型
|
||||||
|
// FileDownloadRequestDTO fileDownloadRequestDTO = new FileDownloadRequestDTO();
|
||||||
|
// fileDownloadRequestDTO.setName("/etc/vol1_stat.txt");
|
||||||
|
// detail.setMsg(fileDownloadRequestDTO); // 设置消息体
|
||||||
|
// message.setDetail(detail);
|
||||||
|
// SendResult send = fileDownloadProducer.send(message);
|
||||||
|
// System.out.println(JSON.toJSON(send));
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -86,11 +86,12 @@ public class AppAutoDataConsumer extends EnhanceConsumerMessageHandler<AppAutoDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消费成功,缓存到redis72小时,避免重复消费
|
* 消费成功,缓存到redis 5分钟,避免重复消费
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void consumeSuccess(AppAutoDataMessage message) {
|
protected void consumeSuccess(AppAutoDataMessage message) {
|
||||||
redisUtil.saveByKeyWithExpire(AppRedisKey.RMQ_CONSUME_KEY.concat(message.getKey()), MessageStatus.SUCCESS, RedisKeyEnum.ROCKET_MQ_KEY.getTime());
|
// redisUtil.saveByKeyWithExpire(AppRedisKey.RMQ_CONSUME_KEY.concat(message.getKey()), MessageStatus.SUCCESS, RedisKeyEnum.ROCKET_MQ_KEY.getTime());
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.RMQ_CONSUME_KEY.concat(message.getKey()), MessageStatus.SUCCESS, 5 * 60L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -68,11 +68,12 @@ public class CldHeartConsumer extends EnhanceConsumerMessageHandler<CldHeartBeat
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消费成功,缓存到redis72小时,避免重复消费
|
* 消费成功,缓存到redis 5分钟,避免重复消费
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void consumeSuccess(CldHeartBeatMessage message) {
|
protected void consumeSuccess(CldHeartBeatMessage message) {
|
||||||
redisUtil.saveByKeyWithExpire(AppRedisKey.RMQ_CONSUME_KEY.concat(message.getKey()), MessageStatus.SUCCESS, RedisKeyEnum.ROCKET_MQ_KEY.getTime());
|
// redisUtil.saveByKeyWithExpire(AppRedisKey.RMQ_CONSUME_KEY.concat(message.getKey()), MessageStatus.SUCCESS, RedisKeyEnum.ROCKET_MQ_KEY.getTime());
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.RMQ_CONSUME_KEY.concat(message.getKey()), MessageStatus.SUCCESS, 5 * 60L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
package com.njcn.message.consumer;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.njcn.middle.rocket.constant.EnhanceMessageConstant;
|
||||||
|
import com.njcn.middle.rocket.handler.EnhanceConsumerMessageHandler;
|
||||||
|
import com.njcn.mq.constant.BusinessTopic;
|
||||||
|
import com.njcn.mq.constant.MessageStatus;
|
||||||
|
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||||
|
import com.njcn.redis.pojo.enums.RedisKeyEnum;
|
||||||
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
|
import com.njcn.system.api.RocketMqLogFeignClient;
|
||||||
|
import com.njcn.system.pojo.po.RocketmqMsgErrorLog;
|
||||||
|
import com.njcn.zlevent.pojo.dto.CommonBaseMessage;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||||
|
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-03-18
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RocketMQMessageListener(
|
||||||
|
topic = BusinessTopic.CLOUD_REPLY_TOPIC,
|
||||||
|
consumerGroup = BusinessTopic.CLOUD_REPLY_TOPIC,
|
||||||
|
consumeThreadNumber = 10,
|
||||||
|
enableMsgTrace = true
|
||||||
|
)
|
||||||
|
@Slf4j
|
||||||
|
public class CommonConsumer extends EnhanceConsumerMessageHandler<CommonBaseMessage> implements RocketMQListener<CommonBaseMessage> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RocketMqLogFeignClient rocketMqLogFeignClient;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleMessage(CommonBaseMessage message) throws Exception {
|
||||||
|
log.info("@@@@@处理Common信息");
|
||||||
|
System.out.println(JSON.toJSON(message));
|
||||||
|
String guid = message.getGuid();
|
||||||
|
|
||||||
|
// 将响应结果存入 Redis
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.COMMON_RESOPNSE + guid, JSON.toJSONString(message), 120L);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 通过redis分布式锁判断当前消息所处状态
|
||||||
|
* 1、null 查不到该key的数据,属于第一次消费,放行
|
||||||
|
* 2、fail 上次消息消费时发生异常,放行
|
||||||
|
* 3、being processed 正在处理,打回去
|
||||||
|
* 4、success 最近72小时消费成功,避免重复消费,打回去
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean filter(CommonBaseMessage message) {
|
||||||
|
String keyStatus = redisUtil.getStringByKey(AppRedisKey.RMQ_FILE_CONSUME_KEY.concat(message.getKey()));
|
||||||
|
if (Objects.isNull(keyStatus) || keyStatus.equalsIgnoreCase(MessageStatus.FAIL)) {
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.RMQ_FILE_CONSUME_KEY.concat(message.getKey()), MessageStatus.BEING_PROCESSED, 60L);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消费成功,缓存到redis72小时,避免重复消费
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void consumeSuccess(CommonBaseMessage message) {
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.RMQ_FILE_CONSUME_KEY.concat(message.getKey()), MessageStatus.SUCCESS, RedisKeyEnum.ROCKET_MQ_KEY.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发生异常时,进行错误信息入库保存
|
||||||
|
* 默认没有实现类,子类可以实现该方法,调用feign接口进行入库保存
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void saveExceptionMsgLog(CommonBaseMessage message, String identity, Exception exception) {
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.RMQ_FILE_CONSUME_KEY.concat(message.getKey()), MessageStatus.FAIL, RedisKeyEnum.ROCKET_MQ_KEY.getTime());
|
||||||
|
RocketmqMsgErrorLog rocketmqMsgErrorLog = new RocketmqMsgErrorLog();
|
||||||
|
rocketmqMsgErrorLog.setMsgKey(message.getKey());
|
||||||
|
rocketmqMsgErrorLog.setResource(message.getSource());
|
||||||
|
if (identity.equalsIgnoreCase(EnhanceMessageConstant.IDENTITY_SINGLE)) {
|
||||||
|
//数据库字段配置长度200,避免插入失败,大致分析异常原因
|
||||||
|
String exceptionMsg = exception.getMessage();
|
||||||
|
if (exceptionMsg.length() > 200) {
|
||||||
|
exceptionMsg = exceptionMsg.substring(0, 180);
|
||||||
|
}
|
||||||
|
rocketmqMsgErrorLog.setRecord(exceptionMsg);
|
||||||
|
//如果是当前消息重试的则略过
|
||||||
|
if (!message.getSource().startsWith(EnhanceMessageConstant.RETRY_PREFIX)) {
|
||||||
|
//单次消费异常
|
||||||
|
rocketMqLogFeignClient.add(rocketmqMsgErrorLog);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rocketmqMsgErrorLog.setRecord("重试消费" + super.getMaxRetryTimes() + "次,依旧消费失败。");
|
||||||
|
//重试N次后,依然消费异常
|
||||||
|
rocketMqLogFeignClient.add(rocketmqMsgErrorLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 处理失败后,是否重试
|
||||||
|
* 一般开启
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean isRetry() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 消费失败是否抛出异常,抛出异常后就不再消费了
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean throwException() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 调用父类handler处理消息的元信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onMessage(CommonBaseMessage message) {
|
||||||
|
super.dispatchMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
package com.njcn.message.consumer;
|
||||||
|
|
||||||
|
import com.njcn.access.api.CsHeartbeatFeignClient;
|
||||||
|
import com.njcn.middle.rocket.constant.EnhanceMessageConstant;
|
||||||
|
import com.njcn.middle.rocket.handler.EnhanceConsumerMessageHandler;
|
||||||
|
import com.njcn.mq.constant.BusinessTopic;
|
||||||
|
import com.njcn.mq.constant.MessageStatus;
|
||||||
|
import com.njcn.mq.message.HeartbeatTimeoutMessage;
|
||||||
|
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||||
|
import com.njcn.redis.pojo.enums.RedisKeyEnum;
|
||||||
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
|
import com.njcn.system.api.RocketMqLogFeignClient;
|
||||||
|
import com.njcn.system.pojo.po.RocketmqMsgErrorLog;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||||
|
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/8/11 15:32
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RocketMQMessageListener(
|
||||||
|
topic = BusinessTopic.HEARTBEAT_TIMEOUT_TOPIC,
|
||||||
|
consumerGroup = BusinessTopic.HEARTBEAT_TIMEOUT_TOPIC,
|
||||||
|
selectorExpression = BusinessTopic.HeartTag.APF_TAG,
|
||||||
|
consumeThreadNumber = 1,
|
||||||
|
enableMsgTrace = true
|
||||||
|
)
|
||||||
|
@Slf4j
|
||||||
|
public class HeartbeatTimeoutConsumer extends EnhanceConsumerMessageHandler<HeartbeatTimeoutMessage> implements RocketMQListener<HeartbeatTimeoutMessage> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
@Resource
|
||||||
|
private RocketMqLogFeignClient rocketMqLogFeignClient;
|
||||||
|
@Resource
|
||||||
|
private CsHeartbeatFeignClient csHeartbeatFeignClient;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleMessage(HeartbeatTimeoutMessage appFileMessage) {
|
||||||
|
csHeartbeatFeignClient.handleHeartbeat(appFileMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 通过redis分布式锁判断当前消息所处状态
|
||||||
|
* 1、null 查不到该key的数据,属于第一次消费,放行
|
||||||
|
* 2、fail 上次消息消费时发生异常,放行
|
||||||
|
* 3、being processed 正在处理,打回去
|
||||||
|
* 4、success 最近72小时消费成功,避免重复消费,打回去
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean filter(HeartbeatTimeoutMessage message) {
|
||||||
|
String keyStatus = redisUtil.getStringByKey(AppRedisKey.RMQ_FILE_CONSUME_KEY.concat(message.getKey()));
|
||||||
|
if (Objects.isNull(keyStatus) || keyStatus.equalsIgnoreCase(MessageStatus.FAIL)) {
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.RMQ_FILE_CONSUME_KEY.concat(message.getKey()), MessageStatus.BEING_PROCESSED, 60L);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消费成功,缓存到redis72小时,避免重复消费
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void consumeSuccess(HeartbeatTimeoutMessage message) {
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.RMQ_FILE_CONSUME_KEY.concat(message.getKey()), MessageStatus.SUCCESS, 300L);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发生异常时,进行错误信息入库保存
|
||||||
|
* 默认没有实现类,子类可以实现该方法,调用feign接口进行入库保存
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void saveExceptionMsgLog(HeartbeatTimeoutMessage message, String identity, Exception exception) {
|
||||||
|
redisUtil.saveByKeyWithExpire(AppRedisKey.RMQ_FILE_CONSUME_KEY.concat(message.getKey()), MessageStatus.FAIL, RedisKeyEnum.ROCKET_MQ_KEY.getTime());
|
||||||
|
RocketmqMsgErrorLog rocketmqMsgErrorLog = new RocketmqMsgErrorLog();
|
||||||
|
rocketmqMsgErrorLog.setMsgKey(message.getKey());
|
||||||
|
rocketmqMsgErrorLog.setResource(message.getSource());
|
||||||
|
if (identity.equalsIgnoreCase(EnhanceMessageConstant.IDENTITY_SINGLE)) {
|
||||||
|
//数据库字段配置长度200,避免插入失败,大致分析异常原因
|
||||||
|
String exceptionMsg = exception.getMessage();
|
||||||
|
if(exceptionMsg.length() > 200){
|
||||||
|
exceptionMsg = exceptionMsg.substring(0,180);
|
||||||
|
}
|
||||||
|
rocketmqMsgErrorLog.setRecord(exceptionMsg);
|
||||||
|
//如果是当前消息重试的则略过
|
||||||
|
if(!message.getSource().startsWith(EnhanceMessageConstant.RETRY_PREFIX)){
|
||||||
|
//单次消费异常
|
||||||
|
rocketMqLogFeignClient.add(rocketmqMsgErrorLog);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rocketmqMsgErrorLog.setRecord("重试消费" + super.getMaxRetryTimes() + "次,依旧消费失败。");
|
||||||
|
//重试N次后,依然消费异常
|
||||||
|
rocketMqLogFeignClient.add(rocketmqMsgErrorLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 处理失败后,是否重试
|
||||||
|
* 一般开启
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean isRetry() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 消费失败是否抛出异常,抛出异常后就不再消费了
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean throwException() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 调用父类handler处理消息的元信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onMessage(HeartbeatTimeoutMessage appFileMessage) {
|
||||||
|
super.dispatchMessage(appFileMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -71,11 +71,11 @@ public class RealDataConsumer extends EnhanceConsumerMessageHandler<AppAutoDataM
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消费成功,缓存到redis72小时,避免重复消费
|
* 消费成功,缓存到redis 5分钟,避免重复消费
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void consumeSuccess(AppAutoDataMessage message) {
|
protected void consumeSuccess(AppAutoDataMessage message) {
|
||||||
redisUtil.saveByKeyWithExpire(AppRedisKey.RMQ_CONSUME_KEY.concat(message.getKey()), MessageStatus.SUCCESS, RedisKeyEnum.ROCKET_MQ_KEY.getTime());
|
redisUtil.saveByKeyWithExpire(AppRedisKey.RMQ_CONSUME_KEY.concat(message.getKey()), MessageStatus.SUCCESS, 5 * 60L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ logging:
|
|||||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||||
level:
|
level:
|
||||||
root: info
|
root: info
|
||||||
|
com.njcn.middle.rocket.handler.EnhanceConsumerMessageHandler: ERROR
|
||||||
|
|
||||||
#mybatis配置信息
|
#mybatis配置信息
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
@@ -51,4 +51,4 @@ mybatis-plus:
|
|||||||
|
|
||||||
|
|
||||||
mqtt:
|
mqtt:
|
||||||
client-id: message-boot${random.value}
|
client-id: message-boot${random.value}
|
||||||
|
|||||||
23
pom.xml
23
pom.xml
@@ -34,11 +34,17 @@
|
|||||||
|
|
||||||
<!--103本地-->
|
<!--103本地-->
|
||||||
<!-- <middle.server.url>192.168.1.103</middle.server.url>-->
|
<!-- <middle.server.url>192.168.1.103</middle.server.url>-->
|
||||||
<!-- <service.server.url>192.168.1.126</service.server.url>-->
|
<!-- <service.server.url>192.168.2.126</service.server.url>-->
|
||||||
<!-- <docker.server.url>192.168.1.103</docker.server.url>-->
|
<!-- <docker.server.url>192.168.1.103</docker.server.url>-->
|
||||||
<!-- <nacos.url>${middle.server.url}:18848</nacos.url>-->
|
<!-- <nacos.url>${middle.server.url}:18848</nacos.url>-->
|
||||||
<!-- <nacos.namespace>72972c43-3c20-4452-a261-66624e17da97</nacos.namespace>-->
|
<!-- <nacos.namespace>72972c43-3c20-4452-a261-66624e17da97</nacos.namespace>-->
|
||||||
|
|
||||||
|
<!-- <middle.server.url>192.168.1.162</middle.server.url>-->
|
||||||
|
<!-- <service.server.url>192.168.1.162</service.server.url>-->
|
||||||
|
<!-- <docker.server.url>192.168.1.162</docker.server.url>-->
|
||||||
|
<!-- <nacos.url>${middle.server.url}:18848</nacos.url>-->
|
||||||
|
<!-- <nacos.namespace></nacos.namespace>-->
|
||||||
|
|
||||||
<!--103线上-->
|
<!--103线上-->
|
||||||
<middle.server.url>192.168.1.103</middle.server.url>
|
<middle.server.url>192.168.1.103</middle.server.url>
|
||||||
<service.server.url>192.168.1.103</service.server.url>
|
<service.server.url>192.168.1.103</service.server.url>
|
||||||
@@ -61,11 +67,24 @@
|
|||||||
|
|
||||||
<!--102-->
|
<!--102-->
|
||||||
<!-- <middle.server.url>192.168.1.102</middle.server.url>-->
|
<!-- <middle.server.url>192.168.1.102</middle.server.url>-->
|
||||||
<!-- <service.server.url>127.0.0.1</service.server.url>-->
|
<!-- <service.server.url>192.168.1.126</service.server.url>-->
|
||||||
|
<!-- <docker.server.url>192.168.1.102</docker.server.url>-->
|
||||||
|
<!-- <nacos.url>${middle.server.url}:18848</nacos.url>-->
|
||||||
|
<!-- <nacos.namespace>d99572a5-415e-480b-bb92-30f05c2f6d93</nacos.namespace>-->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <middle.server.url>192.168.1.102</middle.server.url>-->
|
||||||
|
<!-- <service.server.url>192.168.1.126</service.server.url>-->
|
||||||
<!-- <docker.server.url>192.168.1.102</docker.server.url>-->
|
<!-- <docker.server.url>192.168.1.102</docker.server.url>-->
|
||||||
<!-- <nacos.url>${middle.server.url}:18848</nacos.url>-->
|
<!-- <nacos.url>${middle.server.url}:18848</nacos.url>-->
|
||||||
<!-- <nacos.namespace>c208a65e-1578-4372-b7c0-97fecd323fe6</nacos.namespace>-->
|
<!-- <nacos.namespace>c208a65e-1578-4372-b7c0-97fecd323fe6</nacos.namespace>-->
|
||||||
|
|
||||||
|
<!-- <middle.server.url>192.168.1.102</middle.server.url>-->
|
||||||
|
<!-- <service.server.url>192.168.1.102</service.server.url>-->
|
||||||
|
<!-- <docker.server.url>192.168.1.102</docker.server.url>-->
|
||||||
|
<!-- <nacos.url>${middle.server.url}:18848</nacos.url>-->
|
||||||
|
<!-- <nacos.namespace>c208a65e-1578-4372-b7c0-97fecd323fe6</nacos.namespace>-->
|
||||||
|
|
||||||
<!-- <middle.server.url>192.168.1.27</middle.server.url>-->
|
<!-- <middle.server.url>192.168.1.27</middle.server.url>-->
|
||||||
<!-- <service.server.url>127.0.0.1</service.server.url>-->
|
<!-- <service.server.url>127.0.0.1</service.server.url>-->
|
||||||
<!-- <docker.server.url>192.168.1.27</docker.server.url>-->
|
<!-- <docker.server.url>192.168.1.27</docker.server.url>-->
|
||||||
|
|||||||
Reference in New Issue
Block a user