.gitignore | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
north-glass-erp/northglass-erp/src/views/pp/glassOptimize/RectRenderer.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
north-glass-erp/src/main/java/com/example/erp/common/RabbitMQUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
.gitignore
@@ -11,10 +11,10 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* # Ignore .idea files **/.idea/ # Ignore .idea files**/.idea/ ../idea/* **/target/ /north-glass-erp/erp.iml /north-glass-erp/src/main /north-glass-erp/src/test/test.iml north-glass-erp/northglass-erp/src/views/pp/glassOptimize/RectRenderer.vue
@@ -1,19 +1,26 @@ <template> <div ref="layoutPanel" :class="panelClass" :style="panelStyle"> <div v-for="(layout, layoutIndex) in layouts" :key="layoutIndex" class="layout-container" :style="layoutContainerStyle(layoutIndex)"> class="layout-wrapper"> <!-- 布局信息标签 --> <div class="layout-info" :style="layoutInfoStyle(layoutIndex)"> 布局{{ layoutIndex + 1 }} </div> <div v-for="(rect, rectIndex) in layout.rects" :key="rectIndex" :ref="(el) => { if (el) rectsElements[layoutIndex + '-' + rectIndex] = el }" :class="rectClass" :style="rectStyle(rect, layoutIndex)" @click="handleRectClick(layoutIndex, rectIndex)"> <div v-if="!rect.isRemain" class="rect-content"> <div class="size">{{ rect.w }}×{{ rect.h }}</div> <div class="jia-hao">{{ rect.JiaHao }}</div> <!-- 布局容器 --> <div class="layout-container" :style="layoutContainerStyle(layoutIndex)"> <div v-for="(rect, rectIndex) in layout.rects" :key="rectIndex" :ref="(el) => { if (el) rectsElements[layoutIndex + '-' + rectIndex] = el }" :class="rectClass" :style="rectStyle(rect, layoutIndex)" @click="handleRectClick(layoutIndex, rectIndex)"> <div v-if="!rect.isRemain" class="rect-content"> <div class="size">{{ rect.w }}×{{ rect.h }}</div> <div class="jia-hao">{{ rect.JiaHao }}</div> </div> </div> </div> </div> @@ -65,9 +72,24 @@ top: `${y}px`, width: `${containerWidth}px`, height: `${containerHeight}px`, overflow: 'visible', // 修改:设置为 visible,确保 layout-info 不被截断 overflow: 'visible', border: '1px solid #ccc', background: '#fff' }; }; const layoutInfoStyle = (layoutIndex) => { const containerWidth = (props.gw - 210) / 2; const containerHeight = (props.gh - 100) / 3; const x = (layoutIndex % 2) * (containerWidth + 50); const y = Math.floor(layoutIndex / 2) * (containerHeight + 50); return { position: 'absolute', left: `${x}px`, top: `${y - 45}px`, // 将标签放在版图容器的上方 background: 'none', textAlign: 'center', zIndex: 1000 }; }; @@ -113,26 +135,25 @@ </script> <style scoped> .layout-wrapper { position: relative; margin-top:50px; } .layout-container { position: relative; overflow: visible; /* 修改:设置为 visible,确保 layout-info 不被截断 */ overflow: visible; } .layout-info { position: absolute; top: 5px; right: 5px; color: #444; font-size: 12px; background-color: #ffffff; padding: 5px; padding: 5px 10px; border-radius: 3px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); z-index: 1000; /* 确保 layout-info 显示在其他元素的上方 */ } font-weight: bold; .layout-rect { transition: border-color 0.2s; } .rect-content { north-glass-erp/src/main/java/com/example/erp/common/RabbitMQUtil.java
New file @@ -0,0 +1,68 @@ package com.example.erp.common; import com.rabbitmq.client.*; import java.io.IOException; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.TimeoutException; public class RabbitMQUtil { private static final String SEND_QUEUE_NAME = "temperingUsed"; private static final String RECEIVE_QUEUE_NAME = "temperingReturn"; private static final String HOST = "localhost"; private static final String USERNAME = "guest"; private static final String PASSWORD = "guest"; private ConnectionFactory factory; private Connection connection; private Channel sendChannel; private Channel receiveChannel; private BlockingQueue<String> messageQueue; public RabbitMQUtil() throws IOException, TimeoutException { factory = new ConnectionFactory(); factory.setHost(HOST); factory.setUsername(USERNAME); factory.setPassword(PASSWORD); connection = factory.newConnection(); sendChannel = connection.createChannel(); sendChannel.queueDeclare(SEND_QUEUE_NAME, false, false, false, null); receiveChannel = connection.createChannel(); receiveChannel.queueDeclare(RECEIVE_QUEUE_NAME, false, false, false, null); messageQueue = new ArrayBlockingQueue<>(100); // 设置队列大小 startConsuming(); } public void sendMessage(String message) throws IOException { sendChannel.basicPublish("", SEND_QUEUE_NAME, null, message.getBytes()); } public String receiveMessages() throws InterruptedException { return messageQueue.take(); // 阻塞直到有消息可用 } private void startConsuming() throws IOException { DeliverCallback deliverCallback = (consumerTag, delivery) -> { String message = new String(delivery.getBody(), "UTF-8"); messageQueue.offer(message); // 将消息放入队列 }; receiveChannel.basicConsume(RECEIVE_QUEUE_NAME, true, deliverCallback, consumerTag -> { }); } public void close() throws IOException, TimeoutException { if (sendChannel != null) { sendChannel.close(); } if (receiveChannel != null) { receiveChannel.close(); } if (connection != null) { connection.close(); } } }