Compare commits
2 Commits
1f91405a40
...
agv_twoFlo
| Author | SHA1 | Date | |
|---|---|---|---|
| 01a23d21e0 | |||
| 07998cecbb |
@@ -0,0 +1,38 @@
|
|||||||
|
package org.nl.acs.agv.contorller;
|
||||||
|
|
||||||
|
import org.nl.acs.agv.service.impl.TwoFloorAgvStatusService;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二楼AGV状态控制器
|
||||||
|
* 提供HTTP接口获取AGV状态信息
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/agv/two-floor")
|
||||||
|
public class TwoFloorAgvController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TwoFloorAgvStatusService agvStatusService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有二楼AGV状态
|
||||||
|
* @return 所有AGV状态列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/status")
|
||||||
|
public Object getAllAgvStatus() {
|
||||||
|
return agvStatusService.getAllAgvStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取单个AGV状态
|
||||||
|
* @param vehicleCode AGV车辆代码
|
||||||
|
* @return AGV状态信息
|
||||||
|
*/
|
||||||
|
@GetMapping("/status/{vehicleCode}")
|
||||||
|
public Object getAgvStatus(String vehicleCode) {
|
||||||
|
return agvStatusService.getAgvStatus(vehicleCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,180 @@
|
|||||||
|
package org.nl.acs.agv.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二楼AGV状态数据模型
|
||||||
|
* 用于存储和传输AGV的实时状态信息
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TwoFloorAgvStatus {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AGV车辆代码
|
||||||
|
*/
|
||||||
|
private String vehicle_code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AGV状态
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AGV状态文本描述
|
||||||
|
*/
|
||||||
|
private String status_text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前任务代码
|
||||||
|
*/
|
||||||
|
private String task_code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前指令代码
|
||||||
|
*/
|
||||||
|
private String inst_code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前阶段值
|
||||||
|
*/
|
||||||
|
private Integer phase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前阶段名称
|
||||||
|
*/
|
||||||
|
private String phase_name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前位置
|
||||||
|
*/
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料类型
|
||||||
|
*/
|
||||||
|
private String material_type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料数量
|
||||||
|
*/
|
||||||
|
private Integer quantity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始设备代码
|
||||||
|
*/
|
||||||
|
private String start_device_code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下一个设备代码
|
||||||
|
*/
|
||||||
|
private String next_device_code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否有错误
|
||||||
|
*/
|
||||||
|
private Boolean is_error;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误代码
|
||||||
|
*/
|
||||||
|
private String error_code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误信息
|
||||||
|
*/
|
||||||
|
private String error_message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 卡住的Action
|
||||||
|
*/
|
||||||
|
private String error_action;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 卡住的Mode
|
||||||
|
*/
|
||||||
|
private String error_mode;
|
||||||
|
/**
|
||||||
|
* 卡住的move
|
||||||
|
*/
|
||||||
|
private String error_move;
|
||||||
|
/**
|
||||||
|
* 卡住的error
|
||||||
|
*/
|
||||||
|
private String error_error;
|
||||||
|
/**
|
||||||
|
* 设备号
|
||||||
|
*/
|
||||||
|
private String device_code;
|
||||||
|
/**
|
||||||
|
* 期望的Action
|
||||||
|
*/
|
||||||
|
private String exp_action;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 卡住的Mode
|
||||||
|
*/
|
||||||
|
private String exp_mode;
|
||||||
|
/**
|
||||||
|
* 卡住的move
|
||||||
|
*/
|
||||||
|
private String exp_move;
|
||||||
|
/**
|
||||||
|
* 卡住的error
|
||||||
|
*/
|
||||||
|
private String exp_error;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实际Action
|
||||||
|
*/
|
||||||
|
private String action;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实际Mode
|
||||||
|
*/
|
||||||
|
private String mode;
|
||||||
|
/**
|
||||||
|
* 实际move
|
||||||
|
*/
|
||||||
|
private String move;
|
||||||
|
/**
|
||||||
|
* 实际error
|
||||||
|
*/
|
||||||
|
private String error;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电量
|
||||||
|
*/
|
||||||
|
private Integer electric_qty;
|
||||||
|
|
||||||
|
private String driver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X坐标
|
||||||
|
*/
|
||||||
|
private Integer x;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Y坐标
|
||||||
|
*/
|
||||||
|
private Integer y;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角度
|
||||||
|
*/
|
||||||
|
private Integer angle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 区域
|
||||||
|
*/
|
||||||
|
private Integer region;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否在线
|
||||||
|
*/
|
||||||
|
private Boolean is_online;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 三色灯状态
|
||||||
|
*/
|
||||||
|
private Integer status_light;
|
||||||
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
package org.nl.acs.agv.service.impl;
|
||||||
|
|
||||||
|
import org.nl.acs.agv.domain.TwoFloorAgvStatus;
|
||||||
|
import org.nl.acs.device_driver.agv.utils.TwoAgvPhase;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二楼AGV状态管理服务
|
||||||
|
* 负责管理和更新AGV状态,通过HTTP接口提供状态查询
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class TwoFloorAgvStatusService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TwoAgvPhase twoAgvPhase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储AGV状态信息,key为AGV车辆代码
|
||||||
|
*/
|
||||||
|
private ConcurrentHashMap<String, TwoFloorAgvStatus> agvStatusMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化AGV状态
|
||||||
|
*/
|
||||||
|
public TwoFloorAgvStatusService() {
|
||||||
|
// 初始化二楼的4台AGV
|
||||||
|
for (int i = 1; i <= 4; i++) {
|
||||||
|
TwoFloorAgvStatus agvStatus = new TwoFloorAgvStatus();
|
||||||
|
String vehicleCode = String.format("AGV%02d", i);
|
||||||
|
agvStatus.setVehicle_code(vehicleCode);
|
||||||
|
agvStatus.setStatus("idle");
|
||||||
|
agvStatus.setStatus_text("空闲");
|
||||||
|
agvStatus.setIs_error(false);
|
||||||
|
agvStatus.setIs_online(true);
|
||||||
|
agvStatusMap.put(vehicleCode, agvStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新AGV状态
|
||||||
|
* @param agvStatus AGV状态信息
|
||||||
|
*/
|
||||||
|
public synchronized void updateAgvStatus(TwoFloorAgvStatus agvStatus) {
|
||||||
|
if (agvStatus == null || agvStatus.getVehicle_code() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理阶段名称
|
||||||
|
if (agvStatus.getPhase() != null) {
|
||||||
|
String phaseName = twoAgvPhase.getPhaseName(agvStatus.getPhase());
|
||||||
|
agvStatus.setPhase_name(phaseName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理状态文本
|
||||||
|
this.handleStatusText(agvStatus);
|
||||||
|
|
||||||
|
// 更新状态
|
||||||
|
agvStatusMap.put(agvStatus.getVehicle_code(), agvStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理AGV状态文本
|
||||||
|
*/
|
||||||
|
private void handleStatusText(TwoFloorAgvStatus agvStatus) {
|
||||||
|
switch (agvStatus.getStatus()) {
|
||||||
|
case "running":
|
||||||
|
agvStatus.setStatus_text("运行中");
|
||||||
|
break;
|
||||||
|
case "idle":
|
||||||
|
agvStatus.setStatus_text("空闲");
|
||||||
|
break;
|
||||||
|
case "error":
|
||||||
|
agvStatus.setStatus_text("异常");
|
||||||
|
agvStatus.setIs_error(true);
|
||||||
|
break;
|
||||||
|
case "charging":
|
||||||
|
agvStatus.setStatus_text("充电中");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
agvStatus.setStatus_text("未知");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取单个AGV状态
|
||||||
|
* @param vehicleCode AGV车辆代码
|
||||||
|
* @return AGV状态信息
|
||||||
|
*/
|
||||||
|
public TwoFloorAgvStatus getAgvStatus(String vehicleCode) {
|
||||||
|
return agvStatusMap.get(vehicleCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有AGV状态
|
||||||
|
* @return 所有AGV状态列表
|
||||||
|
*/
|
||||||
|
public List<TwoFloorAgvStatus> getAllAgvStatus() {
|
||||||
|
return new ArrayList<>(agvStatusMap.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除AGV错误信息
|
||||||
|
*/
|
||||||
|
public void clearAgvError(int carno) {
|
||||||
|
String vehicleCode = String.format("AGV%02d", carno);
|
||||||
|
TwoFloorAgvStatus agvStatus = agvStatusMap.get(vehicleCode);
|
||||||
|
if (agvStatus != null) {
|
||||||
|
agvStatus.setIs_error(false);
|
||||||
|
agvStatus.setError_code(null);
|
||||||
|
agvStatus.setError_message(null);
|
||||||
|
agvStatus.setError_action(null);
|
||||||
|
agvStatus.setError_mode(null);
|
||||||
|
// 设置错误信息
|
||||||
|
agvStatus.setDriver(null);
|
||||||
|
agvStatus.setIs_error(false);
|
||||||
|
agvStatus.setError_message(null);
|
||||||
|
agvStatus.setDevice_code(null);
|
||||||
|
agvStatus.setError_action(null);
|
||||||
|
agvStatus.setError_mode(null);
|
||||||
|
agvStatus.setError_move(null);
|
||||||
|
agvStatus.setError_error(null);
|
||||||
|
agvStatus.setExp_action(null);
|
||||||
|
agvStatus.setExp_mode(null);
|
||||||
|
agvStatus.setExp_move(null);
|
||||||
|
agvStatus.setExp_error(null);
|
||||||
|
if ("error".equals(agvStatus.getStatus())) {
|
||||||
|
agvStatus.setStatus("idle");
|
||||||
|
agvStatus.setStatus_text("空闲");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.acs.AcsConfig;
|
import org.nl.acs.AcsConfig;
|
||||||
|
import org.nl.acs.agv.domain.TwoFloorAgvStatus;
|
||||||
import org.nl.acs.agv.server.NDCAgvService;
|
import org.nl.acs.agv.server.NDCAgvService;
|
||||||
import org.nl.acs.device.domain.Device;
|
import org.nl.acs.device.domain.Device;
|
||||||
import org.nl.acs.device.service.DeviceService;
|
import org.nl.acs.device.service.DeviceService;
|
||||||
@@ -17,6 +18,7 @@ import org.nl.acs.instruction.domain.Instruction;
|
|||||||
import org.nl.acs.instruction.service.InstructionService;
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
|
import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
|
||||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||||
|
import org.nl.acs.agv.service.impl.TwoFloorAgvStatusService;
|
||||||
import org.nl.acs.opc.DeviceAppService;
|
import org.nl.acs.opc.DeviceAppService;
|
||||||
import org.nl.config.SpringContextHolder;
|
import org.nl.config.SpringContextHolder;
|
||||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||||
@@ -33,10 +35,7 @@ import java.io.DataOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
@@ -80,6 +79,10 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
AutoRunService autoRunService;
|
AutoRunService autoRunService;
|
||||||
@Autowired
|
@Autowired
|
||||||
LuceneExecuteLogService luceneExecuteLogService;
|
LuceneExecuteLogService luceneExecuteLogService;
|
||||||
|
/**
|
||||||
|
* 二楼AGV状态管理服务
|
||||||
|
*/
|
||||||
|
private TwoFloorAgvStatusService agvStatusService;
|
||||||
@Autowired
|
@Autowired
|
||||||
ISysDictService dictService;
|
ISysDictService dictService;
|
||||||
|
|
||||||
@@ -106,7 +109,8 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
||||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
|
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
|
||||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
||||||
|
// 初始化AGV状态管理服务
|
||||||
|
agvStatusService = SpringContextHolder.getBean(TwoFloorAgvStatusService.class);
|
||||||
try {
|
try {
|
||||||
log.info("2楼1区域AGV系统链接开始");
|
log.info("2楼1区域AGV系统链接开始");
|
||||||
ip = paramService.findByCode(AcsConfig.AGVURL).getValue();
|
ip = paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
395
acs2/nladmin-ui/src/views/screen/twoFloorAgvScreen.vue
Normal file
395
acs2/nladmin-ui/src/views/screen/twoFloorAgvScreen.vue
Normal file
@@ -0,0 +1,395 @@
|
|||||||
|
<template>
|
||||||
|
<div class="two-floor-agv-screen">
|
||||||
|
<div class="header">
|
||||||
|
<h1>二楼AGV监控看板</h1>
|
||||||
|
<div class="time-info">
|
||||||
|
<span>{{ getTime }}</span>
|
||||||
|
<span>{{ getDate }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="agv-list">
|
||||||
|
<div
|
||||||
|
v-for="agv in agvList"
|
||||||
|
:key="agv.vehicle_code"
|
||||||
|
class="agv-item"
|
||||||
|
:class="{ 'agv-error': agv.is_error }"
|
||||||
|
@click="showAgvDetail(agv)"
|
||||||
|
>
|
||||||
|
<div class="agv-header">
|
||||||
|
<div class="agv-basic-info">
|
||||||
|
<h3>{{ agv.vehicle_code }}</h3>
|
||||||
|
<span class="status" :class="agv.status">{{ agv.status_text }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="agv-phase">
|
||||||
|
<span class="label">当前阶段:</span>
|
||||||
|
<span class="phase-value">{{ agv.phase_name || '无' }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="agv-task-info">
|
||||||
|
<div class="task-item">
|
||||||
|
<span class="label">任务代码:</span>
|
||||||
|
<span>{{ agv.task_code || '无' }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="task-item">
|
||||||
|
<span class="label">指令代码:</span>
|
||||||
|
<span>{{ agv.inst_code || '无' }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="task-item">
|
||||||
|
<span class="label">当前位置:</span>
|
||||||
|
<span>{{ agv.address || '未知' }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="agv.is_error" class="agv-error-info">
|
||||||
|
<h4>任务卡住原因:</h4>
|
||||||
|
<div v-if="agv.error_action" class="error-item">
|
||||||
|
<span class="label">Action不满足:</span>
|
||||||
|
<span>{{ agv.error_action }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="agv.error_mode" class="error-item">
|
||||||
|
<span class="label">Mode不满足:</span>
|
||||||
|
<span>{{ agv.error_mode }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="agv.error_error" class="error-item">
|
||||||
|
<span class="label">Error不满足:</span>
|
||||||
|
<span>{{ agv.error_error }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="agv.error_move" class="error-item">
|
||||||
|
<span class="label">Move不满足:</span>
|
||||||
|
<span>{{ agv.error_move }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="agv.error_message" class="error-item">
|
||||||
|
<span class="label">错误信息:</span>
|
||||||
|
<span>{{ agv.error_message }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else-if="agv.phase_name" class="agv-normal-info">
|
||||||
|
<h4>当前任务进度:</h4>
|
||||||
|
<div v-for="(step, index) in agv.phase_steps" :key="index" class="progress-item">
|
||||||
|
<span class="step-name">{{ step.name }}</span>
|
||||||
|
<el-progress
|
||||||
|
:percentage="step.completed ? 100 : 0"
|
||||||
|
:color="step.completed ? '#67C23A' : '#E6A23C'"
|
||||||
|
:stroke-width="6"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- AGV详情弹窗 -->
|
||||||
|
<el-dialog
|
||||||
|
title="AGV详情"
|
||||||
|
:visible.sync="dialogVisible"
|
||||||
|
width="50%"
|
||||||
|
>
|
||||||
|
<div v-if="currentAgv" class="agv-detail">
|
||||||
|
<el-descriptions :column="1" border>
|
||||||
|
<el-descriptions-item label="AGV编号">{{ currentAgv.vehicle_code }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="当前状态">{{ currentAgv.status_text }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="当前阶段">{{ currentAgv.phase_name || '无' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="任务代码">{{ currentAgv.task_code || '无' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="指令代码">{{ currentAgv.inst_code || '无' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="当前位置">{{ currentAgv.address || '未知' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item v-if="currentAgv.is_error" label="错误信息">
|
||||||
|
<div v-if="currentAgv.error_action">Action不满足:{{ currentAgv.error_action }}</div>
|
||||||
|
<div v-if="currentAgv.error_mode">Mode不满足:{{ currentAgv.error_mode }}</div>
|
||||||
|
<div v-if="currentAgv.error_action">Move不满足:{{ currentAgv.error_move }}</div>
|
||||||
|
<div v-if="currentAgv.error_error">Error不满足:{{ currentAgv.error_error }}</div>
|
||||||
|
<div v-if="currentAgv.error_message">{{ currentAgv.error_message }}</div>
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Background from '@/assets/images/bigScreen.png'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
Background: Background,
|
||||||
|
agvList: [
|
||||||
|
{ vehicle_code: 'AGV01', status: 'running', status_text: '运行中', is_error: false },
|
||||||
|
{ vehicle_code: 'AGV02', status: 'idle', status_text: '空闲', is_error: false },
|
||||||
|
{ vehicle_code: 'AGV03', status: 'error', status_text: '异常', is_error: true },
|
||||||
|
{ vehicle_code: 'AGV04', status: 'charging', status_text: '充电中', is_error: false }
|
||||||
|
],
|
||||||
|
getTime: '',
|
||||||
|
getDate: '',
|
||||||
|
dialogVisible: false,
|
||||||
|
currentAgv: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.init()
|
||||||
|
// 定时器,每秒更新一次数据
|
||||||
|
const timer = setInterval(() => {
|
||||||
|
this.settime()
|
||||||
|
this.getMessage()
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
|
// 销毁定时器
|
||||||
|
this.$once('hook:beforeDestroy', () => {
|
||||||
|
clearInterval(timer)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
init() {
|
||||||
|
// 初始化数据
|
||||||
|
this.settime()
|
||||||
|
// 获取AGV状态数据
|
||||||
|
this.getMessage()
|
||||||
|
},
|
||||||
|
settime() {
|
||||||
|
const yy = new Date().getFullYear()
|
||||||
|
const mm = new Date().getMonth() + 1
|
||||||
|
const dd = new Date().getDate()
|
||||||
|
const hh = new Date().getHours()
|
||||||
|
const mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
|
||||||
|
const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
|
||||||
|
this.getDate = yy + '年' + mm + '月' + dd + '日 ' + '星期' + '日一二三四五六'.charAt(new Date().getDay())
|
||||||
|
this.getTime = hh + ':' + mf + ':' + ss
|
||||||
|
},
|
||||||
|
getMessage() {
|
||||||
|
// 通过HTTP接口获取AGV状态数据
|
||||||
|
this.$axios.get('/api/agv/two-floor/status')
|
||||||
|
.then(response => {
|
||||||
|
if (response) {
|
||||||
|
this.updateAgvData(response)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('获取AGV状态数据失败:', error)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
updateAgvData(agvDataList) {
|
||||||
|
// 更新AGV数据
|
||||||
|
agvDataList.forEach(data => {
|
||||||
|
const agvIndex = this.agvList.findIndex(agv => agv.vehicle_code === data.vehicle_code)
|
||||||
|
if (agvIndex !== -1) {
|
||||||
|
// 处理AGV状态
|
||||||
|
const statusMap = {
|
||||||
|
'running': { text: '运行中', class: 'running' },
|
||||||
|
'idle': { text: '空闲', class: 'idle' },
|
||||||
|
'error': { text: '异常', class: 'error' },
|
||||||
|
'charging': { text: '充电中', class: 'charging' }
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据数据状态判断AGV是否处于错误状态
|
||||||
|
const isError = !!(data.is_error || (data.error_action || data.error_mode || data.error_error || data.error_move || data.error_message))
|
||||||
|
|
||||||
|
// 设置状态信息
|
||||||
|
const statusInfo = statusMap[data.status] || { text: '未知', class: 'unknown' }
|
||||||
|
if (isError) {
|
||||||
|
statusInfo.text = '异常'
|
||||||
|
statusInfo.class = 'error'
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新AGV数据
|
||||||
|
this.agvList[agvIndex] = {
|
||||||
|
...this.agvList[agvIndex],
|
||||||
|
...data,
|
||||||
|
status_text: statusInfo.text,
|
||||||
|
status: statusInfo.class,
|
||||||
|
is_error: isError,
|
||||||
|
phase_name: data.phase_name,
|
||||||
|
error_action: data.error_action,
|
||||||
|
error_mode: data.error_mode,
|
||||||
|
error_move: data.error_move,
|
||||||
|
error_error: data.error_error,
|
||||||
|
error_message: data.error_message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
showAgvDetail(agv) {
|
||||||
|
this.currentAgv = agv
|
||||||
|
this.dialogVisible = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.two-floor-agv-screen {
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
background-color: #f0f2f5;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
background-color: #2c3e50;
|
||||||
|
color: white;
|
||||||
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header h1 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-info {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-info span {
|
||||||
|
display: block;
|
||||||
|
margin: 5px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agv-list {
|
||||||
|
padding: 20px;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agv-item {
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 20px;
|
||||||
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
border-left: 5px solid #409eff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agv-item:hover {
|
||||||
|
transform: translateY(-5px);
|
||||||
|
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.agv-item.agv-error {
|
||||||
|
border-left-color: #f56c6c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agv-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agv-basic-info h3 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 20px;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 4px 12px;
|
||||||
|
border-radius: 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status.running {
|
||||||
|
background-color: #67c23a;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status.idle {
|
||||||
|
background-color: #909399;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status.error {
|
||||||
|
background-color: #f56c6c;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status.charging {
|
||||||
|
background-color: #e6a23c;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status.unknown {
|
||||||
|
background-color: #909399;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agv-phase {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #666;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phase-value {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #409eff;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agv-task-info {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.task-item {
|
||||||
|
margin: 8px 0;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agv-error-info {
|
||||||
|
background-color: #fef0f0;
|
||||||
|
border: 1px solid #fbc4ab;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 15px;
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agv-error-info h4 {
|
||||||
|
margin-top: 0;
|
||||||
|
color: #f56c6c;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-item {
|
||||||
|
margin: 8px 0;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agv-normal-info {
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agv-normal-info h4 {
|
||||||
|
margin-top: 0;
|
||||||
|
color: #67c23a;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-item {
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-name {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.agv-detail {
|
||||||
|
padding: 10px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user