PurchaseOrderLineMapper.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.PurchaseOrderLineMapper">

    <resultMap id="PurchaseOrderLine" type="com.lframework.xingyun.sc.entity.PurchaseOrderLine">
        <id column="id" property="id"/>
        <result column="after_id" property="afterId"/>
        <result column="purchase_order_id" property="purchaseOrderId"/>
        <result column="industry" property="industry"/>
        <result column="quality" property="quality"/>
        <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="sales_price" property="salesPrice"/>
        <result column="delivery_date" property="deliveryDate"/>
        <result column="show_order" property="showOrder"/>
        <result column="assessment_exceeds_agreement" property="assessmentExceedsAgreement"/>
        <result column="packaging_fee" property="packagingFee"/>
        <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="PurchaseOrderLine_sql">
        SELECT
            tb.id,
            tb.after_id,
            tb.purchase_order_id,
            tb.industry,
            tb.quality,
            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.sales_price,
            tb.delivery_date,
            tb.show_order,
            tb.assessment_exceeds_agreement,
            tb.packaging_fee,
            tb.create_by_id,
            tb.create_by,
            tb.update_by_id,
            tb.update_by,
            tb.create_time,
            tb.update_time
        FROM tbl_purchase_order_line AS tb
    </sql>

    <select id="query" resultMap="PurchaseOrderLine">
        <include refid="PurchaseOrderLine_sql"/>
        <where>
            and tb.del_flag = false
            <if test="vo.purchaseOrderId != null and vo.purchaseOrderId != ''">
                AND tb.purchase_order_id = #{vo.purchaseOrderId}
            </if>
            <if test="vo.brand != null and vo.brand != ''">
                AND tb.brand = #{vo.brand}
            </if>
            <if test="vo.status != null and vo.status != ''">
                AND tb.status = #{vo.status}
            </if>
            <if test="vo.deliveryDate != null">
                AND tb.delivery_date = #{vo.deliveryDate}
            </if>
        </where>
        ORDER BY tb.show_order ASC
    </select>

    <insert id="batchAdd" parameterType="java.util.List">
        INSERT INTO tbl_purchase_order_line (
        id, purchase_order_id, industry, quality, brand,
        thickness, thickness_tol_pos, thickness_tol_neg,
        width, width_tol_pos, width_tol_neg,
        length, length_tol_pos, length_tol_neg,
        status, quantity, sales_price, delivery_date, show_order,
        assessment_exceeds_agreement, create_by_id, create_by, update_by_id, update_by,
        create_time, update_time, parent_id,packaging_fee
        ) VALUES
        <foreach collection="specList" item="item" separator=",">
            (
            #{item.id}, #{item.purchaseOrderId}, #{item.industry}, #{item.quality}, #{item.brand},
            #{item.thickness}, #{item.thicknessTolPos}, #{item.thicknessTolNeg},
            #{item.width}, #{item.widthTolPos}, #{item.widthTolNeg},
            #{item.length}, #{item.lengthTolPos}, #{item.lengthTolNeg},
            #{item.status}, #{item.quantity}, #{item.salesPrice}, #{item.deliveryDate}, #{item.showOrder},
            #{item.assessmentExceedsAgreement}, #{item.createById}, #{item.createBy}, #{item.updateById}, #{item.updateBy},
            #{item.createTime}, #{item.updateTime}, #{item.parentId},#{item.packagingFee}
            )
        </foreach>
    </insert>

    <update id="batchUpdate" parameterType="java.util.List">
        UPDATE tbl_purchase_order_line
        SET
        industry =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.industry}
        </foreach>,
        quality =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.quality}
        </foreach>,
        brand =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.brand}
        </foreach>,
        thickness =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.thickness}
        </foreach>,
        thickness_tol_pos =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.thicknessTolPos}
        </foreach>,
        thickness_tol_neg =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.thicknessTolNeg}
        </foreach>,
        width =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.width}
        </foreach>,
        width_tol_pos =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.widthTolPos}
        </foreach>,
        width_tol_neg =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.widthTolNeg}
        </foreach>,
        length =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.length}
        </foreach>,
        length_tol_pos =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.lengthTolPos}
        </foreach>,
        length_tol_neg =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.lengthTolNeg}
        </foreach>,
        status =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.status}
        </foreach>,
        quantity =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.quantity}
        </foreach>,
        sales_price =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.salesPrice}
        </foreach>,
        delivery_date =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.deliveryDate}
        </foreach>,
        show_order =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.showOrder}
        </foreach>,
        assessment_exceeds_agreement =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.assessmentExceedsAgreement}
        </foreach>,
        update_by_id =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.updateById}
        </foreach>,
        update_by =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.updateBy}
        </foreach>,
        packaging_fee =
        <foreach collection="specList" item="item" open="CASE id" close="END">
            WHEN #{item.id} THEN #{item.packagingFee}
        </foreach>,
        update_time = NOW()
        WHERE id IN
        <foreach collection="specList" item="item" open="(" separator="," close=")">
            #{item.id}
        </foreach>
    </update>
</mapper>