<?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.cplbusiness.mapper.CommoditySplittingMapper">

        <!-- 通用查询映射结果 -->
        <resultMap id="BaseResultMap" type="com.unis.crk.cplbusiness.entity.CommoditySplitting">
                    <id column="dataId" property="dataId" />
                    <result column="unitid" property="unitid" />
                    <result column="builder" property="builder" />
                    <result column="builderDate" property="builderDate" />
                    <result column="editor" property="editor" />
                    <result column="modifyDate" property="modifyDate" />
                    <result column="updateTime" property="updateTime" />
                    <result column="plit_doc_no" property="plitDocNo" />
                    <result column="commodity_name" property="commodityName" />
                    <result column="commodity_code" property="commodityCode" />
                    <result column="brand" property="brand" />
                    <result column="varieties" property="varieties" />
                    <result column="specification_before_disassembly" property="specificationBeforeDisassembly" />
                    <result column="uom_before_splitting" property="uomBeforeSplitting" />
                    <result column="date_of_manufacture" property="dateOfManufacture" />
                    <result column="number" property="number" />
                    <result column="specification_after_disassembly" property="specificationAfterDisassembly" />
                    <result column="uom_after_splitting" property="uomAfterSplitting" />
                    <result column="plit_time" property="plitTime" />
                    <result column="roduction_batch" property="roductionBatch" />
                    <result column="arehouse_number" property="arehouseNumber" />
                    <result column="location_number" property="locationNumber" />
                    <result column="review_comments" property="reviewComments" />
                    <result column="mainDataId" property="mainDataId" />

        </resultMap>

    <select id="selectMyMapsPage" resultType="java.util.Map">
        SELECT
               builderDate,
               a.dataId,
               a.plit_doc_no,
               mxpz_enum.sjjlspmc AS  commodity_name,
               a.plit_time,
               b.enumName as brand,
               c.enumName as varieties,
               cf_enum.storehouse_name AS arehouseNumber,
               hw_enum.warehouse_name AS locationNumber
               FROM  commodity_splitting a
        LEFT JOIN data_crkyw_cplsp_default mxpz_enum ON mxpz_enum.sjjlspmcbh = a.commodity_code
        and  mxpz_enum.unitId = a.unitId
        LEFT JOIN  basic_enum b on a.brand = b.enumId
        LEFT JOIN  basic_enum c on a.varieties = c.enumId
        LEFT JOIN basic_storehouse cf_enum ON cf_enum.storehouse_id = a.arehouse_number
        LEFT JOIN basic_warehouse hw_enum ON hw_enum.warehouse_id = a.location_number
        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            where   ${ew.sqlSegment}
        </if>
        ORDER BY
        builderDate DESC
    </select>
</mapper>
