Newer
Older
casic-metering-biz-xichang / casic-metering-dao / src / main / resources / mapper / business / BizBusinessSiteExecutiveInfoMapper.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.BizBusinessSiteExecutiveInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.casic.missiles.model.business.BizBusinessSiteExecutiveInfo">
        <id column="id" property="id" />
        <result column="lab_code" property="labCode" />
        <result column="group_code" property="groupCode" />
        <result column="site_executive_no" property="siteExecutiveNo" />
        <result column="site_executive_name" property="siteExecutiveName" />
        <result column="apply_id" property="applyId" />
        <result column="apply_name" property="applyName" />
        <result column="apply_time" property="applyTime" />
        <result column="order_id" property="orderId" />
        <result column="customer_id" property="customerId" />
        <result column="executive_item" property="executiveItem" />
        <result column="executive_address" property="executiveAddress" />
        <result column="executive_environment" property="executiveEnvironment" />
        <result column="approval_status" property="approvalStatus" />
        <result column="print_file_name" property="printFileName" />
        <result column="process_id" property="processId" />
        <result column="remark" property="remark" />
        <result column="create_user_id" property="createUserId" />
        <result column="create_user_name" property="createUserName" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, lab_code, group_code, site_executive_no, site_executive_name, apply_id, apply_name, apply_time, order_id, customer_id, executive_item, executive_address, executive_environment, approval_status, print_file_name, process_id, remark, create_user_id, create_user_name, create_time, update_time
    </sql>

    <select id="selectBatchForApprovalList" resultType="com.casic.missiles.dto.business.siteExecutive.SiteExecutiveApprovalListResponse">
        SELECT bsei.id, bsei.site_executive_no, bsei.site_executive_name, rci.customer_name, bsei.apply_name, bsei.apply_time,
        bsei.approval_status, bsei.process_id, rci.address, rci.contacts, rci.mobile, rci.phone
        FROM biz_business_site_executive_info bsei
        LEFT JOIN biz_resource_customer_info rci ON bsei.customer_id = rci.id
        WHERE 1=1
        <if test="request != null and request.approvalStatus != null and request.approvalStatus !=''">
            and bsei.approval_status = #{request.approvalStatus}
        </if>
        <if test="request != null and request.createUserId != null and request.createUserId !=''">
            and bsei.create_user_id = #{request.createUserId}
        </if>
        <if test="request != null and request.siteExecutiveNo != null and request.siteExecutiveNo !=''">
            and bsei.site_executive_no like concat('%',#{request.siteExecutiveNo},'%')
        </if>
        <if test="request != null and request.customerName != null and request.customerName !=''">
            and rci.customer_name like concat('%',#{request.customerName},'%')
        </if>
        <if test="request != null and request.applyName != null and request.applyName !=''">
            and bsei.apply_name like concat('%',#{request.applyName},'%')
        </if>
        <if test="request != null and request.applyTimeStart != null and request.applyTimeStart !=''">
            and bsei.apply_time &gt;= #{request.applyTimeStart}
        </if>
        <if test="request != null and request.applyTimeEnd != null and request.applyTimeEnd !=''">
            and bsei.apply_time &lt;= #{request.applyTimeEnd}
        </if>
        <if test="businessKeys != null">
            and bsei.id in
            <foreach collection="businessKeys" item="id" index="index" open="(" close=")" separator=",">
                #{id}
            </foreach>
        </if>
        ORDER BY bsei.create_time DESC
    </select>

    <select id="selectMaxNo" resultType="java.lang.Long">
        SELECT IFNULL(max(RIGHT(site_executive_no, 3)), 0) from biz_business_site_executive_info
    </select>

    <select id="selectCustomerById" resultType="com.casic.missiles.model.resource.BizResourceCustomerInfo">
        SELECT rci.*
        FROM biz_business_site_executive_info bsei
        LEFT JOIN biz_resource_customer_info rci ON bsei.customer_id = rci.id
        WHERE bsei.id = #{siteExecutiveId}
    </select>
</mapper>