mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 17:38:48 +08:00
iot相关修改
This commit is contained in:
parent
a7bf08efc6
commit
a610f5e067
@ -14,20 +14,20 @@ import org.springframework.stereotype.Component;
|
||||
public class CommonYmlConfig {
|
||||
|
||||
public static String URL_IOT_BASEURL = "ip端口";
|
||||
public static String URL_IOT_SERVER_ATTRIBUTE = "服务器属性";
|
||||
public static String URL_IOT_SCOPE_ATTRIBUTE = "作用域属性";
|
||||
public static String URL_IOT_TELEMETRY = "遥测";
|
||||
public static String URL_IOT_OPERATE = "操作控制";
|
||||
public static String URL_IOT_DEVICE = "设备信息";
|
||||
|
||||
public String baseurl = "";
|
||||
public String serverAttribute = "";
|
||||
public String scopeAttribute = "";
|
||||
public String telemetry = "";
|
||||
public String operate = "";
|
||||
public String device = "";
|
||||
|
||||
@Value("${iot.url.serverAttribute}")
|
||||
public String setServerAttribute(String serverAttribute) {
|
||||
return URL_IOT_SERVER_ATTRIBUTE = serverAttribute;
|
||||
@Value("${iot.url.scopeAttribute}")
|
||||
public String setScopeAttribute(String scopeAttribute) {
|
||||
return URL_IOT_SCOPE_ATTRIBUTE = scopeAttribute;
|
||||
}
|
||||
|
||||
@Value("${iot.url.telemetry}")
|
||||
|
||||
@ -5,14 +5,14 @@ import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
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.device.iot.DeviceDto;
|
||||
import org.dromara.web.domain.bo.*;
|
||||
import org.dromara.web.domain.vo.*;
|
||||
import org.dromara.web.service.IEqAreaService;
|
||||
import org.dromara.web.service.IEqEquipmentLogService;
|
||||
import org.dromara.web.service.IEqEquipmentService;
|
||||
import org.dromara.web.service.IEqShareService;
|
||||
import org.dromara.web.service.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -39,9 +39,10 @@ public class EqDeviceController extends BaseController {
|
||||
private final IEqEquipmentService eqEquipmentService;
|
||||
|
||||
private final IEqEquipmentLogService logService;
|
||||
private final IotService iotService;
|
||||
|
||||
private final IEqShareService shareService;
|
||||
private final ISysUserService userService;
|
||||
|
||||
|
||||
|
||||
/** todo
|
||||
@ -51,15 +52,12 @@ public class EqDeviceController extends BaseController {
|
||||
*/
|
||||
@GetMapping("/bindDevice")
|
||||
public R<Boolean> bindDevice(EqAppHomeBo bo){
|
||||
if (bo.getEquipmentCode() == null) throw new ServiceException("设备编码不能为空");
|
||||
String equipmentCode = bo.getEquipmentCode();
|
||||
if (equipmentCode == 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));
|
||||
|
||||
return R.ok(eqEquipmentService.bindDevice(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,17 +86,13 @@ public class EqDeviceController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备详情
|
||||
* 传参 设备id
|
||||
*/
|
||||
/** todo
|
||||
* 设备状态实时获取
|
||||
* @param bo
|
||||
* @return
|
||||
* 传参 设备编码
|
||||
*/
|
||||
@GetMapping("/getDeviceMsg")
|
||||
public R<EqEquipmentStatusVo> getDeviceMsg(EqAppHomeBo bo){
|
||||
public R<EqEquipmentDetailVo> getDeviceMsg(EqAppHomeBo bo){
|
||||
if (bo.getEquipmentCode() == null) throw new ServiceException("设备编码不能为空");
|
||||
if (bo.getEquipmentId() == null) throw new ServiceException("设备ID不能为空");
|
||||
return R.ok(eqEquipmentService.getDeviceMsg(bo));
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package org.dromara.web.device;
|
||||
package org.dromara.web.device.iot;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -1,4 +1,4 @@
|
||||
package org.dromara.web.device;
|
||||
package org.dromara.web.device.iot;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -106,7 +106,7 @@ public class DeviceMsgDto {
|
||||
13.电机维护故障 motorMaintainException
|
||||
14.设备故障 deviceException
|
||||
*/
|
||||
private String GarageException;
|
||||
private Integer GarageException;
|
||||
|
||||
/**
|
||||
* //倒计时设置时间
|
||||
@ -152,7 +152,7 @@ public class DeviceMsgDto {
|
||||
* 1.关闭中 closing
|
||||
* 2.开启中 openning
|
||||
*/
|
||||
private String WorkState;
|
||||
private Integer WorkState;
|
||||
|
||||
/**
|
||||
* //是否已经校准行程
|
||||
@ -1,4 +1,4 @@
|
||||
package org.dromara.web.device;
|
||||
package org.dromara.web.device.iot;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -0,0 +1,88 @@
|
||||
package org.dromara.web.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import org.dromara.web.device.iot.DeviceMsgDto;
|
||||
import org.dromara.web.domain.EqEquipment;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 设备信息视图对象 eq_equipment
|
||||
*
|
||||
* @author zzc
|
||||
* @date 2024-07-19
|
||||
*/
|
||||
@Data
|
||||
public class EqEquipmentDetailVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@ExcelProperty(value = "主键ID")
|
||||
private Long equipmentId;
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
@ExcelProperty(value = "设备编码")
|
||||
private String equipmentCode;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
@ExcelProperty(value = "设备名称")
|
||||
private String equipmentName;
|
||||
|
||||
/**
|
||||
* 设备状态
|
||||
*/
|
||||
@ExcelProperty(value = "设备状态 设备的打开状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "eq_status_type")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 设备状态
|
||||
*/
|
||||
@ExcelProperty(value = "设备状态 设备的打开状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "eq_run_status_type")
|
||||
private Integer runStatus;
|
||||
|
||||
/**
|
||||
* 故障状态
|
||||
*/
|
||||
@ExcelProperty(value = "故障状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "eq_fault_status")
|
||||
private Integer faultStatus;
|
||||
|
||||
/**
|
||||
* 离线状态
|
||||
*/
|
||||
@ExcelProperty(value = "离线状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "eq_line_status")
|
||||
private Integer lineStatus;
|
||||
|
||||
/**
|
||||
* 绑定时间
|
||||
*/
|
||||
@ExcelProperty(value = "绑定时间")
|
||||
private Date bindTime;
|
||||
|
||||
/**
|
||||
* 设备状态
|
||||
*/
|
||||
DeviceMsgDto deviceMsgDto;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -3,6 +3,7 @@ package org.dromara.web.service;
|
||||
import org.dromara.web.domain.bo.EqAppHomeBo;
|
||||
import org.dromara.web.domain.bo.EqDeviceCmdBo;
|
||||
import org.dromara.web.domain.bo.EqDeviceSetBo;
|
||||
import org.dromara.web.domain.vo.EqEquipmentDetailVo;
|
||||
import org.dromara.web.domain.vo.EqEquipmentStatusVo;
|
||||
import org.dromara.web.domain.vo.EqEquipmentVo;
|
||||
import org.dromara.web.domain.bo.EqEquipmentBo;
|
||||
@ -79,7 +80,7 @@ public interface IEqEquipmentService {
|
||||
* @param bo
|
||||
* @return
|
||||
*/
|
||||
EqEquipmentStatusVo getDeviceMsg(EqAppHomeBo bo);
|
||||
EqEquipmentDetailVo getDeviceMsg(EqAppHomeBo bo);
|
||||
|
||||
Boolean bindDevice(EqEquipmentBo eqEquipmentBo);
|
||||
Boolean bindDevice(EqAppHomeBo bo);
|
||||
}
|
||||
|
||||
@ -4,16 +4,19 @@ import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import org.dromara.common.core.utils.MessageUtils;
|
||||
import org.dromara.web.config.CommonYmlConfig;
|
||||
import org.dromara.web.device.DeviceCtlDto;
|
||||
import org.javatuples.Pair;
|
||||
import org.dromara.web.device.iot.DeviceCtlDto;
|
||||
import org.dromara.web.device.iot.DeviceMsgDto;
|
||||
import org.dromara.web.device.iot.DeviceServerMsgDto;
|
||||
import org.dromara.web.device.iot.DeviceDto;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -51,11 +54,41 @@ public class IotService {
|
||||
* @param deviceCode
|
||||
* @return
|
||||
*/
|
||||
public String httpTelemetryGetSend(String deviceCode){
|
||||
public DeviceMsgDto httpTelemetryGetSend(String deviceCode){
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("entityType","DEVICE");
|
||||
map.put("entityId",deviceCode);
|
||||
return getSend(CommonYmlConfig.URL_IOT_TELEMETRY, map);
|
||||
String send = getSend(CommonYmlConfig.URL_IOT_TELEMETRY, map);
|
||||
JSONObject jsonObject = JSON.parseObject(send);
|
||||
//转换
|
||||
Map<String, String> resultMap = new HashMap<>();
|
||||
for (String key : jsonObject.keySet()) {
|
||||
JSONObject valueObj = jsonObject.getJSONArray(key).getJSONObject(0);
|
||||
String value = valueObj.getString("value");
|
||||
resultMap.put(key, value);
|
||||
}
|
||||
|
||||
DeviceMsgDto result = new DeviceMsgDto();
|
||||
|
||||
result.setAutomaticDoorClosingSwitch(Boolean.valueOf(resultMap.get("AutomaticDoorClosingSwitch")));
|
||||
result.setAutomaticDoorClosingTime(jsonObject.getInteger("AutomaticDoorClosingTime"));
|
||||
result.setDoorRunningTimesSwitch(jsonObject.getInteger("DoorRunningTimesSwitch"));
|
||||
result.setResidualCountDown(jsonObject.getInteger("ResidualCountDown"));
|
||||
result.setDoorRunningTimes(jsonObject.getInteger("DoorRunningTimes"));
|
||||
result.setGarageException(jsonObject.getInteger("GarageException"));
|
||||
result.setCountDownConfig(jsonObject.getInteger("CountDownConfig"));
|
||||
result.setLightSwitch(jsonObject.getBoolean("LightSwitch"));
|
||||
result.setRemindCloseDoorConfig(jsonObject.getInteger("RemindCloseDoorConfig"));
|
||||
result.setRemindCloseDoorSwitch(jsonObject.getBoolean("RemindCloseDoorSwitch"));
|
||||
result.setPartOpenConfig(jsonObject.getInteger("PartOpenConfig"));
|
||||
result.setPartOpenSwitch(jsonObject.getBoolean("PartOpenSwitch"));
|
||||
result.setOpenPercentage(jsonObject.getInteger("OpenPercentage"));
|
||||
result.setWorkState(jsonObject.getInteger("WorkState"));
|
||||
result.setRouteCorrectStatus(jsonObject.getBoolean("RouteCorrectStatus"));
|
||||
result.setBounceSensitivity(jsonObject.getInteger("BounceSensitivity"));
|
||||
result.setIRSwitch(jsonObject.getBoolean("IRSwitch"));
|
||||
result.setWarningStatus(jsonObject.getInteger("warningStatus"));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,11 +96,19 @@ public class IotService {
|
||||
* @param deviceCode
|
||||
* @return
|
||||
*/
|
||||
public String httpServerGetSend(String deviceCode){
|
||||
public DeviceServerMsgDto httpServerGetSend(String deviceCode){
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("entityType","DEVICE");
|
||||
map.put("entityId",deviceCode);
|
||||
return getSend(CommonYmlConfig.URL_IOT_SERVER_ATTRIBUTE, map);
|
||||
map.put("scope","SERVER_SCOPE");
|
||||
String send = getSend(CommonYmlConfig.URL_IOT_SCOPE_ATTRIBUTE + "?keys=active", map);
|
||||
if (send.startsWith("{")) throw new RuntimeException("获取服务端属性信息失败");
|
||||
JSONArray jsonObject = JSON.parseArray(send);
|
||||
String resultString = JSON.toJSONString(jsonObject.get(0));
|
||||
Object value = JSON.parseObject(resultString).get("value");
|
||||
DeviceServerMsgDto result = new DeviceServerMsgDto();
|
||||
result.setLineStatus(Boolean.valueOf(value.toString()));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -76,10 +117,14 @@ public class IotService {
|
||||
* @param deviceCode
|
||||
* @return
|
||||
*/
|
||||
public String httpDeviceGetSend(String deviceCode){
|
||||
public DeviceDto httpDeviceGetSend(String deviceCode){
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("deviceId",deviceCode);
|
||||
return getSend(CommonYmlConfig.URL_IOT_DEVICE, map);
|
||||
String send = getSend(CommonYmlConfig.URL_IOT_DEVICE, map);
|
||||
JSONObject jsonObject = JSON.parseObject(send);
|
||||
DeviceDto deviceDto = jsonObject.toJavaObject(DeviceDto.class);
|
||||
if (deviceDto.getId()==null) throw new RuntimeException(MessageUtils.message("message.fault.device.notfound"));
|
||||
return deviceDto;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
package org.dromara.web.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@ -12,11 +9,16 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.web.config.CommonYmlConfig;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.service.ISysUserService;
|
||||
import org.dromara.web.device.*;
|
||||
import org.dromara.web.device.iot.DeviceDto;
|
||||
import org.dromara.web.device.iot.DeviceMsgDto;
|
||||
import org.dromara.web.device.iot.DeviceServerMsgDto;
|
||||
import org.dromara.web.domain.bo.EqAppHomeBo;
|
||||
import org.dromara.web.domain.bo.EqDeviceCmdBo;
|
||||
import org.dromara.web.domain.bo.EqDeviceSetBo;
|
||||
import org.dromara.web.domain.vo.EqEquipmentDetailVo;
|
||||
import org.dromara.web.domain.vo.EqEquipmentStatusVo;
|
||||
import org.dromara.web.service.IotService;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -26,6 +28,7 @@ import org.dromara.web.domain.EqEquipment;
|
||||
import org.dromara.web.mapper.EqEquipmentMapper;
|
||||
import org.dromara.web.service.IEqEquipmentService;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
@ -44,6 +47,8 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
|
||||
|
||||
private final IotService iotService;
|
||||
|
||||
private final ISysUserService userService;
|
||||
|
||||
/**
|
||||
* 查询设备信息
|
||||
*
|
||||
@ -199,34 +204,59 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EqEquipmentStatusVo getDeviceMsg(EqAppHomeBo bo) {
|
||||
EqEquipmentStatusVo result = new EqEquipmentStatusVo();
|
||||
public EqEquipmentDetailVo getDeviceMsg(EqAppHomeBo bo) {
|
||||
EqEquipmentDetailVo result = new EqEquipmentDetailVo();
|
||||
result.setEquipmentId(bo.getEquipmentId());
|
||||
result.setEquipmentCode(bo.getEquipmentCode());
|
||||
|
||||
EqEquipmentVo eqEquipmentVo = baseMapper.selectVoById(bo.getEquipmentId());
|
||||
//获取服务属性状态
|
||||
String serverMsg = iotService.httpServerGetSend(bo.getEquipmentCode());
|
||||
DeviceServerMsgDto serverMsgDto = JSONObject.parseObject(serverMsg, DeviceServerMsgDto.class);
|
||||
if (!serverMsgDto.getLineStatus()){
|
||||
result.setLineStatus(0);//离线
|
||||
return result;
|
||||
}
|
||||
DeviceServerMsgDto serverMsg = iotService.httpServerGetSend(bo.getEquipmentCode());
|
||||
result.setLineStatus(serverMsg.getLineStatus()?1:0);
|
||||
//获取遥测数据
|
||||
String telemetryMsg = iotService.httpTelemetryGetSend(bo.getEquipmentCode());
|
||||
DeviceMsgDto deviceMsgDto = JSONObject.parseObject(telemetryMsg, DeviceMsgDto.class);
|
||||
BeanUtil.copyProperties(deviceMsgDto,result,true);
|
||||
DeviceMsgDto telemetryMsg = iotService.httpTelemetryGetSend(bo.getEquipmentCode());
|
||||
result.setStatus(telemetryMsg.getOpenPercentage());
|
||||
result.setRunStatus(telemetryMsg.getGarageException()==10?telemetryMsg.getWorkState():telemetryMsg.getGarageException());
|
||||
result.setEquipmentName(eqEquipmentVo.getEquipmentName());
|
||||
result.setBindTime(eqEquipmentVo.getBindTime());
|
||||
result.setDeviceMsgDto(telemetryMsg);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean bindDevice(EqEquipmentBo eqEquipmentBo) {
|
||||
String equipmentCode = eqEquipmentBo.getEquipmentCode();
|
||||
String result = iotService.httpDeviceGetSend(equipmentCode);
|
||||
//判断是否获取到信息
|
||||
//获取到信息之后 获取设备状态类信息
|
||||
public Boolean bindDevice(EqAppHomeBo bo) {
|
||||
|
||||
//封装 调用设备数据进行保存
|
||||
return null;
|
||||
String equipmentCode = bo.getEquipmentCode();
|
||||
|
||||
LambdaQueryWrapper<EqEquipment> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq( EqEquipment::getEquipmentCode,equipmentCode);
|
||||
EqEquipmentVo eqEquipmentVo = baseMapper.selectVoOne(lqw);
|
||||
if (eqEquipmentVo!=null) throw new RuntimeException("设备已绑定");
|
||||
|
||||
DeviceServerMsgDto deviceServerMsgDto = iotService.httpServerGetSend(equipmentCode);
|
||||
if (!deviceServerMsgDto.getLineStatus()) throw new RuntimeException("设备未连接 无法绑定");
|
||||
|
||||
//从iot平台设置用户绑定 并获取设备信息
|
||||
DeviceDto deviceDto = iotService.httpDeviceGetSend(equipmentCode);//无信息会抛异常 无需判断
|
||||
EqEquipmentBo eqEquipmentBo = new EqEquipmentBo();
|
||||
eqEquipmentBo.setEquipmentCode(equipmentCode);
|
||||
eqEquipmentBo.setUserId(bo.getUserId());
|
||||
eqEquipmentBo.setAreaId(bo.getAreaId());
|
||||
eqEquipmentBo.setEquipmentName(deviceDto.getName());//默认使用iot的设备名称
|
||||
eqEquipmentBo.setType(0);
|
||||
eqEquipmentBo.setBindTime(new Date());
|
||||
SysUserVo sysUserVo = userService.selectUserById(bo.getUserId());
|
||||
eqEquipmentBo.setUserName(sysUserVo.getUserName());
|
||||
eqEquipmentBo.setNickName(sysUserVo.getNickName());
|
||||
DeviceMsgDto deviceMsgDto = iotService.httpTelemetryGetSend(equipmentCode);
|
||||
|
||||
eqEquipmentBo.setStatus(deviceMsgDto.getOpenPercentage());//使用半开作为状态值
|
||||
eqEquipmentBo.setFaultStatus(Integer.valueOf(deviceMsgDto.getGarageException()));
|
||||
|
||||
//判断是否获取到信息 无信息会抛异常 无需判断
|
||||
EqEquipment add = MapstructUtils.convert(eqEquipmentBo, EqEquipment.class);
|
||||
validEntityBeforeSave(add);
|
||||
baseMapper.insert(add);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -260,7 +260,7 @@ justauth:
|
||||
iot:
|
||||
baseurl: http://118.89.86.111:8080
|
||||
url:
|
||||
serverAttribute: /api/plugins/telemetry/{entityType}/{entityId}/values/attributes
|
||||
scopeAttribute: /api/plugins/telemetry/{entityType}/{entityId}/values/attributes/{scope}
|
||||
telemetry: /api/plugins/telemetry/{entityType}/{entityId}/values/timeseries
|
||||
operate: /api/plugins/rpc/oneway/{deviceId}
|
||||
device: /api/device/{deviceId}
|
||||
|
||||
@ -80,3 +80,6 @@ route.detail16= 5. Press and hold the Down key to close the button and release
|
||||
route.detail17= Observation: The door runs in the direction of closing, and stops when the door reaches the closed position
|
||||
route.detail18= Automatic check:
|
||||
route.detail19= 6. Press the "SET" button again
|
||||
|
||||
|
||||
message.fault.device.notfound = Device not found
|
||||
|
||||
@ -79,3 +79,5 @@ route.detail16=5.长按“向下”键至关闭位置后松手
|
||||
route.detail17=观察:门向关门方向运行,当门达到关闭位置后停止
|
||||
route.detail18=自动校验:
|
||||
route.detail19=6.再次按下"SET"键
|
||||
|
||||
message.fault.device.notfound = 设备不存在
|
||||
|
||||
@ -6,18 +6,15 @@ import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.dromara.web.config.CommonYmlConfig;
|
||||
import org.dromara.web.device.DeviceCtlDto;
|
||||
import org.dromara.web.device.iot.DeviceMsgDto;
|
||||
import org.dromara.web.service.IotService;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.thingsboard.rest.client.RestClient;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 断言单元测试案例
|
||||
@ -68,73 +65,21 @@ public class IotHttpTest {
|
||||
|
||||
@Test
|
||||
public void testMethod(){
|
||||
// String deviceCode = "4cd72020-2b11-11ef-890f-e7ba493dc999";
|
||||
String deviceCode = "4cd72020-2b11-11ef-890f-e7ba493dc999";
|
||||
String cmd = "{\"method\":\"zzctest\",\"params\":{\"switch\":\"on\"}}";
|
||||
|
||||
String result = httpCtlPostSend(deviceCode,cmd);
|
||||
System.out.println(result);
|
||||
|
||||
String result2 = httpTelemetryGetSend(deviceCode);
|
||||
// String result = iotService.httpCtlPostSend(deviceCode,cmd);
|
||||
// System.out.println(result);
|
||||
//
|
||||
DeviceMsgDto result2 = iotService.httpTelemetryGetSend(deviceCode);
|
||||
System.out.println(result2);
|
||||
|
||||
String result3 = httpDeviceGetSend(deviceCode);
|
||||
System.out.println(result3);
|
||||
// DeviceDto result3 = iotService.httpDeviceGetSend(deviceCode);
|
||||
// System.out.println(result3);
|
||||
|
||||
String result4 = httpServerGetSend(deviceCode);
|
||||
System.out.println(result4);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设备控制指令
|
||||
* @param deviceCode
|
||||
* @param cmd
|
||||
* @return
|
||||
*/
|
||||
public String httpCtlPostSend(String deviceCode,String cmd){
|
||||
DeviceCtlDto dto = new DeviceCtlDto();
|
||||
DeviceCtlDto.Params params = new DeviceCtlDto.Params();
|
||||
params.setCommand(cmd);
|
||||
dto.setParams(params);
|
||||
Map<String, String> paramMap = new HashMap<>();
|
||||
paramMap.put("deviceId",deviceCode);
|
||||
return iotService.postSendWithParam(CommonYmlConfig.URL_IOT_OPERATE, paramMap, JSON.toJSONString(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备信息
|
||||
* @param deviceCode
|
||||
* @return
|
||||
*/
|
||||
public String httpTelemetryGetSend(String deviceCode){
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("entityType","DEVICE");
|
||||
map.put("entityId",deviceCode);
|
||||
return iotService.getSend(CommonYmlConfig.URL_IOT_TELEMETRY, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务端属性信息
|
||||
* @param deviceCode
|
||||
* @return
|
||||
*/
|
||||
public String httpServerGetSend(String deviceCode){
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("entityType","DEVICE");
|
||||
map.put("entityId",deviceCode);
|
||||
return iotService.getSend(CommonYmlConfig.URL_IOT_SERVER_ATTRIBUTE, map);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取设备信息
|
||||
* @param deviceCode
|
||||
* @return
|
||||
*/
|
||||
public String httpDeviceGetSend(String deviceCode){
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("deviceId",deviceCode);
|
||||
return iotService.getSend(CommonYmlConfig.URL_IOT_DEVICE, map);
|
||||
// String result4 = iotService.httpServerGetSend(deviceCode);
|
||||
// System.out.println(result4);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user