RequestCarTicketMapper.xml 5.89 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.RequestCarTicketMapper">

    <resultMap id="RequestCarTicket" type="com.lframework.xingyun.sc.entity.RequestCarTicket">
        <id column="id" property="id"/>
        <result column="draft_id" property="draftId"/>
        <result column="plan_id" property="planId"/>
        <result column="purchase_order_id" property="purchaseOrderId"/>
        <result column="request_car_date" property="requestCarDate"/>
        <result column="dept_id" property="deptId"/>
        <result column="dept_name" property="deptName"/>
        <result column="delivery_date" property="deliveryDate"/>
        <result column="workshop_id" property="workshopId"/>
        <result column="workshop_name" property="workshopName"/>
        <result column="order_no" property="orderNo"/>
        <result column="customer_short_name" property="customerShortName"/>
        <result column="destination" property="destination"/>
        <result column="quantity" property="quantity"/>
        <result column="consignee" property="consignee"/>
        <result column="phone" property="phone"/>
        <result column="return_plan_arrangement" property="returnPlanArrangement"/>
        <result column="other" property="other"/>
        <result column="external_auditor" property="externalAuditor"/>
        <result column="external_auditor_name" property="externalAuditorName"/>
        <result column="loading_time" property="loadingTime"/>
        <result column="special_loading_requirement" property="specialLoadingRequirement"/>
        <result column="business_office_auditor" property="businessOfficeAuditor"/>
        <result column="business_office_auditor_name" property="businessOfficeAuditorName"/>
        <result column="operations_department_auditor" property="operationsDepartmentAuditor"/>
        <result column="operations_department_auditor_name" property="operationsDepartmentAuditorName"/>
        <result column="status" property="status"/>
        <result column="shipments_order_id" property="shipmentsOrderId"/>
        <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="RequestCarTicket_sql">
        SELECT
            tb.id,
            tb.draft_id,
            tb.plan_id,
            tb.purchase_order_id,
            tb.request_car_date,
            tb.dept_id,
            sd.name AS dept_name,
            tb.delivery_date,
            tb.workshop_id,
            ws.name AS workshop_name,
            tb.order_no,
            tb.ordering_unit,
            cu.name AS ordering_unit_name,
            tb.destination,
            tb.quantity,
            tb.consignee,
            tb.phone,
            tb.return_plan_arrangement,
            tb.other,
            tb.external_auditor,
            su.name AS external_auditor_name,
            tb.loading_time,
            tb.special_loading_requirement,
            tb.business_office_auditor,
            su1.name AS business_office_auditor_name,
            tb.operations_department_auditor,
            su2.name AS operations_department_auditor_name,
            tb.status,
            tb.create_by_id,
            tb.create_by,
            tb.update_by_id,
            tb.update_by,
            tb.create_time,
            tb.update_time
        FROM request_car_ticket AS tb
        left join sys_dept as sd on sd.id = tb.dept_id
        left join base_data_workshop as ws on ws.id = tb.workshop_id
        left join base_data_customer as cu on cu.id = tb.ordering_unit
        left join sys_user as su on su.id = tb.external_auditor
        left join sys_user as su1 on su1.id = tb.business_office_auditor
        left join sys_user as su2 on su2.id = tb.operations_department_auditor
    </sql>

    <select id="query" resultMap="RequestCarTicket">
        <include refid="RequestCarTicket_sql"/>
        <where>
            <if test="vo.requestCarDateStart != null">
                AND tb.request_car_date >= #{vo.requestCarDateStart}
            </if>
            <if test="vo.requestCarDateEnd != null">
                <![CDATA[
               AND tb.request_car_date <= #{vo.requestCarDateEnd}
                ]]>
            </if>
            <if test="vo.workshopId != null and vo.workshopId != ''">
                AND tb.workshop_id = #{vo.workshopId}
            </if>
            <if test="vo.orderNo != null and vo.orderNo != ''">
                AND tb.order_no LIKE CONCAT('%', #{vo.orderNo},'%')
            </if>
            <if test="vo.orderingUnitName != null and vo.orderingUnitName != ''">
                AND cu.name LIKE CONCAT('%', #{vo.orderingUnitName},'%')
            </if>
            <if test="vo.deptName != null and vo.deptName != ''">
                AND sd.name LIKE CONCAT('%', #{vo.deptName},'%')
            </if>
            <if test="vo.status != null and vo.status != ''">
                AND tb.status = #{vo.status}
            </if>
            <if test="vo.planId != null and vo.planId != ''">
                AND tb.plan_id = #{vo.planId}
            </if>
            <if test="vo.shipmentsOrderId != null and vo.shipmentsOrderId != ''">
                AND tb.shipments_order_id = #{vo.shipmentsOrderId}
            </if>
        </where>
        ORDER BY tb.create_time DESC
    </select>

    <select id="findById" resultType="com.lframework.xingyun.sc.entity.RequestCarTicket">
        <include refid="RequestCarTicket_sql"/>
        <where>
            <if test="id != null and id != ''">
                AND tb.id = #{id}
            </if>
        </where>
    </select>
</mapper>