PendingDeliveryOrderMapper.xml 3.49 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.PendingDeliveryOrderMapper">

    <resultMap id="PendingDeliveryOrder" type="com.lframework.xingyun.sc.entity.PendingDeliveryOrder">
        <id column="id" property="id"/>
        <result column="fund_id" property="fundId"/>
        <result column="purchase_order_id" property="purchaseOrderId"/>
        <result column="order_no" property="orderNo"/>
        <result column="ordering_unit_name" property="orderingUnitName"/>
        <result column="workshop_name" property="workshopName"/>
        <result column="dept_name" property="deptName"/>
        <result column="total_quantity" property="totalQuantity"/>
        <result column="dispatched_quantity" property="dispatchedQuantity"/>
        <result column="requested_shipment_quantity" property="requestedShipmentQuantity"/>
        <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="PendingDeliveryOrder_sql">
        SELECT
            tb.id,
            tb.fund_id,
            tb.purchase_order_id,
            poi.order_no,
            cu.name AS ordering_unit_name,
            ws.name AS workshop_name,
            sd.name AS dept_name,
            tb.total_quantity,
            tb.dispatched_quantity,
            tb.requested_shipment_quantity,
            tb.create_by_id,
            tb.create_by,
            tb.update_by_id,
            tb.update_by,
            tb.create_time,
            tb.update_time
        FROM pending_delivery_order AS tb
        left join purchase_order_info as poi on poi.id = tb.purchase_order_id
        left join base_data_customer as cu on cu.id = poi.ordering_unit
        left join sys_dept as sd on sd.id = poi.dept_id
        left join base_data_workshop as ws on ws.id = poi.workshop_id
    </sql>

    <select id="query" resultMap="PendingDeliveryOrder">
        <include refid="PendingDeliveryOrder_sql"/>
        <where>
            <if test="vo.purchaseOrderId != null and vo.purchaseOrderId != ''">
                AND tb.purchase_order_id = #{vo.purchaseOrderId}
            </if>
            <if test="vo.fundId != null and vo.fundId != ''">
                AND tb.fund_id = #{vo.fundId}
            </if>
        </where>
    </select>

    <insert id="batchAdd">
        INSERT INTO pending_delivery_order (
        id,
        fund_id,
        purchase_order_id,
        total_quantity,
        dispatched_quantity,
        requested_shipment_quantity,
        create_by_id,
        create_by,
        update_by_id,
        update_by,
        create_time,
        update_time
        ) VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.id},
            #{item.fundId},
            #{item.purchaseOrderId},
            #{item.totalQuantity},
            #{item.dispatchedQuantity},
            #{item.requestedShipmentQuantity},
            #{item.createById},
            #{item.createBy},
            #{item.updateById},
            #{item.updateBy},
            #{item.createTime},
            #{item.updateTime}
            )
        </foreach>
    </insert>
</mapper>