select c.* from
(
select s.id,s.org_id, s.org_name,s.org_path, s.device_name, dvs.device_name as host_name,
(select group_concat(threshold_code) from iot_device_diagnose_threshold_ch ch where ch.iot_token = s.iot_token
and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code) threshold_codes
from iot_device_info s
inner join iot_device_info dvs on dvs.iot_token = s.iot_token
and dvs.device_product = s.device_product and dvs.device_code = s.host_code
and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
where s.deleted=0 and s.enable=0 and s.device_type = 2
and s.org_id=#{request.orgId}
and s.org_path like CONCAT(#{request.orgPath}, '%')
and s.device_name like CONCAT('%',#{request.deviceName},'%')
order by s.host_code ,cast(s.device_code as signed)
) c where 1=1
and c.threshold_codes is null
and c.threshold_codes is not null
and c.threshold_codes like CONCAT('%',#{request.thresholdCode}, '%')
select count(1) from
(
select s.iot_token,s.device_product,s.host_code dvs,s.device_code channel,
(select group_concat(threshold_code) from iot_device_diagnose_threshold_ch ch where ch.iot_token = s.iot_token
and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code) threshold_codes
from iot_device_info s
inner join iot_device_info dvs on dvs.iot_token = s.iot_token
and dvs.device_product = s.device_product and dvs.device_code = s.host_code
and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
where s.deleted=0 and s.enable=0 and s.device_type = 2
and s.org_id=#{request.orgId}
and s.org_path like CONCAT(#{request.orgPath}, '%')
and s.device_name like CONCAT('%',#{request.deviceName},'%')
order by s.host_code ,cast(s.device_code as signed)
) c where 1=1
and c.threshold_codes is null
and c.threshold_codes is not null
and c.threshold_codes like CONCAT('%',#{request.thresholdCode}, '%')
select c.* from
(
select s.iot_token,s.device_product,s.host_code dvs,s.device_code channel,
(select group_concat(concat(threshold_code,'#',id)) from iot_device_diagnose_threshold_ch ch where ch.iot_token = s.iot_token
and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code) threshold_codes
from iot_device_info s
inner join iot_device_info dvs on dvs.iot_token = s.iot_token
and dvs.device_product = s.device_product and dvs.device_code = s.host_code
and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
where s.deleted=0 and s.enable=0 and s.device_type = 2
and s.org_id=#{request.orgId}
and s.org_path like CONCAT(#{request.orgPath}, '%')
and s.device_name like CONCAT('%',#{request.deviceName},'%')
order by s.host_code ,cast(s.device_code as signed)
) c where 1=1
and c.threshold_codes is null
and c.threshold_codes is not null
and c.threshold_codes like CONCAT('%',#{request.thresholdCode}, '%')
insert into iot_device_diagnose_threshold_ch (id,threshold_code,iot_token,device_product,dvs,channel)
values
(#{item.id},#{item.thresholdCode},#{item.iotToken},#{item.deviceProduct},#{item.dvs}, #{item.channel})
delete from iot_device_diagnose_threshold_ch where id in
#{item}
update iot_device_diagnose_threshold set diagnose_number =
(
select count(1) from iot_device_diagnose_threshold_ch where threshold_code = #{thresholdCode}
)
where threshold_code = #{thresholdCode}
delete from iot_device_diagnose_threshold_ch where threshold_code = #{thresholdCode}
select c.* from
(
select s.id,s.org_id, s.org_name,s.org_path, s.device_name, dvs.device_name as host_name,
(select group_concat(threshold_code) from iot_device_diagnose_threshold_ch ch where ch.iot_token = s.iot_token
and ch.device_product=s.device_product and ch.dvs = s.host_code and ch.channel = s.device_code) threshold_codes
from iot_device_info s
inner join iot_device_info dvs on dvs.iot_token = s.iot_token
and dvs.device_product = s.device_product and dvs.device_code = s.host_code
and dvs.deleted = 0 and s.enable = 0 and dvs.device_type = 1
where s.deleted=0 and s.enable=0 and s.device_type = 2
and s.org_id=#{request.orgId}
and s.org_path like CONCAT(#{request.orgPath}, '%')
and s.device_name like CONCAT('%',#{request.deviceName},'%')
order by s.host_code ,cast(s.device_code as signed)
) c where 1=1
and c.threshold_codes is null
and c.threshold_codes is not null
and c.threshold_codes like CONCAT('%',#{request.thresholdCode}, '%')
select * from iot_device_diagnose_threshold