Merge branch 'herb' into cloud
# Conflicts:
# jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/MqttConstant.java
# jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/mqtt/MqttConfig.java
# jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/mqtt/MqttSampleCallback.java
# jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/service/impl/DryRealTimeDataServiceImpl.java
| | |
| | | |
| | | |
| | | String SERVICE_REQ_PREFIX = "service/req"; |
| | | String SERVICE_REQ_EQUIPMENT = SERVICE_REQ_PREFIX + "/%s/equipment"; |
| | | |
| | | String SERVICE_REQ_EQU_TOPIC = SERVICE_REQ_PREFIX + "/+/equipment"; |
| | | |
| | | |
| | | /**************************服务端向租户端请求数据end*******************************/ |
| | |
| | | case "user": |
| | | //普通客户端只需订阅自身相关消息 |
| | | mqttClient.subscribe(MqttConstant.SERVICE_DOWN_PREFIX + "/" + mqttClientId + "/#"); |
| | | mqttClient.subscribe(MqttConstant.SERVICE_REQ_PREFIX + "/" + mqttClientId.substring(mqttClientId.lastIndexOf("_")+1) + "/#"); |
| | | mqttClient.subscribe(MqttConstant.SERVICE_REQ_PREFIX); |
| | | System.err.println("user订阅" + MqttConstant.SERVICE_DOWN_PREFIX + "/" + mqttClientId + "/#"); |
| | | break; |
| | | |
| | |
| | | |
| | | |
| | | break; |
| | | case MqttConstant.SERVICE_REQ_EQU_TOPIC: |
| | | case MqttConstant.SERVICE_REQ_PREFIX: |
| | | log.debug("收到设备详细信息查询请求"); |
| | | String tenantId = messageJson.getString("tenantId"); |
| | | if (tenantId!=null && tenantId.equals(TenantContext.getTenant())) { |
| | | // 根据设备编码查询设备信息 |
| | | String code = messageJson.getString("code"); |
| | | DryEquipment equipmentVo = equipmentService.selectByTenantIdEquipmentId(TenantContext.getTenant(),code); |
| | | DryEquipment equipmentVo = equipmentService.selectByTenantIdEquipmentId(tenantId,code); |
| | | // 根据设备车间id查询车间信息 |
| | | DryShop shop = dryShopService.getById(equipmentVo.getShopId()); |
| | | |
| | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | break; |
| | | |
| | |
| | | mqttMessage.setQos(0); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("code", realTimeDataVo.getMachineid()); |
| | | object.put("tenantId", realTimeDataVo.getTenantid()); |
| | | mqttMessage.setPayload(object.toJSONString().getBytes()); |
| | | try { |
| | | mqttUtil.getMqttClient().publish(String.format(MqttConstant.SERVICE_REQ_EQUIPMENT, TenantContext.getTenant()) ,mqttMessage); |
| | | mqttUtil.getMqttClient().publish(MqttConstant.SERVICE_REQ_PREFIX ,mqttMessage); |
| | | }catch (MqttException e) { |
| | | e.printStackTrace(); |
| | | } |