From 7b43c04dd530bdd193e0cf02c4e19ba7c2ee2c11 Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期三, 11 五月 2022 10:41:31 +0800
Subject: [PATCH] 设备归属

---
 dao/src/main/resources/mapper/MonitorMapper.xml |   69 +++++++++++++++++++++++++++-------
 1 files changed, 54 insertions(+), 15 deletions(-)

diff --git a/dao/src/main/resources/mapper/MonitorMapper.xml b/dao/src/main/resources/mapper/MonitorMapper.xml
index 79a3179..a94727a 100644
--- a/dao/src/main/resources/mapper/MonitorMapper.xml
+++ b/dao/src/main/resources/mapper/MonitorMapper.xml
@@ -6,24 +6,63 @@
 
     <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.Monitor">
         <id property="id" column="id" jdbcType="BIGINT"/>
-        <result property="userId" column="user_id" jdbcType="VARCHAR"/>
-        <result property="serialNumber" column="serial_number" jdbcType="VARCHAR"/>
-        <result property="belongTo" column="belong_to" jdbcType="VARCHAR"/>
-        <result property="address" column="address" jdbcType="VARCHAR"/>
+        <result property="deviceSerial" column="device_serial" jdbcType="VARCHAR"/>
+        <result property="devicesCode" column="devices_code" jdbcType="VARCHAR"/>
+        <result property="deviceName" column="device_name" jdbcType="VARCHAR"/>
+        <result property="deviceType" column="device_type" jdbcType="VARCHAR"/>
         <result property="equipmentState" column="equipment_state" jdbcType="INTEGER"/>
-        <result property="workState" column="work_state" jdbcType="INTEGER"/>
+        <result property="isEncrypt" column="is_encrypt" jdbcType="INTEGER"/>
         <result property="bindingState" column="binding_state" jdbcType="INTEGER"/>
         <result property="note" column="note" jdbcType="VARCHAR"/>
-        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+        <result property="addTime" column="add_time" jdbcType="TIMESTAMP"/>
+        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+        <result property="netAddress" column="net_address" jdbcType="VARCHAR"/>
     </resultMap>
-    <select id="listMonitorByKeyword" resultType="com.sandu.ximon.dao.domain.Monitor">
-        SELECT    * FROM   (SELECT    * FROM    (SELECT    * FROM    monitor AS table1
-              WHERE serial_number  LIKE CONCAT(CONCAT('%', #{keyword}), '%')
-              OR belong_to  LIKE CONCAT(CONCAT('%', #{keyword}), '%')) AS table2
-         WHERE equipment_state = #{equipmentState1}
-         OR equipment_state = #{equipmentState2}) AS table3
-        WHERE binding_state = #{bindingState1} OR binding_state = #{bindingState2};
+
+    <select id="listMonitorByIds" resultType="com.sandu.ximon.dao.bo.MonitorBo">
+        SELECT
+        t1.*, t2.pole_id,
+        t3.pole_name, t3.province,t3.city,t3.region,t3.address
+        FROM
+        monitor t1
+        LEFT JOIN pole_binding t2 ON t1.device_serial = t2.device_code
+        AND t2.device_type = 7
+        LEFT JOIN pole t3 ON t3.id = t2.pole_id
+        <where>
+            <if test="list != null">
+                t1.device_serial IN
+                <foreach collection="list" open="(" close=")" separator="," item="deviceCode">
+                    #{deviceCode}
+                </foreach>
+            </if>
+            <if test="equipmentState != 2">
+                AND t1.equipment_state = #{equipmentState}
+            </if>
+        </where>
+    </select>
+    <select id="listMonitorDeviceSerial1" resultType="com.sandu.ximon.dao.bo.MonitorBo">
+        SELECT
+        t1.*, t2.pole_id,
+        t3.pole_name, t3.province,t3.city,t3.region,t3.address
+        FROM
+        monitor t1
+        LEFT JOIN pole_binding t2 ON t1.device_serial = t2.device_code
+        AND t2.device_type = 7
+        LEFT JOIN pole t3 ON t3.id = t2.pole_id
+        <where>
+            <if test="userid != null">
+                AND (t3.user_id = #{userid} OR t3.client_id = #{userid})
+            </if>
+            <if test="keyword != null and keyword != ''">
+                AND ( t3.pole_name LIKE CONCAT(CONCAT('%', #{keyword}), '%')
+                OR t1.device_serial LIKE CONCAT(CONCAT('%', #{keyword}), '%')
+                OR t1.note LIKE CONCAT(CONCAT('%', #{keyword}), '%')
+                OR t3.pole_code LIKE CONCAT(CONCAT('%', #{keyword}), '%'))
+            </if>
+            <if test="bindingState != 2">
+                AND t1.binding_state = #{bindingState}
+            </if>
+        </where>
     </select>
 
-
-</mapper>
\ No newline at end of file
+</mapper>

--
Gitblit v1.9.3