From 95766445ae3a3702b25efa433f0945c4c1cf6c54 Mon Sep 17 00:00:00 2001
From: whycxzp <glperry@163.com>
Date: 星期二, 12 十一月 2024 16:56:50 +0800
Subject: [PATCH] 调整语法不兼容

---
 src/main/resources/mapper/Fbs9100sDfuStateMapper.xml |   41 ++++++++++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/src/main/resources/mapper/Fbs9100sDfuStateMapper.xml b/src/main/resources/mapper/Fbs9100sDfuStateMapper.xml
index 9569e5f..ead87b9 100644
--- a/src/main/resources/mapper/Fbs9100sDfuStateMapper.xml
+++ b/src/main/resources/mapper/Fbs9100sDfuStateMapper.xml
@@ -84,23 +84,30 @@
 
 
 	<insert id="addPro">
-		REPLACE into db_ram_db.tb_fbs9100s_dfu_state(dev_id,dfu_wr_stat,dfu_data_blocknum)
-		SELECT DISTINCT fBSDeviceId,0,1 FROM db_battinf.tb_battinf
-		<where>
-			fBSDeviceId not in(select DISTINCT dev_id from db_ram_db.tb_fbs9100s_dfu_state where dfu_en=true)
-            <if test="num == 0">
-				and stationid=#{stationName}
-			</if>
-			<if test="num == 1">
-				and stationname1=#{stationName}
-			</if>
-			<if test="num == 2">
-				and stationname2=#{stationName}
-			</if>
-			<if test="num == 5">
-				and stationname5=#{stationName}
-			</if>
-		</where>
+		merge into db_ram_db.tb_fbs9100s_dfu_state tgt
+		using(
+			SELECT DISTINCT fBSDeviceId,0,1 FROM db_battinf.tb_battinf
+				<where>
+				fBSDeviceId not in(select DISTINCT dev_id from db_ram_db.tb_fbs9100s_dfu_state where dfu_en=true)
+				<if test="num == 0">
+					and stationid=#{stationName}
+				</if>
+				<if test="num == 1">
+					and stationname1=#{stationName}
+				</if>
+				<if test="num == 2">
+					and stationname2=#{stationName}
+				</if>
+				<if test="num == 5">
+					and stationname5=#{stationName}
+				</if>
+				</where>
+		) src on tgt.dev_id=src.fBSDeviceId
+		when not matched then
+		insert(dev_id,dfu_wr_stat,dfu_data_blocknum) values(src.fBSDeviceId,0,1)
+		when matched then
+		update set dfu_wr_stat=0,dfu_data_blocknum=1
+
 	</insert>
 
 	<update id="updatePro">

--
Gitblit v1.9.1