From 4c133c297ff25eddd1a30a4bce032affb334969a Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期二, 30 七月 2024 09:19:30 +0800
Subject: [PATCH] 三一车辆查询bug修改及电磁锁状态修改提交

---
 ard-work/src/main/resources/mapper/sy/ArdSyCarMapper.xml |   82 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 82 insertions(+), 0 deletions(-)

diff --git a/ard-work/src/main/resources/mapper/sy/ArdSyCarMapper.xml b/ard-work/src/main/resources/mapper/sy/ArdSyCarMapper.xml
index 35d3c4b..23e4643 100644
--- a/ard-work/src/main/resources/mapper/sy/ArdSyCarMapper.xml
+++ b/ard-work/src/main/resources/mapper/sy/ArdSyCarMapper.xml
@@ -17,6 +17,30 @@
         <result property="reserved3"    column="reserved_3"    />
     </resultMap>
 
+    <resultMap type="ArdSyCar" id="ArdSyCarLockResult">
+        <result property="id"    column="id"    />
+        <result property="carId"    column="car_id"    />
+        <result property="carModel"    column="car_model"    />
+        <result property="carType"    column="car_type"    />
+        <result property="carBrand"    column="car_brand"    />
+        <result property="deptId"    column="dept_id"    />
+        <result property="carPicture"    column="car_picture"    />
+        <result property="reserved1"    column="reserved_1"    />
+        <result property="reserved2"    column="reserved_2"    />
+        <result property="reserved3"    column="reserved_3"    />
+        <collection property="ardTankLockList" ofType="com.ruoyi.sy.domain.ArdTankLock">
+            <result property="id"    column="lid"    />
+            <result property="lockNum"    column="lock_num"    />
+            <result property="lockName"    column="lock_name"    />
+            <result property="imgPositionTop"    column="img_position_top"    />
+            <result property="imgPositionLeft"    column="img_position_left"    />
+            <result property="carId"    column="lcar_id"    />
+            <result property="enable"    column="enable"    />
+            <result property="restartState"    column="restart_state"    />
+            <result property="onlineTime"    column="online_time"    />
+        </collection>
+    </resultMap>
+
     <sql id="selectArdSyCarVo">
         select id, car_id, car_model, car_type, car_brand, dept_id, car_picture, reserved_1, reserved_2, reserved_3 from ard_sy_car
     </sql>
@@ -102,7 +126,65 @@
         </foreach>
     </select>
 
+
     <select id="carListById" parameterType="String" resultMap="ArdSyCarResult">
         select * from ard_sy_car where id = #{id}
     </select>
+    <select id="getArdSyCarAndDeptByCarId" parameterType="String" resultType="java.util.Map">
+        select asc0.id,asc0.car_id as "carId",coalesce(asc0.car_model,'') as "carModel",
+        coalesce(asc0.car_type,'') as "carType",coalesce(asc0.car_brand,'') as "carBrand",
+        asc0.dept_id as "deptId",asc0.car_picture as "carPicture",sd.ancestors,
+        sd.dept_name as "deptName" from ard_sy_car asc0
+        inner join sys_dept sd on asc0.dept_id = sd.dept_id
+        where asc0.car_id = #{carId}
+    </select>
+    <select id="selectArdSyCarByDeptIds" parameterType="java.lang.Long" resultType="java.lang.String">
+        select asy.car_id from ard_sy_car asy
+        where asy.dept_id in
+        <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
+            #{deptId}
+        </foreach>
+    </select>
+    <select id="getArdSyTankCarByCarId" parameterType="java.lang.String" resultMap="ArdSyCarResult">
+        select distinct "asc".* from ard_sy_car "asc"
+        inner join ard_tank_lock atl on "asc".car_id = atl.car_id
+        where "asc".car_id = #{carId}
+    </select>
+    <select id="getCountByCarIdList" resultType="java.lang.Long">
+        select count(*) from ard_sy_car "asc"
+        where "asc".car_id in
+        <foreach item="carId" collection="carIdList" open="(" separator="," close=")">
+            #{carId}
+        </foreach>
+    </select>
+    <select id="getCarListByDeptIdList" resultMap="ArdSyCarResult">
+        select * from ard_sy_car where dept_id in
+        <foreach item="deptId" collection="deptIdList" open="(" separator="," close=")">
+            #{deptId}
+        </foreach>
+    </select>
+    <select id="selectArdSyCarAndTankLockByUserId" resultMap="ArdSyCarLockResult" parameterType="java.lang.String">
+        select "asc".id,"asc".car_id,"asc".car_model,"asc".car_type,
+        "asc".car_brand,"asc".dept_id,"asc".car_picture,atl.id as lid,
+        atl.lock_num,atl.lock_name,atl.img_position_top,atl.img_position_left,
+        atl.car_id as lcar_id,atl.enable,coalesce(atl.restart_state,'') as restart_state,
+        coalesce(atl.online_time,'') as online_time
+        from ard_sy_car "asc"
+        inner join ard_tank_lock atl on "asc".car_id = atl.car_id
+        where "asc".dept_id in (
+        with recursive rsd as (
+            select sd.dept_id from sys_dept sd where sd.dept_id =
+            (select dept_id from sys_user su where su.user_id = #{userId})
+            union
+            select csd.dept_id from sys_dept csd inner join rsd on rsd.dept_id = csd.parent_id
+        )
+        select dept_id from rsd) order by "asc".car_id desc,atl.lock_num
+    </select>
+    <select id="selectByBrandAndType" resultMap="ArdSyCarResult" parameterType="java.lang.String">
+        select * from ard_sy_car
+        <where>
+            <if test="carType != null  and carType != ''"> and car_type = #{carType}</if>
+            <if test="carBrand != null  and carBrand != ''"> and car_brand = #{carBrand}</if>
+        </where>
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3