From aa89745fe575f876d474b4bb85e01e7a999ebd22 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期六, 05 九月 2026 01:37:44 +0800
Subject: [PATCH] 接入电池组与测试配置DTO边界
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TTestController.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TTestController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TTestController.java
index 746f77d..13751cd 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TTestController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TTestController.java
@@ -19,6 +19,13 @@
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TTest;
+import com.ruoyi.system.domain.TTestBattery;
+import com.ruoyi.system.domain.TTestChannelBinding;
+import com.ruoyi.system.domain.TTestCollectorChannel;
+import com.ruoyi.system.domain.TTestWarningThreshold;
+import com.battery.business.test.dto.TestConfigurationDto;
+import com.battery.business.test.dto.TestBatteryBindingDto;
+import com.battery.business.test.dto.ThresholdDto;
import com.ruoyi.system.domain.TTestResult;
import com.ruoyi.system.domain.TTestLogicStepMapping;
import com.ruoyi.system.domain.TTestConsoleDetail;
@@ -68,8 +75,9 @@
@PreAuthorize("@ss.hasPermi('system:test:add')")
@Log(title = "测试管理", businessType = BusinessType.INSERT)
@PostMapping
- public AjaxResult add(@Validated @RequestBody TTest test)
+ public AjaxResult add(@Validated @RequestBody TestConfigurationDto request)
{
+ TTest test = toDomain(request);
test.setOperatorId(getUserId());
test.setCreatorId(getUserId());
test.setCreateBy(getUsername());
@@ -80,8 +88,9 @@
@PreAuthorize("@ss.hasPermi('system:test:edit')")
@Log(title = "测试管理", businessType = BusinessType.UPDATE)
@PutMapping
- public AjaxResult edit(@Validated @RequestBody TTest test)
+ public AjaxResult edit(@Validated @RequestBody TestConfigurationDto request)
{
+ TTest test = toDomain(request);
test.setOperatorId(getUserId());
test.setUpdateBy(getUsername());
testService.updateTest(test);
@@ -238,4 +247,47 @@
return getDataTable(testService.selectTestResults(result));
}
+ /** 将测试配置 DTO 转换为现有测试服务模型;计划工步等废止字段不再进入服务。 */
+ private TTest toDomain(TestConfigurationDto request)
+ {
+ if (request == null) return null;
+ TTest test = new TTest();
+ test.setTestId(request.testId()); test.setTestName(request.testName()); test.setPrincipalId(request.principalId());
+ test.setTestTypeId(request.testTypeId()); test.setTestPurpose(request.testPurpose());
+ test.setMonitorTimeoutMinutes(request.monitorTimeoutMinutes()); test.setRemark(request.remark());
+ java.util.List<TTestBattery> batteries = new java.util.ArrayList<>();
+ if (request.batteries() != null) for (TestBatteryBindingDto item : request.batteries())
+ {
+ if (item == null) continue;
+ TTestBattery battery = new TTestBattery(); battery.setTestBatteryId(item.resolvedTestBatteryId());
+ battery.setGroupId(item.groupId()); battery.setBatteryNo(item.batteryNo()); battery.setCollectorId(item.collectorId());
+ if (item.resolvedCabinetChannel() != null)
+ {
+ TTestChannelBinding binding = new TTestChannelBinding();
+ binding.setTestBatteryId(item.resolvedTestBatteryId()); binding.setChannelId(item.resolvedCabinetChannel().channelId());
+ binding.setExpectedBarcode(item.resolvedCabinetChannel().expectedBarcode()); battery.setBinding(binding);
+ }
+ java.util.List<TTestCollectorChannel> channels = new java.util.ArrayList<>();
+ if (item.collectorChannels() != null) for (TestBatteryBindingDto.CollectorChannelDto channel : item.collectorChannels())
+ {
+ if (channel == null) continue;
+ TTestCollectorChannel mapping = new TTestCollectorChannel(); mapping.setTestBatteryId(item.resolvedTestBatteryId());
+ mapping.setCollectorId(item.collectorId()); mapping.setMeasurementCode(channel.measurementCode());
+ mapping.setMeasurementName(channel.measurementName()); mapping.setChannelCode(channel.channelCode()); channels.add(mapping);
+ }
+ battery.setCollectorChannels(channels); batteries.add(battery);
+ }
+ test.setBatteries(batteries);
+ java.util.List<TTestWarningThreshold> thresholds = new java.util.ArrayList<>();
+ if (request.thresholds() != null) for (ThresholdDto item : request.thresholds())
+ {
+ if (item == null) continue;
+ TTestWarningThreshold threshold = new TTestWarningThreshold(); threshold.setMetricCode(item.metricCode());
+ threshold.setMinValue(item.minValue()); threshold.setMaxValue(item.maxValue()); threshold.setUnit(item.unit());
+ threshold.setSeverity(item.severity()); thresholds.add(threshold);
+ }
+ test.setThresholds(thresholds);
+ return test;
+ }
+
}
--
Gitblit v1.7.1