ElectricFenceMapper.xml 4.74 KB
<?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="cn.com.glsx.dj.reports.mapper.ElectricFenceMapper">
  <resultMap id="BaseResultMap" type="cn.com.glsx.dj.reports.model.ElectricFence">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="sn" jdbcType="VARCHAR" property="sn" />
    <result column="electric_fence_type" jdbcType="INTEGER" property="electricFenceType" />
    <result column="electric_fence_name" jdbcType="VARCHAR" property="electricFenceName" />
    <result column="location_type" jdbcType="INTEGER" property="locationType" />
    <result column="shape" jdbcType="INTEGER" property="shape" />
    <result column="shape_type" jdbcType="INTEGER" property="shapeType" />
    <result column="radius" jdbcType="INTEGER" property="radius" />
    <result column="lng_lat" jdbcType="VARCHAR" property="lngLat" />
    <result column="start_time" jdbcType="VARCHAR" property="startTime" />
    <result column="end_time" jdbcType="VARCHAR" property="endTime" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="merchant_id" jdbcType="INTEGER" property="merchantId" />
    <result column="created_by" jdbcType="VARCHAR" property="createdBy" />
    <result column="created_date" jdbcType="TIMESTAMP" property="createdDate" />
    <result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
    <result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate" />
    <result column="deleted_flag" jdbcType="CHAR" property="deletedFlag" />
  </resultMap>
  
  <resultMap id="BaseResultDTOMap" type="cn.com.glsx.dj.reports.dto.ElectricFenceDTO" extends="BaseResultMap">
    
  </resultMap>
  
  <sql id="Base_Column_List">
    id, sn, electric_fence_type, electric_fence_name, location_type, shape, shape_type, 
    radius, lng_lat, start_time, end_time, status, merchant_id, created_by, created_date, 
    updated_by, updated_date, deleted_flag
  </sql>
  
  <sql id="Base_Column_List_E">
  	e.id, e.sn, e.electric_fence_type, e.electric_fence_name, e.location_type, e.shape, e.shape_type, 
    e.radius, e.lng_lat, e.start_time, e.end_time, e.status, e.merchant_id, e.created_by, e.created_date, 
    e.updated_by, e.updated_date, e.deleted_flag
  </sql>
  
  <sql id="baseWhereClause" >
    <where>
		<if test="record.id != null">
			and id = #{record.id,jdbcType=INTEGER}
		</if>
		<if test="record.sn != null and record.sn !=''">
			and sn = #{record.sn,jdbcType=VARCHAR}
		</if>
		<if test="record.createdDate != null and record.createdDate !=''">
			and created_date = #{record.createdDate,jdbcType=TIMESTAMP}
		</if>
		<if test="record.updatedDate != null and record.updatedDate !=''">
			and updated_date = #{record.updatedDate,jdbcType=TIMESTAMP}
		</if>
		<if test="record.merchantIds != null and record.merchantIds.size > 0 ">
            and merchant_id in
            <foreach item="merchantId" index="index" collection="record.merchantIds" open="(" separator="," close=")">
	            #{merchantId}
	        </foreach>
		</if>
		and deleted_flag = 'N'
    </where>
  </sql>
  
  <select id="listBasic" parameterType="cn.com.glsx.dj.reports.dto.ElectricFenceDTO" resultMap="BaseResultDTOMap">
  	select <include refid="Base_Column_List"></include> 
  	from dj_electric_fence 
  	<include refid="baseWhereClause"/>
  </select>
  
  <select id="list" parameterType="cn.com.glsx.dj.reports.dto.ElectricFenceDTO" resultMap="BaseResultDTOMap">
  	 SELECT
  	 <include refid="Base_Column_List_E"></include>
        FROM dj_electric_fence e, dj_insure_device de, dj_insure_vehicle dv
        <where>
        	e.sn = de.sn
        	AND de.vehicleId = dv.vehicleId
      		AND deleted_flag = 'N'
      		<if test="merchantIds != null and merchantIds.size > 0 ">
	            and e.merchant_id in
	            <foreach item="merchantId" index="index" collection="merchantIds" open="(" separator="," close=")">
		            #{merchantId}
		        </foreach>
			</if>
			<if test="notStatus != null and notStatus.size > 0 ">
	            and e.status not in
	            <foreach item="item" index="index" collection="notStatus" open="(" separator="," close=")">
		            #{item}
		        </foreach>
			</if>
	        <if test="snList != null and snList.size > 0">
	            and de.sn in <foreach index="index" item="item" collection="snList" separator="," open="(" close=")">#{item}</foreach>
	        </if>
	        <if test="name != null and name != ''">
	            and dv.name like CONCAT('%',#{name},'%')
	        </if>
	        <if test="standNo != null and standNo != ''">
	            and dv.standno like CONCAT('%',#{standNo},'%')
	        </if>
        </where> 
        ORDER BY e.created_date DESC
  </select>
  
</mapper>