1.设备注册接入优化
2.波形文件接收、解析功能调整
This commit is contained in:
@@ -59,7 +59,7 @@ public class RspDataDto {
|
||||
}
|
||||
|
||||
/**
|
||||
* 软件信息
|
||||
* 监测点信息
|
||||
*/
|
||||
@Data
|
||||
public static class LdevInfo {
|
||||
@@ -79,6 +79,9 @@ public class RspDataDto {
|
||||
|
||||
@SerializedName("CtRatio")
|
||||
private Double ctRatio;
|
||||
|
||||
@SerializedName("Capacity_A")
|
||||
private Double capacity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,6 +72,10 @@ public class EventDto {
|
||||
@ApiModelProperty("事件类型")
|
||||
private String type;
|
||||
|
||||
@SerializedName("Code")
|
||||
@ApiModelProperty("告警故障编码(一般显示为Hex)")
|
||||
private String code;
|
||||
|
||||
@SerializedName("Parm")
|
||||
private List<Param> param;
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.njcn.access.pojo.dto.devModel;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/13 12:09
|
||||
*/
|
||||
@Data
|
||||
public class CpuInfoDto implements Serializable {
|
||||
|
||||
@SerializedName("OpAttr")
|
||||
@ApiModelProperty("读写操作属性")
|
||||
private String opAttr;
|
||||
|
||||
@SerializedName("CpuCore")
|
||||
@ApiModelProperty("CPU核心数")
|
||||
private Integer cpuCore;
|
||||
|
||||
@SerializedName("CpuFreq")
|
||||
@ApiModelProperty("CPU主频(单位MHz)")
|
||||
private Float cpuFreq;
|
||||
|
||||
@SerializedName("Arch")
|
||||
@ApiModelProperty("CPU架构")
|
||||
private String arch;
|
||||
|
||||
@SerializedName("CpuLmt")
|
||||
@ApiModelProperty("CPU监控阈值(单位%)")
|
||||
private Float cpuLmt;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.njcn.access.pojo.dto.devModel;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/13 12:08
|
||||
*/
|
||||
@Data
|
||||
public class DevInfoDto implements Serializable {
|
||||
|
||||
@SerializedName("OpAttr")
|
||||
@ApiModelProperty("读写操作属性")
|
||||
private String opAttr;
|
||||
|
||||
@SerializedName("DevType")
|
||||
@ApiModelProperty("设备型号")
|
||||
private String devType;
|
||||
|
||||
@SerializedName("DevName ")
|
||||
@ApiModelProperty("设备名称")
|
||||
private String devName;
|
||||
|
||||
@SerializedName("MsgInfo")
|
||||
@ApiModelProperty("设备厂商信息")
|
||||
private String msgInfo;
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.njcn.access.pojo.dto.devModel;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/13 12:09
|
||||
*/
|
||||
@Data
|
||||
public class DiskInfoDto implements Serializable {
|
||||
|
||||
@SerializedName("OpAttr")
|
||||
@ApiModelProperty("读写操作属性")
|
||||
private String opAttr;
|
||||
|
||||
@SerializedName("DiskPhy")
|
||||
@ApiModelProperty("磁盘空间(单位MB)")
|
||||
private Float diskPhy;
|
||||
|
||||
@SerializedName("DiskLmt")
|
||||
@ApiModelProperty("内存监控阈值(单位%)")
|
||||
private Float diskLmt;
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.njcn.access.pojo.dto.devModel;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.poi.hpsf.Decimal;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/4 10:04
|
||||
*/
|
||||
@Data
|
||||
public class LDevInfoDto implements Serializable {
|
||||
|
||||
@SerializedName("OpAttr")
|
||||
private String opAttr;
|
||||
|
||||
@SerializedName("Cldid")
|
||||
@ApiModelProperty(value = "逻辑子设备Id")
|
||||
private Integer cldId;
|
||||
|
||||
@SerializedName("VolGrade")
|
||||
@ApiModelProperty(value = "电压等级")
|
||||
private Double volGrade;
|
||||
|
||||
@SerializedName("ConType")
|
||||
@ApiModelProperty(value = "接线方式")
|
||||
private Integer conType;
|
||||
|
||||
@SerializedName("PtRatio")
|
||||
@ApiModelProperty(value = "PT变比")
|
||||
private BigDecimal ptRatio;
|
||||
|
||||
@SerializedName("CtRatio")
|
||||
@ApiModelProperty(value = "CT变比")
|
||||
private BigDecimal ctRatio;
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.njcn.access.pojo.dto.devModel;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/13 12:09
|
||||
*/
|
||||
@Data
|
||||
public class MemInfoDto implements Serializable {
|
||||
|
||||
@SerializedName("OpAttr")
|
||||
@ApiModelProperty("读写操作属性")
|
||||
private String opAttr;
|
||||
|
||||
@SerializedName("MemPhy")
|
||||
@ApiModelProperty("物理内存(单位MB)")
|
||||
private Float memPhy;
|
||||
|
||||
@SerializedName("MemLmt")
|
||||
@ApiModelProperty("内存监控阈值(单位%)")
|
||||
private Float memLmt;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.njcn.access.pojo.dto.devModel;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/16 15:30
|
||||
*/
|
||||
@Data
|
||||
public class PrjInfoDto implements Serializable {
|
||||
|
||||
@SerializedName("OpAttr")
|
||||
@NotEmpty(message = "读写操作属性不可为空")
|
||||
private String opAttr;
|
||||
|
||||
@SerializedName("Province")
|
||||
@NotEmpty(message = "安装区域省,不可为空")
|
||||
private String province;
|
||||
|
||||
@SerializedName("City")
|
||||
@NotEmpty(message = "安装区域市,不可为空")
|
||||
private String city;
|
||||
|
||||
@SerializedName("County")
|
||||
@NotEmpty(message = "安装区域县或区,不可为空")
|
||||
private String county;
|
||||
|
||||
@SerializedName("Address")
|
||||
@NotEmpty(message = "安装地址(厂区或变电站),不可为空")
|
||||
private String address;
|
||||
|
||||
@SerializedName("Position")
|
||||
@NotEmpty(message = "安装位置,不可为空")
|
||||
private String position;
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.njcn.access.pojo.dto.devModel;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Null;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/3/13 12:09
|
||||
*/
|
||||
@Data
|
||||
public class SoftInfoDto implements Serializable {
|
||||
|
||||
@SerializedName("OpAttr")
|
||||
@NotEmpty(message = "读写操作属性不可为空")
|
||||
private String opAttr;
|
||||
|
||||
@SerializedName("OsName")
|
||||
@NotEmpty(message = "操作系统名称,裸机系统填Null,不可为空")
|
||||
private String osName;
|
||||
|
||||
@SerializedName("OsVersion")
|
||||
@NotEmpty(message = "操作系统版本,裸机系统填Null,不可为空")
|
||||
private String osVersion;
|
||||
|
||||
@SerializedName("AppVersion")
|
||||
@NotEmpty(message = "应用程序版本号,不可为空")
|
||||
private String appVersion;
|
||||
|
||||
@SerializedName("AppDate")
|
||||
@NotEmpty(message = "应用程序发布日期,不可为空")
|
||||
private String appDate;
|
||||
|
||||
@SerializedName("AppCheck")
|
||||
@NotEmpty(message = "应用程序校验码,不可为空")
|
||||
private String appCheck;
|
||||
|
||||
@SerializedName("Softupdate")
|
||||
@NotEmpty(message = "是否支持远程升级程序,不可为空")
|
||||
private String softUpdate;
|
||||
|
||||
}
|
||||
@@ -50,6 +50,21 @@ public class FileDto implements Serializable {
|
||||
@SerializedName("Name")
|
||||
private String name;
|
||||
|
||||
@SerializedName("FrameCurr")
|
||||
@ApiModelProperty("当前帧")
|
||||
private Integer frameCurr;
|
||||
|
||||
@SerializedName("FrameTotal")
|
||||
@ApiModelProperty("总帧数")
|
||||
private Integer frameTotal;
|
||||
|
||||
@SerializedName("FrameLen")
|
||||
@ApiModelProperty("单帧大小")
|
||||
private Integer frameLen;
|
||||
|
||||
@SerializedName("Offset")
|
||||
private Integer offset;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.njcn.access.handler;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.csp.sentinel.util.StringUtil;
|
||||
import com.alibaba.excel.util.CollectionUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -17,18 +19,17 @@ import com.njcn.access.pojo.dto.file.FileDto;
|
||||
import com.njcn.access.pojo.param.ReqAndResParam;
|
||||
import com.njcn.access.pojo.po.CsDeviceOnlineLogs;
|
||||
import com.njcn.access.pojo.po.CsLineModel;
|
||||
import com.njcn.access.pojo.po.CsSoftInfoPO;
|
||||
import com.njcn.access.pojo.po.CsTopic;
|
||||
import com.njcn.access.service.ICsDeviceOnlineLogsService;
|
||||
import com.njcn.access.service.ICsEquipmentDeliveryService;
|
||||
import com.njcn.access.service.ICsLineModelService;
|
||||
import com.njcn.access.service.ICsTopicService;
|
||||
import com.njcn.access.service.*;
|
||||
import com.njcn.common.pojo.dto.DeviceLogDTO;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.CsLogsFeignClient;
|
||||
import com.njcn.csdevice.api.DataSetFeignClient;
|
||||
import com.njcn.csdevice.api.DevModelFeignClient;
|
||||
import com.njcn.csdevice.api.*;
|
||||
import com.njcn.csdevice.pojo.param.CsLineParam;
|
||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
||||
import com.njcn.csdevice.pojo.po.CsDevCapacityPO;
|
||||
import com.njcn.csdevice.pojo.po.CsDevModelPO;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.mq.message.AppAutoDataMessage;
|
||||
import com.njcn.mq.message.AppEventMessage;
|
||||
import com.njcn.mq.message.AppFileMessage;
|
||||
@@ -42,19 +43,19 @@ import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.Validator;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -93,6 +94,14 @@ public class MqttMessageHandler {
|
||||
|
||||
private final ICsDeviceOnlineLogsService onlineLogsService;
|
||||
|
||||
private final ICsSoftInfoService csSoftInfoService;
|
||||
|
||||
private final CsLineFeignClient csLineFeignClient;
|
||||
|
||||
private final DevCapacityFeignClient devCapacityFeignClient;
|
||||
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
@Autowired
|
||||
Validator validator;
|
||||
|
||||
@@ -292,6 +301,7 @@ public class MqttMessageHandler {
|
||||
* @param payload
|
||||
*/
|
||||
@MqttSubscribe(value = "/Pfm/DevRsp/{version}/{edgeId}",qos = 1)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void devAccessOperation(String topic, MqttMessage message, @NamedValue("version") String version, @NamedValue("edgeId") String nDid, @Payload String payload){
|
||||
//日志实体
|
||||
DeviceLogDTO logDto = new DeviceLogDTO();
|
||||
@@ -306,59 +316,122 @@ public class MqttMessageHandler {
|
||||
//业务处理
|
||||
Gson gson = new Gson();
|
||||
ReqAndResDto.Res res = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResDto.Res.class);
|
||||
switch (res.getType()){
|
||||
case 4613:
|
||||
logDto.setOperate(nDid + "设备接入");
|
||||
log.info("收到接入应答响应--->" + nDid);
|
||||
if (Objects.equals(res.getCode(),AccessEnum.SUCCESS.getCode())){
|
||||
log.info("接入应答成功--->" + nDid);
|
||||
//修改装置状态
|
||||
csEquipmentDeliveryService.updateStatusBynDid(nDid,AccessEnum.ACCESS.getCode());
|
||||
csEquipmentDeliveryService.updateRunStatusBynDid(nDid,AccessEnum.ONLINE.getCode());
|
||||
//记录设备上线
|
||||
CsDeviceOnlineLogs record = onlineLogsService.findLastData(nDid);
|
||||
CsDeviceOnlineLogs csDeviceOnlineLogs = new CsDeviceOnlineLogs();
|
||||
if(Objects.isNull(record)) {
|
||||
csDeviceOnlineLogs.setNdid(nDid);
|
||||
csDeviceOnlineLogs.setOnlineTime(LocalDateTime.now());
|
||||
onlineLogsService.save(csDeviceOnlineLogs);
|
||||
} else {
|
||||
LocalDateTime time = record.getOfflineTime();
|
||||
if (!Objects.isNull(time)){
|
||||
if (Objects.equals(res.getCode(),AccessEnum.SUCCESS.getCode())){
|
||||
switch (res.getType()){
|
||||
case 4613:
|
||||
logDto.setOperate(nDid + "设备接入");
|
||||
log.info("{}收到接入应答响应,应答code {}",nDid,res.getCode());
|
||||
if (Objects.equals(res.getCode(),AccessEnum.SUCCESS.getCode())){
|
||||
int mid = 1;
|
||||
//修改装置状态
|
||||
csEquipmentDeliveryService.updateStatusBynDid(nDid,AccessEnum.ACCESS.getCode());
|
||||
csEquipmentDeliveryService.updateRunStatusBynDid(nDid,AccessEnum.ONLINE.getCode());
|
||||
//记录设备上线
|
||||
CsDeviceOnlineLogs record = onlineLogsService.findLastData(nDid);
|
||||
CsDeviceOnlineLogs csDeviceOnlineLogs = new CsDeviceOnlineLogs();
|
||||
if(Objects.isNull(record)) {
|
||||
csDeviceOnlineLogs.setNdid(nDid);
|
||||
csDeviceOnlineLogs.setOnlineTime(LocalDateTime.now());
|
||||
onlineLogsService.save(csDeviceOnlineLogs);
|
||||
} else {
|
||||
LocalDateTime time = record.getOfflineTime();
|
||||
if (!Objects.isNull(time)){
|
||||
csDeviceOnlineLogs.setNdid(nDid);
|
||||
csDeviceOnlineLogs.setOnlineTime(LocalDateTime.now());
|
||||
onlineLogsService.save(csDeviceOnlineLogs);
|
||||
}
|
||||
}
|
||||
//询问设备软件信息
|
||||
askDevData(nDid,version,1,mid);
|
||||
mid++;
|
||||
//询问设备容量信息
|
||||
askDevData(nDid,version,2,mid);
|
||||
mid++;
|
||||
//询问监测点pt/ct信息
|
||||
askDevData(nDid,version,3,mid);
|
||||
} else {
|
||||
log.info(AccessResponseEnum.ACCESS_RESPONSE_ERROR.getMessage());
|
||||
logDto.setResult(0);
|
||||
logDto.setFailReason(AccessResponseEnum.ACCESS_RESPONSE_ERROR.getMessage());
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
throw new BusinessException(AccessResponseEnum.ACCESS_RESPONSE_ERROR);
|
||||
}
|
||||
} else {
|
||||
log.info(AccessResponseEnum.ACCESS_RESPONSE_ERROR.getMessage());
|
||||
logDto.setResult(0);
|
||||
logDto.setFailReason(AccessResponseEnum.ACCESS_RESPONSE_ERROR.getMessage());
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
throw new BusinessException(AccessResponseEnum.ACCESS_RESPONSE_ERROR);
|
||||
}
|
||||
break;
|
||||
case 4614:
|
||||
logDto.setOperate(nDid + "设备数据应答");
|
||||
log.info("设备数据应答--->" + nDid);
|
||||
RspDataDto rspDataDto = JSON.parseObject(JSON.toJSONString(res.getMsg()), RspDataDto.class);
|
||||
switch (rspDataDto.getDataType()){
|
||||
case 1:
|
||||
RspDataDto.SoftInfo softInfo = JSON.parseObject(JSON.toJSONString(rspDataDto.getDataArray()), RspDataDto.SoftInfo.class);
|
||||
redisUtil.saveByKeyWithExpire(AppRedisKey.SOFTINFO+nDid,softInfo,600L);
|
||||
break;
|
||||
case 2:
|
||||
List<RspDataDto.LdevInfo> ldevInfo = JSON.parseArray(JSON.toJSONString(rspDataDto.getDataArray()), RspDataDto.LdevInfo.class);
|
||||
redisUtil.saveByKeyWithExpire(AppRedisKey.LINE_DATA+nDid,ldevInfo,600L);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
case 4614:
|
||||
log.info("设备数据应答--->" + nDid);
|
||||
RspDataDto rspDataDto = JSON.parseObject(JSON.toJSONString(res.getMsg()), RspDataDto.class);
|
||||
switch (rspDataDto.getDataType()){
|
||||
case 1:
|
||||
logDto.setOperate(nDid + "更新设备软件信息");
|
||||
RspDataDto.SoftInfo softInfo = JSON.parseObject(JSON.toJSONString(rspDataDto.getDataArray()), RspDataDto.SoftInfo.class);
|
||||
//记录设备软件信息
|
||||
CsSoftInfoPO csSoftInfoPo = new CsSoftInfoPO();
|
||||
BeanUtils.copyProperties(softInfo,csSoftInfoPo);
|
||||
try {
|
||||
csSoftInfoPo.setAppDate(new SimpleDateFormat("yyyy-MM-dd").parse(softInfo.getAppDate()));
|
||||
csSoftInfoService.save(csSoftInfoPo);
|
||||
//更新设备软件id 先看是否存在软件信息,删除 然后在录入
|
||||
CsEquipmentDeliveryPO po = equipmentFeignClient.findDevByNDid(nDid).getData();
|
||||
String soft = po.getSoftinfoId();
|
||||
if (StringUtil.isNotBlank(soft)){
|
||||
csSoftInfoService.removeById(soft);
|
||||
}
|
||||
equipmentFeignClient.updateSoftInfo(nDid,csSoftInfoPo.getId());
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
List<RspDataDto.LdevInfo> devInfo = JSON.parseArray(JSON.toJSONString(rspDataDto.getDataArray()), RspDataDto.LdevInfo.class);
|
||||
if (CollectionUtil.isNotEmpty(devInfo)){
|
||||
if (Objects.equals(res.getDid(),1)){
|
||||
logDto.setOperate(nDid + "更新治理监测点信息和设备容量");
|
||||
List<CsDevCapacityPO> list = new ArrayList<>();
|
||||
devInfo.forEach(item->{
|
||||
//1.更新治理监测点信息
|
||||
if (Objects.equals(item.getClDid(),0)){
|
||||
CsLineParam csLineParam = new CsLineParam();
|
||||
csLineParam.setLineId(nDid.concat("0"));
|
||||
csLineParam.setVolGrade(item.getVolGrade());
|
||||
csLineParam.setPtRatio(item.getPtRatio());
|
||||
csLineParam.setCtRatio(item.getCtRatio());
|
||||
csLineParam.setConType(item.getConType());
|
||||
csLineFeignClient.updateLine(csLineParam);
|
||||
}
|
||||
//2.录入各个模块设备容量
|
||||
CsDevCapacityPO csDevCapacity = new CsDevCapacityPO();
|
||||
csDevCapacity.setLineId(nDid.concat("0"));
|
||||
csDevCapacity.setCldid(item.getClDid());
|
||||
csDevCapacity.setCapacity(item.getCapacity());
|
||||
list.add(csDevCapacity);
|
||||
});
|
||||
devCapacityFeignClient.addList(list);
|
||||
//3.更新设备模块个数
|
||||
equipmentFeignClient.updateModuleNumber(nDid,(devInfo.size()-1));
|
||||
} else if (Objects.equals(res.getDid(),2)) {
|
||||
logDto.setOperate(nDid + "更新电网侧、负载侧监测点信息");
|
||||
//1.更新电网侧、负载侧监测点相关信息
|
||||
devInfo.forEach(item->{
|
||||
CsLineParam csLineParam = new CsLineParam();
|
||||
csLineParam.setLineId(nDid.concat(item.getClDid().toString()));
|
||||
csLineParam.setVolGrade(item.getVolGrade());
|
||||
csLineParam.setPtRatio(item.getPtRatio());
|
||||
csLineParam.setCtRatio(item.getCtRatio());
|
||||
csLineParam.setConType(item.getConType());
|
||||
csLineFeignClient.updateLine(csLineParam);
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
}
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
}
|
||||
|
||||
|
||||
@@ -481,11 +554,59 @@ public class MqttMessageHandler {
|
||||
break;
|
||||
case 4658:
|
||||
log.info("获取文件流信息");
|
||||
redisUtil.saveByKeyWithExpire(AppRedisKey.FILE_PART.concat(appFileMessage.getMsg().getName() + appFileMessage.getMid()), appFileMessage.getMid(),3600L);
|
||||
appFileStreamMessageTemplate.sendMember(appFileMessage);
|
||||
if (Objects.equals(fileDto.getCode(),AccessEnum.SUCCESS.getCode())){
|
||||
appFileStreamMessageTemplate.sendMember(appFileMessage);
|
||||
}
|
||||
//todo 处理文件信息,先缓存起来,后期在询问
|
||||
else if (Objects.equals(fileDto.getCode(),AccessEnum.REFUSE_WAIT.getCode())) {
|
||||
log.info("需要缓存请求的文件信息");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* type含义
|
||||
* 1:询问设备软件信息
|
||||
* 2:模块信息
|
||||
* 3:监测点pt/ct信息
|
||||
*/
|
||||
public void askDevData(String nDid,String version,Integer type,Integer mid){
|
||||
ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req();
|
||||
reqAndResParam.setMid(mid);
|
||||
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_6.getCode()));
|
||||
reqAndResParam.setExpire(1);
|
||||
AskDataDto askDataDto = new AskDataDto();
|
||||
askDataDto.setDataAttr(0);
|
||||
askDataDto.setOperate(1);
|
||||
askDataDto.setStartTime(-1);
|
||||
askDataDto.setEndTime(-1);
|
||||
switch (type) {
|
||||
case 1:
|
||||
reqAndResParam.setDid(2);
|
||||
askDataDto.setCldid(0);
|
||||
askDataDto.setDataType(1);
|
||||
break;
|
||||
case 2:
|
||||
reqAndResParam.setDid(1);
|
||||
askDataDto.setCldid(-1);
|
||||
askDataDto.setDataType(2);
|
||||
break;
|
||||
case 3:
|
||||
reqAndResParam.setDid(2);
|
||||
askDataDto.setCldid(-1);
|
||||
askDataDto.setDataType(2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
reqAndResParam.setMsg(askDataDto);
|
||||
publisher.send("/Pfm/DevCmd/"+version+"/"+nDid, new Gson().toJson(reqAndResParam),1,false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
package com.njcn.access.runner;
|
||||
|
||||
import com.njcn.access.service.ICsEquipmentDeliveryService;
|
||||
import com.njcn.access.service.ICsTopicService;
|
||||
import com.njcn.access.service.impl.CsDeviceServiceImpl;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 类的介绍:用来重新发起设备的接入,存在程序意外停止了,缓存失效导致无法更新装置的状态,所以需要在程序启动时发起设备的接入
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/8/28 13:57
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class AccessApplicationRunner implements ApplicationRunner {
|
||||
|
||||
@Resource
|
||||
private CsDeviceServiceImpl csDeviceService;
|
||||
|
||||
@Resource
|
||||
private ICsTopicService csTopicService;
|
||||
|
||||
@Resource
|
||||
private ICsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args){
|
||||
List<CsEquipmentDeliveryPO> list = csEquipmentDeliveryService.getAll();
|
||||
list.forEach(item->{
|
||||
String version = csTopicService.getVersion(item.getNdid());
|
||||
if (!Objects.isNull(version)){
|
||||
csDeviceService.devAccess(item.getNdid(),version);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
//package com.njcn.access.runner;
|
||||
//
|
||||
//import com.njcn.access.service.ICsEquipmentDeliveryService;
|
||||
//import com.njcn.access.service.ICsTopicService;
|
||||
//import com.njcn.access.service.impl.CsDeviceServiceImpl;
|
||||
//import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.boot.ApplicationArguments;
|
||||
//import org.springframework.boot.ApplicationRunner;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//import java.util.List;
|
||||
//import java.util.Objects;
|
||||
//
|
||||
///**
|
||||
// * 类的介绍:用来重新发起设备的接入,存在程序意外停止了,缓存失效导致无法更新装置的状态,所以需要在程序启动时发起设备的接入
|
||||
// *
|
||||
// * @author xuyang
|
||||
// * @version 1.0.0
|
||||
// * @createTime 2023/8/28 13:57
|
||||
// */
|
||||
//@Component
|
||||
//@Slf4j
|
||||
//public class AccessApplicationRunner implements ApplicationRunner {
|
||||
//
|
||||
// @Resource
|
||||
// private CsDeviceServiceImpl csDeviceService;
|
||||
//
|
||||
// @Resource
|
||||
// private ICsTopicService csTopicService;
|
||||
//
|
||||
// @Resource
|
||||
// private ICsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||
//
|
||||
// @Override
|
||||
// public void run(ApplicationArguments args){
|
||||
// List<CsEquipmentDeliveryPO> list = csEquipmentDeliveryService.getAll();
|
||||
// list.forEach(item->{
|
||||
// String version = csTopicService.getVersion(item.getNdid());
|
||||
// if (!Objects.isNull(version)){
|
||||
// csDeviceService.devAccess(item.getNdid(),version);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -217,7 +217,6 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
csLedgerParam.setSort(0);
|
||||
csLedgerService.addLedgerTree(csLedgerParam);
|
||||
List<CsModelDto> modelId = objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + devAccessParam.getNDid()));
|
||||
Integer clDid = null, moduleNumber = null;
|
||||
//2.新增装置-模板关系、获取电能质量的逻辑设备id
|
||||
for (CsModelDto item : modelId) {
|
||||
CsDevModelRelationAddParm csDevModelRelationAddParm = new CsDevModelRelationAddParm();
|
||||
@@ -225,36 +224,6 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
csDevModelRelationAddParm.setModelId(item.getModelId());
|
||||
csDevModelRelationAddParm.setDid(item.getDid());
|
||||
csDevModelRelationService.addDevModelRelation(csDevModelRelationAddParm);
|
||||
if (Objects.equals(item.getType(),1)){
|
||||
clDid = item.getDid();
|
||||
}
|
||||
if (Objects.equals(item.getType(),0)){
|
||||
moduleNumber = item.getModuleNumber();
|
||||
}
|
||||
}
|
||||
if (Objects.isNull(clDid)){
|
||||
logDto.setResult(0);
|
||||
logDto.setFailReason(AccessResponseEnum.CLDID_IS_NULL.getMessage());
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
throw new BusinessException(AccessResponseEnum.CLDID_IS_NULL);
|
||||
}
|
||||
if (Objects.isNull(moduleNumber)){
|
||||
logDto.setResult(0);
|
||||
logDto.setFailReason(AccessResponseEnum.MODULE_NUMBER_IS_NULL.getMessage());
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
throw new BusinessException(AccessResponseEnum.MODULE_NUMBER_IS_NULL);
|
||||
}
|
||||
askDevData(devAccessParam.getNDid(),AccessEnum.L_DEV_INFO.getCode(),version,clDid);
|
||||
List<RspDataDto.LdevInfo> list = new ArrayList<>();
|
||||
//等待mqtt数据
|
||||
Thread.sleep(500);
|
||||
String key = AppRedisKey.LINE_DATA + devAccessParam.getNDid();
|
||||
list = objectToList2(redisUtil.getObjectByKey(key));
|
||||
if (CollectionUtils.isEmpty(list)){
|
||||
logDto.setResult(0);
|
||||
logDto.setFailReason(AccessResponseEnum.LDEVINFO_IS_NULL.getMessage());
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
throw new BusinessException(AccessResponseEnum.LDEVINFO_IS_NULL);
|
||||
}
|
||||
//3.监测点表录入关系
|
||||
for (DevAccessParam.LineParam item : devAccessParam.getList()) {
|
||||
@@ -266,24 +235,14 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
po.setPosition(item.getPosition());
|
||||
po.setClDid(0);
|
||||
if (Objects.equals(DicDataEnum.GRID_SIDE.getCode(),location)){
|
||||
RspDataDto.LdevInfo po1 = list.stream().filter(s -> Objects.equals(s.getClDid(),1)).findFirst().orElse(null);
|
||||
po.setLineId(devAccessParam.getNDid() + "1");
|
||||
param.setId(devAccessParam.getNDid() + "1");
|
||||
appLineTopologyDiagramPo.setLineId(devAccessParam.getNDid() + "1");
|
||||
po.setVolGrade(po1.getVolGrade());
|
||||
po.setPtRatio(po1.getPtRatio());
|
||||
po.setCtRatio(po1.getCtRatio());
|
||||
po.setConType(po1.getConType());
|
||||
po.setClDid(1);
|
||||
} else if (Objects.equals(DicDataEnum.LOAD_SIDE.getCode(),location)){
|
||||
RspDataDto.LdevInfo po1 = list.stream().filter(s -> Objects.equals(s.getClDid(),2)).findFirst().orElse(null);
|
||||
po.setLineId(devAccessParam.getNDid() + "2");
|
||||
param.setId(devAccessParam.getNDid() + "2");
|
||||
appLineTopologyDiagramPo.setLineId(devAccessParam.getNDid() + "2");
|
||||
po.setVolGrade(po1.getVolGrade());
|
||||
po.setPtRatio(po1.getPtRatio());
|
||||
po.setCtRatio(po1.getCtRatio());
|
||||
po.setConType(po1.getConType());
|
||||
po.setClDid(2);
|
||||
} else {
|
||||
po.setLineId(devAccessParam.getNDid() + "0");
|
||||
@@ -321,34 +280,13 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
po.setSubUserId(RequestUtil.getUserIndex());
|
||||
po.setDeviceId(vo.getId());
|
||||
csDeviceUserService.saveBatch(Collections.singletonList(po));
|
||||
//6.录入软件信息 SoftInfo
|
||||
askDevData(devAccessParam.getNDid(),AccessEnum.SOFT_INFO.getCode(),version,0);
|
||||
//等待mqtt数据
|
||||
Thread.sleep(500);
|
||||
String key2 = AppRedisKey.SOFTINFO + devAccessParam.getNDid();
|
||||
RspDataDto.SoftInfo softInfo = JSON.parseObject(JSON.toJSONString(redisUtil.getObjectByKey(key2)), RspDataDto.SoftInfo.class);
|
||||
if (Objects.isNull(softInfo)){
|
||||
logDto.setResult(0);
|
||||
logDto.setFailReason(AccessResponseEnum.SOFTINFO_IS_NULL.getMessage());
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
throw new BusinessException(AccessResponseEnum.SOFTINFO_IS_NULL);
|
||||
}
|
||||
//记录设备软件信息
|
||||
CsSoftInfoPO csSoftInfoPo = new CsSoftInfoPO();
|
||||
BeanUtils.copyProperties(softInfo,csSoftInfoPo);
|
||||
csSoftInfoPo.setAppDate(new SimpleDateFormat("yyyy-MM-dd").parse(softInfo.getAppDate()));
|
||||
csSoftInfoService.save(csSoftInfoPo);
|
||||
//更新设备表软件信息
|
||||
csEquipmentDeliveryService.updateSoftInfoBynDid(devAccessParam.getNDid(),csSoftInfoPo.getId(),moduleNumber);
|
||||
//修改装置状态
|
||||
//6.修改装置状态
|
||||
csEquipmentDeliveryService.updateStatusBynDid(devAccessParam.getNDid(), AccessEnum.REGISTERED.getCode());
|
||||
//7.发起自动接入请求
|
||||
devAccess(devAccessParam.getNDid(),version);
|
||||
//8.删除redis监测点模板信息
|
||||
redisUtil.delete(AppRedisKey.MODEL + devAccessParam.getNDid());
|
||||
redisUtil.delete(AppRedisKey.LINE + devAccessParam.getNDid());
|
||||
redisUtil.delete(AppRedisKey.LINE_DATA + devAccessParam.getNDid());
|
||||
redisUtil.delete(AppRedisKey.SOFTINFO + devAccessParam.getNDid());
|
||||
//存储日志
|
||||
csLogsFeignClient.addUserLog(logDto);
|
||||
//存储设备调试日志表
|
||||
@@ -437,33 +375,4 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
||||
}
|
||||
return urlList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台向设备发送数据命令
|
||||
*/
|
||||
public void askDevData(String nDid,Integer dataType,String version,Integer did){
|
||||
ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req();
|
||||
reqAndResParam.setMid(1);
|
||||
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_6.getCode()));
|
||||
reqAndResParam.setExpire(-1);
|
||||
AskDataDto askDataDto = new AskDataDto();
|
||||
askDataDto.setDataAttr(0);
|
||||
askDataDto.setOperate(1);
|
||||
askDataDto.setStartTime(-1);
|
||||
askDataDto.setEndTime(-1);
|
||||
if (Objects.equals(dataType,AccessEnum.SOFT_INFO.getCode())){
|
||||
askDataDto.setCldid(0);
|
||||
reqAndResParam.setDid(0);
|
||||
askDataDto.setDataType(1);
|
||||
} else if (Objects.equals(dataType,AccessEnum.L_DEV_INFO.getCode())){
|
||||
askDataDto.setCldid(-1);
|
||||
reqAndResParam.setDid(did);
|
||||
askDataDto.setDataType(2);
|
||||
}
|
||||
reqAndResParam.setMsg(askDataDto);
|
||||
logger.info("询问设备软件信息(监测点信息):" + new Gson().toJson(reqAndResParam));
|
||||
publisher.send("/Pfm/DevCmd/"+version+"/"+nDid, new Gson().toJson(reqAndResParam),1,false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,8 +12,16 @@ import com.njcn.access.enums.AccessEnum;
|
||||
import com.njcn.access.enums.TypeEnum;
|
||||
import com.njcn.access.pojo.dto.ReqAndResDto;
|
||||
import com.njcn.access.pojo.dto.mqtt.MqttClientDto;
|
||||
import com.njcn.access.service.ICsEquipmentDeliveryService;
|
||||
import com.njcn.access.service.impl.CsDeviceServiceImpl;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import io.lettuce.core.protocol.CompleteableCommand;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.Credentials;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
@@ -26,15 +34,15 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Array;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
@@ -42,6 +50,7 @@ import java.util.stream.Collectors;
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebAppConfiguration
|
||||
@SpringBootTest(classes = AccessBootApplication.class)
|
||||
@Slf4j
|
||||
public class AppTest
|
||||
{
|
||||
/**
|
||||
@@ -56,6 +65,35 @@ public class AppTest
|
||||
@Resource
|
||||
private MqttPublisher publisher;
|
||||
|
||||
@Resource
|
||||
private FileStorageUtil fileStorageUtil;
|
||||
|
||||
@Resource
|
||||
private ICsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||
|
||||
@Resource
|
||||
private CsDeviceServiceImpl csDeviceService;
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Test
|
||||
public void lossTest() {
|
||||
String nDid = "0008C0A801C8";
|
||||
Integer status = csEquipmentDeliveryService.queryEquipmentByndid(nDid).getRunStatus();
|
||||
if (!Objects.isNull(status) && Objects.equals(status,AccessEnum.ONLINE.getCode())){
|
||||
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(2);
|
||||
ScheduledFuture<?> runnableFuture = executor.scheduleAtFixedRate(() -> {
|
||||
log.info("定时发送接入请求...");
|
||||
Integer status2 = csEquipmentDeliveryService.queryEquipmentByndid(nDid).getRunStatus();
|
||||
if (Objects.equals(status2,AccessEnum.OFFLINE.getCode())){
|
||||
throw new BusinessException(CommonResponseEnum.SUCCESS);
|
||||
}
|
||||
}, 1, 5, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
@@ -69,49 +107,43 @@ public class AppTest
|
||||
// String key = String.valueOf(IdUtil.getSnowflake().nextId());
|
||||
// System.out.println("key==:" + key);
|
||||
|
||||
List<CsLinePO> csLinePoList = new ArrayList<>();
|
||||
CsLinePO po1 = new CsLinePO();
|
||||
po1.setPosition("1");
|
||||
CsLinePO po2= new CsLinePO();
|
||||
po2.setPosition("2");
|
||||
CsLinePO po3= new CsLinePO();
|
||||
po3.setPosition("3");
|
||||
CsLinePO po4= new CsLinePO();
|
||||
po4.setPosition("1");
|
||||
// List<CsLinePO> csLinePoList = new ArrayList<>();
|
||||
// CsLinePO po1 = new CsLinePO();
|
||||
// po1.setPosition("1");
|
||||
// CsLinePO po2= new CsLinePO();
|
||||
// po2.setPosition("2");
|
||||
// CsLinePO po3= new CsLinePO();
|
||||
// po3.setPosition("3");
|
||||
// CsLinePO po4= new CsLinePO();
|
||||
// po4.setPosition("1");
|
||||
//
|
||||
// csLinePoList.add(po1);
|
||||
// csLinePoList.add(po2);
|
||||
// csLinePoList.add(po3);
|
||||
// csLinePoList.add(po4);
|
||||
// List<String> l = csLinePoList.stream().map(CsLinePO::getPosition).collect(Collectors.toList());
|
||||
// System.out.println("l===:" + l);
|
||||
// List<String> lineList = l.stream().filter(e-> Collections.frequency(l,e) > 1).distinct().collect(Collectors.toList());
|
||||
// System.out.println("lineList==:" + lineList);
|
||||
|
||||
csLinePoList.add(po1);
|
||||
csLinePoList.add(po2);
|
||||
csLinePoList.add(po3);
|
||||
csLinePoList.add(po4);
|
||||
List<String> l = csLinePoList.stream().map(CsLinePO::getPosition).collect(Collectors.toList());
|
||||
System.out.println("l===:" + l);
|
||||
List<String> lineList = l.stream().filter(e-> Collections.frequency(l,e) > 1).distinct().collect(Collectors.toList());
|
||||
System.out.println("lineList==:" + lineList);
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// String text = "TkosUFEsMTk5OQ0KNiw2QSwwRA0KMSxBz+C159G5LEEstefRuSxWLDAuMDYyMjU2LDAuMDAwMDAwLDAuMDAwMDAwLC0zMjc2NywzMjc2NywzODAsMzgwLFMNCjIsQs/gtefRuSxCLLXn0bksViwwLjA2MjI1NiwwLjAwMDAwMCwwLjAwMDAwMCwtMzI3NjcsMzI3NjcsMzgwLDM4MCxTDQozLEPP4LXn0bksQyy159G5LFYsMC4wNjIyNTYsMC4wMDAwMDAsMC4wMDAwMDAsLTMyNzY3LDMyNzY3LDM4MCwzODAsUw0KNCxBz+C158H3LEEstefB9yxBLDAuMDE1MjU5LDAuMDAwMDAwLDAuMDAwMDAwLC0zMjc2NywzMjc2NywyMDAsNSxTDQo1LELP4LXnwfcsQiy158H3LEEsMC4wMTUyNTksMC4wMDAwMDAsMC4wMDAwMDAsLTMyNzY3LDMyNzY3LDIwMCw1LFMNCjYsQ8/gtefB9yxDLLXnwfcsQSwwLjAxNTI1OSwwLjAwMDAwMCwwLjAwMDAwMCwtMzI3NjcsMzI3NjcsMjAwLDUsUw0KNTANCjENCjEyODAwLDcxNjgNCjA1LzA5LzIwMjMsMTU6NTQ6MDIuMTM2MDAwDQowNS8wOS8yMDIzLDE1OjU0OjAyLjIzNjAwMA0KQklOQVJZDQoxDQo=";
|
||||
// byte[] byteArray = Base64.getDecoder().decode(text);
|
||||
// InputStream inputStream = new ByteArrayInputStream(byteArray);
|
||||
// fileStorageUtil.uploadStreamSpecifyName(inputStream, "configuration/","xuyang.cfg");
|
||||
// try {
|
||||
// String username = "ac760c62395cecec";
|
||||
// String password = "k0vGfe5xOE2Bl4DCF73uahcknvcwoKOEDPnOkMvuSBB";
|
||||
//
|
||||
// OkHttpClient client = new OkHttpClient();
|
||||
//
|
||||
// Request request = new Request.Builder()
|
||||
// .url("http://192.168.1.18:18083/api/v5/clients/access-boot123456")
|
||||
// .header("Content-Type", "application/json")
|
||||
// .header("Authorization", Credentials.basic(username, password))
|
||||
// .build();
|
||||
//
|
||||
// Response response = client.newCall(request).execute();
|
||||
// response.body();
|
||||
// String res = Objects.requireNonNull(response.body()).string();
|
||||
//
|
||||
// Gson gson = new Gson();
|
||||
// MqttClientDto mqttClientDto = gson.fromJson(res, new TypeToken<MqttClientDto>(){}.getType());
|
||||
// System.out.println("mqttClientDto==:" + mqttClientDto.isConnected());
|
||||
//
|
||||
// inputStream.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
// 要计算CRC32的数据
|
||||
String data = "Hello, World!";
|
||||
CRC32 crc32 = new CRC32();
|
||||
crc32.update(data.getBytes());
|
||||
long crc32Value = crc32.getValue();
|
||||
// 将CRC32校验值转换为16进制字符串
|
||||
String crc32Str = String.format("%08X", crc32Value);
|
||||
System.out.println("CRC32校验值为: " + crc32Str);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user