SupplierQuotationProjectMapper.xml 4.26 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.procurement.mappers.quotation.SupplierQuotationProjectMapper">

    <resultMap id="SupplierQuotationProject" type="com.lframework.xingyun.sc.procurement.entity.SupplierQuotationProject">
        <id column="id" property="id"/>
        <result column="code" property="code"/>
        <result column="name" property="name"/>
        <result column="product_id" property="productId"/>
        <result column="product_name" property="productName"/>
        <result column="product_code" property="productCode"/>
        <result column="quantity" property="quantity"/>
        <result column="start_time" property="startTime"/>
        <result column="end_time" property="endTime"/>
        <result column="project_type" property="projectType"/>
        <result column="bid_time" property="bidTime"/>
        <result column="purchase_rule" property="purchaseRule"/>
        <result column="status" property="status"/>
        <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="SupplierQuotationProjectSql">
        SELECT
            tb.id,
            tb.code,
            tb.name,
            tb.product_id,
            br.product_name,
            br.code AS product_code,
            tb.quantity,
            tb.start_time,
            tb.end_time,
            tb.project_type,
            tb.bid_time,
            tb.purchase_rule,
            tb.status,
            tb.create_by_id,
            tb.create_by,
            tb.update_by_id,
            tb.update_by,
            tb.create_time,
            tb.update_time
        FROM procurement_supplier_quotation_project tb
        LEFT JOIN base_data_breed_relationship br ON br.id = tb.product_id
    </sql>

    <select id="query" resultMap="SupplierQuotationProject">
        <include refid="SupplierQuotationProjectSql"/>
        <where>
            <if test="vo.name != null and vo.name != ''">
                AND tb.name LIKE CONCAT('%', #{vo.name}, '%')
            </if>
            <if test="vo.startTimeStart != null">
                AND tb.start_time <![CDATA[ >= ]]> #{vo.startTimeStart}
            </if>
            <if test="vo.startTimeEnd != null">
                AND tb.start_time <![CDATA[ <= ]]> #{vo.startTimeEnd}
            </if>
            <if test="vo.endTimeStart != null">
                AND tb.end_time <![CDATA[ >= ]]> #{vo.endTimeStart}
            </if>
            <if test="vo.endTimeEnd != null">
                AND tb.end_time <![CDATA[ <= ]]> #{vo.endTimeEnd}
            </if>
            <if test="vo.bidTimeStart != null">
                AND tb.bid_time <![CDATA[ >= ]]> #{vo.bidTimeStart}
            </if>
            <if test="vo.bidTimeEnd != null">
                AND tb.bid_time <![CDATA[ <= ]]> #{vo.bidTimeEnd}
            </if>
        </where>
        ORDER BY tb.create_time DESC, tb.id DESC
    </select>

    <select id="findById" resultMap="SupplierQuotationProject">
        <include refid="SupplierQuotationProjectSql"/>
        WHERE tb.id = #{id}
    </select>

    <select id="getMaxCodeByDay" resultType="java.lang.String">
        SELECT tb.code
        FROM procurement_supplier_quotation_project tb
        WHERE tb.code LIKE CONCAT(#{dayPrefix}, '%')
        ORDER BY CAST(RIGHT(tb.code, 2) AS UNSIGNED) DESC
        LIMIT 1
    </select>

    <select id="queryCurrentDayList" resultMap="SupplierQuotationProject">
        <include refid="SupplierQuotationProjectSql"/>
        WHERE DATE(tb.create_time) = #{day}
        AND tb.status='PUBLISHED'
        ORDER BY tb.create_time DESC, tb.id DESC
    </select>

    <select id="queryCurrentDayFinishedList" resultMap="SupplierQuotationProject">
        <include refid="SupplierQuotationProjectSql"/>
        WHERE DATE(tb.create_time) = #{day}
        AND tb.status IN ('COMPLETED', 'ABORTED')
        ORDER BY tb.update_time DESC, tb.id DESC
    </select>
</mapper>