add - 配电柜实时监控接口。

master
yinq 3 days ago
parent a240f20257
commit af6032804c

@ -308,4 +308,14 @@ public class T_W_TemperturedataController extends BaseController
return result;
}
/**
*
*/
@PostMapping("/distributionCabinetRealTimeMonitor")
@ResponseBody
public AjaxResult distributionCabinetRealTimeMonitor(T_W_Temperturedata t_W_Temperturedata) {
List<T_W_TempertureDataDto> list = t_W_TemperturedataService.selectDistributionCabinetRealTimeMonitor(t_W_Temperturedata);
return AjaxResult.success(list);
}
}

@ -6,6 +6,73 @@
<th:block th:include="include :: ztree-css"/>
<th:block th:include="include :: datetimepicker-css"/>
</head>
<style>
.chartDiv {
width: 16%;
position: relative;
display: inline-block;
margin-bottom: 0.4vw;
}
.height {
height: 22vw;
}
.border {
border: 1px solid #67C23A;
padding: 0 1vw;
}
.chartDiv .chart {
width: 100%;
height: calc(100% - 50px);
position: absolute;
bottom: 0
}
.chartDiv .title {
font-size: 22px;
font-weight: 700;
width: 100%;
text-align: center;
}
.chartDiv .time {
font-size: 16px;
color: #409EFF;
width: 100%;
text-align: center;
}
.chartDiv .mileage {
position: absolute;
top: 74%;
left: 50%;
transform: translateX(-50%);
}
.chartDiv .text {
font-size: 1.25vw;
position: absolute;
top: 80%;
left: 50%;
transform: translateX(-50%);
}
.chartDiv .text1 {
font-size: 1.1vw;
line-height: 1.4vw;
}
.chartDiv .mileage .num {
font-size: 1vw;
margin: 0 0.1vw;
padding: 0.05vw 0.1vw;
background-color: #0001;
display: inline-block;
}
</style>
<body class="gray-bg">
<div class="ui-layout-west">
@ -15,18 +82,19 @@
<i class="fa icon-grid"></i> 测控点信息
</div>
<div class="box-tools pull-right">
<a type="button" class="btn btn-box-tool" href="#" onclick="dept()" title="测控点信息"><i
<a class="btn btn-box-tool" href="#" onclick="dept()" title="测控点信息" type="button"><i
class="fa fa-edit"></i></a>
<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i
<button class="btn btn-box-tool" id="btnExpand" style="display:none;" title="展开" type="button"><i
class="fa fa-chevron-up"></i></button>
<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i
<button class="btn btn-box-tool" id="btnCollapse" title="折叠" type="button"><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 class="btn btn-box-tool" id="btnRefresh" title="刷新" type="button"><i
class="fa fa-refresh"></i>
</button>
</div>
</div>
<div class="ui-layout-content">
<div id="tree" class="ztree"></div>
<div class="ztree" id="tree"></div>
</div>
</div>
</div>
@ -35,40 +103,13 @@
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<input type="hidden" id="monitorId" name="monitorId">
<div class="select-list">
<ul>
<li class="select-time">
<label style="width: auto">采集时间:</label><input type="text" style="width: 150px"
class="form-control" id="laydate-demo-3"
placeholder="开始时间"
name="params[beginCollectTime]"/>
<span>-</span>
<input type="text" class="form-control" id="laydate-demo-4" style="width: 150px"
placeholder="结束时间" name="params[endCollectTime]"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
<div id="chartDivs">
</div>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-warning" onclick="$.table.exportExcel()"
shiro:hasPermission="system:TempertureData:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
</div>
@ -77,102 +118,36 @@
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('system:TempertureData:edit')}]];
var removeFlag = [[${@permission.hasPermi('system:TempertureData:remove')}]];
var prefix = ctx + "system/TempertureData";
let iotType = [[${iotType}]];
$(function () {
var panehHidden = false;
if ($(this).width() < 769) {
panehHidden = true;
}
$('body').layout({initClosed: panehHidden, west__size: 245});
queryUserList();
queryDeptTree();
});
function queryUserList() {
var options = {
url: prefix + "/list?confirmPersonID=1",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "配电柜实施监控",
columns: [{
checkbox: true
},
{
field: 'objid',
title: '编号',
visible: false
},
{
field: 'monitorId',
title: '测控点编号',
visible: false
},
{
field: 'monitorName',
title: '测控点名称'
},
{
field: 'monitorAddr',
title: '测控点位置'
},
{
field: 'collectTime',
title: '采集时间'
},
{
field: 'tempreture',
title: '温度(℃)'
},
{
field: 'humidity',
title: '湿度(%RH',
visible: false
},
{
field: 'illuminance',
title: '照度',
visible: false
},
{
field: 'noise',
title: '噪声',
visible: false
},
{
field: 'concentration',
title: '硫化氢浓度',
visible: false
},
{
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.objid + '\')"><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.objid + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
},
visible: false
}]
};
$.table.init(options);
let time1 = null;
function formatValue(value) {
return (value === null || value === undefined || value === "") ? "-" : value;
}
//动力环境
let monitorType = 99;
if (iotType == 2) {
//变电室
monitorType = 100;
} else if (iotType == 3) {
//冷却循环水
monitorType = 101;
function renderMonitorCards(data) {
$("#chartDivs").html("");
data.forEach(function (v) {
var html = ""
+ "<div class=\"chartDiv border\">"
+ "<div class=\"title\" style=\"font-size: 1.4vw;\">" + (v.monitorName || v.monitorId || "-") + "</div>"
+ "<div class=\"time\" style=\"font-size: 1vw\">" + formatValue(v.collectTime) + "</div>"
+ "<div class=\"text1\">最低温度(湿度):" + formatValue(v.humidity) + "%RH</div>"
+ "<div class=\"text1\">最高温度(照度):" + formatValue(v.illuminance) + "</div>"
+ "<div class=\"text1\">平均温度(温度):" + formatValue(v.tempreture) + "℃</div>"
+ "</div>";
$("#chartDivs").append(html);
});
}
function queryDeptTree() {
@ -180,54 +155,52 @@
var options = {
url: url,
expandLevel: 1,
onClick: zOnClick
check: {
enable: true,
nocheckInherit: false,
chkboxType: {"Y": "", "N": ""}
},
onCheck: onCheck
};
$.tree.init(options);
function zOnClick(event, treeId, treeNode) {
$("#monitorId").val(treeNode.id);
/*alert(treeNode.id)*/
$.table.search();
function onCheck() {
var intervalFun = function () {
var checkedIds = getCheckedMonitorIds();
if (!checkedIds) {
$("#chartDivs").html("");
return;
}
$.post(prefix + "/distributionCabinetRealTimeMonitor", {monitorId: checkedIds}, function (e) {
if (e.code === 0) {
renderMonitorCards(e.data || []);
}
});
};
intervalFun();
if (time1) {
clearInterval(time1);
time1 = null;
}
time1 = setInterval(intervalFun, 10000);
}
}
$('#btnExpand').click(function () {
$._tree.expandAll(true);
$(this).hide();
$('#btnCollapse').show();
});
$('#btnCollapse').click(function () {
$._tree.expandAll(false);
$(this).hide();
$('#btnExpand').show();
});
$('#btnRefresh').click(function () {
queryDeptTree();
});
/* 测控点信息 */
function dept() {
var url = ctx + "system/Monitor?id=4";
$.modal.openTab("测控点信息", url);
function getCheckedMonitorIds() {
var treeObj = $.fn.zTree.getZTreeObj("tree");
if (!treeObj) {
return "";
}
var checkedNode = treeObj.getCheckedNodes(true);
var ids = [];
checkedNode.forEach(function (node) {
if (node && node.id !== undefined && node.id !== null && node.id !== "") {
ids.push(node.id);
}
});
return ids.join(",");
}
layui.use('laydate', function () {
var laydate = layui.laydate;
laydate.render({
elem: '#laydate-demo-3',
type: 'datetime',
trigger: 'click'
});
laydate.render({
elem: '#laydate-demo-4',
type: 'datetime',
trigger: 'click'
});
});
</script>
</body>
</html>
</html>

@ -87,4 +87,9 @@ public interface T_W_TemperturedataMapper
public List<T_W_Temperturedata> selectT_W_illdataList(T_W_Temperturedata t_W_Temperturedata);
public List<T_W_Temperturedata> selectT_W_Max_dataList(T_W_Temperturedata t_W_Temperturedata);
public List<T_W_Temperturedata> selectill_max_min_avg(T_W_Temperturedata t_W_Temperturedata);
/**
*
*/
public List<T_W_TempertureDataDto> selectDistributionCabinetRealTimeMonitor(T_W_Temperturedata t_W_Temperturedata);
}

@ -42,6 +42,11 @@ public interface IT_W_TemperturedataService
public List<T_W_Temperturedata> selectill_max_min_avg(T_W_Temperturedata t_W_Temperturedata);
public List<T_W_Temperturedata> select_max_min_avg(T_W_Temperturedata t_W_Temperturedata);
/**
*
*/
public List<T_W_TempertureDataDto> selectDistributionCabinetRealTimeMonitor(T_W_Temperturedata t_W_Temperturedata);
/**
* 湿
* @return

@ -1,7 +1,10 @@
package com.ruoyi.system.service.impl;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.dto.T_W_TempertureDataDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -81,6 +84,23 @@ public class T_W_TemperturedataServiceImpl implements IT_W_TemperturedataService
return t_W_TemperturedataMapper.select_max_min_avg(t_W_Temperturedata);
}
@Override
public List<T_W_TempertureDataDto> selectDistributionCabinetRealTimeMonitor(T_W_Temperturedata t_W_Temperturedata) {
String monitorId = t_W_Temperturedata.getMonitorId();
if (StringUtils.isBlank(monitorId)) {
return null;
}
List<String> monitorIdList = Arrays.stream(monitorId.split(","))
.map(String::trim)
.filter(StringUtils::isNotBlank)
.collect(Collectors.toList());
if (monitorIdList.isEmpty()) {
return null;
}
t_W_Temperturedata.getParams().put("monitorIdList", monitorIdList);
return t_W_TemperturedataMapper.selectDistributionCabinetRealTimeMonitor(t_W_Temperturedata);
}
/**
* 湿
* @return

@ -169,6 +169,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by t1.monitorId
</select>
<select id="selectDistributionCabinetRealTimeMonitor" parameterType="T_W_Temperturedata" resultMap="T_W_TemperturedataDtoResult">
WITH RankedData AS (
SELECT t1.monitorId,
t1.collectTime,
t1.tempreture,
t1.humidity,
t1.illuminance,
ROW_NUMBER() OVER (PARTITION BY t1.monitorId ORDER BY t1.collectTime DESC) AS rn
FROM T_W_TempertureData t1
<where>
<if test="params.monitorIdList != null and params.monitorIdList.size() > 0">
and t1.monitorId in
<foreach collection="params.monitorIdList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</where>
)
SELECT t.monitorId,
m.monitorName,
t.collectTime,
t.tempreture,
t.humidity,
t.illuminance
FROM RankedData t
LEFT JOIN T_Monitor m ON m.monitorId = t.monitorId
WHERE t.rn = 1
ORDER BY t.monitorId
</select>
<select id="selectT_Tem_Data_First_List" parameterType="T_W_Temperturedata" resultMap="T_W_TemperturedataResult">

Loading…
Cancel
Save