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 ac87f8c..2b362b0 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 @@ -120,15 +120,13 @@ public class KpiController extends BaseController { * 获取库存平面图 * * @param warehouseId 仓库ID - * @param roadwayId 巷道ID - * @param thePlatoon 排 + * @param theFloor 层 * @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)); + @RequestParam("theFloor") String theFloor){ + return success(kpiService.getChartData(warehouseId,theFloor)); } /** @@ -147,5 +145,15 @@ public class KpiController extends BaseController { @RequestParam("thePlatoon") String thePlatoon){ return success(kpiService.getChartMag(warehouseId,theColumn,theFloor,thePlatoon)); } + /** + * 获取货位楼层数据 + * + * @param warehouseId 仓库ID + * @return 货位楼层数据 + */ + @GetMapping("/getFloors") + public AjaxResult getFloors(@RequestParam("warehouseId") String warehouseId){ + return success(kpiService.getFloors(warehouseId)); + } } 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 5d624fc..cb3d709 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 @@ -42,10 +42,12 @@ public interface KpiService { Map getPlatoons(String warehouseId, String roadwayId); - Map getChartData(String warehouseId, String roadwayId, String thePlatoon); + Map getChartData(String warehouseId, String theFloor); Map getChartMag(String warehouseId, String theColumn, String theFloor, String thePlatoon); AjaxResult getInAnalysisByData(String warehouseId, String startTime, String endTime,String inOut); + + Map getFloors(String warehouseId); } 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 02ed570..fcf1a6e 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 @@ -317,6 +317,35 @@ public class KpiServiceImpl implements KpiService } + @Override + public Map getFloors(String warehouseId) { + Map response = new HashMap<>(); + + // 查询指定仓库和巷道的排号信息 + BasCargoSpace queryParams = new BasCargoSpace(); + queryParams.setWarehouseId(warehouseId); + List list = basCargoSpaceMapper.selectBasCargoSpaceList(queryParams); + + // 使用TreeSet去重并排序排号 + Set platoonSet = new TreeSet<>(); + for (BasCargoSpace space : list) { + if (space.getTheFloor() != null) { + platoonSet.add(space.getTheFloor()); + } + } + + // 转换为前端下拉框所需的格式 + 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 getRoadways(String warehouseId){ @@ -380,14 +409,11 @@ public class KpiServiceImpl implements KpiService } @Override - public Map getChartData(String warehouseId, String roadwayId, String thePlatoon) { + public Map getChartData(String warehouseId, String theFloor) { // 查询指定仓库、巷道和排号的货位信息 BasCargoSpace queryParams = new BasCargoSpace(); queryParams.setWarehouseId(warehouseId); - queryParams.setRoadwayId(roadwayId); - if (thePlatoon != null) { - queryParams.setThePlatoon(Long.parseLong(thePlatoon)); - } + queryParams.setTheFloor(Long.valueOf(theFloor)); List list = basCargoSpaceMapper.selectBasCargoSpaceList(queryParams); // 用于存储不同状态的货位坐标 @@ -406,11 +432,11 @@ public class KpiServiceImpl implements KpiService for (BasCargoSpace space : list) { // 收集列和层信息 columnSet.add(space.getTheColumn()); - floorSet.add(space.getTheFloor()); + floorSet.add(space.getThePlatoon()); // 根据状态分类处理 if (space.getStatus() != null) { - String coordinate = "[" + space.getTheColumn() + "," + space.getTheFloor() + "," + space.getStatus() + "],"; + String coordinate = "[" + space.getTheColumn() + "," + space.getThePlatoon() + "," + space.getStatus() + "],"; switch (Integer.parseInt(space.getStatus())) { case 1: empty += coordinate; break; case 2: full += coordinate; break; @@ -425,15 +451,15 @@ public class KpiServiceImpl implements KpiService // 构建列和层的标签 StringBuilder columnLabels = new StringBuilder(); for (Long col : columnSet) { - columnLabels.append("'").append(col).append(MessageUtils.message("kpi.spacePlan.column")).append("',"); + columnLabels.append("'").append(col).append("列").append("',"); } - String column = "[" + columnLabels.toString() + "]"; + String column = "[" + columnLabels + "]"; StringBuilder floorLabels = new StringBuilder(); for (Long floor : floorSet) { - floorLabels.append("'").append(floor).append(MessageUtils.message("kpi.spacePlan.floor")).append("',"); + floorLabels.append("'").append(floor).append("排").append("',"); } - String floor = "[" + floorLabels.toString() + "]"; + String floor = "[" + floorLabels + "]"; // 返回结果 Map map = new HashMap<>(); @@ -498,43 +524,86 @@ public class KpiServiceImpl implements KpiService mydoJobParam.setCreateLeftTime(startTime); mydoJobParam.setCreateRightTime(endTime); mydoJobParam.setInOut(inOut); - List datesBetween = DateUtil.rangeToList(DateUtil.parseDate(startTime), DateUtil.parseDate(endTime), DateField.DAY_OF_MONTH); List list = mydoJobFinishMapper.selectMydoJobFinishListByMydoJob(mydoJobParam); - - // 获取所有巷道ID(1和2) - List roadwayIds = Arrays.asList("1", "2"); - + + // 收集所有涉及的楼层 + Set floorSet = new HashSet<>(); + Map cargoSpaceCache = new HashMap<>(); + + // 遍历作业记录,收集涉及的货位ID并查询对应楼层 + for (MydoJob job : list) { + if (job.getCargoSpaceId() != null) { + // 检查缓存中是否有该货位信息 + if (!cargoSpaceCache.containsKey(job.getCargoSpaceId())) { + // 使用现有的查询方法查询货位信息 + BasCargoSpace queryParam = new BasCargoSpace(); + queryParam.setCargoSpaceId(job.getCargoSpaceId()); + List cargoSpaces = basCargoSpaceMapper.selectBasCargoSpaceList(queryParam); + + if (!cargoSpaces.isEmpty()) { + BasCargoSpace cargoSpace = cargoSpaces.get(0); + cargoSpaceCache.put(job.getCargoSpaceId(), cargoSpace); + if (cargoSpace.getTheFloor() != null) { + floorSet.add(cargoSpace.getTheFloor()); + } + } + } else { + BasCargoSpace cachedSpace = cargoSpaceCache.get(job.getCargoSpaceId()); + if (cachedSpace.getTheFloor() != null) { + floorSet.add(cachedSpace.getTheFloor()); + } + } + } + } + + // 将楼层排序 + List floors = new ArrayList<>(floorSet); + Collections.sort(floors); + + // 生成日期范围 + List datesBetween = DateUtil.rangeToList(DateUtil.parseDate(startTime), DateUtil.parseDate(endTime), DateField.DAY_OF_MONTH); + List xAxis = new ArrayList<>(); List> series = new ArrayList<>(); - - // 为每个巷道创建一个系列 - for (String roadwayId : roadwayIds) { + + // 为每个楼层创建一个系列 + for (Long floor : floors) { Map seriesItem = new HashMap<>(); - seriesItem.put("name", roadwayId + "号巷道"); + seriesItem.put("name", floor + "层"); seriesItem.put("type", "line"); List data = new ArrayList<>(); seriesItem.put("data", data); series.add(seriesItem); } - - // 按日期统计每个巷道的数量 + + // 按日期统计每个楼层的数量 for (DateTime dateTime : datesBetween) { xAxis.add(DateUtil.format(dateTime, "yyyy-MM-dd")); - - // 统计每个巷道在当天的数量 - for (int i = 0; i < roadwayIds.size(); i++) { - String roadwayId = roadwayIds.get(i); - long count = list.stream() - .filter(mydoJob -> roadwayId.equals(mydoJob.getRoadwayId()) - && DateUtil.isIn(mydoJob.getCreateTime(), DateUtil.beginOfDay(dateTime), DateUtil.endOfDay(dateTime))) - .count(); - + + // 统计每个楼层在当天的数量 + for (int i = 0; i < floors.size(); i++) { + Long floor = floors.get(i); + long count = 0; + + // 遍历作业记录,统计该楼层在当天的作业数量 + for (MydoJob job : list) { + if (DateUtil.isIn(job.getCreateTime(), DateUtil.beginOfDay(dateTime), DateUtil.endOfDay(dateTime))) { + // 查找该作业对应的货位是否属于当前楼层 + if (job.getCargoSpaceId() != null && cargoSpaceCache.containsKey(job.getCargoSpaceId())) { + BasCargoSpace space = cargoSpaceCache.get(job.getCargoSpaceId()); + if (space.getTheFloor() != null && space.getTheFloor().equals(floor)) { + count++; + } + } + } + } + @SuppressWarnings("unchecked") List data = (List) series.get(i).get("data"); data.add(count); } } - + res.put("xAxis", xAxis); res.put("series", series); return AjaxResult.success(res); diff --git a/ruoyi-ui/src/api/kpi/spacePlan.js b/ruoyi-ui/src/api/kpi/spacePlan.js index fbe3330..88417ee 100644 --- a/ruoyi-ui/src/api/kpi/spacePlan.js +++ b/ruoyi-ui/src/api/kpi/spacePlan.js @@ -9,6 +9,13 @@ export function getRoadways(query) { params: query }) } +export function getFloors(query) { + return request({ + url: '/kpi/getFloors', + method: 'get', + params: query + }) +} //获取排列表 export function getPlatoons(query) { return request({ diff --git a/ruoyi-ui/src/views/kpi/inAnalysis/indexByTime.vue b/ruoyi-ui/src/views/kpi/inAnalysis/indexByTime.vue index a20255a..b9863b8 100644 --- a/ruoyi-ui/src/views/kpi/inAnalysis/indexByTime.vue +++ b/ruoyi-ui/src/views/kpi/inAnalysis/indexByTime.vue @@ -1,20 +1,21 @@