<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xunmei.core.resumption.mapper.ProtectionMapper">

<!--    <select id="deviceList" resultType="com.isp.inspection.vo.SearchDeviceListVo">-->

<!--        select id as deviceId,name as deviceName from t_device where deleted =0 and category_id=3713671920926720-->
<!--        <if test="request.orgId!=null and request.orgId!=''">-->
<!--            and org_id = #{request.orgId}-->
<!--        </if>-->
<!--        <if test="request.orgPath!=null and request.orgPath!=''">-->
<!--            and org_path like concat(#{request.orgPath},'%')-->
<!--        </if>-->
<!--    </select>-->

    <select id="pageList" resultType="com.xunmei.core.resumption.vo.protection.ProtectionPageVo">
        select a.id,
        a.name as name,
        a.status as status,
        a.org_name as orgName,
        a.all_hour as allHour,
        a.status_update_time as statusUpdateTime
        from core_protection a
        <if test="request.checkSub==true">
            inner join sys_org c
            on a.org_id = c.id and c.deleted=0 and c.path like concat((select id from sys_org where id=#{request.orgId}),  '%')
        </if>
        where a.deleted=0
        <if test="request.checkSub==false">
            and a.org_id = #{request.orgId}
        </if>
        <if test="request.status!=null ">
            and a.status = #{request.status}
        </if>
        <if test="request.key!=null and request.key!=''">
            and a.name like concat('%',#{request.key},'%')
        </if>
        <if test="request.startTime!=null and request.endTime!=null">
            and a.status_update_time >= #{request.startTime} and  a.status_update_time&lt;=#{request.endTime}
        </if>
    </select>
<!--    <select id="pageLog" resultType="com.xunmei.core.resumption.vo.protection.ProtectionLogPageVo">-->
<!--        select a.id, a.name as name,a.status as status,a.status_update_time,a.status_updator_name-->
<!--        from core_protection_log a-->
<!--        where a.deleted=0 and a.protection_id=#{request.protectionId}-->
<!--        <if test="request.startTime!=null and request.endTime!=null">-->
<!--            and a.status_update_time >= #{request.startTime} and  a.status_update_time&lt;=#{request.endTime}-->
<!--        </if>-->
<!--    </select>-->

<!--    <select id="pageSensorList" resultType="com.isp.inspection.vo.pageSensorVo">-->
<!--        select input_name as inputName,input_index as inputIndex,sensor_type_name as sensorTypeName,-->
<!--        status_text as statusText,status_value as statusValue-->
<!--        from t_sensor where defencearea_code =#{request.defenceareaCode}-->
<!--        <if test="request.sensorName!=null and request.sensorName!=''">-->
<!--            and input_name like concat('%',#{request.sensorName},'%')-->
<!--        </if>-->
<!--        <if test="request.status!=null and request.status!=''">-->
<!--            and status_value =#{request.status}-->
<!--        </if>-->
<!--    </select>-->

<!--    <select id="pageByMybatis" resultType="com.isp.device.vo.protection.ProtectionPageVo4Mybatis">-->
<!--        select p.id as id,-->
<!--        p.name as name,-->
<!--        p.code as code,-->
<!--        p.org_id orgId,-->
<!--        ifnull(p.update_time,p.create_time) as updateTime,-->
<!--        p.status as `status`,-->
<!--        p.org_name as orgName,-->
<!--        d.name as alarmHostName-->
<!--        from t_protection p left join t_device d on p.device_id = d.id-->
<!--        <if test="request.code != null and request.code != ''">-->
<!--            inner join t_category c on p.code = c.name = #{request.code,jdbcType=VARCHAR}-->
<!--        </if>-->
<!--        where p.deleted = 0-->
<!--        <if test="request.name != null and request.name != ''">-->
<!--            and p.name like concat('%',#{request.name},'%')-->
<!--        </if>-->
<!--        <if test="request.orgId != null">-->
<!--            and p.org_path like concat((select path from t_org where id = #{request.orgId}),'%')-->
<!--        </if>-->
<!--        <if test="request.status != null">-->
<!--            and p.status = #{request.status}-->
<!--        </if>-->
<!--        <if test="request.id != null and request.id != ''">-->
<!--            and p.id = #{request.id}-->
<!--        </if>-->
<!--        <if test="request.path != null and request.path != ''">-->
<!--            and p.org_path like concat(#{request.path},'%')-->
<!--        </if>-->

<!--        <choose>-->
<!--            <when test="request.onlinType!=null and request.onlinType==1">-->
<!--                <if test="request.time!=null">-->
<!--                    and p.update_time >=#{request.time}-->
<!--                </if>-->
<!--                <if test="request.time==null">-->
<!--                    and p.update_time is not null-->
<!--                </if>-->

<!--            </when>-->
<!--            <when test="request.onlinType!=null and request.onlinType==0">-->
<!--                <if test="request.time!=null">-->
<!--                    and #{request.time}>p.update_time-->
<!--                </if>-->
<!--                <if test="request.time==null">-->
<!--                    and p.update_time is null-->
<!--                </if>-->
<!--            </when>-->
<!--        </choose>-->


<!--        <if test="request.sortColumn == 'orgId'">-->
<!--            order by p.org_id asc-->
<!--        </if>-->
<!--        <if test="request.sortColumn == 'updateTime'">-->
<!--            order by ifnull(p.update_time,p.create_time) desc-->
<!--        </if>-->
<!--    </select>-->
<!--    <select id="selectProtectSensorData" resultType="com.isp.board.vo.ProtectSensorList">-->
<!--        SELECT p.`name`      AS protectionName,-->
<!--               input_name    AS sensorName,-->
<!--               d.update_time AS alarmTime,-->
<!--               input_name   AS alarmType,-->
<!--               isdo          as isDeal-->
<!--        FROM t_protection p-->
<!--                 INNER JOIN t_sensor_alarm_data d ON p.`code` = d.defencearea_code-->
<!--        WHERE p.deleted = 0-->
<!--          and p.org_id = #{orgId}-->
<!--          and d.update_time &gt;= #{startTime}-->
<!--          and d.update_time &lt;= #{endTime}-->
<!--        ORDER BY d.update_time DESC-->
<!--    </select>-->
<!--    <select id="selectIds" resultType="Long">-->
<!--        select  id from t_protection where  org_id=#{orgId} and deleted=0;-->
<!--    </select>-->
<!--    <select id="productDeviceAlarmData" resultType="com.isp.board.vo.ProductDeviceAlarmList">-->
<!--        select p.id, p.device_name as productDeviceName,d.`update_time` as alarmTime,d.isdo as isDeal,c.name as alarmType from t_product_device p inner join t_sensor_alarm_data d on p.str_device_id = d.str_device_id-->
<!--        left join t_category c on p.product_type = c.id    where p.org_id = #{orgId} and d.update_time &gt;= #{startTime} and d.update_time &lt;= #{endTime} and p.source =#{sorce}-->
<!--        <if test="typeList.size>0">-->
<!--            and p.product_type in-->
<!--            <foreach collection="typeList" item="item" index="index" open="(" close=")" separator=",">-->
<!--                #{item}-->
<!--            </foreach>-->
<!--        </if>-->
<!--    </select>-->
</mapper>
