|
|
|
@ -598,9 +598,8 @@ public class DashboardPushTask { |
|
|
|
Map<String, Object> storageUtilization = getInventoryStatsFromWcs(); |
|
|
|
log.debug("库位利用率数据: {}", storageUtilization); |
|
|
|
|
|
|
|
// 查询机器人状态数据 |
|
|
|
//List<Map<String, Object>> robotStatus = dashboardDao.queryWarehouseRobotStatus(); |
|
|
|
List<Map<String, Object>> robotStatus = new ArrayList<>(); |
|
|
|
// 查询机器人状态数据(从WMS Dashboard API获取) |
|
|
|
List<Map<String, Object>> robotStatus = getRobotSortingInfoFromWms(); |
|
|
|
log.debug("查询到机器人状态数据: {}条", robotStatus != null ? robotStatus.size() : 0); |
|
|
|
|
|
|
|
// 查询AGV状态数据(从TUSK系统获取) |
|
|
|
@ -1163,5 +1162,179 @@ public class DashboardPushTask { |
|
|
|
return (receiveList == null || receiveList.isEmpty()) |
|
|
|
&& (inboundList == null || inboundList.isEmpty()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 从WMS Dashboard API获取机械臂分拣信息 |
|
|
|
* |
|
|
|
* <p><b>数据转换说明:</b></p> |
|
|
|
* <ul> |
|
|
|
* <li>从WMS获取原始机械臂分拣状态</li> |
|
|
|
* <li>转换为看板需要的格式</li> |
|
|
|
* <li>映射工作模式和设备状态枚举值</li> |
|
|
|
* <li>1071=机械手1, 1060=机械手2</li> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
* @return 机械臂分拣状态列表 |
|
|
|
*/ |
|
|
|
private List<Map<String, Object>> getRobotSortingInfoFromWms() { |
|
|
|
List<Map<String, Object>> robotList = new ArrayList<>(); |
|
|
|
|
|
|
|
try { |
|
|
|
// 调用WMS Dashboard API(使用配置文件中的URL) |
|
|
|
String url = wcsBoardApi + "WmsDashboard/robot-sorting-info"; |
|
|
|
log.debug("调用WMS机械臂分拣API: {}", url); |
|
|
|
|
|
|
|
String wmsResponse = HttpUtils.doGet(url, null, null); |
|
|
|
log.debug("WMS API返回数据: {}", wmsResponse); |
|
|
|
|
|
|
|
// 解析JSON数据 |
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
JsonNode rootNode = mapper.readTree(wmsResponse); |
|
|
|
|
|
|
|
// 检查返回码 |
|
|
|
int resCode = rootNode.get("resCode").asInt(); |
|
|
|
if (resCode != 200) { |
|
|
|
String resMsg = rootNode.has("resMsg") ? rootNode.get("resMsg").asText() : "未知错误"; |
|
|
|
log.warn("WMS机械臂分拣API返回错误: code={}, msg={}", resCode, resMsg); |
|
|
|
return robotList; |
|
|
|
} |
|
|
|
|
|
|
|
// 获取resData.sortingStations数组 |
|
|
|
if (!rootNode.has("resData") || !rootNode.get("resData").has("sortingStations")) { |
|
|
|
log.warn("WMS返回数据中没有sortingStations"); |
|
|
|
return robotList; |
|
|
|
} |
|
|
|
|
|
|
|
JsonNode sortingStations = rootNode.get("resData").get("sortingStations"); |
|
|
|
if (!sortingStations.isArray()) { |
|
|
|
log.warn("sortingStations不是数组格式"); |
|
|
|
return robotList; |
|
|
|
} |
|
|
|
|
|
|
|
// 转换数据为看板格式 |
|
|
|
for (JsonNode station : sortingStations) { |
|
|
|
Map<String, Object> robot = new HashMap<>(); |
|
|
|
|
|
|
|
// 分拣站编号 |
|
|
|
String sortingStation = station.has("sortingStation") ? station.get("sortingStation").asText() : ""; |
|
|
|
robot.put("id", sortingStation); |
|
|
|
|
|
|
|
// 机械手名称映射:1071=机械手1, 1060=机械手2 |
|
|
|
String robotName; |
|
|
|
if ("1071".equals(sortingStation)) { |
|
|
|
robotName = "机械手 1"; |
|
|
|
} else if ("1060".equals(sortingStation)) { |
|
|
|
robotName = "机械手 2"; |
|
|
|
} else { |
|
|
|
robotName = "机械手 " + sortingStation; |
|
|
|
} |
|
|
|
robot.put("name", robotName); |
|
|
|
|
|
|
|
// 待处理物料数量(任务数) |
|
|
|
int pendingMaterialCount = station.has("pendingMaterialCount") ? station.get("pendingMaterialCount").asInt() : 0; |
|
|
|
robot.put("tasks", pendingMaterialCount); |
|
|
|
|
|
|
|
// 工作模式(OperationMode枚举) |
|
|
|
int workModel = station.has("workModel") ? station.get("workModel").asInt() : 0; |
|
|
|
robot.put("workModel", workModel); |
|
|
|
robot.put("workModelText", getWorkModelText(workModel)); |
|
|
|
|
|
|
|
// 设备状态(DeviceStatus枚举) |
|
|
|
int workStatus = station.has("workStatus") ? station.get("workStatus").asInt() : 0; |
|
|
|
robot.put("workStatus", workStatus); |
|
|
|
robot.put("workStatusText", getWorkStatusText(workStatus)); |
|
|
|
|
|
|
|
// 转换为标准状态(working/idle/error/maintenance) |
|
|
|
String status = convertRobotStatus(workModel, workStatus); |
|
|
|
robot.put("status", status); |
|
|
|
robot.put("statusText", getWorkStatusText(workStatus)); |
|
|
|
|
|
|
|
robotList.add(robot); |
|
|
|
} |
|
|
|
|
|
|
|
log.info("从WMS获取到{}个机械臂分拣站状态", robotList.size()); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
log.error("从WMS获取机械臂分拣数据失败", e); |
|
|
|
} |
|
|
|
|
|
|
|
return robotList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取工作模式文本 |
|
|
|
* |
|
|
|
* @param workModel 工作模式枚举值 |
|
|
|
* @return 工作模式文本 |
|
|
|
*/ |
|
|
|
private String getWorkModelText(int workModel) { |
|
|
|
switch (workModel) { |
|
|
|
case 1: |
|
|
|
return "自动模式"; |
|
|
|
case 2: |
|
|
|
return "半自动模式"; |
|
|
|
case 3: |
|
|
|
return "手动模式"; |
|
|
|
case 4: |
|
|
|
return "报警模式"; |
|
|
|
case 5: |
|
|
|
return "维护模式"; |
|
|
|
default: |
|
|
|
return "未定义"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取设备状态文本 |
|
|
|
* |
|
|
|
* @param workStatus 设备状态枚举值 |
|
|
|
* @return 设备状态文本 |
|
|
|
*/ |
|
|
|
private String getWorkStatusText(int workStatus) { |
|
|
|
switch (workStatus) { |
|
|
|
case 1: |
|
|
|
return "空闲"; |
|
|
|
case 2: |
|
|
|
return "取货中"; |
|
|
|
case 3: |
|
|
|
return "RFID检测中"; |
|
|
|
case 4: |
|
|
|
return "放货中"; |
|
|
|
case 5: |
|
|
|
return "等待上位反馈完成"; |
|
|
|
case 6: |
|
|
|
return "等待流线托盘到位"; |
|
|
|
default: |
|
|
|
return "未定义"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 转换机械臂状态为标准状态 |
|
|
|
* |
|
|
|
* @param workModel 工作模式 |
|
|
|
* @param workStatus 设备状态 |
|
|
|
* @return 标准状态 (working/idle/error/maintenance) |
|
|
|
*/ |
|
|
|
private String convertRobotStatus(int workModel, int workStatus) { |
|
|
|
// 报警模式 |
|
|
|
if (workModel == 4) { |
|
|
|
return "error"; |
|
|
|
} |
|
|
|
|
|
|
|
// 维护模式 |
|
|
|
if (workModel == 5) { |
|
|
|
return "maintenance"; |
|
|
|
} |
|
|
|
|
|
|
|
// 根据设备状态判断 |
|
|
|
if (workStatus == 1) { |
|
|
|
return "idle"; // 空闲 |
|
|
|
} else if (workStatus >= 2 && workStatus <= 6) { |
|
|
|
return "working"; // 工作中 |
|
|
|
} |
|
|
|
|
|
|
|
return "idle"; |
|
|
|
} |
|
|
|
} |
|
|
|
|