fg电池监控平台的达梦数据库版本
whycxzp
2024-11-12 95766445ae3a3702b25efa433f0945c4c1cf6c54
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">