123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340 |
- $(".form-control").datepicker({
- format: 'yyyy-mm-dd',
- language: 'zh-CN',
- autoclose: true,
- todayBtn: 'linked'
- }).on('changeDate', function () {
- }).on('keydown', function (e) {
- return false;
- });
- var zTreeObj;
- var setting = {
- check: {
- enable: true
- },
- view: {
- showIcon: false
- }
- };
- $.ajax({
- url: "/ProductionLine/GetProductionLineMachineTree",
- type: "GET",
- async: true,
- success: function (zNodes) {
- zTreeObj = $.fn.zTree.init($("#productionLineTree"), setting, zNodes);
- }
- });
- function getEnergyConsumptions() {
- var nodes = zTreeObj.getCheckedNodes(true);
- if (nodes.length === 0) {
- alert("请勾选设备!");
- return;
- }
- var ids = new Array();
- for (var i = 0; i < nodes.length; i++) {
- if (nodes[i].level === 1) {
- ids.push(nodes[i].id);
- }
- }
- if (ids.length === 0) {
- alert("请勾选设备!");
- return;
- }
- var startTime = $("#date1").val();
- var endTime = $("#date2").val();
- $.ajax({
- url: "/EnergyConsumption/GetEnergyConsumptionDtoByMes",
- type: "POST",
- async: true,
- data: {
- "ids": ids.toString(),
- "startTime": startTime,
- "endTime": endTime
- },
- success: function (rev) {
- if (rev.code === 0) {
- option.series = [];
- setX(rev.data.x);
- setLegend(rev.data.legend);
- for (var i = 0; i < rev.data.series.length; i++) {
- addSerie(rev.data.series[i].name, "line", rev.data.series[i].data, 0, " kW·h", rev.data.series[i].id);
- }
- myChart.setOption(option, true);
- }
- }
- });
- option2.series = [];
- myChart2.setOption(option2, true);
- option3.series = [];
- myChart3.setOption(option3, true);
- }
- function setLegend(legend) {
- option.legend.data = legend;
- }
- function getHourEnergyConsumptions(id, time) {
- $.ajax({
- url: "/EnergyConsumption/GetHourEnergyConsumptionByMes",
- type: "POST",
- async: true,
- data: {
- "id": id,
- "time": time
- },
- success: function (rev) {
- if (rev.code === 0) {
- if (rev.data.series < 3) {
- return;
- }
- $("#chartName2").text(rev.data.chartName + " 能耗/产能小时曲线");
- option2.series = [];
- addSerie2(rev.data.series[0].name, "line", rev.data.series[0].data, 0, " kW·h");
- addSerie2(rev.data.series[1].name, "line", rev.data.series[1].data, 1, " pcs");
- myChart2.setOption(option2, true);
-
- $("#chartName3").text(rev.data.chartName + " 能耗产能比");
- option3.series = [];
- addSerie3(rev.data.series[2].name, "line", rev.data.series[2].data, 0, " kW·h/pcs");
- myChart3.setOption(option3, true);
- }
- }
- });
- }
- var dom = document.getElementById('container1');
- var myChart = echarts.init(dom, 'dark');
- var option;
- option = {
- backgroundColor: '#001529',
- tooltip: {
- trigger: 'axis'
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- legend: {
- data: []
- },
- toolbox: {
- feature: {
- dataZoom: { yAxisIndex: 'none' },
- restore: {},
- saveAsImage: {}
- }
- },
- textStyle: {
- "fontSize": 16
- },
- xAxis: {
- type: 'category',
- /*boundaryGap: false,*/
- axisLabel:{
- /*interval: 0,*/
- fontSize: 16,
- formatter: function (value) {
- return value.substring(5, 13)
- }
- }
- },
- yAxis: {
- type: 'value',
- name: '能耗',
- axisLabel: {
- fontSize: 16,
- formatter: '{value} Kw·h'
- }
- },
- series: []
- };
- myChart.on('click', function (params) {
- //console.log(params);
- getHourEnergyConsumptions(params.seriesId, params.name);
- });
- if (option && typeof option === 'object') {
- myChart.setOption(option);
- }
- window.addEventListener('resize', myChart.resize);
- function setX(x) {
- option.xAxis.data = x;
- }
- function addSerie(name, type, data, yIndex, company, id) {
- var serie = {
- id: id,
- name: name,
- type: type,
- yAxisIndex: yIndex,
- tooltip: {
- valueFormatter: function (value) {
- return value + company;
- }
- },
- label: {
- show: true
- },
- data: data
- }
- option.series.push(serie);
- }
- var dom2 = document.getElementById('container2');
- var myChart2 = echarts.init(dom2, 'dark');
- var option2;
- option2 = {
- backgroundColor: '#001529',
- tooltip: {
- trigger: 'axis'
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- legend: {
- data: []
- },
- toolbox: {
- feature: {
- dataZoom: { yAxisIndex: 'none' },
- restore: {},
- saveAsImage: {}
- }
- },
- textStyle: {
- "fontSize": 16
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- axisLabel: {
- fontSize: 16,
- interval: 0,
- //formatter: function (value) {
- // return value.substring(11, 13)
- //}
- }
- },
- yAxis: [
- {
- type: 'value',
- name: '能耗',
- axisLabel: {
- fontSize: 16,
- formatter: '{value} kW·h'
- }
- },
- {
- type: 'value',
- name: '产能',
- axisLabel: {
- fontSize: 16,
- formatter: '{value} pcs'
- }
- }
- ],
- series: []
- };
- if (option2 && typeof option === 'object') {
- myChart2.setOption(option);
- }
- window.addEventListener('resize', myChart2.resize);
- function addSerie2(name, type, data, yIndex, company) {
- var serie = {
- name: name,
- type: type,
- yAxisIndex: yIndex,
- //stack: 'Total',
- tooltip: {
- valueFormatter: function (value) {
- return value + company;
- }
- },
- data: data
- }
- option2.series.push(serie);
- }
- var dom3 = document.getElementById('container3');
- var myChart3 = echarts.init(dom3, 'dark');
- var option3;
- option3 = {
- backgroundColor: '#001529',
- tooltip: {
- trigger: 'axis'
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- containLabel: true
- },
- legend: {
- data: []
- },
- toolbox: {
- feature: {
- dataZoom: { yAxisIndex: 'none' },
- restore: {},
- saveAsImage: {}
- }
- },
- textStyle: {
- "fontSize": 16
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- axisLabel: {
- interval: 0,
- fontSize: 16,
- //formatter: function (value) {
- // return value.substring(11, 13)
- //}
- }
- },
- yAxis: {
- type: 'value',
- name: '能耗/产能',
- axisLabel: {
- fontSize: 16,
- formatter: '{value} kW·h/pcs'
- }
- },
- series: []
- };
- if (option3 && typeof option === 'object') {
- myChart3.setOption(option);
- }
- window.addEventListener('resize', myChart3.resize);
- function addSerie3(name, type, data, yIndex, company) {
- var serie = {
- name: name,
- type: type,
- yAxisIndex: yIndex,
- tooltip: {
- valueFormatter: function (value) {
- return value + company;
- }
- },
- data: data
- }
- option3.series.push(serie);
- }
|