<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hdkj.lt.bf.mapper.FaultTransferSchemeSwitchingSequenceMapper">


    <select id="countSwitch"
            resultType="com.hdkj.lt.bf.entity.dto.FhzgPlanTransferSchemeSwitchingSequenceCountDTO">

        SELECT
            count( ss.id ) switchOperationTimes,
            count( CASE WHEN ss.is_auto_switch = '0' THEN 1 END ) nonAutoSwitchOperationTimes
        FROM
            fhzg_fault_transfer_scheme_switching_sequence ss
        WHERE
            ss.scheme_id = #{id}
    </select>   <select id="getTransferSchemeSwitchingSequenceBySchemeId"
            resultType="com.hdkj.lt.bf.entity.dto.FhzgFaultTransferSchemeSwitchingSequenceDTO">
        select
            ss.id id,
            ss.scheme_id schemeId,
            ss.operation_content operationContent,
            ss.loop_close_check loopCloseCheck,
            ss.final_state_check finalStateCheck,
            ss.switching_seq switchingSeq
        from
            fhzg_fault_transfer_scheme_switching_sequence ss
        where ss.scheme_id =#{id}
    </select>

    <select id="getTransferSchemeSwitchingSequenceBySchemeIdPage"
            resultType="com.hdkj.lt.bf.entity.dto.FhzgFaultTransferSchemeSwitchingSequenceDTO">
        select ss.id,
               ss.scheme_id         schemeId,
               ss.switch_id         switchId,
               ss.switch_name       switchName,
               ss.switch_type       switchType,
               ss.is_auto_switch    isAutoSwitch,
               ss.operation_content operationContent,
               ss.switching_seq  switchingSeq,
               ss.loop_close_check  loopCloseCheck,
               ss.final_state_check finalStateCheck
        from fhzg_fault_transfer_scheme_switching_sequence ss
        where ss.scheme_id = #{params.id}
        order by ss.switching_seq asc
    </select></mapper>
