mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 17:38:48 +08:00
设备控制设备状态等大致框架
This commit is contained in:
parent
5d847e626a
commit
3074cfeb04
@ -13,15 +13,17 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class CommonYmlConfig {
|
||||
|
||||
public static String URL_IOT_BASEURL = "ip端口";
|
||||
public static String URL_IOT_SERVER_ATTRIBUTE = "服务器属性";
|
||||
public static String URL_IOT_TELEMETRY = "遥测";
|
||||
public static String URL_IOT_OPERATE = "操作控制";
|
||||
public static String URL_IOT_BASEURL = "ip端口";
|
||||
public static String URL_IOT_DEVICE = "设备信息";
|
||||
|
||||
public String baseurl = "";
|
||||
public String serverAttribute = "";
|
||||
public String telemetry = "";
|
||||
public String operate = "";
|
||||
public String baseurl = "";
|
||||
public String device = "";
|
||||
|
||||
@Value("${iot.url.serverAttribute}")
|
||||
public String setServerAttribute(String serverAttribute) {
|
||||
@ -42,4 +44,9 @@ public class CommonYmlConfig {
|
||||
public String setBase(String baseurl) {
|
||||
return URL_IOT_BASEURL = baseurl;
|
||||
}
|
||||
|
||||
@Value("${iot.url.device}")
|
||||
public String setDevice(String device) {
|
||||
return URL_IOT_DEVICE = device;
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,9 +44,26 @@ public class EqDeviceController extends BaseController {
|
||||
private final ISysUserService userService;
|
||||
|
||||
|
||||
|
||||
/** todo
|
||||
* 控制设备 0关 1停 2开
|
||||
* 添加设备
|
||||
* @param bo 传参用户id 分布id 设备编码
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/bindDevice")
|
||||
public R<Boolean> bindDevice(EqAppHomeBo bo){
|
||||
if (bo.getEquipmentCode() == null) throw new ServiceException("设备编码不能为空");
|
||||
if (bo.getUserId() == null) throw new ServiceException("用户ID不能为空");
|
||||
if (bo.getAreaId() == null) throw new ServiceException("分布ID不能为空");
|
||||
//从iot平台设置用户绑定 并获取设备信息
|
||||
EqEquipmentBo eqEquipmentBo = new EqEquipmentBo();
|
||||
eqEquipmentBo.setEquipmentCode(bo.getEquipmentCode());
|
||||
eqEquipmentBo.setUserId(bo.getUserId());
|
||||
eqEquipmentBo.setAreaId(bo.getAreaId());
|
||||
return R.ok(eqEquipmentService.bindDevice(eqEquipmentBo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制设备 门 灯光 控制
|
||||
* 传参设备编码
|
||||
*/
|
||||
@GetMapping("/operate")
|
||||
@ -57,6 +74,11 @@ public class EqDeviceController extends BaseController {
|
||||
return R.ok(eqEquipmentService.operate(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备设置 门 灯光 红外 弹力 提醒等设置
|
||||
* @param bo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/setting")
|
||||
public R<String> setting(EqDeviceSetBo bo){
|
||||
if (bo.getEquipmentCode() == null) throw new ServiceException("设备编码不能为空");
|
||||
|
||||
@ -11,6 +11,7 @@ import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.service.ISysUserService;
|
||||
import org.dromara.web.config.CommonYmlConfig;
|
||||
import org.dromara.web.domain.bo.*;
|
||||
import org.dromara.web.domain.vo.*;
|
||||
import org.dromara.web.service.*;
|
||||
@ -84,7 +85,7 @@ public class EqHomeController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备详情
|
||||
* 设备详情 (暂时无用)
|
||||
* 传参 设备id
|
||||
*/
|
||||
@GetMapping("/info")
|
||||
@ -93,24 +94,7 @@ public class EqHomeController extends BaseController {
|
||||
return R.ok(eqEquipmentService.queryById(bo.getEquipmentId()));
|
||||
}
|
||||
|
||||
/** todo
|
||||
* 添加设备
|
||||
* @param bo 传参用户id 分布id 设备编码
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
public R<Boolean> add(EqAppHomeBo bo){
|
||||
if (bo.getEquipmentCode() == null) throw new ServiceException("设备编码不能为空");
|
||||
if (bo.getUserId() == null) throw new ServiceException("用户ID不能为空");
|
||||
if (bo.getAreaId() == null) throw new ServiceException("分布ID不能为空");
|
||||
//从iot平台设置用户绑定 并获取设备信息
|
||||
EqEquipmentBo eqEquipmentBo = new EqEquipmentBo();
|
||||
eqEquipmentBo.setEquipmentCode(bo.getEquipmentCode());
|
||||
// eqEquipmentBo.setUserId(bo.getUserId());
|
||||
// eqEquipmentBo.setAreaId(bo.getAreaId());
|
||||
//TODO 未完
|
||||
return R.ok(eqEquipmentService.insertByBo(eqEquipmentBo));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@ -129,7 +113,7 @@ public class EqHomeController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
* 密码已验证
|
||||
* 密码验证
|
||||
* @param bo
|
||||
* @return
|
||||
*/
|
||||
|
||||
@ -0,0 +1,94 @@
|
||||
package org.dromara.web.device.iot;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName : DeviceDto
|
||||
* @Author : ZZC
|
||||
* @Date : 2024/7/26 10:59
|
||||
* @Discription : 设备信息 对应接口/api/device/{deviceId}
|
||||
**/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class DeviceDto implements Serializable {
|
||||
|
||||
private Id id;
|
||||
private Long createdTime;
|
||||
private TenantId tenantId;
|
||||
private CustomerId customerId;
|
||||
private String name;
|
||||
private String type;
|
||||
private String label;
|
||||
private DeviceProfileId deviceProfileId;
|
||||
private DeviceData deviceData;
|
||||
private FirmwareId firmwareId;
|
||||
private SoftwareId softwareId;
|
||||
private AdditionalInfo additionalInfo;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class Id {
|
||||
private String id;
|
||||
private String entityType;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class TenantId {
|
||||
private String id;
|
||||
private String entityType;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class CustomerId {
|
||||
private String id;
|
||||
private String entityType;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class DeviceProfileId {
|
||||
private String id;
|
||||
private String entityType;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class DeviceData {
|
||||
private Configuration configuration;
|
||||
private TransportConfiguration transportConfiguration;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class Configuration {
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class TransportConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class FirmwareId {
|
||||
private String id;
|
||||
private String entityType;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class SoftwareId {
|
||||
private String id;
|
||||
private String entityType;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class AdditionalInfo {
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,8 @@
|
||||
package org.dromara.web.domain;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
@ -39,6 +42,11 @@ public class EqEquipment extends BaseEntity {
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 设备所属用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 登录账号
|
||||
*/
|
||||
|
||||
@ -40,6 +40,9 @@ public class EqEquipmentBo extends BaseEntity {
|
||||
@NotNull(message = "设备类型不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Integer type;
|
||||
|
||||
@NotNull(message = "设备所属用户id", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 登录账号
|
||||
*/
|
||||
|
||||
@ -49,6 +49,12 @@ public class EqEquipmentVo implements Serializable {
|
||||
@ExcelDictFormat(dictType = "eq_equipment_type")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 登录账号
|
||||
*/
|
||||
@ExcelProperty(value = "登录账号ID")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 登录账号
|
||||
*/
|
||||
|
||||
@ -80,4 +80,6 @@ public interface IEqEquipmentService {
|
||||
* @return
|
||||
*/
|
||||
EqEquipmentStatusVo getDeviceMsg(EqAppHomeBo bo);
|
||||
|
||||
Boolean bindDevice(EqEquipmentBo eqEquipmentBo);
|
||||
}
|
||||
|
||||
@ -215,6 +215,13 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean bindDevice(EqEquipmentBo eqEquipmentBo) {
|
||||
String equipmentCode = eqEquipmentBo.getEquipmentCode();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设备控制指令
|
||||
@ -260,4 +267,17 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
|
||||
return HttpUtil.get(url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取设备信息
|
||||
* @param deviceCode
|
||||
* @return
|
||||
*/
|
||||
private String httpDeviceGetSend(String deviceCode){
|
||||
String url = CommonYmlConfig.URL_IOT_BASEURL+CommonYmlConfig.URL_IOT_DEVICE;
|
||||
url = url.replace("{deviceId}",deviceCode) ;
|
||||
// todo 登录相关 token
|
||||
return HttpUtil.get(url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -263,3 +263,4 @@ iot:
|
||||
serverAttribute: /api/plugins/telemetry/{entityType}/{entityId}/values/attributes
|
||||
telemetry: /api/plugins/telemetry/{entityType}/{entityId}/values/timeseries
|
||||
operate: /api/plugins/rpc/oneway/{deviceId}
|
||||
device: /api/device/{deviceId}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user