设备控制相关添加及优化

This commit is contained in:
zhangzhicheng 2024-07-25 12:11:35 +08:00
parent 70916b6eb5
commit 814a52c707
14 changed files with 545 additions and 120 deletions

View File

@ -0,0 +1,38 @@
package org.dromara.web.config;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* @Author zzc
* @Date 17:02 2024/7/24
* @Description 公共配置
**/
@Data
@Component
public class CommonYmlConfig {
public static String URL_IOT_SERVER_ATTRIBUTE = "服务器属性";
public static String URL_IOT_TELEMETRY = "遥测";
public static String URL_IOT_OPERATE = "操作控制";
public String serverAttribute = "";
public String telemetry = "";
public String operate = "";
@Value("${iot.url.serverAttribute}")
public String setServerAttribute(String serverAttribute) {
return URL_IOT_SERVER_ATTRIBUTE = serverAttribute;
}
@Value("${iot.url.telemetry}")
public String setTelemetry(String telemetry) {
return URL_IOT_TELEMETRY = telemetry;
}
@Value("${iot.url.operate}")
public String setOperate(String operate) {
return URL_IOT_OPERATE = operate;
}
}

View File

@ -0,0 +1,105 @@
package org.dromara.web.controller.app;
import lombok.RequiredArgsConstructor;
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.web.core.BaseController;
import org.dromara.system.service.ISysUserService;
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.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* app首页
*
* @author Lion Li
* @date 2024-07-14
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/device")
public class EqDeviceController extends BaseController {
private final IEqAreaService eqAreaService;
private final IEqEquipmentService eqEquipmentService;
private final IEqEquipmentLogService logService;
private final IEqShareService shareService;
private final ISysUserService userService;
/** todo
* 控制设备 0关 1停 2开
* 传参设备编码
*/
@GetMapping("/operate")
public R<String> operate(EqDeviceCmdBo bo){
if (bo.getEquipmentCode() == null) throw new ServiceException("设备编码不能为空");
if (bo.getOperateType() == 0) throw new ServiceException("操作类型不能为0");
if (bo.getUserId() == null) throw new ServiceException("用户ID不能为空");
return R.ok(eqEquipmentService.operate(bo));
}
@GetMapping("/setting")
public R<String> setting(EqDeviceSetBo bo){
if (bo.getEquipmentCode() == null) throw new ServiceException("设备编码不能为空");
if (bo.getOperateType() == 0) throw new ServiceException("操作类型不能为0");
if (bo.getUserId() == null) throw new ServiceException("用户ID不能为空");
return R.ok(eqEquipmentService.setting(bo));
}
/**
* 设备详情
* 传参 设备id
*/
/** todo
* 设备状态实时获取
* @param bo
* @return
*/
@GetMapping("/getDeviceStatus")
public R<EqEquipmentStatusVo> getDeviceStatus(EqAppHomeBo bo){
EqEquipmentStatusVo result = new EqEquipmentStatusVo();
return R.ok(result);
}
/**
* 获取日志
* @param bo
* @param pageQuery
* @return
*/
@GetMapping("/getDeviceLogs")
public TableDataInfo<EqEquipmentLogVo> getDeviceLogs(EqAppHomeBo bo,PageQuery pageQuery){
EqEquipmentLogBo eqEquipmentLogBo = new EqEquipmentLogBo();
eqEquipmentLogBo.setEquipmentId(bo.getEquipmentId());
return logService.queryPageList(eqEquipmentLogBo, pageQuery);
}
/**
* 保存日志
* @param eqEquipmentLogBo
*/
@GetMapping("/saveDeviceLogs")
public void saveDeviceLogs(EqEquipmentLogBo eqEquipmentLogBo){
logService.insertByBo(eqEquipmentLogBo);
}
}

View File

@ -83,18 +83,6 @@ public class EqHomeController extends BaseController {
return eqEquipmentService.queryPageList(eqEquipmentBo, pageQuery); //在设备表中增加了分布id return eqEquipmentService.queryPageList(eqEquipmentBo, pageQuery); //在设备表中增加了分布id
} }
/** todo
* 控制设备 0关 1停 2开
* 传参设备编码
*/
@GetMapping("/operate")
public R<String> operate(EqAppHomeBo bo){
if (bo.getEquipmentCode() == null) throw new ServiceException("设备编码不能为空");
if (bo.getOperateType() == 0) throw new ServiceException("操作类型不能为0");
if (bo.getUserId() == null) throw new ServiceException("用户ID不能为空");
return R.ok(eqEquipmentService.operate(bo));
}
/** /**
* 设备详情 * 设备详情
* 传参 设备id * 传参 设备id
@ -152,43 +140,17 @@ public class EqHomeController extends BaseController {
SysUserVo sysUserVo = userService.selectUserById(bo.getUserId()); SysUserVo sysUserVo = userService.selectUserById(bo.getUserId());
if (sysUserVo == null) throw new ServiceException("用户不存在"); if (sysUserVo == null) throw new ServiceException("用户不存在");
return R.ok(BCrypt.checkpw(bo.getPassword(), sysUserVo.getPassword())); return R.ok(BCrypt.checkpw(bo.getPassword(), sysUserVo.getPassword()));
// return R.ok(BCrypt.hashpw(bo.getPassword()).equals(sysUserVo.getPassword()));
} }
/** /*
* 未设置设备详情页
*/ */
@GetMapping("/noInitDevicePage")
public R<List<String>> noInitDevicePage(){
List<String> list = Arrays.asList(
MessageUtils.message("route.detail1"),
MessageUtils.message("route.detail2"),
MessageUtils.message("route.detail3"),
MessageUtils.message("route.detail4"),
MessageUtils.message("route.detail5"),
MessageUtils.message("route.detail6"),
MessageUtils.message("route.detail7"),
MessageUtils.message("route.detail8"),
MessageUtils.message("route.detail9"),
MessageUtils.message("route.detail10"),
MessageUtils.message("route.detail11"),
MessageUtils.message("route.detail12"),
MessageUtils.message("route.detail13"),
MessageUtils.message("route.detail14"),
MessageUtils.message("route.detail15"),
MessageUtils.message("route.detail16"),
MessageUtils.message("route.detail17"),
MessageUtils.message("route.detail18"),
MessageUtils.message("route.detail19")
);
return R.ok(list);
}
/** todo /** todo
* 设备状态实时获取 * 设备状态实时获取
* @param bo * @param bo
* @return * @return
*/ *//*
@GetMapping("/getDeviceStatus") @GetMapping("/getDeviceStatus")
public R<EqEquipmentStatusVo> getDeviceStatus(EqAppHomeBo bo){ public R<EqEquipmentStatusVo> getDeviceStatus(EqAppHomeBo bo){
EqEquipmentStatusVo result = new EqEquipmentStatusVo(); EqEquipmentStatusVo result = new EqEquipmentStatusVo();
@ -198,12 +160,14 @@ public class EqHomeController extends BaseController {
} }
*/
/** /**
* 获取日志 * 获取日志
* @param bo * @param bo
* @param pageQuery * @param pageQuery
* @return * @return
*/ *//*
@GetMapping("/getDeviceLogs") @GetMapping("/getDeviceLogs")
public TableDataInfo<EqEquipmentLogVo> getDeviceLogs(EqAppHomeBo bo,PageQuery pageQuery){ public TableDataInfo<EqEquipmentLogVo> getDeviceLogs(EqAppHomeBo bo,PageQuery pageQuery){
EqEquipmentLogBo eqEquipmentLogBo = new EqEquipmentLogBo(); EqEquipmentLogBo eqEquipmentLogBo = new EqEquipmentLogBo();
@ -211,14 +175,17 @@ public class EqHomeController extends BaseController {
return logService.queryPageList(eqEquipmentLogBo, pageQuery); return logService.queryPageList(eqEquipmentLogBo, pageQuery);
} }
*/
/** /**
* 保存日志 * 保存日志
* @param eqEquipmentLogBo * @param eqEquipmentLogBo
*/ *//*
@GetMapping("/saveDeviceLogs") @GetMapping("/saveDeviceLogs")
public void saveDeviceLogs(EqEquipmentLogBo eqEquipmentLogBo){ public void saveDeviceLogs(EqEquipmentLogBo eqEquipmentLogBo){
logService.insertByBo(eqEquipmentLogBo); logService.insertByBo(eqEquipmentLogBo);
} }
*/
} }

View File

@ -0,0 +1,82 @@
package org.dromara.web.controller.app;
import cn.dev33.satoken.secure.BCrypt;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MessageUtils;
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.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.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* 固定文本获取
*
* @author zzc
* @date 2024-07-14
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/text")
public class EqTextController extends BaseController {
private final IEqAreaService eqAreaService;
private final IEqEquipmentService eqEquipmentService;
private final IEqEquipmentLogService logService;
private final IEqShareService shareService;
private final ISysUserService userService;
/**
* 未设置设备详情页
*/
@GetMapping("/noInitDevicePage")
public R<List<String>> noInitDevicePage(){
List<String> list = Arrays.asList(
MessageUtils.message("route.detail1"),
MessageUtils.message("route.detail2"),
MessageUtils.message("route.detail3"),
MessageUtils.message("route.detail4"),
MessageUtils.message("route.detail5"),
MessageUtils.message("route.detail6"),
MessageUtils.message("route.detail7"),
MessageUtils.message("route.detail8"),
MessageUtils.message("route.detail9"),
MessageUtils.message("route.detail10"),
MessageUtils.message("route.detail11"),
MessageUtils.message("route.detail12"),
MessageUtils.message("route.detail13"),
MessageUtils.message("route.detail14"),
MessageUtils.message("route.detail15"),
MessageUtils.message("route.detail16"),
MessageUtils.message("route.detail17"),
MessageUtils.message("route.detail18"),
MessageUtils.message("route.detail19")
);
return R.ok(list);
}
}

View File

@ -0,0 +1,42 @@
package org.dromara.web.device;
/**
* @ClassName : DeviceCtlCmd
* @Author : ZZC
* @Date : 2024/7/25 0:07
* @Description : 设备控制命令
**/
public class DeviceCtlCmd {
/**
* 设备控制
* 命令格式URC+ECTAS=设备类型,设备命令,设备参数,设备参数,设备参数
* //开门 URC+ECTAS=GarageDoor,OpenGarage,100,{},73
* //半开门 URC+ECTAS=GarageDoor,PartOpenGarage,{},{},83
* //门体停止 URC+ECTAS=GarageDoor,StopGarage,{},{},f5
* //关门 URC+ECTAS=GarageDoor,OpenGarage,0,{},30
* //门体运行状态循环切换 URC+ECTAS=GarageDoor,ToggleGarage,0,{}
* //复位照明时长 URC+ECTAS=GarageDoor,ResumeCountDown,{},{},1b
* //照明灯开关 URC+ECTPS=GarageDoorLightControl,LightSwitch,0,false,{},4d
* //照明灯开关 URC+ECTPS=GarageDoorLightControl,LightSwitch,0,true,{},98
*/
//开门 URC+ECTAS=GarageDoor,OpenGarage,100,{},73
public final static String OPT_OPEN_GARAGE = "URC+ECTAS=GarageDoor,OpenGarage,100,{},73";
//半开门 URC+ECTAS=GarageDoor,PartOpenGarage,{},{},83
public final static String OPT_PART_OPEN_GARAGE = "URC+ECTAS=GarageDoor,PartOpenGarage,{},{},83";
//门体停止 URC+ECTAS=GarageDoor,StopGarage,{},{},f5
public final static String OPT_STOP_GARAGE = "URC+ECTAS=GarageDoor,StopGarage,{},{},f5";
//关门 URC+ECTAS=GarageDoor,OpenGarage,0,{},30
public final static String OPT_CLOSE_GARAGE = "URC+ECTAS=GarageDoor,OpenGarage,0,{},30";
//门体运行状态循环切换 URC+ECTAS=GarageDoor,ToggleGarage,0,{}
public final static String OPT_TOGGLE_GARAGE = "URC+ECTAS=GarageDoor,ToggleGarage,0,{}";
//复位照明时长 URC+ECTAS=GarageDoor,ResumeCountDown,{},{},1b
public final static String OPT_RESUME_COUNTDOWN = "URC+ECTAS=GarageDoor,ResumeCountDown,{},{},1b";
//照明灯开关 URC+ECTPS=GarageDoorLightControl,LightSwitch,0,false,{},4d
public static final String LightSwitch_false = "URC+ECTPS=GarageDoorLightControl,LightSwitch,0,false,{},4d";
//照明灯开关 URC+ECTPS=GarageDoorLightControl,LightSwitch,0,true,{},98
public static final String LightSwitch_true = "URC+ECTPS=GarageDoorLightControl,LightSwitch,0,true,{},98";
}

View File

@ -0,0 +1,28 @@
package org.dromara.web.device;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @ClassName : DeviceCtlDto
* @Author : ZZC
* @Date : 2024/7/25 11:21
* @Discription : 控制入参
**/
@NoArgsConstructor
@Data
public class DeviceCtlDto implements Serializable {
private String method;
private Params params;
private Boolean persistent = false;
private Integer timeout = 5000;
@NoArgsConstructor
@Data
public static class Params {
private String command;
}
}

View File

@ -0,0 +1,29 @@
package org.dromara.web.device;
/**
* @ClassName : DeviceCtlCmd
* @Author : ZZC
* @Date : 2024/7/25 0:07
* @Description : 设备通知命令
**/
public class DeviceNotifyCmd {
//属性获取 todo 该指令是用于触发属性状态的发送
//自动关门功能开关 URC+ECTPG=GarageDoorLightControl,AutomaticDoorClosingSwitch
//延时自动关门的延时时长 URC+ECTPG=GarageDoorLightControl,AutomaticDoorClosingTime
//运行次数开关 URC+ECTPG=GarageDoorLightControl,DoorRunningTimesSwitch
//倒计时剩余时间 URC+ECTPG=GarageDoorLightControl,ResidualCountDown
//运行次数 URC+ECTPG=GarageDoorLightControl,DoorRunningTimes
//车库门异常状态 URC+ECTPG=GarageDoorLightControl,GarageException
//倒计时设置时间 URC+ECTPG=GarageDoorLightControl,CountDownConfig
//照明灯开关 URC+ECTPG=GarageDoorLightControl,LightSwitch
//提醒关门时间设置 URC+ECTPG=CustomGarageDoor,RemindCloseDoorConfig
//提醒关门功能开关 URC+ECTPG=CustomGarageDoor,RemindCloseDoorSwitch
//半开门高度设置 URC+ECTPG=CustomGarageDoor,PartOpenConfig
//半开门功能开关 URC+ECTPG=CustomGarageDoor,PartOpenSwitch
//开合度百分比 URC+ECTPG=CustomGarageDoor,OpenPercentage
//门体运行状态 URC+ECTPG=CustomGarageDoor,WorkState
//是否已经校准行程 URC+ECTPG=GarageDoor,RouteCorrectStatus
//遇阻回弹的阻力设置 URC+ECTPG=GarageDoor,BounceSensitivity
//红外感应开关 URC+ECTPG=GarageDoor,IRSwitch
}

View File

@ -1,36 +1,12 @@
package org.dromara.web.device; package org.dromara.web.device;
/** /**
* @ClassName : DeviceCmd * @ClassName : DeviceCtlCmd
* @Author : ZZC * @Author : ZZC
* @Date : 2024/7/25 0:07 * @Date : 2024/7/25 0:07
* @Description : 设备命令 * @Description : 设备设置命令
**/ **/
public class DeviceCmd { public class DeviceSetCmd {
/**
* 设备控制
* 命令格式URC+ECTAS=设备类型,设备命令,设备参数,设备参数,设备参数
* 开门 URC+ECTAS=GarageDoor,OpenGarage,100,{},73
* 半开门 URC+ECTAS=GarageDoor,PartOpenGarage,{},{},83
* 门体停止 URC+ECTAS=GarageDoor,StopGarage,{},{},f5
* 关门 URC+ECTAS=GarageDoor,OpenGarage,0,{},30
* 门体运行状态循环切换 URC+ECTAS=GarageDoor,ToggleGarage,0,{}
* 复位照明时长 URC+ECTAS=GarageDoor,ResumeCountDown,{},{},1b
*/
//开门 URC+ECTAS=GarageDoor,OpenGarage,100,{},73
public final static String OPT_OPEN_GARAGE = "URC+ECTAS=GarageDoor,OpenGarage,100,{},73";
//半开门 URC+ECTAS=GarageDoor,PartOpenGarage,{},{},83
public final static String OPT_PART_OPEN_GARAGE = "URC+ECTAS=GarageDoor,PartOpenGarage,{},{},83";
//门体停止 URC+ECTAS=GarageDoor,StopGarage,{},{},f5
public final static String OPT_STOP_GARAGE = "URC+ECTAS=GarageDoor,StopGarage,{},{},f5";
//关门 URC+ECTAS=GarageDoor,OpenGarage,0,{},30
public final static String OPT_CLOSE_GARAGE = "URC+ECTAS=GarageDoor,OpenGarage,0,{},30";
//门体运行状态循环切换 URC+ECTAS=GarageDoor,ToggleGarage,0,{}
public final static String OPT_TOGGLE_GARAGE = "URC+ECTAS=GarageDoor,ToggleGarage,0,{}";
//复位照明时长 URC+ECTAS=GarageDoor,ResumeCountDown,{},{},1b
public final static String OPT_RESUME_COUNTDOWN = "URC+ECTAS=GarageDoor,ResumeCountDown,{},{},1b";
/** /**
* 设备设置 * 设备设置
@ -42,19 +18,19 @@ public class DeviceCmd {
//运行次数开关 URC+ECTPS=GarageDoorLightControl,DoorRunningTimesSwitch,0,true,{},ae //运行次数开关 URC+ECTPS=GarageDoorLightControl,DoorRunningTimesSwitch,0,true,{},ae
//运行次数开关 URC+ECTPS=GarageDoorLightControl,DoorRunningTimesSwitch,0,false,{},2e //运行次数开关 URC+ECTPS=GarageDoorLightControl,DoorRunningTimesSwitch,0,false,{},2e
//倒计时设置时间 URC+ECTPS=GarageDoorLightControl,CountDownConfig,1,50,{} //倒计时设置时间 URC+ECTPS=GarageDoorLightControl,CountDownConfig,1,50,{}
//照明灯开关 URC+ECTPS=GarageDoorLightControl,LightSwitch,0,false,{},4d
//照明灯开关 URC+ECTPS=GarageDoorLightControl,LightSwitch,0,true,{},98
//提醒关门时间设置 URC+ECTPS=CustomGarageDoor,RemindCloseDoorConfig,1,1,{},ee //提醒关门时间设置 URC+ECTPS=CustomGarageDoor,RemindCloseDoorConfig,1,1,{},ee
//提醒关门功能开关 URC+ECTPS=CustomGarageDoor,RemindCloseDoorSwitch,0,true,{},7c //提醒关门功能开关 URC+ECTPS=CustomGarageDoor,RemindCloseDoorSwitch,0,true,{},7c
//提醒关门功能开关 URC+ECTPS=CustomGarageDoor,RemindCloseDoorSwitch,0,false,{},c5 //提醒关门功能开关 URC+ECTPS=CustomGarageDoor,RemindCloseDoorSwitch,0,false,{},c5
//半开门高度设置 URC+ECTPS=CustomGarageDoor,PartOpenConfig,1,10,{},aa //半开门高度设置 URC+ECTPS=CustomGarageDoor,PartOpenConfig,1,10,{},aa
//半开门功能开关 URC+ECTPS=CustomGarageDoor,PartOpenSwitch,0,false,{},f9 //半开门功能开关 URC+ECTPS=CustomGarageDoor,PartOpenSwitch,0,false,{},f9
//半开门功能开关 URC+ECTPS=CustomGarageDoor,PartOpenSwitch,0,true,{},52 //半开门功能开关 URC+ECTPS=CustomGarageDoor,PartOpenSwitch,0,true,{},52
//门体运行状态停止中 URC+ECTPS=CustomGarageDoor,WorkState,3,stop,{}
//门体运行状态关闭中 URC+ECTPS=CustomGarageDoor,WorkState,3,closing,{}
//门体运行状态开启中 URC+ECTPS=CustomGarageDoor,WorkState,3,openning,{}
//遇阻回弹的阻力设置 URC+ECTPS=GarageDoor,BounceSensitivity,1,5,{} //遇阻回弹的阻力设置 URC+ECTPS=GarageDoor,BounceSensitivity,1,5,{}
//红外感应开关开启 URC+ECTPS=GarageDoor,IRSwitch,0,true,{},52 //红外感应开关开启 URC+ECTPS=GarageDoor,IRSwitch,0,true,{},52
//红外感应开关关闭 URC+ECTPS=GarageDoor,IRSwitch,0,false,{},f9 todo 协议没有
//value值替换模板
public static final String MODEL = "MODEL";
//自动关门功能开关 URC+ECTPS=GarageDoorLightControl,AutomaticDoorClosingSwitch,0,false,{},b2 //自动关门功能开关 URC+ECTPS=GarageDoorLightControl,AutomaticDoorClosingSwitch,0,false,{},b2
public static final String AutomaticDoorClosingSwitch_false = "URC+ECTPS=GarageDoorLightControl,AutomaticDoorClosingSwitch,0,false,{},b2"; public static final String AutomaticDoorClosingSwitch_false = "URC+ECTPS=GarageDoorLightControl,AutomaticDoorClosingSwitch,0,false,{},b2";
@ -69,10 +45,9 @@ public class DeviceCmd {
public static final String DoorRunningTimesSwitch_false = "URC+ECTPS=GarageDoorLightControl,DoorRunningTimesSwitch,0,false,{},2e"; public static final String DoorRunningTimesSwitch_false = "URC+ECTPS=GarageDoorLightControl,DoorRunningTimesSwitch,0,false,{},2e";
//倒计时设置时间 URC+ECTPS=GarageDoorLightControl,CountDownConfig,1,50,{} //倒计时设置时间 URC+ECTPS=GarageDoorLightControl,CountDownConfig,1,50,{}
public static final String CountDownConfig = "URC+ECTPS=GarageDoorLightControl,CountDownConfig,1,MODEL,{},98";//MODEL public static final String CountDownConfig = "URC+ECTPS=GarageDoorLightControl,CountDownConfig,1,MODEL,{},98";//MODEL
//照明灯开关 URC+ECTPS=GarageDoorLightControl,LightSwitch,0,false,{},4d
public static final String LightSwitch_false = "URC+ECTPS=GarageDoorLightControl,LightSwitch,0,false,{},4d";
//照明灯开关 URC+ECTPS=GarageDoorLightControl,LightSwitch,0,true,{},98
public static final String LightSwitch_true = "URC+ECTPS=GarageDoorLightControl,LightSwitch,0,true,{},98";
//提醒关门时间设置 URC+ECTPS=CustomGarageDoor,RemindCloseDoorConfig,1,1,{},ee //提醒关门时间设置 URC+ECTPS=CustomGarageDoor,RemindCloseDoorConfig,1,1,{},ee
public static final String RemindCloseDoorConfig = "URC+ECTPS=CustomGarageDoor,RemindCloseDoorConfig,1,MODEL,{},ee"; public static final String RemindCloseDoorConfig = "URC+ECTPS=CustomGarageDoor,RemindCloseDoorConfig,1,MODEL,{},ee";
//提醒关门功能开关 URC+ECTPS=CustomGarageDoor,RemindCloseDoorSwitch,0,true,{},7c //提醒关门功能开关 URC+ECTPS=CustomGarageDoor,RemindCloseDoorSwitch,0,true,{},7c
@ -85,12 +60,15 @@ public class DeviceCmd {
public static final String PartOpenSwitch_false = "URC+ECTPS=CustomGarageDoor,PartOpenSwitch,0,false,{},f9"; public static final String PartOpenSwitch_false = "URC+ECTPS=CustomGarageDoor,PartOpenSwitch,0,false,{},f9";
//半开门功能开关 URC+ECTPS=CustomGarageDoor,PartOpenSwitch,0,true,{},52 //半开门功能开关 URC+ECTPS=CustomGarageDoor,PartOpenSwitch,0,true,{},52
public static final String PartOpenSwitch_true = "URC+ECTPS=CustomGarageDoor,PartOpenSwitch,0,true,{},52"; public static final String PartOpenSwitch_true = "URC+ECTPS=CustomGarageDoor,PartOpenSwitch,0,true,{},52";
//门体运行状态停止中 URC+ECTPS=CustomGarageDoor,WorkState,3,stop,{}
/*//门体运行状态停止中 URC+ECTPS=CustomGarageDoor,WorkState,3,stop,{}
public static final String WorkState_stop = "URC+ECTPS=CustomGarageDoor,WorkState,3,stop,{}"; public static final String WorkState_stop = "URC+ECTPS=CustomGarageDoor,WorkState,3,stop,{}";
//门体运行状态关闭中 URC+ECTPS=CustomGarageDoor,WorkState,3,closing,{} //门体运行状态关闭中 URC+ECTPS=CustomGarageDoor,WorkState,3,closing,{}
public static final String WorkState_closing = "URC+ECTPS=CustomGarageDoor,WorkState,3,closing,{}"; public static final String WorkState_closing = "URC+ECTPS=CustomGarageDoor,WorkState,3,closing,{}";
//门体运行状态开启中 URC+ECTPS=CustomGarageDoor,WorkState,3,openning,{} //门体运行状态开启中 URC+ECTPS=CustomGarageDoor,WorkState,3,openning,{}
public static final String WorkState_openning = "URC+ECTPS=CustomGarageDoor,WorkState,3,openning,{}"; public static final String WorkState_openning = "URC+ECTPS=CustomGarageDoor,WorkState,3,openning,{}";*/
//遇阻回弹的阻力设置 URC+ECTPS=GarageDoor,BounceSensitivity,1,5,{} //遇阻回弹的阻力设置 URC+ECTPS=GarageDoor,BounceSensitivity,1,5,{}
public static final String BounceSensitivity = "URC+ECTPS=GarageDoor,BounceSensitivity,1,MODEL,{}"; public static final String BounceSensitivity = "URC+ECTPS=GarageDoor,BounceSensitivity,1,MODEL,{}";
//红外感应开关开启 URC+ECTPS=GarageDoor,IRSwitch,0,true,{},52 //红外感应开关开启 URC+ECTPS=GarageDoor,IRSwitch,0,true,{},52

View File

@ -31,14 +31,6 @@ public class EqAppHomeBo extends BaseEntity{
* 设备名称 * 设备名称
*/ */
private String equipmentName; private String equipmentName;
/**
* 1.关门 2.停止 3.开门 4.半开门 5.灯光倒计时设置 6.开灯 7 关灯 8.灯光倒计时重置 9对码 10.清码
*/
private int operateType;
/**
* 半开门百分比 插入int类型值
*/
private int openPercent;
/** /**
* 密码密码校验时使用 * 密码密码校验时使用

View File

@ -0,0 +1,50 @@
package org.dromara.web.domain.bo;
import lombok.Data;
import java.io.Serializable;
/**
* @ClassName : EqDeviceCmdBo
* @Author : ZZC
* @Date : 2024/7/25 10:25
* @Discription : 设备控制
**/
@Data
public class EqDeviceCmdBo implements Serializable {
/**
* 选取用户ID家庭主体ID
*/
private Long userId;
/**
* 分布ID
*/
private Long areaId;
/**
* 设备ID
*/
private Long equipmentId;
/**
* 设备编码
*/
private String equipmentCode;
/**
* 操作类型
* 1.开门
* 2.半开门
* 3.门体停止
* 4.关门
* 5.门体运行状态循环切换
* 6.灯光倒计时重置
* 7.开灯
* 8.关灯
* 9对码暂无
* 10.清码暂无
*/
private int operateType;
/**
* 插入int类型值 暂时无用
*/
private Integer operateValue;
}

View File

@ -0,0 +1,56 @@
package org.dromara.web.domain.bo;
import lombok.Data;
import java.io.Serializable;
/**
* @ClassName : EqDeviceCmdBo
* @Author : ZZC
* @Date : 2024/7/25 10:25
* @Discription : 设备设置
**/
@Data
public class EqDeviceSetBo implements Serializable {
/**
* 选取用户ID家庭主体ID
*/
private Long userId;
/**
* 分布ID
*/
private Long areaId;
/**
* 设备ID
*/
private Long equipmentId;
/**
* 设备编码
*/
private String equipmentCode;
/**
* 1. 自动关门功能开关
* 2. 自动关门功能开关
* 3. 延时自动关门的延时时长 value
* 4. 运行次数开关
* 5. 运行次数开关
* 6. 倒计时设置时间 value
* 7. 提醒关门时间设置 value
* 8.提醒关门功能开关
* 9.提醒关门功能开关
* 10.半开门高度设置 value
* 11.半开门功能开关
* 12.半开门功能开关
* 13.遇阻回弹的阻力设置 value
* 14.红外感应开关开启
* 15.红外感应开关关闭
*
*/
private int operateType;
/**
* 设置值 见上面有value标识的类型 统一int类型
*/
private Integer operateValue;
}

View File

@ -1,6 +1,8 @@
package org.dromara.web.service; package org.dromara.web.service;
import org.dromara.web.domain.bo.EqAppHomeBo; 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.EqEquipmentVo; import org.dromara.web.domain.vo.EqEquipmentVo;
import org.dromara.web.domain.bo.EqEquipmentBo; import org.dromara.web.domain.bo.EqEquipmentBo;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -67,5 +69,8 @@ public interface IEqEquipmentService {
*/ */
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
String operate(EqAppHomeBo bo); String operate(EqDeviceCmdBo bo);
String setting(EqDeviceSetBo bo);
} }

View File

@ -1,5 +1,7 @@
package org.dromara.web.service.impl; package org.dromara.web.service.impl;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils; import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -8,7 +10,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.web.domain.bo.EqAppHomeBo; import org.dromara.web.config.CommonYmlConfig;
import org.dromara.web.device.DeviceCtlCmd;
import org.dromara.web.device.DeviceCtlDto;
import org.dromara.web.device.DeviceSetCmd;
import org.dromara.web.domain.bo.EqDeviceCmdBo;
import org.dromara.web.domain.bo.EqDeviceSetBo;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.dromara.web.domain.bo.EqEquipmentBo; import org.dromara.web.domain.bo.EqEquipmentBo;
import org.dromara.web.domain.vo.EqEquipmentVo; import org.dromara.web.domain.vo.EqEquipmentVo;
@ -137,24 +144,64 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService {
} }
@Override @Override
public String operate(EqAppHomeBo bo) { public String operate(EqDeviceCmdBo bo) {
//todo 调用iot平台 进行指令发送 String cmd = "";
int operateType = bo.getOperateType(); int operateType = bo.getOperateType();
switch (operateType){ switch (operateType){
case 1: case 1: cmd = DeviceCtlCmd.OPT_OPEN_GARAGE; break;//开门
// todo 调用iot平台进行控制 case 2: cmd = DeviceCtlCmd.OPT_PART_OPEN_GARAGE; break;//半开门
break; case 3: cmd = DeviceCtlCmd.OPT_STOP_GARAGE; break;//门体停止
case 2: case 4: cmd = DeviceCtlCmd.OPT_CLOSE_GARAGE; break;//关门
case 5: cmd = DeviceCtlCmd.OPT_TOGGLE_GARAGE; break;//门体运行状态循环切换
break; case 6: cmd = DeviceCtlCmd.OPT_RESUME_COUNTDOWN; break;//复位照明时长
case 3: case 7: cmd = DeviceCtlCmd.LightSwitch_false; break;//照明灯开关
case 8: cmd = DeviceCtlCmd.LightSwitch_true; break;//照明灯开关
break;
default: default:
return "指令类型错误"; return "指令类型错误";
} }
//增加操作次数 更新到设备表中 //增加操作次数 更新到设备表中
return null; return httpCtlPostSend(cmd);
}
@Override
public String setting(EqDeviceSetBo bo) {
String cmd = "";
int operateType = bo.getOperateType();
switch (operateType){
case 1: cmd = DeviceSetCmd.AutomaticDoorClosingSwitch_false; break;//自动关门功能开关
case 2: cmd = DeviceSetCmd.AutomaticDoorClosingSwitch_true; break;//自动关门功能开关
case 3: cmd = DeviceSetCmd.AutomaticDoorClosingTime; break;//延时自动关门的延时时长
case 4: cmd = DeviceSetCmd.DoorRunningTimesSwitch_true; break;//运行次数开关
case 5: cmd = DeviceSetCmd.DoorRunningTimesSwitch_false; break;//运行次数开关
case 6: cmd = DeviceSetCmd.CountDownConfig; break;//倒计时设置时间
case 7: cmd = DeviceSetCmd.RemindCloseDoorConfig; break;//提醒关门时间设置
case 8: cmd = DeviceSetCmd.RemindCloseDoorSwitch_true; break;//提醒关门功能开关
case 9: cmd = DeviceSetCmd.RemindCloseDoorSwitch_false; break;//提醒关门功能开关
case 10: cmd = DeviceSetCmd.PartOpenConfig; break;//半开门高度设置
case 11: cmd = DeviceSetCmd.PartOpenSwitch_false; break;//半开门功能开关
case 12: cmd = DeviceSetCmd.PartOpenSwitch_true; break;//半开门功能开关
case 13: cmd = DeviceSetCmd.BounceSensitivity; break;//遇阻回弹的阻力设置
case 14: cmd = DeviceSetCmd.IRSwitch_true; break;//红外感应开关开启
case 15: cmd = DeviceSetCmd.IRSwitch_false; break;//红外感应开关关闭
default:
return "指令类型错误";
}
if (operateType == 3 || operateType == 6 || operateType == 7 || operateType == 10 || operateType == 13){
cmd = cmd.replace(DeviceSetCmd.MODEL,bo.getOperateValue()+"");
}
//增加操作次数 更新到设备表中
return httpCtlPostSend(cmd);
}
private String httpCtlPostSend(String cmd){
DeviceCtlDto dto = new DeviceCtlDto();
// dto.setMethod();//todo 方法
DeviceCtlDto.Params params = dto.getParams();
params.setCommand(cmd);
dto.setParams(params);
// todo 登录相关 token
return HttpUtil.post(CommonYmlConfig.URL_IOT_OPERATE, JSON.toJSONString(dto));
} }
} }

View File

@ -256,3 +256,9 @@ justauth:
client-id: 10**********6 client-id: 10**********6
client-secret: 1f7d08**********5b7**********29e client-secret: 1f7d08**********5b7**********29e
redirect-uri: ${justauth.address}/social-callback?source=gitlab redirect-uri: ${justauth.address}/social-callback?source=gitlab
iot:
url:
serverAttribute: https://www.baidu.com
telemetry: https://www.baidu.com
operate: https://www.baidu.com