From 35a1c88cc80ca675f6173648968ab5394b49e31e Mon Sep 17 00:00:00 2001 From: whycxzp <glperry@163.com> Date: 星期三, 28 五月 2025 17:14:50 +0800 Subject: [PATCH] 消防机器人websocket逻辑更新 --- src/main/java/com/whyc/service/EnvironmentThresholdService.java | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/whyc/service/EnvironmentThresholdService.java b/src/main/java/com/whyc/service/EnvironmentThresholdService.java index af0647f..60d9640 100644 --- a/src/main/java/com/whyc/service/EnvironmentThresholdService.java +++ b/src/main/java/com/whyc/service/EnvironmentThresholdService.java @@ -1,5 +1,7 @@ package com.whyc.service; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.whyc.mapper.EnvironmentThresholdMapper; import com.whyc.pojo.db_fire_robot.EnvironmentThreshold; import org.springframework.stereotype.Service; @@ -15,4 +17,16 @@ public void add(EnvironmentThreshold threshold) { mapper.insert(threshold); } + + public void addOrUpdate(EnvironmentThreshold threshold) { + QueryWrapper<EnvironmentThreshold> query = Wrappers.query(); + query.last(" limit 1"); + EnvironmentThreshold thresholdInDB = mapper.selectOne(query); + if (thresholdInDB ==null) { + mapper.insert(threshold); + }else{ + threshold.setId(thresholdInDB.getId()); + mapper.updateById(threshold); + } + } } -- Gitblit v1.9.1