| | |
| | | <result property="exceptionInfo" column="exception_info" /> |
| | | <result property="delFlag" column="del_flag" /> |
| | | </resultMap> |
| | | <resultMap id="TTestResultRecordMap" type="TTestResultRecord"> |
| | | <id property="resultId" column="result_id" /> |
| | | <result property="sourceType" column="source_type" /> |
| | | <result property="testId" column="test_id" /> |
| | | <result property="testName" column="test_name" /> |
| | | <result property="testStatus" column="test_status" /> |
| | | <result property="receptionStatus" column="reception_status" /> |
| | | <result property="relationId" column="relation_id" /> |
| | | <result property="batteryNo" column="battery_no" /> |
| | | <result property="sourceId" column="source_id" /> |
| | | <result property="sourceIdentity" column="source_identity" /> |
| | | <result property="intervalId" column="interval_id" /> |
| | | <result property="intervalStartAtUtc" column="interval_start_at_utc" /> |
| | | <result property="intervalEndAtUtc" column="interval_end_at_utc" /> |
| | | <result property="cycleNo" column="cycle_no" /> |
| | | <result property="stepNo" column="step_no" /> |
| | | <result property="stepType" column="step_type" /> |
| | | <result property="workStatus" column="work_status" /> |
| | | <result property="voltageV" column="voltage_v" /> |
| | | <result property="currentA" column="current_a" /> |
| | | <result property="capacityAh" column="capacity_ah" /> |
| | | <result property="energyWh" column="energy_wh" /> |
| | | <result property="metricCode" column="metric_code" /> |
| | | <result property="metricValue" column="metric_value" /> |
| | | <result property="unit" column="unit" /> |
| | | <result property="deviceTimeUtc" column="device_time_utc" /> |
| | | <result property="deviceTimeRaw" column="device_time_raw" /> |
| | | <result property="serverReceivedAtUtc" column="server_received_at_utc" /> |
| | | </resultMap> |
| | | <resultMap id="TTestCollectorExceptionIntervalResultMap" type="TTestCollectorExceptionInterval"> |
| | | <id property="intervalId" column="interval_id" /> |
| | | <result property="testId" column="test_id" /> |
| | |
| | | <if test="beginResultTime != null">and result.result_time >= #{beginResultTime}</if> |
| | | <if test="endResultTime != null">and result.result_time <= #{endResultTime}</if> |
| | | order by result.result_time, result.result_id |
| | | </select> |
| | | |
| | | <select id="selectHistoricalResultRecords" parameterType="TTestResultQuery" resultMap="TTestResultRecordMap"> |
| | | select * from ( |
| | | select s.sample_id result_id, 'CABINET_CHANNEL' source_type, t.test_id, t.test_name, |
| | | t.test_status, t.reception_status, b.relation_id, b.battery_no, |
| | | s.channel_id source_id, |
| | | concat('CABINET:', coalesce(cab.adapter_code, ''), ':', coalesce(cab.devtype, ''), ':', |
| | | coalesce(cab.devid, ''), ':', coalesce(cab.subdevid, ''), ':', coalesce(cab.chlid, '')) source_identity, |
| | | s.reception_interval_id interval_id, i.start_boundary_at_utc interval_start_at_utc, |
| | | i.end_boundary_at_utc interval_end_at_utc, s.cycle_no, s.step_no, s.step_type, |
| | | s.step_type work_status, s.voltage_v, s.current_a, s.capacity_ah, s.energy_wh, |
| | | null metric_code, null metric_value, 'V/A/Ah/Wh' unit, 'voltage=V,current=A,capacity=Ah,energy=Wh' unit_metadata, |
| | | s.device_time_utc, s.device_time_raw, s.received_at_utc server_received_at_utc, |
| | | case when exists (select 1 from t_test_integrity_issue x where x.test_id = t.test_id and x.issue_status = 'OPEN') then '完成确认中' else '完整性已通过' end integrity_conclusion |
| | | from t_test_sample s |
| | | join t_test t on t.test_id = s.test_id and t.test_status = 'COMPLETED' and t.del_flag = 0 |
| | | join t_test_channel_binding tb on tb.binding_id = s.binding_id |
| | | join t_test_battery b on b.relation_id = tb.battery_relation_id and b.del_flag = 0 |
| | | join t_test_reception_interval i on i.interval_id = s.reception_interval_id and i.interval_status = 'CLOSED' |
| | | join t_detection_channel cab on cab.channel_id = s.channel_id |
| | | union all |
| | | select cs.sample_id result_id, 'COLLECTOR_CHANNEL' source_type, t.test_id, t.test_name, |
| | | t.test_status, t.reception_status, b.relation_id, b.battery_no, |
| | | cs.collector_id source_id, |
| | | concat('COLLECTOR:', coalesce(col.collector_code, cs.collector_id), ':', cs.collector_channel_code) source_identity, |
| | | cs.reception_interval_id interval_id, i.start_boundary_at_utc interval_start_at_utc, |
| | | i.end_boundary_at_utc interval_end_at_utc, null cycle_no, null step_no, null step_type, |
| | | null work_status, null voltage_v, null current_a, null capacity_ah, null energy_wh, |
| | | cs.metric_code, cs.metric_value, cs.unit, concat('metric=', cs.metric_code, ',unit=', cs.unit) unit_metadata, |
| | | cs.device_time_utc, cs.device_time_raw, cs.server_received_at_utc, |
| | | case when exists (select 1 from t_test_integrity_issue x where x.test_id = t.test_id and x.issue_status = 'OPEN') then '完成确认中' else '完整性已通过' end integrity_conclusion |
| | | from t_test_collector_sample cs |
| | | join t_test t on t.test_id = cs.test_id and t.test_status = 'COMPLETED' and t.del_flag = 0 |
| | | join t_test_channel_binding tb on tb.binding_id = cs.binding_id |
| | | join t_test_battery b on b.relation_id = tb.battery_relation_id and b.del_flag = 0 |
| | | join t_collector col on col.collector_id = cs.collector_id |
| | | join t_test_reception_interval i on i.interval_id = cs.reception_interval_id and i.interval_status = 'CLOSED' |
| | | ) result |
| | | <where> |
| | | <if test="testId != null">and result.test_id = #{testId}</if> |
| | | <if test="testName != null and testName != ''">and result.test_name like concat('%', #{testName}, '%')</if> |
| | | <if test="batteryNo != null and batteryNo != ''">and result.battery_no like concat('%', #{batteryNo}, '%')</if> |
| | | <if test="sourceType != null and sourceType != ''">and result.source_type = #{sourceType}</if> |
| | | <if test="sourceId != null">and result.source_id = #{sourceId}</if> |
| | | <if test="sourceChannelCode != null and sourceChannelCode != ''">and result.source_identity like concat('%:', #{sourceChannelCode})</if> |
| | | <if test="beginDeviceTime != null">and result.device_time_utc >= #{beginDeviceTime}</if> |
| | | <if test="endDeviceTime != null">and result.device_time_utc <= #{endDeviceTime}</if> |
| | | <if test="cycleNo != null">and result.cycle_no = #{cycleNo}</if> |
| | | <if test="stepNo != null">and result.step_no = #{stepNo}</if> |
| | | </where> |
| | | order by result.device_time_utc, result.source_type, result.result_id |
| | | </select> |
| | | |
| | | <select id="countTestTypeEnabled" resultType="int"> |