PlanStandardPurchaseMapper.xml 2.7 KB
Newer Older
qinhu's avatar
1  
qinhu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
<?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="cn.wise.sc.cement.business.mapper.PlanStandardPurchaseMapper">

    <sql id="where">
        <where>
            <if test="params.status != null">
                and t.status = #{params.status}
            </if>
            <if test="params.name != null and params.name != ''">
                and t.name like concat('%', #{params.name}, '%')
            </if>
            <if test="params.code != null and params.code != ''">
                and t.code like concat('%', #{params.code}, '%')
            </if>
        </where>
    </sql>

    <select id="getPage" resultType="cn.wise.sc.cement.business.model.vo.PlanStandardPurchaseVo">
        SELECT t.*, su.name as purchaserName
        FROM plan_standard_purchase t
        left join sys_user su on su.id = t.purchaser_id
        <include refid="where"/>
        ORDER BY t.id DESC
    </select>

    <select id="exportList" resultType="java.util.HashMap">
        SELECT
        (@i:=@i+1) as 序号,
        t.name as 标物名称,
        t.distribution_unit as 经销单位,
        t.purchase_num as 采购数量,
        t.purchase_date as 采购时间,
        su.name as 采购人
        FROM plan_standard_purchase t
        left join sys_user su on su.id = t.purchaser_id
        ,(select @i:=0)t
        <include refid="where"/>
        ORDER BY t.id DESC
    </select>


    <select id="getDetail" resultType="cn.wise.sc.cement.business.model.vo.PlanStandardPurchaseVo">
        SELECT t.*, su.name as purchaserName, su2.name as userName
        FROM plan_standard_purchase t
        left join sys_user su on su.id = t.purchaser_id
        left join sys_user su2 on su2.id = t.user_id
        WHERE t.id = #{id}
    </select>

    <sql id="whereNew">
        <where>
            <if test="params.status != null">
                and t.status = #{params.status}
            </if>
            <if test="params.name != null and params.name != ''">
                and t.name like concat('%', #{params.name}, '%')
            </if>
            <if test="params.start !=null">
                and t.create_time <![CDATA[>=]]> #{params.start}
            </if>
            <if test="params.end !=null">
                and t.create_time <![CDATA[<=]]> #{params.end}
            </if>
        </where>
    </sql>
    <select id="wordList" resultType="cn.wise.sc.cement.business.model.vo.PlanStandardPurchaseVo">
        SELECT t.*, su.name as purchaserName
        FROM plan_standard_purchase t
        left join sys_user su on su.id = t.purchaser_id
        <include refid="whereNew"/>
        ORDER BY t.id DESC
    </select>

</mapper>