Stwzhj-Cloud-Plus/stwzhj-modules/stwzhj-system/src/main/resources/mapper/system/DeviceRedisMapper.xml

50 lines
1.8 KiB
XML

<?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="org.dromara.system.mapper.DeviceRedisMapper">
<resultMap id="deviceRedisResult" type="org.dromara.system.domain.vo.DeviceRedisVo">
</resultMap>
<insert id="insertBatch">
insert into t_device_redis (device_code,device_type,online,zzjgdm)
values
<foreach collection="list" item="entity" separator=",">
(
#{entity.deviceCode},#{entity.deviceType},#{entity.online},#{entity.zzjgdm}
)
</foreach>
ON DUPLICATE KEY UPDATE
device_type = VALUES(device_type),
online = VALUES(online),
zzjgdm = VALUES(zzjgdm)
</insert>
<!-- 全省各类设备总数、在线数 -->
<select id="countByCondition" resultMap="deviceRedisResult">
SELECT d.dict_label type_name,dict_value device_type,COALESCE(r.co,0) online,COALESCE(td.co,0) co from sys_dict_data d
LEFT JOIN (
SELECT device_type,count(*) co FROM (
SELECT * FROM t_device_redis
<where>
online = '1'
<if test="zzjgdm != null and zzjgdm != ''"> and zzjgdm like concat(#{zzjgdm},'%') </if>
</where>
) dr group by device_type) r
on d.dict_value = r.device_type
LEFT JOIN
(SELECT device_type,count(*) co from (SELECT * FROM t_device
<where>
valid = 1
<if test="zzjgdm != null and zzjgdm != ''"> and zzjgdm like concat(#{zzjgdm},'%')</if>
</where>
) r
GROUP BY device_type ) td
on d.dict_value = td.device_type
WHERE d.dict_type = 'zd_device_type'
</select>
</mapper>