ShipmentDetailStatisticsMapper.xml 10.7 KB
<?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.lframework.xingyun.sc.mappers.ShipmentDetailStatisticsMapper">

    <resultMap id="ShipmentDetailStatistics" type="com.lframework.xingyun.sc.entity.ShipmentDetailStatistics">
        <id column="id" property="id"/>
        <result column="shipment_order_no" property="shipmentOrderNo"/>
        <result column="workshop_name" property="workshopName"/>
        <result column="dept_name" property="deptName"/>
        <result column="region_name" property="regionName"/>
        <result column="ordering_unit_name" property="orderingUnitName"/>
        <result column="brand" property="brand"/>
        <result column="thickness" property="thickness"/>
        <result column="width" property="width"/>
        <result column="length" property="length"/>
        <result column="status" property="status"/>
        <result column="quantity" property="quantity"/>
        <result column="actual_shipment_quantity" property="actualShipmentQuantity"/>
        <result column="sales_price" property="salesPrice"/>
        <result column="thickness_tol_pos" property="thicknessTolPos"/>
        <result column="thickness_tol_neg" property="thicknessTolNeg"/>
        <result column="width_tol_pos" property="widthTolPos"/>
        <result column="width_tol_neg" property="widthTolNeg"/>
        <result column="length_tol_pos" property="lengthTolPos"/>
        <result column="length_tol_neg" property="lengthTolNeg"/>
        <result column="assessment_exceeds_agreement" property="assessmentExceedsAgreement"/>
        <result column="shipping_cost" property="shippingCost"/>
        <result column="return_freight" property="returnFreight"/>
        <result column="industry" property="industry"/>
        <result column="stock_up_company_name" property="stockUpCompanyName"/>
        <result column="order_no" property="orderNo"/>
        <result column="yield_batch_no" property="yieldBatchNo"/>
        <result column="invoice_requirements" property="invoiceRequirements"/>
        <result column="order_date" property="orderDate"/>
        <result column="packaging_fee" property="packagingFee"/>
        <result column="quality" property="quality"/>
        <result column="num" property="num"/>
        <result column="settlement_terms" property="settlementTerms"/>
        <result column="processing_or_distribution" property="processingOrDistribution"/>
        <result column="packaging_requirements" property="packagingRequirements"/>
        <result column="shipment_date" property="shipmentDate"/>
        <result column="supplier" property="supplier"/>
        <result column="customer_short_name" property="customerShortName"/>
        <result column="customer_type" property="customerType"/>
        <result column="create_by_id" property="createById"/>
        <result column="update_by_id" property="updateById"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="delivery_method" property="deliveryMethod"/>
    </resultMap>

    <sql id="ShipmentDetailStatistics_sql">
        SELECT
            tb.id,
            tb.shipment_order_no,
            tb.workshop_name,
            tb.dept_name,
            tb.region_name,
            tb.ordering_unit_name,
            tb.brand,
            tb.thickness,
            tb.width,
            tb.length,
            tb.status,
            tb.quantity,
            tb.actual_shipment_quantity,
            tb.sales_price,
            tb.thickness_tol_pos,
            tb.thickness_tol_neg,
            tb.width_tol_pos,
            tb.width_tol_neg,
            tb.length_tol_pos,
            tb.length_tol_neg,
            tb.assessment_exceeds_agreement,
            tb.shipping_cost,
            tb.return_freight,
            tb.industry,
            tb.stock_up_company_name,
            tb.order_no,
            tb.yield_batch_no,
            tb.invoice_requirements,
            tb.order_date,
            tb.packaging_fee,
            tb.quality,
            tb.num,
            tb.settlement_terms,
            tb.processing_or_distribution,
            tb.packaging_requirements,
            tb.shipment_date,
            tb.supplier,
            tb.customer_short_name,
            tb.customer_type,
            tb.create_by_id,
            tb.update_by_id,
            tb.create_time,
            tb.update_time,
            tb.delivery_method
        FROM shipments_detail_statistics AS tb
    </sql>

    <select id="query" resultMap="ShipmentDetailStatistics">
        <include refid="ShipmentDetailStatistics_sql"/>
        <where>
            <if test="vo.workshopName != null and vo.workshopName != ''">
             AND tb.workshop_name LIKE CONCAT('%', #{vo.workshopName}, '%')
            </if>
            <if test="vo.deptName != null and vo.deptName != ''">
             AND tb.dept_name LIKE CONCAT('%', #{vo.deptName}, '%')
            </if>
            <if test="vo.orderingUnitName != null and vo.orderingUnitName != ''">
             AND tb.ordering_unit_name LIKE CONCAT('%', #{vo.orderingUnitName}, '%')
            </if>
        </where>
        ORDER BY tb.shipment_date DESC
    </select>

    <select id="getShipmentDetailInfo" resultType="com.lframework.xingyun.sc.entity.ShipmentDetailStatistics">
        select
            sd.id,
            sd.actual_shipment_quantity,
            sd.yield_batch_no,
            sd.num,
            ol.brand,
            ol.thickness,
            ol.width,
            ol.length,
            ol.status,
            ol.quantity,
            ol.sales_price,
            ol.thickness_tol_pos,
            ol.thickness_tol_neg,
            ol.width_tol_pos,
            ol.width_tol_neg,
            ol.length_tol_pos,
            ol.length_tol_neg,
            ol.assessment_exceeds_agreement,
            ol.industry,
            ol.packaging_fee,
            ol.quality,
            o.dept_id,
            o.region,
            o.ordering_unit,
            o.shipping_cost,
            o.delivery_method,
            o.stock_up_company_id,
            o.order_no,
            o.invoicing_status as invoice_requirements,
            o.order_date,
            o.settlement_terms,
            o.supply_unit as supplier,
            o.workshop_id,
            o.delivery_method,
            so.code as shipment_order_no,
            so.shipments_date as shipment_date,
            sc.id as contract_id,
            sc.type as contract_type,
            sc.packaging_requirements,
            cl.material_product_ratio,
            cl.material_product_ratio_remarks
        from shipments_plan_detail sd
        inner join shipments_order_info so on sd.shipment_order_id = so.id
        left join tbl_purchase_order_line ol on sd.order_spec_id = ol.id
        left join purchase_order_info o on ol.purchase_order_id = o.id
        left join tbl_contract_distributor_standard sc on o.contract_id = sc.id
        left join tbl_contract_std_processing_line cl on sc.id = cl.contract_id
        <where>
            and sd.del_flag = false
            <if test="vo.ids != null and vo.ids.size() > 0">
                and sd.id in
                <foreach collection="vo.ids" open="(" separator="," close=")" item="item">
                    #{item}
                </foreach>
            </if>
            <if test="vo.orderNo != null and vo.orderNo != ''">
                and o.order_no like concat('%', #{vo.orderNo}, '%')
            </if>
            <if test="vo.shipmentOrderNo != null and vo.shipmentOrderNo != ''">
                and so.code like concat('%', #{vo.shipmentOrderNo}, '%')
            </if>
        </where>
        order by so.create_time desc
    </select>

    <insert id="batchAdd">
        INSERT INTO shipments_detail_statistics (
            id,
            shipment_order_no,
            workshop_name,
            dept_name,
            region_name,
            ordering_unit_name,
            brand,
            thickness,
            width,
            length,
            status,
            quantity,
            actual_shipment_quantity,
            sales_price,
            thickness_tol_pos,
            thickness_tol_neg,
            width_tol_pos,
            width_tol_neg,
            length_tol_pos,
            length_tol_neg,
            assessment_exceeds_agreement,
            shipping_cost,
            return_freight,
            industry,
            stock_up_company_name,
            order_no,
            yield_batch_no,
            invoice_requirements,
            order_date,
            packaging_fee,
            quality,
            num,
            settlement_terms,
            processing_or_distribution,
            packaging_requirements,
            shipment_date,
            supplier,
            customer_short_name,
            customer_type,
            delivery_method,
            create_by_id,
            update_by_id,
            create_time,
            update_time
        ) VALUES
        <foreach collection="list" item="item" separator=",">
            (
                #{item.id},
                #{item.shipmentOrderNo},
                #{item.workshopName},
                #{item.deptName},
                #{item.regionName},
                #{item.orderingUnitName},
                #{item.brand},
                #{item.thickness},
                #{item.width},
                #{item.length},
                #{item.status},
                #{item.quantity},
                #{item.actualShipmentQuantity},
                #{item.salesPrice},
                #{item.thicknessTolPos},
                #{item.thicknessTolNeg},
                #{item.widthTolPos},
                #{item.widthTolNeg},
                #{item.lengthTolPos},
                #{item.lengthTolNeg},
                #{item.assessmentExceedsAgreement},
                #{item.shippingCost},
                #{item.returnFreight},
                #{item.industry},
                #{item.stockUpCompanyName},
                #{item.orderNo},
                #{item.yieldBatchNo},
                #{item.invoiceRequirements},
                #{item.orderDate},
                #{item.packagingFee},
                #{item.quality},
                #{item.num},
                #{item.settlementTerms},
                #{item.processingOrDistribution},
                #{item.packagingRequirements},
                #{item.shipmentDate},
                #{item.supplier},
                #{item.customerShortName},
                #{item.customerType},
                #{item.deliveryMethod},
                #{item.createById},
                #{item.updateById},
                #{item.createTime},
                #{item.updateTime}
            )
        </foreach>
    </insert>

</mapper>