From fc6c0ae4ddbfdd9df9b821ba74541c7aca909511 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: Thu, 16 Oct 2025 16:41:09 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../index/controller/IndexController.java | 180 +++++++++--------- ruoyi-ui/src/views/index.vue | 76 +++++--- 2 files changed, 142 insertions(+), 114 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/index/controller/IndexController.java b/ruoyi-admin/src/main/java/com/ruoyi/index/controller/IndexController.java index dce04084..c91d104f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/index/controller/IndexController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/index/controller/IndexController.java @@ -4,6 +4,11 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; + +import com.ruoyi.device.ddj.domain.MsgDdj; +import com.ruoyi.device.ddj.service.IMsgDdjService; +import com.ruoyi.job.domain.MydoJob; +import com.ruoyi.job.service.IMydoJobService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -27,8 +32,7 @@ import com.ruoyi.device.ssj.domain.DeviceSsj; */ @RestController @RequestMapping("/index") -public class IndexController extends BaseController -{ +public class IndexController extends BaseController { @Autowired private IDeviceCarService deviceCarService; @@ -41,38 +45,33 @@ public class IndexController extends BaseController @Autowired private IDeviceSsjService deviceSsjService; + @Autowired + private IMsgDdjService msgDdjService; + + @Autowired + private IMydoJobService mydoJobService; + + /** * 获取设备统计数据 */ @GetMapping("/deviceStats") - public AjaxResult getDeviceStats() - { + public AjaxResult getDeviceStats() { try { DeviceCar deviceCar = new DeviceCar(); + MsgDdj msgDdj = new MsgDdj(); + DeviceSsj deviceSsj = new DeviceSsj(); List deviceList = deviceCarService.selectDeviceCarList(deviceCar); + List msgDdjList = msgDdjService.selectMsgDdjList(msgDdj); + List deviceSsjList = deviceSsjService.selectDeviceSsjList(deviceSsj); - Map stats = new HashMap<>(); - int agvCount = 0; - int ctuCount = 0; - int ssjCount = 0; + Map count = new HashMap<>(); - for (DeviceCar device : deviceList) { - String type = device.getType(); - if ("1".equals(type)) { - agvCount++; - } else if ("2".equals(type)) { - ctuCount++; - } else if ("3".equals(type)) { - ssjCount++; - } - } + count.put("agvCount", deviceList.size()); + count.put("ddjCount", msgDdjList.size()); + count.put("ssjCount", deviceSsjList.size()); - stats.put("agvCount", agvCount); - stats.put("ctuCount", ctuCount); - stats.put("ssjCount", ssjCount); - stats.put("totalCount", deviceList.size()); - - return AjaxResult.success(stats); + return AjaxResult.success(count); } catch (Exception e) { return AjaxResult.error("获取设备统计数据失败"); } @@ -82,34 +81,39 @@ public class IndexController extends BaseController * 获取任务统计数据 */ @GetMapping("/taskStats") - public AjaxResult getTaskStats() - { + public AjaxResult getTaskStats() { try { + MydoJob mydoJob = new MydoJob(); AgvQueue agvQueue = new AgvQueue(); List queueList = agvQueueService.selectAgvQueueList(agvQueue); + List mydoJobList = mydoJobService.selectMydoJobList(mydoJob); + List mydoJobFinishList = mydoJobService.selectMydoJobFinishList(mydoJob); int pendingCount = 0; int runningCount = 0; + int finishedCount = 0; - for (AgvQueue queue : queueList) { - String status = queue.getStatus(); - if ("0".equals(status)||"1".equals(status)) { + for (MydoJob job : mydoJobList) { + String status = job.getStatus(); + if ("2".equals(status)) { pendingCount++; - } else if ("2".equals(status)||"3".equals(status)) { + } else if ("3".equals(status)) { runningCount++; } } - // 获取今日完成任务数 - AgvQueueFinish finishQuery = new AgvQueueFinish(); - List finishList = agvQueueFinishService.selectAgvQueueFinishList(finishQuery); - int finishedCount = finishList.size(); + for (MydoJob Fjob : mydoJobFinishList) { + String status = Fjob.getStatus(); + if ("4".equals(status)) { + finishedCount++; + } + } + Map stats = new HashMap<>(); stats.put("pendingCount", pendingCount); stats.put("runningCount", runningCount); stats.put("finishedCount", finishedCount); - stats.put("totalCount", pendingCount + runningCount + finishedCount); return AjaxResult.success(stats); } catch (Exception e) { @@ -121,13 +125,12 @@ public class IndexController extends BaseController * 获取当前任务队列 */ @GetMapping("/currentTasks") - public AjaxResult getCurrentTasks() - { + public AjaxResult getCurrentTasks() { try { - AgvQueue agvQueue = new AgvQueue(); - List taskList = agvQueueService.selectAgvQueueList(agvQueue); - - return AjaxResult.success(taskList); + MydoJob mydoJobParam = new MydoJob(); + mydoJobParam.setStatus("3"); + List mydoJobList = mydoJobService.selectMydoJobList(mydoJobParam); + return AjaxResult.success(mydoJobList); } catch (Exception e) { return AjaxResult.error("获取当前任务队列失败"); } @@ -137,8 +140,7 @@ public class IndexController extends BaseController * 获取运行中的设备列表 */ @GetMapping("/deviceList") - public AjaxResult getDeviceList() - { + public AjaxResult getDeviceList() { try { List> runningDevices = new ArrayList<>(); @@ -153,7 +155,7 @@ public class IndexController extends BaseController Map deviceInfo = new HashMap<>(); deviceInfo.put("deviceCode", device.getDeviceCode()); deviceInfo.put("deviceName", device.getName()); - deviceInfo.put("deviceType", "1".equals(device.getType()) ? "AGV" : "CTU"); + deviceInfo.put("deviceType", "AGV"); deviceInfo.put("taskNo", device.getTaskNo()); runningDevices.add(deviceInfo); } @@ -176,6 +178,21 @@ public class IndexController extends BaseController } } + MsgDdj msgDdj = new MsgDdj(); + List msgDdjList = msgDdjService.selectMsgDdjList(msgDdj); + + for (MsgDdj ddj : msgDdjList){ + Long taskNo = ddj.getRwh(); + if (taskNo != 0){ + HashMap deviceInfo = new HashMap<>(); + deviceInfo.put("deviceCode",ddj.getId()); + deviceInfo.put("deviceName", ddj.getName()); + deviceInfo.put("deviceType", "DDJ"); + deviceInfo.put("taskNo", ddj.getRwh()); + runningDevices.add(deviceInfo); + } + } + return AjaxResult.success(runningDevices); } catch (Exception e) { return AjaxResult.error("获取运行中设备列表失败"); @@ -186,37 +203,28 @@ public class IndexController extends BaseController * 获取任务类型分布数据 */ @GetMapping("/taskTypeChart") - public AjaxResult getTaskTypeChart() - { + public AjaxResult getTaskTypeChart() { try { - AgvQueue agvQueue = new AgvQueue(); - List queueList = agvQueueService.selectAgvQueueList(agvQueue); + MydoJob mydoJob = new MydoJob(); + List mydoJobFinishList = mydoJobService.selectMydoJobFinishList(mydoJob); - AgvQueueFinish finishQuery = new AgvQueueFinish(); - List finishList = agvQueueFinishService.selectAgvQueueFinishList(finishQuery); + Map inOrOutCount = new HashMap<>(); - Map taskTypeCount = new HashMap<>(); - - // 统计队列中的任务类型 - for (AgvQueue queue : queueList) { - String wmsTaskType = queue.getWmsTaskType(); - if (wmsTaskType != null && !wmsTaskType.isEmpty()) { - taskTypeCount.put(wmsTaskType, taskTypeCount.getOrDefault(wmsTaskType, 0) + 1); - } - } - - // 统计完成任务的类型 - for (AgvQueueFinish finish : finishList) { - String wmsTaskType = finish.getWmsTaskType(); - if (wmsTaskType != null && !wmsTaskType.isEmpty()) { - taskTypeCount.put(wmsTaskType, taskTypeCount.getOrDefault(wmsTaskType, 0) + 1); + // 统计完成任务的 inOrOut 类型 + for (MydoJob job : mydoJobFinishList) { + String inOrOut = job.getInOrOut(); + if (inOrOut != null && !inOrOut.isEmpty()) { + inOrOutCount.put(inOrOut, inOrOutCount.getOrDefault(inOrOut, 0) + 1); } } List> chartData = new ArrayList<>(); - for (Map.Entry entry : taskTypeCount.entrySet()) { + for (Map.Entry entry : inOrOutCount.entrySet()) { Map item = new HashMap<>(); - item.put("name", entry.getKey()); + // 使用字典工具类获取字典标签 + String dictLabel = com.ruoyi.common.utils.DictUtils.getDictLabel("in_or_out", entry.getKey()); + // 如果没有找到对应的字典标签,则使用原始值 + item.put("name", dictLabel != null && !dictLabel.isEmpty() ? dictLabel : entry.getKey()); item.put("value", entry.getValue()); chartData.add(item); } @@ -231,39 +239,27 @@ public class IndexController extends BaseController * 获取设备状态分布数据 */ @GetMapping("/deviceStatusChart") - public AjaxResult getDeviceStatusChart() - { + public AjaxResult getDeviceStatusChart() { try { Map> statusCount = new HashMap<>(); statusCount.put("AGV", new HashMap<>()); - statusCount.put("CTU", new HashMap<>()); + statusCount.put("DDJ", new HashMap<>()); statusCount.put("SSJ", new HashMap<>()); - // 查询DeviceCar数据(AGV和CTU) + // 查询DeviceCar数据(AGV) DeviceCar deviceCar = new DeviceCar(); List deviceList = deviceCarService.selectDeviceCarList(deviceCar); for (DeviceCar device : deviceList) { - String type = device.getType(); String taskNo = device.getTaskNo(); - String deviceType = ""; String status = "其他"; - - if ("1".equals(type)) { - deviceType = "AGV"; - } else if ("2".equals(type)) { - deviceType = "CTU"; - } - // 根据taskNo判断状态:不等于空或0时为运行状态 if (taskNo != null && !taskNo.trim().isEmpty() && !"0".equals(taskNo.trim())) { status = "运行"; } + Map typeStatusCount = statusCount.get("AGV"); + typeStatusCount.put(status, typeStatusCount.getOrDefault(status, 0) + 1); - if (!deviceType.isEmpty()) { - Map typeStatusCount = statusCount.get(deviceType); - typeStatusCount.put(status, typeStatusCount.getOrDefault(status, 0) + 1); - } } // 查询DeviceSsj数据(SSJ) @@ -283,6 +279,19 @@ public class IndexController extends BaseController typeStatusCount.put(status, typeStatusCount.getOrDefault(status, 0) + 1); } + MsgDdj msgDdj = new MsgDdj(); + List msgDdjList = msgDdjService.selectMsgDdjList(msgDdj); + + for (MsgDdj ddj : msgDdjList){ + Long taskNo = ddj.getRwh(); + String status = "其他"; + if (taskNo!=0){ + status = "运行"; + } + Map typeStatusCount = statusCount.get("DDJ"); + typeStatusCount.put(status,typeStatusCount.getOrDefault(status,0) + 1); + } + return AjaxResult.success(statusCount); } catch (Exception e) { return AjaxResult.error("获取设备状态分布数据失败"); @@ -293,8 +302,7 @@ public class IndexController extends BaseController * 获取首页综合数据 */ @GetMapping("/dashboard") - public AjaxResult getDashboardData() - { + public AjaxResult getDashboardData() { try { Map dashboardData = new HashMap<>(); diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue index 87af920f..7d934a76 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -2,7 +2,7 @@
- +
@@ -10,25 +10,38 @@
{{ deviceStats.agvCount }}
-
{{ $t('index.agvDeviceTotal') }}
+
AGV设备总数
- + + +
+
+ +
+
+
{{ deviceStats.ddjCount }}
+
堆垛机设备总数
+
+
+
+
+
-
{{ deviceStats.ctuCount }}
-
{{ $t('index.ctuDeviceTotal') }}
+
{{ deviceStats.ssjCount }}
+
输送机设备总数
- +
@@ -36,12 +49,12 @@
{{ taskStats.pendingCount }}
-
{{ $t('index.pendingTasks') }}
+
待执行任务
- +
@@ -49,7 +62,7 @@
{{ taskStats.runningCount }}
-
{{ $t('index.runningTasks') }}
+
执行中任务
@@ -62,7 +75,7 @@
{{ taskStats.finishedCount }}
-
{{ $t('index.completedTasks') }}
+
已完成任务
@@ -74,7 +87,7 @@
- {{ $t('index.taskTypeDistribution') }} + 任务类型分布
@@ -82,7 +95,7 @@
- {{ $t('index.deviceStatusDistribution') }} + 设备状态分布
@@ -94,31 +107,34 @@
- {{ $t('index.currentTaskQueue') }} - {{ $t('index.refresh') }} + 正执行作业列表 + 刷新
- - + - - - - + + + + + + - +
@@ -154,7 +170,7 @@ import { getDeviceStats, getTaskStats, getCurrentTasks, getDeviceList, getTaskTy export default { name: 'Index', - dicts: ['task_status', 'wms_task_type'], + dicts: ['task_status', 'wms_task_type','job_ep','in_or_out'], data() { return { // 统计数据 @@ -409,9 +425,9 @@ export default { idleData[0] = statusData.AGV['其他'] || 0 // 其他 } // CTU数据 - if (statusData.CTU) { - runningData[1] = statusData.CTU['运行'] || 0 // 运行 - idleData[1] = statusData.CTU['其他'] || 0 // 其他 + if (statusData.DDJ) { + runningData[1] = statusData.DDJ['运行'] || 0 // 运行 + idleData[1] = statusData.DDJ['其他'] || 0 // 其他 } // SSJ数据 if (statusData.SSJ) { @@ -436,7 +452,7 @@ export default { }, xAxis: { type: 'category', - data: ['AGV', 'CTU', 'SSJ'] + data: ['AGV', 'DDJ', 'SSJ'] }, yAxis: { type: 'value' @@ -472,7 +488,7 @@ export default { }, xAxis: { type: 'category', - data: ['AGV', 'CTU', 'SSJ'] + data: ['AGV', 'DDJ', 'SSJ'] }, yAxis: { type: 'value' @@ -599,6 +615,10 @@ export default { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); } +.ddj-icon { + background: linear-gradient(135deg, #dcb536 0%, #e5845b 100%); +} + .ctu-icon { background: linear-gradient(135deg, #36d1dc 0%, #5b86e5 100%); }