ShipmentDetailStatisticsMapper.xml 7.72 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="invoicing_status" property="invoicingStatus"/>
        <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.invoicing_status,
            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>
    </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,
            o.order_date,
            o.settlement_terms,
            case
                when o.supply_unit = 'GJ' then '安徽楚江高精铜带有限公司'
                when o.supply_unit = 'XC' then '安徽楚江科技新材料股份有限公司'
            else ''
            end as supplier,
            o.workshop_id,
            so.code as shipment_order_no,
            so.create_time 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>
            <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>
    </select>
</mapper>