修复版本问题
This commit is contained in:
@@ -16,6 +16,15 @@
|
|||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xingshuangs</groupId>
|
||||||
|
<artifactId>iot-communication</artifactId>
|
||||||
|
<version>1.5.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-framework</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 通用工具-->
|
<!-- 通用工具-->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -42,10 +51,7 @@
|
|||||||
<!-- </dependency>-->
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<!-- 核心模块-->
|
<!-- 核心模块-->
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-framework</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 加密解密工具 opc-->
|
<!-- 加密解密工具 opc-->
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
@@ -114,13 +120,8 @@
|
|||||||
<artifactId>milo-spring-boot-starter</artifactId>
|
<artifactId>milo-spring-boot-starter</artifactId>
|
||||||
<version>3.1.4.0.6.15</version>
|
<version>3.1.4.0.6.15</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- iot-communication(写入改造使用) -->
|
||||||
|
|
||||||
<!-- iot-communication(写入改造使用) -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.xingshuangs</groupId>
|
|
||||||
<artifactId>iot-communication</artifactId>
|
|
||||||
<version>1.5.6</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
<!-- <groupId>com.alibaba</groupId>-->
|
<!-- <groupId>com.alibaba</groupId>-->
|
||||||
@@ -130,4 +131,4 @@
|
|||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* OPC 数据读写服务实现类
|
* OPC 数据读写服务实现类
|
||||||
*
|
* <p>
|
||||||
* 说明:
|
* 说明:
|
||||||
* 1) 写入逻辑已切换为 iot-communication(S7)
|
* 1) 写入逻辑已切换为 iot-communication(S7)
|
||||||
* 2) 读取逻辑仍保留在原 OPC 体系(不在本类中)
|
* 2) 读取逻辑仍保留在原 OPC 体系(不在本类中)
|
||||||
@@ -27,26 +27,21 @@ public class OpcDataServiceImpl implements OpcDataService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean writeData(OpcWriteDataForm form) {
|
public boolean writeData(OpcWriteDataForm form) {
|
||||||
try (S7PLC s7PLC = s7WriteClient.newClient()) {
|
|
||||||
writeByGuessType(s7PLC, form.getFieldName(), form.getValue());
|
S7PLC s7PLC = s7WriteClient.newClient();
|
||||||
return true;
|
writeByGuessType(s7PLC, form.getFieldName(), form.getValue());
|
||||||
} catch (Exception e) {
|
return true;
|
||||||
log.error("写入 S7 数据异常,address={}, value={}", form.getFieldName(), form.getValue(), e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean batchWriteData(OpcBatchWriteDataForm form) {
|
public boolean batchWriteData(OpcBatchWriteDataForm form) {
|
||||||
try (S7PLC s7PLC = s7WriteClient.newClient()) {
|
S7PLC s7PLC = s7WriteClient.newClient();
|
||||||
for (OpcWriteDataForm item : form.getDataList()) {
|
for (OpcWriteDataForm item : form.getDataList()) {
|
||||||
writeByGuessType(s7PLC, item.getFieldName(), item.getValue());
|
writeByGuessType(s7PLC, item.getFieldName(), item.getValue());
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("批量写入 S7 数据异常", e);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeByGuessType(S7PLC s7PLC, String address, Object value) {
|
private void writeByGuessType(S7PLC s7PLC, String address, Object value) {
|
||||||
@@ -73,10 +68,6 @@ public class OpcDataServiceImpl implements OpcDataService {
|
|||||||
s7PLC.writeInt32(address, (Integer) value);
|
s7PLC.writeInt32(address, (Integer) value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (value instanceof Long) {
|
|
||||||
s7PLC.writeInt64(address, (Long) value);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (value instanceof Float) {
|
if (value instanceof Float) {
|
||||||
s7PLC.writeFloat32(address, (Float) value);
|
s7PLC.writeFloat32(address, (Float) value);
|
||||||
return;
|
return;
|
||||||
|
|||||||
7
pom.xml
7
pom.xml
@@ -3,7 +3,7 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi</artifactId>
|
<artifactId>ruoyi</artifactId>
|
||||||
<version>3.8.8</version>
|
<version>3.8.8</version>
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
<name>ruoyi</name>
|
<name>ruoyi</name>
|
||||||
<url>http://www.ruoyi.vip</url>
|
<url>http://www.ruoyi.vip</url>
|
||||||
<description>若依管理系统</description>
|
<description>若依管理系统</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<ruoyi.version>3.8.8</ruoyi.version>
|
<ruoyi.version>3.8.8</ruoyi.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
@@ -221,6 +221,7 @@
|
|||||||
<version>${commons-pool2.version}</version>
|
<version>${commons-pool2.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
@@ -275,4 +276,4 @@
|
|||||||
</pluginRepository>
|
</pluginRepository>
|
||||||
</pluginRepositories>
|
</pluginRepositories>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Reference in New Issue
Block a user