瀏覽代碼

修复响应预案图形展示bug

klzhangweiya 2 年之前
父節點
當前提交
240b8a3acf

+ 84 - 79
VbdsmUI_V2.1.1/src/pc/powerservice/demandresponseplan/demand_response_execute.js

@@ -31,9 +31,9 @@ var projectId = undefined,
 	_endTime,
 	_responseLoad
 //响应预案表格
-$("#plan-project-dategrid").datagrid({
+$('#plan-project-dategrid').datagrid({
 	//	url:'/web/demand/plan/project/getAll.json',
-	title: "需求响应预案",
+	title: '需求响应预案',
 	fit: true,
 	fitcolumns: true,
 	rownumbers: false,
@@ -45,26 +45,26 @@ $("#plan-project-dategrid").datagrid({
 	pageSize: 10,
 	columns: [
 		[
-			{ field: "title", title: "标题", width: 250, align: "left" },
+			{ field: 'title', title: '标题', width: 250, align: 'left' },
 			{
-				field: "sampleDate",
-				title: "样本日期",
+				field: 'sampleDate',
+				title: '样本日期',
 				width: 120,
-				align: "center",
+				align: 'center',
 				formatter: function (value, row, index) {
-					return new Date(value.toString().substr(0, 4), parseInt(value.toString().substr(4, 2)) - 1, value.toString().substr(6, 2)).format("yyyy-MM-dd")
+					return new Date(value.toString().substr(0, 4), parseInt(value.toString().substr(4, 2)) - 1, value.toString().substr(6, 2)).format('yyyy-MM-dd')
 				},
 			},
-			{ field: "startTime", title: "开始时间", width: 100, align: "center" },
-			{ field: "endTime", title: "结束时间", width: 100, align: "center" },
-			{ field: "responseLoad", title: "响应负荷", width: 100, align: "center" },
+			{ field: 'startTime', title: '开始时间', width: 100, align: 'center' },
+			{ field: 'endTime', title: '结束时间', width: 100, align: 'center' },
+			{ field: 'responseLoad', title: '响应负荷', width: 100, align: 'center' },
 			{
-				field: "operate",
-				title: "操作",
+				field: 'operate',
+				title: '操作',
 				width: 100,
-				align: "center",
+				align: 'center',
 				formatter: function (value, row, index) {
-					return '<a href="#" onclick=\'executePlan(' + row.id + "," + row.sampleDate + ',"' + row.startTime + '","' + row.endTime + '",' + row.responseLoad + ")'>执行预案</a>"
+					return '<a href="#" onclick=\'executePlan(' + row.id + ',' + row.sampleDate + ',"' + row.startTime + '","' + row.endTime + '",' + row.responseLoad + ")'>执行预案</a>"
 				},
 			},
 		],
@@ -72,7 +72,7 @@ $("#plan-project-dategrid").datagrid({
 })
 
 function initGridData() {
-	var p = $("#plan-project-dategrid").datagrid("getPager")
+	var p = $('#plan-project-dategrid').datagrid('getPager')
 	//设置分页组件参数
 	$(p).pagination({
 		pageSize: 20,
@@ -82,19 +82,19 @@ function initGridData() {
 			loadPlanProjectData(pageNumber, pageSize)
 		},
 	})
-	var obj = $(p).pagination("options")
+	var obj = $(p).pagination('options')
 	loadPlanProjectData(obj.pageNumber, obj.pageSize)
 }
 
 function loadPlanProjectData(pageNumber, pageSize) {
 	ajax({
-		url: "/web/demand/plan/project/getAll.json",
-		dataType: "json",
+		url: '/web/demand/plan/project/getAll.json',
+		dataType: 'json',
 		cache: false,
 		data: { page: pageNumber, rows: pageSize },
 		success: function (data) {
 			if (data.status == 1) {
-				$("#plan-project-dategrid").datagrid("loadData", data.data)
+				$('#plan-project-dategrid').datagrid('loadData', data.data)
 			} else {
 				toast(data.msg)
 			}
@@ -104,39 +104,39 @@ function loadPlanProjectData(pageNumber, pageSize) {
 
 //执行预案
 function executePlan(id, date, start, end, responseLoad) {
-	$("#imageShow").mask("正在加载数据...")
+	$('#imageShow').mask('正在加载数据...')
 	_responseLoad = responseLoad
 	_execute = undefined
 	;(_startTime = start.substr(0, 2) + start.substr(3, 2)), (_endTime = end.substr(0, 2) + end.substr(3, 2))
 	projectId = id
-	$(".sampleDate")
+	$('.sampleDate')
 		.empty()
-		.html("样本日期【" + new Date(date.toString().substr(0, 4), parseInt(date.toString().substr(4, 2)) - 1, date.toString().substr(6, 2)).format("yyyy年MM月dd日") + "】")
-	$("#date").show()
-	$("#btn").show()
-	$("#executeDate").datebox("setValue", new Date().format("yyyy-MM-dd"))
+		.html('样本日期【' + new Date(date.toString().substr(0, 4), parseInt(date.toString().substr(4, 2)) - 1, date.toString().substr(6, 2)).format('yyyy年MM月dd日') + '】')
+	$('#date').show()
+	$('#btn').show()
+	$('#executeDate').datebox('setValue', new Date().format('yyyy-MM-dd'))
 
 	//构建图表数据
 	var chartData = new Array(),
 		categories = new Array()
 	for (var i = 0; i < 24; i++) {
 		for (var j = 0; j <= 55; j += 5) {
-			categories.push((i < 10 ? "0" + i : i) + ":" + (j < 10 ? "0" + j : j))
+			categories.push((i < 10 ? '0' + i : i) + ':' + (j < 10 ? '0' + j : j))
 		}
 	}
 	var seriesData = getMonitorLoadData(date, 1)
-	chartData.push({ name: "控制负荷", data: seriesData }) //样本负荷数据
+	chartData.push({ name: '控制负荷', data: seriesData }) //样本负荷数据
 	var simulationData = getMonitorTestData(date)
-	chartData.push({ name: "测算负荷", data: simulationData }) //测算负荷数据
+	chartData.push({ name: '测算负荷', data: simulationData }) //测算负荷数据
 
 	showChart(categories, chartData)
 	//更新表格数据
-	$($("#plan-monitor-dategrid").datagrid("getRows")).each(function (index, row) {
+	$($('#plan-monitor-dategrid').datagrid('getRows')).each(function (index, row) {
 		row.forecast = loadMap.get(row.monitorId)
-		$("#plan-monitor-dategrid").datagrid("updateRow", { index: index, row: row })
+		$('#plan-monitor-dategrid').datagrid('updateRow', { index: index, row: row })
 	})
 
-	$("#imageShow").unmask()
+	$('#imageShow').unmask()
 }
 
 //加载报表数据
@@ -146,9 +146,9 @@ function getMonitorLoadData(date, type) {
 	var seriesData = new Array()
 	if (type == 1) sampleChartDataMap.clear()
 	ajax({
-		url: "/web/demand/plan/getP.json",
-		type: "POST",
-		dataType: "json",
+		url: '/web/demand/plan/getP.json',
+		type: 'POST',
+		dataType: 'json',
 		cache: false,
 		async: false,
 		data: { day: date },
@@ -158,6 +158,7 @@ function getMonitorLoadData(date, type) {
 				$.each(data.data, function (index, data) {
 					//if(type == 0) monitorMap.put(data.code, data.value);
 					$.each(data.value, function (index, obj) {
+						obj.value = Number(obj.value) || 0
 						if (chartDataMap.containsKey(obj.code)) {
 							value = chartDataMap.get(obj.code) + obj.value
 							chartDataMap.put(obj.code, value)
@@ -188,7 +189,7 @@ function getMonitorTestData(sampleDate) {
 	pMap = getMonitorP(sampleDate, gridMap)
 	for (var i = 0; i < 24; i++) {
 		for (var j = 0; j < 60; j += 5) {
-			var key = (i < 10 ? "0" + i : i) + "" + (j < 10 ? "0" + j : j)
+			var key = (i < 10 ? '0' + i : i) + '' + (j < 10 ? '0' + j : j)
 			if (parseInt(key) > parseInt(_startTime) && parseInt(key) < parseInt(_endTime)) {
 				var coefficient = 0
 				for (var m = 0; m < gridMap.size(); m++) {
@@ -198,7 +199,9 @@ function getMonitorTestData(sampleDate) {
 						coefficient += map.get(key) * (1 - element.value)
 					}
 				}
-				simulationData.push(parseFloat((sampleChartDataMap.get(key) - coefficient).toFixed(2)))
+				//simulationData.push(parseFloat((sampleChartDataMap.get(key) - coefficient).toFixed(2)))
+				var p = parseFloat(((sampleChartDataMap.get(key) || 0) - (coefficient || 0)).toFixed(2))
+				simulationData.push(p)
 			} else {
 				simulationData.push(null)
 			}
@@ -209,32 +212,34 @@ function getMonitorTestData(sampleDate) {
 
 //获取预案监测点数据
 function getMonitorP(sampleDate, gridMap) {
-	var monitorIds = "",
+	var monitorIds = '',
 		pMap = new Map(),
 		gridData = getMonitorData(projectId)
 	$(gridData).each(function (index, row) {
 		if (gridMap) gridMap.put(row.monitorId, row.ratio)
 		monitorIds += row.monitorId
 		if (index < gridData.length - 1) {
-			monitorIds += ","
+			monitorIds += ','
 		}
 	})
 
 	ajax({
-		url: "/web/demand/plan/getMonitorP.json",
-		type: "POST",
-		dataType: "json",
+		url: '/web/demand/plan/getMonitorP.json',
+		type: 'POST',
+		dataType: 'json',
 		cache: false,
 		async: false,
 		data: { day: sampleDate, monitorIds: monitorIds },
 		success: function (data) {
 			if (data.status == 1) {
 				loadMap.clear()
+				console.log(data.data)
 				$(data.data).each(function (index, data) {
 					var map = new Map(),
 						loadValue = 0,
 						count = 0
 					$(data.value).each(function (index, obj) {
+						obj.value = Number(obj.value) || 0
 						map.put(obj.code, obj.value)
 						if (parseInt(obj.code) > parseInt(_startTime) && parseInt(obj.code) < parseInt(_endTime)) {
 							loadValue += obj.value
@@ -251,7 +256,7 @@ function getMonitorP(sampleDate, gridMap) {
 }
 
 function createPlanMonitorDateGride() {
-	$("#plan-monitor-dategrid").datagrid({
+	$('#plan-monitor-dategrid').datagrid({
 		fit: true,
 		fitcolumns: true,
 		rownumbers: false,
@@ -262,27 +267,27 @@ function createPlanMonitorDateGride() {
 		columns: [
 			[
 				{
-					field: "monitorId",
-					title: "设备名称",
+					field: 'monitorId',
+					title: '设备名称',
 					width: 250,
-					align: "center",
+					align: 'center',
 					formatter: function (value, row, index) {
 						return monitorNameMap.get(value)
 					},
 				},
 				{
-					field: "state",
-					title: "计划状态",
+					field: 'state',
+					title: '计划状态',
 					width: 150,
-					align: "center",
+					align: 'center',
 					formatter: function (value, row, index) {
-						if (value == 1) return "停机"
-						else if (value == 2) return "待机"
-						else if (value == 3) return "减负"
+						if (value == 1) return '停机'
+						else if (value == 2) return '待机'
+						else if (value == 3) return '减负'
 					},
 				},
-				{ field: "forecast", title: "预测负荷(kW)", width: 150, align: "center" },
-				{ field: "practical", title: "实际负荷(kW)", width: 150, align: "center" },
+				{ field: 'forecast', title: '预测负荷(kW)', width: 150, align: 'center' },
+				{ field: 'practical', title: '实际负荷(kW)', width: 150, align: 'center' },
 			],
 		],
 	})
@@ -292,14 +297,14 @@ function createPlanMonitorDateGride() {
 function getMonitorData(projectId) {
 	var monitorData = {}
 	ajax({
-		url: "/web/demand/plan/monitor/getAll/" + projectId + ".json",
-		dataType: "json",
+		url: '/web/demand/plan/monitor/getAll/' + projectId + '.json',
+		dataType: 'json',
 		cache: false,
 		async: false,
 		success: function (data) {
 			monitorData = data.data
 			if (_execute == undefined) {
-				$("#plan-monitor-dategrid").datagrid("loadData", data.data)
+				$('#plan-monitor-dategrid').datagrid('loadData', data.data)
 				_execute = 1
 			}
 		},
@@ -308,37 +313,37 @@ function getMonitorData(projectId) {
 }
 
 //模拟数据
-$("#btnSimulation").click(function () {
-	$("#imageShow").mask("正在加载数据...")
-	var executeDate = new Date($("#executeDate").datebox("getValue")).format("yyyyMMdd")
+$('#btnSimulation').click(function () {
+	$('#imageShow').mask('正在加载数据...')
+	var executeDate = new Date($('#executeDate').datebox('getValue')).format('yyyyMMdd')
 	var realTimeLoad = getMonitorLoadData(executeDate, 0)
 	getMonitorP(executeDate)
 
 	//更新表格数据
-	$($("#plan-monitor-dategrid").datagrid("getRows")).each(function (index, row) {
+	$($('#plan-monitor-dategrid').datagrid('getRows')).each(function (index, row) {
 		row.practical = loadMap.get(row.monitorId)
-		$("#plan-monitor-dategrid").datagrid("updateRow", { index: index, row: row })
+		$('#plan-monitor-dategrid').datagrid('updateRow', { index: index, row: row })
 	})
 
-	var chart = $("#showchart").highcharts()
+	var chart = $('#showchart').highcharts()
 	var seriesList = chart.series //获得图表的所有序列
 	if (seriesList.length > 2) {
 		//多条线时先删除新添加线条
 		chart.series[seriesList.length - 1].remove()
 	}
 	chart.addSeries({
-		name: "实时负荷",
+		name: '实时负荷',
 		data: realTimeLoad,
 	})
 
-	$("#imageShow").unmask()
+	$('#imageShow').unmask()
 })
 
 //显示图表
 function showChart(categories, series) {
-	$("#showchart").highcharts({
+	$('#showchart').highcharts({
 		title: {
-			text: "企业需求响应预案执行",
+			text: '企业需求响应预案执行',
 			x: -20,
 		},
 		xAxis: {
@@ -347,13 +352,13 @@ function showChart(categories, series) {
 		},
 		yAxis: {
 			title: {
-				text: "负荷(kW)",
+				text: '负荷(kW)',
 			},
 			plotLines: [
 				{
 					value: 0,
 					width: 1,
-					color: "#808080",
+					color: '#808080',
 				},
 			],
 		},
@@ -361,22 +366,22 @@ function showChart(categories, series) {
 			crosshairs: [true, true],
 			shared: true,
 			formatter: function () {
-				var s = "<b>" + this.x + "</b>"
+				var s = '<b>' + this.x + '</b>'
 				$.each(this.points, function () {
-					s += "<br/>" + this.series.name + ": " + this.y.toFixed(2) + "(kW)"
+					s += '<br/>' + this.series.name + ': ' + this.y.toFixed(2) + '(kW)'
 				})
 				return s
 			},
 		},
 		legend: {
-			layout: "horizontal",
-			align: "center",
-			verticalAlign: "bottom",
+			layout: 'horizontal',
+			align: 'center',
+			verticalAlign: 'bottom',
 			borderWidth: 0,
 		},
 		series: series,
 	})
-	$("#imageShow").unmask()
+	$('#imageShow').unmask()
 }
 
 //将监测点数据放入MAP
@@ -395,9 +400,9 @@ function getNodeToMap(nodes) {
 $(document).ready(function () {
 	initGridData()
 	ajax({
-		url: "/web/getMonitorTree/outher.json",
-		type: "POST",
-		dataType: "json",
+		url: '/web/getMonitorTree/outher.json',
+		type: 'POST',
+		dataType: 'json',
 		cache: false,
 		async: false,
 		success: function (data) {
@@ -414,8 +419,8 @@ $(document).ready(function () {
 
 //窗口大小变化时延时刷新图片大小
 $(window).resize(function () {
-	if ($("#showchart").highcharts()) {
-		$("#showchart").highcharts().setSize($(window).width(), 300, true)
+	if ($('#showchart').highcharts()) {
+		$('#showchart').highcharts().setSize($(window).width(), 300, true)
 	}
 	/*window.resizeTimer = setTimeout(function() {
 		window.clearTimeout(window.resizeTimer);

+ 184 - 173
VbdsmUI_V2.1.1/src/pc/powerservice/demandresponseplan/demand_response_plan.js

@@ -26,8 +26,8 @@
 
 //重写datebox渲染事件
 $.fn.datebox.defaults.parser = function (value) {
-	if ("" != value && undefined != value) {
-		if (value.toString().indexOf("-") > 0) return new Date(value)
+	if ('' != value && undefined != value) {
+		if (value.toString().indexOf('-') > 0) return new Date(value)
 		else return new Date(value.toString().substr(0, 4), parseInt(value.toString().substr(4, 2)) - 1, value.toString().substr(6, 2))
 	} else {
 		return new Date()
@@ -38,26 +38,26 @@ $.fn.datebox.defaults.parser = function (value) {
 $.extend($.fn.datagrid.defaults.editors, {
 	combotree: {
 		init: function (container, options) {
-			var box = $("<input />").appendTo(container)
+			var box = $('<input />').appendTo(container)
 			box.combotree(options)
 			return box
 		},
 		getValue: function (target) {
-			var t = $(target).combotree("tree", target)
-			var n = t.tree("getSelected")
+			var t = $(target).combotree('tree', target)
+			var n = t.tree('getSelected')
 			return n.id
 		},
 		setValue: function (target, value) {
 			if (value) {
-				$(target).combotree("setValue", value)
+				$(target).combotree('setValue', value)
 			}
 		},
 		resize: function (target, width) {
 			var box = $(target)
-			box.combotree("resize", width)
+			box.combotree('resize', width)
 		},
 		destroy: function (target) {
-			$(target).combotree("destroy")
+			$(target).combotree('destroy')
 		},
 	},
 })
@@ -69,11 +69,11 @@ var projectIndex = undefined,
 	_startTime,
 	_endTime
 //响应预案表格
-$("#plan-project-dategrid").datagrid({
+$('#plan-project-dategrid').datagrid({
 	//	url:'/demand/plan/project/getAll.json',
 	fit: true,
 	//fitcolumns:true,
-	toolbar: "#menu_project",
+	toolbar: '#menu_project',
 	rownumbers: false,
 	animate: true,
 	selectOnCheck: false,
@@ -83,44 +83,44 @@ $("#plan-project-dategrid").datagrid({
 	pageSize: 10,
 	columns: [
 		[
-			{ field: "title", title: "标题", width: 250, align: "left", editor: { type: "validatebox", options: { required: true } } },
+			{ field: 'title', title: '标题', width: 250, align: 'left', editor: { type: 'validatebox', options: { required: true } } },
 			{
-				field: "sampleDate",
-				title: "样本日期",
+				field: 'sampleDate',
+				title: '样本日期',
 				width: 120,
-				align: "center",
-				editor: { type: "datebox", options: { required: true } },
+				align: 'center',
+				editor: { type: 'datebox', options: { required: true } },
 				formatter: function (value, row, index) {
-					if (value != null) return new Date(value.toString().substr(0, 4), parseInt(value.toString().substr(4, 2)) - 1, value.toString().substr(6, 2)).format("yyyy-MM-dd")
+					if (value != null) return new Date(value.toString().substr(0, 4), parseInt(value.toString().substr(4, 2)) - 1, value.toString().substr(6, 2)).format('yyyy-MM-dd')
 				},
 			},
-			{ field: "startTime", title: "开始时间", width: 100, align: "center", editor: { type: "timespinner", options: { required: true, showSeconds: false } } },
-			{ field: "endTime", title: "结束时间", width: 100, align: "center", editor: { type: "timespinner", options: { required: true, showSeconds: false } } },
-			{ field: "responseLoad", title: "响应负荷", width: 100, align: "center", editor: { type: "numberbox", options: { required: true, precision: 0 } } },
+			{ field: 'startTime', title: '开始时间', width: 100, align: 'center', editor: { type: 'timespinner', options: { required: true, showSeconds: false } } },
+			{ field: 'endTime', title: '结束时间', width: 100, align: 'center', editor: { type: 'timespinner', options: { required: true, showSeconds: false } } },
+			{ field: 'responseLoad', title: '响应负荷', width: 100, align: 'center', editor: { type: 'numberbox', options: { required: true, precision: 0 } } },
 			{
-				field: "operate",
-				title: "操作",
+				field: 'operate',
+				title: '操作',
 				width: 100,
-				align: "center",
+				align: 'center',
 				formatter: function (value, row, index) {
-					return '<a href="#" onclick=\'setMonitor(' + row.id + "," + row.sampleDate + ',"' + row.startTime + '","' + row.endTime + "\")'>设置</a>"
+					return '<a href="#" onclick=\'setMonitor(' + row.id + ',' + row.sampleDate + ',"' + row.startTime + '","' + row.endTime + '")\'>设置</a>'
 				},
 			},
 		],
 	],
 	onClickRow: function (rowIndex, rowData) {
-		if (projectIndex != undefined) $("#plan-project-dategrid").datagrid("selectRow", projectIndex)
+		if (projectIndex != undefined) $('#plan-project-dategrid').datagrid('selectRow', projectIndex)
 	},
 	onDblClickRow: function (index, row) {
 		if (projectIndex == undefined) {
-			$("#plan-project-dategrid").datagrid("beginEdit", index)
+			$('#plan-project-dategrid').datagrid('beginEdit', index)
 			projectIndex = index
 		}
 	},
 })
 
 function initGridData() {
-	var p = $("#plan-project-dategrid").datagrid("getPager")
+	var p = $('#plan-project-dategrid').datagrid('getPager')
 	//设置分页组件参数
 	$(p).pagination({
 		pageSize: 20,
@@ -130,19 +130,19 @@ function initGridData() {
 			loadPlanProjectData(pageNumber, pageSize)
 		},
 	})
-	var obj = $(p).pagination("options")
+	var obj = $(p).pagination('options')
 	loadPlanProjectData(obj.pageNumber, obj.pageSize)
 }
 
 function loadPlanProjectData(pageNumber, pageSize) {
 	ajax({
-		url: "/web/demand/plan/project/getAll.json",
-		dataType: "json",
+		url: '/web/demand/plan/project/getAll.json',
+		dataType: 'json',
 		cache: false,
 		data: { page: pageNumber, rows: pageSize },
 		success: function (data) {
 			if (data.status == 1) {
-				$("#plan-project-dategrid").datagrid("loadData", data.data)
+				$('#plan-project-dategrid').datagrid('loadData', data.data)
 			} else {
 				toast(data.msg)
 			}
@@ -151,50 +151,50 @@ function loadPlanProjectData(pageNumber, pageSize) {
 }
 
 //添加需求响应预案
-$("#btnAdd").linkbutton({
+$('#btnAdd').linkbutton({
 	onClick: function () {
 		if (endProjectEditing()) {
-			$("#plan-project-dategrid").datagrid("appendRow", { id: "" })
-			projectIndex = $("#plan-project-dategrid").datagrid("getRows").length - 1
-			$("#plan-project-dategrid").datagrid("selectRow", projectIndex).datagrid("beginEdit", projectIndex)
+			$('#plan-project-dategrid').datagrid('appendRow', { id: '' })
+			projectIndex = $('#plan-project-dategrid').datagrid('getRows').length - 1
+			$('#plan-project-dategrid').datagrid('selectRow', projectIndex).datagrid('beginEdit', projectIndex)
 		} else {
-			alert("请保存当前正在编辑的行。")
+			alert('请保存当前正在编辑的行。')
 		}
 	},
 })
 
 //编辑需求响应预案
-$("#btnModify").linkbutton({
+$('#btnModify').linkbutton({
 	onClick: function () {
-		var row = $("#plan-project-dategrid").datagrid("getSelected")
-		var rowIndex = $("#plan-project-dategrid").datagrid("getRowIndex", row)
-		$("#plan-project-dategrid").datagrid("beginEdit", rowIndex)
+		var row = $('#plan-project-dategrid').datagrid('getSelected')
+		var rowIndex = $('#plan-project-dategrid').datagrid('getRowIndex', row)
+		$('#plan-project-dategrid').datagrid('beginEdit', rowIndex)
 		projectIndex = rowIndex
 	},
 })
 
 //保存需求响应预案
-$("#btnSave").click(function () {
+$('#btnSave').click(function () {
 	if (projectIndex == undefined) return
-	if ($("#plan-project-dategrid").datagrid("validateRow", projectIndex)) {
-		$("#plan-project-dategrid").datagrid("endEdit", projectIndex) //使用JSON序列化datarow对象,发送到后台。
-		var row = $("#plan-project-dategrid").datagrid("getSelected")
+	if ($('#plan-project-dategrid').datagrid('validateRow', projectIndex)) {
+		$('#plan-project-dategrid').datagrid('endEdit', projectIndex) //使用JSON序列化datarow对象,发送到后台。
+		var row = $('#plan-project-dategrid').datagrid('getSelected')
 		ajax({
-			url: "/web/demand/plan/project/saveOne.json",
-			type: "POST",
+			url: '/web/demand/plan/project/saveOne.json',
+			type: 'POST',
 			data: {
 				id: row.id,
 				title: row.title,
-				sampleDate: new Date(row.sampleDate).format("yyyyMMdd"),
+				sampleDate: new Date(row.sampleDate).format('yyyyMMdd'),
 				startTime: row.startTime,
 				endTime: row.endTime,
 				responseLoad: row.responseLoad,
 			},
 			success: function (data) {
 				if (data.status == 1) {
-					$("#plan-project-dategrid").datagrid("updateRow", { index: projectIndex, row: data.data }) //新增后更新当前行的ID值
+					$('#plan-project-dategrid').datagrid('updateRow', { index: projectIndex, row: data.data }) //新增后更新当前行的ID值
 				} else {
-					$("#plan-project-dategrid").datagrid("beginEdit", projectIndex)
+					$('#plan-project-dategrid').datagrid('beginEdit', projectIndex)
 				}
 				projectIndex = undefined
 				toast(data.msg)
@@ -204,23 +204,23 @@ $("#btnSave").click(function () {
 })
 
 //删除需求响应预案
-$("#btnDelete").click(function () {
-	var row = $("#plan-project-dategrid").datagrid("getSelected")
+$('#btnDelete').click(function () {
+	var row = $('#plan-project-dategrid').datagrid('getSelected')
 	if (!row) return
-	confirm("重要操作", "删除后,将导致某些关联数据无法显示。<br/>您确定要删除选中数据吗?", function (r) {
+	confirm('重要操作', '删除后,将导致某些关联数据无法显示。<br/>您确定要删除选中数据吗?', function (r) {
 		if (r) {
 			ajax({
-				url: "/web/demand/plan/project/delete/" + row.id + ".json",
+				url: '/web/demand/plan/project/delete/' + row.id + '.json',
 				success: function (data) {
-					var rowIndex = $("#plan-project-dategrid").datagrid("getRowIndex", row)
-					$("#plan-project-dategrid").datagrid("deleteRow", rowIndex)
+					var rowIndex = $('#plan-project-dategrid').datagrid('getRowIndex', row)
+					$('#plan-project-dategrid').datagrid('deleteRow', rowIndex)
 
-					$("#plan-monitor-dategrid").datagrid("loadData", [])
-					$("#btnSimulation").linkbutton("disable")
-					$("#btnAddMonitor").linkbutton("disable")
-					$("#btnSaveMonitor").linkbutton("disable")
-					$("#btnDeleteMonitor").linkbutton("disable")
-					$("#btnCancelMonitor").linkbutton("disable")
+					$('#plan-monitor-dategrid').datagrid('loadData', [])
+					$('#btnSimulation').linkbutton('disable')
+					$('#btnAddMonitor').linkbutton('disable')
+					$('#btnSaveMonitor').linkbutton('disable')
+					$('#btnDeleteMonitor').linkbutton('disable')
+					$('#btnCancelMonitor').linkbutton('disable')
 
 					toast(data.msg)
 				},
@@ -230,13 +230,13 @@ $("#btnDelete").click(function () {
 })
 
 //取消需求响应预案行编辑
-$("#btnCancel").click(function () {
-	var row = $("#plan-project-dategrid").datagrid("getSelected")
+$('#btnCancel').click(function () {
+	var row = $('#plan-project-dategrid').datagrid('getSelected')
 	if (!row) return
-	if (row.id != undefined && row.id != "") {
-		$("#plan-project-dategrid").datagrid("cancelEdit", projectIndex)
+	if (row.id != undefined && row.id != '') {
+		$('#plan-project-dategrid').datagrid('cancelEdit', projectIndex)
 	} else {
-		$("#plan-project-dategrid").datagrid("deleteRow", projectIndex)
+		$('#plan-project-dategrid').datagrid('deleteRow', projectIndex)
 	}
 	projectIndex = undefined
 })
@@ -246,8 +246,8 @@ function endProjectEditing() {
 	if (projectIndex == undefined) {
 		return true
 	}
-	if ($("#plan-project-dategrid").datagrid("validateRow", projectIndex)) {
-		$("#plan-project-dategrid").datagrid("endEdit", projectIndex)
+	if ($('#plan-project-dategrid').datagrid('validateRow', projectIndex)) {
+		$('#plan-project-dategrid').datagrid('endEdit', projectIndex)
 		projectIndex = undefined
 		return true
 	} else {
@@ -256,35 +256,35 @@ function endProjectEditing() {
 }
 
 function setMonitor(id, date, start, end) {
-	$("#imageShow").mask("正在加载数据...")
+	$('#imageShow').mask('正在加载数据...')
 	_sampleDate = date
 	;(_startTime = start.substr(0, 2) + start.substr(3, 2)), (_endTime = end.substr(0, 2) + end.substr(3, 2))
 	projectId = id
 	loadMonitorData(projectId)
 	loadMonitorP(date)
-	$(".sampleDate")
+	$('.sampleDate')
 		.empty()
-		.html("样本日期【" + new Date(date.toString().substr(0, 4), parseInt(date.toString().substr(4, 2)) - 1, date.toString().substr(6, 2)).format("yyyy年MM月dd日") + "】")
-	$("#btnSimulation").linkbutton("enable")
-	$("#btnAddMonitor").linkbutton("enable")
-	$("#btnSaveMonitor").linkbutton("enable")
-	$("#btnDeleteMonitor").linkbutton("enable")
-	$("#btnCancelMonitor").linkbutton("enable")
+		.html('样本日期【' + new Date(date.toString().substr(0, 4), parseInt(date.toString().substr(4, 2)) - 1, date.toString().substr(6, 2)).format('yyyy年MM月dd日') + '】')
+	$('#btnSimulation').linkbutton('enable')
+	$('#btnAddMonitor').linkbutton('enable')
+	$('#btnSaveMonitor').linkbutton('enable')
+	$('#btnDeleteMonitor').linkbutton('enable')
+	$('#btnCancelMonitor').linkbutton('enable')
 }
 
 function createPlanMonitorDateGride() {
 	var getTarget = function (dg, fieldName) {
-		var row = dg.datagrid("getSelected")
-		var rowIndex = dg.datagrid("getRowIndex", row)
-		var target = dg.datagrid("getEditor", { index: rowIndex, field: fieldName }).target
+		var row = dg.datagrid('getSelected')
+		var rowIndex = dg.datagrid('getRowIndex', row)
+		var target = dg.datagrid('getEditor', { index: rowIndex, field: fieldName }).target
 		return target
 	}
 	//监测点设定
-	var dg = $("#plan-monitor-dategrid").datagrid({
+	var dg = $('#plan-monitor-dategrid').datagrid({
 		fit: true,
 		border: false,
 		//fitcolumns:true,
-		toolbar: "#menu_monitor",
+		toolbar: '#menu_monitor',
 		rownumbers: false,
 		animate: true,
 		selectOnCheck: false,
@@ -294,18 +294,18 @@ function createPlanMonitorDateGride() {
 		columns: [
 			[
 				{
-					field: "monitorId",
-					title: "设备名称",
+					field: 'monitorId',
+					title: '设备名称',
 					width: 250,
-					align: "center",
+					align: 'center',
 					editor: {
-						type: "combotree",
+						type: 'combotree',
 						options: {
 							editable: false,
 							required: true,
 							data: window.monitorTreeData,
 							onSelect: function (record) {
-								getTarget(dg, "pe").numberbox("setValue", record.attribute.pe)
+								getTarget(dg, 'pe').numberbox('setValue', record.attribute.pe)
 							},
 							onLoadSuccess: function (node) {},
 						},
@@ -315,55 +315,55 @@ function createPlanMonitorDateGride() {
 						return monitorNameMap.get(value)
 					},
 				},
-				{ field: "pe", title: "额定功率(kW)", width: 150, align: "center", editor: { type: "numberbox", options: { disabled: true, required: true, min: 0, precision: 2 } } },
+				{ field: 'pe', title: '额定功率(kW)', width: 150, align: 'center', editor: { type: 'numberbox', options: { disabled: true, required: true, min: 0, precision: 2 } } },
 				{
-					field: "state",
-					title: "状态",
+					field: 'state',
+					title: '状态',
 					width: 150,
-					align: "center",
+					align: 'center',
 					editor: {
-						type: "combobox",
+						type: 'combobox',
 						options: {
 							required: true,
-							valueField: "id",
-							textField: "text",
+							valueField: 'id',
+							textField: 'text',
 							data: [
-								{ id: "1", text: "停机", value: "0" },
-								{ id: "2", text: "待机", value: "0.4" },
-								{ id: "3", text: "减负", value: "0.8" },
+								{ id: '1', text: '停机', value: '0' },
+								{ id: '2', text: '待机', value: '0.4' },
+								{ id: '3', text: '减负', value: '0.8' },
 							],
 							onSelect: function (record) {
-								getTarget(dg, "ratio").numberbox("setValue", record.value)
+								getTarget(dg, 'ratio').numberbox('setValue', record.value)
 							},
 						},
 					},
 					formatter: function (value, row, index) {
-						if (value == 1) return "停机"
-						else if (value == 2) return "待机"
-						else if (value == 3) return "减负"
+						if (value == 1) return '停机'
+						else if (value == 2) return '待机'
+						else if (value == 3) return '减负'
 					},
 				},
-				{ field: "ratio", title: "系数", width: 150, align: "center", editor: { type: "numberbox", options: { required: true, min: 0, precision: 2 } } },
+				{ field: 'ratio', title: '系数', width: 150, align: 'center', editor: { type: 'numberbox', options: { required: true, min: 0, precision: 2 } } },
 				{
-					field: "operate",
-					title: "操作",
+					field: 'operate',
+					title: '操作',
 					width: 100,
-					align: "center",
+					align: 'center',
 					formatter: function (value, row, index) {
-						return '<a href="#" onclick=\'modifyMonitor(' + row.id + "," + index + ")'>修改</a>"
+						return '<a href="#" onclick=\'modifyMonitor(' + row.id + ',' + index + ")'>修改</a>"
 					},
 				},
 			],
 		],
 		onLoadError: function () {
-			alert("载入数据发生错误,可能是由于您的登录已失效。</br>请刷新后再试。")
+			alert('载入数据发生错误,可能是由于您的登录已失效。</br>请刷新后再试。')
 		},
 		onClickRow: function (rowIndex, rowData) {
-			if (monitorIndex != undefined) dg.datagrid("selectRow", monitorIndex)
+			if (monitorIndex != undefined) dg.datagrid('selectRow', monitorIndex)
 		},
 		onDblClickRow: function (index, row) {
 			if (monitorIndex == undefined) {
-				dg.datagrid("beginEdit", index)
+				dg.datagrid('beginEdit', index)
 				monitorIndex = index
 			}
 		},
@@ -373,12 +373,12 @@ function createPlanMonitorDateGride() {
 //加载监测点数据
 function loadMonitorData(projectId) {
 	ajax({
-		url: "/web/demand/plan/monitor/getAll/" + projectId + ".json",
-		dataType: "json",
+		url: '/web/demand/plan/monitor/getAll/' + projectId + '.json',
+		dataType: 'json',
 		cache: false,
 		success: function (data) {
 			if (data.status == 1) {
-				$("#plan-monitor-dategrid").datagrid("loadData", data.data)
+				$('#plan-monitor-dategrid').datagrid('loadData', data.data)
 			} else {
 				toast(data.msg)
 			}
@@ -389,7 +389,7 @@ function loadMonitorData(projectId) {
 //编辑行
 function modifyMonitor(id, rowIndex) {
 	if (monitorIndex == undefined) {
-		$("#plan-monitor-dategrid").datagrid("beginEdit", rowIndex)
+		$('#plan-monitor-dategrid').datagrid('beginEdit', rowIndex)
 		monitorIndex = rowIndex
 	}
 }
@@ -399,8 +399,8 @@ function endMonitorEditing() {
 	if (monitorIndex == undefined) {
 		return true
 	}
-	if ($("#plan-monitor-dategrid").datagrid("validateRow", monitorIndex)) {
-		$("#plan-monitor-dategrid").datagrid("endEdit", monitorIndex)
+	if ($('#plan-monitor-dategrid').datagrid('validateRow', monitorIndex)) {
+		$('#plan-monitor-dategrid').datagrid('endEdit', monitorIndex)
 		monitorIndex = undefined
 		return true
 	} else {
@@ -409,27 +409,27 @@ function endMonitorEditing() {
 }
 
 //添加需求响应预案监测点信息
-$("#btnAddMonitor").linkbutton({
+$('#btnAddMonitor').linkbutton({
 	onClick: function () {
 		if (endMonitorEditing()) {
-			$("#plan-monitor-dategrid").datagrid("appendRow", { id: "" })
-			monitorIndex = $("#plan-monitor-dategrid").datagrid("getRows").length - 1
-			$("#plan-monitor-dategrid").datagrid("selectRow", monitorIndex).datagrid("beginEdit", monitorIndex)
+			$('#plan-monitor-dategrid').datagrid('appendRow', { id: '' })
+			monitorIndex = $('#plan-monitor-dategrid').datagrid('getRows').length - 1
+			$('#plan-monitor-dategrid').datagrid('selectRow', monitorIndex).datagrid('beginEdit', monitorIndex)
 		} else {
-			alert("请保存当前正在编辑的行。")
+			alert('请保存当前正在编辑的行。')
 		}
 	},
 })
 
 //保存需求响应预案监测点信息
-$("#btnSaveMonitor").click(function () {
+$('#btnSaveMonitor').click(function () {
 	if (monitorIndex == undefined) return
-	if ($("#plan-monitor-dategrid").datagrid("validateRow", monitorIndex)) {
-		$("#plan-monitor-dategrid").datagrid("endEdit", monitorIndex) //使用JSON序列化datarow对象,发送到后台。
-		var row = $("#plan-monitor-dategrid").datagrid("getSelected")
+	if ($('#plan-monitor-dategrid').datagrid('validateRow', monitorIndex)) {
+		$('#plan-monitor-dategrid').datagrid('endEdit', monitorIndex) //使用JSON序列化datarow对象,发送到后台。
+		var row = $('#plan-monitor-dategrid').datagrid('getSelected')
 		ajax({
-			url: "/web/demand/plan/monitor/saveOne/" + projectId + ".json",
-			type: "POST",
+			url: '/web/demand/plan/monitor/saveOne/' + projectId + '.json',
+			type: 'POST',
 			data: {
 				id: row.id,
 				monitorId: row.monitorId,
@@ -438,9 +438,9 @@ $("#btnSaveMonitor").click(function () {
 			},
 			success: function (data) {
 				if (data.status == 1) {
-					$("#plan-monitor-dategrid").datagrid("updateRow", { index: monitorIndex, row: data.data }) //新增后更新当前行的ID值
+					$('#plan-monitor-dategrid').datagrid('updateRow', { index: monitorIndex, row: data.data }) //新增后更新当前行的ID值
 				} else {
-					$("#plan-monitor-dategrid").datagrid("beginEdit", monitorIndex)
+					$('#plan-monitor-dategrid').datagrid('beginEdit', monitorIndex)
 				}
 				monitorIndex = undefined
 				toast(data.msg)
@@ -450,28 +450,28 @@ $("#btnSaveMonitor").click(function () {
 })
 
 //取消需求响应预案监测点信息行编辑
-$("#btnCancelMonitor").click(function () {
-	var row = $("#plan-monitor-dategrid").datagrid("getSelected")
+$('#btnCancelMonitor').click(function () {
+	var row = $('#plan-monitor-dategrid').datagrid('getSelected')
 	if (!row) return
-	if (row.id != undefined && row.id != "") {
-		$("#plan-monitor-dategrid").datagrid("cancelEdit", monitorIndex)
+	if (row.id != undefined && row.id != '') {
+		$('#plan-monitor-dategrid').datagrid('cancelEdit', monitorIndex)
 	} else {
-		$("#plan-monitor-dategrid").datagrid("deleteRow", monitorIndex)
+		$('#plan-monitor-dategrid').datagrid('deleteRow', monitorIndex)
 	}
 	monitorIndex = undefined
 })
 
 //删除需求响应预案监测点信息
-$("#btnDeleteMonitor").click(function () {
-	var row = $("#plan-monitor-dategrid").datagrid("getSelected")
+$('#btnDeleteMonitor').click(function () {
+	var row = $('#plan-monitor-dategrid').datagrid('getSelected')
 	if (!row) return
-	confirm("重要操作", "删除后,将导致某些关联数据无法显示。<br/>您确定要删除选中数据吗?", function (r) {
+	confirm('重要操作', '删除后,将导致某些关联数据无法显示。<br/>您确定要删除选中数据吗?', function (r) {
 		if (r) {
 			ajax({
-				url: "/web/demand/plan/monitor/delete/" + row.id + ".json",
+				url: '/web/demand/plan/monitor/delete/' + row.id + '.json',
 				success: function (data) {
-					var rowIndex = $("#plan-monitor-dategrid").datagrid("getRowIndex", row)
-					$("#plan-monitor-dategrid").datagrid("deleteRow", rowIndex)
+					var rowIndex = $('#plan-monitor-dategrid').datagrid('getRowIndex', row)
+					$('#plan-monitor-dategrid').datagrid('deleteRow', rowIndex)
 					toast(data.msg)
 				},
 			})
@@ -484,9 +484,9 @@ var chartDataMap = new Map()
 function loadMonitorP(day) {
 	chartDataMap.clear()
 	ajax({
-		url: "/web/demand/plan/getP.json",
-		type: "POST",
-		dataType: "json",
+		url: '/web/demand/plan/getP.json',
+		type: 'POST',
+		dataType: 'json',
 		cache: false,
 		data: { day: day },
 		success: function (data) {
@@ -494,6 +494,7 @@ function loadMonitorP(day) {
 				//原始数据为数组,每条记录为一个监测点,执行数据相加
 				$.each(data.data, function (index, data) {
 					$.each(data.value, function (index, obj) {
+						obj.value = Number(obj.value) || 0
 						if (chartDataMap.containsKey(obj.code)) {
 							var value = chartDataMap.get(obj.code) + obj.value
 							chartDataMap.put(obj.code, value)
@@ -507,9 +508,9 @@ function loadMonitorP(day) {
 					seriesData = new Array(),
 					series = {},
 					dataMap = new Map()
-				series.name = "样本负荷"
+				series.name = '样本负荷'
 				$.each(chartDataMap.elements, function (index, element) {
-					categories.push(element.key.substring(0, 2) + ":" + element.key.substring(2, 4))
+					categories.push(element.key.substring(0, 2) + ':' + element.key.substring(2, 4))
 					seriesData.push(element.value)
 				})
 				series.data = seriesData
@@ -522,24 +523,24 @@ function loadMonitorP(day) {
 }
 
 //模拟数据
-$("#btnSimulation").click(function () {
-	$("#imageShow").mask("正在加载数据...")
-	var gridData = $("#plan-monitor-dategrid").datagrid("getRows")
-	var monitorIds = ""
+$('#btnSimulation').click(function () {
+	$('#imageShow').mask('正在加载数据...')
+	var gridData = $('#plan-monitor-dategrid').datagrid('getRows')
+	var monitorIds = ''
 	var pMap = new Map() /*监测点系数负荷数据*/,
 		gridMap = new Map() /*监测点表格数据*/
 	$(gridData).each(function (index, row) {
 		gridMap.put(row.monitorId, row.ratio)
 		monitorIds += row.monitorId
 		if (index < gridData.length - 1) {
-			monitorIds += ","
+			monitorIds += ','
 		}
 	})
-	if (monitorIds != "") {
+	if (monitorIds != '') {
 		ajax({
-			url: "/web/demand/plan/getMonitorP.json",
-			type: "POST",
-			dataType: "json",
+			url: '/web/demand/plan/getMonitorP.json',
+			type: 'POST',
+			dataType: 'json',
 			cache: false,
 			async: false,
 			data: { day: _sampleDate, monitorIds: monitorIds },
@@ -552,13 +553,21 @@ $("#btnSimulation").click(function () {
 						})
 						pMap.put(obj.code, map)
 					})
+					console.log('pMap', pMap)
 				}
 			},
 		})
 		var simulationData = new Array()
-		for (var i = 0; i < 24; i++) {
-			for (var j = 0; j < 60; j += 5) {
-				var key = (i < 10 ? "0" + i : i) + "" + (j < 10 ? "0" + j : j)
+		var firstkey = chartDataMap.element(0).key
+		var hour = Number(firstkey.substring(0, 2))
+		var minute = Number(firstkey.substring(2))
+		//console.log('chartDataMap', chartDataMap,"first",firstkey,hour,minute)
+		var j = minute
+		for (var i = hour; i < 24; i++) {
+			for (; j < 60; j += 5) {
+				//console.log('i:', i, j)
+				var key = (i < 10 ? '0' + i : i) + '' + (j < 10 ? '0' + j : j)
+				//console.log('key:', key)
 				if (parseInt(key) == parseInt(_startTime) || parseInt(key) == parseInt(_endTime)) {
 					simulationData.push(chartDataMap.get(key))
 				} else if (parseInt(key) > parseInt(_startTime) && parseInt(key) < parseInt(_endTime)) {
@@ -568,31 +577,33 @@ $("#btnSimulation").click(function () {
 						var map = pMap.get(element.key)
 						if (map) coefficient += map.get(key) * (1 - element.value)
 					}
-					simulationData.push(parseFloat((chartDataMap.get(key) - coefficient).toFixed(2)))
+					var p = parseFloat(((chartDataMap.get(key) || 0) - (coefficient || 0)).toFixed(2))
+					simulationData.push(p)
 				} else {
 					simulationData.push(null)
 				}
 			}
+			j = 0
 		}
-		var chart = $("#showchart").highcharts()
+		var chart = $('#showchart').highcharts()
 		var seriesList = chart.series //获得图表的所有序列
 		if (seriesList.length > 1) {
 			//多条线时先删除新添加线条
 			chart.series[1].remove()
 		}
 		chart.addSeries({
-			name: "模拟负荷",
+			name: '模拟负荷',
 			data: simulationData,
 		})
 	}
-	$("#imageShow").unmask()
+	$('#imageShow').unmask()
 })
 
 //显示图表
 function showChart(categories, series) {
-	$("#showchart").highcharts({
+	$('#showchart').highcharts({
 		title: {
-			text: "企业需求响应预案模拟",
+			text: '企业需求响应预案模拟',
 			x: -20,
 		},
 		xAxis: {
@@ -601,13 +612,13 @@ function showChart(categories, series) {
 		},
 		yAxis: {
 			title: {
-				text: "负荷(kW)",
+				text: '负荷(kW)',
 			},
 			plotLines: [
 				{
 					value: 0,
 					width: 1,
-					color: "#808080",
+					color: '#808080',
 				},
 			],
 		},
@@ -615,17 +626,17 @@ function showChart(categories, series) {
 			crosshairs: [true, true],
 			shared: true,
 			formatter: function () {
-				var s = "<b>" + this.x + "</b>"
+				var s = '<b>' + this.x + '</b>'
 				$.each(this.points, function () {
-					s += "<br/>" + this.series.name + ": " + this.y.toFixed(2) + "(kW)"
+					s += '<br/>' + this.series.name + ': ' + this.y.toFixed(2) + '(kW)'
 				})
 				return s
 			},
 		},
 		legend: {
-			layout: "horizontal",
-			align: "center",
-			verticalAlign: "bottom",
+			layout: 'horizontal',
+			align: 'center',
+			verticalAlign: 'bottom',
 			borderWidth: 0,
 		},
 		plotOptions: {
@@ -635,7 +646,7 @@ function showChart(categories, series) {
 		},
 		series: [series],
 	})
-	$("#imageShow").unmask()
+	$('#imageShow').unmask()
 }
 
 //将监测点数据放入MAP
@@ -654,9 +665,9 @@ function getNodeToMap(nodes) {
 $(document).ready(function () {
 	initGridData()
 	ajax({
-		url: "/web/getMonitorTree/outher.json",
-		type: "POST",
-		dataType: "json",
+		url: '/web/getMonitorTree/outher.json',
+		type: 'POST',
+		dataType: 'json',
 		cache: false,
 		async: false,
 		success: function (data) {
@@ -673,8 +684,8 @@ $(document).ready(function () {
 
 //窗口大小变化时延时刷新图片大小
 $(window).resize(function () {
-	if ($("#showchart").highcharts()) {
-		$("#showchart").highcharts().setSize($(window).width(), 300, true)
+	if ($('#showchart').highcharts()) {
+		$('#showchart').highcharts().setSize($(window).width(), 300, true)
 	}
 	/*window.resizeTimer = setTimeout(function() {
 		window.clearTimeout(window.resizeTimer);