TPipeMapper.xml 6.28 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
<?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.zehong.system.mapper.TPipeMapper">
    
    <resultMap type="TPipe" id="TPipeResult">
        <result property="pipeId"    column="pipe_id"    />
        <result property="enterpriseId"    column="enterprise_id"    />
        <result property="pipeName"    column="pipe_name"    />
11
        <result property="pipeCode"    column="pipe_code"    />
12 13 14 15 16 17 18 19 20 21 22 23
        <result property="pipeAddr"    column="pipe_addr"    />
        <result property="coordinates"    column="coordinates"    />
        <result property="pipeLength"    column="pipe_length"    />
        <result property="pipeType"    column="pipe_type"    />
        <result property="pipePressure"    column="pipe_pressure"    />
        <result property="iconUrl"    column="icon_url"    />
        <result property="installationTime"    column="installation_time"    />
        <result property="inspectionTime"    column="inspection_time"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

    <sql id="selectTPipeVo">
24
        select pipe_id, enterprise_id, pipe_name, pipe_code, pipe_addr, coordinates, pipe_length, pipe_type, pipe_pressure, icon_url, installation_time, inspection_time, remarks from t_pipe
25 26 27 28 29
    </sql>

    <select id="selectTPipeList" parameterType="TPipe" resultMap="TPipeResult">
        <include refid="selectTPipeVo"/>
        <where>  
30
            <if test="enterpriseId != null and enterpriseId != 0"> and enterprise_id = #{enterpriseId}</if>
31
            <if test="pipeName != null  and pipeName != ''"> and pipe_name like concat('%', #{pipeName}, '%')</if>
32
            <if test="pipeCode != null  and pipeCode != ''"> and pipe_code like concat('%', #{pipeCode}, '%')</if>
33 34 35 36 37 38 39 40 41 42 43
            <if test="pipeAddr != null  and pipeAddr != ''"> and pipe_addr = #{pipeAddr}</if>
            <if test="coordinates != null  and coordinates != ''"> and coordinates = #{coordinates}</if>
            <if test="pipeType != null  and pipeType != ''"> and pipe_type = #{pipeType}</if>
            <if test="pipePressure != null  and pipePressure != ''"> and pipe_pressure = #{pipePressure}</if>
            <if test="iconUrl != null  and iconUrl != ''"> and icon_url = #{iconUrl}</if>
            <if test="installationTime != null "> and installation_time = #{installationTime}</if>
            <if test="inspectionTime != null "> and inspection_time = #{inspectionTime}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        </where>
    </select>
    
王晓倩's avatar
王晓倩 committed
44
    <select id="selectTPipeById" parameterType="int" resultMap="TPipeResult">
45 46 47
        <include refid="selectTPipeVo"/>
        where pipe_id = #{pipeId}
    </select>
48

49 50 51 52 53
    <select id="selectTPipeByCode" parameterType="String" resultMap="TPipeResult">
        <include refid="selectTPipeVo"/>
        where pipe_code = #{pipeCode}
    </select>

54
    <select id="countPipeLength" resultType="double">
55 56
        select sum(pipe_length) from t_pipe
    </select>
57 58 59 60
        
    <insert id="insertTPipe" parameterType="TPipe" useGeneratedKeys="true" keyProperty="pipeId">
        insert into t_pipe
        <trim prefix="(" suffix=")" suffixOverrides=",">
61
            <if test="enterpriseId != null and enterpriseId != 0">enterprise_id,</if>
62
            <if test="pipeName != null">pipe_name,</if>
63
            <if test="pipeCode != null">pipe_code,</if>
64 65 66 67 68 69 70 71 72 73 74
            <if test="pipeAddr != null">pipe_addr,</if>
            <if test="coordinates != null">coordinates,</if>
            <if test="pipeLength != null">pipe_length,</if>
            <if test="pipeType != null">pipe_type,</if>
            <if test="pipePressure != null">pipe_pressure,</if>
            <if test="iconUrl != null">icon_url,</if>
            <if test="installationTime != null">installation_time,</if>
            <if test="inspectionTime != null">inspection_time,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
75
            <if test="enterpriseId != null and enterpriseId != 0">#{enterpriseId},</if>
76
            <if test="pipeName != null">#{pipeName},</if>
77
            <if test="pipeCode != null">#{pipeCode},</if>
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
            <if test="pipeAddr != null">#{pipeAddr},</if>
            <if test="coordinates != null">#{coordinates},</if>
            <if test="pipeLength != null">#{pipeLength},</if>
            <if test="pipeType != null">#{pipeType},</if>
            <if test="pipePressure != null">#{pipePressure},</if>
            <if test="iconUrl != null">#{iconUrl},</if>
            <if test="installationTime != null">#{installationTime},</if>
            <if test="inspectionTime != null">#{inspectionTime},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTPipe" parameterType="TPipe">
        update t_pipe
        <trim prefix="SET" suffixOverrides=",">
93
            <if test="enterpriseId != null and enterpriseId != 0">enterprise_id = #{enterpriseId},</if>
94
            <if test="pipeName != null">pipe_name = #{pipeName},</if>
95
            <if test="pipeCode != null">pipe_code = #{pipeCode},</if>
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
            <if test="pipeAddr != null">pipe_addr = #{pipeAddr},</if>
            <if test="coordinates != null">coordinates = #{coordinates},</if>
            <if test="pipeLength != null">pipe_length = #{pipeLength},</if>
            <if test="pipeType != null">pipe_type = #{pipeType},</if>
            <if test="pipePressure != null">pipe_pressure = #{pipePressure},</if>
            <if test="iconUrl != null">icon_url = #{iconUrl},</if>
            <if test="installationTime != null">installation_time = #{installationTime},</if>
            <if test="inspectionTime != null">inspection_time = #{inspectionTime},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where pipe_id = #{pipeId}
    </update>

    <delete id="deleteTPipeById" parameterType="Long">
        delete from t_pipe where pipe_id = #{pipeId}
    </delete>

    <delete id="deleteTPipeByIds" parameterType="String">
        delete from t_pipe where pipe_id in 
        <foreach item="pipeId" collection="array" open="(" separator="," close=")">
            #{pipeId}
        </foreach>
    </delete>
</mapper>