mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 08:55:53 +08:00
后端功能完善
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -26,6 +29,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
||||
* @author kerwincui
|
||||
* @date 2021-05-07
|
||||
*/
|
||||
@Api(value="设备分类",tags="设备分类")
|
||||
@RestController
|
||||
@RequestMapping("/system/category")
|
||||
public class IotCategoryController extends BaseController
|
||||
@@ -36,6 +40,7 @@ public class IotCategoryController extends BaseController
|
||||
/**
|
||||
* 查询设备分类列表
|
||||
*/
|
||||
@ApiOperation(value = "分类列表", notes = "分类列表")
|
||||
@PreAuthorize("@ss.hasPermi('system:category:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(IotCategory iotCategory)
|
||||
@@ -48,6 +53,7 @@ public class IotCategoryController extends BaseController
|
||||
/**
|
||||
* 导出设备分类列表
|
||||
*/
|
||||
@ApiOperation(value = "导出分类列表", notes = "导出分类列表")
|
||||
@PreAuthorize("@ss.hasPermi('system:category:export')")
|
||||
@Log(title = "设备分类", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
@@ -61,6 +67,7 @@ public class IotCategoryController extends BaseController
|
||||
/**
|
||||
* 获取设备分类详细信息
|
||||
*/
|
||||
@ApiOperation(value = "获取分类详情", notes = "获取分类详情")
|
||||
@PreAuthorize("@ss.hasPermi('system:category:query')")
|
||||
@GetMapping(value = "/{categoryId}")
|
||||
public AjaxResult getInfo(@PathVariable("categoryId") Long categoryId)
|
||||
@@ -71,6 +78,7 @@ public class IotCategoryController extends BaseController
|
||||
/**
|
||||
* 新增设备分类
|
||||
*/
|
||||
@ApiOperation(value = "新增分类", notes = "新增分类")
|
||||
@PreAuthorize("@ss.hasPermi('system:category:add')")
|
||||
@Log(title = "设备分类", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@@ -82,6 +90,7 @@ public class IotCategoryController extends BaseController
|
||||
/**
|
||||
* 修改设备分类
|
||||
*/
|
||||
@ApiOperation(value = "修改分类", notes = "修改分类")
|
||||
@PreAuthorize("@ss.hasPermi('system:category:edit')")
|
||||
@Log(title = "设备分类", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
@@ -93,6 +102,7 @@ public class IotCategoryController extends BaseController
|
||||
/**
|
||||
* 删除设备分类
|
||||
*/
|
||||
@ApiOperation(value = "删除分类", notes = "删除分类")
|
||||
@PreAuthorize("@ss.hasPermi('system:category:remove')")
|
||||
@Log(title = "设备分类", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{categoryIds}")
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.system.domain.vo.IotDeviceListDto;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -26,6 +30,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
||||
* @author kerwincui
|
||||
* @date 2021-05-06
|
||||
*/
|
||||
@Api(value="设备",tags="设备")
|
||||
@RestController
|
||||
@RequestMapping("/system/device")
|
||||
public class IotDeviceController extends BaseController
|
||||
@@ -36,31 +41,34 @@ public class IotDeviceController extends BaseController
|
||||
/**
|
||||
* 查询设备列表
|
||||
*/
|
||||
@ApiOperation(value = "设备列表", notes = "设备列表")
|
||||
@PreAuthorize("@ss.hasPermi('system:device:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(IotDevice iotDevice)
|
||||
{
|
||||
startPage();
|
||||
List<IotDevice> list = iotDeviceService.selectIotDeviceList(iotDevice);
|
||||
List<IotDeviceListDto> list = iotDeviceService.selectIotDeviceList(iotDevice);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出设备列表
|
||||
*/
|
||||
@ApiOperation(value = "导出设备列表", notes = "导出设备列表")
|
||||
@PreAuthorize("@ss.hasPermi('system:device:export')")
|
||||
@Log(title = "设备", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(IotDevice iotDevice)
|
||||
{
|
||||
List<IotDevice> list = iotDeviceService.selectIotDeviceList(iotDevice);
|
||||
ExcelUtil<IotDevice> util = new ExcelUtil<IotDevice>(IotDevice.class);
|
||||
List<IotDeviceListDto> list = iotDeviceService.selectIotDeviceList(iotDevice);
|
||||
ExcelUtil<IotDeviceListDto> util = new ExcelUtil<IotDeviceListDto>(IotDeviceListDto.class);
|
||||
return util.exportExcel(list, "device");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备详细信息
|
||||
*/
|
||||
@ApiOperation(value = "获取设备详情", notes = "获取设备详情")
|
||||
@PreAuthorize("@ss.hasPermi('system:device:query')")
|
||||
@GetMapping(value = "/{deviceId}")
|
||||
public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId)
|
||||
@@ -68,9 +76,21 @@ public class IotDeviceController extends BaseController
|
||||
return AjaxResult.success(iotDeviceService.selectIotDeviceById(deviceId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据设备编号获取设备详细信息
|
||||
*/
|
||||
@ApiOperation(value = "根据设备编号获取设备详情", notes = "根据设备编号获取设备详情")
|
||||
@PreAuthorize("@ss.hasPermi('system:device:query')")
|
||||
@GetMapping(value = "/getByNum/{deviceNum}")
|
||||
public AjaxResult getInfoByNum(@PathVariable("deviceNum") String deviceNum)
|
||||
{
|
||||
return AjaxResult.success(iotDeviceService.selectIotDeviceByNum(deviceNum));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备
|
||||
*/
|
||||
@ApiOperation(value = "新增设备", notes = "新增设备")
|
||||
@PreAuthorize("@ss.hasPermi('system:device:add')")
|
||||
@Log(title = "设备", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@@ -82,6 +102,7 @@ public class IotDeviceController extends BaseController
|
||||
/**
|
||||
* 修改设备
|
||||
*/
|
||||
@ApiOperation(value = "修改设备", notes = "修改设备")
|
||||
@PreAuthorize("@ss.hasPermi('system:device:edit')")
|
||||
@Log(title = "设备", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
@@ -93,6 +114,7 @@ public class IotDeviceController extends BaseController
|
||||
/**
|
||||
* 删除设备
|
||||
*/
|
||||
@ApiOperation(value = "删除设备", notes = "删除设备")
|
||||
@PreAuthorize("@ss.hasPermi('system:device:remove')")
|
||||
@Log(title = "设备", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{deviceIds}")
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.system.mqtt.config.MqttPushClient;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -26,6 +31,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
||||
* @author kerwincui
|
||||
* @date 2021-05-06
|
||||
*/
|
||||
@Api(value="设备配置",tags="设备配置")
|
||||
@RestController
|
||||
@RequestMapping("/system/set")
|
||||
public class IotDeviceSetController extends BaseController
|
||||
@@ -33,9 +39,13 @@ public class IotDeviceSetController extends BaseController
|
||||
@Autowired
|
||||
private IIotDeviceSetService iotDeviceSetService;
|
||||
|
||||
@Autowired
|
||||
private MqttPushClient mqttPushClient;
|
||||
|
||||
/**
|
||||
* 查询设备配置列表
|
||||
*/
|
||||
@ApiOperation(value = "查询设备配置列表", notes = "查询设备配置列表")
|
||||
@PreAuthorize("@ss.hasPermi('system:set:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(IotDeviceSet iotDeviceSet)
|
||||
@@ -48,6 +58,7 @@ public class IotDeviceSetController extends BaseController
|
||||
/**
|
||||
* 导出设备配置列表
|
||||
*/
|
||||
@ApiOperation(value = "导出设备配置列表", notes = "导出设备配置列表")
|
||||
@PreAuthorize("@ss.hasPermi('system:set:export')")
|
||||
@Log(title = "设备配置", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
@@ -61,6 +72,7 @@ public class IotDeviceSetController extends BaseController
|
||||
/**
|
||||
* 获取设备配置详细信息
|
||||
*/
|
||||
@ApiOperation(value = "获取设备配置详情", notes = "获取设备配置详情")
|
||||
@PreAuthorize("@ss.hasPermi('system:set:query')")
|
||||
@GetMapping(value = "/{deviceSetId}")
|
||||
public AjaxResult getInfo(@PathVariable("deviceSetId") Long deviceSetId)
|
||||
@@ -71,6 +83,7 @@ public class IotDeviceSetController extends BaseController
|
||||
/**
|
||||
* 获取最新设备配置详细信息
|
||||
*/
|
||||
@ApiOperation(value = "获取最新设备配置详情", notes = "获取最新设备配置详情")
|
||||
@PreAuthorize("@ss.hasPermi('system:set:query')")
|
||||
@GetMapping(value = "/new/{deviceId}")
|
||||
public AjaxResult getNewInfo(@PathVariable("deviceId") Long deviceId)
|
||||
@@ -81,6 +94,7 @@ public class IotDeviceSetController extends BaseController
|
||||
/**
|
||||
* 新增设备配置
|
||||
*/
|
||||
@ApiOperation(value = "新增设备配置", notes = "新增设备配置")
|
||||
@PreAuthorize("@ss.hasPermi('system:set:add')")
|
||||
@Log(title = "设备配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@@ -92,22 +106,38 @@ public class IotDeviceSetController extends BaseController
|
||||
/**
|
||||
* 修改设备配置
|
||||
*/
|
||||
@ApiOperation(value = "修改设备配置", notes = "修改设备配置")
|
||||
@PreAuthorize("@ss.hasPermi('system:set:edit')")
|
||||
@Log(title = "设备配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody IotDeviceSet iotDeviceSet)
|
||||
{
|
||||
return toAjax(iotDeviceSetService.updateIotDeviceSet(iotDeviceSet));
|
||||
// 存储
|
||||
iotDeviceSetService.updateIotDeviceSet(iotDeviceSet);
|
||||
// mqtt发布
|
||||
String content = JSON.toJSONString(iotDeviceSet);
|
||||
boolean isSuccess=mqttPushClient.publish(0,true,"setting/set/"+iotDeviceSet.getDeviceNum(),content);
|
||||
if(isSuccess){return AjaxResult.success("mqtt 发布成功");}
|
||||
return AjaxResult.error("mqtt 发布失败。");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "mqtt获取设备配置", notes = "mqtt获取设备配置")
|
||||
@GetMapping(value = "/getSetting/{deviceNum}")
|
||||
public AjaxResult getSetting(@PathVariable("deviceNum") String deviceNum){
|
||||
boolean isSuccess=mqttPushClient.publish(0,true,"setting/get/"+deviceNum,"wumei.live");
|
||||
if(isSuccess){return AjaxResult.success("mqtt 发布成功");}
|
||||
return AjaxResult.error("mqtt 发布失败。");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备配置
|
||||
*/
|
||||
@ApiOperation(value = "删除设备配置", notes = "删除设备配置")
|
||||
@PreAuthorize("@ss.hasPermi('system:set:remove')")
|
||||
@Log(title = "设备配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{deviceConfigIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] deviceConfigIds)
|
||||
@DeleteMapping("/{deviceSetIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] deviceSetIds)
|
||||
{
|
||||
return toAjax(iotDeviceSetService.deleteIotDeviceSetByIds(deviceConfigIds));
|
||||
return toAjax(iotDeviceSetService.deleteIotDeviceSetByIds(deviceSetIds));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.system.mqtt.config.MqttPushClient;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -26,6 +31,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
||||
* @author kerwincui
|
||||
* @date 2021-05-06
|
||||
*/
|
||||
@Api(value="设备状态",tags="设备状态")
|
||||
@RestController
|
||||
@RequestMapping("/system/status")
|
||||
public class IotDeviceStatusController extends BaseController
|
||||
@@ -33,9 +39,13 @@ public class IotDeviceStatusController extends BaseController
|
||||
@Autowired
|
||||
private IIotDeviceStatusService iotDeviceStatusService;
|
||||
|
||||
@Autowired
|
||||
private MqttPushClient mqttPushClient;
|
||||
|
||||
/**
|
||||
* 查询设备状态列表
|
||||
*/
|
||||
@ApiOperation(value = "查询设备状态列表", notes = "查询设备状态列表")
|
||||
@PreAuthorize("@ss.hasPermi('system:status:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(IotDeviceStatus iotDeviceStatus)
|
||||
@@ -48,6 +58,7 @@ public class IotDeviceStatusController extends BaseController
|
||||
/**
|
||||
* 导出设备状态列表
|
||||
*/
|
||||
@ApiOperation(value = "导出设备状态列表", notes = "导出设备状态列表")
|
||||
@PreAuthorize("@ss.hasPermi('system:status:export')")
|
||||
@Log(title = "设备状态", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
@@ -61,6 +72,7 @@ public class IotDeviceStatusController extends BaseController
|
||||
/**
|
||||
* 获取设备状态详细信息
|
||||
*/
|
||||
@ApiOperation(value = "获取设备状态详情", notes = "获取设备状态详情")
|
||||
@PreAuthorize("@ss.hasPermi('system:status:query')")
|
||||
@GetMapping(value = "/{deviceStatusId}")
|
||||
public AjaxResult getInfo(@PathVariable("deviceStatusId") Long deviceStatusId)
|
||||
@@ -68,9 +80,21 @@ public class IotDeviceStatusController extends BaseController
|
||||
return AjaxResult.success(iotDeviceStatusService.selectIotDeviceStatusById(deviceStatusId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据设备编号获取设备状态
|
||||
*/
|
||||
@ApiOperation(value = "根据设备编号获取最新设备状态", notes = "根据设备编号获取最新设备状态")
|
||||
@PreAuthorize("@ss.hasPermi('system:status:query')")
|
||||
@GetMapping(value = "/newByNum/{deviceNum}")
|
||||
public AjaxResult getNewStatus(@PathVariable("deviceNum") String deviceNum)
|
||||
{
|
||||
return AjaxResult.success(iotDeviceStatusService.selectIotDeviceStatusByDeviceNum(deviceNum));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最新设备状态详细信息
|
||||
*/
|
||||
@ApiOperation(value = "获取最新设备状态详情", notes = "获取最新设备状态详情")
|
||||
@PreAuthorize("@ss.hasPermi('system:status:query')")
|
||||
@GetMapping(value = "/new/{deviceId}")
|
||||
public AjaxResult getNewInfo(@PathVariable("deviceId") Long deviceId)
|
||||
@@ -81,6 +105,7 @@ public class IotDeviceStatusController extends BaseController
|
||||
/**
|
||||
* 新增设备状态
|
||||
*/
|
||||
@ApiOperation(value = "新增设备状态", notes = "新增设备状态")
|
||||
@PreAuthorize("@ss.hasPermi('system:status:add')")
|
||||
@Log(title = "设备状态", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@@ -92,17 +117,33 @@ public class IotDeviceStatusController extends BaseController
|
||||
/**
|
||||
* 修改设备状态
|
||||
*/
|
||||
@ApiOperation(value = "修改设备状态", notes = "修改设备状态")
|
||||
@PreAuthorize("@ss.hasPermi('system:status:edit')")
|
||||
@Log(title = "设备状态", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody IotDeviceStatus iotDeviceStatus)
|
||||
{
|
||||
return toAjax(iotDeviceStatusService.updateIotDeviceStatus(iotDeviceStatus));
|
||||
// 存储
|
||||
iotDeviceStatusService.updateIotDeviceStatus(iotDeviceStatus);
|
||||
// mqtt发布
|
||||
String content = JSON.toJSONString(iotDeviceStatus);
|
||||
boolean isSuccess=mqttPushClient.publish(1,true,"status/set/"+iotDeviceStatus.getDeviceNum(),content);
|
||||
if(isSuccess){return AjaxResult.success("mqtt 发布成功");}
|
||||
return AjaxResult.error("mqtt 发布失败。");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "mqtt获取设备状态", notes = "mqtt获取设备状态")
|
||||
@GetMapping(value = "/getStatus/{deviceNum}")
|
||||
public AjaxResult getStatus(@PathVariable("deviceNum") String deviceNum){
|
||||
boolean isSuccess=mqttPushClient.publish(0,true,"status/get/"+deviceNum,"wumei.live");
|
||||
if(isSuccess){return AjaxResult.success("mqtt 发布成功");}
|
||||
return AjaxResult.error("mqtt 发布失败。");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备状态
|
||||
*/
|
||||
@ApiOperation(value = "删除设备状态", notes = "删除设备状态")
|
||||
@PreAuthorize("@ss.hasPermi('system:status:remove')")
|
||||
@Log(title = "设备状态", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{deviceStatusIds}")
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.system.domain.IotGroup;
|
||||
import com.ruoyi.system.service.IIotGroupService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 分组Controller
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2021-05-18
|
||||
*/
|
||||
@Api(value="设备分组",tags="设备分组")
|
||||
@RestController
|
||||
@RequestMapping("/system/group")
|
||||
public class IotGroupController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IIotGroupService iotGroupService;
|
||||
|
||||
/**
|
||||
* 查询分组列表
|
||||
*/
|
||||
@ApiOperation(value = "分组列表", notes = "分组列表")
|
||||
@PreAuthorize("@ss.hasPermi('system:group:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(IotGroup iotGroup)
|
||||
{
|
||||
startPage();
|
||||
List<IotGroup> list = iotGroupService.selectIotGroupList(iotGroup);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出分组列表
|
||||
*/
|
||||
@ApiOperation(value = "导出分组", notes = "导出分组")
|
||||
@PreAuthorize("@ss.hasPermi('system:group:export')")
|
||||
@Log(title = "分组", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(IotGroup iotGroup)
|
||||
{
|
||||
List<IotGroup> list = iotGroupService.selectIotGroupList(iotGroup);
|
||||
ExcelUtil<IotGroup> util = new ExcelUtil<IotGroup>(IotGroup.class);
|
||||
return util.exportExcel(list, "group");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分组详细信息
|
||||
*/
|
||||
@ApiOperation(value = "获取分组详情", notes = "获取分组详情")
|
||||
@PreAuthorize("@ss.hasPermi('system:group:query')")
|
||||
@GetMapping(value = "/{groupId}")
|
||||
public AjaxResult getInfo(@PathVariable("groupId") Long groupId)
|
||||
{
|
||||
return AjaxResult.success(iotGroupService.selectIotGroupById(groupId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增分组
|
||||
*/
|
||||
@ApiOperation(value = "新增分组", notes = "新增分组")
|
||||
@PreAuthorize("@ss.hasPermi('system:group:add')")
|
||||
@Log(title = "分组", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody IotGroup iotGroup)
|
||||
{
|
||||
return toAjax(iotGroupService.insertIotGroup(iotGroup));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分组
|
||||
*/
|
||||
@ApiOperation(value = "修改分组", notes = "修改分组")
|
||||
@PreAuthorize("@ss.hasPermi('system:group:edit')")
|
||||
@Log(title = "分组", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody IotGroup iotGroup)
|
||||
{
|
||||
return toAjax(iotGroupService.updateIotGroup(iotGroup));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分组
|
||||
*/
|
||||
@ApiOperation(value = "删除分组", notes = "删除分组")
|
||||
@PreAuthorize("@ss.hasPermi('system:group:remove')")
|
||||
@Log(title = "分组", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{groupIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] groupIds)
|
||||
{
|
||||
return toAjax(iotGroupService.deleteIotGroupByIds(groupIds));
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
||||
/**
|
||||
* swagger 用户测试方法
|
||||
* mqtt接口
|
||||
*
|
||||
*/
|
||||
@Api("mqtt测试")
|
||||
@Api(value="mqtt消息发布",tags="mqtt消息发布")
|
||||
@RestController
|
||||
@RequestMapping("/test/mqtt")
|
||||
@RequestMapping("/system/mqtt")
|
||||
public class MqttController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
@@ -29,7 +29,7 @@ public class MqttController extends BaseController
|
||||
@PostMapping(value = "/updateStatus")
|
||||
public AjaxResult updateStatus(@RequestBody IotDeviceStatus iotDeviceStatus){
|
||||
String content = JSON.toJSONString(iotDeviceStatus);
|
||||
boolean isSuccess=mqttPushClient.publish(1,false,"status/"+iotDeviceStatus.getDeviceNum(),content);
|
||||
boolean isSuccess=mqttPushClient.publish(1,false,"status/set/"+iotDeviceStatus.getDeviceNum(),content);
|
||||
if(isSuccess){return AjaxResult.success();}
|
||||
return AjaxResult.error("mqtt 发布失败。");
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class MqttController extends BaseController
|
||||
@ApiOperation(value = "获取设备状态", notes = "获取设备状态")
|
||||
@GetMapping(value = "/getStatus/{deviceNum}")
|
||||
public AjaxResult getStatus(@PathVariable("deviceNum") String deviceNum){
|
||||
boolean isSuccess=mqttPushClient.publish(0,false,"status/new/"+deviceNum,"");
|
||||
boolean isSuccess=mqttPushClient.publish(0,false,"status/get/"+deviceNum,"wumei.live");
|
||||
if(isSuccess){return AjaxResult.success();}
|
||||
return AjaxResult.error("mqtt 发布失败。");
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class MqttController extends BaseController
|
||||
@PostMapping(value = "/updateSetting")
|
||||
public AjaxResult updateSetting(@RequestBody IotDeviceSet iotDeviceSet){
|
||||
String content = JSON.toJSONString(iotDeviceSet);
|
||||
boolean isSuccess=mqttPushClient.publish(0,false,"setting/"+iotDeviceSet.getDeviceNum(),content);
|
||||
boolean isSuccess=mqttPushClient.publish(0,false,"setting/set/"+iotDeviceSet.getDeviceNum(),content);
|
||||
if(isSuccess){return AjaxResult.success();}
|
||||
return AjaxResult.error("mqtt 发布失败。");
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class MqttController extends BaseController
|
||||
@ApiOperation(value = "获取设备配置", notes = "获取设备配置")
|
||||
@GetMapping(value = "/getSetting/{deviceNum}")
|
||||
public AjaxResult getSetting(@PathVariable("deviceNum") String deviceNum){
|
||||
boolean isSuccess=mqttPushClient.publish(0,false,"Setting/new/"+deviceNum,"");
|
||||
boolean isSuccess=mqttPushClient.publish(0,false,"setting/get/"+deviceNum,"wumei.lie");
|
||||
if(isSuccess){return AjaxResult.success();}
|
||||
return AjaxResult.error("mqtt 发布失败。");
|
||||
}
|
||||
|
||||
@@ -46,6 +46,18 @@ public class IotDeviceSet extends BaseEntity
|
||||
@Excel(name = "打开AP")
|
||||
private Integer isAp;
|
||||
|
||||
/** 是否离线使用 */
|
||||
@Excel(name = "是否离线使用")
|
||||
private Integer isWifiOffline;
|
||||
|
||||
/** 是否使用证书 */
|
||||
@Excel(name = "是否使用证书")
|
||||
private Integer isOpenCertifi;
|
||||
|
||||
/** 智能配网 */
|
||||
@Excel(name = "智能配网")
|
||||
private Integer isSmartConfig;
|
||||
|
||||
/** 射频遥控 */
|
||||
@Excel(name = "射频遥控")
|
||||
private Integer isRfControl;
|
||||
@@ -86,6 +98,10 @@ public class IotDeviceSet extends BaseEntity
|
||||
@Excel(name = "配网IP")
|
||||
private String networkIp;
|
||||
|
||||
/** 雷达感应间隔 */
|
||||
@Excel(name = "雷达感应间隔")
|
||||
private Integer radarInterval;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
@@ -152,15 +168,43 @@ public class IotDeviceSet extends BaseEntity
|
||||
{
|
||||
return isReset;
|
||||
}
|
||||
|
||||
public void setIsAp(Integer isAp)
|
||||
{
|
||||
this.isAp = isAp;
|
||||
}
|
||||
|
||||
public Integer getIsAp()
|
||||
{
|
||||
return isAp;
|
||||
}
|
||||
|
||||
public void setIsWifiOffline(Integer isWifiOffline)
|
||||
{
|
||||
this.isWifiOffline = isWifiOffline;
|
||||
}
|
||||
public Integer getIsWifiOffline()
|
||||
{
|
||||
return isWifiOffline;
|
||||
}
|
||||
|
||||
public void setIsOpenCertifi(Integer isOpenCertifi)
|
||||
{
|
||||
this.isOpenCertifi = isOpenCertifi;
|
||||
}
|
||||
public Integer getIsOpenCertifi()
|
||||
{
|
||||
return isOpenCertifi;
|
||||
}
|
||||
|
||||
public void setIsSmartConfig(Integer isSmartConfig)
|
||||
{
|
||||
this.isSmartConfig = isSmartConfig;
|
||||
}
|
||||
|
||||
public Integer getIsSmartConfig()
|
||||
{
|
||||
return isSmartConfig;
|
||||
}
|
||||
public void setIsRfControl(Integer isRfControl)
|
||||
{
|
||||
this.isRfControl = isRfControl;
|
||||
@@ -256,6 +300,16 @@ public class IotDeviceSet extends BaseEntity
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public void setRadarInterval(Integer radarInterval)
|
||||
{
|
||||
this.radarInterval = radarInterval;
|
||||
}
|
||||
|
||||
public Integer getRadarInterval()
|
||||
{
|
||||
return radarInterval;
|
||||
}
|
||||
|
||||
public String getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
@@ -272,6 +326,7 @@ public class IotDeviceSet extends BaseEntity
|
||||
.append("isHost", getIsHost())
|
||||
.append("isReset", getIsReset())
|
||||
.append("isAp", getIsAp())
|
||||
.append("isSmartConfig", getIsSmartConfig())
|
||||
.append("isRfControl", getIsRfControl())
|
||||
.append("isRfLearn", getIsRfLearn())
|
||||
.append("isRfClear", getIsRfClear())
|
||||
@@ -282,6 +337,7 @@ public class IotDeviceSet extends BaseEntity
|
||||
.append("ownerId", getOwnerId())
|
||||
.append("networkAddress", getNetworkAddress())
|
||||
.append("networkIp", getNetworkIp())
|
||||
.append("radarInterval", getRadarInterval())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
|
||||
@@ -44,8 +44,8 @@ public class IotDeviceStatus extends BaseEntity
|
||||
private BigDecimal deviceTemperature;
|
||||
|
||||
/** 设备湿度 */
|
||||
@Excel(name = "设备湿度")
|
||||
private BigDecimal deviceHumidity;
|
||||
@Excel(name = "信号")
|
||||
private Integer rssi;
|
||||
|
||||
/** 空气温度 */
|
||||
@Excel(name = "空气温度")
|
||||
@@ -71,6 +71,10 @@ public class IotDeviceStatus extends BaseEntity
|
||||
@Excel(name = "彩灯模式")
|
||||
private Integer lightMode;
|
||||
|
||||
/** 灯渐变时间 */
|
||||
@Excel(name = "渐变时间")
|
||||
private Integer fadeTime;
|
||||
|
||||
/** 红灯 */
|
||||
@Excel(name = "红灯")
|
||||
private Long red;
|
||||
@@ -149,14 +153,14 @@ public class IotDeviceStatus extends BaseEntity
|
||||
{
|
||||
return deviceTemperature;
|
||||
}
|
||||
public void setDeviceHumidity(BigDecimal deviceHumidity)
|
||||
public void setRssi(Integer rssi)
|
||||
{
|
||||
this.deviceHumidity = deviceHumidity;
|
||||
this.rssi = rssi;
|
||||
}
|
||||
|
||||
public BigDecimal getDeviceHumidity()
|
||||
public Integer getRssi()
|
||||
{
|
||||
return deviceHumidity;
|
||||
return rssi;
|
||||
}
|
||||
public void setAirTemperature(BigDecimal airTemperature)
|
||||
{
|
||||
@@ -244,6 +248,15 @@ public class IotDeviceStatus extends BaseEntity
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public void setFadeTime(Integer fadeTime)
|
||||
{
|
||||
this.fadeTime = fadeTime;
|
||||
}
|
||||
public Integer getFadeTime()
|
||||
{
|
||||
return fadeTime;
|
||||
}
|
||||
|
||||
public String getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
@@ -259,13 +272,14 @@ public class IotDeviceStatus extends BaseEntity
|
||||
.append("lightStatus", getLightStatus())
|
||||
.append("isOnline", getIsOnline())
|
||||
.append("deviceTemperature", getDeviceTemperature())
|
||||
.append("deviceHumidity", getDeviceHumidity())
|
||||
.append("rssid", getRssi())
|
||||
.append("airTemperature", getAirTemperature())
|
||||
.append("airHumidity", getAirHumidity())
|
||||
.append("triggerSource", getTriggerSource())
|
||||
.append("brightness", getBrightness())
|
||||
.append("lightInterval", getLightInterval())
|
||||
.append("lightMode", getLightMode())
|
||||
.append("fadeTime", getFadeTime())
|
||||
.append("red", getRed())
|
||||
.append("green", getGreen())
|
||||
.append("blue", getBlue())
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 分组对象 iot_group
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2021-05-18
|
||||
*/
|
||||
public class IotGroup extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 设备分组 */
|
||||
private Long groupId;
|
||||
|
||||
/** 用户 */
|
||||
@Excel(name = "用户")
|
||||
private Long userId;
|
||||
|
||||
/** 分组名称 */
|
||||
@Excel(name = "分组名称")
|
||||
private String groupName;
|
||||
|
||||
/** 排序 */
|
||||
@Excel(name = "排序")
|
||||
private Integer groupOrder;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
public void setGroupId(Long groupId)
|
||||
{
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public Long getGroupId()
|
||||
{
|
||||
return groupId;
|
||||
}
|
||||
public void setUserId(Long userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
public void setGroupName(String groupName)
|
||||
{
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
public String getGroupName()
|
||||
{
|
||||
return groupName;
|
||||
}
|
||||
public void setGroupOrder(Integer groupOrder)
|
||||
{
|
||||
this.groupOrder = groupOrder;
|
||||
}
|
||||
|
||||
public Integer getGroupOrder()
|
||||
{
|
||||
return groupOrder;
|
||||
}
|
||||
public void setDelFlag(String delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("groupId", getGroupId())
|
||||
.append("userId", getUserId())
|
||||
.append("groupName", getGroupName())
|
||||
.append("groupOrder", getGroupOrder())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
package com.ruoyi.system.domain.vo;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 设备对象 iot_device
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2021-05-06
|
||||
*/
|
||||
public class IotDeviceListDto extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 序号 */
|
||||
private Long deviceId;
|
||||
|
||||
/** 编号 */
|
||||
@Excel(name = "编号")
|
||||
private String deviceNum;
|
||||
|
||||
/** 分类 */
|
||||
@Excel(name = "分类")
|
||||
private Long categoryId;
|
||||
|
||||
/** 名称 */
|
||||
@Excel(name = "名称")
|
||||
private String deviceName;
|
||||
|
||||
/** 固件版本 */
|
||||
@Excel(name = "固件版本")
|
||||
private String firmwareVersion;
|
||||
|
||||
/** 用户 */
|
||||
@Excel(name = "用户")
|
||||
private String ownerId;
|
||||
|
||||
@Excel(name="用户昵称")
|
||||
private String nickName;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
|
||||
/** 报警 */
|
||||
@Excel(name = "报警")
|
||||
private Integer isAlarm;
|
||||
|
||||
/** 雷达感应 */
|
||||
@Excel(name = "雷达感应")
|
||||
private Integer isRadar;
|
||||
|
||||
/** 射频遥控 */
|
||||
@Excel(name = "射频遥控")
|
||||
private Integer isRfControl;
|
||||
|
||||
/** 配网地址 */
|
||||
@Excel(name = "配网地址")
|
||||
private String networkAddress;
|
||||
|
||||
/** 配网IP */
|
||||
@Excel(name = "配网IP")
|
||||
private String networkIp;
|
||||
|
||||
|
||||
/** 继电器 */
|
||||
@Excel(name = "继电器")
|
||||
private Integer relayStatus;
|
||||
|
||||
/** 灯状态 */
|
||||
@Excel(name = "灯状态")
|
||||
private Integer lightStatus;
|
||||
|
||||
/** 在线 */
|
||||
@Excel(name = "在线")
|
||||
private Integer isOnline;
|
||||
|
||||
/** 设备温度 */
|
||||
@Excel(name = "设备温度")
|
||||
private BigDecimal deviceTemperature;
|
||||
|
||||
/** 设备湿度 */
|
||||
@Excel(name = "信号")
|
||||
private Integer rssi;
|
||||
|
||||
|
||||
|
||||
public void setDeviceId(Long deviceId)
|
||||
{
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
public Long getDeviceId()
|
||||
{
|
||||
return deviceId;
|
||||
}
|
||||
public void setDeviceNum(String deviceNum)
|
||||
{
|
||||
this.deviceNum = deviceNum;
|
||||
}
|
||||
public String getDeviceNum()
|
||||
{
|
||||
return deviceNum;
|
||||
}
|
||||
public void setCategoryId(Long categoryId)
|
||||
{
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
public Long getCategoryId()
|
||||
{
|
||||
return categoryId;
|
||||
}
|
||||
public void setDeviceName(String deviceName)
|
||||
{
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
public String getDeviceName()
|
||||
{
|
||||
return deviceName;
|
||||
}
|
||||
public void setFirmwareVersion(String firmwareVersion)
|
||||
{
|
||||
this.firmwareVersion = firmwareVersion;
|
||||
}
|
||||
public String getFirmwareVersion()
|
||||
{
|
||||
return firmwareVersion;
|
||||
}
|
||||
public void setOwnerId(String ownerId)
|
||||
{
|
||||
this.ownerId = ownerId;
|
||||
}
|
||||
public String getOwnerId()
|
||||
{
|
||||
return ownerId;
|
||||
}
|
||||
public void setNickName(String nickName)
|
||||
{
|
||||
this.nickName = nickName;
|
||||
}
|
||||
public String getNickName()
|
||||
{
|
||||
return nickName;
|
||||
}
|
||||
public void setDelFlag(String delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
public String getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setIsAlarm(Integer isAlarm)
|
||||
{
|
||||
this.isAlarm = isAlarm;
|
||||
}
|
||||
public Integer getIsAlarm()
|
||||
{
|
||||
return isAlarm;
|
||||
}
|
||||
public void setIsRadar(Integer isRadar)
|
||||
{
|
||||
this.isRadar = isRadar;
|
||||
}
|
||||
public Integer getIsRadar()
|
||||
{
|
||||
return isRadar;
|
||||
}
|
||||
public void setIsRfControl(Integer isRfControl)
|
||||
{
|
||||
this.isRfControl = isRfControl;
|
||||
}
|
||||
public Integer getIsRfControl()
|
||||
{
|
||||
return isRfControl;
|
||||
}
|
||||
public void setNetworkAddress(String networkAddress)
|
||||
{
|
||||
this.networkAddress = networkAddress;
|
||||
}
|
||||
public String getNetworkAddress()
|
||||
{
|
||||
return networkAddress;
|
||||
}
|
||||
public void setNetworkIp(String networkIp)
|
||||
{
|
||||
this.networkIp = networkIp;
|
||||
}
|
||||
public String getNetworkIp()
|
||||
{
|
||||
return networkIp;
|
||||
}
|
||||
|
||||
public void setRelayStatus(Integer relayStatus)
|
||||
{
|
||||
this.relayStatus = relayStatus;
|
||||
}
|
||||
public Integer getRelayStatus()
|
||||
{
|
||||
return relayStatus;
|
||||
}
|
||||
public void setLightStatus(Integer lightStatus)
|
||||
{
|
||||
this.lightStatus = lightStatus;
|
||||
}
|
||||
public Integer getLightStatus()
|
||||
{
|
||||
return lightStatus;
|
||||
}
|
||||
public void setIsOnline(Integer isOnline)
|
||||
{
|
||||
this.isOnline = isOnline;
|
||||
}
|
||||
public Integer getIsOnline()
|
||||
{
|
||||
return isOnline;
|
||||
}
|
||||
public void setDeviceTemperature(BigDecimal deviceTemperature)
|
||||
{
|
||||
this.deviceTemperature = deviceTemperature;
|
||||
}
|
||||
public BigDecimal getDeviceTemperature()
|
||||
{
|
||||
return deviceTemperature;
|
||||
}
|
||||
public void setRssi(Integer rssi)
|
||||
{
|
||||
this.rssi = rssi;
|
||||
}
|
||||
public Integer getRssi()
|
||||
{
|
||||
return rssi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("deviceId", getDeviceId())
|
||||
.append("deviceNum", getDeviceNum())
|
||||
.append("categoryId", getCategoryId())
|
||||
.append("deviceName", getDeviceName())
|
||||
.append("firmwareVersion", getFirmwareVersion())
|
||||
.append("ownerId", getOwnerId())
|
||||
.append("nickName", getNickName())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("isAlarm", getIsAlarm())
|
||||
.append("isRadar", getIsRadar())
|
||||
.append("isRfControl", getIsRfControl())
|
||||
.append("networkAddress", getNetworkAddress())
|
||||
.append("networkIp", getNetworkIp())
|
||||
.append("relayStatus", getRelayStatus())
|
||||
.append("lightStatus", getLightStatus())
|
||||
.append("isOnline", getIsOnline())
|
||||
.append("deviceTemperature", getDeviceTemperature())
|
||||
.append("rssid", getRssi())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.IotDevice;
|
||||
import com.ruoyi.system.domain.vo.IotDeviceListDto;
|
||||
|
||||
/**
|
||||
* 设备Mapper接口
|
||||
@@ -19,13 +20,21 @@ public interface IotDeviceMapper
|
||||
*/
|
||||
public IotDevice selectIotDeviceById(Long deviceId);
|
||||
|
||||
/**
|
||||
* 根据编号查询设备
|
||||
*
|
||||
* @param deviceNum 设备编号
|
||||
* @return 设备
|
||||
*/
|
||||
public IotDevice selectIotDeviceByNum(String deviceNum);
|
||||
|
||||
/**
|
||||
* 查询设备列表
|
||||
*
|
||||
* @param iotDevice 设备
|
||||
* @return 设备集合
|
||||
*/
|
||||
public List<IotDevice> selectIotDeviceList(IotDevice iotDevice);
|
||||
public List<IotDeviceListDto> selectIotDeviceList(IotDevice iotDevice);
|
||||
|
||||
/**
|
||||
* 新增设备
|
||||
|
||||
@@ -27,6 +27,14 @@ public interface IotDeviceStatusMapper
|
||||
*/
|
||||
public IotDeviceStatus selectIotDeviceStatusByDeviceId(Long deviceId);
|
||||
|
||||
/**
|
||||
* 根据设备编号查询设备最新状态
|
||||
*
|
||||
* @param deviceNum 设备编号
|
||||
* @return 设备状态
|
||||
*/
|
||||
public IotDeviceStatus selectIotDeviceStatusByDeviceNum(String deviceNum);
|
||||
|
||||
/**
|
||||
* 查询设备状态列表
|
||||
*
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.IotGroup;
|
||||
|
||||
/**
|
||||
* 分组Mapper接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2021-05-18
|
||||
*/
|
||||
public interface IotGroupMapper
|
||||
{
|
||||
/**
|
||||
* 查询分组
|
||||
*
|
||||
* @param groupId 分组ID
|
||||
* @return 分组
|
||||
*/
|
||||
public IotGroup selectIotGroupById(Long groupId);
|
||||
|
||||
/**
|
||||
* 查询分组列表
|
||||
*
|
||||
* @param iotGroup 分组
|
||||
* @return 分组集合
|
||||
*/
|
||||
public List<IotGroup> selectIotGroupList(IotGroup iotGroup);
|
||||
|
||||
/**
|
||||
* 新增分组
|
||||
*
|
||||
* @param iotGroup 分组
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertIotGroup(IotGroup iotGroup);
|
||||
|
||||
/**
|
||||
* 修改分组
|
||||
*
|
||||
* @param iotGroup 分组
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateIotGroup(IotGroup iotGroup);
|
||||
|
||||
/**
|
||||
* 删除分组
|
||||
*
|
||||
* @param groupId 分组ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteIotGroupById(Long groupId);
|
||||
|
||||
/**
|
||||
* 批量删除分组
|
||||
*
|
||||
* @param groupIds 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteIotGroupByIds(Long[] groupIds);
|
||||
}
|
||||
@@ -3,9 +3,14 @@ package com.ruoyi.system.mqtt.config;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.ip.AddressUtils;
|
||||
import com.ruoyi.common.utils.ip.IpUtils;
|
||||
import com.ruoyi.system.domain.IotCategory;
|
||||
import com.ruoyi.system.domain.IotDevice;
|
||||
import com.ruoyi.system.domain.IotDeviceSet;
|
||||
import com.ruoyi.system.domain.IotDeviceStatus;
|
||||
import com.ruoyi.system.service.IIotCategoryService;
|
||||
import com.ruoyi.system.service.IIotDeviceService;
|
||||
import com.ruoyi.system.service.IIotDeviceSetService;
|
||||
import com.ruoyi.system.service.IIotDeviceStatusService;
|
||||
@@ -31,6 +36,8 @@ public class PushCallback implements MqttCallback {
|
||||
@Autowired
|
||||
private IIotDeviceService iotDeviceService;
|
||||
@Autowired
|
||||
private IIotCategoryService iotCategoryService;
|
||||
@Autowired
|
||||
private IIotDeviceStatusService iotDeviceStatusService;
|
||||
@Autowired
|
||||
private IIotDeviceSetService iotDeviceSetService;
|
||||
@@ -58,33 +65,53 @@ public class PushCallback implements MqttCallback {
|
||||
if(topic.equals("device_info")){
|
||||
//添加设备信息
|
||||
IotDevice device = JSON.parseObject(new String(mqttMessage.getPayload()), IotDevice.class);
|
||||
iotDeviceService.insertIotDevice(device);
|
||||
//获取设备状态
|
||||
mqttPushClient.publish(0,false,"status/new/"+device.getDeviceNum(),"");
|
||||
IotDevice deviceEntity=iotDeviceService.selectIotDeviceByNum(device.getDeviceNum());
|
||||
if(deviceEntity!=null){
|
||||
device.setDeviceId(deviceEntity.getDeviceId());
|
||||
iotDeviceService.updateIotDevice(device);
|
||||
}else {
|
||||
IotCategory categoryEntity=iotCategoryService.selectIotCategoryById(device.getCategoryId());
|
||||
if(device.getDeviceName()==null || device.getDeviceNum().length()==0) {
|
||||
device.setDeviceName(categoryEntity.getCategoryName());
|
||||
}
|
||||
iotDeviceService.insertIotDevice(device);
|
||||
}
|
||||
//获取设备状态(消息内容不能为空,硬件获取不到数据报错)
|
||||
mqttPushClient.publish(1,false,"status/get/"+device.getDeviceNum(),"wumei.live");
|
||||
//获取设备配置
|
||||
mqttPushClient.publish(0,false,"setting/new/"+device.getDeviceNum(),"");
|
||||
mqttPushClient.publish(1,false,"setting/get/"+device.getDeviceNum(),"wumei.live");
|
||||
}else if(topic.equals("status")){
|
||||
IotDeviceStatus deviceStatus = JSON.parseObject(new String(mqttMessage.getPayload()), IotDeviceStatus.class);
|
||||
IotDevice device=iotDeviceService.selectIotDeviceById(deviceStatus.getDeviceId());
|
||||
IotDevice device=iotDeviceService.selectIotDeviceByNum(deviceStatus.getDeviceNum());
|
||||
//添加设备状态
|
||||
deviceStatus.setDeviceId(device.getDeviceId());
|
||||
iotDeviceStatusService.insertIotDeviceStatus(deviceStatus);
|
||||
}else if(topic.equals("setting")){
|
||||
IotDeviceSet deviceSet = JSON.parseObject(new String(mqttMessage.getPayload()), IotDeviceSet.class);
|
||||
//更新设备用户
|
||||
IotDevice device=iotDeviceService.selectIotDeviceById(deviceSet.getDeviceId());
|
||||
device.setOwnerId(deviceSet.getOwnerId());
|
||||
iotDeviceService.updateIotDevice(device);
|
||||
// 智能配网时需要获取IP、地址和设备用户
|
||||
IotDevice device=null;
|
||||
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);
|
||||
}
|
||||
//添加设备配置
|
||||
deviceSet.setDeviceId(device.getDeviceId());
|
||||
iotDeviceSetService.insertIotDeviceSet(deviceSet);
|
||||
}else if(topic.equals("offline")){
|
||||
//离线遗嘱
|
||||
//离线遗嘱 TODO:查询待优化
|
||||
IotDeviceStatus deviceStatus = JSON.parseObject(new String(mqttMessage.getPayload()), IotDeviceStatus.class);
|
||||
//添加设备状态
|
||||
IotDeviceStatus newDeviceStatus=iotDeviceStatusService.selectIotDeviceStatusById(deviceStatus.getDeviceStatusId());
|
||||
newDeviceStatus.setIsOnline(0);
|
||||
iotDeviceStatusService.insertIotDeviceStatus(newDeviceStatus);
|
||||
IotDevice device=iotDeviceService.selectIotDeviceByNum(deviceStatus.getDeviceNum());
|
||||
IotDeviceStatus deviceStatusEntity=iotDeviceStatusService.selectIotDeviceStatusByDeviceId(device.getDeviceId());
|
||||
//跟新最近一条设备状态为离线
|
||||
if(deviceStatusEntity!=null) {
|
||||
deviceStatusEntity.setIsOnline(0);
|
||||
iotDeviceStatusService.updateIotDeviceStatus(deviceStatusEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.IotDevice;
|
||||
import com.ruoyi.system.domain.vo.IotDeviceListDto;
|
||||
|
||||
/**
|
||||
* 设备Service接口
|
||||
@@ -19,13 +20,18 @@ public interface IIotDeviceService
|
||||
*/
|
||||
public IotDevice selectIotDeviceById(Long deviceId);
|
||||
|
||||
/**
|
||||
* 根据编号查询设备
|
||||
*/
|
||||
public IotDevice selectIotDeviceByNum(String deviceNum);
|
||||
|
||||
/**
|
||||
* 查询设备列表
|
||||
*
|
||||
* @param iotDevice 设备
|
||||
* @return 设备集合
|
||||
*/
|
||||
public List<IotDevice> selectIotDeviceList(IotDevice iotDevice);
|
||||
public List<IotDeviceListDto> selectIotDeviceList(IotDevice iotDevice);
|
||||
|
||||
/**
|
||||
* 新增设备
|
||||
|
||||
@@ -27,6 +27,14 @@ public interface IIotDeviceStatusService
|
||||
*/
|
||||
public IotDeviceStatus selectIotDeviceStatusByDeviceId(Long deviceId);
|
||||
|
||||
/**
|
||||
* 根据设备编号查询设备最新状态
|
||||
*
|
||||
* @param deviceNum 设备编号
|
||||
* @return 设备状态
|
||||
*/
|
||||
public IotDeviceStatus selectIotDeviceStatusByDeviceNum(String deviceNum);
|
||||
|
||||
/**
|
||||
* 查询设备状态列表
|
||||
*
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.IotGroup;
|
||||
|
||||
/**
|
||||
* 分组Service接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2021-05-18
|
||||
*/
|
||||
public interface IIotGroupService
|
||||
{
|
||||
/**
|
||||
* 查询分组
|
||||
*
|
||||
* @param groupId 分组ID
|
||||
* @return 分组
|
||||
*/
|
||||
public IotGroup selectIotGroupById(Long groupId);
|
||||
|
||||
/**
|
||||
* 查询分组列表
|
||||
*
|
||||
* @param iotGroup 分组
|
||||
* @return 分组集合
|
||||
*/
|
||||
public List<IotGroup> selectIotGroupList(IotGroup iotGroup);
|
||||
|
||||
/**
|
||||
* 新增分组
|
||||
*
|
||||
* @param iotGroup 分组
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertIotGroup(IotGroup iotGroup);
|
||||
|
||||
/**
|
||||
* 修改分组
|
||||
*
|
||||
* @param iotGroup 分组
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateIotGroup(IotGroup iotGroup);
|
||||
|
||||
/**
|
||||
* 批量删除分组
|
||||
*
|
||||
* @param groupIds 需要删除的分组ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteIotGroupByIds(Long[] groupIds);
|
||||
|
||||
/**
|
||||
* 删除分组信息
|
||||
*
|
||||
* @param groupId 分组ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteIotGroupById(Long groupId);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.system.domain.vo.IotDeviceListDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.mapper.IotDeviceMapper;
|
||||
@@ -32,6 +33,18 @@ public class IotDeviceServiceImpl implements IIotDeviceService
|
||||
return iotDeviceMapper.selectIotDeviceById(deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据编号查询设备
|
||||
*
|
||||
* @param deviceNum 设备编号
|
||||
* @return 设备
|
||||
*/
|
||||
@Override
|
||||
public IotDevice selectIotDeviceByNum(String deviceNum)
|
||||
{
|
||||
return iotDeviceMapper.selectIotDeviceByNum(deviceNum);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备列表
|
||||
*
|
||||
@@ -39,7 +52,7 @@ public class IotDeviceServiceImpl implements IIotDeviceService
|
||||
* @return 设备
|
||||
*/
|
||||
@Override
|
||||
public List<IotDevice> selectIotDeviceList(IotDevice iotDevice)
|
||||
public List<IotDeviceListDto> selectIotDeviceList(IotDevice iotDevice)
|
||||
{
|
||||
return iotDeviceMapper.selectIotDeviceList(iotDevice);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,18 @@ public class IotDeviceStatusServiceImpl implements IIotDeviceStatusService
|
||||
return iotDeviceStatusMapper.selectIotDeviceStatusByDeviceId(deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据设备编号查询最新设备状态
|
||||
*
|
||||
* @param deviceNum 设备编号
|
||||
* @return 设备状态
|
||||
*/
|
||||
@Override
|
||||
public IotDeviceStatus selectIotDeviceStatusByDeviceNum(String deviceNum)
|
||||
{
|
||||
return iotDeviceStatusMapper.selectIotDeviceStatusByDeviceNum(deviceNum);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备状态列表
|
||||
*
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.mapper.IotGroupMapper;
|
||||
import com.ruoyi.system.domain.IotGroup;
|
||||
import com.ruoyi.system.service.IIotGroupService;
|
||||
|
||||
/**
|
||||
* 分组Service业务层处理
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2021-05-18
|
||||
*/
|
||||
@Service
|
||||
public class IotGroupServiceImpl implements IIotGroupService
|
||||
{
|
||||
@Autowired
|
||||
private IotGroupMapper iotGroupMapper;
|
||||
|
||||
/**
|
||||
* 查询分组
|
||||
*
|
||||
* @param groupId 分组ID
|
||||
* @return 分组
|
||||
*/
|
||||
@Override
|
||||
public IotGroup selectIotGroupById(Long groupId)
|
||||
{
|
||||
return iotGroupMapper.selectIotGroupById(groupId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分组列表
|
||||
*
|
||||
* @param iotGroup 分组
|
||||
* @return 分组
|
||||
*/
|
||||
@Override
|
||||
public List<IotGroup> selectIotGroupList(IotGroup iotGroup)
|
||||
{
|
||||
return iotGroupMapper.selectIotGroupList(iotGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增分组
|
||||
*
|
||||
* @param iotGroup 分组
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertIotGroup(IotGroup iotGroup)
|
||||
{
|
||||
iotGroup.setCreateTime(DateUtils.getNowDate());
|
||||
return iotGroupMapper.insertIotGroup(iotGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分组
|
||||
*
|
||||
* @param iotGroup 分组
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateIotGroup(IotGroup iotGroup)
|
||||
{
|
||||
iotGroup.setUpdateTime(DateUtils.getNowDate());
|
||||
return iotGroupMapper.updateIotGroup(iotGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除分组
|
||||
*
|
||||
* @param groupIds 需要删除的分组ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteIotGroupByIds(Long[] groupIds)
|
||||
{
|
||||
return iotGroupMapper.deleteIotGroupByIds(groupIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分组信息
|
||||
*
|
||||
* @param groupId 分组ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteIotGroupById(Long groupId)
|
||||
{
|
||||
return iotGroupMapper.deleteIotGroupById(groupId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user