diff --git a/maibu-common/src/main/java/com/maibu/core/business/Device.java b/maibu-common/src/main/java/com/maibu/core/business/Device.java index 22553d4..2cdaf42 100644 --- a/maibu-common/src/main/java/com/maibu/core/business/Device.java +++ b/maibu-common/src/main/java/com/maibu/core/business/Device.java @@ -234,6 +234,12 @@ public class Device extends BaseDO { private Boolean hasHost; + @TableField(exist = false) + private String productModel;// 产品型号 + + @TableField(exist = false) + private String deviceType; + @TableField(exist = false) private LocationMessage locationMessage; diff --git a/maibu-common/src/main/java/com/maibu/mqtt/HostMessageHandler.java b/maibu-common/src/main/java/com/maibu/mqtt/HostMessageHandler.java index d0c17b5..d824e1b 100644 --- a/maibu-common/src/main/java/com/maibu/mqtt/HostMessageHandler.java +++ b/maibu-common/src/main/java/com/maibu/mqtt/HostMessageHandler.java @@ -570,16 +570,16 @@ public class HostMessageHandler implements CustomMqttMessageHandler { } } } - // try { - // NettyDevice device = deviceSessionManager.getDevice(deviceId); - // if (device != null && device.getDevice() != null) { - // Long siteId = device.getDevice().getSiteId(); - // websocketMesDispather.mapMessageDispather(siteId, - // JsonUtils.toJsonString(sendDto)); - // } - // } catch (Exception e) { - // log.error("实时地图数据websocket推送失败: siteId={}, error={}", e); - // } + try { + NettyDevice device = deviceSessionManager.getDevice(deviceId); + if (device != null && device.getDevice() != null) { + Long siteId = device.getDevice().getSiteId(); + websocketMesDispather.mapMessageDispather(siteId, + JsonUtils.toJsonString(sendDto)); + } + } catch (Exception e) { + log.error("实时地图数据websocket推送失败: siteId={}, error={}", e); + } // todo 推送实时位置和状态消息到外部 try { GlobalMemory.customMqttDeviceMonitor.publish(mqttClientId, diff --git a/maibu-service/maibu-iot-service/src/main/java/com/maibu/controller/HostComputerController.java b/maibu-service/maibu-iot-service/src/main/java/com/maibu/controller/HostComputerController.java index a15ce19..018c206 100644 --- a/maibu-service/maibu-iot-service/src/main/java/com/maibu/controller/HostComputerController.java +++ b/maibu-service/maibu-iot-service/src/main/java/com/maibu/controller/HostComputerController.java @@ -174,6 +174,16 @@ public class HostComputerController extends BaseController { } } } + try { + NettyDevice device = deviceSessionManager.getDevice(deviceId); + if (device != null && device.getDevice() != null) { + Long siteId = device.getDevice().getSiteId(); + websocketMesDispather.mapMessageDispather(siteId, + JsonUtils.toJsonString(dto)); + } + } catch (Exception e) { + log.error("实时地图数据websocket推送失败: siteId={}, error={}", e); + } GlobalMemory.customMqttDeviceMonitor.publish(mqttClientId, String.format(MqttTopic.DEVICE_ROUTE_PUSH_TOPIC, deviceId), JsonUtils.toJsonString(dto)); @@ -248,8 +258,6 @@ public class HostComputerController extends BaseController { String.format("%.6f", minLng), String.format("%.6f", maxLng)); } - - @GetMapping("/searchDevice") public AjaxResult searchDevice(@RequestParam String deviceId) throws Exception { hostComputerService.searchDevice(deviceId); diff --git a/maibu-service/maibu-iot-service/src/main/resources/mapper/iot/DeviceMapper.xml b/maibu-service/maibu-iot-service/src/main/resources/mapper/iot/DeviceMapper.xml index 8948c50..7b49c3f 100644 --- a/maibu-service/maibu-iot-service/src/main/resources/mapper/iot/DeviceMapper.xml +++ b/maibu-service/maibu-iot-service/src/main/resources/mapper/iot/DeviceMapper.xml @@ -9,9 +9,9 @@ - - - + + + @@ -52,8 +52,8 @@ d.org_id, d.site_id, d.device_name, - d.product_id, - d.product_name, + p.product_model, + p.device_type, d.tenant_id, d.tenant_name, d.serial_number, @@ -77,7 +77,7 @@ d.remark, d.slave_id from iot_device d - left join device_product p on d.product_id = p.id + left join iot_device_run_param p on d.device_name = p.device_id @@ -128,8 +128,10 @@ and d.gw_dev_code = #{gwDevCode} and d.device_name like concat('%', #{deviceName}, '%') - and d.product_id = #{productId} - and d.product_name like concat('%', #{productName}, + and p.device_type like concat('%', #{deviceType}, + '%') + + and p.product_model like concat('%', #{productModel}, '%') and d.tenant_id = #{tenantId} @@ -165,8 +167,10 @@ and ISNULL(a.device_id) and d.device_name like concat('%', #{deviceName}, '%') - and d.product_id = #{productId} - and d.product_name like concat('%', #{productName}, + and p.device_type like concat('%', #{deviceType}, + '%') + + and p.product_model like concat('%', #{productModel}, '%') and d.tenant_id = #{tenantId} @@ -264,7 +268,7 @@ - where device_name like concat('%', #{code}, '%') + where d.device_name like concat('%', #{code}, '%')