Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -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<DeviceCar> deviceList = deviceCarService.selectDeviceCarList(deviceCar);
|
||||
List<MsgDdj> msgDdjList = msgDdjService.selectMsgDdjList(msgDdj);
|
||||
List<DeviceSsj> deviceSsjList = deviceSsjService.selectDeviceSsjList(deviceSsj);
|
||||
|
||||
Map<String, Object> stats = new HashMap<>();
|
||||
int agvCount = 0;
|
||||
int ctuCount = 0;
|
||||
int ssjCount = 0;
|
||||
Map<String, Object> 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<AgvQueue> queueList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
List<MydoJob> mydoJobList = mydoJobService.selectMydoJobList(mydoJob);
|
||||
List<MydoJob> 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<AgvQueueFinish> finishList = agvQueueFinishService.selectAgvQueueFinishList(finishQuery);
|
||||
int finishedCount = finishList.size();
|
||||
for (MydoJob Fjob : mydoJobFinishList) {
|
||||
String status = Fjob.getStatus();
|
||||
if ("4".equals(status)) {
|
||||
finishedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
@@ -121,13 +125,12 @@ public class IndexController extends BaseController
|
||||
* 获取当前任务队列
|
||||
*/
|
||||
@GetMapping("/currentTasks")
|
||||
public AjaxResult getCurrentTasks()
|
||||
{
|
||||
public AjaxResult getCurrentTasks() {
|
||||
try {
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
List<AgvQueue> taskList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
|
||||
return AjaxResult.success(taskList);
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
mydoJobParam.setStatus("3");
|
||||
List<MydoJob> 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<Map<String, Object>> runningDevices = new ArrayList<>();
|
||||
|
||||
@@ -153,7 +155,7 @@ public class IndexController extends BaseController
|
||||
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("deviceType", "AGV");
|
||||
deviceInfo.put("taskNo", device.getTaskNo());
|
||||
runningDevices.add(deviceInfo);
|
||||
}
|
||||
@@ -176,6 +178,21 @@ public class IndexController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
MsgDdj msgDdj = new MsgDdj();
|
||||
List<MsgDdj> msgDdjList = msgDdjService.selectMsgDdjList(msgDdj);
|
||||
|
||||
for (MsgDdj ddj : msgDdjList){
|
||||
Long taskNo = ddj.getRwh();
|
||||
if (taskNo != 0){
|
||||
HashMap<String, Object> 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<AgvQueue> queueList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
List<MydoJob> mydoJobFinishList = mydoJobService.selectMydoJobFinishList(mydoJob);
|
||||
|
||||
AgvQueueFinish finishQuery = new AgvQueueFinish();
|
||||
List<AgvQueueFinish> finishList = agvQueueFinishService.selectAgvQueueFinishList(finishQuery);
|
||||
Map<String, Integer> inOrOutCount = new HashMap<>();
|
||||
|
||||
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);
|
||||
// 统计完成任务的 inOrOut 类型
|
||||
for (MydoJob job : mydoJobFinishList) {
|
||||
String inOrOut = job.getInOrOut();
|
||||
if (inOrOut != null && !inOrOut.isEmpty()) {
|
||||
inOrOutCount.put(inOrOut, inOrOutCount.getOrDefault(inOrOut, 0) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, Object>> chartData = new ArrayList<>();
|
||||
for (Map.Entry<String, Integer> entry : taskTypeCount.entrySet()) {
|
||||
for (Map.Entry<String, Integer> entry : inOrOutCount.entrySet()) {
|
||||
Map<String, Object> 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<String, Map<String, Integer>> 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<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 = "运行";
|
||||
}
|
||||
Map<String, Integer> typeStatusCount = statusCount.get("AGV");
|
||||
typeStatusCount.put(status, typeStatusCount.getOrDefault(status, 0) + 1);
|
||||
|
||||
if (!deviceType.isEmpty()) {
|
||||
Map<String, Integer> 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<MsgDdj> msgDdjList = msgDdjService.selectMsgDdjList(msgDdj);
|
||||
|
||||
for (MsgDdj ddj : msgDdjList){
|
||||
Long taskNo = ddj.getRwh();
|
||||
String status = "其他";
|
||||
if (taskNo!=0){
|
||||
status = "运行";
|
||||
}
|
||||
Map<String,Integer> 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<String, Object> dashboardData = new HashMap<>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user