DomesticPlanSummaryMapper.xml 2.53 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.summary.DomesticPlanSummaryMapper">

    <resultMap id="DomesticPlanSummary" type="com.lframework.xingyun.sc.procurement.entity.summary.DomesticPlanSummary">
        <id column="id" property="id"/>
        <result column="code" property="code"/>
        <result column="summary_date" property="summaryDate"/>
        <result column="total_quantity" property="totalQuantity"/>
        <result column="weighted_avg_coordination" property="weightedAvgCoordination"/>
        <result column="create_by_id" property="createById"/>
        <result column="create_by" property="createBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_by_id" property="updateById"/>
        <result column="update_by" property="updateBy"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <sql id="DomesticPlanSummary_sql">
        SELECT
            dps.id,
            dps.code,
            dps.summary_date,
            dps.total_quantity,
            dps.weighted_avg_coordination,
            dps.create_by_id,
            dps.create_by,
            dps.create_time,
            dps.update_by_id,
            dps.update_by,
            dps.update_time
        FROM domestic_plan_summary AS dps
    </sql>

    <select id="query" resultMap="DomesticPlanSummary">
        <include refid="DomesticPlanSummary_sql"/>
        <where>
            <if test="vo.code != null and vo.code != ''">
                AND dps.code LIKE CONCAT('%', #{vo.code}, '%')
            </if>
            <if test="vo.startDate != null">
                AND dps.summary_date &gt;= #{vo.startDate}
            </if>
            <if test="vo.endDate != null">
                AND dps.summary_date &lt;= #{vo.endDate}
            </if>
        </where>
        ORDER BY dps.summary_date DESC, dps.code DESC
    </select>

    <select id="findById" resultMap="DomesticPlanSummary">
        <include refid="DomesticPlanSummary_sql"/>
        WHERE dps.id = #{id}
    </select>

    <select id="countBySummaryDate" resultType="long">
        SELECT COUNT(1) FROM domestic_plan_summary WHERE summary_date = #{summaryDate}
    </select>

    <select id="findMaxCodeByYearPrefix" resultMap="DomesticPlanSummary">
        SELECT * FROM domestic_plan_summary WHERE code LIKE CONCAT(#{prefix}, '%') ORDER BY code DESC LIMIT 1
    </select>
</mapper>