Newer
Older
casic-metering / casic-metering-dao / src / main / resources / mapper / meter / MeterPriceMapper.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.meter.MeterPriceMapper">

    <select id="getMaxNo" resultType="java.lang.Long">
        SELECT IFNULL(max(RIGHT(price_no, 12)), 0) from meter_price
    </select>

    <sql id="MeterPrice">
        SELECT
            mp.id,
            mp.price_no,
            mp.price_name,
            mp.check_type,
            mp.price_type,
            mpc.category_name,
            mp.price_item,
            mpi.item_name,
            mp.price_standard,
            mf.file_name AS price_standard_name,
            mp.price_limit,
            mp.price_description,
            mp.operator_discount_permission,
            mp.director_discount_permission,
            mp.remark,
            mp.create_time,
            mp.update_time,
            mp.model,
            mp.price
        FROM
            meter_price mp
                LEFT JOIN meter_price_category mpc ON mp.price_type = mpc.id
                LEFT JOIN meter_price_item mpi ON mp.price_item = mpi.id
                LEFT JOIN meter_file mf on mp.price_standard = mf.id
    </sql>

    <select id="queryPriceList" resultType="com.casic.missiles.model.meter.MeterPrice">
        <include refid="MeterPrice"/>
        <where>
            mp.is_del = 0
            <if test="request.priceNo != null  and request.priceNo != ''">
                and mp.price_no like CONCAT('%',#{request.priceNo},'%')
            </if>
            <if test="request.priceName != null  and request.priceName != ''">
                and mp.price_name like concat('%', #{request.priceName}, '%')
            </if>
            <if test="request.checkType != null  and  request.checkType != ''">
                and mp.check_type = #{request.checkType}
            </if>
            <if test="request.model != null  and request.model != ''">
                and mp.model like concat('%', #{request.model}, '%')
            </if>
            <if test="request.priceType != null  and request.priceType != ''">
                and mpc.category_name like concat('%', #{request.priceType}, '%')
            </if>
            <if test="request.priceItem != null  and request.priceItem != ''">
                and mpi.item_name like concat('%', #{request.priceItem}, '%')
            </if>
            <if test="request.ids != null and request.ids.size() > 0 ">
                and mp.id in
                <foreach collection='request.ids' item='id' open='(' separator=',' close=')'>
                    #{id}
                </foreach>
            </if>
        </where>
    </select>

    <select id="queryPriceInfo" resultType="com.casic.missiles.model.meter.MeterPrice">
        <include refid="MeterPrice"/>
        where mp.id = #{id}
    </select>

    <insert id="addMeterPriceList" parameterType="java.util.List">
        INSERT INTO meter_price (
            `id`,
            `price_no`,
            `price_name`,
            `check_type`,
            `price_type`,
            `price_item`,
            `price_standard`,
            `price_limit`,
            `price_description`,
            `operator_discount_permission`,
            `director_discount_permission`,
            `remark`,
            `price`
            )
        VALUES
        <foreach collection ="list" item="bean" separator =",">
            (#{bean.id}, #{bean.priceNo}, #{bean.priceName}, #{bean.checkType},
             #{bean.priceType},#{bean.priceItem},#{bean.priceStandard},#{bean.priceLimit}
            ,#{bean.priceDescription},#{bean.operatorDiscountPermission},#{bean.directorDiscountPermission},
             #{bean.remark},#{bean.price}
            )
        </foreach >
    </insert>

    <select id="selectCountByItem" resultType="java.lang.Integer">
        SELECT COUNT(DISTINCT price_item)
        FROM meter_price
        WHERE is_del = 0
    </select>
</mapper>