From 0bf199cf85a36157113d217363bb96314956b75f Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期四, 13 十一月 2025 22:14:12 +0800
Subject: [PATCH] feat: 修复小程序上传附件
---
ruoyi-system/src/main/resources/mapper/system/VehicleInfoMapper.xml | 65 ++++++++++++++++++++++++--------
1 files changed, 49 insertions(+), 16 deletions(-)
diff --git a/ruoyi-system/src/main/resources/mapper/system/VehicleInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/system/VehicleInfoMapper.xml
index e329543..123a769 100644
--- a/ruoyi-system/src/main/resources/mapper/system/VehicleInfoMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/VehicleInfoMapper.xml
@@ -21,6 +21,13 @@
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
+ <!-- 澶氫釜鍒嗗叕鍙稿叧鑱� -->
+ <collection property="deptIds" ofType="Long"
+ select="selectVehicleDeptIds"
+ column="vehicle_id"/>
+ <collection property="deptNames" ofType="String"
+ select="selectVehicleDeptNames"
+ column="vehicle_id"/>
</resultMap>
<sql id="selectVehicleInfoVo">
@@ -28,6 +35,19 @@
from tb_vehicle_info v
left join sys_dept d on v.dept_id = d.dept_id
</sql>
+
+ <!-- 鏌ヨ杞﹁締鍏宠仈鐨勬墍鏈夊垎鍏徃ID -->
+ <select id="selectVehicleDeptIds" resultType="Long">
+ SELECT dept_id FROM tb_vehicle_dept WHERE vehicle_id = #{vehicle_id}
+ </select>
+
+ <!-- 鏌ヨ杞﹁締鍏宠仈鐨勬墍鏈夊垎鍏徃鍚嶇О -->
+ <select id="selectVehicleDeptNames" resultType="String">
+ SELECT d.dept_name
+ FROM tb_vehicle_dept vd
+ LEFT JOIN sys_dept d ON vd.dept_id = d.dept_id
+ WHERE vd.vehicle_id = #{vehicle_id}
+ </select>
<select id="selectVehicleInfoList" parameterType="VehicleInfo" resultMap="VehicleInfoResult">
<include refid="selectVehicleInfoVo"/>
@@ -39,29 +59,19 @@
<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>
- <!-- 閮ㄩ棬杩囨护锛氳嚜鍔ㄦ煡鎵句紶鍏ラ儴闂ㄦ墍灞炵殑鍒嗗叕鍙革紙parent_id=100锛� -->
+ <!-- 閮ㄩ棬杩囨护锛氭牴鎹垎鍏徃ID鏌ヨ杞﹁締锛堥�氳繃鍏宠仈琛級 -->
<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
+ and EXISTS (
+ SELECT 1 FROM tb_vehicle_dept vd
+ WHERE vd.vehicle_id = v.vehicle_id
+ AND vd.dept_id = #{deptId}
)
</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>
@@ -73,6 +83,11 @@
<select id="selectVehicleInfoByPlateNumber" parameterType="String" resultMap="VehicleInfoResult">
<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">
@@ -170,4 +185,22 @@
ORDER BY uv.bind_time DESC
LIMIT 1
</select>
+
+ <!-- 鎵归噺鎻掑叆杞﹁締-鍒嗗叕鍙稿叧鑱� -->
+ <insert id="batchInsertVehicleDept">
+ INSERT INTO tb_vehicle_dept (vehicle_id, dept_id, order_class, create_by, create_time)
+ VALUES
+ <foreach collection="list" item="item" separator=",">
+ (#{item.vehicleId}, #{item.deptId}, #{item.orderClass}, #{item.createBy}, NOW())
+ </foreach>
+ ON DUPLICATE KEY UPDATE
+ order_class = VALUES(order_class),
+ update_by = VALUES(create_by),
+ update_time = NOW()
+ </insert>
+
+ <!-- 鍒犻櫎杞﹁締鐨勬墍鏈夊垎鍏徃鍏宠仈 -->
+ <delete id="deleteVehicleDeptByVehicleId">
+ DELETE FROM tb_vehicle_dept WHERE vehicle_id = #{vehicleId}
+ </delete>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.1