|
@@ -22,9 +22,31 @@
|
|
|
,d.CREATE_BY as "createBy"
|
|
|
,d.DATE_UPDATE as "dateUpdate"
|
|
|
,d.UPDATE_BY as "updateBy"
|
|
|
-
|
|
|
- ,s.SCENE_NAME as "sceneName"
|
|
|
-
|
|
|
+ ,t.MANUFACTURER_NAME as "manufacturerName"
|
|
|
+ ,t.MANUFACTURER_ID as "manufacturerId"
|
|
|
+ ,t.DEVICE_TYPE as "deviceType"
|
|
|
+ ,t.DEVICE_MODE as "deviceMode"
|
|
|
+ </sql>
|
|
|
+ <sql id="Base_Column_SceneList">
|
|
|
+ d.id
|
|
|
+ ,d.TENANT_ID as "tenantId"
|
|
|
+ ,d.DEVICE_CODE as "deviceCode"
|
|
|
+ ,d.DEVICE_NAME as "deviceName"
|
|
|
+ ,d.DEVICE_TYPE_ID as "deviceTypeId"
|
|
|
+ ,d.COMPANY_ORG_ID as "companyOrgId"
|
|
|
+ ,d.DEPT_ORG_ID as "deptOrgId"
|
|
|
+ ,d.SCENE_ID as "sceneId"
|
|
|
+ ,d.POINT_X as "pointX"
|
|
|
+ ,d.POINT_Y as "pointY"
|
|
|
+ ,d.ENABLE_STATE as "enableState"
|
|
|
+ ,d.LAST_UPDATE_TIME as "lastUpdateTime"
|
|
|
+ ,d.ADDRESS as "address"
|
|
|
+ ,d.REMARK as "remark"
|
|
|
+ ,d.`STATUS` as "status"
|
|
|
+ ,d.DATE_CREATE as "dateCreate"
|
|
|
+ ,d.CREATE_BY as "createBy"
|
|
|
+ ,d.DATE_UPDATE as "dateUpdate"
|
|
|
+ ,d.UPDATE_BY as "updateBy"
|
|
|
,t.MANUFACTURER_NAME as "manufacturerName"
|
|
|
,t.MANUFACTURER_ID as "manufacturerId"
|
|
|
,t.DEVICE_TYPE as "deviceType"
|
|
@@ -32,7 +54,6 @@
|
|
|
</sql>
|
|
|
|
|
|
<sql id="deviceJoins">
|
|
|
- left join sms_scene s on d.SCENE_ID =s.id
|
|
|
left join sms_device_type t on d.DEVICE_TYPE_ID = t.id
|
|
|
</sql>
|
|
|
<select id="selectById" resultType="com.huaxu.dto.DeviceDto">
|
|
@@ -74,12 +95,6 @@
|
|
|
<if test="deviceDto.deptOrgId != null and deviceDto.deptOrgId != 0 ">
|
|
|
and d.DEPT_ORG_ID =#{deviceDto.deptOrgId}
|
|
|
</if>
|
|
|
- <if test="deviceDto.sceneIds != null and deviceDto.sceneIds.size() > 0">
|
|
|
- and d.SCENE_ID in
|
|
|
- <foreach collection="deviceDto.sceneIds" item="item" open="(" close=")" separator=",">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
<if test="deviceDto.enableState != null ">
|
|
|
and d.ENABLE_STATE =#{deviceDto.enableState}
|
|
|
</if>
|
|
@@ -113,7 +128,82 @@
|
|
|
</if>
|
|
|
|
|
|
</select>
|
|
|
+ <!--通过实体作为筛选条件查询-->
|
|
|
+ <select id="selectListByScene" resultType="com.huaxu.dto.DeviceDto">
|
|
|
+ select
|
|
|
+ d.id
|
|
|
+ ,d.TENANT_ID as "tenantId"
|
|
|
+ ,d.DEVICE_CODE as "deviceCode"
|
|
|
+ ,d.DEVICE_NAME as "deviceName"
|
|
|
+ ,d.DEVICE_TYPE_ID as "deviceTypeId"
|
|
|
+ ,d.COMPANY_ORG_ID as "companyOrgId"
|
|
|
+ ,d.DEPT_ORG_ID as "deptOrgId"
|
|
|
+ ,d.SCENE_ID as "sceneId"
|
|
|
+ ,d.POINT_X as "pointX"
|
|
|
+ ,d.POINT_Y as "pointY"
|
|
|
+ ,d.ENABLE_STATE as "enableState"
|
|
|
+ ,d.LAST_UPDATE_TIME as "lastUpdateTime"
|
|
|
+ ,d.ADDRESS as "address"
|
|
|
+ ,d.REMARK as "remark"
|
|
|
+ ,d.`STATUS` as "status"
|
|
|
+ ,d.DATE_CREATE as "dateCreate"
|
|
|
+ ,d.CREATE_BY as "createBy"
|
|
|
+ ,d.DATE_UPDATE as "dateUpdate"
|
|
|
+ ,d.UPDATE_BY as "updateBy"
|
|
|
+ ,t.MANUFACTURER_NAME as "manufacturerName"
|
|
|
+ ,t.MANUFACTURER_ID as "manufacturerId"
|
|
|
+ ,t.DEVICE_TYPE as "deviceType"
|
|
|
+ ,t.DEVICE_MODE as "deviceMode"
|
|
|
+ ,case when s.ID is null then 0 else 1 end as "isCheck"
|
|
|
+ from sms_device d
|
|
|
+ left join sms_device_type t on d.DEVICE_TYPE_ID = t.id
|
|
|
+ left join sms_device_scene s on s.DEVICE_ID=d.ID and d.SCENE_ID=#{deviceDto.sceneId}
|
|
|
+ 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>
|
|
|
<!-- 新增所有列 -->
|
|
|
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
|
|
INSERT INTO sms_device ( TENANT_ID , DEVICE_CODE , DEVICE_NAME , DEVICE_TYPE_ID ,
|