堆垛机调度初始化
This commit is contained in:
@@ -8,22 +8,20 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.device.DeviceCar.service.IDeviceCarService;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueFinishService;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueFinishService;
|
||||
import com.ruoyi.device.ssj.service.IDeviceSsjService;
|
||||
import com.ruoyi.device.DeviceCar.domain.DeviceCar;
|
||||
import com.ruoyi.device.agv.domain.AgvQueue;
|
||||
import com.ruoyi.device.agv.domain.AgvQueueFinish;
|
||||
import com.ruoyi.queue.agv.domain.AgvQueue;
|
||||
import com.ruoyi.queue.agv.domain.AgvQueueFinish;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
|
||||
/**
|
||||
* 首页数据Controller
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-01-08
|
||||
*/
|
||||
@@ -33,13 +31,13 @@ public class IndexController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IDeviceCarService deviceCarService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private IAgvQueueFinishService agvQueueFinishService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
|
||||
@@ -52,12 +50,12 @@ public class IndexController extends BaseController
|
||||
try {
|
||||
DeviceCar deviceCar = new DeviceCar();
|
||||
List<DeviceCar> deviceList = deviceCarService.selectDeviceCarList(deviceCar);
|
||||
|
||||
|
||||
Map<String, Object> stats = new HashMap<>();
|
||||
int agvCount = 0;
|
||||
int ctuCount = 0;
|
||||
int ssjCount = 0;
|
||||
|
||||
|
||||
for (DeviceCar device : deviceList) {
|
||||
String type = device.getType();
|
||||
if ("1".equals(type)) {
|
||||
@@ -68,12 +66,12 @@ public class IndexController extends BaseController
|
||||
ssjCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stats.put("agvCount", agvCount);
|
||||
stats.put("ctuCount", ctuCount);
|
||||
stats.put("ssjCount", ssjCount);
|
||||
stats.put("totalCount", deviceList.size());
|
||||
|
||||
|
||||
return AjaxResult.success(stats);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("获取设备统计数据失败");
|
||||
@@ -89,10 +87,10 @@ public class IndexController extends BaseController
|
||||
try {
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
List<AgvQueue> queueList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
|
||||
|
||||
int pendingCount = 0;
|
||||
int runningCount = 0;
|
||||
|
||||
|
||||
for (AgvQueue queue : queueList) {
|
||||
String status = queue.getStatus();
|
||||
if ("0".equals(status)||"1".equals(status)) {
|
||||
@@ -101,18 +99,18 @@ public class IndexController extends BaseController
|
||||
runningCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 获取今日完成任务数
|
||||
AgvQueueFinish finishQuery = new AgvQueueFinish();
|
||||
List<AgvQueueFinish> finishList = agvQueueFinishService.selectAgvQueueFinishList(finishQuery);
|
||||
int finishedCount = finishList.size();
|
||||
|
||||
|
||||
Map<String, Object> 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) {
|
||||
return AjaxResult.error("获取任务统计数据失败");
|
||||
@@ -128,7 +126,7 @@ public class IndexController extends BaseController
|
||||
try {
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
List<AgvQueue> taskList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
|
||||
|
||||
return AjaxResult.success(taskList);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("获取当前任务队列失败");
|
||||
@@ -143,11 +141,11 @@ public class IndexController extends BaseController
|
||||
{
|
||||
try {
|
||||
List<Map<String, Object>> runningDevices = new ArrayList<>();
|
||||
|
||||
|
||||
// 查询运行中的AGV和CTU设备
|
||||
DeviceCar deviceCar = new DeviceCar();
|
||||
List<DeviceCar> deviceList = deviceCarService.selectDeviceCarList(deviceCar);
|
||||
|
||||
|
||||
for (DeviceCar device : deviceList) {
|
||||
String taskNo = device.getTaskNo();
|
||||
// 判断是否为运行中设备:taskNo不为空且不为0
|
||||
@@ -160,11 +158,11 @@ public class IndexController extends BaseController
|
||||
runningDevices.add(deviceInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 查询运行中的SSJ设备
|
||||
DeviceSsj deviceSsj = new DeviceSsj();
|
||||
List<DeviceSsj> ssjList = deviceSsjService.selectDeviceSsjList(deviceSsj);
|
||||
|
||||
|
||||
for (DeviceSsj ssj : ssjList) {
|
||||
int taskNo = ssj.getTaskNo();
|
||||
// 判断是否为运行中设备:taskNo不为0
|
||||
@@ -177,7 +175,7 @@ public class IndexController extends BaseController
|
||||
runningDevices.add(deviceInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return AjaxResult.success(runningDevices);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("获取运行中设备列表失败");
|
||||
@@ -193,12 +191,12 @@ public class IndexController extends BaseController
|
||||
try {
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
List<AgvQueue> queueList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
|
||||
|
||||
AgvQueueFinish finishQuery = new AgvQueueFinish();
|
||||
List<AgvQueueFinish> finishList = agvQueueFinishService.selectAgvQueueFinishList(finishQuery);
|
||||
|
||||
|
||||
Map<String, Integer> taskTypeCount = new HashMap<>();
|
||||
|
||||
|
||||
// 统计队列中的任务类型
|
||||
for (AgvQueue queue : queueList) {
|
||||
String wmsTaskType = queue.getWmsTaskType();
|
||||
@@ -206,7 +204,7 @@ public class IndexController extends BaseController
|
||||
taskTypeCount.put(wmsTaskType, taskTypeCount.getOrDefault(wmsTaskType, 0) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 统计完成任务的类型
|
||||
for (AgvQueueFinish finish : finishList) {
|
||||
String wmsTaskType = finish.getWmsTaskType();
|
||||
@@ -214,7 +212,7 @@ public class IndexController extends BaseController
|
||||
taskTypeCount.put(wmsTaskType, taskTypeCount.getOrDefault(wmsTaskType, 0) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<Map<String, Object>> chartData = new ArrayList<>();
|
||||
for (Map.Entry<String, Integer> entry : taskTypeCount.entrySet()) {
|
||||
Map<String, Object> item = new HashMap<>();
|
||||
@@ -222,7 +220,7 @@ public class IndexController extends BaseController
|
||||
item.put("value", entry.getValue());
|
||||
chartData.add(item);
|
||||
}
|
||||
|
||||
|
||||
return AjaxResult.success(chartData);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("获取任务类型分布数据失败");
|
||||
@@ -240,51 +238,51 @@ public class IndexController extends BaseController
|
||||
statusCount.put("AGV", new HashMap<>());
|
||||
statusCount.put("CTU", new HashMap<>());
|
||||
statusCount.put("SSJ", new HashMap<>());
|
||||
|
||||
|
||||
// 查询DeviceCar数据(AGV和CTU)
|
||||
DeviceCar deviceCar = new DeviceCar();
|
||||
List<DeviceCar> 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 = "运行";
|
||||
}
|
||||
|
||||
|
||||
if (!deviceType.isEmpty()) {
|
||||
Map<String, Integer> typeStatusCount = statusCount.get(deviceType);
|
||||
typeStatusCount.put(status, typeStatusCount.getOrDefault(status, 0) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 查询DeviceSsj数据(SSJ)
|
||||
DeviceSsj deviceSsj = new DeviceSsj();
|
||||
List<DeviceSsj> ssjList = deviceSsjService.selectDeviceSsjList(deviceSsj);
|
||||
|
||||
|
||||
for (DeviceSsj ssj : ssjList) {
|
||||
int taskNo = ssj.getTaskNo();
|
||||
String status = "其他";
|
||||
|
||||
|
||||
// 根据taskNo判断状态:不等于空或0时为运行状态
|
||||
if (taskNo != 0) {
|
||||
status = "运行";
|
||||
}
|
||||
|
||||
|
||||
Map<String, Integer> typeStatusCount = statusCount.get("SSJ");
|
||||
typeStatusCount.put(status, typeStatusCount.getOrDefault(status, 0) + 1);
|
||||
}
|
||||
|
||||
|
||||
return AjaxResult.success(statusCount);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("获取设备状态分布数据失败");
|
||||
@@ -299,34 +297,34 @@ public class IndexController extends BaseController
|
||||
{
|
||||
try {
|
||||
Map<String, Object> dashboardData = new HashMap<>();
|
||||
|
||||
|
||||
// 获取设备统计
|
||||
AjaxResult deviceStatsResult = getDeviceStats();
|
||||
if (deviceStatsResult.get("code").equals(200)) {
|
||||
dashboardData.put("deviceStats", deviceStatsResult.get("data"));
|
||||
}
|
||||
|
||||
|
||||
// 获取任务统计
|
||||
AjaxResult taskStatsResult = getTaskStats();
|
||||
if (taskStatsResult.get("code").equals(200)) {
|
||||
dashboardData.put("taskStats", taskStatsResult.get("data"));
|
||||
}
|
||||
|
||||
|
||||
// 获取当前任务
|
||||
AjaxResult currentTasksResult = getCurrentTasks();
|
||||
if (currentTasksResult.get("code").equals(200)) {
|
||||
dashboardData.put("currentTasks", currentTasksResult.get("data"));
|
||||
}
|
||||
|
||||
|
||||
// 获取设备列表
|
||||
AjaxResult deviceListResult = getDeviceList();
|
||||
if (deviceListResult.get("code").equals(200)) {
|
||||
dashboardData.put("deviceList", deviceListResult.get("data"));
|
||||
}
|
||||
|
||||
|
||||
return AjaxResult.success(dashboardData);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("获取首页数据失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user