Browse Source

<修复托管逻辑问题,修复托管状态点阵屏无法控制问题>

weizhengliang 3 years ago
parent
commit
ba0c7ae783

+ 4 - 2
app/src/main/java/com/wdkl/callingmainnurse/service/led/LedC2MManager.java

@@ -115,13 +115,15 @@ public class LedC2MManager extends LedManager {
                             Gson gson = new Gson();
                             DeviceInfoEntity entity = gson.fromJson(data, DeviceInfoEntity.class);
                             if (entity != null && entity.getDeviceInfoArray() != null && entity.getDeviceInfoArray().size() > 0) {
+                                //Log.e(TAG, "本机设备信息: myself id: " + Constants.MYSELF_ID + ", main id: " + Constants.CALLMAIN_ID + ", trust id: " + Constants.TRUST_OLD_MAIN_ID);
                                 for (DeviceInfoEntity.DeviceInfo deviceInfo : entity.getDeviceInfoArray()) {
                                     //获取该科室中添加的LED屏IP地址,只有状态为未启用的才由护士主机来控制,状态为启用的还是通过服务端控制
                                     //并且只有该护士主机所属的点阵屏设备才有效
+                                    //Log.e(TAG, "获取设备信息: host id: " + deviceInfo.getDEVICE_HOSTING_ID() + ", ip: " + deviceInfo.getDEVICE_ETH_IP());
                                     if (Constants.DEVICE_LED.equals(deviceInfo.getDEVICE_TYPE())
                                             && "0".equals(deviceInfo.getDEVICE_STATUS())
-                                            && Constants.MYSELF_ID.equals(deviceInfo.getDEVICE_HOSTING_ID())) {
-                                        Log.d(TAG, "led info: ip=" + deviceInfo.getDEVICE_ETH_IP() + "type: " + deviceInfo.getDEVICE_SN());
+                                            && (Constants.MYSELF_ID.equals(deviceInfo.getDEVICE_HOSTING_ID()) || Constants.TRUST_OLD_MAIN_ID.equals(deviceInfo.getDEVICE_HOSTING_ID()))) {
+                                        Log.d(TAG, "led info: ip=" + deviceInfo.getDEVICE_ETH_IP() + ", type: " + deviceInfo.getDEVICE_SN());
                                         LedItem item = new LedItem(deviceInfo.getDEVICE_SN(), deviceInfo.getDEVICE_ETH_IP());
                                         ledList.add(item);
                                     }

+ 20 - 20
app/src/main/java/com/wdkl/callingmainnurse/ui/fragment/TrusteeshipFragment.java

@@ -177,8 +177,9 @@ public class TrusteeshipFragment extends BaseFragment implements TrusteeshipAdap
             AnalysisUdpUtil.isOpen = true;
 //            serialPortUtil.closeSerialPort();
             tvNurseHostNoeds.setText(TrustToastTextUtil.setTrusting(getActivity(), SharedPreferencesUtil.getStringSp(getActivity(), INITTRUST, "trust")));
-        } else
+        } else {
             showTrust("1");//正常状态
+        }
         return mView;
     }
 
@@ -505,7 +506,7 @@ public class TrusteeshipFragment extends BaseFragment implements TrusteeshipAdap
 
 
                 if (mCountDownAutoTimerInterrupt == null) {
-                    mCountDownAutoTimerInterrupt = new CountDownTimer(10000, 1000) {
+                    mCountDownAutoTimerInterrupt = new CountDownTimer(3000, 1000) {
                         @Override
                         public void onTick(long l) {
 //                            tvStatus.setText("托管状态:取消中" + l / 1000);
@@ -520,7 +521,7 @@ public class TrusteeshipFragment extends BaseFragment implements TrusteeshipAdap
 //                            tvQuestTp.setText("托管状态:取消不成功,被托管设备未连接网络");
                             mCountDownAutoTimerInterrupt = null;
                             EventBus.getDefault().post(new MessageEvent(TRUST_FLAG_VALUE, Constants.EVENT_FRAGMENT_TRUST));
-                            AutoRebootUtil.reboot();
+                            //AutoRebootUtil.reboot();
                         }
                     };
                 }
@@ -571,7 +572,7 @@ public class TrusteeshipFragment extends BaseFragment implements TrusteeshipAdap
      */
     private void autoRestart(final String content) {
         if (mAutoRestartTimer == null) {//
-            mAutoRestartTimer = new CountDownTimer(10000, 1000) {
+            mAutoRestartTimer = new CountDownTimer(3000, 1000) {
                 @Override
                 public void onTick(long l) {
                     tvStatus.setText(content + l / 1000 + "秒");
@@ -702,11 +703,11 @@ public class TrusteeshipFragment extends BaseFragment implements TrusteeshipAdap
                         mToastH.postDelayed(auto, 50);
 
 //                        LogUtil.d("SSS", "本机收到原主机设备撤销托管要求" + "开启取消托管任务:自动重启倒计时:11111111111111");
-                        break;
                     }
+                    break;
                 }
-                //if (!initdataentity.getId().equals((mUdpEntityInfo).getDoorwayMachineID()))//
-                //    break;
+                if (!initdataentity.getId().equals((mUdpEntityInfo).getDoorwayMachineID()))//
+                    break;
                 LogUtil.d("托管", "主机二:接收主机一的取消托管请求");
                 showTrust("1");
                 LogUtil.d("托管", "跳过");
@@ -769,7 +770,7 @@ public class TrusteeshipFragment extends BaseFragment implements TrusteeshipAdap
                             }
                         }
                         if (mCountDownCancleTimer == null) {//开启恢复取消功能倒计时
-                            mCountDownCancleTimer = new CountDownTimer(10000, 1000) {
+                            mCountDownCancleTimer = new CountDownTimer(3000, 1000) {
                                 @Override
                                 public void onTick(long l) {
                                     tvStatus.setText("托管状态:" + "本机已完成:托管请求" + "取消功能恢复倒计时:" + l / 1000 + "秒");
@@ -903,18 +904,6 @@ public class TrusteeshipFragment extends BaseFragment implements TrusteeshipAdap
                                         mCountDownCancleTimer = null;
                                     }
 
-                                    //reboot device
-                                    Runnable auto = new Runnable() {
-                                        @Override
-                                        public void run() {
-                                            autoRestart("本机收到原主机设备撤销托管要求" + "开启取消托管任务:自动重启倒计时:");
-                                        }
-                                    };
-                                    if (mToastH == null) {
-                                        mToastH = new Handler();
-                                    }
-                                    mToastH.postDelayed(auto, 50);
-
                                 } else {
                                     if (jsonObj.getString("Code").equals("OK!")) {
 //                                        String data = jsonObj.getString("hostList");//
@@ -938,6 +927,17 @@ public class TrusteeshipFragment extends BaseFragment implements TrusteeshipAdap
                                         Log.w("Code", "网络错误");
                                     }
                                 }
+
+                                /*Runnable auto = new Runnable() {
+                                    @Override
+                                    public void run() {
+                                        autoRestart("自动重启倒计时:");
+                                    }
+                                };
+                                if (mToastH == null) {
+                                    mToastH = new Handler();
+                                }
+                                mToastH.postDelayed(auto, 50);*/
                             } catch (JSONException e) {
                                 e.printStackTrace();
                             }

+ 12 - 0
app/src/main/java/com/wdkl/callingmainnurse/util/AnalysisUdpUtil.java

@@ -4,6 +4,7 @@ import android.app.AlarmManager;
 import android.app.PendingIntent;
 import android.content.Context;
 import android.content.Intent;
+import android.text.TextUtils;
 import android.util.Log;
 
 import com.wdkl.callingmainnurse.MyApplication;
@@ -18,6 +19,7 @@ import org.greenrobot.eventbus.EventBus;
 
 import serialporttest.utils.SerialPortUtil;
 
+import static com.wdkl.callingmainnurse.common.Constants.CALLMAIN_ID;
 import static com.wdkl.callingmainnurse.common.Constants.MYSELF_ID;
 import static com.wdkl.callingmainnurse.common.Constants.TRUST_FLAG_VALUE;
 
@@ -343,6 +345,16 @@ public class AnalysisUdpUtil {
                     if (udpEntitys.getNurseHostID().equals(MYSELF_ID) || udpEntitys.getDoorwayMachineID().equals(MYSELF_ID)) {
                         EventBus.getDefault().post(new MessageEvent(3, Constants.EVENT_FRAGMENT));
                         EventBus.getDefault().post(new MessageEvent(11, Constants.EVENT_FRAGMENT_TRUST));
+                        if ("deposit_2".equals(data[0])) {
+                            //if (CALLMAIN_ID.contains("#")) {
+                                //托管中的机器
+                            //}
+
+                            //取消托管,重启设备
+                            if (!TextUtils.isEmpty(Constants.TRUST_OLD_MAIN_ID)) {
+                                AutoRebootUtil.reboot();
+                            }
+                        }
                     }
                     break;