change - 异常数据记录中添加传感器树形菜单

main
wenjy 3 years ago
parent c0ed9b8fbc
commit 5a128d1a14

@ -8,6 +8,7 @@ import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.mysql.cj.xdevapi.JsonArray; import com.mysql.cj.xdevapi.JsonArray;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.Ztree;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.BaseAlarmInfo; import com.ruoyi.system.domain.BaseAlarmInfo;
import com.ruoyi.system.domain.BaseAlarmType; import com.ruoyi.system.domain.BaseAlarmType;
@ -240,6 +241,12 @@ public class BaseSensorInfoController extends BaseController {
ajax.put("value",json); ajax.put("value",json);
return ajax; return ajax;
} }
@GetMapping("/getSensorInfoTree")
@ResponseBody
public List<Ztree> getSensorInfoTree(){
return baseSensorInfoService.selectSensorInfoTree();
}
} }
/** /**

@ -2,18 +2,39 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"> <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head> <head>
<th:block th:include="include :: header('异常数据记录列表')" /> <th:block th:include="include :: header('异常数据记录列表')" />
<th:block th:include="include :: layout-latest-css"/>
<th:block th:include="include :: ztree-css"/>
</head> </head>
<body class="gray-bg"> <body class="gray-bg">
<div class="ui-layout-west">
<div class="box box-main">
<div class="box-header">
<div class="box-title">
<i class="fa icon-grid"></i> 传感器
</div>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i
class="fa fa-chevron-up"></i></button>
<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i
class="fa fa-chevron-down"></i></button>
<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新"><i class="fa fa-refresh"></i>
</button>
</div>
</div>
<div class="ui-layout-content">
<div id="tree" class="ztree"></div>
</div>
</div>
</div>
<div class="ui-layout-center">
<div class="container-div"> <div class="container-div">
<div class="row"> <div class="row">
<div class="col-sm-12 search-collapse"> <div class="col-sm-12 search-collapse">
<form id="formId"> <form id="formId">
<div class="select-list"> <div class="select-list">
<input id="sensorId" type="hidden" name="sensorId"/>
<ul> <ul>
<li>
<label>传感器:</label>
<input type="text" name="sensorId"/>
</li>
<li> <li>
<label>报警类型:</label> <label>报警类型:</label>
<input type="text" name="alarmtypeId"/> <input type="text" name="alarmtypeId"/>
@ -53,13 +74,34 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<script th:inline="javascript"> <script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('record:recordAlarm:edit')}]]; var editFlag = [[${@permission.hasPermi('record:recordAlarm:edit')}]];
var removeFlag = [[${@permission.hasPermi('record:recordAlarm:remove')}]]; var removeFlag = [[${@permission.hasPermi('record:recordAlarm:remove')}]];
var prefix = ctx + "record/recordAlarm"; var prefix = ctx + "record/recordAlarm";
$(function() { $(function () {
var panehHidden = false;
if ($(this).width() < 769) {
panehHidden = true;
}
$('body').layout({initClosed: panehHidden, west__size: 185});
// 回到顶部绑定
if ($.fn.toTop !== undefined) {
var opt = {
win: $('.ui-layout-center'),
doc: $('.ui-layout-center')
};
$('#scroll-up').toTop(opt);
}
queryRecordAlarm();
querySensorInfoTree();
});
function queryRecordAlarm() {
var options = { var options = {
url: prefix + "/list", url: prefix + "/list",
createUrl: prefix + "/add", createUrl: prefix + "/add",
@ -97,24 +139,45 @@
{ {
field: 'collectTime', field: 'collectTime',
title: '采集时间' title: '采集时间'
}, }]
/*{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.sensorId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.sensorId + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}*/]
}; };
$.table.init(options); $.table.init(options);
}
function querySensorInfoTree() {
let url = ctx + "base/sensorInfo/getSensorInfoTree";
let options = {
url: url,
expandLevel: 1,
onClick: zOnClick
};
$.tree.init(options);
function zOnClick(event, treeId, treeNode) {
$("#sensorId").val(treeNode.id);
$.table.search();
}
}
$('#btnExpand').click(function () {
$._tree.expandAll(true);
$(this).hide();
$('#btnCollapse').show();
});
$('#btnCollapse').click(function () {
$._tree.expandAll(false);
$(this).hide();
$('#btnExpand').show();
});
$('#btnRefresh').click(function () {
querySensorInfoTree();
}); });
function selectColumns() { function selectColumns() {
var column = $.table.selectColumns('alarmuid'); var column = $.table.selectColumns('alarmuid');
alert(column); alert(column.length);
} }
</script> </script>
</body> </body>

@ -1,6 +1,8 @@
package com.ruoyi.system.mapper; package com.ruoyi.system.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.system.domain.BaseMonitorunitInfo;
import com.ruoyi.system.domain.BaseSensorInfo; import com.ruoyi.system.domain.BaseSensorInfo;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto; import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
@ -68,4 +70,12 @@ public interface BaseSensorInfoMapper
* @return java.util.List<com.ruoyi.system.domain.dto.BaseSensorInfoDto> * @return java.util.List<com.ruoyi.system.domain.dto.BaseSensorInfoDto>
*/ */
public List<BaseSensorInfoDto> selectSensorDataListBySensorType(String sensorType); public List<BaseSensorInfoDto> selectSensorDataListBySensorType(String sensorType);
/**
*
* @author WenJY
* @date 2022/5/3 10:20
* @return java.util.List<com.ruoyi.system.domain.BaseMonitorunitInfo>
*/
public List<BaseMonitorunitInfo> selectSensorInfoTree();
} }

@ -1,6 +1,9 @@
package com.ruoyi.system.service; package com.ruoyi.system.service;
import java.util.List; import java.util.List;
import com.ruoyi.common.core.domain.Ztree;
import com.ruoyi.system.domain.BaseMonitorunitInfo;
import com.ruoyi.system.domain.BaseSensorInfo; import com.ruoyi.system.domain.BaseSensorInfo;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto; import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
@ -78,4 +81,12 @@ public interface IBaseSensorInfoService
* @return java.util.List<com.ruoyi.system.domain.dto.BaseSensorInfoDto> * @return java.util.List<com.ruoyi.system.domain.dto.BaseSensorInfoDto>
*/ */
public List<BaseSensorInfoDto> selectSensorDataListBySensorType(String sensorType); public List<BaseSensorInfoDto> selectSensorDataListBySensorType(String sensorType);
/**
*
* @author WenJY
* @date 2022/5/3 10:20
* @return java.util.List<com.ruoyi.system.domain.BaseMonitorunitInfo>
*/
public List<Ztree> selectSensorInfoTree();
} }

@ -1,12 +1,15 @@
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import com.ruoyi.common.core.domain.Ztree;
import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.BaseMonitorunitInfo;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto; import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -169,4 +172,26 @@ public class BaseSensorInfoServiceImpl implements IBaseSensorInfoService
public List<BaseSensorInfoDto> selectSensorDataListBySensorType(String sensorType) { public List<BaseSensorInfoDto> selectSensorDataListBySensorType(String sensorType) {
return baseSensorInfoMapper.selectSensorDataListBySensorType(sensorType); return baseSensorInfoMapper.selectSensorDataListBySensorType(sensorType);
} }
/**
*
* @author WenJY
* @date 2022/5/3 10:20
* @return java.util.List<com.ruoyi.system.domain.BaseMonitorunitInfo>
*/
@Override
public List<Ztree> selectSensorInfoTree() {
List<BaseMonitorunitInfo> baseMonitorunitInfos = baseSensorInfoMapper.selectSensorInfoTree();
List<Ztree> ztrees = new ArrayList<Ztree>();
for (BaseMonitorunitInfo baseMonitorunitInfo : baseMonitorunitInfos) {
Ztree ztree = new Ztree();
ztree.setId(baseMonitorunitInfo.getMonitorunitId());
ztree.setpId(baseMonitorunitInfo.getParentId());
ztree.setName(baseMonitorunitInfo.getMonitorunitName());
ztree.setTitle(baseMonitorunitInfo.getMonitorunitName());
ztree.setOpen(false);
ztrees.add(ztree);
}
return ztrees;
}
} }

@ -43,6 +43,12 @@
<result property="collectTime" column="CollectTime"/> <result property="collectTime" column="CollectTime"/>
</resultMap> </resultMap>
<resultMap type="BaseMonitorunitInfo" id="BaseMonitorunitInfoResult">
<result property="monitorunitId" column="MonitorUnit_Id" />
<result property="monitorunitName" column="MonitorUnit_Name" />
<result property="parentId" column="Parent_Id" />
</resultMap>
<sql id="selectBaseSensorInfoVo"> <sql id="selectBaseSensorInfoVo">
select ObjId, select ObjId,
EdgeId, EdgeId,
@ -129,6 +135,14 @@
and t2.CollectTime between DATE_FORMAT(now(), '%Y-%m-%d 00:00:00') and DATE_FORMAT(now(), '%Y-%m-%d 23:59:59'); and t2.CollectTime between DATE_FORMAT(now(), '%Y-%m-%d 00:00:00') and DATE_FORMAT(now(), '%Y-%m-%d 23:59:59');
</select> </select>
<select id="selectSensorInfoTree" resultMap="BaseMonitorunitInfoResult">
select MonitorUnit_Id, MonitorUnit_Name, Parent_Id
from base_monitorunit_info
union
select Sensor_Id as MonitorUnit_Id,Sensor_Name as MonitorUnit_Name,MonitorUnit_Id as Parent_Id
from base_sensor_info
</select>
<insert id="insertBaseSensorInfo" parameterType="BaseSensorInfo" useGeneratedKeys="true" keyProperty="objId"> <insert id="insertBaseSensorInfo" parameterType="BaseSensorInfo" useGeneratedKeys="true" keyProperty="objId">
insert into base_sensor_info insert into base_sensor_info
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">

Loading…
Cancel
Save