From 9559511e56803a558063373f0b0308d03011bebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=AB=E7=8C=ABguowen?= <9290821+guowen-the-cat@user.noreply.gitee.com> Date: Fri, 23 May 2025 17:55:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A7=E4=BD=8D=E5=88=86=E6=9E=90=E3=80=81?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E5=B9=B3=E9=9D=A2=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/kpi/controller/KpiController.java | 57 +++- .../com/ruoyi/kpi/service/KpiService.java | 9 + .../kpi/service/impl/KpiServiceImpl.java | 175 +++++++++- ruoyi-ui/src/api/kpi/spacePlan.js | 35 ++ .../src/views/kpi/spaceAnalysis/index.vue | 21 +- ruoyi-ui/src/views/kpi/spacePlan/index.vue | 319 ++++++++++++++++++ 6 files changed, 607 insertions(+), 9 deletions(-) create mode 100644 ruoyi-ui/src/api/kpi/spacePlan.js create mode 100644 ruoyi-ui/src/views/kpi/spacePlan/index.vue diff --git a/ruoyi-admin/src/main/java/com/ruoyi/kpi/controller/KpiController.java b/ruoyi-admin/src/main/java/com/ruoyi/kpi/controller/KpiController.java index b692500..4f334bd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/kpi/controller/KpiController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/kpi/controller/KpiController.java @@ -67,10 +67,65 @@ public class KpiController extends BaseController { * 获取货位分析数据 * * @param warehouseId 仓库ID - * @return 货位分析数据} + * @return 货位分析数据 */ @GetMapping("/spaceAnalysis") public AjaxResult getSpaceAnalysis(@RequestParam("warehouseId") String warehouseId) { return success(kpiService.getSpaceAnalysis(warehouseId)); } + + /** + * 获取货位巷道数据 + * + * @param warehouseId 仓库ID + * @return 货位巷道数据 + */ + @GetMapping("/getRoadways") + public AjaxResult getRoadways(@RequestParam("warehouseId") String warehouseId){ + return success(kpiService.getRoadways(warehouseId)); + } + /** + * 获取货位排数据 + * + * @param warehouseId 仓库ID + * @param roadwayId 巷道ID + * @return 货位排数据 + */ + @GetMapping("/getPlatoons") + public AjaxResult getPlatoons(@RequestParam("warehouseId") String warehouseId, + @RequestParam("roadwayId") String roadwayId){ + return success(kpiService.getPlatoons(warehouseId,roadwayId)); + } + + /** + * 获取库存平面图 + * + * @param warehouseId 仓库ID + * @param roadwayId 巷道ID + * @param thePlatoon 排 + * @return 库存平面图数据 + */ + @GetMapping("/getChartData") + public AjaxResult getChartData(@RequestParam("warehouseId") String warehouseId, + @RequestParam("roadwayId") String roadwayId, + @RequestParam("thePlatoon") String thePlatoon){ + return success(kpiService.getChartData(warehouseId,roadwayId,thePlatoon)); + } + + /** + * 获取库存平面图信息 + * + * @param warehouseId 仓库ID + * @param theColumn 列 + * @param thePlatoon 排 + * @param theFloor 层 + * @return 库存平面图信息数据 + */ + @GetMapping("/getChartMag") + public AjaxResult getChartMag(@RequestParam("warehouseId") String warehouseId, + @RequestParam("theColumn") String theColumn, + @RequestParam("theFloor") String theFloor, + @RequestParam("thePlatoon") String thePlatoon){ + return success(kpiService.getChartMag(warehouseId,theColumn,theFloor,thePlatoon)); + } } \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/kpi/service/KpiService.java b/ruoyi-admin/src/main/java/com/ruoyi/kpi/service/KpiService.java index 9386cd6..a2bfbf6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/kpi/service/KpiService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/kpi/service/KpiService.java @@ -33,4 +33,13 @@ public interface KpiService { Map getSpaceAnalysis(String warehouseId); + + Map getRoadways(String warehouseId); + + Map getPlatoons(String warehouseId, String roadwayId); + + + Map getChartData(String warehouseId, String roadwayId, String thePlatoon); + + Map getChartMag(String warehouseId, String theColumn, String theFloor, String thePlatoon); } \ No newline at end of file diff --git a/ruoyi-admin/src/main/java/com/ruoyi/kpi/service/impl/KpiServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/kpi/service/impl/KpiServiceImpl.java index b37d2db..31edc5d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/kpi/service/impl/KpiServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/kpi/service/impl/KpiServiceImpl.java @@ -14,6 +14,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.TreeSet; import com.ruoyi.kpi.service.KpiService; @@ -220,7 +221,7 @@ public class KpiServiceImpl implements KpiService } /** - * 获取巷道均匀分析数据 + * 获取货位分析数据 * * @param warehouseId 仓库ID * @return 货位分析 @@ -232,6 +233,13 @@ public class KpiServiceImpl implements KpiService basCargoSpace.setWarehouseId(warehouseId); List list = basCargoSpaceMapper.selectBasCargoSpaceList(basCargoSpace); + // 如果查询结果为空,返回空数据 + if (list == null || list.isEmpty()) { + Map response = new HashMap<>(); + response.put("data", new ArrayList<>()); + return response; + } + // 按巷道和状态分类统计 Map> roadwayStats = new HashMap<>(); Set roadwayIds = new HashSet<>(); @@ -277,5 +285,170 @@ public class KpiServiceImpl implements KpiService return response; } + @Override + public Map getRoadways(String warehouseId){ + Map response = new HashMap<>(); + + // 查询指定仓库的巷道信息 + BasCargoSpace queryParams = new BasCargoSpace(); + queryParams.setWarehouseId(warehouseId); + List list = basCargoSpaceMapper.selectBasCargoSpaceList(queryParams); + + // 使用Set去重并排序巷道ID + Set roadwaySet = new TreeSet<>(); + for (BasCargoSpace space : list) { + if (space.getRoadwayId() != null) { + roadwaySet.add(space.getRoadwayId()); + } + } + + // 转换为前端下拉框所需的格式 + List> roadways = new ArrayList<>(); + for (String roadwayId : roadwaySet) { + Map roadway = new HashMap<>(); + roadway.put("value", roadwayId); + roadway.put("label", "巷道" + roadwayId); + roadways.add(roadway); + } + + response.put("data", roadways); + return response; + } + + @Override + public Map getPlatoons(String warehouseId, String roadwayId){ + Map response = new HashMap<>(); + + // 查询指定仓库和巷道的排号信息 + BasCargoSpace queryParams = new BasCargoSpace(); + queryParams.setWarehouseId(warehouseId); + queryParams.setRoadwayId(roadwayId); + List list = basCargoSpaceMapper.selectBasCargoSpaceList(queryParams); + + // 使用TreeSet去重并排序排号 + Set platoonSet = new TreeSet<>(); + for (BasCargoSpace space : list) { + if (space.getThePlatoon() != null) { + platoonSet.add(space.getThePlatoon()); + } + } + + // 转换为前端下拉框所需的格式 + List> platoons = new ArrayList<>(); + for (Long platoon : platoonSet) { + Map platoonMap = new HashMap<>(); + platoonMap.put("value", platoon.toString()); + platoonMap.put("label", platoon + "排"); + platoons.add(platoonMap); + } + + response.put("data", platoons); + return response; + } + + @Override + public Map getChartData(String warehouseId, String roadwayId, String thePlatoon) { + // 查询指定仓库、巷道和排号的货位信息 + BasCargoSpace queryParams = new BasCargoSpace(); + queryParams.setWarehouseId(warehouseId); + queryParams.setRoadwayId(roadwayId); + if (thePlatoon != null) { + queryParams.setThePlatoon(Long.parseLong(thePlatoon)); + } + List list = basCargoSpaceMapper.selectBasCargoSpaceList(queryParams); + + // 用于存储不同状态的货位坐标 + String empty = ""; + String full = ""; + String inAllot = ""; + String outAllot = ""; + String inCheck = ""; + String outCheck = ""; + + // 用于存储列和层的集合 + Set columnSet = new TreeSet<>(); + Set floorSet = new TreeSet<>(); + + // 处理每个货位的状态 + for (BasCargoSpace space : list) { + // 收集列和层信息 + columnSet.add(space.getTheColumn()); + floorSet.add(space.getTheFloor()); + + // 根据状态分类处理 + if (space.getStatus() != null) { + String coordinate = "[" + space.getTheColumn() + "," + space.getTheFloor() + "," + space.getStatus() + "],"; + switch (Integer.parseInt(space.getStatus())) { + case 1: empty += coordinate; break; + case 2: full += coordinate; break; + case 3: inAllot += coordinate; break; + case 4: outAllot += coordinate; break; + case 5: inCheck += coordinate; break; + case 6: outCheck += coordinate; break; + } + } + } + + // 构建列和层的标签 + StringBuilder columnLabels = new StringBuilder(); + for (Long col : columnSet) { + columnLabels.append("'").append(col).append("列',"); + } + String column = "[" + columnLabels.toString() + "]"; + + StringBuilder floorLabels = new StringBuilder(); + for (Long floor : floorSet) { + floorLabels.append("'").append(floor).append("层',"); + } + String floor = "[" + floorLabels.toString() + "]"; + + // 返回结果 + Map map = new HashMap<>(); + map.put("empty", "[" + empty + "]"); + map.put("full", "[" + full + "]"); + map.put("inAllot", "[" + inAllot + "]"); + map.put("outAllot", "[" + outAllot + "]"); + map.put("inCheck", "[" + inCheck + "]"); + map.put("outCheck", "[" + outCheck + "]"); + map.put("floor", floor); + map.put("column", column); + return map; + } + + + @Override + public Map getChartMag(String warehouseId,String theColumn,String theFloor,String thePlatoon){ + Map response = new HashMap<>(); + + // 查询指定货位信息 + BasCargoSpace queryParams = new BasCargoSpace(); + queryParams.setWarehouseId(warehouseId); + queryParams.setTheColumn(Long.parseLong(theColumn)); + queryParams.setTheFloor(Long.parseLong(theFloor)); + queryParams.setThePlatoon(Long.parseLong(thePlatoon)); + + List list = basCargoSpaceMapper.selectBasCargoSpaceList(queryParams); + + if (!list.isEmpty()) { + BasCargoSpace space = list.get(0); + StringBuilder info = new StringBuilder(); + + // 拼接货位信息 + info.append("货位名称:").append(space.getCargoSpaceName()).append("
"); + info.append("货位类型:").append(space.getTheTypeName()).append("
"); + info.append("是否锁定:").append("Y".equals(space.getLocked()) ? "是" : "否").append("
"); + info.append("托盘条码:").append(space.getTrayCode() != null ? space.getTrayCode() : "无").append("
"); + info.append("货位高度:").append(space.getCargoHight() != null ? space.getCargoHight() : "无").append("
"); + info.append("是否双伸:").append("Y".equals(space.getIssDouble()) ? "是" : "否").append("
"); + + response.put("msg", info.toString()); + } else { + response.put("msg", "未找到货位信息"); + } + + return response; + } + + } diff --git a/ruoyi-ui/src/api/kpi/spacePlan.js b/ruoyi-ui/src/api/kpi/spacePlan.js new file mode 100644 index 0000000..fbe3330 --- /dev/null +++ b/ruoyi-ui/src/api/kpi/spacePlan.js @@ -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 + }) +} diff --git a/ruoyi-ui/src/views/kpi/spaceAnalysis/index.vue b/ruoyi-ui/src/views/kpi/spaceAnalysis/index.vue index c8087ba..c92c688 100644 --- a/ruoyi-ui/src/views/kpi/spaceAnalysis/index.vue +++ b/ruoyi-ui/src/views/kpi/spaceAnalysis/index.vue @@ -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: { diff --git a/ruoyi-ui/src/views/kpi/spacePlan/index.vue b/ruoyi-ui/src/views/kpi/spacePlan/index.vue new file mode 100644 index 0000000..bb6ff01 --- /dev/null +++ b/ruoyi-ui/src/views/kpi/spacePlan/index.vue @@ -0,0 +1,319 @@ + + + + + +