springboot-vue3/.idea/dbnavigator.xml
New file @@ -0,0 +1,413 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="DBNavigator.Project.DDLFileAttachmentManager"> <mappings /> <preferences /> </component> <component name="DBNavigator.Project.DatabaseFileManager"> <open-files /> </component> <component name="DBNavigator.Project.Settings"> <connections /> <browser-settings> <general> <display-mode value="TABBED" /> <navigation-history-size value="100" /> <show-object-details value="false" /> </general> <filters> <object-type-filter> <object-type name="SCHEMA" enabled="true" /> <object-type name="USER" enabled="true" /> <object-type name="ROLE" enabled="true" /> <object-type name="PRIVILEGE" enabled="true" /> <object-type name="CHARSET" enabled="true" /> <object-type name="TABLE" enabled="true" /> <object-type name="VIEW" enabled="true" /> <object-type name="MATERIALIZED_VIEW" enabled="true" /> <object-type name="NESTED_TABLE" enabled="true" /> <object-type name="COLUMN" enabled="true" /> <object-type name="INDEX" enabled="true" /> <object-type name="CONSTRAINT" enabled="true" /> <object-type name="DATASET_TRIGGER" enabled="true" /> <object-type name="DATABASE_TRIGGER" enabled="true" /> <object-type name="SYNONYM" enabled="true" /> <object-type name="SEQUENCE" enabled="true" /> <object-type name="PROCEDURE" enabled="true" /> <object-type name="FUNCTION" enabled="true" /> <object-type name="PACKAGE" enabled="true" /> <object-type name="TYPE" enabled="true" /> <object-type name="TYPE_ATTRIBUTE" enabled="true" /> <object-type name="ARGUMENT" enabled="true" /> <object-type name="DIMENSION" enabled="true" /> <object-type name="CLUSTER" enabled="true" /> <object-type name="DBLINK" enabled="true" /> </object-type-filter> </filters> <sorting> <object-type name="COLUMN" sorting-type="NAME" /> <object-type name="FUNCTION" sorting-type="NAME" /> <object-type name="PROCEDURE" sorting-type="NAME" /> <object-type name="ARGUMENT" sorting-type="POSITION" /> <object-type name="TYPE ATTRIBUTE" sorting-type="POSITION" /> </sorting> <default-editors> <object-type name="VIEW" editor-type="SELECTION" /> <object-type name="PACKAGE" editor-type="SELECTION" /> <object-type name="TYPE" editor-type="SELECTION" /> </default-editors> </browser-settings> <navigation-settings> <lookup-filters> <lookup-objects> <object-type name="SCHEMA" enabled="true" /> <object-type name="USER" enabled="false" /> <object-type name="ROLE" enabled="false" /> <object-type name="PRIVILEGE" enabled="false" /> <object-type name="CHARSET" enabled="false" /> <object-type name="TABLE" enabled="true" /> <object-type name="VIEW" enabled="true" /> <object-type name="MATERIALIZED VIEW" enabled="true" /> <object-type name="INDEX" enabled="true" /> <object-type name="CONSTRAINT" enabled="true" /> <object-type name="DATASET TRIGGER" enabled="true" /> <object-type name="DATABASE TRIGGER" enabled="true" /> <object-type name="SYNONYM" enabled="false" /> <object-type name="SEQUENCE" enabled="true" /> <object-type name="PROCEDURE" enabled="true" /> <object-type name="FUNCTION" enabled="true" /> <object-type name="PACKAGE" enabled="true" /> <object-type name="TYPE" enabled="true" /> <object-type name="DIMENSION" enabled="false" /> <object-type name="CLUSTER" enabled="false" /> <object-type name="DBLINK" enabled="true" /> </lookup-objects> <force-database-load value="false" /> <prompt-connection-selection value="true" /> <prompt-schema-selection value="true" /> </lookup-filters> </navigation-settings> <dataset-grid-settings> <general> <enable-zooming value="true" /> <enable-column-tooltip value="true" /> </general> <sorting> <nulls-first value="true" /> <max-sorting-columns value="4" /> </sorting> <audit-columns> <column-names value="" /> <visible value="true" /> <editable value="false" /> </audit-columns> </dataset-grid-settings> <dataset-editor-settings> <text-editor-popup> <active value="false" /> <active-if-empty value="false" /> <data-length-threshold value="100" /> <popup-delay value="1000" /> </text-editor-popup> <values-actions-popup> <show-popup-button value="true" /> <element-count-threshold value="1000" /> <data-length-threshold value="250" /> </values-actions-popup> <general> <fetch-block-size value="100" /> <fetch-timeout value="30" /> <trim-whitespaces value="true" /> <convert-empty-strings-to-null value="true" /> <select-content-on-cell-edit value="true" /> <large-value-preview-active value="true" /> </general> <filters> <prompt-filter-dialog value="true" /> <default-filter-type value="BASIC" /> </filters> <qualified-text-editor text-length-threshold="300"> <content-types> <content-type name="Text" enabled="true" /> <content-type name="Properties" enabled="true" /> <content-type name="XML" enabled="true" /> <content-type name="DTD" enabled="true" /> <content-type name="HTML" enabled="true" /> <content-type name="XHTML" enabled="true" /> <content-type name="CSS" enabled="true" /> <content-type name="Java" enabled="true" /> <content-type name="SQL" enabled="true" /> <content-type name="PL/SQL" enabled="true" /> <content-type name="JavaScript" enabled="true" /> <content-type name="JSON" enabled="true" /> <content-type name="JSON5" enabled="true" /> <content-type name="JSP" enabled="true" /> <content-type name="JSPx" enabled="true" /> <content-type name="Groovy" enabled="true" /> <content-type name="FTL" enabled="true" /> <content-type name="GSP" enabled="true" /> <content-type name="VTL" enabled="true" /> <content-type name="YAML" enabled="true" /> <content-type name="Manifest" enabled="true" /> </content-types> </qualified-text-editor> <record-navigation> <navigation-target value="VIEWER" /> </record-navigation> </dataset-editor-settings> <code-editor-settings> <general> <show-object-navigation-gutter value="false" /> <show-spec-declaration-navigation-gutter value="true" /> <enable-spellchecking value="true" /> <enable-reference-spellchecking value="false" /> </general> <confirmations> <save-changes value="false" /> <revert-changes value="true" /> <exit-on-changes value="ASK" /> </confirmations> </code-editor-settings> <code-completion-settings> <filters> <basic-filter> <filter-element type="RESERVED_WORD" id="keyword" selected="true" /> <filter-element type="RESERVED_WORD" id="function" selected="true" /> <filter-element type="RESERVED_WORD" id="parameter" selected="true" /> <filter-element type="RESERVED_WORD" id="datatype" selected="true" /> <filter-element type="RESERVED_WORD" id="exception" selected="true" /> <filter-element type="OBJECT" id="schema" selected="true" /> <filter-element type="OBJECT" id="role" selected="true" /> <filter-element type="OBJECT" id="user" selected="true" /> <filter-element type="OBJECT" id="privilege" selected="true" /> <user-schema> <filter-element type="OBJECT" id="table" selected="true" /> <filter-element type="OBJECT" id="view" selected="true" /> <filter-element type="OBJECT" id="materialized view" selected="true" /> <filter-element type="OBJECT" id="index" selected="true" /> <filter-element type="OBJECT" id="constraint" selected="true" /> <filter-element type="OBJECT" id="trigger" selected="true" /> <filter-element type="OBJECT" id="synonym" selected="false" /> <filter-element type="OBJECT" id="sequence" selected="true" /> <filter-element type="OBJECT" id="procedure" selected="true" /> <filter-element type="OBJECT" id="function" selected="true" /> <filter-element type="OBJECT" id="package" selected="true" /> <filter-element type="OBJECT" id="type" selected="true" /> <filter-element type="OBJECT" id="dimension" selected="true" /> <filter-element type="OBJECT" id="cluster" selected="true" /> <filter-element type="OBJECT" id="dblink" selected="true" /> </user-schema> <public-schema> <filter-element type="OBJECT" id="table" selected="false" /> <filter-element type="OBJECT" id="view" selected="false" /> <filter-element type="OBJECT" id="materialized view" selected="false" /> <filter-element type="OBJECT" id="index" selected="false" /> <filter-element type="OBJECT" id="constraint" selected="false" /> <filter-element type="OBJECT" id="trigger" selected="false" /> <filter-element type="OBJECT" id="synonym" selected="false" /> <filter-element type="OBJECT" id="sequence" selected="false" /> <filter-element type="OBJECT" id="procedure" selected="false" /> <filter-element type="OBJECT" id="function" selected="false" /> <filter-element type="OBJECT" id="package" selected="false" /> <filter-element type="OBJECT" id="type" selected="false" /> <filter-element type="OBJECT" id="dimension" selected="false" /> <filter-element type="OBJECT" id="cluster" selected="false" /> <filter-element type="OBJECT" id="dblink" selected="false" /> </public-schema> <any-schema> <filter-element type="OBJECT" id="table" selected="true" /> <filter-element type="OBJECT" id="view" selected="true" /> <filter-element type="OBJECT" id="materialized view" selected="true" /> <filter-element type="OBJECT" id="index" selected="true" /> <filter-element type="OBJECT" id="constraint" selected="true" /> <filter-element type="OBJECT" id="trigger" selected="true" /> <filter-element type="OBJECT" id="synonym" selected="true" /> <filter-element type="OBJECT" id="sequence" selected="true" /> <filter-element type="OBJECT" id="procedure" selected="true" /> <filter-element type="OBJECT" id="function" selected="true" /> <filter-element type="OBJECT" id="package" selected="true" /> <filter-element type="OBJECT" id="type" selected="true" /> <filter-element type="OBJECT" id="dimension" selected="true" /> <filter-element type="OBJECT" id="cluster" selected="true" /> <filter-element type="OBJECT" id="dblink" selected="true" /> </any-schema> </basic-filter> <extended-filter> <filter-element type="RESERVED_WORD" id="keyword" selected="true" /> <filter-element type="RESERVED_WORD" id="function" selected="true" /> <filter-element type="RESERVED_WORD" id="parameter" selected="true" /> <filter-element type="RESERVED_WORD" id="datatype" selected="true" /> <filter-element type="RESERVED_WORD" id="exception" selected="true" /> <filter-element type="OBJECT" id="schema" selected="true" /> <filter-element type="OBJECT" id="user" selected="true" /> <filter-element type="OBJECT" id="role" selected="true" /> <filter-element type="OBJECT" id="privilege" selected="true" /> <user-schema> <filter-element type="OBJECT" id="table" selected="true" /> <filter-element type="OBJECT" id="view" selected="true" /> <filter-element type="OBJECT" id="materialized view" selected="true" /> <filter-element type="OBJECT" id="index" selected="true" /> <filter-element type="OBJECT" id="constraint" selected="true" /> <filter-element type="OBJECT" id="trigger" selected="true" /> <filter-element type="OBJECT" id="synonym" selected="true" /> <filter-element type="OBJECT" id="sequence" selected="true" /> <filter-element type="OBJECT" id="procedure" selected="true" /> <filter-element type="OBJECT" id="function" selected="true" /> <filter-element type="OBJECT" id="package" selected="true" /> <filter-element type="OBJECT" id="type" selected="true" /> <filter-element type="OBJECT" id="dimension" selected="true" /> <filter-element type="OBJECT" id="cluster" selected="true" /> <filter-element type="OBJECT" id="dblink" selected="true" /> </user-schema> <public-schema> <filter-element type="OBJECT" id="table" selected="true" /> <filter-element type="OBJECT" id="view" selected="true" /> <filter-element type="OBJECT" id="materialized view" selected="true" /> <filter-element type="OBJECT" id="index" selected="true" /> <filter-element type="OBJECT" id="constraint" selected="true" /> <filter-element type="OBJECT" id="trigger" selected="true" /> <filter-element type="OBJECT" id="synonym" selected="true" /> <filter-element type="OBJECT" id="sequence" selected="true" /> <filter-element type="OBJECT" id="procedure" selected="true" /> <filter-element type="OBJECT" id="function" selected="true" /> <filter-element type="OBJECT" id="package" selected="true" /> <filter-element type="OBJECT" id="type" selected="true" /> <filter-element type="OBJECT" id="dimension" selected="true" /> <filter-element type="OBJECT" id="cluster" selected="true" /> <filter-element type="OBJECT" id="dblink" selected="true" /> </public-schema> <any-schema> <filter-element type="OBJECT" id="table" selected="true" /> <filter-element type="OBJECT" id="view" selected="true" /> <filter-element type="OBJECT" id="materialized view" selected="true" /> <filter-element type="OBJECT" id="index" selected="true" /> <filter-element type="OBJECT" id="constraint" selected="true" /> <filter-element type="OBJECT" id="trigger" selected="true" /> <filter-element type="OBJECT" id="synonym" selected="true" /> <filter-element type="OBJECT" id="sequence" selected="true" /> <filter-element type="OBJECT" id="procedure" selected="true" /> <filter-element type="OBJECT" id="function" selected="true" /> <filter-element type="OBJECT" id="package" selected="true" /> <filter-element type="OBJECT" id="type" selected="true" /> <filter-element type="OBJECT" id="dimension" selected="true" /> <filter-element type="OBJECT" id="cluster" selected="true" /> <filter-element type="OBJECT" id="dblink" selected="true" /> </any-schema> </extended-filter> </filters> <sorting enabled="true"> <sorting-element type="RESERVED_WORD" id="keyword" /> <sorting-element type="RESERVED_WORD" id="datatype" /> <sorting-element type="OBJECT" id="column" /> <sorting-element type="OBJECT" id="table" /> <sorting-element type="OBJECT" id="view" /> <sorting-element type="OBJECT" id="materialized view" /> <sorting-element type="OBJECT" id="index" /> <sorting-element type="OBJECT" id="constraint" /> <sorting-element type="OBJECT" id="trigger" /> <sorting-element type="OBJECT" id="synonym" /> <sorting-element type="OBJECT" id="sequence" /> <sorting-element type="OBJECT" id="procedure" /> <sorting-element type="OBJECT" id="function" /> <sorting-element type="OBJECT" id="package" /> <sorting-element type="OBJECT" id="type" /> <sorting-element type="OBJECT" id="dimension" /> <sorting-element type="OBJECT" id="cluster" /> <sorting-element type="OBJECT" id="dblink" /> <sorting-element type="OBJECT" id="schema" /> <sorting-element type="OBJECT" id="role" /> <sorting-element type="OBJECT" id="user" /> <sorting-element type="RESERVED_WORD" id="function" /> <sorting-element type="RESERVED_WORD" id="parameter" /> </sorting> <format> <enforce-code-style-case value="true" /> </format> </code-completion-settings> <execution-engine-settings> <statement-execution> <fetch-block-size value="100" /> <execution-timeout value="20" /> <debug-execution-timeout value="600" /> <focus-result value="false" /> <prompt-execution value="false" /> </statement-execution> <script-execution> <command-line-interfaces /> <execution-timeout value="300" /> </script-execution> <method-execution> <execution-timeout value="30" /> <debug-execution-timeout value="600" /> <parameter-history-size value="10" /> </method-execution> </execution-engine-settings> <operation-settings> <transactions> <uncommitted-changes> <on-project-close value="ASK" /> <on-disconnect value="ASK" /> <on-autocommit-toggle value="ASK" /> </uncommitted-changes> <multiple-uncommitted-changes> <on-commit value="ASK" /> <on-rollback value="ASK" /> </multiple-uncommitted-changes> </transactions> <session-browser> <disconnect-session value="ASK" /> <kill-session value="ASK" /> <reload-on-filter-change value="false" /> </session-browser> <compiler> <compile-type value="KEEP" /> <compile-dependencies value="ASK" /> <always-show-controls value="false" /> </compiler> </operation-settings> <ddl-file-settings> <extensions> <mapping file-type-id="VIEW" extensions="vw" /> <mapping file-type-id="TRIGGER" extensions="trg" /> <mapping file-type-id="PROCEDURE" extensions="prc" /> <mapping file-type-id="FUNCTION" extensions="fnc" /> <mapping file-type-id="PACKAGE" extensions="pkg" /> <mapping file-type-id="PACKAGE_SPEC" extensions="pks" /> <mapping file-type-id="PACKAGE_BODY" extensions="pkb" /> <mapping file-type-id="TYPE" extensions="tpe" /> <mapping file-type-id="TYPE_SPEC" extensions="tps" /> <mapping file-type-id="TYPE_BODY" extensions="tpb" /> </extensions> <general> <lookup-ddl-files value="true" /> <create-ddl-files value="false" /> <synchronize-ddl-files value="true" /> <use-qualified-names value="false" /> <make-scripts-rerunnable value="true" /> </general> </ddl-file-settings> <general-settings> <regional-settings> <date-format value="MEDIUM" /> <number-format value="UNGROUPED" /> <locale value="SYSTEM_DEFAULT" /> <use-custom-formats value="false" /> </regional-settings> <environment> <environment-types> <environment-type id="development" name="Development" description="Development environment" color="-2430209/-12296320" readonly-code="false" readonly-data="false" /> <environment-type id="integration" name="Integration" description="Integration environment" color="-2621494/-12163514" readonly-code="true" readonly-data="false" /> <environment-type id="production" name="Production" description="Productive environment" color="-11574/-10271420" readonly-code="true" readonly-data="true" /> <environment-type id="other" name="Other" description="" color="-1576/-10724543" readonly-code="false" readonly-data="false" /> </environment-types> <visibility-settings> <connection-tabs value="true" /> <dialog-headers value="true" /> <object-editor-tabs value="true" /> <script-editor-tabs value="false" /> <execution-result-tabs value="true" /> </visibility-settings> </environment> </general-settings> </component> </project> springboot-vue3/effective-pom.xml
New file Diff too large springboot-vue3/src/main/java/com/example/springboot/AuthorityApplication.java
@@ -1,10 +1,13 @@ package com.example.springboot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ConfigurableApplicationContext; import com.example.springboot.component.*; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.ComponentScan; @SpringBootApplication springboot-vue3/src/main/java/com/example/springboot/common/MessageReceiver.java
File was deleted springboot-vue3/src/main/java/com/example/springboot/common/MessageSender.java
File was deleted springboot-vue3/src/main/java/com/example/springboot/common/RabbitConfig.java
File was deleted springboot-vue3/src/main/java/com/example/springboot/component/MessageQueueReader.java
@@ -13,28 +13,19 @@ public static void main(String[] args) throws Exception { ConnectionFactory factory = new ConnectionFactory(); factory.setHost("localhost"); List<String> messages = new ArrayList<>(); try (Connection connection = factory.newConnection(); Channel channel = connection.createChannel()) { boolean autoAck = false; // autoAck 参数设置为 false,然后手动确认消息处理完成 // 循环获取队列中的所有消息 // while (true) { GetResponse response = channel.basicGet(QUEUE_NAME, autoAck); GetResponse response = channel.basicGet(QUEUE_NAME, autoAck); if (response != null) { String message = new String(response.getBody(), "UTF-8"); messages.add(message); // 手动确认消息处理完成 long deliveryTag = response.getEnvelope().getDeliveryTag(); channel.basicAck(deliveryTag, false); // } else { // // 如果队列为空,则退出循环 // break; // } } } springboot-vue3/src/main/java/com/example/springboot/component/ModuleA.java
@@ -2,13 +2,23 @@ import com.rabbitmq.client.*; import java.util.HashMap; import java.util.Map; public class ModuleA { private final static String QUEUE_NAME = "hangzhoumes"; private static String QUEUE_NAME = "hangzhou2"; public ModuleA(String QUEUENAME){ QUEUE_NAME=QUEUENAME; } public static void main(String[] argv) throws Exception { // 创建连接工厂 ConnectionFactory factory = new ConnectionFactory(); factory.setHost("localhost"); factory.setHost("10.153.19.150"); // factory.setHost("localhost"); try (Connection connection = factory.newConnection(); //channel 是通过 connection 创建的一个 AMQP 信道对象 @@ -21,7 +31,10 @@ //4. `false`:指定是否在不再使用时自动删除队列。在这里设置为`false`,表示当没有消费者或者所有消费者断开连接后,队列不会自动删除。 //5. `null`:指定其他队列属性的参数。在这里设置为`null`,表示没有其他属性需要设置。 //执行`channel.queueDeclare()`方法后,如果队列不存在,将会创建一个新的队列,如果队列已经存在,则不做任何操作。 channel.queueDeclare(QUEUE_NAME, false, false, false, null); Map<String, Object> args = new HashMap<>(); args.put("x-max-length", 10000); channel.queueDeclare(QUEUE_NAME, true, false, false, args); springboot-vue3/src/main/java/com/example/springboot/component/ModuleB.java
@@ -2,25 +2,32 @@ import com.rabbitmq.client.*; import java.util.HashMap; import java.util.Map; public class ModuleB { private final static String QUEUE_NAME = "hangzhoumes"; private final static String QUEUE_NAME = "hangzhou2"; public static void main(String[] argv) throws Exception { // 创建连接工厂 ConnectionFactory factory = new ConnectionFactory(); factory.setHost("localhost"); factory.setHost("10.153.19.150"); // factory.setHost("localhost"); try (Connection connection = factory.newConnection(); Channel channel = connection.createChannel()) { // 声明队列 channel.queueDeclare(QUEUE_NAME, false, false, false, null); Map<String, Object> args = new HashMap<>(); args.put("x-max-length",10000); channel.queueDeclare(QUEUE_NAME, true, false, false, args); // 创建消费者 DeliverCallback deliverCallback = (consumerTag, delivery) -> { String receivedMessage = new String(delivery.getBody(), "UTF-8"); System.out.println(" [x] Received '" + receivedMessage + "'"); }; // 开始消费消息 channel.basicConsume(QUEUE_NAME, true, deliverCallback, consumerTag -> { }); channel.basicConsume(QUEUE_NAME, true, deliverCallback, consumerTag -> { }); } } } springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java
@@ -14,7 +14,7 @@ import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import com.example.springboot.common.MessageSender; import org.apache.commons.io.FileUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -62,8 +62,7 @@ jsonObject.put("key3", jsonArray); try { // 将 JSON 对象转换为字符串并发送到队列 RabbitMQUtils.sendJsonMessage(jsonObject, "json_queue"); // 将 JSON 对象转换为字符串并发送到队列//RabbitMQUtils.sendJsonMessage(jsonObject, "json_queue"); } catch (Exception e) { e.printStackTrace(); } springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
@@ -63,6 +63,9 @@ JSONObject jsonObject = new JSONObject(); try { Thread.sleep(1000); String s1=S7controlalbia.getinstance().readStrings("DB14.38"); String s2=S7controlalbia.getinstance().readStrings("DB14.40"); // 注入mapper homeMapper = WebSocketServer.applicationContext.getBean(HomeMapper.class); spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class); springboot-vue3/src/main/java/com/example/springboot/component/RabbitMQUtils.java
@@ -3,6 +3,9 @@ import com.rabbitmq.client.*; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.ArrayList; import java.util.List; public class RabbitMQUtils { // ObjectMapper对象,用于序列化和反序列化JSON private static ObjectMapper objectMapper = new ObjectMapper(); @@ -25,6 +28,28 @@ } } public List<String> readMessages(String queueName) throws Exception { ConnectionFactory factory = new ConnectionFactory(); factory.setHost("localhost"); List<String> messages = new ArrayList<>(); try (Connection connection = factory.newConnection(); Channel channel = connection.createChannel()) { boolean autoAck = false; GetResponse response = channel.basicGet(queueName, autoAck); if (response != null) { String message = new String(response.getBody(), "UTF-8"); messages.add(message); // 手动确认消息处理完成 long deliveryTag = response.getEnvelope().getDeliveryTag(); channel.basicAck(deliveryTag, false); } } return messages; } // 从 RabbitMQ 队列中接收消息 public static void receiveMessage(String queueName) throws Exception { // 创建连接工厂并设置主机名 springboot-vue3/src/main/java/com/example/springboot/component/S7controlalbia.java
New file @@ -0,0 +1,456 @@ package com.example.springboot.component; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; import java.sql.Time; import java.util.ArrayList; import java.util.List; import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType; import com.github.xingshuangs.iot.protocol.s7.service.MultiAddressWrite; import com.github.xingshuangs.iot.protocol.s7.service.S7PLC; import com.google.common.primitives.Bytes; import org.apache.ibatis.jdbc.Null; public class S7controlalbia { S7PLC s7PLC; // PLC通讯类实例 private EPlcType plcType = EPlcType.S1500; // 西门子PLC类型 private String ip = "192.168.10.1"; // plc ip地址 private int port = 65; // plc 端口号 private static volatile S7controlalbia instance = null; private S7controlalbia() { if (s7PLC == null) s7PLC = new S7PLC(plcType, ip, port, 0, 0); } // 单例模式 获取类的唯一实例 public static S7controlalbia getinstance() { if (instance == null) { synchronized (S7controlalbia.class) { if (instance == null) instance = new S7controlalbia(); } } return instance; } /** * 关闭西门子s7通讯连接 */ public void CloseS7client() { if (s7PLC == null) s7PLC.close(); s7PLC.checkConnected(); } /** * s7通讯连接状态 */ public boolean CheckConnected() { return s7PLC.checkConnected(); } /** * 按指定的地址 写入一个word * * @param address 地址 * @param data word的值 */ public void WriteWord(String address, short data) { if (s7PLC == null) { return; } s7PLC.writeInt16(address, data); } /** * 从某地址连续 写入多个word * * @param address 地址 * @param datas word的值 */ public void WriteWord(String address, List<Short> datas) { if (s7PLC == null) return; // s7PLC.write(address, data); List<String> addresslist = GetAddressList(address, datas.size(), 16); MultiAddressWrite addressWrite = new MultiAddressWrite(); for (int i = 0; i < datas.size(); i++) { addressWrite.addInt16(addresslist.get(i), datas.get(i)); } s7PLC.writeMultiData(addressWrite); } /** * 按指定的地址 写入多个word * * @param address 地址 * @param datas word的值 */ /** * 按指定的地址 写入一个Bit * * @param address 地址 * @param data Bit的值 */ public void WriteBit(String address, Boolean data) { if (s7PLC == null) return; s7PLC.writeBoolean(address, data); } /** * 按指定的地址 写入多个bit * * @param address 地址 * @param datas bit的值 */ public void WriteBit(List<String> address, List<Boolean> datas) { if (s7PLC == null) return; // s7PLC.write(address, data); MultiAddressWrite addressWrite = new MultiAddressWrite(); for (int i = 0; i < address.size(); i++) { addressWrite.addBoolean(address.get(i), datas.get(i)); } s7PLC.writeMultiData(addressWrite); } /** * 从某地址连续 写入多个bit * * @param address 地址 * @param datas word的值 */ public void WriteBit(String address, List<Boolean> datas) { if (s7PLC == null) return; // s7PLC.write(address, data); List<String> addresslist = GetAddressList(address, datas.size(), 1); MultiAddressWrite addressWrite = new MultiAddressWrite(); for (int i = 0; i < datas.size(); i++) { addressWrite.addBoolean(addresslist.get(i), datas.get(i)); } s7PLC.writeMultiData(addressWrite); } /** * 按指定的地址 写入多个byte * * @param address 地址 * @param datas byte的值 */ public void WriteByte(String address, byte[] datas) { if (s7PLC == null) return; // s7PLC.write(address, data); s7PLC.writeByte(address, datas); } /** * 按指定的地址 读取word结果集 * * @param address 地址 * @return 结果 */ public List<Short> ReadWord(List<String> address) { if (s7PLC == null) return null; try { return s7PLC.readInt16(address); } catch (Exception e) { System.out.println("读取 " + address + " 失败:" + e.getMessage()); return null; } } private int getIndexFromAddress(String address) { // 可以解析出地址中的数字部分,并转换为整数 return 0; } private String getAddressFromIndex(int index) { // 整数转换为地址格式的字符串 return ""; } /** * 按指定的地址 读取word结果集 * * @param address 地址 * @param count 连续读多少个word * @return 结果 */ public List<Short> ReadWord(String address, int count) { if (s7PLC == null) return null; List<String> addresslist = GetAddressList(address, count, 16); try { return s7PLC.readInt16(addresslist); } catch (Exception e) { System.out.println("读取 " + address + " 失败:" + e.getMessage()); return null; } } /** * 按指定的地址 读取byte结果集 * * @param address 地址 * @param count 连续读多少个byte * @return 结果 */ public byte[] ReadByte(String address, int count) { if (s7PLC == null) return null; // List<String> addresslist = GetAddressList(address, count, 16); try { return s7PLC.readByte(address, count); } catch (Exception e) { // 处理异常 System.out.println("读取 " + address + " 失败:" + e.getMessage()); return null; } } /** * 按指定的地址 按bit位 0 flase 1 true 读取结果 * * @param addresslist 地址集 * @return Boolean结果 */ public List<Boolean> ReadBits(List<String> addresslist) { if (s7PLC == null) return null; return s7PLC.readBoolean(addresslist); } // 读取不连续地址bit public List<Boolean> readBits(List<String> addressList) { if (s7PLC == null || addressList.isEmpty()) { return null; } List<Boolean> values = new ArrayList<>(); for (String address : addressList) { try { boolean value = s7PLC.readBoolean(address); values.add(value); } catch (Exception e) { // 处理异常 System.out.println("读取 " + address + " 失败:" + e.getMessage()); } } return values; } // 读取String public List<String> readStrings(List<String> addressList) { if (s7PLC == null) { return null; } List<String> result = new ArrayList<>(); for (String address : addressList) { try { byte[] bytes = s7PLC.readByte(address, 14); if (bytes != null) { String str = new String(bytes, StandardCharsets.UTF_8); result.add(str); } } catch (Exception e) { System.out.println("读取 " + address + " 失败:" + e.getMessage()); result.add(null); } } return result; } public List<String> readStringsandword(List<String> addressList) { if (s7PLC == null) { return null; } List<String> result = new ArrayList<>(); for (String address : addressList) { try { if (address.contains("-")) { address = address.substring(0, address.indexOf("-")); byte[] bytes = s7PLC.readByte(address, 14); if (bytes != null) { String str = new String(bytes, StandardCharsets.UTF_8); result.add(str); } } else { Short value = s7PLC.readInt16(address); result.add(value.toString()); } } catch (Exception e) { System.out.println("读取 " + address + " 失败:" + e.getMessage()); result.add(null); } } return result; } // 不连续地址写入Word public void WriteWord(List<String> address, List<Short> datas) { if (s7PLC == null) return; for (int i = 0; i < address.size(); i++) { String addr = address.get(i); short data = datas.get(i); if (addr.contains("-")) { outmesid(String.valueOf(data), addr); // 单独处理带破折号的地址 } else { s7PLC.writeInt16(addr, data); // 将数据写入单个地址 } } } // 字符串写入 public void outmesid(String data, String addr) { // System.out.println("outmesid: " + data); List<Byte> glassidlist = new ArrayList<>(); String[] parts = addr.split("-"); if (parts.length == 2) { addr = parts[0]; // 只保留 "-" 前面的部分 } for (char iditem : data.toCharArray()) { glassidlist.add(Byte.valueOf(String.valueOf(iditem))); } byte[] bytes = Bytes.toArray(glassidlist); S7controlalbia.getinstance().WriteByte(addr, bytes); } // 读取不连续word public List<Short> readWords(List<String> addresses) { if (s7PLC == null) { return null; } List<Short> data = new ArrayList<>(); for (String address : addresses) { try { // 单个地址 Short value = s7PLC.readInt16(address); data.add(value); } catch (Exception e) { System.out.println("读取 " + address + " 失败:" + e.getMessage()); } } return data; } // 读取时间 public Long readtime(String address) { if (s7PLC == null) return null; try { return s7PLC.readTime(address); } catch (Exception e) { System.out.println("读取 " + address + " 失败:" + e.getMessage()); return null; } } public void writetime(String address, long datas) { if (s7PLC == null) return; s7PLC.writeTime(address, datas); // 将数据写入单个地址 } private int extractAddressNumber(String address) { String numberStr = address.replaceAll("\\D+", ""); // 使用正则表达式提取数字部分 return Integer.parseInt(numberStr); } /** * 从指定的地址开始 连续按bit位读取 * * @param address 地址 * @param count 长度 * @return Boolean结果 */ public List<Boolean> ReadBits(String address, int count) { if (s7PLC == null) return null; List<String> addresslist = GetAddressList(address, count, 1); try { return s7PLC.readBoolean(addresslist); } catch (Exception e) { System.out.println("读取 " + address + " 失败:" + e.getMessage()); return null; } }; private List<String> GetAddressList(String address, int count, int addedbit) { List<String> addresslist = new ArrayList<String>(); String[] stringdatas = address.trim().split("\\."); if (stringdatas.length < 2 || !address.startsWith("DB")) return null; int dbwindex = 0; int bitindex = 0; if (stringdatas.length == 2) { dbwindex = Integer.parseInt(stringdatas[1]); } else if (stringdatas.length == 3) { dbwindex = Integer.parseInt(stringdatas[1]); bitindex = Integer.parseInt(stringdatas[2]); } else return null; addresslist.add(address); for (int i = 0; i < count - 1; i++) { int bitcurrent = bitindex + addedbit; if (bitcurrent > 7) { dbwindex += bitcurrent / 8; bitindex = 0; } else bitindex = bitcurrent; String endstr = stringdatas.length == 3 ? "." + bitindex : ""; addresslist.add(stringdatas[0] + "." + dbwindex + endstr); } return addresslist; } public void writeStrings(String data, String addr) { // List<Byte> glassidlist = new ArrayList<>(); String[] parts = addr.split("-"); if (parts.length == 2) { addr = parts[0]; } s7PLC.writeString(addr, data); } public String readStrings(String addr) { return s7PLC.readString(addr); } } springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
@@ -20,18 +20,14 @@ // new PlcHoldNew().start(); // new PLCAutoMes().start(); // new Plchome().start(); new Plchome().start(); // new PlcLayout().start(); // new Plcalarm().start(); // new Plcsign().start(); // new Plcstate().start(); // new PlcPositioning1().start(); // new PlcParameter2().start(); // new PLCAutomaticParameterSetting().start(); // new PlcManualonePosition().start(); // new PlcManualonePosition2().start(); // new PlcServoManualone().start(); @@ -39,9 +35,9 @@ // new Plclog().start(); // new PlcInteractionState().start(); //new PlcParameter1Review().start(); //new PLCAutomaticParameterSettingReview2().start(); // new PLCManualJogReview().start(); // new PlcParameter1Review().start(); // new PLCAutomaticParameterSettingReview2().start(); // new PLCManualJogReview().start(); } } springboot-vue3/src/main/java/com/example/springboot/controller/MessageController.java
File was deleted springboot-vue3/src/main/java/com/example/springboot/mapper/SpianMapper.java
@@ -15,10 +15,10 @@ @Select("select COUNT(if(a.state1=0,cell,0))as cell,ROUND(id/2)as id from (select *,max(state)as state1 from storage_cage a GROUP BY cage,cell)as a where (a.cage=#{cage1}-1 or a.cage=#{cage1}+1)and if(a.cage<6,a.cage>0 and a.cage<6,a.cage>5) and disabled=0 GROUP BY cage ORDER BY cell desc LIMIT 1") int selectCage(int cage1); // 获取笼子号订单号排序的空订单笼子 @Select("select a.cage,FrameBarcode,COUNT(if(a.order_id=#{orderids},a.order_id,null))as orderid,b.shu,c.shu2,a.cell,min(a.state)as state1,max(a.state)as state2,disabled,FrameBarcode from storage_cage a left join (select COUNT(*)shu,cage from storage_cage where order_id=#{orderids} GROUP BY cage)as b on a.cage=b.cage left join(select cage ,COUNT(glass_id)as shu2 from storage_cage GROUP BY cage)c on a.cage=c.cage where (order_id=#{orderids} or ''='') GROUP BY cage,cell HAVING state1=0 ORDER BY shu desc,shu2,state2 asc,cage asc;") @Select("select a.cage,FrameBarcode,COUNT(if(a.order_id=#{orderids},a.order_id,null))as orderid,b.shu,c.shu2,a.cell,min(a.state)as state1,max(a.state)as state2,disabled,FrameBarcode from storage_cage a left join (select COUNT(*)shu,cage from storage_cage where order_id=#{orderids} GROUP BY cage)as b on a.cage=b.cage left join(select cage ,COUNT(glass_id)as shu2 from storage_cage GROUP BY cage)c on a.cage=c.cage where (order_id=#{orderids} or ''='') and a.disabled=0 GROUP BY cage,cell HAVING state1=0 ORDER BY shu desc,shu2,state2 asc,cage asc;") List<StorageCage> selectAll(String orderids,String Fbarcode); //优先判断一次是否有同铝框的空位 @Select("select *,min(state) state1 from storage_cage where width>=(#{width}+#{width2}) GROUP BY cage,cell HAVING state1=0 and FrameBarcode=#{Fbarcode} ORDER BY width desc LIMIT 1;") @Select("select *,min(state) state1 from storage_cage where width>=(#{width}+#{width2}) GROUP BY cage,cell HAVING state1=0 and FrameBarcode=#{Fbarcode} and disabled=0 ORDER BY width desc LIMIT 1;") List<StorageCage> selectAllFbarcode(String Fbarcode,double width,double width2); // 获取判断该格子是否需要把外片推入内片位置 @Select("select state from storage_cage where cage=#{cage} and cell=#{cell} and tier=1;") @@ -63,7 +63,7 @@ int selectGlassState(int cage, int cell); // 判断该调拨的笼子 @Select("select glass_id,cage,cell,max(state)as shu,ROUND(id/2)as prcid,id,abs(#{cell}-cell)as xuhao from storage_cage where width>=#{width} and cage>#{cage1} and cage<#{cage2} GROUP BY cage,cell HAVING shu=0 order by abs(#{cage} - cage),xuhao desc limit 1;") @Select("select glass_id,cage,cell,max(state)as shu,ROUND(id/2)as prcid,id,abs(#{cell}-cell)as xuhao from storage_cage where width>=#{width} and cage>#{cage1} and cage<#{cage2} and disabled=0 GROUP BY cage,cell HAVING shu=0 order by abs(#{cage} - cage),xuhao desc limit 1;") StorageCage selectGlassCage(int cage, double width, int cage1, int cage2,int cell); // 删除笼子信息(出片) springboot-vue3/src/main/resources/application.properties
@@ -23,5 +23,9 @@ spring.jackson.date-format=yyyy-MM-dd HH:mm:ss spring.jackson.time-zone=GMT+8 #spring.rabbitmq.host=10.153.19.150 #spring.rabbitmq.port=5672 #spring.rabbitmq.username=guest #spring.rabbitmq.password=guest