| | |
| | | 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; |
| | |
| | | @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()); |
| | |
| | | @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); |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |