货位分析、库存平面图
This commit is contained in:
35
ruoyi-ui/src/api/kpi/spacePlan.js
Normal file
35
ruoyi-ui/src/api/kpi/spacePlan.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
|
||||
//获取巷道列表
|
||||
export function getRoadways(query) {
|
||||
return request({
|
||||
url: '/kpi/getRoadways',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
//获取排列表
|
||||
export function getPlatoons(query) {
|
||||
return request({
|
||||
url: '/kpi/getPlatoons',
|
||||
method: 'get',
|
||||
params:query
|
||||
})
|
||||
}
|
||||
// 获取库存图表
|
||||
export function getChartData(query) {
|
||||
return request({
|
||||
url: '/kpi/getChartData',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function getChartMag(query){
|
||||
return request({
|
||||
url: '/kpi/getChartMag',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
@@ -45,12 +45,13 @@ export default {
|
||||
chart: null,
|
||||
// 图表数据(模拟数据,注意删除后echarts图初始化会报一下错)
|
||||
chartData:[
|
||||
{
|
||||
"巷道2": 1,
|
||||
"巷道1": 0,
|
||||
"status": "出库分配"
|
||||
}
|
||||
]
|
||||
{
|
||||
"巷道2": 1,
|
||||
"巷道1": 0,
|
||||
"status": "出库分配"
|
||||
}
|
||||
],
|
||||
dimensions:[]
|
||||
}
|
||||
}
|
||||
,
|
||||
@@ -102,6 +103,12 @@ export default {
|
||||
,
|
||||
/** 更新图表数据 */
|
||||
updateChart() {
|
||||
this.dimensions=[]
|
||||
if (this.chartData[0].巷道1!=undefined&&this.chartData[0].巷道1!=null){
|
||||
this.dimensions=['status', '巷道1', '巷道2']
|
||||
}else {
|
||||
this.dimensions=['status', '巷道3', '巷道4']
|
||||
}
|
||||
const option = {
|
||||
title: {
|
||||
text: '货位状态分析',
|
||||
@@ -121,7 +128,7 @@ export default {
|
||||
}
|
||||
},
|
||||
dataset: {
|
||||
dimensions: ['status', '巷道1', '巷道2'],
|
||||
dimensions: this.dimensions,
|
||||
source: this.chartData
|
||||
},
|
||||
xAxis: {
|
||||
|
||||
319
ruoyi-ui/src/views/kpi/spacePlan/index.vue
Normal file
319
ruoyi-ui/src/views/kpi/spacePlan/index.vue
Normal file
@@ -0,0 +1,319 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<div class="search-box">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true">
|
||||
<el-form-item label="仓库">
|
||||
<el-select v-model="queryParams.warehouseId" style="width: 150px" @change="handleWarehouseChange">
|
||||
<el-option label="仓库1" value="01"/>
|
||||
<el-option label="仓库2" value="02"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="巷道">
|
||||
<el-select v-model="queryParams.roadwayId" style="width: 150px" @change="handleRoadwayChange">
|
||||
<el-option v-for="item in roadwayOptions" :key="item.value" :label="item.label" :value="item.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="排">
|
||||
<el-select v-model="queryParams.thePlatoon" style="width: 150px" @change="handlePlatoonChange">
|
||||
<el-option v-for="item in platoonOptions" :key="item.value" :label="item.label" :value="item.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="chart-container">
|
||||
<div id="container" v-show="queryParams.warehouseId !== '04'" style="height: 80vh"></div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as echarts from 'echarts'
|
||||
import {getRoadways, getPlatoons, getChartData, getChartMag} from "@/api/kpi/spacePlan"
|
||||
|
||||
export default {
|
||||
name: 'SpacePlan',
|
||||
data() {
|
||||
return {
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
warehouseId: '01',
|
||||
roadwayId: '1',
|
||||
thePlatoon: '',
|
||||
platoon: '1',
|
||||
specifications: '',
|
||||
quantity_x: '',
|
||||
quantity_j: '',
|
||||
layer_quantity: '',
|
||||
classgroup_number: '',
|
||||
class_workshop_date_time: '',
|
||||
class_now_date_time: '',
|
||||
print_date: '',
|
||||
lot_no: ''
|
||||
},
|
||||
// 巷道选项
|
||||
roadwayOptions: [],
|
||||
// 排号选项
|
||||
platoonOptions: [],
|
||||
// 图表实例
|
||||
normalChart: null,
|
||||
specialChart: null,
|
||||
// 提示信息缓存
|
||||
tooltipCache: {},
|
||||
// 图表数据
|
||||
chartData: {
|
||||
x: [],
|
||||
y: [],
|
||||
empty: [],
|
||||
full: [],
|
||||
inAllot: [],
|
||||
outAllot: [],
|
||||
inCheck: [],
|
||||
outCheck: [],
|
||||
resultsOf: [],
|
||||
outCargo: [],
|
||||
theLocked: []
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initCharts()
|
||||
this.handleWarehouseChange()
|
||||
},
|
||||
methods: {
|
||||
// 初始化图表
|
||||
initCharts() {
|
||||
this.normalChart = echarts.init(document.getElementById('container'))
|
||||
},
|
||||
// 仓库变化处理
|
||||
handleWarehouseChange() {
|
||||
// 重置巷道和排号
|
||||
this.queryParams.roadwayId = ''
|
||||
this.queryParams.thePlatoon = ''
|
||||
this.roadwayOptions = []
|
||||
this.platoonOptions = []
|
||||
// 清空提示信息缓存
|
||||
this.tooltipCache = {}
|
||||
// 获取巷道列表
|
||||
getRoadways(this.queryParams).then(response => {
|
||||
const roadways = response.data.data
|
||||
if (roadways && roadways.length > 0) {
|
||||
this.roadwayOptions = roadways
|
||||
this.queryParams.roadwayId = roadways[0].value
|
||||
this.handleRoadwayChange()
|
||||
}
|
||||
})
|
||||
},
|
||||
// 巷道变化处理
|
||||
handleRoadwayChange() {
|
||||
// 重置排号
|
||||
this.queryParams.thePlatoon = ''
|
||||
this.platoonOptions = []
|
||||
// 清空提示信息缓存
|
||||
this.tooltipCache = {}
|
||||
// 获取排号列表
|
||||
getPlatoons(this.queryParams).then(response => {
|
||||
const platoons = response.data.data
|
||||
if (platoons && platoons.length > 0) {
|
||||
this.platoonOptions = platoons
|
||||
this.queryParams.thePlatoon = platoons[0].value
|
||||
this.loadChartData()
|
||||
}
|
||||
})
|
||||
},
|
||||
handlePlatoonChange() {
|
||||
// 清空提示信息缓存
|
||||
this.tooltipCache = {}
|
||||
this.loadChartData()
|
||||
},
|
||||
// 加载普通仓库图表数据
|
||||
loadChartData() {
|
||||
getChartData(this.queryParams).then(response => {
|
||||
const data = response.data
|
||||
// 调整坐标值以匹配实际位置
|
||||
const adjustCoordinates = (data) => {
|
||||
return data.map(item => [item[0] - 1, item[1] - 1, item[2]]);
|
||||
};
|
||||
this.chartData.x = eval('(' + data["column"] + ')');
|
||||
this.chartData.y = eval('(' + data["floor"] + ')');
|
||||
this.chartData.empty = adjustCoordinates(eval('(' + data["empty"] + ')'));
|
||||
this.chartData.full = adjustCoordinates(eval('(' + data["full"] + ')'));
|
||||
this.chartData.inAllot = adjustCoordinates(eval('(' + data["inAllot"] + ')'));
|
||||
this.chartData.outAllot = adjustCoordinates(eval('(' + data["outAllot"] + ')'));
|
||||
this.chartData.inCheck = adjustCoordinates(eval('(' + data["inCheck"] + ')'));
|
||||
this.chartData.outCheck = adjustCoordinates(eval('(' + data["outCheck"] + ')'));
|
||||
this.updateNormalChart()
|
||||
})
|
||||
|
||||
|
||||
},
|
||||
|
||||
// 更新普通仓库图表
|
||||
updateNormalChart() {
|
||||
const option = {
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: (params) => {
|
||||
return this.formatTooltip(params)
|
||||
}
|
||||
},
|
||||
title: {
|
||||
text: '库位分布平面图',
|
||||
subtext: this.queryParams.thePlatoon + '排'
|
||||
},
|
||||
grid: {
|
||||
width: '90%',
|
||||
height: '70%',
|
||||
top: '20%',
|
||||
left: '5%'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: this.chartData.x,
|
||||
splitArea: {show: true}
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
data: this.chartData.y,
|
||||
splitArea: {show: true}
|
||||
},
|
||||
visualMap: {
|
||||
show: false,
|
||||
min: 1,
|
||||
max: 6,
|
||||
calculable: true,
|
||||
orient: 'horizontal',
|
||||
left: 'center',
|
||||
inRange: {
|
||||
color: ['#AEEEEE', '#FF9900', '#FFFF00', '#00CC00', '#FF0000', '#0000FF']
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
data: ['空位', '满位', '入库分配', '出库分配', '入库需盘点', '出库需盘点']
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '空位',
|
||||
type: 'heatmap',
|
||||
data: this.chartData.empty,
|
||||
itemStyle: {
|
||||
borderColor: '#fff',
|
||||
borderWidth: 2
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '满位',
|
||||
type: 'heatmap',
|
||||
data: this.chartData.full,
|
||||
itemStyle: {
|
||||
borderColor: '#fff',
|
||||
borderWidth: 2
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '入库分配',
|
||||
type: 'heatmap',
|
||||
data: this.chartData.inAllot,
|
||||
itemStyle: {
|
||||
borderColor: '#fff',
|
||||
borderWidth: 2
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '出库分配',
|
||||
type: 'heatmap',
|
||||
data: this.chartData.outAllot,
|
||||
itemStyle: {
|
||||
borderColor: '#fff',
|
||||
borderWidth: 2
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '入库需盘点',
|
||||
type: 'heatmap',
|
||||
data: this.chartData.inCheck,
|
||||
itemStyle: {
|
||||
borderColor: '#fff',
|
||||
borderWidth: 2
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '出库需盘点',
|
||||
type: 'heatmap',
|
||||
data: this.chartData.outCheck,
|
||||
itemStyle: {
|
||||
borderColor: '#fff',
|
||||
borderWidth: 2
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
this.normalChart.setOption(option)
|
||||
},
|
||||
|
||||
// 格式化普通仓库提示信息
|
||||
formatTooltip(params) {
|
||||
return new Promise((resolve) => {
|
||||
let str = '';
|
||||
if (params.seriesName !== '满位') {
|
||||
str = params.seriesName + '<br>' + this.queryParams.thePlatoon + '排' + (params.data[0] + 1) + '列' + (params.data[1] + 1) + '层';
|
||||
resolve(str);
|
||||
} else {
|
||||
const key = `${this.queryParams.warehouseId}-${this.queryParams.thePlatoon}-${params.data[0] + 1}-${params.data[1] + 1}`;
|
||||
// 如果缓存中存在数据,直接使用缓存
|
||||
if (this.tooltipCache && this.tooltipCache[key]) {
|
||||
str = `${params.seriesName}<br>${this.queryParams.thePlatoon}排${params.data[0] + 1}列${params.data[1] + 1}层<br>${this.tooltipCache[key]}`;
|
||||
resolve(str);
|
||||
return;
|
||||
}
|
||||
|
||||
const returnData = {
|
||||
"thePlatoon": this.queryParams.thePlatoon,
|
||||
"theColumn": params.data[0] + 1,
|
||||
"theFloor": params.data[1] + 1,
|
||||
"warehouseId": this.queryParams.warehouseId
|
||||
};
|
||||
|
||||
getChartMag(returnData)
|
||||
.then(response => {
|
||||
const msg = response.data.msg;
|
||||
// 缓存响应数据
|
||||
if (!this.tooltipCache) this.tooltipCache = {};
|
||||
this.tooltipCache[key] = msg;
|
||||
str = `${params.seriesName}<br>${this.queryParams.thePlatoon}排${params.data[0] + 1}列${params.data[1] + 1}层<br>${msg}`;
|
||||
resolve(str);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('获取货位信息失败:', error);
|
||||
str = `${params.seriesName}<br>${this.queryParams.thePlatoon}排${params.data[0] + 1}列${params.data[1] + 1}层<br>获取详细信息失败`;
|
||||
resolve(str);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.app-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
background-color: #fff;
|
||||
padding: 20px;
|
||||
margin-bottom: 20px;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.chart-container {
|
||||
background-color: #fff;
|
||||
padding: 20px;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user