<?xml version="1.0" encoding="gbk" standalone="no"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="">
    <!-- 告警总量
        select sum(gjCount) as mcount,xzbh,xzmc from(
        select count(*) as gjCount, a.alarmdeviceid,a.channelnum,b.xzbh,c.xzmc from ywalarmeventinfo a,Sbtdspsr b, ptxzs c
        where a.alarmdeviceid=b.sbbh and a.channelnum=b.tdbh and b.xzbh=c.xzbh and alarmdevicetype=1
        <isNotEmpty prepend="and" property="timeStart">
         <![CDATA[
            a.alarmtime >= #timeStart#
         ]]>
        </isNotEmpty>
        <isNotEmpty prepend="and" property="timeEnd">
        <![CDATA[
            a.alarmtime <= #timeEnd#
         ]]>
        </isNotEmpty>
        <isNotEmpty prepend="and" property="areacode">
            b.xzbh = #areacode#
        </isNotEmpty>
        group by a.alarmdeviceid,a.channelnum,b.xzbh,c.xzmc
        ) x group by xzbh,xzmc
        <isNotEmpty prepend=' ' property='start'>
            limit #start# ,#limit#
        </isNotEmpty>
     -->
    <!-- 区域设备告警统计   告警总量  恢复量 -->
    <select id="query_Ywmalarmcount" resultClass="java.util.HashMap" parameterClass="java.util.Map">
        <isEqual prepend="" property="alarmdevicetype" compareValue="1">
            select trim(cast(case when g.zcount is null then 0 else g.zcount end as char(8))) as zcount,
            trim(cast(case when h.hfcount is null then 0 else h.hfcount end as char(8))) as hfcount,
            g.xzbh,(select xzmc from ptxzs b where b.xzbh=g.xzbh ) as xzmc from(
            select sum(gjCount) as zcount,xzbh from(
            select count(*) as gjCount, a.alarmdeviceid,a.channelnum, b.xzbh from ywalarmeventinfo
            a, sbtdspsr b where  b.kz3 is not null and b.kz3 != '1' and a.alarmdeviceid=b.sbbh and a.channelnum=b.tdbh
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[   b.xzbh in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[      a.alarmtime >= #timeStart#   ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[      a.alarmtime <= #timeEnd#    ]]>
            </isNotEmpty>
            group by a.alarmdeviceid,a.channelnum, b.xzbh ) x group by xzbh ) g left join
            (
            select sum(gjCount) as hfcount,xzbh from(
            select count(*) as gjCount, d.alarmdeviceid,d.channelnum,e.xzbh xzbh from
            ywalarmeventinfo d,sbtdspsr e
            where  e.kz3 is not null and e.kz3 != '1' and d.alarmdeviceid=e.sbbh and d.channelnum=e.tdbh
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[  e.xzbh in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>

            <isNotEmpty prepend="and" property="alarmdevicetype">
                d.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            and d.processstatus in (915,914,912)
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[       d.processtime >= #timeStart#    ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[        d.processtime <= #timeEnd#     ]]>
            </isNotEmpty>
            group by d.alarmdeviceid,d.channelnum,e.xzbh
            ) y group by xzbh
            ) h on g.xzbh = h.xzbh
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="2">
            select trim(cast(case when g.zcount is null then 0 else g.zcount end as char(8))) as zcount,
            trim(cast(case when h.hfcount is null then 0 else h.hfcount end as char(8))) as hfcount,
            g.xzbh,(select xzmc from ptxzs b where b.xzbh=g.xzbh ) as xzmc from(
            select sum(gjCount) as zcount,xzbh from(
            select count(*) as gjCount, a.alarmdeviceid, b.MACHINEAREANUM xzbh from ywalarmeventinfo a,YWMACHINEINFO b
            where a.alarmdeviceid=b.MACHINEID
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[ b.MACHINEAREANUM in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[
                a.alarmtime >= #timeStart#
                ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[
                 a.alarmtime <= #timeEnd#
                ]]>
            </isNotEmpty>
            group by a.alarmdeviceid, b.MACHINEAREANUM ) x group by xzbh ) g left join
            ( select sum(gjCount) as hfcount,xzbh from( select count(*) as gjCount,
            d.alarmdeviceid,e.MACHINEAREANUM xzbh from ywalarmeventinfo d,YWMACHINEINFO e
            where d.alarmdeviceid=e.machineid
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[ e.MACHINEAREANUM in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                d.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            and d.processstatus in (915,914,912)
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[
                  d.processtime >= #timeStart#
                ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[
                  d.processtime <= #timeEnd#
               ]]>
            </isNotEmpty>
            group by d.alarmdeviceid,e.MACHINEAREANUM ) y group by xzbh ) h on g.xzbh = h.xzbh
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="3">
            select trim(cast(case when g.zcount is null then 0 else g.zcount end as char(8))) as zcount,
            trim(cast(case when h.hfcount is null then 0 else h.hfcount end as char(8))) as hfcount,
            g.xzbh,(select xzmc from ptxzs b where b.xzbh=g.xzbh ) as xzmc from(
            select sum(gjCount) as zcount,xzbh from(
            select count(*) as gjCount, a.alarmdeviceid,b.QYBH xzbh from ywalarmeventinfo
            a, NHYWJTXHDGL b where a.alarmdeviceid=b.xh
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[  b.QYBH in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[
             a.alarmtime >= #timeStart#
            ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[
              a.alarmtime <= #timeEnd#
            ]]>
            </isNotEmpty>
            group by a.alarmdeviceid,b.QYBH ) x group by xzbh ) g left join
            ( select sum(gjCount) as hfcount,xzbh from( select count(*) as gjCount,
            d.alarmdeviceid,e.QYBH xzbh from ywalarmeventinfo d,NHYWJTXHDGL e
            where d.alarmdeviceid=e.XHDBH
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[   e.QYBH in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                d.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            and d.processstatus in (915,914,912)
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[     d.processtime >= #timeStart#     ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[        d.processtime <= #timeEnd#     ]]>
            </isNotEmpty>
            group by d.alarmdeviceid,e.QYBH ) y group by xzbh ) h on g.xzbh = h.xzbh

        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="4">
            select trim(cast(case when g.zcount is null then 0 else g.zcount end as char(8))) as zcount,
            trim(cast(case when h.hfcount is null then 0 else h.hfcount end as char(8))) as hfcount,
            g.xzbh,(select xzmc from ptxzs b where b.xzbh=g.xzbh ) as xzmc from(
            select sum(gjCount) as zcount,xzbh from(
            select count(*) as gjCount, a.alarmdeviceid,b.QYBH xzbh from ywalarmeventinfo a, NHYWJTLEDYDPGL b
            where a.alarmdeviceid=b.xh
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[b.QYBH in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>

            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[        a.alarmtime >= #timeStart#     ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[       a.alarmtime <= #timeEnd#     ]]>
            </isNotEmpty>
            group by a.alarmdeviceid,b.QYBH ) x group by xzbh ) g left join
            ( select sum(gjCount) as hfcount,xzbh from( select count(*) as gjCount,
            d.alarmdeviceid,e.QYBH xzbh from ywalarmeventinfo d,NHYWJTLEDYDPGL e
            where d.alarmdeviceid=e.xh
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[e.QYBH in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                d.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            and d.processstatus in (915,914,912)
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[        d.processtime >= #timeStart#     ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[        d.processtime <= #timeEnd#     ]]>
            </isNotEmpty>
            group by d.alarmdeviceid,e.QYBH ) y group by xzbh ) h on g.xzbh = h.xzbh
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="10">
            select trim(cast(case when g.zcount is null then 0 else g.zcount end as char(8))) as zcount,
            trim(cast(case when h.hfcount is null then 0 else h.hfcount end as char(8))) as hfcount,
            g.xzbh,(select xzmc from ptxzs b where b.xzbh=g.xzbh ) as xzmc from(
            select sum(gjCount) as zcount,xzbh from(
            select count(*) as gjCount, a.alarmdeviceid,b.regionid xzbh from ywalarmeventinfo a, its.ksh_detector b
            where a.alarmdeviceid=b.id
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[b.regionid  in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="detectortype">
                b.detectortype = #detectortype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[        a.alarmtime >= #timeStart#     ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[       a.alarmtime <= #timeEnd#     ]]>
            </isNotEmpty>
            group by a.alarmdeviceid,b.regionid ) x group by xzbh ) g left join
            ( select sum(gjCount) as hfcount,xzbh from( select count(*) as gjCount,
            d.alarmdeviceid,e.regionid xzbh from ywalarmeventinfo d,its.ksh_detector e
            where d.alarmdeviceid=e.id
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[e.regionid in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="detectortype">
                e.detectortype = #detectortype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                d.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            and d.processstatus in (915,914,912)
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[        d.processtime >= #timeStart#     ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[        d.processtime <= #timeEnd#     ]]>
            </isNotEmpty>
            group by d.alarmdeviceid,e.regionid ) y group by xzbh ) h on g.xzbh = h.xzbh
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="11">
            select trim(cast(case when g.zcount is null then 0 else g.zcount end as char(8))) as zcount,
            trim(cast(case when h.hfcount is null then 0 else h.hfcount end as char(8))) as hfcount,
            g.xzbh,(select xzmc from ptxzs b where b.xzbh=g.xzbh ) as xzmc from(
            select sum(gjCount) as zcount,xzbh from(
            select count(*) as gjCount, a.alarmdeviceid,b.regionid xzbh from ywalarmeventinfo a, its.ksh_detector b
            where a.alarmdeviceid=b.id
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[b.regionid  in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="detectortype">
                b.detectortype = #detectortype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[        a.alarmtime >= #timeStart#     ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[       a.alarmtime <= #timeEnd#     ]]>
            </isNotEmpty>
            group by a.alarmdeviceid,b.regionid ) x group by xzbh ) g left join
            ( select sum(gjCount) as hfcount,xzbh from( select count(*) as gjCount,
            d.alarmdeviceid,e.regionid xzbh from ywalarmeventinfo d,its.ksh_detector e
            where d.alarmdeviceid=e.id
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[e.regionid in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="detectortype">
                e.detectortype = #detectortype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                d.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            and d.processstatus in (915,914,912)
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[        d.processtime >= #timeStart#     ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[        d.processtime <= #timeEnd#     ]]>
            </isNotEmpty>
            group by d.alarmdeviceid,e.regionid ) y group by xzbh ) h on g.xzbh = h.xzbh
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="12">
            select trim(cast(case when g.zcount is null then 0 else g.zcount end as char(8))) as zcount,
            trim(cast(case when h.hfcount is null then 0 else h.hfcount end as char(8))) as hfcount,
            g.xzbh,(select xzmc from ptxzs b where b.xzbh=g.xzbh ) as xzmc from(
            select sum(gjCount) as zcount,xzbh from(
            select count(*) as gjCount, a.alarmdeviceid,b.gxdwbh xzbh from ywalarmeventinfo a, its.ksh_zxld b
            where a.alarmdeviceid=b.xh
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[b.gxdwbh   in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[ a.alarmtime >= #timeStart# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[ a.alarmtime <= #timeEnd# ]]>
            </isNotEmpty>
            group by a.alarmdeviceid,b.gxdwbh ) x group by xzbh ) g left join
            ( select sum(gjCount) as hfcount,xzbh from( select count(*) as gjCount,
            d.alarmdeviceid,e.gxdwbh xzbh from ywalarmeventinfo d,its.ksh_zxld e
            where d.alarmdeviceid=e.xh
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[e.gxdwbh  in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                d.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            and d.processstatus in (915,914,912)
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[        d.processtime >= #timeStart#     ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[        d.processtime <= #timeEnd#     ]]>
            </isNotEmpty>
            group by d.alarmdeviceid,e.gxdwbh ) y group by xzbh ) h on g.xzbh = h.xzbh
        </isEqual>
    </select>

    <!-- 区域设备告警统计    上面用的  left join 所以分页可以这么写-->
    <select id="count_Ywmalarmcount" resultClass="java.lang.Integer" parameterClass="java.util.Map">
        <isEqual prepend="" property="alarmdevicetype" compareValue="1">
            select count(*) from (
            select sum(gjCount) as mcount,xzbh,(select xzmc from ptxzs f where f.xzbh=x.xzbh ) as xzmc from(
            select count(*) as gjCount, a.alarmdeviceid,a.channelnum, b.xzbh from ywalarmeventinfo a,
            sbtdspsr b where b.kz3 is not null and b.kz3 != '1' and a.alarmdeviceid=b.sbbh and a.channelnum=b.tdbh
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[b.xzbh in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[
			a.alarmtime >= #timeStart#
		 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[
			a.alarmtime <= #timeEnd#
		 ]]>
            </isNotEmpty>
            group by a.alarmdeviceid,a.channelnum,b.xzbh
            ) x group by xzbh
            ) y
        </isEqual>
        <isEqual prepend=" " property="alarmdevicetype" compareValue="2">
            select count(*) from (
            select sum(gjCount) as mcount,xzbh,(select xzmc from ptxzs b where b.xzbh=x.xzbh ) as xzmc from(
            select count(*) as gjCount, a.alarmdeviceid,b.MACHINEAREANUM xzbh from ywalarmeventinfo a,
            YWMACHINEINFO b where a.alarmdeviceid=b.MACHINEID
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[b.MACHINEAREANUM in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[		a.alarmtime >= #timeStart#	 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[			a.alarmtime <= #timeEnd#		 ]]>
            </isNotEmpty>
            group by a.alarmdeviceid,b.MACHINEAREANUM
            ) x group by xzbh
            ) y
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="3">
            select count(*) from (
            select sum(gjCount) as mcount,xzbh,(select xzmc from ptxzs b where b.xzbh=x.xzbh ) as xzmc from(
            select count(*) as gjCount, a.alarmdeviceid,b.QYBH xzbh from ywalarmeventinfo a,NHYWJTXHDGL b
            where a.alarmdeviceid=b.xh
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[ b.QYBH in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[			a.alarmtime >= #timeStart#		 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[			a.alarmtime <= #timeEnd#		 ]]>
            </isNotEmpty>
            group by a.alarmdeviceid,b.QYBH ) x group by xzbh ) y
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="4">
            select count(*) from (
            select sum(gjCount) as mcount,xzbh,(select xzmc from ptxzs b where b.xzbh=x.xzbh ) as xzmc from(
            select count(*) as gjCount, a.alarmdeviceid,b.QYBH xzbh from ywalarmeventinfo a,
            NHYWJTLEDYDPGL b where a.alarmdeviceid=b.xh
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[ b.QYBH in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[			a.alarmtime >= #timeStart#		 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[			a.alarmtime <= #timeEnd#		 ]]>
            </isNotEmpty>
            group by a.alarmdeviceid,b.QYBH
            ) x group by xzbh
            ) y
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="10">
            select count(*) from (
            select sum(gjCount) as mcount,xzbh,(select xzmc from ptxzs b where b.xzbh=x.xzbh ) as xzmc from(
            select count(*) as gjCount, a.alarmdeviceid,b.regionid xzbh from ywalarmeventinfo a,its.ksh_detector b
            where a.alarmdeviceid=b.id
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[ b.regionid in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="detectortype">
                b.detectortype = #detectortype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[			a.alarmtime >= #timeStart#		 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[			a.alarmtime <= #timeEnd#		 ]]>
            </isNotEmpty>
            group by a.alarmdeviceid,b.regionid
            ) x group by xzbh
            ) y
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="11">
            select count(*) from (
            select sum(gjCount) as mcount,xzbh,(select xzmc from ptxzs b where b.xzbh=xzbh ) as xzmc from(
            select count(*) as gjCount, a.alarmdeviceid,b.regionid xzbh from ywalarmeventinfo a,its.ksh_detector b
            where a.alarmdeviceid=b.id
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[ b.regionid in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="detectortype">
                b.detectortype = #detectortype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[			a.alarmtime >= #timeStart#		 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[			a.alarmtime <= #timeEnd#		 ]]>
            </isNotEmpty>
            group by a.alarmdeviceid,b.regionid
            ) x group by xzbh
            ) y
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="12">
            select count(*) from (
            select sum(gjCount) as mcount,xzbh,(select xzmc from ptxzs b where b.xzbh=xzbh ) as xzmc from(
            select count(*) as gjCount, a.alarmdeviceid,b.gxdwbh xzbh from ywalarmeventinfo a,its.ksh_zxld b
            where a.alarmdeviceid=b.xh
            <isNotEmpty prepend='AND ' property='xzbh'>
                <![CDATA[ b.gxdwbh  in ]]>
                <iterate property="xzbh" conjunction="," open="(" close=")">
                    #xzbh[]#
                </iterate>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype = #alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[			a.alarmtime >= #timeStart#		 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[			a.alarmtime <= #timeEnd#		 ]]>
            </isNotEmpty>
            group by a.alarmdeviceid,b.gxdwbh
            ) x group by xzbh
            ) y
        </isEqual>
    </select>

    <!-- 区域告警设备列表 -->
    <select id="query_alarmbyArea" resultClass="java.util.HashMap" parameterClass="java.util.Map">
        <isEqual prepend="" property="alarmdevicetype" compareValue="1">
            select trim(cast(case when g.mcount is null then 0 else g.mcount end as char(8))) as
            zcount,g.tdmc,g.sbbh,g.tdbh,g.sbip,
            trim(cast(case when h.mcount is null then 0 else h.mcount end as char(8))) as hfcount from(
            select count(*) as mcount, tdmc,b.sbbh,tdbh,sbip from ywalarmeventinfo a, Sbtdspsr b left join sbxx c
            on b.sbbh = c.sbbh where  b.kz3 is not null and b.kz3 != '1' and a.alarmdeviceid = b.sbbh and a.channelnum = b.tdbh and a.alarmdevicetype=1
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[
			a.alarmtime >= #timeStart#
		 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[
			a.alarmtime <= #timeEnd#
		 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and " property="areacode">
                ( b.xzbh = #areacode# or (b.xzbh in (select xzbh from Ptxzs start with sjxzbh= #areacode# connect by
                sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by tdmc,b.sbbh,tdbh,sbip
            ) g left join(
            select count(*) as mcount, tdmc,e.sbbh,tdbh,sbip from ywalarmeventinfo d, Sbtdspsr e left join sbxx f
            on e.sbbh = f.sbbh where  e.kz3 is not null and e.kz3 != '1' and d.alarmdeviceid = e.sbbh and d.channelnum = e.tdbh
            and d.alarmdevicetype=1 and d.processstatus in (915,914,912)
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[
			d.alarmtime >= #timeStart#
		 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[
			d.alarmtime <= #timeEnd#
		 ]]>
            </isNotEmpty>
            <isNotEmpty prepend=" and" property="areacode">
                ( e.xzbh = #areacode# or (e.xzbh in (select xzbh from Ptxzs start with sjxzbh= #areacode# connect by
                sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by tdmc,e.sbbh,tdbh,sbip
            ) h on g.sbbh = h.sbbh and g.tdbh=h.tdbh
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="2">
            select trim(cast(case when g.mcount is null then 0 else g.mcount end as char(8))) as
            zcount,g.tdmc,g.sbbh,g.sbip,
            trim(cast(case when h.mcount is null then 0 else h.mcount end as char(8))) as hfcount from(
            select count(*) as mcount, b.machinename as tdmc,b.machineid as sbbh,machineip sbip from ywalarmeventinfo
            a,YWMACHINEINFO b  where a.alarmdeviceid = b.machineid
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[
			    a.alarmtime >= #timeStart#
		        ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[
			    a.alarmtime <= #timeEnd#
		        ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and " property="areacode">
                ( b.MACHINEAREANUM = #areacode# or (b.MACHINEAREANUM in (select xzbh from Ptxzs start with sjxzbh=
                #areacode# connect by sjxzbh
                =prior xzbh)) )
            </isNotEmpty>

            group by machinename ,machineid,machineip) g left join(
            select count(*) as mcount, machinename tdmc,machineid sbbh,machineip sbip from ywalarmeventinfo d,
            YWMACHINEINFO e
            where d.alarmdeviceid = e.machineid
            <isNotEmpty prepend="and" property="alarmdevicetype">
                d.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            and d.processstatus in (915,914,912)
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[
			d.alarmtime >= #timeStart#
		 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[
			d.alarmtime <= #timeEnd#
		 ]]>
            </isNotEmpty>
            <isNotEmpty prepend=" and" property="areacode">
                ( e.machineareanum = #areacode# or (e.machineareanum in (select xzbh from Ptxzs start with sjxzbh=
                #areacode# connect by sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by machinename ,machineid,machineip
            ) h on g.sbbh = h.sbbh
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="3">
            select trim(cast(case when g.mcount is null then 0 else g.mcount end as char(8))) as
            zcount,g.tdmc,g.sbbh,
            trim(cast(case when h.mcount is null then 0 else h.mcount end as char(8))) as hfcount from(
            select count(*) as mcount, b.xhdmc  as tdmc,b.xhdbh  as sbbh from ywalarmeventinfo a,nhywjtxhdgl b
            where a.alarmdeviceid = b.xh
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[a.alarmtime >= #timeStart# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[a.alarmtime <= #timeEnd# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and " property="areacode">
                ( b.qybh = #areacode# or (b.qybh in (select xzbh from Ptxzs start with sjxzbh= #areacode# connect by
                sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by xhdmc ,xhdbh
            ) g left join(
            select count(*) as mcount, xhdmc tdmc,xhdbh sbbh from ywalarmeventinfo d, nhywjtxhdgl e
            where d.alarmdeviceid = e.xh
            <isNotEmpty prepend="and" property="alarmdevicetype">
                d.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            and d.processstatus in (915,914,912)
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[	d.alarmtime >= #timeStart#	 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[	d.alarmtime <= #timeEnd# ]]>
            </isNotEmpty>
            <isNotEmpty prepend=" and" property="areacode">
                ( e.qybh = #areacode# or (e.qybh in (select xzbh from Ptxzs start with sjxzbh=
                #areacode# connect by sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by xhdmc ,xhdbh
            ) h on g.sbbh = h.sbbh
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="4">
            select trim(cast(case when g.mcount is null then 0 else g.mcount end as char(8))) as
            zcount,g.tdmc,g.sbbh,
            trim(cast(case when h.mcount is null then 0 else h.mcount end as char(8))) as hfcount from(
            select count(*) as mcount, b.ledmc  as tdmc,b.ledbh  as sbbh from ywalarmeventinfo a,NHYWJTLEDYDPGL b
            where a.alarmdeviceid=b.xh
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[a.alarmtime >= #timeStart# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[a.alarmtime <= #timeEnd# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and " property="areacode">
                ( b.qybh = #areacode# or (b.qybh in (select xzbh from Ptxzs start with sjxzbh= #areacode# connect by
                sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by ledmc ,ledbh
            ) g left join(
            select count(*) as mcount, ledmc tdmc,ledbh sbbh from ywalarmeventinfo d, NHYWJTLEDYDPGL e
            where d.alarmdeviceid = e.xh
            <isNotEmpty prepend="and" property="alarmdevicetype">
                d.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            and d.processstatus in (915,914,912)
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[	d.alarmtime >= #timeStart#	 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[	d.alarmtime <= #timeEnd# ]]>
            </isNotEmpty>
            <isNotEmpty prepend=" and" property="areacode">
                ( e.qybh = #areacode# or (e.qybh in (select xzbh from Ptxzs start with sjxzbh=
                #areacode# connect by sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by ledmc ,ledbh
            ) h on g.sbbh = h.sbbh
        </isEqual>

        <isEqual prepend="" property="alarmdevicetype" compareValue="10">
            select trim(cast(case when g.mcount is null then 0 else g.mcount end as char(8))) as
            zcount,g.tdmc,g.sbbh,
            trim(cast(case when h.mcount is null then 0 else h.mcount end as char(8))) as hfcount from(
            select count(*) as mcount, b.name  as tdmc,b.id  as sbbh from ywalarmeventinfo a,its.ksh_detector b
            where a.alarmdeviceid=b.id
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[a.alarmtime >= #timeStart# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[a.alarmtime <= #timeEnd# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and " property="areacode">
                ( b.regionid = #areacode# or (b.regionid in (select xzbh from Ptxzs start with sjxzbh= #areacode# connect by
                sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by name ,id
            ) g left join(
            select count(*) as mcount, name tdmc,id sbbh from ywalarmeventinfo d, its.ksh_detector e
            where d.alarmdeviceid = e.id
            <isNotEmpty prepend="and" property="alarmdevicetype">
                d.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            and d.processstatus in (915,914,912)
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[	d.alarmtime >= #timeStart#	 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[	d.alarmtime <= #timeEnd# ]]>
            </isNotEmpty>
            <isNotEmpty prepend=" and" property="areacode">
                ( e.regionid = #areacode# or (e.regionid in (select xzbh from Ptxzs start with sjxzbh=
                #areacode# connect by sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by name ,id
            ) h on g.sbbh = h.sbbh
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="11">
            select trim(cast(case when g.mcount is null then 0 else g.mcount end as char(8))) as
            zcount,g.tdmc,g.sbbh,
            trim(cast(case when h.mcount is null then 0 else h.mcount end as char(8))) as hfcount from(
            select count(*) as mcount, b.name  as tdmc,b.id  as sbbh from ywalarmeventinfo a,its.ksh_detector b
            where a.alarmdeviceid=b.id
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[a.alarmtime >= #timeStart# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[a.alarmtime <= #timeEnd# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and " property="areacode">
                ( b.regionid = #areacode# or (b.regionid in (select xzbh from Ptxzs start with sjxzbh= #areacode# connect by
                sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by name ,id
            ) g left join(
            select count(*) as mcount, name tdmc,id sbbh from ywalarmeventinfo d, its.ksh_detector e
            where d.alarmdeviceid = e.id
            <isNotEmpty prepend="and" property="alarmdevicetype">
                d.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            and d.processstatus in (915,914,912)
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[	d.alarmtime >= #timeStart#	 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[	d.alarmtime <= #timeEnd# ]]>
            </isNotEmpty>
            <isNotEmpty prepend=" and" property="areacode">
                ( e.regionid = #areacode# or (e.regionid in (select xzbh from Ptxzs start with sjxzbh=
                #areacode# connect by sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by name ,id
            ) h on g.sbbh = h.sbbh
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="12">
            select trim(cast(case when g.mcount is null then 0 else g.mcount end as char(8))) as
            zcount,g.tdmc,g.sbbh,
            trim(cast(case when h.mcount is null then 0 else h.mcount end as char(8))) as hfcount from(
            select count(*) as mcount, b.ldmc  as tdmc,b.ldbh  as sbbh from ywalarmeventinfo a,its.ksh_zxld b
            where a.alarmdeviceid=b.xh
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[a.alarmtime >= #timeStart# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[a.alarmtime <= #timeEnd# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and " property="areacode">
                ( b.gxdwbh = #areacode# or (b.gxdwbh in (select xzbh from Ptxzs start with sjxzbh= #areacode# connect by
                sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by ldmc ,ldbh
            ) g left join(
            select count(*) as mcount, ldmc tdmc,ldbh sbbh from ywalarmeventinfo d, its.ksh_zxld e
            where d.alarmdeviceid = e.xh
            <isNotEmpty prepend="and" property="alarmdevicetype">
                d.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            and d.processstatus in (915,914,912)
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[	d.alarmtime >= #timeStart#	 ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[	d.alarmtime <= #timeEnd# ]]>
            </isNotEmpty>
            <isNotEmpty prepend=" and" property="areacode">
                ( e.gxdwbh = #areacode# or (e.gxdwbh in (select xzbh from Ptxzs start with sjxzbh=
                #areacode# connect by sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by ldmc ,ldbh
            ) h on g.sbbh = h.sbbh
        </isEqual>
        <!-- <isNotEmpty prepend=' ' property='start'>
            limit #start# ,#limit#
        </isNotEmpty> -->
    </select>


    <select id="count_videoalarmbyArea" resultClass="java.lang.Integer" parameterClass="java.util.Map">

        <isEqual prepend="" property="alarmdevicetype" compareValue="1">
        select count(*) from (
        select count(*) as mcount, b.tdmc,b.sbbh,b.tdbh,sbip from
        ywalarmeventinfo a, sbtdspsr b left join sbxx c
        on b.sbbh = c.sbbh where b.kz3 is not null and b.kz3 != '1' and  a.alarmdeviceid = b.sbbh and a.channelnum = b.tdbh
        and a.alarmdevicetype=1
        <isNotEmpty prepend="and" property="timeStart">
            <![CDATA[
			a.alarmtime >= #timeStart#
		 ]]>
        </isNotEmpty>
        <isNotEmpty prepend="and" property="timeEnd">
            <![CDATA[
			a.alarmtime <= #timeEnd#
		 ]]>
        </isNotEmpty>
        <isNotEmpty prepend=" and" property="areacode">
            (b.xzbh = #areacode# or (b.xzbh in (select xzbh from Ptxzs start with sjxzbh= #areacode#
            connect by sjxzbh
            =prior xzbh)) )
        </isNotEmpty>
        group by b.tdmc,b.sbbh,b.tdbh,sbip
        ) x
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="2">
            select count(*) from(
            select count(*) as mcount, b.machinename as tdmc,b.machineid as sbbh,machineip sbip from ywalarmeventinfo  a,
            YWMACHINEINFO b  where a.alarmdeviceid = b.machineid
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[
			    a.alarmtime >= #timeStart#
		        ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[
			    a.alarmtime <= #timeEnd#
		        ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and " property="areacode">
                ( b.MACHINEAREANUM = #areacode# or (b.MACHINEAREANUM in (select xzbh from Ptxzs start with sjxzbh=
                #areacode# connect by sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by machinename ,machineid,machineip) g
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="3">
            select count(*) from(
            select count(*) as mcount, b.xhdmc  as tdmc,b.xhdbh  as sbbh,lkh,lkmc from ywalarmeventinfo a,nhywjtxhdgl b
            where a.alarmdeviceid = b.xh
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[a.alarmtime >= #timeStart# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[a.alarmtime <= #timeEnd# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and " property="areacode">
                ( b.qybh = #areacode# or (b.qybh in (select xzbh from Ptxzs start with sjxzbh= #areacode# connect by
                sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by xhdmc ,xhdbh,lkh,lkmc
            ) g
        </isEqual>

        <isEqual prepend="" property="alarmdevicetype" compareValue="4">
            select count(*) from(
            select count(*) as mcount, b.ledmc  as tdmc,b.ledbh  as sbbh from ywalarmeventinfo a,NHYWJTLEDYDPGL b
            where a.alarmdeviceid=b.xh
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[a.alarmtime >= #timeStart# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[a.alarmtime <= #timeEnd# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and " property="areacode">
                ( b.qybh = #areacode# or (b.qybh in (select xzbh from Ptxzs start with sjxzbh= #areacode# connect by
                sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by ledmc ,ledbh
            ) g
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="10">
            select count(*) from(
            select count(*) as mcount, b.name  as tdmc,b.id  as sbbh from ywalarmeventinfo a,its.ksh_detector b
            where a.alarmdeviceid=b.id
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[a.alarmtime >= #timeStart# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[a.alarmtime <= #timeEnd# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and " property="areacode">
                ( b.regionid = #areacode# or (b.regionid in (select xzbh from Ptxzs start with sjxzbh= #areacode# connect by
                sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by name ,id
            ) g
        </isEqual>
        <isEqual prepend="" property="alarmdevicetype" compareValue="11">
            select count(*) from(
            select count(*) as mcount, b.name  as tdmc,b.id  as sbbh from ywalarmeventinfo a,its.ksh_detector b
            where a.alarmdeviceid=b.id
            <isNotEmpty prepend="and" property="alarmdevicetype">
                a.alarmdevicetype=#alarmdevicetype#
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeStart">
                <![CDATA[a.alarmtime >= #timeStart# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and" property="timeEnd">
                <![CDATA[a.alarmtime <= #timeEnd# ]]>
            </isNotEmpty>
            <isNotEmpty prepend="and " property="areacode">
                ( b.regionid = #areacode# or (b.regionid in (select xzbh from Ptxzs start with sjxzbh= #areacode# connect by
                sjxzbh
                =prior xzbh)) )
            </isNotEmpty>
            group by name ,id
            ) g
        </isEqual>
    </select>

</sqlMap>











