<?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.devplatform.equipment.modules.eppatrolresult.dao.EpPatrolResultDao">
  <!-- Result Map -->
  <resultMap id="BaseResultMap" type="com.devplatform.equipment.modules.eppatrolresult.bean.EpPatrolResult">
    <result column="id" property="id"/>
    <result column="line_id" property="lineId"/>
    <result column="line_name" property="lineName"/>
    <result column="station_id" property="stationId"/>
    <result column="plan_id" property="planId"/>
    <result column="plan_name" property="planName"/>
    <result column="start_time" property="startTime"/>
    <result column="end_time" property="endTime"/>
    <result column="patroller_id" property="patrollerId"/>
    <result column="patroller_name" property="patrollerName"/>
    <result column="plan_times" property="planTimes"/>
    <result column="arrive_times" property="arriveTimes"/>
    <result column="missed_times" property="missedTimes"/>
    <result column="missed_rate" property="missedRate"/>
    <result column="status" property="status"/>
    <result column="sys_sign" property="sysSign"/>
    <result column="deleted" property="deleted"/>
    <result column="create_user_id" property="createUserId"/>
    <result column="create_time" property="createTime"/>
    <result column="update_user_id" property="updateUserId"/>
    <result column="update_time" property="updateTime"/>
    <result column="byx2" property="byx2"/>
    <result column="byx3" property="byx3"/>
    <result column="byx1" property="byx1"/>
  </resultMap>

  <!-- ep_patrol_result table all fields -->
  <sql id="Base_Column_List">
		id,line_id,line_name,station_id,plan_id,plan_name,start_time,end_time,patroller_id,patroller_name,plan_times,arrive_times,missed_times,missed_rate,status,sys_sign,deleted,create_user_id,create_time,update_user_id,update_time,byx2,byx3,byx1
	</sql>

  <!-- 公共查询条件 -->
  <sql id="Example_Where_Clause">
    where deleted=0
    <if test="id!=null and id!=''">and id = #{id}</if>
    <if test="lineId!=null and lineId!=''">and line_id = #{lineId}</if>
    <if test="lineName!=null and lineName!=''">and line_name = #{lineName}</if>
    <if test="stationId!=null and stationId!=''">and station_id = #{stationId}</if>
    <if test="planId!=null and planId!=''">and plan_id = #{planId}</if>
    <if test="planName!=null and planName!=''">and plan_name = #{planName}</if>
    <if test="startTime!=null ">and start_time = #{startTime}</if>
    <if test="endTime!=null ">and end_time = #{endTime}</if>
    <if test="patrollerId!=null and patrollerId!=''">and patroller_id = #{patrollerId}</if>
    <if test="patrollerName!=null and patrollerName!=''">and patroller_name = #{patrollerName}</if>
    <if test="planTimes!=null ">and plan_times = #{planTimes}</if>
    <if test="arriveTimes!=null ">and arrive_times = #{arriveTimes}</if>
    <if test="missedTimes!=null ">and missed_times = #{missedTimes}</if>
    <if test="missedRate!=null ">and missed_rate = #{missedRate}</if>
    <if test="status!=null ">and status = #{status}</if>
    <if test="sysSign!=null and sysSign!=''">and sys_sign = #{sysSign}</if>
    <if test="deleted!=null ">and deleted = #{deleted}</if>
    <if test="createUserId!=null and createUserId!=''">and create_user_id = #{createUserId}</if>
    <if test="createTime!=null ">and create_time = #{createTime}</if>
    <if test="updateUserId!=null and updateUserId!=''">and update_user_id = #{updateUserId}</if>
    <if test="updateTime!=null ">and update_time = #{updateTime}</if>
    <if test="byx2!=null and byx2!=''">and byx2 = #{byx2}</if>
    <if test="byx3!=null and byx3!=''">and byx3 = #{byx3}</if>
    <if test="byx1!=null and byx1!=''">and byx1 = #{byx1}</if>
  </sql>
  <select id="queryPageByCount" parameterType="com.devplatform.equipment.modules.eppatrolresult.model.EpPatrolResultModel"
    resultType="java.lang.Integer">
    select count(1) from ep_patrol_result
    <include refid="queryPageByListClause"></include>
  </select>
  <select id="queryPageByList"
    parameterType="com.devplatform.equipment.modules.eppatrolresult.model.EpPatrolResultModel"
    resultType="com.devplatform.equipment.modules.eppatrolresult.bean.EpPatrolResult">
    select * from ep_patrol_result
    <include refid="queryPageByListClause"></include>
    <if test="pager.orderCondition != null and pager.orderCondition != ''">
      ${pager.orderCondition}
    </if>
    <if test="pager.mysqlQueryCondition != null and pager.mysqlQueryCondition != ''">
      ${pager.mysqlQueryCondition}
    </if>
  </select>
  <select id="countByPlanId" parameterType="string" resultType="java.lang.Integer">
    SELECT count(1) FROM ep_patrol_result WHERE plan_id = #{id} and deleted = 0
    <if test="stationId!=null and stationId!=''">and station_id = #{stationId}</if>
  </select>
  <sql id="queryPageByListClause">
    WHERE deleted = 0
    <if test="stationId!=null and stationId!=''">
      AND station_id =#{stationId}
    </if>
    <if test="keywords!=null and keywords!=''">
      AND (INSTR(plan_name, #{keywords})
      or INSTR(line_name, #{keywords})
      or INSTR(patroller_name, #{keywords}))
    </if>
  </sql>
</mapper>