123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353 |
- <?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.bz.smart_city.dao.ChannelMapper">
- <!--auto generated Code-->
- <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.Channel">
- <result column="id" property="id" jdbcType="INTEGER"/>
- <result column="parent_id" property="parentId" jdbcType="INTEGER"/>
- <result column="channel_name" property="channelName" jdbcType="VARCHAR"/>
- <result column="channel_code" property="channelCode" jdbcType="VARCHAR"/>
- <result column="status" property="status" jdbcType="INTEGER"/>
- <result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
- <result column="create_by" property="createBy" jdbcType="VARCHAR"/>
- <result column="update_date" property="updateDate" jdbcType="TIMESTAMP"/>
- <result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
- <result column="channel_desc" property="channelDesc" jdbcType="VARCHAR"/>
- <result column="icon" property="icon" jdbcType="VARCHAR"/>
- <result column="sort" property="sort" jdbcType="INTEGER"/>
- </resultMap>
- <!--auto generated Code-->
- <sql id="Base_Column_List">
- id,
- parent_id,
- channel_name,
- channel_code,
- status,
- create_date,
- create_by,
- update_date,
- update_by,
- channel_desc,
- icon,
- sort
- </sql>
- <!--auto generated Code-->
- <insert id="insert" useGeneratedKeys="true" keyProperty="channel.id">
- INSERT INTO sc_channel (
- id,
- parent_id,
- channel_name,
- status,
- create_date,
- create_by,
- update_date,
- update_by,
- channel_desc,
- channel_code,
- icon,
- sort
- ) VALUES (
- #{channel.id,jdbcType=INTEGER},
- #{channel.parentId,jdbcType=INTEGER},
- #{channel.channelName,jdbcType=VARCHAR},
- #{channel.status,jdbcType=INTEGER},
- #{channel.createDate,jdbcType=TIMESTAMP},
- #{channel.createBy,jdbcType=VARCHAR},
- #{channel.updateDate,jdbcType=TIMESTAMP},
- #{channel.updateBy,jdbcType=VARCHAR},
- #{channel.channelDesc,jdbcType=VARCHAR},
- #{channel.channelCode,jdbcType=VARCHAR},
- #{channel.icon,jdbcType=VARCHAR},
- #{channel.sort,jdbcType=INTEGER}
- )
- </insert>
- <!--auto generated Code-->
- <insert id="insertSelective" useGeneratedKeys="true" keyProperty="channel.id">
- INSERT INTO sc_channel
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="channel.id!=null"> id,</if>
- <if test="channel.parentId!=null"> parent_id,</if>
- <if test="channel.channelName!=null"> channel_name,</if>
- <if test="channel.status!=null"> status,</if>
- <if test="channel.createDate!=null"> create_date,</if>
- <if test="channel.createBy!=null"> create_by,</if>
- <if test="channel.updateDate!=null"> update_date,</if>
- <if test="channel.updateBy!=null"> update_by,</if>
- <if test="channel.channelDesc!=null"> channel_desc,</if>
- <if test="channel.channelCode!=null"> channel_code,</if>
- <if test="channel.icon!=null"> icon,</if>
- <if test="channel.sort!=null"> sort</if>
- </trim>
- VALUES
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="channel.id!=null"> #{channel.id,jdbcType=INTEGER},</if>
- <if test="channel.parentId!=null"> #{channel.parentId,jdbcType=INTEGER},</if>
- <if test="channel.channelName!=null"> #{channel.channelName,jdbcType=VARCHAR},</if>
- <if test="channel.status!=null"> #{channel.status,jdbcType=INTEGER},</if>
- <if test="channel.createDate!=null"> #{channel.createDate,jdbcType=TIMESTAMP},</if>
- <if test="channel.createBy!=null"> #{channel.createBy,jdbcType=VARCHAR},</if>
- <if test="channel.updateDate!=null"> #{channel.updateDate,jdbcType=TIMESTAMP},</if>
- <if test="channel.updateBy!=null"> #{channel.updateBy,jdbcType=VARCHAR},</if>
- <if test="channel.channelDesc!=null"> #{channel.channelDesc,jdbcType=VARCHAR},</if>
- <if test="channel.channelCode!=null"> #{channel.channelCode,jdbcType=VARCHAR},</if>
- <if test="channel.icon!=null"> #{channel.icon,jdbcType=VARCHAR},</if>
- <if test="channel.sort!=null"> #{channel.sort,jdbcType=INTEGER}</if>
- </trim>
- </insert>
- <!--auto generated Code-->
- <insert id="insertList">
- INSERT INTO sc_channel(
- id,
- parent_id,
- channel_name,
- status,
- create_date,
- create_by,
- update_date,
- update_by,
- channel_desc,
- channel_code,
- icon,
- sort
- )VALUES
- <foreach collection="channels" item="channel" index="index" separator=",">
- (
- #{channel.id,jdbcType=INTEGER},
- #{channel.parentId,jdbcType=INTEGER},
- #{channel.channelName,jdbcType=VARCHAR},
- #{channel.status,jdbcType=INTEGER},
- #{channel.createDate,jdbcType=TIMESTAMP},
- #{channel.createBy,jdbcType=VARCHAR},
- #{channel.updateDate,jdbcType=TIMESTAMP},
- #{channel.updateBy,jdbcType=VARCHAR},
- #{channel.channelDesc,jdbcType=VARCHAR},
- #{channel.channelCode,jdbcType=VARCHAR},
- #{channel.icon,jdbcType=VARCHAR},
- #{channel.sort,jdbcType=INTEGER}
- )
- </foreach>
- </insert>
- <!--auto generated Code-->
- <update id="updateByPrimaryKeySelective">
- UPDATE sc_channel
- <set>
- <if test="channel.id != null"> id = #{channel.id,jdbcType=INTEGER},</if>
- <if test="channel.parentId != null"> parent_id = #{channel.parentId,jdbcType=INTEGER},</if>
- <if test="channel.channelName != null"> channel_name = #{channel.channelName,jdbcType=VARCHAR},</if>
- <if test="channel.status != null"> status = #{channel.status,jdbcType=INTEGER},</if>
- <if test="channel.createDate != null"> create_date = #{channel.createDate,jdbcType=TIMESTAMP},</if>
- <if test="channel.createBy != null"> create_by = #{channel.createBy,jdbcType=VARCHAR},</if>
- <if test="channel.updateDate != null"> update_date = #{channel.updateDate,jdbcType=TIMESTAMP},</if>
- <if test="channel.updateBy != null"> update_by = #{channel.updateBy,jdbcType=VARCHAR},</if>
- <if test="channel.channelDesc != null"> channel_desc = #{channel.channelDesc,jdbcType=VARCHAR},</if>
- <if test="channel.channelCode != null"> channel_code = #{channel.channelCode,jdbcType=VARCHAR},</if>
- <if test="channel.icon != null"> icon = #{channel.icon,jdbcType=VARCHAR},</if>
- <if test="channel.sort != null"> sort = #{channel.sort,jdbcType=INTEGER}</if>
- </set>
- WHERE id = #{channel.id,jdbcType=INTEGER}
- </update>
- <select id="getList" resultType="com.bz.smart_city.dto.ChannelDeviceCountDto">
- SELECT
- sc.* ,
- IF(smt.id is null,0,1) is_water_channel
- FROM
- sc_channel sc left join sc_w_meter_type smt on (sc.id = smt.channel_id)
- WHERE
- sc.STATUS = 1
- AND sc.parent_id != 0
- ORDER BY
- sc.sort ASC
- </select>
- <select id="getListByIds" resultType="com.bz.smart_city.dto.ChannelDeviceCountDto">
- select
- distinct sc.*,
- IF(smt.id is null,0,1) is_water_channel
- from sc_channel sc left join sc_w_meter_type smt on (sc.id = smt.channel_id)
- where sc.status = 1 and sc.parent_id != 0
- <if test="channelList != null and channelList.size() != 0">
- and sc.id in <foreach collection="channelList" item="item" open="(" separator="," close=")">#{item.id}</foreach>
- </if>
- order by sc.sort asc
- </select>
- <select id="getChanelCountDeviceNum" resultType="com.bz.smart_city.dto.ChannelDeviceCountDto">
- select
- sc.id,
- sc.parent_id,
- sc.channel_name,
- (
- SELECT count(1) FROM sc_device sd
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
- WHERE sd.status=1 and sd.sys_id = sc.id
- <if test="siteId != null"> and sd.site_id = #{siteId} </if>
- <if test="buildingId != null"> and sd.building_id = #{buildingId} </if>
- <if test="deviceStatus != null">AND sd.device_status = #{deviceStatus} </if>
- <if test="deviceNo != null and deviceNo != ''"> AND sd.device_no LIKE concat('%',#{deviceNo},'%')</if>
- <if test="deviceTypeId != null"> AND sd.device_type = #{deviceTypeId} </if>
- <if test="locDesc != null and locDesc != ''"> AND sd.loc_desc LIKE concat('%',#{locDesc},'%')</if>
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- ) as num
- from sc_channel sc where sc.status = 1 and sc.parent_id != 0
- <if test="channelList != null and channelList.size() != 0">
- and sc.id in <foreach collection="channelList" item="item" open="(" separator="," close=")">#{item.id}</foreach>
- </if>
- order by sc.sort asc
- </select>
- <select id="getChanelCountErrorNum" resultType="com.bz.smart_city.dto.ChannelDeviceCountDto">
- select
- sc.id,
- sc.parent_id,
- sc.channel_name,
- (
- SELECT count(1) FROM sc_device_error sde
- left join sc_device sd on sd.id = sde.device_id and sd.status = 1
- left join sc_building sb on(sb.id = sde.building_id and sb.status = 1)
- <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sde.device_id and sdd.status = 1)</if>
- WHERE sde.status = 1 and sde.sys_id=sc.id
- <if test="siteId != null"> and sde.site_id=#{siteId} </if>
- <if test="buildingId != null"> and sde.building_id=#{buildingId} </if>
- <if test="deviceNo != null and deviceNo != ''"> AND sde.device_no LIKE concat('%',#{deviceNo},'%')</if>
- <if test="alarmCategory != null"> AND sde.alarm_category = #{alarmCategory} </if>
- <if test="handleStatus != null"> AND sde.handle_status = #{handleStatus} </if>
- <if test="deviceTypeId != null"> AND sd.device_type = #{deviceTypeId} </if>
- <if test="location != null and location != ''"> and sde.location LIKE concat('%',#{location},'%')</if>
- <if test="startDate != null"> and sde.alarm_time <![CDATA[ >= ]]> #{startDate}</if>
- <if test="endDate != null"> and sde.alarm_time <![CDATA[ <= ]]> #{endDate}</if>
- <if test="programItems != null and programItems.size() != 0"> and
- <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
- sdd.${item.dimensionCode} = #{item.dimensionValue}
- </foreach>
- </if>
- ) as num
- from sc_channel sc where sc.status = 1 and sc.parent_id != 0
- <if test="channelList != null and channelList.size() != 0">
- and sc.id in <foreach collection="channelList" item="item" open="(" separator="," close=")">#{item.id}</foreach>
- </if>
- order by sc.sort asc
- </select>
- <select id="getSelect" resultType="com.bz.smart_city.dto.ChannelDto">
- select sc.*,if(isnull(ssc.id),0,1) AS isSelected from sc_channel sc
- left join sc_site_channel ssc on ssc.channel_id = sc.id AND ssc.site_id = #{siteId} AND ssc.status=1
- WHERE sc.status = 1 order by sc.sort asc
- </select>
- <select id="getChannelBySiteId" resultType="java.lang.Integer">
- select channel_id from sc_site_channel where status = 1 and site_id = #{siteId}
- </select>
- <select id="findList" resultMap="lazyLoadDeviceTypeId">
- select <include refid="Base_Column_List"/> from sc_channel
- where status = 1 and parent_id = 1
- <if test="name != null and name != ''"> AND channel_name LIKE concat('%',#{name},'%') </if>
- order by create_date desc
- </select>
- <resultMap id="lazyLoadDeviceTypeId" type="com.bz.smart_city.dto.ChannelDto" extends="BaseResultMap">
- <collection property="deviceTypeIds" ofType="java.lang.Integer" select="com.bz.smart_city.dao.ChannelDeviceTypeUseMapper.findDeviceTypeByChannelId"
- column="id"></collection>
- </resultMap>
- <select id="findByNameUnique" resultType="int">
- select count(1) from sc_channel
- where status = 1 and channel_name = #{channelName}
- <if test="id != null"> and id != #{id}</if>
- </select>
- <select id="findById" resultMap="BaseResultMap">
- select <include refid="Base_Column_List"/> from sc_channel
- where status = 1 and id = #{sysId}
- </select>
- <select id="getUserChannelList" resultMap="BaseResultMap">
- SELECT
- sc.*
- FROM
- sc_channel sc
- WHERE
- sc.id IN (
- SELECT
- sp.sys_id
- FROM
- sc_role_permission srp
- RIGHT JOIN sc_permission sp ON sp.id = srp.pid
- WHERE
- srp.rid IN (
- SELECT
- sur.rid
- FROM
- sc_user_role sur
- LEFT JOIN sc_user su ON su.id = sur.uid
- LEFT JOIN sc_role sr ON sr.id = sur.rid
- WHERE
- sur.uid = #{userId}
- AND su.STATUS = 1
- AND sur.STATUS = 1
- <if test="siteId != null"> and sr.site_id=#{siteId} </if>
- )
- AND is_menu = 1
- AND srp.STATUS = 1
- AND sp.STATUS = 1
- AND sp.sys_id IS NOT NULL
- GROUP BY
- sp.sys_id
- )
- </select>
- <select id="getChannelListBySiteId" resultMap="BaseResultMap">
- select sc.id,sc.parent_id,sc.channel_name from sc_site_channel ssc
- left join sc_channel sc on(sc.id = ssc.channel_id)
- where ssc.status = 1 and sc.status = 1 and ssc.site_id = #{siteId}
- </select>
- <select id="getChannelList" resultMap="BaseResultMap">
- select
- sc.*
- from sc_channel sc where sc.status = 1 and sc.parent_id != 0 order by sc.sort asc
- </select>
- <!--多个站点的场景ID-->
- <select id="getChannelIdsByMultiSite" resultType="java.lang.Integer">
- select sc.id,sc.parent_id,sc.channel_name from sc_site_channel ssc
- left join sc_channel sc on(sc.id = ssc.channel_id)
- where ssc.status = 1 and sc.status = 1
- <if test="siteIds != null and siteIds.size() != 0"> and ssc.site_id in <foreach collection="siteIds" item="item" open="(" separator="," close=")">#{item}</foreach></if>
- GROUP BY sc.id,sc.parent_id,sc.channel_name
- </select>
- <select id="getOptionChanelList" resultType="com.bz.smart_city.dto.ChannelDto">
- select sc.id,sc.parent_id,sc.channel_name,sc.channel_code,if((select count(1) from sc_permission where status = 1 and sys_id = sc.id)>0,1,0) AS isSelected from sc_channel sc
- where sc.status = 1 and sc.parent_id = 1
- </select>
- <select id="findChannelByCode" resultType="com.bz.smart_city.dto.ChannelDto">
- select
- <include refid="Base_Column_List" />
- from
- sc_channel
- where status = 1
- and channel_code = #{channelCode}
- </select>
- <select id="getWaterChanelList" resultType="com.bz.smart_city.dto.ChannelDeviceCountDto">
- select
- distinct sc.*,
- IF(smt.id is null,0,1) is_water_channel
- from sc_channel sc left join sc_w_meter_type smt on (sc.id = smt.channel_id)
- where sc.status = 1 and sc.parent_id != 0
- and smt.level= 2
- order by sc.sort asc
- </select>
- </mapper>
|