123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700 |
- package com.wdkl.callingmainnursemanager.ui.fragment;
- import android.annotation.SuppressLint;
- import android.os.Bundle;
- import android.os.Handler;
- import android.os.Message;
- import android.support.v4.widget.SwipeRefreshLayout;
- import android.support.v7.app.AlertDialog;
- import android.support.v7.widget.GridLayoutManager;
- import android.support.v7.widget.LinearLayoutManager;
- import android.support.v7.widget.RecyclerView;
- import android.support.v7.widget.helper.ItemTouchHelper;
- import android.util.Log;
- import android.view.LayoutInflater;
- import android.view.MotionEvent;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.AdapterView;
- import android.widget.ArrayAdapter;
- import android.widget.Button;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.ScrollView;
- import android.widget.Spinner;
- import android.widget.TextView;
- import com.google.gson.Gson;
- import com.wdkl.callingmainnursemanager.MyApplication;
- import com.wdkl.callingmainnursemanager.R;
- import com.wdkl.callingmainnursemanager.adapter.CallListAdapter;
- import com.wdkl.callingmainnursemanager.adapter.CallingQueuingInfoAdapter;
- import com.wdkl.callingmainnursemanager.adapter.DutyDoctorAdapter;
- import com.wdkl.callingmainnursemanager.adapter.DutyNurseAdapter;
- import com.wdkl.callingmainnursemanager.adapter.ImportantMessageAdapter;
- import com.wdkl.callingmainnursemanager.adapter.SicknessBedAdapter;
- import com.wdkl.callingmainnursemanager.adapter.SicknessRoomAdapter;
- 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;
- import com.wdkl.callingmainnursemanager.entity.MessageEvent;
- import com.wdkl.callingmainnursemanager.entity.RoomEntity;
- import com.wdkl.callingmainnursemanager.entity.SystemInfoEntity;
- import com.wdkl.callingmainnursemanager.entity.UdpEntity;
- import com.wdkl.callingmainnursemanager.ui.activity.MainFragmentActivity;
- import com.wdkl.callingmainnursemanager.util.ListComparatorUtil;
- import com.wdkl.callingmainnursemanager.util.LogUtil;
- import com.wdkl.callingmainnursemanager.util.PalyPhonetics;
- import com.wdkl.callingmainnursemanager.util.SharedPreferencesUtil;
- import com.wdkl.callingmainnursemanager.util.StringUtils;
- import com.wdkl.callingmainnursemanager.util.ToastUtil;
- import com.wdkl.callingmainnursemanager.util.UIUtils;
- import com.wdkl.callingmainnursemanager.util.UdpSendUtil;
- import com.wdkl.callingmainnursemanager.util.VoiceManagerUtil;
- import com.wdkl.callingmainnursemanager.util.VoiceMessageRoomWardInformationUtil;
- import com.wdkl.callingmainnursemanager.widget.dialog.UrgentPopupwindow;
- import com.wdkl.callingmainnursemanager.widget.view.GridSpacingItemDecoration;
- import com.wdkl.callingmainnursemanager.util.PopupwindowVoiceNoticeUtil;
- import com.zhy.http.okhttp.OkHttpUtils;
- import com.zhy.http.okhttp.callback.StringCallback;
- import org.greenrobot.eventbus.EventBus;
- import org.greenrobot.eventbus.Subscribe;
- import org.greenrobot.eventbus.ThreadMode;
- import org.json.JSONException;
- import org.json.JSONObject;
- import java.util.ArrayList;
- import java.util.List;
- import butterknife.Bind;
- import butterknife.ButterKnife;
- import butterknife.OnClick;
- import okhttp3.Call;
- import serialporttest.utils.SerialPortUtil;
- import static com.wdkl.callingmainnursemanager.common.Constants.DOOR_CALL;
- import static com.wdkl.callingmainnursemanager.common.Constants.FTP_VOICE;
- import static com.wdkl.callingmainnursemanager.util.FtpUtil.ftpFilePath;
- import static com.wdkl.callingmainnursemanager.util.StringUtils.notEmpty;
- import static com.wdkl.callingmainnursemanager.util.ToastUtil.showToast;
- import static com.wdkl.callingmainnursemanager.widget.VoiceMessageRecordPopupwindow.fileOriginalName;
- import static com.wdkl.callingmainnursemanager.widget.VoiceMessageRecordPopupwindow.getCurrentDate;
- /**
- * Created by xuhuan on 2017/8/23 <br></>
- * Changed by Waderson on 2017/11/01
- */
- public class CallingBedFragment extends BaseFragment implements SicknessBedAdapter.CallingSicknessBedItemOnclickListener,
- SicknessRoomAdapter.CallingSicknessRoomItemOnclickListener, CallListAdapter.CallingListItemOnclickListener,
- SerialPortUtil.ISerialPortOnclickEvent, SerialPortUtil.IForkSpringSwiData, CallingQueuingInfoAdapter.CallingQueuingItemOnclickListener
- , SwipeRefreshLayout.OnRefreshListener, View.OnClickListener {
- private View mView;
- /**
- * 右侧病人数据View
- */
- @Bind(R.id.fragment_ll_show_right_patient_info)
- View vRightPatientInfo;
- /**
- * 右侧通话状态View
- */
- @Bind(R.id.fragment_ll_show_right_call_info)
- View vRightCallInfo;
- /**
- * 右侧通话呼叫的病人信息列表总View
- */
- @Bind(R.id.fragment_ll_show_right_call_list_info)
- View vRightCallListInfo;
- /**
- * 右侧通话呼叫的病人信息列表View
- */
- @Bind(R.id.right_call_list_infomation)
- ScrollView rightCallListInfomation;
- /**
- * 右侧通话呼叫的病人信息列表下面按键
- */
- @Bind(R.id.right_in_call_list_layout_iv_call)
- ImageView ivCallListPic;
- /**
- * 科室的所有病房列表
- */
- @Bind(R.id.fragment_rv_callsickbed_room)
- RecyclerView rvCallRoom;
- /**
- * 某个病房下面的病床列表
- */
- @Bind(R.id.fragment_rv_calling_sick_bed)
- RecyclerView rvCallBed;
- /**
- * 动态呼叫列表
- */
- @Bind(R.id.fragment_rv_calling_call_list)
- RecyclerView rvCallList;
- /**
- * 科室的值班医生列表
- */
- @Bind(R.id.fragment_rv_duty_doctor)
- RecyclerView rvDutyDoctor;
- /**
- * 科室的值班护士列表
- */
- @Bind(R.id.fragment_rv_nurse_on_duty)
- RecyclerView rvNurseOnDuty;
- /**
- * 科室的要事留言列表
- */
- @Bind(R.id.fragment_rv_important_message)
- RecyclerView rvImportantMessage;
- /**
- * 科室的呼叫记录信息栏列表
- */
- @Bind(R.id.fragment_rv_calling_queuing_info_bar)
- RecyclerView rvCallingQueuingBar;
- @Bind(R.id.fragment_ll_sickbed_bg)
- LinearLayout llBgList;
- @Bind(R.id.fragment_call_sickbed_room_tv_list_title)
- TextView tvTitle;
- @Bind(R.id.tv_part_title)
- TextView tvPartTitle;
- @Bind(R.id.right_patient_info_layout_tv_back)
- TextView tvBackHost;
- /**
- * 病房适配器
- */
- private SicknessRoomAdapter roomAdapter;
- /**
- * 病床适配器
- */
- private SicknessBedAdapter bedAdapter;
- /**
- * 呼叫列表适配器
- */
- private CallListAdapter callListAdapter;
- /**
- * 消息适配器
- */
- private ImportantMessageAdapter importantMessageAdapter;
- /**
- * 责任医生的适配器
- */
- private DutyDoctorAdapter dutyDoctorAdapter;
- /**
- * 责任护士的适配器
- */
- private DutyNurseAdapter dutyNurseAdapter;
- /**
- * 呼叫记录信息的适配器
- */
- private CallingQueuingInfoAdapter callingQueuingInfoAdapter;
- /**
- * 呼叫排队信息栏实体
- */
- private CallingQueuingInfoEntity callingQueuingInfoEntity;
- /**
- * 呼叫排队信息栏的数据源
- */
- private ArrayList<CallingQueuingInfoEntity> callingQueuingInfoList;
- private MainFragmentActivity mainFragmentActivity;
- @Bind(R.id.textView3)
- TextView leaveWord;
- //刷新控件
- @Bind(R.id.fragment_calling_bed_layout_sr_refresh)
- SwipeRefreshLayout swipeRefreshLayout;
- @Bind(R.id.fragment_rv_calling_nodatainfomation)
- TextView noCalledDataText;
- @Bind(R.id.fragment_tv_room_bed_answer_call_state)
- TextView tvBedCallState;
- @Bind(R.id.fragment_tv_room_bed_answer_state)
- TextView tvRoomBedAnswerState;
- //房间号 床号
- @Bind(R.id.right_in_calling_layout_room_msg)
- TextView tvRoomMsg;
- //病人姓名 性别 年龄 入院时间
- @Bind(R.id.fragment_tv_patient_info)
- TextView tvPatientInfo;
- //入院时间
- @Bind(R.id.fragment_tv_patient_admission_time)
- TextView tvPatientInfoAdmissionTime;
- //责任医生
- @Bind(R.id.fragment_tv_attending_doctor)
- TextView tvAttendingDoctor;
- //责任护士
- @Bind(R.id.fragment_tv_nurse_in_charge)
- TextView tvNurseInCharge;
- //病情诊断
- @Bind(R.id.fragment_tv_condition)
- TextView tvCondition;
- //护理内容
- @Bind(R.id.fragment_tv_grade_level)
- TextView tvGradeLevel;
- //饮食内容
- @Bind(R.id.fragment_tv_diet_level)
- TextView tvDietLevel;
- //计量内容
- @Bind(R.id.fragment_tv_dosage_level)
- TextView tvDosageLevel;
- //隔离内容 InsulateLevel
- @Bind(R.id.fragment_tv_insulate_level)
- TextView tvInsulateLevel;
- //拨号图片
- @Bind(R.id.right_in_calling_layout_iv_call)
- ImageView ivCallPic;
- //拨号图片
- @Bind(R.id.fragment_calling_right_layout_ll_call)
- LinearLayout llCallPic;
- //返回按钮
- @Bind(R.id.right_in_call_list_layout_iv_back)
- TextView tvBack;
- @Bind(R.id.fragment_calling_right_layout_ll_calls)
- LinearLayout llCallPics;
- //拨号状态
- @Bind(R.id.right_in_calling_layout_tv_state)
- TextView tvCallState;
- /**
- * 医院数据
- **/
- //病人人数
- @Bind(R.id.fragment_sick_bed_layout_tv_patient_num)
- TextView tvPatientNum;
- //空闲床位
- @Bind(R.id.fragment_sick_bed_layout_tv_free_bed)
- TextView tvFreeBed;
- //今日入院
- @Bind(R.id.fragment_sick_bed_layout_tv_today_admission)
- TextView tvTodayAdmission;
- //进入出院
- @Bind(R.id.fragment_sick_bed_layout_tv_today_leave)
- TextView tvTodayLeave;
- //明日出院
- @Bind(R.id.fragment_sick_bed_layout_tv_tomorrow_leave)
- TextView tvTomorrowLeave;
- //今日手术
- @Bind(R.id.fragment_sick_bed_layout_tv_today_operation)
- TextView tvTodayOperation;
- //明日手术
- @Bind(R.id.fragment_sick_bed_layout_tv_tomorrow_operation)
- TextView tvTomorrowOperation;
- //特级护理
- @Bind(R.id.fragment_sick_bed_layout_tv_special_care)
- TextView tvSpecialCare;
- //一级护理
- @Bind(R.id.fragment_sick_bed_layout_tv_primary_care)
- TextView tvPrimaryCare;
- /**
- * 呼叫列表
- */
- //呼叫列表呼叫状态
- @Bind(R.id.right_call_list_layout_tv_state)
- TextView tvCallListState;
- //呼叫列表数据
- @Bind(R.id.right_call_list_layout_tv_room_msg)
- TextView tvCallListRoomMsg;
- //、、、、、、、、病人的个人信息、、、、、、、、、、
- @Bind(R.id.right_call_list_layout_tv_patient_name)
- TextView tvCallListName;
- @Bind(R.id.right_call_infomation)
- TextView rightCallInfomation;
- @Bind(R.id.right_call_infomationone)
- TextView rightCallInfomationOne;
- @Bind(R.id.right_call_infomationtwo)
- TextView rightCallInfomationTwo;
- @Bind(R.id.right_call_infomationthree)
- TextView rightCallInfomationThree;
- @Bind(R.id.right_call_infomationfour)
- TextView rightCallInfomationFour;
- @Bind(R.id.right_call_infomationfive)
- TextView rightCallInfomationFive;
- @Bind(R.id.right_call_infomationsix)
- TextView rightCallInfomationSix;
- @Bind(R.id.right_call_infomationseven)
- TextView rightCallInfomationSeven;
- @Bind(R.id.right_call_infomationeight)
- TextView rightCallInfomationEight;
- //、、、、、、、、病人的个人信息、、、、、、、、、、
- /**
- * 病房列表和病床列表
- */
- private ArrayList<RoomEntity.WardInformation> wardInformationList;
- /**
- * 单个病房的病床列表
- */
- private ArrayList<RoomEntity.WardInformation.SickbedInformation> sickbedInformationList;
- /**
- * 整个科室的数据
- */
- private RoomEntity roomEntity;
- /**
- * 整个医院的数据
- */
- private HospitalInfoEntity hospitalInfoEntity;
- /**
- * 所有值班医生的列表
- */
- private ArrayList<String> dutyDoctorList;
- /**
- * 所有值班护士的列表
- */
- private ArrayList<String> nurseOnDutyList;
- /**
- * 所有留言的列表
- */
- private ArrayList<String> importantMessageList;
- /**
- * 保存房号的position
- */
- private int position = -1;
- /**
- * 当前点击房间的条目索引
- */
- private static int ROOM_LIST_POSITION = -1;
- /**
- * 床位条目索引
- */
- private static int BED_LIST_POSITION = -1;
- /**
- * 用户拨打电话的条目索引
- */
- private static int CALL_LIST_POSITION = -1;
- /**
- * 用户拨打电话的当前实例
- */
- protected UdpEntity callingEntity;
- /**
- * 用户选择的当前床位实例
- */
- protected RoomEntity.WardInformation.SickbedInformation sickBedInfo;
- /**
- * 是否需要轮流播报
- */
- public static boolean have_Speak = true;
- /**
- * 是否拨打了电话
- */
- public boolean have_Call = false;
- /**
- * 是否拨打床位电话
- */
- public boolean callBed = false;
- /**
- * 串口工具类
- */
- SerialPortUtil serialPortUtil;
- /**
- * 用户向上滑动的item的Position
- */
- int upScrllPosition = -1;
- /**
- * 语音播报循环次数
- */
- public int speakLooping = 2;
- /**
- * 系统设置
- */
- public SystemInfoEntity systemInfoEntity;
- /**
- * 是否需要音频PA
- */
- public static boolean HAVA_PA = false;
- /**
- * 语音轮播线程
- */
- Thread palyPhoneticsThread;
- public static CallingBedFragment mCallingBedFragment;
- public static CallingBedFragment getInstance() {
- return mCallingBedFragment == null ? new CallingBedFragment() : mCallingBedFragment;
- }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- mView = inflater.inflate(R.layout.fragment_calling_sick_bed, null);
- ButterKnife.bind(this, mView);
- mCallingBedFragment = this;
- if (null != MyApplication.serialPortUtil) { //初始化;打开外部音响
- MyApplication.serialPortUtil.stereoControl("1");
- }
- return mView;
- }
- @Override
- protected void initView(View RootView) {
- //默认的通话状态
- //Constants.CALL_STATE = Constants.STANDBY;
- vRightPatientInfo.setVisibility(View.VISIBLE);
- vRightCallInfo.setVisibility(View.GONE);
- vRightCallListInfo.setVisibility(View.GONE);
- //tvPartTitle.setText("当前科室: " + Constants.PartName);
- //默认设置
- rvCallBed.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
- @Override
- public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
- UIUtils.rvSideslipShowPopu(getActivity(), motionEvent);
- return false;
- }
- @Override
- public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
- }
- @Override
- public void onRequestDisallowInterceptTouchEvent(boolean b) {
- }
- });
- rvCallRoom.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
- @Override
- public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
- UIUtils.rvSideslipShowPopu(getActivity(), motionEvent);
- return false;
- }
- @Override
- public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
- }
- @Override
- public void onRequestDisallowInterceptTouchEvent(boolean b) {
- }
- });
- rvCallList.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
- @Override
- public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
- UIUtils.rvSideslipShowPopu(getActivity(), motionEvent);
- return false;
- }
- @Override
- public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
- }
- @Override
- public void onRequestDisallowInterceptTouchEvent(boolean b) {
- }
- });
- leaveWord.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View view) {
- ToastUtil.showToast("CALL_STATE=" + Constants.CALL_STATE);
- return false;
- }
- });
- }
- @Override
- protected void initUtil() {
- serialPortUtil = ((MyApplication) getActivity().getApplication()).serialPortUtil;
- serialPortUtil.setOnDataReceiveListener(this, this);
- setVolumePA(false);
- setPowerLed("1");
- startPalyPhonetics();
- }
- @Override
- protected void initData() {
- try {
- getSYSsetingData();
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- }
- mainFragmentActivity = (MainFragmentActivity) getActivity();
- roomEntity = new RoomEntity();
- wardInformationList = new ArrayList<>();
- sickbedInformationList = new ArrayList<>();
- hospitalInfoEntity = new HospitalInfoEntity();
- dutyDoctorList = new ArrayList<>();
- nurseOnDutyList = new ArrayList<>();
- importantMessageList = new ArrayList<>();
- initRecyclerManager();
- //setPartId(); //设置科室id
- updatePartName(); //更新科室名称
- resetData();
- getData(); //获取数据
- //初始化病房数据
- //getRoomData();
- //getRoomTestData();
- //获得医院信息
- getHospitalData();
- //初始化排队信息栏数据
- //initCallingQueuingInfo();
- MainFragmentActivity.initCallVoiceShowProgress();//add by waderson 20190801 SIP通话音量不能保存?要动态设置??曹强的东西真搞不懂他
- }
- private void initRecyclerManager() {
- //Room
- swipeRefreshLayout.setOnRefreshListener(this);
- roomAdapter = new SicknessRoomAdapter(getActivity(), wardInformationList);
- GridLayoutManager gridLayoutRoomManager = new GridLayoutManager(getActivity(), 8);
- rvCallRoom.setLayoutManager(gridLayoutRoomManager);
- rvCallRoom.addItemDecoration(new GridSpacingItemDecoration(8, 10, true));
- roomAdapter.setSicknessRoomItemOnClickListener(CallingBedFragment.this);
- rvCallRoom.setAdapter(roomAdapter);
- //Bed
- LinearLayoutManager linearLayoutBedManager = new LinearLayoutManager(getActivity());
- linearLayoutBedManager.setOrientation(LinearLayoutManager.HORIZONTAL);
- rvCallBed.setLayoutManager(linearLayoutBedManager);
- bedAdapter = new SicknessBedAdapter(getActivity(), sickbedInformationList);
- rvCallBed.setAdapter(bedAdapter);
- bedAdapter.setSicknessBedItemOnClickLinstener(this);
- //call list
- LinearLayoutManager linearLayoutCallListManager = new LinearLayoutManager(getActivity());
- linearLayoutCallListManager.setOrientation(LinearLayoutManager.HORIZONTAL);
- rvCallList.setLayoutManager(linearLayoutCallListManager);
- callListAdapter = new CallListAdapter(getActivity(), ((MyApplication) getActivity().getApplication()).callEntityList);
- rvCallList.setAdapter(callListAdapter);
- callListAdapter.setCallingListItemOnClickListener(this);
- ItemTouchHelper.Callback mCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.UP) {
- @Override
- public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
- return false;
- }
- @Override
- public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { //上滑删除item
- upScrllPosition = viewHolder.getAdapterPosition();
- UdpEntity upScrllUdpEntity = MyApplication.callEntityList.get(upScrllPosition);
- deleteCallingItem(upScrllUdpEntity , 0);
- }
- };
- //用Callback构造ItemtouchHelper
- ItemTouchHelper touchHelper = new ItemTouchHelper(mCallback);
- //调用ItemTouchHelper的attachToRecyclerView方法建立联系
- touchHelper.attachToRecyclerView(rvCallList);
- //Doctor
- LinearLayoutManager dutyDoctorLayoutBedManager = new LinearLayoutManager(getActivity());
- dutyDoctorLayoutBedManager.setOrientation(LinearLayoutManager.HORIZONTAL);
- rvDutyDoctor.setLayoutManager(dutyDoctorLayoutBedManager);
- dutyDoctorAdapter = new DutyDoctorAdapter(getActivity(), dutyDoctorList);
- rvDutyDoctor.setAdapter(dutyDoctorAdapter);
- //Nurse
- LinearLayoutManager dutyNurseDoctorLayoutBedManager = new LinearLayoutManager(getActivity());
- dutyNurseDoctorLayoutBedManager.setOrientation(LinearLayoutManager.HORIZONTAL);
- rvNurseOnDuty.setLayoutManager(dutyNurseDoctorLayoutBedManager);
- dutyNurseAdapter = new DutyNurseAdapter(getActivity(), nurseOnDutyList);
- rvNurseOnDuty.setAdapter(dutyNurseAdapter);
- //msg
- LinearLayoutManager MsgLayoutBedManager = new LinearLayoutManager(getActivity());
- MsgLayoutBedManager.setOrientation(LinearLayoutManager.VERTICAL);
- rvImportantMessage.setLayoutManager(MsgLayoutBedManager);
- importantMessageAdapter = new ImportantMessageAdapter(getActivity(), importantMessageList);
- rvImportantMessage.setAdapter(importantMessageAdapter);
- }
- /**
- * 删除指定的条目(change by waderson 20191108)
- * @param deleteEntity 被删除的实体
- * @param type 0 手指上滑 ; 1 子机取消呼叫UDP
- */
- protected void deleteCallingItem(UdpEntity deleteEntity , int type) {
- if (callingEntity != null) {
- if (deleteEntity.equals(callingEntity)) {
- vRightPatientInfo.setVisibility(View.VISIBLE);
- vRightCallInfo.setVisibility(View.GONE);
- vRightCallListInfo.setVisibility(View.GONE);
- }
- }
- //删除后通知外面做出改变
- sendRemoveBack(deleteEntity);
- if (null != callingEntity) {
- if (callingEntity.equals(deleteEntity)) {//判断是否为当前通话;如果是就挂断电话,改变UI
- endCall();
- }
- }
- //viewHolder.getAdapterPosition() 和 iewHolder.getLayoutPosition()有16ms 的差距 之后adpter默认-1
- if (null != loopingUdpentity && loopingUdpentity.equals(deleteEntity)) {
- if (null != loopVoice) {
- loopVoice.setPalyDismiss(true);
- }
- } else {
- for (int i = 0; i< PalyPhonetics.speakEntityList.size(); i++) {//将播报列表也删除该元素 两种实体格式不一样,所以要用循环
- if(PalyPhonetics.speakEntityList.get(i).equals(deleteEntity)) {
- PalyPhonetics.speakEntityList.remove(i);
- }
- }
- }
- endCallNotifi(deleteEntity);
- for (int i=0; i< MyApplication.callEntityList.size(); i++) {//将列表也删除该元素 两种实体格式不一样,所以要用循环
- if(MyApplication.callEntityList.get(i).equals(deleteEntity)) {
- MyApplication.callEntityList.remove(i);
- }
- }
- sendNoAnyRequestDoor(deleteEntity);
- sendCallWaitingNumber(MyApplication.callEntityList.size());
- callListAdapter.updateList(MyApplication.callEntityList);
- roomAdapter.notifyDataSetChanged();
- if (!StringUtils.listNotEmpty(MyApplication.callEntityList)) {
- setPowerLed("1");
- }
- }
- private void getRoomTestData() {
- if (swipeRefreshLayout.isRefreshing()) {
- swipeRefreshLayout.setRefreshing(false);
- }
- RoomEntity entity = new RoomEntity();
- ArrayList<RoomEntity.WardInformation> wardInformations = new ArrayList<>();
- for (int i = 0; i < 200; i++) {
- ArrayList<RoomEntity.WardInformation.SickbedInformation> sickbedInformations = new ArrayList<>();
- RoomEntity.WardInformation wardInfo = new RoomEntity.WardInformation();
- wardInfo.setRoomNum("" + i);
- for (int j = 0; j < 2; j++) {
- RoomEntity.WardInformation.SickbedInformation sickBedInfo = new RoomEntity.WardInformation.SickbedInformation();
- int bedNum = i*2 + j;
- sickBedInfo.setBedNum("" + bedNum);
- sickBedInfo.setPatientName("" + bedNum);
- sickbedInformations.add(sickBedInfo);
- }
- wardInfo.setSickbedInformationList(sickbedInformations);
- wardInformations.add(wardInfo);
- }
- entity.setWardInformationList(wardInformations);
- wardInformationList = entity.getWardInformationList();
- roomAdapter.updateList(wardInformationList);
- if (null != wardInformationList && CallingBedFragment.this.position != -1) {
- try {
- sickbedInformationList = wardInformationList.get(CallingBedFragment.this.position).getSickbedInformationList();
- } catch (Exception e) {
- LogUtil.d("getRoomData", "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);
- }
- }
- 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() {
- Constants.DEVICE_ID = ""; //重置deviceId
- 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.sendMessageDelayed(msg, 200);
- break;
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- private void getDeviceId(String mac) {
- Constants.DEVICE_ID = ""; //重置deviceId
- 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.sendMessageDelayed(msg, 200);
- }
- }
- } 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)
- // .addParams("deviceId","5")
- .addParams("deviceId", Constants.MYSELF_ID)
- .build()
- .execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e, int id) {
- if (swipeRefreshLayout.isRefreshing()) {
- swipeRefreshLayout.setRefreshing(false);
- }
- hideProgress();
- handler.sendEmptyMessage(GETROOMDATA_ERROR);
- }
- @Override
- public void onResponse(String response, int id) {
- LogUtil.d(CallingBedFragment.class, "getRoomData==" + 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!")) {
- handler.sendEmptyMessage(GETROOMDATA_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("getRoomData", "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 getHospitalData() {
- if (!StringUtils.notEmpty(Constants.URL)) return;
- if (!StringUtils.notEmpty(Constants.SelectedPartId)) return;
- OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_HOSPITAL)
- .addParams("PartID", Constants.SelectedPartId)
- .build()
- .execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e, int id) {
- hideProgress();
- Constants.MGR_UPDATE = false;
- if (swipeRefreshLayout.isRefreshing()) {
- swipeRefreshLayout.setRefreshing(false);
- }
- handler.sendEmptyMessage(GETHOSPITALDATA_ERROR);
- }
- @Override
- public void onResponse(String response, int id) {
- String data = response.substring(0, response.length() - 4);
- LogUtil.d("getHospitalData", "data=="+data);
- try {
- if (swipeRefreshLayout.isRefreshing()) {
- swipeRefreshLayout.setRefreshing(false);
- }
- JSONObject jsonObj = new JSONObject(data);
- if (jsonObj.getString("Code").equals("ERROR!")) {
- handler.sendEmptyMessage(GETHOSPITALDATA_ERROR);
- LogUtil.d("Code", "网络错误");
- } else {
- Gson gson = new Gson();
- hospitalInfoEntity = gson.fromJson(data, HospitalInfoEntity.class);
- dutyDoctorList = (ArrayList<String>) hospitalInfoEntity.getDutyDoctorList();
- nurseOnDutyList = (ArrayList<String>) hospitalInfoEntity.getNurseOnDutyList();
- importantMessageList = (ArrayList<String>) hospitalInfoEntity.getImportantMessageList();
- }
- setHospitalView();
- } catch (JSONException e) {
- e.printStackTrace();
- if (swipeRefreshLayout.isRefreshing()) {
- swipeRefreshLayout.setRefreshing(false);
- }
- }
- Constants.MGR_UPDATE = false;
- }
- });
- }
- private void resetData() {
- vRightPatientInfo.setVisibility(View.VISIBLE);
- vRightCallInfo.setVisibility(View.GONE);
- vRightCallListInfo.setVisibility(View.GONE);
- wardInformationList.clear();
- sickbedInformationList.clear();
- roomAdapter.updateList(wardInformationList);
- bedAdapter.listUpdate(sickbedInformationList);
- }
- public void updateBedInfo() {
- updatePartName();
- resetData();
- getData();
- getHospitalData();
- }
- /**
- * 获取系统设置信息
- */
- private void getSYSsetingData() {
- if (!StringUtils.notEmpty(Constants.URL)) return;
- LogUtil.d("setSYSsetingData", Constants.URL + Constants.URL_END + Constants.SYSTEM_INFO);
- if (!StringUtils.notEmpty(Constants.PartID)) return;
- OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.SYSTEM_INFO)
- .addParams("PartID", Constants.PartID)
- .build()
- .execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e, int id) {
- e.printStackTrace();
- Constants.MGR_UPDATE = false;
- handler.sendEmptyMessage(GETSYSSETINGDATA_ERROR);
- LogUtil.d("setSYSsetingData", "error");
- }
- @Override
- public void onResponse(String response, int id) {
- LogUtil.d("setSYSsetingData", "response==" + response);
- String data = response.substring(0, response.length() - 4);
- try {
- JSONObject jsonObj = new JSONObject(data);
- if (jsonObj.getString("Code").equals("ERROR!")) {
- LogUtil.d("setSYSsetingData", "ERROR!");
- handler.sendEmptyMessage(GETSYSSETINGDATA_ERROR);
- } else {
- Gson gson = new Gson();
- systemInfoEntity = gson.fromJson(data, SystemInfoEntity.class);
- if (null != systemInfoEntity) {
- Constants.MORNING_NIGTH = systemInfoEntity.getDayOrNight();
- Constants.DAY_RING_TIMES = systemInfoEntity.getDayRingTimes();
- Constants.NIGHT_RING_TIMES = systemInfoEntity.getNightRingTimes();
- Constants.VOICE_BROADCAST_TYPE = systemInfoEntity.getVoiceBroadcastType();
- LogUtil.d("setSYSsetingData", systemInfoEntity.getDayOrNight() + systemInfoEntity.getDayRingTimes() + systemInfoEntity.getNightRingTimes());
- setSYSParameter(false);
- }
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- Constants.MGR_UPDATE = false;
- }
- });
- }
- /**
- * 获取病人个人信息
- **/
- private void getPatientData(String bedId) {
- if (!StringUtils.notEmpty(Constants.URL)) return;
- OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_PATIENT)
- .addParams("bedid", bedId)
- .build()
- .execute(new StringCallback() {
- @Override
- public void onError(Call call, Exception e, int id) {
- onErrorClean();
- LogUtil.i(CallingBedFragment.class, "请求错误");
- }
- @Override
- public void onResponse(String response, int id) {
- LogUtil.d(CallingBedFragment.class, "getPatientData==" + response);
- String data = response.substring(0, response.length() - 4);
- try {
- JSONObject jsonObj = new JSONObject(data);
- if (jsonObj.getString("Code").equals("ERROR!")) {
- onErrorClean();
- LogUtil.i(CallingBedFragment.class, "返回错误标识");
- } else {
- LogUtil.i(CallingBedFragment.class, "返回正常");
- tvCallListName.setText("姓名:" + jsonObj.getString("patientName"));
- rightCallInfomation.setText("性别:" + jsonObj.getString("patientGender"));
- rightCallInfomationOne.setText("年龄:" + jsonObj.getString("PatientAge"));
- rightCallInfomationThree.setText("责任医生:" + jsonObj.getString("attendingDoctor"));
- rightCallInfomationFour.setText("责任护士:" + jsonObj.getString("nurseInCharge"));
- rightCallInfomationFive.setText("入院时间:" + jsonObj.getString("admissionTime"));
- String trusteeshipState = jsonObj.getString("trusteeshipState");
- if (notEmpty(trusteeshipState) && !trusteeshipState.equals("0")) {
- rightCallInfomationSix.setText("托管状态:" + "已托管");
- } else {
- rightCallInfomationSix.setText("托管状态:" + "未托管");
- }
- rightCallInfomationEight.setText("病情状况:" + StringUtils.replaceNull(StringUtils.qj2bj(jsonObj.getString("Condition"))));
- //rightCallInfomationSeven.setText(":" + jsonObj.getString(""));
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- });
- }
- private void initCallingQueuingInfo() {
- callingQueuingInfoList = new ArrayList<>();
- for (int i = 0; i < 10; i++) {
- callingQueuingInfoEntity = new CallingQueuingInfoEntity();
- callingQueuingInfoEntity.setDate("呼叫时间:2017-11-17 11:36:08");
- callingQueuingInfoEntity.setCallingRoomNo("呼叫床位:104房006床");
- //callingQueuingInfoList.add(callingQueuingInfoEntity);
- }
- LinearLayoutManager manager = new LinearLayoutManager(getActivity());
- rvCallingQueuingBar.setLayoutManager(manager);
- callingQueuingInfoAdapter = new CallingQueuingInfoAdapter(getActivity(), callingQueuingInfoList);
- rvCallingQueuingBar.setAdapter(callingQueuingInfoAdapter);
- callingQueuingInfoAdapter.setCallingQueuingItemOnclickListener(this);
- noCalledDataText.setVisibility(View.VISIBLE);
- rvCallingQueuingBar.setVisibility(View.INVISIBLE);
- }
- /**
- * Sip注册不成功不能发起拨打电话
- */
- private boolean filterSipToast() {
- if (Constants.SIP_REGIST_STATUS == 0) {
- ToastUtil.showToast("通话协议注册失败!");
- return false;
- } else if (Constants.SIP_REGIST_STATUS == 1) {
- ToastUtil.showToast("通话协议正在注册中,请稍候!");
- return false;
- }
- return true;
- }
- @Override
- public void onClick(View view) {
- switch (view.getId()) {
- case R.id.confirm_button:
- if (null != urgentPopupwindow) {
- urgentPopupwindow.dismiss();
- }
- break;
- }
- }
- /**
- * 来电呼叫列表中的右下角呼叫按键
- */
- @OnClick(R.id.right_in_call_list_layout_iv_call)
- public void listCall(View view) {
- currentTime = System.currentTimeMillis();
- if (currentTime - lastClickTime > CLICK_DELAY_TIME) {
- lastClickTime = currentTime;
- //加了个点击缓冲 20180319
- // ===============================暂时注掉20180408(Ping网:有时候 网络已经连上 但是ping不通)===========================//
- if (!filterSipToast()) {
- return;
- }
- if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
- if (null == callingEntity) {
- return;
- }
- if (null != loopVoice) {
- loopVoice.setPalyDismiss(true);
- }
- //String sipAddress = callingEntity.getSipAddress();
- String sipAddress = callingEntity.getSipAddress();
- if (StringUtils.notEmpty(sipAddress)) {
- LogUtil.d("sipAddress", "Call==sipAddress==" + sipAddress);
- LogUtil.d("sipAddress", "Call==deviceMAC==" + callingEntity.getDeviceMAC());
- //ToastUtil.showToast(sipAddress+"===="+callingEntity.getDeviceMAC());
- callBed = false;
- ivCallListPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
- mainFragmentActivity.initiateCall(sipAddress, callingEntity.getType(), callingEntity.getDeviceMAC());
- }
- } else {
- if (null != loopingUdpentity && loopingUdpentity.equals(callingEntity)) {
- loopVoice.setPalyDismiss(true);
- }
- endCall();
- }
- } else {
- ToastUtil.showToast("请勿频繁点击!");
- }
- }
- /**
- * 选择床位和选择记录列表后右边底部呼叫按钮
- */
- @OnClick(R.id.right_in_calling_layout_iv_call)
- public void Call(View view) {
- currentTime = System.currentTimeMillis();
- if (currentTime - lastClickTime > CLICK_DELAY_TIME) {
- lastClickTime = currentTime;
- //加了个点击缓冲 20180319
- // ===============================暂时注掉20180408(Ping网:有时候 网络已经连上 但是ping不通)===========================//
- if (!filterSipToast()) {
- return;
- }
- if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
- if (null != sickBedInfo) {
- String sipAddress = sickBedInfo.getSipID();
- if (null != loopVoice) {
- loopVoice.setPalyDismiss(true);
- }
- if (StringUtils.notEmpty(sipAddress)) {
- LogUtil.d("sipAddress", "Call==sipAddress==" + sipAddress);
- LogUtil.d("sipAddress", "Call==deviceMAC==" + sickBedInfo.getDeviceMAC());
- //ToastUtil.showToast(sipAddress+"===="+sickBedInfo.getDeviceMAC());
- callBed = true;
- ivCallPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
- mainFragmentActivity.initiateCall(sipAddress, Constants.SON_CALL, sickBedInfo.getDeviceMAC() == null ? "-1" : sickBedInfo.getDeviceMAC());
- }
- }
- } else {
- endCall();
- }
- } else {
- ToastUtil.showToast("请勿频繁点击!");
- }
- }
- @OnClick(R.id.right_in_call_list_layout_iv_back)
- public void back() {
- if (!Constants.CALL_STATE.equals(Constants.STANDBY)) {
- ToastUtil.showToast("当前正在通话中,无法返回");
- return;
- }
- EventBus.getDefault().post(new MessageEvent(0, Constants.EVENT_FRAGMENT));
- }
- @OnClick(R.id.right_patient_info_layout_tv_back)
- public void backHost() {
- if (!Constants.CALL_STATE.equals(Constants.STANDBY)) {
- ToastUtil.showToast("当前正在通话中,无法返回");
- return;
- }
- EventBus.getDefault().post(new MessageEvent(0, Constants.EVENT_FRAGMENT));
- }
- private void setHospitalView() {
- if (null != hospitalInfoEntity) {
- tvPatientNum.setText(hospitalInfoEntity.getPatientNum());
- tvFreeBed.setText(hospitalInfoEntity.getFreeBeds());
- tvTodayAdmission.setText(hospitalInfoEntity.getAdmissionToday());
- tvTodayLeave.setText(hospitalInfoEntity.getDischargedToday());
- tvTomorrowLeave.setText(hospitalInfoEntity.getDischargeTomorrow());
- tvTodayOperation.setText(hospitalInfoEntity.getOperationToday());
- tvTomorrowOperation.setText(hospitalInfoEntity.getOperationTomorrow());
- tvSpecialCare.setText(hospitalInfoEntity.getSpecialCare());
- tvPrimaryCare.setText(hospitalInfoEntity.getPrimaryCare());
- importantMessageAdapter.updateList(importantMessageList);
- dutyNurseAdapter.updateList(nurseOnDutyList);
- dutyDoctorAdapter.updateList(dutyDoctorList);
- /* 刷新各个列表*/
- }
- }
- /**
- * @param view 病房适配器的view
- * @param position 点击的position
- */
- @Override
- public void sicknessRoomItemOnclick(View view, final int position) {
- this.position = position;
- if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
- vRightPatientInfo.setVisibility(View.VISIBLE);
- vRightCallInfo.setVisibility(View.GONE);
- vRightCallListInfo.setVisibility(View.GONE);
- }
- //重置床位数据
- /*if (position == 0) {
- //sickbedInformationList = null;
- //callListAdapter.updateList(((MyApplication) getActivity().getApplication()).callEntityList);
- rvCallBed.setVisibility(View.GONE);
- rvCallList.setVisibility(View.VISIBLE);
- llBgList.setBackgroundResource(R.mipmap.bg_call_list);
- //tvTitle.setText("呼叫列表");
- //显示科室选择框
- showPartSelectDialog();
- } else */{
- llBgList.setBackgroundResource(R.mipmap.bg_bed_list);
- tvTitle.setText("床位列表");
- rvCallList.setVisibility(View.GONE);
- if (null != wardInformationList) {
- sickbedInformationList = wardInformationList.get(position).getSickbedInformationList();
- if (sickbedInformationList.size() > 0) {
- for (int i = 0; i < sickbedInformationList.size(); i++) {
- try {
- if (wardInformationList.get(position).getTrusteeshipState().equals("1")) {
- sickbedInformationList.get(i).setTrusteeshipState("1");
- } else
- sickbedInformationList.get(i).setTrusteeshipState("0");
- } catch (Exception e) {
- LogUtil.d("sicknessRoomItemOnclick", "Exception");
- }
- }
- bedAdapter.listUpdate(sickbedInformationList);
- rvCallBed.setVisibility(View.VISIBLE);
- ROOM_LIST_POSITION = position;
- } else {
- rvCallBed.setVisibility(View.GONE);
- ROOM_LIST_POSITION = -1;
- }
- }
- }
- }
- /**
- * 病床点击position
- *
- * @param view 病床适配器的view
- * @param position 点击的position
- */
- @Override
- public void sicknessBedItemOnclick(View view, int position) {
- if (null == sickbedInformationList || null == sickbedInformationList.get(position) || null == sickbedInformationList.get(position).getPatientID()) {
- return;
- }
- if (!Constants.CALL_STATE.equals(Constants.STANDBY) /*&& !sickBedInfo.equals(sickbedInformationList.get(position))*/) {
- ToastUtil.showToast("请先取消当前呼叫");
- return;
- }
- if (vRightCallInfo.getVisibility() == View.VISIBLE && sickBedInfo.equals(sickbedInformationList.get(position))) {
- if (null == sickBedInfo || !StringUtils.listNotEmpty(sickbedInformationList)) return;
- if (filterSipToast()) {
- if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
- String sipAddress = sickBedInfo.getSipID();
- if (StringUtils.notEmpty(sipAddress)) {
- callBed = true;
- ivCallPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
- mainFragmentActivity.initiateCall(sipAddress, Constants.SON_CALL, sickBedInfo.getDeviceMAC() == null ? "-1" : sickBedInfo.getDeviceMAC());
- }
- } else {
- endCall();
- }
- }
- } else {
- if (!Constants.CALL_STATE.equals(Constants.STANDBY)) return;
- vRightPatientInfo.setVisibility(View.GONE);
- vRightCallListInfo.setVisibility(View.GONE);
- vRightCallInfo.setVisibility(View.VISIBLE);
- //2018 9 17 胡博文 不判断病人id ,之后电话的时候判断是否有sip id
- sickBedInfo = sickbedInformationList.get(position);
- setPatientView(sickBedInfo);
- BED_LIST_POSITION = position;
- // if (sickbedInformationList.get(position).getPatientID().equals("0")) {
- // sickBedInfo = null;
- // setPatientView(sickBedInfo);
- // BED_LIST_POSITION = -1;
- // } else { //对应床位的病人信息
- // sickBedInfo = sickbedInformationList.get(position);
- // setPatientView(sickBedInfo);
- // BED_LIST_POSITION = position;
- // }
- }
- }
- private static int selectPos;
- private void showPartSelectDialog() {
- selectPos = 0;
- if (MyApplication.partInfoList.size() <= 0) {
- ToastUtil.showToast("没有科室信息");
- return;
- }
- List<String> partItems = new ArrayList<>();
- 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;
- }
- }
- final int lastPos = selectPos;
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- final AlertDialog dialog = builder.create();
- 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) {
- Constants.SelectedPartId = MyApplication.partInfoList.get(position).getID();
- Constants.SelectedPartName = MyApplication.partInfoList.get(position).getPART_NAME();
- selectPos = position;
- }
- @Override
- public void onNothingSelected(AdapterView<?> parent) {
- }
- });
- button.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (lastPos != selectPos) {
- updatePartName();
- resetData();
- getData();
- getHospitalData();
- }
- dialog.dismiss();
- }
- });
- dialog.setView(dialogView);
- dialog.show();
- if (dialog.getWindow() != null) {
- dialog.getWindow().setBackgroundDrawableResource(R.drawable.dialog_round_bg);
- }
- }
- private void setPatientView(RoomEntity.WardInformation.SickbedInformation bedEntity) {
- if (null != bedEntity) {
- tvRoomBedAnswerState.setText(wardInformationList.get(this.position).getRoomNum() + "房" + bedEntity.getBedNum() + "床");
- tvRoomMsg.setText(wardInformationList.get(this.position).getRoomNum() + "房" + bedEntity.getBedNum() + "床");
- tvPatientInfo.setText(bedEntity.getPatientName() + " " + bedEntity.getPatientGender() + " " + bedEntity.getPatientAge());
- tvPatientInfoAdmissionTime.setText("入院时间:" + bedEntity.getAdmissionTime());
- tvAttendingDoctor.setText("责任医生:" + bedEntity.getAttendingDoctor());
- tvNurseInCharge.setText("责任护士:" + bedEntity.getNurseInCharge());
- tvGradeLevel.setText("护理等级:" + bedEntity.getGradeNurse());
- String trusteeshipState = bedEntity.getTrusteeshipState();
- if (notEmpty(trusteeshipState) && !trusteeshipState.equals("0")) {
- tvDietLevel.setText("托管状态:" + "已托管");
- } else {
- tvDietLevel.setText("托管状态:" + "未托管");
- }
- // tvDietLevel.setText("饮食等级:" + bedEntity.getDietLevel());
- tvDosageLevel.setText("计量等级:" + bedEntity.getDosageLevel() + "级");
- tvInsulateLevel.setText("隔离等级:" + bedEntity.getInsulateLevel() + "级");
- tvCondition.setText("病情状况:" + bedEntity.getCondition());
- } else {
- tvRoomBedAnswerState.setText(wardInformationList.get(this.position).getRoomNum() + "房");
- tvRoomMsg.setText(wardInformationList.get(this.position).getRoomNum() + "房");
- tvPatientInfo.setText("--");
- tvPatientInfoAdmissionTime.setText("--");
- tvAttendingDoctor.setText("--");
- tvNurseInCharge.setText("--");
- tvGradeLevel.setText("--");
- tvDietLevel.setText("--");
- tvDosageLevel.setText("--");
- tvInsulateLevel.setText("--");
- tvCondition.setText("--");
- }
- }
- UdpEntity callItemChooseEntity;
- /**
- * 呼叫列表position
- *
- * @param view 呼叫列表的view
- * @param position 点击的position
- */
- @Override
- public void callListItemOnclick(View view, int position) {
- if (!Constants.CALL_STATE.equals(Constants.STANDBY) /*&& !callItemChooseEntity.equals(MyApplication.callEntityList.get(position))*/) {
- ToastUtil.showToast("请先取消当前呼叫");
- return;
- }
- if (vRightCallListInfo.getVisibility() == View.VISIBLE && callItemChooseEntity.equals(MyApplication.callEntityList.get(position))) {
- if (null == callItemChooseEntity) return;
- if (filterSipToast() && !MyApplication.callEntityList.get(position).getType().equals(Constants.WSHROOM_CALL) && !MyApplication.callEntityList.get(position).getType().equals(Constants.ROOMHELP_CALL)) {
- if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
- String sipAddress = callItemChooseEntity.getSipAddress();
- if (StringUtils.notEmpty(sipAddress)) {
- callBed = false;
- ivCallListPic.setVisibility(View.VISIBLE);
- ivCallListPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
- LogUtil.d("sipAddress", "Call==sipAddress==" + sipAddress);
- LogUtil.d("sipAddress", "Call==deviceMAC==" + callItemChooseEntity.getDeviceMAC());
- //ToastUtil.showToast(sipAddress+"===="+callItemChooseEntity.getDeviceMAC());
- mainFragmentActivity.initiateCall(sipAddress, callItemChooseEntity.getType(), callItemChooseEntity.getDeviceMAC());
- }
- } else {
- endCall();
- }
- }
- } else {
- if (!Constants.CALL_STATE.equals(Constants.STANDBY)) return;
- if (MyApplication.callEntityList.get(position).getType().equals(Constants.WSHROOM_CALL)) {
- ToastUtil.showToast("不支持卫生间通话");
- vRightCallListInfo.setVisibility(View.GONE);
- vRightPatientInfo.setVisibility(View.VISIBLE);
- vRightCallInfo.setVisibility(View.GONE);
- //rightCallListInfomation.setVisibility(View.INVISIBLE);
- //ivCallListPic.setVisibility(View.INVISIBLE);
- //tvCallListRoomMsg.setText(MyApplication.callEntityList.get(position).getRoomNumber() + "房卫生间紧急呼叫");
- return;
- } else if (MyApplication.callEntityList.get(position).getType().equals(Constants.ROOMHELP_CALL)) {
- ToastUtil.showToast("不支持紧急增援通话");
- vRightCallListInfo.setVisibility(View.GONE);
- vRightPatientInfo.setVisibility(View.VISIBLE);
- vRightCallInfo.setVisibility(View.GONE);
- //rightCallListInfomation.setVisibility(View.VISIBLE);
- //ivCallListPic.setVisibility(View.INVISIBLE);
- //tvCallListRoomMsg.setText(MyApplication.callEntityList.get(position).getRoomNumber() + "房" + MyApplication.callEntityList.get(position).getBedNumber() + "床请求增援");
- //setCallListMsg(MyApplication.callEntityList.get(position));
- return;
- }
- chooseCallItemUI(position);
- }
- callItemChooseEntity = MyApplication.callEntityList.get(position);
- }
- @Subscribe(threadMode = ThreadMode.MAIN)
- public void onMoonEvent(MessageEvent messageEvent) {
- switch (messageEvent.getType()) {
- case Constants.EVENT_SIP:
- LogUtil.d("CALLSTATE", "Constants.CALL_STATE==" + Constants.CALL_STATE);
- if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
- LogUtil.d("onMoonEvent", "通话状态==STANDBY");
- if (null != MyApplication.serialPortUtil) { //呼叫结束了;打开外部音响
- MyApplication.serialPortUtil.stereoControl("1");
- }
- if (null != loopVoice) { //呼叫结束了;将播报音量为1;
- loopVoice.setVolumes(1.0f);
- }
- ivCallPic.setImageResource(R.mipmap.ic_calling_sickbed_right_calling);
- ivCallListPic.setImageResource(R.mipmap.ic_calling_sickbed_right_calling);
- tvBedCallState.setText("");
- tvCallListState.setText("");
- //呼叫结束了;同时将呼叫列表删除该用户(20171102 Waderson)
- if (have_Call) {
- setVolumePA(false);
- if (CALL_LIST_POSITION >= 0 && upScrllPosition != CALL_LIST_POSITION) {
- if (!callBed) {
- endCallNotifi(callingEntity);
- if (((MyApplication) getActivity().getApplication()).callEntityList.contains(callingEntity)) {
- // //由于SIP结束回调的延时而出现重叠(在连续狂打电话的情况下效果重叠不行)
- // if (null != loopingUdpentity && loopingUdpentity.equals(callingEntity)) {
- // loopVoice.setPalyDismiss(true);
- // }
- if (null != loopingUdpentity && loopingUdpentity.equals(callingEntity)) {// Waderson 20180305
- if (null != loopVoice) {
- loopVoice.setPalyDismiss(true);
- }
- } else {
- if (PalyPhonetics.speakEntityList.contains(callingEntity)) {//将播报列表也删除该元素
- PalyPhonetics.speakEntityList.remove(callingEntity);
- }
- }
- ((MyApplication) getActivity().getApplication()).callEntityList.remove(callingEntity);
- sendNoAnyRequestDoor(callingEntity);
- sendCallWaitingNumber(MyApplication.callEntityList.size());
- callListAdapter.notifyDataSetChanged();
- roomAdapter.notifyDataSetChanged();
- if (!StringUtils.listNotEmpty(((MyApplication) getActivity().getApplication()).callEntityList)) {
- setPowerLed("1");
- }
- }
- }
- }
- vRightPatientInfo.setVisibility(View.VISIBLE);
- vRightCallListInfo.setVisibility(View.GONE);
- vRightCallInfo.setVisibility(View.GONE);
- upScrllPosition = -1;
- have_Call = false;
- callBed = false;
- }
- } else {
- // ivCallPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
- // ivCallListPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
- }
- if (Constants.CALL_STATE.equals(Constants.IN_CALL)) {
- tvBedCallState.setText(" 正在呼叫中...");
- tvCallListState.setText(" 正在呼叫中...");
- } else if (Constants.CALL_STATE.equals(Constants.IN_CALLING)) {
- have_Call = true;
- setVolumePA(true);
- upScrllPosition = -1;//通话的时候废掉上滑索引;以免与通话结束后自动删除CALL条目相冲突
- tvBedCallState.setText(" 正在通话中...");
- tvCallListState.setText(" 正在通话中...");
- if (null != MyApplication.serialPortUtil) { //正在呼叫;将关闭外部音响
- MyApplication.serialPortUtil.stereoControl("0");
- }
- //正在呼叫;将播报音量为0
- if (null != loopVoice) {
- loopVoice.setVolumes(0f);
- }
- //安卓端接通电话,通知点阵屏,但要排除固定列表
- if (!callBed) {
- callingNotifi(callingEntity);
- }
- MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
- }
- }, 100);
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
- }
- }, 600);
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
- }
- }, 1100);
- }
- break;
- case Constants.EVENT_UDP:
- UdpEntity udpEntity = (UdpEntity) messageEvent.getMessage();
- String nurseHostID = udpEntity.getNurseHostID();
- String headMachineID = udpEntity.getHeadMachineID();
- //String doorwayMachineID = udpEntity.getDoorwayMachineID();
- //String roomNumber = udpEntity.getRoomNumber();
- LogUtil.d(CallingBedFragment.class, "udpEntityString==" + udpEntity.toString());
- switch (udpEntity.getIndexes()) {
- case "call_1": //子机呼叫护士主机
- case "call_2"://卫生间呼叫护士主机
- case "call_4"://增援呼叫护士主机
- case "call_6": //门口机呼叫护士主机
- if (isMySelfMachine(nurseHostID)) {//只有属于自己管的机器才能加进列表
- if (!PalyPhonetics.speakEntityList.contains(udpEntity)) {
- addPhonetics(udpEntity); //在此加入列表队列 Waderson 20171101
- }
- if (!MyApplication.callEntityList.contains(udpEntity)) {
- if (isHaveThisWSHtype(udpEntity)) return;
- MyApplication.callEntityList.add(udpEntity);
- setPowerLed("2");//有电话过来就让电源灯闪 Waderson 20171221
- sortList();//在此执行排序 Waderson 20171031
- sendCallWaitingNumber(MyApplication.callEntityList.size());
- }
- callListAdapter.notifyDataSetChanged();
- roomAdapter.notifyDataSetChanged();
- }
- break;
- case "call_1_b1": //护士已经退出护理
- if (notEmpty(nurseHostID) && nurseHostID.equals(Constants.MYSELF_ID)) {
- // //此处请注意:由于没有限定一个房间只能有一个“请求增援”;所以当护士退出护理后不做任何操作
- // //如果将播报列表删除该“请求增援”元素,那么删除哪个呢?全部删除吗?这样做显然不妥;所以经过
- // //我们的讨论此处暂时不做任何操作!Waderson
- // udpEntity.setIndexes("call_4");
- // if (((MyApplication) getActivity().getApplication()).callEntityList.contains(udpEntity)) {
- // if (null != loopingUdpentity && loopingUdpentity.equals(udpEntity)) {
- // loopVoice.setPalyDismiss(true);
- // }
- // if (null != loopingUdpentity && loopingUdpentity.equals(udpEntity)) {// Waderson 20180305
- // if (null != loopVoice) {
- // loopVoice.setPalyDismiss(true);
- // }
- // } else {
- // if (PalyPhonetics.speakEntityList.contains(udpEntity)) {//将播报列表也删除该元素
- // PalyPhonetics.speakEntityList.remove(udpEntity);
- // }
- // }
- // ((MyApplication) getActivity().getApplication()).callEntityList.remove(udpEntity);
- // sendNoAnyRequestDoor(udpEntity);
- // sendCallWaitingNumber(MyApplication.callEntityList.size());
- // endCallNotifi(udpEntity);
- // if(!StringUtils.listNotEmpty(((MyApplication) getActivity().getApplication()).callEntityList)){setPowerLed("1");}
- // }
- // callListAdapter.notifyDataSetChanged();
- // roomAdapter.notifyDataSetChanged();
- }
- break;
- case "cancel_bed_call"://门口机取消呼叫
- deleteRoomBedCall(udpEntity);
- break;
- case "call_1_hang_up": //子机取消呼叫 add by waderson 20191108
- deleteCallingItem(udpEntity , 1);
- break;
- case "call_1_transfer"://床头机转接护士主机电话
- if (notEmpty(nurseHostID) && nurseHostID.equals(Constants.MYSELF_ID)) {
- sendTransferForSon(headMachineID);
- }
- break;
- case "call_transfer_bedtobed": //子机转接子机成功后,告诉外面执行状态联动
- if (notEmpty(nurseHostID) && nurseHostID.equals(Constants.MYSELF_ID)) {
- transferBedToBed(udpEntity);
- }
- break;
- case "nursing_1": //进入护理
- if (notEmpty(nurseHostID) && nurseHostID.equals(Constants.MYSELF_ID)) {
- setIsNursing(udpEntity, true);
- }
- break;
- case "nursing_2": //退出护理
- if (notEmpty(nurseHostID) && nurseHostID.equals(Constants.MYSELF_ID)) {
- setIsNursing(udpEntity, false);
- }
- break;
- case "back_1": //接听回调
- break;
- case "end_1"://挂断电话
- break;
- }
- break;
- case Constants.EVENT_MGR_UPDATE://后台相关数据改变后通知护士主机刷新UI
- //getRoomData();//病房数据
- //getHospitalData(); //医院数据
- getSYSsetingData();//系统设置数据
- handler.sendEmptyMessageDelayed(RESET, 2000);//做个复位
- break;
- case Constants.EVENT_SETSYS://系统设置参数
- setSYSParameter(true);
- break;
- case Constants.EVENT_UPLOAD:
- if (!ftpFilePath.equals(FTP_VOICE))
- return;
- if ((Boolean) messageEvent.getMessage()) {//上传成功
- sendUdpVoiceMessage(fileOriginalName);
- ToastUtil.showToast("上传成功");
- } else {//上传失败
- ToastUtil.showToast("上传失败");
- }
- break;
- }
- }
- /**
- * UDP语音上传
- *
- * @param fileName
- */
- private void sendUdpVoiceMessage(String fileName) {
- MessageEntity messageEntity = new MessageEntity();
- messageEntity.setHosManInfo(PopupwindowVoiceNoticeUtil.mVoiceMessageDetailPopupwindow.getMessageEntity().getHosManInfo());
- messageEntity.setDeviceType(VoiceMessageAdapter.CHAT_ITEM_TYPE_RIGHT + "");
- messageEntity.setDeviceID(PopupwindowVoiceNoticeUtil.mVoiceMessageDetailPopupwindow.getMessageEntity().getDeviceID());
- messageEntity.setPatientID(PopupwindowVoiceNoticeUtil.mVoiceMessageDetailPopupwindow.getMessageEntity().getPatientID());
- messageEntity.setPatientName(PopupwindowVoiceNoticeUtil.mVoiceMessageDetailPopupwindow.getMessageEntity().getPatientName());
- messageEntity.setFileOriginalName(fileName);
- messageEntity.setFileStoreName(fileName);
- messageEntity.setMessageTime(getCurrentDate());
- messageEntity.setContent("");
- messageEntity.setID(PopupwindowVoiceNoticeUtil.mVoiceMessageDetailPopupwindow.getMessageEntity().getID());
- UdpSendUtil.sendVoiceMessage(messageEntity);
- }
- /**
- * 是否是属于自己管的机器<br></>
- */
- private boolean isMySelfMachine(String nurseHostID) {
- String n = StringUtils.substringByLengh(nurseHostID, 0, 1);
- if ("#".equals(n)) {
- String nDis = StringUtils.deleteCharAt(nurseHostID, 0);
- String my = nDis.split(",")[0];
- String his = nDis.split(",")[1];
- return Constants.MYSELF_ID.equals(my) && Constants.TRUST_OLD_MAIN_ID.equals(his);
- } else {
- return notEmpty(nurseHostID) && nurseHostID.equals(Constants.MYSELF_ID);
- }
- }
- /**
- * 是否已经有该卫生间紧急呼叫<br></>
- */
- private boolean isHaveThisWSHtype(UdpEntity udpEntity) {
- if (!Constants.WSHROOM_CALL.equals(udpEntity.getType())) return false;
- ArrayList<UdpEntity> callEntityList = ((MyApplication) getActivity().getApplication()).callEntityList;
- for (int i = 0; i < callEntityList.size(); i++) {
- if (Constants.WSHROOM_CALL.equals(callEntityList.get(i).getType()) && udpEntity.getRoomNumber().equals(callEntityList.get(i).getRoomNumber())) {
- return true;
- }
- }
- return false;
- }
- /**
- * 门口机主动删除,删除该房间的呼叫<br></>
- */
- protected void deleteRoomBedCall(UdpEntity deleteUdpEntity) {
- if (null != deleteUdpEntity) {
- String roomNumber = deleteUdpEntity.getRoomNumber();
- if (StringUtils.notEmpty(roomNumber)) {
- for (int i = 0; i < PalyPhonetics.speakEntityList.size(); i++) {
- if (roomNumber.equals(PalyPhonetics.speakEntityList.get(i).getRoomNumber())) {
- if (null != loopingUdpentity && loopingUdpentity.equals(PalyPhonetics.speakEntityList.get(i))) {
- if (null != loopVoice) {
- loopVoice.setPalyDismiss(true);
- }
- }
- PalyPhonetics.speakEntityList.remove(i);
- i--;
- }
- }
- for (int i = 0; i < MyApplication.callEntityList.size(); i++) {
- if (roomNumber.equals(MyApplication.callEntityList.get(i).getRoomNumber())) {
- if (null != urgentUdpEntity && urgentUdpEntity.equals(MyApplication.callEntityList.get(i))) {
- if (null != urgentPopupwindow) urgentPopupwindow.dismiss();
- }
- endCallNotifi(MyApplication.callEntityList.get(i));
- sendRemoveBack(MyApplication.callEntityList.get(i));
- MyApplication.callEntityList.remove(i);
- i--;
- }
- }
- InitDataEntity initdataentity = ((MainFragmentActivity) getActivity()).getInitDataEntity();
- UdpSendUtil.sendNotificationDoorLightWhite(initdataentity, deleteUdpEntity);//门灯变白
- sendCallWaitingNumber(MyApplication.callEntityList.size());
- callListAdapter.updateList(MyApplication.callEntityList);
- roomAdapter.notifyDataSetChanged();
- if (!StringUtils.listNotEmpty(MyApplication.callEntityList)) {
- setPowerLed("1");
- }
- }
- }
- }
- /**
- * 设置系统的各项参数,根据后台UDP的指令改变机器的状态<br></>
- */
- private void setSYSParameter(boolean isUDPSend) {
- //SP保存语音播报的类型 Context context, String spname, String vname, String vdata
- SharedPreferencesUtil.putStringSp(getActivity(), Constants.MSG_SP, Constants.VOICE_BROADCAST_TAG, Constants.VOICE_BROADCAST_TYPE);
- if ("2".equals(Constants.VOICE_BROADCAST_TYPE)) {// type是“2”;就关掉语音轮播
- if (null != loopVoice) {
- loopVoice.setPalyDismiss(true);
- }
- }
- if (isUDPSend) {
- if (notEmpty(Constants.RINGLVOICELOOP)) {
- speakLooping = StringUtils.parseInt(Constants.RINGLVOICELOOP);
- }
- //-----------------------------------Sip通话音量设置------------------------------//
- // VoiceManagerUtil.setCallVoice(getActivity(), StringUtils.parseInt(Constants.CALLVOICE));
- } else {
- if (notEmpty(Constants.MORNING_NIGTH) && Constants.MORNING_NIGTH.equals("0")) {
- speakLooping = StringUtils.parseInt(Constants.DAY_RING_TIMES);
- }
- if (notEmpty(Constants.MORNING_NIGTH) && Constants.MORNING_NIGTH.equals("1")) {
- speakLooping = StringUtils.parseInt(Constants.NIGHT_RING_TIMES);
- }
- if (systemInfoEntity.getDayBright().equals("0")) {
- //=========================白天sip通话音量
- // VoiceManagerUtil.setCallVoice(getActivity(), StringUtils.parseInt(systemInfoEntity.getDaySipVol()) );
- } else {
- //=========================晚上sip通话音量
- // VoiceManagerUtil.setCallVoice(getActivity(), StringUtils.parseInt(systemInfoEntity.getNightSipVol()) );
- }
- }
- }
- /**
- * 护理改变UI
- */
- private void setIsNursing(UdpEntity udpEntity, boolean isNursing) {
- String roomNumber_in = udpEntity.getRoomNumber();
- for (int i = 0; i < roomAdapter.getList().size(); i++) {
- if (roomNumber_in.equals(roomAdapter.getList().get(i).getRoomNum())) {
- roomAdapter.getList().get(i).setNursing(isNursing);
- }
- }
- roomAdapter.notifyDataSetChanged();
- }
- /**
- * 主机收到床头机转接请求,发出UDP带上SIP地址,筛选操作
- */
- private void sendTransferForSon(String headMachineID) {
- ArrayList<UdpEntity> callEntityList = ((MyApplication) getActivity().getApplication()).callEntityList;
- UdpEntity udpEntity = null;
- if (callEntityList.size() > 0) {
- for (int i = 0; i < callEntityList.size(); i++) {
- if (!callEntityList.get(i).getType().equals(Constants.WSHROOM_CALL) && !callEntityList.get(i).getType().equals(Constants.ROOMHELP_CALL)) {//筛选一个;因为卫生间,请求增援是不能呼叫的
- if (notEmpty(headMachineID) && !callEntityList.get(i).getHeadMachineID().equals(headMachineID)) {//转接的时候排除他自己
- udpEntity = callEntityList.get(i);
- break;
- }
- }
- }
- if (null != udpEntity) {//发UDP到床头机;然后将列表中的该条呼叫删除掉。。。
- InitDataEntity initdataentity = ((MainFragmentActivity) getActivity()).getInitDataEntity();
- UdpSendUtil.sendToBedDeleteCallListItem(udpEntity, initdataentity, headMachineID);
- if (((MyApplication) getActivity().getApplication()).callEntityList.contains(udpEntity)) {
- LogUtil.d("sendTransferForSon", "-----1111----" + udpEntity.toString());
- if (null != loopingUdpentity && loopingUdpentity.equals(udpEntity)) {// Waderson 20180305
- if (null != loopVoice) {
- loopVoice.setPalyDismiss(true);
- }
- } else {
- if (PalyPhonetics.speakEntityList.contains(udpEntity)) {//将播报列表也删除该元素
- LogUtil.d("sendTransferForSon", "-----2222----");
- PalyPhonetics.speakEntityList.remove(udpEntity);
- }
- }
- MyApplication.callEntityList.remove(udpEntity);
- endCallNotifi(udpEntity);
- sendNoAnyRequestDoor(udpEntity);
- sendCallWaitingNumber(MyApplication.callEntityList.size());
- callListAdapter.notifyDataSetChanged();
- roomAdapter.notifyDataSetChanged();
- if (!StringUtils.listNotEmpty(((MyApplication) getActivity().getApplication()).callEntityList)) {
- setPowerLed("1");
- }
- }
- }
- }
- }
- /**
- * 子机转接子机成功后,告诉外面执行状态联动
- */
- private void transferBedToBed(UdpEntity udpEntity) {
- ArrayList<UdpEntity> callEntityList = MyApplication.callEntityList;
- if (StringUtils.listNotEmpty(callEntityList)) {
- for (int i = 0; i < callEntityList.size(); i++) {
- if (callEntityList.get(i).getSipAddress().equals(udpEntity.getSipAddress()) && callEntityList.get(i).getNurseHostID().equals(udpEntity.getNurseHostID())) {
- if (null != loopingUdpentity && loopingUdpentity.equals(callEntityList.get(i))) {
- if (null != loopVoice) {
- loopVoice.setPalyDismiss(true);
- }
- } else {
- if (PalyPhonetics.speakEntityList.contains(callEntityList.get(i))) {//将播报列表也删除该元素
- PalyPhonetics.speakEntityList.remove(udpEntity);
- }
- }
- endCallNotifi(callEntityList.get(i));
- sendNoAnyRequestDoor(callEntityList.get(i));
- MyApplication.callEntityList.remove(callEntityList.get(i));
- }
- }
- sendCallWaitingNumber(MyApplication.callEntityList.size());
- callListAdapter.notifyDataSetChanged();
- roomAdapter.notifyDataSetChanged();
- if (!StringUtils.listNotEmpty(MyApplication.callEntityList)) {
- setPowerLed("1");
- }
- }
- }
- /**
- * 护士主机通知门口机当前房间无任何请求,请将门灯变白,筛选操作
- */
- private void sendNoAnyRequestDoor(UdpEntity deleteEntity) {
- ArrayList<UdpEntity> callEntityList = MyApplication.callEntityList;
- boolean haveThisRoomEntity = false;
- String deleteRoomNumber = deleteEntity.getRoomNumber();
- if (callEntityList.size() > 0) {
- for (int i = 0; i < callEntityList.size(); i++) {
- if (callEntityList.get(i).getRoomNumber().equals(deleteRoomNumber)) {
- haveThisRoomEntity = true;
- break;
- }
- }
- } else {
- haveThisRoomEntity = false;
- }
- if (!haveThisRoomEntity) {
- InitDataEntity initdataentity = ((MainFragmentActivity) getActivity()).getInitDataEntity();
- UdpSendUtil.sendNotificationDoorLightWhite(initdataentity, deleteEntity);
- }
- }
- /**
- * 护士主机告诉子机当前有多少条呼叫等待
- */
- private void sendCallWaitingNumber(int number) {
- InitDataEntity initdataentity = ((MainFragmentActivity) getActivity()).getInitDataEntity();
- UdpSendUtil.sendCallWaitingNumber(initdataentity, number);
- }
- /**
- * 按照优先等级进行排序(waderson 20171031)
- */
- private void sortList() {
- ArrayList<UdpEntity> callList = ((MyApplication) getActivity().getApplication()).callEntityList;
- if (null != callList && callList.size() > 1) {
- ArrayList<UdpEntity> wcList = new ArrayList<>();
- ArrayList<UdpEntity> supportList = new ArrayList<>();
- ArrayList<UdpEntity> bedList = new ArrayList<>();
- ArrayList<UdpEntity> traditionBedList = new ArrayList<>();
- ArrayList<UdpEntity> mainList = new ArrayList<>();
- ArrayList<UdpEntity> doorList = new ArrayList<>();
- for (int i = 0; i < callList.size(); i++) {
- //type :1门口机 2主机 3 子机 4卫生间 优先等级依次升高
- if (Constants.WSHROOM_CALL.equals(callList.get(i).getType())) {
- wcList.add(callList.get(i));
- } else if (Constants.ROOMHELP_CALL.equals(callList.get(i).getType())) {
- supportList.add(callList.get(i));
- } else if (Constants.SON_CALL.equals(callList.get(i).getType())) {
- bedList.add(callList.get(i));
- } else if (Constants.TRADITION_CALL.equals(callList.get(i).getType())) {
- traditionBedList.add(callList.get(i));
- } else if (Constants.MAIN_CALL.equals(callList.get(i).getType())) {
- mainList.add(callList.get(i));
- } else if (DOOR_CALL.equals(callList.get(i).getType())) {
- doorList.add(callList.get(i));
- }
- }
- if (wcList.size() > 1) {
- ListComparatorUtil.sort(wcList);
- }
- if (supportList.size() > 1) {
- ListComparatorUtil.sort(supportList);
- }
- if (bedList.size() > 1) {
- ListComparatorUtil.sort(bedList);
- }
- if (traditionBedList.size() > 1) {
- ListComparatorUtil.sort(traditionBedList);
- }
- if (mainList.size() > 1) {
- ListComparatorUtil.sort(mainList);
- }
- if (doorList.size() > 1) {
- ListComparatorUtil.sort(doorList);
- }
- callList.clear();
- callList.addAll(wcList);
- callList.addAll(supportList);
- callList.addAll(bedList);
- callList.addAll(traditionBedList);
- callList.addAll(mainList);
- callList.addAll(doorList);
- ((MyApplication) getActivity().getApplication()).callEntityList = callList;
- wcList = supportList = bedList = traditionBedList = mainList = doorList = null;
- }
- }
- /**
- * 语音轮播
- */
- PalyPhonetics loopVoice;
- /**
- * 语音轮播的当前实体
- */
- UdpEntity loopingUdpentity;
- /**
- * 播放语音(waderson 20171031)
- */
- private void palyPhonetics() {
- if (null != PalyPhonetics.speakEntityList && PalyPhonetics.speakEntityList.size() > 0) {
- String voiceBroadcastType = SharedPreferencesUtil.getStringSp(getActivity(), Constants.MSG_SP, Constants.VOICE_BROADCAST_TAG);
- if ("2".equals(voiceBroadcastType)) {
- return;
- }
- if (!Constants.volumePAStatus) {
- setVolumePA(true);
- }
- if (null == loopVoice) {
- loopVoice = PalyPhonetics.getInstance(getActivity());
- }
- if (!Constants.CALL_STATE.equals(Constants.IN_CALLING)) {
- loopVoice.setVolumes(1.0f);
- }
- loopVoice.setPalyDismiss(false);
- loopVoice.setLooping(speakLooping);
- loopingUdpentity = PalyPhonetics.speakEntityList.get(0);
- ArrayList<Integer> resIdlist = new ArrayList<>();
- resIdlist.clear();
- String type = loopingUdpentity.getType();
- String rnb = loopingUdpentity.getRoomNumber();
- String bnb = loopingUdpentity.getBedNumber();
- boolean haveVip = false;
- if (StringUtils.isHaveStr(bnb, "-")) {// add by waderson 20191212
- String b1 = bnb.substring(0, bnb.indexOf("-"));//前
- bnb = bnb.substring(bnb.indexOf("-") + 1);//后
- haveVip = true;
- }
- String roomnumber = PalyPhonetics.changeNumType(rnb, false);
- String bednumber = PalyPhonetics.changeNumType(bnb, false);
- switch (type) {
- case DOOR_CALL: //门口机
- ArrayList<String> list_str1 = StringUtils.substringBySing(roomnumber);
- if (null != list_str1) {
- for (String s : list_str1) {
- resIdlist.add(PalyPhonetics.getResIdInt(s));
- }
- resIdlist.add(R.raw.fang);
- resIdlist.add(R.raw.menkoji);
- resIdlist.add(R.raw.hujiao);
- }
- break;
- case Constants.MAIN_CALL://主机
- ArrayList<String> list_str2 = StringUtils.substringBySing(roomnumber);
- if (null != list_str2) {
- for (String s : list_str2) {
- resIdlist.add(PalyPhonetics.getResIdInt(s));
- }
- resIdlist.add(R.raw.hao);
- resIdlist.add(R.raw.zhujihujiao);
- }
- break;
- case Constants.SON_CALL://床位
- ArrayList<String> list_str3 = StringUtils.substringBySing(roomnumber);
- ArrayList<String> list_str33 = StringUtils.substringBySing(bednumber);
- if (null != list_str3 && "1".equals(voiceBroadcastType)) {//是否要播报“房” 0不要 1要
- for (String s : list_str3) {
- resIdlist.add(PalyPhonetics.getResIdInt(s));
- }
- resIdlist.add(R.raw.fang);
- }
- if (null != list_str33) {
- if (haveVip) {// add by waderson 20191212
- resIdlist.add(R.raw.vip);
- }
- for (String s : list_str33) {
- resIdlist.add(PalyPhonetics.getResIdInt(s));
- }
- resIdlist.add(R.raw.chuang);
- resIdlist.add(R.raw.hujiao);
- }
- break;
- case Constants.TRADITION_CALL://传统床位
- ArrayList<String> list_str6 = StringUtils.substringBySing(roomnumber);
- ArrayList<String> list_str66 = StringUtils.substringBySing(bednumber);
- if ("1".equals(voiceBroadcastType)) {//是否要播报“房” 0不要 1要
- if (StringUtils.listNotEmpty(list_str6)) {
- for (String s : list_str6) {
- resIdlist.add(PalyPhonetics.getResIdInt(s));
- }
- resIdlist.add(R.raw.fang);
- } else {
- if (StringUtils.listNotEmpty(wardInformationList)) {
- for (int i = 0; i < wardInformationList.size(); i++) {
- list_str6 = StringUtils.substringBySing(wardInformationList.get(0).getRoomNum());
- }
- }
- if (StringUtils.listNotEmpty(list_str6)) {
- for (String s : list_str6) {
- resIdlist.add(PalyPhonetics.getResIdInt(s));
- }
- resIdlist.add(R.raw.fang);
- }
- }
- }
- if (StringUtils.listNotEmpty(list_str66)) {
- if (haveVip) {// add by waderson 20191212
- resIdlist.add(R.raw.vip);
- }
- for (String s : list_str66) {
- resIdlist.add(PalyPhonetics.getResIdInt(s));
- }
- resIdlist.add(R.raw.chuang);
- resIdlist.add(R.raw.hujiao);
- }
- break;
- case Constants.ROOMHELP_CALL://请求增援
- ArrayList<String> list_str4 = StringUtils.substringBySing(roomnumber);
- ArrayList<String> list_str44 = StringUtils.substringBySing(bednumber);
- if (null != list_str4 && "1".equals(voiceBroadcastType)) {//是否要播报“房” 0不要 1要
- for (String s : list_str4) {
- resIdlist.add(PalyPhonetics.getResIdInt(s));
- }
- resIdlist.add(R.raw.fang);
- }
- if (null != list_str44) {
- if (haveVip) {// add by waderson 20191212
- resIdlist.add(R.raw.vip);
- }
- for (String s : list_str44) {
- resIdlist.add(PalyPhonetics.getResIdInt(s));
- }
- resIdlist.add(R.raw.chuang);
- }
- resIdlist.add(R.raw.qingqiuzhenyuan);
- break;
- case Constants.WSHROOM_CALL://卫生间
- ArrayList<String> list_str5 = StringUtils.substringBySing(roomnumber);
- if (null != list_str5) {
- for (String s : list_str5) {
- resIdlist.add(PalyPhonetics.getResIdInt(s));
- }
- resIdlist.add(R.raw.fang);
- resIdlist.add(R.raw.weishejian);
- resIdlist.add(R.raw.jinjihujiao);
- }
- break;
- }
- if (null != loopVoice) {
- try {
- loopVoice.speak(resIdlist);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- if (PalyPhonetics.speakEntityList.contains(loopingUdpentity)) {
- PalyPhonetics.speakEntityList.remove(loopingUdpentity);
- }
- if (PalyPhonetics.speakEntityList.size() <= 0) {
- setVolumePA(false);//没有语音播报就关闭PA
- }
- }
- }
- public void addPhonetics(UdpEntity udpEntity) {
- startPalyPhonetics();
- PalyPhonetics.speakEntityList.add(udpEntity);
- showUrgentWindow(udpEntity);
- }
- public void startPalyPhonetics() {
- if (null == palyPhoneticsThread) {
- have_Speak = true;
- palyPhoneticsThread = new Thread(new palyPhoneticsRunnable());
- palyPhoneticsThread.start();
- } else if (null != palyPhoneticsThread && !palyPhoneticsThread.isAlive()) {
- have_Speak = true;
- palyPhoneticsThread.start();
- }
- }
- public class palyPhoneticsRunnable implements Runnable {
- public void run() {
- while (have_Speak) {
- palyPhonetics();
- }
- }
- }
- /**
- * 紧急情况弹出的Popupwindow
- */
- UrgentPopupwindow urgentPopupwindow;
- /**
- * 紧急情况弹出的当前实体
- */
- UdpEntity urgentUdpEntity;
- /**
- * 紧急情况弹出window
- */
- public void showUrgentWindow(UdpEntity udpEntity) {
- if (null == udpEntity) {
- return;
- }
- urgentUdpEntity = udpEntity;
- if (null == urgentPopupwindow) {
- urgentPopupwindow = new UrgentPopupwindow(getActivity(), null, UrgentPopupwindow.ATCENTER, true);
- }
- switch (udpEntity.getType()) {
- case Constants.ROOMHELP_CALL:
- urgentPopupwindow.setWindowContentText(udpEntity.getRoomNumber() + "房" + udpEntity.getBedNumber() + "床请求增援!!!").setWindowLogoImg(R.mipmap.ic_support).setOnClickListener(this).show();
- break;
- case Constants.WSHROOM_CALL:
- urgentPopupwindow.setWindowContentText(udpEntity.getRoomNumber() + "房卫生间紧急呼叫!!!").setWindowLogoImg(R.mipmap.ic_wc).setOnClickListener(this).show();
- break;
- }
- }
- 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")
- Handler handler = new Handler() {
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case OUTBUTTONCLICK:
- byte[] buffer = msg.getData().getByteArray(OUTBUTTONCLICK_CONTENT);
- LogUtil.d("OUTBUTTONCLICK", "物理键data==" + buffer[0]);
- //ToastUtil.showToast("物理键data==" + buffer[0]);
- if (buffer[0] == 0) {//按下
- } else {//松开
- currentTime = System.currentTimeMillis();
- if (currentTime - lastClickTime > CLICK_DELAY_TIME) {
- lastClickTime = currentTime;
- if (!filterSipToast()) {
- return;
- }
- if (!handTelephone) {//只有当话筒没有被拿起外部按键才有用
- if (Constants.CALL_STATE.equals(Constants.STANDBY)) {//是空闲状态就拨打电话!
- autoStartCall();
- } else {
- //结束通话将当前呼叫对象语音关闭; 减少由于SIP结束回调的延时而出现重叠(之前是写在SIP结束回调的;在连续狂打电话的情况下效果重叠不行)
- if (null != loopingUdpentity && loopingUdpentity.equals(callingEntity)) {
- loopVoice.setPalyDismiss(true);
- }
- endCall(); //否则就挂断电话!
- }
- }
- } else {
- ToastUtil.showToast("请勿频繁点击!");
- }
- }
- break;
- case SPRINGCLICK:
- int data = msg.getData().getInt(SPRINGCLICK_CONTENT);
- LogUtil.d("SPRINGCLICK", "叉簧开关data==" + data);
- //ToastUtil.showToast("叉簧开关data==" + data);
- if (1 == data) {//放下状态
- Constants.HANDS_FREE = true;
- setHandsFree(true);
- setMIC(true);
- setCallVoice(0);//0为外喇叭 1为 手柄
- if (handTelephone) {
- if (null != loopingUdpentity && loopingUdpentity.equals(callingEntity)) {
- loopVoice.setPalyDismiss(true);
- }
- endCall(); //挂断电话!
- }
- // ivCallPic.setImageResource(R.mipmap.ic_calling_sickbed_right_calling);
- handTelephone = false;
- MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
- }
- if (0 == data) {//拿起状态
- Constants.HANDS_FREE = false;
- setHandsFree(false);
- setMIC(false);
- setCallVoice(1);//0为外喇叭 1为 手柄
- if (!handTelephone) { //拨打电话开始!
- autoStartCall();
- }
- handTelephone = true;
- MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
- }
- break;
- case GETROOMDATA_ERROR:
- //getRoomData();
- break;
- case GETHOSPITALDATA_ERROR:
- //getHospitalData();
- break;
- case GETSYSSETINGDATA_ERROR:
- getSYSsetingData();
- break;
- 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;
- }
- }
- };
- public void setCallVoice(int type) {//0为外喇叭 1为 手柄
- int sb = SharedPreferencesUtil.getIntSp(getActivity(), Constants.MSG_SP, SharedPreferencesUtil.SbCallingVoice);
- int sbing = SharedPreferencesUtil.getIntSp(getActivity(), Constants.MSG_SP, SharedPreferencesUtil.SbingCallingVoice);
- if (0 == type) {
- if (sb < 0) {
- VoiceManagerUtil.setCallVoice(MyApplication.getAppContext(), 90);
- } else {
- VoiceManagerUtil.setCallVoice(MyApplication.getAppContext(), sb);
- }
- }
- if (1 == type) {
- if (sbing < 0) {
- VoiceManagerUtil.setCallVoice(MyApplication.getAppContext(), 90);
- } else {
- VoiceManagerUtil.setCallVoice(MyApplication.getAppContext(), sbing);
- }
- }
- }
- /**
- * 选择呼叫列表的条目并且改变UI
- */
- private void chooseCallItemUI(int position) {
- setPowerLed("1");//用户触碰呼叫列表就让电源灯停止闪 Waderson 20171221
- callingEntity = ((MyApplication) getActivity().getApplication()).callEntityList.get(position);
- CALL_LIST_POSITION = position;
- if (((MyApplication) getActivity().getApplication()).callEntityList.get(position).getType().equals(DOOR_CALL)) {
- if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
- vRightCallListInfo.setVisibility(View.VISIBLE);
- rightCallListInfomation.setVisibility(View.INVISIBLE);
- ivCallListPic.setVisibility(View.VISIBLE);
- vRightPatientInfo.setVisibility(View.GONE);
- vRightCallInfo.setVisibility(View.GONE);
- tvCallListRoomMsg.setText(((MyApplication) getActivity().getApplication()).callEntityList.get(position).getRoomNumber() + "房" + "门口机呼叫...");
- }
- return;
- }
- if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
- vRightCallListInfo.setVisibility(View.VISIBLE);
- rightCallListInfomation.setVisibility(View.VISIBLE);
- ivCallListPic.setVisibility(View.VISIBLE);
- vRightPatientInfo.setVisibility(View.GONE);
- vRightCallInfo.setVisibility(View.GONE);
- }
- setCallListMsg(callingEntity);
- }
- /**
- * 设置呼叫列表的右侧病人个人信息
- **/
- private void setCallListMsg(UdpEntity udpEntity) {
- LogUtil.d(CallingBedFragment.class, "udpEntitytostring==" + udpEntity.toString());
- if (null != udpEntity) {
- tvCallListRoomMsg.setText(udpEntity.getRoomNumber() + "房" + udpEntity.getBedNumber() + "床");
- rightCallInfomationTwo.setText("护理等级:" + udpEntity.getLevel() + "级");
- getPatientData(udpEntity.getHeadMachineID());
- }
- }
- /**
- * 请求数据失败后的清空操作
- */
- private void onErrorClean() {
- tvCallListName.setText("--");
- rightCallInfomation.setText("--");
- rightCallInfomationOne.setText("--");
- rightCallInfomationTwo.setText("--");
- rightCallInfomationThree.setText("--");
- rightCallInfomationFour.setText("--");
- rightCallInfomationFive.setText("--");
- rightCallInfomationSix.setText("--");
- rightCallInfomationEight.setText("--");
- //rightCallInfomationSeven.setText("--");
- }
- /**
- * 自动开始呼叫的筛选操作
- */
- private void autoStartCall() {
- // ===========暂时注掉20180408(Ping网:有时候 网络已经连上 但是ping不通)===============//
- if (!filterSipToast()) {
- return;
- }
- ArrayList<UdpEntity> callEntityList = ((MyApplication) getActivity().getApplication()).callEntityList;
- if (callEntityList.size() > 0) {
- for (int i = 0; i < callEntityList.size(); i++) {
- if (!callEntityList.get(i).getType().equals(Constants.WSHROOM_CALL) && !callEntityList.get(i).getType().equals(Constants.ROOMHELP_CALL)) {
- chooseCallItemUI(i);//拨打一个电话;因为卫生间和请求增援是不能呼叫的
- ivCallPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
- ivCallListPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
- startCall(i);
- break;
- }
- }
- }
- }
- /**
- * 开始呼叫
- */
- private void startCall(int position) {
- if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
- String sipAddress = ((MyApplication) getActivity().getApplication()).callEntityList
- .get(position).getSipAddress();
- LogUtil.d("sipAddress", "startCall==sipAddress==" + sipAddress);
- mainFragmentActivity.initiateCall(sipAddress,
- ((MyApplication) getActivity().getApplication()).callEntityList.get(position)
- .getType(), callingEntity.getDeviceMAC());
- }
- }
- /**
- * 结束呼叫
- */
- public void endCall() {
- if (!Constants.CALL_STATE.equals(Constants.STANDBY)) {
- mainFragmentActivity.endCalled();
- }
- }
- /**
- * 安卓端接通电话;通知外面点阵屏;
- * 本来想将这段代码写到Calling()里面的;但固定列表不需要发送;为了保持原有代码的安全性,所以我另外写了这个方法!
- */
- public void callingNotifi(UdpEntity callEntity) {
- InitDataEntity initdataentity = ((MainFragmentActivity) getActivity()).getInitDataEntity();
- if ("call_1".equals(callEntity.getIndexes())) {//床位呼叫
- UdpSendUtil.sendCalling(initdataentity, callEntity, "call_1_calling");
- } else if ("call_2".equals(callEntity.getIndexes())) {//卫生间紧急呼叫
- UdpSendUtil.sendCalling(initdataentity, callEntity, "call_2_calling");
- } else if ("call_4".equals(callEntity.getIndexes())) {//请求增援呼叫
- UdpSendUtil.sendCalling(initdataentity, callEntity, "call_4_calling");
- } else if ("call_6".equals(callEntity.getIndexes())) {//门口机呼叫
- UdpSendUtil.sendCalling(initdataentity, callEntity, "call_6_calling");
- }
- }
- /**
- * 安卓端挂断电话;通知外面点阵屏;
- * 本来想将这段代码写到endCall()里面的;但固定列表不需要发送;为了保持原有代码的安全性,所以我另外写了这个方法!
- */
- public void endCallNotifi(UdpEntity callEntity) {
- InitDataEntity initdataentity = ((MainFragmentActivity) getActivity()).getInitDataEntity();
- if ("call_1".equals(callEntity.getIndexes()) || "call_1_hang_up".equals(callEntity.getIndexes())) {//add by waderson 20191111
- UdpSendUtil.sendRingOff(initdataentity, callEntity, "call_1_ringoff");
- } else if ("call_2".equals(callEntity.getIndexes())) {//卫生间紧急呼叫
- UdpSendUtil.sendRingOff(initdataentity, callEntity, "call_2_ringoff");
- } else if ("call_4".equals(callEntity.getIndexes())) {//请求增援呼叫
- UdpSendUtil.sendRingOff(initdataentity, callEntity, "call_4_ringoff");
- } else if ("call_6".equals(callEntity.getIndexes())) {
- UdpSendUtil.sendRingOff(initdataentity, callEntity, "call_6_ringoff");
- }
- }
- /**
- * 设置免提
- */
- private void setHandsFree(boolean isHandsFree) {
- // LogUtil.d(LogUtil.getTag(null), "是否需要免提==" + isHandsFree);
- if (isHandsFree) {
- if (null != serialPortUtil) {
- serialPortUtil.sendCommand(SerialPortUtil.AUDIO, "0", "F");
- handsFreeStatus = true;
- }
- } else {
- if (null != serialPortUtil) {
- serialPortUtil.sendCommand(SerialPortUtil.AUDIO, "1", "F");
- handsFreeStatus = false;
- }
- }
- }
- /**
- * 设置音频PA
- */
- private void setVolumePA(boolean isVolumePA) {
- if (HAVA_PA) {
- if (isVolumePA) {
- if (null != serialPortUtil) {
- serialPortUtil.sendCommand(SerialPortUtil.AUDIOPA, "1", "F");
- Constants.volumePAStatus = true;
- }
- } else {
- if (null != serialPortUtil) {
- serialPortUtil.sendCommand(SerialPortUtil.AUDIOPA, "0", "F");
- Constants.volumePAStatus = false;
- }
- }
- }
- }
- /**
- * 麦克风切换控制
- */
- private void setMIC(boolean haveMainMIC) {
- if (haveMainMIC) {
- if (null != serialPortUtil) {
- serialPortUtil.sendCommand(SerialPortUtil.MIC, "0", "F");
- isMainMIC = true;
- }
- } else {
- if (null != serialPortUtil) {
- serialPortUtil.sendCommand(SerialPortUtil.MIC, "1", "F");
- isMainMIC = false;
- }
- }
- }
- /**
- * 电源指示灯切换控制<br></>
- * 0:灯灭 1:常亮 2:闪动
- */
- private void setPowerLed(String powerLedType) {
- if ("0".equals(powerLedType) || "1".equals(powerLedType) || "2".equals(powerLedType)) {
- if (null != serialPortUtil) {
- serialPortUtil.sendCommand(SerialPortUtil.POWERLED, powerLedType, "F");
- }
- }
- }
- /**
- * 上滑移除后发UDP通知外面
- */
- private void sendRemoveBack(UdpEntity udpEntity) {
- if (null != udpEntity) {
- InitDataEntity initdataentity = ((MainFragmentActivity) getActivity()).getInitDataEntity();
- UdpSendUtil.sendNotificationRemove(udpEntity, initdataentity);
- }
- }
- public static final long CLICK_DELAY_TIME = 500;
- private long lastClickTime = 0;
- private long currentTime;
- @Override
- public void queuingItemOnclick(View view, int position) {//呼叫记录列表的点击
- //showToast("点击了=="+position);
- }
- public final String OUTBUTTONCLICK_CONTENT = "outbuttonclickcontent";
- public final String SPRINGCLICK_CONTENT = "springclickcontent";
- public final int OUTBUTTONCLICK = 201;
- public final int SPRINGCLICK = 202;
- boolean handTelephone = false;//是否拿起了电话
- boolean handsFreeStatus = true;//是否是免提
- boolean isMainMIC = true;//是否是外部MIC
- @Override
- public void serialPortBedOnclick(byte[] buffer) {
- //按键串口的回调 (Waderson)
- if (Constants.currentFragment != 0) {
- return;
- }
- /*Message msg = handler.obtainMessage();
- Bundle data = new Bundle();
- data.putByteArray(OUTBUTTONCLICK_CONTENT, buffer);
- msg.setData(data);
- msg.what = OUTBUTTONCLICK;
- handler.sendMessage(msg);*/
- }
- @Override
- public void forkSpringData(int data) {
- //叉簧开关 的状态(Waderson)
- /*Message msg = handler.obtainMessage();
- Bundle data_p = new Bundle();
- data_p.putInt(SPRINGCLICK_CONTENT, data);
- msg.setData(data_p);
- msg.what = SPRINGCLICK;
- handler.sendMessage(msg);*/
- }
- @Override
- public void onRefresh() {
- getHospitalData();
- getRoomInfo();
- //getRoomData();
- }
- @Override
- protected int getContentLayout() {
- return 0;
- }
- @Override
- public void showInitError() {
- }
- @Override
- public void onDestroy() {
- super.onDestroy();
- ButterKnife.unbind(this);
- }
- @OnClick(R.id.textView2)
- public void a(View view) {
- UdpSendUtil.sendNurseStationState(((MainFragmentActivity) getActivity()).getInitDataEntity(), 0);
- }
- @OnClick(R.id.textView8)
- public void b(View view) {
- UdpSendUtil.sendNurseStationState(((MainFragmentActivity) getActivity()).getInitDataEntity(), 1);
- }
- }
|