Browse Source

去掉log

master
han\hanst 4 weeks ago
parent
commit
d1f6c5e2db
  1. 15
      src/main/java/com/gaotao/modules/dashboard/service/DashboardWebSocketService.java
  2. 168
      src/main/java/com/gaotao/modules/dashboard/task/DashboardPushTask.java

15
src/main/java/com/gaotao/modules/dashboard/service/DashboardWebSocketService.java

@ -59,7 +59,6 @@ public class DashboardWebSocketService {
* @param data 看板数据 * @param data 看板数据
*/ */
public void pushManualPickingData(Map<String, Object> data) { public void pushManualPickingData(Map<String, Object> data) {
log.debug("推送人工拣选看板数据");
try { try {
messagingTemplate.convertAndSend("/topic/dashboard/manual-picking", messagingTemplate.convertAndSend("/topic/dashboard/manual-picking",
createResponseWithServerTime(data)); createResponseWithServerTime(data));
@ -74,9 +73,6 @@ public class DashboardWebSocketService {
* @param data 看板数据 * @param data 看板数据
*/ */
public void pushRobotPickingData(Map<String, Object> data) { public void pushRobotPickingData(Map<String, Object> data) {
log.debug("推送机械臂拣选看板数据: 周转箱{}条, 原材{}条",
data.get("containerList") != null ? ((java.util.List<?>)data.get("containerList")).size() : 0,
data.get("materialList") != null ? ((java.util.List<?>)data.get("materialList")).size() : 0);
try { try {
messagingTemplate.convertAndSend("/topic/dashboard/robot-picking", messagingTemplate.convertAndSend("/topic/dashboard/robot-picking",
createResponseWithServerTime(data)); createResponseWithServerTime(data));
@ -91,7 +87,6 @@ public class DashboardWebSocketService {
* @param data 看板数据 * @param data 看板数据
*/ */
public void pushSlittingBoardData(Map<String, Object> data) { public void pushSlittingBoardData(Map<String, Object> data) {
log.debug("推送分切区看板数据");
try { try {
messagingTemplate.convertAndSend("/topic/dashboard/slitting-board", messagingTemplate.convertAndSend("/topic/dashboard/slitting-board",
createResponseWithServerTime(data)); createResponseWithServerTime(data));
@ -106,7 +101,6 @@ public class DashboardWebSocketService {
* @param data 看板数据 * @param data 看板数据
*/ */
public void pushInventoryBoardData(Map<String, Object> data) { public void pushInventoryBoardData(Map<String, Object> data) {
log.debug("推送库存分析看板数据");
try { try {
messagingTemplate.convertAndSend("/topic/dashboard/inventory-board", messagingTemplate.convertAndSend("/topic/dashboard/inventory-board",
createResponseWithServerTime(data)); createResponseWithServerTime(data));
@ -121,7 +115,6 @@ public class DashboardWebSocketService {
* @param data 看板数据 * @param data 看板数据
*/ */
public void pushFinishedProductBoardData(Map<String, Object> data) { public void pushFinishedProductBoardData(Map<String, Object> data) {
log.debug("推送成品入库出库区看板数据");
try { try {
messagingTemplate.convertAndSend("/topic/dashboard/finished-product-board", messagingTemplate.convertAndSend("/topic/dashboard/finished-product-board",
createResponseWithServerTime(data)); createResponseWithServerTime(data));
@ -136,7 +129,6 @@ public class DashboardWebSocketService {
* @param data 看板数据 * @param data 看板数据
*/ */
public void pushMaterialReceivingBoardData(Map<String, Object> data) { public void pushMaterialReceivingBoardData(Map<String, Object> data) {
log.debug("推送原材收货区看板数据");
try { try {
messagingTemplate.convertAndSend("/topic/dashboard/material-receiving-board", messagingTemplate.convertAndSend("/topic/dashboard/material-receiving-board",
createResponseWithServerTime(data)); createResponseWithServerTime(data));
@ -151,7 +143,6 @@ public class DashboardWebSocketService {
* @param data 看板数据 * @param data 看板数据
*/ */
public void pushBufferBoardData(Map<String, Object> data) { public void pushBufferBoardData(Map<String, Object> data) {
log.debug("推送缓存区看板数据");
try { try {
messagingTemplate.convertAndSend("/topic/dashboard/buffer-board", messagingTemplate.convertAndSend("/topic/dashboard/buffer-board",
createResponseWithServerTime(data)); createResponseWithServerTime(data));
@ -166,7 +157,6 @@ public class DashboardWebSocketService {
* @param data 看板数据 * @param data 看板数据
*/ */
public void pushWorkshopFeedingBoardData(Map<String, Object> data) { public void pushWorkshopFeedingBoardData(Map<String, Object> data) {
log.debug("推送车间AGV放料区看板数据");
try { try {
messagingTemplate.convertAndSend("/topic/dashboard/workshop-feeding-board", messagingTemplate.convertAndSend("/topic/dashboard/workshop-feeding-board",
createResponseWithServerTime(data)); createResponseWithServerTime(data));
@ -181,7 +171,6 @@ public class DashboardWebSocketService {
* @param data 看板数据 * @param data 看板数据
*/ */
public void pushExceptionBoardData(Map<String, Object> data) { public void pushExceptionBoardData(Map<String, Object> data) {
log.debug("推送异常处理区看板数据");
try { try {
messagingTemplate.convertAndSend("/topic/dashboard/exception-board", messagingTemplate.convertAndSend("/topic/dashboard/exception-board",
createResponseWithServerTime(data)); createResponseWithServerTime(data));
@ -196,7 +185,6 @@ public class DashboardWebSocketService {
* @param data 看板数据 * @param data 看板数据
*/ */
public void broadcastToAllDashboards(Map<String, Object> data) { public void broadcastToAllDashboards(Map<String, Object> data) {
log.info("广播推送到所有看板");
try { try {
messagingTemplate.convertAndSend("/topic/dashboard/broadcast", messagingTemplate.convertAndSend("/topic/dashboard/broadcast",
createResponseWithServerTime(data)); createResponseWithServerTime(data));
@ -211,7 +199,6 @@ public class DashboardWebSocketService {
* @param data 看板数据 * @param data 看板数据
*/ */
public void pushWarehouse3dBoardData(Map<String, Object> data) { public void pushWarehouse3dBoardData(Map<String, Object> data) {
log.debug("推送智能立体仓库看板数据");
try { try {
messagingTemplate.convertAndSend("/topic/dashboard/warehouse-3d", messagingTemplate.convertAndSend("/topic/dashboard/warehouse-3d",
createResponseWithServerTime(data)); createResponseWithServerTime(data));
@ -227,7 +214,6 @@ public class DashboardWebSocketService {
* @param data 数据 * @param data 数据
*/ */
public void pushToTopic(String topic, Object data) { public void pushToTopic(String topic, Object data) {
log.debug("推送数据到主题: {}", topic);
try { try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss E"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss E");
String serverTime = sdf.format(new Date()); String serverTime = sdf.format(new Date());
@ -237,4 +223,3 @@ public class DashboardWebSocketService {
} }
} }
} }

168
src/main/java/com/gaotao/modules/dashboard/task/DashboardPushTask.java

@ -1,6 +1,5 @@
package com.gaotao.modules.dashboard.task; package com.gaotao.modules.dashboard.task;
import com.beust.ah.A;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.gaotao.common.utils.HttpUtils; import com.gaotao.common.utils.HttpUtils;
@ -8,7 +7,6 @@ import com.gaotao.modules.automatedWarehouse.entity.tusk.AgvStatus;
import com.gaotao.modules.automatedWarehouse.entity.tusk.TuskResponse; import com.gaotao.modules.automatedWarehouse.entity.tusk.TuskResponse;
import com.gaotao.modules.automatedWarehouse.service.TuskClientService; import com.gaotao.modules.automatedWarehouse.service.TuskClientService;
import com.gaotao.modules.dashboard.service.DashboardWebSocketService; import com.gaotao.modules.dashboard.service.DashboardWebSocketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@ -32,13 +30,12 @@ import java.util.*;
* <ul> * <ul>
* <li>每5秒检查一次机械臂拣选数据</li> * <li>每5秒检查一次机械臂拣选数据</li>
* <li>数据有变化时立即推送</li> * <li>数据有变化时立即推送</li>
* <li>推送失败时记录日志,不影响下次推送</li>
* <li>推送失败不影响下次推送</li>
* </ul> * </ul>
* *
* @author System * @author System
* @since 2025-01-23 * @since 2025-01-23
*/ */
@Slf4j
@Component @Component
public class DashboardPushTask { public class DashboardPushTask {
@ -95,13 +92,10 @@ public class DashboardPushTask {
public void pushManualPickingData() { public void pushManualPickingData() {
// 检查总开关 // 检查总开关
if (!dashboardPushEnabled) { if (!dashboardPushEnabled) {
log.trace("看板推送已禁用");
return; return;
} }
try { try {
log.debug("=== 开始获取人工拣选看板数据 ===");
// 从WCS获取人工拣选数据 // 从WCS获取人工拣选数据
Map<String, Object> data = getManualPickingDataFromWcs(); Map<String, Object> data = getManualPickingDataFromWcs();
@ -115,17 +109,14 @@ public class DashboardPushTask {
webSocketService.pushManualPickingData(data); webSocketService.pushManualPickingData(data);
lastDataHash.put("manual-picking", currentHash); lastDataHash.put("manual-picking", currentHash);
log.debug("=== 人工拣选数据推送完成 ===");
} catch (Exception e) {
log.error("推送人工拣选数据失败,推送空数据清空前端列表: {}", e.getMessage(), e);
} catch (Exception ignored) {
// 异常时推送空数据,避免前端显示过期数据 // 异常时推送空数据,避免前端显示过期数据
try { try {
Map<String, Object> emptyData = createEmptyManualPickingData(); Map<String, Object> emptyData = createEmptyManualPickingData();
webSocketService.pushManualPickingData(emptyData); webSocketService.pushManualPickingData(emptyData);
lastDataHash.put("manual-picking", emptyData.hashCode()); lastDataHash.put("manual-picking", emptyData.hashCode());
} catch (Exception ex) {
log.error("推送空数据失败: {}", ex.getMessage());
} catch (Exception ignoredPush) {
// 空数据推送失败不影响后续推送
} }
} }
} }
@ -141,27 +132,19 @@ public class DashboardPushTask {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
// 请求1043站数据 // 请求1043站数据
log.info("调用WCS人工拣选API (1043站): {}", url);
List<Map<String, Object>> station1043List = getStationData(url, "1043", mapper); List<Map<String, Object>> station1043List = getStationData(url, "1043", mapper);
log.info("1043站数据获取完成: {}条", station1043List.size());
// 请求1028站数据 // 请求1028站数据
log.info("调用WCS人工拣选API (1028站): {}", url);
List<Map<String, Object>> station1028List = getStationData(url, "1028", mapper); List<Map<String, Object>> station1028List = getStationData(url, "1028", mapper);
log.info("1028站数据获取完成: {}条", station1028List.size());
// 构造返回数据 // 构造返回数据
Map<String, Object> resultData = new HashMap<>(); Map<String, Object> resultData = new HashMap<>();
resultData.put("station1043List", station1043List); resultData.put("station1043List", station1043List);
resultData.put("station1028List", station1028List); resultData.put("station1028List", station1028List);
log.info("=== 人工拣选数据处理完成 === 1043站:{}条, 1028站:{}条",
station1043List.size(), station1028List.size());
return resultData; return resultData;
} catch (Exception e) {
log.error("从WCS获取人工拣选数据失败: {}", e.getMessage(), e);
} catch (Exception ignored) {
return null; return null;
} }
} }
@ -182,14 +165,12 @@ public class DashboardPushTask {
String jsonBody = "\"" + devCode + "\""; String jsonBody = "\"" + devCode + "\"";
String wcsResponse = HttpUtils.doPost(url, jsonBody, null); String wcsResponse = HttpUtils.doPost(url, jsonBody, null);
log.debug("WCS API返回数据 ({}站): {}", devCode, wcsResponse);
// 解析JSON数据 // 解析JSON数据
JsonNode rootNode = mapper.readTree(wcsResponse); JsonNode rootNode = mapper.readTree(wcsResponse);
// 获取sortingStations数组 // 获取sortingStations数组
if (!rootNode.has("sortingStations")) { if (!rootNode.has("sortingStations")) {
log.warn("WCS返回数据中没有sortingStations ({}站)", devCode);
return stationList; return stationList;
} }
@ -208,8 +189,8 @@ public class DashboardPushTask {
} }
} }
} catch (Exception e) {
log.error("获取{}站数据失败: {}", devCode, e.getMessage(), e);
} catch (Exception ignored) {
// 单次采集失败返回已有结果,避免中断整页看板推送
} }
return stationList; return stationList;
@ -283,7 +264,6 @@ public class DashboardPushTask {
public void pushRobotPickingData() { public void pushRobotPickingData() {
// 检查总开关 // 检查总开关
if (!dashboardPushEnabled) { if (!dashboardPushEnabled) {
log.trace("看板推送已禁用");
return; return;
} }
@ -301,15 +281,14 @@ public class DashboardPushTask {
webSocketService.pushRobotPickingData(data); webSocketService.pushRobotPickingData(data);
lastDataHash.put("robot-picking", currentHash); lastDataHash.put("robot-picking", currentHash);
} catch (Exception e) {
log.error("推送机械臂拣选数据失败,推送空数据清空前端列表: {}", e.getMessage(), e);
} catch (Exception ignored) {
// 异常时推送空数据,避免前端显示过期数据 // 异常时推送空数据,避免前端显示过期数据
try { try {
Map<String, Object> emptyData = createEmptyData(); Map<String, Object> emptyData = createEmptyData();
webSocketService.pushRobotPickingData(emptyData); webSocketService.pushRobotPickingData(emptyData);
lastDataHash.put("robot-picking", emptyData.hashCode()); lastDataHash.put("robot-picking", emptyData.hashCode());
} catch (Exception ex) {
log.error("推送空数据失败: {}", ex.getMessage());
} catch (Exception ignoredPush) {
// 空数据推送失败不影响后续推送
} }
} }
} }
@ -332,14 +311,12 @@ public class DashboardPushTask {
// 检查返回码 // 检查返回码
int resCode = rootNode.get("resCode").asInt(); int resCode = rootNode.get("resCode").asInt();
if (resCode != 200) { if (resCode != 200) {
log.warn("WCS API返回错误: code={}", resCode);
return null; return null;
} }
// 获取sortingStations数组 // 获取sortingStations数组
JsonNode resData = rootNode.get("resData"); JsonNode resData = rootNode.get("resData");
if (resData == null || !resData.has("sortingStations")) { if (resData == null || !resData.has("sortingStations")) {
log.warn("WCS返回数据中没有sortingStations");
return createEmptyData(); return createEmptyData();
} }
@ -374,8 +351,7 @@ public class DashboardPushTask {
return resultData; return resultData;
} catch (Exception e) {
log.error("从WCS获取机械臂拣选数据失败: {}", e.getMessage());
} catch (Exception ignored) {
return null; return null;
} }
} }
@ -460,7 +436,6 @@ public class DashboardPushTask {
public void pushSlittingBoardData() { public void pushSlittingBoardData() {
// 检查总开关 // 检查总开关
if (!dashboardPushEnabled) { if (!dashboardPushEnabled) {
log.trace("看板推送已禁用");
return; return;
} }
@ -478,15 +453,14 @@ public class DashboardPushTask {
webSocketService.pushSlittingBoardData(data); webSocketService.pushSlittingBoardData(data);
lastDataHash.put("slitting-board", currentHash); lastDataHash.put("slitting-board", currentHash);
} catch (Exception e) {
log.error("推送分切区看板数据失败,推送空数据清空前端列表: {}", e.getMessage(), e);
} catch (Exception ignored) {
// 异常时推送空数据,避免前端显示过期数据 // 异常时推送空数据,避免前端显示过期数据
try { try {
Map<String, Object> emptyData = createEmptySlittingData(); Map<String, Object> emptyData = createEmptySlittingData();
webSocketService.pushSlittingBoardData(emptyData); webSocketService.pushSlittingBoardData(emptyData);
lastDataHash.put("slitting-board", emptyData.hashCode()); lastDataHash.put("slitting-board", emptyData.hashCode());
} catch (Exception ex) {
log.error("推送空数据失败: {}", ex.getMessage());
} catch (Exception ignoredPush) {
// 空数据推送失败不影响后续推送
} }
} }
} }
@ -500,11 +474,9 @@ public class DashboardPushTask {
try { try {
// 查询助力臂区数据 // 查询助力臂区数据
List<Map<String, Object>> assistArmList = dashboardDao.querySlittingAssistArmData(); List<Map<String, Object>> assistArmList = dashboardDao.querySlittingAssistArmData();
log.debug("查询到助力臂区数据: {}条", assistArmList != null ? assistArmList.size() : 0);
// 查询分切入库区数据 // 查询分切入库区数据
List<Map<String, Object>> inboundList = dashboardDao.querySlittingInboundData(); List<Map<String, Object>> inboundList = dashboardDao.querySlittingInboundData();
log.debug("查询到分切入库区数据: {}条", inboundList != null ? inboundList.size() : 0);
// 构造返回数据 // 构造返回数据
Map<String, Object> resultData = new HashMap<>(); Map<String, Object> resultData = new HashMap<>();
@ -513,8 +485,7 @@ public class DashboardPushTask {
return resultData; return resultData;
} catch (Exception e) {
log.error("从数据库获取分切区看板数据失败: {}", e.getMessage(), e);
} catch (Exception ignored) {
return null; return null;
} }
} }
@ -558,7 +529,6 @@ public class DashboardPushTask {
public void refreshWarehouseInventoryTrendCache() { public void refreshWarehouseInventoryTrendCache() {
// 检查总开关 // 检查总开关
if (!dashboardPushEnabled) { if (!dashboardPushEnabled) {
log.trace("看板推送已禁用,跳过库存趋势缓存刷新");
return; return;
} }
@ -572,11 +542,8 @@ public class DashboardPushTask {
specifiedMaterialTrendCache = specifiedMaterialTrend != null ? new ArrayList<>(specifiedMaterialTrend) : Collections.emptyList(); specifiedMaterialTrendCache = specifiedMaterialTrend != null ? new ArrayList<>(specifiedMaterialTrend) : Collections.emptyList();
finishedGoodsTrendCache = finishedGoodsTrend != null ? new ArrayList<>(finishedGoodsTrend) : Collections.emptyList(); finishedGoodsTrendCache = finishedGoodsTrend != null ? new ArrayList<>(finishedGoodsTrend) : Collections.emptyList();
log.info("刷新库存趋势缓存完成: 原材料{}条, 规格料{}条, 产成品{}条",
rawMaterialTrendCache.size(), specifiedMaterialTrendCache.size(), finishedGoodsTrendCache.size());
} catch (Exception e) {
} catch (Exception ignored) {
// 刷新失败时保留上一次成功数据,避免看板趋势瞬间被清空 // 刷新失败时保留上一次成功数据,避免看板趋势瞬间被清空
log.error("刷新库存趋势缓存失败,沿用上次缓存数据: {}", e.getMessage(), e);
} }
} }
@ -597,7 +564,6 @@ public class DashboardPushTask {
public void pushWarehouse3dBoardData() { public void pushWarehouse3dBoardData() {
// 检查总开关 // 检查总开关
if (!dashboardPushEnabled) { if (!dashboardPushEnabled) {
log.trace("看板推送已禁用");
return; return;
} }
@ -615,15 +581,14 @@ public class DashboardPushTask {
webSocketService.pushWarehouse3dBoardData(data); webSocketService.pushWarehouse3dBoardData(data);
lastDataHash.put("warehouse-3d", currentHash); lastDataHash.put("warehouse-3d", currentHash);
} catch (Exception e) {
log.error("推送智能立体仓库看板数据失败,推送空数据: {}", e.getMessage(), e);
} catch (Exception ignored) {
// 异常时推送空数据,避免前端显示过期数据 // 异常时推送空数据,避免前端显示过期数据
try { try {
Map<String, Object> emptyData = createEmptyWarehouse3dData(); Map<String, Object> emptyData = createEmptyWarehouse3dData();
webSocketService.pushWarehouse3dBoardData(emptyData); webSocketService.pushWarehouse3dBoardData(emptyData);
lastDataHash.put("warehouse-3d", emptyData.hashCode()); lastDataHash.put("warehouse-3d", emptyData.hashCode());
} catch (Exception ex) {
log.error("推送空数据失败: {}", ex.getMessage());
} catch (Exception ignoredPush) {
// 空数据推送失败不影响后续推送
} }
} }
} }
@ -635,40 +600,30 @@ public class DashboardPushTask {
*/ */
private Map<String, Object> getWarehouse3dBoardDataFromDb() { private Map<String, Object> getWarehouse3dBoardDataFromDb() {
try { try {
log.debug("开始从数据库获取智能立体仓库看板数据");
// 查询任务统计数据 // 查询任务统计数据
Map<String, Object> taskStats = dashboardDao.queryWarehouseTaskStats(); Map<String, Object> taskStats = dashboardDao.queryWarehouseTaskStats();
log.debug("任务统计数据: {}", taskStats);
// 查询库位利用率数据(从WCS Board API获取) // 查询库位利用率数据(从WCS Board API获取)
Map<String, Object> storageUtilization = getInventoryStatsFromWcs(); Map<String, Object> storageUtilization = getInventoryStatsFromWcs();
log.debug("库位利用率数据: {}", storageUtilization);
// 查询机器人状态数据(从WMS Dashboard API获取) // 查询机器人状态数据(从WMS Dashboard API获取)
List<Map<String, Object>> robotStatus = getRobotSortingInfoFromWms(); List<Map<String, Object>> robotStatus = getRobotSortingInfoFromWms();
log.debug("查询到机器人状态数据: {}条", robotStatus != null ? robotStatus.size() : 0);
// 查询AGV状态数据(从TUSK系统获取) // 查询AGV状态数据(从TUSK系统获取)
List<Map<String, Object>> agvStatus = getAgvStatusFromTusk(); List<Map<String, Object>> agvStatus = getAgvStatusFromTusk();
log.debug("查询到AGV状态数据: {}条", agvStatus != null ? agvStatus.size() : 0);
// 查询领料申请单统计 // 查询领料申请单统计
//Map<String, Object> materialRequestStats = dashboardDao.queryWarehouseMaterialRequestStats(); //Map<String, Object> materialRequestStats = dashboardDao.queryWarehouseMaterialRequestStats();
Map<String, Object> materialRequestStats = new HashMap<>(); Map<String, Object> materialRequestStats = new HashMap<>();
log.debug("领料申请单统计: {}", materialRequestStats);
// 查询发货统计 // 查询发货统计
//Map<String, Object> shipmentStats = dashboardDao.queryWarehouseShipmentStats(); //Map<String, Object> shipmentStats = dashboardDao.queryWarehouseShipmentStats();
Map<String, Object> shipmentStats = new HashMap<>(); Map<String, Object> shipmentStats = new HashMap<>();
log.debug("发货统计: {}", shipmentStats);
// 使用小时级任务刷新后的库存趋势缓存,避免10秒推送高频查库 // 使用小时级任务刷新后的库存趋势缓存,避免10秒推送高频查库
List<Map<String, Object>> rawMaterialTrend = new ArrayList<>(rawMaterialTrendCache); List<Map<String, Object>> rawMaterialTrend = new ArrayList<>(rawMaterialTrendCache);
List<Map<String, Object>> specifiedMaterialTrend = new ArrayList<>(specifiedMaterialTrendCache); List<Map<String, Object>> specifiedMaterialTrend = new ArrayList<>(specifiedMaterialTrendCache);
List<Map<String, Object>> finishedGoodsTrend = new ArrayList<>(finishedGoodsTrendCache); List<Map<String, Object>> finishedGoodsTrend = new ArrayList<>(finishedGoodsTrendCache);
log.debug("使用库存趋势缓存数据: 原材料{}条, 规格料{}条, 产成品{}条",
rawMaterialTrend.size(), specifiedMaterialTrend.size(), finishedGoodsTrend.size());
// 构造返回数据 // 构造返回数据
Map<String, Object> resultData = new HashMap<>(); Map<String, Object> resultData = new HashMap<>();
@ -684,11 +639,9 @@ public class DashboardPushTask {
resultData.put("specifiedMaterialTrend", specifiedMaterialTrend != null ? specifiedMaterialTrend : new ArrayList<>()); resultData.put("specifiedMaterialTrend", specifiedMaterialTrend != null ? specifiedMaterialTrend : new ArrayList<>());
resultData.put("finishedGoodsTrend", finishedGoodsTrend != null ? finishedGoodsTrend : new ArrayList<>()); resultData.put("finishedGoodsTrend", finishedGoodsTrend != null ? finishedGoodsTrend : new ArrayList<>());
log.debug("智能立体仓库看板数据组装完成");
return resultData; return resultData;
} catch (Exception e) {
log.error("从数据库获取智能立体仓库看板数据失败: {}", e.getMessage(), e);
} catch (Exception ignored) {
return null; return null;
} }
} }
@ -717,10 +670,8 @@ public class DashboardPushTask {
try { try {
// 调用WCS Board API // 调用WCS Board API
String url = wcsBoardApi + "WmsDashboard/inventory-stats"; String url = wcsBoardApi + "WmsDashboard/inventory-stats";
log.debug("调用WCS库存统计API: {}", url);
String wcsResponse = HttpUtils.doGet(url, null, null); String wcsResponse = HttpUtils.doGet(url, null, null);
log.debug("WCS API返回数据: {}", wcsResponse);
// 解析JSON数据 // 解析JSON数据
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
@ -729,22 +680,18 @@ public class DashboardPushTask {
// 检查返回码 // 检查返回码
int resCode = rootNode.get("resCode").asInt(); int resCode = rootNode.get("resCode").asInt();
if (resCode != 200) { if (resCode != 200) {
String resMsg = rootNode.has("resMsg") ? rootNode.get("resMsg").asText() : "未知错误";
log.warn("WCS API返回错误: code={}, msg={}", resCode, resMsg);
return createEmptyStorageData(); return createEmptyStorageData();
} }
// 获取resData数据 // 获取resData数据
JsonNode resData = rootNode.get("resData"); JsonNode resData = rootNode.get("resData");
if (resData == null || resData.isNull()) { if (resData == null || resData.isNull()) {
log.warn("WCS返回数据中没有resData");
return createEmptyStorageData(); return createEmptyStorageData();
} }
// 获取materialInventory(物料库存) // 获取materialInventory(物料库存)
JsonNode materialInventory = resData.get("materialInventory"); JsonNode materialInventory = resData.get("materialInventory");
if (materialInventory == null || materialInventory.isNull()) { if (materialInventory == null || materialInventory.isNull()) {
log.warn("WCS返回数据中没有materialInventory");
return createEmptyStorageData(); return createEmptyStorageData();
} }
@ -809,14 +756,9 @@ public class DashboardPushTask {
storageData.put("materialInventory", materialInventoryData); // 物料盘库存 storageData.put("materialInventory", materialInventoryData); // 物料盘库存
storageData.put("emptyContainerInventory", emptyContainerInventoryData); // 空盘库存 storageData.put("emptyContainerInventory", emptyContainerInventoryData); // 空盘库存
log.info("库存统计数据获取成功 - 物料盘[平托:{}, 框架托:{}, 钢托:{}], 空盘[平托:{}, 框架托:{}, 钢托:{}], 总使用:{}, 利用率:{}%",
materialFlatPallet, materialFramePallet, materialSteelPallet,
emptyFlatPallet, emptyFramePallet, emptySteelPallet, usedSlots, utilizationRate);
return storageData; return storageData;
} catch (Exception e) {
log.error("从WCS获取库存统计数据失败: {}", e.getMessage(), e);
} catch (Exception ignored) {
return createEmptyStorageData(); return createEmptyStorageData();
} }
} }
@ -905,7 +847,6 @@ public class DashboardPushTask {
try { try {
// 如果TUSK客户端服务未配置,返回空列表 // 如果TUSK客户端服务未配置,返回空列表
if (tuskClientService == null) { if (tuskClientService == null) {
log.debug("TUSK客户端服务未配置,跳过AGV状态查询");
return agvList; return agvList;
} }
@ -913,7 +854,6 @@ public class DashboardPushTask {
TuskResponse<List<AgvStatus>> response = tuskClientService.getOnlineRobots(); TuskResponse<List<AgvStatus>> response = tuskClientService.getOnlineRobots();
if (!response.isSuccess() || response.getData() == null) { if (!response.isSuccess() || response.getData() == null) {
log.warn("从TUSK获取AGV状态失败: {}", response.getMsg());
return agvList; return agvList;
} }
@ -941,10 +881,8 @@ public class DashboardPushTask {
agvList.add(agv); agvList.add(agv);
} }
log.debug("成功从TUSK获取{}个AGV状态", agvList.size());
} catch (Exception e) {
log.error("从TUSK获取AGV状态异常: {}", e.getMessage(), e);
} catch (Exception ignored) {
// 单次采集失败返回已有结果,避免中断整页看板推送
} }
return agvList; return agvList;
@ -1027,7 +965,6 @@ public class DashboardPushTask {
public void pushFinishedProductBoardData() { public void pushFinishedProductBoardData() {
// 检查总开关 // 检查总开关
if (!dashboardPushEnabled) { if (!dashboardPushEnabled) {
log.trace("看板推送已禁用");
return; return;
} }
@ -1045,15 +982,14 @@ public class DashboardPushTask {
webSocketService.pushFinishedProductBoardData(data); webSocketService.pushFinishedProductBoardData(data);
lastDataHash.put("finished-product", currentHash); lastDataHash.put("finished-product", currentHash);
} catch (Exception e) {
log.error("推送成品入库出库区看板数据失败,推送空数据清空前端列表: {}", e.getMessage(), e);
} catch (Exception ignored) {
// 异常时推送空数据,避免前端显示过期数据 // 异常时推送空数据,避免前端显示过期数据
try { try {
Map<String, Object> emptyData = createEmptyFinishedProductData(); Map<String, Object> emptyData = createEmptyFinishedProductData();
webSocketService.pushFinishedProductBoardData(emptyData); webSocketService.pushFinishedProductBoardData(emptyData);
lastDataHash.put("finished-product", emptyData.hashCode()); lastDataHash.put("finished-product", emptyData.hashCode());
} catch (Exception ex) {
log.error("推送空数据失败: {}", ex.getMessage());
} catch (Exception ignoredPush) {
// 空数据推送失败不影响后续推送
} }
} }
} }
@ -1067,11 +1003,9 @@ public class DashboardPushTask {
try { try {
// 查询成品包装区数据 // 查询成品包装区数据
List<Map<String, Object>> packageList = dashboardDao.queryFinishPackageData(); List<Map<String, Object>> packageList = dashboardDao.queryFinishPackageData();
log.debug("查询到成品包装区数据: {}条", packageList != null ? packageList.size() : 0);
// 查询成品入库区数据 // 查询成品入库区数据
List<Map<String, Object>> inboundList = dashboardDao.queryFinishInboundData(); List<Map<String, Object>> inboundList = dashboardDao.queryFinishInboundData();
log.debug("查询到成品入库区数据: {}条", inboundList != null ? inboundList.size() : 0);
// 构造返回数据 // 构造返回数据
Map<String, Object> resultData = new HashMap<>(); Map<String, Object> resultData = new HashMap<>();
@ -1080,8 +1014,7 @@ public class DashboardPushTask {
return resultData; return resultData;
} catch (Exception e) {
log.error("从数据库获取成品入库出库区看板数据失败: {}", e.getMessage(), e);
} catch (Exception ignored) {
return null; return null;
} }
} }
@ -1129,7 +1062,6 @@ public class DashboardPushTask {
public void pushMaterialReceivingBoardData() { public void pushMaterialReceivingBoardData() {
// 检查总开关 // 检查总开关
if (!dashboardPushEnabled) { if (!dashboardPushEnabled) {
log.trace("看板推送已禁用");
return; return;
} }
@ -1147,15 +1079,14 @@ public class DashboardPushTask {
webSocketService.pushMaterialReceivingBoardData(data); webSocketService.pushMaterialReceivingBoardData(data);
lastDataHash.put("material-receiving", currentHash); lastDataHash.put("material-receiving", currentHash);
} catch (Exception e) {
log.error("推送原材收货区看板数据失败,推送空数据清空前端列表: {}", e.getMessage(), e);
} catch (Exception ignored) {
// 异常时推送空数据,避免前端显示过期数据 // 异常时推送空数据,避免前端显示过期数据
try { try {
Map<String, Object> emptyData = createEmptyMaterialReceivingData(); Map<String, Object> emptyData = createEmptyMaterialReceivingData();
webSocketService.pushMaterialReceivingBoardData(emptyData); webSocketService.pushMaterialReceivingBoardData(emptyData);
lastDataHash.put("material-receiving", emptyData.hashCode()); lastDataHash.put("material-receiving", emptyData.hashCode());
} catch (Exception ex) {
log.error("推送空数据失败: {}", ex.getMessage());
} catch (Exception ignoredPush) {
// 空数据推送失败不影响后续推送
} }
} }
} }
@ -1169,11 +1100,9 @@ public class DashboardPushTask {
try { try {
// 查询原材收货区数据 // 查询原材收货区数据
List<Map<String, Object>> receiveList = dashboardDao.queryReceivingReceiveData(); List<Map<String, Object>> receiveList = dashboardDao.queryReceivingReceiveData();
log.debug("查询到原材收货区数据: {}条", receiveList != null ? receiveList.size() : 0);
// 查询原材入库区数据 // 查询原材入库区数据
List<Map<String, Object>> inboundList = dashboardDao.queryReceivingInboundData(); List<Map<String, Object>> inboundList = dashboardDao.queryReceivingInboundData();
log.debug("查询到原材入库区数据: {}条", inboundList != null ? inboundList.size() : 0);
// 构造返回数据 // 构造返回数据
Map<String, Object> resultData = new HashMap<>(); Map<String, Object> resultData = new HashMap<>();
@ -1182,8 +1111,7 @@ public class DashboardPushTask {
return resultData; return resultData;
} catch (Exception e) {
log.error("从数据库获取原材收货区看板数据失败: {}", e.getMessage(), e);
} catch (Exception ignored) {
return null; return null;
} }
} }
@ -1237,10 +1165,8 @@ public class DashboardPushTask {
try { try {
// 调用WMS Dashboard API(使用配置文件中的URL) // 调用WMS Dashboard API(使用配置文件中的URL)
String url = wcsBoardApi + "WmsDashboard/robot-sorting-info"; String url = wcsBoardApi + "WmsDashboard/robot-sorting-info";
log.debug("调用WMS机械臂分拣API: {}", url);
String wmsResponse = HttpUtils.doGet(url, null, null); String wmsResponse = HttpUtils.doGet(url, null, null);
log.debug("WMS API返回数据: {}", wmsResponse);
// 解析JSON数据 // 解析JSON数据
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
@ -1249,20 +1175,16 @@ public class DashboardPushTask {
// 检查返回码 // 检查返回码
int resCode = rootNode.get("resCode").asInt(); int resCode = rootNode.get("resCode").asInt();
if (resCode != 200) { if (resCode != 200) {
String resMsg = rootNode.has("resMsg") ? rootNode.get("resMsg").asText() : "未知错误";
log.warn("WMS机械臂分拣API返回错误: code={}, msg={}", resCode, resMsg);
return robotList; return robotList;
} }
// 获取resData.sortingStations数组 // 获取resData.sortingStations数组
if (!rootNode.has("resData") || !rootNode.get("resData").has("sortingStations")) { if (!rootNode.has("resData") || !rootNode.get("resData").has("sortingStations")) {
log.warn("WMS返回数据中没有sortingStations");
return robotList; return robotList;
} }
JsonNode sortingStations = rootNode.get("resData").get("sortingStations"); JsonNode sortingStations = rootNode.get("resData").get("sortingStations");
if (!sortingStations.isArray()) { if (!sortingStations.isArray()) {
log.warn("sortingStations不是数组格式");
return robotList; return robotList;
} }
@ -1307,10 +1229,8 @@ public class DashboardPushTask {
robotList.add(robot); robotList.add(robot);
} }
log.info("从WMS获取到{}个机械臂分拣站状态", robotList.size());
} catch (Exception e) {
log.error("从WMS获取机械臂分拣数据失败", e);
} catch (Exception ignored) {
// 单次采集失败返回已有结果,避免中断整页看板推送
} }
return robotList; return robotList;
@ -1412,7 +1332,6 @@ public class DashboardPushTask {
public void pushExceptionBoardData() { public void pushExceptionBoardData() {
// 检查总开关 // 检查总开关
if (!dashboardPushEnabled) { if (!dashboardPushEnabled) {
log.trace("看板推送已禁用");
return; return;
} }
@ -1430,15 +1349,14 @@ public class DashboardPushTask {
webSocketService.pushExceptionBoardData(data); webSocketService.pushExceptionBoardData(data);
lastDataHash.put("exception-board", currentHash); lastDataHash.put("exception-board", currentHash);
} catch (Exception e) {
log.error("推送异常看板数据失败,推送空数据: {}", e.getMessage(), e);
} catch (Exception ignored) {
// 异常时推送空数据,避免前端显示过期数据 // 异常时推送空数据,避免前端显示过期数据
try { try {
Map<String, Object> emptyData = createEmptyExceptionData(); Map<String, Object> emptyData = createEmptyExceptionData();
webSocketService.pushExceptionBoardData(emptyData); webSocketService.pushExceptionBoardData(emptyData);
lastDataHash.put("exception-board", emptyData.hashCode()); lastDataHash.put("exception-board", emptyData.hashCode());
} catch (Exception ex) {
log.error("推送空数据失败: {}", ex.getMessage());
} catch (Exception ignoredPush) {
// 空数据推送失败不影响后续推送
} }
} }
} }
@ -1461,12 +1379,10 @@ public class DashboardPushTask {
try { try {
// 调用WMS异常查询API // 调用WMS异常查询API
String url = wcsUrl + "query-task-error-info"; String url = wcsUrl + "query-task-error-info";
log.debug("调用WMS异常查询API: {}", url);
// 构造POST请求参数 - 传入设备编码1101 // 构造POST请求参数 - 传入设备编码1101
String jsonBody = "\"1101\""; String jsonBody = "\"1101\"";
String wmsResponse = HttpUtils.doPost(url, jsonBody, null); String wmsResponse = HttpUtils.doPost(url, jsonBody, null);
log.debug("WMS API返回数据: {}", wmsResponse);
// 解析JSON数据 // 解析JSON数据
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
@ -1475,7 +1391,6 @@ public class DashboardPushTask {
// 检查返回码 // 检查返回码
int resCode = rootNode.get("resCode").asInt(); int resCode = rootNode.get("resCode").asInt();
if (resCode != 200) { if (resCode != 200) {
log.warn("WMS异常查询API返回错误: code={}", resCode);
return createExceptionBoardData(exceptionList); return createExceptionBoardData(exceptionList);
} }
@ -1488,14 +1403,10 @@ public class DashboardPushTask {
if (exception != null) { if (exception != null) {
exceptionList.add(exception); exceptionList.add(exception);
} }
} else {
log.debug("WMS返回无异常信息: {}", resMsg);
} }
log.info("从WMS获取到{}条异常数据", exceptionList.size());
} catch (Exception e) {
log.error("从WMS获取异常数据失败", e);
} catch (Exception ignored) {
// 单次采集失败返回已有结果,避免中断整页看板推送
} }
return createExceptionBoardData(exceptionList); return createExceptionBoardData(exceptionList);
@ -1565,8 +1476,7 @@ public class DashboardPushTask {
return exception; return exception;
} catch (Exception e) {
log.error("解析异常消息失败: {}", resMsg, e);
} catch (Exception ignored) {
return null; return null;
} }
} }

Loading…
Cancel
Save