Browse Source

门口机端门灯控制优化及其他优化

weizhengliang 7 months ago
parent
commit
2a09a88f02

+ 4 - 0
android_bed/src/main/java/com/wdkl/app/ncs/callingbed/adapter/DeviceMenuAdapter.kt

@@ -48,12 +48,16 @@ class DeviceMenuAdapter : RecyclerView.Adapter<DeviceMenuAdapter.ViewHolder>{
         if ( data.get(position).name!=null){
             holder.textView.text = data.get(position).name
         }
+
         if (data.get(position).icon_src!=null && !data.get(position).icon_src.equals("")){
             Glide.with(holder.imageView.context)
                     .load( data.get(position).icon_src)
                     .diskCacheStrategy(DiskCacheStrategy.ALL)
                     .into(holder.imageView)
+        } else {
+            holder.imageView.setImageResource(R.drawable.ic_device)
         }
+
         holder.actionView.setOnClickListener {
             onItemClickListener.onItemClick(holder.itemView, position)
         }

+ 15 - 48
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/activity/CallingdoorActivity.kt

@@ -359,7 +359,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
         }
     }
     //会到首页
-    fun BackMain() {
+    fun backToMain() {
         if (!mainFragment.equals(curFragment)) {
             updateLeftBtState(mainFragment)
             switchFragment(R.id.callingdoor_main_frame, MainFragment(), mainFragment)
@@ -680,7 +680,6 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                 showMessage(R.string.net_error)
             }
 
-            Constant.callNums = 0
             DoorLightHelper.resetDoorLight()
             SpeechUtil.getInstance().stopSpeak()
             bedCalls.clear()
@@ -689,37 +688,6 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
 
     }
 
-    //开启网络调试
-    private fun openNetwrokDebug() {
-        val commands = arrayListOf(
-                "/system/bin/sh",
-                "setprop service.adb.tcp.port 5555",
-                "stop adbd",
-                "start adbd"
-        )
-        try {
-            RunAsRoot(commands)
-        } catch (e: IOException) {
-            e.printStackTrace()
-        }
-    }
-
-
-    private fun RunAsRoot(cmds: ArrayList<String>) {
-        val p = Runtime.getRuntime().exec("su")
-        val os = DataOutputStream(p.outputStream)
-        for (tmpCmd in cmds) {
-            os.writeBytes(
-                    """
-            $tmpCmd
-            
-            """.trimIndent()
-            )
-        }
-        os.writeBytes("exit\n")
-        os.flush()
-    }
-
     //设置串口监听
      fun setSerialListener() {
         // 串口监听
@@ -1039,7 +1007,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
 
     private fun regReceiver() {
         receiver = TimeReceiver()
-        var intentFilter = IntentFilter()
+        val intentFilter = IntentFilter()
         intentFilter.addAction(Intent.ACTION_TIME_TICK)
         intentFilter.addAction(Intent.ACTION_TIMEZONE_CHANGED)
         intentFilter.addAction(Intent.ACTION_TIME_CHANGED)
@@ -1346,7 +1314,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
 
                             nursingInteId = interactionVO.id
                             SettingConfig.setNursingId(activity, nursingInteId)
-                            SerialPortHelper.setDoorLight(1, Constant.nursingColor) //绿色
+                            HardWareFactroy.getHardTools().setDoorLight(1)
                         } else if (tcpModel.action == TcpAction.SideAction.SHOW || tcpModel.action == TcpAction.SideAction.CLEAR) {
                             //显示分机呼叫或紧急呼叫
                             updateCallInfo(tcpModel)
@@ -1415,26 +1383,21 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
 
     private fun callControl(tcpModel: TcpModel) {
         if (tcpModel.action == TcpAction.SideAction.CALL) {
-            Constant.callNums++
-            SerialPortHelper.setDoorLight(1, "200")
+            HardWareFactroy.getHardTools().setDoorLight(3)
         } else if (tcpModel.action == TcpAction.SideAction.SOS_CALL) {
-            SerialPortHelper.setDoorLight(1, "200")
+            HardWareFactroy.getHardTools().setDoorLight(3)
             Constant.sosOn = true
         } else if (tcpModel.action == TcpAction.SideAction.ACCEPT || tcpModel.action == TcpAction.SideAction.CANCEL) {
-            Constant.callNums--
-            if (Constant.callNums < 0) {
-                Constant.callNums = 0
-            }
             //如果当前还有其他床位呼叫或者是紧急呼叫则不重置门灯
-            if (Constant.callNums == 0 && !Constant.sosOn) {
+            if (bedCalls.size == 0 && !Constant.sosOn) {
                 DoorLightHelper.resetDoorLight()
             }
         } else if (tcpModel.action == TcpAction.SideAction.SOS_CANCEL) {
             Constant.sosOn = false
-            if (Constant.callNums == 0) {
+            if (bedCalls.size == 0) {
                 DoorLightHelper.resetDoorLight()
             }
-        }else if (tcpModel.action == TcpAction.SideAction.NURSING ||tcpModel.action == TcpAction.SideAction.NURSING_END) {
+        } else if (tcpModel.action == TcpAction.SideAction.NURSING ||tcpModel.action == TcpAction.SideAction.NURSING_END) {
             DoorLightHelper.resetDoorLight()
         }
     }
@@ -1491,12 +1454,19 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                         }
                     }
                 }
+
+                //此时若没有分机呼叫和紧急呼叫则重置门灯
+                if (bedCalls.size == 0 && !Constant.sosOn) {
+                    DoorLightHelper.resetDoorLight()
+                }
+
                 /*if (Locale.CHINESE.language.equals(language)) {
                     if (Constant.TTS_STATUS == 2) {
                         SpeechUtil.getInstance().removeSpeak(speechText)
                     }
                 }*/
             }
+
             //分机呼叫显示
             showCalls()
         } catch (ex: Exception) {
@@ -1523,9 +1493,6 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                 runOnUiThread {
                     showCalls()
                 }
-            } else {
-                Constant.callNums = 0
-                DoorLightHelper.resetDoorLight()
             }
         } catch (ex: Exception) {
             ex.printStackTrace()

+ 1 - 1
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/activity/SetHintActivity.kt

@@ -171,7 +171,7 @@ class SetHintActivity : BaseActivity<SetHintActivityPresenter, CallingdoorNurseM
                     timer1?.cancel()
                     //退出护理 直接回到首页。
                     YhUtil.sendReinforceResponsed(Constant.DEVICE_ID, id.toInt())
-                    (activity as CallingdoorActivity).BackMain()
+                    (activity as CallingdoorActivity).backToMain()
                 }
             }.start()
 

+ 4 - 4
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/adapter/DeviceMenuAdapter.kt

@@ -50,18 +50,18 @@ class DeviceMenuAdapter : RecyclerView.Adapter<DeviceMenuAdapter.ViewHolder>{
         if ( data.get(position).name!=null){
             holder.textView.text = data.get(position).name
         }
+
         if (data.get(position).icon_src!=null && !data.get(position).icon_src.equals("")){
             Glide.with(holder.imageView.context)
                     .load( data.get(position).icon_src)
                     .diskCacheStrategy(DiskCacheStrategy.ALL)
                     .into(holder.imageView)
-        }else{
-            holder.imageView.visibility=View.GONE
+        } else {
+            holder.imageView.setImageResource(R.drawable.ic_device)
         }
-//        holder.imageView1.visibility=View.VISIBLE
+
         holder.actionView.setOnClickListener {
             onItemClickListener.onItemClick(holder.itemView, position)
-//            onItemClickListener?.onItemClick(holder.itemView, data?.get(position).id)
         }
     }
 

+ 2 - 2
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/fragment/NurseFragment.kt

@@ -59,7 +59,7 @@ class NurseFragment : BaseFragment<NurseFragmentPresenter, CallingdoorNurseMainB
            //退出医护
         nurse_main_bt.setOnClickListener {
             YhUtil.sendReinforceResponsed(Constant.DEVICE_ID, id.toInt())
-            (activity as CallingdoorActivity).BackMain()
+            (activity as CallingdoorActivity).backToMain()
         }
         //定位
         nurse_main_1_ll.setOnClickListener {
@@ -237,7 +237,7 @@ class NurseFragment : BaseFragment<NurseFragmentPresenter, CallingdoorNurseMainB
                 ExitHuliDialogHelper.showDialog(activity,object : ExitHuliDialogHelper.ClickListener {
                     override fun onClick() {
                         YhUtil.sendReinforceResponsed(Constant.DEVICE_ID, id.toInt())
-                        (activity as CallingdoorActivity).BackMain()
+                        (activity as CallingdoorActivity).backToMain()
                     }
                 })
 

+ 9 - 15
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/fragment/NursingWorkFragment.kt

@@ -3,6 +3,7 @@ package com.wdkl.app.ncs.callingdoor.fragment
 import android.content.Intent
 import android.content.res.Configuration
 import android.os.CountDownTimer
+import android.text.TextUtils
 
 import android.util.Log
 import android.view.View
@@ -26,6 +27,7 @@ import com.wdkl.ncs.android.middleware.logic.contract.callingdoor.NursingWorkFra
 import com.wdkl.ncs.android.middleware.logic.presenter.callingdoor.NursingWorkFragmentPresenter
 import com.wdkl.ncs.android.middleware.model.vo.DeviceMenulist
 import com.wdkl.ncs.android.middleware.tcp.channel.YhUtil
+import com.wdkl.ncs.android.middleware.utils.StringUtil
 import kotlinx.android.synthetic.main.callingdoor_nurse_main.*
 import kotlinx.android.synthetic.main.nursing_work_lay.*
 import org.greenrobot.eventbus.EventBus
@@ -36,15 +38,12 @@ import org.json.JSONObject
 
 class NursingWorkFragment : BaseFragment<NursingWorkFragmentPresenter, NursingWorkLayBinding>(), NursingWorkFragmentContract.View ,DeviceMenuAdapter.OnItemClickListener{
     val TAG = "QrCodeFragment"
-    val pattern = "\\$([^#]*)#".toRegex()
     var id: String? = ""
-    var cardNo: String? = null
 
     var type: String? = ""
     var name: String? = ""
     private var allOrders = ArrayList<DeviceMenulist>()
     private lateinit var deviceMenuapter : DeviceMenuAdapter
-    private lateinit var timer: CountDownTimer
 
     override fun getLayId(): Int {
         return R.layout.nursing_work_lay
@@ -75,9 +74,9 @@ class NursingWorkFragment : BaseFragment<NursingWorkFragmentPresenter, NursingWo
             deviceMenuapter.setOnItemClickListener(this)
             recycler.adapter = deviceMenuapter
         }
-        var part_id =Constant.DEVICE_REGISTER_ID
-        if (part_id!=null){
-            presenter.DeviceMenulist(part_id!!, )
+
+        if (StringUtil.notEmpty(Constant.DEVICE_REGISTER_ID)){
+            presenter.DeviceMenulist(Constant.DEVICE_REGISTER_ID)
         }
     }
     //点击事件
@@ -91,7 +90,6 @@ class NursingWorkFragment : BaseFragment<NursingWorkFragmentPresenter, NursingWo
 
 
     override fun setlist(a: List<String>) {
-        val components = a
 
     }
 
@@ -108,8 +106,9 @@ class NursingWorkFragment : BaseFragment<NursingWorkFragmentPresenter, NursingWo
                 }
             }
             deviceMenuapter.updateData(allOrders)
+        } else {
+            showDefaultDeviceMenu()
         }
-
     }
 
     override fun onNoneNet() {
@@ -143,12 +142,7 @@ class NursingWorkFragment : BaseFragment<NursingWorkFragmentPresenter, NursingWo
         super.onStart()
     }
 
-    override fun onResume() {
-        super.onResume()
-    }
-    override fun onPause() {
-        super.onPause()
-    }
+
     override fun onStop() {
         if (EventBus.getDefault().isRegistered(this)) {
             EventBus.getDefault().unregister(this);
@@ -226,7 +220,7 @@ class NursingWorkFragment : BaseFragment<NursingWorkFragmentPresenter, NursingWo
                         HuliTiemDialogHelper.showDialog(activity,true,object : HuliTiemDialogHelper.ClickListener {
                             override fun onClick(time: Int) {
                                 (activity as CallingdoorActivity).setHuli(time)
-                                }
+                            }
                         })
                     }
 

+ 0 - 26
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/helper/DoorLightHelper.java

@@ -9,32 +9,6 @@ import com.wdkl.ncs.android.middleware.tcp.enums.TcpAction;
 
 public class DoorLightHelper {
 
-    public static void handleDoorLight(TcpModel tcpModel) {
-        if (TcpAction.SideAction.CALL == tcpModel.getAction()
-            || TcpAction.SideAction.SOS_CALL == tcpModel.getAction()) {
-            //门灯红色闪烁
-            SerialPortHelper.setDoorLight(1, "200"); //红色闪烁
-
-            if (TcpAction.SideAction.SOS_CALL == tcpModel.getAction()) {
-                Constant.sosOn = true;
-            }
-        } else if (TcpAction.SideAction.ACCEPT == tcpModel.getAction()
-            || TcpAction.SideAction.CANCEL == tcpModel.getAction()
-            || TcpAction.SideAction.SOS_CANCEL == tcpModel.getAction()) {
-            //如果当前在护理中则不操作门灯,如果不在护理中则重置门灯
-            if (Constant.inNursing) {
-                SerialPortHelper.setDoorLight(1, Constant.nursingColor); //绿色
-            } else {
-                //SerialPortHelper.setDoorLight(1, "111"); //白色
-                resetDoorLight();
-            }
-
-            if (TcpAction.SideAction.SOS_CANCEL == tcpModel.getAction()) {
-                Constant.sosOn = false;
-            }
-        }
-    }
-
     public static void resetDoorLight() {
         //有人入住时点亮门灯,无人入住关闭门灯
         Constant.inNursing = SettingConfig.getInNursing(BaseApplication.appContext);

+ 7 - 14
callingdoor/src/main/res/layout-land/item_icon_lay.xml

@@ -1,42 +1,36 @@
 <?xml version="1.0" encoding="utf-8"?>
 <layout xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <data>
-
-    </data>
-
     <LinearLayout
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginRight="@dimen/d28"
         android:layout_marginBottom="@dimen/d15"
-        >
+        android:background="@drawable/shape_bed_bg">
 
         <LinearLayout
             android:id="@+id/ll_menu_bt"
             android:layout_width="@dimen/d270"
             android:layout_height="126dp"
-            android:orientation="horizontal"
             android:gravity="center_vertical"
-            android:background="@drawable/shape_bed_bg"
-            android:layout_below="@+id/tv_nursing_code">
+            android:orientation="horizontal">
 
             <ImageView
                 android:id="@+id/img_menu"
                 android:layout_width="67dp"
                 android:layout_height="67dp"
                 android:layout_marginLeft="@dimen/d34"
-                />
+                android:src="@drawable/ic_device"/>
 
             <TextView
                 android:id="@+id/tx_menu"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:textColor="@color/black"
-                android:textStyle="bold"
                 android:layout_marginLeft="@dimen/d20"
                 android:text="设备信息"
-                android:textSize="17sp" />
+                android:textColor="@color/black"
+                android:textSize="17sp"
+                android:textStyle="bold" />
 
             <ImageView
                 android:id="@+id/img_menu1"
@@ -44,8 +38,7 @@
                 android:layout_height="@dimen/d20"
                 android:layout_marginLeft="@dimen/d15"
                 android:layout_marginRight="@dimen/d30"
-                android:background="@mipmap/jr"
-                />
+                android:background="@mipmap/jr" />
         </LinearLayout>
 
     </LinearLayout>

+ 7 - 14
callingdoor/src/main/res/layout/nursing_work_lay.xml

@@ -1,23 +1,16 @@
 <?xml version="1.0" encoding="utf-8"?>
 <layout xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <data>
-
-    </data>
-
     <RelativeLayout
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:background="#F7F7F7"
-        >
+        android:background="#EAF2F9">
 
-            <androidx.recyclerview.widget.RecyclerView
-                android:id="@+id/recycler"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:background="#F7F7F7"
-                android:clipChildren="true"
-                android:padding="@dimen/font_size_20"
-                />
+        <androidx.recyclerview.widget.RecyclerView
+            android:id="@+id/recycler"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:clipChildren="true"
+            android:padding="@dimen/font_size_20" />
     </RelativeLayout>
 </layout>

+ 0 - 2
middleware/src/main/code/com/wdkl/ncs/android/middleware/common/Constant.java

@@ -291,8 +291,6 @@ public class Constant {
     //床位是否有人入住
     public static boolean bedCustomIn = false;
 
-    public static int callNums = 0;
-
     //来电设备id
     public static Integer fromId = -1;
     public static int callingId = -1;