chenlu
2024-03-07 de18cca83738bdf6b279046e34b910ccd5b73a84
north-glass-erp/src/main/resources/mapper/sd/DeliveryDetail.xml
New file
@@ -0,0 +1,445 @@
<?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.example.erp.mapper.sd.DeliveryDetailMapper">
    <resultMap id="selectDeliveryFinishedGoodsInventoryOrderDetail" type="com.example.erp.entity.sd.OrderDetail">
        <result column="order_id" property="orderId"/>
        <result column="order_number" property="orderNumber"/>
        <result column="o_quantity" property="quantity"/>
        <result column="building_number" property="buildingNumber"/>
        <result column="product_name" property="productName"/>
        <result column="product_id" property="productId"/>
        <result column="price" property="price"/>
        <result column="width" property="width"/>
        <result column="height" property="height"/>
        <result column="shape" property="shape"/>
        <result column="gross_area" property="grossArea"/>
        <result column="compute_area" property="computeArea"/>
        <result column="compute_gross_area" property="computeGrossArea"/>
        <result column="processing_note" property="processingNote"/>
        <result column="edging_type" property="edgingType"/>
        <result column="perimeter" property="perimeter"/>
        <result column="delivery_num" property="deliveryNum"/>
        <result column="delivery_id" property="deliveryDetail.deliveryid"/>
        <result column="d_quantity" property="deliveryDetail.quantity"/>
        <result column="money" property="deliveryDetail.money"/>
        <result column="delivery_number" property="deliveryDetail.deliveryNumber"/>
        <result column="delivery_detail_remakes" property="deliveryDetail.deliveryDetailRemakes"/>
        <result column="batch" property="order.batch"/>
        <result column="t_quantity" property="order.quantity"/>
        <result column="customer_id" property="delivery.customerId"/>
        <result column="customer_name" property="delivery.customerName"/>
        <result column="project" property="delivery.project"/>
        <result column="pay_method" property="delivery.payMethod"/>
        <result column="pay_date" property="delivery.payDate"/>
        <result column="contacts" property="delivery.contacts"/>
        <result column="contact_number" property="delivery.contactNumber"/>
        <result column="delivery_address" property="delivery.deliveryAddress"/>
        <result column="remarks" property="delivery.remarks"/>
        <result column="create_time" property="delivery.createTime"/>
        <result column="delivery_date" property="delivery.deliveryDate"/>
        <result column="creator" property="delivery.creator"/>
        <result column="quantity_available" property="finishedGoodsInventory.quantityAvailable"/>
        <result column="storage_region" property="finishedGoodsInventory.storageRegion"/>
        <result column="actual_signal_area" property="finishedGoodsInventory.actualSignalArea"/>
    </resultMap>
    <delete id="deleteDeliveryDetail">
        delete from sd.delivery_detail where delivery_id=#{deliveryId}
    </delete>
    <update id="updateOrderDetailDeliveryNum">
        update sd.order_detail set delivery_num=#{deliveryDetail.quantity} where order_id=#{orderId} and order_number=#{orderNumber}
    </update>
    <update id="updateIsNotOrderDetailDeliveryNum">
        update sd.order_detail set delivery_num=delivery_num-#{quantity} where order_id=#{orderId} and order_number=#{orderNumber}
    </update>
    <select id="getdeliveryDetailmaximum" >
        select count(*) from sd.delivery_detail where  delivery_id=#{deliveryId}
    </select>
    <select id="getIsNotDeliveryDetail" >
        select * from sd.delivery_detail where  delivery_id=#{deliveryId}
    </select>
    <insert id="insertDeliveryDetail"  useGeneratedKeys="true" >
        insert into sd.delivery_detail (delivery_id,delivery_number,order_number,
                                        area,order_id,quantity,money,delivery_detail_remakes,delivery_detail_state,create_time)
        values (
                   #{number} ,#{deliveryNumber},#{orderDetail.order_number},#{orderDetail.computeGrossArea},
                #{orderDetail.orderId},#{orderDetail.deliveryDetail.quantity},
                #{orderDetail.price}*#{orderDetail.deliveryDetail.quantity},'',1,now()
               )
    </insert>
    <select id="getSelectShippingOrderDetail" resultMap="selectDeliveryFinishedGoodsInventoryOrderDetail">
        select od.order_id,
               o.batch,
               dd.delivery_number,
               fgi.quantity_available + dd.quantity as quantity_available,
               od.order_number,
               od.quantity-dd.quantity as t_quantity,
               od.quantity as o_quantity,
               dd.quantity as d_quantity,
               od.building_number,
               od.product_id,
               od.product_name,
               od.price,
               fgi.storage_region,
               dd.money,
               od.width,
               od.height,
               od.shape,
               fgi.actual_signal_area,
               od.gross_area,
               od.compute_area,
               od.compute_gross_area,
               od.processing_note,
               od.edging_type,
               od.perimeter,
               dd.delivery_detail_remakes
        from sd.delivery_detail dd
        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
        <where>
            <if test="orderDetail.deliveryDetail.deliveryId != null and orderDetail.deliveryDetail.deliveryId != ''">
                and dd.delivery_id regexp #{orderDetail.deliveryDetail.deliveryId}
            </if>
            <if test="orderDetail.orderId != null and orderDetail.orderId != ''">
                and od.order_id regexp #{orderDetail.orderId}
            </if>
            <if test="orderDetail.order.batch != null and orderDetail.order.batch != ''">
                and o.batch regexp #{orderDetail.order.batch}
            </if>
            <if test="orderDetail.finishedGoodsInventory.quantityAvailable != null and orderDetail.finishedGoodsInventory.quantityAvailable != ''">
                and fgi.quantity_available regexp #{orderDetail.finishedGoodsInventory.quantityAvailable}
            </if>
            <if test="orderDetail.quantity != null and orderDetail.quantity != ''">
                and od.quantity regexp #{orderDetail.quantity}
            </if>
            <if test="orderDetail.deliveryDetail.quantity != null and orderDetail.deliveryDetail.quantity != ''">
                and dd.quantity regexp #{orderDetail.deliveryDetail.quantity}
            </if>
            <if test="orderDetail.buildingNumber != null and orderDetail.buildingNumber != ''">
                and od.building_number regexp #{orderDetail.buildingNumber}
            </if>
            <if test="orderDetail.productId != null and orderDetail.productId != ''">
                and od.product_id regexp #{orderDetail.productId}
            </if>
            <if test="orderDetail.productName != null and orderDetail.productName != ''">
                and od.product_name regexp #{orderDetail.productName}
            </if>
            <if test="orderDetail.price != null and orderDetail.price != ''">
                and od.price regexp #{orderDetail.price}
            </if>
            <if test="orderDetail.finishedGoodsInventory.storageRegion != null and orderDetail.finishedGoodsInventory.storageRegion != ''">
                and fgi.storage_region regexp #{orderDetail.finishedGoodsInventory.storageRegion}
            </if>
            <if test="orderDetail.deliveryDetail.money != null and orderDetail.deliveryDetail.money != ''">
                and dd.money regexp  REGEXP_REPLACE(#{orderDetail.deliveryDetail.money},'\\.0+$','')
            </if>
            <if test="orderDetail.width != null and orderDetail.width != ''">
                and od.width regexp REGEXP_REPLACE(#{orderDetail.width},'\\.0+$','')
            </if>
            <if test="orderDetail.height != null and orderDetail.height != ''">
                and od.height regexp REGEXP_REPLACE(#{orderDetail.height},'\\.0+$','')
            </if>
            <if test="orderDetail.shape != null and orderDetail.shape != ''">
                and od.shape regexp #{orderDetail.shape}
            </if>
            <if test="orderDetail.finishedGoodsInventory.actualSignalArea != null and orderDetail.finishedGoodsInventory.actualSignalArea != ''">
                and fgi.actual_signal_area regexp REGEXP_REPLACE(#{orderDetail.finishedGoodsInventory.actualSignalArea},'\\.0+$','')
            </if>
            <if test="orderDetail.grossArea != null and orderDetail.grossArea != ''">
                and od.gross_area regexp REGEXP_REPLACE(#{orderDetail.grossArea},'\\.0+$','')
            </if>
            <if test="orderDetail.computeArea != null and orderDetail.computeArea != ''">
                and od.compute_area regexp REGEXP_REPLACE(#{orderDetail.computeArea},'\\.0+$','')
            </if>
            <if test="orderDetail.computeGrossArea != null and orderDetail.computeGrossArea != ''">
                and od.compute_gross_area regexp REGEXP_REPLACE(#{orderDetail.computeGrossArea},'\\.0+$','')
            </if>
            <if test="orderDetail.processingNote != null and orderDetail.processingNote != ''">
                and od.processing_note regexp #{orderDetail.processingNote}
            </if>
            <if test="orderDetail.edgingType != null and orderDetail.edgingType != ''">
                and od.edging_type regexp #{orderDetail.edgingType}
            </if>
            <if test="orderDetail.perimeter != null and orderDetail.perimeter != ''">
                and od.perimeter regexp #{orderDetail.perimeter}
            </if>
            <if test="orderDetail.deliveryDetail.deliveryDetailRemakes != null and orderDetail.deliveryDetail.deliveryDetailRemakes != ''">
                and dd.delivery_detail_remakes regexp #{orderDetail.deliveryDetail.deliveryDetailRemakes}
            </if>
        </where>
        limit #{offset},#{pageSize};
    </select>
    <select id="getSelectShippingOrderDetailPageTotal">
        select
            CEILING(count(dd.id)/#{pageSize})
        from sd.delivery_detail dd
                 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
        <where>
            <if test="orderDetail.deliveryDetail.deliveryId != null and orderDetail.deliveryDetail.deliveryId != ''">
                and dd.delivery_id regexp #{orderDetail.deliveryDetail.deliveryId}
            </if>
            <if test="orderDetail.orderId != null and orderDetail.orderId != ''">
                and od.order_id regexp #{orderDetail.orderId}
            </if>
            <if test="orderDetail.order.batch != null and orderDetail.order.batch != ''">
                and o.batch regexp #{orderDetail.order.batch}
            </if>
            <if test="orderDetail.finishedGoodsInventory.quantityAvailable != null and orderDetail.finishedGoodsInventory.quantityAvailable != ''">
                and fgi.quantity_available regexp #{orderDetail.finishedGoodsInventory.quantityAvailable}
            </if>
            <if test="orderDetail.quantity != null and orderDetail.quantity != ''">
                and od.quantity regexp #{orderDetail.quantity}
            </if>
            <if test="orderDetail.deliveryDetail.quantity != null and orderDetail.deliveryDetail.quantity != ''">
                and dd.quantity regexp #{orderDetail.deliveryDetail.quantity}
            </if>
            <if test="orderDetail.buildingNumber != null and orderDetail.buildingNumber != ''">
                and od.building_number regexp #{orderDetail.buildingNumber}
            </if>
            <if test="orderDetail.productId != null and orderDetail.productId != ''">
                and od.product_id regexp #{orderDetail.productId}
            </if>
            <if test="orderDetail.productName != null and orderDetail.productName != ''">
                and od.product_name regexp #{orderDetail.productName}
            </if>
            <if test="orderDetail.price != null and orderDetail.price != ''">
                and od.price regexp #{orderDetail.price}
            </if>
            <if test="orderDetail.finishedGoodsInventory.storageRegion != null and orderDetail.finishedGoodsInventory.storageRegion != ''">
                and fgi.storage_region regexp #{orderDetail.finishedGoodsInventory.storageRegion}
            </if>
            <if test="orderDetail.deliveryDetail.money != null and orderDetail.deliveryDetail.money != ''">
                and dd.money regexp  REGEXP_REPLACE(#{orderDetail.deliveryDetail.money},'\\.0+$','')
            </if>
            <if test="orderDetail.width != null and orderDetail.width != ''">
                and od.width regexp REGEXP_REPLACE(#{orderDetail.width},'\\.0+$','')
            </if>
            <if test="orderDetail.height != null and orderDetail.height != ''">
                and od.height regexp REGEXP_REPLACE(#{orderDetail.height},'\\.0+$','')
            </if>
            <if test="orderDetail.shape != null and orderDetail.shape != ''">
                and od.shape regexp #{orderDetail.shape}
            </if>
            <if test="orderDetail.finishedGoodsInventory.actualSignalArea != null and orderDetail.finishedGoodsInventory.actualSignalArea != ''">
                and fgi.actual_signal_area regexp REGEXP_REPLACE(#{orderDetail.finishedGoodsInventory.actualSignalArea},'\\.0+$','')
            </if>
            <if test="orderDetail.grossArea != null and orderDetail.grossArea != ''">
                and od.gross_area regexp REGEXP_REPLACE(#{orderDetail.grossArea},'\\.0+$','')
            </if>
            <if test="orderDetail.computeArea != null and orderDetail.computeArea != ''">
                and od.compute_area regexp REGEXP_REPLACE(#{orderDetail.computeArea},'\\.0+$','')
            </if>
            <if test="orderDetail.computeGrossArea != null and orderDetail.computeGrossArea != ''">
                and od.compute_gross_area regexp REGEXP_REPLACE(#{orderDetail.computeGrossArea},'\\.0+$','')
            </if>
            <if test="orderDetail.processingNote != null and orderDetail.processingNote != ''">
                and od.processing_note regexp #{orderDetail.processingNote}
            </if>
            <if test="orderDetail.edgingType != null and orderDetail.edgingType != ''">
                and od.edging_type regexp #{orderDetail.edgingType}
            </if>
            <if test="orderDetail.perimeter != null and orderDetail.perimeter != ''">
                and od.perimeter regexp #{orderDetail.perimeter}
            </if>
            <if test="orderDetail.deliveryDetail.deliveryDetailRemakes != null and orderDetail.deliveryDetail.deliveryDetailRemakes != ''">
                and dd.delivery_detail_remakes regexp #{orderDetail.deliveryDetail.deliveryDetailRemakes}
            </if>
        </where>
        limit #{offset},#{pageSize};
    </select>
    <select id="getSelectShippingOrderDetails" resultMap="selectDeliveryFinishedGoodsInventoryOrderDetail">
        select od.order_id,
               od.order_number,
               o.batch,
               fgi.quantity_available,
               od.quantity- od.delivery_num as t_quantity,
               od.quantity as o_quantity,
               fgi.quantity_available as d_quantity,
               od.building_number,
               od.product_id,
               od.product_name,
               od.price,
               fgi.storage_region,
               od.width,
               od.height,
               od.shape,
               fgi.actual_signal_area,
               od.gross_area,
               od.compute_area,
               od.compute_gross_area,
               od.processing_note,
               od.edging_type,
               od.perimeter
        from sd.order_detail od
                 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
        <where>
            fgi.quantity_available > 0 and od.quantity > od.delivery_num
            <if test="orderDetail.orderId != null and orderDetail.orderId != ''">
                and od.order_id regexp #{orderDetail.orderId}
            </if>
            <if test="orderDetail.order.batch != null and orderDetail.order.batch != ''">
                and o.batch regexp #{orderDetail.order.batch}
            </if>
            <if test="orderDetail.finishedGoodsInventory.quantityAvailable != null and orderDetail.finishedGoodsInventory.quantityAvailable != ''">
                and fgi.quantity_available regexp #{orderDetail.finishedGoodsInventory.quantityAvailable}
            </if>
            <if test="orderDetail.quantity != null and orderDetail.quantity != ''">
                and od.quantity regexp #{orderDetail.quantity}
            </if>
            <if test="orderDetail.deliveryNum != null and orderDetail.deliveryNum != ''">
                and od.delivery_num regexp #{orderDetail.deliveryNum}
            </if>
            <if test="orderDetail.buildingNumber != null and orderDetail.buildingNumber != ''">
                and od.building_number regexp #{orderDetail.buildingNumber}
            </if>
            <if test="orderDetail.productId != null and orderDetail.productId != ''">
                and od.product_id regexp #{orderDetail.productId}
            </if>
            <if test="orderDetail.productName != null and orderDetail.productName != ''">
                and od.product_name regexp #{orderDetail.productName}
            </if>
            <if test="orderDetail.price != null and orderDetail.price != ''">
                and od.price regexp  REGEXP_REPLACE(#{orderDetail.price},'\\.0+$','')
            </if>
            <if test="orderDetail.finishedGoodsInventory.storageRegion != null and orderDetail.finishedGoodsInventory.storageRegion != ''">
                and fgi.storage_region regexp #{orderDetail.finishedGoodsInventory.storageRegion}
            </if>
            <if test="orderDetail.width != null and orderDetail.width != ''">
                and od.width regexp REGEXP_REPLACE(#{orderDetail.width},'\\.0+$','')
            </if>
            <if test="orderDetail.height != null and orderDetail.height != ''">
                and od.height regexp REGEXP_REPLACE(#{orderDetail.height},'\\.0+$','')
            </if>
            <if test="orderDetail.shape != null and orderDetail.shape != ''">
                and od.shape regexp #{orderDetail.shape}
            </if>
            <if test="orderDetail.finishedGoodsInventory.actualSignalArea != null and orderDetail.finishedGoodsInventory.actualSignalArea != ''">
                and fgi.actual_signal_area regexp REGEXP_REPLACE(#{orderDetail.finishedGoodsInventory.actualSignalArea},'\\.0+$','')
            </if>
            <if test="orderDetail.grossArea != null and orderDetail.grossArea != ''">
                and od.gross_area regexp REGEXP_REPLACE(#{orderDetail.grossArea},'\\.0+$','')
            </if>
            <if test="orderDetail.computeArea != null and orderDetail.computeArea != ''">
                and od.compute_area regexp REGEXP_REPLACE(#{orderDetail.computeArea},'\\.0+$','')
            </if>
            <if test="orderDetail.computeGrossArea != null and orderDetail.computeGrossArea != ''">
                and od.compute_gross_area regexp REGEXP_REPLACE(#{orderDetail.computeGrossArea},'\\.0+$','')
            </if>
            <if test="orderDetail.processingNote != null and orderDetail.processingNote != ''">
                and od.processing_note regexp #{orderDetail.processingNote}
            </if>
            <if test="orderDetail.edgingType != null and orderDetail.edgingType != ''">
                and od.edging_type regexp #{orderDetail.edgingType}
            </if>
            <if test="orderDetail.perimeter != null and orderDetail.perimeter != ''">
                and od.perimeter regexp #{orderDetail.perimeter}
            </if>
        </where>
        limit #{offset},#{pageSize};
    </select>
    <select id="getSelectShippingOrderDetailsPageTotal">
        select
        CEILING(count(od.id)/#{pageSize})
        from sd.order_detail od
        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
        <where>
            fgi.quantity_available > 0 and od.quantity > od.delivery_num
            <if test="orderDetail.orderId != null and orderDetail.orderId != ''">
                and od.order_id regexp #{orderDetail.orderId}
            </if>
            <if test="orderDetail.order.batch != null and orderDetail.order.batch != ''">
                and o.batch regexp #{orderDetail.order.batch}
            </if>
            <if test="orderDetail.finishedGoodsInventory.quantityAvailable != null and orderDetail.finishedGoodsInventory.quantityAvailable != ''">
                and fgi.quantity_available regexp #{orderDetail.finishedGoodsInventory.quantityAvailable}
            </if>
            <if test="orderDetail.quantity != null and orderDetail.quantity != ''">
                and od.quantity regexp #{orderDetail.quantity}
            </if>
            <if test="orderDetail.deliveryNum != null and orderDetail.deliveryNum != ''">
                and od.delivery_num regexp #{orderDetail.deliveryNum}
            </if>
            <if test="orderDetail.buildingNumber != null and orderDetail.buildingNumber != ''">
                and od.building_number regexp #{orderDetail.buildingNumber}
            </if>
            <if test="orderDetail.productId != null and orderDetail.productId != ''">
                and od.product_id regexp #{orderDetail.productId}
            </if>
            <if test="orderDetail.productName != null and orderDetail.productName != ''">
                and od.product_name regexp #{orderDetail.productName}
            </if>
            <if test="orderDetail.price != null and orderDetail.price != ''">
                and od.price regexp  REGEXP_REPLACE(#{orderDetail.price},'\\.0+$','')
            </if>
            <if test="orderDetail.finishedGoodsInventory.storageRegion != null and orderDetail.finishedGoodsInventory.storageRegion != ''">
                and fgi.storage_region regexp #{orderDetail.finishedGoodsInventory.storageRegion}
            </if>
            <if test="orderDetail.width != null and orderDetail.width != ''">
                and od.width regexp REGEXP_REPLACE(#{orderDetail.width},'\\.0+$','')
            </if>
            <if test="orderDetail.height != null and orderDetail.height != ''">
                and od.height regexp REGEXP_REPLACE(#{orderDetail.height},'\\.0+$','')
            </if>
            <if test="orderDetail.shape != null and orderDetail.shape != ''">
                and od.shape regexp #{orderDetail.shape}
            </if>
            <if test="orderDetail.finishedGoodsInventory.actualSignalArea != null and orderDetail.finishedGoodsInventory.actualSignalArea != ''">
                and fgi.actual_signal_area regexp REGEXP_REPLACE(#{orderDetail.finishedGoodsInventory.actualSignalArea},'\\.0+$','')
            </if>
            <if test="orderDetail.grossArea != null and orderDetail.grossArea != ''">
                and od.gross_area regexp REGEXP_REPLACE(#{orderDetail.grossArea},'\\.0+$','')
            </if>
            <if test="orderDetail.computeArea != null and orderDetail.computeArea != ''">
                and od.compute_area regexp REGEXP_REPLACE(#{orderDetail.computeArea},'\\.0+$','')
            </if>
            <if test="orderDetail.computeGrossArea != null and orderDetail.computeGrossArea != ''">
                and od.compute_gross_area regexp REGEXP_REPLACE(#{orderDetail.computeGrossArea},'\\.0+$','')
            </if>
            <if test="orderDetail.processingNote != null and orderDetail.processingNote != ''">
                and od.processing_note regexp #{orderDetail.processingNote}
            </if>
            <if test="orderDetail.edgingType != null and orderDetail.edgingType != ''">
                and od.edging_type regexp #{orderDetail.edgingType}
            </if>
            <if test="orderDetail.perimeter != null and orderDetail.perimeter != ''">
                and od.perimeter regexp #{orderDetail.perimeter}
            </if>
        </where>
        limit #{offset},#{pageSize};
    </select>
</mapper>