huminmin
3 天以前 ec3375d0aa399f2f7aa97f61e2d782d1ad17c695
src/main/resources/mapper/production/ProductOrderMapper.xml
@@ -15,50 +15,16 @@
    </resultMap>
    <select id="pageProductOrder" resultType="com.ruoyi.production.dto.ProductOrderDto">
        select po.*,
        sl.sales_contract_no,
        sl.customer_name,
        p.product_name as product_category,
        pm.model as specification_model,
        pm.unit,
        ppr.process_route_code,
        pb.bom_no,
        ROUND(po.complete_quantity / po.quantity * 100, 2) AS completionStatus,
        DATEDIFF(sl.delivery_date, CURDATE()) AS delivery_days_diff,
        sl.delivery_date,
        CASE
        WHEN shipping_status_counts.total_count = 0 THEN false
        WHEN shipping_status_counts.unshipped_count = 0 THEN true
        ELSE false
        END AS is_fh
        ROUND(po.complete_quantity / po.quantity * 100, 2) AS completionStatus
        from product_order po
        left join sales_ledger sl on po.sales_ledger_id = sl.id
        LEFT JOIN (
        SELECT sales_ledger_id,
        COUNT(*) as total_count,
        SUM(CASE WHEN status != '已发货' THEN 1 ELSE 0 END) as unshipped_count
        FROM shipping_info
        GROUP BY sales_ledger_id
        ) shipping_status_counts ON sl.id = shipping_status_counts.sales_ledger_id
            left join product_model pm on po.product_model_id = pm.id
            left join product p on pm.product_id = p.id
        left join sales_ledger_product slp on po.sale_ledger_product_id = slp.id and slp.type = 1
        left join product_process_route ppr on po.id = ppr.product_order_id
        left join product_bom pb on pb.id = ppr.bom_id
        <where>
            <if test="c.npsNo != null and c.npsNo != ''">
                and po.nps_no like concat('%',#{c.npsNo},'%')
            </if>
            <if test="c.salesContractNo != null and c.salesContractNo != ''">
                and sl.sales_contract_no like concat('%',#{c.salesContractNo},'%')
            </if>
            <if test="c.customerName != null and c.customerName != ''">
                and sl.customer_name like concat('%',#{c.customerName},'%')
            </if>
            <if test="c.productCategory != null and c.productCategory != ''">
                and slp.product_category like concat('%',#{c.productCategory},'%')
            </if>
            <if test="c.specificationModel != null and c.specificationModel != ''">
                and slp.specification_model like concat('%',#{c.specificationModel},'%')
            </if>
            <if test="c.startTime != null and c.endTime != null">
                and po.create_time between #{c.startTime} and #{c.endTime}