change - 传感器报警设置报警类型选择

main
wenjy 3 years ago
parent 623f9c824c
commit e0d098be20

@ -1,6 +1,10 @@
package com.ruoyi.web.controller.base;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.dto.BaseAlarmInfoDto;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -50,7 +54,7 @@ public class BaseAlarmInfoController extends BaseController
public TableDataInfo list(BaseAlarmInfo baseAlarmInfo)
{
startPage();
List<BaseAlarmInfo> list = baseAlarmInfoService.selectBaseAlarmInfoList(baseAlarmInfo);
List<BaseAlarmInfoDto> list = baseAlarmInfoService.selectBaseAlarmInfoList(baseAlarmInfo);
return getDataTable(list);
}
@ -63,8 +67,8 @@ public class BaseAlarmInfoController extends BaseController
@ResponseBody
public AjaxResult export(BaseAlarmInfo baseAlarmInfo)
{
List<BaseAlarmInfo> list = baseAlarmInfoService.selectBaseAlarmInfoList(baseAlarmInfo);
ExcelUtil<BaseAlarmInfo> util = new ExcelUtil<BaseAlarmInfo>(BaseAlarmInfo.class);
List<BaseAlarmInfoDto> list = baseAlarmInfoService.selectBaseAlarmInfoList(baseAlarmInfo);
ExcelUtil<BaseAlarmInfoDto> util = new ExcelUtil<BaseAlarmInfoDto>(BaseAlarmInfoDto.class);
return util.exportExcel(list, "传感器报警信息数据");
}
@ -86,6 +90,8 @@ public class BaseAlarmInfoController extends BaseController
@ResponseBody
public AjaxResult addSave(BaseAlarmInfo baseAlarmInfo)
{
baseAlarmInfo.setCreateBy(ShiroUtils.getLoginName());
baseAlarmInfo.setCreateTime(new Date());
return toAjax(baseAlarmInfoService.insertBaseAlarmInfo(baseAlarmInfo));
}
@ -95,7 +101,7 @@ public class BaseAlarmInfoController extends BaseController
@GetMapping("/edit/{objId}")
public String edit(@PathVariable("objId") Long objId, ModelMap mmap)
{
BaseAlarmInfo baseAlarmInfo = baseAlarmInfoService.selectBaseAlarmInfoByObjId(objId);
BaseAlarmInfoDto baseAlarmInfo = baseAlarmInfoService.selectBaseAlarmInfoByObjId(objId);
mmap.put("baseAlarmInfo", baseAlarmInfo);
return prefix + "/edit";
}
@ -109,6 +115,8 @@ public class BaseAlarmInfoController extends BaseController
@ResponseBody
public AjaxResult editSave(BaseAlarmInfo baseAlarmInfo)
{
baseAlarmInfo.setUpdateBy(ShiroUtils.getLoginName());
baseAlarmInfo.setUpdateTime(new Date());
return toAjax(baseAlarmInfoService.updateBaseAlarmInfo(baseAlarmInfo));
}

@ -6,6 +6,7 @@
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-alarmInfo-add">
<input name="alarmtypeId" type="hidden" id="treeId"/>
<div class="form-group">
<label class="col-sm-3 control-label">传感器编号:</label>
<div class="col-sm-8">
@ -14,8 +15,14 @@
</div>
<div class="form-group">
<label class="col-sm-3 control-label">报警类型编号:</label>
<div class="col-sm-8">
<!--<div class="col-sm-8">
<input name="alarmtypeId" class="form-control" type="text">
</div>-->
<div class="col-sm-8">
<div class="input-group">
<input class="form-control" type="text" name="treeName" onclick="selectAlarmTypeTree()" id="treeName">
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
</div>
<div class="form-group">
@ -47,11 +54,43 @@
focusCleanup: true
});
$(()=>{
var cp_keynum = "alarmType";
var str = localStorage.getItem(cp_keynum);
var num = JSON.parse(str);
if(num != null) {
$("#treeId").val(num.cp_num_value.substring(0, num.cp_num_value.indexOf('/')));
$("#treeName").val(num.cp_num_value.substring(num.cp_num_value.indexOf('/')+1,num.cp_num_value.length ));
}
})
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-alarmInfo-add').serialize());
}
}
/* 选择报警类型树 */
function selectAlarmTypeTree() {
var deptId = $.common.isEmpty($("#alarmtypeId").val()) ? "100" : $("#alarmtypeId").val();
var url = ctx + "base/alarmType/selectAlarmTypeTree/" + deptId;
var options = {
title: '报警类型',
width: "380",
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var tree = layero.find("iframe")[0].contentWindow.$._tree;
var body = $.modal.getChildFrame(index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
$.modal.close(index);
}
</script>
</body>
</html>

@ -2,22 +2,41 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('传感器报警信息列表')" />
<th:block th:include="include :: layout-latest-css" />
<th:block th:include="include :: ztree-css" />
</head>
<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">
<a type="button" class="btn btn-box-tool" href="#" onclick="alarmTypeInfo()" title="报警类型"><i class="fa fa-edit"></i></a>
<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="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<input id="alarmtypeId" type="hidden" name="alarmtypeId"/>
<div class="select-list">
<ul>
<li>
<label>传感器:</label>
<input type="text" name="sensorId"/>
</li>
<li>
<label>报警类型:</label>
<input type="text" name="alarmtypeId"/>
</li>
<li>
<label>是否启用:</label>
@ -55,14 +74,41 @@
</div>
</div>
</div>
</div>
<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">
var editFlag = [[${@permission.hasPermi('base:alarmInfo:edit')}]];
var removeFlag = [[${@permission.hasPermi('base:alarmInfo:remove')}]];
var enableFlagDatas = [[${@dict.getType('enable_flag')}]];
var prefix = ctx + "base/alarmInfo";
$(()=>{
if(typeof(Storage) == 'undefined'){
alert('对不起,您的浏览器不支持 web 存储。')
}
});
$(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);
}
queryAlarmInfoList();
queryalarmTypeTree();
});
function queryAlarmInfoList() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
@ -79,12 +125,12 @@
visible: false
},
{
field: 'sensorId',
title: '传感器编号'
field: 'sensorName',
title: '传感器'
},
{
field: 'alarmtypeId',
title: '报警类型编号'
field: 'alarmTypeName',
title: '报警类型'
},
{
field: 'maxValue',
@ -101,22 +147,6 @@
return $.table.selectDictLabel(enableFlagDatas, value);
}
},
{
field: 'createBy',
title: '创建人'
},
{
field: 'createTime',
title: '创建时间'
},
{
field: 'updateBy',
title: '更新人'
},
{
field: 'updateTime',
title: '更新时间'
},
{
title: '操作',
align: 'center',
@ -129,7 +159,50 @@
}]
};
$.table.init(options);
}
function queryalarmTypeTree()
{
var url = ctx + "base/alarmType/treeData";
var options = {
url: url,
expandLevel: 2,
onClick : zOnClick
};
$.tree.init(options);
function zOnClick(event, treeId, treeNode) {
$("#alarmtypeId").val(treeNode.id);
$.table.search();
var num = new Object;
num.cp_keynum ="alarmType";
num.cp_num_value = treeNode.id+"/"+treeNode.name;
var str = JSON.stringify(num); // 将对象转换为字符串
localStorage.setItem(num.cp_keynum,str);
}
}
$('#btnExpand').click(function() {
$._tree.expandAll(true);
$(this).hide();
$('#btnCollapse').show();
});
$('#btnCollapse').click(function() {
$._tree.expandAll(false);
$(this).hide();
$('#btnExpand').show();
});
$('#btnRefresh').click(function() {
queryMonitorTree();
});
function alarmTypeInfo() {
var url = ctx + "base/alarmType";
$.modal.openTab("报警类型", url);
}
</script>
</body>
</html>

@ -7,17 +7,29 @@
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-alarmInfo-edit" th:object="${baseAlarmInfo}">
<input name="objId" th:field="*{objId}" type="hidden">
<input name="alarmtypeId" type="hidden" th:field="*{alarmtypeId}" id="treeId"/>
<div class="form-group">
<label class="col-sm-3 control-label">传感器编号:</label>
<div class="col-sm-8">
<input name="sensorId" th:field="*{sensorId}" class="form-control" type="text">
<input name="sensorId" th:field="*{sensorId}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">传感器名称:</label>
<div class="col-sm-8">
<input name="sensorName" th:field="*{sensorName}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">报警类型编号:</label>
<label class="col-sm-3 control-label">报警类型:</label>
<div class="col-sm-8">
<input name="alarmtypeId" th:field="*{alarmtypeId}" class="form-control" type="text">
<!--<input name="alarmtypeId" th:field="*{alarmtypeId}" class="form-control" type="text">-->
<div class="input-group">
<input class="form-control" type="text" name="treeName" onclick="selectAlarmTypeTree()" id="treeName" th:field="*{alarmTypeName}">
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">阈值(最大)</label>
@ -53,6 +65,27 @@
$.operate.save(prefix + "/edit", $('#form-alarmInfo-edit').serialize());
}
}
/* 选择报警类型树 */
function selectAlarmTypeTree() {
var deptId = $.common.isEmpty($("#alarmtypeId").val()) ? "100" : $("#alarmtypeId").val();
var url = ctx + "base/alarmType/selectAlarmTypeTree/" + deptId;
var options = {
title: '报警类型',
width: "380",
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var tree = layero.find("iframe")[0].contentWindow.$._tree;
var body = $.modal.getChildFrame(index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
$.modal.close(index);
}
</script>
</body>
</html>

@ -0,0 +1,14 @@
package com.ruoyi.system.domain.dto;
import com.ruoyi.system.domain.BaseAlarmInfo;
import lombok.Data;
/**
* @author WenJY
* @date 20220214 10:42
*/
@Data
public class BaseAlarmInfoDto extends BaseAlarmInfo {
private String sensorName;
private String alarmTypeName;
}

@ -2,6 +2,7 @@ package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.BaseAlarmInfo;
import com.ruoyi.system.domain.dto.BaseAlarmInfoDto;
/**
* Mapper
@ -17,7 +18,7 @@ public interface BaseAlarmInfoMapper
* @param objId
* @return
*/
public BaseAlarmInfo selectBaseAlarmInfoByObjId(Long objId);
public BaseAlarmInfoDto selectBaseAlarmInfoByObjId(Long objId);
/**
*
@ -25,7 +26,7 @@ public interface BaseAlarmInfoMapper
* @param baseAlarmInfo
* @return
*/
public List<BaseAlarmInfo> selectBaseAlarmInfoList(BaseAlarmInfo baseAlarmInfo);
public List<BaseAlarmInfoDto> selectBaseAlarmInfoList(BaseAlarmInfo baseAlarmInfo);
/**
*

@ -2,6 +2,7 @@ package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.BaseAlarmInfo;
import com.ruoyi.system.domain.dto.BaseAlarmInfoDto;
/**
* Service
@ -17,7 +18,7 @@ public interface IBaseAlarmInfoService
* @param objId
* @return
*/
public BaseAlarmInfo selectBaseAlarmInfoByObjId(Long objId);
public BaseAlarmInfoDto selectBaseAlarmInfoByObjId(Long objId);
/**
*
@ -25,7 +26,7 @@ public interface IBaseAlarmInfoService
* @param baseAlarmInfo
* @return
*/
public List<BaseAlarmInfo> selectBaseAlarmInfoList(BaseAlarmInfo baseAlarmInfo);
public List<BaseAlarmInfoDto> selectBaseAlarmInfoList(BaseAlarmInfo baseAlarmInfo);
/**
*

@ -2,6 +2,7 @@ package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.dto.BaseAlarmInfoDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.BaseAlarmInfoMapper;
@ -28,7 +29,7 @@ public class BaseAlarmInfoServiceImpl implements IBaseAlarmInfoService
* @return
*/
@Override
public BaseAlarmInfo selectBaseAlarmInfoByObjId(Long objId)
public BaseAlarmInfoDto selectBaseAlarmInfoByObjId(Long objId)
{
return baseAlarmInfoMapper.selectBaseAlarmInfoByObjId(objId);
}
@ -40,7 +41,7 @@ public class BaseAlarmInfoServiceImpl implements IBaseAlarmInfoService
* @return
*/
@Override
public List<BaseAlarmInfo> selectBaseAlarmInfoList(BaseAlarmInfo baseAlarmInfo)
public List<BaseAlarmInfoDto> selectBaseAlarmInfoList(BaseAlarmInfo baseAlarmInfo)
{
return baseAlarmInfoMapper.selectBaseAlarmInfoList(baseAlarmInfo);
}

@ -17,28 +17,66 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="Update_Time" />
</resultMap>
<resultMap type="BaseAlarmInfoDto" id="BaseAlarmInfoDtoResult">
<result property="objId" column="ObjId" />
<result property="sensorId" column="Sensor_Id" />
<result property="sensorName" column="Sensor_Name" />
<result property="alarmtypeId" column="AlarmType_Id" />
<result property="alarmTypeName" column="AlarmType_Name" />
<result property="maxValue" column="Max_Value" />
<result property="minValue" column="Min_Value" />
<result property="enableFlag" column="Enable_Flag" />
<result property="createBy" column="Create_By" />
<result property="createTime" column="Create_Time" />
<result property="updateBy" column="Update_By" />
<result property="updateTime" column="Update_Time" />
</resultMap>
<sql id="selectBaseAlarmInfoVo">
select ObjId, Sensor_Id, AlarmType_Id, Max_Value, Min_Value, Enable_Flag, Create_By, Create_Time, Update_By, Update_Time from base_alarm_info
</sql>
<select id="selectBaseAlarmInfoList" parameterType="BaseAlarmInfo" resultMap="BaseAlarmInfoResult">
<include refid="selectBaseAlarmInfoVo"/>
<select id="selectBaseAlarmInfoList" parameterType="BaseAlarmInfo" resultMap="BaseAlarmInfoDtoResult">
<!--<include refid="selectBaseAlarmInfoVo"/>-->
select t1.ObjId,
t1.Sensor_Id,
t3.Sensor_Name,
t1.AlarmType_Id,
t2.AlarmType_Name,
t1.Max_Value,
t1.Min_Value,
t1.Enable_Flag,
t1.Create_By,
t1.Create_Time,
t1.Update_By,
t1.Update_Time
from base_alarm_info t1
left join base_alarm_type t2 on t1.AlarmType_Id = t2.alarmType_Id
left join base_sensor_info t3 on t1.Sensor_Id = t3.Sensor_Id
<where>
<if test="sensorId != null and sensorId != ''"> and Sensor_Id = #{sensorId}</if>
<if test="alarmtypeId != null and alarmtypeId != ''"> and AlarmType_Id = #{alarmtypeId}</if>
<if test="maxValue != null "> and Max_Value = #{maxValue}</if>
<if test="minValue != null and minValue != ''"> and Min_Value = #{minValue}</if>
<if test="enableFlag != null "> and Enable_Flag = #{enableFlag}</if>
<if test="createBy != null and createBy != ''"> and Create_By = #{createBy}</if>
<if test="createTime != null "> and Create_Time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''"> and Update_By = #{updateBy}</if>
<if test="updateTime != null "> and Update_Time = #{updateTime}</if>
<if test="sensorId != null and sensorId != ''"> and t1.Sensor_Id = #{sensorId}</if>
<if test="alarmtypeId != null and alarmtypeId != ''"> and t1.AlarmType_Id = #{alarmtypeId}</if>
</where>
</select>
<select id="selectBaseAlarmInfoByObjId" parameterType="Long" resultMap="BaseAlarmInfoResult">
<include refid="selectBaseAlarmInfoVo"/>
where ObjId = #{objId}
<select id="selectBaseAlarmInfoByObjId" parameterType="Long" resultMap="BaseAlarmInfoDtoResult">
<!--<include refid="selectBaseAlarmInfoVo"/>-->
select t1.ObjId,
t1.Sensor_Id,
t3.Sensor_Name,
t1.AlarmType_Id,
t2.AlarmType_Name,
t1.Max_Value,
t1.Min_Value,
t1.Enable_Flag,
t1.Create_By,
t1.Create_Time,
t1.Update_By,
t1.Update_Time
from base_alarm_info t1
left join base_alarm_type t2 on t1.AlarmType_Id = t2.alarmType_Id
left join base_sensor_info t3 on t1.Sensor_Id = t3.Sensor_Id
where t1.ObjId = #{objId}
</select>
<insert id="insertBaseAlarmInfo" parameterType="BaseAlarmInfo" useGeneratedKeys="true" keyProperty="objId">

Loading…
Cancel
Save