| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <?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.ydtech.modules.admin.dao.SysDeptMapper">
- <resultMap id="BaseResultMap" type="com.ydtech.modules.admin.model.SysDept">
- <id property="id" column="id" jdbcType="VARCHAR"/>
- <result property="name" column="name" jdbcType="VARCHAR"/>
- <result property="parentId" column="parent_id" jdbcType="VARCHAR"/>
- <result property="orderNum" column="order_num" jdbcType="INTEGER"/>
- <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
- <result property="lastUpdateBy" column="last_update_by" jdbcType="VARCHAR"/>
- <result property="lastUpdateTime" column="last_update_time" jdbcType="TIMESTAMP"/>
- <result property="delFlag" column="del_flag" jdbcType="TINYINT"/>
- <result property="comtype" column="comtype" jdbcType="VARCHAR"/>
- <result property="comlevel" column="comlevel" jdbcType="VARCHAR"/>
- <result property="address" column="address" jdbcType="VARCHAR"/>
- <result property="leadername" column="leadername" jdbcType="VARCHAR"/>
- <result property="leaderphone" column="leaderphone" jdbcType="VARCHAR"/>
- <result property="comattribute" column="comattribute" jdbcType="VARCHAR"/>
- <result property="isstop" column="isstop" jdbcType="VARCHAR"/>
- <result property="deptCode" column="dept_code" jdbcType="VARCHAR"/>
- <result property="province" column="province" jdbcType="VARCHAR"/>
- <result property="city" column="city" jdbcType="VARCHAR"/>
- <result property="area" column="area" jdbcType="VARCHAR"/>
- <result property="house" column="house" jdbcType="VARCHAR"/>
- <result property="deptType" column="dept_type" jdbcType="VARCHAR"/>
- <result property="leaderId" column="leader_id" jdbcType="VARCHAR"/>
- </resultMap>
- <sql id="Base_Column_List">
- id,name,parent_id,
- order_num,create_by,create_time,
- last_update_by,last_update_time,del_flag,
- comtype,comlevel,address,
- leadername,leaderphone,comattribute,
- isstop,dept_code,province,
- city,area,house,
- dept_type,management_fee,leader_id
- </sql>
- <select id="getMaxId" resultType="java.lang.String">
- SELECT IFNULL(MAX(id), 0) maxid
- FROM `sys_dept`
- WHERE parent_id = #{deptId}
- <if test='comlevel != null and comlevel != ""'>
- and comlevel = #{comlevel}
- </if>
- <!-- <if test='deptType != null and deptType != ""'>-->
- <!-- and id NOT LIKE '%M%'-->
- <!-- </if>-->
- </select>
- <select id="queryListByParentId" resultType="com.ydtech.modules.admin.model.SysDept">
- SELECT
- dept.*
- FROM
- sys_dept dept
- WHERE
- dept.del_flag = 0
- <if test="level == 0">
- AND dept.parent_id = #{parentId}
- </if>
- <if test='level == "1"'>
- AND dept.province IN ( SELECT area_code FROM sys_area WHERE LEVEL = 1 )
- AND LENGTH(
- IFNULL( dept.province, '' )) + LENGTH( IFNULL( dept.city, '' ) ) + LENGTH(
- IFNULL( dept.area, '' ))=6
- AND dept.parent_id = #{parentId}
- </if>
- <if test='level == "2"'>
- AND dept.city IN ( SELECT area_code FROM sys_area WHERE LEVEL = 2 )
- AND LENGTH(
- IFNULL( dept.province, '' )) + LENGTH( IFNULL( dept.city, '' ) ) + LENGTH(
- IFNULL( dept.area, '' ))= 12
- AND dept.parent_id = #{parentId}
- </if>
- <if test='level == "3"'>
- AND dept.area IN ( SELECT area_code FROM sys_area WHERE LEVEL = 3)
- AND LENGTH(
- IFNULL( dept.province, '' )) + LENGTH( IFNULL( dept.city, '' ) ) + LENGTH(
- IFNULL( dept.area, '' ))= 18
- AND dept.parent_id = #{parentId}
- </if>
- <if test='level == "4"'>
- AND dept.parent_id = #{parentId}
- </if>
- </select>
- <select id="queryListByQXDept" resultType="com.ydtech.modules.admin.model.SysDept">
- SELECT sd.id as id,
- sd.name as name,
- sd.parent_id as parentId,
- sd.comlevel as comlevel,
- false as flag
- FROM sys_dept sd
- WHERE (sd.comlevel = 3)
- OR (sd.comlevel = 4)
- OR (sd.comlevel > 4 AND sd.id LIKE '%M%')
- OR (sd.comlevel > 4 AND sd.id LIKE '%D%')
- OR (sd.id LIKE '%M%')
- ORDER BY comlevel
- </select>
- <select id="queryHXDeptTree" resultType="com.ydtech.modules.admin.model.SysDept">
- SELECT sd.id AS id,
- sd.NAME AS NAME,
- sd.parent_id AS parentId,
- sd.comlevel AS comlevel,
- FALSE AS flag
- FROM sys_dept sd
- WHERE (sd.comlevel < 4)
- OR (sd.id LIKE '%D%' AND sd.id NOT LIKE '%M%')
- ORDER BY id
- </select>
- <select id="getByOrderNoQueryManagementSource" resultType="java.lang.String">
- SELECT management_source
- FROM sys_dept
- WHERE id = (SELECT deptid
- FROM ins_orders
- WHERE orderno = #{orderNo})
- </select>
- <select id="getListByIds" resultType="com.ydtech.modules.admin.model.SysDept">
- SELECT sd.id AS id,
- sd.NAME AS NAME,
- sd.parent_id AS parentId,
- sd.comlevel AS comlevel,
- sd.management_source as managementSource
- FROM sys_dept sd
- <where>
- <if test="ids!=null and ids !='' and ids.size()>0">
- sd.id in
- <foreach collection="ids" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <select id="getFiveLevelDept" resultType="com.ydtech.modules.admin.model.SysDept">
- select * from
- sys_dept sd
- <where>
- sd.del_flag ='0'
- AND sd.id LIKE concat('%','9','%')
- AND sd.comlevel is not null
- <if test="vo.deptIds !=null and vo.deptIds!='' and vo.deptIds.size()>0">
- AND sd.id in
- <foreach collection="vo.deptIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="vo.managementSource !=null and vo.managementSource!='' ">
- AND sd.management_source =#{vo.managementSource}
- </if>
- </where>
- </select>
- <select id="queryFiveLevelDept" resultType="com.ydtech.modules.admin.model.SysDept">
- select * from
- sys_dept sd
- <where>
- sd.del_flag ='0'
- AND sd.id LIKE concat('%','9','%')
- AND sd.comlevel is not null
- <if test="vo.deptIds !=null and vo.deptIds!='' and vo.deptIds.size()>0">
- AND sd.id in
- <foreach collection="vo.deptIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <select id="getListByIdsByKzt" resultType="com.ydtech.modules.admin.model.SysDept">
- SELECT sd.id AS id,
- sd.NAME AS NAME,
- sd.parent_id AS parentId,
- sd.comlevel AS comlevel
- FROM sys_dept sd
- <where>
- (sd.management_source != '1' or sd.management_source is null)
- <if test="ids!=null and ids !='' and ids.size()>0">
- and sd.id in
- <foreach collection="ids" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <select id="selectMaxId" resultType="java.lang.String">
- SELECT id FROM sys_dept WHERE parent_id = #{parentId} and comlevel = #{comlevel}
- ORDER BY CAST(SUBSTRING_INDEX(id, 'M', 1) AS UNSIGNED) DESC, CAST(SUBSTRING_INDEX(id, 'M', -1) AS UNSIGNED) DESC LIMIT 1
- </select>
- </mapper>
|