首页与国际化
This commit is contained in:
@@ -0,0 +1,332 @@
|
|||||||
|
package com.ruoyi.index.controller;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
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.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.device.ssj.domain.DeviceSsj;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首页数据Controller
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2025-01-08
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/index")
|
||||||
|
public class IndexController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private IDeviceCarService deviceCarService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IAgvQueueService agvQueueService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IAgvQueueFinishService agvQueueFinishService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IDeviceSsjService deviceSsjService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备统计数据
|
||||||
|
*/
|
||||||
|
@GetMapping("/deviceStats")
|
||||||
|
public AjaxResult getDeviceStats()
|
||||||
|
{
|
||||||
|
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)) {
|
||||||
|
agvCount++;
|
||||||
|
} else if ("2".equals(type)) {
|
||||||
|
ctuCount++;
|
||||||
|
} else if ("3".equals(type)) {
|
||||||
|
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("获取设备统计数据失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取任务统计数据
|
||||||
|
*/
|
||||||
|
@GetMapping("/taskStats")
|
||||||
|
public AjaxResult getTaskStats()
|
||||||
|
{
|
||||||
|
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)) {
|
||||||
|
pendingCount++;
|
||||||
|
} else if ("2".equals(status)||"3".equals(status)) {
|
||||||
|
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("获取任务统计数据失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前任务队列
|
||||||
|
*/
|
||||||
|
@GetMapping("/currentTasks")
|
||||||
|
public AjaxResult getCurrentTasks()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
AgvQueue agvQueue = new AgvQueue();
|
||||||
|
List<AgvQueue> taskList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||||
|
|
||||||
|
return AjaxResult.success(taskList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return AjaxResult.error("获取当前任务队列失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取运行中的设备列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/deviceList")
|
||||||
|
public AjaxResult getDeviceList()
|
||||||
|
{
|
||||||
|
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
|
||||||
|
if (taskNo != null && !taskNo.trim().isEmpty() && !"0".equals(taskNo.trim())) {
|
||||||
|
Map<String, Object> deviceInfo = new HashMap<>();
|
||||||
|
deviceInfo.put("deviceCode", device.getDeviceCode());
|
||||||
|
deviceInfo.put("deviceName", device.getName());
|
||||||
|
deviceInfo.put("deviceType", "1".equals(device.getType()) ? "AGV" : "CTU");
|
||||||
|
deviceInfo.put("taskNo", device.getTaskNo());
|
||||||
|
runningDevices.add(deviceInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询运行中的SSJ设备
|
||||||
|
DeviceSsj deviceSsj = new DeviceSsj();
|
||||||
|
List<DeviceSsj> ssjList = deviceSsjService.selectDeviceSsjList(deviceSsj);
|
||||||
|
|
||||||
|
for (DeviceSsj ssj : ssjList) {
|
||||||
|
int taskNo = ssj.getTaskNo();
|
||||||
|
// 判断是否为运行中设备:taskNo不为0
|
||||||
|
if (taskNo != 0) {
|
||||||
|
Map<String, Object> deviceInfo = new HashMap<>();
|
||||||
|
deviceInfo.put("deviceCode", ssj.getDeviceCode());
|
||||||
|
deviceInfo.put("deviceName", ssj.getName());
|
||||||
|
deviceInfo.put("deviceType", "SSJ");
|
||||||
|
deviceInfo.put("taskNo", String.valueOf(ssj.getTaskNo()));
|
||||||
|
runningDevices.add(deviceInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return AjaxResult.success(runningDevices);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return AjaxResult.error("获取运行中设备列表失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取任务类型分布数据
|
||||||
|
*/
|
||||||
|
@GetMapping("/taskTypeChart")
|
||||||
|
public AjaxResult getTaskTypeChart()
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Map<String, Object>> chartData = new ArrayList<>();
|
||||||
|
for (Map.Entry<String, Integer> entry : taskTypeCount.entrySet()) {
|
||||||
|
Map<String, Object> item = new HashMap<>();
|
||||||
|
item.put("name", entry.getKey());
|
||||||
|
item.put("value", entry.getValue());
|
||||||
|
chartData.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return AjaxResult.success(chartData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return AjaxResult.error("获取任务类型分布数据失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备状态分布数据
|
||||||
|
*/
|
||||||
|
@GetMapping("/deviceStatusChart")
|
||||||
|
public AjaxResult getDeviceStatusChart()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Map<String, Map<String, Integer>> statusCount = new HashMap<>();
|
||||||
|
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("获取设备状态分布数据失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取首页综合数据
|
||||||
|
*/
|
||||||
|
@GetMapping("/dashboard")
|
||||||
|
public AjaxResult getDashboardData()
|
||||||
|
{
|
||||||
|
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