feat(仪表盘): 添加任务历史、库位状态和当前任务统计图表
refactor(库存交易): 使用AutoMapper简化库存交易记录创建逻辑
This commit is contained in:
1 parent
d89f6ffb3e
commit
3cba19da98
5 files changed
+563
-203
No files matched your search
@@ -4,96 +4,44 @@
|
||||
<div class="layui-row layui-col-space15" id="frontpage">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-row layui-col-space15">
|
||||
<!-- 一周内出入库任务统计柱状图 -->
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">ShortCut</div>
|
||||
<div class="layui-card-header">一周内出入库任务统计</div>
|
||||
<div class="layui-card-body">
|
||||
|
||||
<div class="layui-carousel layadmin-carousel layadmin-shortcut">
|
||||
<ul class="layui-row layui-col-space10">
|
||||
<li class="layui-col-xs2">
|
||||
<a lay-href="_Admin/FrameworkUser/Index">
|
||||
<i class="layui-icon layui-icon-username"></i>
|
||||
<cite>Users</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs2">
|
||||
<a lay-href="_Admin/FrameworkRole/Index">
|
||||
<i class="layui-icon layui-icon-tabs"></i>
|
||||
<cite>Roles</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs2">
|
||||
<a lay-href="_Admin/FrameworkMenu/Index">
|
||||
<i class="layui-icon layui-icon-app"></i>
|
||||
<cite>Menu</cite>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="layui-col-xs2">
|
||||
<a lay-href="_Admin/ActionLog/Index">
|
||||
<i class="layui-icon layui-icon-console"></i>
|
||||
<cite>Logs</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs2">
|
||||
<a href="/_codegen/index" target="_blank">
|
||||
<i class="layui-icon layui-icon-template-1"></i>
|
||||
<cite>CodeGen</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs2">
|
||||
<a href="https://wtmdoc.walkingtec.cn" target="_blank">
|
||||
<i class="layui-icon layui-icon-read"></i>
|
||||
<cite>Doc</cite>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="taskHistoryChart" style="width: 100%; height: 300px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 库内库位统计南丁格尔图 -->
|
||||
<div class="layui-col-md6">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">Controllers</div>
|
||||
<div class="layui-card-header">库内库位统计</div>
|
||||
<div class="layui-card-body">
|
||||
<wt:chart is-horizontal="true" show-legend="true" show-tooltip="true" type="Bar" height="300" trigger-url="/Home/GetActionChart" />
|
||||
<div id="locationChart" style="width: 100%; height: 300px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 当前任务统计仪表盘 -->
|
||||
<div class="layui-col-md6">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">Models</div>
|
||||
<div class="layui-card-header">未完成任务统计</div>
|
||||
<div class="layui-card-body">
|
||||
<wt:chart show-legend="true" show-tooltip="true" type="Pie" height="300" trigger-url="/Home/GetLocationChart" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">Mock data</div>
|
||||
<div class="layui-card-body">
|
||||
<wt:chart is-horizontal="true" type="Scatter" height="400" trigger-url="/Home/GetSampleChart" radius="50" name-x="X" name-y="Y" name-category="C" name-addition="A" />
|
||||
|
||||
<div id="currentTaskChart" style="width: 100%; height: 300px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$("#frontpage").parent().css("background-color", "#eee");
|
||||
|
||||
$("#githubstar").html('100k');
|
||||
$("#githubstars").html('100');
|
||||
$("#githubfork").html(100);
|
||||
$("#githubwatch").html(100);
|
||||
$("#githubissue").html(100);
|
||||
|
||||
|
||||
//区块轮播切换
|
||||
// 初始化所有图表
|
||||
layui.use(['admin', 'carousel'], function () {
|
||||
var $ = layui.$
|
||||
, admin = layui.admin
|
||||
@@ -101,10 +49,368 @@
|
||||
, element = layui.element
|
||||
, device = layui.device();
|
||||
|
||||
|
||||
|
||||
element.render('progress');
|
||||
|
||||
|
||||
// 初始化图表
|
||||
initTaskHistoryChart();
|
||||
initLocationChart();
|
||||
initCurrentTaskChart();
|
||||
});
|
||||
|
||||
console.log(echarts);
|
||||
// 一周内出入库任务统计柱状图
|
||||
function initTaskHistoryChart() {
|
||||
var taskHistoryChart = echarts.init(document.getElementById('taskHistoryChart'));
|
||||
|
||||
// 显示加载动画
|
||||
taskHistoryChart.showLoading();
|
||||
|
||||
// 获取数据
|
||||
$.ajax({
|
||||
url: '/Home/GetTaskHistoryChart',
|
||||
type: 'GET',
|
||||
success: function(res) {
|
||||
taskHistoryChart.hideLoading();
|
||||
|
||||
// 处理数据
|
||||
var categories = [];
|
||||
var inData = [];
|
||||
var outData = [];
|
||||
var moveData = [];
|
||||
|
||||
if (res) {
|
||||
try {
|
||||
// 解析后端返回的JSON字符串
|
||||
var dataset = JSON.parse(res.dataset);
|
||||
var series = JSON.parse(res.series);
|
||||
var legend = JSON.parse(res.legend);
|
||||
|
||||
// 从dataset中提取数据
|
||||
if (dataset && dataset.source && dataset.source.length > 1) {
|
||||
// 第一行是表头,获取日期列表
|
||||
var headers = dataset.source[0];
|
||||
var dateIndex = 0; // 假设第一列是日期
|
||||
|
||||
// 找到各个任务类型的索引
|
||||
var inIndex = headers.indexOf('入库任务');
|
||||
var outIndex = headers.indexOf('出库任务');
|
||||
var moveIndex = headers.indexOf('移库任务');
|
||||
|
||||
// 提取日期列表(跳过表头行)
|
||||
for (var i = 1; i < dataset.source.length; i++) {
|
||||
categories.push(dataset.source[i][dateIndex]);
|
||||
}
|
||||
|
||||
// 提取各类任务数据
|
||||
for (var i = 1; i < dataset.source.length; i++) {
|
||||
var row = dataset.source[i];
|
||||
inData.push(inIndex > 0 ? parseInt(row[inIndex]) || 0 : 0);
|
||||
outData.push(outIndex > 0 ? parseInt(row[outIndex]) || 0 : 0);
|
||||
moveData.push(moveIndex > 0 ? parseInt(row[moveIndex]) || 0 : 0);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('解析数据失败:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 设置图表选项
|
||||
var option = {
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'shadow'
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
data: ['入库任务', '出库任务', '移库任务']
|
||||
},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: categories
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
minInterval: 1,
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '入库任务',
|
||||
type: 'bar',
|
||||
label: {
|
||||
show: true,
|
||||
position: 'top'
|
||||
},
|
||||
emphasis: {
|
||||
focus: 'series'
|
||||
},
|
||||
data: inData
|
||||
},
|
||||
{
|
||||
name: '出库任务',
|
||||
type: 'bar',
|
||||
label: {
|
||||
show: true,
|
||||
position: 'top'
|
||||
},
|
||||
emphasis: {
|
||||
focus: 'series'
|
||||
},
|
||||
data: outData
|
||||
},
|
||||
{
|
||||
name: '移库任务',
|
||||
label: {
|
||||
show: true,
|
||||
position: 'top'
|
||||
},
|
||||
type: 'bar',
|
||||
emphasis: {
|
||||
focus: 'series'
|
||||
},
|
||||
data: moveData
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// 设置图表选项并渲染
|
||||
taskHistoryChart.setOption(option);
|
||||
},
|
||||
error: function() {
|
||||
taskHistoryChart.hideLoading();
|
||||
layer.msg('获取任务历史数据失败');
|
||||
}
|
||||
});
|
||||
|
||||
// 窗口大小变化时,重新调整图表大小
|
||||
window.addEventListener('resize', function() {
|
||||
taskHistoryChart.resize();
|
||||
});
|
||||
}
|
||||
|
||||
// 库内库位统计南丁格尔图
|
||||
function initLocationChart() {
|
||||
var locationChart = echarts.init(document.getElementById('locationChart'));
|
||||
|
||||
// 显示加载动画
|
||||
locationChart.showLoading();
|
||||
|
||||
// 获取数据
|
||||
$.ajax({
|
||||
url: '/Home/GetLocationChart',
|
||||
type: 'GET',
|
||||
success: function(res) {
|
||||
locationChart.hideLoading();
|
||||
|
||||
// 处理数据
|
||||
var data = [];
|
||||
|
||||
if (res) {
|
||||
try {
|
||||
// 解析后端返回的JSON字符串
|
||||
var dataset = JSON.parse(res.dataset);
|
||||
var series = JSON.parse(res.series);
|
||||
var legend = JSON.parse(res.legend);
|
||||
|
||||
// 从dataset中提取数据
|
||||
if (dataset && dataset.source && dataset.source.length > 1) {
|
||||
// 跳过表头行
|
||||
for (var i = 1; i < dataset.source.length; i++) {
|
||||
var row = dataset.source[i];
|
||||
data.push({
|
||||
name: row[0],
|
||||
value: row[1]
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('解析数据失败:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 设置图表选项
|
||||
var option = {
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: '{a} <br/>{b}: {c} ({d}%)'
|
||||
},
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
left: 'left',
|
||||
data: data.map(item => item.name)
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '库位状态',
|
||||
type: 'pie',
|
||||
radius: ['30%', '70%'],
|
||||
center: ['50%', '50%'],
|
||||
roseType: 'area', // 南丁格尔图
|
||||
itemStyle: {
|
||||
borderRadius: 8
|
||||
},
|
||||
data: data,
|
||||
emphasis: {
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// 设置图表选项并渲染
|
||||
locationChart.setOption(option);
|
||||
},
|
||||
error: function() {
|
||||
locationChart.hideLoading();
|
||||
layer.msg('获取库位统计数据失败');
|
||||
}
|
||||
});
|
||||
|
||||
// 窗口大小变化时,重新调整图表大小
|
||||
window.addEventListener('resize', function() {
|
||||
locationChart.resize();
|
||||
});
|
||||
}
|
||||
|
||||
// 当前任务统计仪表盘
|
||||
function initCurrentTaskChart() {
|
||||
var currentTaskChart = echarts.init(document.getElementById('currentTaskChart'));
|
||||
|
||||
// 显示加载动画
|
||||
currentTaskChart.showLoading();
|
||||
|
||||
// 获取数据
|
||||
$.ajax({
|
||||
url: '/Home/GetCurrentTaskChart',
|
||||
type: 'GET',
|
||||
success: function(res) {
|
||||
currentTaskChart.hideLoading();
|
||||
|
||||
// 处理数据
|
||||
var data = [];
|
||||
var maxValue = 0;
|
||||
|
||||
if (res) {
|
||||
try {
|
||||
// 解析后端返回的JSON字符串
|
||||
var dataset = JSON.parse(res.dataset);
|
||||
var series = JSON.parse(res.series);
|
||||
var legend = JSON.parse(res.legend);
|
||||
|
||||
// 从dataset中提取数据
|
||||
if (dataset && dataset.source && dataset.source.length > 1) {
|
||||
// 跳过表头行
|
||||
for (var i = 1; i < dataset.source.length; i++) {
|
||||
var row = dataset.source[i];
|
||||
data.push({
|
||||
name: row[0],
|
||||
value: parseInt(row[1]) || 0
|
||||
});
|
||||
}
|
||||
|
||||
// 计算最大值,用于仪表盘刻度
|
||||
maxValue = Math.max(...data.map(item => item.value), 10);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('解析数据失败:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// 设置仪表盘的位置和大小
|
||||
var gaugeWidth = 100 / (data.length || 1);
|
||||
var gauges = [];
|
||||
|
||||
data.forEach(function(item, index) {
|
||||
gauges.push({
|
||||
name: item.name,
|
||||
type: 'gauge',
|
||||
center: [(index + 0.5) * gaugeWidth + '%', '55%'],
|
||||
radius: '70%',
|
||||
min: 0,
|
||||
max: maxValue,
|
||||
splitNumber: 5,
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
width: 8,
|
||||
color: [
|
||||
[0.3, '#67e0e3'],
|
||||
[0.7, '#37a2da'],
|
||||
[1, '#fd666d']
|
||||
]
|
||||
}
|
||||
},
|
||||
pointer: {
|
||||
itemStyle: {
|
||||
color: 'auto'
|
||||
}
|
||||
},
|
||||
axisTick: {
|
||||
distance: -30,
|
||||
length: 8,
|
||||
lineStyle: {
|
||||
color: '#fff',
|
||||
width: 2
|
||||
}
|
||||
},
|
||||
splitLine: {
|
||||
distance: -30,
|
||||
length: 30,
|
||||
lineStyle: {
|
||||
color: '#fff',
|
||||
width: 4
|
||||
}
|
||||
},
|
||||
axisLabel: {
|
||||
color: 'auto',
|
||||
distance: 40,
|
||||
fontSize: 10
|
||||
},
|
||||
detail: {
|
||||
valueAnimation: true,
|
||||
formatter: '{value}',
|
||||
color: 'auto',
|
||||
fontSize: 16
|
||||
},
|
||||
title: {
|
||||
offsetCenter: [0, '80%'],
|
||||
fontSize: 12
|
||||
},
|
||||
data: [{
|
||||
value: item.value,
|
||||
name: item.name
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
||||
// 设置图表选项
|
||||
var option = {
|
||||
tooltip: {
|
||||
formatter: '{a} <br/>{b} : {c}'
|
||||
},
|
||||
series: gauges
|
||||
};
|
||||
|
||||
// 设置图表选项并渲染
|
||||
currentTaskChart.setOption(option);
|
||||
},
|
||||
error: function() {
|
||||
currentTaskChart.hideLoading();
|
||||
layer.msg('获取当前任务统计数据失败');
|
||||
}
|
||||
});
|
||||
|
||||
// 窗口大小变化时,重新调整图表大小
|
||||
window.addEventListener('resize', function() {
|
||||
currentTaskChart.resize();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user