swmmapper.xml 10.7 KB
Newer Older
hulei 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
<?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.brilliance.isc.mda.dao.SwmMapper">

    <resultMap id="BaseResultMap" type="com.brilliance.isc.bo.Swm">
        <result property="fmt" column="fmt" jdbcType="VARCHAR"/>
        <result property="mt" column="mt" jdbcType="VARCHAR"/>
        <result property="frm" column="frm" jdbcType="VARCHAR"/>
        <result property="tag" column="tag" jdbcType="VARCHAR"/>
        <result property="subtag" column="subtag" jdbcType="VARCHAR"/>
        <result property="dst" column="dst" jdbcType="VARCHAR"/>
        <result property="ins" column="ins" jdbcType="VARCHAR"/>
        <result property="met" column="met" jdbcType="VARCHAR"/>
        <result property="cpyflg" column="cpyflg" jdbcType="VARCHAR"/>
        <result property="ovwflg" column="ovwflg" jdbcType="VARCHAR"/>
        <result property="dstgrp" column="dstgrp" jdbcType="VARCHAR"/>
        <result property="altmapflg" column="altmapflg" jdbcType="VARCHAR"/>
        <result property="jonflg" column="jonflg" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        inr,fmt,mt,frm,tag,subtag,dst,ins,met,cpyflg,ovwflg,dstgrp,altmapflg,jonflg
    </sql>

    <select id="selectByWhere" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from swm
        where 1=1
        <if test="fmt != null and fmt != ''">and fmt = #{fmt,jdbcType=VARCHAR}</if>
        <if test="mt != null and mt != ''">and mt = #{mt,jdbcType=VARCHAR}</if>
        <if test="frm != null and frm!= ''">and frm = #{frm,jdbcType=VARCHAR}</if>
        <if test="tag != null and tag!= ''">and tag = #{tag,jdbcType=VARCHAR}</if>
        <if test="subtag != null and subtag!= ''">and subtag = #{subtag,jdbcType=VARCHAR}</if>
        <if test="dst != null and dst!= ''">and dst = #{dst,jdbcType=VARCHAR}</if>
        <if test="ins != null and ins!= ''">and ins = #{ins,jdbcType=VARCHAR}</if>
        <if test="met != null and met!= ''">and met = #{met,jdbcType=VARCHAR}</if>
        <if test="cpyflg != null and cpyflg!= ''">and cpyflg = #{cpyflg,jdbcType=VARCHAR}</if>
        <if test="ovwflg != null and ovwflg!= ''">and ovwflg = #{ovwflg,jdbcType=VARCHAR}</if>
        <if test="dstgrp != null and dstgrp!= ''">and dstgrp = #{dstgrp,jdbcType=VARCHAR}</if>
        <if test="altmapflg != null and altmapflg!= ''">and altmapflg = #{altmapflg,jdbcType=VARCHAR}</if>
    </select>

    <!--查询指定联合主键的数据-->
    <select id="queryById" resultMap="BaseResultMap">
        select
        INR,FMT, MT, FRM, TAG, SUBTAG, DST, INS, MET, CPYFLG, OVWFLG, DSTGRP, ALTMAPFLG, JONFLG
        from SWM
        <where>
            <if test="frm != null and frm != ''">
                and FRM like concat(concat ('%',#{frm}),'%')
            </if>
            <if test="fmt != null and fmt != ''">
                and FMT like concat(concat ('%',#{fmt}),'%')
            </if>
            <if test="mt != null and mt != ''">
                and MT like concat(concat ('%',#{mt}),'%')
            </if>
        </where>
        ORDER BY length(INR) DESC, INR DESC
    </select>

    <!--查询单个-->
    <select id="queryByInr" resultMap="BaseResultMap">
        SELECT INR,FMT, MT, FRM, TAG, SUBTAG, DST, INS, MET, CPYFLG, OVWFLG, DSTGRP, ALTMAPFLG, JONFLG
        FROM SWM where INR = #{inr}
    </select>

    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="BaseResultMap">
        select
        FMT, MT, FRM,count(*) as num
        from SWM
        <where>
            <if test="frm != null and frm != ''">
                FRM like concat(concat ('%',#{frm}),'%')
            </if>
            <if test="fmt != null and fmt != ''">
                and FMT like concat(concat ('%',#{fmt}),'%')
            </if>
            <if test="mt != null and mt != ''">
                and MT like concat(concat ('%',#{mt}),'%')
            </if>
        </where>
        group by FRM,FMT,MT
    </select>

    <!--查询所有映射栏位模型组-->
    <select id="selectAlldst" resultMap="BaseResultMap">
         SELECT DISTINCT DSTGRP FROM SWM WHERE DSTGRP IS NOT NULL
    </select>

    <!--统计总行数-->
    <select id="count" resultType="java.lang.Long">
        select count(*)
        from SWM
        <where>
            <if test="fmt != null and fmt != ''">
                and FMT = #{fmt}
            </if>
            <if test="mt != null and mt != ''">
                and MT = #{mt}
            </if>
            <if test="frm != null and frm != ''">
                and FRM =#{frm}
            </if>
        </where>
    </select>

    <!--新增所有列-->
    <insert id="insert" keyProperty="" useGeneratedKeys="true">
        insert into SWM(INR,FMT, MT, FRM, TAG, SUBTAG, DST, INS, MET, CPYFLG, OVWFLG, DSTGRP, ALTMAPFLG, JONFLG)
        values (#{inr},#{fmt}, #{mt}, #{frm}, #{tag}, #{subtag}, #{dst},#{ins}, #{met}, #{cpyflg}, #{ovwflg}, #{dstgrp}, #{altmapflg},#{jonflg})
    </insert>

    <insert id="insertBatch" keyProperty="" useGeneratedKeys="true">
        insert into SWM(INR,FMT, MT, FRM, TAG, SUBTAG, DST, INS, MET, CPYFLG, OVWFLG, DSTGRP, ALTMAPFLG, JONFLG)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.inr},#{entity.fmt}, #{entity.mt}, #{entity.frm}, #{entity.tag}, #{entity.subtag}, #{entity.dst},
            #{entity.ins}, #{entity.met}, #{entity.cpyflg}, #{entity.ovwflg}, #{entity.dstgrp}, #{entity.altmapflg},#{entity.jonflg})
        </foreach>
    </insert>

    <!--通过主键修改数据-->
    <update id="update">
        update SWM
        <set>
            <if test="fmt != null and fmt != ''">
                FMT = #{fmt},
            </if>
            <if test="mt != null and mt != ''">
                MT = #{mt},
            </if>
            <if test="frm != null and frm != ''">
                FRM = #{frm},
            </if>
            <if test="tag != null and tag != ''">
                TAG = #{tag},
            </if>
            <if test="subtag != null and subtag != ''">
                SUBTAG = #{subtag},
            </if>
            <if test="dst != null and dst != ''">
                DST = #{dst},
            </if>
            <if test="ins != null and ins != ''">
                INS = #{ins},
            </if>
            <if test="met != null and met != ''">
                MET = #{met},
            </if>
            <if test="cpyflg != null and cpyflg != ''">
                CPYFLG = #{cpyflg},
            </if>
            <if test="ovwflg != null and ovwflg != ''">
                OVWFLG = #{ovwflg},
            </if>
            <if test="dstgrp != null and dstgrp != ''">
                DSTGRP = #{dstgrp},
            </if>
            <if test="altmapflg != null and altmapflg != ''">
                ALTMAPFLG = #{altmapflg},
            </if>
            <if test="jonflg != null and jonflg != ''">
                JONFLG = #{jonflg}
            </if>
        </set>
        where INR = #{inr}
    </update>

    <delete id="deleteById">
        delete from SWM
        <where>
            <if test="fmt != null and fmt != ''">
                FMT = #{fmt}
            </if>
            <if test="mt != null and mt != ''">
                and MT = #{mt}
            </if>
            <if test="frm != null and frm != ''">
                and FRM = #{frm}
            </if>
            <if test="tag != null and tag != ''">
                and TAG = #{tag}
            </if>
            <if test="subtag != null and subtag != ''">
                and SUBTAG = #{subtag}
            </if>
            <if test="dst != null and dst != ''">
                and DST = #{dst}
            </if>
            <if test="ins != null and ins != ''">
                and INS = #{ins}
            </if>
            <if test="met != null and met != ''">
                and MET = #{met}
            </if>
            <if test="cpyflg != null and cpyflg != ''">
                and CPYFLG = #{cpyflg}
            </if>
            <if test="ovwflg != null and ovwflg != ''">
                and OVWFLG = #{ovwflg}
            </if>
            <if test="dstgrp != null and dstgrp != ''">
                and DSTGRP = #{dstgrp}
            </if>
            <if test="altmapflg != null and altmapflg != ''">
                and ALTMAPFLG = #{altmapflg}
            </if>
            <if test="jonflg != null and jonflg != ''">
                and JONFLG = #{jonflg}
            </if>
        </where>
    </delete>
    <!--批量删除-->
    <delete id="deleteAll">
        <if test="list != null and list.size() > 0">
            delete from SWM where INR in
            <foreach collection="list" item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
    </delete>

    <select id="check" resultType="java.lang.Integer">
        select count(*)
        from SWM
        <where>
            <if test="frm != null and frm != ''">
                and FRM = #{frm}
            </if>
            <if test="fmt != null and fmt != ''">
                and FMT= #{fmt}
            </if>
            <if test="mt != null and mt != ''">
                and MT = #{mt}
            </if>
            <if test="tag != null and tag != ''">
                and TAG = #{tag}
            </if>
            <if test="subtag != null and subtag != ''">
                and SUBTAG = #{subtag}
            </if>
            <if test="dst != null and dst != ''">
                and DST = #{dst}
            </if>
            <if test="dstgrp != null and dstgrp != ''">
                and DSTGRP = #{dstgrp}
            </if>
        </where>
    </select>

    <select id="selectFrmByWhere" resultType="java.lang.String">
        select distinct FRM from SWM WHERE FMT = #{fmt} AND MT = #{mt} AND FRM = #{frm} and ALTMAPFLG ='X'
    </select>

    <select id="selectFrmListByWhere" resultType="java.lang.String">
        SELECT distinct FRM from SWM WHERE FMT = #{fmt} AND MT = #{mt}
        <choose>
            <when test="altmapflg != null and altmapflg != ''">
                and ALTMAPFLG = #{altmapflg}
            </when>
            <otherwise>
                and (ALTMAPFLG is null or ALTMAPFLG = '')
            </otherwise>
        </choose>
    </select>

    <select id="selectSwmListByWhere" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from swm
        WHERE FMT = #{fmt} AND MT = #{mt}  AND FRM = #{frm}
        <choose>
            <when test="altmapflg != null and altmapflg != ''">
                and ALTMAPFLG = #{altmapflg}
            </when>
            <otherwise>
                and (ALTMAPFLG is null or ALTMAPFLG = '')
            </otherwise>
        </choose>
    </select>

</mapper>