|
|
@ -6,6 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.messaging.simp.SimpMessagingTemplate; |
|
|
import org.springframework.messaging.simp.SimpMessagingTemplate; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
|
import java.util.Date; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -37,6 +39,20 @@ public class DashboardWebSocketService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private SimpMessagingTemplate messagingTemplate; |
|
|
private SimpMessagingTemplate messagingTemplate; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 创建带服务器时间的响应 |
|
|
|
|
|
* |
|
|
|
|
|
* @param data 业务数据 |
|
|
|
|
|
* @return 包含服务器时间的响应 |
|
|
|
|
|
*/ |
|
|
|
|
|
private R createResponseWithServerTime(Map<String, Object> data) { |
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss E"); |
|
|
|
|
|
String serverTime = sdf.format(new Date()); |
|
|
|
|
|
return R.ok() |
|
|
|
|
|
.put("data", data) |
|
|
|
|
|
.put("serverTime", serverTime); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 推送人工拣选看板数据 |
|
|
* 推送人工拣选看板数据 |
|
|
* |
|
|
* |
|
|
@ -46,7 +62,7 @@ public class DashboardWebSocketService { |
|
|
log.debug("推送人工拣选看板数据"); |
|
|
log.debug("推送人工拣选看板数据"); |
|
|
try { |
|
|
try { |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/manual-picking", |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/manual-picking", |
|
|
R.ok().put("data", data)); |
|
|
|
|
|
|
|
|
createResponseWithServerTime(data)); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("推送人工拣选看板数据失败: {}", e.getMessage(), e); |
|
|
log.error("推送人工拣选看板数据失败: {}", e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
@ -63,7 +79,7 @@ public class DashboardWebSocketService { |
|
|
data.get("materialList") != null ? ((java.util.List<?>)data.get("materialList")).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", |
|
|
R.ok().put("data", data)); |
|
|
|
|
|
|
|
|
createResponseWithServerTime(data)); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("推送机械臂拣选看板数据失败: {}", e.getMessage(), e); |
|
|
log.error("推送机械臂拣选看板数据失败: {}", e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
@ -78,7 +94,7 @@ public class DashboardWebSocketService { |
|
|
log.debug("推送分切区看板数据"); |
|
|
log.debug("推送分切区看板数据"); |
|
|
try { |
|
|
try { |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/slitting-board", |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/slitting-board", |
|
|
R.ok().put("data", data)); |
|
|
|
|
|
|
|
|
createResponseWithServerTime(data)); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("推送分切区看板数据失败: {}", e.getMessage(), e); |
|
|
log.error("推送分切区看板数据失败: {}", e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
@ -93,7 +109,7 @@ public class DashboardWebSocketService { |
|
|
log.debug("推送库存分析看板数据"); |
|
|
log.debug("推送库存分析看板数据"); |
|
|
try { |
|
|
try { |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/inventory-board", |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/inventory-board", |
|
|
R.ok().put("data", data)); |
|
|
|
|
|
|
|
|
createResponseWithServerTime(data)); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("推送库存分析看板数据失败: {}", e.getMessage(), e); |
|
|
log.error("推送库存分析看板数据失败: {}", e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
@ -108,7 +124,7 @@ public class DashboardWebSocketService { |
|
|
log.debug("推送成品入库出库区看板数据"); |
|
|
log.debug("推送成品入库出库区看板数据"); |
|
|
try { |
|
|
try { |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/finished-product-board", |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/finished-product-board", |
|
|
R.ok().put("data", data)); |
|
|
|
|
|
|
|
|
createResponseWithServerTime(data)); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("推送成品入库出库区看板数据失败: {}", e.getMessage(), e); |
|
|
log.error("推送成品入库出库区看板数据失败: {}", e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
@ -123,7 +139,7 @@ public class DashboardWebSocketService { |
|
|
log.debug("推送原材收货区看板数据"); |
|
|
log.debug("推送原材收货区看板数据"); |
|
|
try { |
|
|
try { |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/material-receiving-board", |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/material-receiving-board", |
|
|
R.ok().put("data", data)); |
|
|
|
|
|
|
|
|
createResponseWithServerTime(data)); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("推送原材收货区看板数据失败: {}", e.getMessage(), e); |
|
|
log.error("推送原材收货区看板数据失败: {}", e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
@ -138,7 +154,7 @@ public class DashboardWebSocketService { |
|
|
log.debug("推送缓存区看板数据"); |
|
|
log.debug("推送缓存区看板数据"); |
|
|
try { |
|
|
try { |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/buffer-board", |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/buffer-board", |
|
|
R.ok().put("data", data)); |
|
|
|
|
|
|
|
|
createResponseWithServerTime(data)); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("推送缓存区看板数据失败: {}", e.getMessage(), e); |
|
|
log.error("推送缓存区看板数据失败: {}", e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
@ -153,7 +169,7 @@ public class DashboardWebSocketService { |
|
|
log.debug("推送车间AGV放料区看板数据"); |
|
|
log.debug("推送车间AGV放料区看板数据"); |
|
|
try { |
|
|
try { |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/workshop-feeding-board", |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/workshop-feeding-board", |
|
|
R.ok().put("data", data)); |
|
|
|
|
|
|
|
|
createResponseWithServerTime(data)); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("推送车间AGV放料区看板数据失败: {}", e.getMessage(), e); |
|
|
log.error("推送车间AGV放料区看板数据失败: {}", e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
@ -168,7 +184,7 @@ public class DashboardWebSocketService { |
|
|
log.debug("推送异常处理区看板数据"); |
|
|
log.debug("推送异常处理区看板数据"); |
|
|
try { |
|
|
try { |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/exception-board", |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/exception-board", |
|
|
R.ok().put("data", data)); |
|
|
|
|
|
|
|
|
createResponseWithServerTime(data)); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("推送异常处理区看板数据失败: {}", e.getMessage(), e); |
|
|
log.error("推送异常处理区看板数据失败: {}", e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
@ -183,7 +199,7 @@ public class DashboardWebSocketService { |
|
|
log.info("广播推送到所有看板"); |
|
|
log.info("广播推送到所有看板"); |
|
|
try { |
|
|
try { |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/broadcast", |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/broadcast", |
|
|
R.ok().put("data", data)); |
|
|
|
|
|
|
|
|
createResponseWithServerTime(data)); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("广播推送到所有看板失败: {}", e.getMessage(), e); |
|
|
log.error("广播推送到所有看板失败: {}", e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
@ -198,7 +214,7 @@ public class DashboardWebSocketService { |
|
|
log.debug("推送智能立体仓库看板数据"); |
|
|
log.debug("推送智能立体仓库看板数据"); |
|
|
try { |
|
|
try { |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/warehouse-3d", |
|
|
messagingTemplate.convertAndSend("/topic/dashboard/warehouse-3d", |
|
|
R.ok().put("data", data)); |
|
|
|
|
|
|
|
|
createResponseWithServerTime(data)); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("推送智能立体仓库看板数据失败: {}", e.getMessage(), e); |
|
|
log.error("推送智能立体仓库看板数据失败: {}", e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
@ -213,7 +229,9 @@ public class DashboardWebSocketService { |
|
|
public void pushToTopic(String topic, Object data) { |
|
|
public void pushToTopic(String topic, Object data) { |
|
|
log.debug("推送数据到主题: {}", topic); |
|
|
log.debug("推送数据到主题: {}", topic); |
|
|
try { |
|
|
try { |
|
|
messagingTemplate.convertAndSend(topic, R.ok().put("data", data)); |
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss E"); |
|
|
|
|
|
String serverTime = sdf.format(new Date()); |
|
|
|
|
|
messagingTemplate.convertAndSend(topic, R.ok().put("data", data).put("serverTime", serverTime)); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("推送数据到主题{}失败: {}", topic, e.getMessage(), e); |
|
|
log.error("推送数据到主题{}失败: {}", topic, e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
|