|
@@ -49,7 +49,7 @@
|
|
|
s.scene_type_name as "sceneTypeName"
|
|
|
</sql>
|
|
|
<sql id="deviceJoins">
|
|
|
- left join sms_scene_type s on s.id =a.scene_type_id
|
|
|
+ left join sms_scene_type s on s.id =a.scene_type_id and s.status=1
|
|
|
</sql>
|
|
|
<!-- 根据主键获取实体 -->
|
|
|
<select id="findSceneById" resultType="com.huaxu.entity.SceneEntity">
|
|
@@ -221,4 +221,43 @@
|
|
|
</where>
|
|
|
order by a.date_create desc
|
|
|
</select>
|
|
|
+ <!--一级场景查询-->
|
|
|
+ <select id="selectByTypeName" resultType="com.huaxu.entity.SceneEntity">
|
|
|
+ SELECT
|
|
|
+ <include refid="sceneColumns"/>
|
|
|
+ FROM sms_scene a
|
|
|
+ <include refid="deviceJoins"/>
|
|
|
+ <where>
|
|
|
+ a.parent_scene_id=0 and a.status=1 and s.scene_type_name=#{scene.sceneTypeName}
|
|
|
+ <if test="scene.tenantId != null and scene.tenantId != ''">and a.tenant_id = #{scene.tenantId}</if>
|
|
|
+ <if test="scene.userType!=null and scene.userType!=-999 and scene.userType!=-9999 and scene.programItems != null and scene.programItems.size() > 0">
|
|
|
+ <if test="scene.permissonType == 5 or scene.permissonType == 2">
|
|
|
+ and ( a.DEPT_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ or
|
|
|
+ a.COMPANY_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="scene.permissonType == 4 or scene.permissonType == 3">
|
|
|
+ and a.DEPT_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="scene.permissonType == 1">
|
|
|
+ and a.COMPANY_ORG_ID in
|
|
|
+ <foreach collection="scene.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ order by a.date_create
|
|
|
+ </select>
|
|
|
</mapper>
|