<?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.tzs.flc.api.mapper.CylinderInfoMapper">


    <select id="queryNumAndOutOfDateNum" resultType="java.util.Map">
        SELECT
        count( sequence_nbr ) AS cylinderNum,
        count( CASE WHEN t.next_inspection_date <![CDATA[ < ]]> now() THEN 1 ELSE 0 END ) AS outOfDateNum
        FROM
        tz_cylinder_info t
        WHERE
        t.sequence_nbr IN ( SELECT max( tt.sequence_nbr ) FROM tz_cylinder_info tt GROUP BY tt.sequence_code )
        AND t.app_id = (
        SELECT
        u.app_id
        FROM
        tz_cylinder_unit u
        WHERE
        u.sequence_nbr = #{sequenceNbr}
        )
    </select>


</mapper>
