opt:西门子车辆状态显示报警信息
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package org.nl.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* RestTemplate 配置类
|
||||
*/
|
||||
@Configuration
|
||||
public class RestTemplateConfig {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate() {
|
||||
return new RestTemplate();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.nl.wms.ext.acs.controller;
|
||||
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.wms.ext.acs.service.AcsAlarmService;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ACS 报警信息控制器
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/acs/alarm")
|
||||
public class AcsAlarmController {
|
||||
|
||||
@Autowired
|
||||
private AcsAlarmService acsAlarmService;
|
||||
|
||||
/**
|
||||
* 获取 AGV 状态
|
||||
* @param deviceCode 设备编码
|
||||
* @return AGV 状态信息
|
||||
*/
|
||||
@GetMapping("/status")
|
||||
public Object getAgvStatus() {
|
||||
return acsAlarmService.getAgvStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 AGV 报警信息
|
||||
* @param deviceCode 设备编码
|
||||
* @return AGV 报警信息列表
|
||||
*/
|
||||
@GetMapping("/alarms")
|
||||
public TableDataInfo getAgvAlarms(@RequestParam String deviceCode) {
|
||||
List<Object> alarms = acsAlarmService.getAgvAlarms(deviceCode);
|
||||
TableDataInfo dataInfo = new TableDataInfo();
|
||||
dataInfo.setContent(alarms);
|
||||
dataInfo.setTotalElements(alarms.size());
|
||||
return dataInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最新报警信息
|
||||
* @param limit 限制数量
|
||||
* @return 最新报警信息列表
|
||||
*/
|
||||
@GetMapping("/alarms/latest")
|
||||
public TableDataInfo getLatestAlarms(@RequestParam(defaultValue = "10") int limit) {
|
||||
List<Object> alarms = acsAlarmService.getLatestAlarms(limit);
|
||||
TableDataInfo dataInfo = new TableDataInfo();
|
||||
dataInfo.setContent(alarms);
|
||||
dataInfo.setTotalElements(alarms.size());
|
||||
return dataInfo;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.nl.wms.ext.acs.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ACS 报警信息服务
|
||||
*/
|
||||
public interface AcsAlarmService {
|
||||
|
||||
/**
|
||||
* 获取 AGV 状态
|
||||
* @param deviceCode 设备编码
|
||||
* @return AGV 状态信息
|
||||
*/
|
||||
Object getAgvStatus();
|
||||
|
||||
/**
|
||||
* 获取 AGV 报警信息
|
||||
* @param deviceCode 设备编码
|
||||
* @return AGV 报警信息列表
|
||||
*/
|
||||
List<Object> getAgvAlarms(String deviceCode);
|
||||
|
||||
/**
|
||||
* 获取最新报警信息
|
||||
* @param limit 限制数量
|
||||
* @return 最新报警信息列表
|
||||
*/
|
||||
List<Object> getLatestAlarms(int limit);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package org.nl.wms.ext.acs.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.param.dao.Param;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.nl.wms.ext.acs.service.AcsAlarmService;
|
||||
import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse;
|
||||
import org.nl.wms.sch.task_manage.GeneralDefinition;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ACS 报警信息服务实现
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AcsAlarmServiceImpl implements AcsAlarmService {
|
||||
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
|
||||
@Override
|
||||
public List<Object> getAgvStatus() {
|
||||
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
||||
//判断是否连接ACS系统
|
||||
Param isConnectAcs = sysParamService.findByCode(GeneralDefinition.IS_CONNECT_ACS);
|
||||
if (ObjectUtil.isEmpty(isConnectAcs)) {
|
||||
log.error("参数表中:" + GeneralDefinition.IS_CONNECT_ACS + "不存在");
|
||||
return null;
|
||||
}
|
||||
String isConnect = isConnectAcs.getValue();
|
||||
//ACS地址:127.0.0.1:8010
|
||||
Param acsUrlObj = sysParamService.findByCode(GeneralDefinition.ACS_URL);
|
||||
if (ObjectUtil.isEmpty(acsUrlObj)) {
|
||||
log.error("参数表中:" + GeneralDefinition.ACS_URL + "不存在");
|
||||
return null;
|
||||
}
|
||||
String acsUrl = acsUrlObj.getValue();
|
||||
if (StrUtil.equals(GeneralDefinition.NO, isConnect)) {
|
||||
log.error("未连接ACS!");
|
||||
return null;
|
||||
}
|
||||
String url = acsUrl + "api/agv_alarm/status";
|
||||
try {
|
||||
// 尝试作为 JSON 数组接收
|
||||
ResponseEntity<List> response = restTemplate.exchange(url, HttpMethod.GET, null, List.class);
|
||||
return response.getBody();
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
// 尝试作为 JSON 对象接收
|
||||
ResponseEntity<Map> response = restTemplate.exchange(url, HttpMethod.GET, null, Map.class);
|
||||
Map<String, Object> body = response.getBody();
|
||||
return (List<Object>) body.get("data");
|
||||
} catch (Exception ex) {
|
||||
log.error("获取AGV报警信息失败:" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getAgvAlarms(String deviceCode) {
|
||||
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
||||
//判断是否连接ACS系统
|
||||
Param isConnectAcs = sysParamService.findByCode(GeneralDefinition.IS_CONNECT_ACS);
|
||||
if (ObjectUtil.isEmpty(isConnectAcs)) {
|
||||
log.error("参数表中:" + GeneralDefinition.IS_CONNECT_ACS + "不存在");
|
||||
return null;
|
||||
}
|
||||
String isConnect = isConnectAcs.getValue();
|
||||
//ACS地址:127.0.0.1:8010
|
||||
Param acsUrlObj = sysParamService.findByCode(GeneralDefinition.ACS_URL);
|
||||
if (ObjectUtil.isEmpty(acsUrlObj)) {
|
||||
log.error("参数表中:" + GeneralDefinition.ACS_URL + "不存在");
|
||||
return null;
|
||||
}
|
||||
String acsUrl = acsUrlObj.getValue();
|
||||
if (StrUtil.equals(GeneralDefinition.NO, isConnect)) {
|
||||
log.error("未连接ACS!");
|
||||
return null;
|
||||
}
|
||||
String url = acsUrl + "api/agv_alarm/alarms?deviceCode=" + deviceCode;
|
||||
try {
|
||||
// 尝试作为 JSON 数组接收
|
||||
ResponseEntity<List> response = restTemplate.exchange(url, HttpMethod.GET, null, List.class);
|
||||
return response.getBody();
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
// 尝试作为 JSON 对象接收
|
||||
ResponseEntity<Map> response = restTemplate.exchange(url, HttpMethod.GET, null, Map.class);
|
||||
Map<String, Object> body = response.getBody();
|
||||
return (List<Object>) body.get("data");
|
||||
} catch (Exception ex) {
|
||||
log.error("获取AGV报警信息失败:" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getLatestAlarms(int limit) {
|
||||
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
||||
//判断是否连接ACS系统
|
||||
Param isConnectAcs = sysParamService.findByCode(GeneralDefinition.IS_CONNECT_ACS);
|
||||
if (ObjectUtil.isEmpty(isConnectAcs)) {
|
||||
log.error("参数表中:" + GeneralDefinition.IS_CONNECT_ACS + "不存在");
|
||||
return null;
|
||||
}
|
||||
String isConnect = isConnectAcs.getValue();
|
||||
//ACS地址:127.0.0.1:8010
|
||||
Param acsUrlObj = sysParamService.findByCode(GeneralDefinition.ACS_URL);
|
||||
if (ObjectUtil.isEmpty(acsUrlObj)) {
|
||||
log.error("参数表中:" + GeneralDefinition.ACS_URL + "不存在");
|
||||
return null;
|
||||
}
|
||||
String acsUrl = acsUrlObj.getValue();
|
||||
if (StrUtil.equals(GeneralDefinition.NO, isConnect)) {
|
||||
log.error("未连接ACS!");
|
||||
return null;
|
||||
}
|
||||
String url = acsUrl + "api/agv_alarm/alarms/latest?limit=" + limit;
|
||||
try {
|
||||
// 尝试作为 JSON 数组接收
|
||||
ResponseEntity<List> response = restTemplate.exchange(url, HttpMethod.GET, null, List.class);
|
||||
return response.getBody();
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
// 尝试作为 JSON 对象接收
|
||||
ResponseEntity<Map> response = restTemplate.exchange(url, HttpMethod.GET, null, Map.class);
|
||||
Map<String, Object> body = response.getBody();
|
||||
return (List<Object>) body.get("data");
|
||||
} catch (Exception ex) {
|
||||
log.error("获取最新报警信息失败:" + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
29
lms/nladmin-ui/src/api/agv_alarm.js
Normal file
29
lms/nladmin-ui/src/api/agv_alarm.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 调用 LMS 后端的 API,由 LMS 后端调用 ACS 后端
|
||||
|
||||
// 获取 AGV 状态
|
||||
export function getAgvStatus() {
|
||||
return request({
|
||||
url: '/api/acs/alarm/status',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 获取 AGV 报警信息
|
||||
export function getAgvAlarms(deviceCode) {
|
||||
return request({
|
||||
url: '/api/acs/alarm/alarms',
|
||||
method: 'get',
|
||||
params: { deviceCode }
|
||||
})
|
||||
}
|
||||
|
||||
// 获取最新报警信息
|
||||
export function getLatestAlarms(limit = 10) {
|
||||
return request({
|
||||
url: '/api/acs/alarm/alarms/latest',
|
||||
method: 'get',
|
||||
params: { limit }
|
||||
})
|
||||
}
|
||||
@@ -396,6 +396,7 @@
|
||||
|
||||
<script>
|
||||
import crudProduceScreen from './produceScreen'
|
||||
import {getAgvStatus} from '@/api/agv_alarm'
|
||||
// import crudProduceScreen from './mork'
|
||||
export default {
|
||||
data() {
|
||||
@@ -631,15 +632,15 @@ export default {
|
||||
searchOrder() {
|
||||
crudProduceScreen.regionOrder(this.popData.device_code, this.searchKey).then(res => {
|
||||
let data = [...res.content]
|
||||
|
||||
|
||||
// 提取去重后的工序列表
|
||||
this.processList = [...new Set(data.map(item => item.region_code).filter(Boolean))]
|
||||
|
||||
|
||||
// 根据选中的工序进行筛选
|
||||
if (this.selectedProcess) {
|
||||
data = data.filter(item => item.region_code === this.selectedProcess)
|
||||
}
|
||||
|
||||
|
||||
this.popList = data
|
||||
this.show = true
|
||||
})
|
||||
@@ -660,26 +661,46 @@ export default {
|
||||
},
|
||||
// 检查异常信息
|
||||
checkErrors() {
|
||||
// 从后端获取异常信息
|
||||
if (this.screenData && this.screenData.device_code) {
|
||||
crudProduceScreen.getExceptionMessage(this.screenData.device_code).then(res => {
|
||||
// 处理接口返回的异常信息
|
||||
if (res && res.content) {
|
||||
this.errorDetails = res.content
|
||||
this.hasError = res.content.length > 0
|
||||
} else {
|
||||
this.errorDetails = []
|
||||
this.hasError = false
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('获取异常信息失败:', error)
|
||||
// 从 LMS 后端获取 AGV 报警信息
|
||||
getAgvStatus().then(res => {
|
||||
if (res && res.length > 0) {
|
||||
// 转换报警信息格式:先过滤再映射,避免undefined
|
||||
this.errorDetails = res
|
||||
.filter(status => status.isActive === '1') // 先过滤出激活的报警
|
||||
.map(status => { // 再映射成目标格式
|
||||
return {
|
||||
type: 'AGV报警',
|
||||
message: `${status.deviceName || status.deviceCode}: ${status.status}`,
|
||||
time: new Date(status.updateTime).toLocaleString('zh-CN')
|
||||
}
|
||||
})
|
||||
this.hasError = this.errorDetails.length > 0
|
||||
} else {
|
||||
this.errorDetails = []
|
||||
this.hasError = false
|
||||
})
|
||||
} else {
|
||||
this.errorDetails = []
|
||||
this.hasError = false
|
||||
}
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('获取AGV报警信息失败:', error)
|
||||
// 如果从 LMS 后端获取失败,尝试从 LMS 系统获取
|
||||
if (this.screenData && this.screenData.device_code) {
|
||||
crudProduceScreen.getExceptionMessage(this.screenData.device_code).then(res => {
|
||||
if (res && res.content) {
|
||||
this.errorDetails = res.content
|
||||
this.hasError = res.content.length > 0
|
||||
} else {
|
||||
this.errorDetails = []
|
||||
this.hasError = false
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('获取异常信息失败:', error)
|
||||
this.errorDetails = []
|
||||
this.hasError = false
|
||||
})
|
||||
} else {
|
||||
this.errorDetails = []
|
||||
this.hasError = false
|
||||
}
|
||||
})
|
||||
},
|
||||
// 定时检查异常
|
||||
startErrorCheck() {
|
||||
|
||||
Reference in New Issue
Block a user