|
@@ -1,40 +1,62 @@
|
|
|
<?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="vip.xiaonuo.coldchain.modular.monitortarget.mapper.MonitorTargetMapper">
|
|
|
+
|
|
|
<resultMap id="MonitorTargetResultMap" type="vip.xiaonuo.coldchain.modular.monitortarget.entity.MonitorTarget">
|
|
|
<result column="alarm_users" property="alarmUsers" javaType="java.util.List" typeHandler="vip.xiaonuo.coldchain.core.handler.SensorAlarmUserTypeHandler"/>
|
|
|
<result column="notification_channel" property="notificationChannel" javaType="java.util.List" typeHandler="vip.xiaonuo.coldchain.core.handler.NotificationChannelListTypeHandler"/>
|
|
|
</resultMap>
|
|
|
|
|
|
+<!-- <select id="getCountByStatus" resultType="vip.xiaonuo.coldchain.modular.monitortarget.entity.StatusCount">-->
|
|
|
+<!-- select status, count(`status`) as count-->
|
|
|
+<!-- from `monitor_target`-->
|
|
|
+<!-- where `CREATE_ORG` = #{orgId}-->
|
|
|
+<!-- and delete_flag = 'NOT_DELETE'-->
|
|
|
+<!-- <if test="name != null and name != ''">-->
|
|
|
+<!-- and name like '%${name}%'-->
|
|
|
+<!-- or id in (-->
|
|
|
+<!-- select `monitor_target_id`-->
|
|
|
+<!-- from `monitor_target_region`-->
|
|
|
+<!-- where sensor_code like '%${name}%'-->
|
|
|
+<!-- )-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- <if test="roomId != null and roomId != ''">-->
|
|
|
+<!-- and room_id=#{roomId}-->
|
|
|
+<!-- </if>-->
|
|
|
+<!-- group by status-->
|
|
|
+<!-- </select>-->
|
|
|
+
|
|
|
<select id="getCountByStatus" resultType="vip.xiaonuo.coldchain.modular.monitortarget.entity.StatusCount">
|
|
|
- select status, count(`status`) as count
|
|
|
- from `monitor_target`
|
|
|
- where `CREATE_ORG` = #{orgId}
|
|
|
- and delete_flag = 'NOT_DELETE'
|
|
|
- <if test="name != null and name != ''">
|
|
|
- and name like '%${name}%'
|
|
|
- or id in (
|
|
|
- select `monitor_target_id`
|
|
|
- from `monitor_target_region`
|
|
|
- where sensor_code like '%${name}%'
|
|
|
- )
|
|
|
+ select t.status, COUNT(*) as count
|
|
|
+ FROM monitor_target t
|
|
|
+ LEFT JOIN monitor_target_region r ON r.monitor_target_id = t.id
|
|
|
+ WHERE 1=1
|
|
|
+ <!-- 过滤条件:MonitorTarget 删除标志 -->
|
|
|
+ AND t.DELETE_FLAG = 'NOT_DELETE'
|
|
|
+ <!-- 过滤条件:monitor_target_region 删除标志 -->
|
|
|
+ AND r.DELETE_FLAG = 'NOT_DELETE'
|
|
|
+ <!-- 动态条件:按房间ID查询 -->
|
|
|
+ <if test="roomId != null and roomId.trim() != ''">
|
|
|
+ AND t.room_id = #{roomId}
|
|
|
</if>
|
|
|
- <if test="roomId != null and roomId != ''">
|
|
|
- and room_id=#{roomId}
|
|
|
+ <!-- 动态条件:按机构ID查询 -->
|
|
|
+ <if test="orgId != null and orgId.trim() != ''">
|
|
|
+ AND t.create_org = #{orgId}
|
|
|
+ </if>
|
|
|
+ <!-- 动态条件:按 sensor_code 或 name 模糊查询 -->
|
|
|
+ <if test="name != null and name.trim() != ''">
|
|
|
+ AND (r.sensor_code LIKE CONCAT('%', #{name}, '%')
|
|
|
+ OR r.name LIKE CONCAT('%', #{name}, '%'))
|
|
|
</if>
|
|
|
- group by status
|
|
|
+ GROUP BY t.status
|
|
|
</select>
|
|
|
|
|
|
-
|
|
|
- <!-- 查询 MonitorTarget 列表 -->
|
|
|
<select id="selectMonitorTargetByPage" resultMap="MonitorTargetResultMap">
|
|
|
SELECT t.*
|
|
|
FROM monitor_target t
|
|
|
LEFT JOIN monitor_target_region r ON r.monitor_target_id = t.id
|
|
|
WHERE 1=1
|
|
|
- <!-- 过滤条件:MonitorTarget 删除标志 -->
|
|
|
AND t.DELETE_FLAG = 'NOT_DELETE'
|
|
|
- <!-- 过滤条件:monitor_target_region 删除标志 -->
|
|
|
AND r.DELETE_FLAG = 'NOT_DELETE'
|
|
|
<!-- 动态条件:按名称模糊查询 -->
|
|
|
<if test="param.name != null and param.name.trim() != ''">
|
|
@@ -52,9 +74,6 @@
|
|
|
<if test="param.orgId != null and param.orgId.trim() != ''">
|
|
|
AND t.create_org = #{param.orgId}
|
|
|
</if>
|
|
|
- <if test="param.orgId == null or param.orgId.trim() == ''">
|
|
|
- AND t.create_org = #{param.orgId}
|
|
|
- </if>
|
|
|
<!-- 动态条件:按 sensor_code 或 name 模糊查询 -->
|
|
|
<if test="param.searchKey != null and param.searchKey.trim() != ''">
|
|
|
AND (r.sensor_code LIKE CONCAT('%', #{param.searchKey}, '%')
|
|
@@ -75,9 +94,10 @@
|
|
|
ORDER BY t.status ASC, t.name ASC
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
- <!-- 分页 -->
|
|
|
- LIMIT #{param.offset}, #{param.size}
|
|
|
+<!-- <!– 分页 –>-->
|
|
|
+<!-- LIMIT #{param.offset}, #{param.size}-->
|
|
|
</select>
|
|
|
|
|
|
|
|
|
+
|
|
|
</mapper>
|