Commit 3b37c54f authored by 耿迪迪's avatar 耿迪迪

燃气设备监控配置 gengdidi

parent e4063260
package com.zehong.web.controller.device;
import java.util.List;
import com.zehong.system.domain.form.RelationTMonitorDevice;
import com.zehong.system.domain.form.TMonitorDeviceFrom;
import com.zehong.system.service.ITDeviceInfoService;
import com.zehong.system.service.impl.TPipeServiceImpl;
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.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.TMonitorDevice;
import com.zehong.system.service.ITMonitorDeviceService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;
/**
* 设备监控Controller
*
* @author zehong
* @date 2021-08-05
*/
@RestController
@RequestMapping("/system/device")
public class TMonitorDeviceController extends BaseController
{
@Autowired
private ITMonitorDeviceService tMonitorDeviceService;
@Autowired
private ITDeviceInfoService itDeviceInfoService;
@Autowired
private TPipeServiceImpl tPipeService;
/**
* 查询设备监控列表
*/
@PreAuthorize("@ss.hasPermi('system:device:list')")
@GetMapping("/list")
public TableDataInfo list(TMonitorDevice tMonitorDevice)
{
startPage();
List<TMonitorDevice> list = tMonitorDeviceService.selectTMonitorDeviceList(tMonitorDevice);
for(TMonitorDevice device: list){
device.setDeviceName(itDeviceInfoService.selectTDeviceInfoById(device.getDeviceId().intValue()).getDeviceName());
device.setRelationDeviceName(itDeviceInfoService.selectTDeviceInfoById(device.getRelationDeviceId().intValue()).getDeviceName());
device.setRelationPipeName(tPipeService.selectTPipeById(device.getRelationPipeId().intValue()).getPipeName());
}
return getDataTable(list);
}
/**
* 导出设备监控列表
*/
@PreAuthorize("@ss.hasPermi('system:device:export')")
@Log(title = "设备监控", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TMonitorDevice tMonitorDevice)
{
List<TMonitorDevice> list = tMonitorDeviceService.selectTMonitorDeviceList(tMonitorDevice);
ExcelUtil<TMonitorDevice> util = new ExcelUtil<TMonitorDevice>(TMonitorDevice.class);
return util.exportExcel(list, "设备监控数据");
}
/**
* 获取设备监控详细信息
*/
@PreAuthorize("@ss.hasPermi('system:device:query')")
@GetMapping(value = "/{monitorId}")
public AjaxResult getInfo(@PathVariable("monitorId") Long monitorId)
{
return AjaxResult.success(tMonitorDeviceService.selectTMonitorDeviceById(monitorId));
}
/**
* 新增设备监控
*/
@PreAuthorize("@ss.hasPermi('system:device:add')")
@Log(title = "设备监控", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TMonitorDevice tMonitorDevice)
{
return toAjax(tMonitorDeviceService.insertTMonitorDevice(tMonitorDevice));
}
@PostMapping("/batchAdd")
public AjaxResult batchAdd(@RequestBody TMonitorDeviceFrom tMonitorDeviceFrom){
for(RelationTMonitorDevice relationTMonitorDevice : tMonitorDeviceFrom.getRelationDevices()){
TMonitorDevice tMonitorDevice = new TMonitorDevice();
tMonitorDevice.setDeviceId(tMonitorDeviceFrom.getDeviceId());
tMonitorDevice.setDeviceThreshold(tMonitorDeviceFrom.getDeviceThreshold());
tMonitorDevice.setRelationDeviceId(relationTMonitorDevice.getRelationDeviceId());
tMonitorDevice.setRelationDeviceThreshold(relationTMonitorDevice.getRelationDeviceThreshold());
tMonitorDevice.setRelationPipeId(relationTMonitorDevice.getRelationPipeId());
tMonitorDevice.setRelationPipeThreshold(relationTMonitorDevice.getRelationPipeThreshold());
tMonitorDeviceService.insertTMonitorDevice(tMonitorDevice);
}
return AjaxResult.success();
}
/**
* 修改设备监控
*/
@PreAuthorize("@ss.hasPermi('system:device:edit')")
@Log(title = "设备监控", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TMonitorDevice tMonitorDevice)
{
return toAjax(tMonitorDeviceService.updateTMonitorDevice(tMonitorDevice));
}
/**
* 删除设备监控
*/
@PreAuthorize("@ss.hasPermi('system:device:remove')")
@Log(title = "设备监控", businessType = BusinessType.DELETE)
@DeleteMapping("/{monitorIds}")
public AjaxResult remove(@PathVariable Long[] monitorIds)
{
return toAjax(tMonitorDeviceService.deleteTMonitorDeviceByIds(monitorIds));
}
}
package com.zehong.system.domain;
import java.math.BigDecimal;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
/**
* 设备监控对象 t_monitor_device
*
* @author zehong
* @date 2021-08-05
*/
public class TMonitorDevice extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 设备监控id */
private Long monitorId;
/** 设备id */
@Excel(name = "设备id")
private Long deviceId;
/** 设备阈值 */
@Excel(name = "设备阈值")
private BigDecimal deviceThreshold;
/** 关联管道id */
@Excel(name = "关联管道id")
private Long relationPipeId;
/** 关联管道阈值 */
@Excel(name = "关联管道阈值")
private BigDecimal relationPipeThreshold;
/** 关联设备id */
@Excel(name = "关联设备id")
private Long relationDeviceId;
/** 关联设备阈值 */
@Excel(name = "关联设备阈值")
private BigDecimal relationDeviceThreshold;
private String relationPipeName;
private String deviceName;
private String relationDeviceName;
public String getRelationPipeName() {
return relationPipeName;
}
public void setRelationPipeName(String relationPipeName) {
this.relationPipeName = relationPipeName;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getRelationDeviceName() {
return relationDeviceName;
}
public void setRelationDeviceName(String relationDeviceName) {
this.relationDeviceName = relationDeviceName;
}
public void setMonitorId(Long monitorId)
{
this.monitorId = monitorId;
}
public Long getMonitorId()
{
return monitorId;
}
public void setDeviceId(Long deviceId)
{
this.deviceId = deviceId;
}
public Long getDeviceId()
{
return deviceId;
}
public void setDeviceThreshold(BigDecimal deviceThreshold)
{
this.deviceThreshold = deviceThreshold;
}
public BigDecimal getDeviceThreshold()
{
return deviceThreshold;
}
public void setRelationPipeId(Long relationPipeId)
{
this.relationPipeId = relationPipeId;
}
public Long getRelationPipeId()
{
return relationPipeId;
}
public void setRelationPipeThreshold(BigDecimal relationPipeThreshold)
{
this.relationPipeThreshold = relationPipeThreshold;
}
public BigDecimal getRelationPipeThreshold()
{
return relationPipeThreshold;
}
public void setRelationDeviceId(Long relationDeviceId)
{
this.relationDeviceId = relationDeviceId;
}
public Long getRelationDeviceId()
{
return relationDeviceId;
}
public void setRelationDeviceThreshold(BigDecimal relationDeviceThreshold)
{
this.relationDeviceThreshold = relationDeviceThreshold;
}
public BigDecimal getRelationDeviceThreshold()
{
return relationDeviceThreshold;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("monitorId", getMonitorId())
.append("deviceId", getDeviceId())
.append("deviceThreshold", getDeviceThreshold())
.append("relationPipeId", getRelationPipeId())
.append("relationPipeThreshold", getRelationPipeThreshold())
.append("relationDeviceId", getRelationDeviceId())
.append("relationDeviceThreshold", getRelationDeviceThreshold())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.toString();
}
}
package com.zehong.system.domain.form;
import java.math.BigDecimal;
public class RelationTMonitorDevice {
/** 关联管道id */
private Long relationPipeId;
/** 关联管道阈值 */
private BigDecimal relationPipeThreshold;
/** 关联设备id */
private Long relationDeviceId;
/** 关联设备阈值 */
private BigDecimal relationDeviceThreshold;
public Long getRelationPipeId() {
return relationPipeId;
}
public void setRelationPipeId(Long relationPipeId) {
this.relationPipeId = relationPipeId;
}
public BigDecimal getRelationPipeThreshold() {
return relationPipeThreshold;
}
public void setRelationPipeThreshold(BigDecimal relationPipeThreshold) {
this.relationPipeThreshold = relationPipeThreshold;
}
public Long getRelationDeviceId() {
return relationDeviceId;
}
public void setRelationDeviceId(Long relationDeviceId) {
this.relationDeviceId = relationDeviceId;
}
public BigDecimal getRelationDeviceThreshold() {
return relationDeviceThreshold;
}
public void setRelationDeviceThreshold(BigDecimal relationDeviceThreshold) {
this.relationDeviceThreshold = relationDeviceThreshold;
}
}
package com.zehong.system.domain.form;
import java.math.BigDecimal;
import java.util.List;
public class TMonitorDeviceFrom {
/** 设备id */
private Long deviceId;
/** 设备阈值 */
private BigDecimal deviceThreshold;
private List<RelationTMonitorDevice> relationDevices;
public Long getDeviceId() {
return deviceId;
}
public void setDeviceId(Long deviceId) {
this.deviceId = deviceId;
}
public BigDecimal getDeviceThreshold() {
return deviceThreshold;
}
public void setDeviceThreshold(BigDecimal deviceThreshold) {
this.deviceThreshold = deviceThreshold;
}
public List<RelationTMonitorDevice> getRelationDevices() {
return relationDevices;
}
public void setRelationDevices(List<RelationTMonitorDevice> relationDevices) {
this.relationDevices = relationDevices;
}
}
package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.TMonitorDevice;
/**
* 设备监控Mapper接口
*
* @author zehong
* @date 2021-08-05
*/
public interface TMonitorDeviceMapper
{
/**
* 查询设备监控
*
* @param monitorId 设备监控ID
* @return 设备监控
*/
public TMonitorDevice selectTMonitorDeviceById(Long monitorId);
/**
* 查询设备监控列表
*
* @param tMonitorDevice 设备监控
* @return 设备监控集合
*/
public List<TMonitorDevice> selectTMonitorDeviceList(TMonitorDevice tMonitorDevice);
/**
* 新增设备监控
*
* @param tMonitorDevice 设备监控
* @return 结果
*/
public int insertTMonitorDevice(TMonitorDevice tMonitorDevice);
/**
* 修改设备监控
*
* @param tMonitorDevice 设备监控
* @return 结果
*/
public int updateTMonitorDevice(TMonitorDevice tMonitorDevice);
/**
* 删除设备监控
*
* @param monitorId 设备监控ID
* @return 结果
*/
public int deleteTMonitorDeviceById(Long monitorId);
/**
* 批量删除设备监控
*
* @param monitorIds 需要删除的数据ID
* @return 结果
*/
public int deleteTMonitorDeviceByIds(Long[] monitorIds);
}
package com.zehong.system.service;
import java.util.List;
import com.zehong.system.domain.TMonitorDevice;
/**
* 设备监控Service接口
*
* @author zehong
* @date 2021-08-05
*/
public interface ITMonitorDeviceService
{
/**
* 查询设备监控
*
* @param monitorId 设备监控ID
* @return 设备监控
*/
public TMonitorDevice selectTMonitorDeviceById(Long monitorId);
/**
* 查询设备监控列表
*
* @param tMonitorDevice 设备监控
* @return 设备监控集合
*/
public List<TMonitorDevice> selectTMonitorDeviceList(TMonitorDevice tMonitorDevice);
/**
* 新增设备监控
*
* @param tMonitorDevice 设备监控
* @return 结果
*/
public int insertTMonitorDevice(TMonitorDevice tMonitorDevice);
/**
* 修改设备监控
*
* @param tMonitorDevice 设备监控
* @return 结果
*/
public int updateTMonitorDevice(TMonitorDevice tMonitorDevice);
/**
* 批量删除设备监控
*
* @param monitorIds 需要删除的设备监控ID
* @return 结果
*/
public int deleteTMonitorDeviceByIds(Long[] monitorIds);
/**
* 删除设备监控信息
*
* @param monitorId 设备监控ID
* @return 结果
*/
public int deleteTMonitorDeviceById(Long monitorId);
}
package com.zehong.system.service.impl;
import java.util.List;
import com.zehong.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TMonitorDeviceMapper;
import com.zehong.system.domain.TMonitorDevice;
import com.zehong.system.service.ITMonitorDeviceService;
/**
* 设备监控Service业务层处理
*
* @author zehong
* @date 2021-08-05
*/
@Service
public class TMonitorDeviceServiceImpl implements ITMonitorDeviceService
{
@Autowired
private TMonitorDeviceMapper tMonitorDeviceMapper;
/**
* 查询设备监控
*
* @param monitorId 设备监控ID
* @return 设备监控
*/
@Override
public TMonitorDevice selectTMonitorDeviceById(Long monitorId)
{
return tMonitorDeviceMapper.selectTMonitorDeviceById(monitorId);
}
/**
* 查询设备监控列表
*
* @param tMonitorDevice 设备监控
* @return 设备监控
*/
@Override
public List<TMonitorDevice> selectTMonitorDeviceList(TMonitorDevice tMonitorDevice)
{
return tMonitorDeviceMapper.selectTMonitorDeviceList(tMonitorDevice);
}
/**
* 新增设备监控
*
* @param tMonitorDevice 设备监控
* @return 结果
*/
@Override
public int insertTMonitorDevice(TMonitorDevice tMonitorDevice)
{
tMonitorDevice.setCreateTime(DateUtils.getNowDate());
return tMonitorDeviceMapper.insertTMonitorDevice(tMonitorDevice);
}
/**
* 修改设备监控
*
* @param tMonitorDevice 设备监控
* @return 结果
*/
@Override
public int updateTMonitorDevice(TMonitorDevice tMonitorDevice)
{
tMonitorDevice.setUpdateTime(DateUtils.getNowDate());
return tMonitorDeviceMapper.updateTMonitorDevice(tMonitorDevice);
}
/**
* 批量删除设备监控
*
* @param monitorIds 需要删除的设备监控ID
* @return 结果
*/
@Override
public int deleteTMonitorDeviceByIds(Long[] monitorIds)
{
return tMonitorDeviceMapper.deleteTMonitorDeviceByIds(monitorIds);
}
/**
* 删除设备监控信息
*
* @param monitorId 设备监控ID
* @return 结果
*/
@Override
public int deleteTMonitorDeviceById(Long monitorId)
{
return tMonitorDeviceMapper.deleteTMonitorDeviceById(monitorId);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zehong.system.mapper.TMonitorDeviceMapper">
<resultMap type="TMonitorDevice" id="TMonitorDeviceResult">
<result property="monitorId" column="monitor_id" />
<result property="deviceId" column="device_id" />
<result property="deviceThreshold" column="device_threshold" />
<result property="relationPipeId" column="relation_pipe_id" />
<result property="relationPipeThreshold" column="relation_pipe_threshold" />
<result property="relationDeviceId" column="relation_device_id" />
<result property="relationDeviceThreshold" column="relation_device_threshold" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectTMonitorDeviceVo">
select monitor_id, device_id, device_threshold, relation_pipe_id, relation_pipe_threshold, relation_device_id, relation_device_threshold, create_time, update_time from t_monitor_device
</sql>
<select id="selectTMonitorDeviceList" parameterType="TMonitorDevice" resultMap="TMonitorDeviceResult">
<include refid="selectTMonitorDeviceVo"/>
<where>
<if test="deviceId != null "> and device_id = #{deviceId}</if>
<if test="deviceThreshold != null "> and device_threshold = #{deviceThreshold}</if>
<if test="relationPipeId != null "> and relation_pipe_id = #{relationPipeId}</if>
<if test="relationPipeThreshold != null "> and relation_pipe_threshold = #{relationPipeThreshold}</if>
<if test="relationDeviceId != null "> and relation_device_id = #{relationDeviceId}</if>
<if test="relationDeviceThreshold != null "> and relation_device_threshold = #{relationDeviceThreshold}</if>
</where>
</select>
<select id="selectTMonitorDeviceById" parameterType="Long" resultMap="TMonitorDeviceResult">
<include refid="selectTMonitorDeviceVo"/>
where monitor_id = #{monitorId}
</select>
<insert id="insertTMonitorDevice" parameterType="TMonitorDevice" useGeneratedKeys="true" keyProperty="monitorId">
insert into t_monitor_device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null">device_id,</if>
<if test="deviceThreshold != null">device_threshold,</if>
<if test="relationPipeId != null">relation_pipe_id,</if>
<if test="relationPipeThreshold != null">relation_pipe_threshold,</if>
<if test="relationDeviceId != null">relation_device_id,</if>
<if test="relationDeviceThreshold != null">relation_device_threshold,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null">#{deviceId},</if>
<if test="deviceThreshold != null">#{deviceThreshold},</if>
<if test="relationPipeId != null">#{relationPipeId},</if>
<if test="relationPipeThreshold != null">#{relationPipeThreshold},</if>
<if test="relationDeviceId != null">#{relationDeviceId},</if>
<if test="relationDeviceThreshold != null">#{relationDeviceThreshold},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateTMonitorDevice" parameterType="TMonitorDevice">
update t_monitor_device
<trim prefix="SET" suffixOverrides=",">
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="deviceThreshold != null">device_threshold = #{deviceThreshold},</if>
<if test="relationPipeId != null">relation_pipe_id = #{relationPipeId},</if>
<if test="relationPipeThreshold != null">relation_pipe_threshold = #{relationPipeThreshold},</if>
<if test="relationDeviceId != null">relation_device_id = #{relationDeviceId},</if>
<if test="relationDeviceThreshold != null">relation_device_threshold = #{relationDeviceThreshold},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where monitor_id = #{monitorId}
</update>
<delete id="deleteTMonitorDeviceById" parameterType="Long">
delete from t_monitor_device where monitor_id = #{monitorId}
</delete>
<delete id="deleteTMonitorDeviceByIds" parameterType="String">
delete from t_monitor_device where monitor_id in
<foreach item="monitorId" collection="array" open="(" separator="," close=")">
#{monitorId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
import request from '@/utils/request'
// 查询设备监控列表
export function listDevice(query) {
return request({
url: '/system/device/list',
method: 'get',
params: query
})
}
// 查询设备监控详细
export function getDevice(monitorId) {
return request({
url: '/system/device/' + monitorId,
method: 'get'
})
}
// 新增设备监控
export function addDevice(data) {
return request({
url: '/system/device',
method: 'post',
data: data
})
}
export function batchAdd(data) {
return request({
url: '/system/device/batchAdd',
method: 'post',
data: data
})
}
// 修改设备监控
export function updateDevice(data) {
return request({
url: '/system/device',
method: 'put',
data: data
})
}
// 删除设备监控
export function delDevice(monitorId) {
return request({
url: '/system/device/' + monitorId,
method: 'delete'
})
}
// 导出设备监控
export function exportDevice(query) {
return request({
url: '/system/device/export',
method: 'get',
params: query
})
}
<template>
<div class="add-div" style="width: 100%;height: 100%;padding: 50px;">
<el-row :gutter="20">
<span>新增设备</span>
<el-input placeholder="请输入设备名称" style="width: 300px;margin-left: 20px;"></el-input>
<el-input placeholder="请输入设备阈值" style="width: 300px;margin-left: 50px;"></el-input>
</el-row>
<el-button type="primary" class="el-icon-plus clolos1" @click="addPdfFile" style="margin-top: 20px;margin-bottom: 20px;">新增关联设备</el-button>
<div class="add_pdf" v-for="(item, index) in addPdf" :key="index" style="margin-bottom: 30px;">
<el-form ref="form" :model="form" label-width="80px">
<el-row :gutter="20">
<el-col :span="11" style="float: left;box-shadow: rgb(233, 229, 229) 3px 3px 7px 2px;padding-top: 20px;padding-left: 15px;">
<el-form-item label="关联管道:" prop="pipeCode">
<el-input v-model="form.sss" placeholder="请输入关联管道名称" style="width: 40%;margin-left: 20px;"></el-input>
<el-input v-model="form.aaa" placeholder="请输入关联管道阈值" style="width: 40%;margin-left: 50px;"></el-input>
</el-form-item>
<el-form-item label="关联设备:" prop="pipeCode">
<el-input placeholder="请输入关联设备名称" style="width: 40%;margin-left: 20px;"></el-input>
<el-input placeholder="请输入关联设备阈值" style="width: 40%;margin-left: 50px;"></el-input>
</el-form-item>
</el-col>
<div style="float: left;margin-top: 50px;margin-left: 50px;">
<el-button type="danger" class="el-icon-delete clolos clolos3" @click="deletePdf(index)" circle></el-button>
</div>
</el-row>
</el-form>
<!-- <div v-show="index !== 0"> -->
</div>
<el-form label-width="100px">
<el-form-item style="margin-left:200px;margin-top:40px;">
<el-button type="primary" @click="submitForm()">提交</el-button>
<el-button @click="close()">返回</el-button>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="设备" prop="deviceId">
<el-select v-model="queryParams.deviceId" placeholder="请选择设备">
<el-option
v-for="dict in devices"
:key="dict.deviceId"
:label="dict.deviceName"
:value="dict.deviceId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备阈值" prop="deviceThreshold">
<el-input
v-model="queryParams.deviceThreshold"
placeholder="请输入设备阈值"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="关联管道" prop="relationPipeId">
<el-select v-model="queryParams.relationPipeId" placeholder="请选择关联管道">
<el-option
v-for="dict in pipes"
:key="dict.pipeId"
:label="dict.pipeName"
:value="dict.pipeId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="关联管道阈值" prop="relationPipeThreshold">
<el-input
v-model="queryParams.relationPipeThreshold"
placeholder="请输入关联管道阈值"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="关联设备" prop="relationDeviceId">
<el-select v-model="queryParams.relationDeviceId" placeholder="请选择关联设备">
<el-option
v-for="dict in devices"
:key="dict.deviceId"
:label="dict.deviceName"
:value="dict.deviceId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="关联设备阈值" prop="relationDeviceThreshold">
<el-input
v-model="queryParams.relationDeviceThreshold"
placeholder="请输入关联设备阈值"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</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>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:device:add']"
>新增</el-button>
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="dialogVisible = true"
>批量新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:device:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:device:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
:loading="exportLoading"
@click="handleExport"
v-hasPermi="['system:device:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="deviceList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="设备监控id" align="center" prop="monitorId" />
<el-table-column label="设备" align="center" prop="deviceName" />
<el-table-column label="设备阈值" align="center" prop="deviceThreshold" />
<el-table-column label="关联管道" align="center" prop="relationPipeName" />
<el-table-column label="关联管道阈值" align="center" prop="relationPipeThreshold" />
<el-table-column label="关联设备" align="center" prop="relationDeviceName" />
<el-table-column label="关联设备阈值" align="center" prop="relationDeviceThreshold" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:device:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:device:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改设备监控对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="设备id" prop="deviceId">
<!--<el-input v-model="form.deviceId" placeholder="请输入设备id" />-->
<el-select v-model="form.deviceId" placeholder="请选择设备">
<el-option
v-for="dict in devices"
:key="dict.deviceId"
:label="dict.deviceName"
:value="dict.deviceId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备阈值" prop="deviceThreshold">
<el-input v-model="form.deviceThreshold" placeholder="请输入设备阈值" />
</el-form-item>
<el-form-item label="关联管道id" prop="relationPipeId">
<!--<el-input v-model="form.relationPipeId" placeholder="请输入关联管道id" />-->
<el-select v-model="form.relationPipeId" placeholder="请选择关联管道">
<el-option
v-for="dict in pipes"
:key="dict.pipeId"
:label="dict.pipeName"
:value="dict.pipeId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="关联管道阈值" prop="relationPipeThreshold">
<el-input v-model="form.relationPipeThreshold" placeholder="请输入关联管道阈值" />
</el-form-item>
<el-form-item label="关联设备id" prop="relationDeviceId">
<!-- <el-input v-model="form.relationDeviceId" placeholder="请输入关联设备id" />-->
<el-select v-model="form.relationDeviceId" placeholder="请选择关联设备">
<el-option
v-for="dict in devices"
:key="dict.deviceId"
:label="dict.deviceName"
:value="dict.deviceId"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="关联设备阈值" prop="relationDeviceThreshold">
<el-input v-model="form.relationDeviceThreshold" placeholder="请输入关联设备阈值" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<!--批量新增-->
<el-dialog title="批量新增" :visible.sync="dialogVisible" append-to-body>
<div class="add-div" style="width: 100%;height: 100%;padding: 50px;">
<el-row :gutter="50">
<span>新增设备</span>
<!--<el-input placeholder="请输入设备名称" style="width: 260px;margin-left: 20px;"></el-input>-->
<el-select v-model="subForm.deviceId" placeholder="请选择设备名称">
<el-option
v-for="dict in devices"
:key="dict.deviceId"
:label="dict.deviceName"
:value="dict.deviceId"
></el-option>
</el-select>
<el-input v-model="subForm.deviceThreshold" placeholder="请输入设备阈值" style="width: 260px;margin-left: 50px;"></el-input>
</el-row>
<el-button type="primary" class="el-icon-plus clolos1" @click="addPdfFile" style="margin-top: 20px;margin-bottom: 20px;">新增关联设备</el-button>
<div class="add_pdf" v-for="(item, index) in subForm.relationDevices" :key="index" style="margin-bottom: 30px;">
<el-form :model="item" label-width="80px">
<el-row :gutter="50">
<el-col :span="20" style="float: left;box-shadow: rgb(233, 229, 229) 3px 3px 7px 2px;padding-top: 20px;padding-left: 15px;">
<el-form-item label="关联管道:" prop="pipeCode">
<!--<el-input v-model="item.sss" placeholder="请输入关联管道名称" style="width: 40%;margin-left: 20px;"></el-input>-->
<el-select v-model="item.relationPipeId" placeholder="请选择关联管道名称">
<el-option
v-for="dict in pipes"
:key="dict.pipeId"
:label="dict.pipeName"
:value="dict.pipeId"
></el-option>
</el-select>
<el-input v-model="item.relationPipeThreshold" placeholder="请输入关联管道阈值" style="width: 40%;margin-left: 50px;"></el-input>
</el-form-item>
<el-form-item label="关联设备:" prop="pipeCode">
<!-- <el-input v-model="item.qqq" placeholder="请输入关联设备名称" style="width: 40%;margin-left: 20px;"></el-input>-->
<el-select v-model="item.relationDeviceId" placeholder="请选择关联设备名称">
<el-option
v-for="dict in devices"
:key="dict.deviceId"
:label="dict.deviceName"
:value="dict.deviceId"
></el-option>
</el-select>
<el-input v-model="item.relationDeviceThreshold" placeholder="请输入关联设备阈值" style="width: 40%;margin-left: 50px;"></el-input>
</el-form-item>
</el-col>
<div style="float: left;margin-top: 50px;margin-left: 50px;">
<el-button type="danger" class="el-icon-delete clolos clolos3" @click="deletePdf(index)" circle></el-button>
</div>
</el-row>
</el-form>
<!-- <div v-show="index !== 0"> -->
</div>
<el-form label-width="100px">
<el-form-item style="margin-left:100px;margin-top:40px;">
<el-button type="primary" @click="batchSubmit()">提交</el-button>
<el-button @click="dialogVisible = false">返回</el-button>
</el-form-item>
</el-form>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
data() {
return {
addPdf: [1],
form: {}
};
},
methods:{
addPdfFile(){
this.addPdf.push([]);
import { listDevice, getDevice, delDevice, addDevice, updateDevice, exportDevice, batchAdd } from "@/api/device/deviceMonitor";
import { getAllDeviceInfo } from "@/api/device/deviceInfo";
import { pipeAllInfoList } from "@/api/device/pipe";
export default {
name: "Device",
components: {
},
data() {
return {
// 遮罩层
loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 设备监控表格数据
deviceList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
deviceId: null,
deviceThreshold: null,
relationPipeId: null,
relationPipeThreshold: null,
relationDeviceId: null,
relationDeviceThreshold: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
},
deletePdf(index){
this.addPdf.splice(index,1);
devices: [],
pipes: [],
dialogVisible: false,
subForm:{
relationDevices: [{}]
}
};
},
created() {
this.getList();
this.getAllDeviceInfo();
this.pipeAllInfoList();
},
methods: {
/** 查询设备监控列表 */
getList() {
this.loading = true;
listDevice(this.queryParams).then(response => {
this.deviceList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
monitorId: null,
deviceId: null,
deviceThreshold: null,
relationPipeId: null,
relationPipeThreshold: null,
relationDeviceId: null,
relationDeviceThreshold: null,
createTime: null,
updateTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.monitorId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加设备监控";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const monitorId = row.monitorId || this.ids
getDevice(monitorId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改设备监控";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.monitorId != null) {
updateDevice(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addDevice(this.form).then(response => {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const monitorIds = row.monitorId || this.ids;
this.$confirm('是否确认删除设备监控编号为"' + monitorIds + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delDevice(monitorIds);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有设备监控数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true;
return exportDevice(queryParams);
}).then(response => {
this.download(response.msg);
this.exportLoading = false;
}).catch(() => {});
},
getAllDeviceInfo(){
getAllDeviceInfo().then(response => {
this.devices = response.data;
});
},
pipeAllInfoList(){
pipeAllInfoList().then(res =>{
this.pipes = res.data;
});
},
addPdfFile(){
this.subForm.relationDevices.push({});
},
deletePdf(index){
this.subForm.relationDevices.splice(index,1);
console.log(this.subForm,"fdfdfdfasdfdsf");
},
batchSubmit(){
batchAdd(this.subForm).then(res =>{
this.msgSuccess("新增成功");
this.dialogVisible = false;
this.getList();
});
}
}
};
</script>
<style lang='scss' scoped>
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment