<?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="">
    <typeAlias alias="detector" type="cn.im.detector.detectorBean"/>

    <sql id="condition_Detector">
        where 1=1
        <isNotEmpty prepend='AND ' property='LIKEid'>
            (id like '%$LIKEid$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='id'>
            (id = #id# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEbianma'>
            (bianma like '%$LIKEbianma$%')
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='bianma'>
            (bianma = #bianma#)
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEstate'>
            (state like '%$LIKEstate$%')
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='state'>
            (state = #state# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEname'>
            (name like '%$LIKEname$%')
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='name'>
            (name = #name# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEdetfrequency'>
            (detfrequency like '%$LIKEdetfrequency$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='detfrequency'>
            (detfrequency = #detfrequency# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKElongitude'>
            (longitude like '%$LIKElongitude%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='longitude'>
            (longitude = #longitude# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKElatitude'>
            (latitude like '%$LIKElatitude$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='latitude'>
            (latitude = #latitude# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEdetectortype'>
            (detectortype like '%$LIKEdetectortype$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='detectortype'>
            (detectortype = #detectortype# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEip'>
            (ip like '%$LIKEip$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='ip'>
            (ip = #ip# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEroadname'>
            (roadname like '%$LIKEroadname$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='roadname'>
            (roadname = #roadname# )
        </isNotEmpty>

        <isNotEmpty prepend='AND ' property='LIKEroadid'>
            (roadid like '%$LIKEroadid$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='roadid'>
            (roadid = #roadid# )
        </isNotEmpty>

        <isNotEmpty prepend='AND ' property='LIKEbianma2'>
            (bianma2 like '%$LIKEbianma2$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='bianma2'>
            (bianma2 = #bianma2# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEfactoryid'>
            (factoryid like '%$LIKEfactoryid$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='factoryid'>
            (factoryid = #factoryid# )
        </isNotEmpty>

        <isNotEmpty prepend='AND ' property='LIKEregionid'>
            (regionid like '%$LIKEregionid$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='regionid'>
            (regionid = #regionid# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEip'>
            (ip like '%$LIKEip$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='ip'>
            (ip = #ip# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEbz'>
            (remarks like '%$LIKEbz$%' )
        </isNotEmpty>
        <isNotEmpty property='emptyremarks'>
            <isEqual prepend='AND ' property='emptyremarks' compareValue="0">
                (remarks is null or remarks =' ' )
            </isEqual>
            <isEqual prepend='AND ' property='emptyremarks' compareValue="1">
                (remarks is not null and  remarks !=' ' )
            </isEqual>
        </isNotEmpty>
        <isNotEmpty property='tableparam'>
            $tableparam$
        </isNotEmpty>
        <isNotEmpty property='order'>
            $order$
        </isNotEmpty>
    </sql>

    <!-- add object -->
    <insert id="insert_Detector" parameterClass="java.util.Map">
        insert into
        its.ksh_detector(
        <dynamic prepend=" ">
            <isNotEmpty prepend=',' property='id'>id</isNotEmpty>
            <isNotEmpty prepend=',' property='bianma'>bianma</isNotEmpty>
            <isNotEmpty prepend=',' property='name'>name</isNotEmpty>
            <isNotEmpty prepend=',' property='state'>state</isNotEmpty>
            <isNotEmpty prepend=',' property='detfrequency'>detfrequency</isNotEmpty>
            <isNotEmpty prepend=',' property='longitude'>longitude</isNotEmpty>
            <isNotEmpty prepend=',' property='latitude'>latitude</isNotEmpty>
            <isNotEmpty prepend=',' property='detectortype'>detectortype</isNotEmpty>
            <isNotEmpty prepend=',' property='roadname'>roadname</isNotEmpty>
            <isNotEmpty prepend=',' property='roadid'>roadid</isNotEmpty>
            <isNotEmpty prepend=',' property='bianma2'>bianma2</isNotEmpty>
            <isNotEmpty prepend=',' property='factoryid'>factoryid</isNotEmpty>
            <isNotEmpty prepend=',' property='regionid'>regionid</isNotEmpty>
            <isNotEmpty prepend=',' property='ip'>ip</isNotEmpty>
            <isNotEmpty prepend=',' property='updatetime'>updatetime</isNotEmpty>
        </dynamic>
        <![CDATA[
	        ) values (
	    ]]>
        <dynamic prepend=" ">
            <isNotEmpty prepend=',' property='id'>#id#</isNotEmpty>
            <isNotEmpty prepend=',' property='bianma'>#bianma#</isNotEmpty>
            <isNotEmpty prepend=',' property='name'>#name#</isNotEmpty>
            <isNotEmpty prepend=',' property='state'>#state#</isNotEmpty>
            <isNotEmpty prepend=',' property='detfrequency'>#detfrequency#</isNotEmpty>
            <isNotEmpty prepend=',' property='longitude'>#longitude#</isNotEmpty>
            <isNotEmpty prepend=',' property='latitude'>#latitude#</isNotEmpty>
            <isNotEmpty prepend=',' property='detectortype'>#detectortype#</isNotEmpty>
            <isNotEmpty prepend=',' property='roadname'>#roadname#</isNotEmpty>
            <isNotEmpty prepend=',' property='roadid'>#roadid#</isNotEmpty>
            <isNotEmpty prepend=',' property='bianma2'>#bianma2#</isNotEmpty>
            <isNotEmpty prepend=',' property='factoryid'>#factoryid#</isNotEmpty>
            <isNotEmpty prepend=',' property='regionid'>#regionid#</isNotEmpty>
            <isNotEmpty prepend=',' property='ip'>#ip#</isNotEmpty>
            <isNotEmpty prepend=',' property='updatetime'>#updatetime#</isNotEmpty>
        </dynamic>
        <![CDATA[
	        )
	    ]]>
    </insert>

    <!-- edit object  -->
    <update id="update_Detector" parameterClass="java.util.Map">
        update its.ksh_detector
        <dynamic prepend="set ">
            <isNotEmpty prepend=',' property='bianma'>bianma=#bianma#</isNotEmpty>
            <isNotEmpty prepend=',' property='name'>name=#name#</isNotEmpty>
            <isNotEmpty prepend=',' property='state'>state=#state#</isNotEmpty>
            <isNotEmpty prepend=',' property='detfrequency'>detfrequency=#detfrequency#</isNotEmpty>
            <isNotEmpty prepend=',' property='longitude'>longitude=#longitude#</isNotEmpty>
            <isNotEmpty prepend=',' property='latitude'>latitude=#latitude#</isNotEmpty>
            <isNotEmpty prepend=',' property='detectortype'>detectortype=#detectortype#</isNotEmpty>
            <isNotEmpty prepend=',' property='roadname'>roadname=#roadname#</isNotEmpty>
            <isNotEmpty prepend=',' property='roadid'>roadid=#roadid#</isNotEmpty>
            <isNotEmpty prepend=',' property='jd'>longitude=#jd#</isNotEmpty>
            <isNotEmpty prepend=',' property='wd'>latitude=#wd#</isNotEmpty>
            <isNotEmpty prepend=',' property='bianma2'>bianma2=#bianma2#</isNotEmpty>
            <isNotEmpty prepend=',' property='factoryid'>factoryid=#factoryid#</isNotEmpty>
            <isNotEmpty prepend=',' property='regionid'>regionid=#regionid#</isNotEmpty>
            <isNotEmpty prepend=',' property='ip'>ip=#ip#</isNotEmpty>
            <isNotEmpty prepend=',' property='updatetime'>updatetime=#updatetime#</isNotEmpty>
            <isNotEmpty prepend=',' property='remarks'>remarks=#remarks#</isNotEmpty>
        </dynamic>
        where  id=#XGTJid#
    </update>

    <!-- delete object -->
    <delete id="delete_Detector" parameterClass="java.util.Map">
        delete from its.ksh_detector where   (id = #id# )
    </delete>

    <!-- batch delete object -->
    <delete id="batch_delete_Detector_bak" parameterClass="java.util.Map">
        delete from its.ksh_detector       where             id  in (#keyword#)
    </delete>
    <delete id="batch_delete_Detector" parameterClass="java.util.List">
        delete from its.ksh_detector
        where id in
        <iterate open="(" close=")" conjunction=" ,">
            #list[]#
        </iterate>
    </delete>
    <update id="batch_update_Detector" parameterClass="java.util.Map">
        update its.ksh_detector
        <dynamic prepend="set ">
            <isNotEmpty prepend=',' property='bianma'>bianma=#bianma#</isNotEmpty>
            <isNotEmpty prepend=',' property='name'>name=#name#</isNotEmpty>
            <isNotEmpty prepend=',' property='state'>state=#state#</isNotEmpty>
            <isNotEmpty prepend=',' property='detfrequency'>detfrequency=#detfrequency#</isNotEmpty>
            <isNotEmpty prepend=',' property='longitude'>longitude=#longitude#</isNotEmpty>
            <isNotEmpty prepend=',' property='latitude'>latitude=#latitude#</isNotEmpty>
            <isNotEmpty prepend=',' property='detectortype'>detectortype=#detectortype#</isNotEmpty>
            <isNotEmpty prepend=',' property='roadname'>roadname=#roadname#</isNotEmpty>
            <isNotEmpty prepend=',' property='roadid'>roadid=#roadid#</isNotEmpty>
            <isNotEmpty prepend=',' property='bianma2'>bianma2=#bianma2#</isNotEmpty>
            <isNotEmpty prepend=',' property='factoryid'>factoryid=#factoryid#</isNotEmpty>
            <isNotEmpty prepend=',' property='regionid'>regionid=#regionid#</isNotEmpty>
            <isNotEmpty prepend=',' property='ip'>ip=#ip#</isNotEmpty>
            <isNotEmpty prepend=',' property='updatetime'>updatetime=#updatetime#</isNotEmpty>
        </dynamic>
        where id in
        <iterate open="(" close=")" conjunction="," property="keyword">
            #keyword[]#
        </iterate>
    </update>

    <select id="query_Detector" resultClass="java.util.HashMap" parameterClass="java.util.Map">
        select
        id,bianma,name,state,detfrequency,longitude,latitude,detectortype,roadname,roadid,bianma2,factoryid,regionid,(
        select xzmc from Ptxzs where xzbh=regionid) regionname, ip,updatetime ,remarks from its.ksh_detector b
        <include refid="condition_Detector"/>
    </select>

    <!-- query objects totalcount -->
    <select id="count_Detector" resultClass="java.lang.Integer" parameterClass="java.util.Map">
        select count(*) from its.ksh_detector
        <include refid="condition_Detector"/>
    </select>

    <select id="query_Detectortask" resultClass="java.util.HashMap" parameterClass="java.util.Map">
        select a.*,b.csdm,b.csmc from its.ksh_detector a left join xtcl b on rw_state = b.csdm and b.csdl =
        'ywTaskEnable'
        <include refid="condition_Detector"/>
    </select>


    <select id="query_DetectorNotask" resultClass="java.util.HashMap" parameterClass="java.util.Map">
        <isEqual compareValue="1" property="type">
            select c.xh ,c.xhdbh id ,c.xhdmc mc ,c.qybh ,c.qymc from its.ksh_detector c
            where 1=1
            <isNotEmpty prepend='AND ' property='LIKExh'>
                (xhdbh like '%$LIKExh$%' )
            </isNotEmpty>
            <isNotEmpty prepend='AND ' property='xh'>
                (xhdbh = #xh# )
            </isNotEmpty>
            <isNotEmpty prepend='AND ' property='LIKEledmc'>
                (xhdmc like '%$LIKEledmc$%' )
            </isNotEmpty>
            and xh not in (select DEVICEID from Detector where 1=1
            <isNotEmpty prepend='AND ' property='xjid'>
                (xjid =#xjid# )
            </isNotEmpty>
            )
        </isEqual>
        <isEqual compareValue="2" property="type">
            select c.xh ,c.ledbh id ,c.ledmc mc ,c.qybh ,c.qymc from nhywjtledydpgl c
            where 1=1
            <isNotEmpty prepend='AND ' property='LIKExh'>
                (ledbh like '%$LIKExh$%' )
            </isNotEmpty>
            <isNotEmpty prepend='AND ' property='xh'>
                (ledbh = #xh# )
            </isNotEmpty>
            <isNotEmpty prepend='AND ' property='LIKEledmc'>
                (ledmc like '%$LIKEledmc$%' )
            </isNotEmpty>
            and xh not in (select DEVICEID from Detector where 1=1
            <isNotEmpty prepend='AND ' property='xjid'>
                (xjid =#xjid# )
            </isNotEmpty>

            )
        </isEqual>
    </select>
    <select id="count_DetectorNotask" resultClass="java.lang.Integer" parameterClass="java.util.Map">
        <isEqual compareValue="1" property="type">
            select count(c.xh) from nhywjtxhdgl c where 1=1
            <isNotEmpty prepend='AND ' property='LIKExh'>
                (xhdbh like '%$LIKExh$%' )
            </isNotEmpty>
            <isNotEmpty prepend='AND ' property='xh'>
                (xhdbh = #xh# )
            </isNotEmpty>
            <isNotEmpty prepend='AND ' property='LIKEledmc'>
                (xhdmc like '%$LIKEledmc$%' )
            </isNotEmpty>
            and xh not in (select DEVICEID from Detector
            where 1=1
            <isNotEmpty prepend='AND ' property='xjid'>
                (xjid =#xjid# )
            </isNotEmpty>)
        </isEqual>
        <isEqual compareValue="2" property="type">
            select count(c.xh) from nhywjtledydpgl c
            where 1=1
            <isNotEmpty prepend='AND ' property='LIKExh'>
                (ledbh like '%$LIKExh$%' )
            </isNotEmpty>
            <isNotEmpty prepend='AND ' property='xh'>
                (ledbh = #xh# )
            </isNotEmpty>
            <isNotEmpty prepend='AND ' property='LIKEledmc'>
                (ledmc like '%$LIKEledmc$%' )
            </isNotEmpty>
            and xh not in (select DEVICEID from Detector
            where 1=1
            <isNotEmpty prepend='AND ' property='xjid'>
                (xjid =#xjid# )
            </isNotEmpty>)
        </isEqual>
    </select>
    <select id="query_DetectortaskByPage" resultClass="java.util.HashMap" parameterClass="java.util.Map">
        <isEqual compareValue="1" property="type">
            select c.xh ,c.xhdbh id ,c.xhdmc mc ,c.qybh ,c.qymc from nhywjtxhdgl c where 1=1
            <isNotEmpty prepend='AND ' property='LIKExh'>
                (xhdbh like '%$LIKExh$%' )
            </isNotEmpty>
            <isNotEmpty prepend='AND ' property='xh'>
                (xhdbh = #xh# )
            </isNotEmpty>
            <isNotEmpty prepend='AND ' property='LIKEledmc'>
                (xhdmc like '%$LIKEledmc$%' )
            </isNotEmpty>
            and xh in (select DEVICEID from Detector
            where 1=1
            <isNotEmpty prepend='AND ' property='xjid'>
                (xjid =#xjid# )
            </isNotEmpty>)
        </isEqual>
        <isEqual compareValue="2" property="type">
            select c.xh ,c.ledbh id ,c.ledmc mc ,c.qybh ,c.qymc from nhywjtledydpgl c where 1=1
            <isNotEmpty prepend='AND ' property='LIKExh'>
                (ledbh like '%$LIKExh$%' )
            </isNotEmpty>
            <isNotEmpty prepend='AND ' property='xh'>
                (ledbh = #xh# )
            </isNotEmpty>
            <isNotEmpty prepend='AND ' property='LIKEledmc'>
                (ledmc like '%$LIKEledmc$%' )
            </isNotEmpty>
            and xh in (select DEVICEID from Detector
            where 1=1
            <isNotEmpty prepend='AND ' property='xjid'>
                (xjid =#xjid# )
            </isNotEmpty>
            )
        </isEqual>
    </select>


    <delete id="batchdelete_Detector" parameterClass="java.util.Map">
        delete from its.ksh_detector
        where xjid =#xjid# and type =#type# and id in
        <iterate open="(" close=")" conjunction=" ," property="ids">
            #ids[]#
        </iterate>
    </delete>
    <insert id="batchinsert_Detector" parameterClass="java.util.List">
        <iterate open="begin" close="end;">
            insert into its.ksh_detector(id,xjid,deviceid,type) values
            (#list[].id#, #list[].xjid#, #list[].deviceid#, #list[].type#);
        </iterate>

    </insert>

    <!-- 根据 xh 批量更新启用状态 -->
    <update id="edit_Detector" parameterClass="java.util.Map">
        update its.ksh_detector
        <dynamic prepend="set ">
            <isNotEmpty prepend=',' property='rw_state'>rw_state=#rw_state#</isNotEmpty>
        </dynamic>
        where id in
        <iterate open="(" close=")" conjunction="," property="keys">
            #keys[]#
        </iterate>
    </update>
    <select id="statisticsDetectorRate" resultClass="java.util.HashMap" parameterClass="java.util.Map">
		select COUNT(*) as totalcount ,'gvdtotalcount' as name	from its.ksh_detector  where detectortype='GVD'
		union ALL
		select COUNT(a.state) as totalcount,'gvdonlinenum' as name from its.ksh_detector a where  a.state=1 and  a.detectortype='GVD'
		union ALL
		select COUNT(a.id) as totalcount ,'gvdunonlinenum' as name from its.ksh_detector a  where   ( a.state=0  or a.state is null) and   a.detectortype='GVD'
		union all
		select COUNT(*) as totalcount ,'sentotalcount' as name	from its.ksh_detector where  detectortype='SMARTSENSOR'
         union ALL
		select COUNT(*) as totalcount ,'senonlinenum' as name from its.ksh_detector  a   where a.state=1 and   a.detectortype='SMARTSENSOR'
		union ALL
	   select COUNT(a.id) as totalcount,'senunonlinenum' as name from its.ksh_detector a where   ( a.state=0  or a.state is null) and   a.detectortype='SMARTSENSOR'

	</select>


    <select id="listDetectorStatus" resultClass="java.util.HashMap" parameterClass="java.util.Map" remapResults="true">
        select
        a.id,bianma,name,state,detfrequency,longitude,latitude,a.detectortype,roadname,roadid,bianma2,factoryid,regionid,(
        select xzmc from Ptxzs where
        xzbh=regionid) regionname,ip, updatetime from its.ksh_detector a where 1=1
        <isNotEmpty prepend='AND ' property='detectortype'>
            (a.detectortype = #detectortype# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEname'>
            (name like '%LIKEname%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='state'>
            (a.state = #state# )
        </isNotEmpty>
        <isNotEmpty property='tableparam'>
            $tableparam$
        </isNotEmpty>
    </select>
    <select id="countDetectorStatus" resultClass="java.lang.Integer" parameterClass="java.util.Map" remapResults="true">
        select count(a.id) from its.ksh_detector a where 1=1
        <isNotEmpty prepend='AND ' property='detectortype'>
            (a.detectortype = #detectortype# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='state'>
            (a.state = #state# )
        </isNotEmpty> <isNotEmpty prepend='AND ' property='LIKEname'>
        (name like '%LIKEname%' )
        </isNotEmpty>
        <isNotEmpty property='tableparam'>
            $tableparam$
        </isNotEmpty>
    </select>


    <update id="updateDetctorJdWdByXh" parameterClass="java.util.HashMap">
		update its.ksh_detector  set  longitude = #jd# , latitude=#wd#  where id  = #id#
	</update>


    <select id="query_Detectorcurrentstate" resultClass="java.util.HashMap" parameterClass="java.util.Map"
            remapResults="true">
        select id,bianma,name,state,
        (select csmc from  Xtcl where csdl='ksh_detectorCurrentState' and csdm=state)status,detfrequency,longitude,latitude,
        longitude jd,latitude wd,a.detectortype,roadname,roadid,bianma2,factoryid,regionid,repairstate, (select alarmname from ywalarmeventcode where alarmcode=repairstate)repairstatename,
        ( select xzmc from Ptxzs where  xzbh=regionid) xzmc, ip,updatetime, regionid xzbh,remarks
        from its.ksh_detector a where 1=1
        <isNotEmpty prepend='AND ' property='LIKEname'>
            (name like '%LIKEname%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='detectortype'>
            (a.detectortype = #detectortype# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEbz'>
            (remarks like '%$LIKEbz$%' )
        </isNotEmpty>
        <isNotEmpty property='emptyremarks'>
            <isEqual prepend='AND ' property='emptyremarks' compareValue="0">
                (remarks is null or remarks =' ' )
            </isEqual>
            <isEqual prepend='AND ' property='emptyremarks' compareValue="1">
                (remarks is not null and remarks !=' ' )
            </isEqual>
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='state'>
            (a.state = #state# )
        </isNotEmpty>
        <isNotEmpty property='tableparam'>
            $tableparam$
        </isNotEmpty>
    </select>

    <select id="query_Detectorhistory" resultClass="java.util.HashMap" parameterClass="java.util.Map"
            remapResults="true">
        select a.id,bianma,name,a.state
        ,detfrequency,longitude,latitude,a.detectortype,roadname,roadid,bianma2,factoryid,regionid,( select xzmc from
        Ptxzs where
        xzbh=regionid) regionname, ip,updatetime ,b.state zt, to_char(b.create_time,'yyyy-mm-dd hh24:mi:ss')create_time
        from  (select * from its.ksh_detector
            <include refid="condition_Detector"/>
        )a inner join its.KSH_DETECTOR_HISTORY b on a.id=b.id
        <isNotEmpty prepend="and" property="startTime">
            <![CDATA[b.create_time >=to_date(#startTime#,'yyyy-mm-dd hh24:mi:ss') ]]>
        </isNotEmpty>
        <isNotEmpty prepend="and" property="endTime">
            <![CDATA[b.create_time <=to_date(#endTime#,'yyyy-mm-dd hh24:mi:ss')	 ]]>
        </isNotEmpty>
    </select>

    <select id="count_Detectorhistory" resultClass="java.lang.Integer" parameterClass="java.util.Map"
            remapResults="true">
        select count(*) from
        (select * from its.ksh_detector
        <include refid="condition_Detector"/>
        )a inner join its.KSH_DETECTOR_HISTORY b on a.id=b.id
        <isNotEmpty prepend="and" property="startTime">
            <![CDATA[b.create_time >=to_date(#startTime#,'yyyy-mm-dd hh24:mi:ss') ]]>
        </isNotEmpty>
        <isNotEmpty prepend="and" property="endTime">
            <![CDATA[b.create_time <=to_date(#endTime#,'yyyy-mm-dd hh24:mi:ss')	 ]]>
        </isNotEmpty>
    </select>

    <select id="get_Detector" resultClass="java.util.HashMap" parameterClass="java.util.Map" remapResults="true">
        select
        id,bianma,name,state,detfrequency,longitude,latitude,detectortype,roadname,roadid,bianma2,factoryid,regionid,(
        select xzmc from Ptxzs where xzbh=regionid) regionname,ip, updatetime from its.ksh_detector b
        <include refid="condition_Detector"/>
    </select>

    <update id="update_DetectorCurrentState" parameterClass="java.util.HashMap">
		update its.ksh_detector  set  repairstate = #repairstate#    where  id=#XGTJid# and detectortype=#detectortype#
	</update>
    <update id="update_DetectorRemarks" parameterClass="java.util.HashMap">
		update its.ksh_detector  set remarks=#remarks#
        <isNotEmpty prepend="," property="repairstate">
            repairstate = #repairstate#
        </isNotEmpty>
        <isNotEmpty prepend="," property="state">
            state = #state#
        </isNotEmpty>
		 where  id=#XGTJid#
	</update>


</sqlMap>











