123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <?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.huaxu.dao.AppReportMonitorMapper">
- <select id="getSceneByCompany" resultType="com.huaxu.entity.SceneEntity">
- select
- s.id,
- s.SCENE_NAME as "sceneName",
- s.PARENT_SCENE_ID as "parentSceneId"
- from sms_scene_type st
- left join sms_scene s on st.id=s.SCENE_TYPE_ID
- where st.STATUS = 1 and s.STATUS = 1
- and st.SCENE_TYPE_NAME =#{sceneType}
- and s.COMPANY_ORG_ID = #{companyOrgId}
- and s.TENANT_ID = #{tenantId}
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2">
- and ( s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- or
- s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- )
- </if>
- <if test="permissonType == 4 or permissonType == 3">
- and s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- <if test="permissonType == 1">
- and s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
- </if>
- </if>
- order by s.SCENE_NAME
- </select>
- <select id="getDeviceByCompany" resultType="com.huaxu.entity.DeviceEntity">
- select
- d.id
- ,d.DEVICE_CODE as "deviceCode"
- ,d.DEVICE_NAME as "deviceName"
- from sms_scene_type st
- left join sms_scene s on st.id=s.SCENE_TYPE_ID
- left join sms_device_scene ds on ds.SCENE_ID =s.id
- left join sms_device d on d.id=ds.DEVICE_ID
- where st.STATUS = 1 and s.STATUS = 1 and ds.`STATUS` =1 and d.`STATUS` =1 and d.ENABLE_STATE =1
- and st.SCENE_TYPE_NAME = '管网'
- and s.COMPANY_ORG_ID = #{companyOrgId}
- and s.TENANT_ID = #{tenantId}
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2">
- and ( s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- or
- s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- )
- </if>
- <if test="permissonType == 4 or permissonType == 3">
- and s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- <if test="permissonType == 1">
- and s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
- </if>
- </if>
- order by s.SCENE_NAME
- </select>
- <select id="getCompanyBySceneCondition" resultType="java.lang.Integer">
- select
- distinct
- s.COMPANY_ORG_ID
- from sms_scene_type st
- left join sms_scene s on st.id=s.SCENE_TYPE_ID
- where st.STATUS = 1 and s.STATUS = 1
- and st.SCENE_TYPE_NAME =#{sceneType}
- <if test="condition != null and condition !=''">
- and s.SCENE_NAME like concat('%',#{condition},'%')
- </if>
- and s.TENANT_ID = #{tenantId}
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2">
- and ( s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- or
- s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- )
- </if>
- <if test="permissonType == 4 or permissonType == 3">
- and s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- <if test="permissonType == 1">
- and s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
- </if>
- </if>
- </select>
- <select id="getCompanyByDeviceCondition" resultType="java.lang.Integer">
- select
- distinct
- d.COMPANY_ORG_ID
- from sms_scene_type st
- left join sms_scene s on st.id=s.SCENE_TYPE_ID
- left join sms_device_scene ds on ds.SCENE_ID =s.id
- left join sms_device d on d.id=ds.DEVICE_ID
- where st.STATUS = 1 and s.STATUS = 1 and ds.`STATUS` =1 and d.`STATUS` =1 and d.ENABLE_STATE =1
- and st.SCENE_TYPE_NAME ='管网'
- <if test="condition != null and condition !=''">
- and d.DEVICE_NAME like concat('%',#{condition},'%')
- </if>
- and s.TENANT_ID = #{tenantId}
- <if test="userType!=null and userType!=-999 and userType!=-9999 and programItems != null and programItems.size() > 0">
- <if test="permissonType == 5 or permissonType == 2">
- and ( s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- or
- s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- )
- </if>
- <if test="permissonType == 4 or permissonType == 3">
- and s.DEPT_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- </if>
- <if test="permissonType == 1">
- and s.COMPANY_ORG_ID in
- <foreach collection="programItems" item="item" open="(" close=")" separator=",">
- #{item.orgId}
- </foreach>
- and (s.DEPT_ORG_ID is null or s.DEPT_ORG_ID =0)
- </if>
- </if>
- </select>
- </mapper>
|