<?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.shinsoft.sto.mapper.main.AreaMapper">

    <resultMap id="BaseResultMap" type="com.shinsoft.sto.model.main.Area">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="process_instance_id" property="processInstanceId" jdbcType="VARCHAR"/>
        <result column="process_instance_status" property="processInstanceStatus" jdbcType="VARCHAR"/>
        <result column="add_id" property="addId" jdbcType="VARCHAR"/>
        <result column="add_code" property="addCode" jdbcType="VARCHAR"/>
        <result column="add_name" property="addName" jdbcType="VARCHAR"/>
        <result column="add_dept_id" property="addDeptId" jdbcType="VARCHAR"/>
        <result column="add_dept_code" property="addDeptCode" jdbcType="VARCHAR"/>
        <result column="add_dept_name" property="addDeptName" jdbcType="VARCHAR"/>
        <result column="add_time" property="addTime" jdbcType="TIMESTAMP"/>
        <result column="modify_id" property="modifyId" jdbcType="VARCHAR"/>
        <result column="modify_code" property="modifyCode" jdbcType="VARCHAR"/>
        <result column="modify_name" property="modifyName" jdbcType="VARCHAR"/>
        <result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP"/>
        <result column="cancel_id" property="cancelId" jdbcType="VARCHAR"/>
        <result column="cancel_code" property="cancelCode" jdbcType="VARCHAR"/>
        <result column="cancel_name" property="cancelName" jdbcType="VARCHAR"/>
        <result column="cancel_time" property="cancelTime" jdbcType="TIMESTAMP"/>
        <result column="cancel_flag" property="cancelFlag" jdbcType="VARCHAR"/>
        <result column="belong_id" property="belongId" jdbcType="VARCHAR"/>
        <result column="ware_id" property="wareId" jdbcType="VARCHAR"/>
        <result column="area_name" property="areaName" jdbcType="VARCHAR"/>
        <result column="area_code" property="areaCode" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        a.id, a.process_instance_id, a.process_instance_status, a.add_id, a.add_code, a.add_name, a.add_dept_id,
        a.add_dept_code, a.add_dept_name, a.add_time, a.modify_id, a.modify_code, a.modify_name, a.modify_time,
        a.cancel_id, a.cancel_code, a.cancel_name, a.cancel_time, a.cancel_flag, a.belong_id, a.ware_id,
        a.area_name, a.area_code
    </sql>

    <select id="selectAreaPage" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>,
        w.ware_nm as ware_name
        from T_MAIN_AREA a
                 left join T_MAIN_WARE w on w.id = a.ware_id
        where nvl(a.cancel_flag,'0') = '0'
        <if test="wareId != null and wareId != ''">
            and a.ware_id = #{wareId}
        </if>
        order by a.add_time desc
    </select>

</mapper>


