swmmapper.xml 10.7 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.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>