From 20b346ef9d4fcbbbe05abfe08e4f4f0303b0812e Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期日, 30 八月 2026 20:37:45 +0800
Subject: [PATCH] 实现 Ticket12 人工结束与顺序接入
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTestServiceImpl.java | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTestServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTestServiceImpl.java
index 4e655b7..329d523 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTestServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTestServiceImpl.java
@@ -180,8 +180,8 @@
TDetectionChannel channel = testMapper.selectReceptionChannelForUpdate(binding.getChannelId());
if (channel == null || !isEnabled(channel.getStatus()) || !isOnline(channel.getOnlineStatus()))
throw new ServiceException("检测柜通道 " + binding.getChannelId() + " 当前离线或不可观测");
- runtimeAttach |= "WORKING".equalsIgnoreCase(channel.getWorkStatus())
- || "PAUSED".equalsIgnoreCase(channel.getWorkStatus());
+ // 只有设备事实为运行中时才标记“运行中接入”;设备暂停属于独立设备状态。
+ runtimeAttach |= "WORKING".equalsIgnoreCase(channel.getWorkStatus());
if (testMapper.selectChannelLeaseForUpdate(binding.getChannelId()) != null)
throw new ServiceException("检测柜通道 " + binding.getChannelId() + " 已被其他测试占用");
if (battery.getCollectorId() == null || testMapper.countCollectorEnabled(battery.getCollectorId()) == 0)
@@ -200,9 +200,15 @@
{
TTestChannelBinding binding = battery.getBinding();
testMapper.insertChannelLease(binding.getChannelId(), testId, binding.getBindingId(), operatorId, actionAt);
+ testMapper.insertReceptionInterval(testId, binding.getBindingId(), "CABINET_CHANNEL",
+ binding.getChannelId(), null, actionAt, "RECEPTION_STARTED");
for (TTestCollectorChannel mapping : mutable(battery.getCollectorChannels()))
+ {
testMapper.insertCollectorChannelLease(battery.getCollectorId(), mapping.getChannelCode(), testId,
binding.getBindingId(), operatorId, actionAt);
+ testMapper.insertReceptionInterval(testId, binding.getBindingId(), "COLLECTOR_CHANNEL",
+ battery.getCollectorId(), mapping.getChannelCode(), actionAt, "RECEPTION_STARTED");
+ }
}
if (testMapper.updateReceptionStarted(testId, actionAt, runtimeAttach, updateBy) != 1)
throw new ServiceException("测试状态已变更,请刷新后重试");
@@ -266,10 +272,12 @@
Date actionAt = new Date();
if (testMapper.updateReceptionStopped(testId, updateBy, actionAt) != 1)
throw new ServiceException("测试状态已变更,请刷新后重试");
+ int closedIntervals = testMapper.closeOpenReceptionIntervals(testId, actionAt, "MANUAL_END");
testMapper.deleteChannelLeasesByTestId(testId);
testMapper.deleteCollectorChannelLeasesByTestId(testId);
testMapper.insertTestAudit(testId, "TEST_STOPPED", operatorId, updateBy, null,
- JSON.toJSONString(Map.of("testStatus", "COMPLETED", "receptionStatus", "ENDED", "polling", "STOPPED")));
+ JSON.toJSONString(Map.of("testStatus", "COMPLETED", "receptionStatus", "ENDED",
+ "polling", "STOPPED", "closedIntervals", closedIntervals, "release", "IMMEDIATE")));
return 1;
}
@@ -360,6 +368,8 @@
test.setBatteryNo(joinBatteryNos(batteries));
List<TTestWarningThreshold> loadedThresholds = testMapper.selectTestThresholds(testId);
test.setThresholds(loadedThresholds == null ? mutable(test.getThresholds()) : mutable(loadedThresholds));
+ List<com.ruoyi.system.domain.TTestReceptionInterval> intervals = testMapper.selectTestReceptionIntervals(testId);
+ test.setReceptionIntervals(intervals == null ? List.of() : intervals);
List<TTestFieldSnapshot> loadedSnapshots = sharedFieldSnapshotService.selectByTestId(testId);
test.setFieldSnapshots(loadedSnapshots == null ? mutable(test.getFieldSnapshots()) : loadedSnapshots);
}
--
Gitblit v1.7.1