|
@@ -119,6 +119,97 @@
|
|
|
</if>
|
|
|
</if>
|
|
|
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--通过实体作为筛选条件查询-->
|
|
|
+ <select id="selectListForReport" resultType="com.huaxu.dto.DeviceDto">
|
|
|
+ select
|
|
|
+ distinct
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ <if test="deviceDto.sceneId!= null and deviceDto.sceneId != 0 ">
|
|
|
+ ,s.PARENT_SCENE_ID as "parentSceneId"
|
|
|
+ ,s.SCENE_ID as "sceneId"
|
|
|
+ </if>
|
|
|
+ from sms_device d
|
|
|
+ left join sms_device_type t on d.DEVICE_TYPE_ID = t.id
|
|
|
+
|
|
|
+ <if test="deviceDto.sceneId!= null and deviceDto.sceneId != 0 ">
|
|
|
+ <if test="deviceDto.searchType == null or deviceDto.searchType == 0 ">
|
|
|
+ inner join sms_device_scene s on s.DEVICE_ID=d.ID and (s.SCENE_ID=#{deviceDto.sceneId} or s.parent_scene_id = #{deviceDto.sceneId}) and s.status=1
|
|
|
+ </if>
|
|
|
+ <if test="deviceDto.searchType != null and deviceDto.searchType == 1 ">
|
|
|
+ inner join sms_device_scene s on s.DEVICE_ID=d.ID and s.SCENE_ID=#{deviceDto.sceneId} and s.status=1
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ <if test="deviceDto.sceneIds!= null and deviceDto.sceneIds.size()>0 ">
|
|
|
+ inner join sms_device_scene s on s.DEVICE_ID=d.ID and s.status=1 and s.SCENE_ID in
|
|
|
+ <foreach collection="deviceDto.sceneIds" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ inner join sms_device_parm dp on dp.DEVICE_ID=d.id and dp.`STATUS`=1
|
|
|
+ <if test="deviceDto.tenantId != null and deviceDto.tenantId != '' ">
|
|
|
+ and dp.TENANT_ID= #{deviceDto.tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="deviceDto.sceneIds!= null and deviceDto.sceneIds.size()>0 ">
|
|
|
+ and dp.SCENE_ID in
|
|
|
+ <foreach collection="deviceDto.sceneIds" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ inner join sms_report_dimension_setting rds on rds.device_parm_id=dp.id and rds.type=1
|
|
|
+ <if test="deviceDto.tenantId != null and deviceDto.tenantId != '' ">
|
|
|
+ and rds.user_id= #{deviceDto.userId}
|
|
|
+ </if>
|
|
|
+ <if test="deviceDto.tenantId != null and deviceDto.tenantId != '' ">
|
|
|
+ and rds.tenant_id = #{deviceDto.tenantId}
|
|
|
+ </if>
|
|
|
+ and rds.show_on_off=1
|
|
|
+ where d.status = 1
|
|
|
+ <if test="deviceDto.tenantId != null and deviceDto.tenantId != '' ">
|
|
|
+ and d.tenant_id = #{deviceDto.tenantId}
|
|
|
+ </if>
|
|
|
+ <if test="deviceDto.condition != null and deviceDto.condition != ''">
|
|
|
+ and (device_code like concat('%', #{deviceDto.condition},'%') or device_name like concat('%', #{deviceDto.condition},'%'))
|
|
|
+ </if>
|
|
|
+ <if test="deviceDto.companyOrgId != null and deviceDto.companyOrgId != 0 ">
|
|
|
+ and d.COMPANY_ORG_ID=#{deviceDto.companyOrgId}
|
|
|
+ </if>
|
|
|
+ <if test="deviceDto.deptOrgId != null and deviceDto.deptOrgId != 0 ">
|
|
|
+ and d.DEPT_ORG_ID =#{deviceDto.deptOrgId}
|
|
|
+ </if>
|
|
|
+ <if test="deviceDto.enableState != null ">
|
|
|
+ and d.ENABLE_STATE =#{deviceDto.enableState}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="deviceDto.userType!=null and deviceDto.userType!=-999 and deviceDto.userType!=-9999 and deviceDto.programItems != null and deviceDto.programItems.size() > 0">
|
|
|
+ <if test="deviceDto.permissonType == 5 or deviceDto.permissonType == 2">
|
|
|
+ and ( d.DEPT_ORG_ID in
|
|
|
+ <foreach collection="deviceDto.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ or
|
|
|
+ d.COMPANY_ORG_ID in
|
|
|
+ <foreach collection="deviceDto.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test="deviceDto.permissonType == 4 or deviceDto.permissonType == 3">
|
|
|
+ and d.DEPT_ORG_ID in
|
|
|
+ <foreach collection="deviceDto.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="deviceDto.permissonType == 1">
|
|
|
+ and d.COMPANY_ORG_ID in
|
|
|
+ <foreach collection="deviceDto.programItems" item="item" open="(" close=")" separator=",">
|
|
|
+ #{item.orgId}
|
|
|
+ </foreach>
|
|
|
+ and (d.DEPT_ORG_ID is null or d.DEPT_ORG_ID =0)
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+
|
|
|
</select>
|
|
|
<select id="selectListBySceneId" resultType="com.huaxu.dto.DeviceDto">
|
|
|
select
|