修复版本问题

This commit is contained in:
2026-04-13 15:48:37 +08:00
parent 8610b76a1d
commit de48dec1b4
3 changed files with 27 additions and 34 deletions

View File

@@ -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>-->

View File

@@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
/** /**
* OPC 数据读写服务实现类 * OPC 数据读写服务实现类
* * <p>
* 说明: * 说明:
* 1) 写入逻辑已切换为 iot-communicationS7 * 1) 写入逻辑已切换为 iot-communicationS7
* 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()) {
S7PLC s7PLC = s7WriteClient.newClient();
writeByGuessType(s7PLC, form.getFieldName(), form.getValue()); writeByGuessType(s7PLC, form.getFieldName(), form.getValue());
return true; return true;
} catch (Exception e) {
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; return true;
} catch (Exception e) {
log.error("批量写入 S7 数据异常", e);
return false;
}
} }
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;

View File

@@ -221,6 +221,7 @@
<version>${commons-pool2.version}</version> <version>${commons-pool2.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>