add gateway service

plp
chenshuichuan 2 years ago
parent 4445d42621
commit a67e8cc985

@ -77,6 +77,9 @@
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
</project>

@ -0,0 +1,108 @@
package cn.iocoder.yudao.module.iot.framework.constant;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
@Data
@AllArgsConstructor
public class AddressDataType {
private static Map<String,String> tdDataTypeMap = new HashMap<>();
private static Map<String,String> mysqlDataTypeMap = new HashMap<>();
private static Map<String,Integer> gatewayDataTypeMap = new HashMap<>();
static {
tdDataTypeMap.put("bool","BOOL");
tdDataTypeMap.put("int8","INT");
tdDataTypeMap.put("int16","INT");
tdDataTypeMap.put("int32","INT");
tdDataTypeMap.put("int64","BIGINT");
tdDataTypeMap.put("uint8","INT");
tdDataTypeMap.put("uint16","INT");
tdDataTypeMap.put("uint32","BIGINT");
tdDataTypeMap.put("uint64","BIGINT");
tdDataTypeMap.put("float32","float");
tdDataTypeMap.put("float64","float");
tdDataTypeMap.put("string","NCHAR(255)");
tdDataTypeMap.put("date","TIMESTAMP");
tdDataTypeMap.put("bcd","BINARY(64)");
gatewayDataTypeMap.put("bool",1);
gatewayDataTypeMap.put("int8",2);
gatewayDataTypeMap.put("uint8",3);
gatewayDataTypeMap.put("int16",4);
gatewayDataTypeMap.put("uint16",5);
gatewayDataTypeMap.put("int32",6);
gatewayDataTypeMap.put("uint32",7);
gatewayDataTypeMap.put("int64",8);
gatewayDataTypeMap.put("uint64",9);
gatewayDataTypeMap.put("float32",10);
gatewayDataTypeMap.put("float64",11);
gatewayDataTypeMap.put("string",12);
gatewayDataTypeMap.put("date",13);
gatewayDataTypeMap.put("bcd",14);
gatewayDataTypeMap.put("Bool",1);
gatewayDataTypeMap.put("Int8",2);
gatewayDataTypeMap.put("Uint8",3);
gatewayDataTypeMap.put("Int16",4);
gatewayDataTypeMap.put("Uint16",5);
gatewayDataTypeMap.put("Int32",6);
gatewayDataTypeMap.put("Uint32",7);
gatewayDataTypeMap.put("Int64",8);
gatewayDataTypeMap.put("Uint64",9);
gatewayDataTypeMap.put("Float32",10);
gatewayDataTypeMap.put("Float64",11);
gatewayDataTypeMap.put("String",12);
gatewayDataTypeMap.put("Date",13);
gatewayDataTypeMap.put("Bcd",14);
gatewayDataTypeMap.put("BOOL",1);
gatewayDataTypeMap.put("INT8",2);
gatewayDataTypeMap.put("UINT8",3);
gatewayDataTypeMap.put("INT16",4);
gatewayDataTypeMap.put("UINT16",5);
gatewayDataTypeMap.put("INT32",6);
gatewayDataTypeMap.put("UINT32",7);
gatewayDataTypeMap.put("INT64",8);
gatewayDataTypeMap.put("UINT64",9);
gatewayDataTypeMap.put("FLOAT32",10);
gatewayDataTypeMap.put("FLOAT64",11);
gatewayDataTypeMap.put("STRING",12);
gatewayDataTypeMap.put("DATE",13);
gatewayDataTypeMap.put("BCD",14);
mysqlDataTypeMap.put("bool","BOOL");
mysqlDataTypeMap.put("int8","INT");
mysqlDataTypeMap.put("int16","INT");
mysqlDataTypeMap.put("int32","INT");
mysqlDataTypeMap.put("int64","BIGINT");
mysqlDataTypeMap.put("uint8","INT");
mysqlDataTypeMap.put("uint16","INT");
mysqlDataTypeMap.put("uint32","BIGINT");
mysqlDataTypeMap.put("uint64","BIGINT");
mysqlDataTypeMap.put("float32","float");
mysqlDataTypeMap.put("float64","float");
mysqlDataTypeMap.put("string","varchar(255)");
mysqlDataTypeMap.put("date","TIMESTAMP");
mysqlDataTypeMap.put("bcd","double");
}
public static Map<String,String> getDataTypeMap(){
return tdDataTypeMap;
}
public static String getTdDataType(String originDataType){
return tdDataTypeMap.get(originDataType);
}
public static String getTMysqlDataType(String originDataType){
//return mysqlDataTypeMap.get(originDataType);
return "double(8,4)";
}
public static Map<String,Integer> getGatewayDataTypeMap(){
return gatewayDataTypeMap;
}
public static Integer getGatewayDataTypeMap(String originDataType){
return gatewayDataTypeMap.get(originDataType);
}
}

@ -0,0 +1,18 @@
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;
}

@ -0,0 +1,205 @@
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;
}
}

@ -0,0 +1,18 @@
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;
}

@ -0,0 +1,111 @@
package cn.iocoder.yudao.module.iot.framework.gateway.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DeviceModbusEntity {
/**
* id
*/
private String deviceConfigID;
/**
* ID
*/
private String equipmentsId;
private String deviceConfigId;
/**
* modbus
*/
private String deviceId;
/**
* modbus
*/
private String deviceName;
/**
* modbus(serial-rtu)
*/
private String modbusProtocol;
/**
* modbus(client)
*/
private String modbusPattern;
/**
* modbus
*/
private String portName;
/**
* ( 960081N
*/
private String modbusConnectParam;
/**
* (01)
*/
private String readCronType;
/**
*
*/
private Integer readRepeatValue;
/**
*
*/
private String readRepeatUnit;
/**
*
*/
private String readCron;
/**
*
*/
private String writeCronType;
/**
*
*/
private Integer writeRepeatValue;
/**
*
*/
private String writeRepeatUnit;
/**
*
*/
private String writeCron;
/**
* (01)
*/
private String localPersistent;
/**
* (12)
*/
private String uploadRate;
/**
*
*/
private Integer rateCount;
/**
* (01)
*/
private String modbusReadAddrGap;
}

@ -0,0 +1,71 @@
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;
}

@ -0,0 +1,31 @@
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;
}

@ -0,0 +1,52 @@
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;
}

@ -0,0 +1,22 @@
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;
}

@ -0,0 +1,22 @@
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";
}
}

@ -0,0 +1,22 @@
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";
}
}

@ -0,0 +1,57 @@
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;
}

@ -0,0 +1,25 @@
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);
}

@ -0,0 +1,48 @@
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);
}

@ -0,0 +1,52 @@
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.DeviceSiemensEntity;
import cn.iocoder.yudao.module.iot.framework.gateway.entity.SiemensPointEntity;
import java.util.List;
public interface ISiemensPointService {
//调用前统一登录保存cookies
public String login(String url ,String username ,String password);
/*西门子*/
//获取设备列表
public List<DeviceSiemensEntity> getSiemensList(String url, String username , String password);
//获取指定编码设备列表
public List<DeviceSiemensEntity> getSiemensList(String url, String username , String password,String deviceId);
//下发单个设备
public int add(DeviceSiemensEntity siemens,String url);
//下发单个设备
public int add(List<DeviceSiemensEntity> list,String url);
//删除单个设备
public int delete(String url, String ids);
//启用
public int changeStatus(ChangeStatus changeStatus, String url);
//获取设备点位列表
public List<SiemensPointEntity> getPointList(String url, String deviceConfigID, String username , String password);
//下发点位
public int add(SiemensPointEntity point, String url, String id);
public int add(List<SiemensPointEntity> list, String url, String deviceConfigID);
//更改点位状态
public int edit(SiemensPointEntity point,String url);
//删除点位
public int deletePoint(String url, String ids);
//启用设备
public int changeStatusDevice(List<String>deviceIds,ChangeStatus changeStatus, String url);
Integer getPointListByCount(String url, String deviceConfigID, String username, String password);
List<SiemensPointEntity> getPointListAll(String adminIp, String deviceConfigID, String username, String password);
}

@ -0,0 +1,22 @@
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);
}

@ -0,0 +1,141 @@
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 GatewayServiceImpl implements GatewayMqttService {
private static final Logger log = LoggerFactory.getLogger(GatewayServiceImpl.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;
}
}

@ -0,0 +1,361 @@
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.DeviceModbusEntity;
import cn.iocoder.yudao.module.iot.framework.gateway.entity.ModbusPointEntity;
import cn.iocoder.yudao.module.iot.framework.gateway.entity.PageEntity;
import cn.iocoder.yudao.module.iot.framework.gateway.entity.PageEntityByDecice;
import cn.iocoder.yudao.module.iot.framework.gateway.service.IModbusPointService;
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.entity.UrlEncodedFormEntity;
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.message.BasicNameValuePair;
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.ArrayList;
import java.util.List;
import static cn.iocoder.yudao.module.iot.framework.gateway.util.HttpUtils.getHttpPost;
/* :
* 1.
* 2.
* 3.topic
*/
@Service
public class ModbusPointServiceImpl implements IModbusPointService {
private static final Logger log = LoggerFactory.getLogger(ModbusPointServiceImpl.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<DeviceModbusEntity> getModbusList(String address, String username, String password) {
PageEntity pageEntity = new PageEntity();
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
List<DeviceModbusEntity> list = null;
try {
String getlistUrl = address + UrlConstans.modbus_list;
HttpPost httpPost = getHttpPost(getlistUrl, HttpEntity.getPageParam(pageEntity));//检索条件
login(getlistUrl, username, password);
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
String entityStr = EntityUtils.toString(httpResponse.getEntity());
list = JsonUtils.toDeviceModbusEntityList(entityStr);
}
// 无论如何必须关闭连接
catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return list;
}
/*获取指定设备编码Modbus设备*/
@Override
public List<DeviceModbusEntity> getModbusList(String address, String username, String password, String deviceId) {
PageEntityByDecice pageEntity = new PageEntityByDecice();
pageEntity.setDeviceID(deviceId);
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
List<DeviceModbusEntity> list = null;
try {
String getlistUrl = address + UrlConstans.modbus_list;
HttpPost httpPost = getHttpPost(getlistUrl, HttpEntity.getPageParamVo(pageEntity));//检索条件
login(address, username, password);
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
String entityStr = EntityUtils.toString(httpResponse.getEntity());
list = JsonUtils.toDeviceModbusEntityList(entityStr);
}
// 无论如何必须关闭连接
catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return list;
}
@Override
public int add(DeviceModbusEntity deviceModbusEntity, String address) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
HttpPost httpPost = null;
try {
if (deviceModbusEntity.getDeviceConfigID() != null) {
httpPost = getHttpPost(address + UrlConstans.modbus_edit, HttpEntity.getParam(deviceModbusEntity));
} else {
httpPost = getHttpPost(address + UrlConstans.modbus_add, HttpEntity.getParam(deviceModbusEntity));
}
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
System.err.println(EntityUtils.toString(httpResponse.getEntity()));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return 1;
} catch (ClientProtocolException e) {
e.printStackTrace();
return 1;
} catch (IOException e) {
e.printStackTrace();
return 1;
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return 0;
}
@Override
public int add(List<DeviceModbusEntity> list, String url) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
HttpPost httpPost = null;
try {
httpPost = getHttpPost(url + UrlConstans.modbus_add, null);
httpPost.setHeader("Cookie", cookie);
for (DeviceModbusEntity entity : list) {
List<BasicNameValuePair> pairList = HttpEntity.getParam(entity);
if (pairList != null) {
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(pairList);
// 设置 HttpPost 参数
httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
}
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 delete(String address, String ids) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
HttpPost httpPost = null;
try {
httpPost = getHttpPost(address + UrlConstans.siemens_remove, HttpEntity.getRemoveParam(ids));//网关上设备的id
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
log.debug(EntityUtils.toString(httpResponse.getEntity()));
} 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;
try {
httpPost = getHttpPost(address + UrlConstans.siemens_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;
}
@Override
public List<ModbusPointEntity> getPointList(String address, String username, String password, String deviceConfigID) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
List<ModbusPointEntity> list = new ArrayList<>();
try {
/**
* TODO deviceSiemensEntity.getDeviceConfigID()
* */
String getlistUrl = address + UrlConstans.modbus_iopoint_list + deviceConfigID;
HttpPost httpPost = getHttpPost(getlistUrl, null);
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
String entityStr = EntityUtils.toString(httpResponse.getEntity());
list = JsonUtils.toModbusPointEntityList(entityStr);
}
// 无论如何必须关闭连接
catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return list;
}
@Override
public int add(ModbusPointEntity point, String address, String deviceConfigID) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
HttpPost httpPost = null;
try {
//https://71220220500200002.ng.xjzyun.com/device/config/siemens/content/add/r/0/82
httpPost = getHttpPost(address + UrlConstans.modbus_iopoint_add_r + deviceConfigID, HttpEntity.getParam(point));
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
System.err.println(EntityUtils.toString(httpResponse.getEntity()));
} catch (Exception e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return 0;
}
@Override
public int add(List<ModbusPointEntity> list, String address, String deviceConfigID) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
HttpPost httpPost = null;
try {
//https://71220220500200002.ng.xjzyun.com/device/config/siemens/content/add/r/0/82
httpPost = getHttpPost(address + UrlConstans.modbus_iopoint_add_r + deviceConfigID, null);
httpPost.setHeader("Cookie", cookie);
for (ModbusPointEntity entity : list) {
List<BasicNameValuePair> pairList = HttpEntity.getParam(entity);
if (pairList != null) {
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(pairList);
// 设置 HttpPost 参数
httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
}
httpResponse = httpClient.execute(httpPost);
////{"code":500,"msg":"缩放因子必须是有效的正小数"}
log.debug(EntityUtils.toString(httpResponse.getEntity()));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return 0;
}
@Override
public int deletePoint(String address, String ids) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
try {
HttpPost httpPost = getHttpPost(address + UrlConstans.modbus_iopoint_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 Integer getPointListByCount(String url, String username, String password, String deviceConfigID) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
Integer count = 0;
try {
/**
* TODO deviceSiemensEntity.getDeviceConfigID()
* */
String getlistUrl = url + UrlConstans.modbus_iopoint_list + deviceConfigID;
HttpPost httpPost = getHttpPost(getlistUrl, null);
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
String entityStr = EntityUtils.toString(httpResponse.getEntity());
count = Integer.parseInt(JsonUtils.toPointEntity(entityStr).getTotal());
}
// 无论如何必须关闭连接
catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return count;
}
@Override
public List<ModbusPointEntity> getPointListAll(String address, String username, String password, String deviceConfigID) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
List<ModbusPointEntity> list = new ArrayList<>();
try {
/**
* TODO deviceSiemensEntity.getDeviceConfigID()
* */
String getlistUrl = address + UrlConstans.modbus_iopoint_list + deviceConfigID;
HttpPost httpPost = getHttpPost(getlistUrl, null);
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
String entityStrTotal = EntityUtils.toString(httpResponse.getEntity());
String total = JsonUtils.toModbusPointEntityTotal(entityStrTotal);
PageEntity pageEntity = new PageEntity();
pageEntity.setPageNum("1");
pageEntity.setPageSize(total);
List<BasicNameValuePair> pageParam = HttpEntity.getPageParam(pageEntity);
httpPost.setEntity(new UrlEncodedFormEntity(pageParam, "UTF-8"));
httpResponse = httpClient.execute(httpPost);
String entityStr = EntityUtils.toString(httpResponse.getEntity());
list = JsonUtils.toModbusPointEntityList(entityStr);
}
// 无论如何必须关闭连接
catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return list;
}
}

@ -0,0 +1,398 @@
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.DeviceSiemensEntity;
import cn.iocoder.yudao.module.iot.framework.gateway.entity.PageEntity;
import cn.iocoder.yudao.module.iot.framework.gateway.entity.PageEntityByDecice;
import cn.iocoder.yudao.module.iot.framework.gateway.entity.SiemensPointEntity;
import cn.iocoder.yudao.module.iot.framework.gateway.service.ISiemensPointService;
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.entity.UrlEncodedFormEntity;
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.message.BasicNameValuePair;
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.ArrayList;
import java.util.HashMap;
import java.util.List;
import static cn.iocoder.yudao.module.iot.framework.gateway.util.HttpUtils.getHttpPost;
/**
* :
* 1.
* 2.
* 3.topic
*/
@Service
public class SiemensPointServiceImpl implements ISiemensPointService {
private static final Logger log = LoggerFactory.getLogger(SiemensPointServiceImpl.class);
private String cookie;
//先登录
@Override
public String 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);
this.cookie = HttpUtils.getCookies(httpResponse);
}
// 无论如何必须关闭连接
catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return cookie;
}
public HashMap<String, Object> getDate(SiemensPointEntity point) {
HashMap<String, Object> map = new HashMap<>();
map.put("siemensFieldName", point.getSiemensFieldName());
map.put("siemensFieldAddress", point.getSiemensFieldAddress());
map.put("siemensFieldDataType", point.getSiemensFieldDataType());
map.put("siemensFieldPrecision", point.getSiemensFieldPrecision());
map.put("siemensFieldUnit", point.getSiemensFieldUnit());
return map;
}
/*获取西门子设备列表*/
@Override
public List<DeviceSiemensEntity> getSiemensList(String url , String username , String password) {
PageEntity pageEntity = new PageEntity();
// 创建 HttpClient 客户端
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
List<DeviceSiemensEntity> list = null;
try {
String getlistUrl = url + UrlConstans.siemens_list;
HttpPost httpPost = getHttpPost(getlistUrl, HttpEntity.getPageParam(pageEntity));//检索条件
login(url, username, password);
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
if (httpResponse.getEntity() != null) {
String entityStr = EntityUtils.toString(httpResponse.getEntity());
list = JsonUtils.toDeviceSiemensEntityList(entityStr);
}
}
// 无论如何必须关闭连接
catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return list;
}
/*获取西门子设备列表*/
@Override
public List<DeviceSiemensEntity> getSiemensList(String url , String username , String password,String deviceId) {
PageEntityByDecice pageEntity = new PageEntityByDecice();
pageEntity.setDeviceID(deviceId);
// 创建 HttpClient 客户端
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
List<DeviceSiemensEntity> list = null;
try {
String getlistUrl = url + UrlConstans.siemens_list;
HttpPost httpPost = getHttpPost(getlistUrl, HttpEntity.getPageParamVo(pageEntity));//检索条件
login(url, username, password);
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
if (httpResponse.getEntity() != null) {
String entityStr = EntityUtils.toString(httpResponse.getEntity());
list = JsonUtils.toDeviceSiemensEntityList(entityStr);
}
}
// 无论如何必须关闭连接
catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return list;
}
@Override
public int add(DeviceSiemensEntity deviceSiemensEntity, String url) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
HttpPost httpPost = null;
try {
httpPost = getHttpPost(url + UrlConstans.siemens_add, HttpEntity.getParam(deviceSiemensEntity));
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 add(List<DeviceSiemensEntity> list, String url) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
HttpPost httpPost = null;
try {
httpPost = getHttpPost(url + UrlConstans.siemens_add, null);
httpPost.setHeader("Cookie", cookie);
for (DeviceSiemensEntity entity: list) {
List<BasicNameValuePair> pairList = HttpEntity.getParam(entity);
if (pairList != null) {
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(pairList);
// 设置 HttpPost 参数
httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
}
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 delete(String url, String ids) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
HttpPost httpPost = null;
try {
httpPost = getHttpPost(url + UrlConstans.siemens_remove, HttpEntity.getRemoveParam(ids));//网关上设备的id
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
} catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return 0;
}
@Override
public int changeStatus(ChangeStatus changeStatus, String url) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
HttpPost httpPost = null;
try {
httpPost = getHttpPost(url + UrlConstans.siemens_changestatus, HttpEntity.getChangestatus(changeStatus));
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
} catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return 0;
}
@Override
public List<SiemensPointEntity> getPointList(String url, String deviceConfigID,String username ,String password) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
List<SiemensPointEntity> list = new ArrayList<>();
try {
String getlistUrl = url + UrlConstans.siemens_iopoint_list_r +
deviceConfigID;
HttpPost httpPost = getHttpPost(getlistUrl, null);
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
String entityStr = EntityUtils.toString(httpResponse.getEntity());
list = JsonUtils.toSiemensPointEntityList(entityStr);
}
// 无论如何必须关闭连接
catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return list;
}
@Override
public int add(SiemensPointEntity point, String url, String deviceConfigID) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
HttpPost httpPost = null;
try {
httpPost = getHttpPost(url + UrlConstans.siemens_iopoint_edit_r+deviceConfigID, HttpEntity.getParam(point));
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
} catch (Exception e) {
e.printStackTrace();
}
finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return 0;
}
@Override
public int add(List<SiemensPointEntity> list, String url, String deviceConfigID) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
HttpPost httpPost = null;
try {
httpPost = getHttpPost(url + UrlConstans.siemens_iopoint_add_r+deviceConfigID, null);
httpPost.setHeader("Cookie", cookie);
for (SiemensPointEntity entity: list) {
if(entity.getSiemensFieldDataType()==null)continue;
List<BasicNameValuePair> pairList = HttpEntity.getParam(entity);
if (pairList != null) {
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(pairList);
// 设置 HttpPost 参数
httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
}
httpResponse = httpClient.execute(httpPost);
log.debug(EntityUtils.toString(httpResponse.getEntity()));
}
} catch (Exception e) {
e.printStackTrace();
}
finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return 0;
}
@Override
public int edit(SiemensPointEntity point, String url) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
HttpPost httpPost = null;
try {
httpPost = getHttpPost(url + UrlConstans.siemens_iopoint_edit_r, HttpEntity.getParam(point));
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
} catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return 0;
}
@Override
public int deletePoint( String url, String ids) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
HttpPost httpPost = null;
try {
httpPost = getHttpPost(url + UrlConstans.siemens_iopoint_remove_r, 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 changeStatusDevice(List<String>deviceIds,ChangeStatus changeStatus, String url) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
try {
HttpPost httpPost = getHttpPost(url + UrlConstans.siemens_changestatus, null);
httpPost.setHeader("Cookie", cookie);
for (String id: deviceIds) {
changeStatus.setChangesStatusID(id);
List<BasicNameValuePair> pairList = HttpEntity.getChangestatus(changeStatus);
if (pairList != null) {
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(pairList);
// 设置 HttpPost 参数
httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
}
httpResponse = httpClient.execute(httpPost);
log.debug(EntityUtils.toString(httpResponse.getEntity()));
}
} catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return 0;
}
@Override
public Integer getPointListByCount(String url, String deviceConfigID, String username, String password) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
Integer count = 0;
try {
String getlistUrl = url + UrlConstans.siemens_iopoint_list_r +
deviceConfigID;
HttpPost httpPost = getHttpPost(getlistUrl, null);
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
String entityStr = EntityUtils.toString(httpResponse.getEntity());
count = Integer.parseInt(JsonUtils.toPointEntity(entityStr).getTotal());
}
// 无论如何必须关闭连接
catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return count;
}
@Override
public List<SiemensPointEntity> getPointListAll(String url, String deviceConfigID,String username ,String password) {
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
List<SiemensPointEntity> list = new ArrayList<>();
try {
String getlistUrl = url + UrlConstans.siemens_iopoint_list_r +
deviceConfigID;
HttpPost httpPost = getHttpPost(getlistUrl, null);
httpPost.setHeader("Cookie", cookie);
httpResponse = httpClient.execute(httpPost);
String entityStrTotal = EntityUtils.toString(httpResponse.getEntity());
String total = JsonUtils.toSiemensPointEntityTotal(entityStrTotal);
PageEntity pageEntity = new PageEntity();
pageEntity.setPageNum("1");
pageEntity.setPageSize(total);
List<BasicNameValuePair> pageParam = HttpEntity.getPageParam(pageEntity);
httpPost.setEntity(new UrlEncodedFormEntity(pageParam, "UTF-8"));
httpResponse = httpClient.execute(httpPost);
String entityStr = EntityUtils.toString(httpResponse.getEntity());
list = JsonUtils.toSiemensPointEntityList(entityStr);
}
// 无论如何必须关闭连接
catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return list;
}
}

@ -0,0 +1,549 @@
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.DeviceDO;
import cn.iocoder.yudao.module.iot.dal.dataobject.gateway.GatewayDO;
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.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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Service
public class TheGatewayServiceImpl {
@Autowired
private IBeEquipmentsSiemensService beEquipmentsSiemensService;
@Autowired
private IIoPointService ioPointService;
@Autowired
private IVideoService videoService;
@Autowired
private ISiemensPointService siemensPointService;
@Autowired
private IMqttService mqttService;
@Autowired
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, String deviceCode) {
siemensPointService.login(gatewaysMessage.getAdminIp(), gatewaysMessage.getUsername(), gatewaysMessage.getPassword());
List<DeviceSiemensEntity> list = siemensPointService.getSiemensList(gatewaysMessage.getAdminIp(),
gatewaysMessage.getUsername(), gatewaysMessage.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<SiemensPointEntity> pointList = siemensPointService.getPointListAll(gatewaysMessage.getAdminIp(),
list.get(i).getDeviceConfigID(), gatewaysMessage.getUsername(), gatewaysMessage.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(gatewaysMessage.getAdminIp(), String.join(",", addressIds));
}
}
//再清除设备数据
siemensPointService.delete(gatewaysMessage.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 gatewaysMessage, DeviceDO siemens) {
siemensPointService.login(gatewaysMessage.getAdminIp(), gatewaysMessage.getUsername(), gatewaysMessage.getPassword());
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());
siemensPointService.add(deviceSiemensEntity, gatewaysMessage.getAdminIp());
}
//下发完成西门子设备后 下发对应设备的点位
public void addDeviceSiemensEntity(BeGatewaysMessage gatewaysMessage,String equipmentsId, String deviceId) {
siemensPointService.login(gatewaysMessage.getAdminIp(), gatewaysMessage.getUsername(), gatewaysMessage.getPassword());
/*下发好设备后获取设备列表找点位*/
List<DeviceSiemensEntity> siemensList = siemensPointService.getSiemensList(gatewaysMessage.getAdminIp(),
gatewaysMessage.getUsername(), gatewaysMessage.getPassword(), deviceId);
for (DeviceSiemensEntity deviceSiemensEntity : siemensList) {
//根据deviceId 和机台编码查询sql数据库点位信息
IoPoint bo = new IoPoint();
bo.setDeviceId(deviceSiemensEntity.getDeviceID());
bo.setEquipmentsId(equipmentsId);
//检索
List<IoPoint> points = ioPointService.list(ioPointService.buildQueryWrapper(bo));
List<SiemensPointEntity> list = new ArrayList<>();
for (IoPoint point : points) {
//新增点位
SiemensPointEntity siemensPointEntity = new SiemensPointEntity();
siemensPointEntity.setSiemensFieldName(point.getPointCode());
siemensPointEntity.setSiemensFieldAddress(point.getAddress());
Integer dataType = AddressDataType.getGatewayDataTypeMap(point.getDataType());
siemensPointEntity.setSiemensFieldDataType(dataType);
siemensPointEntity.setSiemensFieldPrecision(point.getSiemensFieldPrecision());
siemensPointEntity.setSiemensFieldUnit(point.getUnit());
list.add(siemensPointEntity);
}
if (list.size() > 0)
siemensPointService.add(list, gatewaysMessage.getAdminIp(), deviceSiemensEntity.getDeviceConfigID());
}
}
//下发完成西门子设备后 下发对应设备的点位
public void addDeviceSiemensEntity(BeEquipments equipments) {
siemensPointService.login(equipments.getAdminIp(), equipments.getUsername(), equipments.getPassword());
/*下发好设备后获取设备列表找点位*/
List<DeviceSiemensEntity> siemensList = siemensPointService.getSiemensList(equipments.getAdminIp(),
equipments.getUsername(), equipments.getPassword());
for (DeviceSiemensEntity deviceSiemensEntity : siemensList) {
//根据deviceId 和机台编码查询sql数据库点位信息
IoPoint bo = new IoPoint();
bo.setDeviceId(deviceSiemensEntity.getDeviceID());
bo.setEquipmentsId(equipments.getEquipmentsId());
//检索
List<IoPoint> points = ioPointService.list(ioPointService.buildQueryWrapper(bo));
List<SiemensPointEntity> list = new ArrayList<>();
for (IoPoint point : points) {
//新增点位
SiemensPointEntity siemensPointEntity = new SiemensPointEntity();
siemensPointEntity.setSiemensFieldName(point.getPointCode());
siemensPointEntity.setSiemensFieldAddress(point.getAddress());
Integer dataType = AddressDataType.getGatewayDataTypeMap(point.getDataType());
siemensPointEntity.setSiemensFieldDataType(dataType);
siemensPointEntity.setSiemensFieldPrecision(point.getSiemensFieldPrecision());
siemensPointEntity.setSiemensFieldUnit(point.getUnit());
list.add(siemensPointEntity);
}
if (list.size() > 0)
siemensPointService.add(list, equipments.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(BeGatewaysMessage gatewaysMessage, String deviceId) {
modbusPointService.login(gatewaysMessage.getAdminIp(), gatewaysMessage.getUsername(), gatewaysMessage.getPassword());
List<DeviceModbusEntity> list = modbusPointService.getModbusList(gatewaysMessage.getAdminIp(), gatewaysMessage.getUsername(), gatewaysMessage.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(gatewaysMessage.getAdminIp(),
gatewaysMessage.getUsername(), gatewaysMessage.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(gatewaysMessage.getAdminIp(), String.join(",", addressIds));
}
}
//再清除设备数据
modbusPointService.delete(gatewaysMessage.getAdminIp(), String.join(",", deviceIds));
}
}
public void addModbusEntity(BeEquipments equipments) {
modbusPointService.login(equipments.getAdminIp(), equipments.getUsername(), equipments.getPassword());
BeEquipmentsModbus bo = new BeEquipmentsModbus();
bo.setEquipmentsId(equipments.getEquipmentsId());
List<BeEquipmentsModbus> modbuses = beEquipmentsModbusService.list(beEquipmentsModbusService.buildQueryWrapper(bo));
List<DeviceModbusEntity> list = new ArrayList<>();
if (modbuses != null && modbuses.size() > 0) {
for (BeEquipmentsModbus modbus : modbuses) {
DeviceModbusEntity deviceModbusEntity = new DeviceModbusEntity();
deviceModbusEntity.setEquipmentsId(modbus.getEquipmentsId());
deviceModbusEntity.setDeviceId(modbus.getDeviceId());
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());
list.add(deviceModbusEntity);
//mob 下发失败 {"code":500,"msg":"该串口已经配置"}
}
if (list.size() > 0) modbusPointService.add(list, equipments.getAdminIp());
}
}
public void addModbusEntity(BeGatewaysMessage gatewaysMessage, BeEquipmentsModbus modbus) {
DeviceModbusEntity deviceModbusEntity = new DeviceModbusEntity();
deviceModbusEntity.setEquipmentsId(modbus.getEquipmentsId());
deviceModbusEntity.setDeviceId(modbus.getDeviceId());
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());
//mob 下发失败 {"code":500,"msg":"该串口已经配置"}
modbusPointService.add(deviceModbusEntity, gatewaysMessage.getAdminIp());
}
public void addDeviceModbusEntity(BeEquipments equipments) {
modbusPointService.login(equipments.getAdminIp(), equipments.getUsername(), equipments.getPassword());
/*下发好设备后获取设备列表找点位*/
List<DeviceModbusEntity> modbusPointList = modbusPointService.getModbusList(equipments.getAdminIp(), equipments.getUsername(), equipments.getPassword());
for (DeviceModbusEntity deviceModbusEntity : modbusPointList) {
//根据deviceId 和机台编码查询sql数据库点位信息
IoPoint bo = new IoPoint();
bo.setDeviceId(deviceModbusEntity.getDeviceId());
bo.setEquipmentsId(equipments.getEquipmentsId());
List<IoPoint> points = ioPointService.list(ioPointService.buildQueryWrapper(bo));
List<ModbusPointEntity> list = new ArrayList<>();
for (IoPoint point : points) {
//新增点位
ModbusPointEntity modbusPointEntity = new ModbusPointEntity();
modbusPointEntity.setModbusSlaveID(point.getModbusSlaveId());
modbusPointEntity.setModbusFieldName(point.getPointName());
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);
}
if (list.size() > 0)
modbusPointService.add(list, equipments.getAdminIp(), deviceModbusEntity.getDeviceConfigID());
}
}
public void addDeviceModbusEntity(BeGatewaysMessage gatewaysMessage,String equipmentsId, String deviceId) {
modbusPointService.login(gatewaysMessage.getAdminIp(), gatewaysMessage.getUsername(), gatewaysMessage.getPassword());
/*下发好设备后获取设备列表找点位*/
List<DeviceModbusEntity> modbusPointList = modbusPointService.getModbusList(gatewaysMessage.getAdminIp(), gatewaysMessage.getUsername(), gatewaysMessage.getPassword(), deviceId);
for (DeviceModbusEntity deviceModbusEntity : modbusPointList) {
//根据deviceId 和机台编码查询sql数据库点位信息
IoPoint bo = new IoPoint();
bo.setDeviceId(deviceModbusEntity.getDeviceId());
bo.setEquipmentsId(equipmentsId);
List<IoPoint> points = ioPointService.list(ioPointService.buildQueryWrapper(bo));
List<ModbusPointEntity> list = new ArrayList<>();
for (IoPoint point : points) {
//新增点位
ModbusPointEntity modbusPointEntity = new ModbusPointEntity();
modbusPointEntity.setModbusSlaveID(point.getModbusSlaveId());
modbusPointEntity.setModbusFieldName(point.getPointCode());
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);
}
if (list.size() > 0)
modbusPointService.add(list, gatewaysMessage.getAdminIp(), deviceModbusEntity.getDeviceConfigID());
}
}
/**
* mqtt
* 1
* 2
* 3
* 4
* 5
*/
public void deleteMqttEntity(BeEquipments equipments) {
//modbusPointService.login(equipments.getAdminIp(),equipments.getUsername(),equipments.getPassword());
List<MqttBrokerEntity> mqttBrokerEntity = mqttService.getMqttBrokerEntity(equipments.getAdminIp(),
equipments.getUsername(), equipments.getPassword());
for (MqttBrokerEntity brokerEntity : mqttBrokerEntity) {
mqttService.delete(equipments.getAdminIp(), brokerEntity.getCloudConfigID());
}
}
/***启用设备 */
public void changeStatus(BeGatewaysMessage gatewaysMessage, String deviceId, String type) {
List<String> deviceIds = new ArrayList<>();
if (type.equals("modbus")) {
/*下发好设备后获取设备列表找点位*/
List<DeviceModbusEntity> modbusPointList = modbusPointService.getModbusList(gatewaysMessage.getAdminIp(),
gatewaysMessage.getUsername(), gatewaysMessage.getPassword(), deviceId);
for (DeviceModbusEntity entity : modbusPointList) {
deviceIds.add(entity.getDeviceConfigID());
}
}
if (type.equals("siemens")) {
/*下发好设备后获取设备列表找点位*/
List<DeviceSiemensEntity> siemensList = siemensPointService.getSiemensList(gatewaysMessage.getAdminIp(),
gatewaysMessage.getUsername(), gatewaysMessage.getPassword(), deviceId);
for (DeviceSiemensEntity entity : siemensList) {
deviceIds.add(entity.getDeviceConfigID());
}
}
ChangeStatus changeStatus = new ChangeStatus();
changeStatus.setNewStatus("2");
changeStatus.setOldStatus("1");
siemensPointService.changeStatusDevice(deviceIds, changeStatus, gatewaysMessage.getAdminIp());
}
/***启用设备 */
public void changeStatus(BeEquipments equipments) {
/*下发好设备后获取设备列表找点位*/
List<DeviceModbusEntity> modbusPointList = modbusPointService.getModbusList(equipments.getAdminIp(),
equipments.getUsername(), equipments.getPassword());
/*下发好设备后获取设备列表找点位*/
List<DeviceSiemensEntity> siemensList = siemensPointService.getSiemensList(equipments.getAdminIp(),
equipments.getUsername(), equipments.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, equipments.getAdminIp());
}
public BeEquipments getEquipments(Integer gatewayMessageId) {
BeGatewaysMessage gatewaysMessage = gatewaysMessageService.getById(gatewayMessageId);
BeEquipments bo = new BeEquipments();
bo.setEquipmentsId(gatewaysMessage.getEquipmentId());
bo = equipmentsService.getOne(equipmentsService.buildQueryWrapper(bo));
return bo;
}
/*检测下发数据和实际下发数量是否匹配*/
public AjaxResult compare(String url, String username, String password, String deviceId, String equipmentId, String type) {
String deviceConfigID = null;
Integer pointList = 0;
if ("m".equals(type)) {
List<DeviceModbusEntity> modbusList = modbusPointService.getModbusList(url, username, password, deviceId);
if (modbusList != null && modbusList.size() > 0) {
deviceConfigID = modbusList.get(0).getDeviceConfigID();
}
pointList = modbusPointService.getPointListByCount(url, username, password, deviceConfigID);
} else {
List<DeviceSiemensEntity> siemensList = siemensPointService.getSiemensList(url, username, password, deviceId);
if (siemensList != null && siemensList.size() > 0) {
deviceConfigID = siemensList.get(0).getDeviceConfigID();
}
pointList = siemensPointService.getPointListByCount(url, deviceConfigID, username, password);
}
//根据deviceId 和机台编码查询sql数据库点位信息
IoPoint bo = new IoPoint();
bo.setDeviceId(deviceId);
bo.setEquipmentsId(equipmentId);
List<IoPoint> points = ioPointService.list(ioPointService.buildQueryWrapper(bo));
int size = points.size();
return size!=pointList?AjaxResult.error("下发失败!应下发" + points.size() + "个地址,实下发" + pointList + "个地址")
:AjaxResult.success("下发成功!应下发" + points.size() + "个地址,实下发" + pointList + "个地址");
}
/**网关登录测试*/
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);
}
}

@ -0,0 +1,128 @@
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;
}
}

@ -0,0 +1,385 @@
package cn.iocoder.yudao.module.iot.framework.gateway.util;
import org.apache.http.Header;
import org.apache.http.StatusLine;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.TrustStrategy;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.*;
import java.io.*;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLConnection;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
/**
* http
*
* @author ruoyi
*/
public class HttpUtils
{
private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
/**
* URL GET
*
* @param url URL
* @param param name1=value1&name2=value2
* @return
*/
public static String sendGet(String url, String param)
{
return sendGet(url, param, "UTF-8");
}
/**
* URL GET
*
* @param url URL
* @param param name1=value1&name2=value2
* @param contentType
* @return
*/
public static String sendGet(String url, String param, String contentType)
{
StringBuilder result = new StringBuilder();
BufferedReader in = null;
try
{
String urlNameString = url + "?" + param;
log.info("sendGet - {}", urlNameString);
URL realUrl = new URL(urlNameString);
URLConnection connection = realUrl.openConnection();
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
connection.connect();
in = new BufferedReader(new InputStreamReader(connection.getInputStream(), contentType));
String line;
while ((line = in.readLine()) != null)
{
result.append(line);
}
log.info("recv - {}", result);
}
catch (ConnectException e)
{
log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e);
}
catch (SocketTimeoutException e)
{
log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e);
}
catch (IOException e)
{
log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e);
}
catch (Exception e)
{
log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e);
}
finally
{
try
{
if (in != null)
{
in.close();
}
}
catch (Exception ex)
{
log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
}
}
return result.toString();
}
/**
* URL POST
*
* @param url URL
* @param param name1=value1&name2=value2
* @return
*/
public static String sendPost(String url, String param)
{
PrintWriter out = null;
BufferedReader in = null;
StringBuilder result = new StringBuilder();
try
{
String urlNameString = url;
log.info("sendPost - {}", urlNameString);
URL realUrl = new URL(urlNameString);
URLConnection conn = realUrl.openConnection();
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setRequestProperty("Accept-Charset", "utf-8");
conn.setRequestProperty("contentType", "utf-8");
conn.setDoOutput(true);
conn.setDoInput(true);
out = new PrintWriter(conn.getOutputStream());
out.print(param);
out.flush();
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"));
String line;
while ((line = in.readLine()) != null)
{
result.append(line);
}
log.info("recv - {}", result);
}
catch (ConnectException e)
{
log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e);
}
catch (SocketTimeoutException e)
{
log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e);
}
catch (IOException e)
{
log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e);
}
catch (Exception e)
{
log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e);
}
finally
{
try
{
if (out != null)
{
out.close();
}
if (in != null)
{
in.close();
}
}
catch (IOException ex)
{
log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
}
}
return result.toString();
}
public static String sendSSLPost(String url, String param)
{
StringBuilder result = new StringBuilder();
String urlNameString = url + "?" + param;
try
{
log.info("sendSSLPost - {}", urlNameString);
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom());
URL console = new URL(urlNameString);
HttpsURLConnection conn = (HttpsURLConnection) console.openConnection();
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setRequestProperty("Accept-Charset", "utf-8");
conn.setRequestProperty("contentType", "utf-8");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setSSLSocketFactory(sc.getSocketFactory());
conn.setHostnameVerifier(new TrustAnyHostnameVerifier());
conn.connect();
InputStream is = conn.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String ret = "";
while ((ret = br.readLine()) != null)
{
if (ret != null && !"".equals(ret.trim()))
{
result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8"));
}
}
log.info("recv - {}", result);
conn.disconnect();
br.close();
}
catch (ConnectException e)
{
log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e);
}
catch (SocketTimeoutException e)
{
log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e);
}
catch (IOException e)
{
log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e);
}
catch (Exception e)
{
log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e);
}
return result.toString();
}
private static class TrustAnyTrustManager implements X509TrustManager
{
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType)
{
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType)
{
}
@Override
public X509Certificate[] getAcceptedIssuers()
{
return new X509Certificate[] {};
}
}
private static class TrustAnyHostnameVerifier implements HostnameVerifier
{
@Override
public boolean verify(String hostname, SSLSession session)
{
return true;
}
}
public static CloseableHttpClient createSSLClientDefault() {
try {
//使用 loadTrustMaterial() 方法实现一个信任策略,信任所有证书
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
// 信任所有
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
}).build();
//NoopHostnameVerifier类: 作为主机名验证工具,实质上关闭了主机名验证,它接受任何
//有效的SSL会话并匹配到目标主机。
HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE;
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
return HttpClients.custom().setSSLSocketFactory(sslsf).build();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyStoreException e) {
e.printStackTrace();
}
return HttpClients.createDefault();
}
public static HttpPost getHttpPost(String url, List<BasicNameValuePair> list) throws UnsupportedEncodingException {
// 创建 HttpPost 请求
HttpPost httpPost = new HttpPost(url);
// 设置长连接
httpPost.setHeader("Connection", "keep-alive");
// 设置代理(模拟浏览器版本)
httpPost.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36");
httpPost.setHeader("Accept", "application/json, text/javascript, */*; q=0.01");
httpPost.setHeader("Accept-Encoding", "gzip, deflate, br");
httpPost.setHeader("Accept-Language", "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7");
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
// 设置 Cookie
//httpPost.setHeader("Cookie", "UM_distinctid=16442706a09352-0376059833914f-3c604504-1fa400-16442706a0b345; CNZZDATA1262458286=1603637673-1530123020-%7C1530123020; JSESSIONID=805587506F1594AE02DC45845A7216A4");
// 创建 HttpPost 参数
if (list != null) {
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(list);
// 设置 HttpPost 参数
httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
}
return httpPost;
}
public static HttpGet getHttpGet(String url, List<BasicNameValuePair> list) throws UnsupportedEncodingException {
// 创建 HttpGet 请求
HttpGet httpGet = new HttpGet(url);
// 设置长连接
httpGet.setHeader("Connection", "keep-alive");
// 设置代理(模拟浏览器版本)
httpGet.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36");
httpGet.setHeader("Accept", "application/json, text/javascript, */*; q=0.01");
httpGet.setHeader("Accept-Encoding", "gzip, deflate, br");
httpGet.setHeader("Accept-Language", "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7");
httpGet.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
// 创建 httpGet 参数
if (list != null) {
for (BasicNameValuePair pair : list) {
// 设置 httpGet 参数
httpGet.setHeader(pair.getName(),pair.getValue());
}
}
return httpGet;
}
public static boolean testNetworkConnected(String url){
// 创建 HttpClient 客户端
CloseableHttpClient httpClient = HttpUtils.createSSLClientDefault();
CloseableHttpResponse httpResponse = null;
try {
HttpGet httpGet = HttpUtils.getHttpGet(url,new ArrayList<>());
httpResponse = httpClient.execute(httpGet);
StatusLine statusLine = httpResponse.getStatusLine();
if(statusLine.getStatusCode() == 200)return true;
}
// 无论如何必须关闭连接
catch (IOException e) {
e.printStackTrace();
} finally {
HttpUtils.closeHttp(httpClient, httpResponse);
}
return false;
}
public static String getCookies(CloseableHttpResponse httpResponse) {
Header str = httpResponse.getHeaders("Set-Cookie")[0];
return str.getValue().split(";")[0];
}
public static void closeHttp(CloseableHttpClient httpClient, CloseableHttpResponse httpResponse) {
try {
if (httpClient != null) {
httpClient.close();
}
if (httpResponse != null) {
httpResponse.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
/*post操作是否成功*/
public static Boolean isOk(CloseableHttpResponse httpResponse) {
try {
return "200".equals(EntityUtils.toString(httpResponse.getEntity()));
} catch (IOException e) {
}
return false;
}
}

@ -0,0 +1,89 @@
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;
}
}

@ -0,0 +1,54 @@
package cn.iocoder.yudao.module.iot.framework.gateway.util;
import javax.net.ssl.*;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
public class SslUtil {
private static void trustAllHttpsCertificates() throws Exception {
TrustManager[] trustAllCerts = new TrustManager[1];
TrustManager tm = new miTM();
trustAllCerts[0] = tm;
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
static class miTM implements TrustManager, X509TrustManager {
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public boolean isServerTrusted(X509Certificate[] certs) {
return true;
}
public boolean isClientTrusted(X509Certificate[] certs) {
return true;
}
@Override
public void checkServerTrusted(X509Certificate[] certs, String authType) {
return;
}
@Override
public void checkClientTrusted(X509Certificate[] certs, String authType)
throws CertificateException {
return;
}
}
/**
* HTTPSSSLopenConnection
*/
public static void ignoreSsl() throws Exception{
HostnameVerifier hv = (urlHostName, session) -> true;
trustAllHttpsCertificates();
HttpsURLConnection.setDefaultHostnameVerifier(hv);
}
}

@ -0,0 +1,176 @@
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.SiemensPointEntity;
import cn.iocoder.yudao.module.iot.framework.gateway.service.ISiemensPointService;
import cn.iocoder.yudao.module.iot.framework.mqtt.utils.DateUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
@EnableScheduling
public class TestApp {
@Autowired
private ISiemensPointService iopointUploadService;
public static void main(String[] args){
System.out.println(DateUtils.getMillsLong());//1657075430559 1657461174420
//get();
//post();
//test();
}
//@Scheduled(fixedRate = 5000)
public void testHttp(){
//iopointUploadService.getList();
}
private static void get() {
// 创建 HttpClient 客户端
CloseableHttpClient httpClient = HttpClients.createDefault();
// 创建 HttpGet 请求
HttpGet httpGet = new HttpGet("https://71220220500200002.ng.xjzyun.com/");
// 设置长连接
httpGet.setHeader("Connection", "keep-alive");
// 设置代理(模拟浏览器版本)
httpGet.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36");
// 设置 Cookie
//httpGet.setHeader("Cookie", "UM_distinctid=16442706a09352-0376059833914f-3c604504-1fa400-16442706a0b345; CNZZDATA1262458286=1603637673-1530123020-%7C1530123020; JSESSIONID=805587506F1594AE02DC45845A7216A4");
CloseableHttpResponse httpResponse = null;
try {
// 请求并获得响应结果
httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
// 输出请求结果
System.out.println(EntityUtils.toString(httpEntity));
} catch (IOException e) {
e.printStackTrace();
}
// 无论如何必须关闭连接
finally {
if (httpResponse != null) {
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (httpClient != null) {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
private static void post() {
// 创建 HttpClient 客户端
CloseableHttpClient httpClient = HttpClients.createDefault();
// 创建 HttpPost 请求
HttpPost httpPost = new HttpPost("https://71220220500200002.ng.xjzyun.com/login");
// 设置长连接
httpPost.setHeader("Connection", "keep-alive");
// 设置代理(模拟浏览器版本)
httpPost.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36");
// 设置 Cookie
//httpPost.setHeader("Cookie", "UM_distinctid=16442706a09352-0376059833914f-3c604504-1fa400-16442706a0b345; CNZZDATA1262458286=1603637673-1530123020-%7C1530123020; JSESSIONID=805587506F1594AE02DC45845A7216A4");
// 创建 HttpPost 参数
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("username", "admini"));
params.add(new BasicNameValuePair("password", "adminx@052002"));
CloseableHttpResponse httpResponse = null;
try {
// 设置 HttpPost 参数
httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
// 输出请求结果
System.out.println(EntityUtils.toString(httpEntity));
for (Header str :
httpResponse.getHeaders("Set-Cookie")) {
System.out.println("name:"+str.getName()+",value:"+str.getValue());
}
System.out.println();;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// 无论如何必须关闭连接
finally {
try {
if (httpResponse != null) {
httpResponse.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if (httpClient != null) {
httpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void test(){
String str = "{\"code\":0,\"total\":14,\"msg\":\"\",\"rows\":[{\"deviceConfigContentID\":\"6\",\"siemensFieldAccess\":\"r\",\"siemensFieldAddress\":\"I0.0\",\"siemensFieldDataType\":\"1\",\"siemensFieldName\":\"系统手动\",\"siemensFieldPrecision\":\"0\"},{\"deviceConfigContentID\":\"7\",\"siemensFieldAccess\":\"r\",\"siemensFieldAddress\":\"I0.1\",\"siemensFieldDataType\":\"1\",\"siemensFieldName\":\"系统自动\",\"siemensFieldPrecision\":\"0\"},{\"deviceConfigContentID\":\"8\",\"siemensFieldAccess\":\"r\",\"siemensFieldAddress\":\"I0.2\",\"siemensFieldDataType\":\"1\",\"siemensFieldName\":\"系统启动\",\"siemensFieldPrecision\":\"0\"},{\"deviceConfigContentID\":\"9\",\"siemensFieldAccess\":\"r\",\"siemensFieldAddress\":\"I0.3\",\"siemensFieldDataType\":\"1\",\"siemensFieldName\":\"系统停止\",\"siemensFieldPrecision\":\"0\"},{\"deviceConfigContentID\":\"10\",\"siemensFieldAccess\":\"r\",\"siemensFieldAddress\":\"I0.4\",\"siemensFieldDataType\":\"1\",\"siemensFieldName\":\"找原点\",\"siemensFieldPrecision\":\"0\"},{\"deviceConfigContentID\":\"11\",\"siemensFieldAccess\":\"r\",\"siemensFieldAddress\":\"I0.5\",\"siemensFieldDataType\":\"1\",\"siemensFieldName\":\"系统复位\",\"siemensFieldPrecision\":\"0\"},{\"deviceConfigContentID\":\"12\",\"siemensFieldAccess\":\"r\",\"siemensFieldAddress\":\"I0.2\",\"siemensFieldDataType\":\"2\",\"siemensFieldName\":\"sys_test1\",\"siemensFieldPrecision\":\"0\"},{\"deviceConfigContentID\":\"13\",\"siemensFieldAccess\":\"r\",\"siemensFieldAddress\":\"I0.5\",\"siemensFieldDataType\":\"1\",\"siemensFieldName\":\"sys_test2\",\"siemensFieldPrecision\":\"0\"},{\"deviceConfigContentID\":\"14\",\"siemensFieldAccess\":\"r\",\"siemensFieldAddress\":\"I0.6\",\"siemensFieldDataType\":\"1\",\"siemensFieldName\":\"sys_test3\",\"siemensFieldPrecision\":\"0\"},{\"deviceConfigContentID\":\"15\",\"siemensFieldAccess\":\"r\",\"siemensFieldAddress\":\"I0.0\",\"siemensFieldDataType\":\"1\",\"siemensFieldName\":\"sys_test4\",\"siemensFieldPrecision\":\"0\"}]}";
Map<String,Object> map = JSON.parseObject(str);
for (Object obj : map.keySet()){
Object value = map.get(obj);
System.out.println("key为"+obj+"值为:"+value);
}
String key ="rows";
List<JSONArray> jsonArrays = (List<JSONArray>) map.get(key);
ListEntity entity = JSON.parseObject(str, ListEntity.class);
for (JSONObject json :
entity.getRows()) {
String obj = json.toJSONString();
SiemensPointEntity pointEntity = JSON.parseObject(obj, SiemensPointEntity.class);
System.out.println(pointEntity.toString());
}
}
}

@ -0,0 +1,91 @@
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…
Cancel
Save