This commit is contained in:
huangzj
2023-08-03 14:03:46 +08:00
parent ab360ed348
commit 448af492d6
29 changed files with 457 additions and 151 deletions

View File

@@ -3,6 +3,7 @@ package com.njcn.csdevice.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.fallback.CsLedgerFeignClientFallbackFactory;
import com.njcn.csdevice.pojo.dto.LineParamDTO;
import com.njcn.csdevice.pojo.param.CsLedgerParam;
import com.njcn.csdevice.pojo.po.CsLedger;
import org.springframework.cloud.openfeign.FeignClient;
@@ -11,6 +12,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @author xy
*/
@@ -23,4 +26,8 @@ public interface CsLedgerFeignClient {
@PostMapping("/add")
HttpResult<CsLedger> add(@RequestBody @Validated CsLedgerParam csLedgerParam);
}
@PostMapping("/queryLine")
HttpResult<List<CsLedger>> queryLine(@RequestBody @Validated LineParamDTO lineParamdto);
}

View File

@@ -4,6 +4,7 @@ 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.csdevice.api.CsLedgerFeignClient;
import com.njcn.csdevice.pojo.dto.LineParamDTO;
import com.njcn.csdevice.pojo.param.CsLedgerParam;
import com.njcn.csdevice.pojo.po.CsLedger;
import com.njcn.csdevice.utils.CsDeviceEnumUtil;
@@ -11,6 +12,8 @@ import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author xy
*/
@@ -39,6 +42,12 @@ public class CsLedgerFeignClientFallbackFactory implements FallbackFactory<CsLed
log.error("{}异常,降级处理,异常为:{}","新增台账数据",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsLedger>> queryLine(LineParamDTO lineParamdto) {
log.error("{}异常,降级处理,异常为:{}","查询监测点",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -32,8 +32,8 @@ public enum AlgorithmResponseEnum {
CHIRLDREN_EXIST("A00513","工程下存在项目,不能删除"),
CHIRLDREN2_EXIST("A00514","项目下存在设备,不能删除"),
DATA_ARRAY_MISSING("A00515","详细数据为空")
DATA_ARRAY_MISSING("A00515","详细数据为空"),
UNKNOW_ROLE("A00515","角色无权限操作")
;

View File

@@ -0,0 +1,26 @@
package com.njcn.csdevice.pojo.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* Description:
* Date: 2023/8/1 15:25【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
public class LineParamDTO {
@ApiModelProperty(value = "工程id")
private String engineerId;
/**
* 项目Id
*/
@ApiModelProperty(value = "项目Id")
private String projectId;
@ApiModelProperty(value = "设备id")
private String devId;
}

View File

@@ -0,0 +1,18 @@
package com.njcn.csdevice.pojo.param;
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
import lombok.Data;
import java.util.List;
/**
* Description:
* Date: 2023/8/2 9:14【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
public class LinePostionParam {
private List<AppLineTopologyDiagramPO> pointList;
}

View File

@@ -17,29 +17,39 @@ import java.util.List;
@Data
public class DevCountVO {
@ApiModelProperty(value = "工程id")
private String id;
@ApiModelProperty(value = "设备总数")
private Integer allDevCount;
private List<CsEquipmentDeliveryPO> allDevs;
@ApiModelProperty(value = "在线设备数")
private Integer onLineCount;
//
@ApiModelProperty(value = "设备在线总数")
private Integer onLineDevCount;
private List<CsEquipmentDeliveryPO> onLineDevs;
@ApiModelProperty(value = "离线设备数")
private Integer offLineCount;
@ApiModelProperty(value = "设备离线总")
private Integer offLineDevCount;
private List<CsEquipmentDeliveryPO> offLineDevs;
@ApiModelProperty(value = "报警设备")
private Integer alarmLineCount;
private List<CsEquipmentAlarmVO> alarmLineDevs;
@ApiModelProperty(value = "设备报警事件数")
private Integer alarmEventCount;
@ApiModelProperty(value = "稳态/暂态发生事件数")
@ApiModelProperty(value = "警告")
private Integer alarmCount;
@ApiModelProperty(value = "事件数")
private Integer eventCount;
@ApiModelProperty(value = "项目数")
private Integer projectCount;
@ApiModelProperty(value = "当前工程id")
private String currentId;
@ApiModelProperty(value = "当前工程设备在线总数")
private Integer currentOnLineDevCount;
private List<CsEquipmentDeliveryPO> currentOnLineDevs;
@ApiModelProperty(value = "当前工程设备在线总数")
private Integer currentOffLineDevCount;
private List<CsEquipmentDeliveryPO> currentOffLineDevs;
@ApiModelProperty(value = "警告数")
private Integer currentAlarmCount;
@ApiModelProperty(value = "事件数")
private Integer currentEventCount;
@ApiModelProperty(value = "项目数")
private Integer currentProjectCount;
}

View File

@@ -0,0 +1,74 @@
package com.njcn.csdevice.utils;
import org.eclipse.paho.client.mqttv3.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
/**
* Description:
* Date: 2023/8/2 13:41【需求编号】
*
* @author clam
* @version V1.0.0
*/
public class MqttTest {
private static final String MQTT_BROKER = "tcp://192.168.1.13:1883";
private static final String MQTT_TOPIC = "file/upload";
private static final String FILE_PATH = "C:\\Users\\无名\\Desktop\\111.json"; // Replace with the path to your file
public static void main(String[] args) {
MqttClient mqttClient = null;
try {
// Connect to the MQTT broker
mqttClient = new MqttClient(MQTT_BROKER, MqttClient.generateClientId());
MqttConnectOptions connOpts = new MqttConnectOptions();
connOpts.setUserName("t_user");
connOpts.setPassword("njcnpqs".toCharArray());
mqttClient.connect(connOpts);
// Read the file
File file = new File(FILE_PATH);
FileInputStream fis = new FileInputStream(file);
byte[] fileContent = new byte[(int) file.length()];
fis.read(fileContent);
fis.close();
// Create a new MQTT message
MqttMessage message = new MqttMessage(fileContent);
// Set QoS level and retain flag as per your requirement
message.setQos(1);
// message.setRetained(false);
// Record the start time
long startTime = System.currentTimeMillis();
// Publish the message to the MQTT topic
mqttClient.publish(MQTT_TOPIC, message);
// Record the end time
long endTime = System.currentTimeMillis();
System.out.println("File published successfully!");
System.out.println("Time taken: " + (endTime - startTime) + " ms");
} catch (MqttException | IOException e) {
e.printStackTrace();
} finally {
// Disconnect from the MQTT broker
if (mqttClient != null && mqttClient.isConnected()) {
try {
mqttClient.disconnect();
} catch (MqttException e) {
e.printStackTrace();
}
}
}
}
}