From 0fbbf8c20ece1586a119fd4accc962fe73b5b268 Mon Sep 17 00:00:00 2001
From: 陈力 <chenli@lotaai.com>
Date: 星期三, 14 六月 2023 19:31:46 +0800
Subject: [PATCH] bug

---
 app/src/main/java/com/lotaai/canguiayw/mqtt/MyMQTTService.java |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/app/src/main/java/com/lotaai/canguiayw/mqtt/MyMQTTService.java b/app/src/main/java/com/lotaai/canguiayw/mqtt/MyMQTTService.java
index 65da2ac..1a0324a 100644
--- a/app/src/main/java/com/lotaai/canguiayw/mqtt/MyMQTTService.java
+++ b/app/src/main/java/com/lotaai/canguiayw/mqtt/MyMQTTService.java
@@ -55,7 +55,9 @@
     @Override
     public int onStartCommand(Intent intent, int flags, int startId) {
         init();
-        EventBus.getDefault().register(MyMQTTService.this);
+        if (!EventBus.getDefault().isRegistered(MyMQTTService.this)) {
+            EventBus.getDefault().register(MyMQTTService.this);
+        }
         return super.onStartCommand(intent, flags, startId);
     }
 
@@ -81,7 +83,7 @@
         // 服务器地址(协议+地址+端口号)
         String uri = "tcp://" + SettingConfig.getInstance().MQTT_IP+":"+SettingConfig.getInstance().MQTT_PORT;;
         LogUtils.i(uri);
-        client = new MqttAndroidClient(this, uri, CacheDiskUtils.getInstance().getString(SettingConfig.getInstance().Cache_Device_Code));
+        client = new MqttAndroidClient(this, uri, CacheDiskUtils.getInstance().getString(SettingConfig.getInstance().Cache_Device_Code)+"houping");
         // 设置MQTT监听并且接受消息
         client.setCallback(mqttCallback);
         conOpt = new MqttConnectOptions();
@@ -273,6 +275,12 @@
                     dvmessage.setDeviceType(DeviceType.CANGUI.ordinal());
                     dvmessage.setMessageByte(command);
                     EventBus.getDefault().post(dvmessage);
+                    //判断是否是取餐的,如果是取餐的,需要将这个订单从本地删除掉
+                    String qucan = json.getString("qucan");
+                    if (qucan!=null && "1".equals(qucan)){
+                        SqlliteDbManage.getInstance().deleteFromOrderByGridNo(grid);
+                        SqlliteDbManage.getInstance().updateGridByStr(grid,0);
+                    }
                 }
             }
         }

--
Gitblit v1.7.1