Newer
Older
casic-metering / casic-metering-dao / src / main / resources / mapper / business / BusinessInterchangeMapper.xml
<?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.casic.missiles.mapper.business.BusinessInterchangeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.casic.missiles.model.business.BusinessInterchange">
        <id column="id" property="id"/>
        <result column="interchange_code" property="interchangeCode"/>
        <result column="order_id" property="orderId"/>
        <result column="certification_company" property="certificationCompany"/>
        <result column="certification_company_fex" property="certificationCompanyFex"/>
        <result column="certification_company_email" property="certificationCompanyEmail"/>
        <result column="reciever" property="reciever"/>
        <result column="reciever_phone" property="recieverPhone"/>
        <result column="certification_company_address" property="certificationCompanyAddress"/>
        <result column="customer_id" property="customerId"/>
        <result column="require_over_time" property="requireOverTime"/>
        <result column="deliver_time" property="deliverTime"/>
        <result column="mesure_category" property="mesureCategory"/>
        <result column="secrecy" property="secrecy"/>
        <result column="appearance" property="appearance"/>
        <result column="rely_file" property="relyFile"/>
        <result column="deliverer_sign_file" property="delivererSignFile"/>
        <result column="deliverer_sign_time" property="delivererSignTime"/>
        <result column="reciever_sign_file" property="recieverSignFile"/>
        <result column="remark" property="remark"/>
        <result column="is_del" property="isDel"/>
        <result column="create_user" property="createUser"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, interchange_code, order_id, certification_company, certification_company_fex, certification_company_email, reciever, reciever_phone, certification_company_address, customer_id, require_over_time, deliver_time, mesure_category, secrecy, appearance, rely_file, deliverer_sign_file, deliverer_sign_time, reciever_sign_file, remark, is_del, create_user, create_time, update_time
    </sql>

    <select id="selectInterchangeListPage" resultType="com.casic.missiles.dto.business.interchange.InterchangeListResponse">
        SELECT   deliverer,customerNo,customerName,orderId,id,interchangeCode,remark,deliverTime
        FROM (
        SELECT id,interchange_code AS "interchangeCode",remark,order_id,deliver_time AS "deliverTime"
        FROM business_interchange
        WHERE is_del = 0
            <if test="request.interchangeCode != null and request.interchangeCode !=''">
                AND interchange_Code=#{request.interchangeCode}
            </if>
            <if test="request.reciever != null and request.reciever !=''">
                AND reciever=#{request.reciever}
            </if>
            <if test="request.deliverTime != null and request.deliverTime !=''">
                AND deliver_time=#{request.deliverTime}
            </if>
        ) bif
        JOIN (
            SELECT deliverer,customer_no AS "customerNo",customer_name AS "customerName",id as  "orderId"
            FROM business_order
            WHERE is_del = 0
            <if test="request.deliverer != null and request.deliverer !=''">
                AND deliverer=#{request.deliverer}
            </if>
            <if test="request.customerNo != null and request.customerNo !=''">
                AND customer_no=#{request.customerNo}
            </if>
            <if test="request.customerName != null and request.customerName !=''">
                AND customer_name=#{request.customerName}
            </if>
        ) bo ON bo.orderId = bif.order_id
        ORDER BY bo.deliverTime DESC
    </select>

    <select id="selectMaxExchangeNo" resultType="Long">
        SELECT IFNULL(max(RIGHT(interchange_code, 12)), 0)
        FROM business_interchange
    </select>

</mapper>