<?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="Ywmachinecurrentstatebean" type="cn.vp.XXX.model.YwmachinecurrentstateBean"/> -->
    <typeAlias alias="Ywmachinecurrentstate" type="cn.yw.ywmachinecurrentstate.YwmachinecurrentstateBean"/>

    <sql id="condition_Ywmachinecurrentstate">
        where 1=1
        <isNotEmpty prepend='AND ' property='startTime'>
            <![CDATA[
			 	currentstatetime >= #startTime#
			 ]]>
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='endTime'>
            <![CDATA[
			 	currentstatetime <= #endTime#
			 ]]>
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEcurrentstateid'>
            (currentstateid like '%$LIKEcurrentstateid$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='currentstateid'>
            (currentstateid = #currentstateid# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEmachineid'>
            (machineid like '%$LIKEmachineid$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='machineid'>
            (machineid = #machineid# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEmachinenum'>
            (machinenum like '%$LIKEmachinenum$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='machinenum'>
            (machinenum = #machinenum# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEmachinename'>
            (machinename like '%$LIKEmachinename$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='machinename'>
            (machinename = #machinename# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEmachineip'>
            (machineip like '%$LIKEmachineip$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='machineip'>
            (machineip = #machineip# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEcurrentstate'>
            (currentstate like '%$LIKEcurrentstate$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='currentstate'>
            (currentstate = #currentstate# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='intactState'>
            (currentstate != #intactState# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKErepairstate'>
            (repairstate like '%$LIKErepairstate$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='repairstate'>
            (repairstate = #repairstate# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEcurrentstatetime'>
            (currentstatetime like '%$LIKEcurrentstatetime$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='currentstatetime'>
            (currentstatetime = #currentstatetime# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEmachinestate'>
            (machinestate like '%$LIKEmachinestate$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='machinestate'>
            (machinestate = #machinestate# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEcpustatus'>
            (cpustatus like '%$LIKEcpustatus$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='cpustatus'>
            (cpustatus = #cpustatus# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEcpuusage'>
            (cpuusage like '%$LIKEcpuusage$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='cpuusage'>
            (cpuusage = #cpuusage# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEmemorystate'>
            (memorystate like '%$LIKEmemorystate$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='memorystate'>
            (memorystate = #memorystate# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEmemorytotal'>
            (memorytotal like '%$LIKEmemorytotal$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='memorytotal'>
            (memorytotal = #memorytotal# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEmemoryusage'>
            (memoryusage like '%$LIKEmemoryusage$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='memoryusage'>
            (memoryusage = #memoryusage# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEharddiskstate'>
            (harddiskstate like '%$LIKEharddiskstate$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='harddiskstate'>
            (harddiskstate = #harddiskstate# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEharddisktotal'>
            (harddisktotal like '%$LIKEharddisktotal$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='harddisktotal'>
            (harddisktotal = #harddisktotal# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEharddiskusage'>
            (harddiskusage like '%$LIKEharddiskusage$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='harddiskusage'>
            (harddiskusage = #harddiskusage# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEstatusupbatch'>
            (statusupbatch like '%$LIKEstatusupbatch$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='statusupbatch'>
            (statusupbatch = #statusupbatch# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEcreateaccount'>
            (createaccount like '%$LIKEcreateaccount$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='createaccount'>
            (createaccount = #createaccount# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEcreatetime'>
            (createtime like '%$LIKEcreatetime$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='createtime'>
            (createtime = #createtime# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEmodifyaccount'>
            (modifyaccount like '%$LIKEmodifyaccount$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='modifyaccount'>
            (modifyaccount = #modifyaccount# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEmodifytime'>
            (modifytime like '%$LIKEmodifytime$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='modifytime'>
            (modifytime = #modifytime# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEremarks'>
            (remarks like '%$LIKEremarks$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='remarks'>
            (remarks = #remarks# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEextend1'>
            (extend1 like '%$LIKEextend1$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='extend1'>
            (extend1 = #extend1# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEextend2'>
            (extend2 like '%$LIKEextend2$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='extend2'>
            (extend2 = #extend2# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEextend3'>
            (extend3 like '%$LIKEextend3$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='extend3'>
            (extend3 = #extend3# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEextend4'>
            (extend4 like '%$LIKEextend4$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='extend4'>
            (extend4 = #extend4# )
        </isNotEmpty>
        <isNotEmpty property='tableparam'>
            $tableparam$
        </isNotEmpty>
        <isNotEmpty property='order'>
            $order$
        </isNotEmpty>
    </sql>

    <!-- add object -->
    <insert id="insert_Ywmachinecurrentstate" parameterClass="java.util.Map">
        insert into
        ywmachinecurrentstate(
        <dynamic prepend=" ">
            <isNotEmpty prepend=',' property='currentstateid'>currentstateid</isNotEmpty>
            <isNotEmpty prepend=',' property='currentstate'>currentstate</isNotEmpty>
            <isNotEmpty prepend=',' property='machineid'>machineid</isNotEmpty>
            <isNotEmpty prepend=',' property='machinenum'>machinenum</isNotEmpty>
            <isNotEmpty prepend=',' property='machinename'>machinename</isNotEmpty>
            <isNotEmpty prepend=',' property='machineip'>machineip</isNotEmpty>
            <isNotEmpty prepend=',' property='repairstate'>repairstate</isNotEmpty>
            <isNotEmpty prepend=',' property='currentstatetime'>currentstatetime</isNotEmpty>
            <isNotEmpty prepend=',' property='machinestate'>machinestate</isNotEmpty>
            <isNotEmpty prepend=',' property='cpustatus'>cpustatus</isNotEmpty>
            <isNotEmpty prepend=',' property='cpuusage'>cpuusage</isNotEmpty>
            <isNotEmpty prepend=',' property='memorystate'>memorystate</isNotEmpty>
            <isNotEmpty prepend=',' property='memorytotal'>memorytotal</isNotEmpty>
            <isNotEmpty prepend=',' property='memoryusage'>memoryusage</isNotEmpty>
            <isNotEmpty prepend=',' property='harddiskstate'>harddiskstate</isNotEmpty>
            <isNotEmpty prepend=',' property='harddisktotal'>harddisktotal</isNotEmpty>
            <isNotEmpty prepend=',' property='harddiskusage'>harddiskusage</isNotEmpty>
            <isNotEmpty prepend=',' property='statusupbatch'>statusupbatch</isNotEmpty>
            <isNotEmpty prepend=',' property='createaccount'>createaccount</isNotEmpty>
            <isNotEmpty prepend=',' property='createtime'>createtime</isNotEmpty>
            <isNotEmpty prepend=',' property='modifyaccount'>modifyaccount</isNotEmpty>
            <isNotEmpty prepend=',' property='modifytime'>modifytime</isNotEmpty>
            <isNotEmpty prepend=',' property='remarks'>remarks</isNotEmpty>
            <isNotEmpty prepend=',' property='extend1'>extend1</isNotEmpty>
            <isNotEmpty prepend=',' property='extend2'>extend2</isNotEmpty>
            <isNotEmpty prepend=',' property='extend3'>extend3</isNotEmpty>
            <isNotEmpty prepend=',' property='extend4'>extend4</isNotEmpty>

        </dynamic>
        <![CDATA[
	        ) values ( 
	    ]]>
        <dynamic prepend=" ">
            <isNotEmpty prepend=',' property='currentstateid'>#currentstateid#</isNotEmpty>
            <isNotEmpty prepend=',' property='currentstate'>#currentstate#</isNotEmpty>
            <isNotEmpty prepend=',' property='machineid'>#machineid#</isNotEmpty>
            <isNotEmpty prepend=',' property='machinenum'>#machinenum#</isNotEmpty>
            <isNotEmpty prepend=',' property='machinename'>#machinename#</isNotEmpty>
            <isNotEmpty prepend=',' property='machineip'>#machineip#</isNotEmpty>
            <isNotEmpty prepend=',' property='repairstate'>#repairstate#</isNotEmpty>
            <isNotEmpty prepend=',' property='currentstatetime'>#currentstatetime#</isNotEmpty>
            <isNotEmpty prepend=',' property='machinestate'>#machinestate#</isNotEmpty>
            <isNotEmpty prepend=',' property='cpustatus'>#cpustatus#</isNotEmpty>
            <isNotEmpty prepend=',' property='cpuusage'>#cpuusage#</isNotEmpty>
            <isNotEmpty prepend=',' property='memorystate'>#memorystate#</isNotEmpty>
            <isNotEmpty prepend=',' property='memorytotal'>#memorytotal#</isNotEmpty>
            <isNotEmpty prepend=',' property='memoryusage'>#memoryusage#</isNotEmpty>
            <isNotEmpty prepend=',' property='harddiskstate'>#harddiskstate#</isNotEmpty>
            <isNotEmpty prepend=',' property='harddisktotal'>#harddisktotal#</isNotEmpty>
            <isNotEmpty prepend=',' property='harddiskusage'>#harddiskusage#</isNotEmpty>
            <isNotEmpty prepend=',' property='statusupbatch'>#statusupbatch#</isNotEmpty>
            <isNotEmpty prepend=',' property='createaccount'>#createaccount#</isNotEmpty>
            <isNotEmpty prepend=',' property='createtime'>#createtime#</isNotEmpty>
            <isNotEmpty prepend=',' property='modifyaccount'>#modifyaccount#</isNotEmpty>
            <isNotEmpty prepend=',' property='modifytime'>#modifytime#</isNotEmpty>
            <isNotEmpty prepend=',' property='remarks'>#remarks#</isNotEmpty>
            <isNotEmpty prepend=',' property='extend1'>#extend1#</isNotEmpty>
            <isNotEmpty prepend=',' property='extend2'>#extend2#</isNotEmpty>
            <isNotEmpty prepend=',' property='extend3'>#extend3#</isNotEmpty>
            <isNotEmpty prepend=',' property='extend4'>#extend4#</isNotEmpty>

        </dynamic>
        <![CDATA[
	        ) 
	    ]]>
    </insert>

    <!-- edit object  -->
    <update id="update_Ywmachinecurrentstate" parameterClass="java.util.Map">
        update ywmachinecurrentstate
        <dynamic prepend="set ">

            <isNotEmpty prepend=',' property='machineid'>machineid=#machineid#</isNotEmpty>
            <isNotEmpty prepend=',' property='machinenum'>machinenum=#machinenum#</isNotEmpty>
            <isNotEmpty prepend=',' property='machinename'>machinename=#machinename#</isNotEmpty>
            <isNotEmpty prepend=',' property='machineip'>machineip=#machineip#</isNotEmpty>
            <isNotEmpty prepend=',' property='repairstate'>repairstate=#repairstate#</isNotEmpty>
            <isNotEmpty prepend=',' property='currentstatetime'>currentstatetime=#currentstatetime#</isNotEmpty>
            <isNotEmpty prepend=',' property='machinestate'>machinestate=#machinestate#</isNotEmpty>
            <isNotEmpty prepend=',' property='cpustatus'>cpustatus=#cpustatus#</isNotEmpty>
            <isNotEmpty prepend=',' property='cpuusage'>cpuusage=#cpuusage#</isNotEmpty>
            <isNotEmpty prepend=',' property='memorystate'>memorystate=#memorystate#</isNotEmpty>
            <isNotEmpty prepend=',' property='memorytotal'>memorytotal=#memorytotal#</isNotEmpty>
            <isNotEmpty prepend=',' property='memoryusage'>memoryusage=#memoryusage#</isNotEmpty>
            <isNotEmpty prepend=',' property='harddiskstate'>harddiskstate=#harddiskstate#</isNotEmpty>
            <isNotEmpty prepend=',' property='harddisktotal'>harddisktotal=#harddisktotal#</isNotEmpty>
            <isNotEmpty prepend=',' property='harddiskusage'>harddiskusage=#harddiskusage#</isNotEmpty>
            <isNotEmpty prepend=',' property='statusupbatch'>statusupbatch=#statusupbatch#</isNotEmpty>
            <isNotEmpty prepend=',' property='createaccount'>createaccount=#createaccount#</isNotEmpty>
            <isNotEmpty prepend=',' property='createtime'>createtime=#createtime#</isNotEmpty>
            <isNotEmpty prepend=',' property='modifyaccount'>modifyaccount=#modifyaccount#</isNotEmpty>
            <isNotEmpty prepend=',' property='modifytime'>modifytime=#modifytime#</isNotEmpty>
            <isNotEmpty prepend=',' property='remarks'>remarks=#remarks#</isNotEmpty>
            <isNotEmpty prepend=',' property='extend1'>extend1=#extend1#</isNotEmpty>
            <isNotEmpty prepend=',' property='extend2'>extend2=#extend2#</isNotEmpty>
            <isNotEmpty prepend=',' property='extend3'>extend3=#extend3#</isNotEmpty>
            <isNotEmpty prepend=',' property='extend4'>extend4=#extend4#</isNotEmpty>
        </dynamic>
        where currentstateid = #XGTJcurrentstateid#
        <isNotEmpty prepend='AND ' property='XGTJcurrentstate'>currentstate = #XGTJcurrentstate#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJmachineid'>machineid = #XGTJmachineid#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJmachinenum'>machinenum = #XGTJmachinenum#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJmachinename'>machinename = #XGTJmachinename#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJmachineip'>machineip = #XGTJmachineip#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJrepairstate'>repairstate = #XGTJrepairstate#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJcurrentstatetime'>currentstatetime = #XGTJcurrentstatetime#
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJmachinestate'>machinestate = #XGTJmachinestate#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJcpustatus'>cpustatus = #XGTJcpustatus#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJcpuusage'>cpuusage = #XGTJcpuusage#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJmemorystate'>memorystate = #XGTJmemorystate#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJmemorytotal'>memorytotal = #XGTJmemorytotal#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJmemoryusage'>memoryusage = #XGTJmemoryusage#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJharddiskstate'>harddiskstate = #XGTJharddiskstate#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJharddisktotal'>harddisktotal = #XGTJharddisktotal#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJharddiskusage'>harddiskusage = #XGTJharddiskusage#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJstatusupbatch'>statusupbatch = #XGTJstatusupbatch#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJcreateaccount'>createaccount = #XGTJcreateaccount#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJcreatetime'>createtime = #XGTJcreatetime#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJmodifyaccount'>modifyaccount = #XGTJmodifyaccount#</isNotEmpty>
        <isNotEmpty prepend='AND ' property='XGTJmodifytime'>modifytime = #XGTJmodifytime#</isNotEmpty>


    </update>

    <!-- delete object -->
    <delete id="delete_Ywmachinecurrentstate" parameterClass="java.util.Map">
        delete from ywmachinecurrentstate
        <include refid="condition_Ywmachinecurrentstate"/>
    </delete>

    <!-- batch delete object -->
    <delete id="batch_delete_Ywmachinecurrentstate" parameterClass="java.util.Map">
		delete from ywmachinecurrentstate 	where key  in (#keyword#)
	</delete>

    <!-- query objects by page-->
    <select id="query_Ywmachinecurrentstate" resultClass="java.util.HashMap" parameterClass="java.util.Map"
            remapResults="true">
        <!--		select -->
        <!--			(select csmc from xtcl  where csdl='ywMachineCurrentState' and csdm=currentstate) as currentstatename,-->
        <!--			currentstateid,currentstate,machineid,machinenum,machinename,machineip,repairstate,currentstatetime,machinestate,cpustatus,cpuusage,memorystate,memorytotal,memoryusage,harddiskstate,harddisktotal,harddiskusage,statusupbatch,createaccount,createtime,modifyaccount,modifytime,remarks,extend1,extend2,extend3,extend4-->
        <!--		from ywmachinecurrentstate -->
        <!--		<include refid="condition_Ywmachinecurrentstate"/>	-->
        <!--		&lt;!&ndash; <isNotEmpty prepend=' ' property='start'>-->
        <!--			limit $start$ ,$limit$-->
        <!--		</isNotEmpty> &ndash;&gt;-->

        SELECT (select csmc from xtcl where csdl = 'ywMachineCurrentState' and csdm = currentstate ) as currentstatename,
        currentstateid, currentstate, b.machineid, b.machinenum , b.machinename, b.machineip, repairstate,
        (select alarmname from ywalarmeventcode where alarmcode=repairstate) repairstatename,
        currentstatetime, machinestate, cpustatus, cpuusage, memorystate, memorytotal, memoryusage, harddiskstate,
        harddisktotal, harddiskusage, statusupbatch,b.remarks
        FROM (select * from ywmachinecurrentstate a
        <include refid="condition_Ywmachinecurrentstate"/>) a right join
        ywmachineinfo b on a.machineid=b.machineid where 1=1
        <isNotEmpty prepend='AND ' property='LIKEbz'>
            (b.remarks like '%$LIKEbz$%' )
        </isNotEmpty>
        <isNotEmpty property='emptyremarks'>
            <isEqual prepend='AND ' property='emptyremarks' compareValue="0">
                (b.remarks is null or b.remarks =' ' )
            </isEqual>
            <isEqual prepend='AND ' property='emptyremarks' compareValue="1">
                (b.remarks is not null and b.remarks !=' ' )
            </isEqual>
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='currentstate'>
            (a.currentstate = #currentstate# )
        </isNotEmpty>
        <isNotEmpty property='tableparam'>
            $tableparam$
        </isNotEmpty>
    </select>
    <!-- query objects by page-->
    <select id="get_Ywmachinecurrentstate" resultClass="java.util.HashMap" parameterClass="java.util.Map"
            remapResults="true">
        SELECT (
        SELECT csmc
        FROM xtcl
        WHERE csdl = 'ywMachineCurrentState'
        AND csdm = currentstate
        ) AS currentstatename, currentstateid, currentstate, machineid, machinenum
        , machinename, machineip, repairstate, currentstatetime, machinestate
        , cpustatus, cpuusage, memorystate, memorytotal, memoryusage
        , harddiskstate, harddisktotal, harddiskusage, statusupbatch
        FROM ywmachinecurrentstate
        <include refid="condition_Ywmachinecurrentstate"/>
    </select>

    <select id="count_YwmachineUnonline" resultClass="java.lang.Integer" parameterClass="java.util.Map"
            remapResults="true">
        SELECT count(*) from ( select machineid
        FROM ywmachinecurrentstate
        <include refid="condition_Ywmachinecurrentstate"/>
        union all
        select machineid
        FROM ywmachineinfo where machineid not in (
        select machineid FROM ywmachinecurrentstate )
        )
    </select>


    <select id="query_YwmachineUnonline" resultClass="java.util.HashMap" parameterClass="java.util.Map"
            remapResults="true">
        SELECT (
        SELECT csmc
        FROM xtcl
        WHERE csdl = 'ywMachineCurrentState'
        AND csdm = currentstate
        ) AS currentstatename, currentstateid, currentstate, machineid, machinenum
        , machinename, machineip, repairstate, currentstatetime, machinestate
        , cpustatus, cpuusage, memorystate, memorytotal, memoryusage
        , harddiskstate, harddisktotal, harddiskusage, statusupbatch
        FROM ywmachinecurrentstate
        <include refid="condition_Ywmachinecurrentstate"/>
        union all
        select '' currentstatename, '' currentstateid, '' currentstate, machineid, machinenum , machinename, machineip,
        0 repairstate, '' currentstatetime, 0 machinestate
        , 0 cpustatus, '' cpuusage, 0 memorystate, '' memorytotal, '' memoryusage , 0 harddiskstate, '' harddisktotal,
        '' harddiskusage, '' statusupbatch
        FROM ywmachineinfo where machineid not in (
        select machineid FROM ywmachinecurrentstate )

    </select>
    <select id="count_Ywmachineonline" resultClass="java.lang.Integer" parameterClass="java.util.Map"
            remapResults="true">
        SELECT count(*) FROM ywmachinecurrentstate
        <include refid="condition_Ywmachinecurrentstate"/>

    </select>


    <select id="query_Ywmachineonline" resultClass="java.util.HashMap" parameterClass="java.util.Map"
            remapResults="true">
        SELECT (
        SELECT csmc
        FROM xtcl
        WHERE csdl = 'ywMachineCurrentState'
        AND csdm = currentstate
        ) AS currentstatename, currentstateid, currentstate, machineid, machinenum
        , machinename, machineip, repairstate, currentstatetime, machinestate
        , cpustatus, cpuusage, memorystate, memorytotal, memoryusage
        , harddiskstate, harddisktotal, harddiskusage, statusupbatch
        FROM ywmachinecurrentstate
        <include refid="condition_Ywmachinecurrentstate"/>

    </select>
    <select id="listMachineInfo" resultClass="java.util.HashMap" parameterClass="java.util.Map" remapResults="true">
		SELECT machineid,machinenum,machinename,machineip,machinestate,cpustatus,cpuusage,
			memorystate,memorytotal,memoryusage,harddiskstate,harddisktotal,
			harddiskusage,currentstatetime,(case when currentstate='1' then '1' else '0' end) as state
		FROM ywmachinecurrentstate
	</select>

    <!-- query objects totalcount -->
    <select id="count_Ywmachinecurrentstate" resultClass="java.lang.Integer" parameterClass="java.util.Map">
        select count(*) from ywmachineinfo where 1=1
        <isNotEmpty prepend='AND ' property='LIKEmachineid'>
            (machineid like '%$LIKEmachineid$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='machineid'>
            (machineid = #machineid# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEmachinenum'>
            (machinenum like '%$LIKEmachinenum$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='machinenum'>
            (machinenum = #machinenum# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEmachinename'>
            (machinename like '%$LIKEmachinename$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='machinename'>
            (machinename = #machinename# )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='LIKEmachineip'>
            (machineip like '%$LIKEmachineip$%' )
        </isNotEmpty>
        <isNotEmpty prepend='AND ' property='machineip'>
            (machineip = #machineip# )
        </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>
    </select>

    <!-- batch add objects -->
    <insert id="batch_insert_Ywmachinecurrentstate" parameterClass="java.util.List">
        <![CDATA[
          INSERT
      	]]>
        <iterate conjunction=" ">
            into ywmachinecurrentstate(
            <![CDATA[
				currentstateid,machineid,machinenum,machinename,machineip,currentstate,repairstate,currentstatetime,machinestate,cpustatus,cpuusage,memorystate,memorytotal,memoryusage,harddiskstate,harddisktotal,harddiskusage,statusupbatch,createaccount,createtime,modifyaccount,modifytime,remarks,extend1,extend2,extend3,extend4
			)values
			 ]]>
            <![CDATA[
				(
				#list[].currentstateid#,#list[].machineid#,#list[].machinenum#,#list[].machinename#,#list[].machineip#,	#list[].currentstate#,#list[].repairstate#,#list[].currentstatetime#,#list[].machinestate#,#list[].cpustatus#,#list[].cpuusage#,#list[].memorystate#,#list[].memorytotal#,#list[].memoryusage#,#list[].harddiskstate#,#list[].harddisktotal#,#list[].harddiskusage#,#list[].statusupbatch#,#list[].createaccount#,#list[].createtime#,#list[].modifyaccount#,#list[].modifytime#,#list[].remarks#,#list[].extend1#,#list[].extend2#,#list[].extend3#,#list[].extend4#
				)
			]]>
        </iterate>
    </insert>
    <select id="statisticsMachineOnlineRate-backup" resultClass="java.util.HashMap" parameterClass="java.util.Map">
		select COUNT(*) as totalCount, 
		<![CDATA[ 
		(select COUNT(currentstate) from ywmachinecurrentstate where currentstate in('1','3','4','5')) as fwonlineNum,
		(select COUNT(*) from ywmachinecurrentstate where currentstate not in('1','3','4','5') or currentstate is null) as fwunonlineNum,
		(select COUNT(currentstate) from ywmachinecurrentstate where currentstate = '1') as fwintactNum,
		(select COUNT(*) from ywmachinecurrentstate where currentstate <> '1' or currentstate is null) as fwunIntactNum
		]]>
		from ywmachinecurrentstate
	</select>
    <select id="statisticsMachineOnlineRate" resultClass="java.util.HashMap" parameterClass="java.util.Map">
		select COUNT(*) as totalcount ,'totalcount' as name      
		from ywmachineinfo
		union ALL
		(select COUNT(currentstate) as totalcount,'fwonlinenum' as name from ywmachinecurrentstate where currentstate in('1','3','4','5')  )
		union ALL
		(select COUNT(*) as totalcount ,'fwunonlinenum' as name from (
		 select machineid  from  ywmachineinfo where machineid not in  (select machineid from ywmachinecurrentstate)
		 union
		 select machineid from  ywmachinecurrentstate where currentstate not in('1','3','4','5') or currentstate is null)
		 )
		union ALL
		(select COUNT(currentstate) as totalcount ,'fwintactnum' as name from ywmachinecurrentstate where currentstate = '1')    
		union ALL
		(select COUNT(*) as totalcount ,'fwunIntactnum' as name    from ywmachinecurrentstate where currentstate != '1' or currentstate is null) 
	</select>
    <select id="listStatisticsMachineIntactRate" resultClass="java.util.HashMap" parameterClass="java.util.Map">
		(select count(*) as totalcount ,'intactNum' as name from ywmachinecurrentstate  where currentstate ='1' )
		union all 
		(select count(*) as totalcount,'unIntactNum' as name from ywmachinecurrentstate where  currentstate!= '1' )
	</select>

    <select id="query_AbnormalMachine">
        <![CDATA[
		select * from ywmachinecurrentstate	where  currentstate <> '1' or currentstate is null
		]]>
        <isNotEmpty prepend=' ' property='start'>
            limit $start$ ,$limit$
        </isNotEmpty>
    </select>

</sqlMap>











