20260712:1、权限临时方案;2、简易分配设备给用户
This commit is contained in:
parent
95d35341ac
commit
bfd1b9580d
@ -25,7 +25,9 @@
|
||||
"Bash(git diff:*)",
|
||||
"Bash(source \"$HOME/.nvm/nvm.sh\")",
|
||||
"Bash(nvm use:*)",
|
||||
"Bash(npm run:*)"
|
||||
"Bash(npm run:*)",
|
||||
"mcp__filesystem__read_text_file",
|
||||
"Bash(sips:*)"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,6 +111,8 @@ fastbee-plugs/
|
||||
|
||||
**认证方式:** 通过 `Authorization` 请求头传递 JWT Token。Token 配置在 `application.yml` 的 `token:` 节点下。
|
||||
|
||||
**权限策略(重要):** 后端接口权限基于若依 `@PreAuthorize("@ss.hasPermi(...)" )` / `@ss.hasAnyPermi(...)`。`sys_menu.menu_type = C` 通常代表页面权限,`menu_type = F` 代表按钮/功能权限。由于前端页面会跨模块复用选择器/列表/详情接口(例如设备计算公式页面复用产品物模型接口、数据中心复用设备/场景接口),读接口、列表接口、下拉选择器、详情接口应优先使用 `hasAnyPermi`,允许“接口原所属权限 + 实际使用页面的页面级权限”。示例:`@PreAuthorize("@ss.hasAnyPermi('iot:model:list,iot:device:list')")`。写接口(新增/修改/删除/导入/导出)不要默认用页面 `list` 权限放开;只有确认该写操作属于该页面功能时,才追加对应页面的 `add/edit/remove` 权限,例如设备页维护计算公式可考虑 `iot:model:edit,iot:device:edit`。
|
||||
|
||||
**API 文档:** 服务运行时可通过 `/swagger-ui/index.html` 访问 Swagger/OpenAPI 文档。
|
||||
|
||||
### 前端架构
|
||||
|
||||
@ -32,7 +32,7 @@ public class SysNoticeController extends BaseController {
|
||||
* 获取通知公告列表
|
||||
*/
|
||||
@ApiOperation("获取通知公告列表")
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('system:notice:list,iot:device:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysNotice notice) {
|
||||
startPage();
|
||||
@ -44,7 +44,7 @@ public class SysNoticeController extends BaseController {
|
||||
* 根据通知公告编号获取详细信息
|
||||
*/
|
||||
@ApiOperation("根据通知公告编号获取详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('system:notice:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('system:notice:query,iot:device:list')")
|
||||
@GetMapping(value = "/{noticeId}")
|
||||
public AjaxResult getInfo(@PathVariable Long noticeId) {
|
||||
return success(noticeService.selectNoticeById(noticeId));
|
||||
|
||||
@ -55,7 +55,7 @@ public class SysUserController extends BaseController {
|
||||
* 获取用户列表
|
||||
*/
|
||||
@ApiOperation("获取用户分页列表")
|
||||
@PreAuthorize("@ss.hasPermi('system:user:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('system:user:list,iot:project:list,iot:device:list,iot:push:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysUser user) {
|
||||
startPage();
|
||||
@ -245,7 +245,7 @@ public class SysUserController extends BaseController {
|
||||
* 获取部门树列表
|
||||
*/
|
||||
@ApiOperation("获取部门树列表")
|
||||
@PreAuthorize("@ss.hasAnyPermi('system:user:list,iot:device:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('system:user:list,iot:device:list,dataCenter:history:list,iot:project:list')")
|
||||
@GetMapping("/deptTree")
|
||||
public AjaxResult deptTree(SysDept dept) {
|
||||
return success(deptService.selectDeptTreeList(dept));
|
||||
|
||||
@ -41,7 +41,7 @@ public class NotifyTemplateController extends BaseController {
|
||||
/**
|
||||
* 查询通知模版列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('notify:template:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('notify:template:list,iot:alert:list,iot:push:list')")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询通知模版列表")
|
||||
public TableDataInfo list(NotifyTemplate notifyTemplate) {
|
||||
@ -66,7 +66,7 @@ public class NotifyTemplateController extends BaseController {
|
||||
/**
|
||||
* 获取通知模版详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('notify:template:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('notify:template:query,iot:alert:list,iot:push:list')")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiOperation("获取通知模版详细信息")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
@ -109,7 +109,7 @@ public class NotifyTemplateController extends BaseController {
|
||||
/**
|
||||
* 获取消息通知模版参数信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('notify:template:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('notify:template:query,iot:alert:list,iot:push:list')")
|
||||
@GetMapping(value = "/msgParams")
|
||||
@ApiOperation("获取模板参数配置")
|
||||
public AjaxResult msgParams(Long channelId, String msgType) {
|
||||
@ -120,7 +120,7 @@ public class NotifyTemplateController extends BaseController {
|
||||
/**
|
||||
* 获取通知模版详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('notify:template:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('notify:template:query,iot:alert:list,iot:push:list')")
|
||||
@GetMapping(value = "/getUsable")
|
||||
@ApiOperation("获取同一业务的模板是否有可用的")
|
||||
public AjaxResult getUsable(NotifyTemplate notifyTemplate) {
|
||||
@ -142,7 +142,7 @@ public class NotifyTemplateController extends BaseController {
|
||||
/**
|
||||
* 获取消息通知模版参数变量
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('notify:template:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('notify:template:query,iot:alert:list,iot:push:list')")
|
||||
@GetMapping(value = "/listVariables")
|
||||
@ApiOperation("获取模板内容变量")
|
||||
public AjaxResult listVariables(Long id, String channelType, String provider) {
|
||||
|
||||
@ -58,7 +58,7 @@ public class DataCenterController {
|
||||
* @return com.fastbee.common.core.domain.AjaxResult
|
||||
*/
|
||||
@ApiOperation("查询设备的历史数据")
|
||||
@PreAuthorize("@ss.hasPermi('dataCenter:history:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('dataCenter:history:list,iot:device:list')")
|
||||
@PostMapping("/deviceHistory")
|
||||
public AjaxResult deviceHistory(@RequestBody DeviceHistoryParam deviceHistoryParam) {
|
||||
if (StringUtils.isEmpty(deviceHistoryParam.getSerialNumber())) {
|
||||
@ -134,7 +134,7 @@ public class DataCenterController {
|
||||
}
|
||||
|
||||
@ApiOperation("网关计算物模型历史(查询时按公式计算,按分钟对齐,缺数沿用上一分钟)")
|
||||
@PreAuthorize("@ss.hasPermi('dataCenter:history:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('dataCenter:history:list,iot:device:list')")
|
||||
@PostMapping("/deviceHistoryCalculated")
|
||||
public AjaxResult deviceHistoryCalculated(@RequestBody DeviceHistoryParam deviceHistoryParam) {
|
||||
if (deviceHistoryParam.getDeviceId() == null || StringUtils.isEmpty(deviceHistoryParam.getSerialNumber())) {
|
||||
@ -217,14 +217,14 @@ public class DataCenterController {
|
||||
}
|
||||
|
||||
@ApiOperation("网关设备仅计算物模型列表(历史记录-网关计算量 变量下拉用)")
|
||||
@PreAuthorize("@ss.hasPermi('dataCenter:history:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('dataCenter:history:list,iot:device:list')")
|
||||
@GetMapping("/gatewayCalculatedModels")
|
||||
public AjaxResult listGatewayCalculatedModels(@RequestParam Long deviceId) {
|
||||
return AjaxResult.success(dataCenterService.listGatewayCalculatedModels(deviceId));
|
||||
}
|
||||
|
||||
@ApiOperation("多设备对比历史(支持多变量,按分钟对齐,缺数沿用上一分钟)")
|
||||
@PreAuthorize("@ss.hasPermi('dataCenter:history:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('dataCenter:history:list,iot:device:list')")
|
||||
@PostMapping("/subDeviceComparativeHistory")
|
||||
public AjaxResult subDeviceComparativeHistory(@RequestBody SubDeviceCompareParam param) {
|
||||
boolean hasIdentifier = (param.getIdentifierList() != null && !param.getIdentifierList().isEmpty())
|
||||
@ -292,7 +292,7 @@ public class DataCenterController {
|
||||
}
|
||||
|
||||
@ApiOperation("查询场景变量历史数据")
|
||||
@PreAuthorize("@ss.hasPermi('dataCenter:history:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('dataCenter:history:list,iot:device:list,scene:model:list')")
|
||||
@GetMapping("/sceneHistory")
|
||||
public AjaxResult sceneHistory(SceneHistoryParam sceneHistoryParam) {
|
||||
if (StringUtils.isNotEmpty(sceneHistoryParam.getSerialNumber())) {
|
||||
|
||||
@ -107,7 +107,7 @@ public class DeviceController extends BaseController {
|
||||
/**
|
||||
* 查询设备简短列表,主页列表数据
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:device:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:device:list,iot:scene:list,dataCenter:history:list,dataCenter:analysis:list,dataCenter:repair:list')")
|
||||
@GetMapping("/shortList")
|
||||
@ApiOperation("设备分页简短列表")
|
||||
public TableDataInfo shortList(Device device) {
|
||||
@ -382,6 +382,23 @@ public class DeviceController extends BaseController {
|
||||
return deviceService.assignment(deptId, deviceIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 超级管理员将设备分配给指定用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:device:assignment')")
|
||||
@ApiOperation("超级管理员分配设备给指定用户")
|
||||
@PostMapping("/assignUser")
|
||||
public AjaxResult assignUser(@RequestParam("deviceId") Long deviceId,
|
||||
@RequestParam("userId") Long userId) {
|
||||
if (null == deviceId) {
|
||||
return error(MessageUtils.message("device.id.null"));
|
||||
}
|
||||
if (null == userId) {
|
||||
return error(MessageUtils.message("device.user.id.null"));
|
||||
}
|
||||
return deviceService.assignUser(deviceId, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回收设备
|
||||
*
|
||||
@ -424,7 +441,7 @@ public class DeviceController extends BaseController {
|
||||
/**
|
||||
* 查询变量概况
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:device:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:device:query,iot:device:list,dataCenter:history:list,dataCenter:analysis:list,dataCenter:repair:list')")
|
||||
@GetMapping("/listThingsModel")
|
||||
@ApiOperation("查询变量概况")
|
||||
public TableDataInfo listThingsModel(Integer pageNum, Integer pageSize, Long deviceId, String modelName, Integer type) {
|
||||
|
||||
@ -34,7 +34,7 @@ public class GroupController extends BaseController {
|
||||
/**
|
||||
* 查询设备分组列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:group:list,iot:device:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:group:list,iot:device:list,dataCenter:history:list,iot:project:list')")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("分组分页列表")
|
||||
public TableDataInfo list(Group group) {
|
||||
@ -58,7 +58,7 @@ public class GroupController extends BaseController {
|
||||
/**
|
||||
* 获取设备分组详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:group:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:group:query,iot:device:list,dataCenter:history:list,iot:project:list')")
|
||||
@GetMapping(value = "/{groupId}")
|
||||
@ApiOperation("获取分组详情")
|
||||
public AjaxResult getInfo(@PathVariable("groupId") Long groupId) {
|
||||
@ -68,7 +68,7 @@ public class GroupController extends BaseController {
|
||||
/**
|
||||
* 获取分组下的所有关联设备ID数组
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:group:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:group:query,iot:device:list,dataCenter:history:list,iot:project:list')")
|
||||
@GetMapping(value = "/getDeviceIds/{groupId}")
|
||||
@ApiOperation("获取分组下的所有关联设备ID数组")
|
||||
public AjaxResult getDeviceIds(@PathVariable("groupId") Long groupId) {
|
||||
|
||||
@ -44,7 +44,7 @@ public class ThingsModelController extends BaseController {
|
||||
/**
|
||||
* 查询物模型列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:model:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:model:list,iot:device:list')")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("产品物模型分页列表")
|
||||
public TableDataInfo list(ThingsModel thingsModel) {
|
||||
@ -56,7 +56,7 @@ public class ThingsModelController extends BaseController {
|
||||
/**
|
||||
* 查询物模型列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:model:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:model:list,iot:device:list')")
|
||||
@GetMapping("/listByProductIdAndSerialNumber")
|
||||
@ApiOperation("产品物模型分页列表(根据产品ID和设备编号查询)")
|
||||
public TableDataInfo listByProductIdAndSerialNumber(@RequestParam("productId") Long productId,
|
||||
@ -80,7 +80,7 @@ public class ThingsModelController extends BaseController {
|
||||
/**
|
||||
* 获取物模型详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:model:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:model:query,iot:device:list')")
|
||||
@GetMapping(value = "/{modelId}")
|
||||
@ApiOperation("获取产品物模型详情")
|
||||
public AjaxResult getInfo(@PathVariable("modelId") Long modelId) {
|
||||
@ -150,7 +150,7 @@ public class ThingsModelController extends BaseController {
|
||||
/**
|
||||
* 获取缓存的JSON物模型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:model:query,iot:device:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:model:query,iot:device:list,iot:scene:list')")
|
||||
@GetMapping(value = "/cache/{productId}")
|
||||
@ApiOperation("获取缓存的JSON物模型")
|
||||
public AjaxResult getCacheThingsModelByProductId(@PathVariable("productId") Long productId) {
|
||||
@ -182,7 +182,7 @@ public class ThingsModelController extends BaseController {
|
||||
/**
|
||||
* 获取modbus配置可选择物模型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:model:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:model:list,iot:device:list')")
|
||||
@GetMapping("/listModbus")
|
||||
@ApiOperation("获取modbus配置可选择物模型")
|
||||
public TableDataInfo listModbus(Long productId) {
|
||||
@ -195,7 +195,7 @@ public class ThingsModelController extends BaseController {
|
||||
/**
|
||||
* 根据设备获取可读写物模型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:model:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:model:list,iot:device:list')")
|
||||
@GetMapping("/write")
|
||||
@ApiOperation("根据设备获取可读写物模型")
|
||||
public TableDataInfo write(Long deviceId) {
|
||||
|
||||
@ -34,7 +34,7 @@ public class EventLogController extends BaseController {
|
||||
* 查询事件日志列表
|
||||
*/
|
||||
@ApiOperation("查询事件日志列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:event:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:event:list,iot:device:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(EventLog eventLog) {
|
||||
startPage();
|
||||
@ -59,7 +59,7 @@ public class EventLogController extends BaseController {
|
||||
* 获取事件日志详细信息
|
||||
*/
|
||||
@ApiOperation("获取事件日志详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('iot:event:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:event:query,iot:device:list')")
|
||||
@GetMapping(value = "/{logId}")
|
||||
public AjaxResult getInfo(@PathVariable("logId") Long logId) {
|
||||
return success(eventLogService.getById(logId));
|
||||
|
||||
@ -34,7 +34,7 @@ public class FunctionLogController extends BaseController {
|
||||
* 查询设备服务下发日志列表
|
||||
*/
|
||||
@ApiOperation("查询设备服务下发日志列表")
|
||||
@PreAuthorize("@ss.hasPermi('iot:log:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:log:list,iot:device:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(FunctionLog functionLog) {
|
||||
startPage();
|
||||
@ -59,7 +59,7 @@ public class FunctionLogController extends BaseController {
|
||||
* 获取设备服务下发日志详细信息
|
||||
*/
|
||||
@ApiOperation("获取设备服务下发日志详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('iot:log:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:log:query,iot:device:list')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(functionLogService.selectFunctionLogById(id));
|
||||
|
||||
@ -32,7 +32,7 @@ public class SubGatewayController extends BaseController {
|
||||
/**
|
||||
* 查询网关与子设备关联列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('sub:gateway:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('sub:gateway:list,iot:device:list,dataCenter:history:list')")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询网关与子设备关联列表")
|
||||
public TableDataInfo list(SubGateway gateway) {
|
||||
@ -44,7 +44,7 @@ public class SubGatewayController extends BaseController {
|
||||
/**
|
||||
* 获取网关与子设备关联详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('sub:gateway:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('sub:gateway:query,iot:device:list,dataCenter:history:list')")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiOperation("获取网关与子设备关联详细信息")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
@ -84,7 +84,7 @@ public class SubGatewayController extends BaseController {
|
||||
/**
|
||||
* 获取可选择的网关子设备列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('sub:gateway:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('sub:gateway:query,iot:device:list')")
|
||||
@GetMapping(value = "/subDevice")
|
||||
@ApiOperation("获取可选择的网关子设备列表")
|
||||
public TableDataInfo subDevice(GateSubDeviceVO subDeviceVO) {
|
||||
|
||||
@ -33,7 +33,7 @@ public class PlatformDeviceMappingController extends BaseController {
|
||||
return getDataTable(mappingService.selectList(query));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('platform:deviceMapping:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('platform:deviceMapping:query,platform:deviceMapping:list')")
|
||||
@GetMapping("/{id}")
|
||||
@ApiOperation("获取设备绑定详情")
|
||||
public AjaxResult getInfo(@PathVariable Long id) {
|
||||
@ -75,7 +75,7 @@ public class PlatformDeviceMappingController extends BaseController {
|
||||
|
||||
// ==================== 子映射管理 ====================
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('platform:deviceMapping:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('platform:deviceMapping:query,platform:deviceMapping:list')")
|
||||
@GetMapping("/{id}/sub-mappings")
|
||||
@ApiOperation("查询子设备映射列表")
|
||||
public AjaxResult listSubMappings(@PathVariable Long id) {
|
||||
|
||||
@ -31,7 +31,7 @@ public class BridgeController extends BaseController {
|
||||
/**
|
||||
* 查询数据桥接列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:bridge:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:bridge:list,iot:scene:list')")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询数据桥接列表")
|
||||
public TableDataInfo list(Bridge bridge) {
|
||||
@ -55,7 +55,7 @@ public class BridgeController extends BaseController {
|
||||
/**
|
||||
* 获取数据桥接详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:bridge:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('iot:bridge:query,iot:scene:list')")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiOperation("获取数据桥接详细信息")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
|
||||
@ -33,7 +33,7 @@ public class SceneModelController extends BaseController {
|
||||
/**
|
||||
* 查询场景管理列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyPermi('scene:model:list,iot:device:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('scene:model:list,iot:device:list,dataCenter:history:list')")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询场景管理列表")
|
||||
public TableDataInfo list(SceneModel sceneModel) {
|
||||
@ -58,7 +58,7 @@ public class SceneModelController extends BaseController {
|
||||
/**
|
||||
* 获取场景管理详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('scene:model:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('scene:model:query,scene:model:list,dataCenter:history:list')")
|
||||
@GetMapping(value = "/{sceneModelId}")
|
||||
@ApiOperation("获取场景管理详细信息")
|
||||
public AjaxResult getInfo(@PathVariable("sceneModelId") Long sceneModelId) {
|
||||
|
||||
@ -37,7 +37,7 @@ public class SceneModelDataController extends BaseController {
|
||||
/**
|
||||
* 查询所有变量列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('scene:modelData:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('scene:modelData:list,scene:model:list,dataCenter:history:list')")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询所有变量列表")
|
||||
public TableDataInfo list(SceneModelData sceneModelData) {
|
||||
@ -55,7 +55,7 @@ public class SceneModelDataController extends BaseController {
|
||||
/**
|
||||
* 查询关联设备变量的列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('scene:modelDeviceData:list')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('scene:modelDeviceData:list,scene:model:list,dataCenter:history:list,iot:scene:list')")
|
||||
@GetMapping("/listByType")
|
||||
@ApiOperation("查询关联设备变量的列表")
|
||||
public TableDataExtendInfo listByType(SceneModelData sceneModelData) {
|
||||
@ -82,7 +82,7 @@ public class SceneModelDataController extends BaseController {
|
||||
/**
|
||||
* 获取【请填写功能名称】详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('scene:modelData:query')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('scene:modelData:query,scene:model:list,dataCenter:history:list')")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiOperation("获取场景变量详情")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
|
||||
@ -96,16 +96,15 @@ public class PubMqttCallBack implements MqttCallbackExtended {
|
||||
@Override
|
||||
public void connectComplete(boolean reconnect, String serverURI) {
|
||||
log.info("MQTT内部客户端已经连接!");
|
||||
System.out.print("" +
|
||||
" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n" +
|
||||
" * _⚲_⚲_ ______ _ ____ * \n" +
|
||||
" * | / \\ | | ____| | | | _ \\ * \n" +
|
||||
" * | | | ● | | | | |__ __ _ ___| |_ | |_) | ___ ___ * \n" +
|
||||
" * | \\ / | | __/ _` / __| __| | _ < / _ \\/ _ \\ * \n" +
|
||||
" * \\ / | | | (_| \\__ \\ |_ | |_) | __/ __/ * \n" +
|
||||
" * V |_| \\__,_|___/\\__| |____/ \\___|\\___| * \n" +
|
||||
" * * \n" +
|
||||
" * * * * * * * * * * * * FastBee物联网平台[✔启动成功] * * * * * * * * * * * * \n");
|
||||
System.out.print(
|
||||
"▌▌▌▌ ▌▌▌▌ ▌▌▌▌▌▌ ▍▌▌▌▌▍ ▌▌▌ ▌▌▌▌ ▌▌▌▌▌▍ ▌▌▌▌\n" +
|
||||
" ▌▌▌▌▎▌▌▌▌ ▌▌▌ ▌▌▌ ▍▌▌▌▌▌▌▎ ▌▌▌ ▌▌▌▎▌▌ ▌▌▌▌▌▌▌ ▌▌▌▌\n" +
|
||||
" ▌▌▌▌▌▌ ▌▌▌▌ ▌▌▌ ▍▌▌▌▏▌▌▌▌ ▌▌▌ ▌▌▌ ▌▌▌ ▌▌▌▌▌▌▌▌ ▌▌▌▌\n" +
|
||||
" ▌▌▌▍ ▌▌▌▍▍▍▌▌▌▌ ▌▌▌▌ ▌▌▌▌▌▌▌ ▌▌▌▌▍▍▍▌▌▌ ▌▌▌▌ ▌▌▌▌▌▌▌▌\n" +
|
||||
" ▌▌▌▏ ▌▌▌▌▌▌▌▌▌▌▌▌ ▌▌▌▌ ▌▌▌▌▌▌ ▌▌▌▌▌▌▌▌▌▌▌▌ ▌▌▌▌ ▌▌▌▌▌▌\n" +
|
||||
" ▌▌▌▏ ▌▌▌▌ ▌▌▌▌ ▌▌▌▌ ▌▌▌▌▌ ▌▌▌▌ ▌▌▌▌ ▌▌▌▌ ▌▌▌▌▌"
|
||||
);
|
||||
|
||||
|
||||
//连接后订阅, enable为false表示使用emq
|
||||
if (!enabled) {
|
||||
|
||||
@ -356,6 +356,11 @@ public interface DeviceMapper extends BaseMapperX<Device> {
|
||||
*/
|
||||
int updateTenantIdByDeptIds(@Param("tenantId") Long tenantId, @Param("tenantName") String tenantName, @Param("deviceIdList") List<Long> deviceIdList);
|
||||
|
||||
/**
|
||||
* 更新单个设备所属用户
|
||||
*/
|
||||
int updateTenantIdByDeviceId(@Param("tenantId") Long tenantId, @Param("tenantName") String tenantName, @Param("deviceId") Long deviceId);
|
||||
|
||||
/**
|
||||
* 查询终端用户设备简短列表,主页列表数据
|
||||
*/
|
||||
|
||||
@ -354,6 +354,15 @@ public interface IDeviceService {
|
||||
*/
|
||||
AjaxResult assignment(Long deptId, String deviceIds);
|
||||
|
||||
/**
|
||||
* 超级管理员将设备分配给指定用户
|
||||
*
|
||||
* @param deviceId 设备id
|
||||
* @param userId 用户id
|
||||
* @return com.fastbee.common.core.domain.AjaxResult
|
||||
*/
|
||||
AjaxResult assignUser(Long deviceId, Long userId);
|
||||
|
||||
/**
|
||||
* 回收设备
|
||||
*
|
||||
|
||||
@ -2113,6 +2113,40 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
return result > 0 ? AjaxResult.success("分配设备成功") : AjaxResult.error("分配设备失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult assignUser(Long deviceId, Long userId) {
|
||||
if (!Objects.equals(SecurityUtils.getUserId(), 1L)) {
|
||||
return AjaxResult.error("只有超级管理员可以分配设备");
|
||||
}
|
||||
Device device = deviceMapper.selectDeviceByDeviceId(deviceId);
|
||||
if (null == device) {
|
||||
return AjaxResult.error("设备不存在");
|
||||
}
|
||||
SysUser targetUser = userService.selectUserById(userId);
|
||||
if (null == targetUser) {
|
||||
return AjaxResult.error("用户不存在");
|
||||
}
|
||||
int result = deviceMapper.updateTenantIdByDeviceId(targetUser.getUserId(), targetUser.getUserName(), deviceId);
|
||||
if (result > 0) {
|
||||
SysUser currSysUser = getLoginUser().getUser();
|
||||
DeviceRecord deviceRecord = new DeviceRecord();
|
||||
deviceRecord.setOperateDeptId(currSysUser.getDeptId())
|
||||
.setTargetDeptId(targetUser.getDeptId())
|
||||
.setDeviceId(device.getDeviceId())
|
||||
.setProductId(device.getProductId())
|
||||
.setSerialNumber(device.getSerialNumber())
|
||||
.setType(DeviceRecordTypeEnum.ASSIGNMENT_DETAIL.getType())
|
||||
.setDistributeType(DeviceDistributeTypeEnum.SELECT.getType())
|
||||
.setTenantId(device.getTenantId())
|
||||
.setTenantName(device.getTenantName())
|
||||
.setStatus(StatusEnum.SUCCESS.getStatus())
|
||||
.setCreateBy(currSysUser.getUserName());
|
||||
deviceRecordMapper.insertDeviceRecord(deviceRecord);
|
||||
return AjaxResult.success("分配设备成功");
|
||||
}
|
||||
return AjaxResult.error("分配设备失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult recovery(String deviceIds, Long recoveryDeptId) {
|
||||
SysUser currSysUser = getLoginUser().getUser();
|
||||
|
||||
@ -1033,6 +1033,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateTenantIdByDeviceId">
|
||||
update iot_device
|
||||
set tenant_id = #{tenantId},
|
||||
tenant_name = #{tenantName},
|
||||
update_time = now()
|
||||
where device_id = #{deviceId}
|
||||
</update>
|
||||
|
||||
<select id="selectDeviceByChannelId" resultMap="DeviceResult">
|
||||
select device_name,device_id from iot_device
|
||||
where channel_id = #{channelId}
|
||||
|
||||
@ -84,6 +84,15 @@ export function distributionDevice(deptId, deviceIds) {
|
||||
method: 'post',
|
||||
});
|
||||
}
|
||||
|
||||
// 超级管理员分配设备给指定用户
|
||||
export function assignDeviceUser(deviceId, userId) {
|
||||
return request({
|
||||
url: '/iot/device/assignUser',
|
||||
method: 'post',
|
||||
params: { deviceId, userId },
|
||||
});
|
||||
}
|
||||
//回收设备
|
||||
export function recycleDevice(deviceIds, recoveryDeptId) {
|
||||
return request({
|
||||
|
||||
@ -31,7 +31,11 @@
|
||||
<span style="color: red;">*</span>
|
||||
{{ $t('device.device-edit.tenant') }}
|
||||
</template>
|
||||
<el-input v-model="form.tenantName" disabled />
|
||||
<el-input v-model="form.tenantName" disabled>
|
||||
<el-button v-if="isSuperAdmin && form.deviceId != 0" slot="append" @click="openAssignUserDialog">
|
||||
分配
|
||||
</el-button>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="" prop="serialNumber">
|
||||
<template slot="label">
|
||||
@ -235,7 +239,7 @@
|
||||
<alert-user ref="alertUser" :device="form"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane name="deviceAlert" :disabled="form.deviceId == 0">
|
||||
<span slot="label" v-hasPermi="['iot:alertLog:list']">{{ $t('device.device-edit.148398-81') }}</span>
|
||||
<span slot="label" v-hasPermi="['iot:alertLog:list', 'iot:device:list']">{{ $t('device.device-edit.148398-81') }}</span>
|
||||
<device-alert ref="deviceAlert" :device="form"/>
|
||||
</el-tab-pane>
|
||||
|
||||
@ -360,6 +364,38 @@
|
||||
<el-button @click="closeSummaryDialog">{{ $t('device.device-edit.148398-57') }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="分配设备" :visible.sync="assignUserOpen" width="800px" append-to-body>
|
||||
<el-form :model="assignUserQuery" ref="assignUserQueryForm" :inline="true" label-width="80px" @submit.native.prevent>
|
||||
<el-form-item label="用户名" prop="userName">
|
||||
<el-input v-model="assignUserQuery.userName" clearable size="small" placeholder="请输入用户名" @keyup.enter.native="handleAssignUserQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号" prop="phonenumber">
|
||||
<el-input v-model="assignUserQuery.phonenumber" clearable size="small" placeholder="请输入手机号" @keyup.enter.native="handleAssignUserQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleAssignUserQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetAssignUserQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table v-loading="assignUserLoading" :data="assignUserList" highlight-current-row size="mini" border @current-change="handleAssignUserChange">
|
||||
<el-table-column label="选择" width="55" align="center">
|
||||
<template slot-scope="scope">
|
||||
<input type="radio" :checked="selectedAssignUser && selectedAssignUser.userId === scope.row.userId" name="assignUser" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="用户ID" align="center" prop="userId" width="90" />
|
||||
<el-table-column label="用户名" align="center" prop="userName" />
|
||||
<el-table-column label="昵称" align="center" prop="nickName" />
|
||||
<el-table-column label="手机号" align="center" prop="phonenumber" width="120" />
|
||||
<el-table-column label="部门" align="center" prop="dept.deptName" />
|
||||
</el-table>
|
||||
<pagination v-show="assignUserTotal > 0" :total="assignUserTotal" :page.sync="assignUserQuery.pageNum" :limit.sync="assignUserQuery.pageSize" @pagination="getAssignUserList" />
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitAssignUser">确定</el-button>
|
||||
<el-button @click="assignUserOpen = false">取消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
@ -399,9 +435,12 @@ import {
|
||||
addDevice,
|
||||
updateDevice,
|
||||
generatorDeviceNum,
|
||||
getMqttConnect
|
||||
getMqttConnect,
|
||||
assignDeviceUser
|
||||
} from '@/api/iot/device';
|
||||
import {getDeviceRunningStatus} from '@/api/iot/device';
|
||||
import {listUser} from '@/api/system/user';
|
||||
import {getUserId} from '@/utils/auth';
|
||||
import {cacheJsonThingsModel} from '@/api/iot/model';
|
||||
import DeviceFunc from '@/views/iot/device/device-functionlog';
|
||||
import RealTimeStatus from '@/views/iot/device/realTime-status';
|
||||
@ -470,6 +509,9 @@ export default {
|
||||
return 0;
|
||||
},
|
||||
},
|
||||
isSuperAdmin() {
|
||||
return Number(getUserId()) === 1;
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -488,6 +530,18 @@ export default {
|
||||
mqttList: [],
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
assignUserOpen: false,
|
||||
assignUserLoading: false,
|
||||
assignUserList: [],
|
||||
assignUserTotal: 0,
|
||||
selectedAssignUser: null,
|
||||
assignUserQuery: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
userName: undefined,
|
||||
phonenumber: undefined,
|
||||
status: 0,
|
||||
},
|
||||
// 设备开始状态
|
||||
oldDeviceStatus: null,
|
||||
deviceId: '',
|
||||
@ -573,6 +627,50 @@ export default {
|
||||
this.mqttUnSubscribe(this.form);
|
||||
},
|
||||
methods: {
|
||||
openAssignUserDialog() {
|
||||
this.assignUserOpen = true;
|
||||
this.selectedAssignUser = null;
|
||||
this.getAssignUserList();
|
||||
},
|
||||
getAssignUserList() {
|
||||
this.assignUserLoading = true;
|
||||
listUser(this.assignUserQuery).then((response) => {
|
||||
this.assignUserList = response.rows;
|
||||
this.assignUserTotal = response.total;
|
||||
this.assignUserLoading = false;
|
||||
}).catch(() => {
|
||||
this.assignUserLoading = false;
|
||||
});
|
||||
},
|
||||
handleAssignUserQuery() {
|
||||
this.assignUserQuery.pageNum = 1;
|
||||
this.getAssignUserList();
|
||||
},
|
||||
resetAssignUserQuery() {
|
||||
this.assignUserQuery = {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
userName: undefined,
|
||||
phonenumber: undefined,
|
||||
status: 0,
|
||||
};
|
||||
this.selectedAssignUser = null;
|
||||
this.getAssignUserList();
|
||||
},
|
||||
handleAssignUserChange(user) {
|
||||
this.selectedAssignUser = user;
|
||||
},
|
||||
submitAssignUser() {
|
||||
if (!this.selectedAssignUser) {
|
||||
this.$modal.msgWarning('请选择用户');
|
||||
return;
|
||||
}
|
||||
assignDeviceUser(this.form.deviceId, this.selectedAssignUser.userId).then(() => {
|
||||
this.$modal.msgSuccess('分配成功');
|
||||
this.assignUserOpen = false;
|
||||
this.getDevice(this.form.deviceId);
|
||||
});
|
||||
},
|
||||
/* 连接Mqtt消息服务器 */
|
||||
async connectMqtt() {
|
||||
if (this.$mqttTool.client == null) {
|
||||
|
||||
@ -271,7 +271,7 @@
|
||||
<alert-user ref="alertUser" :device="form"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane name="deviceAlert" :disabled="form.deviceId == 0">
|
||||
<span slot="label" v-hasPermi="['iot:alertLog:list']">{{ $t('device.device-edit.148398-81') }}</span>
|
||||
<span slot="label" v-hasPermi="['iot:alertLog:list', 'iot:device:list']">{{ $t('device.device-edit.148398-81') }}</span>
|
||||
<device-alert ref="deviceAlert" :device="form"/>
|
||||
</el-tab-pane>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user