src/main/resources/mapper/production/ProductionPlanMapper.xml
@@ -16,38 +16,57 @@
        <result column="qty_required" property="qtyRequired"/>
        <result column="issued" property="issued"/>
        <result column="source" property="source"/>
        <result column="is_audit" property="isAudit"/>
        <result column="promised_delivery_date" property="promisedDeliveryDate"/>
    </resultMap>
    <select id="listPage" resultType="com.ruoyi.production.bean.vo.ProductionPlanVo">
        SELECT
        pp.*,
        pms.material_code AS materialCode,
        pmdl.model,
        pms.product_id AS productMaterialId,
        pm.model,
        p.id as productId,
        p.product_name AS productName,
        pmdl.unit
        pm.unit,
        sl.sales_contract_no,
        sl.customer_name,
        sl.project_name
        FROM production_plan pp
        left join product_material_sku pms on pp.product_material_sku_id = pms.id
        left join product_model pmdl on pp.product_model_id = pmdl.id
        left join product p on pmdl.product_id = p.id
        ORDER BY COALESCE(pp.form_modified_time, pp.id) DESC
        left join product_model pm on pp.product_model_id = pm.id
        left join product p on pm.product_id = p.id
        left join sales_ledger sl on pp.sales_ledger_id = sl.id
        <where>
            <if test="c != null">
                <if test="c.id != null">
                    and pp.id = #{c.id}
                </if>
                <if test="c.productName != null and c.productName != ''">
                    and p.product_name like concat('%', #{c.productName}, '%')
                </if>
                <if test="c.model != null and c.model != ''">
                    and pm.model like concat('%', #{c.model}, '%')
                </if>
                <if test="c.status != null">
                    and pp.status = #{c.status}
                </if>
                <if test="c.mpsNo != null and c.mpsNo != ''">
                    and pp.mps_no like concat('%', #{c.mpsNo}, '%')
                </if>
                <if test="c.requiredDateStart != null and c.requiredDateEnd != null">
                    and pp.required_date between #{c.requiredDateStart} and #{c.requiredDateEnd}
                </if>
            </if>
        </where>
        ORDER BY COALESCE(pp.id) DESC
    </select>
    <select id="selectWithMaterialByIds" resultType="com.ruoyi.production.bean.dto.ProductionPlanDto">
        SELECT
        pp.*,
        pms.material_code AS materialCode,
        pmdl.model,
        pm.model,
        p.product_name AS productName,
        pmdl.unit,
        pms.product_id AS productMaterialId
        pm.unit
        FROM production_plan pp
        LEFT JOIN product_material_sku pms ON pp.product_material_sku_id = pms.id
        LEFT JOIN product_model pmdl ON pp.product_model_id = pmdl.id
        LEFT JOIN product p ON pmdl.product_id = p.id
        LEFT JOIN product_model pm ON pp.product_model_id = pm.id
        LEFT JOIN product p ON pm.product_id = p.id
        WHERE pp.id IN
        <foreach collection="ids" item="id" open="(" separator="," close=")">
            #{id}
@@ -57,15 +76,31 @@
    <select id="selectProductionPlanDtoById" resultType="com.ruoyi.production.bean.dto.ProductionPlanDto">
        SELECT
        pp.*,
        pms.material_code AS materialCode,
        pmdl.model,
        pms.product_id AS productMaterialId,
        pm.model,
        p.product_name AS productName,
        pmdl.unit
        pm.unit
        FROM production_plan pp
        left join product_material_sku pms on pp.product_material_sku_id = pms.id
        left join product_model pmdl on pp.product_model_id = pmdl.id
        left join product p on pmdl.product_id = p.id
        left join product_model pm on pp.product_model_id = pm.id
        left join product p on pm.product_id = p.id
        WHERE pp.id = #{productionPlanId}
    </select>
    <select id="getSource" resultType="com.ruoyi.production.bean.vo.ProductionPlanVo">
         SELECT
        pp.*,
        pm.model,
        p.product_name AS productName,
        pm.unit,
        sl.sales_contract_no,
        sl.customer_name,
        sl.project_name
        FROM production_plan pp
        LEFT JOIN product_model pm ON pp.product_model_id = pm.id
        LEFT JOIN product p ON pm.product_id = p.id
        left join sales_ledger sl on pp.sales_ledger_id = sl.id
        WHERE pp.id IN
        <foreach collection="ids" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        ORDER BY pp.id ASC
    </select>
</mapper>