diff --git a/ruoyi-admin/src/main/java/org/dromara/web/config/CommonYmlConfig.java b/ruoyi-admin/src/main/java/org/dromara/web/config/CommonYmlConfig.java new file mode 100644 index 000000000..b2896b196 --- /dev/null +++ b/ruoyi-admin/src/main/java/org/dromara/web/config/CommonYmlConfig.java @@ -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; + } +} diff --git a/ruoyi-admin/src/main/java/org/dromara/web/controller/app/EqDeviceController.java b/ruoyi-admin/src/main/java/org/dromara/web/controller/app/EqDeviceController.java new file mode 100644 index 000000000..b54e760c1 --- /dev/null +++ b/ruoyi-admin/src/main/java/org/dromara/web/controller/app/EqDeviceController.java @@ -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 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 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 getDeviceStatus(EqAppHomeBo bo){ + EqEquipmentStatusVo result = new EqEquipmentStatusVo(); + + + return R.ok(result); + } + + + /** + * 获取日志 + * @param bo + * @param pageQuery + * @return + */ + @GetMapping("/getDeviceLogs") + public TableDataInfo 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); + } + +} + diff --git a/ruoyi-admin/src/main/java/org/dromara/web/controller/app/EqHomeController.java b/ruoyi-admin/src/main/java/org/dromara/web/controller/app/EqHomeController.java index cf8e722f7..ef62889e1 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/controller/app/EqHomeController.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/controller/app/EqHomeController.java @@ -83,18 +83,6 @@ public class EqHomeController extends BaseController { return eqEquipmentService.queryPageList(eqEquipmentBo, pageQuery); //在设备表中增加了分布id } - /** todo - * 控制设备 0关 1停 2开 - * 传参设备编码 - */ - @GetMapping("/operate") - public R 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 @@ -152,43 +140,17 @@ public class EqHomeController extends BaseController { SysUserVo sysUserVo = userService.selectUserById(bo.getUserId()); if (sysUserVo == null) throw new ServiceException("用户不存在"); return R.ok(BCrypt.checkpw(bo.getPassword(), sysUserVo.getPassword())); -// return R.ok(BCrypt.hashpw(bo.getPassword()).equals(sysUserVo.getPassword())); } - /** - * 未设置设备详情页 - */ - @GetMapping("/noInitDevicePage") - public R> noInitDevicePage(){ - List 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 * @return - */ + *//* + @GetMapping("/getDeviceStatus") public R getDeviceStatus(EqAppHomeBo bo){ EqEquipmentStatusVo result = new EqEquipmentStatusVo(); @@ -198,12 +160,14 @@ public class EqHomeController extends BaseController { } - /** + */ +/** * 获取日志 * @param bo * @param pageQuery * @return - */ + *//* + @GetMapping("/getDeviceLogs") public TableDataInfo getDeviceLogs(EqAppHomeBo bo,PageQuery pageQuery){ EqEquipmentLogBo eqEquipmentLogBo = new EqEquipmentLogBo(); @@ -211,14 +175,17 @@ public class EqHomeController extends BaseController { return logService.queryPageList(eqEquipmentLogBo, pageQuery); } - /** + */ +/** * 保存日志 * @param eqEquipmentLogBo - */ + *//* + @GetMapping("/saveDeviceLogs") public void saveDeviceLogs(EqEquipmentLogBo eqEquipmentLogBo){ logService.insertByBo(eqEquipmentLogBo); } +*/ } diff --git a/ruoyi-admin/src/main/java/org/dromara/web/controller/app/EqTextController.java b/ruoyi-admin/src/main/java/org/dromara/web/controller/app/EqTextController.java new file mode 100644 index 000000000..8bdb0c5f2 --- /dev/null +++ b/ruoyi-admin/src/main/java/org/dromara/web/controller/app/EqTextController.java @@ -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> noInitDevicePage(){ + List 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); + } + + +} + diff --git a/ruoyi-admin/src/main/java/org/dromara/web/device/DeviceCtlCmd.java b/ruoyi-admin/src/main/java/org/dromara/web/device/DeviceCtlCmd.java new file mode 100644 index 000000000..07db0dc36 --- /dev/null +++ b/ruoyi-admin/src/main/java/org/dromara/web/device/DeviceCtlCmd.java @@ -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"; + + +} diff --git a/ruoyi-admin/src/main/java/org/dromara/web/device/DeviceCtlDto.java b/ruoyi-admin/src/main/java/org/dromara/web/device/DeviceCtlDto.java new file mode 100644 index 000000000..96302c6f6 --- /dev/null +++ b/ruoyi-admin/src/main/java/org/dromara/web/device/DeviceCtlDto.java @@ -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; + } +} diff --git a/ruoyi-admin/src/main/java/org/dromara/web/device/DeviceNotifyCmd.java b/ruoyi-admin/src/main/java/org/dromara/web/device/DeviceNotifyCmd.java new file mode 100644 index 000000000..9e2333d42 --- /dev/null +++ b/ruoyi-admin/src/main/java/org/dromara/web/device/DeviceNotifyCmd.java @@ -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 +} diff --git a/ruoyi-admin/src/main/java/org/dromara/web/device/DeviceCmd.java b/ruoyi-admin/src/main/java/org/dromara/web/device/DeviceSetCmd.java similarity index 59% rename from ruoyi-admin/src/main/java/org/dromara/web/device/DeviceCmd.java rename to ruoyi-admin/src/main/java/org/dromara/web/device/DeviceSetCmd.java index 2897792a3..2c15a3f76 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/device/DeviceCmd.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/device/DeviceSetCmd.java @@ -1,60 +1,36 @@ package org.dromara.web.device; /** - * @ClassName : DeviceCmd + * @ClassName : DeviceCtlCmd * @Author : ZZC * @Date : 2024/7/25 0:07 - * @Description : 设备命令 + * @Description : 设备设置命令 **/ -public class DeviceCmd { - - /** - * 设备控制 - * 命令格式: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"; - +public class DeviceSetCmd { /** * 设备设置 */ - //自动关门功能开关 URC+ECTPS=GarageDoorLightControl,AutomaticDoorClosingSwitch,0,false,{},b2 - //自动关门功能开关 URC+ECTPS=GarageDoorLightControl,AutomaticDoorClosingSwitch,0,true,{},a7 + //自动关门功能开关 URC+ECTPS=GarageDoorLightControl,AutomaticDoorClosingSwitch,0,false,{},b2 + //自动关门功能开关 URC+ECTPS=GarageDoorLightControl,AutomaticDoorClosingSwitch,0,true,{},a7 //延时自动关门的延时时长 URC+ECTPS=GarageDoorLightControl,AutomaticDoorClosingTime,1,1,{},98 - //运行次数开关 URC+ECTPS=GarageDoorLightControl,DoorRunningTimesSwitch,0,true,{},ae - //运行次数开关 URC+ECTPS=GarageDoorLightControl,DoorRunningTimesSwitch,0,false,{},2e - //倒计时设置时间 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,RemindCloseDoorSwitch,0,true,{},7c - //提醒关门功能开关 URC+ECTPS=CustomGarageDoor,RemindCloseDoorSwitch,0,false,{},c5 - //半开门高度设置 URC+ECTPS=CustomGarageDoor,PartOpenConfig,1,10,{},aa - //半开门功能开关:关 URC+ECTPS=CustomGarageDoor,PartOpenSwitch,0,false,{},f9 - //半开门功能开关:开 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,IRSwitch,0,true,{},52 + //运行次数开关 URC+ECTPS=GarageDoorLightControl,DoorRunningTimesSwitch,0,true,{},ae + //运行次数开关 URC+ECTPS=GarageDoorLightControl,DoorRunningTimesSwitch,0,false,{},2e + //倒计时设置时间 URC+ECTPS=GarageDoorLightControl,CountDownConfig,1,50,{} + //提醒关门时间设置 URC+ECTPS=CustomGarageDoor,RemindCloseDoorConfig,1,1,{},ee + //提醒关门功能开关 URC+ECTPS=CustomGarageDoor,RemindCloseDoorSwitch,0,true,{},7c + //提醒关门功能开关 URC+ECTPS=CustomGarageDoor,RemindCloseDoorSwitch,0,false,{},c5 + //半开门高度设置 URC+ECTPS=CustomGarageDoor,PartOpenConfig,1,10,{},aa + //半开门功能开关:关 URC+ECTPS=CustomGarageDoor,PartOpenSwitch,0,false,{},f9 + //半开门功能开关:开 URC+ECTPS=CustomGarageDoor,PartOpenSwitch,0,true,{},52 + //遇阻回弹的阻力设置 URC+ECTPS=GarageDoor,BounceSensitivity,1,5,{} + //红外感应开关开启 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 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"; //倒计时设置时间 URC+ECTPS=GarageDoorLightControl,CountDownConfig,1,50,{} 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 public static final String RemindCloseDoorConfig = "URC+ECTPS=CustomGarageDoor,RemindCloseDoorConfig,1,MODEL,{},ee"; //提醒关门功能开关 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"; //半开门功能开关:开 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,{}"; //门体运行状态:关闭中 URC+ECTPS=CustomGarageDoor,WorkState,3,closing,{} public static final String WorkState_closing = "URC+ECTPS=CustomGarageDoor,WorkState,3,closing,{}"; //门体运行状态:开启中 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,{} public static final String BounceSensitivity = "URC+ECTPS=GarageDoor,BounceSensitivity,1,MODEL,{}"; //红外感应开关开启 URC+ECTPS=GarageDoor,IRSwitch,0,true,{},52 diff --git a/ruoyi-admin/src/main/java/org/dromara/web/domain/bo/EqAppHomeBo.java b/ruoyi-admin/src/main/java/org/dromara/web/domain/bo/EqAppHomeBo.java index c545e755d..d8f20cab3 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/domain/bo/EqAppHomeBo.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/domain/bo/EqAppHomeBo.java @@ -31,14 +31,6 @@ public class EqAppHomeBo extends BaseEntity{ * 设备名称 */ private String equipmentName; - /** - * 1.关门 2.停止 3.开门 4.半开门 5.灯光倒计时设置 6.开灯 7 关灯 8.灯光倒计时重置 9对码 10.清码 - */ - private int operateType; - /** - * 半开门百分比 插入int类型值 - */ - private int openPercent; /** * 密码(密码校验时使用) diff --git a/ruoyi-admin/src/main/java/org/dromara/web/domain/bo/EqDeviceCmdBo.java b/ruoyi-admin/src/main/java/org/dromara/web/domain/bo/EqDeviceCmdBo.java new file mode 100644 index 000000000..6814e3b70 --- /dev/null +++ b/ruoyi-admin/src/main/java/org/dromara/web/domain/bo/EqDeviceCmdBo.java @@ -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; +} diff --git a/ruoyi-admin/src/main/java/org/dromara/web/domain/bo/EqDeviceSetBo.java b/ruoyi-admin/src/main/java/org/dromara/web/domain/bo/EqDeviceSetBo.java new file mode 100644 index 000000000..9a5d5ef8a --- /dev/null +++ b/ruoyi-admin/src/main/java/org/dromara/web/domain/bo/EqDeviceSetBo.java @@ -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; + +} diff --git a/ruoyi-admin/src/main/java/org/dromara/web/service/IEqEquipmentService.java b/ruoyi-admin/src/main/java/org/dromara/web/service/IEqEquipmentService.java index c29e22afc..40dcaac4a 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/service/IEqEquipmentService.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/service/IEqEquipmentService.java @@ -1,6 +1,8 @@ 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.EqEquipmentVo; import org.dromara.web.domain.bo.EqEquipmentBo; import org.dromara.common.mybatis.core.page.TableDataInfo; @@ -67,5 +69,8 @@ public interface IEqEquipmentService { */ Boolean deleteWithValidByIds(Collection ids, Boolean isValid); - String operate(EqAppHomeBo bo); + String operate(EqDeviceCmdBo bo); + + String setting(EqDeviceSetBo bo); + } diff --git a/ruoyi-admin/src/main/java/org/dromara/web/service/impl/EqEquipmentServiceImpl.java b/ruoyi-admin/src/main/java/org/dromara/web/service/impl/EqEquipmentServiceImpl.java index 480640c01..21dd0e8b2 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/service/impl/EqEquipmentServiceImpl.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/service/impl/EqEquipmentServiceImpl.java @@ -1,5 +1,7 @@ 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.StringUtils; 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.toolkit.Wrappers; 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.dromara.web.domain.bo.EqEquipmentBo; import org.dromara.web.domain.vo.EqEquipmentVo; @@ -137,24 +144,64 @@ public class EqEquipmentServiceImpl implements IEqEquipmentService { } @Override - public String operate(EqAppHomeBo bo) { - //todo 调用iot平台 进行指令发送 + public String operate(EqDeviceCmdBo bo) { + String cmd = ""; int operateType = bo.getOperateType(); switch (operateType){ - case 1: - // todo 调用iot平台进行控制 - break; - case 2: - - break; - case 3: - - break; + case 1: cmd = DeviceCtlCmd.OPT_OPEN_GARAGE; break;//开门 + case 2: cmd = DeviceCtlCmd.OPT_PART_OPEN_GARAGE; break;//半开门 + case 3: cmd = DeviceCtlCmd.OPT_STOP_GARAGE; break;//门体停止 + case 4: cmd = DeviceCtlCmd.OPT_CLOSE_GARAGE; break;//关门 + case 5: cmd = DeviceCtlCmd.OPT_TOGGLE_GARAGE; break;//门体运行状态循环切换 + case 6: cmd = DeviceCtlCmd.OPT_RESUME_COUNTDOWN; break;//复位照明时长 + case 7: cmd = DeviceCtlCmd.LightSwitch_false; break;//照明灯开关 关 + case 8: cmd = DeviceCtlCmd.LightSwitch_true; break;//照明灯开关 开 default: 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)); } } diff --git a/ruoyi-admin/src/main/resources/application-dev.yml b/ruoyi-admin/src/main/resources/application-dev.yml index 1dc000d07..6477ba4a3 100644 --- a/ruoyi-admin/src/main/resources/application-dev.yml +++ b/ruoyi-admin/src/main/resources/application-dev.yml @@ -256,3 +256,9 @@ justauth: client-id: 10**********6 client-secret: 1f7d08**********5b7**********29e 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