OrderDetailReportMapper.xml 8.75 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.OrderDetailReportMapper">

    <resultMap id="OrderDetailReport" type="com.lframework.xingyun.sc.entity.OrderDetailReport">
        <id column="id" property="id"/>
        <result column="purchase_order_line_id" property="purchaseOrderLineId"/>
        <result column="order_no" property="orderNo"/>
        <result column="order_date" property="orderDate"/>
        <result column="workshop_id" property="workshopId"/>
        <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="industry" property="industry"/>
        <result column="brand" property="brand"/>
        <result column="thickness" property="thickness"/>
        <result column="thickness_tol_pos" property="thicknessTolPos"/>
        <result column="thickness_tol_neg" property="thicknessTolNeg"/>
        <result column="width" property="width"/>
        <result column="width_tol_pos" property="widthTolPos"/>
        <result column="width_tol_neg" property="widthTolNeg"/>
        <result column="length" property="length"/>
        <result column="length_tol_pos" property="lengthTolPos"/>
        <result column="length_tol_neg" property="lengthTolNeg"/>
        <result column="status" property="status"/>
        <result column="quantity" property="quantity"/>
        <result column="suggested_price" property="suggestedPrice"/>
        <result column="delivery_date" property="deliveryDate"/>
        <result column="assessment_exceeds_agreement" property="assessmentExceedsAgreement"/>
        <result column="sales_price" property="salesPrice"/>
        <result column="price_list_no" property="priceListNo"/>
        <result column="packaging_fee" property="packagingFee"/>
        <result column="invoicing_status" property="invoicingStatus"/>
        <result column="piece_weight_header" property="pieceWeightHeader"/>
        <result column="surface" property="surface"/>
        <result column="tolerance" property="tolerance"/>
        <result column="performance" property="performance"/>
        <result column="packaging" property="packaging"/>
        <result column="remarks" property="remarks"/>
        <result column="shipping_cost" property="shippingCost"/>
        <result column="return_shipping_cost" property="returnShippingCost"/>
        <result column="customer_type" property="customerType"/>
        <result column="quality" property="quality"/>
        <result column="contract_type" property="contractType"/>
        <result column="stock_up_company_name" property="stockUpCompanyName"/>
        <result column="order_type" property="orderType"/>
        <result column="show_order" property="showOrder"/>
        <result column="create_by_id" property="createById"/>
        <result column="create_by" property="createBy"/>
        <result column="update_by_id" property="updateById"/>
        <result column="update_by" property="updateBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <sql id="OrderDetailReport_sql">
        SELECT
            tb.id,
            tb.purchase_order_line_id,
            tb.order_no,
            tb.order_date,
            tb.workshop_id,
            ws.name AS workshop_name,
            tb.dept_name,
            tb.region_name,
            tb.ordering_unit_name,
            tb.industry,
            tb.brand,
            tb.thickness,
            tb.thickness_tol_pos,
            tb.thickness_tol_neg,
            tb.width,
            tb.width_tol_pos,
            tb.width_tol_neg,
            tb.length,
            tb.length_tol_pos,
            tb.length_tol_neg,
            tb.status,
            tb.quantity,
            tb.suggested_price,
            tb.delivery_date,
            tb.assessment_exceeds_agreement,
            tb.sales_price,
            tb.price_list_no,
            tb.packaging_fee,
            tb.invoicing_status,
            tb.piece_weight_header,
            tb.surface,
            tb.tolerance,
            tb.performance,
            tb.packaging,
            tb.remarks,
            tb.shipping_cost,
            tb.return_shipping_cost,
            tb.customer_type,
            tb.quality,
            tb.contract_type,
            tb.stock_up_company_name,
            tb.order_type,
            tb.show_order,
            tb.create_by_id,
            tb.create_by,
            tb.update_by_id,
            tb.update_by,
            tb.create_time,
            tb.update_time
        FROM order_detail_report AS tb
        left join base_data_workshop as ws on ws.id = tb.workshop_id
    </sql>

<!--    <select id="query" resultMap="OrderDetailReport">-->
<!--        <include refid="OrderDetailReport_sql"/>-->
<!--        <where>-->
<!--            <if test="vo.purchaseOrderLineId != null and vo.purchaseOrderLineId != ''">-->
<!--                AND tb.purchase_order_line_id = #{vo.purchaseOrderLineId}-->
<!--            </if>-->
<!--            <if test="vo.orderNo != null and vo.orderNo != ''">-->
<!--                AND tb.order_no LIKE CONCAT('%', #{vo.orderNo}, '%')-->
<!--            </if>-->
<!--            <if test="vo.workshopId != null and vo.workshopId != ''">-->
<!--                AND tb.workshop_id = #{vo.workshopId}-->
<!--            </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="findById" resultType="com.lframework.xingyun.sc.entity.OrderDetailReport">
        <include refid="OrderDetailReport_sql"/>
        <where>
            <if test="id != null and id != ''">
                AND tb.id = #{id}
            </if>
        </where>
    </select>

    <select id="query" resultMap="OrderDetailReport">
        SELECT *
        FROM (
        SELECT
        tb.id,
        tb.purchase_order_line_id,
        tb.order_no,
        tb.order_date,
        tb.workshop_id,
        ws.name AS workshop_name,
        tb.dept_name,
        tb.region_name,
        tb.ordering_unit_name,
        tb.industry,
        tb.brand,
        tb.thickness,
        tb.thickness_tol_pos,
        tb.thickness_tol_neg,
        tb.width,
        tb.width_tol_pos,
        tb.width_tol_neg,
        tb.length,
        tb.length_tol_pos,
        tb.length_tol_neg,
        tb.status,
        tb.quantity,
        tb.suggested_price,
        tb.delivery_date,
        tb.assessment_exceeds_agreement,
        tb.sales_price,
        tb.price_list_no,
        tb.packaging_fee,
        tb.invoicing_status,
        tb.piece_weight_header,
        tb.surface,
        tb.tolerance,
        tb.performance,
        tb.packaging,
        tb.remarks,
        tb.shipping_cost,
        tb.return_shipping_cost,
        tb.customer_type,
        tb.quality,
        tb.contract_type,
        tb.stock_up_company_name,
        tb.order_type,
        tb.show_order,
        tb.create_by_id,
        tb.create_by,
        tb.update_by_id,
        tb.update_by,
        tb.create_time,
        tb.update_time,
        MAX(tb.create_time) OVER (PARTITION BY tb.order_no, tb.purchase_order_line_id) AS group_latest_time
        FROM order_detail_report tb
        LEFT JOIN base_data_workshop ws ON ws.id = tb.workshop_id
        <where>
            <if test="vo.purchaseOrderLineId != null and vo.purchaseOrderLineId != ''">
                AND tb.purchase_order_line_id = #{vo.purchaseOrderLineId}
            </if>
            <if test="vo.orderNo != null and vo.orderNo != ''">
                AND tb.order_no LIKE CONCAT('%', #{vo.orderNo}, '%')
            </if>
            <if test="vo.workshopId != null and vo.workshopId != ''">
                AND tb.workshop_id = #{vo.workshopId}
            </if>
            <if test="vo.deptName != null and vo.dedeptName != ''">
                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>
        ) t
        ORDER BY
        t.group_latest_time DESC,
        t.order_no ASC,
        t.purchase_order_line_id ASC,
        t.show_order ASC
    </select>
</mapper>