|
|
@@ -116,96 +116,85 @@
|
|
|
<select id="appBadge" resultType="java.lang.Integer">
|
|
|
SELECT count(0)
|
|
|
FROM iot_alarm_data a
|
|
|
- where a.org_id = #{orgId} and a.end_time is null
|
|
|
+ where a.org_id = #{orgId}
|
|
|
+ and a.end_time is null
|
|
|
</select>
|
|
|
|
|
|
<select id="selectAlarmDataListByOrgPath" resultType="com.xunmei.common.core.domain.mediator.domain.IotAlarmData">
|
|
|
- select d.* from iot_alarm_data d inner join sys_org o on d.org_id = o.id where o.path like concat(#{orgPath},'%') and o.deleted = 0
|
|
|
+ select d.* from iot_alarm_data d inner join sys_org o on d.org_id = o.id where o.path like
|
|
|
+ concat(#{orgPath},'%') and o.deleted = 0
|
|
|
<if test="dataType != null">
|
|
|
and d.data_type = #{dataType}
|
|
|
</if>
|
|
|
</select>
|
|
|
|
|
|
<select id="selectDeviceTypeCount" resultType="com.xunmei.iot.vo.alarmData.DeviceTypeCountVo">
|
|
|
- SELECT
|
|
|
- s.device_type AS deviceType,
|
|
|
- count(*) AS deviceTypeCount,
|
|
|
- (
|
|
|
- SELECT
|
|
|
- count(*)
|
|
|
- FROM
|
|
|
- iot_sensor a
|
|
|
- WHERE
|
|
|
- a.device_type = s.device_type
|
|
|
- AND a.state = 1
|
|
|
- <if test=" query.checkSub != null and query.checkSub == true">
|
|
|
- and a.org_path like concat(concat('%',#{query.orgPath}),'%')
|
|
|
- </if>
|
|
|
- <if test=" query.checkSub != null and query.checkSub == false">
|
|
|
- and a.org_id = #{query.orgId}
|
|
|
- </if>
|
|
|
- ) AS deviceTypeAlarmCount
|
|
|
- FROM
|
|
|
- iot_sensor s
|
|
|
- WHERE
|
|
|
- s.deleted = 0
|
|
|
+ SELECT a.device_type as deviceType ,count(1) as deviceTypeCount,t.alarmNums as deviceTypeAlarmCount
|
|
|
+ FROM iot_device_info a INNER JOIN (
|
|
|
+ SELECT s.device_id as deviceId,COUNT(1) as alarmNums from iot_device_info i INNER join iot_device_status s on
|
|
|
+ i.id = s.device_id and i.iot_token = s.iot_token
|
|
|
+ WHERE s.state=1
|
|
|
+ ) t on t.deviceId= a.id
|
|
|
+ <where>
|
|
|
<if test=" query.checkSub != null and query.checkSub == true">
|
|
|
- and s.org_path like concat(concat('%',#{query.orgPath}),'%')
|
|
|
+ and a.org_path like concat(concat('%',#{query.orgPath}),'%')
|
|
|
</if>
|
|
|
<if test=" query.checkSub != null and query.checkSub == false">
|
|
|
- and s.org_id = #{query.orgId}
|
|
|
+ and a.org_id = #{query.orgId}
|
|
|
</if>
|
|
|
- GROUP BY
|
|
|
- s.device_type
|
|
|
+ </where>
|
|
|
+ GROUP BY a.device_type;
|
|
|
</select>
|
|
|
<select id="selectSensorAlarmPageList" resultType="com.xunmei.iot.vo.alarm.IotAlarmDataVo">
|
|
|
SELECT
|
|
|
- a.*,
|
|
|
- b.affiliated_area AS city,
|
|
|
- b.affiliated_bank AS bank,
|
|
|
- b.short_name AS org_name
|
|
|
+ a.*,
|
|
|
+ b.affiliated_area AS city,
|
|
|
+ b.affiliated_bank AS bank,
|
|
|
+ b.short_name AS org_name
|
|
|
FROM
|
|
|
- iot_alarm_data a
|
|
|
- LEFT JOIN iot_sensor s ON a.device_id = s.device_code AND a.org_id = s.org_id
|
|
|
- LEFT JOIN sys_org b ON a.org_id = b.id
|
|
|
+ iot_alarm_data a
|
|
|
+ LEFT JOIN iot_sensor s ON a.device_id = s.device_code AND a.org_id = s.org_id
|
|
|
+ LEFT JOIN sys_org b ON a.org_id = b.id
|
|
|
WHERE
|
|
|
- 1=1
|
|
|
- <if test="param.sensorId != null">
|
|
|
- and s.id = #{param.sensorId}
|
|
|
- </if>
|
|
|
- <if test="param.deviceName != null and param.deviceName != ''">
|
|
|
- and s.device_name like concat('%',#{param.deviceName},'%')
|
|
|
- </if>
|
|
|
+ 1=1
|
|
|
+ <if test="param.sensorId != null">
|
|
|
+ and s.id = #{param.sensorId}
|
|
|
+ </if>
|
|
|
+ <if test="param.deviceName != null and param.deviceName != ''">
|
|
|
+ and s.device_name like concat('%',#{param.deviceName},'%')
|
|
|
+ </if>
|
|
|
ORDER BY
|
|
|
- a.`time` DESC,
|
|
|
- a.end_time DESC
|
|
|
+ a.`time` DESC,
|
|
|
+ a.end_time DESC
|
|
|
</select>
|
|
|
|
|
|
<select id="selectAlarmCount" resultType="java.util.Map">
|
|
|
select CAST(d.source_type as CHAR) deviceType, CAST(SUM(1) AS CHAR) as nums
|
|
|
from iot_alarm_data d
|
|
|
inner join sys_org o on o.id = d.org_id
|
|
|
- where o.deleted = 0 and data_type=0
|
|
|
+ where o.deleted = 0
|
|
|
+ and data_type = 0
|
|
|
and (
|
|
|
- (
|
|
|
- #{beginTime} <![CDATA[<=]]> d.time
|
|
|
- and now() <![CDATA[>=]]> d.time
|
|
|
- )
|
|
|
+ (
|
|
|
+ #{beginTime} <![CDATA[<=]]> d.time
|
|
|
+ and now() <![CDATA[>=]]> d.time
|
|
|
+ )
|
|
|
or
|
|
|
- (
|
|
|
- #{beginTime} <![CDATA[<=]]> d.end_time
|
|
|
- and now() <![CDATA[>=]]> d.end_time
|
|
|
- )
|
|
|
+ (
|
|
|
+ #{beginTime} <![CDATA[<=]]> d.end_time
|
|
|
+ and now() <![CDATA[>=]]> d.end_time
|
|
|
+ )
|
|
|
or (
|
|
|
- #{beginTime} <![CDATA[>=]]> d.time
|
|
|
- and now() <![CDATA[<=]]> d.end_time
|
|
|
- )
|
|
|
+ #{beginTime} <![CDATA[>=]]> d.time
|
|
|
+ and now() <![CDATA[<=]]> d.end_time
|
|
|
+ )
|
|
|
)
|
|
|
- and o.path like concat(#{orgPath}, '%') and d.source_type is not null
|
|
|
+ and o.path like concat(#{orgPath}, '%')
|
|
|
+ and d.source_type is not null
|
|
|
group by d.source_type
|
|
|
</select>
|
|
|
|
|
|
- <select id="selectAlarmTypeList" resultType="com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO">
|
|
|
+ <select id="selectAlarmTypeList" resultType="com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO">
|
|
|
select source_type as value,
|
|
|
replace(source_type_des,'传感器','') as label
|
|
|
from iot_alarm_system_field
|