<?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.unis.crk.basic.mapper.StorageGrainCardMapper">

        <!-- 通用查询映射结果 -->
        <resultMap id="BaseResultMap" type="com.unis.crk.basic.entity.StorageGrainCard">
                    <id column="id" property="id" />
                    <result column="storehouse_num" property="storehouseNum" />
                    <result column="warehouse_num" property="warehouseNum" />
                    <result column="storehouse_name" property="storehouseName" />
                    <result column="warehouse_name" property="warehouseName" />
                    <result column="grain_variety_num" property="grainVarietyNum" />
                    <result column="grain_variety_name" property="grainVarietyName" />
                    <result column="accept_date" property="acceptDate" />
                    <result column="check_type_num" property="checkTypeNum" />
                    <result column="check_type_name" property="checkTypeName" />
                    <result column="grain_remark" property="grainRemark" />
                    <result column="water_remark" property="waterRemark" />
                    <result column="hwbm" property="hwbm" />
                    <result column="rksl" property="rksl" />
                    <result column="sfmc" property="sfmc" />
                    <result column="scnd" property="scnd" />
                    <result column="tgph" property="tgph" />
                    <result column="org_id" property="orgId" />
                    <result column="flag_type" property="flagType" />
                    <result column="storehouse_id" property="storehouseId" />
                    <result column="warehouse_id" property="warehouseId" />
                    <result column="spare_one" property="spareOne" />
                    <result column="spare_two" property="spareTwo" />
                    <result column="spare_three" property="spareThree" />
                    <result column="spare_four" property="spareFour" />
                    <result column="spare_five" property="spareFive" />
                    <result column="sfgd" property="sfgd" />
                    <result column="gdsj" property="gdsj" />
        </resultMap>

    <select id="selectMyMapsPage" resultType="java.util.Map">
        SELECT
        a.id,
        a.storehouse_name,
        a.warehouse_name,
        a.grain_variety_num,
        a.grain_variety_name,
        a.accept_date,
        a.check_type_num,
        a.check_type_name,
        a.rksl,
        a.scnd,
        a.storehouse_id,
        a.warehouse_id,
        a.spare_one,
        b.enumName as "lspz_value",
        c.enumName as "scnd_value"
        FROM storage_grain_card a
        LEFT JOIN basic_enum b on a.grain_variety_num = b.enumId
        LEFT JOIN basic_enum c on a.scnd = b.enumId
        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            where  ${ew.sqlSegment}
        </if>
    </select>
    <select id="getOne" resultType="java.util.Map">
        SELECT
        a.id,
        a.storehouse_name,
        a.warehouse_name,
        a.grain_variety_num,
        a.accept_date,
        a.check_type_num,
        a.check_type_name,
        a.rksl,
        a.scnd,
        a.storehouse_id,
        a.warehouse_id,
        a.spare_one,
        b.enumName as "lspz_value",
        c.enumName as "scnd_value"
        FROM storage_grain_card a
        LEFT JOIN basic_enum b on a.grain_variety_num = b.enumId
        LEFT JOIN basic_enum c on a.scnd = b.enumId
        <where>
            <if test='id != null and id != ""'>
                a.id = #{id}
            </if>
        </where>
    </select>
</mapper>