From 5464bf2beb3f07a6f3843f88df887f95cbe983af Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期二, 06 一月 2026 17:05:03 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/wuhuyancao' into wuhuyancao
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java | 36 +++++++++++++++++++++++++++++++-----
1 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
index c30157f..e8b905c 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
@@ -118,7 +118,32 @@
if(device.getDoorNameObj()!=null && Constants.equalsInteger(device.getType(),Constants.DEVICE_TYPE.duanluqi)){
device.setDoorName(JSONObject.toJSONString(device.getDoorNameObj()));
}
+ Device model = deviceMapper.selectById(device.getId());
+ if(model ==null){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY);
+ }
+ if(Constants.equalsInteger(model.getType(),Constants.DEVICE_TYPE.duanluqi)){
+ //濡傛灉鏄柗璺櫒
+ if( Constants.equalsInteger(model.getIsUsed(),Constants.ZERO)
+ && StringUtils.equals(device.getDoorName(),model.getDoorName())){
+ //濡傛灉閰嶇疆鍙傛暟鍙戠敓浜嗗彉鍖�,璁剧疆鐘舵�佹湭鍚敤
+ device.setIsUsed(Constants.ONE);
+ try {
+ MqttClient mqttClient = MqttClientCache.clientMapCache.get("device"+device.getId());
+ if(mqttClient !=null){
+ if(mqttClient.isConnected()){
+ mqttClient.disconnect();
+ }
+ mqttClient.close();
+ MqttClientCache.clientMapCache.remove("device"+device.getId());
+ }
+ }catch (Exception e){
+ log.error("==============绔彛mqtt閾炬帴澶辫触锛�"+model.getName()+e.getMessage());
+ }
+ }
+ }
deviceMapper.updateById(device);
+
}
@Override
@@ -349,11 +374,12 @@
//濡傛灉绯荤粺涓嶇敤浜嗭紝绔彛mqtt杩炴帴
try {
mqttClient = mqttBizService.unsubscribe(mqttClient,config ,topics);
- if(mqttClient ==null){
- throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"寤虹珛杩炴帴澶辫触锛�");
- }
- if(mqttClient.isConnected()){
- mqttClient.disconnect();
+ if(mqttClient !=null){
+ if(mqttClient.isConnected()){
+ mqttClient.disconnect();
+ }
+ mqttClient.close();
+ MqttClientCache.clientMapCache.remove("device"+param.getId());
}
}catch (Exception e){
log.error("==============绔彛mqtt閾炬帴澶辫触锛�"+model.getName()+e.getMessage());
--
Gitblit v1.9.3