YsEntityBudgetMapper.xml 7.79 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.chinagas.modules.system.mapper.YsEntityBudgetMapper">
    
    <resultMap type="com.chinagas.modules.system.entity.YsEntityBudget" id="YsEntityBudgetResult">
        <result property="id"    column="ID"    />
        <result property="plateId"    column="PLATE_ID"    />
        <result property="plate"    column="PLATE"    />
        <result property="regionId"    column="REGION_ID"    />
        <result property="region"    column="REGION"    />
        <result property="eMGroupId"    column="E_M_Group_ID"    />
        <result property="eMGroup"    column="E_M_Group"    />
        <result property="entity"    column="ENTITY"    />
        <result property="entityName"    column="ENTITY_NAME"    />
        <result property="aEntityId"    column="A_ENTITY_ID"    />
        <result property="aEntityName"    column="A_ENTITY_NAME"    />
        <result property="status"    column="status"    />
    </resultMap>

    <sql id="selectYsEntityBudgetVo">
        select ID, PLATE_ID, PLATE, REGION_ID, REGION, E_M_Group_ID, E_M_Group, ENTITY, ENTITY_NAME, A_ENTITY_ID, A_ENTITY_NAME, status from ys_entity_budget
    </sql>

    <sql id="selectYsEntityBudgetVo1">
        select distinct(ENTITY) ID, PLATE_ID, PLATE, REGION_ID, REGION, E_M_Group_ID, E_M_Group, ENTITY, ENTITY_NAME, A_ENTITY_ID, A_ENTITY_NAME, status from ys_entity_budget
    </sql>

    <select id="selectYsEntityBudgetList" parameterType="com.chinagas.modules.system.entity.YsEntityBudget" resultMap="YsEntityBudgetResult">
        <include refid="selectYsEntityBudgetVo"/>
        <where>  
            <if test="plateId != null "> and PLATE_ID = #{plateId}</if>
            <if test="plate != null  and plate != ''"> and PLATE = #{plate}</if>
            <if test="regionId != null "> and REGION_ID = #{regionId}</if>
            <if test="region != null  and region != ''"> and REGION = #{region}</if>
            <if test="eMGroupId != null "> and E_M_Group_ID = #{eMGroupId}</if>
            <if test="eMGroup != null  and eMGroup != ''"> and E_M_Group = #{eMGroup}</if>
            <if test="entity != null "> and ENTITY = #{entity}</if>
            <if test="entityName != null  and entityName != ''"> and ENTITY_NAME like concat('%', #{entityName}, '%')</if>
            <if test="aEntityId != null "> and A_ENTITY_ID = #{aEntityId}</if>
            <if test="aEntityName != null  and aEntityName != ''"> and A_ENTITY_NAME like concat('%', #{aEntityName}, '%')</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>

    <select id="selectYsEntityBudgetList1" parameterType="com.chinagas.modules.system.entity.YsEntityBudget" resultMap="YsEntityBudgetResult">
        <include refid="selectYsEntityBudgetVo1"/>
        <where>
            <if test="plateId != null "> and PLATE_ID = #{plateId}</if>
            <if test="plate != null  and plate != ''"> and PLATE = #{plate}</if>
            <if test="regionId != null "> and REGION_ID = #{regionId}</if>
            <if test="region != null  and region != ''"> and REGION = #{region}</if>
            <if test="eMGroupId != null "> and E_M_Group_ID = #{eMGroupId}</if>
            <if test="eMGroup != null  and eMGroup != ''"> and E_M_Group = #{eMGroup}</if>
            <if test="entity != null "> and ENTITY = #{entity}</if>
            <if test="entityName != null  and entityName != ''"> and ENTITY_NAME like concat('%', #{entityName}, '%')</if>
            <if test="aEntityId != null "> and A_ENTITY_ID = #{aEntityId}</if>
            <if test="aEntityName != null  and aEntityName != ''"> and A_ENTITY_NAME like concat('%', #{aEntityName}, '%')</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectYsEntityBudgetById" parameterType="Long" resultMap="YsEntityBudgetResult">
        <include refid="selectYsEntityBudgetVo"/>
        where ID = #{id}
    </select>
        
    <insert id="insertYsEntityBudget" parameterType="com.chinagas.modules.system.entity.YsEntityBudget">
        insert into ys_entity_budget
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">ID,</if>
            <if test="plateId != null">PLATE_ID,</if>
            <if test="plate != null and plate != ''">PLATE,</if>
            <if test="regionId != null">REGION_ID,</if>
            <if test="region != null and region != ''">REGION,</if>
            <if test="eMGroupId != null">E_M_Group_ID,</if>
            <if test="eMGroup != null and eMGroup != ''">E_M_Group,</if>
            <if test="entity != null">ENTITY,</if>
            <if test="entityName != null and entityName != ''">ENTITY_NAME,</if>
            <if test="aEntityId != null">A_ENTITY_ID,</if>
            <if test="aEntityName != null and aEntityName != ''">A_ENTITY_NAME,</if>
            <if test="status != null">status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="plateId != null">#{plateId},</if>
            <if test="plate != null and plate != ''">#{plate},</if>
            <if test="regionId != null">#{regionId},</if>
            <if test="region != null and region != ''">#{region},</if>
            <if test="eMGroupId != null">#{eMGroupId},</if>
            <if test="eMGroup != null and eMGroup != ''">#{eMGroup},</if>
            <if test="entity != null">#{entity},</if>
            <if test="entityName != null and entityName != ''">#{entityName},</if>
            <if test="aEntityId != null">#{aEntityId},</if>
            <if test="aEntityName != null and aEntityName != ''">#{aEntityName},</if>
            <if test="status != null">#{status},</if>
         </trim>
    </insert>

    <update id="updateYsEntityBudget" parameterType="com.chinagas.modules.system.entity.YsEntityBudget">
        update ys_entity_budget
        <trim prefix="SET" suffixOverrides=",">
            <if test="plateId != null">PLATE_ID = #{plateId},</if>
            <if test="plate != null and plate != ''">PLATE = #{plate},</if>
            <if test="regionId != null">REGION_ID = #{regionId},</if>
            <if test="region != null and region != ''">REGION = #{region},</if>
            <if test="eMGroupId != null">E_M_Group_ID = #{eMGroupId},</if>
            <if test="eMGroup != null and eMGroup != ''">E_M_Group = #{eMGroup},</if>
            <if test="entity != null">ENTITY = #{entity},</if>
            <if test="entityName != null and entityName != ''">ENTITY_NAME = #{entityName},</if>
            <if test="aEntityId != null">A_ENTITY_ID = #{aEntityId},</if>
            <if test="aEntityName != null and aEntityName != ''">A_ENTITY_NAME = #{aEntityName},</if>
            <if test="status != null">status = #{status},</if>
        </trim>
        where ID = #{id}
    </update>

    <delete id="deleteYsEntityBudgetById" parameterType="Long">
        delete from ys_entity_budget where ID = #{id}
    </delete>

    <delete id="deleteYsEntityBudgetByIds" parameterType="String">
        delete from ys_entity_budget where ID in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <select id="selectYsEntityBudgetByEntity" parameterType="Long" resultMap="YsEntityBudgetResult">
        <include refid="selectYsEntityBudgetVo"/>
        where ENTITY = #{entity}
    </select>

    <select id="selectYsAccounting" parameterType="Long" resultMap="YsEntityBudgetResult">
        <include refid="selectYsEntityBudgetVo"/>
        where ENTITY in
        <foreach collection="array" item="longs" index="index" open="(" close=")" separator=",">
            #{longs}
        </foreach>
    </select>
</mapper>