function ElectrictyUtil(options) {
|
this.electricDataList = []
|
this.defaultIndex = ['1', '2', '5', '6']// 表格默认展示因子
|
// 图表数据
|
this.chartData = {
|
values: [],
|
status: []
|
}
|
// 当前显示的下标
|
this.checkOptions = ['1']// 电流值
|
this.checkOptions2 = ['1']// 设备状态
|
// 显示模式, 0: 显示电流值;1:显示装置运行状态
|
this.mode = 0
|
|
this.xAxis = []
|
this.lineChart = options.lineChart
|
this.chartSlider = options.chartSlider
|
this.pageSize = options.pageSize
|
|
this.factorMode = 'type3'// 监测因子对应模式
|
|
// 多选框选项1
|
this.options1 = [{
|
label: "产线喷漆房-电流",
|
value: "1"
|
},
|
{
|
label: "废气净化装置-电流",
|
value: "2"
|
}]
|
|
// 多选框选项1
|
this.options2 = [{
|
label: "产线喷漆房-运行状态",
|
value: "1"
|
}, {
|
label: "废气净化装置-运行状态",
|
value: "2"
|
}]
|
}
|
|
ElectrictyUtil.prototype = {
|
|
init: function () {
|
|
this.initChart()
|
this.initTable()
|
},
|
|
initChart: function (){
|
// 2.初始化监测因子复选框
|
$('#history_chart_factorbox').empty()
|
CheckBox.newCheckBox('history_chart_factorbox', this.options1, ['1'], this.onCheckLineChart.bind(this))
|
// 3.创建初始折线图
|
this.lineChartOption = FChart.genLineChart(this.lineChart, this.xAxis, [], false)
|
|
this.chartData.values = []
|
this.chartData.status = []
|
// 电流值折线图
|
for (let i = 0; i < this.options1.length; i++) {
|
const o = this.options1[i]
|
this.chartData.values.push({
|
name: o.label,
|
type: 'line',
|
data: [],
|
showAllSymbol: true,
|
animationDelay: function(idx) {
|
return idx * 10;
|
},
|
show: this.checkOptions.indexOf(o.value) != -1
|
})
|
}
|
// 装置状态折线图
|
for (let i = 0; i < this.options2.length; i++) {
|
const o = this.options2[i]
|
this.chartData.status.push({
|
name: o.label,
|
type: 'line',
|
data: [],
|
showAllSymbol: true,
|
animationDelay: function(idx) {
|
return idx * 10;
|
},
|
show: this.checkOptions2.indexOf(o.value) != -1
|
})
|
}
|
|
var that = this
|
$('#electrcity_status').on('click', function () {
|
var op = that.options1
|
var checks = that.checkOptions
|
if (this.checked) {
|
that.mode = 1
|
op = that.options2
|
checks = that.checkOptions2
|
} else {
|
that.mode = 0
|
op = that.options1
|
checks = that.checkOptions
|
}
|
$('#history_chart_factorbox').empty()
|
CheckBox.newCheckBox('history_chart_factorbox', op, checks, that.onCheckLineChart.bind(that))
|
that.refreshChart()
|
})
|
},
|
|
onCheckLineChart: function (obj) {
|
var index = parseInt(obj.value) - 1
|
if (this.mode == 0) {
|
this.chartData.values[index].show = obj.checked
|
} else {
|
this.chartData.status[index].show = obj.checked
|
}
|
|
var checkOp = this.checkOptions
|
if (this.mode == 0) {
|
checkOp = this.checkOptions
|
} else {
|
checkOp = this.checkOptions2
|
}
|
if (obj.checked) {
|
checkOp.push(obj.value)
|
} else {
|
var i = checkOp.indexOf(obj.value)
|
if (i != -1) {
|
checkOp.splice(i, 1)
|
}
|
}
|
|
this.refreshChart()
|
},
|
|
refreshChartCheckBox: function (type) {
|
switch (type) {
|
case 0:
|
this.options1 = [{
|
label: "产线喷漆房-电流",
|
value: "1"
|
}, {
|
label: "废气净化装置-电流",
|
value: "2"
|
}]
|
this.options2 = [{
|
label: "产线喷漆房-运行状态",
|
value: "1"
|
}, {
|
label: "废气净化装置-运行状态",
|
value: "2"
|
}]
|
break;
|
case 1:
|
this.options1 = [{
|
label: "产线风机-电流",
|
value: "1"
|
}, {
|
label: "废气净化装置-电流",
|
value: "2"
|
}]
|
this.options2 = [{
|
label: "产线风机-运行状态",
|
value: "1"
|
}, {
|
label: "废气净化装置-运行状态",
|
value: "2"
|
}]
|
break;
|
default:
|
break;
|
}
|
// 初始化监测因子复选框
|
this.mode = 0
|
$('#electrcity_status').prop('checked', false)
|
$('#history_chart_factorbox').empty()
|
CheckBox.newCheckBox('history_chart_factorbox', this.options1, this.checkOptions, this.onCheckLineChart.bind(this))
|
},
|
|
refreshChart: function () {
|
var that = this
|
var series = this.chartData.values
|
var label = undefined
|
if (this.mode == 0) {
|
series = this.chartData.values
|
} else {
|
series = this.chartData.status
|
label = true
|
}
|
this.lineChartOption = FChart.genLineChart(this.lineChart, this.xAxis, series, false, undefined, function (value) {
|
if (label) {
|
if (value == 0) {
|
return '待机'
|
}
|
else if (value == 1) {
|
return '低负荷运行'
|
}
|
else if (value == 2) {
|
return '运行'
|
}
|
else if (value == 3) {
|
return '超负荷'
|
} else {
|
return '待机'
|
}
|
} else {
|
return value
|
}
|
})
|
this.chartSlider.setOnDragCallback(function(p) {
|
if (p != that.lastProgress) {
|
that.progress = p
|
FChart.lineChartOnPage2({
|
chart: that.lineChart,
|
option: that.lineChartOption,
|
progress: p,
|
size: that.pageSize
|
})
|
}
|
})
|
},
|
|
setPage: function (pageSize) {
|
this.pageSize = pageSize
|
FChart.lineChartOnPage2({
|
chart: this.lineChart,
|
option: this.lineChartOption,
|
progress: this.progress,
|
size: this.pageSize
|
})
|
},
|
|
/**
|
* 用电量数据格式化,转换为两种格式
|
* 1. 所有设备的各项电流值
|
* 2. 所有设备的运行状态
|
*/
|
setData: function (electricDataList) {
|
this.electricDataList = electricDataList
|
this.xAxis = []
|
this.chartData.values.forEach(v => {
|
v.data = []
|
})
|
this.chartData.status.forEach(s => {
|
s.data = []
|
})
|
electricDataList.forEach(d => {
|
this.xAxis.push(d.time)
|
this.chartData.values[0].data.push(d.d1Avg)
|
this.chartData.values[1].data.push(d.d2Avg)
|
// this.chartData.values[0].data.push(d.d1eA)
|
// this.chartData.values[1].data.push(d.d1eB)
|
// this.chartData.values[2].data.push(d.d1eC)
|
// this.chartData.values[3].data.push(d.d2eA)
|
// this.chartData.values[4].data.push(d.d2eB)
|
// this.chartData.values[5].data.push(d.d2eC)
|
this.chartData.status[0].data.push(d.d1Status)
|
this.chartData.status[1].data.push(d.d2Status)
|
})
|
},
|
|
initTable: function() {
|
CheckBox.newCheckBox('history_table_factorbox', Util.selectOptions3[this.factorMode], this.defaultIndex, this.onCheckTable.bind(this))
|
},
|
onCheckTable: function(obj) {
|
Table.onChangeTh(obj.value, obj.checked)
|
},
|
|
refreshTable: function() {
|
Table.table('history_table', this.electricDataList, this.factorMode, {}, function(trC, d, indexs) {
|
var td = $('<td></td>')
|
td.append(d.time.split(' ')[1])
|
trC.append(td)
|
|
td = $('<td></td>')
|
td.append(d.d1StatusName)
|
td.prop("index", '1')
|
trC.append(td)
|
if (indexs.indexOf("1") != -1) {
|
td.show("fast")
|
} else {
|
td.hide("fast")
|
}
|
td = $('<td></td>')
|
td.append(d.d1Avg)
|
td.prop("index", '2')
|
trC.append(td)
|
if (indexs.indexOf("2") != -1) {
|
td.show("fast")
|
} else {
|
td.hide("fast")
|
}
|
// td = $('<td></td>')
|
// td.append(d.d1eB)
|
// trC.append(td)
|
// if (indexs.indexOf("3") != -1) {
|
// td.show("fast")
|
// } else {
|
// td.hide("fast")
|
// }
|
// td = $('<td></td>')
|
// td.append(d.d1eC)
|
// trC.append(td)
|
// if (indexs.indexOf("4") != -1) {
|
// td.show("fast")
|
// } else {
|
// td.hide("fast")
|
// }
|
|
td = $('<td></td>')
|
td.append(d.d2StatusName)
|
td.prop("index", '5')
|
trC.append(td)
|
if (indexs.indexOf("5") != -1) {
|
td.show("fast")
|
} else {
|
td.hide("fast")
|
}
|
td = $('<td></td>')
|
td.append(d.d2Avg)
|
td.prop("index", '6')
|
trC.append(td)
|
if (indexs.indexOf("6") != -1) {
|
td.show("fast")
|
} else {
|
td.hide("fast")
|
}
|
// td = $('<td></td>')
|
// td.append(d.d2eB)
|
// trC.append(td)
|
// if (indexs.indexOf("7") != -1) {
|
// td.show("fast")
|
// } else {
|
// td.hide("fast")
|
// }
|
// td = $('<td></td>')
|
// td.append(d.d2eC)
|
// trC.append(td)
|
// if (indexs.indexOf("8") != -1) {
|
// td.show("fast")
|
// } else {
|
// td.hide("fast")
|
// }
|
}, this.defaultIndex)
|
$('#table_data_count').text('数据量:' + this.electricDataList.length + '个,单页:200个')
|
},
|
}
|