From e55c8b0a92eb9715edd90c31dfd4de51a47b588b Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期五, 04 十一月 2022 17:40:08 +0800
Subject: [PATCH] changes

---
 dao/src/main/resources/mapper/LightMapper.xml |   77 +++++++++++++++++++++++++++++++++-----
 1 files changed, 67 insertions(+), 10 deletions(-)

diff --git a/dao/src/main/resources/mapper/LightMapper.xml b/dao/src/main/resources/mapper/LightMapper.xml
index ccc88cc..9aa1194 100644
--- a/dao/src/main/resources/mapper/LightMapper.xml
+++ b/dao/src/main/resources/mapper/LightMapper.xml
@@ -5,24 +5,81 @@
 <mapper namespace="com.sandu.ximon.dao.mapper.LightMapper">
 
     <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.Light">
-            <id property="lightId" column="light_id" jdbcType="BIGINT"/>
-            <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
-            <result property="remark" column="remark" jdbcType="VARCHAR"/>
-            <result property="lightPercent" column="light_percent" jdbcType="INTEGER"/>
-            <result property="light2Percent" column="light2_percent" jdbcType="INTEGER"/>
-            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
-            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+        <id property="lightId" column="light_id" jdbcType="BIGINT"/>
+        <result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
+        <result property="remark" column="remark" jdbcType="VARCHAR"/>
+        <result property="lightCount" column="light_count" jdbcType="INTEGER"/>
+        <result property="lightPercent" column="light_percent" jdbcType="INTEGER"/>
+        <result property="light2Percent" column="light2_percent" jdbcType="INTEGER"/>
+        <result property="power1" column="power1" jdbcType="INTEGER"/>
+        <result property="power2" column="power2" jdbcType="INTEGER"/>
+        <result property="light1" column="light1" jdbcType="INTEGER"/>
+        <result property="light2" column="light2" jdbcType="INTEGER"/>
+        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
     </resultMap>
 
     <resultMap id="listLight" type="com.sandu.ximon.dao.bo.LightBo" extends="BaseResultMap">
         <result property="poleId" column="pole_id" jdbcType="BIGINT"/>
         <result property="poleCode" column="pole_code" jdbcType="VARCHAR"/>
         <result property="poleName" column="pole_name" jdbcType="VARCHAR"/>
-        <result property="taskName" column="task_name" jdbcType="VARCHAR"/>
+        <collection property="taskNameIdBos" ofType="com.sandu.ximon.dao.bo.LightTaskNameIdBo">
+            <result property="taskId" column="task_id" jdbcType="BIGINT"/>
+            <result property="taskName" column="task_name" jdbcType="VARCHAR"/>
+            <result property="lightAddress" column="light_address" jdbcType="VARCHAR"/>
+        </collection>
     </resultMap>
 
 
     <select id="listLight" resultMap="listLight">
+        SELECT
+        t1.*,
+        t2.id AS pole_id,
+        t2.pole_code,
+        t2.pole_name,
+        t4.task_id AS task_id,
+        t4.task_name AS task_name,
+        t3.light_address AS light_address
+        FROM
+        light t1
+        LEFT JOIN pole_binding t5 ON t1.device_code = t5.device_code
+        LEFT JOIN pole t2 ON t2.id=t5.pole_id AND t5.device_type=0
+        LEFT JOIN light_task_pole_relation t3 ON t3.pole_id = t2.id
+        LEFT JOIN light_task t4 ON t3.task_id = t4.task_id
+        <where>
+            <if test="clientId != null">
+                AND (t2.user_id = #{clientId} OR t2.client_id = #{clientId})
+            </if>
+            <if test="keyword != null and keyword != ''">
+                AND (
+                t1.device_code LIKE CONCAT('%', #{keyword},'%')
+                OR t2.pole_name LIKE CONCAT('%', #{keyword},'%')
+                )
+            </if>
+        </where>
+    </select>
+    <select id="listCode" resultType="java.lang.String">
+        SELECT
+        t1.device_code
+        FROM
+        light t1
+        LEFT JOIN pole t2 ON t1.device_code = t2.device_code
+        <where>
+            <if test="userId != null">
+                AND (t2.user_id = #{userId} OR t2.client_id = #{userId})
+            </if>
+            <if test="keyword != null and keyword != ''">
+                AND (
+                t1.device_code LIKE CONCAT('%', #{keyword},'%')
+                OR t2.pole_name LIKE CONCAT('%', #{keyword},'%')
+                )
+            </if>
+            <if test="deviceCode != null and deviceCode!= ''">
+                AND t1.device_code = #{deviceCode}
+            </if>
+        </where>
+    </select>
+    <select id="listLightOnBinding" resultType="com.sandu.ximon.dao.bo.LightBo">
         SELECT
         t1.*,
         t2.id AS pole_id,
@@ -36,12 +93,12 @@
         LEFT JOIN light_task t4 ON t3.task_id = t4.task_id
         <where>
             <if test="clientId != null">
-                AND t2.client_id = #{clientId}
+                AND (t2.user_id = #{clientId} OR t2.client_id = #{clientId})
             </if>
             <if test="keyword != null and keyword != ''">
                 AND (
                 t1.device_code LIKE CONCAT('%', #{keyword},'%')
-                OR t2.pole_name LIKE CONCAT('%', #{keyword},'%')
+                OR t1.light_id LIKE CONCAT('%', #{keyword},'%')
                 )
             </if>
         </where>

--
Gitblit v1.9.3