提交修改

This commit is contained in:
LEED
2025-03-27 17:15:27 +08:00
parent 6a8cbff440
commit 988e68bdc7
47 changed files with 1051 additions and 255 deletions

View File

@@ -358,6 +358,7 @@
group by d.device_id,d.tenant_id
</select>
<select id="selectSerialNumberByProductId" parameterType="Long" resultType="String">
select serial_number
from iot_device
@@ -394,7 +395,7 @@
where device_id = #{deviceId}
</update>
<select id="selectDeviceShortList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">
<select id="selectDeviceGShortList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">
select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,
d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code,
d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,
@@ -413,7 +414,7 @@
<if test="groupId != null and groupId !=0 ">left join iot_device_group g on g.device_id=d.device_id</if>
<where>
and d.gw_dev_code is null and d.del_flag = '0'
<if test="groupId != null and groupId !=0 ">and d.group_id = #{groupId}</if>
<!-- <if test="groupId != null and groupId !=0 ">and d.group_id = #{groupId}</if>-->
<if test="deviceName != null and deviceName != ''">and d.device_name like concat('%', #{deviceName}, '%')
</if>
<if test="productId != null ">and d.product_id = #{productId}</if>
@@ -425,10 +426,11 @@
<if test="gwDevCode != null and gwDevCode != ''">and d.gw_dev_code = #{gwDevCode}</if>
<if test="status != null ">and d.status = #{status}</if>
<if test="isSimulate != null">and d.is_simulate = #{isSimulate}</if>
<if test="agenciesId == null">and d.agencies_id IS NULL</if>
<if test="agenciesId != null">and d.agencies_id = #{agenciesId}</if>
<!-- <if test="groupIdExclude != null">and d.group_id != #{groupIdExclude}</if>-->
<if test="groupIdExclude != null">and d.group_id != #{groupIdExclude}</if>
<if test="deptId != null and deptId != 0 and showChild != null and showChild">
<if test="deptId != null and deptId != 0 and showChild != null and showChild ">
and
( d.tenant_id in (SELECT u.user_id FROM sys_user u
join sys_dept de on u.dept_id = de.dept_id
@@ -450,6 +452,94 @@
order by d.create_time desc
</select>
<!-- <select id="selectDeviceShortList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">-->
<!-- select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,-->
<!-- d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code,-->
<!-- d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,-->
<!-- d.things_model_value, d.active_time,d.create_time, if(null = d.img_url or '' = d.img_url, p.img_url, d.img_url) as img_url,-->
<!-- case-->
<!-- when (select count(*) from iot_device_share du where du.device_id = d.device_id and du.user_id = #{tenantId}) then 0-->
<!-- else 1-->
<!-- end as is_owner,-->
<!-- (select count(*) from iot_device d1 where d1.gw_dev_code = d.serial_number) as sub_device_count,-->
<!-- p.protocol_code,p.transport,p.guid-->
<!-- from iot_device d-->
<!-- left join iot_product p on p.product_id=d.product_id-->
<!-- <if test="groupId != null and groupId !=0 "> left join iot_device_group g on g.device_id=d.device_id </if>-->
<!-- <where>-->
<!-- and d.del_flag = '0'-->
<!-- <if test="groupId != null and groupId !=0 "> and g.group_id = #{groupId}</if>-->
<!-- <if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>-->
<!-- <if test="productId != null "> and d.product_id = #{productId}</if>-->
<!-- <if test="deviceType != null "> and p.device_type = #{deviceType}</if>-->
<!-- <if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>-->
<!-- <if test="serialNumber != null and serialNumber != ''"> and d.serial_number = #{serialNumber}</if>-->
<!-- <if test="gwDevCode != null and gwDevCode != ''"> and d.gw_dev_code = #{gwDevCode}</if>-->
<!-- <if test="status != null "> and d.status = #{status}</if>-->
<!-- <if test="isSimulate != null">and d.is_simulate = #{isSimulate}</if>-->
<!--&lt;!&ndash; <if test="deptId != null and deptId != 0 and showChild != null and showChild">&ndash;&gt;-->
<!-- <if test="deptId != null and deptId != 0 ">-->
<!-- and-->
<!-- ( d.agencies_id in (SELECT u.dept_id FROM sys_user u-->
<!-- join sys_dept de on u.dept_id = de.dept_id-->
<!-- WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})-->
<!-- )-->
<!-- </if>-->
<!--&lt;!&ndash; <if test="deptId != null and deptId != 0 and showChild != null and !showChild">&ndash;&gt;-->
<!--&lt;!&ndash; and (&ndash;&gt;-->
<!--&lt;!&ndash; d.tenant_id = (SELECT dept_user_id FROM sys_dept WHERE dept_id = #{deptId})&ndash;&gt;-->
<!--&lt;!&ndash; or d.device_id in (select du.device_id from iot_device_share du where du.user_id = #{tenantId})&ndash;&gt;-->
<!--&lt;!&ndash; )&ndash;&gt;-->
<!--&lt;!&ndash; </if>&ndash;&gt;-->
<!-- <if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>-->
<!-- </where>-->
<!-- group by d.device_id,d.tenant_id-->
<!-- order by d.create_time desc-->
<!-- </select>-->
<select id="selectDeviceShortList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">
select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,
d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code,
d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,
d.things_model_value, d.active_time,d.create_time, if(null = d.img_url or '' = d.img_url, p.img_url, d.img_url) as img_url,
case
when (select count(*) from iot_device_share du where du.device_id = d.device_id and du.user_id = #{tenantId}) then 0
else 1
end as is_owner,
(select count(*) from iot_device d1 where d1.gw_dev_code = d.serial_number) as sub_device_count,
p.protocol_code,p.transport,p.guid
from iot_device d
left join iot_product p on p.product_id=d.product_id
<if test="groupId != null and groupId !=0 "> left join iot_device_group g on g.device_id=d.device_id </if>
<where>
and d.del_flag = '0'
<if test="groupId != null and groupId !=0 "> and g.group_id = #{groupId}</if>
<if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>
<if test="productId != null "> and d.product_id = #{productId}</if>
<if test="deviceType != null "> and p.device_type = #{deviceType}</if>
<if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>
<if test="serialNumber != null and serialNumber != ''"> and d.serial_number = #{serialNumber}</if>
<if test="gwDevCode != null and gwDevCode != ''"> and d.gw_dev_code = #{gwDevCode}</if>
<if test="status != null "> and d.status = #{status}</if>
<if test="isSimulate != null">and d.is_simulate = #{isSimulate}</if>
<if test="deptId != null and deptId != 0 ">
and
( d.agencies_id in (SELECT de.dept_id FROM sys_dept de
WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})
)
</if>
<!-- <if test="deptId != null and deptId != 0 and showChild != null and !showChild">-->
<!-- and (-->
<!-- d.agencies_id = (SELECT dept_user_id FROM sys_dept WHERE dept_id = #{deptId})-->
<!-- or d.device_id in (select du.device_id from iot_device_share du where du.user_id = #{tenantId})-->
<!-- )-->
<!-- </if>-->
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
</where>
group by d.device_id,d.tenant_id
order by d.create_time desc
</select>
<select id="selectDeviceByDeviceId" parameterType="Long" resultMap="DeviceResult">
select d.device_id,
d.device_name,
@@ -502,6 +592,7 @@
(select count(distinct d.device_id,d.tenant_id)
from iot_device d
<where>
d.del_flag = '0'
<if test="deptId != null and deptId != 0">
and d.tenant_id in (SELECT u.user_id FROM sys_user u
join sys_dept de on u.dept_id = de.dept_id