/** * 企业用电量监测 */ function ElectrictyMode(options) { this.companys this.showingSites = [] this.deviceName = { '31011020210601': '废气净化装置', '31011020210602': '产线风机', '31011020210603': '产线喷漆房', '31011020210604': '废气净化装置', } this.deviceCodes = ['31011020210601', '31011020210602', '31011020210603', '31011020210604'] this.cIds = [ ['麦格纳汽车镜像(上海)有限公司', '15xCtnjxa9pfmDSj'], ['上海慧嵘五金有限公司', 'J3euwNl19WZvH7iE'], ] this.historyMode = options.historyMode this.timePicker = options.timePicker } ElectrictyMode.prototype = { init: function () { this.getStats() this.dailyAnalysis() }, enable: function () { this.isEnable = true this.uiChange(true) // var k = Object.keys(this.companys) // if (k[0] != undefined) { // this.showData(this.companys[k[0]].code) // } if (this.electrictyUtil == undefined) { var that = this this.electrictyUtil = new ElectrictyUtil({ lineChart: that.historyMode.lineChart, chartSlider: that.historyMode.slider, pageSize: that.historyMode.pageSize }) } this.electrictyUtil.init() }, disable: function () { this.isEnable = false this.uiChange(false) Object.keys(this.companys).forEach(k => { this._hideSite(this.companys[k].code) }); }, deviceStatus: function (code, data) { var t = 0 var c = data.length data.forEach(d => { t += d }); var ave = c == 0 ? 0 : t / c var values = [1, 100] var status = ['待机', '运行', '超负荷'] switch (code) { case '31011020210601': values = [1, 100] status = ['待机', '运行', '超负荷'] break; case '31011020210602': values = [13, 30] status = ['待机', '运行', '超负荷'] break; case '31011020210603': values = [1, 50, 80] status = ['待机', '低负荷运行', '运行', '超负荷'] break; case '31011020210604': values = [15, 90, 125] status = ['待机', '低负荷运行', '运行', '超负荷'] break; default: values = [1, 100] break; } for (let i = 0; i < values.length; i++) { const v = values[i]; if (ave < v) { return status[i] } } return status[status.length - 1] }, getStats: function () { this.companys = { '15xCtnjxa9pfmDSj': { name: '麦格纳汽车镜像(上海)有限公司', code: '15xCtnjxa9pfmDSj', company: { }, show: false, data: '', location: [0, 0], // 地图标记点 marker: '', // 标记点信息窗体 infoWindow: '' }, 'J3euwNl19WZvH7iE': { name: '上海慧嵘五金有限公司', code: 'J3euwNl19WZvH7iE', company: { }, show: false, data: '', location: [0, 0], // 地图标记点 marker: '', // 标记点信息窗体 infoWindow: '' }, } var that = this var group = $('#electricity_sites') group.empty() Object.keys(this.companys).forEach(k => { var s = this.companys[k] var d1 = $('
') var check = $('') check.attr('id', s.code) check.attr('value', s.code) check.on('click', function () { var code = $(this).val() that.showData(code) }) var label = $('