import * as echarts from '../../components/ec-canvas/echarts';
|
import constant from '../../utils/constant.js';
|
var util = require('../../utils/util.js');
|
var Constant = require('../../utils/constant.js');
|
import Request from "../../utils/api"
|
const urls = [{
|
ID: "1578958652814004224",
|
Name: '1号监控',
|
src: 'http://hls01open.ys7.com/openlive/e01b103e297845a4a995caf3503f21da.hd.m3u8',
|
DeviceNo: "J92078290",
|
IsRotateAble: true,
|
IsZoomble: false
|
},
|
{
|
ID: "1580107400608878592",
|
Name: '2号监控',
|
src: 'http://hls01open.ys7.com/openlive/f1420f1f2c3b4a8e96ea3ec62917acce.hd.m3u8',
|
DeviceNo: "K60368326",
|
IsRotateAble: true,
|
IsZoomble: false
|
},
|
]
|
//获取引用实例
|
var app = getApp();
|
var RefreshTime = 120;
|
var barec = null; //动态配置图表数据的变量
|
Page({
|
/**
|
* 页面的初始数据
|
*/
|
data: {
|
tabBar: [{
|
index: 0,
|
iconPath: "icon-shebeijiance-dianji",
|
selectedIconPath: "icon-shebeijiance-dianji blue",
|
text: "数据监测"
|
},
|
{
|
index: 1,
|
iconPath: "icon-gongzuo",
|
selectedIconPath: "icon-gongzuo blue",
|
text: "工作时间"
|
},
|
{
|
index: 2,
|
iconPath: "icon-guzhang",
|
selectedIconPath: "icon-guzhang blue",
|
text: "警报"
|
},
|
{
|
index: 3,
|
iconPath: "icon-jiankong",
|
selectedIconPath: "icon-jiankong blue",
|
text: "视频监控"
|
}
|
],
|
moreVideo: [], //视频监控列表
|
machineList: [], //泵组详情名称
|
|
startAlarmDate: util.formatDay(util.GetBeforeDate(7)),
|
endAlarmDate: util.formatDay(new Date()),
|
today: util.formatDay(new Date()),
|
stationID: 0,
|
currentTabIndex: 0,
|
lastRefreshTime: RefreshTime, //秒
|
loadingHidden: false,
|
loadingInfo: "加载中,请稍等...",
|
intervalRefreshTime: null,
|
allProductPoints: [],
|
allPointId: [],
|
alarmListInfo: [],
|
|
isInitialAlarmData: false, //是否初始化警报记录
|
hasAlarmData: false,
|
hasPointData: true,
|
|
IsDefault: true,
|
kpiParas: { //顶部状态
|
status: false,
|
runNnumber: 0,
|
alarmNumber: "无",
|
operationModel:true,//true 表示远程开关机 false 表示手动开关机
|
},
|
|
scrollHeight: wx.getSystemInfoSync().windowHeight,
|
isShowFloatMenu: false, //是否显示
|
animationFloatMenu: '', //显示动画
|
|
//echart 所有变量定义
|
ec: {
|
onInit: function (canvas, width, height, dpr) {
|
//初始化echarts元素,绑定到全局变量,方便更改数据
|
barec = echarts.init(canvas, null, {
|
width: width,
|
height: height,
|
devicePixelRatio: dpr
|
});
|
canvas.setChart(barec);
|
return barec;
|
},
|
},
|
//当前时间
|
yestday: util.formatDay(util.GetNextDate(new Date(), 0)),
|
historyDate: util.formatDay(util.GetNextDate(new Date(), 0)),
|
currentDayTimeStamp: new Date().getTime(util.formatDay(new Date())),//当前日期的时间戳
|
isNextDayAble: false, //是否可以点击下一天
|
PageIndex: 1, //初始化页数
|
PageSize: 20, //初始化条数
|
message: '未发生报警',
|
bottomStatus: false,
|
isExpandList: false, //列表展开状态 默认true不展开
|
isShowFloatMenu: false, //是否显示
|
animationFloatMenu: '', //显示动画
|
scrollHeight: wx.getSystemInfoSync().windowHeight,
|
scrollTop: 0,
|
|
dialogModalVisible: false, //对话框显隐
|
operationModel:1,//当前自动关机的模式 1 表示按时长 2表示按流量 1也表示手动关机--前提是时长为0
|
|
openPwd: "", //开启设备的密码
|
rulePwd: {
|
visibleStatus: false,
|
message: "密码不能为空"
|
}, //开机密码校验
|
closePwd: "", //停止设备的密码
|
ruleClosePwd: {
|
visibleStatus: false,
|
message: "密码不能为空"
|
}, //关机密码校验
|
openTime:"",//开机时长
|
openTimeUnit:"hours",//hours 表示按小时 minute 表示按分钟
|
ruleOpenTime: {
|
visibleStatus: false,
|
message: "开机时间不能为空"
|
}, //开机时间校验
|
frequencyValue:"",//频率
|
ruleFrequency:{
|
visibleStatus: false,
|
message: "频率不能为空"
|
},//频率校验
|
openPower:"",
|
ruleOpenPower:{
|
visibleStatus: false,
|
message: "功率不能为空"
|
},
|
initVideoInfoList: false, //是否请求过监控列表
|
isInOperationByEdit: false, //是在进行修改
|
isInOperationByOpenOrClose: false, //是否在进行开关机操作
|
|
m_currentEditSingleObj: {
|
modelVisible: false, //当前模态款的显/隐状态
|
parentID: null, //当前的泵组id
|
currentSingleID: null, //当前的修改的监测项id
|
currentEditValue: null, //当前修改的监测项的值
|
}, //当前修改的监测项的信息
|
isVisibleMonitorDataTime: false, //是否显示监测点数据更新时间
|
},
|
//监测列表伸缩
|
tapExpandList() {
|
var allProductPoints = this.data.allProductPoints
|
if (this.data.isExpandList) {
|
for (let i = 0; i < allProductPoints.length; i++) {
|
allProductPoints[i].IsExpand = false
|
}
|
this.setData({
|
isExpandList: false,
|
allProductPoints: allProductPoints
|
})
|
} else if (this.data.isExpandList == false) {
|
for (let i = 0; i < allProductPoints.length; i++) {
|
allProductPoints[i].IsExpand = true
|
}
|
this.setData({
|
isExpandList: true,
|
allProductPoints: allProductPoints
|
})
|
}
|
},
|
//上一天点击事件
|
yesterDay: function () {
|
this.setData({
|
historyDate: util.formatDay(util.GetNextDate(this.data.historyDate, -1)),
|
isNextDayAble: true,
|
});
|
this.getWorkTime()
|
},
|
//下一天点击事件
|
tomorrow: function () {
|
var day = util.formatDay(util.GetNextDate(this.data.historyDate, 1));
|
// console.log(day);
|
// console.log(this.data.yestday);
|
|
var isNextDayAble = true;
|
if (day == this.data.yestday) {
|
isNextDayAble = false;
|
}
|
this.setData({
|
historyDate: day,
|
isNextDayAble: isNextDayAble
|
});
|
this.getWorkTime()
|
},
|
/**
|
* 生命周期函数--监听页面加载
|
*/
|
onLoad: function (options) {
|
// console.log(options)
|
wx.setNavigationBarTitle({
|
title: options.name
|
})
|
let isVisibleDataTime = wx.getStorageSync('isVisibleDataTime')
|
if (isVisibleDataTime == "" || isVisibleDataTime == undefined) {
|
isVisibleDataTime = false
|
}
|
this.videoContext = wx.createVideoContext('myVideo')
|
// console.log(options.)
|
var getNewDateArry = util.getNewDateArry.getNewDateArry();
|
var that = this;
|
var stationID = options.id;
|
//console.log('打印stationID', stationID);
|
if (stationID == null) {
|
stationID = 5;
|
}
|
|
this.setData({
|
stationID: stationID,
|
getNewDateArry: getNewDateArry.ymdhm,
|
isVisibleMonitorDataTime: isVisibleDataTime
|
});
|
var userInfo = app.globalData.userInfo;
|
if (userInfo == null) {
|
return;
|
}
|
|
Request({
|
url: Constant.BASE_SERVER_URL + "Monitor/MonitorPoint/Mobile/GetGeneralGroupListByStationID@V1.0",
|
method: 'GET',
|
data: {
|
StationID: stationID,
|
CorpID: userInfo.CorpID
|
},
|
header: {
|
'content-type': 'application/json'
|
},
|
fail: function (err) {
|
that.setData({
|
loadingHidden: true
|
});
|
}, //请求失败
|
success: function (res) {
|
that.setData({
|
loadingHidden: true
|
});
|
|
var result = res.data;
|
// console.log('获取的泵站信息', result);
|
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '',
|
content: result.Message,
|
});
|
return;
|
}
|
// console.log(result);
|
var dict = result.Data;
|
// var dict = result.Data.PointList;
|
// console.log('dict',dict);
|
var allProductPoints = dict;
|
if (allProductPoints.length == 0) {
|
return;
|
}
|
// console.log('allProductPoints', allProductPoints);
|
|
|
var machineList = []
|
for (var i = 0; i < allProductPoints.length; i++) {
|
var node = allProductPoints[i];
|
machineList.push({
|
ID: node.ID,
|
TitleName: node.Name,
|
MachineName: node.Name,
|
WorkTime: 0
|
});
|
}
|
var allPointIds = [];
|
|
for (var k = 0; k < allProductPoints.length; k++) {
|
var product = allProductPoints[k];
|
product.IsExpand = false;
|
if (allProductPoints.length == 1) {
|
product.IsExpand = true;
|
}
|
|
product.isExpandAll = false;
|
|
var dis_num = 0;
|
for (var n = 0; n < product.Items.length; n++) {
|
var record = product.Items[n];
|
record.SignalList[0].SignalValue = ""
|
record.SignalList[0].RecordTime = ""
|
record.SignalList[0].isEdit = false //添加是否能修改的属性
|
// 根据ID判断当前监测点是不是变频频率 如果是可修改
|
if (record.SignalList[0].ID == "1575030605865947136") {
|
record.SignalList[0].isEdit = true
|
}
|
record.isDisp = false;
|
if (allProductPoints.length > 1) {
|
if (record.length <= 2) {
|
record.isDisp = true;
|
dis_num++;
|
allPointIds.push(record.ID);
|
}
|
} else {
|
record.isDisp = true;
|
dis_num++;
|
allPointIds.push(record.ID);
|
}
|
|
}
|
if (dis_num < 2) { //没有就显示前两个
|
for (var n = 0; n < product.Items.length; n++) {
|
var record = product.Items[n];
|
if (dis_num <= 2) {
|
record.isDisp = true;
|
dis_num++;
|
allPointIds.push(record.ID);
|
}
|
}
|
}
|
}
|
// console.log(allPointIds)
|
|
//定时刷新
|
var intervalRefreshTime = setInterval(function () {
|
var getNewDateArry = util.getNewDateArry.getNewDateArry()
|
var miao = that.data.lastRefreshTime;
|
miao = miao - 1;
|
if (miao <= 0) {
|
that.setData({
|
lastRefreshTime: RefreshTime,
|
getNewDateArry: getNewDateArry.ymdhm
|
});
|
that.refreshRecordValue();
|
} else {
|
that.setData({
|
lastRefreshTime: miao
|
});
|
}
|
}, 1000);
|
|
// console.log('289行',allProductPoints)
|
//更新数据
|
that.setData({
|
allPointId: allPointIds,
|
hasPointData: true,
|
allProductPoints: allProductPoints,
|
intervalRefreshTime: intervalRefreshTime,
|
machineList: machineList
|
});
|
// console.log('machineList', that.data.machineList);
|
|
that.refreshRecordValue(); //刷新一下
|
}
|
});
|
},
|
onReady: function () {
|
// this.getPoint(); //更新图表配置
|
},
|
//获取泵站运行时间
|
getWorkTime: function () {
|
var that = this;
|
var machineList = this.data.machineList;
|
var userInfo = app.globalData.userInfo;
|
Request({
|
url: Constant.BASE_SERVER_URL + 'Run/RunSpan/Mobile/GetByStationIDOfDay@V1.0',
|
method: 'GET',
|
data: {
|
CorpID: userInfo.CorpID,
|
StationID: that.data.stationID,
|
Day: that.data.historyDate
|
},
|
header: {
|
'content-type': 'application/json'
|
},
|
success(res) {
|
// console.log(res,306)
|
var result = res.data
|
if (result.Code != 0) {
|
return;
|
}
|
//
|
var run_time_array = result.Data;
|
//
|
console.log('291行 ', that.data.historyDate + '的开停机:', run_time_array);
|
if (run_time_array == null || run_time_array.length == 0) {
|
wx.showModal({
|
title: "提示",
|
content: "暂未开启监控",
|
})
|
return
|
}
|
for (var i = 0; i < machineList.length; i++) {
|
console.log()
|
|
run_time_array.forEach(item => {
|
if (machineList[i].TitleName == item.Name) {
|
machineList[i].WorkTime = (item.RumTime / 60 / 60).toFixed(1)
|
}
|
});
|
}
|
that.setData({
|
machineList: machineList
|
})
|
that.calcChartWorkTime(run_time_array)
|
},
|
fail(err) {}
|
})
|
},
|
//构建图表
|
calcChartWorkTime: function (records) {
|
// console.log(records,"已获取导数据")
|
var that = this
|
var seriesData = []; //定义图表内容的数组
|
var yAxisData = []; //定义y轴内容的数组
|
|
var machineList = that.data.machineList;
|
|
for (let i = 0; i < machineList.length; i++) { // 循环遍历获取开关机状态
|
var machineListNode = []
|
records.forEach(item => {
|
if (item.Name == machineList[i].MachineName) {
|
machineListNode.push(item.Spans)
|
}
|
});
|
// console.log('machineListNode', machineListNode)
|
yAxisData.push(machineList[i].MachineName)
|
machineList[i].list = machineListNode
|
for (let j = 0; j < machineListNode[0].length; j++) {
|
var nodeItem = machineListNode[0][j];
|
nodeItem.StartTime = nodeItem.StartTime.replace(/-/gi, '/')
|
nodeItem.EndTime = nodeItem.EndTime.replace(/-/gi, '/')
|
if (nodeItem.RunStatus == 1) {
|
seriesData.push({
|
name: "开机",
|
value: [
|
i,
|
new Date(new Date(nodeItem.StartTime)) - 0,
|
new Date(new Date(nodeItem.EndTime)) - 0,
|
"开启",
|
"关闭",
|
(nodeItem.Duration / 60 / 60).toFixed(1)
|
],
|
itemStyle: {
|
normal: {
|
color: '#7b9ce1'
|
}
|
}
|
})
|
} else if (nodeItem.RunStatus == 0) {
|
seriesData.push({
|
name: "关机",
|
value: [
|
i,
|
+new Date(new Date(nodeItem.StartTime)) - 0,
|
+new Date(new Date(nodeItem.EndTime)) - 0,
|
"关闭",
|
"开启",
|
(nodeItem.Duration / 60 / 60).toFixed(1)
|
],
|
itemStyle: {
|
normal: {
|
color: '#ddd'
|
}
|
}
|
})
|
}
|
}
|
}
|
|
// console.log(seriesData,"seriesData")
|
var minTime = '';
|
var maxTime = '';
|
if (seriesData.length == 0) { //判断处理x轴的最小时间和最大时间
|
minTime = that.data.historyDate
|
maxTime = that.data.historyDate + " 23:59:59"
|
} else {
|
minTime = seriesData[0].value[1]
|
maxTime = seriesData[seriesData.length - 1].value[2]
|
}
|
// var time1 = util.formatDay(util.GetNextDate(seriesData[0].value[1], 0)) + ' 00:00:00'
|
// var time2 = util.formatDay(util.GetNextDate(seriesData[0].value[1], 1)) + ' 00:00:00'
|
|
|
barec.setOption({
|
disableTouch: true,
|
tooltip: {
|
formatter: function (params) {
|
// console.log(new Date(params.value[1]).getHours());
|
// console.log(params.value[3]);
|
// console.log('111',params)
|
return params.name + ': ' + params.value[5] + "小时" + '\n' +
|
params.value[4] + ': ' + (new Date(params.value[1]).getHours()) + ":" + (new Date(params.value[1]).getMinutes()) + '\n' +
|
params.value[3] + ': ' + (new Date(params.value[2]).getHours()) + ":" + (new Date(params.value[2]).getMinutes());
|
}
|
},
|
title: {
|
text: '泵开关机状态表',
|
x: 'center',
|
y: '7px',
|
textStyle: {
|
color: '#16b5cb',
|
fontSize: 16
|
},
|
textAlign: 'left'
|
},
|
grid: {
|
left: '17%',
|
bottom: '60',
|
top: '40',
|
right: '4%'
|
},
|
xAxis: {
|
position: 'right',
|
type: 'time',
|
splitLine: {
|
show: false
|
},
|
// min: +new Date(time1),
|
min: minTime,
|
max: maxTime,
|
// max: +new Date(time2),
|
scale: false,
|
axisLabel: {
|
formatter: function (val) {
|
// console.log(val);
|
var date = new Date(val);
|
var texts = [date.getHours(), date.getMinutes()];
|
return texts.join(':');
|
}
|
}
|
},
|
yAxis: {
|
splitLine: {
|
show: false
|
},
|
axisLabel: {
|
interval: 0,
|
rotate: 20
|
},
|
scale: false,
|
offset: 2,
|
inverse: true,
|
data: yAxisData
|
},
|
series: [{
|
type: 'custom',
|
renderItem: function (params, api) {
|
var categoryIndex = api.value(0);
|
var start = api.coord([api.value(1), categoryIndex]);
|
var end = api.coord([api.value(2), categoryIndex]);
|
var height = (api.size([0, 1])[1] * 0.6) < 40 ? api.size([0, 1])[1] * 0.6 : 40;
|
var barLength = end[0] - start[0];
|
// var runtime = '开机:' + api.value(5) + '小时';
|
var runtime = '';
|
var flightNumberWidth = echarts.format.getTextRect(runtime).width;
|
var text = api.value(3) == '开启' ? runtime : '';
|
text = (barLength > flightNumberWidth) ? text : '';
|
var rectShape = echarts.graphic.clipRectByRect({
|
x: start[0],
|
y: start[1] - height / 2,
|
width: end[0] - start[0],
|
height: height
|
}, {
|
x: params.coordSys.x,
|
y: params.coordSys.y,
|
width: params.coordSys.width,
|
height: params.coordSys.height
|
});
|
return {
|
type: 'rect',
|
shape: rectShape,
|
style: api.style({
|
text: text,
|
textFill: '#fff'
|
})
|
};
|
},
|
itemStyle: {
|
opacity: 1
|
},
|
encode: {
|
x: [1, 2],
|
y: 0
|
},
|
data: seriesData
|
}]
|
})
|
|
// console.log(barec,"获取图标配置")
|
},
|
|
//自定义图表方法
|
renderItemFunc: function (params, api) {
|
var categoryIndex = api.value(0);
|
var start = api.coord([api.value(1), categoryIndex]);
|
var end = api.coord([api.value(2), categoryIndex]);
|
var height = (api.size([0, 1])[1] * 0.6) < 40 ? api.size([0, 1])[1] * 0.6 : 40;
|
var barLength = end[0] - start[0];
|
var runtime = '开机:' + api.value(5) + '小时';
|
var flightNumberWidth = echarts.format.getTextRect(runtime).width;
|
var text = api.value(3) == '开启' ? runtime : '';
|
text = (barLength > flightNumberWidth) ? text : '';
|
var rectShape = echarts.graphic.clipRectByRect({
|
x: start[0],
|
y: start[1] - height / 2,
|
width: end[0] - start[0],
|
height: height
|
}, {
|
x: params.coordSys.x,
|
y: params.coordSys.y,
|
width: params.coordSys.width,
|
height: params.coordSys.height
|
});
|
return {
|
type: 'rect',
|
shape: rectShape,
|
style: api.style({
|
text: text,
|
textFill: '#fff'
|
})
|
};
|
},
|
//底部tab切换栏
|
tapTab: function (e) {
|
var selIndex = e.currentTarget.dataset.index;
|
var that = this;
|
this.setData({
|
currentTabIndex: selIndex
|
});
|
if (selIndex == 1) { //当选中的下标为1的时候修改图表配置
|
setTimeout(function () {
|
that.getWorkTime()
|
}, 500)
|
}
|
if (selIndex == 2 && !this.data.isInitialAlarmData) {
|
|
this.setData({
|
loadingHidden: false,
|
isInitialAlarmData: true
|
})
|
that.getAlarmData(); //调用警报
|
}
|
if (selIndex == 3 && !this.data.initVideoInfoList) {
|
this.setData({
|
initVideoInfoList: true
|
})
|
that.getVideoListInfo(); //调用警报
|
}
|
},
|
|
tapProductItem: function (e) {
|
// console.log(e.currentTarget.dataset.id)
|
|
// wx.navigateTo({
|
// url: '../product/index?id=' + e.currentTarget.dataset.id,
|
//})
|
},
|
//刷新获取值
|
refreshRecordValue: function (e) {
|
var that = this;
|
var allPointId = this.data.allPointId;
|
var userInfo = app.globalData.userInfo;
|
if (allPointId == null || allPointId.length == 0)
|
return;
|
that.setData({
|
loadingHidden: false,
|
loadingInfo: "刷新中,请稍等..."
|
});
|
|
// console.log(allPointId.join(','))
|
|
Request({
|
url: Constant.BASE_SERVER_URL + "Run/MonitorRecord/Mobile/GetGeneralLastRecordByStationID@V1.0",
|
method: 'GET',
|
data: {
|
CorpID: userInfo.CorpID,
|
StationID: that.data.stationID
|
},
|
header: {
|
'content-type': 'application/json'
|
},
|
fail: function (err) {
|
that.setData({
|
loadingHidden: true
|
});
|
wx.showModal({
|
title: '',
|
content: '通讯失败',
|
})
|
}, //请求失败
|
complete: function () {}, //请求完成后执行的函数
|
success: function (res) {
|
// console.log('打印刷新后的数据',res);
|
that.setData({
|
loadingHidden: true
|
});
|
|
var result = res.data;
|
if (result.Code != 0) {
|
wx.showModal({
|
title: '',
|
content: result.Message,
|
});
|
return;
|
}
|
|
//
|
var newRecordList = result.Data;
|
// console.log(newRecordList,"新数据");
|
if (newRecordList == null)
|
return;
|
let openNumber = 0 //开启台数
|
let faultNumber = 0 //故障数量
|
let isOpen = false //是否开启
|
var allProductPoints = that.data.allProductPoints;
|
// 循环泵组
|
for (var p = 0; p < allProductPoints.length; p++) {
|
var allRecordList = allProductPoints[p].Items;
|
// 循环泵组下的测点
|
for (var i = 0; i < allRecordList.length; i++) {
|
var r_ds = allRecordList[i];
|
// 循环获取的测点数据
|
for (var j = 0; j < newRecordList.length; j++) {
|
// 使用新的测点数据的MonitorPointID 与 之前测点的ID比较 如果相同则赋值
|
if (r_ds.ID == newRecordList[j].MonitorPointID) {
|
r_ds.SignalList[0].SignalValue = newRecordList[j].DataValue;
|
r_ds.SignalList[0].RecordTime = newRecordList[j].DataTime;
|
r_ds.SignalList[0].ymdTime = newRecordList[j].DataTime.substring(0,10) //年月日截取
|
r_ds.SignalList[0].hmsTime = newRecordList[j].DataTime.substring(11,19) //时分秒截取
|
r_ds.SignalList[0].ymdTimeStamp = new Date().getTime(newRecordList[j].DataTime.substring(0,10)) //年月日时间戳 用于判断是否是当天
|
// 判断值是否属于枚举型
|
if (r_ds.SignalList[0].ValueType == 2 && r_ds.SignalList[0].ValueSettings != null) {
|
r_ds.SignalList[0].SignalValue = r_ds.SignalList[0].ValueSettings[r_ds.SignalList[0].SignalValue];
|
if (allProductPoints[p].Name != "泵站") {
|
// 根据ID判断当前监测项是不是“变频泵状态”
|
// 判断当前测点名称是否是变频泵状态 根据测点值判断是否 开/关机
|
if (r_ds.SignalList[0].ID == "1582303421720039424") {
|
if (r_ds.SignalList[0].SignalValue != '停止' && r_ds.SignalList[0].SignalValue != '故障' && r_ds.SignalList[0].SignalValue != '') {
|
openNumber++
|
// 1表示开
|
allProductPoints[p].SignalStatus = 1
|
isOpen = true
|
} else {
|
//0表示关
|
allProductPoints[p].SignalStatus = 0
|
if (r_ds.SignalList[0].SignalValue == '故障') {
|
allProductPoints[p].SignalStatus = -1
|
faultNumber++
|
}
|
}
|
allProductPoints[p].RunStatus = r_ds.SignalList[0].SignalValue
|
}
|
// console.log(r_ds.SignalList[0].SignalValue,723)
|
break;
|
}
|
}
|
break;
|
}
|
}
|
}
|
}
|
// console.log(allProductPoints, 736)
|
//更新数据
|
that.setData({
|
allProductPoints: allProductPoints,
|
"kpiParas.runNnumber": openNumber,
|
"kpiParas.alarmNumber": faultNumber,
|
"kpiParas.status": isOpen,
|
});
|
}
|
|
});
|
|
},
|
// 跳转查看监测点详情
|
tapeMonitorPoint: function (e) {
|
// console.log(e,653)
|
var pointid = e.currentTarget.dataset.pointid;
|
let cronType = e.currentTarget.dataset.crontype;
|
let pointName = e.currentTarget.dataset.pointname;
|
let pointUnit = e.currentTarget.dataset.pointunit;
|
console.log(pointid);
|
if (cronType != 0) {
|
wx.showModal({
|
title: "提示",
|
content: "不是实时测点,暂无配置",
|
showCancel: false,
|
})
|
return
|
}
|
wx.navigateTo({
|
url: '../singlePoint/index?id=' + pointid + '&name=' + pointName + "&unit=" + pointUnit,
|
});
|
},
|
//刷新警报数据
|
tapRefreshAlarm: function () {
|
this.setData({ //初始化设置
|
bottomStatus: false,
|
PageIndex: 1,
|
alarmListInfo: []
|
})
|
this.getAlarmData();
|
},
|
//警报
|
getAlarmData: function () {
|
var that = this;
|
var alarmListInfo = that.data.alarmListInfo
|
var userInfo = app.globalData.userInfo;
|
wx.showLoading({
|
title: '加载中...',
|
})
|
|
let data = {
|
CorpID: Constant.CorpID,
|
StationID: that.data.stationID,
|
StartTime: that.data.startAlarmDate,
|
EndTime: that.data.endAlarmDate,
|
PageIndex: that.data.PageIndex,
|
PageSize: that.data.PageSize
|
}
|
// console.log(data,697)
|
Request({
|
url: Constant.BASE_SERVER_URL + "Run/MonitorAlarmRecord/Mobile/GetPageListByStationID@V1.1",
|
method: 'GET',
|
data: {
|
CorpID: Constant.CorpID,
|
StationID: that.data.stationID,
|
StartTime: that.data.startAlarmDate,
|
EndTime: that.data.endAlarmDate,
|
PageIndex: that.data.PageIndex,
|
PageSize: that.data.PageSize
|
},
|
header: {
|
'content-type': 'application/json'
|
},
|
fail: function (err) {
|
wx.showModal({
|
title: '',
|
content: '通讯失败',
|
})
|
}, //请求失败
|
complete: function () {
|
that.setData({
|
loadingHidden: true
|
});
|
}, //请求完成后执行的函数
|
success: function (res) {
|
// console.log('打印警报信息', res.data)
|
wx.hideLoading();
|
if (res.data.Code != 0) {
|
wx.showToast({
|
title: '获取数据失败',
|
});
|
that.setData({
|
hasAlarmData: false
|
});
|
return;
|
}
|
let result = res.data.Data
|
if (result.List.length == 0) {
|
wx.showToast({
|
title: '当前无报警数据',
|
});
|
that.setData({
|
hasAlarmData: false
|
});
|
return;
|
}
|
if (result.Total == 0) {
|
that.setData({
|
hasAlarmData: false,
|
message: '暂无报警数据'
|
});
|
return;
|
}
|
if (result == null) {
|
that.setData({
|
bottomStatus: true,
|
message: '暂无报警数据'
|
});
|
return;
|
}
|
// console.log(that.data.PageIndex, that.data.PageSize)
|
// console.log(that.data.PageIndex * that.data.PageSize)
|
|
if (that.data.PageIndex * that.data.PageSize > res.data.Data.Total) {
|
let list = res.data.Data.List
|
that.setData({
|
bottomStatus: true,
|
hasAlarmData: false,
|
alarmListInfo: alarmListInfo.concat(list)
|
})
|
return;
|
}
|
var pageIndex = that.data.PageIndex
|
var ListInfo = res.data.Data.List
|
// console.log(pageIndex,733)
|
//更新数据
|
that.setData({
|
hasAlarmData: true,
|
alarmListInfo: alarmListInfo.concat(ListInfo),
|
PageIndex: ++pageIndex
|
});
|
// console.log(that.data.alarmListInfo);
|
}
|
});
|
},
|
//回到scroll组件顶部
|
goTop() {
|
this.setData({
|
scrollTop: 0
|
})
|
},
|
//scroll组件高度监听
|
scrollListView(e) {
|
let scrollTop = e.detail.scrollTop
|
// 如果超过半屏
|
if (scrollTop > this.data.scrollHeight / 2) {
|
this.setData({
|
isShowFloatMenu: true,
|
animationFloatMenu: 'fadeIn'
|
})
|
} else {
|
this.setData({
|
isShowFloatMenu: false,
|
animationFloatMenu: 'fadeOut'
|
})
|
// setTimeout(() => {this.setData({visual: false})}, 1000)
|
}
|
},
|
//警报 -- 开始时间选择器
|
bindStartAlarmDateChange: function (e) {
|
this.setData({
|
startAlarmDate: e.detail.value
|
})
|
},
|
//警报 -- 结束时间选择器
|
bindEndAlarmDateChange: function (e) {
|
this.setData({
|
endAlarmDate: e.detail.value
|
})
|
},
|
//展开与收缩
|
tapProductName: function (e) {
|
var list = this.data.allProductPoints;
|
var pid = e.currentTarget.dataset.productid;
|
// console.log(pid,801)
|
for (var i = 0; i < list.length; i++) {
|
if (list[i].ID == pid) {
|
list[i].IsExpand = !list[i].IsExpand
|
}
|
}
|
this.setData({
|
allProductPoints: list
|
});
|
// console.log(list,364)
|
},
|
//列表展示更多
|
tapMoreMonitor(e) {
|
var that = this;
|
var allProductPoints = that.data.allProductPoints;
|
//var id = e.currentTarget.dataset.id;
|
var index = e.currentTarget.dataset.index;
|
var product = allProductPoints[index];
|
product.isExpandAll = true;
|
// console.log(RecordList)
|
//allProductPoints[index].RecordList = JSON.parse(JSON.stringify(RecordList).replace(/false/g, "true"));
|
//allProductPoints[index].StateMore = "是否展示更多";
|
|
var pointids = this.data.allPointId;
|
// console.log(pointids,product,825)
|
for (var n = 0; n < product.Items.length; n++) {
|
var record = product.Items[n];
|
if (!record.isDisp) {
|
record.isDisp = true;
|
pointids.push(record.PointID);
|
}
|
}
|
//console.log(allProductPoints)
|
//更新数据
|
that.setData({
|
allProductPoints: allProductPoints,
|
allPointId: pointids
|
});
|
|
that.refreshRecordValue();
|
},
|
//警报列表 -- 到底部时加载数据
|
lowRefresh: function () {
|
var that = this
|
if (that.data.bottomStatus == true) {
|
return;
|
}
|
that.getAlarmData()
|
},
|
|
//改变设备开机状态
|
changeProductRunStatus(e) {
|
let _this = this
|
if (_this.data.isInOperationByOpenOrClose || !_this.data.kpiParas.operationModel) {
|
return
|
}
|
_this.setData({
|
dialogModalVisible: true
|
})
|
},
|
//监听开关机控制模式切换
|
handlCloseOrOpen(e){
|
this.setData({
|
"kpiParas.operationModel":e.detail.value
|
})
|
},
|
//监听开关机控制模式切换
|
handlCloseOrOpenCtrl(e){
|
//1 点击后先弹出 输入密码模态款
|
//2 输入密码后才调用api
|
// api 入参中 ReadOnly:表示是否修改 IsRemote:表示是否为远程
|
},
|
|
|
|
//监听自动停止模式选择
|
handleOperationModelRadio(e){
|
// console.log(e,1012)
|
this.setData({
|
operationModel:e.detail.value
|
})
|
},
|
// 监听输入的功率值并赋值
|
handlePowerValue(e) {
|
this.setData({
|
openPower: e.detail.value
|
})
|
},
|
// 监听输入的频率值并赋值
|
handleFrequencyValue(e) {
|
this.setData({
|
frequencyValue: e.detail.value
|
})
|
},
|
//监听开机时间输入
|
handleInputOpenTime(e){
|
this.setData({
|
openTime: e.detail.value
|
})
|
},
|
//监听开机时间单位
|
handleOpenTimeUnit(e){
|
let openTime = this.data.openTime
|
if(openTime>0){
|
if(e.detail.value == "hours"){
|
openTime = openTime / 60
|
}
|
if(e.detail.value == "minute"){
|
openTime = openTime * 60
|
}
|
}
|
|
this.setData({
|
openTimeUnit:e.detail.value,
|
openTime:openTime
|
})
|
},
|
//监听开机密码的输入
|
handleInputPwd(e) {
|
let _this = this
|
if (e.detail.value.length != 0) {
|
_this.setData({
|
openPwd: e.detail.value,
|
})
|
} else {
|
_this.setData({
|
openPwd: e.detail.value,
|
})
|
}
|
},
|
//监听停止密码的输入
|
handleInputclosePwd(e){
|
let openTime = 0
|
if(e.detail.value == 3){
|
this.setData({
|
openTime:openTime
|
})
|
}
|
this.setData({
|
closePwd:e.detail.value
|
})
|
},
|
//确定开/关机按钮
|
defindBtn() {
|
let _this = this
|
let isPassRule = true //判断是否通过校验
|
// 判断当前是开机状态则调用关机api
|
if (_this.data.kpiParas.status) {
|
let closePwd = _this.data.closePwd
|
let closePwdRuleVisible = false
|
let colsePwdRuleMsg = ""
|
if(closePwd.length == 0 || closePwd == ""){
|
closePwdRuleVisible = true
|
colsePwdRuleMsg = "密码不能为空"
|
isPassRule = false
|
}else {
|
closePwdRuleVisible = true
|
colsePwdRuleMsg = ""
|
}
|
if(!isPassRule){
|
_this.setData({
|
"ruleClosePwd.visibleStatus":closePwdRuleVisible,
|
"ruleClosePwd.message":colsePwdRuleMsg,
|
})
|
return
|
}
|
_this.setData({
|
isInOperationByOpenOrClose: true,
|
dialogModalVisible: false
|
})
|
//
|
_this.testClosePump()
|
} else {
|
// 如果是关机状态则调用开机api
|
let openTimeRuleMsg = "" //开机时间校验提示
|
let frequencyValueRuleMsg = "" //频率校验提示
|
let openPwdMsg = "" //开机密码校验提示
|
let openPowerMsg = "" //开机功率校验提示
|
let openTimeRuleVisible = false //开机时间校验提示显示
|
let frequencyValueRuleVisible = false //开机频率校验提示显示
|
let openPwdRule = false // 开机密码校验提示显示
|
let openPowerRule = false //开机功率校验提示显示
|
if (_this.data.openPwd.length == 0) {
|
openPwdMsg = "开机密码不能为空"
|
openPwdRule = true
|
isPassRule = false
|
}
|
let frequencyValue = _this.data.frequencyValue
|
if (frequencyValue.length == 0 || frequencyValue.length == "") {
|
frequencyValueRuleMsg = "频率不能为空"
|
frequencyValueRuleVisible = true
|
isPassRule = false
|
}
|
else if (frequencyValue < 20) {
|
frequencyValueRuleMsg = "频率范围不能低于20"
|
frequencyValueRuleVisible = true
|
isPassRule = false
|
}
|
else if (frequencyValue > 50) {
|
frequencyValueRuleMsg = "频率范围不能超过50"
|
frequencyValueRuleVisible = true
|
isPassRule = false
|
}else{
|
frequencyValueRuleVisible = false
|
frequencyValueRuleMsg = ""
|
_this.setData({
|
"ruleFrequency.message":frequencyValueRuleMsg,
|
"ruleFrequency.visibleStatus":frequencyValueRuleVisible,
|
})
|
}
|
let openTime = _this.data.openTime
|
if(_this.data.operationModel == 1){
|
if(openTime.length == 0 || openTime <= 0){
|
openTimeRuleMsg = "开机时间填写错误"
|
openTimeRuleVisible = true
|
isPassRule = false
|
}
|
if(_this.data.openTimeUnit == "hours"){
|
if(openTime < 0.1){
|
openTimeRuleMsg = "开机时间不能小于6分钟"
|
openTimeRuleVisible = true
|
isPassRule = false
|
}
|
}
|
if(_this.data.openTimeUnit == "minute"){
|
if(openTime < 6){
|
openTimeRuleMsg = "开机时间不能小于6分钟"
|
openTimeRuleVisible = true
|
isPassRule = false
|
}
|
}
|
}
|
|
let openPower = _this.data.openPower
|
if(_this.data.operationModel == 0){
|
if(openPower.length == 0 || openPower <= 0){
|
openPowerRuleMsg = "功率不能为空或是0"
|
openPowerRuleVisible = true
|
isPassRule = false
|
}
|
}
|
|
if(!isPassRule){
|
_this.setData({
|
"rulePwd.message":openPwdMsg,
|
"rulePwd.visibleStatus":openPwdRule,
|
"ruleFrequency.message":frequencyValueRuleMsg,
|
"ruleFrequency.visibleStatus":frequencyValueRuleVisible,
|
"ruleOpenTime.visibleStatus":openTimeRuleVisible,
|
"ruleOpenTime.message":openTimeRuleMsg,
|
"ruleOpenPower.visibleStatus":openTimeRuleVisible,
|
"ruleOpenPower.message":openTimeRuleMsg,
|
})
|
return
|
}
|
_this.setData({
|
dialogModalVisible:false,
|
isInOperationByOpenOrClose:true
|
})
|
_this.testStartPump()
|
}
|
|
},
|
//隐藏开关机模态框
|
hideModal() {
|
this.setData({
|
dialogModalVisible: false
|
})
|
},
|
//泵测试开机
|
testStartPump() {
|
let _this = this
|
let OperatingMode = _this.data.operationModel
|
let OperatingValue = ""
|
if(OperatingMode == 0){
|
OperatingValue = _this.data.openPower
|
}
|
if(OperatingMode == 1){
|
OperatingValue = _this.data.openTime
|
}
|
if(OperatingMode == 3){
|
OperatingMode = 1
|
OperatingValue = 0
|
}
|
Request({
|
url: Constant.BASE_SERVER_URL + "Monitor/Control/NT/TestStart@V1.0",
|
method: 'POST',
|
data: {
|
Password: _this.data.openPwd,
|
HZ: _this.data.frequencyValue,
|
OperatingMode: OperatingMode,
|
OperatingValue: OperatingValue
|
},
|
header: {
|
'content-type': 'application/json'
|
},
|
fail: function (err) {
|
console.log(err, "开启失败")
|
// 测试使用-----------
|
setTimeout(() => {
|
wx.showToast({
|
title: '开启操作失败',
|
icon: "error",
|
duration: 2000
|
})
|
}, 5000);
|
// 测试结束-----------
|
}, //请求失败
|
success: function (res) {
|
// console.log(res, "开启成功")
|
// 测试使用-----------
|
setTimeout(() => {
|
if(res.data.Code != 0){
|
wx.showToast({
|
title: res.data.Message,
|
icon:"error",
|
duration:2000
|
})
|
_this.setData({
|
isInOperationByOpenOrClose: false,
|
})
|
return
|
}
|
_this.setData({
|
isInOperationByOpenOrClose: false,
|
"kpiParas.status": true,
|
})
|
_this.refreshRecordValue()
|
}, 5000);
|
// 测试结束-----------
|
}
|
})
|
},
|
//泵测试关机
|
testClosePump() {
|
let _this = this
|
Request({
|
url: Constant.BASE_SERVER_URL + "Monitor/Control/NT/TestStop@V1.0",
|
method: 'POST',
|
data: {
|
Password:_this.data.closePwd
|
},
|
header: {
|
'content-type': 'application/json'
|
},
|
fail: function (err) {
|
console.log(err, "关机失败")
|
// 测试使用-----------
|
setTimeout(() => {
|
wx.showToast({
|
title: '关机操作失败',
|
icon: "error",
|
duration: 2000
|
})
|
}, 5000);
|
// 测试结束-----------
|
}, //请求失败
|
success: function (res) {
|
// console.log(res, "关机成功")
|
setTimeout(() => {
|
if(res.data.Code != 0){
|
wx.showToast({
|
title: res.data.Message,
|
icon:"error",
|
duration:2000
|
})
|
_this.setData({
|
isInOperationByOpenOrClose: false,
|
})
|
return
|
}
|
_this.setData({
|
isInOperationByOpenOrClose: false,
|
"kpiParas.status": false,
|
})
|
_this.refreshRecordValue()
|
}, 5000);
|
}
|
})
|
},
|
// 泵开机
|
openProduct() {
|
let _this = this
|
return
|
wx.showModal({
|
title: "提示",
|
content: "是否开启当前机组?",
|
success(res) {
|
_this.setData({
|
modalName: null,
|
ListTouchDirection: null
|
})
|
if (res.confirm) {
|
wx.showToast({
|
title: '开启成功',
|
icon: 'success',
|
duration: 1000
|
})
|
} else if (res.cancel) {
|
wx.showToast({
|
title: '取消开启',
|
icon: 'none',
|
duration: 1000
|
})
|
}
|
}
|
})
|
},
|
//获取监控信息及播放地址
|
getVideoListInfo() {
|
let _this = this
|
wx.request({
|
url: Constant.BASE_SERVER_URL + "Camera/Video/GetHikListByStationID@V1.0",
|
header: {
|
'content-type': 'application/json'
|
},
|
method: 'GET',
|
data: {
|
CorpID: Constant.CorpID,
|
StationID: _this.data.stationID
|
},
|
success: function (res) {
|
console.log(res, '摄像头信息')
|
let m_caremaList = res.data.Data;
|
m_caremaList[0].LiveUrl = "http://hls01open.ys7.com/openlive/e01b103e297845a4a995caf3503f21da.hd.m3u8"
|
m_caremaList[1].LiveUrl = "http://hls01open.ys7.com/openlive/f1420f1f2c3b4a8e96ea3ec62917acce.hd.m3u8"
|
_this.setData({
|
moreVideo: m_caremaList
|
})
|
},
|
fail: function (res) {
|
console.log('失败')
|
},
|
})
|
},
|
//跳转到摄像头详情
|
tapCamearListDetailView(e) {
|
console.log(e, 1049)
|
let videoInfo = JSON.stringify(e.currentTarget.dataset.videoObj);
|
|
// console.log(model,397)
|
wx.navigateTo({
|
url: '/video/single/index?from=list&videoInfo=' + videoInfo
|
});
|
},
|
/**播放错误 */
|
videoErrorCallback: function (e) {
|
this.showModal("提示", "视频错误信息")
|
console.log(e.detail.errMsg)
|
},
|
/**
|
* 生命周期函数--监听页面初次渲染完成
|
*/
|
onReady: function () {},
|
|
/**
|
* 生命周期函数--监听页面显示
|
*/
|
onShow: function () {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面隐藏
|
*/
|
onHide: function () {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面卸载
|
*/
|
onUnload: function () {
|
if (this.data.intervalRefreshTime != null)
|
clearInterval(this.data.intervalRefreshTime);
|
},
|
|
/**
|
* 页面相关事件处理函数--监听用户下拉动作
|
*/
|
onPullDownRefresh: function () {
|
|
},
|
|
/**
|
* 页面上拉触底事件的处理函数
|
*/
|
onReachBottom: function () {
|
|
},
|
/** 时间选择器状态 **/
|
tapChangeWorkTime(e) {
|
var isNextDayAble = true;
|
if (e.detail.value == this.data.yestday) {
|
isNextDayAble = false;
|
}
|
this.setData({
|
historyDate: e.detail.value,
|
isNextDayAble: isNextDayAble
|
})
|
this.getWorkTime();
|
},
|
/**返回顶部 */
|
goTop() {
|
this.setData({
|
scrollTop: 0
|
})
|
},
|
scrollListView(e) {
|
var that = this;
|
let scrollTop = e.detail.scrollTop
|
// 如果超过半屏
|
if (scrollTop > that.data.scrollHeight / 3.5) {
|
that.setData({
|
isShowFloatMenu: true,
|
animationFloatMenu: 'fadeIn'
|
})
|
} else {
|
that.setData({
|
isShowFloatMenu: false,
|
animationFloatMenu: 'fadeOut'
|
})
|
// setTimeout(() => {that.setData({visual: false})}, 1000)
|
}
|
},
|
/**
|
*
|
* 屏幕旋转事件
|
*/
|
onResize(res) {
|
res.size.windowWidth // 新的显示区域宽度
|
res.size.windowHeight // 新的显示区域高度
|
},
|
|
/**
|
* 用户点击右上角分享
|
*/
|
onShareAppMessage: function () {
|
return Constant.Share;
|
},
|
})
|