<%@ 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;
|
}
|
</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">产品大类1</option>
|
<option value="产品大类2">产品大类2</option>
|
<option value="产品大类3">产品大类3</option>
|
</select>
|
|
<!-- 工程下拉框 -->
|
<select id="project-select">
|
<option value="">莱阳厨电</option>
|
<option value="工程1">工程1</option>
|
</select>
|
|
<!-- 开始日期 -->
|
<input type="date" id="start-date" />
|
|
<!-- 结束日期 -->
|
<input type="date" id="end-date" />
|
|
<!-- 查询按钮 -->
|
<button onclick="filterData()">查询</button>
|
|
<!-- 重置按钮 -->
|
<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>
|
|
<!-- 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: {
|
},
|
|
},
|
methods:{
|
dingdanxiangqing(){
|
let HisArr="";
|
// HisArr = this.$echarts.init(document.getElementById('main2'));
|
let a = {
|
value: this.shuzu1[0]['6_qualified'],
|
name: "成品",
|
itemStyle: { color: '#53a2ff' },
|
label:{fontSize:30}
|
}
|
let b = {
|
value: this.shuzu1[0]['7_qualified_not'],
|
name: "次品",
|
itemStyle: { color: 'darkseagreen' },
|
label:{fontSize:30}
|
}
|
this.val1.title.text="合格率"
|
this.val1.title.top="45%"
|
this.val1.title.left="45%"
|
this.val1.title.textStyle.fontSize=30
|
this.val1.series[0].data[0]=a
|
this.val1.series[0].data[1]=b
|
HisArr.setOption(this.val1);
|
},
|
dingdanxiangqing1(){
|
let HisArr="";
|
// HisArr = this.$echarts.init(document.getElementById('main4'));
|
let a = {
|
value: this.shuzu1[0]['2_smallglass_completed'],
|
|
name: "已完成",
|
itemStyle: { color: '#53a2ff' },
|
label:{fontSize:30}
|
}
|
let b = {
|
value: this.shuzu1[0]['3_smallglass_processing'],
|
name: "未完成",
|
itemStyle: { color: 'darkseagreen' },
|
label:{fontSize:30}
|
|
}
|
this.val1.title.text="订单加工"
|
this.val1.title.top="45%"
|
this.val1.title.left="45%"
|
this.val1.title.textStyle.fontSize=30
|
this.val1.series[0].data[0]=a
|
this.val1.series[0].data[1]=b
|
HisArr.setOption(this.val1);
|
},
|
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 = [];
|
|
// 检查数据是否存在
|
// if (this.shuzu && this.shuzu.length > 0) {
|
// 遍历 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);
|
}
|
|
console.log('日期:', datashijian);
|
console.log('停机时长:', shutdownTimes);
|
|
// 初始化图表
|
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);
|
// } else {
|
// console.error('shuzu 数据为空或未加载');
|
// console.log(this.shuzu);
|
// }
|
this.loading = false;
|
},
|
},
|
watch:{
|
|
shuzu(){
|
this.echarsInit();
|
this.echarsInit3();
|
},
|
},
|
mounted: function() {
|
|
this.shuzu = [];
|
let sql="{call machine_bigScreen(5,'','','')}";
|
let flag = 2;
|
this.loadAjxss('任务查询成功',sql,flag,"shuzu");
|
|
}
|
|
})
|
// 初始化 ECharts 图表
|
const trendChart1 = echarts.init(document.getElementById('trendChart1'));
|
const trendChart2 = echarts.init(document.getElementById('trendChart2'));
|
const trendChart3 = echarts.init(document.getElementById('trendChart3'));
|
|
|
|
// 配置第一个图表 (柱状图 - 订单计划和订单完成)
|
// const option1 = {
|
// tooltip: {
|
// trigger: 'axis'
|
// },
|
// legend: {
|
// data: ['订单计划', '订单完成']
|
// },
|
// xAxis: {
|
// type: 'category',
|
// data: dates
|
// },
|
// yAxis: {
|
// type: 'value'
|
// },
|
// series: [{
|
// name: '订单计划',
|
// type: 'bar',
|
// data: plans,
|
// itemStyle: {
|
// color: 'rgba(54, 162, 235, 1)'
|
// }
|
// },
|
// {
|
// name: '订单完成',
|
// type: 'bar',
|
// data: overnums,
|
// itemStyle: {
|
// color: 'rgba(75, 192, 192, 1)'
|
// }
|
// }
|
// ]
|
// };
|
// trendChart1.setOption(option1);
|
|
// 配置第二个图表 (柱状图 - 工程不良台数和工程不良率)
|
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);
|
|
// 配置第三个图表 (柱状图 - 停机时长和停机时率)
|
// const option3 = {
|
// 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: [1, 2, 3],
|
// itemStyle: {
|
// color: 'rgba(255, 159, 64, 1)'
|
// }
|
// },
|
// {
|
// name: '停机时率',
|
// type: 'bar',
|
// data: [0.02, 0.03, 0.04],
|
// itemStyle: {
|
// color: 'rgba(153, 102, 255, 1)'
|
// }
|
// }
|
// ]
|
// };
|
// trendChart3.setOption(option3);
|
|
// 根据日期范围过滤数据
|
function filterData() {
|
const startDate = document.getElementById('start-date').value;
|
const endDate = document.getElementById('end-date').value;
|
// 模拟新的数据
|
const newData1 = {
|
labels: ['2025-03-30', '2025-03-31'],
|
datasets: [{
|
label: '订单计划',
|
data: [7098, 8000],
|
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
borderColor: 'rgba(54, 162, 235, 1)',
|
borderWidth: 1
|
}, {
|
label: '订单完成',
|
data: [7897, 8200],
|
backgroundColor: 'rgba(75, 192, 192, 0.2)',
|
borderColor: 'rgba(75, 192, 192, 1)',
|
borderWidth: 1
|
}]
|
};
|
trendChart1.setOption({
|
xAxis: {
|
data: newData1.labels
|
},
|
series: [{
|
data: newData1.datasets[0].data
|
},
|
{
|
data: newData1.datasets[1].data
|
}
|
]
|
});
|
}
|
|
// 重置搜索栏
|
function resetFilters() {
|
document.getElementById('start-date').value = '';
|
document.getElementById('end-date').value = '';
|
}
|
|
</script>
|
|
|
</body>
|
</html>
|