guoyujie
2025-12-04 eba3314826d53ff0f7e5679d185baaff84e50354
north-glass-erp/src/main/resources/mapper/sd/DeliveryDetailMapper.xml
@@ -54,6 +54,7 @@
        <result column="storage_region" property="finishedGoodsInventory.storageRegion"/>
        <result column="actual_signal_area" property="finishedGoodsInventory.actualSignalArea"/>
        <result column="box_no" property="finishedGoodsInventory.boxNo"/>
        <result column="id" property="finishedGoodsInventory.id"/>
    </resultMap>
@@ -72,6 +73,7 @@
        <result column="delivery_detail_remakes" property="deliveryDetailRemakes"/>
        <result column="delivery_detail_state" property="deliveryDetailState"/>
        <result column="create_time" property="createTime"/>
        <result column="box_no" property="boxNo"/>
        <result column="customer_id" property="delivery.customerId"/>
        <result column="customer_name" property="delivery.customerName"/>
@@ -91,9 +93,12 @@
        <result column="product_id" property="orderDetail.productId"/>
        <result column="product_name" property="orderDetail.productName"/>
        <result column="width" property="orderDetail.width"/>
        <result column="height" property="orderDetail.height"/>
        <result column="building_number" property="orderDetail.buildingNumber"/>
        <result column="other_money" property="order.otherMoney"/>
        <result column="batch" property="order.batch"/>
    </resultMap>
@@ -115,8 +120,11 @@
        <result column="product_id" property="orderDetail.productId"/>
        <result column="product_name" property="orderDetail.productName"/>
        <result column="order_id" property="orderDetail.orderId"/>
        <result column="width" property="orderDetail.edgingType"/>
        <result column="height" property="orderDetail.shape"/>
        <result column="contract_id" property="order.contractId"/>
        <result column="batch" property="order.batch"/>
@@ -179,7 +187,7 @@
               fgi.quantity_available + dd.quantity as quantity_available,
               od.order_number,
               od.quantity-od.delivery_num as t_quantity,
               od.quantity as o_quantity,
        (fgi.quantity_available+ifnull(dd1.sumQuantity,0)) as o_quantity,
               dd.quantity as d_quantity,
               od.building_number,
               od.product_id,
@@ -205,10 +213,14 @@
        left join sd.delivery d on dd.delivery_id=d.delivery_id
        left join sd.order_detail od on dd.order_id=od.order_id and dd.order_number=od.order_number
        left join sd.`order` o on dd.order_id=o.order_id
        left join mm.finished_goods_inventory fgi on dd.order_id=fgi.order_id and dd.order_number=fgi.order_number
        left join mm.finished_goods_inventory fgi on dd.order_id=fgi.order_id and dd.order_number=fgi.order_number and fgi.box_no = dd.box_no
        left join (SELECT IFNULL(sum(quantity),0) as sumQuantity,dd.*
                    from sd.delivery_detail dd
                    GROUP BY dd.order_id,dd.order_number,dd.box_no) AS dd1
        on od.order_id = dd1.order_id and od.order_number = dd1.order_number and dd1.box_no = fgi.box_no
        <where>
            <if test="orderDetail.deliveryDetail.deliveryId != null and orderDetail.deliveryDetail.deliveryId != ''">
                and dd.delivery_id regexp #{orderDetail.deliveryDetail.deliveryId}
                and dd.delivery_id = #{orderDetail.deliveryDetail.deliveryId}
            </if>
            <if test="orderDetail.orderId != null and orderDetail.orderId != ''">
                and od.order_id regexp #{orderDetail.orderId}
@@ -281,7 +293,7 @@
            </if>
        </where>
        order by dd.id
        order by dd.box_no,dd.order_id,dd.order_number
    </select>
    <select id="getSelectShippingOrderDetailPageTotal">
@@ -369,14 +381,16 @@
    </select>
    <select id="getSelectShippingOrderDetails" resultMap="selectDeliveryFinishedGoodsInventoryOrderDetail">
        select od.order_id,
        select
        fgi.id,
                od.order_id,
               od.order_number,
               o.batch,
               o.calculate_type,
               fgi.quantity_available,
               od.quantity- od.delivery_num as t_quantity,
               od.quantity as o_quantity,
               fgi.quantity_available as d_quantity,
               od.quantity- od.delivery_num as t_quantity,-- 未发数量
        ifnull(dd1.sumQuantity,0)+fgi.quantity_available as o_quantity,-- 数量
               fgi.quantity_available as d_quantity,-- 发货数量
               od.building_number,
               od.product_id,
               od.product_name,
@@ -399,6 +413,13 @@
                 left join sd.`order` o on od.order_id = o.order_id
                 left join mm.finished_goods_inventory fgi
                 on od.order_id = fgi.order_id and od.order_number = fgi.order_number
        left join (SELECT IFNULL(sum(quantity),0) as sumQuantity,dd.*
                    from sd.delivery_detail dd
                    where dd.order_id regexp #{orderDetail.orderId}
                    GROUP BY dd.order_id,dd.order_number,dd.box_no) AS dd1
        on od.order_id = dd1.order_id and od.order_number = dd1.order_number and dd1.box_no = fgi.box_no
        <where>
            fgi.quantity_available > 0 and od.quantity > od.delivery_num
            <if test="orderDetail.orderId != null and orderDetail.orderId != ''">
@@ -571,13 +592,33 @@
        o.other_money,
        d.freight_price,
        d.freight_quantity,
        d.freight
        d.freight,
        o.batch,
        od.width,
        od.height,
        od.building_number,
        dd.box_no
        from sd.delivery_detail dd
        left join sd.delivery d on dd.delivery_id=d.delivery_id
        left join order_detail od on dd.order_id=od.order_id and dd.order_number=od.order_number
        left join sd.`order` o on dd.order_id=o.order_id
        <where>
               and date(dd.create_time)>=#{startDate} and date(dd.create_time) &lt;= #{endDate}
            <if test="deliveryDetail.order!=null and (deliveryDetail.order.batch != null and deliveryDetail.order.batch != '')">
                and o.batch like concat('%',#{deliveryDetail.order.batch},'%')
            </if>
            <if test="deliveryDetail.orderDetail!=null and (deliveryDetail.orderDetail.width != null and deliveryDetail.orderDetail.width != '')">
                and od.width regexp REGEXP_REPLACE(#{deliveryDetail.orderDetail.width},'\\.0+$','')
            </if>
            <if test="deliveryDetail.orderDetail!=null and (deliveryDetail.orderDetail.height != null and deliveryDetail.orderDetail.height != '')">
                and od.height regexp REGEXP_REPLACE(#{deliveryDetail.orderDetail.height},'\\.0+$','')
            </if>
            <if test="deliveryDetail.orderDetail!=null and (deliveryDetail.orderDetail.buildingNumber != null and deliveryDetail.orderDetail.buildingNumber != '')">
                and od.building_number like concat('%',#{deliveryDetail.orderDetail.buildingNumber},'%')
            </if>
            <if test="deliveryDetail.boxNo != null and deliveryDetail.boxNo != ''">
                and dd.box_no like concat('%',#{deliveryDetail.boxNo},'%')
            </if>
            <if test="deliveryDetail.deliveryId != null and deliveryDetail.deliveryId != ''">
                and dd.delivery_id like concat('%',#{deliveryDetail.deliveryId},'%')
            </if>
@@ -677,6 +718,21 @@
        left join sd.`order` o on dd.order_id=o.order_id
        <where>
            and date(dd.create_time)>=#{startDate} and date(dd.create_time) &lt;= #{endDate}
            <if test="deliveryDetail.order!=null and (deliveryDetail.order.batch != null and deliveryDetail.order.batch != '')">
                and o.batch like concat('%',#{deliveryDetail.order.batch},'%')
            </if>
            <if test="deliveryDetail.orderDetail!=null and (deliveryDetail.orderDetail.width != null and deliveryDetail.orderDetail.width != '')">
                and od.width regexp REGEXP_REPLACE(#{deliveryDetail.orderDetail.width},'\\.0+$','')
            </if>
            <if test="deliveryDetail.orderDetail!=null and (deliveryDetail.orderDetail.height != null and deliveryDetail.orderDetail.height != '')">
                and od.height regexp REGEXP_REPLACE(#{deliveryDetail.orderDetail.height},'\\.0+$','')
            </if>
            <if test="deliveryDetail.orderDetail!=null and (deliveryDetail.orderDetail.buildingNumber != null and deliveryDetail.orderDetail.buildingNumber != '')">
                and od.building_number like concat('%',#{deliveryDetail.orderDetail.buildingNumber},'%')
            </if>
            <if test="deliveryDetail.boxNo != null and deliveryDetail.boxNo != ''">
                and dd.box_no like concat('%',#{deliveryDetail.boxNo},'%')
            </if>
            <if test="deliveryDetail.deliveryId != null and deliveryDetail.deliveryId != ''">
                and dd.delivery_id like concat('%',#{deliveryDetail.deliveryId},'%')
            </if>
@@ -761,6 +817,7 @@
            <if test="deliveryDetail.delivery!=null and (deliveryDetail.delivery.freightPrice != null )">
                and d.freight_price regexp REGEXP_REPLACE(#{deliveryDetail.delivery.freightPrice},'\\.0+$','')
            </if>
        </where>
        order by dd.delivery_id,dd.delivery_number
    </select>
@@ -993,7 +1050,7 @@
    <select id="getSelectDeliveryPrinting" resultMap="selectDeliveryDetailOrderDetail" >
        select dd.delivery_id,od.order_id,od.product_id,IF(#{type}='product_abbreviation',pt.remarks,od.product_name) as product_name,dd.price,sum(dd.area) as area,
               sum(dd.money) as money,sum(dd.quantity) as quantity,o.contract_id from
               sum(dd.money) as money,sum(dd.quantity) as quantity,o.contract_id,o.batch from
        delivery_detail dd left join order_detail od on dd.order_id=od.order_id and dd.order_number=od.order_number
                                                            left join product pt on pt.id=od.product_id
                                                            left join sd.`order` o on o.order_id=dd.order_id
@@ -1002,6 +1059,183 @@
                where dd.delivery_id like concat('%',#{deliveryId},'%')
        group by od.order_id,od.product_name,od.product_id
    </select>
    <select id="getSelectDeliveryPrintingMoney" resultMap="selectDeliveryDetailOrderDetail" >
        select dd.delivery_id,
               od.order_id,
               IF(#{type} = 'product_abbreviation', pt.remarks, od.product_name) as product_name,
               dd.price,
               sum(dd.area)                                                      as area,
               sum(dd.money)                                                     as money,
               sum(dd.quantity)                                                  as quantity,
               o.contract_id,
               od.width,
               od.height
        from delivery_detail dd
                 left join (select product_name,
                                   order_id,
                                   product_id,
                                   order_number,
                                   CASE
                                       WHEN height &lt; 4000 AND height >= 3660 and height>width THEN
                                           '3660&lt;H&lt;4000'
                                       WHEN height &lt; 5000 AND height >= 4000 and height>width THEN
                                           '4000&lt;H&lt;5000'
                                       WHEN height &lt; 6000 AND height >= 5000 and height>width THEN
                                           '5000&lt;H&lt;6000'
                                       WHEN height &lt; 7000 AND height >= 6000 and height>width THEN
                                           '6000&lt;H&lt;7000'
                                       WHEN height &lt; 8000 AND height >= 7000 and height>width THEN
                                           '7000&lt;H&lt;8000'
                                       WHEN height &lt; 9000 AND height >= 8000 and height>width THEN
                                           '8000&lt;H&lt;9000'
                                       WHEN height &lt; 10000 AND height >= 9000 and height>width THEN
                                           '9000&lt;H&lt;10000'
                                       WHEN height &lt; 11000 AND height >= 10000 and height>width THEN
                                           '10000&lt;H&lt;11000'
                                       WHEN height &lt; 12000 AND height >= 11000 and height>width THEN
                                           '11000&lt;H&lt;12000'
                                       ELSE
                                           ''
                                       END height,
                                   CASE
                                       WHEN width &lt; 4000 AND width >= 3660 and width>height THEN
                                           '3660&lt;H&lt;4000'
                                       WHEN width &lt; 5000 AND width >= 4000 and width>height THEN
                                           '4000&lt;H&lt;5000'
                                       WHEN width &lt; 6000 AND width >= 5000 and width>height THEN
                                           '5000&lt;H&lt;6000'
                                       WHEN width &lt; 7000 AND width >= 6000 and width>height THEN
                                           '6000&lt;H&lt;7000'
                                       WHEN width &lt; 8000 AND width >= 7000 and width>height THEN
                                           '7000&lt;H&lt;8000'
                                       WHEN width &lt; 9000 AND width >= 8000 and width>height THEN
                                           '8000&lt;H&lt;9000'
                                       WHEN width &lt; 10000 AND width >= 9000 and width>height THEN
                                           '9000&lt;H&lt;10000'
                                       WHEN width &lt; 11000 AND width >= 10000 and width>height THEN
                                           '10000&lt;H&lt;11000'
                                       WHEN width &lt; 12000 AND width >= 11000 and width>height THEN
                                           '11000&lt;H&lt;12000'
                                       ELSE
                                           ''
                                       END width
                            from order_detail) as od on dd.order_id = od.order_id and dd.order_number = od.order_number
                 left join product pt on pt.id = od.product_id
                 left join sd.`order` o on o.order_id = dd.order_id
        where dd.delivery_id like concat('%', #{deliveryId}, '%')
        group by od.order_id, od.product_name,od.width,od.height, dd.price
    </select>
    <select id="getSelectDeliveryPrintingNoMoney" resultMap="selectDeliveryDetailOrderDetail" >
        select dd.delivery_id,
               od.order_id,
               IF(#{type} = 'product_abbreviation', pt.remarks, od.product_name) as product_name,
               sum(dd.area)                                                      as area,
               sum(dd.quantity)                                                  as quantity,
               o.contract_id,
               od.width,
               od.height
        from delivery_detail dd
                 left join (select product_name,
                                   order_id,
                                   product_id,
                                   order_number,
                                   CASE
                                       WHEN height &lt; 4000 AND height >= 3660 and height>width THEN
                                           '3660&lt;H&lt;4000'
                                       WHEN height &lt; 5000 AND height >= 4000 and height>width THEN
                                           '4000&lt;H&lt;5000'
                                       WHEN height &lt; 6000 AND height >= 5000 and height>width THEN
                                           '5000&lt;H&lt;6000'
                                       WHEN height &lt; 7000 AND height >= 6000 and height>width THEN
                                           '6000&lt;H&lt;7000'
                                       WHEN height &lt; 8000 AND height >= 7000 and height>width THEN
                                           '7000&lt;H&lt;8000'
                                       WHEN height &lt; 9000 AND height >= 8000 and height>width THEN
                                           '8000&lt;H&lt;9000'
                                       WHEN height &lt; 10000 AND height >= 9000 and height>width THEN
                                           '9000&lt;H&lt;10000'
                                       WHEN height &lt; 11000 AND height >= 10000 and height>width THEN
                                           '10000&lt;H&lt;11000'
                                       WHEN height &lt; 12000 AND height >= 11000 and height>width THEN
                                           '11000&lt;H&lt;12000'
                                       ELSE
                                           ''
                                       END height,
                                   CASE
                                       WHEN width &lt; 4000 AND width >= 3660 and width>height THEN
                                           '3660&lt;H&lt;4000'
                                       WHEN width &lt; 5000 AND width >= 4000 and width>height THEN
                                           '4000&lt;H&lt;5000'
                                       WHEN width &lt; 6000 AND width >= 5000 and width>height THEN
                                           '5000&lt;H&lt;6000'
                                       WHEN width &lt; 7000 AND width >= 6000 and width>height THEN
                                           '6000&lt;H&lt;7000'
                                       WHEN width &lt; 8000 AND width >= 7000 and width>height THEN
                                           '7000&lt;H&lt;8000'
                                       WHEN width &lt; 9000 AND width >= 8000 and width>height THEN
                                           '8000&lt;H&lt;9000'
                                       WHEN width &lt; 10000 AND width >= 9000 and width>height THEN
                                           '9000&lt;H&lt;10000'
                                       WHEN width &lt; 11000 AND width >= 10000 and width>height THEN
                                           '10000&lt;H&lt;11000'
                                       WHEN width &lt; 12000 AND width >= 11000 and width>height THEN
                                           '11000&lt;H&lt;12000'
                                       ELSE
                                           ''
                                       END width
                            from order_detail) as od on dd.order_id = od.order_id and dd.order_number = od.order_number
                 left join product pt on pt.id = od.product_id
                 left join sd.`order` o on o.order_id = dd.order_id
        where dd.delivery_id like concat('%', #{deliveryId}, '%')
        group by od.order_id, od.product_name, width, height
    </select>
    <select id="getSelectDeliveryPrintingMoneySpecifications" >
        select od.order_id,
               od.building_number,
               od.width,
               od.height,
               od.product_name,
               sum(dd.area)                                                      as area,
               sum(dd.money)                                                     as money,
               sum(dd.quantity)                                                  as quantity,
               dd.price
        from delivery_detail dd
                 left join order_detail od on dd.order_id = od.order_id and dd.order_number = od.order_number
                 left join product p on od.product_id = p.id
        where delivery_id = #{deliveryId}
          and od.order_id = #{orderId}
          and od.product_id = #{productId}
        group by od.width,od.height, dd.price
    </select>
    <select id="getSelectDeliveryPrintingNoMoneySpecifications"  >
        select od.order_id,
               od.building_number,
               od.width,
               od.height,
               od.product_name,
               sum(dd.area)                                                     as area,
               sum(dd.quantity)                                                  as quantity
        from delivery_detail dd
                 left join order_detail od on dd.order_id = od.order_id and dd.order_number = od.order_number
                 left join product p on od.product_id = p.id
        where delivery_id = #{deliveryId}
          and od.order_id = #{orderId}
          and od.product_id = #{productId}
        group by od.width,od.height
    </select>
    <select id="getSelectOrderPrinting"  >
@@ -1023,6 +1257,7 @@
               dd.area,
               ifnull(od.processing_note,"") as processingNote,
               ifnull(od.building_number,"") as buildingNumber,
               dd.box_no,
               dd.price,
               od.other_columns,
               od.remarks
@@ -1111,7 +1346,12 @@
        o.other_money,
        d.freight,
        d.freight_price,
        d.freight_quantity
        d.freight_quantity,
        od.width,
        od.height,
        o.batch,
        od.building_number,
        dd.box_no
        from sd.delivery_detail dd
        left join sd.delivery d on dd.delivery_id=d.delivery_id
        left join order_detail od on dd.order_id=od.order_id and dd.order_number=od.order_number