若依微服务1.2.3

1、设备管理增删改查
dev 1.2.3
xins 1 year ago
parent e4f977911a
commit bfd9bf573b

@ -49,4 +49,10 @@ public class HwDictConstants {
public static final Long ADMINISTRATOR_TENANT_ID = 0L;//金瑞铭租户ID
public static final String DEVICE_TYPE_GATEWAY_DEVICE = "1";//网关设备
public static final String DEVICE_TYPE_GATEWAY_SUB_EQUIPMENT = "2";//网关子设备
public static final String DEVICE_TYPE_DIRECT_CONNECT_DEVICE = "3";//直连设备
}

@ -1,14 +1,22 @@
package com.ruoyi.business.controller;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.business.domain.HwDeviceMode;
import com.ruoyi.business.domain.HwMonitorUnit;
import com.ruoyi.business.domain.HwScene;
import com.ruoyi.business.domain.VO.DeviceModeVo;
import com.ruoyi.business.domain.VO.HwMonitorUnitVo;
import com.ruoyi.business.service.IHwDeviceModeService;
import com.ruoyi.business.service.IHwMonitorUnitService;
import com.ruoyi.business.service.IHwSceneService;
import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysDept;
import com.ruoyi.system.api.domain.SysRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -43,6 +51,13 @@ public class HwDeviceController extends BaseController
@Autowired
private IHwMonitorUnitService hwMonitorUnitService;
@Autowired
private IHwDeviceModeService hwDeviceModeService;
@Autowired
private IHwSceneService hwSceneService;
/**
*
*/
@ -51,7 +66,7 @@ public class HwDeviceController extends BaseController
public TableDataInfo list(HwDevice hwDevice)
{
startPage();
List<HwDevice> list = hwDeviceService.selectHwDeviceList(hwDevice);
List<HwDevice> list = hwDeviceService.selectHwDeviceJoinList(hwDevice);
return getDataTable(list);
}
@ -115,14 +130,56 @@ public class HwDeviceController extends BaseController
}
@RequiresPermissions("business:device:list")
@GetMapping("/getScenes")
public AjaxResult getScenes(HwScene scene)
{
return success(hwSceneService.selectHwSceneList(scene));
}
/**
*
*/
// @RequiresPermissions("business:device:list")
@GetMapping("/monitorUnitTree")
public AjaxResult monitorUnitTree(HwMonitorUnit monitorUnit)
@RequiresPermissions("business:device:list")
@GetMapping(value = {"/monitorUnitTree/", "/monitorUnitTree/{sceneId}"})
public AjaxResult monitorUnitTree(@PathVariable(value = "sceneId", required = false) Long sceneId)
{
HwMonitorUnit queryMonitorUnit = new HwMonitorUnit();
queryMonitorUnit.setSceneId(sceneId);
return success(hwMonitorUnitService.selectMonitorTreeList(queryMonitorUnit));
}
@RequiresPermissions("business:device:list")
@GetMapping(value = {"/getDeviceModes/", "/getDeviceModes/{sceneId}"})
public AjaxResult getDeviceModes(@PathVariable(value = "sceneId", required = false) Long sceneId)
{
HwDeviceMode queryDeviceMode = new HwDeviceMode();
queryDeviceMode.setSceneId(sceneId);
return success(hwDeviceModeService.selectHwDeviceModeList(queryDeviceMode));
}
@RequiresPermissions("business:device:list")
@GetMapping(value = {"/getGatewayDevices/", "/getGatewayDevices/{sceneId}"})
public AjaxResult getGatewayDevices(@PathVariable(value = "sceneId", required = false) Long sceneId)
{
HwDevice queryHwDevice = new HwDevice();
queryHwDevice.setSceneId(sceneId);
queryHwDevice.setDeviceType(HwDictConstants.DEVICE_TYPE_GATEWAY_DEVICE);
return success(hwDeviceService.selectHwDeviceList(queryHwDevice));
}
/**
*
*/
@RequiresPermissions("business:device:edit")
@Log(title = "设备管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeDeviceStatus")
public AjaxResult changeDeviceStatus(@RequestBody HwDevice device)
{
return success(hwMonitorUnitService.selectMonitorTreeList(monitorUnit));
device.setUpdateBy(SecurityUtils.getUsername());
device.setUpdateTime(new Date());
return toAjax(hwDeviceService.updateHwDevice(device));
}
}

@ -16,6 +16,7 @@ import com.ruoyi.common.core.enums.DataTypeEnums;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.RemoteConfigService;
import com.ruoyi.tdengine.api.RemoteTdEngineService;
@ -72,6 +73,7 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
* @return
*/
@Override
@DataScope(tenantAlias = "hdm")
public List<HwDeviceMode> selectHwDeviceModeList(HwDeviceMode hwDeviceMode) {
return hwDeviceModeMapper.selectHwDeviceModeList(hwDeviceMode);
}

@ -16,6 +16,7 @@ import com.ruoyi.common.core.constant.TdEngineConstants;
import com.ruoyi.common.core.enums.DataTypeEnums;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.NumberUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.TdHistorySelectDto;
import com.ruoyi.tdengine.api.domain.TdSelectDto;
@ -48,6 +49,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
*/
@Override
public HwDevice selectHwDeviceByDeviceId(Long deviceId) {
return hwDeviceMapper.selectHwDeviceByDeviceId(deviceId);
}
@ -69,6 +71,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
* @return
*/
@Override
@DataScope(tenantAlias = "hd")
public List<HwDevice> selectHwDeviceList(HwDevice hwDevice) {
return hwDeviceMapper.selectHwDeviceList(hwDevice);
}
@ -93,6 +96,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
@Override
public int insertHwDevice(HwDevice hwDevice) {
hwDevice.setCreateTime(DateUtils.getNowDate());
return hwDeviceMapper.insertHwDevice(hwDevice);
}
@ -233,4 +237,16 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
return devicesMap;
}
/**
* ,join
*
* @param hwDevice
* @return
*/
@Override
@DataScope(tenantAlias = "hd")
public List<HwDevice> selectHwDeviceJoinList(HwDevice hwDevice) {
return hwDeviceMapper.selectHwDeviceJoinList(hwDevice);
}
}

@ -14,6 +14,7 @@ import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.NumberUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.DeviceStatus;
import com.ruoyi.tdengine.api.domain.TdSelectDto;
@ -299,6 +300,7 @@ public class HwMonitorUnitServiceImpl implements IHwMonitorUnitService {
* @return
*/
@Override
@DataScope(tenantAlias = "hmu")
public List<TreeSelectVo> selectMonitorTreeList(HwMonitorUnit hwMonitorUnit) {
List<HwMonitorUnit> hwMonitorUnits = this.selectHwMonitorUnitList(hwMonitorUnit);
return buildMonitorUnitTreeSelect(hwMonitorUnits);

@ -9,6 +9,7 @@ import com.ruoyi.business.domain.HwSceneMode;
import com.ruoyi.business.domain.VO.HwSceneVo;
import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
@ -59,14 +60,8 @@ public class HwSceneServiceImpl implements IHwSceneService {
* @return
*/
@Override
@DataScope(tenantAlias = "hs")
public List<HwScene> selectHwSceneList(HwScene hwScene) {
// LoginUser loginUser = SecurityUtils.getLoginUser();
// SysUser sysUser = loginUser.getSysUser();
// Long tenantId = sysUser.getTenantId();
Long tenantId = 1L;
if (tenantId != 0L) {//如果不是金瑞铭,则只能返回租户自己的场景
hwScene.setTenantId(tenantId);
}
List<HwScene> scenes = hwSceneMapper.selectHwSceneList(hwScene);
boolean defaultFlag = false;
for (HwScene scene : scenes) {

@ -34,6 +34,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="deviceField" column="device_field" />
<result property="tenantId" column="tenant_id" />
<result property="onlineStatus" column="online_status" />
<result property="sceneName" column="scene_name" />
<result property="tenantName" column="tenant_name" />
<result property="deviceModeName" column="device_mode_name" />
<result property="monitorUnitName" column="monitor_unit_name" />
</resultMap>
@ -74,13 +77,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!--以上为监控平台接口所用-->
<sql id="selectHwDeviceVo">
select device_id, device_code, device_name, scene_id, monitor_unit_id, device_type, networking_mode, access_protocol, data_format, releated_device_id, device_mode_id, access_gw_protocol, active_status, device_status, active_time, device_pic, ip_address, area_id, device_location, current_module_version, current_singlechip_version, remark, create_by, create_time, update_by, update_time, device_field, tenant_id, online_status from hw_device
select device_id, device_code, device_name, scene_id, monitor_unit_id, device_type, networking_mode, access_protocol, data_format, releated_device_id, device_mode_id, access_gw_protocol, active_status, device_status, active_time, device_pic, ip_address, area_id, device_location, current_module_version, current_singlechip_version, remark, create_by, create_time, update_by, update_time, device_field, tenant_id, online_status from hw_device hd
</sql>
<select id="selectHwDeviceList" parameterType="HwDevice" resultMap="HwDeviceResult">
<include refid="selectHwDeviceVo"/>
<where>
<if test="deviceCode != null and deviceCode != ''"> and device_code = #{deviceCode}</if>
<if test="deviceCode != null and deviceCode != ''"> and device_code like concat('%', #{deviceCode}, '%')</if>
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
<if test="monitorUnitId != null "> and monitor_unit_id = #{monitorUnitId}</if>
@ -103,6 +106,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deviceField != null and deviceField != ''"> and device_field = #{deviceField}</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="onlineStatus != null and onlineStatus != ''"> and online_status = #{onlineStatus}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
</select>
@ -242,4 +247,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and har.device_id = #{deviceId})
</select>
<select id="selectHwDeviceJoinList" parameterType="HwDevice" resultMap="HwDeviceResult">
select hd.device_id,hd.device_code,hd.device_name,hd.device_type,
hd.tenant_id,hd.scene_id,hd.monitor_unit_id,hd.device_mode_id,hd.active_status,
hd.active_time,hd.device_status,hd.online_status,
hs.scene_name,hmu.monitor_unit_name,hdmf.device_mode_name,ht.tenant_name
from hw_device hd
left join hw_scene hs on hd.scene_id = hs.scene_id
left join hw_monitor_unit hmu on hd.monitor_unit_id = hmu.monitor_unit_id
left join hw_device_mode hdmf on hd.device_mode_id = hdmf.device_mode_id
left join hw_tenant ht on hd.tenant_id=ht.tenant_id
<where>
<if test="deviceCode != null and deviceCode != ''"> and hd.device_code like concat('%', #{deviceCode}, '%')</if>
<if test="deviceName != null and deviceName != ''"> and hd.device_name like concat('%', #{deviceName}, '%')</if>
<if test="sceneId != null "> and hd.scene_id = #{sceneId}</if>
<if test="monitorUnitId != null "> and hd.monitor_unit_id = #{monitorUnitId}</if>
<if test="deviceType != null and deviceType != ''"> and hd.device_type = #{deviceType}</if>
<if test="deviceModeId != null "> and hd.device_mode_id = #{deviceModeId}</if>
<if test="activeStatus != null and activeStatus != ''"> and hd.active_status = #{activeStatus}</if>
<if test="deviceStatus != null and deviceStatus != ''"> and hd.device_status = #{deviceStatus}</if>
<if test="tenantId != null "> and hd.tenant_id = #{tenantId}</if>
<if test="onlineStatus != null and onlineStatus != ''"> and hd.online_status = #{onlineStatus}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
</select>
</mapper>

@ -67,7 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectHwDeviceModeVo">
select device_mode_id, device_mode_name, tenant_id, scene_id, language_code, gps_flag, device_mode_status, common_flag, mode_classfication, device_mode_pic, data_verify_level, remark, create_by, create_time, update_by, update_time, device_mode_field from hw_device_mode
select device_mode_id, device_mode_name, tenant_id, scene_id, language_code, gps_flag, device_mode_status, common_flag, mode_classfication, device_mode_pic, data_verify_level, remark, create_by, create_time, update_by, update_time, device_mode_field from hw_device_mode hdm
</sql>
<sql id="selectHwDeviceModeParameterVo">
@ -88,6 +88,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deviceModePic != null and deviceModePic != ''"> and device_mode_pic = #{deviceModePic}</if>
<if test="dataVerifyLevel != null and dataVerifyLevel != ''"> and data_verify_level = #{dataVerifyLevel}</if>
<if test="deviceModeField != null and deviceModeField != ''"> and device_mode_field = #{deviceModeField}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
</select>

@ -58,7 +58,7 @@
</resultMap>
<sql id="selectHwMonitorUnitVo">
select monitor_unit_id, monitor_unit_name, scene_id, parent_id, monitor_unit_type_id, area_id, monitor_address, monitor_pic, preserve_time, remark, monitor_unit_status, create_by, create_time, update_by, update_time, monitor_unit_field from hw_monitor_unit
select monitor_unit_id, monitor_unit_name, scene_id, parent_id, monitor_unit_type_id, area_id, monitor_address, monitor_pic, preserve_time, remark, monitor_unit_status, create_by, create_time, update_by, update_time, monitor_unit_field from hw_monitor_unit hmu
</sql>
<sql id="selectHwMonitorUnitJoinScene">
@ -96,14 +96,16 @@
<if test="preserveTime != null "> and preserve_time = #{preserveTime}</if>
<if test="monitorUnitStatus != null "> and monitor_unit_status = #{monitorUnitStatus}</if>
<if test="monitorUnitField != null and monitorUnitField != ''"> and monitor_unit_field = #{monitorUnitField}</if>
</where>
</select>
<!-- 租户数据范围过滤 -->
<!-- todo ${params.tenantDataScope}-->
</where>
</select>
<select id="selectHwMonitorUnitByMonitorUnitId" parameterType="Long" resultMap="HwMonitorUnitResult">
<include refid="selectHwMonitorUnitVo"/>
where monitor_unit_id = #{monitorUnitId}
</select>
<!--查询最子集监控单元以场景进行分组-->
<select id="selectHwMonitorUnitByMonitorUnitId" parameterType="Long" resultMap="HwMonitorUnitResult">
<include refid="selectHwMonitorUnitVo"/>
where monitor_unit_id = #{monitorUnitId}
</select>
<!--查询最子集监控单元以场景进行分组-->
<select id="selectAllNums" resultMap="AllNumsVoResult">
select scene_id,count(*) as sub_sum from
(select monitor_unit_id,scene_id from hw_monitor_unit

@ -87,6 +87,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="testPreserveTime != null "> and test_preserve_time = #{testPreserveTime}</if>
<if test="sceneEnvironment != null and sceneEnvironment != ''"> and scene_environment = #{sceneEnvironment}</if>
<if test="sceneField != null and sceneField != ''"> and scene_field = #{sceneField}</if>
<!-- 租户数据范围过滤 -->
${params.tenantDataScope}
</where>
order by scene_id desc
</select>

@ -1,4 +1,5 @@
import request from '@/utils/request'
import {parseStrEmpty} from "@/utils/ruoyi";
// 查询设备信息列表
export function listDevice(query) {
@ -43,10 +44,52 @@ export function delDevice(deviceId) {
})
}
// 查询场景信息列表供选择使用(例如下拉列表)
export function getScenes(query) {
return request({
url: '/business/device/getScenes',
method: 'get',
params: query
})
}
// 查询监控单元树
export function getMonitorTree() {
export function getMonitorTree(sceneId) {
return request({
url: '/business/device/monitorUnitTree/' + parseStrEmpty(sceneId),
method: 'get'
})
}
// 查询设备模型
export function getDeviceModes(sceneId) {
return request({
url: '/business/device/monitorUnitTree',
url: '/business/device/getDeviceModes/' + parseStrEmpty(sceneId),
method: 'get'
})
}
// 查询网关设备
export function getGatewayDevices(sceneId) {
return request({
url: '/business/device/getGatewayDevices/' + parseStrEmpty(sceneId),
method: 'get'
})
}
// 设备状态修改
export function changeDeviceStatus(deviceId, deviceStatus) {
const data = {
deviceId,
deviceStatus
}
return request({
url: '/business/device/changeDeviceStatus',
method: 'put',
data: data
})
}

@ -43,13 +43,3 @@ export function delScene(sceneId) {
})
}
// 查询场景信息列表供选择使用(例如下拉列表)
export function getScenes(query) {
return request({
url: '/business/scene/getScenes',
method: 'get',
params: query
})
}

@ -17,89 +17,81 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="所属场景" prop="sceneId">
<el-input
v-model="queryParams.sceneId"
placeholder="请输入所属场景"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="所属监控单元" prop="monitorUnitId">
<el-input
v-model="queryParams.monitorUnitId"
placeholder="请输入所属监控单元"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="设备类型" prop="networkingMode">
<el-select v-model="queryParams.deviceType" placeholder="请选择设备类型" clearable>
<el-option
v-for="dict in dict.type.hw_device_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="所属场景" prop="sceneId">
<el-select v-model="queryParams.sceneId" placeholder="请选择" @input="sceneChange">
<el-option
v-for="(scene, index) in scenes"
:key="index"
:label="scene.sceneName"
:value="scene.sceneId"
></el-option>
</el-select>
<el-form-item label="接入协议" prop="accessProtocol">
<el-input
v-model="queryParams.accessProtocol"
placeholder="请输入接入协议"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="数据格式" prop="dataFormat">
<el-input
v-model="queryParams.dataFormat"
placeholder="请输入数据格式"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="监控单元" prop="monitorUnitId">
<treeselect v-model="queryParams.monitorUnitId" :options="editedMonitorUnits" :show-count="true"
placeholder="请选择所属监控单元" :normalizer="normalizer" :flat="true" clearable style="width: 200px;"/>
</el-form-item>
<el-form-item label="设备模型" prop="deviceModeId">
<el-input
v-model="queryParams.deviceModeId"
placeholder="请输入设备模型"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="接入网关协议" prop="accessGwProtocol">
<el-input
v-model="queryParams.accessGwProtocol"
placeholder="请输入接入网关协议"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="设备激活时间" prop="activeTime">
<el-date-picker clearable
v-model="queryParams.activeTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择设备激活时间">
</el-date-picker>
<el-select v-model="queryParams.deviceModeId" placeholder="请选择" clearable>
<el-option
v-for="(editedDeviceMode, index) in editedDeviceModes"
:key="index"
:label="editedDeviceMode.deviceModeName"
:value="editedDeviceMode.deviceModeId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备图片地址" prop="devicePic">
<el-input
v-model="queryParams.devicePic"
placeholder="请输入设备图片地址"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="激活状态" prop="activeStatus">
<el-select v-model="queryParams.activeStatus" placeholder="请选择" clearable>
<el-option
v-for="dict in dict.type.hw_device_active_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="网络地址" prop="ipAddress">
<el-input
v-model="queryParams.ipAddress"
placeholder="请输入网络地址"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="设备状态" prop="deviceStatus">
<el-select v-model="queryParams.deviceStatus" placeholder="请选择" clearable>
<el-option
v-for="dict in dict.type.hw_device_device_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="租户ID" prop="tenantId">
<el-input
v-model="queryParams.tenantId"
placeholder="请输入租户ID"
clearable
@keyup.enter.native="handleQuery"
/>
<el-form-item label="在线状态" prop="onlineStatus">
<el-select v-model="queryParams.onlineStatus" placeholder="请选择" clearable>
<el-option
v-for="dict in dict.type.hw_device_online_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
@ -160,25 +152,42 @@
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="设备编号" align="center" prop="deviceCode"/>
<el-table-column label="设备名称" align="center" prop="deviceName"/>
<el-table-column label="所属场景" align="center" prop="sceneId"/>
<el-table-column label="所属监控单元" align="center" prop="monitorUnitId"/>
<el-table-column label="设备类型" align="center" prop="deviceType"/>
<el-table-column label="联网方式" align="center" prop="networkingMode"/>
<el-table-column label="接入协议" align="center" prop="accessProtocol"/>
<el-table-column label="数据格式" align="center" prop="dataFormat"/>
<el-table-column label="设备模型" align="center" prop="deviceModeId"/>
<el-table-column label="接入网关协议" align="center" prop="accessGwProtocol"/>
<el-table-column label="激活状态" align="center" prop="activeStatus"/>
<el-table-column label="设备状态" align="center" prop="deviceStatus"/>
<el-table-column label="设备类型" align="center" prop="deviceType">
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_device_type" :value="scope.row.deviceType"/>
</template>
</el-table-column>
<el-table-column label="所属租户" align="center" prop="tenantName"/>
<el-table-column label="所属场景" align="center" prop="sceneName"/>
<el-table-column label="监控单元" align="center" prop="monitorUnitName"/>
<el-table-column label="设备模型" align="center" prop="deviceModeName"/>
<el-table-column label="激活状态" align="center" prop="activeStatus">
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_device_active_status" :value="scope.row.activeStatus"/>
</template>
</el-table-column>
<el-table-column label="设备激活时间" align="center" prop="activeTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.activeTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="设备图片地址" align="center" prop="devicePic"/>
<el-table-column label="网络地址" align="center" prop="ipAddress"/>
<el-table-column label="租户" align="center" prop="tenantId"/>
<el-table-column label="在线状态" align="center" prop="onlineStatus"/>
<el-table-column label="设备状态" align="center" prop="deviceStatus">
<template slot-scope="scope">
<el-switch
v-model="scope.row.deviceStatus"
active-value="0"
inactive-value="1"
@change="handleDeviceStatusChange(scope.row)"
></el-switch>
</template>
</el-table-column>
<el-table-column label="在线状态" align="center" prop="onlineStatus">
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_device_online_status" :value="scope.row.onlineStatus"/>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
@ -211,15 +220,26 @@
<!-- 添加或修改设备信息对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="设备编号" prop="deviceCode">
<el-input v-model="form.deviceCode" placeholder="请输入设备编号"/>
<el-input v-model="form.deviceCode" placeholder="请输入设备编号" maxlength="20"/>
</el-form-item>
<el-form-item label="设备名称" prop="deviceName">
<el-input v-model="form.deviceName" placeholder="请输入设备名称"/>
</el-form-item>
<el-form-item label="设备类型" prop="networkingMode">
<el-select v-model="form.deviceType" placeholder="请选择设备类型" @input="deviceTypeChange">
<el-option
v-for="dict in dict.type.hw_device_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="所属场景" prop="sceneId">
<el-select v-model="form.sceneId" placeholder="请选择" :input="getMonitorUnitTree()">
<el-select v-model="form.sceneId" placeholder="请选择" @input="sceneChange">
<el-option
v-for="(scene, index) in scenes"
:key="index"
@ -229,18 +249,13 @@
</el-select>
</el-form-item>
<el-form-item label="所属监控单元" prop="monitorUnitId">
<el-select v-model="form.monitorUnitId" placeholder="请选择" :disabled="disabled">
<el-option
v-for="(monitorUnit, index) in monitorUnits"
:key="index"
:label="monitorUnit.monitorUnitName"
:value="monitorUnit.monitorUnitId"
></el-option>
</el-select>
<el-form-item label="监控单元" prop="monitorUnitId">
<treeselect v-model="form.monitorUnitId" :options="editedMonitorUnits" :show-count="true"
placeholder="请选择所属监控单元" :normalizer="normalizer" :flat="true"/>
</el-form-item>
<el-form-item label="联网方式" prop="networkingMode">
<el-form-item label="联网方式" prop="networkingMode" v-if="deviceVisible">
<el-select v-model="form.networkingMode" placeholder="请选择数据类型">
<el-option
v-for="dict in dict.type.hw_device_networking_mode"
@ -249,23 +264,49 @@
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="接入协议" prop="accessProtocol">
<el-input v-model="form.accessProtocol" placeholder="请输入接入协议"/>
</el-form-item>
<el-form-item label="数据格式" prop="dataFormat">
<el-input v-model="form.dataFormat" placeholder="请输入数据格式"/>
<el-form-item label="接入协议" prop="accessProtocol" v-if="deviceVisible">
<el-select v-model="form.accessProtocol" placeholder="请选择接入协议">
<el-option
v-for="dict in dict.type.hw_device_access_protocol"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="关联设备" prop="releatedDeviceId">
<el-input v-model="form.releatedDeviceId" placeholder="请输入关联设备hw_device表中国的device_id"/>
<el-form-item label="数据格式" prop="dataFormat" v-if="deviceVisible">
<el-select v-model="form.accessProtocol" placeholder="请选择数据格式">
<el-option
v-for="dict in dict.type.hw_device_data_format"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备模型" prop="deviceModeId">
<el-input v-model="form.deviceModeId" placeholder="请输入设备模型"/>
<el-form-item label="关联网关" prop="releatedDeviceId" v-if="subDeviceVisible">
<el-select v-model="form.releatedDeviceId" placeholder="请选择">
<el-option
v-for="(editedGatewayDevice, index) in editedGatewayDevices"
:key="index"
:label="editedGatewayDevice.deviceName"
:value="editedGatewayDevice.deviceId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="接入网关协议" prop="accessGwProtocol">
<el-input v-model="form.accessGwProtocol" placeholder="请输入接入网关协议"/>
<el-form-item label="设备模型" prop="deviceModeId" v-if="subDeviceVisible">
<el-select v-model="form.deviceModeId" placeholder="请选择">
<el-option
v-for="(editedDeviceMode, index) in editedDeviceModes"
:key="index"
:label="editedDeviceMode.deviceModeName"
:value="editedDeviceMode.deviceModeId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="描述" prop="remark">
@ -324,11 +365,25 @@
</template>
<script>
import {listDevice, getDevice, delDevice, addDevice, updateDevice,getMonitorTree} from "@/api/business/device";
import {getScenes} from "@/api/business/scene";
import {
listDevice,
getDevice,
delDevice,
addDevice,
updateDevice,
getScenes,
getMonitorTree,
getDeviceModes,
getGatewayDevices,
changeDeviceStatus
} from "@/api/business/device";
import {getToken} from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {changeUserStatus} from "@/api/system/user";
export default {
components: {Treeselect},
dicts: ['hw_device_type', 'hw_device_networking_mode', 'hw_device_access_protocol', 'hw_device_data_format', 'hw_device_active_status', 'hw_device_device_status', 'hw_device_online_status'],
name: "Device",
props: {
@ -373,12 +428,27 @@ export default {
deviceList: [],
//
scenes: [],
//
monitorUnits: [],
//
editedMonitorUnits: undefined,
//
editedDeviceModes: [],
//
editedGatewayDevices: [],
subDeviceVisible: false,//
deviceVisible: false,//
DEVICE_TYPE_GATEWAY_DEVICE: "1",//
DEVICE_TYPE_GATEWAY_SUB_EQUIPMENT: "2",//
DEVICE_TYPE_DIRECT_CONNECT_DEVICE: "3",//
DEVICE_ACCESS_PROTOCOL_WIFI: "1",//WIFI
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
@ -409,38 +479,25 @@ export default {
//
rules: {
deviceCode: [
{required: true, message: "设备编号不能为空", trigger: "blur"}
{required: true, message: "设备编号不能为空", trigger: "blur"},
{
pattern: /^[a-z][a-z0-9_]+$/,
message: "2-20个字符由小写字母、数字或下划线组成开头必须为小写字母",
trigger: "blur"
}
],
deviceName: [
{required: true, message: "设备名称不能为空", trigger: "blur"}
],
sceneId: [
{required: true, message: "所属场景关联hw_scene表的scene_id字段不能为空", trigger: "blur"}
{required: true, message: "所属场景不能为空", trigger: "change"}
],
deviceType: [
{required: true, message: "设备类型不能为空", trigger: "change"}
],
networkingMode: [
{required: true, message: "联网方式(1:Wi-Fi2、蜂窝(2G/3G/4G/5G),3、以太网4、其他)不能为空", trigger: "blur"}
],
accessProtocol: [
{required: true, message: "接入协议不能为空", trigger: "blur"}
monitorUnitId: [
{required: true, message: "监控单元不能为空", trigger: "change"}
],
dataFormat: [
{required: true, message: "数据格式不能为空", trigger: "blur"}
],
activeStatus: [
{required: true, message: "激活状态不能为空", trigger: "change"}
],
deviceStatus: [
{required: true, message: "设备状态不能为空", trigger: "change"}
],
tenantId: [
{required: true, message: "租户ID关联hw_tenant的tenant_id不能为空", trigger: "blur"}
],
onlineStatus: [
{required: true, message: "在线状态不能为空", trigger: "change"}
]
},
number: 0,
uploadList: [],
@ -455,9 +512,7 @@ export default {
};
},
created() {
getMonitorTree().then(response => {
alert(JSON.stringify(response.data));
});
this.getList();
getScenes().then(response => {
this.scenes = response.data;
@ -473,11 +528,18 @@ export default {
showTip() {
return this.isShowTip && (this.fileType || this.fileSize);
},
formatRow() {
return (row) => {
// let languages = this.languages;
// for (let i = 0; i < languages.length; i++) {
// if (languages[i].languageCode === row.languageCode) {
// return languages[i].languageName;
// }
// }
};
},
},
methods: {
getMonitorUnitTree(){
},
/** 查询设备信息列表 */
getList() {
this.loading = true;
@ -500,7 +562,7 @@ export default {
deviceName: null,
sceneId: null,
monitorUnitId: null,
deviceType: 2,
deviceType: "2",
networkingMode: null,
accessProtocol: null,
dataFormat: null,
@ -540,15 +602,35 @@ export default {
},
/** 新增按钮操作 */
handleAdd() {
this.fileList = [];
this.reset();
this.subDeviceVisible = true;
this.open = true;
this.title = "添加设备信息";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.fileList = [];
const deviceId = row.deviceId || this.ids
getDevice(deviceId).then(response => {
if (response.data.devicePic != null) {
let previewFile = {};
previewFile.url = response.data.devicePic
this.fileList.push(previewFile);
}
this.getEditedMonitorTree(response.data.sceneId);
if (response.data.deviceType === this.DEVICE_TYPE_GATEWAY_DEVICE || response.data.deviceType === this.DEVICE_TYPE_DIRECT_CONNECT_DEVICE) {
this.subDeviceVisible = false;
this.deviceVisible = true;
} else {
this.subDeviceVisible = true;
this.deviceVisible = false;
this.getEditedDeviceModes(response.data.sceneId);
this.getGatewayDevices(response.data.sceneId);
}
this.form = response.data;
this.open = true;
this.title = "修改设备信息";
@ -560,6 +642,31 @@ export default {
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.deviceType === this.DEVICE_TYPE_GATEWAY_DEVICE || this.form.deviceType === this.DEVICE_TYPE_DIRECT_CONNECT_DEVICE) {
// if(this.form.net)
// networkingMode: [
// {required: true, message: "(1:Wi-Fi2(2G/3G/4G/5G),34)", trigger: "blur"}
// ],
// accessProtocol: [
// {required: true, message: "", trigger: "blur"}
// ],
// dataFormat: [
// {required: true, message: "", trigger: "blur"}
// ],
} else {
if (this.form.releatedDeviceId === null || this.form.releatedDeviceId === undefined
|| this.form.releatedDeviceId === '') {
this.$modal.msgWarning("请选择关联网关");
return;
}
if (this.form.deviceModeId === null || this.form.deviceModeId === undefined
|| this.form.deviceModeId === '') {
this.$modal.msgWarning("请选择设备模型");
return;
}
}
if (this.form.deviceId != null) {
updateDevice(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
@ -634,7 +741,7 @@ export default {
//
handleExceed() {
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} limit!`);
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} !`);
},
//
handleUploadSuccess(res, file) {
@ -691,7 +798,94 @@ export default {
}
}
return strs != '' ? strs.substr(0, strs.length - 1) : '';
}
},
getEditedMonitorTree(sceneId) {
getMonitorTree(sceneId).then(response => {
this.editedMonitorUnits = response.data;
});
},
getEditedDeviceModes(sceneId) {
getDeviceModes(sceneId).then(response => {
this.editedDeviceModes = response.data;
});
},
getGatewayDevices(sceneId) {
getGatewayDevices(sceneId).then(response => {
this.editedGatewayDevices = response.data;
});
},
sceneChange(sceneId) {
this.form.monitorUnitId = null;
this.queryParams.monitorUnitId = null;
this.form.deivceModeId = null;
this.queryParams.deviceModeId = null;
this.getEditedMonitorTree(sceneId);
this.getEditedDeviceModes(sceneId);
this.getGatewayDevices(sceneId);
},
deviceTypeChange(deviceType) {
if (deviceType === this.DEVICE_TYPE_GATEWAY_DEVICE || deviceType === this.DEVICE_TYPE_DIRECT_CONNECT_DEVICE) {
this.form.releatedDeviceId = null;
this.form.deviceModeId = null;
this.form.accessProtocol = this.DEVICE_ACCESS_PROTOCOL_WIFI;
this.form.networkingMode = "1";
this.deviceVisible = true;
this.subDeviceVisible = false;
} else {
this.form.networkingMode = null;
this.form.accessProtocol = null;
this.form.dataFormat = null;
this.subDeviceVisible = true;
this.deviceVisible = false;
}
},
monitorUnitSelect(node) {
if (node.children !== undefined) {
this.form.monitorUnitId = null;
this.$modal.msgWarning("请选择子级监控单元");
}
},
normalizer(node) {
return {
id: node.id,
label: node.label,
children: node.children,
isDisabled: node.children !== undefined
};
// if (!node.children) {
// return {
// id: node.monitorUnitId,
// label: node.monitorUnitName
// };
// }
},
//
handleDeviceStatusChange(row) {
if(row.deviceStatus==='0' && row.activeStatus === '0'){
this.$modal.msgSuccess("激活后才能修改为发布状态");
row.deviceStatus = row.deviceStatus === "0" ? "1" : "0";
return;
}
let text = row.deviceStatus === "1" ? "测试" : "发布";
this.$modal.confirm('确认要改为'+text+'状态吗?').then(function () {
return changeDeviceStatus(row.deviceId, row.deviceStatus);
}).then(() => {
this.$modal.msgSuccess("修改状态成功");
}).catch(function () {
row.deviceStatus = row.deviceStatus === "0" ? "1" : "0";
});
},
}
};
</script>

Loading…
Cancel
Save