<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
|
<!DOCTYPE html>
|
<html lang="zh-CN">
|
<head>
|
<meta charset="UTF-8">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<title>智能制造可视化</title>
|
<%-- <script src="https://csdn.jsdelivr.net/npm/chart.js"></script>--%>
|
|
|
<style>
|
body {
|
font-family: Arial, sans-serif;
|
margin: 0;
|
padding: 0;
|
background-color: #f4f4f4;
|
}
|
|
.container {
|
width: 90%;
|
margin: 20px auto;
|
}
|
|
.header {
|
display: flex;
|
justify-content: space-between;
|
background-color: #007bff;
|
color: white;
|
padding: 15px;
|
align-items: center;
|
}
|
|
.header h1 {
|
font-size: 24px;
|
}
|
|
.date-time {
|
font-size: 14px;
|
}
|
|
/* 搜索栏样式 */
|
.header .search-bar {
|
display: flex;
|
align-items: center;
|
background-color: #ffffff;
|
border-radius: 20px;
|
padding: 5px 10px;
|
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
|
width: 70%;
|
}
|
|
.search-bar select, .search-bar input {
|
margin: 0 10px;
|
padding: 8px;
|
font-size: 14px;
|
border-radius: 5px;
|
border: 1px solid #ccc;
|
}
|
|
.search-bar button {
|
background-color: #007bff;
|
color: white;
|
border: none;
|
padding: 8px 15px;
|
font-size: 14px;
|
border-radius: 20px;
|
cursor: pointer;
|
}
|
|
.search-bar button.reset-btn {
|
background-color: #ccc;
|
margin-left: 10px;
|
}
|
|
/* 主内容部分 */
|
.dashboard {
|
display: flex;
|
flex-direction: column;
|
margin-top: 20px;
|
}
|
|
.main-content {
|
width: 100%;
|
padding: 20px;
|
}
|
|
/* 四个数据显示的方块 */
|
.top-blocks {
|
display: flex;
|
justify-content: space-between;
|
margin-bottom: 20px;
|
}
|
|
.top-block {
|
width: 23%;
|
background-color: #ffffff;
|
padding: 20px;
|
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
|
text-align: center;
|
}
|
|
.top-block .title {
|
font-size: 16px;
|
color: #333;
|
}
|
|
.top-block .value {
|
font-size: 24px;
|
font-weight: bold;
|
color: #007bff;
|
}
|
|
/* 图表容器 */
|
.chart-container {
|
display: flex;
|
justify-content: space-between;
|
margin-top: 20px;
|
}
|
|
.chart {
|
width: 30%;
|
height: 300px;
|
}
|
|
/* 表格样式 */
|
.data-table {
|
width: 100%;
|
border-collapse: collapse;
|
margin-top: 20px;
|
}
|
|
.data-table th, .data-table td {
|
border: 1px solid #ddd;
|
padding: 10px;
|
text-align: center;
|
}
|
|
.data-table th {
|
background-color: #007bff;
|
color: white;
|
}
|
#biaoti{
|
color:black;
|
margin-left: 350px;
|
}
|
</style>
|
</head>
|
<body>
|
<div id="app" class="container">
|
<!-- Header Section -->
|
<div class="header">
|
<h1>北玻智能可视化</h1>
|
<%-- <div class="date-time">--%>
|
<%-- <span>数据更新时间: 2025-04-31 12:50:52</span>--%>
|
<%-- </div>--%>
|
<!-- 搜索栏 -->
|
<div class="search-bar">
|
<!-- 产业下拉框 -->
|
<select id="industry-select">
|
<option value="">莱阳厨电</option>
|
</select>
|
|
<!-- 产品大类下拉框 -->
|
<select id="product-category-select">
|
<option value="">全部</option>
|
<option value="1">消毒柜</option>
|
<option value="2">蒸烤箱</option>
|
<option value="3">烟机</option>
|
</select>
|
|
<!-- 工程下拉框 -->
|
<select id="project-select">
|
<option value="">莱阳厨电</option>
|
|
</select>
|
|
<!-- 开始日期 -->
|
<input type="date" id="start-date" />
|
|
<!-- 结束日期 -->
|
<input type="date" id="end-date" />
|
|
<!-- 查询按钮 -->
|
<button @click="filterData()">查询</button>
|
<h2 id="biaoti">{{title}}</h2>
|
<!-- 重置按钮 -->
|
<%-- <button class="reset-btn" onclick="resetFilters()">重置</button>--%>
|
</div>
|
</div>
|
|
<!-- Dashboard Section -->
|
<div class="dashboard">
|
<!-- Main Content -->
|
<div class="main-content">
|
<!-- Top Data Blocks -->
|
<div class="top-blocks">
|
<div class="top-block">
|
<div class="title">计划完成率</div>
|
<div class="value">76.00%</div>
|
</div>
|
<div class="top-block">
|
<div class="title">工程不良率</div>
|
<div class="value">0.00%</div>
|
</div>
|
<div class="top-block">
|
<div class="title">停机率</div>
|
<div class="value">0.00%</div>
|
</div>
|
<div class="top-block">
|
<div class="title">停机时长</div>
|
<div class="value">0</div>
|
</div>
|
</div>
|
|
<!-- Chart Section -->
|
<div class="chart-container">
|
<div id="trendChart1" class="chart"></div>
|
<div id="trendChart2" class="chart"></div>
|
<div id="trendChart3" class="chart"></div>
|
<!-- 显示曲线图 -->
|
<div id="trendChart4" class="chart"></div>
|
|
</div>
|
|
<!-- Table Section -->
|
<div class="side-visual">
|
<table class="table table-striped table-hover data-table" style="overflow-x: auto;font-size: 12px;">
|
<thead>
|
<tr>
|
<th>日期</th>
|
<th>产品名称</th>
|
<th>工厂名称</th>
|
<th>线体</th>
|
<th>订单计划</th>
|
<th>订单完成</th>
|
<th>差异</th>
|
<th>计划完成率</th>
|
</tr>
|
</thead>
|
<tbody>
|
<tr v-for="(item, index) in shuzu" :key="index">
|
<td>{{ item['0_createtime'] || '暂无数据' }}</td>
|
<td>{{ item['1_type'] || '暂无数据' }}</td>
|
<td>{{ item['2_factory'] || '暂无数据' }}</td>
|
<td>{{ item['3_line'] || '暂无数据' }}</td>
|
<td>{{ item['4_plan'] || 0 }}</td>
|
<td>{{ item['5_overnum'] || 0 }}</td>
|
<td>{{ item['6_difference'] || '暂无数据' }}</td>
|
<td>{{ item['7_plan_completion_rate'] || '暂无数据' }}%</td>
|
</tr>
|
</tbody>
|
</table>
|
</div>
|
|
</div>
|
</div>
|
</div>
|
|
|
<!-- Chart.js Script -->
|
<script src="../js/jquery-3.4.1.min.js"></script>
|
<script type="text/javascript" src="../static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
<script src="../js/vue.min.js"></script>
|
<script src="../js/axios.min.js"></script>
|
<script src="../js/mixins.js"></script>
|
<script src="../js/echarts.min.js"></script>
|
<script>
|
Vue.prototype.$echarts = echarts;
|
Vue.prototype.$http= axios;
|
let app = new Vue({
|
el:'#app',
|
mixins:[mixin],
|
data:{
|
shuzu:[{}],
|
shuzu1:[{}],
|
shuzu2:[{}],
|
yield:[{}],
|
machineElectric:[{}],
|
machineWater:[{}],
|
val1: {},
|
title:"<%= request.getParameter("name") %>",
|
|
},
|
methods:{
|
// 提交一次查询刷新
|
filterData() {
|
// 获取产品类别
|
const type = document.getElementById('product-category-select').value;
|
// 获取日期选择器的值
|
const startDate = document.getElementById('start-date').value;
|
const endDate = document.getElementById('end-date').value;
|
|
// 构造查询参数
|
let canshu1={
|
line:<%= request.getParameter("id") %>,
|
type: type,
|
startDate: startDate,
|
endDate: endDate
|
}
|
// 清空当前数据
|
this.shuzu = [];
|
this.shuzu1 = [];
|
// console.log("输出");
|
// console.log(canshu1);
|
// 拼接SQL查询语句
|
let sql="{call machine_bigScreen('"+canshu1.line+"','"+canshu1.startDate+"','"+canshu1.endDate+"','"+canshu1.type+"')}";
|
let flag = 2;
|
this.loadAjxss('任务查询成功', sql, flag, "shuzu");
|
let sql1="{call machine_bigScreen24('"+canshu.line+"')}";
|
let flag1 = 2;
|
// 调用数据加载函数(例如AJAX请求)
|
this.loadAjxss('任务查询成功', sql1, flag1, "shuzu1");
|
//console.log(this.shuzu);
|
},
|
|
echarsInit() {
|
let datashijian = [];
|
let plans = [];
|
let overnums = [];
|
|
// 遍历 shuzu 数组提取日期、计划数和完成数
|
for (let i in this.shuzu) {
|
// 这里将 createtime 转换成 "MM/DD" 格式的日期
|
let date = this.shuzu[i]["0_createtime"];
|
let day = new Date(date);
|
let formattedDate = (day.getMonth() + 1) + "/" + day.getDate(); // 格式化日期
|
datashijian.push(formattedDate);
|
|
plans.push(this.shuzu[i]["4_plan"]); // 提取计划数
|
overnums.push(this.shuzu[i]["5_overnum"]); // 提取完成数
|
}
|
|
// 选择图表容器
|
let HisArr = this.$echarts.init(document.getElementById('trendChart1'));
|
|
// 设置 ECharts 配置
|
let option = {
|
tooltip: { trigger: 'axis' },
|
legend: { data: ['订单计划', '订单完成'] },
|
xAxis: {
|
type: 'category',
|
data: datashijian
|
},
|
yAxis: { type: 'value' },
|
series: [
|
{
|
name: '订单计划',
|
type: 'bar',
|
data: plans, // 使用提取的计划数数据
|
itemStyle: { color: 'rgba(54, 162, 235, 1)' }, // 设置颜色
|
barWidth: '40%' // 设置柱状图宽度
|
},
|
{
|
name: '订单完成',
|
type: 'bar',
|
data: overnums, // 使用提取的完成数数据
|
itemStyle: { color: 'rgba(75, 192, 192, 1)' }, // 设置颜色
|
barWidth: '40%' // 设置柱状图宽度
|
}
|
]
|
};
|
|
// 设置图表
|
HisArr.setOption(option);
|
this.loading = false; // 结束加载状态
|
},
|
echarsInit3() {
|
let datashijian = [];
|
let shutdownTimes = [];
|
|
// 检查数据是否存在
|
// 遍历 shuzu 数据提取停机时长数据
|
for (let i in this.shuzu) {
|
let date = this.shuzu[i]["0_createtime"];
|
let shutdownNum = this.shuzu[i]["8_shutdownNum"];
|
|
// 格式化日期
|
let day = new Date(date);
|
let formattedDate = (day.getMonth() + 1) + "/" + day.getDate();
|
datashijian.push(formattedDate);
|
// 停机时长
|
shutdownTimes.push(shutdownNum);
|
}
|
// 初始化图表
|
let HisArr = this.$echarts.init(document.getElementById('trendChart3'));
|
|
let option = {
|
tooltip: { trigger: 'axis' },
|
legend: { data: ['停机时长(分)'] },
|
|
xAxis: {
|
type: 'category',
|
data: datashijian
|
},
|
yAxis: { type: 'value' },
|
series: [
|
{
|
name: '停机时长(分)',
|
type: 'bar',
|
data: shutdownTimes,
|
itemStyle: { color: 'rgba(255, 99, 132, 1)' }, // 可根据需要调整颜色
|
barWidth: '40%' // 调整柱宽
|
}
|
]
|
};
|
|
HisArr.setOption(option);
|
this.loading = false;
|
},
|
updateLineChart() {
|
let datatime = [];
|
let sum = [];
|
let hourFormatted
|
for (let i in this.shuzu1) {
|
let hours = this.shuzu1[i]["0_hour"];
|
let production = this.shuzu1[i]["1_total_num"];
|
hourFormatted = new Date(hours).getHours().toString().padStart(2, '0') + ":00";
|
datatime.push(hourFormatted);
|
sum.push(production);
|
|
}
|
let HisArr = this.$echarts.init(document.getElementById('trendChart4'));
|
const option = {
|
xAxis: {
|
type: 'category',
|
data: datatime,
|
axisLabel: {
|
formatter: '{value}:00'
|
}
|
},
|
yAxis: {
|
type: 'value'
|
},
|
series: [{
|
data: sum,
|
type: 'line',
|
smooth: true,
|
lineStyle: {
|
color: 'blue'
|
}
|
}]
|
};
|
|
// 使用新数据更新曲线图
|
HisArr.setOption(option);
|
HisArr.resize();
|
this.loading = false;
|
}
|
|
},
|
watch:{
|
|
shuzu(){
|
this.echarsInit();
|
this.echarsInit3();
|
this.updateLineChart();
|
},
|
},
|
async mounted(){
|
|
// 获取选中的产品类别
|
const type = document.getElementById('product-category-select').value;
|
// 获取日期选择器的值
|
const startDate = document.getElementById('start-date').value;
|
const endDate = document.getElementById('end-date').value;
|
let canshu={
|
line:<%= request.getParameter("id") %>,
|
type: type,
|
startDate: startDate,
|
endDate: endDate
|
}
|
this.shuzu = [];
|
let sql="{call machine_bigScreen('"+canshu.line+"','"+canshu.startDate+"','"+canshu.endDate+"','"+canshu.type+"')}";
|
let flag = 2;
|
this.loadAjxss('任务查询成功',sql,flag,"shuzu");
|
|
this.shuzu1 = [];
|
let sql1="{call machine_bigScreen24('"+canshu.line+"')}";
|
let flag1 = 2;
|
this.loadAjxss('任务查询成功',sql1,flag1,"shuzu1");
|
|
|
|
|
|
await setInterval(()=>{
|
// 获取选中的产品类别
|
const type = document.getElementById('product-category-select').value;
|
// 获取日期选择器的值
|
const startDate = document.getElementById('start-date').value;
|
const endDate = document.getElementById('end-date').value;
|
let canshu={
|
line:<%= request.getParameter("id") %>,
|
type: type,
|
startDate: startDate,
|
endDate: endDate
|
}
|
// console.log("输出:");
|
// console.log(canshu);
|
sql="{call machine_bigScreen('"+canshu.line+"','"+canshu.startDate+"','"+canshu.endDate+"','"+canshu.type+"')}";
|
this.interValLoadAjxs('任务查询成功',sql,flag,"shuzu")
|
|
sql1="{call machine_bigScreen24('"+canshu.line+"')}";
|
this.loadAjxss('24小时产量查询',sql1,flag1,"shuzu1");
|
},5000)
|
}
|
|
})
|
// 初始化 ECharts 图表
|
const trendChart1 = echarts.init(document.getElementById('trendChart1'));
|
const trendChart2 = echarts.init(document.getElementById('trendChart2'));
|
const trendChart3 = echarts.init(document.getElementById('trendChart3'));
|
const trendChart4 = echarts.init(document.getElementById('trendChart4'));
|
// 获取当前日期
|
const currentDate = new Date();
|
|
// 设置结束日期为明天
|
// currentDate.setDate(currentDate.getDate() + 1);
|
// const endDate = currentDate.toISOString().split('T')[0];
|
// document.getElementById('end-date').value = endDate;
|
//
|
// // 设置开始日期为三天前
|
// currentDate.setDate(currentDate.getDate() - 3); // 恢复到三天前
|
// const startDate = currentDate.toISOString().split('T')[0];
|
// document.getElementById('start-date').value = startDate;
|
|
|
|
// 配置第二个图表 (柱状图 - 工程不良台数和工程不良率)
|
const option2 = {
|
tooltip: {
|
trigger: 'axis'
|
},
|
legend: {
|
data: ['工程不良台数', '工程不良率']
|
},
|
xAxis: {
|
type: 'category',
|
data: ['2025-03-30', '2025-03-31', '2025-04-01']
|
},
|
yAxis: {
|
type: 'value'
|
},
|
series: [{
|
name: '工程不良台数',
|
type: 'bar',
|
data: [5, 3, 2],
|
itemStyle: {
|
color: 'rgba(75, 192, 192, 1)'
|
}
|
},
|
{
|
name: '工程不良率',
|
type: 'bar',
|
data: [0.01, 0.02, 0.03],
|
itemStyle: {
|
color: 'rgba(255, 99, 132, 1)'
|
}
|
}
|
]
|
};
|
trendChart2.setOption(option2);
|
|
|
|
|
|
|
|
</script>
|
|
|
</body>
|
</html>
|