Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/process/dataPatrolCurve.jsp
2026-01-16 14:13:44 +08:00

375 lines
13 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%@ page language="java" pageEncoding="UTF-8" %>
<!-- 引入daterangepicker-->
<link rel="stylesheet" href="<%=request.getContextPath()%>/plugins/bootstrap-daterangepicker/daterangepicker.css"/>
<script type="text/javascript" src="<%=request.getContextPath()%>/plugins/bootstrap-daterangepicker/moment.min.js"
charset="utf-8"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/plugins/bootstrap-daterangepicker/daterangepicker.js"
charset="utf-8"></script>
<script type="text/javascript">
var beginTimeStore1 = '';
var endTimeStore1 = '';
function initDate() {
//定义locale汉化插件
beginTimeStore1 = moment().subtract(7, 'days').format('YYYY-MM-DD HH:mm');
endTimeStore1 = moment().subtract(0, 'days').format('YYYY-MM-DD HH:mm');
var locale = {
"format": 'YYYY-MM-DD HH:mm',
"separator": " ~ ",
"applyLabel": "确定",
"cancelLabel": "取消",
"fromLabel": "起始时间",
"toLabel": "结束时间'",
"customRangeLabel": "自定义",
"weekLabel": "W",
"daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
"monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
"firstDay": 1
};
$('#reservationtime').daterangepicker({
"timePicker": true,
"timePicker24Hour": true,
"linkedCalendars": false,
"autoUpdateInput": false,
"timePickerIncrement": 10,
"locale": locale,
//汉化按钮部分
ranges: {
// '今日': [moment(), moment().subtract(-1, 'days')],
'昨日': [moment().subtract(1, 'days'), moment()],
'最近7日': [moment().subtract(6, 'days'), moment().subtract(-1, 'days')],
'本月': [moment().startOf('month'), moment().endOf('month').subtract(-1, 'days')],
'上月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month').subtract(-1, 'days')]
},
startDate: beginTimeStore1,
endDate: endTimeStore1
}, function (start, end, label) {
beginTimeStore1 = start.format(this.locale.format);
endTimeStore1 = end.format(this.locale.format);
if (!this.startDate) {
this.element.val('');
} else {
this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
}
});
$('#reservationtime').val(beginTimeStore1 + locale.separator + endTimeStore1);
};
var color = [
"#2ec7c9",
"#b6a2de",
"#5ab1ef",
"#ffb980",
"#d87a80",
"#8d98b3",
"#e5cf0d",
"#97b552",
"#95706d",
"#dc69aa",
"#07a2a4",
"#9a7fd1",
"#588dd5",
"#f5994e",
"#c05050",
"#59678c",
"#c9ab00",
"#7eb00a",
"#6f5553",
"#c14089"
];
let myChart1 = "";
let option1 = [];
let myChart2 = "";
let option2 = [];
let source2Data = [];
function getdata() {
$.post(ext.contextPath + '/process/dataPatrol/getDetailData.do', {
mpcode: "${param.mpcode}",
sdt: beginTimeStore1,
edt: endTimeStore1,
unitId: unitId
}, function (result) {
// console.log(result);
let outData = result[0];
let name = outData.name;
let legend1Data = [];
legend1Data.push(name);
option1.legend.name = legend1Data;
option1.series[0].name = name;
option1.series[0].data = outData.data;
// console.log(option1);
myChart1.setOption(option1, true);
source2Data = [];
// console.log(option2);
option2.dataset[0].source[0]=outData.data2;
option2.dataset[1].transform.config.itemNameFormatter = name;
myChart2.setOption(option2, true);
}, 'json');
}
function getEcharts1() {
let series = [];
let yAxis = [];
let legenddata = [];
series.push({
symbol: 'none',
type: 'line',
lineStyle: {
name:"",
width: 2
},
markPoint: {
data: [
{type: 'max', name: '最大值'},
{type: 'min', name: '最小值'}
]
},
markLine: {
data: [
{type: 'average', name: '平均值'}
]
}
})
document.getElementById("chart1").removeAttribute("_echarts_instance_");
myChart1 = echarts.init(document.getElementById("chart1"));
yAxis.push({
type: 'value',
name: false,
splitLine: {
show: false//是否显示分隔线。默认数值轴显示,类目轴不显示。
},
scale: true//设置成 true 后坐标刻度不会强制包含零刻度。
});
option1 = {
color: color,
animation: false,
legend: {
left: 'center'
},
grid: {
left: '4%', // 与容器左侧的距离
right: '4%', // 与容器右侧的距离
top: '8%', // 与容器顶部的距离
//bottom: '5%', // 与容器底部的距离
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {show: true}
}
},
xAxis: {
type: 'time'
},
yAxis: yAxis,
series: series,
tooltip: {
trigger: 'axis',
formatter: function (params, ticket, callback) {
var htmlStr = '';
for (var i = 0; i < params.length; i++) {
var param = params[i];
// console.log(param);
var xName = param.name;//x轴的名称
var seriesName = param.seriesName;//图例名称
var xvalue = param.value[0];//x轴值
var yvalue = param.value[1];//y轴值
var remarkvalue = param.value[2];//备注轴值
var color = param.color;//图例颜色
var dataIndex = param.dataIndex;
var seriesIndex = param.seriesIndex;
htmlStr += '<div>';
htmlStr += xvalue + '<br/>';
htmlStr += '<span style="margin-right:5px;display:inline-block;width:10px;height:10px;border-radius:5px;background-color:' + color + ';"></span>';
htmlStr += seriesName + ':' + yvalue + '';
htmlStr += '</div>';
}
return htmlStr;
}
// alwaysShowContent:true,
},
dataZoom: [{
type: 'inside',
start: 0,
end: 100
}, {
start: 0,
end: 100,
handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
handleSize: '60%',
handleStyle: {
color: '#fff',
shadowBlur: 3,
shadowColor: 'rgba(0, 0, 0, 0.6)',
shadowOffsetX: 2,
shadowOffsetY: 2
}
}]
};
myChart1.setOption(option1, true);
}
function getEcharts2() {
document.getElementById("chart2").removeAttribute("_echarts_instance_");
myChart2 = echarts.init(document.getElementById("chart2"));
option2 = {
title: [
{
text: '最大值: Q3 + 1.5 * IQR最小值: Q1 - 1.5 * IQR',
borderColor: '#999',
borderWidth: 1,
textStyle: {
fontWeight: 'normal',
fontSize: 14,
lineHeight: 20
},
left: '10%',
top: '95%'
}
],
dataset: [
{
// prettier-ignore
source: [
source2Data
]
},
{
transform: {
type: 'boxplot',
config: {itemNameFormatter: ''}
}
},
{
fromDatasetIndex: 1,
fromTransformResult: 1
}
],
tooltip: {
trigger: 'item',
axisPointer: {
type: 'shadow'
}
},
grid: {
left: '5%',
right: '5%',
bottom: '10%'
},
xAxis: {
type: 'category',
boundaryGap: true,
nameGap: 30,
splitArea: {
show: false
},
splitLine: {
show: false
}
},
yAxis: {
type: 'value',
name: '',
splitArea: {
show: true
}
},
series: [
{
name: '盒须图',
type: 'boxplot',
datasetIndex: 1,
tooltip: {
formatter: function (param) {
return [
'最大值: ' + param.data[5],
'上四分位数: ' + param.data[4],
'中位数: ' + param.data[3],
'下四分位数: ' + param.data[2],
'最小值: ' + param.data[1]
].join('<br/>');
}
}
},
{
name: '界外值',
type: 'scatter',
datasetIndex: 2
}
]
};
myChart2.setOption(option2, true);
}
$(function () {
var windowhight = $(window).height();
var windowwidth = $(window).width();
$('#chart1').css("width", (windowwidth - 100) + "px");
$('#chart1').css("height", (windowhight - 200) + "px");
$('#chart2').css("width", (windowwidth - 100) + "px");
$('#chart2').css("height", (windowhight - 200) + "px");
initDate();
getEcharts1();
getEcharts2();
getdata();
});
function doCurveSearch() {
getdata();
}
let nowCurveType = 0;
function changeCurveType() {
if (nowCurveType == 0) {
nowCurveType = 1;
$('#chart1').css("display", "none");
$('#chart2').css("display", "block");
} else {
nowCurveType = 0;
$('#chart2').css("display", "none");
$('#chart1').css("display", "block");
}
}
</script>
<div class="modal fade" id="curveModal">
<div style="padding: 20px;">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">历史曲线</h4>
</div>
<div class="modal-body">
<div style="float: left;width: 100%;">
<input type="text" class="form-control pull-left" id="reservationtime" style="width:270px">
<div class="input-group-btn pull-left">
<button type="button" class="btn btn-default" onclick="doCurveSearch();"><i
class="fa fa-search"></i> 查询
</button>
</div>
<div class="input-group-btn pull-left" style="margin-left: 80px;">
<button type="button" class="btn btn-default" onclick="changeCurveType();">切换
</button>
</div>
</div>
<div id="chart1" style="float: left;display: block;"></div>
<div id="chart2" style="float: left;display: none;"></div>
</div>
<div class="modal-footer" style="border-top: 0px;">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
</div>
</div>
</div>
</div>