Browse Source

<设置中增加查询转换盒状态>

weizhengliang 4 năm trước cách đây
mục cha
commit
9d25ca08ed

+ 1 - 1
app/build.gradle

@@ -24,7 +24,7 @@ android {
         minSdkVersion 21
         targetSdkVersion 26
         versionCode 1
-        versionName "1.7"
+        versionName "1.71"
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
         multiDexEnabled true
 

+ 84 - 0
app/src/main/java/com/wdkl/callingmainnurse/adapter/TraditionDeviceAdapter.java

@@ -0,0 +1,84 @@
+package com.wdkl.callingmainnurse.adapter;
+
+import android.content.Context;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.wdkl.callingmainnurse.R;
+import com.wdkl.callingmainnurse.entity.HostDevice;
+
+import java.util.List;
+
+public class TraditionDeviceAdapter extends RecyclerView.Adapter<TraditionDeviceAdapter.MyViewHolder> {
+    private List<HostDevice> devices;
+    private Context mContext;
+    private OnItemClickListener clickListener;
+
+    public TraditionDeviceAdapter(Context context, List<HostDevice> data) {
+        mContext = context;
+        devices = data;
+    }
+
+    public void setData(List<HostDevice> data) {
+        devices = data;
+        notifyDataSetChanged();
+    }
+
+    @Override
+    public MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
+        View view = LayoutInflater.from(mContext).inflate(R.layout.item_tradition_device, viewGroup, false);
+        TraditionDeviceAdapter.MyViewHolder myViewHolder = new TraditionDeviceAdapter.MyViewHolder(view);
+        return myViewHolder;
+    }
+
+    @Override
+    public void onBindViewHolder(MyViewHolder myViewHolder, int i) {
+        myViewHolder.name.setText(devices.get(i).getHostDeviceName());
+        myViewHolder.ip.setText(devices.get(i).getHostDeviceId());
+    }
+
+    @Override
+    public int getItemCount() {
+        return devices.size();
+    }
+
+    public void setOnItemClickListener(OnItemClickListener listener) {
+        this.clickListener = listener;
+    }
+
+    public interface OnItemClickListener {
+        void onItemClick(View view, int position);
+        void onItemLongClick(View view, int position);
+    }
+
+    public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
+        TextView name;
+        TextView ip;
+
+        public MyViewHolder(View itemView) {
+            super(itemView);
+            name = itemView.findViewById(R.id.tv_tradition_name);
+            ip = itemView.findViewById(R.id.tv_tradition_ip);
+            itemView.setOnClickListener(this);
+            itemView.setOnLongClickListener(this);
+        }
+
+        @Override
+        public void onClick(View v) {
+            if (clickListener != null) {
+                clickListener.onItemClick(v, getLayoutPosition());
+            }
+        }
+
+        @Override
+        public boolean onLongClick(View v) {
+            if (clickListener != null) {
+                clickListener.onItemLongClick(v, getLayoutPosition());
+            }
+            return false;
+        }
+    }
+}

+ 2 - 0
app/src/main/java/com/wdkl/callingmainnurse/common/Constants.java

@@ -232,6 +232,8 @@ public class Constants {
 
     public static boolean ledFontExist = false;
 
+    public static String DEVICE_TRADITION = "11";  //转接盒
+
     /**
      * 各种呼叫的机型
      * type : 1门口机 2主机 3 子机  4请求增援 5卫生间 6总控机 7护士主机 8医生机 9护士主机转接给医生机  优先等级依次升高   12传统机

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

@@ -65,7 +65,7 @@ public class LedC2MManager extends LedManager {
                     @Override
                     public void onResponse(String response, int id) {
                         String data = response.substring(0, response.length() - 4);
-                        Log.d("led", "getAllDeviceInfo data:== " + data);
+                        //Log.d("led", "getAllDeviceInfo data:== " + data);
                         try {
                             Gson gson = new Gson();
                             DeviceInfoEntity entity = gson.fromJson(data, DeviceInfoEntity.class);

+ 188 - 0
app/src/main/java/com/wdkl/callingmainnurse/ui/activity/OtherSettingsActivity.java

@@ -1,5 +1,10 @@
 package com.wdkl.callingmainnurse.ui.activity;
 
+import android.content.DialogInterface;
+import android.os.CountDownTimer;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
 import android.support.v7.widget.Toolbar;
 import android.text.TextUtils;
 import android.util.Log;
@@ -16,12 +21,15 @@ import com.google.gson.Gson;
 import com.wdkl.callingmainnurse.MyApplication;
 import com.wdkl.callingmainnurse.R;
 import com.wdkl.callingmainnurse.adapter.SpinnerHostDeviceAdapter;
+import com.wdkl.callingmainnurse.adapter.TraditionDeviceAdapter;
 import com.wdkl.callingmainnurse.base.BaseActivity;
 import com.wdkl.callingmainnurse.common.Constants;
+import com.wdkl.callingmainnurse.entity.DeviceInfoEntity;
 import com.wdkl.callingmainnurse.entity.HostDevice;
 import com.wdkl.callingmainnurse.entity.MessageEvent;
 import com.wdkl.callingmainnurse.entity.NurseHostListInfo;
 import com.wdkl.callingmainnurse.entity.SystemInfoEntity;
+import com.wdkl.callingmainnurse.entity.UdpEntity;
 import com.wdkl.callingmainnurse.util.LogUtil;
 import com.wdkl.callingmainnurse.util.SharedPreferencesUtil;
 import com.wdkl.callingmainnurse.util.StringUtils;
@@ -87,9 +95,16 @@ public class OtherSettingsActivity extends BaseActivity {
     @Bind(R.id.rb_set_debug_off)
     RadioButton rbDebugOff;
 
+    @Bind(R.id.btn_check_tradition)
+    Button btnTraditionCheck;
+
+    private List<HostDevice> traditionList = new ArrayList<>();
     private List<HostDevice> hostDeviceList = new ArrayList<>();
     private String selectHostDeviceId;
 
+    private CountDownTimer mCountDownTimer;
+    private String traditionIP;
+
     @Override
     public int getLayoutId() {
         return R.layout.activity_other_settings_layout;
@@ -229,10 +244,18 @@ public class OtherSettingsActivity extends BaseActivity {
                 }
             }
         });
+
+        btnTraditionCheck.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                getTraditionDevice(Constants.PartID);
+            }
+        });
     }
 
     @Override
     protected void initData() {
+        initCountDownTimer();
     }
 
     private void getNurseHostInfo(String partId) {
@@ -283,6 +306,63 @@ public class OtherSettingsActivity extends BaseActivity {
         }
     }
 
+    private void initCountDownTimer() {
+        mCountDownTimer = new CountDownTimer(10000, 5000) {
+            @Override
+            public void onTick(long time) {
+                //
+            }
+
+            @Override
+            public void onFinish() {
+                showErrorDialog();
+            }
+        };
+    }
+
+    private void getTraditionDevice(String partId) {
+        try {
+            //获取科室所有设备信息
+            OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_DEVICE_INFO)
+                    .addParams("PartID", partId)
+                    .build()
+                    .execute(new StringCallback() {
+                        @Override
+                        public void onError(Call call, Exception e, int id) {
+                            LogUtil.d("getNurseHostInfo", "===error===");
+                            ToastUtil.showToast("网络错误!");
+                        }
+
+                        @Override
+                        public void onResponse(String response, int id) {
+                            String data = response.substring(0, response.length() - 4);
+                            try {
+                                Gson gson = new Gson();
+                                DeviceInfoEntity entity = gson.fromJson(data, DeviceInfoEntity.class);
+                                if (entity != null && entity.getDeviceInfoArray() != null && entity.getDeviceInfoArray().size() > 0) {
+                                    for (DeviceInfoEntity.DeviceInfo deviceInfo : entity.getDeviceInfoArray()) {
+                                        //获取该科室中的所有转换盒设备
+                                        if (Constants.DEVICE_TRADITION.equals(deviceInfo.getDEVICE_TYPE())) {
+                                            Log.d("wzlll", "device info: ip=" + deviceInfo.getDEVICE_ETH_IP());
+                                            HostDevice device = new HostDevice();
+                                            device.setHostDeviceName(deviceInfo.getDEVICE_NAME());
+                                            device.setHostDeviceId(deviceInfo.getDEVICE_ETH_IP());
+                                            traditionList.add(device);
+                                        }
+                                    }
+
+                                    showTraditionCheck();
+                                }
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    });
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
     private void updateHostDeviceList() {
         SpinnerHostDeviceAdapter adapter = new SpinnerHostDeviceAdapter(OtherSettingsActivity.this, hostDeviceList);
         spinnerHost.setAdapter(adapter);
@@ -318,7 +398,115 @@ public class OtherSettingsActivity extends BaseActivity {
         }
     }
 
+    private void showTraditionCheck() {
+        View dialogView = View.inflate(OtherSettingsActivity.this, R.layout.dialog_tradition, null);
+        RecyclerView recyclerView = dialogView.findViewById(R.id.rv_tradition_device);
+        AlertDialog.Builder builder = new AlertDialog.Builder(OtherSettingsActivity.this);
+        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                //
+            }
+        });
+
+        final AlertDialog dialog = builder.create();
+        LinearLayoutManager manager = new LinearLayoutManager(OtherSettingsActivity.this);
+        final TraditionDeviceAdapter adapter = new TraditionDeviceAdapter(OtherSettingsActivity.this, traditionList);
+        recyclerView.setAdapter(adapter);
+        recyclerView.setLayoutManager(manager);
+        adapter.setOnItemClickListener(new TraditionDeviceAdapter.OnItemClickListener() {
+            @Override
+            public void onItemClick(View view, int position) {
+                if (position < traditionList.size()) {
+                    String ip = traditionList.get(position).getHostDeviceId();
+                    UdpSendUtil.sendTraditionCheck(ip);
+                    traditionIP = ip;
+                    if (mCountDownTimer != null) {
+                        mCountDownTimer.cancel();
+                        mCountDownTimer.start();
+                    }
+                    if (dialog.isShowing()) {
+                        dialog.dismiss();
+                    }
+                }
+            }
+
+            @Override
+            public void onItemLongClick(View view, int position) {
+                if (position < traditionList.size()) {
+                    String ip = traditionList.get(position).getHostDeviceId();
+                    UdpSendUtil.sendTraditionReboot(ip);
+                    ToastUtil.showToast("发送转换盒重启命令...");
+                    if (dialog.isShowing()) {
+                        dialog.dismiss();
+                    }
+                }
+            }
+        });
+
+        dialog.setView(dialogView);
+        dialog.setOnShowListener(new DialogInterface.OnShowListener() {
+            @Override
+            public void onShow(DialogInterface dialog) {
+                adapter.setData(traditionList);
+            }
+        });
+        dialog.show();
+    }
+
+    private void showErrorDialog() {
+        AlertDialog.Builder builder = new AlertDialog.Builder(OtherSettingsActivity.this);
+        builder.setTitle("当前查询: " + traditionIP);
+        builder.setMessage("转换盒查询超时,网络不通!");
+        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                //
+            }
+        });
+
+        AlertDialog dialog = builder.create();
+        dialog.show();
+    }
+
     @Subscribe(threadMode = ThreadMode.MAIN)
     public void onMoonEvent(MessageEvent messageEvent) {
+        if (Constants.EVENT_UDP == messageEvent.getType()) {
+            if (mCountDownTimer != null) {
+                mCountDownTimer.cancel();
+            }
+            UdpEntity udpEntity = (UdpEntity) messageEvent.getMessage();
+            AlertDialog.Builder builder = new AlertDialog.Builder(OtherSettingsActivity.this);
+            builder.setTitle("来自转换盒回复: " + udpEntity.getNurseHostID());
+            StringBuilder text = new StringBuilder();
+            if (udpEntity.getDoorwayMachineID().equals("1")) {
+                text.append("以太网连接正常\n");
+            } else {
+                text.append("以太网断开\n");
+            }
+            text.append("SIP注册状态: ");
+            switch (udpEntity.getHeadMachineID()) {
+                case "register_ing":
+                    text.append("注册中");
+                    break;
+                case "register_fail":
+                    text.append("注册失败");
+                    break;
+                case "register_com":
+                    text.append("注册完成");
+                    break;
+            }
+
+            builder.setMessage(text.toString());
+            builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
+                @Override
+                public void onClick(DialogInterface dialog, int which) {
+                    //
+                }
+            });
+
+            AlertDialog dialog = builder.create();
+            dialog.show();
+        }
     }
 }

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

@@ -432,6 +432,15 @@ public class AnalysisUdpUtil {
                     } else {
                         return;
                     }
+                    break;
+                case "tradition_state":
+                    UdpEntity traditionState = new UdpEntity();
+                    traditionState.setIndexes(data[0]);
+                    traditionState.setNurseHostID(data[1]);
+                    traditionState.setDoorwayMachineID(data[2]);
+                    traditionState.setHeadMachineID(data[3]);
+                    EventBus.getDefault().post(new MessageEvent(traditionState, Constants.EVENT_UDP));
+                    break;
                 case "back_1":
                     //呼叫回复");
                     break;

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

@@ -479,6 +479,18 @@ public class UdpSendUtil {
                 , callListEntity.getUdpEntity().getType());//传的呼叫类型
     }
 
+    public static void sendTraditionCheck(String ipStr) {
+        AnalysisUdpUtil.sendUdpData("tradition_check"
+                , ipStr
+                , "0", "0", "0", "0", "0", "0", "0", "0", "0");
+    }
+
+    public static void sendTraditionReboot(String ipStr) {
+        AnalysisUdpUtil.sendUdpData("tradition_reboot"
+                , ipStr
+                , "0", "0", "0", "0", "0", "0", "0", "0", "0");
+    }
+
     //主机发生异常通知各分机
     public static void sendExceptionNotification() {
         AnalysisUdpUtil.sendUdpData("call_host_exception"

+ 5 - 0
app/src/main/res/drawable/shape_bg_line.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
+    <stroke android:color="@color/gray"
+        android:width="2dp"/>
+</shape>

+ 15 - 4
app/src/main/res/layout/activity_other_settings_layout.xml

@@ -16,20 +16,23 @@
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="80dp"
-        android:padding="20dp"
+        android:paddingLeft="20dp"
+        android:paddingRight="20dp"
         android:gravity="center_vertical">
 
         <TextView
-            android:layout_width="wrap_content"
+            android:layout_width="0dp"
             android:layout_height="wrap_content"
+            android:layout_weight="1"
             android:text="使用TTS语音播报:"
             android:textColor="@color/white"
             android:textSize="28sp"/>
 
         <RadioGroup
             android:id="@+id/group_tts_set"
-            android:layout_width="wrap_content"
+            android:layout_width="0dp"
             android:layout_height="wrap_content"
+            android:layout_weight="2"
             android:layout_marginLeft="30dp"
             android:orientation="horizontal">
             <RadioButton
@@ -48,6 +51,15 @@
                 android:textColor="@color/white"
                 android:textSize="28sp"/>
         </RadioGroup>
+
+        <Button
+            android:id="@+id/btn_check_tradition"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:layout_marginLeft="200dp"
+            android:text="转换盒检测"
+            android:textSize="28sp"/>
     </LinearLayout>
 
     <LinearLayout
@@ -214,5 +226,4 @@
         </RadioGroup>
     </LinearLayout>
 
-
 </LinearLayout>

+ 55 - 0
app/src/main/res/layout/dialog_tradition.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:background="@drawable/shape_bg_line">
+    <LinearLayout
+        android:id="@+id/ll_tradition_title"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:padding="10dp"
+        android:visibility="gone">
+        <TextView
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:textSize="28sp"
+            android:text="转换盒名称"/>
+        <View
+            android:layout_width="1dp"
+            android:layout_height="match_parent"
+            android:background="@color/gray" />
+        <TextView
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:gravity="center"
+            android:textSize="28sp"
+            android:text="转换盒IP地址"/>
+    </LinearLayout>
+
+    <TextView
+        android:id="@+id/tv_tradition_title"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingTop="10dp"
+        android:paddingBottom="10dp"
+        android:gravity="center"
+        android:textSize="28sp"
+        android:text="转接盒测试"/>
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="1dp"
+        android:background="@color/gray"
+        android:layout_below="@id/tv_tradition_title"/>
+
+    <android.support.v7.widget.RecyclerView
+        android:id="@+id/rv_tradition_device"
+        android:layout_below="@id/tv_tradition_title"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:padding="10dp"/>
+</RelativeLayout>

+ 42 - 0
app/src/main/res/layout/item_tradition_device.xml

@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <TextView
+            android:id="@+id/tv_tradition_name"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:padding="8dp"
+            android:textSize="24sp"
+            android:text="转换盒名称"
+            android:gravity="center"/>
+
+        <View
+            android:layout_width="1dp"
+            android:layout_height="match_parent"
+            android:background="@color/gray" />
+
+        <TextView
+            android:id="@+id/tv_tradition_ip"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:padding="8dp"
+            android:textSize="24sp"
+            android:text="转换盒IP"
+            android:gravity="center"/>
+    </LinearLayout>
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="1dp"
+        android:background="@color/gray" />
+</LinearLayout>