|
@@ -9,10 +9,81 @@
|
|
|
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.SCENE_TYPE_NAME =#{sceneType}
|
|
|
+ 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">
|
|
@@ -21,11 +92,83 @@
|
|
|
s.COMPANY_ORG_ID
|
|
|
from sms_scene_type st
|
|
|
left join sms_scene s on st.id=s.SCENE_TYPE_ID
|
|
|
- where
|
|
|
- st.SCENE_TYPE_NAME =#{sceneType}
|
|
|
+ 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>
|
|
|
|