guoyujie
2025-04-23 3067d24d5f5d20b5c69e626169227a07e1bf1f49
north-glass-erp/src/main/resources/mapper/pp/GlassOptimize.xml
@@ -286,6 +286,67 @@
            `i`.`available_quantity` DESC ;
    </select>
    <!--余料信息-->
    <select id="surplusMaterialsMp">
        SELECT
            i.id AS id,
            '' AS producer,
            i.quantity AS available_quantity,
            i.width,
            i.height,
            i.thickness,
            i.colour AS name,
            i.colour
        FROM  mm.surplus_materials as i
        WHERE
            i.quantity>0 and i.colour=#{model} and i.thickness=#{thickness}
        ORDER BY
            i.quantity DESC ;
    </select>
    <!--库存余料信息-->
    <select id="materialStoreSurplusMp">
        (SELECT
            i.id AS id,
            i.producer AS producer,
            i.available_quantity-i.plan_quantity AS available_quantity,
            JSON_EXTRACT(s.json, '$.width') AS width,
            JSON_EXTRACT(s.json, '$.height') AS height,
            JSON_EXTRACT(s.json, '$.thickness') AS thickness,
            JSON_EXTRACT(s.json, '$.name') AS name,
            JSON_EXTRACT(s.json, '$.model') AS model
        FROM  mm.material_inventory as `i`
                  LEFT JOIN  mm.material_store  as s ON (
            (
                `i`.`material_code` = `s`.`id`
                )
            )
        WHERE
            (
                    (`s`.`type` = '原片')
                    AND (`i`.`optimize_state` = 1)
                    AND (`i`.`available_quantity`-i.plan_quantity > 0)
                    AND JSON_EXTRACT(s.json, '$.thickness') = #{thickness}
                    AND JSON_EXTRACT(s.json, '$.model') = #{model}
                )
        ORDER BY
            `i`.`available_quantity` DESC) union
        (SELECT
            i.id AS id,
            '' AS producer,
            i.quantity AS available_quantity,
            i.width,
            i.height,
            i.thickness,
            i.colour AS name,
            i.colour
        FROM  mm.surplus_materials as i
        WHERE
            i.quantity>0 and i.colour=#{model} and i.thickness=#{thickness}
        ORDER BY
            i.quantity DESC );
    </select>
    <select id="materialStoreOptimizeUse">
        select ms.id AS id,