添加datapage页面
修改新物料没有订单是返回所有的工序,优先满足入库
This commit is contained in:
1 parent
59f2af943b
commit
b78861a3d6
6 files changed
+641
-2
No files matched your search
@@ -0,0 +1,248 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using HHWMS.Web.Models;
|
||||
using HHWMS.Web.Support;
|
||||
using HHWMS.Web.Support.PLC;
|
||||
using HslCommunication;
|
||||
using HslCommunication.Profinet.Siemens;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using HslCommunication.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
|
||||
namespace HHWMS.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// 提供给WCS调用接口
|
||||
/// 调用方向 WCS --> WMS
|
||||
/// </summary>
|
||||
[Public]
|
||||
[ActionDescription("HHWMS.DataApi")]
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]"), ApiExplorerSettings(GroupName = "User")]
|
||||
public class IDataController : ApiController
|
||||
{
|
||||
private readonly IUnitWork _unitWork;
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IMemoryCache _cache;
|
||||
|
||||
public IDataController(IUnitWork unitWork, IMapper mapper, IMemoryCache cache)
|
||||
{
|
||||
_unitWork = unitWork;
|
||||
_mapper = mapper;
|
||||
_cache = cache;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetTaskHistoryChart()
|
||||
{
|
||||
var data = new List<ChartData>();
|
||||
// 获取一周内的日期
|
||||
var today = DateTime.Today;
|
||||
var weekStart = today.AddDays(-6);
|
||||
|
||||
// 查询一周内的出入库任务历史
|
||||
var taskHis = Wtm.DC.Set<TaskHeaderHistory>()
|
||||
.Where(x => x.CreateTime >= weekStart && x.CreateTime <= today.AddDays(1))
|
||||
.Select(x => new
|
||||
{
|
||||
TaskType = x.TaskType,
|
||||
Date = x.CreateTime.ToString(),
|
||||
})
|
||||
.ToList();
|
||||
var taskHistory = taskHis
|
||||
.GroupBy(x => new { Date = x.Date.Substring(0,10), Type = x.TaskType })
|
||||
.Select(g => new { Date = g.Key.Date, Type = g.Key.Type, Count = g.Count() })
|
||||
.ToList();
|
||||
|
||||
// 生成每天的数据
|
||||
for (var date = weekStart; date <= today; date = date.AddDays(1))
|
||||
{
|
||||
// 入库任务
|
||||
var inCount = taskHistory
|
||||
.Where(x => x.Date == date.ToString("yyyy-MM-dd") && x.Type == TaskTypeEnum.入库)
|
||||
.Sum(x => x.Count);
|
||||
|
||||
data.Add(new ChartData
|
||||
{
|
||||
Category = date.ToString("MM-dd"),
|
||||
Value = inCount,
|
||||
Series = "入库任务"
|
||||
});
|
||||
|
||||
// 出库任务
|
||||
var outCount = taskHistory
|
||||
.Where(x => x.Date == date.ToString("yyyy-MM-dd") && x.Type == TaskTypeEnum.出库)
|
||||
.Sum(x => x.Count);
|
||||
|
||||
data.Add(new ChartData
|
||||
{
|
||||
Category = date.ToString("MM-dd"),
|
||||
Value = outCount,
|
||||
Series = "出库任务"
|
||||
});
|
||||
|
||||
// 移库任务
|
||||
var moveCount = taskHistory
|
||||
.Where(x => x.Date == date.ToString("yyyy-MM-dd") && x.Type == TaskTypeEnum.移库)
|
||||
.Sum(x => x.Count);
|
||||
|
||||
data.Add(new ChartData
|
||||
{
|
||||
Category = date.ToString("MM-dd"),
|
||||
Value = moveCount,
|
||||
Series = "移库任务"
|
||||
});
|
||||
}
|
||||
|
||||
var rv = data.ToChartData();
|
||||
return ApiResult(rv);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetContainerChart()
|
||||
{
|
||||
var data = new List<ChartData>();
|
||||
|
||||
// 查询不同类型的容器数量
|
||||
var containers = Wtm.DC.Set<Container>()
|
||||
.AsEnumerable()
|
||||
.GroupBy(x => x.Type)
|
||||
.Select(g => new { Type = g.Key, Count = g.Count() })
|
||||
.ToList();
|
||||
|
||||
foreach (var container in containers)
|
||||
{
|
||||
data.Add(new ChartData
|
||||
{
|
||||
Category = container.Type,
|
||||
Value = container.Count,
|
||||
Series = "容器类型"
|
||||
});
|
||||
}
|
||||
|
||||
var rv = data.ToChartData();
|
||||
return ApiResult(rv);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetCurrentTaskChart()
|
||||
{
|
||||
var data = new List<ChartData>();
|
||||
|
||||
// 查询当前任务状态
|
||||
var tasks = Wtm.DC.Set<TaskHeader>()
|
||||
.AsEnumerable()
|
||||
.GroupBy(x => x.TaskType)
|
||||
.Select(g => new { Type = g.Key, Count = g.Count() })
|
||||
.ToList();
|
||||
|
||||
foreach (var task in tasks)
|
||||
{
|
||||
data.Add(new ChartData
|
||||
{
|
||||
Category = task.Type.ToString(),
|
||||
Value = task.Count,
|
||||
Series = "当前任务"
|
||||
});
|
||||
}
|
||||
|
||||
var rv = data.ToChartData();
|
||||
return ApiResult(rv);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetLocationChart()
|
||||
{
|
||||
var statusMap = new Dictionary<string, string> // 如果是字符串类型,键改为string
|
||||
{
|
||||
{ LocationStatus.有货, "有货" },
|
||||
{ LocationStatus.空仓位, "空仓位" },
|
||||
{ LocationStatus.空容器, "空容器" },
|
||||
{ LocationStatus.任务锁, "任务锁" },
|
||||
// 补充其他状态的映射关系
|
||||
};
|
||||
|
||||
var data = new List<ChartData>();
|
||||
var locations = Wtm.DC.Set<Location>()
|
||||
.AsEnumerable()
|
||||
.GroupBy(x => x.ContainerStatus).ToList()
|
||||
.Select(x => new { status = statusMap.TryGetValue(x.Key, out var chineseName)
|
||||
? chineseName
|
||||
: x.Key.ToString(), count = x.Count() });
|
||||
foreach (var item in locations)
|
||||
{
|
||||
data.Add(new ChartData
|
||||
{
|
||||
Value = item.count,
|
||||
Category = item.status.ToString(),
|
||||
Series = "库位状态"
|
||||
});
|
||||
}
|
||||
|
||||
var rv = data.ToChartData();
|
||||
return ApiResult(rv);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult GetLocationHeatmap()
|
||||
{
|
||||
var statusMap = new Dictionary<string, (string name, string color)>
|
||||
{
|
||||
{ LocationStatus.空仓位, ("空仓位", "#E1E1E1") },
|
||||
{ LocationStatus.有货, ("有货", "#409EFF") },
|
||||
{ LocationStatus.满货, ("满货", "#E6A23C") },
|
||||
{ LocationStatus.任务锁, ("任务锁", "#F56C6C") },
|
||||
{ LocationStatus.空容器, ("空容器", "#67C23A") },
|
||||
};
|
||||
|
||||
var locations = Wtm.DC.Set<Location>()
|
||||
.Where(x => x.ZoneId != 1027)
|
||||
.OrderBy(x => x.RoadWay)
|
||||
.ThenBy(x => x.Row)
|
||||
.ThenBy(x => x.Line)
|
||||
.ThenBy(x => x.Layer)
|
||||
.ToList();
|
||||
|
||||
var groups = locations.GroupBy(x => new { x.RoadWay, x.Row });
|
||||
var result = new List<HeatmapDto>();
|
||||
|
||||
foreach (var group in groups)
|
||||
{
|
||||
var heatmap = new HeatmapDto
|
||||
{
|
||||
Title = $"第{group.Key.RoadWay}巷道第{group.Key.Row}排",
|
||||
RoadWay = group.Key.RoadWay,
|
||||
Row = group.Key.Row,
|
||||
Points = new List<HeatmapPointDto>(),
|
||||
MaxLine = group.Max(x => x.Line),
|
||||
MaxLayer = group.Max(x => x.Layer)
|
||||
};
|
||||
|
||||
foreach (var loc in group)
|
||||
{
|
||||
statusMap.TryGetValue(loc.ContainerStatus, out var statusInfo);
|
||||
heatmap.Points.Add(new HeatmapPointDto
|
||||
{
|
||||
Line = loc.Line,
|
||||
Layer = loc.Layer,
|
||||
Status = statusInfo.name ?? loc.ContainerStatus ?? "未知",
|
||||
Color = statusInfo.color ?? "#909399",
|
||||
ContainerCode = loc.ContainerCode,
|
||||
LocationCode = loc.Code
|
||||
});
|
||||
}
|
||||
result.Add(heatmap);
|
||||
}
|
||||
|
||||
return ApiResult(result);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -235,6 +235,19 @@ namespace HHWMS.Web.Controllers
|
||||
processName = x.ProcessName
|
||||
})
|
||||
.ToList();
|
||||
if (processes.Count == 0)
|
||||
{
|
||||
processes = _unitWork.Find<ProcessConfig>(x => x.ID > 0)
|
||||
.OrderBy(x => x.Code)
|
||||
.Select(x => new
|
||||
{
|
||||
value = x.ID.ToString(),
|
||||
label = x.Name,
|
||||
processCode = x.Code,
|
||||
processName = x.Name
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
return Json(new { Code = 200, Data = processes });
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -266,7 +279,7 @@ namespace HHWMS.Web.Controllers
|
||||
var orders = result.Data.Select(x => new
|
||||
{
|
||||
value = x.MoDetailId,
|
||||
label = x.MoCode,
|
||||
label = string.IsNullOrEmpty(x.MoCode) ? x.MoDetailId : x.MoCode,
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
@@ -44,6 +44,13 @@ namespace HHWMS.Web.Controllers
|
||||
|
||||
return PartialView();
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[ActionDescription("DataPage")]
|
||||
public IActionResult DataPage()
|
||||
{
|
||||
return PartialView();
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
public IActionResult GetActionChart()
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HHWMS.Web.Models
|
||||
{
|
||||
public class HeatmapDto
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public int RoadWay { get; set; }
|
||||
public int Row { get; set; }
|
||||
public List<HeatmapPointDto> Points { get; set; }
|
||||
public int MaxLine { get; set; }
|
||||
public int MaxLayer { get; set; }
|
||||
}
|
||||
|
||||
public class HeatmapPointDto
|
||||
{
|
||||
public int Line { get; set; }
|
||||
public int Layer { get; set; }
|
||||
public string Status { get; set; }
|
||||
public string Color { get; set; }
|
||||
public string ContainerCode { get; set; }
|
||||
public string LocationCode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
|
||||
},
|
||||
"applicationUrl": "http://localhost:5000/"
|
||||
"applicationUrl": "http://0.0.0.0:5000/"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,347 @@
|
||||
@model WalkingTec.Mvvm.Core.BaseVM
|
||||
@using System.Text.Json
|
||||
|
||||
<div id="app">
|
||||
<div id="fullscreen-container" style="padding: 20px; background-color: #f2f3f5; min-height: 100vh; position: relative;">
|
||||
<!-- 全屏按钮 -->
|
||||
<div style="position: absolute; top: 20px; right: 20px; z-index: 100;">
|
||||
<a-button type="primary" shape="circle" @@click="toggleFullscreen">
|
||||
<template #icon>
|
||||
<icon-fullscreen-exit v-if="isFullscreen"></icon-fullscreen-exit>
|
||||
<icon-fullscreen v-else></icon-fullscreen>
|
||||
</template>
|
||||
</a-button>
|
||||
</div>
|
||||
|
||||
<a-grid :cols="24" :col-gap="16" :row-gap="16">
|
||||
<!-- 一周内出入库任务统计柱状图 -->
|
||||
<a-grid-item :span="24">
|
||||
<a-card title="一周内出入库任务统计" :bordered="false" :style="{ borderRadius: '8px' }">
|
||||
<div id="taskHistoryChart" style="width: 100%; height: 350px;"></div>
|
||||
</a-card>
|
||||
</a-grid-item>
|
||||
|
||||
<!-- 库内库位统计南丁格尔图 -->
|
||||
<a-grid-item :span="12">
|
||||
<a-card title="库内库位统计" :bordered="false" :style="{ borderRadius: '8px' }">
|
||||
<div id="locationChart" style="width: 100%; height: 350px;"></div>
|
||||
</a-card>
|
||||
</a-grid-item>
|
||||
|
||||
<!-- 当前任务统计仪表盘 -->
|
||||
<a-grid-item :span="12">
|
||||
<a-card title="未完成任务统计" :bordered="false" :style="{ borderRadius: '8px' }">
|
||||
<div id="currentTaskChart" style="width: 100%; height: 350px;"></div>
|
||||
</a-card>
|
||||
</a-grid-item>
|
||||
<!-- Heatmap Display -->
|
||||
<a-grid-item :span="24">
|
||||
<a-card title="库位占用分布 (Heatmap)" :bordered="false" :style="{ borderRadius: '8px' }">
|
||||
<!-- 状态图例 -->
|
||||
<div style="margin-bottom: 16px; display: flex; justify-content: center; gap: 20px;">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<div style="width: 16px; height: 16px; background-color: #EBEEF5; border: 1px solid #DCDFE6; border-radius: 2px;"></div>
|
||||
<span style="font-size: 13px;">空仓位</span>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<div style="width: 16px; height: 16px; background-color: #1890FF; border-radius: 2px;"></div>
|
||||
<span style="font-size: 13px;">有货</span>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<div style="width: 16px; height: 16px; background-color: #FAAD14; border-radius: 2px;"></div>
|
||||
<span style="font-size: 13px;">满货</span>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<div style="width: 16px; height: 16px; background-color: #F5222D; border-radius: 2px;"></div>
|
||||
<span style="font-size: 13px;">任务锁</span>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<div style="width: 16px; height: 16px; background-color: #52C41A; border-radius: 2px;"></div>
|
||||
<span style="font-size: 13px;">空容器</span>
|
||||
</div>
|
||||
</div>
|
||||
<a-grid :cols="24" :col-gap="16" :row-gap="16">
|
||||
<a-grid-item v-for="(item, index) in heatmaps" :key="index" :span="12">
|
||||
<div :id="'heatmap-' + index" style="width: 100%; height: 320px;"></div>
|
||||
</a-grid-item>
|
||||
</a-grid>
|
||||
</a-card>
|
||||
</a-grid-item>
|
||||
</a-grid>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/front/vue.global.js"></script>
|
||||
<script src="/front/arco-vue.js"></script>
|
||||
<script src="/front/arco-vue-icon.js"></script>
|
||||
<link rel="stylesheet" href="/front/arco.min.css" />
|
||||
<script src="/jquery.min.js"></script>
|
||||
<script src="/jquery.cookie.js"></script>
|
||||
<script src="/echarts/json-fns.js"></script>
|
||||
<script src="/echarts/echarts.min.js"></script>
|
||||
<script src="/echarts/chalk.js"></script>
|
||||
<script src="/echarts/essos.js"></script>
|
||||
<script src="/echarts/macarons.js"></script>
|
||||
<script src="/echarts/roma.js"></script>
|
||||
<script src="/echarts/vintage.js"></script>
|
||||
<script src="/echarts/walden.js"></script>
|
||||
<script src="/echarts/westeros.js"></script>
|
||||
<script src="/echarts/wonderland.js"></script>
|
||||
|
||||
<script>
|
||||
const { createApp, ref, onMounted, onUnmounted, nextTick } = Vue;
|
||||
|
||||
const App = {
|
||||
setup() {
|
||||
let charts = [];
|
||||
const isFullscreen = ref(false);
|
||||
const heatmaps = ref([]);
|
||||
|
||||
const toggleFullscreen = () => {
|
||||
const container = document.getElementById('fullscreen-container');
|
||||
if (!document.fullscreenElement) {
|
||||
container.requestFullscreen().catch(err => {
|
||||
console.error(`Error attempting to enable full-screen mode: ${err.message}`);
|
||||
});
|
||||
} else {
|
||||
document.exitFullscreen();
|
||||
}
|
||||
};
|
||||
|
||||
const handleFullscreenChange = () => {
|
||||
isFullscreen.value = !!document.fullscreenElement;
|
||||
// Resize charts after transition
|
||||
setTimeout(() => {
|
||||
charts.forEach(chart => chart && chart.resize());
|
||||
}, 300);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
nextTick(() => {
|
||||
initCharts();
|
||||
// Ensure charts are correctly sized after layout
|
||||
setTimeout(() => {
|
||||
charts.forEach(chart => chart && chart.resize());
|
||||
}, 200);
|
||||
});
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
charts.forEach(chart => chart && chart.resize());
|
||||
});
|
||||
|
||||
document.addEventListener('fullscreenchange', handleFullscreenChange);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener('fullscreenchange', handleFullscreenChange);
|
||||
});
|
||||
|
||||
const initCharts = () => {
|
||||
charts.push(initTaskHistoryChart());
|
||||
charts.push(initLocationChart());
|
||||
charts.push(initCurrentTaskChart());
|
||||
initHeatmaps();
|
||||
};
|
||||
|
||||
function initTaskHistoryChart() {
|
||||
const chart = echarts.init(document.getElementById('taskHistoryChart'));
|
||||
chart.showLoading();
|
||||
$.ajax({
|
||||
url: '/api/IData/GetTaskHistoryChart',
|
||||
type: 'GET',
|
||||
success: (res) => {
|
||||
chart.hideLoading();
|
||||
const data = res.Data || res;
|
||||
if (!data) return;
|
||||
try {
|
||||
const dataset = JSON.parse(data.dataset);
|
||||
if (dataset && dataset.source && dataset.source.length > 1) {
|
||||
const headers = dataset.source[0];
|
||||
const inIndex = headers.indexOf('入库任务');
|
||||
const outIndex = headers.indexOf('出库任务');
|
||||
const moveIndex = headers.indexOf('移库任务');
|
||||
const categories = dataset.source.slice(1).map(row => row[0]);
|
||||
const inData = dataset.source.slice(1).map(row => inIndex >= 0 ? parseInt(row[inIndex]) || 0 : 0);
|
||||
const outData = dataset.source.slice(1).map(row => outIndex >= 0 ? parseInt(row[outIndex]) || 0 : 0);
|
||||
const moveData = dataset.source.slice(1).map(row => moveIndex >= 0 ? parseInt(row[moveIndex]) || 0 : 0);
|
||||
|
||||
chart.setOption({
|
||||
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' }, data: inData },
|
||||
{ name: '出库任务', type: 'bar', label: { show: true, position: 'top' }, data: outData },
|
||||
{ name: '移库任务', type: 'bar', label: { show: true, position: 'top' }, data: moveData }
|
||||
]
|
||||
});
|
||||
}
|
||||
} catch (e) { console.error('Data parse error:', e); }
|
||||
},
|
||||
error: () => {
|
||||
chart.hideLoading();
|
||||
if (window.ArcoVue && window.ArcoVue.Message) window.ArcoVue.Message.error('获取任务历史数据失败');
|
||||
}
|
||||
});
|
||||
return chart;
|
||||
}
|
||||
|
||||
function initLocationChart() {
|
||||
const chart = echarts.init(document.getElementById('locationChart'));
|
||||
chart.showLoading();
|
||||
$.ajax({
|
||||
url: '/api/IData/GetLocationChart',
|
||||
type: 'GET',
|
||||
success: (res) => {
|
||||
chart.hideLoading();
|
||||
const chartData = res.Data || res;
|
||||
if (!chartData) return;
|
||||
try {
|
||||
const dataset = JSON.parse(chartData.dataset);
|
||||
if (dataset && dataset.source && dataset.source.length > 1) {
|
||||
const data = dataset.source.slice(1).map(row => ({ name: row[0], value: row[1] }));
|
||||
chart.setOption({
|
||||
tooltip: { trigger: 'item', formatter: '{a} <br/>{b}: {c} ({d}%)' },
|
||||
legend: { orient: 'vertical', left: 'left' },
|
||||
series: [{
|
||||
name: '库位状态', type: 'pie', radius: ['30%', '70%'], roseType: 'area',
|
||||
itemStyle: { borderRadius: 8 }, data: data
|
||||
}]
|
||||
});
|
||||
}
|
||||
} catch (e) { console.error('Data parse error:', e); }
|
||||
},
|
||||
error: () => {
|
||||
chart.hideLoading();
|
||||
if (window.ArcoVue && window.ArcoVue.Message) window.ArcoVue.Message.error('获取库位统计数据失败');
|
||||
}
|
||||
});
|
||||
return chart;
|
||||
}
|
||||
|
||||
function initCurrentTaskChart() {
|
||||
const chart = echarts.init(document.getElementById('currentTaskChart'));
|
||||
chart.showLoading();
|
||||
$.ajax({
|
||||
url: '/api/IData/GetCurrentTaskChart',
|
||||
type: 'GET',
|
||||
success: (res) => {
|
||||
chart.hideLoading();
|
||||
const chartData = res.Data || res;
|
||||
if (!chartData) return;
|
||||
try {
|
||||
const dataset = JSON.parse(chartData.dataset);
|
||||
if (dataset && dataset.source && dataset.source.length > 1) {
|
||||
const data = dataset.source.slice(1).map(row => ({ name: row[0], value: parseInt(row[1]) || 0 }));
|
||||
const maxValue = Math.max(...data.map(item => item.value), 10);
|
||||
const gaugeWidth = 100 / (data.length || 1);
|
||||
const series = data.map((item, index) => ({
|
||||
name: item.name, type: 'gauge', center: [(index + 0.5) * gaugeWidth + '%', '55%'],
|
||||
radius: '70%', min: 0, max: maxValue, detail: { valueAnimation: true, formatter: '{value}', fontSize: 16 },
|
||||
title: { offsetCenter: [0, '80%'], fontSize: 12 }, data: [{ value: item.value, name: item.name }]
|
||||
}));
|
||||
chart.setOption({ tooltip: { formatter: '{a} <br/>{b} : {c}' }, series: series });
|
||||
}
|
||||
} catch (e) { console.error('Data parse error:', e); }
|
||||
},
|
||||
error: () => {
|
||||
chart.hideLoading();
|
||||
if (window.ArcoVue && window.ArcoVue.Message) window.ArcoVue.Message.error('获取当前任务统计数据失败');
|
||||
}
|
||||
});
|
||||
return chart;
|
||||
}
|
||||
|
||||
function initHeatmaps() {
|
||||
$.ajax({
|
||||
url: '/api/IData/GetLocationHeatmap',
|
||||
type: 'GET',
|
||||
success: (res) => {
|
||||
const data = res.Data || res;
|
||||
if (!data || !Array.isArray(data)) return;
|
||||
heatmaps.value = data;
|
||||
|
||||
nextTick(() => {
|
||||
data.forEach((hm, index) => {
|
||||
const chartDom = document.getElementById('heatmap-' + index);
|
||||
if (!chartDom) return;
|
||||
const chart = echarts.init(chartDom);
|
||||
|
||||
// Prepare heatmap data: [x, y, value, status, color, locationCode, containerCode]
|
||||
const points = hm.points || hm.Points || [];
|
||||
const scatterData = points.map(p => {
|
||||
return [
|
||||
(p.line ?? p.Line) - 1,
|
||||
(p.layer ?? p.Layer) - 1,
|
||||
1,
|
||||
p.status ?? p.Status,
|
||||
p.color ?? p.Color,
|
||||
p.locationCode ?? p.LocationCode,
|
||||
p.containerCode ?? p.ContainerCode
|
||||
];
|
||||
});
|
||||
|
||||
const option = {
|
||||
title: { text: hm.title || hm.Title, left: 'center', textStyle: { fontSize: 14 } },
|
||||
tooltip: {
|
||||
position: 'top',
|
||||
formatter: function (params) {
|
||||
return `库位: ${params.data[5]}<br/>状态: ${params.data[3]}<br/>容器: ${params.data[6] || '无'}`;
|
||||
}
|
||||
},
|
||||
grid: { height: '65%', top: '15%', bottom: '20%', left: '8%', right: '8%' },
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: Array.from({length: hm.maxLine || hm.MaxLine}, (_, i) => i + 1),
|
||||
splitArea: { show: true },
|
||||
name: '列'
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
data: Array.from({length: hm.maxLayer || hm.MaxLayer}, (_, i) => i + 1),
|
||||
splitArea: { show: true },
|
||||
name: '层'
|
||||
},
|
||||
series: [{
|
||||
name: hm.title || hm.Title,
|
||||
type: 'heatmap',
|
||||
data: scatterData,
|
||||
label: { show: false },
|
||||
itemStyle: {
|
||||
color: function(params) {
|
||||
return params.data[4];
|
||||
},
|
||||
borderWidth: 1,
|
||||
borderColor: '#fff'
|
||||
},
|
||||
emphasis: {
|
||||
itemStyle: { shadowBlur: 10, shadowColor: 'rgba(0, 0, 0, 0.5)' }
|
||||
}
|
||||
}]
|
||||
};
|
||||
chart.setOption(option);
|
||||
charts.push(chart);
|
||||
});
|
||||
});
|
||||
},
|
||||
error: () => {
|
||||
if (window.ArcoVue && window.ArcoVue.Message) window.ArcoVue.Message.error('获取库位热力图数据失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
isFullscreen,
|
||||
toggleFullscreen,
|
||||
heatmaps
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const app = createApp(App);
|
||||
app.use(window.ArcoVue);
|
||||
app.use(window.ArcoVueIcon);
|
||||
app.mount('#app');
|
||||
</script>
|
||||
Reference in new issue
Block a user