| | |
| | | select t.test_id, t.test_name, t.creator_id, creator.nick_name creator_name, |
| | | t.principal_id, principal.nick_name principal_name, |
| | | t.test_type_id, ty.test_type_name, t.test_purpose, |
| | | t.test_status, t.reception_status, t.monitor_timeout_minutes, |
| | | case when t.test_status = 'RUNNING' |
| | | and exists (select 1 from t_test_collector_exception_interval exception_fact |
| | | where exception_fact.test_id = t.test_id |
| | | and exception_fact.interval_status = 'OPEN') |
| | | then 'RUNNING_ABNORMAL' |
| | | else t.test_status end test_status, |
| | | t.reception_status, t.monitor_timeout_minutes, |
| | | t.started_at_utc, t.ended_at_utc, t.del_flag, |
| | | t.create_by, t.create_time, t.update_by, t.update_time, t.remark, |
| | | (select count(1) from t_test_battery b where b.test_id = t.test_id and b.del_flag = 0) battery_count, |
| | |
| | | <if test="testName != null and testName != ''">and t.test_name like concat('%', #{testName}, '%')</if> |
| | | <if test="testTypeId != null">and t.test_type_id = #{testTypeId}</if> |
| | | <if test="batteryNo != null and batteryNo != ''">and exists (select 1 from t_test_battery fb where fb.test_id = t.test_id and fb.battery_no = #{batteryNo} and fb.del_flag = 0)</if> |
| | | <if test="testStatus != null and testStatus != ''">and t.test_status = #{testStatus}</if> |
| | | <if test="testStatus != null and testStatus != ''"> |
| | | and case |
| | | when #{testStatus} = 'RUNNING_ABNORMAL' then t.test_status = 'RUNNING' |
| | | and exists (select 1 from t_test_collector_exception_interval exception_fact |
| | | where exception_fact.test_id = t.test_id and exception_fact.interval_status = 'OPEN') |
| | | when #{testStatus} = 'RUNNING' then t.test_status = 'RUNNING' |
| | | and not exists (select 1 from t_test_collector_exception_interval exception_fact |
| | | where exception_fact.test_id = t.test_id and exception_fact.interval_status = 'OPEN') |
| | | else t.test_status = #{testStatus} |
| | | end |
| | | </if> |
| | | <if test="receptionStatus != null and receptionStatus != ''">and t.reception_status = #{receptionStatus}</if> |
| | | <if test="beginCreateTime != null">and t.create_time >= #{beginCreateTime}</if> |
| | | <if test="endCreateTime != null">and t.create_time <= #{endCreateTime}</if> |
| | |
| | | </update> |
| | | <update id="updateReceptionStopped"> |
| | | update t_test |
| | | set test_status = 'TERMINATED', reception_status = 'ENDED', ended_at_utc = #{endedAtUtc}, |
| | | set test_status = 'COMPLETED', reception_status = 'ENDED', ended_at_utc = #{endedAtUtc}, |
| | | update_by = #{updateBy}, update_time = #{endedAtUtc} |
| | | where test_id = #{testId} and reception_status in ('RECEIVING', 'PAUSED') and del_flag = 0 |
| | | </update> |
| | |
| | | left join t_test_collector_channel mapping on mapping.battery_relation_id = exception_fact.battery_relation_id |
| | | and mapping.collector_id = exception_fact.collector_id |
| | | and mapping.channel_code = exception_fact.collector_channel_code |
| | | where exception_fact.test_id = #{testId} |
| | | where exception_fact.test_id = #{testId} and exception_fact.interval_status = 'OPEN' |
| | | order by exception_fact.opened_at_utc, exception_fact.interval_id |
| | | </select> |
| | | </mapper> |