yeg
2026-09-01 3d781111a5289987fdda13ce45bcfcabad207644
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
package com.ruoyi.system.mapper;
 
import java.util.List;
import java.util.Date;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.system.domain.TTest;
import com.ruoyi.system.domain.TTestBattery;
import com.ruoyi.system.domain.TTestBatteryField;
import com.ruoyi.system.domain.TTestChannelBinding;
import com.ruoyi.system.domain.TTestCollectorChannel;
import com.ruoyi.system.domain.TTestPlanStep;
import com.ruoyi.system.domain.TTestResult;
import com.ruoyi.system.domain.TTestWarningThreshold;
import com.ruoyi.system.domain.TTestCollectorSource;
import com.ruoyi.system.domain.TTestCollectorExceptionInterval;
import com.ruoyi.system.domain.TTestReceptionInterval;
import com.ruoyi.system.domain.TTestLogicStepMapping;
import com.ruoyi.system.domain.TTestBackfillCursor;
import com.ruoyi.system.domain.TTestIntegrityIssue;
import com.ruoyi.system.domain.TDetectionChannel;
import com.ruoyi.system.domain.TTestDataRevisionAction;
import com.ruoyi.system.domain.TTestConsoleImportRecord;
import com.ruoyi.system.domain.TTestDataOverride;
import com.ruoyi.system.domain.vo.TestBatteryOptionVo;
import com.ruoyi.system.domain.vo.TestChannelOptionVo;
import com.ruoyi.system.domain.vo.TestCollectorOptionVo;
import com.ruoyi.system.domain.vo.TestTypeOptionVo;
import com.ruoyi.system.domain.vo.TestUserOptionVo;
 
/** 测试配置及其只追加审计的数据访问接口。 */
public interface TTestMapper
{
    TTest selectTestById(Long testId);
    TTest selectTestByIdForUpdate(Long testId);
    List<TTest> selectTestList(TTest test);
    List<TTestBattery> selectBatteryNosByTestIds(@Param("testIds") List<Long> testIds);
    TTest selectTestByName(String testName);
    int insertTest(TTest test);
    int updateTest(TTest test);
    int deleteTestById(@Param("testId") Long testId, @Param("updateBy") String updateBy);
    int deleteTestBindingsByTestId(Long testId);
    int deleteTestCollectorChannelsByTestId(Long testId);
    int deleteTestPlanStepsByTestId(Long testId);
    int deleteTestBatteriesByTestId(Long testId);
    int deleteTestFieldsByTestId(Long testId);
    int deleteTestThresholdsByTestId(Long testId);
    int insertTestPlanStep(TTestPlanStep step);
    int insertTestBattery(TTestBattery battery);
    int insertTestBatteryField(TTestBatteryField field);
    int insertTestChannelBinding(TTestChannelBinding binding);
    int insertTestCollectorChannel(TTestCollectorChannel mapping);
    int insertTestThreshold(TTestWarningThreshold threshold);
    List<TTestPlanStep> selectTestPlanSteps(Long testId);
    List<TTestBattery> selectTestBatteries(Long testId);
    List<TTestBatteryField> selectTestBatteryFields(Long testId);
    List<TTestChannelBinding> selectTestChannelBindings(Long testId);
    List<TTestCollectorChannel> selectTestCollectorChannels(Long testId);
    List<TTestWarningThreshold> selectTestThresholds(Long testId);
    /** 按来源和起始边界顺序返回测试接收区间。 */
    List<TTestReceptionInterval> selectTestReceptionIntervals(Long testId);
    List<TTestResult> selectTestResults(TTestResult result);
    String selectLogicStepMappingsJson(Long testId);
    int updateLogicStepMappings(@Param("testId") Long testId, @Param("mappingsJson") String mappingsJson,
            @Param("updateBy") String updateBy, @Param("updateTime") Date updateTime);
    int countTestTypeEnabled(Long testTypeId);
    int countUserEnabled(Long userId);
    int countBatteryInEnabledGroup(@Param("groupId") Long groupId, @Param("batteryNo") String batteryNo);
    int countRegisteredChannel(Long channelId);
    int countCollectorEnabled(Long collectorId);
    Integer selectCollectorChannelCount(Long collectorId);
    String selectCollectorCode(Long collectorId);
    List<TestUserOptionVo> selectEnabledUserOptions();
    List<TestTypeOptionVo> selectEnabledTestTypeOptions();
    List<TestBatteryOptionVo> selectEnabledBatteryOptions();
    List<TestChannelOptionVo> selectRegisteredChannelOptions();
    List<TestCollectorOptionVo> selectEnabledCollectorOptions();
    int insertTestAudit(@Param("testId") Long testId, @Param("eventType") String eventType,
            @Param("actorId") Long actorId, @Param("actorName") String actorName,
            @Param("previousValue") String previousValue, @Param("newValue") String newValue);
 
    /** 锁定检测柜通道的最新可观测事实,供开始接收校验使用。 */
    TDetectionChannel selectReceptionChannelForUpdate(Long channelId);
    /** 锁定当前检测柜通道租约;返回空表示可接入。 */
    TTestChannelBinding selectChannelLeaseForUpdate(Long channelId);
    int insertChannelLease(@Param("channelId") Long channelId, @Param("testId") Long testId,
            @Param("bindingId") Long bindingId, @Param("acquiredBy") Long acquiredBy,
            @Param("acquiredAtUtc") Date acquiredAtUtc);
    int insertCollectorChannelLease(@Param("collectorId") Long collectorId, @Param("channelCode") String channelCode,
            @Param("testId") Long testId, @Param("bindingId") Long bindingId,
            @Param("acquiredBy") Long acquiredBy, @Param("acquiredAtUtc") Date acquiredAtUtc);
    /** 为每个绑定来源追加一个开放接收区间;区间关闭后仅保留历史事实。 */
    int insertReceptionInterval(@Param("testId") Long testId, @Param("bindingId") Long bindingId,
            @Param("sourceType") String sourceType, @Param("sourceId") Long sourceId,
            @Param("sourceChannelCode") String sourceChannelCode, @Param("actionAtUtc") Date actionAtUtc,
            @Param("boundaryNote") String boundaryNote);
    /** 在停止动作事务内关闭该测试全部开放区间,返回实际关闭数量。 */
    int closeOpenReceptionIntervals(@Param("testId") Long testId, @Param("endBoundaryAtUtc") Date endBoundaryAtUtc,
            @Param("boundaryNote") String boundaryNote);
    int deleteChannelLeasesByTestId(Long testId);
    int deleteCollectorChannelLeasesByTestId(Long testId);
    int hasReceivingTestForAdapter(@Param("adapterCode") String adapterCode);
    int hasPausedOrEndedTestForAdapter(@Param("adapterCode") String adapterCode);
    List<TDetectionChannel> selectReceivingChannelsForAdapter(@Param("adapterCode") String adapterCode);
    boolean collectorOnline(Long collectorId);
    int updateReceptionStarted(@Param("testId") Long testId, @Param("startedAtUtc") Date startedAtUtc,
            @Param("runtimeAttach") boolean runtimeAttach, @Param("updateBy") String updateBy);
    int updateReceptionPaused(@Param("testId") Long testId, @Param("updateBy") String updateBy,
            @Param("updatedAtUtc") Date updatedAtUtc);
    int updateReceptionResumed(@Param("testId") Long testId, @Param("updateBy") String updateBy,
            @Param("updatedAtUtc") Date updatedAtUtc);
    int updateReceptionStopped(@Param("testId") Long testId, @Param("updateBy") String updateBy,
            @Param("endedAtUtc") Date endedAtUtc);
 
    /** 查询仍在接收中的采集器来源。 */
    List<TTestCollectorSource> selectReceivingCollectorSources();
    /** 查询来源当前开放的断线区间。 */
    TTestCollectorExceptionInterval selectOpenCollectorException(@Param("testId") Long testId,
            @Param("batteryRelationId") Long batteryRelationId, @Param("collectorId") Long collectorId,
            @Param("channelCode") String channelCode);
    int insertCollectorExceptionInterval(TTestCollectorExceptionInterval interval);
    int closeCollectorExceptionInterval(@Param("intervalId") Long intervalId,
            @Param("recoveredAtUtc") Date recoveredAtUtc, @Param("missingToUtc") Date missingToUtc);
    List<TTestCollectorExceptionInterval> selectCollectorExceptionIntervals(Long testId);
 
    /** 查询需要自然结束或继续补采的测试。 */
    List<TTest> selectTestsForNaturalEnd();
    List<TTest> selectTestsForBackfill();
    /** 按稳定来源身份锁定补采游标,避免应用重启重复推进。 */
    TTestBackfillCursor selectBackfillCursorForUpdate(@Param("testId") Long testId,
            @Param("bindingId") Long bindingId, @Param("sourceType") String sourceType,
            @Param("sourceId") Long sourceId, @Param("sourceChannelCode") String sourceChannelCode);
    int insertBackfillCursor(TTestBackfillCursor cursor);
    int updateBackfillCursor(TTestBackfillCursor cursor);
    int updateTestBackfillStarted(@Param("testId") Long testId, @Param("updatedAtUtc") Date updatedAtUtc);
    int updateTestBackfillWaiting(@Param("testId") Long testId, @Param("updatedAtUtc") Date updatedAtUtc,
            @Param("error") String error);
    int updateTestBackfillCompleted(@Param("testId") Long testId, @Param("updatedAtUtc") Date updatedAtUtc);
    int updateTestCompleted(@Param("testId") Long testId, @Param("updatedAtUtc") Date updatedAtUtc);
    int updateTestNaturallyEnded(@Param("testId") Long testId, @Param("endedAtUtc") Date endedAtUtc);
    String selectSampleContentHash(@Param("channelId") Long channelId, @Param("btsTestId") String btsTestId,
            @Param("sequenceId") Long sequenceId);
    int insertBtsSample(@Param("testId") Long testId, @Param("bindingId") Long bindingId,
            @Param("channelId") Long channelId, @Param("intervalId") Long intervalId,
            @Param("btsTestId") String btsTestId, @Param("sequenceId") Long sequenceId,
            @Param("deviceTimeUtc") Date deviceTimeUtc, @Param("deviceTimeRaw") String deviceTimeRaw,
            @Param("receivedAtUtc") Date receivedAtUtc, @Param("cycleNo") Integer cycleNo,
            @Param("stepNo") Integer stepNo, @Param("stepType") String stepType,
            @Param("testTimeMs") Long testTimeMs, @Param("voltageV") java.math.BigDecimal voltageV,
            @Param("currentA") java.math.BigDecimal currentA, @Param("capacityAh") java.math.BigDecimal capacityAh,
            @Param("energyWh") java.math.BigDecimal energyWh, @Param("contentSha256") byte[] contentSha256);
    int insertBtsMeasurement(@Param("sampleId") Long sampleId, @Param("metricCode") String metricCode,
            @Param("metricValue") java.math.BigDecimal metricValue, @Param("unit") String unit,
            @Param("sourceType") String sourceType);
    Long selectBtsSampleId(@Param("channelId") Long channelId, @Param("btsTestId") String btsTestId,
            @Param("sequenceId") Long sequenceId);
    int insertCollectorSample(@Param("testId") Long testId, @Param("bindingId") Long bindingId,
            @Param("intervalId") Long intervalId,
            @Param("collectorId") Long collectorId, @Param("channelCode") String channelCode,
            @Param("sequenceId") Long sequenceId, @Param("deviceTimeUtc") Date deviceTimeUtc,
            @Param("deviceTimeRaw") String deviceTimeRaw, @Param("receivedAtUtc") Date receivedAtUtc,
            @Param("metricCode") String metricCode, @Param("metricValue") java.math.BigDecimal metricValue,
            @Param("unit") String unit, @Param("contentSha256") byte[] contentSha256);
    Long selectCollectorSampleId(@Param("collectorId") Long collectorId, @Param("channelCode") String channelCode,
            @Param("sequenceId") Long sequenceId, @Param("metricCode") String metricCode);
    String selectCollectorSampleContentHash(@Param("collectorId") Long collectorId,
            @Param("channelCode") String channelCode, @Param("sequenceId") Long sequenceId,
            @Param("metricCode") String metricCode);
    int insertBackfillConflict(@Param("testId") Long testId, @Param("channelId") Long channelId,
            @Param("detail") String detail);
    List<TTestIntegrityIssue> selectIntegrityIssues(Long testId);
    List<TTestIntegrityIssue> selectTestExceptionFacts(Long testId);
    List<Long> selectBtsSequencesByInterval(Long intervalId);
    List<Long> selectCollectorSequencesByInterval(Long intervalId);
    TTestIntegrityIssue selectOpenIntegrityIssue(@Param("intervalId") Long intervalId,
            @Param("sourceType") String sourceType, @Param("sourceId") Long sourceId,
            @Param("sourceChannelCode") String sourceChannelCode, @Param("missingFrom") Long missingFrom,
            @Param("missingTo") Long missingTo);
    List<TTestIntegrityIssue> selectOpenIntegrityIssues(@Param("intervalId") Long intervalId,
            @Param("sourceType") String sourceType, @Param("sourceId") Long sourceId,
            @Param("sourceChannelCode") String sourceChannelCode);
    int insertIntegrityIssue(TTestIntegrityIssue issue);
    int touchIntegrityIssue(@Param("issueId") Long issueId, @Param("retryCount") Integer retryCount,
            @Param("detail") String detail, @Param("detectedAtUtc") Date detectedAtUtc);
    int rewindBackfillCursor(@Param("testId") Long testId, @Param("bindingId") Long bindingId,
            @Param("sourceType") String sourceType, @Param("sourceId") Long sourceId,
            @Param("sourceChannelCode") String sourceChannelCode, @Param("nextPosition") Long nextPosition);
    int resolveIntegrityIssues(@Param("testId") Long testId, @Param("intervalId") Long intervalId,
            @Param("sourceType") String sourceType, @Param("sourceId") Long sourceId,
            @Param("sourceChannelCode") String sourceChannelCode, @Param("resolvedAtUtc") Date resolvedAtUtc);
    int resolveIntegrityIssue(@Param("issueId") Long issueId, @Param("resolvedAtUtc") Date resolvedAtUtc);
    int countOpenIntegrityIssues(Long testId);
    int countOpenExceptions(Long testId);
 
    int insertDataRevisionAction(TTestDataRevisionAction action);
    int upsertDataOverride(TTestDataOverride override);
    List<TTestDataOverride> selectDataOverrides(@Param("testId") Long testId,
            @Param("dataType") String dataType);
    int deleteBtsSamplesByIds(@Param("testId") Long testId, @Param("sampleIds") List<Long> sampleIds);
    int deleteBtsMeasurementsBySampleIds(@Param("sampleIds") List<Long> sampleIds);
    int deleteCollectorSamplesByIds(@Param("testId") Long testId, @Param("sampleIds") List<Long> sampleIds);
    Long selectBtsSampleIdByChannelSequence(@Param("testId") Long testId,
            @Param("channelId") Long channelId, @Param("sequenceId") Long sequenceId);
    int insertConsoleImportRecord(TTestConsoleImportRecord record);
    int countTestBatteryNo(@Param("testId") Long testId, @Param("batteryNo") String batteryNo);
}