TbAreaBlockSmapper.xml 4.77 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.zteits.sys.mapper.smapper.TbAreaBlockSmapper">
    <resultMap id="BaseResultMap" type="com.zteits.sys.domain.TbAreaBlock">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="area_code" property="areaCode" jdbcType="BIGINT"/>
        <result column="area_name" property="areaName" jdbcType="VARCHAR"/>
        <result column="area_type" property="areaType" jdbcType="INTEGER"/>
        <result column="parent_id" property="parentId" jdbcType="BIGINT"/>
        <result column="org_id" property="orgId" jdbcType="BIGINT"/>
        <result column="data_state" property="dataState" jdbcType="INTEGER"/>
        <result column="create_empid" property="createEmpid" jdbcType="VARCHAR"/>
        <result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
        <result column="modfiy_empid" property="modfiyEmpid" jdbcType="VARCHAR"/>
        <result column="modfiy_date" property="modfiyDate" jdbcType="TIMESTAMP"/>
        <result column="remark" property="remark" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="Base_Column_List">
    id, area_code, area_name, area_type, parent_id, org_id, data_state, create_empid,
    create_date, modfiy_empid, modfiy_date, remark
  </sql>

    <!--查询块信息-->
    <select id="queryTbAreaBlock" parameterType="com.zteits.sys.domain.TbAreaBlock" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tb_area_block
        where 1=1
        <if test="areaCode != null">
            and area_code=#{areaCode,jdbcType="BIGINT"}
        </if>
        <if test="areaName != null and areaName !=''">
            and area_name=#{areaName,jdbcType=VARCHAR}
        </if>
        <if test="areaType != null">
            and area_type=#{areaType,jdbcType=INTEGER}
        </if>
        <if test="parentId != null">
            and parent_id=#{parentId,jdbcType=BIGINT}
        </if>
        <if test="parentAreaId != null">
            and parent_area_id=#{parentAreaId,jdbcType=BIGINT}
        </if>
        <if test="orgId != null">
            and org_id=#{orgId,jdbcType=BIGINT}
        </if>
        <if test="id != null">
            and id=#{id,jdbcType=BIGINT}
        </if>
        <choose>
            <when test="dataState != null">
                and data_state = #{dataState,jdbcType=INTEGER}
            </when>
            <otherwise>
                and data_state = 1
            </otherwise>
        </choose>
    </select>

    <select id="queryAreaBlockByAreaType" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tb_area_block
        where area_type IN
        <foreach collection="areaTypes" item="areaType" index="index" open="(" separator="," close=")">
            #{areaType}
        </foreach>
        <if test="orgId != null and orgId !=-1">
            and org_id= #{orgId}
        </if>
       
        and data_state = 1
    </select>

    <select id="queryAreaBlockByParentIdAndOrgId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tb_area_block
        where parent_id =#{parentId}
        and org_id= #{orgId}
        and data_state = 1
    </select>
    
    
    <select id="queryAreaBlockByBlockId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tb_area_block
        where id IN
        <foreach collection="plBlockIds" item="plBlockId" index="index" open="(" separator="," close=")">
            #{plBlockId}
        </foreach>
        and data_state = 1
    </select>
    <!-- 通过操作员ID+组织id查询块信息 -->
    <select id="queryAreaBlockByOpIdAndOrgId" resultMap="BaseResultMap">
		  SELECT
			c.id, c.area_code, c.area_name, c.area_type, c.parent_id, c.org_id, c.data_state
		FROM
		    tb_area_block c 
		WHERE  c.data_state=1
		   <if test="orgId != null and orgId !='' and orgId !='-1' ">
		     and c.org_id=#{orgId}
		   </if>
		    
		    and c.area_type=#{areaType}
		    order by c.area_name
    </select>
    
    <!--检查块名称是否唯一-->
    <select id="checkBlockNameUnique" parameterType="com.zteits.clouds.api.dto.sys.param.CheckBlockNameUniqueRequest" resultType="java.lang.Integer">
      SELECT
			count(1)
		FROM
			tb_area_block a
		WHERE
			a.data_state = 1
		AND a.area_name=#{blockName}  
    </select>


    <!-- 查询区域的下一级 -->
    <select id="queryNextLowerLeverByIdForArea" parameterType="com.zteits.sys.domain.TbAreaBlock" resultMap="BaseResultMap" >
        select
        <include refid="Base_Column_List" />
        from tb_area_block
        where data_state = 1
        and parent_id=#{id}

    </select>

</mapper>