Prechádzať zdrojové kódy

西班牙客户需求变更:当患者从浴室拨打紧急电话时,走廊灯应每 1 秒闪烁一次红色,直到护士来到房间并按下终端屏幕上的绿色“护理”按钮。 房间内,则护士站的紧急呼叫必须消失,走廊灯必须变为绿色,直到护士离开房间时再次按下绿色按钮,灯必须关闭

weizhengliang 1 rok pred
rodič
commit
b83d37de16

+ 40 - 13
android_door/src/main/h10_a133_chile/java/com/wdkl/app/ncs/callingdoor/activity/CallingdoorActivity.kt

@@ -116,8 +116,11 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
     private var initialized :Boolean = false
     private var loaded: Boolean = false
 
+    private var sosItId: Int = -1
+    private var sosToId: Int = -1
     private var nursingInteId: Int = -1
     private var blueCodeId: Int = -1
+    private var blueCodeTid: String = ""
 
     private var clickTime : Long = 0
     private var clickSosTime : Long = 0
@@ -617,6 +620,18 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                     OtherUtil.sendNursingEnd(Constant.DEVICE_ID, nursingInteId)
                     nursingInteId = -1
                 }
+
+                //退出护理时同时取消blue code
+                if (Constant.inBlueCode) {
+                    Constant.inBlueCode = false
+                    room_action_blue_code.isEnabled = false
+
+                    SerialPortHelper.setDoorLight(0, "000")
+
+                    if (Constant.DEVICE_ID != -1 && blueCodeId != -1) {
+                        BlueCodeUtil.sendBlueCodeResponse(blueCodeTid, Constant.DEVICE_ID, blueCodeId)
+                    }
+                }
             } else {
                 Constant.inNursing = true
                 SettingConfig.setInNursing(activity, true)
@@ -627,6 +642,17 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                 }
             }
 
+            //当有紧急呼叫时按下护理后取消紧急呼叫灯,同时取消紧急呼叫
+            if (Constant.sosOn && Constant.DEVICE_ID != -1) {
+                SOSHelper.sosReset()
+                val tcpModel = OtherUtil.SOSCancel2(Constant.DEVICE_ID, sosToId, sosItId)
+                TcpClient.getInstance().sendMsg(tcpModel.toJson())
+
+                //按了护理清除呼叫信息
+                bedCalls.clear()
+                showCalls()
+            }
+
             return@setOnLongClickListener true
         }
 
@@ -804,7 +830,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                     if (Constant.inBlueCode) {
                         //退出blue code
                         Constant.inBlueCode = false
-                        room_action_blue_code.setText(R.string.str_blue_code)
+                        /*room_action_blue_code.setText(R.string.str_blue_code)
                         if (!Constant.inNursing) {
                             room_action_blue_code.isEnabled = false
                         }
@@ -812,11 +838,11 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
 
                         if (blueCodeId != -1) {
                             BlueCodeUtil.sendBlueCodeResponse(Constant.DEVICE_ID, blueCodeId)
-                        }
+                        }*/
                     } else {
                         //进入blue code
                         Constant.inBlueCode = true
-                        room_action_blue_code.setText(R.string.str_cancel)
+                        room_action_blue_code.isEnabled = false
                         //蓝色门灯0.25s闪烁一次
                         DoorLightHelper.blueCodeLight()
 
@@ -1549,7 +1575,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                     } else if (tcpModel.type == TcpType.SOS) {
                         if (tcpModel.action == TcpAction.SOSAction.CANCEL) {
                             //紧急呼叫已处理
-                            SOSHelper.sosStop()
+                            //SOSHelper.sosStop()
                         }
                     } else if (tcpModel.type == TcpType.DEVICE) {
                         //检查APP版本
@@ -1633,14 +1659,15 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                             //blue code请求成功
                             val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
                             blueCodeId = interactionVO.id
+                            blueCodeTid = tcpModel.tid
                         } else if (tcpModel.action == TcpAction.BlueCodeAction.RESPONDED) {
                             //主机响应blue code
-                            Constant.inBlueCode = false
+                            /*Constant.inBlueCode = false
                             room_action_blue_code.setText(R.string.str_blue_code)
                             if (!Constant.inNursing) {
                                 room_action_blue_code.isEnabled = false
                             }
-                            DoorLightHelper.resetDoorLight()
+                            DoorLightHelper.resetDoorLight()*/
                         }
                     }
                 }
@@ -1707,6 +1734,9 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
             //SerialPortHelper.setDoorLight(1, "200")
             SerialPortHelper.flashDoorLight("100", 1000) //红色间隔1s闪烁
             Constant.sosOn = true
+            val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
+            sosItId = interactionVO.id
+            sosToId = interactionVO.fromDeviceId
         } else if (tcpModel.action == TcpAction.SideAction.ACCEPT || tcpModel.action == TcpAction.SideAction.CANCEL) {
             if (Constant.CALL_STATE == Constant.CALL_STANDBY) {
                 RingPlayHelper.stopRingTone()
@@ -1723,13 +1753,10 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                 //}
             }
         } else if (tcpModel.action == TcpAction.SideAction.SOS_CANCEL) {
-            Constant.sosOn = false
+            /*Constant.sosOn = false
             if (SettingConfig.getDoorLightAlwaysOn(activity) == 0) {
-                //如果当前还有其他床位呼叫或者是紧急呼叫则不重置门灯
-                //if (bedCalls.size == 0) {
-                    DoorLightHelper.resetDoorLight()
-                //}
-            }
+                DoorLightHelper.resetDoorLight()
+            }*/
         }
     }
 
@@ -1768,7 +1795,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                     val iterator = bedCalls.iterator()
                     while (iterator.hasNext()) {
                         val it = iterator.next()
-                        if (it.text == showText) {
+                        if (it.text == showText && interactionVO.actionType != TcpType.SOS.name) {
                             iterator.remove()
                         }
                     }

+ 26 - 41
android_door/src/main/h10_a133_chile/java/com/wdkl/app/ncs/callingdoor/helper/SOSHelper.java

@@ -15,55 +15,40 @@ import com.wdkl.ncs.android.middleware.tcp.channel.OtherUtil;
  */
 public class SOSHelper {
 
-    private static final Handler handler = new Handler(Looper.getMainLooper()) {
-        @Override
-        public void handleMessage(Message msg) {
-            sosStop();
-        }
-    };
-
     public static void sosStart() {
-        //if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL)) {
-            SerialPortHelper.setSosLight("2");
-            int beds = Utils.getInBedVOS().size();
-            if (beds <= 0) {
-                OtherUtil.sendSosCall(Constant.DEVICE_ID);
-            } else {
-                OtherUtil.sendSosRoomCall(Utils.getInBedVOS().get(0).getBedDeviceId());
-            }
-
-            //SerialPortHelper.setDoorLight(1, "200"); //红色闪烁
-            SerialPortHelper.flashDoorLight("100", 1000); //红色间隔1s闪烁
+        SerialPortHelper.setSosLight("2");
+        int beds = Utils.getInBedVOS().size();
+        if (beds <= 0) {
+            OtherUtil.sendSosCall(Constant.DEVICE_ID);
+        } else {
+            OtherUtil.sendSosRoomCall(Utils.getInBedVOS().get(0).getBedDeviceId());
+        }
 
-            Constant.sosOn = true;
+        //SerialPortHelper.setDoorLight(1, "200"); //红色闪烁
+        SerialPortHelper.flashDoorLight("100", 1000); //红色间隔1s闪烁
 
-            //紧急按钮灯自动复位
-            handler.removeCallbacksAndMessages(null);
-            handler.sendEmptyMessageDelayed(110, 30*60000);
-        //}
+        Constant.sosOn = true;
     }
 
     public static void sosStop() {
-        //if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL)) {
-            handler.removeCallbacksAndMessages(null);
-            /*if (Constant.day_state == 1) {
-                SerialPortHelper.setSosLight("1");
-            } else {
-                SerialPortHelper.setSosLight("0");
-            }*/
-            SerialPortHelper.setSosLight("0");
+        SerialPortHelper.setSosLight("0");
 
-            Constant.sosOn = false;
+        Constant.sosOn = false;
 
-            //如果当前在护理中则不操作门灯,如果不在护理中则重置门灯
-            if (SettingConfig.getDoorLightAlwaysOn(BaseApplication.appContext) == 0) {
-                if (Constant.inNursing) {
-                    SerialPortHelper.setDoorLight(1, Constant.nursingColor); //绿色
-                } else {
-                    //SerialPortHelper.setDoorLight(1, "111"); //白色
-                    DoorLightHelper.resetDoorLight();
-                }
+        //如果当前在护理中则不操作门灯,如果不在护理中则重置门灯
+        if (SettingConfig.getDoorLightAlwaysOn(BaseApplication.appContext) == 0) {
+            if (Constant.inNursing) {
+                SerialPortHelper.setDoorLight(1, Constant.nursingColor); //绿色
+            } else {
+                //SerialPortHelper.setDoorLight(1, "111"); //白色
+                DoorLightHelper.resetDoorLight();
             }
-        //}
+        }
+    }
+
+    public static void sosReset() {
+        SerialPortHelper.setSosLight("0");
+
+        Constant.sosOn = false;
     }
 }

+ 4 - 4
middleware/src/main/code/com/wdkl/ncs/android/middleware/tcp/channel/BlueCodeUtil.java

@@ -22,8 +22,8 @@ public class BlueCodeUtil {
         return tcpModel;
     }
 
-    public static TcpModel BlueCodeResponse(Integer fromId, Integer interactionId){
-        TcpModel tcpModel = new TcpModel(null);
+    public static TcpModel BlueCodeResponse(String tid, Integer fromId, Integer interactionId){
+        TcpModel tcpModel = new TcpModel(tid);
         tcpModel.setType(TcpType.BLUE_CODE);
         tcpModel.setAction(TcpAction.BlueCodeAction.RESPONSE);
         tcpModel.setFromId(fromId);
@@ -46,8 +46,8 @@ public class BlueCodeUtil {
         TcpClient.getInstance().sendMsg(tcpModel.toJson());
     }
 
-    public static void sendBlueCodeResponse(Integer fromId, Integer interactionId) {
-        TcpModel tcpModel = BlueCodeUtil.BlueCodeResponse(fromId, interactionId);
+    public static void sendBlueCodeResponse(String tid, Integer fromId, Integer interactionId) {
+        TcpModel tcpModel = BlueCodeUtil.BlueCodeResponse(tid, fromId, interactionId);
         TcpClient.getInstance().sendMsg(tcpModel.toJson());
     }
 }

+ 10 - 0
middleware/src/main/code/com/wdkl/ncs/android/middleware/tcp/channel/OtherUtil.java

@@ -32,6 +32,16 @@ public class OtherUtil {
         return tcpModel;
     }
 
+    public static TcpModel SOSCancel2(Integer fromId, Integer toId, Integer interactionId){
+        TcpModel tcpModel = new TcpModel(null);
+        tcpModel.setType(TcpType.SOS);
+        tcpModel.setAction(TcpAction.SOSAction.CANCEL);
+        tcpModel.setFromId(fromId);
+        tcpModel.setToId(toId);
+        tcpModel.setData(interactionId);
+        return tcpModel;
+    }
+
     public static TcpModel nursing(Integer fromId){
         TcpModel tcpModel = new TcpModel(null);
         tcpModel.setType(TcpType.SIDE);