delete old gateway
parent
806174e2e3
commit
5988ec6ce9
@ -1,18 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.bo;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 网关接受的Siemens iopoint实体 启用
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class ChangeStatus {
|
|
||||||
private String changesStatusID;
|
|
||||||
private String newStatus;
|
|
||||||
private String oldStatus;
|
|
||||||
}
|
|
||||||
@ -1,206 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.bo;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.entity.*;
|
|
||||||
import org.apache.http.message.BasicNameValuePair;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class HttpEntity {
|
|
||||||
|
|
||||||
public static List<BasicNameValuePair> getRemoveParam(String ids) {
|
|
||||||
List<BasicNameValuePair> params = new ArrayList<>();
|
|
||||||
params.add(new BasicNameValuePair("ids", ids));
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static List<BasicNameValuePair> getRemoveSiemens(Integer id) {
|
|
||||||
List<BasicNameValuePair> params = new ArrayList<>();
|
|
||||||
params.add(new BasicNameValuePair("ids", id.toString()));
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BasicNameValuePair> getPageParam(PageEntity pageEntity) {
|
|
||||||
List<BasicNameValuePair> params = new ArrayList<>();
|
|
||||||
params.add(new BasicNameValuePair("pageSize", pageEntity.getPageSize()));
|
|
||||||
params.add(new BasicNameValuePair("pageNum", pageEntity.getPageNum()));
|
|
||||||
params.add(new BasicNameValuePair("orderByColumn", pageEntity.getOrderByColumn()));
|
|
||||||
params.add(new BasicNameValuePair("isAsc", pageEntity.getIsAsc()));
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BasicNameValuePair> getPageParamVo(PageEntityByDecice pageEntity) {
|
|
||||||
List<BasicNameValuePair> params = new ArrayList<>();
|
|
||||||
params.add(new BasicNameValuePair("pageSize", pageEntity.getPageSize()));
|
|
||||||
params.add(new BasicNameValuePair("pageNum", pageEntity.getPageNum()));
|
|
||||||
params.add(new BasicNameValuePair("orderByColumn", pageEntity.getOrderByColumn()));
|
|
||||||
params.add(new BasicNameValuePair("isAsc", pageEntity.getIsAsc()));
|
|
||||||
params.add(new BasicNameValuePair("deviceID", pageEntity.getDeviceID()));
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BasicNameValuePair> getParam(DeviceSiemensEntity entity) {
|
|
||||||
List<BasicNameValuePair> params = new ArrayList<>();
|
|
||||||
params.add(new BasicNameValuePair("deviceConfigID", entity.getDeviceConfigID()));
|
|
||||||
params.add(new BasicNameValuePair("deviceID", entity.getDeviceID()));
|
|
||||||
params.add(new BasicNameValuePair("deviceName", entity.getDeviceName()));
|
|
||||||
params.add(new BasicNameValuePair("localPersistent", entity.getLocalPersistent()));
|
|
||||||
params.add(new BasicNameValuePair("rateCount", entity.getRateCount().toString()));
|
|
||||||
params.add(new BasicNameValuePair("siemensConnectParam", entity.getSiemensConnectParam()));
|
|
||||||
params.add(new BasicNameValuePair("siemensSeries", entity.getSiemensSeries()));
|
|
||||||
params.add(new BasicNameValuePair("uploadRate", entity.getUploadRate()));
|
|
||||||
params.add(new BasicNameValuePair("pageSize", entity.getReadRepeatValue().toString()));
|
|
||||||
params.add(new BasicNameValuePair("pageNum", entity.getWriteRepeatValue().toString()));
|
|
||||||
params.add(new BasicNameValuePair("ReadCron", entity.getReadCron()));
|
|
||||||
params.add(new BasicNameValuePair("ReadCronType", entity.getReadCronType()));
|
|
||||||
params.add(new BasicNameValuePair("ReadRepeatUnit", entity.getReadRepeatUnit()));
|
|
||||||
params.add(new BasicNameValuePair("WriteCron", entity.getWriteCron()));
|
|
||||||
params.add(new BasicNameValuePair("WriteCronType", entity.getWriteCronType()));
|
|
||||||
params.add(new BasicNameValuePair("WriteRepeatUnit", entity.getWriteRepeatUnit()));
|
|
||||||
params.add(new BasicNameValuePair("ids", entity.getWriteRepeatUnit()));
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BasicNameValuePair> getParam(DeviceModbusEntity entity) {
|
|
||||||
List<BasicNameValuePair> params = new ArrayList<>();
|
|
||||||
if (entity.getReadRepeatValue() != null) {
|
|
||||||
params.add(new BasicNameValuePair("pageSize", entity.getReadRepeatValue().toString()));
|
|
||||||
}
|
|
||||||
if (entity.getWriteRepeatValue() != null) {
|
|
||||||
params.add(new BasicNameValuePair("pageNum", entity.getWriteRepeatValue().toString()));
|
|
||||||
}
|
|
||||||
if (entity.getDeviceConfigID() != null) {
|
|
||||||
params.add(new BasicNameValuePair("orderByColumn", entity.getDeviceConfigID()));
|
|
||||||
}
|
|
||||||
if (entity.getDeviceId() != null) {
|
|
||||||
params.add(new BasicNameValuePair("deviceID", entity.getDeviceId()));
|
|
||||||
}
|
|
||||||
if (entity.getDeviceName() != null) {
|
|
||||||
params.add(new BasicNameValuePair("deviceName", entity.getDeviceName()));
|
|
||||||
}
|
|
||||||
if (entity.getModbusProtocol() != null) {
|
|
||||||
params.add(new BasicNameValuePair("modbusProtocol", entity.getModbusProtocol()));
|
|
||||||
}
|
|
||||||
if (entity.getModbusPattern() != null) {
|
|
||||||
params.add(new BasicNameValuePair("modbusPattern", entity.getModbusPattern()));
|
|
||||||
}
|
|
||||||
if (entity.getPortName() != null) {
|
|
||||||
params.add(new BasicNameValuePair("portName", entity.getPortName()));
|
|
||||||
}
|
|
||||||
if (entity.getModbusConnectParam() != null) {
|
|
||||||
params.add(new BasicNameValuePair("modbusConnectParam", entity.getModbusConnectParam()));
|
|
||||||
}
|
|
||||||
if (entity.getReadCronType() != null) {
|
|
||||||
params.add(new BasicNameValuePair("readCronType", entity.getReadCronType()));
|
|
||||||
}
|
|
||||||
if (entity.getReadRepeatValue() != null) {
|
|
||||||
params.add(new BasicNameValuePair("readRepeatValue", entity.getReadRepeatValue().toString()));
|
|
||||||
}
|
|
||||||
if (entity.getReadRepeatUnit() != null) {
|
|
||||||
params.add(new BasicNameValuePair("readRepeatUnit", entity.getReadRepeatUnit()));
|
|
||||||
}
|
|
||||||
if (entity.getReadCron() != null) {
|
|
||||||
params.add(new BasicNameValuePair("readCron", entity.getReadCron()));
|
|
||||||
}
|
|
||||||
if (entity.getWriteCronType() != null) {
|
|
||||||
params.add(new BasicNameValuePair("writeCronType", entity.getWriteCronType()));
|
|
||||||
}
|
|
||||||
if (entity.getWriteRepeatValue() != null) {
|
|
||||||
params.add(new BasicNameValuePair("writeRepeatValue", entity.getWriteRepeatValue().toString()));
|
|
||||||
}
|
|
||||||
if (entity.getWriteRepeatUnit() != null) {
|
|
||||||
params.add(new BasicNameValuePair("writeRepeatUnit", entity.getWriteRepeatUnit()));
|
|
||||||
}
|
|
||||||
if (entity.getReadRepeatValue() != null) {
|
|
||||||
params.add(new BasicNameValuePair("writeCron", entity.getWriteCron()));
|
|
||||||
}
|
|
||||||
if (entity.getLocalPersistent() != null) {
|
|
||||||
params.add(new BasicNameValuePair("localPersistent", entity.getLocalPersistent()));
|
|
||||||
}
|
|
||||||
if (entity.getUploadRate() != null) {
|
|
||||||
params.add(new BasicNameValuePair("uploadRate", entity.getUploadRate()));
|
|
||||||
}
|
|
||||||
if (entity.getRateCount() != null) {
|
|
||||||
params.add(new BasicNameValuePair("rateCount", entity.getRateCount().toString()));
|
|
||||||
}
|
|
||||||
if (entity.getModbusReadAddrGap() != null) {
|
|
||||||
params.add(new BasicNameValuePair("modbusReadAddrGap", entity.getModbusReadAddrGap()));
|
|
||||||
}
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BasicNameValuePair> getParam(ModbusPointEntity entity) {
|
|
||||||
List<BasicNameValuePair> params = new ArrayList<>();
|
|
||||||
params.add(new BasicNameValuePair("deviceConfigContentID", entity.getDeviceConfigContentID()));
|
|
||||||
params.add(new BasicNameValuePair("modbusAddressType", entity.getModbusAddressType()));
|
|
||||||
// params.add(new BasicNameValuePair("modbusFieldAccess", entity.getModbusFieldAccess()));
|
|
||||||
params.add(new BasicNameValuePair("modbusFieldAddress", entity.getModbusFieldAddress()));
|
|
||||||
params.add(new BasicNameValuePair("modbusFieldDataType", entity.getModbusFieldDataType()));
|
|
||||||
params.add(new BasicNameValuePair("modbusFieldName", entity.getModbusFieldName()));
|
|
||||||
params.add(new BasicNameValuePair("modbusFieldOrder", entity.getModbusFieldOrder()));
|
|
||||||
params.add(new BasicNameValuePair("modbusFieldPrecision", entity.getModbusFieldPrecision()));
|
|
||||||
if (entity.getModbusFieldSize() != null) {
|
|
||||||
params.add(new BasicNameValuePair("modbusFieldSize", entity.getModbusFieldSize().toString()));
|
|
||||||
}
|
|
||||||
params.add(new BasicNameValuePair("modbusFieldUnit", entity.getModbusFieldUnit()));
|
|
||||||
params.add(new BasicNameValuePair("modbusSlaveID", entity.getModbusSlaveID()));
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BasicNameValuePair> getParam(SiemensPointEntity entity) {
|
|
||||||
List<BasicNameValuePair> params = new ArrayList<>();
|
|
||||||
params.add(new BasicNameValuePair("deviceConfigContentID", String.valueOf(entity.getDeviceConfigContentID())));
|
|
||||||
params.add(new BasicNameValuePair("siemensFieldAddress", entity.getSiemensFieldAddress()));
|
|
||||||
params.add(new BasicNameValuePair("siemensFieldDataType", entity.getSiemensFieldDataType().toString()));
|
|
||||||
params.add(new BasicNameValuePair("siemensFieldName", entity.getSiemensFieldName()));
|
|
||||||
params.add(new BasicNameValuePair("siemensFieldPrecision", String.valueOf(entity.getSiemensFieldPrecision())));
|
|
||||||
params.add(new BasicNameValuePair("siemensFieldUnit", entity.getSiemensFieldUnit()));
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BasicNameValuePair> getParam(DeviceVideoEntity entity) {
|
|
||||||
List<BasicNameValuePair> params = new ArrayList<>();
|
|
||||||
// params.add(new BasicNameValuePair("deviceConfigID", String.valueOf(entity.getDeviceConfigID())));
|
|
||||||
params.add(new BasicNameValuePair("deviceID", entity.getDeviceID()));
|
|
||||||
params.add(new BasicNameValuePair("videoAddress", entity.getVideoAddress()));
|
|
||||||
params.add(new BasicNameValuePair("serverAddress", entity.getServerAddress()));
|
|
||||||
params.add(new BasicNameValuePair("deviceName", String.valueOf(entity.getDeviceName())));
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BasicNameValuePair> getParam(MqttBrokerEntity entity) {
|
|
||||||
List<BasicNameValuePair> params = new ArrayList<>();
|
|
||||||
params.add(new BasicNameValuePair("cloudConfigID", entity.getCloudConfigID()));
|
|
||||||
params.add(new BasicNameValuePair("cloudStatus", entity.getCloudStatus()));
|
|
||||||
params.add(new BasicNameValuePair("createTime", entity.getCreateTime()));
|
|
||||||
params.add(new BasicNameValuePair("updateTime", entity.getUpdateTime()));
|
|
||||||
params.add(new BasicNameValuePair("mqttAddress", entity.getMqttAddress()));
|
|
||||||
params.add(new BasicNameValuePair("mqttPassword", entity.getMqttPassword()));
|
|
||||||
params.add(new BasicNameValuePair("mqttUserName", entity.getMqttUserName()));
|
|
||||||
params.add(new BasicNameValuePair("mqttPort", entity.getMqttPort()));
|
|
||||||
params.add(new BasicNameValuePair("mqttPublishTopic", entity.getMqttPublishTopic()));
|
|
||||||
params.add(new BasicNameValuePair("mqttSslFlag", entity.getMqttSslFlag().toString()));
|
|
||||||
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*启用模型*/
|
|
||||||
public static List<BasicNameValuePair> getChangestatus(ChangeStatus changeStatus) {
|
|
||||||
List<BasicNameValuePair> params = new ArrayList<>();
|
|
||||||
params.add(new BasicNameValuePair("changesStatusID", changeStatus.getChangesStatusID()));
|
|
||||||
params.add(new BasicNameValuePair("newStatus", changeStatus.getNewStatus()));
|
|
||||||
params.add(new BasicNameValuePair("oldStatus", changeStatus.getOldStatus()));
|
|
||||||
|
|
||||||
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BasicNameValuePair> getLoginParam(String username, String password) {
|
|
||||||
List<BasicNameValuePair> params = new ArrayList<>();
|
|
||||||
params.add(new BasicNameValuePair("username", username));
|
|
||||||
params.add(new BasicNameValuePair("password", password));
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.bo;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class ListEntity {
|
|
||||||
String code;
|
|
||||||
String msg;
|
|
||||||
String total;
|
|
||||||
List<JSONObject> rows;
|
|
||||||
}
|
|
||||||
@ -1,98 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.entity;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class DeviceSiemensEntity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库id
|
|
||||||
*/
|
|
||||||
String deviceConfigID;
|
|
||||||
/**
|
|
||||||
* 设备编号
|
|
||||||
*/
|
|
||||||
String deviceID;//71220220500200001
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备名称
|
|
||||||
*/
|
|
||||||
String deviceName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Siemens系列
|
|
||||||
*/
|
|
||||||
String siemensSeries;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 连接参数
|
|
||||||
*/
|
|
||||||
String siemensConnectParam;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 读取任务
|
|
||||||
*/
|
|
||||||
String readCronType;//无、频率、定点
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 频率值
|
|
||||||
*/
|
|
||||||
Integer readRepeatValue;//正整数
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 读单位
|
|
||||||
*/
|
|
||||||
String readRepeatUnit;//秒、分、时、毫秒
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 读取任务时间表达式
|
|
||||||
*/
|
|
||||||
String readCron;
|
|
||||||
|
|
||||||
//写入任务时间间隔
|
|
||||||
String writeCronType;
|
|
||||||
|
|
||||||
//写入任务时间间隔
|
|
||||||
Integer writeRepeatValue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据库id
|
|
||||||
*/
|
|
||||||
String writeRepeatUnit;
|
|
||||||
/**
|
|
||||||
* 写入任务时间表达式
|
|
||||||
*/
|
|
||||||
String writeCron;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否持久化
|
|
||||||
*/
|
|
||||||
String localPersistent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上传
|
|
||||||
*/
|
|
||||||
String uploadRate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 不变次数
|
|
||||||
*/
|
|
||||||
Integer rateCount;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备类型
|
|
||||||
*/
|
|
||||||
String deviceType; //siemens、modbus
|
|
||||||
String deviceComm; //1
|
|
||||||
String deviceStatus;//0,notok; 1,ok
|
|
||||||
String createTime;
|
|
||||||
String updateTime;
|
|
||||||
String portName;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.entity;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class DeviceVideoEntity {
|
|
||||||
/**
|
|
||||||
* 网关管理后台的id
|
|
||||||
*/
|
|
||||||
private String deviceConfigID;
|
|
||||||
/**
|
|
||||||
* 设备编号
|
|
||||||
*/
|
|
||||||
private String deviceID;
|
|
||||||
/**
|
|
||||||
* 视频地址
|
|
||||||
*/
|
|
||||||
private String videoAddress;
|
|
||||||
/**
|
|
||||||
* 服务地址
|
|
||||||
*/
|
|
||||||
private String serverAddress;
|
|
||||||
/**
|
|
||||||
* 视频名称
|
|
||||||
*/
|
|
||||||
private String deviceName;
|
|
||||||
}
|
|
||||||
@ -1,52 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.entity;
|
|
||||||
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 网关接受的iopoint实体
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class ModbusPointEntity {
|
|
||||||
|
|
||||||
String deviceConfigContentID;
|
|
||||||
//站号
|
|
||||||
//@Excel(name = "站号")
|
|
||||||
String modbusSlaveID;
|
|
||||||
//地址名称/编码(下发用)
|
|
||||||
//@Excel(name = "地址编码")
|
|
||||||
String modbusFieldName;// json_flag
|
|
||||||
//地址名称 真的名称
|
|
||||||
//@Excel(name = "地址名称")
|
|
||||||
String modbusName;// json_flag
|
|
||||||
//寄存器地址
|
|
||||||
//@Excel(name = "寄存器地址")
|
|
||||||
String modbusFieldAddress;// 111
|
|
||||||
//寄存器地址类型
|
|
||||||
//@Excel(name = "寄存器地址类型")
|
|
||||||
String modbusAddressType;// 1
|
|
||||||
//个数
|
|
||||||
//@Excel(name = "个数")
|
|
||||||
Integer modbusFieldSize;// 2
|
|
||||||
//缩放因子
|
|
||||||
//@Excel(name = "缩放因子")
|
|
||||||
String modbusFieldPrecision;// 1
|
|
||||||
//数据类型
|
|
||||||
//@Excel(name = "数据类型")
|
|
||||||
String modbusFieldDataType;// 1
|
|
||||||
//字节顺序
|
|
||||||
//@Excel(name = "字节顺序")
|
|
||||||
String modbusFieldOrder;//DCBA
|
|
||||||
//单位
|
|
||||||
//@Excel(name = "单位")
|
|
||||||
String modbusFieldUnit;// s
|
|
||||||
//@Excel(name = "机台编码")
|
|
||||||
String equipmentCode;
|
|
||||||
//@Excel(name = "设备编码")
|
|
||||||
String deviceCode;
|
|
||||||
}
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.entity;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class MqttBrokerEntity {
|
|
||||||
|
|
||||||
private String mqttAddress;//ip地址
|
|
||||||
private String mqttPort;//端口
|
|
||||||
private String mqttUserName;//授权账号 一定要授权的
|
|
||||||
private String mqttPassword;//密码
|
|
||||||
private String mqttPublishTopic;//发布主题
|
|
||||||
private Boolean mqttSslFlag; //是否启用ssl
|
|
||||||
|
|
||||||
private String cloudConfigID;
|
|
||||||
private String cloudAddress;
|
|
||||||
private String cloudStatus;
|
|
||||||
private String createTime;
|
|
||||||
private String updateTime;
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.entity;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class PageEntity {
|
|
||||||
|
|
||||||
//String pageSize,String pageNum,String orderByColumn,String isAsc
|
|
||||||
String pageSize; // 10
|
|
||||||
String pageNum; //: 1
|
|
||||||
String orderByColumn; //: updateTime
|
|
||||||
String isAsc; //: asc
|
|
||||||
|
|
||||||
// String deviceID; //: 设备编码
|
|
||||||
public PageEntity() {
|
|
||||||
this.isAsc = "asc";
|
|
||||||
this.orderByColumn = "updateTime";
|
|
||||||
this.pageSize = "100";
|
|
||||||
this.pageNum = "1";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.entity;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class PageEntityByDecice {
|
|
||||||
|
|
||||||
//String pageSize,String pageNum,String orderByColumn,String isAsc
|
|
||||||
String pageSize; // 10
|
|
||||||
String pageNum; //: 1
|
|
||||||
String orderByColumn; //: updateTime
|
|
||||||
String isAsc; //: asc
|
|
||||||
String deviceID; //: 设备编码
|
|
||||||
|
|
||||||
public PageEntityByDecice() {
|
|
||||||
this.isAsc = "asc";
|
|
||||||
this.orderByColumn = "updateTime";
|
|
||||||
this.pageSize = "100";
|
|
||||||
this.pageNum = "1";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,57 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.entity;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 网关接受的Siemens iopoint实体
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class SiemensPointEntity {
|
|
||||||
/**
|
|
||||||
* 数据库id
|
|
||||||
*/
|
|
||||||
Integer deviceConfigContentID;
|
|
||||||
/**
|
|
||||||
* 地址编码
|
|
||||||
*/
|
|
||||||
//@Excel(name = "地址编码")
|
|
||||||
String siemensFieldName;
|
|
||||||
/**
|
|
||||||
* 地址名称
|
|
||||||
*/
|
|
||||||
//@Excel(name = "地址名称")
|
|
||||||
String siemensName;
|
|
||||||
/**
|
|
||||||
* 地址
|
|
||||||
*/
|
|
||||||
//@Excel(name = "地址")
|
|
||||||
String siemensFieldAddress;
|
|
||||||
/**
|
|
||||||
* 数据类型(下发用value值)
|
|
||||||
*/
|
|
||||||
Integer siemensFieldDataType;
|
|
||||||
/**
|
|
||||||
* 数据类型名称
|
|
||||||
*/
|
|
||||||
//@Excel(name = "数据类型名称")
|
|
||||||
String siemensFieldDataTypeName;
|
|
||||||
/**
|
|
||||||
* 数据精度
|
|
||||||
*/
|
|
||||||
//@Excel(name = "数据精度")
|
|
||||||
Integer siemensFieldPrecision;
|
|
||||||
/**
|
|
||||||
* 数据单位
|
|
||||||
*/
|
|
||||||
//@Excel(name = "数据单位")
|
|
||||||
String siemensFieldUnit;
|
|
||||||
//@Excel(name = "机台编码")
|
|
||||||
String equipmentCode;
|
|
||||||
//@Excel(name = "设备编码")
|
|
||||||
String deviceCode;
|
|
||||||
}
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.service;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.bo.ChangeStatus;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.entity.MqttBrokerEntity;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public interface GatewayMqttService {
|
|
||||||
public void login(String url, String username, String password);
|
|
||||||
|
|
||||||
//获取mqtt主题
|
|
||||||
public List<MqttBrokerEntity> getMqttBrokerEntity(String url, String username, String password);
|
|
||||||
|
|
||||||
//下发单个mqtt主题
|
|
||||||
public int add(MqttBrokerEntity entity, String url);
|
|
||||||
|
|
||||||
//删除mqtt主题
|
|
||||||
public int delete(String url, String ids);
|
|
||||||
|
|
||||||
//启用网关
|
|
||||||
public int changeStatus(ChangeStatus changeStatus, String url);
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,48 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.service;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.bo.ChangeStatus;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.entity.DeviceModbusEntity;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.entity.ModbusPointEntity;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public interface IModbusPointService {
|
|
||||||
|
|
||||||
public void login(String url, String username, String password);
|
|
||||||
|
|
||||||
/*modbus*/
|
|
||||||
//获取设备列表
|
|
||||||
public List<DeviceModbusEntity> getModbusList(String url, String username, String password);
|
|
||||||
|
|
||||||
//获取指定设备编码列表
|
|
||||||
public List<DeviceModbusEntity> getModbusList(String url, String username, String password, String deviceId);
|
|
||||||
|
|
||||||
//下发单个设备
|
|
||||||
public int add(DeviceModbusEntity entity, String url);
|
|
||||||
|
|
||||||
public int add(List<DeviceModbusEntity> list, String url);
|
|
||||||
|
|
||||||
//删除单个设备
|
|
||||||
public int delete(String url, String ids);
|
|
||||||
|
|
||||||
//启用
|
|
||||||
public int changeStatus(ChangeStatus changeStatus, String url);
|
|
||||||
|
|
||||||
|
|
||||||
//获取设备点位列表
|
|
||||||
public List<ModbusPointEntity> getPointList(String url, String username, String password, String deviceConfigID); //下发点位
|
|
||||||
|
|
||||||
//下发点位
|
|
||||||
public int add(ModbusPointEntity point, String url, String id);
|
|
||||||
|
|
||||||
public int add(List<ModbusPointEntity> list, String address, String deviceConfigID);
|
|
||||||
|
|
||||||
//删除点位
|
|
||||||
public int deletePoint(String url, String ids);
|
|
||||||
|
|
||||||
Integer getPointListByCount(String url, String username, String password, String deviceConfigID);
|
|
||||||
|
|
||||||
List<ModbusPointEntity> getPointListAll(String adminIp, String username, String password, String deviceConfigID);
|
|
||||||
}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.service;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.entity.DeviceVideoEntity;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public interface IVideoService {
|
|
||||||
public void login(String url, String username, String password);
|
|
||||||
|
|
||||||
|
|
||||||
List<DeviceVideoEntity> getVideoId(String adminIp, String username, String password, String monitorCode);
|
|
||||||
|
|
||||||
|
|
||||||
int deleteByIds(String adminIp, String ids);
|
|
||||||
|
|
||||||
int add(DeviceVideoEntity list, String adminIp);
|
|
||||||
|
|
||||||
int openOrClose(String adminIp, String videoId);
|
|
||||||
}
|
|
||||||
@ -1,143 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.service.impl;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.bo.ChangeStatus;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.bo.HttpEntity;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.entity.MqttBrokerEntity;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.service.GatewayMqttService;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.util.HttpUtils;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.util.JsonUtils;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.util.UrlConstans;
|
|
||||||
import org.apache.http.client.ClientProtocolException;
|
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
||||||
import org.apache.http.client.methods.HttpPost;
|
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
|
||||||
import org.apache.http.util.EntityUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class GatewayMqttServiceImpl implements GatewayMqttService {
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(GatewayMqttServiceImpl.class);
|
|
||||||
private String cookie;
|
|
||||||
|
|
||||||
//先登录
|
|
||||||
@Override
|
|
||||||
public void login(String url, String username, String password) {
|
|
||||||
// 创建 HttpClient 客户端
|
|
||||||
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
|
|
||||||
CloseableHttpResponse httpResponse = null;
|
|
||||||
try {
|
|
||||||
HttpPost httpPost = HttpUtils.getHttpPost(url + UrlConstans.loginUrl, HttpEntity.getLoginParam(username, password));
|
|
||||||
httpResponse = httpClient.execute(httpPost);
|
|
||||||
log.debug(EntityUtils.toString(httpResponse.getEntity()));
|
|
||||||
this.cookie = HttpUtils.getCookies(httpResponse);
|
|
||||||
}
|
|
||||||
// 无论如何必须关闭连接
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
HttpUtils.closeHttp(httpClient, httpResponse);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<MqttBrokerEntity> getMqttBrokerEntity(String url, String username, String password) {
|
|
||||||
|
|
||||||
// 创建 HttpClient 客户端
|
|
||||||
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
|
|
||||||
CloseableHttpResponse httpResponse = null;
|
|
||||||
List<MqttBrokerEntity> list = null;
|
|
||||||
try {
|
|
||||||
String getlistUrl = url + UrlConstans.mqtt_list;
|
|
||||||
HttpPost httpPost = HttpUtils.getHttpPost(getlistUrl, null);//检索条件
|
|
||||||
httpPost.setHeader("Cookie", cookie);
|
|
||||||
httpResponse = httpClient.execute(httpPost);
|
|
||||||
if (httpResponse.getEntity() != null) {
|
|
||||||
String entityStr = EntityUtils.toString(httpResponse.getEntity());
|
|
||||||
list = JsonUtils.toMqttEntityList(entityStr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 无论如何必须关闭连接
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
HttpUtils.closeHttp(httpClient, httpResponse);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int add(MqttBrokerEntity entity, String address) {
|
|
||||||
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
|
|
||||||
CloseableHttpResponse httpResponse = null;
|
|
||||||
HttpPost httpPost = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (entity.getCloudConfigID() != null) {
|
|
||||||
httpPost = HttpUtils.getHttpPost(address + UrlConstans.mqtt_edit, HttpEntity.getParam(entity));
|
|
||||||
} else {
|
|
||||||
httpPost = HttpUtils.getHttpPost(address + UrlConstans.mqtt_add, HttpEntity.getParam(entity));
|
|
||||||
}
|
|
||||||
httpPost.setHeader("Cookie", cookie);
|
|
||||||
httpResponse = httpClient.execute(httpPost);
|
|
||||||
System.err.println(EntityUtils.toString(httpResponse.getEntity()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return 1;
|
|
||||||
} finally {
|
|
||||||
HttpUtils.closeHttp(httpClient, httpResponse);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int delete(String address, String ids) {
|
|
||||||
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
|
|
||||||
CloseableHttpResponse httpResponse = null;
|
|
||||||
HttpPost httpPost = null;
|
|
||||||
try {
|
|
||||||
httpPost = HttpUtils.getHttpPost(address + UrlConstans.mqtt_remove, HttpEntity.getRemoveParam(ids));//网关上设备的id
|
|
||||||
httpPost.setHeader("Cookie", cookie);
|
|
||||||
httpResponse = httpClient.execute(httpPost);
|
|
||||||
System.err.println("删除" + httpResponse.getEntity());
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ClientProtocolException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
HttpUtils.closeHttp(httpClient, httpResponse);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int changeStatus(ChangeStatus changeStatus, String address) {
|
|
||||||
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
|
|
||||||
CloseableHttpResponse httpResponse = null;
|
|
||||||
HttpPost httpPost = null;
|
|
||||||
httpPost.setHeader("Cookie", cookie);
|
|
||||||
try {
|
|
||||||
httpPost = HttpUtils.getHttpPost(address + UrlConstans.mqtt_changestatus, HttpEntity.getChangestatus(changeStatus));
|
|
||||||
// httpPost.setHeader("Cookie", cookie);
|
|
||||||
httpResponse = httpClient.execute(httpPost);
|
|
||||||
System.err.println("启用" + httpResponse.getEntity());
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ClientProtocolException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
HttpUtils.closeHttp(httpClient, httpResponse);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,503 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.service.impl;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
||||||
import cn.iocoder.yudao.module.iot.dal.dataobject.device.DeviceAttributeDO;
|
|
||||||
import cn.iocoder.yudao.module.iot.dal.dataobject.device.DeviceDO;
|
|
||||||
import cn.iocoder.yudao.module.iot.dal.dataobject.gateway.GatewayDO;
|
|
||||||
import cn.iocoder.yudao.module.iot.dal.mysql.device.DeviceAttributeMapper;
|
|
||||||
import cn.iocoder.yudao.module.iot.dal.mysql.device.DeviceMapper;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.constant.AddressDataType;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.bo.ChangeStatus;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.bo.HttpEntity;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.entity.*;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.service.GatewayMqttService;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.service.IModbusPointService;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.service.ISiemensPointService;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.service.IVideoService;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.util.HttpUtils;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.util.UrlConstans;
|
|
||||||
import cn.iocoder.yudao.module.iot.service.gateway.GatewayService;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
||||||
import org.apache.http.client.methods.HttpPost;
|
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
|
||||||
import org.apache.http.util.EntityUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class TheGatewayServiceImpl {
|
|
||||||
@Resource
|
|
||||||
private DeviceMapper deviceMapper;
|
|
||||||
@Resource
|
|
||||||
private DeviceAttributeMapper deviceAttributeMapper;
|
|
||||||
@Resource
|
|
||||||
private IVideoService videoService;
|
|
||||||
@Resource
|
|
||||||
private ISiemensPointService siemensPointService;
|
|
||||||
@Resource
|
|
||||||
private IModbusPointService modbusPointService;
|
|
||||||
@Resource
|
|
||||||
private GatewayMqttService gatewayMqttService;
|
|
||||||
@Resource
|
|
||||||
private GatewayService gatewayService;
|
|
||||||
|
|
||||||
//清除原本的西门子设备和点位数据
|
|
||||||
// public void deleteSiemensEntity(BeEquipments equipments) {
|
|
||||||
// siemensPointService.login(equipments.getAdminIp(), equipments.getUsername(), equipments.getPassword());
|
|
||||||
// List<DeviceSiemensEntity> list = siemensPointService.getSiemensList(equipments.getAdminIp(),
|
|
||||||
// equipments.getUsername(), equipments.getPassword());
|
|
||||||
// if (null != list && list.size() > 0) {
|
|
||||||
// //先清除点位数据
|
|
||||||
// String[] deviceIds = new String[list.size()];
|
|
||||||
// for (int i = 0; i < list.size(); i++) {
|
|
||||||
// deviceIds[i] = list.get(i).getDeviceConfigID();
|
|
||||||
// //删除每个设备下的原有点位
|
|
||||||
// List<SiemensPointEntity> pointList = siemensPointService.getPointList(equipments.getAdminIp(),
|
|
||||||
// list.get(i).getDeviceConfigID(), equipments.getUsername(), equipments.getPassword());
|
|
||||||
// if (pointList != null && pointList.size() > 0) {
|
|
||||||
// String[] addressIds = new String[pointList.size()];
|
|
||||||
// for (int j = 0; j < pointList.size(); j++) {
|
|
||||||
// addressIds[j] = pointList.get(j).getDeviceConfigContentID().toString();
|
|
||||||
// }
|
|
||||||
// //删除点位
|
|
||||||
// siemensPointService.deletePoint(equipments.getAdminIp(), String.join(",", addressIds));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// //再清除设备数据
|
|
||||||
// siemensPointService.delete(equipments.getAdminIp(), String.join(",", deviceIds));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
//清除指定原本的西门子设备和点位数据
|
|
||||||
public void deleteSiemensEntity(GatewayDO gatewayDO, DeviceDO deviceDO) {
|
|
||||||
|
|
||||||
siemensPointService.login(gatewayDO.getAdminIp(), gatewayDO.getUsername(), gatewayDO.getPassword());
|
|
||||||
List<DeviceSiemensEntity> list = siemensPointService.getSiemensList(gatewayDO.getAdminIp(),
|
|
||||||
gatewayDO.getUsername(), gatewayDO.getPassword(), deviceDO.getDeviceCode());
|
|
||||||
if (null != list && list.size() > 0) {
|
|
||||||
//先清除点位数据
|
|
||||||
String[] deviceIds = new String[list.size()];
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
deviceIds[i] = list.get(i).getDeviceConfigID();
|
|
||||||
//删除每个设备下的原有点位
|
|
||||||
List<SiemensPointEntity> pointList = siemensPointService.getPointListAll(gatewayDO.getAdminIp(),
|
|
||||||
list.get(i).getDeviceConfigID(), gatewayDO.getUsername(), gatewayDO.getPassword());
|
|
||||||
if (pointList != null && pointList.size() > 0) {
|
|
||||||
String[] addressIds = new String[pointList.size()];
|
|
||||||
for (int j = 0; j < pointList.size(); j++) {
|
|
||||||
addressIds[j] = pointList.get(j).getDeviceConfigContentID().toString();
|
|
||||||
}
|
|
||||||
//删除点位
|
|
||||||
siemensPointService.deletePoint(gatewayDO.getAdminIp(), String.join(",", addressIds));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//再清除设备数据
|
|
||||||
siemensPointService.delete(gatewayDO.getAdminIp(), String.join(",", deviceIds));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//查询西门子设备列表 并新增
|
|
||||||
// public void addSiemensEntity(BeEquipments equipments) {
|
|
||||||
// siemensPointService.login(equipments.getAdminIp(), equipments.getUsername(), equipments.getPassword());
|
|
||||||
// //根据机台编号查询设备
|
|
||||||
// BeEquipmentsSiemens bo = new BeEquipmentsSiemens();
|
|
||||||
// bo.setEquipmentsId(equipments.getEquipmentsId());
|
|
||||||
// List<BeEquipmentsSiemens> siemens = beEquipmentsSiemensService.list(beEquipmentsSiemensService.buildQueryWrapper(bo));
|
|
||||||
// if (siemens != null && siemens.size() > 0) {
|
|
||||||
// List<DeviceSiemensEntity> list = new ArrayList<>();
|
|
||||||
// for (BeEquipmentsSiemens siemen : siemens) {
|
|
||||||
// DeviceSiemensEntity deviceSiemensEntity = new DeviceSiemensEntity();
|
|
||||||
// deviceSiemensEntity.setDeviceID(siemen.getDeviceId());
|
|
||||||
// deviceSiemensEntity.setDeviceName(siemen.getDeviceName());
|
|
||||||
// deviceSiemensEntity.setSiemensSeries(siemen.getSiemensSeries());
|
|
||||||
// deviceSiemensEntity.setSiemensConnectParam(siemen.getSiemensConnectParam());
|
|
||||||
// deviceSiemensEntity.setReadCronType(siemen.getReadCronType());
|
|
||||||
// deviceSiemensEntity.setReadRepeatValue(siemen.getReadRepeatValue());
|
|
||||||
// deviceSiemensEntity.setReadRepeatUnit(siemen.getReadRepeatUnit());
|
|
||||||
// deviceSiemensEntity.setReadCron(siemen.getReadCron());
|
|
||||||
// deviceSiemensEntity.setWriteCronType(siemen.getWriteCronType());
|
|
||||||
// deviceSiemensEntity.setWriteRepeatValue(siemen.getWriteRepeatValue());
|
|
||||||
// deviceSiemensEntity.setWriteCron(siemen.getWriteCron());
|
|
||||||
// deviceSiemensEntity.setLocalPersistent(siemen.getLocalPersistent());
|
|
||||||
// deviceSiemensEntity.setUploadRate(siemen.getUploadRate());
|
|
||||||
// deviceSiemensEntity.setRateCount(siemen.getRateCount());
|
|
||||||
// list.add(deviceSiemensEntity);
|
|
||||||
// }
|
|
||||||
// if (list.size() > 0) siemensPointService.add(list, equipments.getAdminIp());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
//新增西门子设备
|
|
||||||
public void addSiemensEntity(GatewayDO gatewayDO, DeviceDO siemens) {
|
|
||||||
siemensPointService.login(gatewayDO.getAdminIp(), gatewayDO.getUsername(), gatewayDO.getPassword());
|
|
||||||
DeviceSiemensEntity deviceSiemensEntity = new DeviceSiemensEntity();
|
|
||||||
deviceSiemensEntity.setDeviceID(siemens.getDeviceCode());
|
|
||||||
deviceSiemensEntity.setDeviceName(siemens.getDeviceName());
|
|
||||||
deviceSiemensEntity.setSiemensSeries(siemens.getSiemensSeries());
|
|
||||||
deviceSiemensEntity.setSiemensConnectParam(siemens.getSiemensConnectParam());
|
|
||||||
deviceSiemensEntity.setReadCronType(siemens.getReadCronType());
|
|
||||||
deviceSiemensEntity.setReadRepeatValue(siemens.getReadRepeatValue());
|
|
||||||
deviceSiemensEntity.setReadRepeatUnit(siemens.getReadRepeatUnit());
|
|
||||||
deviceSiemensEntity.setReadCron(siemens.getReadCron());
|
|
||||||
deviceSiemensEntity.setWriteCronType(siemens.getWriteCronType());
|
|
||||||
deviceSiemensEntity.setWriteRepeatValue(siemens.getWriteRepeatValue());
|
|
||||||
deviceSiemensEntity.setWriteCron(siemens.getWriteCron());
|
|
||||||
deviceSiemensEntity.setLocalPersistent(siemens.getLocalPersistent());
|
|
||||||
deviceSiemensEntity.setUploadRate(siemens.getUploadRate());
|
|
||||||
deviceSiemensEntity.setRateCount(siemens.getRateCount());
|
|
||||||
siemensPointService.add(deviceSiemensEntity, gatewayDO.getAdminIp());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//下发完成西门子设备后 下发对应设备的点位
|
|
||||||
public void addDeviceSiemensEntity(GatewayDO gatewayDO, Long machineId, DeviceDO deviceDO) {
|
|
||||||
siemensPointService.login(gatewayDO.getAdminIp(), gatewayDO.getUsername(), gatewayDO.getPassword());
|
|
||||||
/*下发好设备后获取设备列表找点位*/
|
|
||||||
List<DeviceSiemensEntity> siemensList = siemensPointService.getSiemensList(gatewayDO.getAdminIp(),
|
|
||||||
gatewayDO.getUsername(), gatewayDO.getPassword(), deviceDO.getDeviceCode());
|
|
||||||
for (DeviceSiemensEntity deviceSiemensEntity : siemensList) {
|
|
||||||
//根据deviceId 和机台编码查询sql数据库点位信息
|
|
||||||
List<DeviceAttributeDO> points = deviceAttributeMapper.selectByDeviceId(deviceDO.getId());
|
|
||||||
List<SiemensPointEntity> list = new ArrayList<>();
|
|
||||||
for (DeviceAttributeDO point : points) {
|
|
||||||
Integer dataType = AddressDataType.getGatewayDataTypeMap(point.getDataType());
|
|
||||||
//新增点位
|
|
||||||
SiemensPointEntity siemensPointEntity = new SiemensPointEntity()
|
|
||||||
.setSiemensFieldName(point.getAttributeCode())
|
|
||||||
.setSiemensFieldAddress(point.getAddress())
|
|
||||||
.setSiemensFieldDataType(dataType)
|
|
||||||
.setSiemensFieldPrecision(point.getSiemensFieldPrecision())
|
|
||||||
.setSiemensFieldUnit(point.getUnit());
|
|
||||||
|
|
||||||
list.add(siemensPointEntity);
|
|
||||||
}
|
|
||||||
if (list.size() > 0)
|
|
||||||
siemensPointService.add(list, gatewayDO.getAdminIp(), deviceSiemensEntity.getDeviceConfigID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//清除原本的Modbus设备数据
|
|
||||||
// public void deleteModbusEntity(BeEquipments equipments) {
|
|
||||||
// modbusPointService.login(equipments.getAdminIp(), equipments.getUsername(), equipments.getPassword());
|
|
||||||
// List<DeviceModbusEntity> list = modbusPointService.getModbusList(equipments.getAdminIp(), equipments.getUsername(), equipments.getPassword());
|
|
||||||
// if (null != list && list.size() > 0) {
|
|
||||||
// //先清除点位数据
|
|
||||||
// String[] deviceIds = new String[list.size()];
|
|
||||||
// for (int i = 0; i < list.size(); i++) {
|
|
||||||
// deviceIds[i] = list.get(i).getDeviceConfigID();
|
|
||||||
// //删除每个设备下的原有点位
|
|
||||||
// List<ModbusPointEntity> pointList = modbusPointService.getPointList(equipments.getAdminIp(),
|
|
||||||
// equipments.getUsername(), equipments.getPassword(), list.get(i).getDeviceConfigID());
|
|
||||||
// if (pointList != null && pointList.size() > 0) {
|
|
||||||
// String[] addressIds = new String[pointList.size()];
|
|
||||||
// for (int j = 0; j < pointList.size(); j++) {
|
|
||||||
// addressIds[j] = pointList.get(j).getDeviceConfigContentID().toString();
|
|
||||||
// }
|
|
||||||
// //删除点位数据
|
|
||||||
// modbusPointService.deletePoint(equipments.getAdminIp(), String.join(",", addressIds));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// //再清除设备数据
|
|
||||||
// modbusPointService.delete(equipments.getAdminIp(), String.join(",", deviceIds));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
//清除原本的Modbus设备数据
|
|
||||||
public void deleteModbusEntity(GatewayDO gatewayDO, String deviceId) {
|
|
||||||
modbusPointService.login(gatewayDO.getAdminIp(), gatewayDO.getUsername(), gatewayDO.getPassword());
|
|
||||||
List<DeviceModbusEntity> list = modbusPointService.getModbusList(gatewayDO.getAdminIp(),
|
|
||||||
gatewayDO.getUsername(), gatewayDO.getPassword(), deviceId);
|
|
||||||
if (null != list && list.size() > 0) {
|
|
||||||
//先清除点位数据
|
|
||||||
String[] deviceIds = new String[list.size()];
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
deviceIds[i] = list.get(i).getDeviceConfigID();
|
|
||||||
//删除每个设备下的原有点位
|
|
||||||
List<ModbusPointEntity> pointList = modbusPointService.getPointListAll(gatewayDO.getAdminIp(),
|
|
||||||
gatewayDO.getUsername(), gatewayDO.getPassword(), list.get(i).getDeviceConfigID());
|
|
||||||
if (pointList != null && pointList.size() > 0) {
|
|
||||||
String[] addressIds = new String[pointList.size()];
|
|
||||||
for (int j = 0; j < pointList.size(); j++) {
|
|
||||||
addressIds[j] = pointList.get(j).getDeviceConfigContentID();
|
|
||||||
}
|
|
||||||
//删除点位数据
|
|
||||||
modbusPointService.deletePoint(gatewayDO.getAdminIp(), String.join(",", addressIds));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//再清除设备数据
|
|
||||||
modbusPointService.delete(gatewayDO.getAdminIp(), String.join(",", deviceIds));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addModbusEntity(GatewayDO gatewayDO) {
|
|
||||||
modbusPointService.login(gatewayDO.getAdminIp(), gatewayDO.getUsername(), gatewayDO.getPassword());
|
|
||||||
List<DeviceDO> modbuses = deviceMapper.selectByGatewayId(gatewayDO.getId());
|
|
||||||
List<DeviceModbusEntity> list = new ArrayList<>();
|
|
||||||
if (modbuses != null && modbuses.size() > 0) {
|
|
||||||
for (DeviceDO modbus : modbuses) {
|
|
||||||
DeviceModbusEntity deviceModbusEntity = initEntity(modbus);
|
|
||||||
list.add(deviceModbusEntity);
|
|
||||||
//mob 下发失败 {"code":500,"msg":"该串口已经配置"}
|
|
||||||
}
|
|
||||||
modbusPointService.add(list, gatewayDO.getAdminIp());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private DeviceModbusEntity initEntity(DeviceDO modbus) {
|
|
||||||
DeviceModbusEntity deviceModbusEntity = new DeviceModbusEntity();
|
|
||||||
deviceModbusEntity.setEquipmentsId(modbus.getOrgId().toString());
|
|
||||||
deviceModbusEntity.setDeviceId(modbus.getDeviceCode());
|
|
||||||
deviceModbusEntity.setDeviceName(modbus.getDeviceName());
|
|
||||||
deviceModbusEntity.setModbusProtocol(modbus.getModbusProtocol());
|
|
||||||
deviceModbusEntity.setModbusPattern(modbus.getModbusPattern());
|
|
||||||
deviceModbusEntity.setPortName(modbus.getPortName());
|
|
||||||
deviceModbusEntity.setModbusConnectParam(modbus.getModbusConnectParam());
|
|
||||||
deviceModbusEntity.setReadCronType(modbus.getReadCronType());
|
|
||||||
deviceModbusEntity.setReadRepeatValue(modbus.getReadRepeatValue());
|
|
||||||
deviceModbusEntity.setReadRepeatUnit(modbus.getReadRepeatUnit());
|
|
||||||
deviceModbusEntity.setReadCron(modbus.getReadCron());
|
|
||||||
deviceModbusEntity.setWriteCronType(modbus.getWriteCronType());
|
|
||||||
deviceModbusEntity.setWriteRepeatValue(modbus.getWriteRepeatValue());
|
|
||||||
deviceModbusEntity.setWriteRepeatUnit(modbus.getWriteRepeatUnit());
|
|
||||||
deviceModbusEntity.setWriteCron(modbus.getWriteCron());
|
|
||||||
deviceModbusEntity.setLocalPersistent(modbus.getLocalPersistent());
|
|
||||||
deviceModbusEntity.setUploadRate(modbus.getUploadRate());
|
|
||||||
deviceModbusEntity.setRateCount(modbus.getRateCount());
|
|
||||||
deviceModbusEntity.setModbusReadAddrGap(modbus.getModbusReadAddrGap());
|
|
||||||
return deviceModbusEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addModbusEntity(GatewayDO gatewayDO, DeviceDO modbus) {
|
|
||||||
DeviceModbusEntity deviceModbusEntity = initEntity(modbus);
|
|
||||||
//mob 下发失败 {"code":500,"msg":"该串口已经配置"}
|
|
||||||
modbusPointService.add(deviceModbusEntity, gatewayDO.getAdminIp());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addDeviceModbusEntity(GatewayDO gatewayDO) {
|
|
||||||
modbusPointService.login(gatewayDO.getAdminIp(), gatewayDO.getUsername(), gatewayDO.getPassword());
|
|
||||||
/*下发好设备后获取设备列表找点位*/
|
|
||||||
List<DeviceModbusEntity> modbusPointList = modbusPointService.getModbusList(gatewayDO.getAdminIp(),
|
|
||||||
gatewayDO.getUsername(), gatewayDO.getPassword());
|
|
||||||
|
|
||||||
for (DeviceModbusEntity deviceModbusEntity : modbusPointList) {
|
|
||||||
//根据deviceId 和机台编码查询sql数据库点位信息
|
|
||||||
List<DeviceAttributeDO> points = deviceAttributeMapper.selectByDeviceId(1L);
|
|
||||||
getModbusPointEntityList(gatewayDO, deviceModbusEntity, points);
|
|
||||||
List<ModbusPointEntity> list = getModbusPointEntityList(gatewayDO, deviceModbusEntity, points);
|
|
||||||
//下发
|
|
||||||
if (list.size() > 0)
|
|
||||||
modbusPointService.add(list, gatewayDO.getAdminIp(), deviceModbusEntity.getDeviceConfigID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addDeviceModbusEntity(GatewayDO gatewayDO, DeviceDO deviceDO) {
|
|
||||||
modbusPointService.login(gatewayDO.getAdminIp(), gatewayDO.getUsername(), gatewayDO.getPassword());
|
|
||||||
/*下发好设备后获取设备列表找点位*/
|
|
||||||
List<DeviceModbusEntity> modbusPointList = modbusPointService.getModbusList(gatewayDO.getAdminIp(),
|
|
||||||
gatewayDO.getUsername(), gatewayDO.getPassword(), deviceDO.getDeviceCode());
|
|
||||||
for (DeviceModbusEntity deviceModbusEntity : modbusPointList) {
|
|
||||||
//根据deviceId 和机台编码查询sql数据库点位信息
|
|
||||||
|
|
||||||
List<DeviceAttributeDO> points = deviceAttributeMapper.selectByDeviceId(deviceDO.getId());
|
|
||||||
List<ModbusPointEntity> list = getModbusPointEntityList(gatewayDO, deviceModbusEntity, points);
|
|
||||||
if (list.size() > 0)
|
|
||||||
modbusPointService.add(list, gatewayDO.getAdminIp(), deviceModbusEntity.getDeviceConfigID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ModbusPointEntity> getModbusPointEntityList(GatewayDO gatewayDO,
|
|
||||||
DeviceModbusEntity deviceModbusEntity,
|
|
||||||
List<DeviceAttributeDO> points) {
|
|
||||||
List<ModbusPointEntity> list = new ArrayList<>();
|
|
||||||
for (DeviceAttributeDO point : points) {
|
|
||||||
//新增点位
|
|
||||||
ModbusPointEntity modbusPointEntity = new ModbusPointEntity();
|
|
||||||
modbusPointEntity.setModbusSlaveID(point.getModbusSlaveId());
|
|
||||||
modbusPointEntity.setModbusFieldName(point.getAttributeCode());
|
|
||||||
modbusPointEntity.setModbusFieldAddress(point.getModbusFieldAddress());
|
|
||||||
modbusPointEntity.setModbusAddressType(point.getModbusAddressType());
|
|
||||||
modbusPointEntity.setModbusFieldSize(point.getModbusFieldSize());
|
|
||||||
modbusPointEntity.setModbusFieldPrecision(point.getModbusFieldPrecision());
|
|
||||||
modbusPointEntity.setModbusFieldDataType(point.getDataType());
|
|
||||||
modbusPointEntity.setModbusFieldOrder(point.getModbusFieldOrder());
|
|
||||||
modbusPointEntity.setModbusFieldUnit(point.getUnit());
|
|
||||||
list.add(modbusPointEntity);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 下发mqtt主题
|
|
||||||
* 1拿到列表
|
|
||||||
* 2停用
|
|
||||||
* 3删除
|
|
||||||
* 4新增
|
|
||||||
* 5启用
|
|
||||||
*/
|
|
||||||
public void deleteMqttEntity(GatewayDO gatewayDO) {
|
|
||||||
modbusPointService.login(gatewayDO.getAdminIp(), gatewayDO.getUsername(), gatewayDO.getPassword());
|
|
||||||
List<MqttBrokerEntity> mqttBrokerEntity = gatewayMqttService.getMqttBrokerEntity(gatewayDO.getAdminIp(),
|
|
||||||
gatewayDO.getUsername(), gatewayDO.getPassword());
|
|
||||||
for (MqttBrokerEntity brokerEntity : mqttBrokerEntity) {
|
|
||||||
gatewayMqttService.delete(gatewayDO.getAdminIp(), brokerEntity.getCloudConfigID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***启用设备 */
|
|
||||||
public void changeStatus(GatewayDO gatewayDO, String deviceCode, String type) {
|
|
||||||
List<String> deviceIds = new ArrayList<>();
|
|
||||||
if (type.equals("modbus")) {
|
|
||||||
/*下发好设备后获取设备列表找点位*/
|
|
||||||
List<DeviceModbusEntity> modbusPointList = modbusPointService.getModbusList(gatewayDO.getAdminIp(),
|
|
||||||
gatewayDO.getUsername(), gatewayDO.getPassword(), deviceCode);
|
|
||||||
for (DeviceModbusEntity entity : modbusPointList) {
|
|
||||||
deviceIds.add(entity.getDeviceConfigID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (type.equals("siemens")) {
|
|
||||||
/*下发好设备后获取设备列表找点位*/
|
|
||||||
List<DeviceSiemensEntity> siemensList = siemensPointService.getSiemensList(gatewayDO.getAdminIp(),
|
|
||||||
gatewayDO.getUsername(), gatewayDO.getPassword(), deviceCode);
|
|
||||||
|
|
||||||
for (DeviceSiemensEntity entity : siemensList) {
|
|
||||||
deviceIds.add(entity.getDeviceConfigID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ChangeStatus changeStatus = new ChangeStatus();
|
|
||||||
changeStatus.setNewStatus("2");
|
|
||||||
changeStatus.setOldStatus("1");
|
|
||||||
siemensPointService.changeStatusDevice(deviceIds, changeStatus, gatewayDO.getAdminIp());
|
|
||||||
}
|
|
||||||
|
|
||||||
/***启用设备 */
|
|
||||||
public void changeStatus(GatewayDO gatewayDO) {
|
|
||||||
/*下发好设备后获取设备列表找点位*/
|
|
||||||
List<DeviceModbusEntity> modbusPointList = modbusPointService.getModbusList(gatewayDO.getAdminIp(),
|
|
||||||
gatewayDO.getUsername(), gatewayDO.getPassword());
|
|
||||||
/*下发好设备后获取设备列表找点位*/
|
|
||||||
List<DeviceSiemensEntity> siemensList = siemensPointService.getSiemensList(gatewayDO.getAdminIp(),
|
|
||||||
gatewayDO.getUsername(), gatewayDO.getPassword());
|
|
||||||
List<String> deviceIds = new ArrayList<>();
|
|
||||||
for (DeviceModbusEntity entity : modbusPointList) {
|
|
||||||
deviceIds.add(entity.getDeviceConfigID());
|
|
||||||
}
|
|
||||||
for (DeviceSiemensEntity entity : siemensList) {
|
|
||||||
deviceIds.add(entity.getDeviceConfigID());
|
|
||||||
}
|
|
||||||
ChangeStatus changeStatus = new ChangeStatus();
|
|
||||||
changeStatus.setNewStatus("2");
|
|
||||||
changeStatus.setOldStatus("1");
|
|
||||||
siemensPointService.changeStatusDevice(deviceIds, changeStatus, gatewayDO.getAdminIp());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*检测下发数据和实际下发数量是否匹配*/
|
|
||||||
public CommonResult<String> compare(GatewayDO gatewayDO, DeviceDO deviceDO, String type) {
|
|
||||||
String deviceConfigID = null;
|
|
||||||
Integer pointList = 0;
|
|
||||||
if ("modbus".equals(type)) {
|
|
||||||
List<DeviceModbusEntity> modbusList = modbusPointService.getModbusList(gatewayDO.getAdminIp(),
|
|
||||||
gatewayDO.getUsername(), gatewayDO.getPassword(), deviceDO.getDeviceCode());
|
|
||||||
if (modbusList != null && modbusList.size() > 0) {
|
|
||||||
deviceConfigID = modbusList.get(0).getDeviceConfigID();
|
|
||||||
}
|
|
||||||
pointList = modbusPointService.getPointListByCount(gatewayDO.getAdminIp(),
|
|
||||||
gatewayDO.getUsername(), gatewayDO.getPassword(), deviceConfigID);
|
|
||||||
} else {
|
|
||||||
List<DeviceSiemensEntity> siemensList = siemensPointService.getSiemensList(gatewayDO.getAdminIp(),
|
|
||||||
gatewayDO.getUsername(), gatewayDO.getPassword(), deviceDO.getDeviceCode());
|
|
||||||
if (siemensList != null && siemensList.size() > 0) {
|
|
||||||
deviceConfigID = siemensList.get(0).getDeviceConfigID();
|
|
||||||
}
|
|
||||||
pointList = siemensPointService.getPointListByCount(gatewayDO.getAdminIp(), deviceConfigID,
|
|
||||||
gatewayDO.getUsername(), gatewayDO.getPassword());
|
|
||||||
}
|
|
||||||
//根据deviceId 和机台编码查询sql数据库点位信息
|
|
||||||
|
|
||||||
List<DeviceAttributeDO> points = deviceAttributeMapper.selectByDeviceId(deviceDO.getId());
|
|
||||||
int size = points.size();
|
|
||||||
String str = "应下发" + points.size() + "个地址,实下发" + pointList + "个地址";
|
|
||||||
return size != pointList ? CommonResult.error(500, "下发失败!" + str)
|
|
||||||
: CommonResult.success("下发成功!" + str);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 网关登录测试
|
|
||||||
*/
|
|
||||||
public CommonResult login(GatewayDO gateway) {
|
|
||||||
// 创建 HttpClient 客户端
|
|
||||||
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
|
|
||||||
CloseableHttpResponse httpResponse = null;
|
|
||||||
try {
|
|
||||||
HttpPost httpPost = HttpUtils.getHttpPost(
|
|
||||||
gateway.getAdminIp() + UrlConstans.loginUrl,
|
|
||||||
HttpEntity.getLoginParam(gateway.getUsername(), gateway.getPassword()));
|
|
||||||
httpResponse = httpClient.execute(httpPost);
|
|
||||||
if (httpResponse.getEntity() != null) {
|
|
||||||
String entityStr = EntityUtils.toString(httpResponse.getEntity());
|
|
||||||
if (entityStr.contains("服务不可用") || entityStr.contains("<!DOCTYPE html>"))
|
|
||||||
return CommonResult.success("网关服务不可用!");
|
|
||||||
ResponseInfo info = JSON.parseObject(entityStr, ResponseInfo.class);
|
|
||||||
if (info.code == 0) return CommonResult.success("网关登录测试成功!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 无论如何必须关闭连接
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
HttpUtils.closeHttp(httpClient, httpResponse);
|
|
||||||
}
|
|
||||||
return CommonResult.error(500, "网关登录测试失败!");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int openOrClose(String adminIp, String username, String password, String monitorCode) {
|
|
||||||
List<DeviceVideoEntity> videoId = videoService.getVideoId(adminIp, username, password, monitorCode);
|
|
||||||
if (videoId != null && videoId.size() > 0) {
|
|
||||||
String[] addressIds = new String[videoId.size()];
|
|
||||||
for (int j = 0; j < videoId.size(); j++) {
|
|
||||||
addressIds[j] = videoId.get(j).getDeviceConfigID();
|
|
||||||
}
|
|
||||||
return videoService.openOrClose(adminIp, String.join(",", addressIds));
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
public static class ResponseInfo {
|
|
||||||
int code;
|
|
||||||
String msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteVideo(String adminIp, String username, String password, String monitorCode) {
|
|
||||||
videoService.login(adminIp, username, password);
|
|
||||||
List<DeviceVideoEntity> videoId = videoService.getVideoId(adminIp, username, password, monitorCode);
|
|
||||||
if (videoId != null && videoId.size() > 0) {
|
|
||||||
String[] addressIds = new String[videoId.size()];
|
|
||||||
for (int j = 0; j < videoId.size(); j++) {
|
|
||||||
addressIds[j] = videoId.get(j).getDeviceConfigID();
|
|
||||||
}
|
|
||||||
videoService.deleteByIds(adminIp, String.join(",", addressIds));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void addVideo(String adminIp,String username,String password, Monitor monitor) {
|
|
||||||
// videoService.login(adminIp,username,password);
|
|
||||||
// DeviceVideoEntity deviceVideoEntity = new DeviceVideoEntity();
|
|
||||||
// deviceVideoEntity.setDeviceID(monitor.getMonitorCode());
|
|
||||||
// deviceVideoEntity.setDeviceName(monitor.getMonitorName());
|
|
||||||
// deviceVideoEntity.setServerAddress(monitor.getServiceAddress());
|
|
||||||
// deviceVideoEntity.setVideoAddress(monitor.getVideoAddress());
|
|
||||||
// videoService.add(deviceVideoEntity, adminIp);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@ -1,129 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.service.impl;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.bo.HttpEntity;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.entity.DeviceVideoEntity;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.entity.PageEntityByDecice;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.service.IVideoService;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.util.HttpUtils;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.util.JsonUtils;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.util.UrlConstans;
|
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
||||||
import org.apache.http.client.methods.HttpPost;
|
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
|
||||||
import org.apache.http.util.EntityUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.module.iot.framework.gateway.util.HttpUtils.getHttpPost;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class VideoServiceImpl implements IVideoService {
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(VideoServiceImpl.class);
|
|
||||||
private String cookie;
|
|
||||||
|
|
||||||
//先登录
|
|
||||||
@Override
|
|
||||||
public void login(String url, String username, String password) {
|
|
||||||
// 创建 HttpClient 客户端
|
|
||||||
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
|
|
||||||
CloseableHttpResponse httpResponse = null;
|
|
||||||
try {
|
|
||||||
HttpPost httpPost = getHttpPost(url + UrlConstans.loginUrl, HttpEntity.getLoginParam(username, password));
|
|
||||||
httpResponse = httpClient.execute(httpPost);
|
|
||||||
log.debug(EntityUtils.toString(httpResponse.getEntity()));
|
|
||||||
this.cookie = HttpUtils.getCookies(httpResponse);
|
|
||||||
}
|
|
||||||
// 无论如何必须关闭连接
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
HttpUtils.closeHttp(httpClient, httpResponse);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<DeviceVideoEntity> getVideoId(String adminIp, String username, String password, String monitorCode) {
|
|
||||||
PageEntityByDecice pageEntity = new PageEntityByDecice();
|
|
||||||
pageEntity.setDeviceID(monitorCode);
|
|
||||||
// 创建 HttpClient 客户端
|
|
||||||
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
|
|
||||||
CloseableHttpResponse httpResponse = null;
|
|
||||||
List<DeviceVideoEntity> list = null;
|
|
||||||
try {
|
|
||||||
String getlistUrl = adminIp + UrlConstans.video_list;
|
|
||||||
HttpPost httpPost = getHttpPost(getlistUrl, HttpEntity.getPageParamVo(pageEntity));//检索条件
|
|
||||||
login(adminIp, username, password);
|
|
||||||
httpPost.setHeader("Cookie", cookie);
|
|
||||||
httpResponse = httpClient.execute(httpPost);
|
|
||||||
if (httpResponse.getEntity() != null) {
|
|
||||||
String entityStr = EntityUtils.toString(httpResponse.getEntity());
|
|
||||||
list = JsonUtils.toVideoEntityList(entityStr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 无论如何必须关闭连接
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
HttpUtils.closeHttp(httpClient, httpResponse);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int deleteByIds(String adminIp, String ids) {
|
|
||||||
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
|
|
||||||
CloseableHttpResponse httpResponse = null;
|
|
||||||
try {
|
|
||||||
HttpPost httpPost = getHttpPost(adminIp + UrlConstans.video_remove, HttpEntity.getRemoveParam(ids));
|
|
||||||
httpPost.setHeader("Cookie", cookie);
|
|
||||||
httpResponse = httpClient.execute(httpPost);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
HttpUtils.closeHttp(httpClient, httpResponse);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int add(DeviceVideoEntity list, String adminIp) {
|
|
||||||
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
|
|
||||||
CloseableHttpResponse httpResponse = null;
|
|
||||||
HttpPost httpPost = null;
|
|
||||||
try {
|
|
||||||
httpPost = getHttpPost(adminIp + UrlConstans.video_add, HttpEntity.getParam(list));
|
|
||||||
httpPost.setHeader("Cookie", cookie);
|
|
||||||
// 设置 HttpPost 参数
|
|
||||||
httpResponse = httpClient.execute(httpPost);
|
|
||||||
log.debug(EntityUtils.toString(httpResponse.getEntity()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return 1;
|
|
||||||
} finally {
|
|
||||||
HttpUtils.closeHttp(httpClient, httpResponse);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int openOrClose(String adminIp, String videoId) {
|
|
||||||
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
|
|
||||||
CloseableHttpResponse httpResponse = null;
|
|
||||||
try {
|
|
||||||
HttpPost httpPost = getHttpPost(adminIp + UrlConstans.video_push_stream, HttpEntity.getRemoveParam(videoId));
|
|
||||||
httpPost.setHeader("Cookie", cookie);
|
|
||||||
httpResponse = httpClient.execute(httpPost);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
HttpUtils.closeHttp(httpClient, httpResponse);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,89 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.util;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.bo.ListEntity;
|
|
||||||
import cn.iocoder.yudao.module.iot.framework.gateway.entity.*;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class JsonUtils {
|
|
||||||
|
|
||||||
|
|
||||||
public static List<SiemensPointEntity> toSiemensPointEntityList(String jsonStr) {
|
|
||||||
List<SiemensPointEntity> list = new ArrayList<>();
|
|
||||||
ListEntity entity = JSON.parseObject(jsonStr, ListEntity.class);
|
|
||||||
for (JSONObject json : entity.getRows()) {
|
|
||||||
String obj = json.toJSONString();
|
|
||||||
list.add(JSON.parseObject(obj, SiemensPointEntity.class));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toSiemensPointEntityTotal(String jsonStr) {
|
|
||||||
List<SiemensPointEntity> list = new ArrayList<>();
|
|
||||||
ListEntity entity = JSON.parseObject(jsonStr, ListEntity.class);
|
|
||||||
return entity.getTotal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ModbusPointEntity> toModbusPointEntityList(String jsonStr) {
|
|
||||||
List<ModbusPointEntity> list = new ArrayList<>();
|
|
||||||
ListEntity entity = JSON.parseObject(jsonStr, ListEntity.class);
|
|
||||||
for (JSONObject json : entity.getRows()) {
|
|
||||||
String obj = json.toJSONString();
|
|
||||||
list.add(JSON.parseObject(obj, ModbusPointEntity.class));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toModbusPointEntityTotal(String jsonStr) {
|
|
||||||
List<ModbusPointEntity> list = new ArrayList<>();
|
|
||||||
ListEntity entity = JSON.parseObject(jsonStr, ListEntity.class);
|
|
||||||
return entity.getTotal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ListEntity toPointEntity(String jsonStr) {
|
|
||||||
return JSON.parseObject(jsonStr, ListEntity.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<DeviceSiemensEntity> toDeviceSiemensEntityList(String jsonStr) {
|
|
||||||
List<DeviceSiemensEntity> list = new ArrayList<>();
|
|
||||||
ListEntity entity = JSON.parseObject(jsonStr, ListEntity.class);
|
|
||||||
for (JSONObject json : entity.getRows()) {
|
|
||||||
String obj = json.toJSONString();
|
|
||||||
list.add(JSON.parseObject(obj, DeviceSiemensEntity.class));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<DeviceModbusEntity> toDeviceModbusEntityList(String jsonStr) {
|
|
||||||
List<DeviceModbusEntity> list = new ArrayList<>();
|
|
||||||
ListEntity entity = JSON.parseObject(jsonStr, ListEntity.class);
|
|
||||||
for (JSONObject json : entity.getRows()) {
|
|
||||||
String obj = json.toJSONString();
|
|
||||||
list.add(JSON.parseObject(obj, DeviceModbusEntity.class));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<MqttBrokerEntity> toMqttEntityList(String jsonStr) {
|
|
||||||
List<MqttBrokerEntity> list = new ArrayList<>();
|
|
||||||
ListEntity entity = JSON.parseObject(jsonStr, ListEntity.class);
|
|
||||||
for (JSONObject json : entity.getRows()) {
|
|
||||||
String obj = json.toJSONString();
|
|
||||||
list.add(JSON.parseObject(obj, MqttBrokerEntity.class));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<DeviceVideoEntity> toVideoEntityList(String jsonStr) {
|
|
||||||
List<DeviceVideoEntity> list = new ArrayList<>();
|
|
||||||
ListEntity entity = JSON.parseObject(jsonStr, ListEntity.class);
|
|
||||||
for (JSONObject json : entity.getRows()) {
|
|
||||||
String obj = json.toJSONString();
|
|
||||||
list.add(JSON.parseObject(obj, DeviceVideoEntity.class));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,91 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.iot.framework.gateway.util;
|
|
||||||
|
|
||||||
public class UrlConstans {
|
|
||||||
|
|
||||||
public static final String loginUrl = "/login";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* mqtt
|
|
||||||
*/
|
|
||||||
public static final String mqtt_add = "/cloud/config/mqtt/add";
|
|
||||||
public static final String mqtt_list = "/cloud/config/mqtt/list";
|
|
||||||
public static final String mqtt_edit = "/cloud/config/mqtt/add";
|
|
||||||
public static final String mqtt_remove = "/cloud/config/remove";
|
|
||||||
public static final String mqtt_changestatus = "/cloud/config/changestatus";//启用
|
|
||||||
|
|
||||||
/***/
|
|
||||||
public static final String siemens_list = "/device/config/siemens/list";
|
|
||||||
public static final String siemens_add = "/device/config/siemens/add";
|
|
||||||
public static final String siemens_edit = "/device/config/siemens/add";
|
|
||||||
public static final String siemens_remove = "/device/config/remove";
|
|
||||||
public static final String siemens_changestatus = "/device/config/changeStatus";//启用
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Video
|
|
||||||
*/
|
|
||||||
public static final String video_list = "/device/config/video/list";
|
|
||||||
public static final String video_add = "/device/config/video/add";
|
|
||||||
// public static final String video_edit = "/device/config/video/add";
|
|
||||||
public static final String video_remove = "/device/config/video/remove";
|
|
||||||
//device/config/video/push/stream/399/?_=1665714825994
|
|
||||||
public static final String video_push_stream = "/device/config/video/push/stream";//推流
|
|
||||||
// public static final String Video_changestatus = "/device/config/changeStatus";//启用
|
|
||||||
|
|
||||||
/**
|
|
||||||
* siemens iopoint list
|
|
||||||
*/
|
|
||||||
public static final String siemens_iopoint_list_r = "/device/config/siemens/contentlist/r/";
|
|
||||||
/**
|
|
||||||
* siemens iopoint add
|
|
||||||
*/
|
|
||||||
//https://71220220500200002.ng.xjzyun.com/device/config/siemens/content/add/r/0/82
|
|
||||||
public static final String siemens_iopoint_add_r = "/device/config/siemens/content/add/r/0/";
|
|
||||||
/**
|
|
||||||
* siemens iopoint list
|
|
||||||
*/
|
|
||||||
public static final String siemens_iopoint_edit_r = "/device/config/siemens/content/add/r/";
|
|
||||||
/**
|
|
||||||
* siemens iopoint list
|
|
||||||
*/
|
|
||||||
public static final String siemens_iopoint_remove_r = "/device/configcontent/remove";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* siemens iopoint list
|
|
||||||
*/
|
|
||||||
public static final String siemens_iopoint_list_w = "/device/config/siemens/contentlist/r/";
|
|
||||||
/**
|
|
||||||
* siemens iopoint add
|
|
||||||
*/
|
|
||||||
public static final String siemens_iopoint_add_w = "/device/config/siemens/content/add/w/0/";
|
|
||||||
/**
|
|
||||||
* siemens iopoint list
|
|
||||||
*/
|
|
||||||
public static final String siemens_iopoint_edit_w = "/device/config/siemens/content/add/w/";
|
|
||||||
/**
|
|
||||||
* siemens iopoint list
|
|
||||||
*/
|
|
||||||
public static final String siemens_iopoint_remove_w = "/device/configcontent/remove";
|
|
||||||
|
|
||||||
/***/
|
|
||||||
public static final String modbus_list = "/device/config/modbus/list";
|
|
||||||
public static final String modbus_add = "/device/config/modbus/add";
|
|
||||||
public static final String modbus_edit = "/device/config/modbus/edit";
|
|
||||||
public static final String modbus_remove = "/device/config/modbus/remove";
|
|
||||||
public static final String modbus_changestatus = "/device/config/changestatus";//启用
|
|
||||||
/**
|
|
||||||
* modbus iopoint list
|
|
||||||
*/
|
|
||||||
public static final String modbus_iopoint_list = "/device/config/modbus/contentlist/r/";
|
|
||||||
/**
|
|
||||||
* modbus iopoint add
|
|
||||||
*/
|
|
||||||
public static final String modbus_iopoint_add_r = "/device/config/modbus/content/add/r/0/";
|
|
||||||
/**
|
|
||||||
* modbus iopoint list
|
|
||||||
*/
|
|
||||||
public static final String modbus_iopoint_edit = "/device/config/modbus/content/add/r/";
|
|
||||||
/**
|
|
||||||
* siemens iopoint list
|
|
||||||
*/
|
|
||||||
public static final String modbus_iopoint_remove = "/device/configcontent/remove";
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue