<?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.fjhx.mes.mapper.material.MaterialPreparationMapper">
    <select id="getPage" resultType="com.fjhx.mes.entity.material.vo.MaterialPreparationVo">
        <include refid="pageOrList"/>
    </select>
    <select id="getList" resultType="com.fjhx.mes.entity.material.vo.MaterialPreparationVo">
        <include refid="pageOrList"/>
    </select>

    <sql id="pageOrList">
        SELECT mp.id,
               mp.contract_id,
               mp.contract_detail_id,
               mp.production_order_id,
               mp.production_order_detail_id,
               mp.material_id,
               mp.quantity,
               mp.preparation_deadline,
               mp.production_time,
               mp.`status`,
               mp.create_user,
               mp.create_time,
               mp.update_user,
               mp.update_time,
               mp.company_id,
               po.`code`      AS orderCode,
               po.delivery_period,
               pi.`name`      AS materialName,
               pi.custom_code AS materialCode
        FROM material_preparation mp
                 LEFT JOIN production_order po ON mp.production_order_id = po.id
                 LEFT JOIN product_info pi ON mp.material_id = pi.id
            ${ew.customSqlSegment}
    </sql>

</mapper>
