济菏高速数据中心代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

376 lines
20 KiB

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zc.business.mapper.DcDeviceMapper">
<resultMap type="DcDevice" id="DcDevice">
<result property="id" column="id"/>
<result property="iotDeviceId" column="iot_device_id"/>
<result property="groupId" column="group_id"/>
<result property="productId" column="product_id"/>
<result property="stakeMark" column="stake_mark"/>
<result property="direction" column="direction"/>
<result property="deviceName" column="device_name"/>
<result property="deviceCode" column="device_code"/>
<result property="deviceType" column="device_type"/>
<result property="installationDate" column="installation_Date"/>
<result property="productionDate" column="production_date"/>
<result property="durableYears" column="durable_years"/>
<result property="installationSite" column="installation_site"/>
<result property="useState" column="use_state"/>
<result property="deviceState" column="device_state"/>
<result property="otherConfig" column="other_config"/>
<result property="remark" column="remark"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="facilitiesType" column="facilities_type"/>
<result property="deviceIp" column="device_ip"/>
<result property="stakeMarkRange" column="stake_mark_range"/>
<result property="networkSegment" column="network_segment"/>
<result property="deviceImg" column="device_img"/>
<result property="longitude" column="longitude"/>
<result property="latitude" column="latitude"/>
<result property="childType" column="child_type"/>
<result property="manufacturer" column="manufacturer"/>
</resultMap>
<resultMap id="dcStakeMarkResult" type="dcStakeMark">
<result property="longitude" column="longitude"/>
<result property="latitude" column="latitude"/>
</resultMap>
<sql id="selectDcDeviceVo">
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
</sql>
5 months ago
<insert id="insertDoorMonitor">
insert into dc_door_monitor
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="stakeMark != null and stakeMark != ''">stake_mark,</if>
<if test="direction != null and direction != ''">direction,</if>
<if test="deviceType != null and deviceType != ''">device_type,</if>
<if test="deviceName != null and deviceName != ''">device_name,</if>
<if test="operate != null and operate != ''">operate,</if>
<if test="createTime != null ">create_time,</if>
<if test="iotDeviceId != null and iotDeviceId != ''">iot_device_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="stakeMark != null and stakeMark != ''">#{stakeMark},</if>
<if test="direction != null and direction != ''">#{direction},</if>
<if test="deviceType != null and deviceType != ''">#{deviceType},</if>
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="operate != null and operate != ''">#{operate},</if>
<if test="createTime != null ">#{createTime},</if>
<if test="iotDeviceId != null and iotDeviceId != ''">#{iotDeviceId},</if>
</trim>
</insert>
3 months ago
<insert id="insertSmokeRecord" useGeneratedKeys="true" keyProperty="id">
insert into dc_smoke_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="stakeMark != null and stakeMark != ''">stake_mark,</if>
<if test="direction != null and direction != ''">direction,</if>
<if test="deviceType != null and deviceType != ''">device_type,</if>
<if test="deviceName != null and deviceName != ''">device_name,</if>
<if test="smokeValue != null and smokeValue != ''">smoke_value,</if>
<if test="createTime != null ">create_time,</if>
<if test="iotDeviceId != null and iotDeviceId != ''">iot_device_id,</if>
<if test="pushTime != null ">push_time,</if>
3 months ago
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="stakeMark != null and stakeMark != ''">#{stakeMark},</if>
<if test="direction != null and direction != ''">#{direction},</if>
<if test="deviceType != null and deviceType != ''">#{deviceType},</if>
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="smokeValue != null and smokeValue != ''">#{smokeValue},</if>
<if test="createTime != null ">#{createTime},</if>
<if test="iotDeviceId != null and iotDeviceId != ''">#{iotDeviceId},</if>
<if test="pushTime != null ">#{pushTime},</if>
</trim>
</insert>
<insert id="insertSnmpAlarm" useGeneratedKeys="true" keyProperty="id">
insert into dc_snmp_alarm
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="deviceName != null and deviceName != ''">device_name,</if>
<if test="content != null and content != ''">content,</if>
<if test="createTime != null ">create_time,</if>
<if test="iotDeviceId != null and iotDeviceId != ''">iot_device_id,</if>
<if test="ip != null and ip != ''">ip,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="content != null and content != ''">#{content},</if>
<if test="createTime != null ">#{createTime},</if>
<if test="iotDeviceId != null and iotDeviceId != ''">#{iotDeviceId},</if>
<if test="ip != null and ip != ''">#{ip},</if>
3 months ago
</trim>
</insert>
<select id="selectDcDeviceList" parameterType="dcDevice" resultMap="DcDevice">
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
<where>
<if test="id != null and id != ''">and t1.id = #{id}</if>
<if test="iotDeviceId != null and iotDeviceId != ''">and t1.iot_device_id = #{iotDeviceId}</if>
<if test="groupId != null and groupId != ''">and t1.group_id = #{groupId}</if>
<if test="productId != null and productId != ''">and t1.product_id = #{productId}</if>
<if test="stakeMark != null and stakeMark != ''">and t1.stake_mark = #{stakeMark}</if>
<if test="direction != null and direction != ''">and t1.direction = #{direction}</if>
<if test="deviceName != null and deviceName != ''">and t1.device_name like concat('%', #{deviceName}, '%')</if>
<if test="deviceCode != null and deviceCode != ''">and t1.device_code = #{deviceCode}</if>
<if test="deviceType != null and deviceType != ''">and t1.device_type = #{deviceType}</if>
<if test="installationDate != null and installationDate != ''">and t1.installation_Date = #{installationDate}</if>
<if test="productionDate != null and productionDate != ''">and t1.production_date = #{productionDate}</if>
<if test="durableYears != null and durableYears != ''">and t1.durable_years = #{durableYears}</if>
<if test="installationSite != null and installationSite != ''">and t1.installation_site = #{installationSite}</if>
<if test="useState != null">and t1.use_state = #{useState}</if>
<if test="deviceState != null and deviceState != ''">and t1.device_state = #{deviceState}</if>
<if test="otherConfig != null and otherConfig != ''">and json_extract(t1.other_config,'$.childType') = #{otherConfig}</if>
<if test="remark != null and remark != ''">and t1.remark = #{remark}</if>
<if test="createTime != null and createTime != ''">and t1.create_time = #{createTime}</if>
<if test="updateTime != null and updateTime != ''">and t1.update_time = #{updateTime}</if>
<if test="facilitiesType != null and facilitiesType != ''">and t1.facilities_type = #{facilitiesType}</if>
<if test="deviceIp != null and deviceIp != ''">and t1.device_ip = #{deviceIp}</if>
<if test="stakeMarkRange != null and stakeMarkRange != ''">and t1.stake_mark_range = #{stakeMarkRange}</if>
<if test="networkSegment != null and networkSegment != ''">and t1.network_segment = #{networkSegment}</if>
<if test="deviceImg != null and deviceImg != ''">and t1.device_img = #{deviceImg}</if>
<if test="childType != null and childType != ''">and t1.child_type = #{childType}</if>
</where>
</select>
<select id="numberOfDevicesByType" parameterType="dcDevice" resultMap="DcDevice">
SELECT use_state, COALESCE(child_type, device_type) AS device_type, COUNT(*) AS sumAll
FROM dc_device
<where>
<if test="useState!=null">
use_state = #{useState}
</if>
</where>
GROUP BY device_type, child_type;
</select>
<select id="selectNearCamPile" resultMap="DcDevice">
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 &lt;= #{endMileage}
</select>
<select id="selectNearBoard" resultType="com.zc.business.domain.DcDevice">
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 &lt;= #{endMileage}
</select>
<select id="countTheNumberOfEligibleItems" resultType="java.util.Map">
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>
<select id="selectDeviceNameList" resultType="java.util.HashMap">
select iot_device_id deviceId, device_type deviceType,device_name deviceName,device_state deviceState from dc_device
<where>
<if test="deviceState != null and deviceState != ''">and device_state = #{deviceState}</if>
<if test="deviceName != null and deviceName != ''">and device_name like concat('%', #{deviceName}, '%')</if>
<if test="deviceType != null and deviceType != ''">and device_type = #{deviceType} and iot_device_id is not null</if>
<if test="deviceType == null || deviceType == ''">
and (device_type=3||device_type=13||device_type=15||device_type=16||device_type=17) and iot_device_id is not null
</if>
</where>
</select>
<select id="selectDeviceParameterProperties" resultType="java.util.HashMap">
select id, device_type deviceType,
property_id propertyId,property_name propertyName,
name from dc_device_attribute
where device_type=#{deviceType}
</select>
<select id="selectDeviceNumber" resultType="int">
SELECT
(SELECT COUNT(id) FROM dc_device) +
(SELECT COUNT(id) FROM dc_facility) AS total_count;
</select>
<select id="selectDeviceOfRoad" resultType="java.util.HashMap">
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>
<select id="selectDeviceTollStationCamera" resultType="com.zc.business.domain.DcDevice">
select id,iot_device_id from dc_device where facilities_type=5
</select>
9 months ago
<update id="updateTollStationCameraStatus">
update dc_device set device_state=#{deviceState} where id=#{id}
</update>
3 months ago
9 months ago
<select id="selectTollStationCamPile" resultType="com.zc.business.domain.DcDevice">
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 &lt;= #{endMileage}
</select>
<select id="getDcDeviceById" resultType="com.zc.business.domain.DcDevice">
select device_state from dc_device where iot_device_id=#{iotDeviceId}
</select>
5 months ago
<select id="selectDcDoorList" resultType="com.zc.business.domain.DcDoor">
select id,device_name,device_type,direction,stake_mark,operate,create_time from dc_door_monitor
<where>
<if test="deviceName != null and deviceName != ''">and device_name like concat('%', #{deviceName}, '%')</if>
<if test="deviceType != null and deviceType != ''">and device_type = #{deviceType}</if>
<if test="stakeMark != null and stakeMark != ''"> and stake_mark BETWEEN #{stakeMark} and #{endStakeMark} </if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
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') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
</if>
</where>
order by create_time desc
</select>
<select id="selectDcDoorOpen" resultType="com.zc.business.domain.DcDoor">
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
<foreach item="item" collection="iotIds" open="(" separator="," close=")">
#{item}
</foreach>
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>
3 months ago
<select id="selectSmokeList" resultType="com.zc.business.domain.DcSmokeRecord">
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
<foreach item="item" collection="iotIds" open="(" separator="," close=")">
#{item}
</foreach>
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>
<select id="selectSmokeRecordIotId" resultType="com.zc.business.domain.DcSmokeRecord">
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>
<select id="selectSnmpAlarm" resultType="com.zc.business.domain.DcSnmpAlarm">
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
<foreach item="item" collection="iotIds" open="(" separator="," close=")">
#{item}
</foreach>
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>
3 months ago
<update id="updateSmokeValue">
UPDATE dc_smoke_record
<trim prefix="SET" suffixOverrides=",">
<if test="smokeValue != null and smokeValue != ''">smoke_value = #{smokeValue},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="pushTime != null">push_time = #{pushTime},</if>
</trim>
3 months ago
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>
<update id="updateSnmpAlarm">
UPDATE dc_snmp_alarm
<trim prefix="SET" suffixOverrides=",">
<if test="content != null and content != ''">content = #{content},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
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
);
</update>
</mapper>