<?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.cecep.talroad.mapper.MAmDoorMonitorAccountFiMapper">
  <resultMap id="BaseResultMap" type="cn.cecep.talroad.domain.MAmDoorMonitorAccountFi">
    <!--@mbg.generated-->
    <!--@Table m_am_door_monitor_account_fi-->
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="factory_id" jdbcType="VARCHAR" property="factoryId" />
    <result column="lpn_code" jdbcType="VARCHAR" property="lpnCode" />
    <result column="entry_type" jdbcType="VARCHAR" property="entryType" />
    <result column="entry_time" jdbcType="VARCHAR" property="entryTime" />
    <result column="car_team" jdbcType="VARCHAR" property="carTeam" />
    <result column="discharge_stage" jdbcType="VARCHAR" property="dischargeStage" />
    <result column="ngine_code" jdbcType="VARCHAR" property="ngineCode" />
    <result column="io_type" jdbcType="VARCHAR" property="ioType" />
    <result column="cargo_quantity" jdbcType="VARCHAR" property="cargoQuantity" />
    <result column="driving_license_image" jdbcType="VARCHAR" property="drivingLicenseImage" />
    <result column="accessory_list_image" jdbcType="VARCHAR" property="accessoryListImage" />
    <result column="access_control_code" jdbcType="VARCHAR" property="accessControlCode" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, factory_id, lpn_code, entry_type, entry_time, car_team, discharge_stage, ngine_code, 
    io_type, cargo_quantity, driving_license_image, accessory_list_image, access_control_code
  </sql>

  <select id="selectByMaps" resultType="java.util.Map">
    SELECT
    case discharge_stage
    WHEN 'I' then '国一'
    WHEN 'II' then '国二'
    WHEN 'III' then '国三'
    WHEN 'IV' then '国四'
    WHEN 'V' then '国五'
    WHEN 'VI' then '国六'
    WHEN 'NE' then '新能源'
    END name,
    COUNT ( DISTINCT lpn_code ) value
    FROM
    m_am_door_monitor_account_fi
    WHERE
    discharge_stage != ''
    AND lpn_code != ''
    AND entry_time != ''
    AND factory_id = #{map.factoryId}
    AND access_control_code = #{map.accessControlCode}
    AND entry_time &gt;= #{map.startTime}
    AND entry_time &lt;= #{map.endTime}
    GROUP BY
    discharge_stage
    order by value desc
  </select>

  <select id="selectLists" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List">
    </include>
    from
    m_am_door_monitor_account_fi
    where
    discharge_stage != ''
    AND lpn_code != ''
    AND entry_time != ''
    AND factory_id = #{map.factoryId}
    AND access_control_code = #{map.accessControlCode}
    AND entry_time &gt;= #{map.startTime}
    AND entry_time &lt;= #{map.endTime}
    order by entry_time

  </select>
</mapper>