From b96e9ab76e8e7032fe9ddc98a0692c182b298152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B1=9F=E7=8E=AE?= Date: Fri, 18 Aug 2023 18:14:30 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E4=BB=93=E5=82=A8=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/rest/DashboardController.java | 7 + .../dashboard/service/DashboardService.java | 130 +++++++++++++++++- 2 files changed, 136 insertions(+), 1 deletion(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/rest/DashboardController.java b/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/rest/DashboardController.java index 9f89236..5110ccb 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/rest/DashboardController.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/rest/DashboardController.java @@ -44,4 +44,11 @@ public class DashboardController { public ResponseEntity productionStatistics(){ return new ResponseEntity<>(dashboardService.productionStatistics(), HttpStatus.OK); } + + @PostMapping("/warehouseMonitor") + @Log("仓储监控") + @ApiOperation("仓储监控") + public ResponseEntity warehouseMonitor(){ + return new ResponseEntity<>(dashboardService.warehouseMonitor(), HttpStatus.OK); + } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/service/DashboardService.java b/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/service/DashboardService.java index 561a9e5..cfacd9b 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/service/DashboardService.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/dashboard/service/DashboardService.java @@ -7,6 +7,8 @@ import lombok.RequiredArgsConstructor; import org.nl.wms.sch.manage.WorkOrderEnum; import org.springframework.stereotype.Service; +import java.util.stream.Collectors; + /** * @author zhangjiangwei */ @@ -420,7 +422,7 @@ public class DashboardService { */ public JSONObject productionStatistics() { JSONObject result = new JSONObject(); - + // 总量---------------------------------------------------------------------------------------------------------- JSONObject total = new JSONObject(); result.put("total", total); @@ -504,6 +506,132 @@ public class DashboardService { return result; } + /** + * 仓储监控 + * + * @return 仓储监控数据 + */ + public JSONObject warehouseMonitor() { + JSONObject result = new JSONObject(); + + // 困料监控------------------------------------------------------------------------------------------------------ + JSONArray standMonitor = new JSONArray(); + result.put("standMonitor", standMonitor); + // todo 现在是假数据,后期更新。 + for (int i = 1; i <= 41; i++) { + JSONObject row = new JSONObject(); + row.put("storageLocation", i + "号位"); + String pointStatus = this.randomFrom1To(3); + row.put("pointStatus", pointStatus); + if (!"1".equals(pointStatus)) { + row.put("vehicleCode", String.format("%04d", Integer.parseInt(this.randomFrom1To(9999)))); + if (!"2".equals(pointStatus)) { + row.put("materialCode", "WL" + String.format("%02d", i)); + row.put("materialName", "物料" + i); + row.put("weight", this.randomFrom1To(2000)); + row.put("warehousingTime", DateUtil.format(DateUtil.offsetHour(DateUtil.date(), -1), "yyyy-MM-dd HH:mm:ss")); + row.put("standTime", "1"); + row.put("standStatus", this.randomFrom1To(5)); + } + } + standMonitor.add(row); + } + + // 成型暂存监控--------------------------------------------------------------------------------------------------- + JSONArray frontWarehouseMonitor = new JSONArray(); + result.put("frontWarehouseMonitor", frontWarehouseMonitor); + // todo 现在是假数据,后期更新。 + for (int i = 1; i <= 28; i += 2) { + JSONObject row = new JSONObject(); + row.put("storageLocation", "窑前货位" + i); + String pointStatus = this.randomFrom1To(3); + row.put("pointStatus", pointStatus); + if (!"1".equals(pointStatus)) { + row.put("vehicleCode", String.format("%04d", Integer.parseInt(this.randomFrom1To(9999)))); + if (!"2".equals(pointStatus)) { + row.put("materialCode", "WL" + String.format("%02d", i)); + row.put("materialName", "物料" + i); + row.put("qty", this.randomFrom1To(200)); + row.put("warehousingTime", DateUtil.format(DateUtil.offsetHour(DateUtil.date(), -1), "yyyy-MM-dd HH:mm:ss")); + } + } + frontWarehouseMonitor.add(row); + } + for (int i = 2; i <= 28; i += 2) { + JSONObject row = new JSONObject(); + row.put("storageLocation", "窑前货位" + i); + String pointStatus = this.randomFrom1To(3); + row.put("pointStatus", pointStatus); + if (!"1".equals(pointStatus)) { + row.put("vehicleCode", String.format("%04d", Integer.parseInt(this.randomFrom1To(9999)))); + if (!"2".equals(pointStatus)) { + row.put("materialCode", "WL" + String.format("%02d", i)); + row.put("materialName", "物料" + i); + row.put("qty", this.randomFrom1To(200)); + row.put("warehousingTime", DateUtil.format(DateUtil.offsetHour(DateUtil.date(), -1), "yyyy-MM-dd HH:mm:ss")); + } + } + frontWarehouseMonitor.add(row); + } + + // 半成品暂存监控------------------------------------------------------------------------------------------------- + JSONArray backWarehouseMonitor = new JSONArray(); + result.put("backWarehouseMonitor", backWarehouseMonitor); + // todo 现在是假数据,后期更新。 + for (int i = 1; i <= 26; i += 2) { + JSONObject row = new JSONObject(); + row.put("storageLocation", "窑后货位" + i); + String pointStatus = this.randomFrom1To(3); + row.put("pointStatus", pointStatus); + if (!"1".equals(pointStatus)) { + row.put("vehicleCode", String.format("%04d", Integer.parseInt(this.randomFrom1To(9999)))); + if (!"2".equals(pointStatus)) { + row.put("materialCode", "WL" + String.format("%02d", i)); + row.put("materialName", "物料" + i); + row.put("qty", this.randomFrom1To(200)); + row.put("warehousingTime", DateUtil.format(DateUtil.offsetHour(DateUtil.date(), -1), "yyyy-MM-dd HH:mm:ss")); + } + } + backWarehouseMonitor.add(row); + } + for (int i = 2; i <= 26; i += 2) { + JSONObject row = new JSONObject(); + row.put("storageLocation", "窑后货位" + i); + String pointStatus = this.randomFrom1To(3); + row.put("pointStatus", pointStatus); + if (!"1".equals(pointStatus)) { + row.put("vehicleCode", String.format("%04d", Integer.parseInt(this.randomFrom1To(9999)))); + if (!"2".equals(pointStatus)) { + row.put("materialCode", "WL" + String.format("%02d", i)); + row.put("materialName", "物料" + i); + row.put("qty", this.randomFrom1To(200)); + row.put("warehousingTime", DateUtil.format(DateUtil.offsetHour(DateUtil.date(), -1), "yyyy-MM-dd HH:mm:ss")); + } + } + backWarehouseMonitor.add(row); + } + + // 困料库存------------------------------------------------------------------------------------------------------ + JSONArray standStock = new JSONArray(standMonitor.stream() + .filter(o -> "3".equals(((JSONObject) o).getString("pointStatus"))) + .collect(Collectors.toList())); + result.put("standStock", standStock); + + // 成型库存------------------------------------------------------------------------------------------------------ + JSONArray frontWarehouseStock = new JSONArray(frontWarehouseMonitor.stream() + .filter(o -> "3".equals(((JSONObject) o).getString("pointStatus"))) + .collect(Collectors.toList())); + result.put("frontWarehouseStock", frontWarehouseStock); + + // 半成品库存----------------------------------------------------------------------------------------------------- + JSONArray backWarehouseStock = new JSONArray(backWarehouseMonitor.stream() + .filter(o -> "3".equals(((JSONObject) o).getString("pointStatus"))) + .collect(Collectors.toList())); + result.put("backWarehouseStock", backWarehouseStock); + + return result; + } + private String randomFrom1To(int to) { return String.valueOf(1 + (int) (Math.random() * to)); }