|
@@ -31,6 +31,7 @@ import com.hfln.portal.domain.customer.util.WxOfficeAccountClient;
|
|
import com.hfln.portal.domain.exception.ErrorEnum;
|
|
import com.hfln.portal.domain.exception.ErrorEnum;
|
|
import com.hfln.portal.domain.gateway.DeviceGateway;
|
|
import com.hfln.portal.domain.gateway.DeviceGateway;
|
|
import com.hfln.portal.infrastructure.mqtt.MqttClient;
|
|
import com.hfln.portal.infrastructure.mqtt.MqttClient;
|
|
|
|
+import com.hfln.portal.infrastructure.mqtt.MqttSubHandle;
|
|
import com.hfln.portal.infrastructure.oss.OssClient;
|
|
import com.hfln.portal.infrastructure.oss.OssClient;
|
|
import com.hfln.portal.infrastructure.oss.OssUtils;
|
|
import com.hfln.portal.infrastructure.oss.OssUtils;
|
|
import com.hfln.portal.infrastructure.po.*;
|
|
import com.hfln.portal.infrastructure.po.*;
|
|
@@ -99,6 +100,9 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
@Autowired
|
|
@Autowired
|
|
private TblTenantService tblTenantService;
|
|
private TblTenantService tblTenantService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private MqttSubHandle mqttSubHandle;
|
|
|
|
+
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public HomeInfoDTO queryHomeInfo(Long userId) {
|
|
public HomeInfoDTO queryHomeInfo(Long userId) {
|
|
@@ -575,72 +579,22 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
// 更新dev_room表
|
|
// 更新dev_room表
|
|
devRoomService.saveOrUpdate(param);
|
|
devRoomService.saveOrUpdate(param);
|
|
|
|
|
|
- //发送家具信息到算法
|
|
|
|
- String topic = String.format(TopicConstants.TOPIC_DAS_SET_FURNITURE_PARAM, devInfo.getClientId());
|
|
|
|
- JSONObject msg = new JSONObject();
|
|
|
|
- msg.put("dev_id", devInfo.getClientId());
|
|
|
|
- if (mqttClient != null) {
|
|
|
|
- try{
|
|
|
|
- mqttClient.sendMessage(topic, msg.toJSONString());
|
|
|
|
- log.info("Message sent successfully to topic: {}", topic); // 记录消息发送成功的日志
|
|
|
|
- } catch (Exception e){
|
|
|
|
- log.error("Failed to send message to topic: {}", topic, e); // 记录发送失败的错误日志
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- log.warn("MQTT client is not available, message not sent to topic: {}", topic); // 记录客户端不可用的警告日志
|
|
|
|
|
|
+ // 发送家具信息到算法
|
|
|
|
+ if (param.getFurnitures() != null && !param.getFurnitures().isEmpty()) {
|
|
|
|
+ mqttSubHandle.sendMqttMessage(TopicConstants.TOPIC_DAS_SET_FURNITURE_PARAM, devInfo.getClientId());
|
|
}
|
|
}
|
|
|
|
|
|
- //发送屏蔽子区域信息到算法
|
|
|
|
- String subTopic = String.format(TopicConstants.TOPIC_DAS_SET_SUB_REGION_PARAM, devInfo.getClientId());
|
|
|
|
- JSONObject subRegionMsg = new JSONObject();
|
|
|
|
- msg.put("dev_id", devInfo.getClientId());
|
|
|
|
- if (mqttClient != null) {
|
|
|
|
- try{
|
|
|
|
- mqttClient.sendMessage(subTopic, subRegionMsg.toJSONString());
|
|
|
|
- log.info("Message sent successfully to topic: {}", subTopic); // 记录消息发送成功的日志
|
|
|
|
- } catch (Exception e){
|
|
|
|
- log.error("Failed to send message to topic: {}", subTopic, e); // 记录发送失败的错误日志
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- log.warn("MQTT client is not available, message not sent to topic: {}", subTopic); // 记录客户端不可用的警告日志
|
|
|
|
|
|
+ // 发送屏蔽子区域信息到算法
|
|
|
|
+ if (subRegions != null && !subRegions.isEmpty()) {
|
|
|
|
+ mqttSubHandle.sendMqttMessage(TopicConstants.TOPIC_DAS_SET_SUB_REGION_PARAM, devInfo.getClientId());
|
|
}
|
|
}
|
|
|
|
|
|
- //发送子区域信息到设备
|
|
|
|
|
|
+ // 发送子区域信息到设备
|
|
if (subRegions != null && !subRegions.isEmpty()) {
|
|
if (subRegions != null && !subRegions.isEmpty()) {
|
|
- JSONArray extSubRegions = new JSONArray();
|
|
|
|
- for (SubRegionInfo region : subRegions) {
|
|
|
|
- JSONObject base = new JSONObject();
|
|
|
|
- base.put("x_cm_start", region.getStartXx());
|
|
|
|
- base.put("x_cm_stop", region.getStopXx());
|
|
|
|
- base.put("y_cm_start", region.getStartYy());
|
|
|
|
- base.put("y_cm_stop", region.getStopYy());
|
|
|
|
- base.put("presence_enter_duration", region.getPresenceEnterDuration());
|
|
|
|
- base.put("presence_exit_duration", region.getPresenceExitDuration());
|
|
|
|
- base.put("track_presence", region.getTrackPresence());
|
|
|
|
- base.put("exclude_falling", region.getExcludeFalling());
|
|
|
|
-
|
|
|
|
- JSONObject regionJson = new JSONObject();
|
|
|
|
- regionJson.put("base", base);
|
|
|
|
- regionJson.put("z_cm_start", region.getStartZz());
|
|
|
|
- regionJson.put("z_cm_stop", region.getStopZz());
|
|
|
|
- regionJson.put("is_low_snr", region.getIsLowSnr());
|
|
|
|
- regionJson.put("is_door", region.getIsDoor());
|
|
|
|
-
|
|
|
|
- extSubRegions.add(regionJson);
|
|
|
|
- }
|
|
|
|
- JSONObject infoMsg = new JSONObject();
|
|
|
|
- infoMsg.put("ext_sub_regions", extSubRegions);
|
|
|
|
-
|
|
|
|
- String topicDev = String.format(TopicConstants.TOPIC_SET_DEVICE_PARAM, devInfo.getClientId());
|
|
|
|
- try {
|
|
|
|
- mqttClient.sendMessage(topicDev, infoMsg.toJSONString());
|
|
|
|
- log.info("SubRegions message sent successfully to topic: {}", topicDev);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("Failed to send subRegions message to topic: {}", topicDev, e);
|
|
|
|
- }
|
|
|
|
|
|
+ mqttSubHandle.sendSubRegionToDevice(devInfo.getClientId(), subRegions);
|
|
}
|
|
}
|
|
|
|
|
|
- return null;
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|