mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 00:45:55 +08:00
后端V1.0
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.system.domain.IotDeviceStatus;
|
||||
import com.ruoyi.system.mqtt.config.MqttPushClient;
|
||||
import com.ruoyi.system.service.IIotDeviceStatusService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -38,6 +50,8 @@ public class IotDeviceSetController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IIotDeviceSetService iotDeviceSetService;
|
||||
@Autowired
|
||||
private IIotDeviceStatusService iotDeviceStatusService;
|
||||
|
||||
@Autowired
|
||||
private MqttPushClient mqttPushClient;
|
||||
@@ -112,11 +126,51 @@ public class IotDeviceSetController extends BaseController
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody IotDeviceSet iotDeviceSet)
|
||||
{
|
||||
IotDeviceStatus status=iotDeviceStatusService.selectIotDeviceStatusByDeviceId(iotDeviceSet.getDeviceId());
|
||||
if(status.getIsOnline()!=1){return AjaxResult.error("设备已离线,不能更新配置。");}
|
||||
// 存储
|
||||
iotDeviceSetService.updateIotDeviceSet(iotDeviceSet);
|
||||
// mqtt发布
|
||||
String content = JSON.toJSONString(iotDeviceSet);
|
||||
boolean isSuccess=mqttPushClient.publish(0,true,"setting/set/"+iotDeviceSet.getDeviceNum(),content);
|
||||
|
||||
//
|
||||
IotDeviceSet set=iotDeviceSetService.selectIotDeviceSetByDeviceId(iotDeviceSet.getDeviceId());
|
||||
if(iotDeviceSet.getIsRadar()!=null){
|
||||
set.setIsRadar(iotDeviceSet.getIsRadar());
|
||||
}
|
||||
if(iotDeviceSet.getIsAlarm()!=null){
|
||||
set.setIsAlarm(iotDeviceSet.getIsAlarm());
|
||||
}
|
||||
if(iotDeviceSet.getRadarInterval()!=null){
|
||||
set.setRadarInterval(iotDeviceSet.getRadarInterval());
|
||||
}
|
||||
if(iotDeviceSet.getIsRfControl()!=null){
|
||||
set.setIsRfControl(iotDeviceSet.getIsRfControl());
|
||||
}
|
||||
if(iotDeviceSet.getRfOneFunc()!=null){
|
||||
set.setRfOneFunc(iotDeviceSet.getRfOneFunc());
|
||||
}
|
||||
if(iotDeviceSet.getRfTwoFunc()!=null){
|
||||
set.setRfTwoFunc(iotDeviceSet.getRfTwoFunc());
|
||||
}
|
||||
if(iotDeviceSet.getRfThreeFunc()!=null){
|
||||
set.setRfThreeFunc(iotDeviceSet.getRfThreeFunc());
|
||||
}
|
||||
if(iotDeviceSet.getRfFourFunc()!=null){
|
||||
set.setRfFourFunc(iotDeviceSet.getRfFourFunc());
|
||||
}
|
||||
if(iotDeviceSet.getIsRfLearn()!=null){
|
||||
set.setIsRfLearn(iotDeviceSet.getIsRfLearn());
|
||||
}
|
||||
if(iotDeviceSet.getIsRfClear()!=null){
|
||||
set.setIsRfClear(iotDeviceSet.getIsRfClear());
|
||||
}
|
||||
if(iotDeviceSet.getIsAp()!=null){
|
||||
set.setIsAp(iotDeviceSet.getIsAp());
|
||||
}
|
||||
if(iotDeviceSet.getIsReset()!=null){
|
||||
set.setIsReset(iotDeviceSet.getIsReset());
|
||||
}
|
||||
String content = JSON.toJSONString(set);
|
||||
boolean isSuccess=mqttPushClient.publish(0,true,"setting/set/"+set.getDeviceNum(),content);
|
||||
if(isSuccess){return AjaxResult.success("mqtt 发布成功");}
|
||||
return AjaxResult.error("mqtt 发布失败。");
|
||||
}
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
@@ -123,12 +133,43 @@ public class IotDeviceStatusController extends BaseController
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody IotDeviceStatus iotDeviceStatus)
|
||||
{
|
||||
IotDeviceStatus status=iotDeviceStatusService.selectIotDeviceStatusByDeviceId(iotDeviceStatus.getDeviceId());
|
||||
if(status.getIsOnline()!=1){return AjaxResult.error("设备已离线,不能更新状态。");}
|
||||
// 存储
|
||||
iotDeviceStatusService.updateIotDeviceStatus(iotDeviceStatus);
|
||||
|
||||
// mqtt发布
|
||||
String content = JSON.toJSONString(iotDeviceStatus);
|
||||
boolean isSuccess=mqttPushClient.publish(1,true,"status/set/"+iotDeviceStatus.getDeviceNum(),content);
|
||||
if(iotDeviceStatus.getRelayStatus()!=null){
|
||||
status.setRelayStatus(iotDeviceStatus.getRelayStatus());
|
||||
}
|
||||
if(iotDeviceStatus.getLightStatus()!=null){
|
||||
status.setLightStatus(iotDeviceStatus.getLightStatus());
|
||||
}
|
||||
if(iotDeviceStatus.getLightMode()!=null){
|
||||
status.setLightMode(iotDeviceStatus.getLightMode());
|
||||
}
|
||||
if(iotDeviceStatus.getLightInterval()!=null){
|
||||
status.setLightInterval(iotDeviceStatus.getLightInterval());
|
||||
}
|
||||
if(iotDeviceStatus.getFadeTime()!=null){
|
||||
status.setFadeTime(iotDeviceStatus.getFadeTime());
|
||||
}
|
||||
if(iotDeviceStatus.getBrightness()!=null){
|
||||
status.setBrightness(iotDeviceStatus.getBrightness());
|
||||
}
|
||||
if(iotDeviceStatus.getRed()!=null){
|
||||
status.setRed(iotDeviceStatus.getRed());
|
||||
}
|
||||
if(iotDeviceStatus.getGreen()!=null){
|
||||
status.setGreen(iotDeviceStatus.getGreen());
|
||||
}
|
||||
if(iotDeviceStatus.getBlue()!=null){
|
||||
status.setBlue(iotDeviceStatus.getBlue());
|
||||
}
|
||||
String content = JSON.toJSONString(status);
|
||||
boolean isSuccess=mqttPushClient.publish(1,true,"status/set/"+status.getDeviceNum(),content);
|
||||
if(isSuccess){return AjaxResult.success("mqtt 发布成功");}
|
||||
|
||||
return AjaxResult.error("mqtt 发布失败。");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -22,41 +32,41 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
@RequestMapping("/system/mqtt")
|
||||
public class MqttController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private MqttPushClient mqttPushClient;
|
||||
|
||||
@ApiOperation(value = "更新设备状态", notes = "更新设备状态")
|
||||
@PostMapping(value = "/updateStatus")
|
||||
public AjaxResult updateStatus(@RequestBody IotDeviceStatus iotDeviceStatus){
|
||||
String content = JSON.toJSONString(iotDeviceStatus);
|
||||
boolean isSuccess=mqttPushClient.publish(1,false,"status/set/"+iotDeviceStatus.getDeviceNum(),content);
|
||||
if(isSuccess){return AjaxResult.success();}
|
||||
return AjaxResult.error("mqtt 发布失败。");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取设备状态", notes = "获取设备状态")
|
||||
@GetMapping(value = "/getStatus/{deviceNum}")
|
||||
public AjaxResult getStatus(@PathVariable("deviceNum") String deviceNum){
|
||||
boolean isSuccess=mqttPushClient.publish(0,false,"status/get/"+deviceNum,"wumei.live");
|
||||
if(isSuccess){return AjaxResult.success();}
|
||||
return AjaxResult.error("mqtt 发布失败。");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新设备配置", notes = "更新设备配置")
|
||||
@PostMapping(value = "/updateSetting")
|
||||
public AjaxResult updateSetting(@RequestBody IotDeviceSet iotDeviceSet){
|
||||
String content = JSON.toJSONString(iotDeviceSet);
|
||||
boolean isSuccess=mqttPushClient.publish(0,false,"setting/set/"+iotDeviceSet.getDeviceNum(),content);
|
||||
if(isSuccess){return AjaxResult.success();}
|
||||
return AjaxResult.error("mqtt 发布失败。");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取设备配置", notes = "获取设备配置")
|
||||
@GetMapping(value = "/getSetting/{deviceNum}")
|
||||
public AjaxResult getSetting(@PathVariable("deviceNum") String deviceNum){
|
||||
boolean isSuccess=mqttPushClient.publish(0,false,"setting/get/"+deviceNum,"wumei.lie");
|
||||
if(isSuccess){return AjaxResult.success();}
|
||||
return AjaxResult.error("mqtt 发布失败。");
|
||||
}
|
||||
// @Autowired
|
||||
// private MqttPushClient mqttPushClient;
|
||||
//
|
||||
// @ApiOperation(value = "更新设备状态", notes = "更新设备状态")
|
||||
// @PostMapping(value = "/updateStatus")
|
||||
// public AjaxResult updateStatus(@RequestBody IotDeviceStatus iotDeviceStatus){
|
||||
// String content = JSON.toJSONString(iotDeviceStatus);
|
||||
// boolean isSuccess=mqttPushClient.publish(1,false,"status/set/"+iotDeviceStatus.getDeviceNum(),content);
|
||||
// if(isSuccess){return AjaxResult.success();}
|
||||
// return AjaxResult.error("mqtt 发布失败。");
|
||||
// }
|
||||
//
|
||||
// @ApiOperation(value = "获取设备状态", notes = "获取设备状态")
|
||||
// @GetMapping(value = "/getStatus/{deviceNum}")
|
||||
// public AjaxResult getStatus(@PathVariable("deviceNum") String deviceNum){
|
||||
// boolean isSuccess=mqttPushClient.publish(0,false,"status/get/"+deviceNum,"wumei.live");
|
||||
// if(isSuccess){return AjaxResult.success();}
|
||||
// return AjaxResult.error("mqtt 发布失败。");
|
||||
// }
|
||||
//
|
||||
// @ApiOperation(value = "更新设备配置", notes = "更新设备配置")
|
||||
// @PostMapping(value = "/updateSetting")
|
||||
// public AjaxResult updateSetting(@RequestBody IotDeviceSet iotDeviceSet){
|
||||
// String content = JSON.toJSONString(iotDeviceSet);
|
||||
// boolean isSuccess=mqttPushClient.publish(0,false,"setting/set/"+iotDeviceSet.getDeviceNum(),content);
|
||||
// if(isSuccess){return AjaxResult.success();}
|
||||
// return AjaxResult.error("mqtt 发布失败。");
|
||||
// }
|
||||
//
|
||||
// @ApiOperation(value = "获取设备配置", notes = "获取设备配置")
|
||||
// @GetMapping(value = "/getSetting/{deviceNum}")
|
||||
// public AjaxResult getSetting(@PathVariable("deviceNum") String deviceNum){
|
||||
// boolean isSuccess=mqttPushClient.publish(0,false,"setting/get/"+deviceNum,"wumei.lie");
|
||||
// if(isSuccess){return AjaxResult.success();}
|
||||
// return AjaxResult.error("mqtt 发布失败。");
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
@@ -5,6 +15,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 设备对象 iot_device
|
||||
*
|
||||
@@ -26,6 +38,14 @@ public class IotDevice extends BaseEntity
|
||||
@Excel(name = "分类")
|
||||
private Long categoryId;
|
||||
|
||||
/** 分类名称 */
|
||||
@Excel(name = "分类名称")
|
||||
private String categoryName;
|
||||
|
||||
/** 分类名称 */
|
||||
@Excel(name = "分类名称")
|
||||
private BigDecimal deviceTemp;
|
||||
|
||||
/** 名称 */
|
||||
@Excel(name = "名称")
|
||||
private String deviceName;
|
||||
@@ -38,6 +58,9 @@ public class IotDevice extends BaseEntity
|
||||
@Excel(name = "用户")
|
||||
private String ownerId;
|
||||
|
||||
/** 分组ID */
|
||||
private Long groupId;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
@@ -45,7 +68,6 @@ public class IotDevice extends BaseEntity
|
||||
{
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public Long getDeviceId()
|
||||
{
|
||||
return deviceId;
|
||||
@@ -54,7 +76,6 @@ public class IotDevice extends BaseEntity
|
||||
{
|
||||
this.deviceNum = deviceNum;
|
||||
}
|
||||
|
||||
public String getDeviceNum()
|
||||
{
|
||||
return deviceNum;
|
||||
@@ -63,7 +84,6 @@ public class IotDevice extends BaseEntity
|
||||
{
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public Long getCategoryId()
|
||||
{
|
||||
return categoryId;
|
||||
@@ -72,7 +92,6 @@ public class IotDevice extends BaseEntity
|
||||
{
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
public String getDeviceName()
|
||||
{
|
||||
return deviceName;
|
||||
@@ -81,7 +100,6 @@ public class IotDevice extends BaseEntity
|
||||
{
|
||||
this.firmwareVersion = firmwareVersion;
|
||||
}
|
||||
|
||||
public String getFirmwareVersion()
|
||||
{
|
||||
return firmwareVersion;
|
||||
@@ -90,7 +108,6 @@ public class IotDevice extends BaseEntity
|
||||
{
|
||||
this.ownerId = ownerId;
|
||||
}
|
||||
|
||||
public String getOwnerId()
|
||||
{
|
||||
return ownerId;
|
||||
@@ -99,18 +116,44 @@ public class IotDevice extends BaseEntity
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
public Long getGroupId()
|
||||
{
|
||||
return groupId;
|
||||
}
|
||||
public void setGroupId(Long groupId)
|
||||
{
|
||||
this.groupId = groupId;
|
||||
}
|
||||
public void setDeviceTemp(BigDecimal deviceTemp)
|
||||
{
|
||||
this.deviceTemp = deviceTemp;
|
||||
}
|
||||
public BigDecimal getDeviceTemp()
|
||||
{
|
||||
return deviceTemp;
|
||||
}
|
||||
public void setCategoryName(String categoryName)
|
||||
{
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
public String getCategoryName()
|
||||
{
|
||||
return categoryName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("deviceId", getDeviceId())
|
||||
.append("deviceNum", getDeviceNum())
|
||||
.append("categoryName", getCategoryName())
|
||||
.append("deviceTemp", getDeviceTemp())
|
||||
.append("categoryId", getCategoryId())
|
||||
.append("groupId", getGroupId())
|
||||
.append("deviceName", getDeviceName())
|
||||
.append("firmwareVersion", getFirmwareVersion())
|
||||
.append("ownerId", getOwnerId())
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.domain.vo;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
@@ -28,6 +38,10 @@ public class IotDeviceListDto extends BaseEntity
|
||||
@Excel(name = "分类")
|
||||
private Long categoryId;
|
||||
|
||||
/** 分类名称 */
|
||||
@Excel(name = "分类名称")
|
||||
private String categoryName;
|
||||
|
||||
/** 名称 */
|
||||
@Excel(name = "名称")
|
||||
private String deviceName;
|
||||
@@ -114,6 +128,14 @@ public class IotDeviceListDto extends BaseEntity
|
||||
{
|
||||
return categoryId;
|
||||
}
|
||||
public void setCategoryName(String categoryName)
|
||||
{
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
public String getCategoryName()
|
||||
{
|
||||
return categoryName;
|
||||
}
|
||||
public void setDeviceName(String deviceName)
|
||||
{
|
||||
this.deviceName = deviceName;
|
||||
@@ -243,6 +265,7 @@ public class IotDeviceListDto extends BaseEntity
|
||||
.append("deviceId", getDeviceId())
|
||||
.append("deviceNum", getDeviceNum())
|
||||
.append("categoryId", getCategoryId())
|
||||
.append("categoryName", getCategoryName())
|
||||
.append("deviceName", getDeviceName())
|
||||
.append("firmwareVersion", getFirmwareVersion())
|
||||
.append("ownerId", getOwnerId())
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.mqtt.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.mqtt.config;
|
||||
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
package com.ruoyi.system.mqtt.config;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -22,6 +32,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @Classname PushCallback
|
||||
@@ -72,7 +83,8 @@ public class PushCallback implements MqttCallback {
|
||||
}else {
|
||||
IotCategory categoryEntity=iotCategoryService.selectIotCategoryById(device.getCategoryId());
|
||||
if(device.getDeviceName()==null || device.getDeviceNum().length()==0) {
|
||||
device.setDeviceName(categoryEntity.getCategoryName());
|
||||
Random rand = new Random(); //随机生成两位数
|
||||
device.setDeviceName(categoryEntity.getCategoryName()+(rand.nextInt(90) + 10));
|
||||
}
|
||||
iotDeviceService.insertIotDevice(device);
|
||||
}
|
||||
@@ -89,13 +101,12 @@ public class PushCallback implements MqttCallback {
|
||||
}else if(topic.equals("setting")){
|
||||
IotDeviceSet deviceSet = JSON.parseObject(new String(mqttMessage.getPayload()), IotDeviceSet.class);
|
||||
// 智能配网时需要获取IP、地址和设备用户
|
||||
IotDevice device=null;
|
||||
IotDevice device=iotDeviceService.selectIotDeviceByNum(deviceSet.getDeviceNum());
|
||||
if(deviceSet.getIsSmartConfig()==1){
|
||||
final String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
|
||||
deviceSet.setNetworkIp(ip);
|
||||
deviceSet.setNetworkAddress( AddressUtils.getRealAddressByIP(ip));
|
||||
//更新设备用户
|
||||
device=iotDeviceService.selectIotDeviceByNum(deviceSet.getDeviceNum());
|
||||
device.setOwnerId(deviceSet.getOwnerId());
|
||||
iotDeviceService.updateIotDevice(device);
|
||||
}
|
||||
@@ -103,14 +114,13 @@ public class PushCallback implements MqttCallback {
|
||||
deviceSet.setDeviceId(device.getDeviceId());
|
||||
iotDeviceSetService.insertIotDeviceSet(deviceSet);
|
||||
}else if(topic.equals("offline")){
|
||||
//离线遗嘱 TODO:查询待优化
|
||||
//离线遗嘱
|
||||
IotDeviceStatus deviceStatus = JSON.parseObject(new String(mqttMessage.getPayload()), IotDeviceStatus.class);
|
||||
IotDevice device=iotDeviceService.selectIotDeviceByNum(deviceStatus.getDeviceNum());
|
||||
IotDeviceStatus deviceStatusEntity=iotDeviceStatusService.selectIotDeviceStatusByDeviceId(device.getDeviceId());
|
||||
//跟新最近一条设备状态为离线
|
||||
IotDeviceStatus deviceStatusEntity=iotDeviceStatusService.selectIotDeviceStatusByDeviceNum(deviceStatus.getDeviceNum());
|
||||
//设备状态为离线
|
||||
if(deviceStatusEntity!=null) {
|
||||
deviceStatusEntity.setIsOnline(0);
|
||||
iotDeviceStatusService.updateIotDeviceStatus(deviceStatusEntity);
|
||||
iotDeviceStatusService.insertIotDeviceStatus(deviceStatusEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user