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