干燥机配套车间生产管理系统/云平台服务端
bsw215583320
2024-11-07 e62ffd3aaa1ba27b63885f8a3c8610ed283245d6
jeecg-module-dry/jeecg-module-dry-biz/src/main/java/org/jeecg/modules/dry/mqtt/MqttSampleCallback.java
@@ -254,28 +254,32 @@
        break;
      case MqttConstant.SERVICE_REQ_EQU_TOPIC:
      case MqttConstant.SERVICE_REQ_PREFIX:
        log.debug("收到设备详细信息查询请求");
        // 根据设备编码查询设备信息
        String code = messageJson.getString("code");
        DryEquipment equipmentVo = equipmentService.selectByTenantIdEquipmentId(TenantContext.getTenant(),code);
        // 根据设备车间id查询车间信息
        DryShop shop = dryShopService.getById(equipmentVo.getShopId());
        String tenantId = messageJson.getString("tenantId");
        if (tenantId!=null && tenantId.equals(TenantContext.getTenant())) {
          // 根据设备编码查询设备信息
          String code = messageJson.getString("code");
          DryEquipment equipmentVo = equipmentService.selectByTenantIdEquipmentId(tenantId,code);
          // 根据设备车间id查询车间信息
          DryShop shop = dryShopService.getById(equipmentVo.getShopId());
        JSONObject res = new JSONObject();
          JSONObject res = new JSONObject();
        res.put("tenant", TenantContext.getTenant());
        res.put("equipment", equipmentVo);
        res.put("shop", shop);
        try {
          MqttMessage sendMessage = new MqttMessage(res.toJSONString().getBytes());
          sendMessage.setQos(0);
          mqttUtil.getMqttClient().publish(MqttConstant.TENANT_UP_PREFIX_EQU, sendMessage);
          // baseCommonService.addLog(res.toString(), CommonConstant.LOG_TYPE_MQTT, CommonConstant.OPERATE_MQTT_2);
        } catch (Exception e) {
          e.printStackTrace();
          res.put("tenant", TenantContext.getTenant());
          res.put("equipment", equipmentVo);
          res.put("shop", shop);
          try {
            MqttMessage sendMessage = new MqttMessage(res.toJSONString().getBytes());
            sendMessage.setQos(0);
            mqttUtil.getMqttClient().publish(MqttConstant.TENANT_UP_PREFIX_EQU, sendMessage);
            // baseCommonService.addLog(res.toString(), CommonConstant.LOG_TYPE_MQTT, CommonConstant.OPERATE_MQTT_2);
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
        break;
    }