Переглянути джерело

<总控制室主机的个科室列表及各床位分机列表显示完成,分机通话功能完成,科室主机通话还需要修改>

weizhengliang 5 роки тому
батько
коміт
09cc1a83fa

+ 6 - 0
app/src/main/java/com/wdkl/callingmainnursemanager/MyApplication.java

@@ -8,6 +8,7 @@ import android.content.ServiceConnection;
 import android.net.wifi.WifiManager;
 import android.os.IBinder;
 
+import com.wdkl.callingmainnursemanager.entity.PartInfoEntity;
 import com.wdkl.callingmainnursemanager.entity.UdpEntity;
 import com.wdkl.callingmainnursemanager.service.APPService;
 import com.wdkl.callingmainnursemanager.util.ScreenExtinguishUtil;
@@ -16,6 +17,7 @@ import com.wdkl.callingmainnursemanager.util.anrfcutil.AnrFcExceptionUtil;
 import com.zhy.http.okhttp.OkHttpUtils;
 
 import java.util.ArrayList;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 import okhttp3.ConnectionPool;
@@ -68,6 +70,9 @@ public class MyApplication extends Application {
 
     public static ScreenExtinguishUtil mScreenExtinguishUtil;
 
+    //全局科室列表
+    public static List<PartInfoEntity.PartInfo> partInfoList;
+
     public MyApplication() {
         sAppContext = getAppContext();
     }
@@ -101,6 +106,7 @@ public class MyApplication extends Application {
 
         sAppContext = getApplicationContext();
         callEntityList = new ArrayList<>();
+        partInfoList = new ArrayList<>();
         initUdp();
         initClient();
 

+ 7 - 6
app/src/main/java/com/wdkl/callingmainnursemanager/adapter/NurseHostAdapter.java

@@ -10,8 +10,10 @@ import android.widget.TextView;
 
 import com.wdkl.callingmainnursemanager.R;
 import com.wdkl.callingmainnursemanager.entity.NurseHostListInfo;
+import com.wdkl.callingmainnursemanager.entity.PartInfoEntity;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import butterknife.Bind;
 import butterknife.ButterKnife;
@@ -23,13 +25,14 @@ import butterknife.ButterKnife;
 public class NurseHostAdapter extends RecyclerView.Adapter<NurseHostAdapter.MyViewHolder> {
 
     private Context mcontext;
-    private ArrayList<NurseHostListInfo> list;
+    //private ArrayList<NurseHostListInfo> list;
+    private List<PartInfoEntity.PartInfo> list;
     private LayoutInflater inflater;
     private NurseHostItemOnclickListener itemOnclickListener;
     private NurseHostListInfo nurseHostEntity = new NurseHostListInfo();
     private int selectedPosition = -1;
 
-    public NurseHostAdapter(Context context, ArrayList<NurseHostListInfo> list) {
+    public NurseHostAdapter(Context context, List<PartInfoEntity.PartInfo> list) {
         this.mcontext = context;
         this.list = list;
         inflater = LayoutInflater.from(mcontext);
@@ -38,7 +41,7 @@ public class NurseHostAdapter extends RecyclerView.Adapter<NurseHostAdapter.MyVi
     /**
      * @param list
      */
-    public void updateList(ArrayList<NurseHostListInfo> list) {
+    public void updateList(List<PartInfoEntity.PartInfo> list) {
         this.list = list;
         selectedPosition = -1;
         notifyDataSetChanged();
@@ -50,7 +53,6 @@ public class NurseHostAdapter extends RecyclerView.Adapter<NurseHostAdapter.MyVi
 
     @Override
     public NurseHostAdapter.MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int position) {
-
         View view = inflater.inflate(R.layout.fragment_nurse_host_adapter, viewGroup, false);
         MyViewHolder holder = new MyViewHolder(view, itemOnclickListener);
         return holder;
@@ -59,11 +61,10 @@ public class NurseHostAdapter extends RecyclerView.Adapter<NurseHostAdapter.MyVi
     @Override
     public void onBindViewHolder(NurseHostAdapter.MyViewHolder holder, int position) {
         if (null == list.get(position)) return;
-        holder.tvNurseHostNo.setText(list.get(position).getDeviceName());
+        holder.tvNurseHostNo.setText(list.get(position).getPART_NAME());
         holder.ivNurseHost.setTag(position);
         if (list.get(position).isChecked()) {
             holder.ivNurseHost.setImageResource(R.mipmap.ic_nurse_sel);
-
         } else {
             holder.ivNurseHost.setImageResource(R.mipmap.ic_nurse_standby);
         }

+ 20 - 1
app/src/main/java/com/wdkl/callingmainnursemanager/common/Constants.java

@@ -80,6 +80,10 @@ public class Constants {
     public static final String CALLINGMAINNURSE_DOCTORLIST = "/WDHS-I/callingMainNurse_DoctorHostList.aspx";
     //系统设置数据
     public static final String SYSTEM_INFO = "/WDHS-I/callingMainNurse_systemInfo.aspx";
+    //所有科室信息
+    public static final String CALLINGMAINNURSE_PART_INFO = "/Mgr/GetWD_PartInfoArray.aspx";
+    //所有设备信息
+    public static final String CALLINGMAINNURSE_DEVICE_INFO = "/Mgr/GetWD_DeviceInfoArray.aspx";
 
     /**
      * 检查APP更新版本
@@ -98,6 +102,8 @@ public class Constants {
     public static final String IN_CALLING = "2";
     //挂断状态  21
     public static int CALLING_ENDING = 21;
+    //呼叫护士主机id
+    public static String CALLING_HOST_ID = "";
 
 
     //EventBus 所需判断类型
@@ -117,6 +123,8 @@ public class Constants {
      */
     public static final int EVENT_MGR_APP_UPDATE = 0x09;
 
+    public static final int EVENT_UDP2 = 0x20;
+
     /**
      * APP更新flag值<br></>
      * false为无更新指令。
@@ -213,8 +221,9 @@ public class Constants {
 
     /**
      * 各种呼叫的机型
-     * type :1门口机 2主机 3 子机  4请求增援 5卫生间优先等级依次升高   12传统机
+     * type : 0总控机 1门口机 2主机 3 子机  4请求增援 5卫生间优先等级依次升高   12传统机
      */
+    public static final String MANAGER_CALL = "0";
     public static final String DOOR_CALL = "1";
     public static final String MAIN_CALL = "2";
     public static final String SON_CALL = "3";
@@ -222,12 +231,18 @@ public class Constants {
     public static final String WSHROOM_CALL = "5";
     public static final String TRADITION_CALL = "12";
 
+    public static String DEVICE_ID = "";
     public static String MYSELF_ID = "";//自己的机器ID
     public static String CALLMAIN_ID = "";//所属主机机器ID
     public static String DOOR_ID = "";//门口机机器ID
     public static String TRUST_OLD_MAIN_ID = "";//托管主机的Id
     public static int TRUST_FLAG_VALUE = 88;//托管是否取消成功的值:66成功;88失败
 
+    //设备类型
+    public static String DEVICE_HOST = "1";  //护士主机
+    public static String DEVICE_DOOR = "3";  //门口机
+    public static String DEVICE_SLAVE = "4";  //分机
+
     /**
      * PartID:科室 ID 号
      */
@@ -235,6 +250,10 @@ public class Constants {
 
     public static String PartName = "";
 
+    public static String SelectedPartId = "";
+
+    public static String SelectedPartName = "";
+
     public static int currentFragment = 0;
     /**
      * 白天还是晚上<br>

+ 100 - 0
app/src/main/java/com/wdkl/callingmainnursemanager/entity/DeviceInfoEntity.java

@@ -0,0 +1,100 @@
+package com.wdkl.callingmainnursemanager.entity;
+
+import java.util.List;
+
+public class DeviceInfoEntity {
+
+    private List<DeviceInfo> DeviceInfoArray;
+
+    public List<DeviceInfo> getDeviceInfoArray() {
+        return DeviceInfoArray;
+    }
+
+    public void setDeviceInfoArray(List<DeviceInfo> deviceInfoArray) {
+        DeviceInfoArray = deviceInfoArray;
+    }
+
+    public class DeviceInfo {
+        //"ID":"4059","PARTID":"2003","DEVICE_TYPE":"1","DEVICE_SN":"SZHSI2004160001","DEVICE_MODEL":"WD","DEVICE_SOFT_VER":"S01",
+        // "DEVICE_HARD_VER":"HSI","DEVICE_NAME":"护士主机1","DEVICE_ETH_MAC":"1C:05:00:00:00:29","DEVICE_ETH_IP":"192.168.23.20",
+        // "DEVICE_WIFI_MAC":"FF:FF:FF:FF:FF:FF","DEVICE_WIFI_IP":"","DEVICE_WIFI_HOSTNAME":"","DEVICE_STATUS":"1","DEVICE_ROOM_NUM":"",
+        // "DEVICE_ROOM_ID":"0","DEVICE_BED_NUM":"","DEVICE_BED_NAME":"","DEVICE_HUMAN_TYPE":"0","DEVICE_HUMAN_ID":"0","DEVICE_SIP_IP":"192.168.101.2",
+        // "DEVICE_SIP_ID":"1000040590","DEVICE_SIP_PASSWORD":"1000040590","DEVICE_HOSTING_ID":"4059","DEVICE_IR_CFG":"",
+        // "DEVICE_ZONE0":"0","DEVICE_ZONE1":"0","DEVICE_ZONE2":"0","DEVICE_ZONE3":"0","DEVICE_ZONE4":"0","DEVICE_ZONE5":"0",
+        // "DEVICE_DATETIME":"2020/06/16 12:01:57","Code":"OK!"
+
+        private String ID;
+        private String PARTID;
+        private String DEVICE_TYPE;
+        private String DEVICE_SN;
+        private String DEVICE_MODEL;
+        private String DEVICE_SOFT_VER;
+        private String DEVICE_HARD_VER;
+        private String DEVICE_NAME;
+        private String DEVICE_ETH_MAC;
+        private String DEVICE_ETH_IP;
+        private String DEVICE_WIFI_MAC;
+        private String DEVICE_WIFI_IP;
+        private String DEVICE_WIFI_HOSTNAME;
+        private String DEVICE_STATUS;
+        private String DEVICE_ROOM_NUM;
+        private String DEVICE_ROOM_ID;
+        private String DEVICE_BED_NUM;
+        private String DEVICE_BED_NAME;
+        private String DEVICE_HUMAN_TYPE;
+        private String DEVICE_HUMAN_ID;
+        private String DEVICE_SIP_IP;
+        private String DEVICE_SIP_ID;
+        private String DEVICE_SIP_PASSWORD;
+        private String DEVICE_HOSTING_ID;
+        private String DEVICE_IR_CFG;
+        private String DEVICE_ZONE0;
+        private String DEVICE_ZONE1;
+        private String DEVICE_ZONE2;
+        private String DEVICE_ZONE3;
+        private String DEVICE_ZONE4;
+        private String DEVICE_ZONE5;
+        private String DEVICE_DATETIME;
+        private String Code;
+
+        public String getID() {
+            return ID;
+        }
+
+        public void setID(String ID) {
+            this.ID = ID;
+        }
+
+        public String getPARTID() {
+            return PARTID;
+        }
+
+        public void setPARTID(String PARTID) {
+            this.PARTID = PARTID;
+        }
+
+        public String getDEVICE_TYPE() {
+            return DEVICE_TYPE;
+        }
+
+        public void setDEVICE_TYPE(String DEVICE_TYPE) {
+            this.DEVICE_TYPE = DEVICE_TYPE;
+        }
+
+        public String getDEVICE_NAME() {
+            return DEVICE_NAME;
+        }
+
+        public void setDEVICE_NAME(String DEVICE_NAME) {
+            this.DEVICE_NAME = DEVICE_NAME;
+        }
+
+        public String getDEVICE_ETH_MAC() {
+            return DEVICE_ETH_MAC;
+        }
+
+        public void setDEVICE_ETH_MAC(String DEVICE_ETH_MAC) {
+            this.DEVICE_ETH_MAC = DEVICE_ETH_MAC;
+        }
+    }
+}

+ 59 - 0
app/src/main/java/com/wdkl/callingmainnursemanager/entity/PartInfoEntity.java

@@ -0,0 +1,59 @@
+package com.wdkl.callingmainnursemanager.entity;
+
+import java.util.List;
+
+public class PartInfoEntity {
+
+    private List<PartInfo> PartInfoArray;
+
+    public List<PartInfo> getPartInfoArray() {
+        return PartInfoArray;
+    }
+
+    public void setPartInfoArray(List<PartInfo> partInfoArray) {
+        PartInfoArray = partInfoArray;
+    }
+
+    public class PartInfo {
+        //科室id
+        private String ID;
+        //医院名称
+        private String PART_HOSPITALNAME;
+        //科室名称
+        private String PART_NAME;
+        //是否选中
+        public boolean isChecked;
+
+        public String getID() {
+            return ID;
+        }
+
+        public void setID(String ID) {
+            this.ID = ID;
+        }
+
+        public String getPART_HOSPITALNAME() {
+            return PART_HOSPITALNAME;
+        }
+
+        public void setPART_HOSPITALNAME(String PART_HOSPITALNAME) {
+            this.PART_HOSPITALNAME = PART_HOSPITALNAME;
+        }
+
+        public String getPART_NAME() {
+            return PART_NAME;
+        }
+
+        public void setPART_NAME(String PART_NAME) {
+            this.PART_NAME = PART_NAME;
+        }
+
+        public boolean isChecked() {
+            return isChecked;
+        }
+
+        public void setChecked(boolean checked) {
+            isChecked = checked;
+        }
+    }
+}

+ 6 - 3
app/src/main/java/com/wdkl/callingmainnursemanager/ui/activity/MainFragmentActivity.java

@@ -510,6 +510,7 @@ public class MainFragmentActivity extends FragmentActivity implements IVvsipServ
      * 结束电话
      */
     public void endCalled() {
+
         //20171219
         //=============================================SIP结束电话===================================//
         SipHelperUtil.getInstance(this).getmSipCallBackI().endCall();
@@ -702,7 +703,9 @@ public class MainFragmentActivity extends FragmentActivity implements IVvsipServ
                 }
                 break;
             case Constants.EVENT_SIP_INTERNETPING_: //显示代托管标题状态
-                if (messageEvent.getMessage() instanceof Integer && (int) messageEvent.getMessage() == 1) {
+                ivTrust.setVisibility(View.GONE);
+                tvTrust.setVisibility(View.GONE);
+                /*if (messageEvent.getMessage() instanceof Integer && (int) messageEvent.getMessage() == 1) {
                     ivTrust.setVisibility(View.VISIBLE);
                     tvTrust.setVisibility(View.VISIBLE);
                     tvTrust.setText("托管中");
@@ -715,7 +718,7 @@ public class MainFragmentActivity extends FragmentActivity implements IVvsipServ
                     tvTrust.setVisibility(View.VISIBLE);
                     tvTrust.setText("未托管");
                     ivTrust.setVisibility(View.VISIBLE);
-                }
+                }*/
                 if (messageEvent.getMessage() instanceof String && ((String) messageEvent.getMessage()).equals(ETHERNETSTATUS)) {
                     refreshEthernetAndWifi();
                 }
@@ -861,7 +864,7 @@ public class MainFragmentActivity extends FragmentActivity implements IVvsipServ
     @Override
     public void onStatusVvsipCallEvent(VvsipCall call) {
         LogUtil.d("QQWW", "call.mState:==" + call.mState
-                + "\ncall.isIncomingCall()" + call.isIncomingCall());
+                + "\ncall.isIncomingCall()" + call.isIncomingCall() + ", mac: " + call.macStr);
         switch (call.mState) {
             case 0://正在呼叫中:子机自动接通 isIncomingCall() = true  mState = 0
                 Constants.CALL_STATE = Constants.IN_CALL;

+ 202 - 12
app/src/main/java/com/wdkl/callingmainnursemanager/ui/fragment/CallingBedFragment.java

@@ -38,6 +38,7 @@ import com.wdkl.callingmainnursemanager.adapter.VoiceMessageAdapter;
 import com.wdkl.callingmainnursemanager.base.BaseFragment;
 import com.wdkl.callingmainnursemanager.common.Constants;
 import com.wdkl.callingmainnursemanager.entity.CallingQueuingInfoEntity;
+import com.wdkl.callingmainnursemanager.entity.DeviceInfoEntity;
 import com.wdkl.callingmainnursemanager.entity.HospitalInfoEntity;
 import com.wdkl.callingmainnursemanager.entity.InitDataEntity;
 import com.wdkl.callingmainnursemanager.entity.MessageEntity;
@@ -68,6 +69,7 @@ import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import butterknife.Bind;
 import butterknife.ButterKnife;
@@ -445,7 +447,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
         vRightPatientInfo.setVisibility(View.VISIBLE);
         vRightCallInfo.setVisibility(View.GONE);
         vRightCallListInfo.setVisibility(View.GONE);
-        tvPartTitle.setText("当前科室: " + Constants.PartName);
+        //tvPartTitle.setText("当前科室: " + Constants.PartName);
         //默认设置
         rvCallBed.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
             @Override
@@ -529,8 +531,15 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
         importantMessageList = new ArrayList<>();
 
         initRecyclerManager();
+
+        setPartId();  //设置科室id
+        updatePartName();  //更新科室名称
+        getData();  //获取数据
+
+
+
         //初始化病房数据
-        getRoomData();
+        //getRoomData();
         //getRoomTestData();
         //获得医院信息
         getHospitalData();
@@ -717,6 +726,158 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
     }
 
 
+    private void updatePartName() {
+        tvPartTitle.setText("当前科室: " + Constants.SelectedPartName);
+    }
+
+    //若默认没有选定partid,则设置第一个为默认
+    private void setPartId() {
+        if (StringUtils.isEmpty(Constants.SelectedPartId)) {
+            if (MyApplication.partInfoList.size() > 0) {
+                Constants.SelectedPartId = MyApplication.partInfoList.get(0).getID();
+                Constants.SelectedPartName = MyApplication.partInfoList.get(0).getPART_NAME();
+            }
+        }
+    }
+
+    //通过选定的partid获取对应护士主机的mac
+    private void getData() {
+        OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_DEVICE_INFO)
+                .addParams("PartID", Constants.SelectedPartId)
+                .build()
+                .execute(new StringCallback() {
+                    @Override
+                    public void onError(Call call, Exception e, int id) {
+                        ToastUtil.showToast("getData Error...");
+                        Log.d("getData", "Error: " + e.getMessage());
+                    }
+
+                    @Override
+                    public void onResponse(String response, int id) {
+                        String data = response.substring(0, response.length() - 4);
+                        Log.d("getData", "data:== " + data);
+                        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_HOST.equals(deviceInfo.getDEVICE_TYPE())) {
+                                        Message msg = handler.obtainMessage();
+                                        msg.what = GET_DEVICE_ID;
+                                        msg.obj = deviceInfo.getDEVICE_ETH_MAC();
+                                        handler.sendMessage(msg);
+                                        break;
+                                    }
+                                }
+                            }
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                });
+    }
+
+    private void getDeviceId(String mac) {
+        OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_INIT)
+                .addParams("deviceMAC", mac)
+                .build()
+                .execute(new StringCallback() {
+                    @Override
+                    public void onError(Call call, Exception e, int id) {
+                        ToastUtil.showToast("getDeviceId Error...");
+                    }
+
+                    @Override
+                    public void onResponse(String response, int id) {
+                        LogUtil.d("getDeviceId", "responseString==" + response);
+                        //去掉 ,OK!
+                        String data = response.substring(0, response.length() - 4);
+                        try {
+                            JSONObject jsonObj = new JSONObject(data);
+                            if (jsonObj.getString("Code").equals("ERROR!")) {
+                                ToastUtil.showToast("getDeviceId() 数据错误异常");
+                            } else {
+                                if (jsonObj.getString("deviceStatus").equals("1")) {
+                                    Gson gson = new Gson();
+                                    InitDataEntity initDataEntity = gson.fromJson(data, InitDataEntity.class);
+                                    Message msg = handler.obtainMessage();
+                                    msg.what = GET_ROOM_INFO;
+                                    msg.obj = initDataEntity.getId();
+                                    handler.sendMessage(msg);
+                                }
+                            }
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                });
+    }
+
+    private void getRoomInfo() {
+        if (StringUtils.isEmpty(Constants.DEVICE_ID)) return;
+        OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_ROOM)
+                .addParams("deviceId", Constants.DEVICE_ID)
+                .build()
+                .execute(new StringCallback() {
+                    @Override
+                    public void onError(Call call, Exception e, int id) {
+                        if (swipeRefreshLayout.isRefreshing()) {
+                            swipeRefreshLayout.setRefreshing(false);
+                        }
+                        hideProgress();
+                    }
+
+                    @Override
+                    public void onResponse(String response, int id) {
+                        LogUtil.d(CallingBedFragment.class, "getRoomInfo==" + response);
+                        if (swipeRefreshLayout.isRefreshing()) {
+                            swipeRefreshLayout.setRefreshing(false);
+                        }
+                        String data = response.substring(0, response.length() - 4);
+                        try {
+                            JSONObject jsonObj = new JSONObject(data);
+                            if (jsonObj.getString("Code").equals("ERROR!")) {
+                                Log.w("Code", "网络错误");
+                            } else {
+                                Gson gson = new Gson();
+                                roomEntity = gson.fromJson(data, RoomEntity.class);
+                                wardInformationList = roomEntity.getWardInformationList();
+                            }
+                            //VoiceMessageRoomWardInformationUtil.getInstance().getRoomEntityList(wardInformationList);
+                            LogUtil.d(CallingBedFragment.class, "wardInformationList==" + wardInformationList.toString());
+                            roomAdapter.updateList(wardInformationList);
+
+                            if (null != wardInformationList && CallingBedFragment.this.position != -1) {
+                                try {
+                                    sickbedInformationList = wardInformationList.get(CallingBedFragment.this.position).getSickbedInformationList();
+                                } catch (Exception e) {
+                                    LogUtil.d("getRoomInfo", "position越界");
+                                }
+                            }
+                            if (CallingBedFragment.this.position != -1 && null != sickbedInformationList) {
+                                if (sickbedInformationList.size() > 0) {
+                                    for (int i = 0; i < sickbedInformationList.size(); i++) {
+                                        if ("1".equals(wardInformationList.get(CallingBedFragment.this.position).getTrusteeshipState())) {
+                                            sickbedInformationList.get(i).setTrusteeshipState("1");
+                                        } else {
+                                            sickbedInformationList.get(i).setTrusteeshipState("0");
+                                        }
+                                    }
+                                }
+                                bedAdapter.listUpdate(sickbedInformationList);
+                            }
+                        } catch (JSONException e) {
+                            if (swipeRefreshLayout.isRefreshing()) {
+                                swipeRefreshLayout.setRefreshing(false);
+                            }
+                            e.printStackTrace();
+                        }
+                    }
+                });
+    }
+
+
+
     private void getRoomData() {
         if (!StringUtils.notEmpty(Constants.URL)) return;
         OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_ROOM)
@@ -785,9 +946,9 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
 
     private void getHospitalData() {
         if (!StringUtils.notEmpty(Constants.URL)) return;
-        if (!StringUtils.notEmpty(Constants.PartID)) return;
+        if (!StringUtils.notEmpty(Constants.SelectedPartId)) return;
         OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_HOSPITAL)
-                .addParams("PartID", Constants.PartID)
+                .addParams("PartID", Constants.SelectedPartId)
                 .build()
                 .execute(new StringCallback() {
                     @Override
@@ -1089,6 +1250,7 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
             rvCallList.setVisibility(View.VISIBLE);
             llBgList.setBackgroundResource(R.mipmap.bg_call_list);
             //tvTitle.setText("呼叫列表");
+            //显示科室选择框
             showPartSelectDialog();
         } else {
             llBgList.setBackgroundResource(R.mipmap.bg_bed_list);
@@ -1172,20 +1334,34 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
     }
 
     private void showPartSelectDialog() {
-        final String[] partItems = {Constants.PartName};  //test
+        if (MyApplication.partInfoList.size() <= 0) {
+            return;
+        }
+        List<String> partItems = new ArrayList<>();
+        int selectPos = 0;
+        for(int i = 0; i < MyApplication.partInfoList.size(); i++) {
+            partItems.add(MyApplication.partInfoList.get(i).getPART_NAME());
+            String id = MyApplication.partInfoList.get(i).getID();
+            if (Constants.SelectedPartId.equals(id)) {
+                selectPos = i;
+            }
+        }
+
         AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
         final AlertDialog dialog = builder.create();
-        //dialog.setCanceledOnTouchOutside(false);
+        dialog.setCanceledOnTouchOutside(false);
         View dialogView = View.inflate(getActivity(), R.layout.dialog_part_select_layout, null);
         ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getActivity(), R.layout.custom_spinner_item, partItems);
         spinnerAdapter.setDropDownViewResource(R.layout.custom_spinner_dropdown_item);
         Spinner partSpinner = dialogView.findViewById(R.id.sp_part_select);
         Button button = dialogView.findViewById(R.id.btn_ok);
         partSpinner.setAdapter(spinnerAdapter);
+        partSpinner.setSelection(selectPos);
         partSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
             @Override
             public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
-                Log.d("wzl", "on item selected: " + position);
+                Constants.SelectedPartId = MyApplication.partInfoList.get(position).getID();
+                Constants.SelectedPartName = MyApplication.partInfoList.get(position).getPART_NAME();
             }
 
             @Override
@@ -1197,6 +1373,9 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
             @Override
             public void onClick(View v) {
                 dialog.dismiss();
+                updatePartName();
+                getData();
+                getHospitalData();
             }
         });
         dialog.setView(dialogView);
@@ -1497,8 +1676,8 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                 }
                 break;
             case Constants.EVENT_MGR_UPDATE://后台相关数据改变后通知护士主机刷新UI
-                getRoomData();//病房数据
-                getHospitalData(); //医院数据
+                //getRoomData();//病房数据
+                //getHospitalData(); //医院数据
                 getSYSsetingData();//系统设置数据
 
                 handler.sendEmptyMessageDelayed(RESET, 2000);//做个复位
@@ -2065,6 +2244,8 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
     private final int GETROOMDATA_ERROR = 2001;
     private final int GETHOSPITALDATA_ERROR = 2002;
     private final int GETSYSSETINGDATA_ERROR = 2003;
+    private final int GET_DEVICE_ID = 2004;
+    private final int GET_ROOM_INFO = 2005;
     public final int RESET = 5003;
 
     @SuppressLint("HandlerLeak")
@@ -2131,10 +2312,10 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                     }
                     break;
                 case GETROOMDATA_ERROR:
-                    getRoomData();
+                    //getRoomData();
                     break;
                 case GETHOSPITALDATA_ERROR:
-                    getHospitalData();
+                    //getHospitalData();
                     break;
                 case GETSYSSETINGDATA_ERROR:
                     getSYSsetingData();
@@ -2142,6 +2323,14 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
                 case RESET:
                     Constants.MGR_UPDATE = false;
                     break;
+                case GET_DEVICE_ID:
+                    String macAddr = (String) msg.obj;
+                    getDeviceId(macAddr);
+                    break;
+                case GET_ROOM_INFO:
+                    Constants.DEVICE_ID = (String) msg.obj;
+                    getRoomInfo();
+                    break;
             }
         }
     };
@@ -2426,7 +2615,8 @@ public class CallingBedFragment extends BaseFragment implements SicknessBedAdapt
     @Override
     public void onRefresh() {
         getHospitalData();
-        getRoomData();
+        getRoomInfo();
+        //getRoomData();
     }
 
     @Override

+ 244 - 24
app/src/main/java/com/wdkl/callingmainnursemanager/ui/fragment/CallingHostFragment.java

@@ -16,6 +16,7 @@ import android.widget.TextView;
 
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
+import com.wdkl.callingmainnursemanager.MyApplication;
 import com.wdkl.callingmainnursemanager.R;
 import com.wdkl.callingmainnursemanager.adapter.DoctorHostAdapter;
 import com.wdkl.callingmainnursemanager.adapter.DutyDoctorAdapter;
@@ -26,26 +27,33 @@ import com.wdkl.callingmainnursemanager.base.BaseFragment;
 import com.wdkl.callingmainnursemanager.common.Constants;
 import com.wdkl.callingmainnursemanager.entity.CallingQueuingInfoEntity;
 import com.wdkl.callingmainnursemanager.entity.DoctorHostEntity;
+import com.wdkl.callingmainnursemanager.entity.HospitalInfoEntity;
 import com.wdkl.callingmainnursemanager.entity.MessageEvent;
 import com.wdkl.callingmainnursemanager.entity.NurseHostListInfo;
+import com.wdkl.callingmainnursemanager.entity.PartInfoEntity;
+import com.wdkl.callingmainnursemanager.entity.UdpEntity;
 import com.wdkl.callingmainnursemanager.util.LogUtil;
 import com.wdkl.callingmainnursemanager.util.StringUtils;
 import com.wdkl.callingmainnursemanager.util.UIUtils;
 import com.wdkl.callingmainnursemanager.util.ToastUtil;
+import com.wdkl.callingmainnursemanager.util.UdpSendUtil;
 import com.zhy.http.okhttp.OkHttpUtils;
 import com.zhy.http.okhttp.callback.StringCallback;
 
 import org.greenrobot.eventbus.Subscribe;
 import org.greenrobot.eventbus.ThreadMode;
+import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import butterknife.Bind;
 import butterknife.ButterKnife;
 import okhttp3.Call;
 
+import static com.wdkl.callingmainnursemanager.util.StringUtils.formateBankNumber;
 import static com.wdkl.callingmainnursemanager.util.StringUtils.notEmpty;
 import static com.wdkl.callingmainnursemanager.util.ToastUtil.showToast;
 
@@ -82,6 +90,16 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
      */
     private DoctorHostEntity doctorHostEntity;
     private ArrayList<DoctorHostEntity> doctorHostList;
+
+    //科室列表
+    private PartInfoEntity partInfoEntity;
+
+    //科室数据
+    private HospitalInfoEntity hospitalInfoEntity;
+
+    //通话的状态
+    private String CALL_STATUS = Constants.STANDBY;
+
     /**
      * 医生主机的适配器
      */
@@ -171,7 +189,7 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
 
     @Override
     protected void initView(View RootView) {
-        ivEndCalling.setOnClickListener(this);
+        //ivEndCalling.setOnClickListener(this);
         rvDoctor.addOnItemTouchListener(this);
         rvNurse.addOnItemTouchListener(this);
         swipeNurseRefreshLayout.setOnRefreshListener(this);
@@ -212,7 +230,7 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
         //nurseManager.setOrientation(LinearLayoutManager.HORIZONTAL);
         GridLayoutManager nurseManager = new GridLayoutManager(getActivity(), 4);
         rvNurse.setLayoutManager(nurseManager);
-        nurseHostAdapter = new NurseHostAdapter(getActivity(), nurseHostList);
+        nurseHostAdapter = new NurseHostAdapter(getActivity(), MyApplication.partInfoList);
         rvNurse.setAdapter(nurseHostAdapter);
         nurseHostAdapter.setNurseHostItemOnclickListener(this);
 
@@ -229,8 +247,10 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
         rvDutyNurses.setAdapter(dutyNurseAdapter);
 
         //getNurseHostList();
-        getNurseHostTestData();
+        //getNurseHostTestData();
         //getDoctorHostList();
+        getAllPartInfo();
+        getAllDeviceInfo();
     }
 
     /**
@@ -257,10 +277,12 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
     public void onRefresh() {
         resetRightList();
         //getNurseHostList();
-        getNurseHostTestData();
+        //getNurseHostTestData();
+        getAllPartInfo();
     }
 
-    private void getNurseHostTestData() {
+    //test data
+    /*private void getNurseHostTestData() {
         ArrayList<String> dutyDoctors = new ArrayList<>();
         dutyDoctors.add("刘医生");
         dutyDoctors.add("张医生");
@@ -283,11 +305,86 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
         if (swipeNurseRefreshLayout.isRefreshing()) {
             swipeNurseRefreshLayout.setRefreshing(false);
         }
+    }*/
+
+    private void getAllPartInfo() {
+        OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_PART_INFO)
+                .build()
+                .execute(new StringCallback() {
+                    @Override
+                    public void onError(Call call, Exception e, int id) {
+                        if (swipeNurseRefreshLayout.isRefreshing()) {
+                            swipeNurseRefreshLayout.setRefreshing(false);
+                        }
+                        hideProgress();
+                    }
+
+                    @Override
+                    public void onResponse(String response, int id) {
+                        if (swipeNurseRefreshLayout.isRefreshing()) {
+                            swipeNurseRefreshLayout.setRefreshing(false);
+                        }
+                        if (notEmpty(response)) {
+                            LogUtil.d(CallingHostFragment.class, "part info==" + response);
+                            String code = getStringData(response, "Code");
+                            if (code.equals("OK!")) {
+                                String data = response.substring(0, response.length() - 4);
+                                Gson gson = new Gson();
+                                partInfoEntity = gson.fromJson(data, PartInfoEntity.class);
+                                if (null != partInfoEntity) {
+                                    List<PartInfoEntity.PartInfo> list = partInfoEntity.getPartInfoArray();
+                                    if (list != null && list.size() > 0) {
+                                        MyApplication.partInfoList.clear();
+                                        for (int i = 0; i < list.size(); i++) {
+                                            //因为本机设定为总控主机,当成是一个特殊的科室,不需要显示在列表,所以需要过滤掉本机的partId
+                                            if (!Constants.PartID.equals(list.get(i).getID())) {
+                                                MyApplication.partInfoList.add(list.get(i));
+                                            }
+                                        }
+                                    }
+
+                                    nurseHostAdapter.updateList(MyApplication.partInfoList);
+                                }
+                            } else {
+                                LogUtil.i(CallingHostFragment.class, "Code==" + code + "---数据返回错误!");
+                            }
+                        } else {
+                            LogUtil.i(CallingHostFragment.class, "数据返回为空!");
+                        }
+                    }
+                });
+    }
+
+    private void getAllDeviceInfo() {
+        OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_DEVICE_INFO)
+                .addParams("PartID", Constants.PartID)
+                .build()
+                .execute(new StringCallback() {
+                    @Override
+                    public void onError(Call call, Exception e, int id) {
+                        if (swipeNurseRefreshLayout.isRefreshing()) {
+                            swipeNurseRefreshLayout.setRefreshing(false);
+                        }
+                        hideProgress();
+                    }
+
+                    @Override
+                    public void onResponse(String response, int id) {
+                        if (swipeNurseRefreshLayout.isRefreshing()) {
+                            swipeNurseRefreshLayout.setRefreshing(false);
+                        }
+                        if (notEmpty(response)) {
+                            LogUtil.d(CallingHostFragment.class, "device info==" + response);
+                        } else {
+                            LogUtil.i(CallingHostFragment.class, "数据返回为空!");
+                        }
+                    }
+                });
     }
 
     private void resetRightList() {
         tvCallingTips.setText("");
-        nurse_CallStaus.setText("--");
+        nurse_CallStaus.setText("");
         ivDoctorOrNurseCalling.setImageResource(R.mipmap.ic_trusteeship_n);
         ivEndCalling.setVisibility(View.GONE);
         rlIncall.setVisibility(View.VISIBLE);
@@ -335,7 +432,7 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
     /**
      * 获取医护主机列表信息
      */
-    private void getNurseHostList() {
+    /*private void getNurseHostList() {
         if (!StringUtils.notEmpty(Constants.PartID)) return;
         OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_NURSELIST)
                 .addParams("PartID", Constants.PartID)
@@ -381,7 +478,7 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
                         }
                     }
                 });
-    }
+    }*/
 
 //    /**
 //     * 获取呼叫历史列表信息
@@ -402,14 +499,128 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
 //                });
 //    }
 
+
+    private void getPartData(String partId) {
+        if (!StringUtils.notEmpty(Constants.URL)) return;
+        if (!StringUtils.notEmpty(partId)) return;
+        OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_HOSPITAL)
+                .addParams("PartID", partId)
+                .build()
+                .execute(new StringCallback() {
+                    @Override
+                    public void onError(Call call, Exception e, int id) {
+                        LogUtil.d("getPartData", "===error===");
+                    }
+
+                    @Override
+                    public void onResponse(String response, int id) {
+                        String data = response.substring(0, response.length() - 4);
+                        LogUtil.d("getPartData", "data=="+data);
+                        try {
+                            JSONObject jsonObj = new JSONObject(data);
+                            if (jsonObj.getString("Code").equals("ERROR!")) {
+                                LogUtil.d("getPartData", "网络错误");
+                            } else {
+                                Gson gson = new Gson();
+                                hospitalInfoEntity = gson.fromJson(data, HospitalInfoEntity.class);
+                                ArrayList<String> doctorList = (ArrayList<String>) hospitalInfoEntity.getDutyDoctorList();
+                                ArrayList<String> nurseList = (ArrayList<String>) hospitalInfoEntity.getNurseOnDutyList();
+                                dutyDoctorAdapter.updateList(doctorList);
+                                dutyNurseAdapter.updateList(nurseList);
+                            }
+                        } catch (JSONException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                });
+    }
+
+    private void getNurseHostInfo(String partId) {
+        try {
+            OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_NURSELIST)
+                    .addParams("PartID", partId)
+                    .build()
+                    .execute(new StringCallback() {
+                        @Override
+                        public void onError(Call call, Exception e, int id) {
+                            LogUtil.d("getNurseHostInfo", "===error===");
+                        }
+
+                        @Override
+                        public void onResponse(String response, int id) {
+                            try {
+                                JSONObject jsonObj = new JSONObject(response);
+                                if (jsonObj.getString("Code").equals("ERROR!")) {
+                                    LogUtil.d("getNurseHostInfo", "网络错误");
+                                } else {
+                                    if (jsonObj.getString("Code").equals("OK!")) {
+                                        String data = jsonObj.getString("hostList");
+                                        JSONArray array = new JSONArray(data);
+                                        Gson gson = new Gson();
+                                        List<NurseHostListInfo> nurseHostList = new ArrayList<>();
+                                        for (int i = 0; i < array.length(); i++) {
+                                            NurseHostListInfo nurseHostListInfo = gson.fromJson(array.get(i).toString(), NurseHostListInfo.class);
+                                            nurseHostList.add(nurseHostListInfo);
+                                        }
+
+                                        if (nurseHostList.size() > 0 && nurseHostList.get(0) != null) {
+                                            NurseHostListInfo hostInfo = nurseHostList.get(0);
+                                            final String hostId = hostInfo.getDeviceHostingID();
+                                            //final String sip = hostInfo.getDeviceSipIp();
+                                            //final String name = hostInfo.getDeviceName();
+                                            ivEndCalling.setOnClickListener(new View.OnClickListener() {
+                                                @Override
+                                                public void onClick(View v) {
+                                                    getActivity().runOnUiThread(new Runnable() {
+                                                        @Override
+                                                        public void run() {
+                                                            callClick(hostId);
+                                                        }
+                                                    });
+                                                }
+                                            });
+                                        }
+                                    } else {
+                                        LogUtil.d("Code", "网络错误");
+                                    }
+                                }
+                            } catch (JSONException e) {
+                                e.printStackTrace();
+                            }
+                        }
+                    });
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private void callClick(String hostId) {
+        if (CALL_STATUS.equals(Constants.STANDBY)) {
+            //呼叫中
+            ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_hang_up);
+            nurse_CallStaus.setText("正在呼叫...");
+            UdpSendUtil.sendNurseHostCall(hostId);
+            CALL_STATUS = Constants.IN_CALL;
+            Constants.CALLING_HOST_ID = hostId;
+        } else {
+            //挂断
+            ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_calling);
+            nurse_CallStaus.setText("");
+            UdpSendUtil.sendNurseHostHangUp(hostId);
+            CALL_STATUS = Constants.STANDBY;
+            Constants.CALLING_HOST_ID = "";
+        }
+    }
+
+
     @Override
     public void onClick(View view) {
-        switch (view.getId()) {
+        /*switch (view.getId()) {
             case R.id.fragment_iv_end_calling: //右边的挂断
                 ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_hang_up);
                 nurse_CallStaus.setText("正在连接中...");
                 break;
-        }
+        }*/
     }
 
     /**
@@ -447,31 +658,29 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
      */
     @Override
     public void nurseHostItemOnclick(View view, int position) {
-        if (null == nurseHostList || nurseHostList.size() <= 0 || null == nurseHostList.get(position))
+        if (MyApplication.partInfoList.size() <= 0 || null == MyApplication.partInfoList.get(position)) {
             return;
-        NurseHostListInfo info = nurseHostList.get(position);
-        if (info.isChecked()) {
-            //nurseHostList.get(position).setChecked(false);
-            //rlIncall.setVisibility(View.GONE);
-            //rlNotInCallBg.setVisibility(View.VISIBLE);
-            //tvCallingTips.setText("");
-        } else {
-            for (NurseHostListInfo entity : nurseHostList) {
+        }
+        PartInfoEntity.PartInfo  info = MyApplication.partInfoList.get(position);
+        if (!info.isChecked()) {
+            for (PartInfoEntity.PartInfo entity : MyApplication.partInfoList) {
                 if (null == entity) continue;
                 entity.setChecked(false);
             }
             info.setChecked(true);
-            tvCallingTips.setText(info.getDeviceName());
-            nurse_CallStaus.setText(info.getDeviceName());
+            nurseHostAdapter.notifyDataSetChanged();
+
+            tvCallingTips.setText(info.getPART_NAME());
+            //nurse_CallStaus.setText(info.getPART_NAME());
             ivDoctorOrNurseCalling.setImageResource(R.mipmap.ic_nurse_right_in_call);
             ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_calling);
             ivEndCalling.setVisibility(View.VISIBLE);
             rlIncall.setVisibility(View.VISIBLE);
             rlNotInCallBg.setVisibility(View.GONE);
+
+            getPartData(info.getID());
+            getNurseHostInfo(info.getID());
         }
-        nurseHostAdapter.notifyDataSetChanged();
-        dutyDoctorAdapter.updateList(info.getDutyDoctorList());
-        dutyNurseAdapter.updateList(info.getNurseOnDutyList());
     }
 
     /**
@@ -508,6 +717,17 @@ public class CallingHostFragment extends BaseFragment implements DoctorHostAdapt
 
     @Subscribe(threadMode = ThreadMode.MAIN)
     public void onMoonEvent(MessageEvent messageEvent) {
+        if (messageEvent.getType() == Constants.EVENT_UDP2) {
+            UdpEntity udpEntity = (UdpEntity) messageEvent.getMessage();
+            String nurseHostID = udpEntity.getNurseHostID();
+            if (Constants.CALLING_HOST_ID.equals(nurseHostID)) {
+                //对方挂断
+                ivEndCalling.setBackgroundResource(R.mipmap.ic_calling_sickbed_right_calling);
+                nurse_CallStaus.setText("");
+                CALL_STATUS = Constants.STANDBY;
+                Constants.CALLING_HOST_ID = "";
+            }
+        }
     }
 
     /**

+ 27 - 7
app/src/main/java/com/wdkl/callingmainnursemanager/util/AnalysisUdpUtil.java

@@ -44,15 +44,35 @@ public class AnalysisUdpUtil {
             udpMsg = delHeadAndEnd(udpMsg, "$", "#");
             final String[] data = udpMsg.split(Character.toString((char) 3));
 
-            if(StringUtils.notEmpty(Constants.PartID)){
-            try {
-                LogUtil.d("AAGGH", "PartID==" + Constants.PartID+"-----UDPPartID=="+data[data.length - 1]);
-                if (!StringUtils.notEmpty(data[data.length - 1]) || !Constants.PartID.equals(data[data.length - 1])) {// 协议规定所有UDP最后一条为  PartID (科室ID)。只有属于自己科室的才能作用
+            if (Constants.MANAGER_CALL.equals(data[8])) {
+                if ("call_12_upremove".equals(data[0])){
+                        UdpEntity call_12_hang_up = new UdpEntity();
+                        call_12_hang_up.setIndexes(data[0]);
+                        call_12_hang_up.setNurseHostID(data[1]);
+                        call_12_hang_up.setDoorwayMachineID(data[2]);
+                        call_12_hang_up.setHeadMachineID(data[3]);
+                        call_12_hang_up.setSipAddress(data[4]);
+                        call_12_hang_up.setRoomNumber(data[5]);
+                        call_12_hang_up.setBedNumber(data[6]);
+                        call_12_hang_up.setLevel(data[7]);
+                        call_12_hang_up.setType(data[8]);
+                        call_12_hang_up.setName(data[9]);
+                        call_12_hang_up.setDeviceMAC(data[10]);
+                        call_12_hang_up.setShowText("护士主机取消呼叫");
+                        EventBus.getDefault().post(new MessageEvent(call_12_hang_up, Constants.EVENT_UDP2));
+                }
+            }
+
+            if (StringUtils.notEmpty(Constants.PartID)) {
+                try {
+                    LogUtil.d("AAGGH", "PartID==" + Constants.PartID + "-----UDPPartID==" + data[data.length - 1]);
+                    if (!StringUtils.notEmpty(data[data.length - 1]) || !Constants.PartID.equals(data[data.length - 1])) {// 协议规定所有UDP最后一条为  PartID (科室ID)。只有属于自己科室的才能作用
+                        return;
+                    }
+                } catch (Exception e) {
                     return;
                 }
-            } catch (Exception e) {
-                return;
-            }}
+            }
 
             //判断indexes 是否为当前端口使用
             switch (data[0]) {

+ 1 - 1
app/src/main/java/com/wdkl/callingmainnursemanager/util/StringUtils.java

@@ -71,7 +71,7 @@ public class StringUtils {
     }
 
     public static String getAllVersionName() {
-        String str = "\r\nAPP版本号:V" + BuildConfig.VERSION_NAME + "     中央服务器系列护士总机\r\n发布日期:" + BuildConfig.BUILD_TIME;
+        String str = "\r\nAPP版本号:V" + BuildConfig.VERSION_NAME + "     中央服务器系列总控主机\r\n发布日期:" + BuildConfig.BUILD_TIME;
         if (android.os.Build.VERSION.SDK_INT >= 26) { //android8.0 = 26
             str = str + "    android8.1 , rk3368";// rk3368 android8.1
         } else if (android.os.Build.VERSION.SDK_INT >= 24) { //android7.0 = 24

+ 39 - 0
app/src/main/java/com/wdkl/callingmainnursemanager/util/UdpSendUtil.java

@@ -1,6 +1,7 @@
 package com.wdkl.callingmainnursemanager.util;
 
 import android.content.Context;
+import android.text.TextUtils;
 
 import com.wdkl.callingmainnursemanager.common.Constants;
 import com.wdkl.callingmainnursemanager.entity.InitDataEntity;
@@ -223,6 +224,44 @@ public class UdpSendUtil {
     }
 
     /**
+     * 总控制室主机向护士主机请求通话
+     */
+    public static void sendNurseHostCall(String hostId) {
+        if (TextUtils.isEmpty(hostId)) {
+            return;
+        }
+        AnalysisUdpUtil.sendUdpData("call_12",
+                hostId, //接收通话请求的护士主机id
+                "",
+                "",
+                Constants.SIP_ID, //总控主机sip id
+                "",
+                "",
+                "",
+                Constants.MANAGER_CALL, //呼叫类型
+                "",
+                Constants.MAC_ADDRESS);
+    }
+
+    /**
+     * 总控制室主机挂断通话,需要通知对方护士主机
+     */
+    public static void sendNurseHostHangUp(String hostId) {
+        AnalysisUdpUtil.sendUdpData("call_12_hang_up",
+                hostId, //通话对方的护士主机id
+                "",
+                "",
+                Constants.SIP_ID,
+                "",
+                "",
+                "",
+                Constants.MANAGER_CALL, //呼叫类型
+                "",
+                Constants.MAC_ADDRESS);
+    }
+
+
+    /**
      * 安卓端接通电话;通知外面点阵屏;安卓端本身暂时没有用到这条UDP
      * 我将连发2次,防止UDP丢失
      *

+ 3 - 2
app/src/main/res/layout/activity_fragment.xml

@@ -56,10 +56,11 @@
         </LinearLayout>
 
         <LinearLayout
-            android:layout_width="180dp"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:gravity="center"
             android:orientation="horizontal"
+            android:layout_marginRight="20dp"
             android:weightSum="1.8">
 
             <ImageView
@@ -90,7 +91,7 @@
                 android:layout_marginLeft="2dp"
                 android:layout_marginRight="2dp"
                 android:gravity="center"
-                android:text="本地连"
+                android:text=""
                 android:textColor="@color/white"
                 android:textSize="12sp" />
             <!--wifi-->

+ 2 - 0
app/src/main/res/layout/custom_spinner_dropdown_item.xml

@@ -2,6 +2,8 @@
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
+    android:paddingTop="10dp"
+    android:paddingBottom="10dp"
     android:id="@+id/my_dropdown_item"
     android:gravity="center"
     android:singleLine="true"

+ 0 - 1
app/src/main/res/layout/fragment_medical_hosts_call_queuing_info_bar_layout.xml

@@ -111,7 +111,6 @@
                 android:layout_below="@+id/fragment_iv_doctor_or_nurse_calling"
                 android:layout_centerInParent="true"
                 android:layout_marginTop="@dimen/margin_10dp"
-                android:text="--"
                 android:textColor="@color/white"
                 android:textSize="16sp" />
 

+ 7 - 5
app/src/main/res/layout/fragment_nurse_host_adapter.xml

@@ -1,9 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="350dp"
-    android:layout_height="310dp"
+    android:layout_width="340dp"
+    android:layout_height="320dp"
     android:layout_gravity="center"
-    android:layout_marginBottom="@dimen/margin_30dp"
     android:orientation="vertical">
 
     <ImageView
@@ -15,12 +14,15 @@
 
     <TextView
         android:id="@+id/adapter_tv_nurse_host_no"
-        android:layout_width="wrap_content"
+        android:layout_width="200dp"
         android:layout_height="wrap_content"
         android:layout_below="@+id/adapter_iv_nurse_host"
         android:layout_centerHorizontal="true"
+        android:gravity="center_horizontal"
         android:text="医生主机一"
+        android:lines="2"
+        android:ellipsize="end"
         android:textColor="@color/white"
-        android:textSize="@dimen/text_size_20px" />
+        android:textSize="24sp" />
 
 </RelativeLayout>

+ 1 - 1
app/src/main/res/values/strings.xml

@@ -1,5 +1,5 @@
 <resources>
-    <string name="app_name">护士总机</string>
+    <string name="app_name">总控主机</string>
     <string name="loading_title">努力加载中</string>
     <!--初始化提示String-->
     <string name="DEVICE_NULL">设备未启用</string>