select id,
iot_device_id,
group_id,
product_id,
stake_mark,
direction,
device_name,
device_code,
device_type,
installation_Date,
production_date,
durable_years,
installation_site,
use_state,
device_state,
other_config,
remark,
create_time,
update_time,
facilities_type,
device_ip,
stake_mark_range,
network_segment,
device_img,
child_type
from dc_device
insert into dc_door_monitor
id,
stake_mark,
direction,
device_type,
device_name,
operate,
create_time,
iot_device_id,
#{id},
#{stakeMark},
#{direction},
#{deviceType},
#{deviceName},
#{operate},
#{createTime},
#{iotDeviceId},
insert into dc_smoke_record
id,
stake_mark,
direction,
device_type,
device_name,
smoke_value,
create_time,
iot_device_id,
push_time,
#{id},
#{stakeMark},
#{direction},
#{deviceType},
#{deviceName},
#{smokeValue},
#{createTime},
#{iotDeviceId},
#{pushTime},
insert into dc_snmp_alarm
id,
device_name,
content,
create_time,
iot_device_id,
ip,
#{id},
#{deviceName},
#{content},
#{createTime},
#{iotDeviceId},
#{ip},
select t1.id, t1.iot_device_id, t1.group_id, t1.product_id, t1.stake_mark, t1.direction, t1.device_name, t1.device_code, t1.device_type,
t1.installation_Date,t1.production_date,t1.durable_years,t1.installation_site,t1.use_state,t1.device_state,t1.other_config,t1.remark,
t1.create_time,t1.update_time,t1.facilities_type,t1.device_ip,t1.stake_mark_range,t1.network_segment,t1.device_img,t1.child_type,
t1.facilities_type,t1.longitude,t1.latitude,t3.manufacturer
from dc_device t1
left join dc_product t3 on t3.id = t1.product_id
and t1.id = #{id}
and t1.iot_device_id = #{iotDeviceId}
and t1.group_id = #{groupId}
and t1.product_id = #{productId}
and t1.stake_mark = #{stakeMark}
and t1.direction = #{direction}
and t1.device_name like concat('%', #{deviceName}, '%')
and t1.device_code = #{deviceCode}
and t1.device_type = #{deviceType}
and t1.installation_Date = #{installationDate}
and t1.production_date = #{productionDate}
and t1.durable_years = #{durableYears}
and t1.installation_site = #{installationSite}
and t1.use_state = #{useState}
and t1.device_state = #{deviceState}
and json_extract(t1.other_config,'$.childType') = #{otherConfig}
and t1.remark = #{remark}
and t1.create_time = #{createTime}
and t1.update_time = #{updateTime}
and t1.facilities_type = #{facilitiesType}
and t1.device_ip = #{deviceIp}
and t1.stake_mark_range = #{stakeMarkRange}
and t1.network_segment = #{networkSegment}
and t1.device_img = #{deviceImg}
and t1.child_type = #{childType}
SELECT use_state, COALESCE(child_type, device_type) AS device_type, COUNT(*) AS sumAll
FROM dc_device
use_state = #{useState}
GROUP BY device_type, child_type;
select t1.id, t1.iot_device_id, t1.group_id, t1.product_id, t1.stake_mark, t1.direction, t1.device_name,
t1.device_code, t1.device_type,t1.installation_Date,t1.production_date,t1.durable_years,t1.installation_site,
t1.use_state,t1.device_state,t1.other_config,t1.remark,t1.create_time,t1.update_time,t1.facilities_type,
t1.device_ip,t1.stake_mark_range,t1.network_segment,t1.device_img,t1.child_type,t1.facilities_type,t1.longitude,t1.latitude
from dc_device t1
left join (select * from dc_stake_mark GROUP BY stake_mark) t2 on t1.stake_mark = t2.stake_mark
where !ISNULL(t1.iot_device_id) and t1.device_type = '1' and t1.facilities_type = '1' and t1.direction = #{direction}
and t2.mileage >= #{startMileage} and t2.mileage <= #{endMileage}
select t1.id, t1.iot_device_id, t1.group_id, t1.product_id, t1.stake_mark, t1.direction, t1.device_name,
t1.device_code, t1.device_type,t1.installation_Date,t1.production_date,t1.durable_years,t1.installation_site,
t1.use_state,t1.device_state,t1.other_config,t1.remark,t1.create_time,t1.update_time,t1.facilities_type,
t1.device_ip,t1.stake_mark_range,t1.network_segment,t1.device_img,t1.child_type,t1.facilities_type,t2.longitude,t2.latitude
from dc_device t1
left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.direction = t2.direction
where t1.device_type = '2' and t1.direction = #{direction}
and t2.mileage >= #{startMileage} and t2.mileage <= #{endMileage}
SELECT dc_road_section.id,
COUNT(dc_device.stake_mark) as number
FROM
dc_road_section
JOIN dc_stake_mark
ON dc_road_section.id = dc_stake_mark.section_id
JOIN dc_device ON dc_stake_mark.stake_mark = dc_device.stake_mark
GROUP BY
dc_road_section.id;
select iot_device_id deviceId, device_type deviceType,device_name deviceName,device_state deviceState from dc_device
and device_state = #{deviceState}
and device_name like concat('%', #{deviceName}, '%')
and device_type = #{deviceType} and iot_device_id is not null
and (device_type=3||device_type=13||device_type=15||device_type=16||device_type=17) and iot_device_id is not null
select id, device_type deviceType,
property_id propertyId,property_name propertyName,
name from dc_device_attribute
where device_type=#{deviceType}
SELECT
(SELECT COUNT(id) FROM dc_device) +
(SELECT COUNT(id) FROM dc_facility) AS total_count;
select d.id deviceId, r.id roadId,use_state useStata FROM dc_device d
JOIN dc_stake_mark s ON s.stake_mark = d.stake_mark AND s.direction = d.direction
JOIN dc_road_section r ON r.id = s.section_id
select id,iot_device_id from dc_device where facilities_type=5
update dc_device set device_state=#{deviceState} where id=#{id}
select t1.id, t1.iot_device_id, t1.group_id, t1.product_id, t1.stake_mark, t1.direction, t1.device_name,
t1.device_code, t1.device_type,t1.installation_Date,t1.production_date,t1.durable_years,t1.installation_site,
t1.use_state,t1.device_state,t1.other_config,t1.remark,t1.create_time,t1.update_time,t1.facilities_type,
t1.device_ip,t1.stake_mark_range,t1.network_segment,t1.device_img,t1.child_type,t1.facilities_type,t1.longitude,t1.latitude
from dc_device t1
left join (select * from dc_stake_mark GROUP BY stake_mark) t2 on t1.stake_mark = t2.stake_mark
where !ISNULL(t1.iot_device_id) and t1.device_type = '1' and (t1.facilities_type = '5'|| t1.facilities_type = '4')
and t2.mileage >= #{startMileage} and t2.mileage <= #{endMileage}
select device_state from dc_device where iot_device_id=#{iotDeviceId}
select id,device_name,device_type,direction,stake_mark,operate,create_time from dc_door_monitor
and device_name like concat('%', #{deviceName}, '%')
and device_type = #{deviceType}
and stake_mark BETWEEN #{stakeMark} and #{endStakeMark}
and date_format(create_time,'%Y-%m-%d %H:%i:%s') >= date_format(#{startTime},'%Y-%m-%d %H:%i:%s')
and date_format(create_time,'%Y-%m-%d %H:%i:%s') <= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
order by create_time desc
select id,device_name,device_type,direction,stake_mark,operate,create_time from dc_door_monitor as a
INNER JOIN (
SELECT
iot_device_id,
MAX(create_time) AS latest_time
FROM dc_door_monitor
WHERE iot_device_id IN
#{item}
GROUP BY iot_device_id
) b ON a.iot_device_id = b.iot_device_id AND a.create_time = b.latest_time
ORDER BY a.create_time DESC
select id,device_name,device_type,direction,stake_mark,smoke_value,create_time,update_time from dc_smoke_record as a
INNER JOIN (
SELECT
iot_device_id,
MAX(create_time) AS latest_time
FROM dc_smoke_record
WHERE iot_device_id IN
#{item}
GROUP BY iot_device_id
) b ON a.iot_device_id = b.iot_device_id AND a.create_time = b.latest_time
ORDER BY a.create_time DESC
select push_time,device_name from dc_smoke_record
WHERE id = (
SELECT id FROM (
SELECT id
FROM dc_smoke_record
WHERE iot_device_id = #{iotDeviceId}
ORDER BY create_time DESC
LIMIT 1
) AS latest_record
);
select id,device_name,content,create_time,update_time,ip from dc_snmp_alarm as a
INNER JOIN (
SELECT
iot_device_id,
MAX(create_time) AS latest_time
FROM dc_snmp_alarm
WHERE iot_device_id IN
#{item}
GROUP BY iot_device_id
) b ON a.iot_device_id = b.iot_device_id AND a.create_time = b.latest_time
ORDER BY a.create_time DESC
UPDATE dc_smoke_record
smoke_value = #{smokeValue},
update_time = #{updateTime},
push_time = #{pushTime},
WHERE id = (
SELECT id FROM (
SELECT id
FROM dc_smoke_record
WHERE iot_device_id = #{iotDeviceId}
ORDER BY create_time DESC
LIMIT 1
) AS latest_record
);
UPDATE dc_snmp_alarm
content = #{content},
update_time = #{updateTime},
WHERE id = (
SELECT id FROM (
SELECT id
FROM dc_snmp_alarm
WHERE iot_device_id = #{iotDeviceId}
ORDER BY create_time DESC
LIMIT 1
) AS latest_record
);