package com.battery.business.mapper; import java.util.List; import java.util.Date; import org.apache.ibatis.annotations.Param; import com.battery.business.domain.TTest; import com.battery.business.domain.TTestBattery; import com.battery.business.domain.CurrentBatteryField; import com.battery.business.domain.TTestChannelBinding; import com.battery.business.domain.TTestCollectorChannel; import com.battery.business.domain.TTestWarningThreshold; import com.battery.business.domain.TTestWarningException; import com.battery.business.domain.TTestLogicStepMapping; import com.battery.business.domain.TDetectionChannel; import com.battery.business.domain.TTestDataRevisionAction; import com.battery.business.domain.DataRevisionItem; import com.battery.business.domain.TTestRealtimeRecord; import com.battery.business.domain.TTestStepRecord; import com.battery.business.domain.TTestCycleRecord; import com.battery.business.domain.vo.TestBatteryOptionVo; import com.battery.business.domain.vo.TestChannelOptionVo; import com.battery.business.domain.vo.TestCollectorOptionVo; import com.battery.business.domain.vo.TestTypeOptionVo; import com.battery.business.domain.vo.TestUserOptionVo; /** 读写测试配置、成功接收数据、修订记录和异常处理事实。 */ public interface TTestMapper { int deleteTestWarningExceptionsByTestId(Long testId); int deleteTestLogicStepMappingsByTestId(Long testId); java.util.Map selectDataRecord(@Param("testId") Long testId, @Param("dataType") String dataType, @Param("recordId") Long recordId); int updateDataRecord(@Param("testId") Long testId, @Param("dataType") String dataType, @Param("recordId") Long recordId, @Param("values") java.util.Map values); int deleteDataRecord(@Param("testId") Long testId, @Param("dataType") String dataType, @Param("recordId") Long recordId); java.util.Map selectImportBinding(@Param("testId") Long testId, @Param("batteryNo") String batteryNo); int insertImportedDataRecord(@Param("dataType") String dataType, @Param("values") java.util.Map values); TTest selectTestById(Long testId); TTest selectTestByIdForUpdate(Long testId); List selectTestList(TTest test); List selectBatteryNosByTestIds(@Param("testIds") List testIds); TTest selectTestByName(String testName); int insertTest(TTest test); int updateTest(TTest test); int deleteTestById(@Param("testId") Long testId, @Param("updateBy") String updateBy); int deleteTestThresholdRowsByTestId(Long testId); int deleteTestBindingsByTestId(Long testId); int deleteTestCollectorChannelsByTestId(Long testId); int deleteTestBatteriesByTestId(Long testId); int deleteTestThresholdsByTestId(Long testId); int insertTestBattery(TTestBattery battery); int insertTestChannelBinding(TTestChannelBinding binding); int insertTestCollectorChannel(TTestCollectorChannel mapping); int insertTestThreshold(TTestWarningThreshold threshold); List selectTestBatteries(Long testId); /** 读取测试所选电池组的当前字段值,不创建测试快照。 */ List selectCurrentBatteryFields(Long testId); List selectTestChannelBindings(Long testId); List selectTestCollectorChannels(Long testId); List selectTestThresholds(Long testId); /** 以测试、指标和阈值规则为开放异常键原子聚合成功接收的超限值。 */ int upsertWarningException(@Param("testId") Long testId, @Param("thresholdId") Long thresholdId, @Param("sourceType") String sourceType, @Param("sourceIdentity") String sourceIdentity, @Param("metricCode") String metricCode, @Param("value") java.math.BigDecimal value, @Param("unit") String unit, @Param("ruleSnapshot") String ruleSnapshot, @Param("severity") String severity, @Param("occurredAt") Date occurredAt); /** 查询绑定来源的离线事实,同一采集器的多通道绑定只返回一次。 */ List selectOfflineTestSources(Long testId); /** 以测试和来源身份聚合离线异常,不写入阈值或测量值。 */ int upsertOfflineException(@Param("testId") Long testId, @Param("sourceType") String sourceType, @Param("sourceIdentity") String sourceIdentity, @Param("occurredAt") Date occurredAt); /** 查询已持久化的阈值及离线异常事实。 */ List selectWarningExceptions(@Param("testId") Long testId, @Param("status") String status); TTestWarningException selectWarningExceptionById(Long exceptionId); /** 仅将开放异常转为已关闭,原始异常事实仍保留。 */ int closeWarningException(@Param("exceptionId") Long exceptionId, @Param("handledBy") Long handledBy, @Param("handledByName") String handledByName, @Param("handledAt") Date handledAt, @Param("handlingNote") String handlingNote); /** 查询当前正在接收的测试,供接收调度绑定测试事实。 */ List selectReceivingTestIds(); int insertRealtimeRecord(TTestRealtimeRecord record); String selectRealtimeRecordContentHash(@Param("testId") Long testId, @Param("testBatteryId") Long testBatteryId, @Param("captureSlotUtc") Date captureSlotUtc); int insertStepRecord(TTestStepRecord record); int insertCycleRecord(TTestCycleRecord record); String selectStepRecordContentHash(@Param("testBatteryId") Long testBatteryId, @Param("sourceIdentity") String sourceIdentity, @Param("dedupeKey") String dedupeKey); String selectCycleRecordContentHash(@Param("testBatteryId") Long testBatteryId, @Param("sourceIdentity") String sourceIdentity, @Param("dedupeKey") String dedupeKey); List> selectPersistedFinalRealtimeRecords(@Param("testId") Long testId); List> selectPersistedFinalStepRecords(@Param("testId") Long testId); List> selectPersistedFinalCycleRecords(@Param("testId") Long testId); boolean wasAggregateDeleted(@Param("testId") Long testId, @Param("dataType") String dataType, @Param("testBatteryId") Long testBatteryId, @Param("sourceIdentity") String sourceIdentity, @Param("dedupeKey") String dedupeKey); boolean wasRealtimeSlotDeleted(@Param("testId") Long testId, @Param("testBatteryId") Long testBatteryId, @Param("captureSlotMillis") long captureSlotMillis); String selectLogicStepMappingsJson(Long testId); int updateLogicStepMappings(@Param("testId") Long testId, @Param("mappingsJson") String mappingsJson, @Param("updateBy") String updateBy, @Param("updateTime") Date updateTime); int updateConsoleDetail(@Param("testId") Long testId, @Param("detailJson") String detailJson, @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 selectEnabledUserOptions(); List selectEnabledTestTypeOptions(); List selectEnabledBatteryOptions(); List selectRegisteredChannelOptions(); List selectEnabledCollectorOptions(); /** 锁定检测柜通道的最新可观测事实,供开始接收校验使用。 */ TDetectionChannel selectReceptionChannelForUpdate(Long channelId); int hasReceivingTestForAdapter(@Param("adapterCode") String adapterCode); List selectReceivingChannelsForAdapter(@Param("adapterCode") String adapterCode); 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); int insertDataRevisionAction(TTestDataRevisionAction action); List selectDataRevisionActions(TTestDataRevisionAction query); TTestDataRevisionAction selectDataRevisionActionById(Long actionId); int deleteRealtimeRecordsByIds(@Param("testId") Long testId, @Param("recordIds") List recordIds); int deleteStepRecordsByIds(@Param("testId") Long testId, @Param("recordIds") List recordIds); int deleteCycleRecordsByIds(@Param("testId") Long testId, @Param("recordIds") List recordIds); int deleteTestRealtimeRecordsByTestId(Long testId); int deleteTestStepRecordsByTestId(Long testId); int deleteTestCycleRecordsByTestId(Long testId); int deleteTestDataRevisionActionsByTestId(Long testId); int countTestBatteryNo(@Param("testId") Long testId, @Param("batteryNo") String batteryNo); }