Newer
Older
casic-metering-biz-xichang / casic-metering-dao / src / main / resources / mapper / business / BizBusinessOrderInfoMapper.xml
wangpeng on 29 Apr 2024 4 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.casic.missiles.mapper.business.BizBusinessOrderInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.casic.missiles.model.business.BizBusinessOrderInfo">
        <id column="id" property="id" />
        <result column="order_no" property="orderNo" />
        <result column="deliverer_id" property="delivererId" />
        <result column="deliverer" property="deliverer" />
        <result column="customer_id" property="customerId" />
        <result column="customer_name" property="customerName" />
        <result column="dept_id" property="deptId" />
        <result column="dept_name" property="deptName" />
        <result column="deliverer_tel" property="delivererTel" />
        <result column="plan_deliver_time" property="planDeliverTime" />
        <result column="require_over_time" property="requireOverTime" />
        <result column="customer_address" property="customerAddress" />
        <result column="customer_phone" property="customerPhone" />
        <result column="is_urgent" property="isUrgent" />
        <result column="maintain_major" property="maintainMajor" />
        <result column="undertaker_id" property="undertakerId" />
        <result column="measure_company" property="measureCompany" />
        <result column="undertaker_name" property="undertakerName" />
        <result column="undertake_time" property="undertakeTime" />
        <result column="receive_status" property="receiveStatus" />
        <result column="receive_illustrate" property="receiveIllustrate" />
        <result column="is_on_site_check" property="isOnSiteCheck" />
        <result column="on_site_check_time" property="onSiteCheckTime" />
        <result column="site_executive_id" property="siteExecutiveId" />
        <result column="site_executive_no" property="siteExecutiveNo" />
        <result column="data_source" property="dataSource" />
        <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, order_no, deliverer_id, deliverer, customer_id, customer_name, dept_id, dept_name, deliverer_tel, plan_deliver_time, require_over_time, customer_address,
        customer_phone, is_urgent, maintain_major, undertaker_id, measure_company, undertaker_name, undertake_time, receive_status, receive_illustrate,
        is_on_site_check, on_site_check_time, site_executive_id, site_executive_no, data_source, create_user_id, create_user_name, create_time, update_time
    </sql>

    <select id="selectMaxOrderNo" resultType="java.lang.Long">
        SELECT IFNULL(max(RIGHT(order_no, 12)), 0) from biz_business_order_info
    </select>

    <select id="selectCustomerByOrderId" resultType="com.casic.missiles.model.resource.BizResourceCustomerInfo">
        SELECT rci.*
        FROM biz_business_order_info boi
        JOIN biz_resource_customer_info rci ON rci.id = boi.customer_id
        WHERE boi.id = #{orderId}
    </select>

    <select id="sampleListByCustomerId" resultType="com.casic.missiles.dto.business.dispatch.ReadSampleDTO">
        SELECT sampleId, sampleNo, sampleName, sampleModel, manufactureNo, labelBind, certificateValid
        FROM (
            SELECT id AS sampleId, equipment_no AS sampleNo, equipment_name AS sampleName, model AS sampleModel, manufacture_no AS manufactureNo,
                RFID AS labelBind, certificate_valid AS certificateValid
            FROM eqpt_equipment_info
            WHERE is_del=0
        ) csi
        WHERE csi.sampleId NOT IN
        (
            SELECT sample_id
            FROM biz_business_order_sample_relation bosr
            JOIN (
                SELECT id
                FROM biz_business_order_info
                WHERE 1=1
                <if test="customerId != null and customerId !=''">
                    AND customer_id=#{customerId}
                </if>
                AND (receive_status ='2' OR receive_status ='1' OR  receive_status ='')     <!-- 委托书创建,引入的委托书只能是只能为接收状态-->
            ) bo ON bo.id=bosr.order_id
        )
    </select>

    <update id="updateSiteExecutiveIdById">
        UPDATE biz_business_order_info SET site_executive_id = #{siteExecutiveId}, site_executive_no = #{siteExecutiveNo} WHERE id = #{orderId};
    </update>
</mapper>