mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-19 01:48:47 +08:00
代码y优化 处理重复状态推送问题
This commit is contained in:
parent
4d8f90c728
commit
5fc537af8c
@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.http.HttpResponse;
|
import cn.hutool.http.HttpResponse;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.github.benmanes.caffeine.cache.Cache;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.dromara.common.core.constant.Constants;
|
import org.dromara.common.core.constant.Constants;
|
||||||
@ -33,6 +34,7 @@ import org.springframework.util.CollectionUtils;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
@ -65,7 +67,8 @@ public class EqIotDeviceController extends BaseController {
|
|||||||
|
|
||||||
private final WebSocketBusinessHandler webSocketBusinessHandler;
|
private final WebSocketBusinessHandler webSocketBusinessHandler;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private Cache<String, String> tokenCache;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,6 +142,17 @@ public class EqIotDeviceController extends BaseController {
|
|||||||
@SaIgnore
|
@SaIgnore
|
||||||
@PostMapping("/sendDeviceMsg2")
|
@PostMapping("/sendDeviceMsg2")
|
||||||
public void sendDeviceMsg2(@RequestBody EqEquipmentLogBo eqEquipmentLogBo){
|
public void sendDeviceMsg2(@RequestBody EqEquipmentLogBo eqEquipmentLogBo){
|
||||||
|
String status = eqEquipmentLogBo.getStatus() + "";
|
||||||
|
String statusCache = tokenCache.getIfPresent("status");
|
||||||
|
if (StringUtils.isEmpty(statusCache)){
|
||||||
|
tokenCache.put("status",status);
|
||||||
|
}else {
|
||||||
|
if (!statusCache.equals(status)){
|
||||||
|
tokenCache.put("status",status);
|
||||||
|
}else{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
String equipmentName = eqEquipmentLogBo.getEquipmentName();
|
String equipmentName = eqEquipmentLogBo.getEquipmentName();
|
||||||
//设备id查询
|
//设备id查询
|
||||||
DeviceByDeviceName deviceByNameDto = iotService.apiTenantDevicesByName(equipmentName);//无信息会抛异常 无需判断
|
DeviceByDeviceName deviceByNameDto = iotService.apiTenantDevicesByName(equipmentName);//无信息会抛异常 无需判断
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user