<?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.yeejoin.amos.boot.module.common.api.mapper.FailureDetailsMapper">
    <select id="selectAllPage" resultType="com.yeejoin.amos.boot.module.common.api.entity.FailureDetails">
        SELECT
            sequence_nbr,
            current_status,
            failure_equipment_id,
            failure_equipment,
            fault_time,
            fault_phenomenon,
            submission_name,
            submission_pid,
            biz_code,
            submission_time,
            submission_branch,
            submission_branch_id
        FROM
            cb_failure_details

    </select>

    <select id="selectISubPage" resultType="com.yeejoin.amos.boot.module.common.api.entity.FailureDetails">
        SELECT
            sequence_nbr,
            current_status,
            failure_equipment_id,
            failure_equipment,
            fault_time,
            fault_phenomenon,
            submission_name,
            submission_pid,
            biz_code,
            submission_time,
            submission_branch,
            submission_branch_id
        FROM
            cb_failure_details
        WHERE
            submission_pid = #{submissionPid}

    </select>

    <select id="selectInProcessing" resultType="com.yeejoin.amos.boot.module.common.api.entity.FailureDetails">
        SELECT
            sequence_nbr,
            current_status,
            failure_equipment_id,
            failure_equipment,
            fault_time,
            fault_phenomenon,
            submission_name,
            submission_pid,
            biz_code,
            submission_time,
            submission_branch,
            submission_branch_id
        FROM
            cb_failure_details
        WHERE
            cb_failure_details.current_status = 3
           OR
            cb_failure_details.current_status = 0
    </select>

    <select id="selectStatusWaitTj" resultType="com.yeejoin.amos.boot.module.common.api.entity.FailureDetails">
        SELECT
            sequence_nbr,
            current_status,
            failure_equipment_id,
            failure_equipment,
            fault_time,
            fault_phenomenon,
            submission_name,
            submission_pid,
            biz_code,
            submission_time,
            submission_branch,
            submission_branch_id
        FROM
            cb_failure_details
        WHERE
            cb_failure_details.current_status = 1

    </select>

    <select id="selectStatusWaitWx" resultType="com.yeejoin.amos.boot.module.common.api.entity.FailureDetails">
        SELECT
            sequence_nbr,
            current_status,
            failure_equipment_id,
            failure_equipment,
            fault_time,
            fault_phenomenon,
            submission_name,
            submission_pid,
            biz_code,
            submission_time,
            submission_branch,
            submission_branch_id
        FROM
            cb_failure_details
        WHERE
            cb_failure_details.current_status = 6
           OR
            cb_failure_details.current_status = 2

    </select>

    <select id="selectStatusCount" resultType="com.yeejoin.amos.boot.module.common.api.dto.StatusDto">
        SELECT
            cb_failure_details.current_status  ,
            count(cb_failure_details.current_status)
         AS currentStatusCount
        FROM
            cb_failure_details
        GROUP BY
            cb_failure_details.current_status
    </select>

    <select id="selectStatusWx" resultType="com.yeejoin.amos.boot.module.common.api.dto.StatusDto">
        SELECT
            cb_failure_details.current_status  ,
            count(cb_failure_details.current_status)
                AS currentStatusCount
        FROM
            cb_failure_details
        WHERE
            cb_failure_details.current_status = 6
        OR
            cb_failure_details.current_status = 2
        GROUP BY
            cb_failure_details.current_status
    </select>

    <select id="selectStatusFq" resultType="com.yeejoin.amos.boot.module.common.api.dto.StatusDto">
        SELECT
            cb_failure_details.current_status  ,
            count(cb_failure_details.current_status)
                AS currentStatusCount
        FROM
            cb_failure_details
        WHERE
            cb_failure_details.current_status = 1

        GROUP BY
            cb_failure_details.current_status
    </select>

    <select id="selectStatusLeader" resultType="com.yeejoin.amos.boot.module.common.api.dto.StatusDto">
        SELECT
            cb_failure_details.current_status  ,
            count(cb_failure_details.current_status)
                AS currentStatusCount
        FROM
            cb_failure_details
        WHERE
            cb_failure_details.current_status = 0
        or
             cb_failure_details.current_status = 3
        GROUP BY
            cb_failure_details.current_status
    </select>

    <select id="selectStatusFqp" parameterType="integer" resultType="com.yeejoin.amos.boot.module.common.api.dto.StatusDto">
        SELECT
            cb_failure_details.current_status  ,
            count(cb_failure_details.current_status)
                AS currentStatusCount
        FROM
            cb_failure_details
        WHERE
            submission_pid = #{submissionPid}
        GROUP BY
            cb_failure_details.current_status
    </select>



</mapper>
