From 82d6b98f5b6b88e223259547208ab59829ad723e Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期六, 01 十一月 2025 21:30:52 +0800
Subject: [PATCH] fix:增加旧系统状态同步到新系统,新系统状态同步到旧系统

---
 ruoyi-system/src/main/resources/mapper/system/VehicleInfoMapper.xml |   36 ++++++++++++++++++++++++++++++++++--
 1 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/ruoyi-system/src/main/resources/mapper/system/VehicleInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/system/VehicleInfoMapper.xml
index d011369..e44b722 100644
--- a/ruoyi-system/src/main/resources/mapper/system/VehicleInfoMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/VehicleInfoMapper.xml
@@ -6,6 +6,7 @@
     
     <resultMap type="com.ruoyi.system.domain.VehicleInfo" id="VehicleInfoResult">
         <id     property="vehicleId"      column="vehicle_id"      />
+        <result property="carId"          column="car_id"          />
         <result property="deviceId"       column="device_id"       />
         <result property="vehicleNo"      column="vehicle_no"      />
         <result property="vehicleType"    column="vehicle_type"    />
@@ -23,7 +24,7 @@
     </resultMap>
 
     <sql id="selectVehicleInfoVo">
-        select v.vehicle_id, v.device_id, v.vehicle_no, v.vehicle_type, v.vehicle_brand, v.vehicle_model, v.status, v.platform_code, v.dept_id, d.dept_name, v.create_by, v.create_time, v.update_by, v.update_time, v.remark
+        select v.vehicle_id, v.car_id, v.device_id, v.vehicle_no, v.vehicle_type, v.vehicle_brand, v.vehicle_model, v.status, v.platform_code, v.dept_id, d.dept_name, v.create_by, v.create_time, v.update_by, v.update_time, v.remark
         from tb_vehicle_info v
         left join sys_dept d on v.dept_id = d.dept_id
     </sql>
@@ -38,7 +39,30 @@
             <if test="vehicleModel != null  and vehicleModel != ''"> and v.vehicle_model = #{vehicleModel}</if>
             <if test="status != null  and status != ''"> and v.status = #{status}</if>
             <if test="platformCode != null  and platformCode != ''"> and v.platform_code = #{platformCode}</if>
-            <if test="deptId != null"> and v.dept_id = #{deptId}</if>
+            <!-- 閮ㄩ棬杩囨护锛氳嚜鍔ㄦ煡鎵句紶鍏ラ儴闂ㄦ墍灞炵殑鍒嗗叕鍙革紙parent_id=100锛� -->
+            <if test="deptId != null">
+                and v.dept_id = (
+                    <!-- 濡傛灉浼犲叆鐨勫氨鏄垎鍏徃锛坧arent_id=100锛夛紝鐩存帴杩斿洖 -->
+                    select case 
+                        when exists(select 1 from sys_dept where dept_id = #{deptId} and parent_id = 100) then #{deptId}
+                        else (
+                            <!-- 鍚﹀垯浠� ancestors 涓煡鎵惧垎鍏徃ID -->
+                            select d.dept_id
+                            from sys_dept d
+                            where d.parent_id = 100
+                            and FIND_IN_SET(d.dept_id, (
+                                select ancestors from sys_dept where dept_id = #{deptId}
+                            ))
+                            limit 1
+                        )
+                    end
+                )
+            </if>
+            <!-- 浠诲姟杞﹁締閫夋嫨蹇呴』杩囨护锛氬彧鏄剧ずcar_id鍜宒ept_id閮戒笉涓虹┖鐨勮溅杈� -->
+            and v.car_id is not null and v.car_id != ''
+            and v.dept_id is not null
+            and v.status=0
+
         </where>
     </select>
     
@@ -51,10 +75,16 @@
         <include refid="selectVehicleInfoVo"/>
         where v.vehicle_no = #{plateNumber}
     </select>
+
+    <select id="selectVehicleInfoByVehicleNo" parameterType="String" resultMap="VehicleInfoResult">
+        <include refid="selectVehicleInfoVo"/>
+        where v.vehicle_no = #{vehicleNo}
+    </select>
         
     <insert id="insertVehicleInfo" parameterType="VehicleInfo" useGeneratedKeys="true" keyProperty="vehicleId">
         insert into tb_vehicle_info
         <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="carId != null">car_id,</if>
             <if test="deviceId != null">device_id,</if>
             <if test="vehicleNo != null">vehicle_no,</if>
             <if test="vehicleType != null">vehicle_type,</if>
@@ -70,6 +100,7 @@
             <if test="remark != null">remark,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="carId != null">#{carId},</if>
             <if test="deviceId != null">#{deviceId},</if>
             <if test="vehicleNo != null">#{vehicleNo},</if>
             <if test="vehicleType != null">#{vehicleType},</if>
@@ -89,6 +120,7 @@
     <update id="updateVehicleInfo" parameterType="VehicleInfo">
         update tb_vehicle_info
         <trim prefix="SET" suffixOverrides=",">
+            <if test="carId != null">car_id = #{carId},</if>
             <if test="deviceId != null">device_id = #{deviceId},</if>
             <if test="vehicleNo != null">vehicle_no = #{vehicleNo},</if>
             <if test="vehicleType != null">vehicle_type = #{vehicleType},</if>

--
Gitblit v1.9.1