|
|
|
@ -45,7 +45,7 @@ public class DashboardPushTask { |
|
|
|
|
|
|
|
@Value("${custom.wcs-board-api}") |
|
|
|
private String wcsBoardApi; |
|
|
|
|
|
|
|
|
|
|
|
// 看板推送任务开关配置(所有看板共用一个开关) |
|
|
|
@Value("${dashboard.push.enabled:true}") |
|
|
|
private boolean dashboardPushEnabled; |
|
|
|
@ -69,20 +69,20 @@ public class DashboardPushTask { |
|
|
|
* <li>如果数据变化频繁,可以缩短间隔(如2-3秒)</li> |
|
|
|
* <li>如果数据变化不频繁,可以延长间隔(如10-15秒)</li> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
* |
|
|
|
* <p><b>配置开关:</b></p> |
|
|
|
* <ul> |
|
|
|
* <li>dashboard.push.enabled - 看板推送总开关</li> |
|
|
|
* </ul> |
|
|
|
*/ |
|
|
|
@Scheduled(fixedRate = 5000) |
|
|
|
@Scheduled(fixedRate = 10000) |
|
|
|
public void pushRobotPickingData() { |
|
|
|
// 检查总开关 |
|
|
|
if (!dashboardPushEnabled) { |
|
|
|
log.trace("看板推送已禁用"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
// 从WCS Board API获取机械臂拣选数据 |
|
|
|
Map<String, Object> data = getRobotPickingDataFromWcs(); |
|
|
|
@ -252,14 +252,14 @@ public class DashboardPushTask { |
|
|
|
* <li>view_board_slitting_inbound - 分切入库区数据</li> |
|
|
|
* </ul> |
|
|
|
*/ |
|
|
|
@Scheduled(fixedRate = 5000) |
|
|
|
@Scheduled(fixedRate = 10000) |
|
|
|
public void pushSlittingBoardData() { |
|
|
|
// 检查总开关 |
|
|
|
if (!dashboardPushEnabled) { |
|
|
|
log.trace("看板推送已禁用"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
// 从数据库视图获取分切区数据 |
|
|
|
Map<String, Object> data = getSlittingBoardDataFromDb(); |
|
|
|
@ -358,14 +358,14 @@ public class DashboardPushTask { |
|
|
|
* <li>发货统计 - queryWarehouseShipmentStats</li> |
|
|
|
* </ul> |
|
|
|
*/ |
|
|
|
@Scheduled(fixedRate = 5000) |
|
|
|
@Scheduled(fixedRate = 10000) |
|
|
|
public void pushWarehouse3dBoardData() { |
|
|
|
// 检查总开关 |
|
|
|
if (!dashboardPushEnabled) { |
|
|
|
log.trace("看板推送已禁用"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
// 从数据库获取立体仓库看板数据 |
|
|
|
Map<String, Object> data = getWarehouse3dBoardDataFromDb(); |
|
|
|
@ -447,7 +447,7 @@ public class DashboardPushTask { |
|
|
|
resultData.put("agvData", agvStatus != null ? agvStatus : new ArrayList<>()); |
|
|
|
resultData.put("materialRequestData", materialRequestStats != null ? materialRequestStats : new HashMap<>()); |
|
|
|
resultData.put("shipmentData", shipmentStats != null ? shipmentStats : new HashMap<>()); |
|
|
|
|
|
|
|
|
|
|
|
// 添加库存趋势数据 |
|
|
|
resultData.put("rawMaterialTrend", rawMaterialTrend != null ? rawMaterialTrend : new ArrayList<>()); |
|
|
|
resultData.put("specifiedMaterialTrend", specifiedMaterialTrend != null ? specifiedMaterialTrend : new ArrayList<>()); |
|
|
|
@ -487,7 +487,7 @@ public class DashboardPushTask { |
|
|
|
// 调用WCS Board API |
|
|
|
String url = wcsBoardApi + "WmsDashboard/inventory-stats"; |
|
|
|
log.debug("调用WCS库存统计API: {}", url); |
|
|
|
|
|
|
|
|
|
|
|
String wcsResponse = HttpUtils.doGet(url, null, null); |
|
|
|
log.debug("WCS API返回数据: {}", wcsResponse); |
|
|
|
|
|
|
|
@ -517,36 +517,59 @@ public class DashboardPushTask { |
|
|
|
return createEmptyStorageData(); |
|
|
|
} |
|
|
|
|
|
|
|
// 提取各类托盘数量 |
|
|
|
int flatPallet = materialInventory.has("flatPallet") ? |
|
|
|
// 提取物料盘各类托盘数量 |
|
|
|
int materialFlatPallet = materialInventory.has("flatPallet") ? |
|
|
|
materialInventory.get("flatPallet").asInt() : 0; |
|
|
|
int framePallet = materialInventory.has("framePallet") ? |
|
|
|
int materialFramePallet = materialInventory.has("framePallet") ? |
|
|
|
materialInventory.get("framePallet").asInt() : 0; |
|
|
|
int steelPallet = materialInventory.has("steelPallet") ? |
|
|
|
int materialSteelPallet = materialInventory.has("steelPallet") ? |
|
|
|
materialInventory.get("steelPallet").asInt() : 0; |
|
|
|
|
|
|
|
// 提取空容器库存 |
|
|
|
int emptyContainer = resData.has("emptyContainerInventory") ? |
|
|
|
resData.get("emptyContainerInventory").asInt() : 0; |
|
|
|
|
|
|
|
// 计算总使用库位和利用率 |
|
|
|
int usedSlots = flatPallet + framePallet + steelPallet; |
|
|
|
// 提取空容器各类托盘数量 |
|
|
|
JsonNode emptyContainerInventory = resData.get("emptyContainerInventory"); |
|
|
|
int emptyFlatPallet = 0; |
|
|
|
int emptyFramePallet = 0; |
|
|
|
int emptySteelPallet = 0; |
|
|
|
|
|
|
|
if (emptyContainerInventory != null && !emptyContainerInventory.isNull()) { |
|
|
|
emptyFlatPallet = emptyContainerInventory.has("flatPallet") ? |
|
|
|
emptyContainerInventory.get("flatPallet").asInt() : 0; |
|
|
|
emptyFramePallet = emptyContainerInventory.has("framePallet") ? |
|
|
|
emptyContainerInventory.get("framePallet").asInt() : 0; |
|
|
|
emptySteelPallet = emptyContainerInventory.has("steelPallet") ? |
|
|
|
emptyContainerInventory.get("steelPallet").asInt() : 0; |
|
|
|
} |
|
|
|
|
|
|
|
// 计算总使用库位和利用率(物料盘+空盘) |
|
|
|
int usedSlots = materialFlatPallet + materialFramePallet + materialSteelPallet |
|
|
|
+ emptyFlatPallet + emptyFramePallet + emptySteelPallet; |
|
|
|
int totalSlots = 1960; // 固定值 |
|
|
|
double utilizationRate = totalSlots > 0 ? |
|
|
|
double utilizationRate = totalSlots > 0 ? |
|
|
|
Math.round((double) usedSlots / totalSlots * 1000.0) / 10.0 : 0.0; |
|
|
|
|
|
|
|
// 构造物料盘库存数据 |
|
|
|
Map<String, Object> materialInventoryData = new HashMap<>(); |
|
|
|
materialInventoryData.put("flatPallet", materialFlatPallet+emptyFlatPallet); // 物料盘-平托 |
|
|
|
materialInventoryData.put("framePallet", materialFramePallet+emptyFramePallet); // 物料盘-围框托盘 |
|
|
|
materialInventoryData.put("steelPallet", materialSteelPallet+emptySteelPallet); // 物料盘-钢底托 |
|
|
|
|
|
|
|
// 构造空盘库存数据 |
|
|
|
Map<String, Object> emptyContainerInventoryData = new HashMap<>(); |
|
|
|
emptyContainerInventoryData.put("flatPallet", emptyFlatPallet); // 空盘-平托 |
|
|
|
emptyContainerInventoryData.put("framePallet", emptyFramePallet); // 空盘-围框托盘 |
|
|
|
emptyContainerInventoryData.put("steelPallet", emptySteelPallet); // 空盘-钢底托 |
|
|
|
|
|
|
|
// 构造返回数据 |
|
|
|
Map<String, Object> storageData = new HashMap<>(); |
|
|
|
storageData.put("totalSlots", totalSlots); // 总库位数 |
|
|
|
storageData.put("usedSlots", usedSlots); // 已使用库位数 |
|
|
|
storageData.put("utilizationRate", utilizationRate); // 利用率 |
|
|
|
storageData.put("flatPallet", flatPallet); // 平托 |
|
|
|
storageData.put("guardPallet", framePallet); // 围挡托盘(对应framePallet) |
|
|
|
storageData.put("steelPallet", steelPallet); // 钢托盘 |
|
|
|
storageData.put("otherPallet", emptyContainer); // 其他(空容器) |
|
|
|
storageData.put("totalSlots", totalSlots); // 总库位数 |
|
|
|
storageData.put("usedSlots", usedSlots); // 已使用库位数 |
|
|
|
storageData.put("utilizationRate", utilizationRate); // 利用率 |
|
|
|
storageData.put("materialInventory", materialInventoryData); // 物料盘库存 |
|
|
|
storageData.put("emptyContainerInventory", emptyContainerInventoryData); // 空盘库存 |
|
|
|
|
|
|
|
log.info("库存统计数据获取成功 - 平托:{}, 框架托:{}, 钢托:{}, 空容器:{}, 总使用:{}, 利用率:{}%", |
|
|
|
flatPallet, framePallet, steelPallet, emptyContainer, usedSlots, utilizationRate); |
|
|
|
log.info("库存统计数据获取成功 - 物料盘[平托:{}, 框架托:{}, 钢托:{}], 空盘[平托:{}, 框架托:{}, 钢托:{}], 总使用:{}, 利用率:{}%", |
|
|
|
materialFlatPallet, materialFramePallet, materialSteelPallet, |
|
|
|
emptyFlatPallet, emptyFramePallet, emptySteelPallet, usedSlots, utilizationRate); |
|
|
|
|
|
|
|
return storageData; |
|
|
|
|
|
|
|
@ -562,14 +585,25 @@ public class DashboardPushTask { |
|
|
|
* @return 空的库存统计数据结构 |
|
|
|
*/ |
|
|
|
private Map<String, Object> createEmptyStorageData() { |
|
|
|
// 构造空的物料盘库存数据 |
|
|
|
Map<String, Object> emptyMaterialInventory = new HashMap<>(); |
|
|
|
emptyMaterialInventory.put("flatPallet", 0); |
|
|
|
emptyMaterialInventory.put("framePallet", 0); |
|
|
|
emptyMaterialInventory.put("steelPallet", 0); |
|
|
|
|
|
|
|
// 构造空的空盘库存数据 |
|
|
|
Map<String, Object> emptyContainerInventory = new HashMap<>(); |
|
|
|
emptyContainerInventory.put("flatPallet", 0); |
|
|
|
emptyContainerInventory.put("framePallet", 0); |
|
|
|
emptyContainerInventory.put("steelPallet", 0); |
|
|
|
|
|
|
|
// 构造返回数据 |
|
|
|
Map<String, Object> emptyData = new HashMap<>(); |
|
|
|
emptyData.put("totalSlots", 1960); |
|
|
|
emptyData.put("usedSlots", 0); |
|
|
|
emptyData.put("utilizationRate", 0.0); |
|
|
|
emptyData.put("flatPallet", 0); |
|
|
|
emptyData.put("guardPallet", 0); |
|
|
|
emptyData.put("steelPallet", 0); |
|
|
|
emptyData.put("otherPallet", 0); |
|
|
|
emptyData.put("materialInventory", emptyMaterialInventory); |
|
|
|
emptyData.put("emptyContainerInventory", emptyContainerInventory); |
|
|
|
return emptyData; |
|
|
|
} |
|
|
|
|
|
|
|
@ -747,14 +781,14 @@ public class DashboardPushTask { |
|
|
|
* <li>view_board_finish_inbound - 成品入库区数据</li> |
|
|
|
* </ul> |
|
|
|
*/ |
|
|
|
@Scheduled(fixedRate = 5000) |
|
|
|
@Scheduled(fixedRate = 10000) |
|
|
|
public void pushFinishedProductBoardData() { |
|
|
|
// 检查总开关 |
|
|
|
if (!dashboardPushEnabled) { |
|
|
|
log.trace("看板推送已禁用"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
// 从数据库视图获取成品区数据 |
|
|
|
Map<String, Object> data = getFinishedProductBoardDataFromDb(); |
|
|
|
@ -849,14 +883,14 @@ public class DashboardPushTask { |
|
|
|
* <li>view_board_receiving_inbound - 原材入库区数据</li> |
|
|
|
* </ul> |
|
|
|
*/ |
|
|
|
@Scheduled(fixedRate = 5000) |
|
|
|
@Scheduled(fixedRate = 10000) |
|
|
|
public void pushMaterialReceivingBoardData() { |
|
|
|
// 检查总开关 |
|
|
|
if (!dashboardPushEnabled) { |
|
|
|
log.trace("看板推送已禁用"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
// 从数据库视图获取原材收货区数据 |
|
|
|
Map<String, Object> data = getMaterialReceivingBoardDataFromDb(); |
|
|
|
|