From 7ae1456345209704248fd184e0218b0c0f677a84 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期二, 06 一月 2026 15:26:17 +0800
Subject: [PATCH] 最新版本541200007最新版本541200007
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java | 46 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 39 insertions(+), 7 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 5627748..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
@@ -216,6 +241,12 @@
}
if (pageWrap.getModel().getName() != null) {
queryWrapper.lambda().like(Device::getName, pageWrap.getModel().getName());
+ }
+ if (pageWrap.getModel().getDoorNo() != null) {
+ queryWrapper.lambda().like(Device::getDoorNo, pageWrap.getModel().getDoorNo());
+ }
+ if (pageWrap.getModel().getNo() != null) {
+ queryWrapper.lambda().like(Device::getNo, pageWrap.getModel().getNo());
}
if (pageWrap.getModel().getDoorName() != null) {
queryWrapper.lambda().like(Device::getDoorName, pageWrap.getModel().getDoorName());
@@ -343,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());
@@ -396,7 +428,7 @@
}
MqttClientCache.clientMapCache.put("device"+param.getId(),mqttClient);
String curremak = "銆�"+param.getLoginUserInfo().getRealname()
- +"銆戜簬"+ DateUtil.getPlusTime2(new Date()) +"杩涜浜�"+(Constants.equalsInteger(param.getStatus(),Constants.ONE)?"銆愬紑闂搞��":"銆愬叧闂搞��")+"鎿嶄綔,寮�鍏炽��"+param.getChannelNo()+"銆戯紱";
+ +"銆戜簬"+ DateUtil.getPlusTime2(new Date()) +"杩涜浜�"+(Constants.equalsInteger(param.getStatus(),Constants.ONE)?"銆愬悎闂搞��":"銆愬垎闂搞��")+"鎿嶄綔,寮�鍏炽��"+param.getChannelNo()+"銆戯紱";
deviceMapper.update(null,new UpdateWrapper<Device>().lambda()
// .setSql("remark = concat(ifnull(remark,''),'"+curremak+"','\n')")
.set(Device::getRemark,curremak)
@@ -414,7 +446,7 @@
data.setVal1("杩滅▼鎺у埗");
data.setVal2(curremak);
data.setHappenTime(DateUtil.getPlusTime2(data.getCreateDate()));
- data.setVal3((Constants.equalsInteger(param.getStatus(),Constants.ONE)?"銆愬紑闂搞��":"銆愬叧闂搞��"));
+ data.setVal3((Constants.equalsInteger(param.getStatus(),Constants.ONE)?"銆愬悎闂搞��":"銆愬垎闂搞��"));
data.setVal4(param.getLoginUserInfo().getRealname());
data.setVal5(param.getChannelNo());
deviceDataMapper.insert(data);
--
Gitblit v1.9.3