1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?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.usky.iot.mapper.DmpDeviceStatusMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.usky.iot.domain.DmpDeviceStatus">
- <id column="id" property="id" />
- <result column="device_id" property="deviceId" />
- <result column="product_id" property="productId" />
- <result column="device_status" property="deviceStatus" />
- <result column="last_online_time" property="lastOnlineTime" />
- <result column="last_offline_time" property="lastOfflineTime" />
- </resultMap>
- <select id="getAllCollect" resultType="com.usky.iot.service.vo.DmpDataOverviewVO">
- select ddi.product_id as productId,
- count(*) as deviceCount,
- COUNT(to_days(last_online_time) = to_days(now()) or null) as hyCount,
- count(service_status = 2 or null) as jhCount,
- count(service_status) as zcCount,
- count(device_status = 1 or null) as dzcCount,
- count(device_status = 4 or null) as dlxCount
- from dmp_device ddi
- left join dmp_device_status dds
- on ddi.device_id = dds.device_id
- <where>
- <if test="startTime != null and endTime != null">
- and ddi.created_time between #{startTime}
- and #{endTime}
- </if>
- <if test="productId != null">
- and ddi.product_id = #{productId}
- </if>
- </where>
- </select>
- <select id="getMonthHyCollect" resultType="com.usky.iot.service.vo.DmpDataOverviewVO">
- select ddi.product_id as productId,
- count(*) hyCount
- from dmp_device ddi
- left join dmp_device_status dds
- on ddi.device_id = dds.device_id
- <where>
- <if test="startTime != null and endTime != null">
- and dds.last_online_time between #{startTime}
- and #{endTime}
- </if>
- <if test="productId != null">
- and ddi.product_id = #{productId}
- </if>
- </where>
- group by productId
- </select>
- <select id="getAllMonthHyCollect" resultType="com.usky.iot.service.vo.DmpDataOverviewVO">
- select ddi.product_id as productId,
- count(*) hyCount
- from dmp_device ddi
- left join dmp_device_status dds
- on ddi.device_id = dds.device_id
- <where>
- <if test="startTime != null and endTime != null">
- and dds.last_online_time between #{startTime}
- and #{endTime}
- </if>
- <if test="productId != null">
- and ddi.product_id = #{productId}
- </if>
- </where>
- </select>
- <select id="getDeviceStatusCollect" resultType="com.usky.iot.service.vo.DmpDataOverviewVO">
- select ddi.product_id as productId,
- count(*) as deviceCount,
- COUNT(to_days(last_online_time) = to_days(now()) or null) as hyCount,
- count(service_status = 2 or null) as jhCount,
- count(service_status) as zcCount,
- count(device_status = 1 or null) as dzcCount,
- count(device_status = 4 or null) as dlxCount
- from dmp_device ddi
- left join dmp_device_status dds
- on ddi.device_id = dds.device_id
- <where>
- <if test="startTime != null and endTime != null">
- and ddi.created_time between #{startTime}
- and #{endTime}
- </if>
- <if test="productId != null">
- and ddi.product_id = #{productId}
- </if>
- </where>
- group by productId
- </select>
- </mapper>
|