CallingBedFragment.java 108 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463
  1. package com.wdkl.callingmainnurse.ui.fragment;
  2. import android.annotation.SuppressLint;
  3. import android.content.DialogInterface;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.os.Handler;
  7. import android.os.Message;
  8. import android.support.v4.widget.SwipeRefreshLayout;
  9. import android.support.v7.app.AlertDialog;
  10. import android.support.v7.widget.GridLayoutManager;
  11. import android.support.v7.widget.LinearLayoutManager;
  12. import android.support.v7.widget.RecyclerView;
  13. import android.support.v7.widget.helper.ItemTouchHelper;
  14. import android.util.Log;
  15. import android.view.LayoutInflater;
  16. import android.view.MotionEvent;
  17. import android.view.View;
  18. import android.view.ViewGroup;
  19. import android.widget.AdapterView;
  20. import android.widget.ArrayAdapter;
  21. import android.widget.Button;
  22. import android.widget.ImageView;
  23. import android.widget.LinearLayout;
  24. import android.widget.ScrollView;
  25. import android.widget.Spinner;
  26. import android.widget.TextView;
  27. import com.google.gson.Gson;
  28. import com.wdkl.callingmainnurse.MyApplication;
  29. import com.wdkl.callingmainnurse.R;
  30. import com.wdkl.callingmainnurse.adapter.CallListAdapter;
  31. import com.wdkl.callingmainnurse.adapter.CallingQueuingInfoAdapter;
  32. import com.wdkl.callingmainnurse.adapter.DutyDoctorAdapter;
  33. import com.wdkl.callingmainnurse.adapter.DutyNurseAdapter;
  34. import com.wdkl.callingmainnurse.adapter.ImportantMessageAdapter;
  35. import com.wdkl.callingmainnurse.adapter.SicknessBedAdapter;
  36. import com.wdkl.callingmainnurse.adapter.SicknessRoomAdapter;
  37. import com.wdkl.callingmainnurse.adapter.VoiceMessageAdapter;
  38. import com.wdkl.callingmainnurse.base.BaseFragment;
  39. import com.wdkl.callingmainnurse.common.Constants;
  40. import com.wdkl.callingmainnurse.entity.CallingQueuingInfoEntity;
  41. import com.wdkl.callingmainnurse.entity.HospitalInfoEntity;
  42. import com.wdkl.callingmainnurse.entity.InitDataEntity;
  43. import com.wdkl.callingmainnurse.entity.MessageEntity;
  44. import com.wdkl.callingmainnurse.entity.MessageEvent;
  45. import com.wdkl.callingmainnurse.entity.RoomEntity;
  46. import com.wdkl.callingmainnurse.entity.SystemInfoEntity;
  47. import com.wdkl.callingmainnurse.entity.UdpEntity;
  48. import com.wdkl.callingmainnurse.ui.activity.MainFragmentActivity;
  49. import com.wdkl.callingmainnurse.ui.activity.SysCallingVolSetActivity;
  50. import com.wdkl.callingmainnurse.util.ListComparatorUtil;
  51. import com.wdkl.callingmainnurse.util.LogUtil;
  52. import com.wdkl.callingmainnurse.util.PalyPhonetics;
  53. import com.wdkl.callingmainnurse.util.SharedPreferencesUtil;
  54. import com.wdkl.callingmainnurse.util.SipUtil.SipHelperUtil;
  55. import com.wdkl.callingmainnurse.util.StringUtils;
  56. import com.wdkl.callingmainnurse.util.ToastUtil;
  57. import com.wdkl.callingmainnurse.util.UIUtils;
  58. import com.wdkl.callingmainnurse.util.UdpSendUtil;
  59. import com.wdkl.callingmainnurse.util.VoiceManagerUtil;
  60. import com.wdkl.callingmainnurse.util.VoiceMessageRoomWardInformationUtil;
  61. import com.wdkl.callingmainnurse.widget.dialog.UrgentPopupwindow;
  62. import com.wdkl.callingmainnurse.widget.view.GridSpacingItemDecoration;
  63. import com.zhy.http.okhttp.OkHttpUtils;
  64. import com.zhy.http.okhttp.callback.StringCallback;
  65. import org.greenrobot.eventbus.EventBus;
  66. import org.greenrobot.eventbus.Subscribe;
  67. import org.greenrobot.eventbus.ThreadMode;
  68. import org.json.JSONException;
  69. import org.json.JSONObject;
  70. import java.util.ArrayList;
  71. import java.util.List;
  72. import butterknife.Bind;
  73. import butterknife.ButterKnife;
  74. import butterknife.OnClick;
  75. import okhttp3.Call;
  76. import serialporttest.utils.SerialPortUtil;
  77. import static com.wdkl.callingmainnurse.common.Constants.DOOR_CALL;
  78. import static com.wdkl.callingmainnurse.common.Constants.FTP_VOICE;
  79. import static com.wdkl.callingmainnurse.util.FtpUtil.ftpFilePath;
  80. import static com.wdkl.callingmainnurse.util.PopupwindowVoiceNoticeUtil.mVoiceMessageDetailPopupwindow;
  81. import static com.wdkl.callingmainnurse.util.StringUtils.notEmpty;
  82. import static com.wdkl.callingmainnurse.util.ToastUtil.showToast;
  83. import static com.wdkl.callingmainnurse.widget.VoiceMessageRecordPopupwindow.fileOriginalName;
  84. import static com.wdkl.callingmainnurse.widget.VoiceMessageRecordPopupwindow.getCurrentDate;
  85. /**
  86. * Created by xuhuan on 2017/8/23 <br></>
  87. * Changed by Waderson on 2017/11/01
  88. */
  89. public class CallingBedFragment extends BaseFragment implements SicknessBedAdapter.CallingSicknessBedItemOnclickListener,
  90. SicknessRoomAdapter.CallingSicknessRoomItemOnclickListener, CallListAdapter.CallingListItemOnclickListener,
  91. SerialPortUtil.ISerialPortOnclickEvent, SerialPortUtil.IForkSpringSwiData, CallingQueuingInfoAdapter.CallingQueuingItemOnclickListener
  92. , SwipeRefreshLayout.OnRefreshListener, View.OnClickListener {
  93. private View mView;
  94. /**
  95. * 右侧病人数据View
  96. */
  97. @Bind(R.id.fragment_ll_show_right_patient_info)
  98. View vRightPatientInfo;
  99. /**
  100. * 右侧通话状态View
  101. */
  102. @Bind(R.id.fragment_ll_show_right_call_info)
  103. View vRightCallInfo;
  104. /**
  105. * 右侧通话呼叫的病人信息列表总View
  106. */
  107. @Bind(R.id.fragment_ll_show_right_call_list_info)
  108. View vRightCallListInfo;
  109. /**
  110. * 右侧通话呼叫的病人信息列表View
  111. */
  112. @Bind(R.id.right_call_list_infomation)
  113. ScrollView rightCallListInfomation;
  114. /**
  115. * 右侧通话呼叫的病人信息列表下面按键
  116. */
  117. @Bind(R.id.right_in_call_list_layout_iv_call)
  118. ImageView ivCallListPic;
  119. /**
  120. * 科室的所有病房列表
  121. */
  122. @Bind(R.id.fragment_rv_callsickbed_room)
  123. RecyclerView rvCallRoom;
  124. /**
  125. * 某个病房下面的病床列表
  126. */
  127. @Bind(R.id.fragment_rv_calling_sick_bed)
  128. RecyclerView rvCallBed;
  129. /**
  130. * 动态呼叫列表
  131. */
  132. @Bind(R.id.fragment_rv_calling_call_list)
  133. RecyclerView rvCallList;
  134. /**
  135. * 科室的值班医生列表
  136. */
  137. @Bind(R.id.fragment_rv_duty_doctor)
  138. RecyclerView rvDutyDoctor;
  139. /**
  140. * 科室的值班护士列表
  141. */
  142. @Bind(R.id.fragment_rv_nurse_on_duty)
  143. RecyclerView rvNurseOnDuty;
  144. /**
  145. * 科室的要事留言列表
  146. */
  147. @Bind(R.id.fragment_rv_important_message)
  148. RecyclerView rvImportantMessage;
  149. /**
  150. * 科室的呼叫记录信息栏列表
  151. */
  152. @Bind(R.id.fragment_rv_calling_queuing_info_bar)
  153. RecyclerView rvCallingQueuingBar;
  154. @Bind(R.id.fragment_ll_sickbed_bg)
  155. LinearLayout llBgList;
  156. @Bind(R.id.fragment_call_sickbed_room_tv_list_title)
  157. TextView tvTitle;
  158. @Bind(R.id.tv_part_title)
  159. TextView tvPartTitle;
  160. /**
  161. * 病房适配器
  162. */
  163. private SicknessRoomAdapter roomAdapter;
  164. /**
  165. * 病床适配器
  166. */
  167. private SicknessBedAdapter bedAdapter;
  168. /**
  169. * 呼叫列表适配器
  170. */
  171. private CallListAdapter callListAdapter;
  172. /**
  173. * 消息适配器
  174. */
  175. private ImportantMessageAdapter importantMessageAdapter;
  176. /**
  177. * 责任医生的适配器
  178. */
  179. private DutyDoctorAdapter dutyDoctorAdapter;
  180. /**
  181. * 责任护士的适配器
  182. */
  183. private DutyNurseAdapter dutyNurseAdapter;
  184. /**
  185. * 呼叫记录信息的适配器
  186. */
  187. private CallingQueuingInfoAdapter callingQueuingInfoAdapter;
  188. /**
  189. * 呼叫排队信息栏实体
  190. */
  191. private CallingQueuingInfoEntity callingQueuingInfoEntity;
  192. /**
  193. * 呼叫排队信息栏的数据源
  194. */
  195. private ArrayList<CallingQueuingInfoEntity> callingQueuingInfoList;
  196. private MainFragmentActivity mainFragmentActivity;
  197. @Bind(R.id.textView3)
  198. TextView leaveWord;
  199. //刷新控件
  200. @Bind(R.id.fragment_calling_bed_layout_sr_refresh)
  201. SwipeRefreshLayout swipeRefreshLayout;
  202. @Bind(R.id.fragment_rv_calling_nodatainfomation)
  203. TextView noCalledDataText;
  204. @Bind(R.id.fragment_tv_room_bed_answer_call_state)
  205. TextView tvBedCallState;
  206. @Bind(R.id.fragment_tv_room_bed_answer_state)
  207. TextView tvRoomBedAnswerState;
  208. //房间号 床号
  209. @Bind(R.id.right_in_calling_layout_room_msg)
  210. TextView tvRoomMsg;
  211. //病人姓名 性别 年龄 入院时间
  212. @Bind(R.id.fragment_tv_patient_info)
  213. TextView tvPatientInfo;
  214. //入院时间
  215. @Bind(R.id.fragment_tv_patient_admission_time)
  216. TextView tvPatientInfoAdmissionTime;
  217. //责任医生
  218. @Bind(R.id.fragment_tv_attending_doctor)
  219. TextView tvAttendingDoctor;
  220. //责任护士
  221. @Bind(R.id.fragment_tv_nurse_in_charge)
  222. TextView tvNurseInCharge;
  223. //病情诊断
  224. @Bind(R.id.fragment_tv_condition)
  225. TextView tvCondition;
  226. //护理内容
  227. @Bind(R.id.fragment_tv_grade_level)
  228. TextView tvGradeLevel;
  229. //饮食内容
  230. @Bind(R.id.fragment_tv_diet_level)
  231. TextView tvDietLevel;
  232. //计量内容
  233. @Bind(R.id.fragment_tv_dosage_level)
  234. TextView tvDosageLevel;
  235. //隔离内容 InsulateLevel
  236. @Bind(R.id.fragment_tv_insulate_level)
  237. TextView tvInsulateLevel;
  238. //拨号图片
  239. @Bind(R.id.right_in_calling_layout_iv_call)
  240. ImageView ivCallPic;
  241. //拨号图片
  242. @Bind(R.id.fragment_calling_right_layout_ll_call)
  243. LinearLayout llCallPic;
  244. @Bind(R.id.fragment_calling_right_layout_ll_calls)
  245. LinearLayout llCallPics;
  246. //拨号状态
  247. @Bind(R.id.right_in_calling_layout_tv_state)
  248. TextView tvCallState;
  249. /**
  250. * 医院数据
  251. **/
  252. //病人人数
  253. @Bind(R.id.fragment_sick_bed_layout_tv_patient_num)
  254. TextView tvPatientNum;
  255. //空闲床位
  256. @Bind(R.id.fragment_sick_bed_layout_tv_free_bed)
  257. TextView tvFreeBed;
  258. //今日入院
  259. @Bind(R.id.fragment_sick_bed_layout_tv_today_admission)
  260. TextView tvTodayAdmission;
  261. //进入出院
  262. @Bind(R.id.fragment_sick_bed_layout_tv_today_leave)
  263. TextView tvTodayLeave;
  264. //明日出院
  265. @Bind(R.id.fragment_sick_bed_layout_tv_tomorrow_leave)
  266. TextView tvTomorrowLeave;
  267. //今日手术
  268. @Bind(R.id.fragment_sick_bed_layout_tv_today_operation)
  269. TextView tvTodayOperation;
  270. //明日手术
  271. @Bind(R.id.fragment_sick_bed_layout_tv_tomorrow_operation)
  272. TextView tvTomorrowOperation;
  273. //特级护理
  274. @Bind(R.id.fragment_sick_bed_layout_tv_special_care)
  275. TextView tvSpecialCare;
  276. //一级护理
  277. @Bind(R.id.fragment_sick_bed_layout_tv_primary_care)
  278. TextView tvPrimaryCare;
  279. /**
  280. * 呼叫列表
  281. */
  282. //呼叫列表呼叫状态
  283. @Bind(R.id.right_call_list_layout_tv_state)
  284. TextView tvCallListState;
  285. //呼叫列表数据
  286. @Bind(R.id.right_call_list_layout_tv_room_msg)
  287. TextView tvCallListRoomMsg;
  288. //、、、、、、、、病人的个人信息、、、、、、、、、、
  289. @Bind(R.id.right_call_list_layout_tv_patient_name)
  290. TextView tvCallListName;
  291. @Bind(R.id.right_call_infomation)
  292. TextView rightCallInfomation;
  293. @Bind(R.id.right_call_infomationone)
  294. TextView rightCallInfomationOne;
  295. @Bind(R.id.right_call_infomationtwo)
  296. TextView rightCallInfomationTwo;
  297. @Bind(R.id.right_call_infomationthree)
  298. TextView rightCallInfomationThree;
  299. @Bind(R.id.right_call_infomationfour)
  300. TextView rightCallInfomationFour;
  301. @Bind(R.id.right_call_infomationfive)
  302. TextView rightCallInfomationFive;
  303. @Bind(R.id.right_call_infomationsix)
  304. TextView rightCallInfomationSix;
  305. @Bind(R.id.right_call_infomationseven)
  306. TextView rightCallInfomationSeven;
  307. @Bind(R.id.right_call_infomationeight)
  308. TextView rightCallInfomationEight;
  309. //、、、、、、、、病人的个人信息、、、、、、、、、、
  310. /**
  311. * 病房列表和病床列表
  312. */
  313. private ArrayList<RoomEntity.WardInformation> wardInformationList;
  314. /**
  315. * 单个病房的病床列表
  316. */
  317. private ArrayList<RoomEntity.WardInformation.SickbedInformation> sickbedInformationList;
  318. /**
  319. * 整个科室的数据
  320. */
  321. private RoomEntity roomEntity;
  322. /**
  323. * 整个医院的数据
  324. */
  325. private HospitalInfoEntity hospitalInfoEntity;
  326. /**
  327. * 所有值班医生的列表
  328. */
  329. private ArrayList<String> dutyDoctorList;
  330. /**
  331. * 所有值班护士的列表
  332. */
  333. private ArrayList<String> nurseOnDutyList;
  334. /**
  335. * 所有留言的列表
  336. */
  337. private ArrayList<String> importantMessageList;
  338. /**
  339. * 保存房号的position
  340. */
  341. private int position = -1;
  342. /**
  343. * 当前点击房间的条目索引
  344. */
  345. private static int ROOM_LIST_POSITION = -1;
  346. /**
  347. * 床位条目索引
  348. */
  349. private static int BED_LIST_POSITION = -1;
  350. /**
  351. * 用户拨打电话的条目索引
  352. */
  353. private static int CALL_LIST_POSITION = -1;
  354. /**
  355. * 用户拨打电话的当前实例
  356. */
  357. protected UdpEntity callingEntity;
  358. /**
  359. * 用户选择的当前床位实例
  360. */
  361. protected RoomEntity.WardInformation.SickbedInformation sickBedInfo;
  362. /**
  363. * 是否需要轮流播报
  364. */
  365. public static boolean have_Speak = true;
  366. /**
  367. * 是否拨打了电话
  368. */
  369. public boolean have_Call = false;
  370. /**
  371. * 是否拨打床位电话
  372. */
  373. public boolean callBed = false;
  374. /**
  375. * 串口工具类
  376. */
  377. SerialPortUtil serialPortUtil;
  378. /**
  379. * 用户向上滑动的item的Position
  380. */
  381. int upScrllPosition = -1;
  382. /**
  383. * 语音播报循环次数
  384. */
  385. public int speakLooping = 2;
  386. /**
  387. * 系统设置
  388. */
  389. public SystemInfoEntity systemInfoEntity;
  390. /**
  391. * 是否需要音频PA
  392. */
  393. public static boolean HAVA_PA = false;
  394. /**
  395. * 语音轮播线程
  396. */
  397. Thread palyPhoneticsThread;
  398. public static CallingBedFragment mCallingBedFragment;
  399. public static CallingBedFragment getInstance() {
  400. return mCallingBedFragment == null ? new CallingBedFragment() : mCallingBedFragment;
  401. }
  402. @Override
  403. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  404. mView = inflater.inflate(R.layout.fragment_calling_sick_bed, null);
  405. ButterKnife.bind(this, mView);
  406. mCallingBedFragment = this;
  407. if (null != MyApplication.serialPortUtil) { //初始化;打开外部音响
  408. MyApplication.serialPortUtil.stereoControl("1");
  409. }
  410. return mView;
  411. }
  412. @Override
  413. protected void initView(View RootView) {
  414. //默认的通话状态
  415. Constants.CALL_STATE = Constants.STANDBY;
  416. vRightPatientInfo.setVisibility(View.VISIBLE);
  417. vRightCallInfo.setVisibility(View.GONE);
  418. vRightCallListInfo.setVisibility(View.GONE);
  419. tvPartTitle.setText("当前科室: " + Constants.PartName);
  420. //默认设置
  421. rvCallBed.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
  422. @Override
  423. public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
  424. UIUtils.rvSideslipShowPopu(getActivity(), motionEvent);
  425. return false;
  426. }
  427. @Override
  428. public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
  429. }
  430. @Override
  431. public void onRequestDisallowInterceptTouchEvent(boolean b) {
  432. }
  433. });
  434. rvCallRoom.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
  435. @Override
  436. public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
  437. UIUtils.rvSideslipShowPopu(getActivity(), motionEvent);
  438. return false;
  439. }
  440. @Override
  441. public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
  442. }
  443. @Override
  444. public void onRequestDisallowInterceptTouchEvent(boolean b) {
  445. }
  446. });
  447. rvCallList.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
  448. @Override
  449. public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
  450. UIUtils.rvSideslipShowPopu(getActivity(), motionEvent);
  451. return false;
  452. }
  453. @Override
  454. public void onTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
  455. }
  456. @Override
  457. public void onRequestDisallowInterceptTouchEvent(boolean b) {
  458. }
  459. });
  460. leaveWord.setOnLongClickListener(new View.OnLongClickListener() {
  461. @Override
  462. public boolean onLongClick(View view) {
  463. ToastUtil.showToast("CALL_STATE=" + Constants.CALL_STATE);
  464. return false;
  465. }
  466. });
  467. }
  468. @Override
  469. protected void initUtil() {
  470. serialPortUtil = ((MyApplication) getActivity().getApplication()).serialPortUtil;
  471. serialPortUtil.setOnDataReceiveListener(this, this);
  472. setVolumePA(false);
  473. setPowerLed("1");
  474. startPalyPhonetics();
  475. }
  476. @Override
  477. protected void initData() {
  478. try {
  479. getSYSsetingData();
  480. } catch (IllegalArgumentException e) {
  481. e.printStackTrace();
  482. }
  483. mainFragmentActivity = (MainFragmentActivity) getActivity();
  484. roomEntity = new RoomEntity();
  485. wardInformationList = new ArrayList<>();
  486. sickbedInformationList = new ArrayList<>();
  487. hospitalInfoEntity = new HospitalInfoEntity();
  488. dutyDoctorList = new ArrayList<>();
  489. nurseOnDutyList = new ArrayList<>();
  490. importantMessageList = new ArrayList<>();
  491. initRecyclerManager();
  492. //初始化病房数据
  493. getRoomData();
  494. //获得医院信息
  495. getHospitalData();
  496. //初始化排队信息栏数据
  497. //initCallingQueuingInfo();
  498. MainFragmentActivity.initCallVoiceShowProgress();//add by waderson 20190801 SIP通话音量不能保存?要动态设置??曹强的东西真搞不懂他
  499. }
  500. private void initRecyclerManager() {
  501. //Room
  502. swipeRefreshLayout.setOnRefreshListener(this);
  503. roomAdapter = new SicknessRoomAdapter(getActivity(), wardInformationList);
  504. GridLayoutManager gridLayoutRoomManager = new GridLayoutManager(getActivity(), 8);
  505. rvCallRoom.setLayoutManager(gridLayoutRoomManager);
  506. rvCallRoom.addItemDecoration(new GridSpacingItemDecoration(8, 10, true));
  507. roomAdapter.setSicknessRoomItemOnClickListener(CallingBedFragment.this);
  508. rvCallRoom.setAdapter(roomAdapter);
  509. //Bed
  510. LinearLayoutManager linearLayoutBedManager = new LinearLayoutManager(getActivity());
  511. linearLayoutBedManager.setOrientation(LinearLayoutManager.HORIZONTAL);
  512. rvCallBed.setLayoutManager(linearLayoutBedManager);
  513. bedAdapter = new SicknessBedAdapter(getActivity(), sickbedInformationList);
  514. rvCallBed.setAdapter(bedAdapter);
  515. bedAdapter.setSicknessBedItemOnClickLinstener(this);
  516. //call list
  517. LinearLayoutManager linearLayoutCallListManager = new LinearLayoutManager(getActivity());
  518. linearLayoutCallListManager.setOrientation(LinearLayoutManager.HORIZONTAL);
  519. rvCallList.setLayoutManager(linearLayoutCallListManager);
  520. callListAdapter = new CallListAdapter(getActivity(), ((MyApplication) getActivity().getApplication()).callEntityList);
  521. rvCallList.setAdapter(callListAdapter);
  522. callListAdapter.setCallingListItemOnClickListener(this);
  523. ItemTouchHelper.Callback mCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.UP) {
  524. @Override
  525. public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
  526. return false;
  527. }
  528. @Override
  529. public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { //上滑删除item
  530. upScrllPosition = viewHolder.getAdapterPosition();
  531. UdpEntity upScrllUdpEntity = MyApplication.callEntityList.get(upScrllPosition);
  532. deleteCallingItem(upScrllUdpEntity , 0);
  533. }
  534. };
  535. //用Callback构造ItemtouchHelper
  536. ItemTouchHelper touchHelper = new ItemTouchHelper(mCallback);
  537. //调用ItemTouchHelper的attachToRecyclerView方法建立联系
  538. touchHelper.attachToRecyclerView(rvCallList);
  539. //Doctor
  540. LinearLayoutManager dutyDoctorLayoutBedManager = new LinearLayoutManager(getActivity());
  541. dutyDoctorLayoutBedManager.setOrientation(LinearLayoutManager.HORIZONTAL);
  542. rvDutyDoctor.setLayoutManager(dutyDoctorLayoutBedManager);
  543. dutyDoctorAdapter = new DutyDoctorAdapter(getActivity(), dutyDoctorList);
  544. rvDutyDoctor.setAdapter(dutyDoctorAdapter);
  545. //Nurse
  546. LinearLayoutManager dutyNurseDoctorLayoutBedManager = new LinearLayoutManager(getActivity());
  547. dutyNurseDoctorLayoutBedManager.setOrientation(LinearLayoutManager.HORIZONTAL);
  548. rvNurseOnDuty.setLayoutManager(dutyNurseDoctorLayoutBedManager);
  549. dutyNurseAdapter = new DutyNurseAdapter(getActivity(), nurseOnDutyList);
  550. rvNurseOnDuty.setAdapter(dutyNurseAdapter);
  551. //msg
  552. LinearLayoutManager MsgLayoutBedManager = new LinearLayoutManager(getActivity());
  553. MsgLayoutBedManager.setOrientation(LinearLayoutManager.VERTICAL);
  554. rvImportantMessage.setLayoutManager(MsgLayoutBedManager);
  555. importantMessageAdapter = new ImportantMessageAdapter(getActivity(), importantMessageList);
  556. rvImportantMessage.setAdapter(importantMessageAdapter);
  557. }
  558. /**
  559. * 删除指定的条目(change by waderson 20191108)
  560. * @param deleteEntity 被删除的实体
  561. * @param type 0 手指上滑 ; 1 子机取消呼叫UDP
  562. */
  563. protected void deleteCallingItem(UdpEntity deleteEntity , int type) {
  564. if (callingEntity != null) {
  565. if (deleteEntity.equals(callingEntity)) {
  566. vRightPatientInfo.setVisibility(View.VISIBLE);
  567. vRightCallInfo.setVisibility(View.GONE);
  568. vRightCallListInfo.setVisibility(View.GONE);
  569. }
  570. }
  571. //删除后通知外面做出改变
  572. sendRemoveBack(deleteEntity);
  573. if (null != callingEntity) {
  574. if (callingEntity.equals(deleteEntity)) {//判断是否为当前通话;如果是就挂断电话,改变UI
  575. endCall();
  576. }
  577. }
  578. //viewHolder.getAdapterPosition() 和 iewHolder.getLayoutPosition()有16ms 的差距 之后adpter默认-1
  579. if (null != loopingUdpentity && loopingUdpentity.equals(deleteEntity)) {
  580. if (null != loopVoice) {
  581. loopVoice.setPalyDismiss(true);
  582. }
  583. } else {
  584. for (int i=0; i<PalyPhonetics.speakEntityList.size(); i++) {//将播报列表也删除该元素 两种实体格式不一样,所以要用循环
  585. if(PalyPhonetics.speakEntityList.get(i).equals(deleteEntity)) {
  586. PalyPhonetics.speakEntityList.remove(i);
  587. }
  588. }
  589. }
  590. endCallNotifi(deleteEntity);
  591. for (int i=0; i< MyApplication.callEntityList.size(); i++) {//将列表也删除该元素 两种实体格式不一样,所以要用循环
  592. if(MyApplication.callEntityList.get(i).equals(deleteEntity)) {
  593. MyApplication.callEntityList.remove(i);
  594. }
  595. }
  596. sendNoAnyRequestDoor(deleteEntity);
  597. sendCallWaitingNumber(MyApplication.callEntityList.size());
  598. callListAdapter.updateList(MyApplication.callEntityList);
  599. roomAdapter.notifyDataSetChanged();
  600. if (!StringUtils.listNotEmpty(MyApplication.callEntityList)) {
  601. setPowerLed("1");
  602. }
  603. }
  604. private void getRoomTestData() {
  605. if (swipeRefreshLayout.isRefreshing()) {
  606. swipeRefreshLayout.setRefreshing(false);
  607. }
  608. RoomEntity entity = new RoomEntity();
  609. ArrayList<RoomEntity.WardInformation> wardInformations = new ArrayList<>();
  610. for (int i = 0; i < 50; i++) {
  611. ArrayList<RoomEntity.WardInformation.SickbedInformation> sickbedInformations = new ArrayList<>();
  612. RoomEntity.WardInformation wardInfo = new RoomEntity.WardInformation();
  613. wardInfo.setRoomNum("" + i);
  614. for (int j = 0; j < 5; j++) {
  615. RoomEntity.WardInformation.SickbedInformation sickBedInfo = new RoomEntity.WardInformation.SickbedInformation();
  616. int bedNum = i*5 + j;
  617. sickBedInfo.setBedNum("" + bedNum);
  618. sickBedInfo.setPatientName("" + bedNum);
  619. sickbedInformations.add(sickBedInfo);
  620. }
  621. wardInfo.setSickbedInformationList(sickbedInformations);
  622. wardInformations.add(wardInfo);
  623. }
  624. entity.setWardInformationList(wardInformations);
  625. wardInformationList = entity.getWardInformationList();
  626. roomAdapter.updateList(wardInformationList);
  627. if (null != wardInformationList && CallingBedFragment.this.position != -1) {
  628. try {
  629. sickbedInformationList = wardInformationList.get(CallingBedFragment.this.position).getSickbedInformationList();
  630. } catch (Exception e) {
  631. LogUtil.d("getRoomData", "position越界");
  632. }
  633. }
  634. if (CallingBedFragment.this.position != -1 && null != sickbedInformationList) {
  635. if (sickbedInformationList.size() > 0) {
  636. for (int i = 0; i < sickbedInformationList.size(); i++) {
  637. if ("1".equals(wardInformationList.get(CallingBedFragment.this.position).getTrusteeshipState())) {
  638. sickbedInformationList.get(i).setTrusteeshipState("1");
  639. } else {
  640. sickbedInformationList.get(i).setTrusteeshipState("0");
  641. }
  642. }
  643. }
  644. bedAdapter.listUpdate(sickbedInformationList);
  645. }
  646. }
  647. private void getRoomData() {
  648. if (!StringUtils.notEmpty(Constants.URL)) return;
  649. OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_ROOM)
  650. // .addParams("deviceId","5")
  651. .addParams("deviceId", Constants.MYSELF_ID)
  652. .build()
  653. .execute(new StringCallback() {
  654. @Override
  655. public void onError(Call call, Exception e, int id) {
  656. if (swipeRefreshLayout.isRefreshing()) {
  657. swipeRefreshLayout.setRefreshing(false);
  658. }
  659. hideProgress();
  660. handler.sendEmptyMessage(GETROOMDATA_ERROR);
  661. }
  662. @Override
  663. public void onResponse(String response, int id) {
  664. LogUtil.d(CallingBedFragment.class, "getRoomData==" + response);
  665. if (swipeRefreshLayout.isRefreshing()) {
  666. swipeRefreshLayout.setRefreshing(false);
  667. }
  668. String data = response.substring(0, response.length() - 4);
  669. try {
  670. JSONObject jsonObj = new JSONObject(data);
  671. if (jsonObj.getString("Code").equals("ERROR!")) {
  672. handler.sendEmptyMessage(GETROOMDATA_ERROR);
  673. Log.w("Code", "网络错误");
  674. } else {
  675. Gson gson = new Gson();
  676. roomEntity = gson.fromJson(data, RoomEntity.class);
  677. wardInformationList = roomEntity.getWardInformationList();
  678. }
  679. VoiceMessageRoomWardInformationUtil.getInstance().getRoomEntityList(wardInformationList);
  680. LogUtil.d(CallingBedFragment.class, "wardInformationList==" + wardInformationList.toString());
  681. roomAdapter.updateList(wardInformationList);
  682. if (null != wardInformationList && CallingBedFragment.this.position != -1) {
  683. try {
  684. sickbedInformationList = wardInformationList.get(CallingBedFragment.this.position).getSickbedInformationList();
  685. } catch (Exception e) {
  686. LogUtil.d("getRoomData", "position越界");
  687. }
  688. }
  689. if (CallingBedFragment.this.position != -1 && null != sickbedInformationList) {
  690. if (sickbedInformationList.size() > 0) {
  691. for (int i = 0; i < sickbedInformationList.size(); i++) {
  692. if ("1".equals(wardInformationList.get(CallingBedFragment.this.position).getTrusteeshipState())) {
  693. sickbedInformationList.get(i).setTrusteeshipState("1");
  694. } else {
  695. sickbedInformationList.get(i).setTrusteeshipState("0");
  696. }
  697. }
  698. }
  699. bedAdapter.listUpdate(sickbedInformationList);
  700. }
  701. } catch (JSONException e) {
  702. if (swipeRefreshLayout.isRefreshing()) {
  703. swipeRefreshLayout.setRefreshing(false);
  704. }
  705. e.printStackTrace();
  706. }
  707. }
  708. });
  709. }
  710. private void getHospitalData() {
  711. if (!StringUtils.notEmpty(Constants.URL)) return;
  712. if (!StringUtils.notEmpty(Constants.PartID)) return;
  713. OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_HOSPITAL)
  714. .addParams("PartID", Constants.PartID)
  715. .build()
  716. .execute(new StringCallback() {
  717. @Override
  718. public void onError(Call call, Exception e, int id) {
  719. hideProgress();
  720. Constants.MGR_UPDATE = false;
  721. if (swipeRefreshLayout.isRefreshing()) {
  722. swipeRefreshLayout.setRefreshing(false);
  723. }
  724. handler.sendEmptyMessage(GETHOSPITALDATA_ERROR);
  725. }
  726. @Override
  727. public void onResponse(String response, int id) {
  728. String data = response.substring(0, response.length() - 4);
  729. LogUtil.d("getHospitalData", "data=="+data);
  730. try {
  731. if (swipeRefreshLayout.isRefreshing()) {
  732. swipeRefreshLayout.setRefreshing(false);
  733. }
  734. JSONObject jsonObj = new JSONObject(data);
  735. if (jsonObj.getString("Code").equals("ERROR!")) {
  736. handler.sendEmptyMessage(GETHOSPITALDATA_ERROR);
  737. LogUtil.d("Code", "网络错误");
  738. } else {
  739. Gson gson = new Gson();
  740. hospitalInfoEntity = gson.fromJson(data, HospitalInfoEntity.class);
  741. dutyDoctorList = (ArrayList<String>) hospitalInfoEntity.getDutyDoctorList();
  742. nurseOnDutyList = (ArrayList<String>) hospitalInfoEntity.getNurseOnDutyList();
  743. importantMessageList = (ArrayList<String>) hospitalInfoEntity.getImportantMessageList();
  744. }
  745. setHospitalView();
  746. } catch (JSONException e) {
  747. e.printStackTrace();
  748. if (swipeRefreshLayout.isRefreshing()) {
  749. swipeRefreshLayout.setRefreshing(false);
  750. }
  751. }
  752. Constants.MGR_UPDATE = false;
  753. }
  754. });
  755. }
  756. /**
  757. * 获取系统设置信息
  758. */
  759. private void getSYSsetingData() {
  760. if (!StringUtils.notEmpty(Constants.URL)) return;
  761. LogUtil.d("setSYSsetingData", Constants.URL + Constants.URL_END + Constants.SYSTEM_INFO);
  762. if (!StringUtils.notEmpty(Constants.PartID)) return;
  763. OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.SYSTEM_INFO)
  764. .addParams("PartID", Constants.PartID)
  765. .build()
  766. .execute(new StringCallback() {
  767. @Override
  768. public void onError(Call call, Exception e, int id) {
  769. e.printStackTrace();
  770. Constants.MGR_UPDATE = false;
  771. handler.sendEmptyMessage(GETSYSSETINGDATA_ERROR);
  772. LogUtil.d("setSYSsetingData", "error");
  773. }
  774. @Override
  775. public void onResponse(String response, int id) {
  776. LogUtil.d("setSYSsetingData", "response==" + response);
  777. String data = response.substring(0, response.length() - 4);
  778. try {
  779. JSONObject jsonObj = new JSONObject(data);
  780. if (jsonObj.getString("Code").equals("ERROR!")) {
  781. LogUtil.d("setSYSsetingData", "ERROR!");
  782. handler.sendEmptyMessage(GETSYSSETINGDATA_ERROR);
  783. } else {
  784. Gson gson = new Gson();
  785. systemInfoEntity = gson.fromJson(data, SystemInfoEntity.class);
  786. if (null != systemInfoEntity) {
  787. Constants.MORNING_NIGTH = systemInfoEntity.getDayOrNight();
  788. Constants.DAY_RING_TIMES = systemInfoEntity.getDayRingTimes();
  789. Constants.NIGHT_RING_TIMES = systemInfoEntity.getNightRingTimes();
  790. Constants.VOICE_BROADCAST_TYPE = systemInfoEntity.getVoiceBroadcastType();
  791. LogUtil.d("setSYSsetingData", systemInfoEntity.getDayOrNight() + systemInfoEntity.getDayRingTimes() + systemInfoEntity.getNightRingTimes());
  792. setSYSParameter(false);
  793. }
  794. }
  795. } catch (JSONException e) {
  796. e.printStackTrace();
  797. }
  798. Constants.MGR_UPDATE = false;
  799. }
  800. });
  801. }
  802. /**
  803. * 获取病人个人信息
  804. **/
  805. private void getPatientData(String bedId) {
  806. if (!StringUtils.notEmpty(Constants.URL)) return;
  807. OkHttpUtils.post().url(Constants.URL + Constants.URL_END + Constants.CALLINGMAINNURSE_PATIENT)
  808. .addParams("bedid", bedId)
  809. .build()
  810. .execute(new StringCallback() {
  811. @Override
  812. public void onError(Call call, Exception e, int id) {
  813. onErrorClean();
  814. LogUtil.i(CallingBedFragment.class, "请求错误");
  815. }
  816. @Override
  817. public void onResponse(String response, int id) {
  818. LogUtil.d(CallingBedFragment.class, "getPatientData==" + response);
  819. String data = response.substring(0, response.length() - 4);
  820. try {
  821. JSONObject jsonObj = new JSONObject(data);
  822. if (jsonObj.getString("Code").equals("ERROR!")) {
  823. onErrorClean();
  824. LogUtil.i(CallingBedFragment.class, "返回错误标识");
  825. } else {
  826. LogUtil.i(CallingBedFragment.class, "返回正常");
  827. tvCallListName.setText("姓名:" + jsonObj.getString("patientName"));
  828. rightCallInfomation.setText("性别:" + jsonObj.getString("patientGender"));
  829. rightCallInfomationOne.setText("年龄:" + jsonObj.getString("PatientAge"));
  830. rightCallInfomationThree.setText("责任医生:" + jsonObj.getString("attendingDoctor"));
  831. rightCallInfomationFour.setText("责任护士:" + jsonObj.getString("nurseInCharge"));
  832. rightCallInfomationFive.setText("入院时间:" + jsonObj.getString("admissionTime"));
  833. String trusteeshipState = jsonObj.getString("trusteeshipState");
  834. if (notEmpty(trusteeshipState) && !trusteeshipState.equals("0")) {
  835. rightCallInfomationSix.setText("托管状态:" + "已托管");
  836. } else {
  837. rightCallInfomationSix.setText("托管状态:" + "未托管");
  838. }
  839. rightCallInfomationEight.setText("病情状况:" + StringUtils.replaceNull(StringUtils.qj2bj(jsonObj.getString("Condition"))));
  840. //rightCallInfomationSeven.setText(":" + jsonObj.getString(""));
  841. }
  842. } catch (JSONException e) {
  843. e.printStackTrace();
  844. }
  845. }
  846. });
  847. }
  848. private void initCallingQueuingInfo() {
  849. callingQueuingInfoList = new ArrayList<>();
  850. for (int i = 0; i < 10; i++) {
  851. callingQueuingInfoEntity = new CallingQueuingInfoEntity();
  852. callingQueuingInfoEntity.setDate("呼叫时间:2017-11-17 11:36:08");
  853. callingQueuingInfoEntity.setCallingRoomNo("呼叫床位:104房006床");
  854. //callingQueuingInfoList.add(callingQueuingInfoEntity);
  855. }
  856. LinearLayoutManager manager = new LinearLayoutManager(getActivity());
  857. rvCallingQueuingBar.setLayoutManager(manager);
  858. callingQueuingInfoAdapter = new CallingQueuingInfoAdapter(getActivity(), callingQueuingInfoList);
  859. rvCallingQueuingBar.setAdapter(callingQueuingInfoAdapter);
  860. callingQueuingInfoAdapter.setCallingQueuingItemOnclickListener(this);
  861. noCalledDataText.setVisibility(View.VISIBLE);
  862. rvCallingQueuingBar.setVisibility(View.INVISIBLE);
  863. }
  864. /**
  865. * Sip注册不成功不能发起拨打电话
  866. */
  867. private boolean filterSipToast() {
  868. if (Constants.SIP_REGIST_STATUS == 0) {
  869. ToastUtil.showToast("通话协议注册失败!");
  870. return false;
  871. } else if (Constants.SIP_REGIST_STATUS == 1) {
  872. ToastUtil.showToast("通话协议正在注册中,请稍候!");
  873. return false;
  874. }
  875. return true;
  876. }
  877. @Override
  878. public void onClick(View view) {
  879. switch (view.getId()) {
  880. case R.id.confirm_button:
  881. if (null != urgentPopupwindow) {
  882. urgentPopupwindow.dismiss();
  883. }
  884. break;
  885. }
  886. }
  887. /**
  888. * 来电呼叫列表中的右下角呼叫按键
  889. */
  890. @OnClick(R.id.right_in_call_list_layout_iv_call)
  891. public void listCall(View view) {
  892. currentTime = System.currentTimeMillis();
  893. if (currentTime - lastClickTime > CLICK_DELAY_TIME) {
  894. lastClickTime = currentTime;
  895. //加了个点击缓冲 20180319
  896. // ===============================暂时注掉20180408(Ping网:有时候 网络已经连上 但是ping不通)===========================//
  897. if (!filterSipToast()) {
  898. return;
  899. }
  900. if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
  901. if (null == callingEntity) {
  902. return;
  903. }
  904. if (null != loopVoice) {
  905. loopVoice.setPalyDismiss(true);
  906. }
  907. //String sipAddress = callingEntity.getSipAddress();
  908. String sipAddress = callingEntity.getSipAddress();
  909. if (StringUtils.notEmpty(sipAddress)) {
  910. LogUtil.d("sipAddress", "Call==sipAddress==" + sipAddress);
  911. LogUtil.d("sipAddress", "Call==deviceMAC==" + callingEntity.getDeviceMAC());
  912. //ToastUtil.showToast(sipAddress+"===="+callingEntity.getDeviceMAC());
  913. callBed = false;
  914. ivCallListPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
  915. mainFragmentActivity.initiateCall(sipAddress, callingEntity.getType(), callingEntity.getDeviceMAC());
  916. }
  917. } else {
  918. if (null != loopingUdpentity && loopingUdpentity.equals(callingEntity)) {
  919. loopVoice.setPalyDismiss(true);
  920. }
  921. endCall();
  922. }
  923. } else {
  924. ToastUtil.showToast("请勿频繁点击!");
  925. }
  926. }
  927. /**
  928. * 选择床位和选择记录列表后右边底部呼叫按钮
  929. */
  930. @OnClick(R.id.right_in_calling_layout_iv_call)
  931. public void Call(View view) {
  932. currentTime = System.currentTimeMillis();
  933. if (currentTime - lastClickTime > CLICK_DELAY_TIME) {
  934. lastClickTime = currentTime;
  935. //加了个点击缓冲 20180319
  936. // ===============================暂时注掉20180408(Ping网:有时候 网络已经连上 但是ping不通)===========================//
  937. if (!filterSipToast()) {
  938. return;
  939. }
  940. if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
  941. if (null != sickBedInfo) {
  942. String sipAddress = sickBedInfo.getSipID();
  943. if (null != loopVoice) {
  944. loopVoice.setPalyDismiss(true);
  945. }
  946. if (StringUtils.notEmpty(sipAddress)) {
  947. LogUtil.d("sipAddress", "Call==sipAddress==" + sipAddress);
  948. LogUtil.d("sipAddress", "Call==deviceMAC==" + sickBedInfo.getDeviceMAC());
  949. //ToastUtil.showToast(sipAddress+"===="+sickBedInfo.getDeviceMAC());
  950. callBed = true;
  951. ivCallPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
  952. mainFragmentActivity.initiateCall(sipAddress, "", sickBedInfo.getDeviceMAC() == null ? "-1" : sickBedInfo.getDeviceMAC());
  953. }
  954. }
  955. } else {
  956. endCall();
  957. }
  958. } else {
  959. ToastUtil.showToast("请勿频繁点击!");
  960. }
  961. }
  962. private void setHospitalView() {
  963. if (null != hospitalInfoEntity) {
  964. tvPatientNum.setText(hospitalInfoEntity.getPatientNum());
  965. tvFreeBed.setText(hospitalInfoEntity.getFreeBeds());
  966. tvTodayAdmission.setText(hospitalInfoEntity.getAdmissionToday());
  967. tvTodayLeave.setText(hospitalInfoEntity.getDischargedToday());
  968. tvTomorrowLeave.setText(hospitalInfoEntity.getDischargeTomorrow());
  969. tvTodayOperation.setText(hospitalInfoEntity.getOperationToday());
  970. tvTomorrowOperation.setText(hospitalInfoEntity.getOperationTomorrow());
  971. tvSpecialCare.setText(hospitalInfoEntity.getSpecialCare());
  972. tvPrimaryCare.setText(hospitalInfoEntity.getPrimaryCare());
  973. importantMessageAdapter.updateList(importantMessageList);
  974. dutyNurseAdapter.updateList(nurseOnDutyList);
  975. dutyDoctorAdapter.updateList(dutyDoctorList);
  976. /* 刷新各个列表*/
  977. }
  978. }
  979. /**
  980. * @param view 病房适配器的view
  981. * @param position 点击的position
  982. */
  983. @Override
  984. public void sicknessRoomItemOnclick(View view, final int position) {
  985. this.position = position;
  986. if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
  987. vRightPatientInfo.setVisibility(View.VISIBLE);
  988. vRightCallInfo.setVisibility(View.GONE);
  989. vRightCallListInfo.setVisibility(View.GONE);
  990. }
  991. //重置床位数据
  992. if (position == 0) {
  993. //sickbedInformationList = null;
  994. //callListAdapter.updateList(((MyApplication) getActivity().getApplication()).callEntityList);
  995. rvCallBed.setVisibility(View.GONE);
  996. rvCallList.setVisibility(View.VISIBLE);
  997. llBgList.setBackgroundResource(R.mipmap.bg_call_list);
  998. //tvTitle.setText("呼叫列表");
  999. showPartSelectDialog();
  1000. } else {
  1001. llBgList.setBackgroundResource(R.mipmap.bg_bed_list);
  1002. tvTitle.setText("床位列表");
  1003. rvCallList.setVisibility(View.GONE);
  1004. if (null != wardInformationList) {
  1005. sickbedInformationList = wardInformationList.get(position).getSickbedInformationList();
  1006. if (sickbedInformationList.size() > 0) {
  1007. for (int i = 0; i < sickbedInformationList.size(); i++) {
  1008. try {
  1009. if (wardInformationList.get(position).getTrusteeshipState().equals("1")) {
  1010. sickbedInformationList.get(i).setTrusteeshipState("1");
  1011. } else
  1012. sickbedInformationList.get(i).setTrusteeshipState("0");
  1013. } catch (Exception e) {
  1014. LogUtil.d("sicknessRoomItemOnclick", "Exception");
  1015. }
  1016. }
  1017. bedAdapter.listUpdate(sickbedInformationList);
  1018. rvCallBed.setVisibility(View.VISIBLE);
  1019. ROOM_LIST_POSITION = position;
  1020. } else {
  1021. rvCallBed.setVisibility(View.GONE);
  1022. ROOM_LIST_POSITION = -1;
  1023. }
  1024. }
  1025. }
  1026. }
  1027. /**
  1028. * 病床点击position
  1029. *
  1030. * @param view 病床适配器的view
  1031. * @param position 点击的position
  1032. */
  1033. @Override
  1034. public void sicknessBedItemOnclick(View view, int position) {
  1035. if (null == sickbedInformationList || null == sickbedInformationList.get(position) || null == sickbedInformationList.get(position).getPatientID()) {
  1036. return;
  1037. }
  1038. if (!Constants.CALL_STATE.equals(Constants.STANDBY) && !sickBedInfo.equals(sickbedInformationList.get(position))) {
  1039. ToastUtil.showToast("请先取消当前呼叫");
  1040. return;
  1041. }
  1042. if (vRightCallInfo.getVisibility() == View.VISIBLE && sickBedInfo.equals(sickbedInformationList.get(position))) {
  1043. if (null == sickBedInfo || !StringUtils.listNotEmpty(sickbedInformationList)) return;
  1044. if (filterSipToast()) {
  1045. if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
  1046. String sipAddress = sickBedInfo.getSipID();
  1047. if (StringUtils.notEmpty(sipAddress)) {
  1048. callBed = true;
  1049. ivCallPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
  1050. mainFragmentActivity.initiateCall(sipAddress, "", sickBedInfo.getDeviceMAC() == null ? "-1" : sickBedInfo.getDeviceMAC());
  1051. }
  1052. } else {
  1053. endCall();
  1054. }
  1055. }
  1056. } else {
  1057. if (!Constants.CALL_STATE.equals(Constants.STANDBY)) return;
  1058. vRightPatientInfo.setVisibility(View.GONE);
  1059. vRightCallListInfo.setVisibility(View.GONE);
  1060. vRightCallInfo.setVisibility(View.VISIBLE);
  1061. //2018 9 17 胡博文 不判断病人id ,之后电话的时候判断是否有sip id
  1062. sickBedInfo = sickbedInformationList.get(position);
  1063. setPatientView(sickBedInfo);
  1064. BED_LIST_POSITION = position;
  1065. // if (sickbedInformationList.get(position).getPatientID().equals("0")) {
  1066. // sickBedInfo = null;
  1067. // setPatientView(sickBedInfo);
  1068. // BED_LIST_POSITION = -1;
  1069. // } else { //对应床位的病人信息
  1070. // sickBedInfo = sickbedInformationList.get(position);
  1071. // setPatientView(sickBedInfo);
  1072. // BED_LIST_POSITION = position;
  1073. // }
  1074. }
  1075. }
  1076. private void showPartSelectDialog() {
  1077. final String[] partItems = {Constants.PartName}; //test
  1078. AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
  1079. final AlertDialog dialog = builder.create();
  1080. //dialog.setCanceledOnTouchOutside(false);
  1081. View dialogView = View.inflate(getActivity(), R.layout.dialog_part_select_layout, null);
  1082. ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getActivity(), R.layout.custom_spinner_item, partItems);
  1083. spinnerAdapter.setDropDownViewResource(R.layout.custom_spinner_dropdown_item);
  1084. Spinner partSpinner = dialogView.findViewById(R.id.sp_part_select);
  1085. Button button = dialogView.findViewById(R.id.btn_ok);
  1086. partSpinner.setAdapter(spinnerAdapter);
  1087. partSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  1088. @Override
  1089. public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
  1090. Log.d("wzl", "on item selected: " + position);
  1091. }
  1092. @Override
  1093. public void onNothingSelected(AdapterView<?> parent) {
  1094. }
  1095. });
  1096. button.setOnClickListener(new View.OnClickListener() {
  1097. @Override
  1098. public void onClick(View v) {
  1099. dialog.dismiss();
  1100. }
  1101. });
  1102. dialog.setView(dialogView);
  1103. dialog.show();
  1104. if (dialog.getWindow() != null) {
  1105. dialog.getWindow().setBackgroundDrawableResource(R.drawable.dialog_round_bg);
  1106. }
  1107. }
  1108. private void setPatientView(RoomEntity.WardInformation.SickbedInformation bedEntity) {
  1109. if (null != bedEntity) {
  1110. tvRoomBedAnswerState.setText(wardInformationList.get(this.position).getRoomNum() + "房" + bedEntity.getBedNum() + "床");
  1111. tvRoomMsg.setText(wardInformationList.get(this.position).getRoomNum() + "房" + bedEntity.getBedNum() + "床");
  1112. tvPatientInfo.setText(bedEntity.getPatientName() + " " + bedEntity.getPatientGender() + " " + bedEntity.getPatientAge());
  1113. tvPatientInfoAdmissionTime.setText("入院时间:" + bedEntity.getAdmissionTime());
  1114. tvAttendingDoctor.setText("责任医生:" + bedEntity.getAttendingDoctor());
  1115. tvNurseInCharge.setText("责任护士:" + bedEntity.getNurseInCharge());
  1116. tvGradeLevel.setText("护理等级:" + bedEntity.getGradeNurse());
  1117. String trusteeshipState = bedEntity.getTrusteeshipState();
  1118. if (notEmpty(trusteeshipState) && !trusteeshipState.equals("0")) {
  1119. tvDietLevel.setText("托管状态:" + "已托管");
  1120. } else {
  1121. tvDietLevel.setText("托管状态:" + "未托管");
  1122. }
  1123. // tvDietLevel.setText("饮食等级:" + bedEntity.getDietLevel());
  1124. tvDosageLevel.setText("计量等级:" + bedEntity.getDosageLevel() + "级");
  1125. tvInsulateLevel.setText("隔离等级:" + bedEntity.getInsulateLevel() + "级");
  1126. tvCondition.setText("病情状况:" + bedEntity.getCondition());
  1127. } else {
  1128. tvRoomBedAnswerState.setText(wardInformationList.get(this.position).getRoomNum() + "房");
  1129. tvRoomMsg.setText(wardInformationList.get(this.position).getRoomNum() + "房");
  1130. tvPatientInfo.setText("--");
  1131. tvPatientInfoAdmissionTime.setText("--");
  1132. tvAttendingDoctor.setText("--");
  1133. tvNurseInCharge.setText("--");
  1134. tvGradeLevel.setText("--");
  1135. tvDietLevel.setText("--");
  1136. tvDosageLevel.setText("--");
  1137. tvInsulateLevel.setText("--");
  1138. tvCondition.setText("--");
  1139. }
  1140. }
  1141. UdpEntity callItemChooseEntity;
  1142. /**
  1143. * 呼叫列表position
  1144. *
  1145. * @param view 呼叫列表的view
  1146. * @param position 点击的position
  1147. */
  1148. @Override
  1149. public void callListItemOnclick(View view, int position) {
  1150. if (!Constants.CALL_STATE.equals(Constants.STANDBY) && !callItemChooseEntity.equals(MyApplication.callEntityList.get(position))) {
  1151. ToastUtil.showToast("请先取消当前呼叫");
  1152. return;
  1153. }
  1154. if (vRightCallListInfo.getVisibility() == View.VISIBLE && callItemChooseEntity.equals(MyApplication.callEntityList.get(position))) {
  1155. if (null == callItemChooseEntity) return;
  1156. if (filterSipToast() && !MyApplication.callEntityList.get(position).getType().equals(Constants.WSHROOM_CALL) && !MyApplication.callEntityList.get(position).getType().equals(Constants.ROOMHELP_CALL)) {
  1157. if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
  1158. String sipAddress = callItemChooseEntity.getSipAddress();
  1159. if (StringUtils.notEmpty(sipAddress)) {
  1160. callBed = false;
  1161. ivCallListPic.setVisibility(View.VISIBLE);
  1162. ivCallListPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
  1163. LogUtil.d("sipAddress", "Call==sipAddress==" + sipAddress);
  1164. LogUtil.d("sipAddress", "Call==deviceMAC==" + callItemChooseEntity.getDeviceMAC());
  1165. //ToastUtil.showToast(sipAddress+"===="+callItemChooseEntity.getDeviceMAC());
  1166. mainFragmentActivity.initiateCall(sipAddress, callItemChooseEntity.getType(), callItemChooseEntity.getDeviceMAC());
  1167. }
  1168. } else {
  1169. endCall();
  1170. }
  1171. }
  1172. } else {
  1173. if (!Constants.CALL_STATE.equals(Constants.STANDBY)) return;
  1174. if (MyApplication.callEntityList.get(position).getType().equals(Constants.WSHROOM_CALL)) {
  1175. showToast("不支持卫生间通话");
  1176. vRightCallListInfo.setVisibility(View.GONE);
  1177. vRightPatientInfo.setVisibility(View.VISIBLE);
  1178. vRightCallInfo.setVisibility(View.GONE);
  1179. //rightCallListInfomation.setVisibility(View.INVISIBLE);
  1180. //ivCallListPic.setVisibility(View.INVISIBLE);
  1181. //tvCallListRoomMsg.setText(MyApplication.callEntityList.get(position).getRoomNumber() + "房卫生间紧急呼叫");
  1182. return;
  1183. } else if (MyApplication.callEntityList.get(position).getType().equals(Constants.ROOMHELP_CALL)) {
  1184. showToast("不支持紧急增援通话");
  1185. vRightCallListInfo.setVisibility(View.GONE);
  1186. vRightPatientInfo.setVisibility(View.VISIBLE);
  1187. vRightCallInfo.setVisibility(View.GONE);
  1188. //rightCallListInfomation.setVisibility(View.VISIBLE);
  1189. //ivCallListPic.setVisibility(View.INVISIBLE);
  1190. //tvCallListRoomMsg.setText(MyApplication.callEntityList.get(position).getRoomNumber() + "房" + MyApplication.callEntityList.get(position).getBedNumber() + "床请求增援");
  1191. //setCallListMsg(MyApplication.callEntityList.get(position));
  1192. return;
  1193. }
  1194. chooseCallItemUI(position);
  1195. }
  1196. callItemChooseEntity = MyApplication.callEntityList.get(position);
  1197. }
  1198. @Subscribe(threadMode = ThreadMode.MAIN)
  1199. public void onMoonEvent(MessageEvent messageEvent) {
  1200. switch (messageEvent.getType()) {
  1201. case Constants.EVENT_SIP:
  1202. LogUtil.d("CALLSTATE", "Constants.CALL_STATE==" + Constants.CALL_STATE);
  1203. if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
  1204. LogUtil.d("onMoonEvent", "通话状态==STANDBY");
  1205. if (null != MyApplication.serialPortUtil) { //呼叫结束了;打开外部音响
  1206. MyApplication.serialPortUtil.stereoControl("1");
  1207. }
  1208. if (null != loopVoice) { //呼叫结束了;将播报音量为1;
  1209. loopVoice.setVolumes(1.0f);
  1210. }
  1211. ivCallPic.setImageResource(R.mipmap.ic_calling_sickbed_right_calling);
  1212. ivCallListPic.setImageResource(R.mipmap.ic_calling_sickbed_right_calling);
  1213. tvBedCallState.setText("");
  1214. tvCallListState.setText("");
  1215. //呼叫结束了;同时将呼叫列表删除该用户(20171102 Waderson)
  1216. if (have_Call) {
  1217. setVolumePA(false);
  1218. if (CALL_LIST_POSITION >= 0 && upScrllPosition != CALL_LIST_POSITION) {
  1219. if (!callBed) {
  1220. endCallNotifi(callingEntity);
  1221. if (((MyApplication) getActivity().getApplication()).callEntityList.contains(callingEntity)) {
  1222. // //由于SIP结束回调的延时而出现重叠(在连续狂打电话的情况下效果重叠不行)
  1223. // if (null != loopingUdpentity && loopingUdpentity.equals(callingEntity)) {
  1224. // loopVoice.setPalyDismiss(true);
  1225. // }
  1226. if (null != loopingUdpentity && loopingUdpentity.equals(callingEntity)) {// Waderson 20180305
  1227. if (null != loopVoice) {
  1228. loopVoice.setPalyDismiss(true);
  1229. }
  1230. } else {
  1231. if (PalyPhonetics.speakEntityList.contains(callingEntity)) {//将播报列表也删除该元素
  1232. PalyPhonetics.speakEntityList.remove(callingEntity);
  1233. }
  1234. }
  1235. ((MyApplication) getActivity().getApplication()).callEntityList.remove(callingEntity);
  1236. sendNoAnyRequestDoor(callingEntity);
  1237. sendCallWaitingNumber(MyApplication.callEntityList.size());
  1238. callListAdapter.notifyDataSetChanged();
  1239. roomAdapter.notifyDataSetChanged();
  1240. if (!StringUtils.listNotEmpty(((MyApplication) getActivity().getApplication()).callEntityList)) {
  1241. setPowerLed("1");
  1242. }
  1243. }
  1244. }
  1245. }
  1246. vRightPatientInfo.setVisibility(View.VISIBLE);
  1247. vRightCallListInfo.setVisibility(View.GONE);
  1248. vRightCallInfo.setVisibility(View.GONE);
  1249. upScrllPosition = -1;
  1250. have_Call = false;
  1251. callBed = false;
  1252. }
  1253. } else {
  1254. // ivCallPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
  1255. // ivCallListPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
  1256. }
  1257. if (Constants.CALL_STATE.equals(Constants.IN_CALL)) {
  1258. tvBedCallState.setText(" 正在呼叫中...");
  1259. tvCallListState.setText(" 正在呼叫中...");
  1260. } else if (Constants.CALL_STATE.equals(Constants.IN_CALLING)) {
  1261. have_Call = true;
  1262. setVolumePA(true);
  1263. upScrllPosition = -1;//通话的时候废掉上滑索引;以免与通话结束后自动删除CALL条目相冲突
  1264. tvBedCallState.setText(" 正在通话中...");
  1265. tvCallListState.setText(" 正在通话中...");
  1266. if (null != MyApplication.serialPortUtil) { //正在呼叫;将关闭外部音响
  1267. MyApplication.serialPortUtil.stereoControl("0");
  1268. }
  1269. //正在呼叫;将播报音量为0
  1270. if (null != loopVoice) {
  1271. loopVoice.setVolumes(0f);
  1272. }
  1273. //安卓端接通电话,通知点阵屏,但要排除固定列表
  1274. if (!callBed) {
  1275. callingNotifi(callingEntity);
  1276. }
  1277. MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
  1278. new Handler().postDelayed(new Runnable() {
  1279. @Override
  1280. public void run() {
  1281. MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
  1282. }
  1283. }, 100);
  1284. new Handler().postDelayed(new Runnable() {
  1285. @Override
  1286. public void run() {
  1287. MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
  1288. }
  1289. }, 600);
  1290. new Handler().postDelayed(new Runnable() {
  1291. @Override
  1292. public void run() {
  1293. MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
  1294. }
  1295. }, 1100);
  1296. }
  1297. break;
  1298. case Constants.EVENT_UDP:
  1299. UdpEntity udpEntity = (UdpEntity) messageEvent.getMessage();
  1300. String nurseHostID = udpEntity.getNurseHostID();
  1301. String headMachineID = udpEntity.getHeadMachineID();
  1302. //String doorwayMachineID = udpEntity.getDoorwayMachineID();
  1303. //String roomNumber = udpEntity.getRoomNumber();
  1304. LogUtil.d(CallingBedFragment.class, "udpEntityString==" + udpEntity.toString());
  1305. switch (udpEntity.getIndexes()) {
  1306. case "call_1": //子机呼叫护士主机
  1307. case "call_2"://卫生间呼叫护士主机
  1308. case "call_4"://增援呼叫护士主机
  1309. case "call_6": //门口机呼叫护士主机
  1310. if (isMySelfMachine(nurseHostID)) {//只有属于自己管的机器才能加进列表
  1311. if (!PalyPhonetics.speakEntityList.contains(udpEntity)) {
  1312. addPhonetics(udpEntity); //在此加入列表队列 Waderson 20171101
  1313. }
  1314. if (!MyApplication.callEntityList.contains(udpEntity)) {
  1315. if (isHaveThisWSHtype(udpEntity)) return;
  1316. MyApplication.callEntityList.add(udpEntity);
  1317. setPowerLed("2");//有电话过来就让电源灯闪 Waderson 20171221
  1318. sortList();//在此执行排序 Waderson 20171031
  1319. sendCallWaitingNumber(MyApplication.callEntityList.size());
  1320. }
  1321. callListAdapter.notifyDataSetChanged();
  1322. roomAdapter.notifyDataSetChanged();
  1323. }
  1324. break;
  1325. case "call_1_b1": //护士已经退出护理
  1326. if (notEmpty(nurseHostID) && nurseHostID.equals(Constants.MYSELF_ID)) {
  1327. // //此处请注意:由于没有限定一个房间只能有一个“请求增援”;所以当护士退出护理后不做任何操作
  1328. // //如果将播报列表删除该“请求增援”元素,那么删除哪个呢?全部删除吗?这样做显然不妥;所以经过
  1329. // //我们的讨论此处暂时不做任何操作!Waderson
  1330. // udpEntity.setIndexes("call_4");
  1331. // if (((MyApplication) getActivity().getApplication()).callEntityList.contains(udpEntity)) {
  1332. // if (null != loopingUdpentity && loopingUdpentity.equals(udpEntity)) {
  1333. // loopVoice.setPalyDismiss(true);
  1334. // }
  1335. // if (null != loopingUdpentity && loopingUdpentity.equals(udpEntity)) {// Waderson 20180305
  1336. // if (null != loopVoice) {
  1337. // loopVoice.setPalyDismiss(true);
  1338. // }
  1339. // } else {
  1340. // if (PalyPhonetics.speakEntityList.contains(udpEntity)) {//将播报列表也删除该元素
  1341. // PalyPhonetics.speakEntityList.remove(udpEntity);
  1342. // }
  1343. // }
  1344. // ((MyApplication) getActivity().getApplication()).callEntityList.remove(udpEntity);
  1345. // sendNoAnyRequestDoor(udpEntity);
  1346. // sendCallWaitingNumber(MyApplication.callEntityList.size());
  1347. // endCallNotifi(udpEntity);
  1348. // if(!StringUtils.listNotEmpty(((MyApplication) getActivity().getApplication()).callEntityList)){setPowerLed("1");}
  1349. // }
  1350. // callListAdapter.notifyDataSetChanged();
  1351. // roomAdapter.notifyDataSetChanged();
  1352. }
  1353. break;
  1354. case "cancel_bed_call"://门口机取消呼叫
  1355. deleteRoomBedCall(udpEntity);
  1356. break;
  1357. case "call_1_hang_up": //子机取消呼叫 add by waderson 20191108
  1358. deleteCallingItem(udpEntity , 1);
  1359. break;
  1360. case "call_1_transfer"://床头机转接护士主机电话
  1361. if (notEmpty(nurseHostID) && nurseHostID.equals(Constants.MYSELF_ID)) {
  1362. sendTransferForSon(headMachineID);
  1363. }
  1364. break;
  1365. case "call_transfer_bedtobed": //子机转接子机成功后,告诉外面执行状态联动
  1366. if (notEmpty(nurseHostID) && nurseHostID.equals(Constants.MYSELF_ID)) {
  1367. transferBedToBed(udpEntity);
  1368. }
  1369. break;
  1370. case "nursing_1": //进入护理
  1371. if (notEmpty(nurseHostID) && nurseHostID.equals(Constants.MYSELF_ID)) {
  1372. setIsNursing(udpEntity, true);
  1373. }
  1374. break;
  1375. case "nursing_2": //退出护理
  1376. if (notEmpty(nurseHostID) && nurseHostID.equals(Constants.MYSELF_ID)) {
  1377. setIsNursing(udpEntity, false);
  1378. }
  1379. break;
  1380. case "back_1": //接听回调
  1381. break;
  1382. case "end_1"://挂断电话
  1383. break;
  1384. }
  1385. break;
  1386. case Constants.EVENT_MGR_UPDATE://后台相关数据改变后通知护士主机刷新UI
  1387. getRoomData();//病房数据
  1388. getHospitalData(); //医院数据
  1389. getSYSsetingData();//系统设置数据
  1390. handler.sendEmptyMessageDelayed(RESET, 2000);//做个复位
  1391. break;
  1392. case Constants.EVENT_SETSYS://系统设置参数
  1393. setSYSParameter(true);
  1394. break;
  1395. case Constants.EVENT_UPLOAD:
  1396. if (!ftpFilePath.equals(FTP_VOICE))
  1397. return;
  1398. if ((Boolean) messageEvent.getMessage()) {//上传成功
  1399. sendUdpVoiceMessage(fileOriginalName);
  1400. ToastUtil.showToast("上传成功");
  1401. } else {//上传失败
  1402. ToastUtil.showToast("上传失败");
  1403. }
  1404. break;
  1405. }
  1406. }
  1407. /**
  1408. * UDP语音上传
  1409. *
  1410. * @param fileName
  1411. */
  1412. private void sendUdpVoiceMessage(String fileName) {
  1413. MessageEntity messageEntity = new MessageEntity();
  1414. messageEntity.setHosManInfo(mVoiceMessageDetailPopupwindow.getMessageEntity().getHosManInfo());
  1415. messageEntity.setDeviceType(VoiceMessageAdapter.CHAT_ITEM_TYPE_RIGHT + "");
  1416. messageEntity.setDeviceID(mVoiceMessageDetailPopupwindow.getMessageEntity().getDeviceID());
  1417. messageEntity.setPatientID(mVoiceMessageDetailPopupwindow.getMessageEntity().getPatientID());
  1418. messageEntity.setPatientName(mVoiceMessageDetailPopupwindow.getMessageEntity().getPatientName());
  1419. messageEntity.setFileOriginalName(fileName);
  1420. messageEntity.setFileStoreName(fileName);
  1421. messageEntity.setMessageTime(getCurrentDate());
  1422. messageEntity.setContent("");
  1423. messageEntity.setID(mVoiceMessageDetailPopupwindow.getMessageEntity().getID());
  1424. UdpSendUtil.sendVoiceMessage(messageEntity);
  1425. }
  1426. /**
  1427. * 是否是属于自己管的机器<br></>
  1428. */
  1429. private boolean isMySelfMachine(String nurseHostID) {
  1430. String n = StringUtils.substringByLengh(nurseHostID, 0, 1);
  1431. if ("#".equals(n)) {
  1432. String nDis = StringUtils.deleteCharAt(nurseHostID, 0);
  1433. String my = nDis.split(",")[0];
  1434. String his = nDis.split(",")[1];
  1435. return Constants.MYSELF_ID.equals(my) && Constants.TRUST_OLD_MAIN_ID.equals(his);
  1436. } else {
  1437. return notEmpty(nurseHostID) && nurseHostID.equals(Constants.MYSELF_ID);
  1438. }
  1439. }
  1440. /**
  1441. * 是否已经有该卫生间紧急呼叫<br></>
  1442. */
  1443. private boolean isHaveThisWSHtype(UdpEntity udpEntity) {
  1444. if (!Constants.WSHROOM_CALL.equals(udpEntity.getType())) return false;
  1445. ArrayList<UdpEntity> callEntityList = ((MyApplication) getActivity().getApplication()).callEntityList;
  1446. for (int i = 0; i < callEntityList.size(); i++) {
  1447. if (Constants.WSHROOM_CALL.equals(callEntityList.get(i).getType()) && udpEntity.getRoomNumber().equals(callEntityList.get(i).getRoomNumber())) {
  1448. return true;
  1449. }
  1450. }
  1451. return false;
  1452. }
  1453. /**
  1454. * 门口机主动删除,删除该房间的呼叫<br></>
  1455. */
  1456. protected void deleteRoomBedCall(UdpEntity deleteUdpEntity) {
  1457. if (null != deleteUdpEntity) {
  1458. String roomNumber = deleteUdpEntity.getRoomNumber();
  1459. if (StringUtils.notEmpty(roomNumber)) {
  1460. for (int i = 0; i < PalyPhonetics.speakEntityList.size(); i++) {
  1461. if (roomNumber.equals(PalyPhonetics.speakEntityList.get(i).getRoomNumber())) {
  1462. if (null != loopingUdpentity && loopingUdpentity.equals(PalyPhonetics.speakEntityList.get(i))) {
  1463. if (null != loopVoice) {
  1464. loopVoice.setPalyDismiss(true);
  1465. }
  1466. }
  1467. PalyPhonetics.speakEntityList.remove(i);
  1468. i--;
  1469. }
  1470. }
  1471. for (int i = 0; i < MyApplication.callEntityList.size(); i++) {
  1472. if (roomNumber.equals(MyApplication.callEntityList.get(i).getRoomNumber())) {
  1473. if (null != urgentUdpEntity && urgentUdpEntity.equals(MyApplication.callEntityList.get(i))) {
  1474. if (null != urgentPopupwindow) urgentPopupwindow.dismiss();
  1475. }
  1476. endCallNotifi(MyApplication.callEntityList.get(i));
  1477. sendRemoveBack(MyApplication.callEntityList.get(i));
  1478. MyApplication.callEntityList.remove(i);
  1479. i--;
  1480. }
  1481. }
  1482. InitDataEntity initdataentity = ((MainFragmentActivity) getActivity()).getInitDataEntity();
  1483. UdpSendUtil.sendNotificationDoorLightWhite(initdataentity, deleteUdpEntity);//门灯变白
  1484. sendCallWaitingNumber(MyApplication.callEntityList.size());
  1485. callListAdapter.updateList(MyApplication.callEntityList);
  1486. roomAdapter.notifyDataSetChanged();
  1487. if (!StringUtils.listNotEmpty(MyApplication.callEntityList)) {
  1488. setPowerLed("1");
  1489. }
  1490. }
  1491. }
  1492. }
  1493. /**
  1494. * 设置系统的各项参数,根据后台UDP的指令改变机器的状态<br></>
  1495. */
  1496. private void setSYSParameter(boolean isUDPSend) {
  1497. //SP保存语音播报的类型 Context context, String spname, String vname, String vdata
  1498. SharedPreferencesUtil.putStringSp(getActivity(), Constants.MSG_SP, Constants.VOICE_BROADCAST_TAG, Constants.VOICE_BROADCAST_TYPE);
  1499. if ("2".equals(Constants.VOICE_BROADCAST_TYPE)) {// type是“2”;就关掉语音轮播
  1500. if (null != loopVoice) {
  1501. loopVoice.setPalyDismiss(true);
  1502. }
  1503. }
  1504. if (isUDPSend) {
  1505. if (notEmpty(Constants.RINGLVOICELOOP)) {
  1506. speakLooping = StringUtils.parseInt(Constants.RINGLVOICELOOP);
  1507. }
  1508. //-----------------------------------Sip通话音量设置------------------------------//
  1509. // VoiceManagerUtil.setCallVoice(getActivity(), StringUtils.parseInt(Constants.CALLVOICE));
  1510. } else {
  1511. if (notEmpty(Constants.MORNING_NIGTH) && Constants.MORNING_NIGTH.equals("0")) {
  1512. speakLooping = StringUtils.parseInt(Constants.DAY_RING_TIMES);
  1513. }
  1514. if (notEmpty(Constants.MORNING_NIGTH) && Constants.MORNING_NIGTH.equals("1")) {
  1515. speakLooping = StringUtils.parseInt(Constants.NIGHT_RING_TIMES);
  1516. }
  1517. if (systemInfoEntity.getDayBright().equals("0")) {
  1518. //=========================白天sip通话音量
  1519. // VoiceManagerUtil.setCallVoice(getActivity(), StringUtils.parseInt(systemInfoEntity.getDaySipVol()) );
  1520. } else {
  1521. //=========================晚上sip通话音量
  1522. // VoiceManagerUtil.setCallVoice(getActivity(), StringUtils.parseInt(systemInfoEntity.getNightSipVol()) );
  1523. }
  1524. }
  1525. }
  1526. /**
  1527. * 护理改变UI
  1528. */
  1529. private void setIsNursing(UdpEntity udpEntity, boolean isNursing) {
  1530. String roomNumber_in = udpEntity.getRoomNumber();
  1531. for (int i = 0; i < roomAdapter.getList().size(); i++) {
  1532. if (roomNumber_in.equals(roomAdapter.getList().get(i).getRoomNum())) {
  1533. roomAdapter.getList().get(i).setNursing(isNursing);
  1534. }
  1535. }
  1536. roomAdapter.notifyDataSetChanged();
  1537. }
  1538. /**
  1539. * 主机收到床头机转接请求,发出UDP带上SIP地址,筛选操作
  1540. */
  1541. private void sendTransferForSon(String headMachineID) {
  1542. ArrayList<UdpEntity> callEntityList = ((MyApplication) getActivity().getApplication()).callEntityList;
  1543. UdpEntity udpEntity = null;
  1544. if (callEntityList.size() > 0) {
  1545. for (int i = 0; i < callEntityList.size(); i++) {
  1546. if (!callEntityList.get(i).getType().equals(Constants.WSHROOM_CALL) && !callEntityList.get(i).getType().equals(Constants.ROOMHELP_CALL)) {//筛选一个;因为卫生间,请求增援是不能呼叫的
  1547. if (notEmpty(headMachineID) && !callEntityList.get(i).getHeadMachineID().equals(headMachineID)) {//转接的时候排除他自己
  1548. udpEntity = callEntityList.get(i);
  1549. break;
  1550. }
  1551. }
  1552. }
  1553. if (null != udpEntity) {//发UDP到床头机;然后将列表中的该条呼叫删除掉。。。
  1554. InitDataEntity initdataentity = ((MainFragmentActivity) getActivity()).getInitDataEntity();
  1555. UdpSendUtil.sendToBedDeleteCallListItem(udpEntity, initdataentity, headMachineID);
  1556. if (((MyApplication) getActivity().getApplication()).callEntityList.contains(udpEntity)) {
  1557. LogUtil.d("sendTransferForSon", "-----1111----" + udpEntity.toString());
  1558. if (null != loopingUdpentity && loopingUdpentity.equals(udpEntity)) {// Waderson 20180305
  1559. if (null != loopVoice) {
  1560. loopVoice.setPalyDismiss(true);
  1561. }
  1562. } else {
  1563. if (PalyPhonetics.speakEntityList.contains(udpEntity)) {//将播报列表也删除该元素
  1564. LogUtil.d("sendTransferForSon", "-----2222----");
  1565. PalyPhonetics.speakEntityList.remove(udpEntity);
  1566. }
  1567. }
  1568. MyApplication.callEntityList.remove(udpEntity);
  1569. endCallNotifi(udpEntity);
  1570. sendNoAnyRequestDoor(udpEntity);
  1571. sendCallWaitingNumber(MyApplication.callEntityList.size());
  1572. callListAdapter.notifyDataSetChanged();
  1573. roomAdapter.notifyDataSetChanged();
  1574. if (!StringUtils.listNotEmpty(((MyApplication) getActivity().getApplication()).callEntityList)) {
  1575. setPowerLed("1");
  1576. }
  1577. }
  1578. }
  1579. }
  1580. }
  1581. /**
  1582. * 子机转接子机成功后,告诉外面执行状态联动
  1583. */
  1584. private void transferBedToBed(UdpEntity udpEntity) {
  1585. ArrayList<UdpEntity> callEntityList = MyApplication.callEntityList;
  1586. if (StringUtils.listNotEmpty(callEntityList)) {
  1587. for (int i = 0; i < callEntityList.size(); i++) {
  1588. if (callEntityList.get(i).getSipAddress().equals(udpEntity.getSipAddress()) && callEntityList.get(i).getNurseHostID().equals(udpEntity.getNurseHostID())) {
  1589. if (null != loopingUdpentity && loopingUdpentity.equals(callEntityList.get(i))) {
  1590. if (null != loopVoice) {
  1591. loopVoice.setPalyDismiss(true);
  1592. }
  1593. } else {
  1594. if (PalyPhonetics.speakEntityList.contains(callEntityList.get(i))) {//将播报列表也删除该元素
  1595. PalyPhonetics.speakEntityList.remove(udpEntity);
  1596. }
  1597. }
  1598. endCallNotifi(callEntityList.get(i));
  1599. sendNoAnyRequestDoor(callEntityList.get(i));
  1600. MyApplication.callEntityList.remove(callEntityList.get(i));
  1601. }
  1602. }
  1603. sendCallWaitingNumber(MyApplication.callEntityList.size());
  1604. callListAdapter.notifyDataSetChanged();
  1605. roomAdapter.notifyDataSetChanged();
  1606. if (!StringUtils.listNotEmpty(MyApplication.callEntityList)) {
  1607. setPowerLed("1");
  1608. }
  1609. }
  1610. }
  1611. /**
  1612. * 护士主机通知门口机当前房间无任何请求,请将门灯变白,筛选操作
  1613. */
  1614. private void sendNoAnyRequestDoor(UdpEntity deleteEntity) {
  1615. ArrayList<UdpEntity> callEntityList = MyApplication.callEntityList;
  1616. boolean haveThisRoomEntity = false;
  1617. String deleteRoomNumber = deleteEntity.getRoomNumber();
  1618. if (callEntityList.size() > 0) {
  1619. for (int i = 0; i < callEntityList.size(); i++) {
  1620. if (callEntityList.get(i).getRoomNumber().equals(deleteRoomNumber)) {
  1621. haveThisRoomEntity = true;
  1622. break;
  1623. }
  1624. }
  1625. } else {
  1626. haveThisRoomEntity = false;
  1627. }
  1628. if (!haveThisRoomEntity) {
  1629. InitDataEntity initdataentity = ((MainFragmentActivity) getActivity()).getInitDataEntity();
  1630. UdpSendUtil.sendNotificationDoorLightWhite(initdataentity, deleteEntity);
  1631. }
  1632. }
  1633. /**
  1634. * 护士主机告诉子机当前有多少条呼叫等待
  1635. */
  1636. private void sendCallWaitingNumber(int number) {
  1637. InitDataEntity initdataentity = ((MainFragmentActivity) getActivity()).getInitDataEntity();
  1638. UdpSendUtil.sendCallWaitingNumber(initdataentity, number);
  1639. }
  1640. /**
  1641. * 按照优先等级进行排序(waderson 20171031)
  1642. */
  1643. private void sortList() {
  1644. ArrayList<UdpEntity> callList = ((MyApplication) getActivity().getApplication()).callEntityList;
  1645. if (null != callList && callList.size() > 1) {
  1646. ArrayList<UdpEntity> wcList = new ArrayList<>();
  1647. ArrayList<UdpEntity> supportList = new ArrayList<>();
  1648. ArrayList<UdpEntity> bedList = new ArrayList<>();
  1649. ArrayList<UdpEntity> traditionBedList = new ArrayList<>();
  1650. ArrayList<UdpEntity> mainList = new ArrayList<>();
  1651. ArrayList<UdpEntity> doorList = new ArrayList<>();
  1652. for (int i = 0; i < callList.size(); i++) {
  1653. //type :1门口机 2主机 3 子机 4卫生间 优先等级依次升高
  1654. if (Constants.WSHROOM_CALL.equals(callList.get(i).getType())) {
  1655. wcList.add(callList.get(i));
  1656. } else if (Constants.ROOMHELP_CALL.equals(callList.get(i).getType())) {
  1657. supportList.add(callList.get(i));
  1658. } else if (Constants.SON_CALL.equals(callList.get(i).getType())) {
  1659. bedList.add(callList.get(i));
  1660. } else if (Constants.TRADITION_CALL.equals(callList.get(i).getType())) {
  1661. traditionBedList.add(callList.get(i));
  1662. } else if (Constants.MAIN_CALL.equals(callList.get(i).getType())) {
  1663. mainList.add(callList.get(i));
  1664. } else if (DOOR_CALL.equals(callList.get(i).getType())) {
  1665. doorList.add(callList.get(i));
  1666. }
  1667. }
  1668. if (wcList.size() > 1) {
  1669. ListComparatorUtil.sort(wcList);
  1670. }
  1671. if (supportList.size() > 1) {
  1672. ListComparatorUtil.sort(supportList);
  1673. }
  1674. if (bedList.size() > 1) {
  1675. ListComparatorUtil.sort(bedList);
  1676. }
  1677. if (traditionBedList.size() > 1) {
  1678. ListComparatorUtil.sort(traditionBedList);
  1679. }
  1680. if (mainList.size() > 1) {
  1681. ListComparatorUtil.sort(mainList);
  1682. }
  1683. if (doorList.size() > 1) {
  1684. ListComparatorUtil.sort(doorList);
  1685. }
  1686. callList.clear();
  1687. callList.addAll(wcList);
  1688. callList.addAll(supportList);
  1689. callList.addAll(bedList);
  1690. callList.addAll(traditionBedList);
  1691. callList.addAll(mainList);
  1692. callList.addAll(doorList);
  1693. ((MyApplication) getActivity().getApplication()).callEntityList = callList;
  1694. wcList = supportList = bedList = traditionBedList = mainList = doorList = null;
  1695. }
  1696. }
  1697. /**
  1698. * 语音轮播
  1699. */
  1700. PalyPhonetics loopVoice;
  1701. /**
  1702. * 语音轮播的当前实体
  1703. */
  1704. UdpEntity loopingUdpentity;
  1705. /**
  1706. * 播放语音(waderson 20171031)
  1707. */
  1708. private void palyPhonetics() {
  1709. if (null != PalyPhonetics.speakEntityList && PalyPhonetics.speakEntityList.size() > 0) {
  1710. String voiceBroadcastType = SharedPreferencesUtil.getStringSp(getActivity(), Constants.MSG_SP, Constants.VOICE_BROADCAST_TAG);
  1711. if ("2".equals(voiceBroadcastType)) {
  1712. return;
  1713. }
  1714. if (!Constants.volumePAStatus) {
  1715. setVolumePA(true);
  1716. }
  1717. if (null == loopVoice) {
  1718. loopVoice = PalyPhonetics.getInstance(getActivity());
  1719. }
  1720. if (!Constants.CALL_STATE.equals(Constants.IN_CALLING)) {
  1721. loopVoice.setVolumes(1.0f);
  1722. }
  1723. loopVoice.setPalyDismiss(false);
  1724. loopVoice.setLooping(speakLooping);
  1725. loopingUdpentity = PalyPhonetics.speakEntityList.get(0);
  1726. ArrayList<Integer> resIdlist = new ArrayList<>();
  1727. resIdlist.clear();
  1728. String type = loopingUdpentity.getType();
  1729. String rnb = loopingUdpentity.getRoomNumber();
  1730. String bnb = loopingUdpentity.getBedNumber();
  1731. boolean haveVip = false;
  1732. if (StringUtils.isHaveStr(bnb, "-")) {// add by waderson 20191212
  1733. String b1 = bnb.substring(0, bnb.indexOf("-"));//前
  1734. bnb = bnb.substring(bnb.indexOf("-") + 1);//后
  1735. haveVip = true;
  1736. }
  1737. String roomnumber = PalyPhonetics.changeNumType(rnb, false);
  1738. String bednumber = PalyPhonetics.changeNumType(bnb, false);
  1739. switch (type) {
  1740. case DOOR_CALL: //门口机
  1741. ArrayList<String> list_str1 = StringUtils.substringBySing(roomnumber);
  1742. if (null != list_str1) {
  1743. for (String s : list_str1) {
  1744. resIdlist.add(PalyPhonetics.getResIdInt(s));
  1745. }
  1746. resIdlist.add(R.raw.fang);
  1747. resIdlist.add(R.raw.menkoji);
  1748. resIdlist.add(R.raw.hujiao);
  1749. }
  1750. break;
  1751. case Constants.MAIN_CALL://主机
  1752. ArrayList<String> list_str2 = StringUtils.substringBySing(roomnumber);
  1753. if (null != list_str2) {
  1754. for (String s : list_str2) {
  1755. resIdlist.add(PalyPhonetics.getResIdInt(s));
  1756. }
  1757. resIdlist.add(R.raw.hao);
  1758. resIdlist.add(R.raw.zhujihujiao);
  1759. }
  1760. break;
  1761. case Constants.SON_CALL://床位
  1762. ArrayList<String> list_str3 = StringUtils.substringBySing(roomnumber);
  1763. ArrayList<String> list_str33 = StringUtils.substringBySing(bednumber);
  1764. if (null != list_str3 && "1".equals(voiceBroadcastType)) {//是否要播报“房” 0不要 1要
  1765. for (String s : list_str3) {
  1766. resIdlist.add(PalyPhonetics.getResIdInt(s));
  1767. }
  1768. resIdlist.add(R.raw.fang);
  1769. }
  1770. if (null != list_str33) {
  1771. if (haveVip) {// add by waderson 20191212
  1772. resIdlist.add(R.raw.vip);
  1773. }
  1774. for (String s : list_str33) {
  1775. resIdlist.add(PalyPhonetics.getResIdInt(s));
  1776. }
  1777. resIdlist.add(R.raw.chuang);
  1778. resIdlist.add(R.raw.hujiao);
  1779. }
  1780. break;
  1781. case Constants.TRADITION_CALL://传统床位
  1782. ArrayList<String> list_str6 = StringUtils.substringBySing(roomnumber);
  1783. ArrayList<String> list_str66 = StringUtils.substringBySing(bednumber);
  1784. if ("1".equals(voiceBroadcastType)) {//是否要播报“房” 0不要 1要
  1785. if (StringUtils.listNotEmpty(list_str6)) {
  1786. for (String s : list_str6) {
  1787. resIdlist.add(PalyPhonetics.getResIdInt(s));
  1788. }
  1789. resIdlist.add(R.raw.fang);
  1790. } else {
  1791. if (StringUtils.listNotEmpty(wardInformationList)) {
  1792. for (int i = 0; i < wardInformationList.size(); i++) {
  1793. list_str6 = StringUtils.substringBySing(wardInformationList.get(0).getRoomNum());
  1794. }
  1795. }
  1796. if (StringUtils.listNotEmpty(list_str6)) {
  1797. for (String s : list_str6) {
  1798. resIdlist.add(PalyPhonetics.getResIdInt(s));
  1799. }
  1800. resIdlist.add(R.raw.fang);
  1801. }
  1802. }
  1803. }
  1804. if (StringUtils.listNotEmpty(list_str66)) {
  1805. if (haveVip) {// add by waderson 20191212
  1806. resIdlist.add(R.raw.vip);
  1807. }
  1808. for (String s : list_str66) {
  1809. resIdlist.add(PalyPhonetics.getResIdInt(s));
  1810. }
  1811. resIdlist.add(R.raw.chuang);
  1812. resIdlist.add(R.raw.hujiao);
  1813. }
  1814. break;
  1815. case Constants.ROOMHELP_CALL://请求增援
  1816. ArrayList<String> list_str4 = StringUtils.substringBySing(roomnumber);
  1817. ArrayList<String> list_str44 = StringUtils.substringBySing(bednumber);
  1818. if (null != list_str4 && "1".equals(voiceBroadcastType)) {//是否要播报“房” 0不要 1要
  1819. for (String s : list_str4) {
  1820. resIdlist.add(PalyPhonetics.getResIdInt(s));
  1821. }
  1822. resIdlist.add(R.raw.fang);
  1823. }
  1824. if (null != list_str44) {
  1825. if (haveVip) {// add by waderson 20191212
  1826. resIdlist.add(R.raw.vip);
  1827. }
  1828. for (String s : list_str44) {
  1829. resIdlist.add(PalyPhonetics.getResIdInt(s));
  1830. }
  1831. resIdlist.add(R.raw.chuang);
  1832. }
  1833. resIdlist.add(R.raw.qingqiuzhenyuan);
  1834. break;
  1835. case Constants.WSHROOM_CALL://卫生间
  1836. ArrayList<String> list_str5 = StringUtils.substringBySing(roomnumber);
  1837. if (null != list_str5) {
  1838. for (String s : list_str5) {
  1839. resIdlist.add(PalyPhonetics.getResIdInt(s));
  1840. }
  1841. resIdlist.add(R.raw.fang);
  1842. resIdlist.add(R.raw.weishejian);
  1843. resIdlist.add(R.raw.jinjihujiao);
  1844. }
  1845. break;
  1846. }
  1847. if (null != loopVoice) {
  1848. try {
  1849. loopVoice.speak(resIdlist);
  1850. } catch (InterruptedException e) {
  1851. e.printStackTrace();
  1852. }
  1853. }
  1854. if (PalyPhonetics.speakEntityList.contains(loopingUdpentity)) {
  1855. PalyPhonetics.speakEntityList.remove(loopingUdpentity);
  1856. }
  1857. if (PalyPhonetics.speakEntityList.size() <= 0) {
  1858. setVolumePA(false);//没有语音播报就关闭PA
  1859. }
  1860. }
  1861. }
  1862. public void addPhonetics(UdpEntity udpEntity) {
  1863. startPalyPhonetics();
  1864. PalyPhonetics.speakEntityList.add(udpEntity);
  1865. showUrgentWindow(udpEntity);
  1866. }
  1867. public void startPalyPhonetics() {
  1868. if (null == palyPhoneticsThread) {
  1869. have_Speak = true;
  1870. palyPhoneticsThread = new Thread(new palyPhoneticsRunnable());
  1871. palyPhoneticsThread.start();
  1872. } else if (null != palyPhoneticsThread && !palyPhoneticsThread.isAlive()) {
  1873. have_Speak = true;
  1874. palyPhoneticsThread.start();
  1875. }
  1876. }
  1877. public class palyPhoneticsRunnable implements Runnable {
  1878. public void run() {
  1879. while (have_Speak) {
  1880. palyPhonetics();
  1881. }
  1882. }
  1883. }
  1884. /**
  1885. * 紧急情况弹出的Popupwindow
  1886. */
  1887. UrgentPopupwindow urgentPopupwindow;
  1888. /**
  1889. * 紧急情况弹出的当前实体
  1890. */
  1891. UdpEntity urgentUdpEntity;
  1892. /**
  1893. * 紧急情况弹出window
  1894. */
  1895. public void showUrgentWindow(UdpEntity udpEntity) {
  1896. if (null == udpEntity) {
  1897. return;
  1898. }
  1899. urgentUdpEntity = udpEntity;
  1900. if (null == urgentPopupwindow) {
  1901. urgentPopupwindow = new UrgentPopupwindow(getActivity(), null, UrgentPopupwindow.ATCENTER, true);
  1902. }
  1903. switch (udpEntity.getType()) {
  1904. case Constants.ROOMHELP_CALL:
  1905. urgentPopupwindow.setWindowContentText(udpEntity.getRoomNumber() + "房" + udpEntity.getBedNumber() + "床请求增援!!!").setWindowLogoImg(R.mipmap.ic_support).setOnClickListener(this).show();
  1906. break;
  1907. case Constants.WSHROOM_CALL:
  1908. urgentPopupwindow.setWindowContentText(udpEntity.getRoomNumber() + "房卫生间紧急呼叫!!!").setWindowLogoImg(R.mipmap.ic_wc).setOnClickListener(this).show();
  1909. break;
  1910. }
  1911. }
  1912. private final int GETROOMDATA_ERROR = 2001;
  1913. private final int GETHOSPITALDATA_ERROR = 2002;
  1914. private final int GETSYSSETINGDATA_ERROR = 2003;
  1915. public final int RESET = 5003;
  1916. @SuppressLint("HandlerLeak")
  1917. Handler handler = new Handler() {
  1918. public void handleMessage(Message msg) {
  1919. switch (msg.what) {
  1920. case OUTBUTTONCLICK:
  1921. byte[] buffer = msg.getData().getByteArray(OUTBUTTONCLICK_CONTENT);
  1922. LogUtil.d("OUTBUTTONCLICK", "物理键data==" + buffer[0]);
  1923. //ToastUtil.showToast("物理键data==" + buffer[0]);
  1924. if (buffer[0] == 0) {//按下
  1925. } else {//松开
  1926. currentTime = System.currentTimeMillis();
  1927. if (currentTime - lastClickTime > CLICK_DELAY_TIME) {
  1928. lastClickTime = currentTime;
  1929. if (!filterSipToast()) {
  1930. return;
  1931. }
  1932. if (!handTelephone) {//只有当话筒没有被拿起外部按键才有用
  1933. if (Constants.CALL_STATE.equals(Constants.STANDBY)) {//是空闲状态就拨打电话!
  1934. autoStartCall();
  1935. } else {
  1936. //结束通话将当前呼叫对象语音关闭; 减少由于SIP结束回调的延时而出现重叠(之前是写在SIP结束回调的;在连续狂打电话的情况下效果重叠不行)
  1937. if (null != loopingUdpentity && loopingUdpentity.equals(callingEntity)) {
  1938. loopVoice.setPalyDismiss(true);
  1939. }
  1940. endCall(); //否则就挂断电话!
  1941. }
  1942. }
  1943. } else {
  1944. ToastUtil.showToast("请勿频繁点击!");
  1945. }
  1946. }
  1947. break;
  1948. case SPRINGCLICK:
  1949. int data = msg.getData().getInt(SPRINGCLICK_CONTENT);
  1950. LogUtil.d("SPRINGCLICK", "叉簧开关data==" + data);
  1951. //ToastUtil.showToast("叉簧开关data==" + data);
  1952. if (1 == data) {//放下状态
  1953. Constants.HANDS_FREE = true;
  1954. setHandsFree(true);
  1955. setMIC(true);
  1956. setCallVoice(0);//0为外喇叭 1为 手柄
  1957. if (handTelephone) {
  1958. if (null != loopingUdpentity && loopingUdpentity.equals(callingEntity)) {
  1959. loopVoice.setPalyDismiss(true);
  1960. }
  1961. endCall(); //挂断电话!
  1962. }
  1963. // ivCallPic.setImageResource(R.mipmap.ic_calling_sickbed_right_calling);
  1964. handTelephone = false;
  1965. MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
  1966. }
  1967. if (0 == data) {//拿起状态
  1968. Constants.HANDS_FREE = false;
  1969. setHandsFree(false);
  1970. setMIC(false);
  1971. setCallVoice(1);//0为外喇叭 1为 手柄
  1972. if (!handTelephone) { //拨打电话开始!
  1973. autoStartCall();
  1974. }
  1975. handTelephone = true;
  1976. MainFragmentActivity.initCallVoiceShowProgress();//20190801 waderson
  1977. }
  1978. break;
  1979. case GETROOMDATA_ERROR:
  1980. getRoomData();
  1981. break;
  1982. case GETHOSPITALDATA_ERROR:
  1983. getHospitalData();
  1984. break;
  1985. case GETSYSSETINGDATA_ERROR:
  1986. getSYSsetingData();
  1987. break;
  1988. case RESET:
  1989. Constants.MGR_UPDATE = false;
  1990. break;
  1991. }
  1992. }
  1993. };
  1994. public void setCallVoice(int type) {//0为外喇叭 1为 手柄
  1995. int sb = SharedPreferencesUtil.getIntSp(getActivity(), Constants.MSG_SP, SharedPreferencesUtil.SbCallingVoice);
  1996. int sbing = SharedPreferencesUtil.getIntSp(getActivity(), Constants.MSG_SP, SharedPreferencesUtil.SbingCallingVoice);
  1997. if (0 == type) {
  1998. if (sb < 0) {
  1999. VoiceManagerUtil.setCallVoice(MyApplication.getAppContext(), 90);
  2000. } else {
  2001. VoiceManagerUtil.setCallVoice(MyApplication.getAppContext(), sb);
  2002. }
  2003. }
  2004. if (1 == type) {
  2005. if (sbing < 0) {
  2006. VoiceManagerUtil.setCallVoice(MyApplication.getAppContext(), 90);
  2007. } else {
  2008. VoiceManagerUtil.setCallVoice(MyApplication.getAppContext(), sbing);
  2009. }
  2010. }
  2011. }
  2012. /**
  2013. * 选择呼叫列表的条目并且改变UI
  2014. */
  2015. private void chooseCallItemUI(int position) {
  2016. setPowerLed("1");//用户触碰呼叫列表就让电源灯停止闪 Waderson 20171221
  2017. callingEntity = ((MyApplication) getActivity().getApplication()).callEntityList.get(position);
  2018. CALL_LIST_POSITION = position;
  2019. if (((MyApplication) getActivity().getApplication()).callEntityList.get(position).getType().equals(DOOR_CALL)) {
  2020. if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
  2021. vRightCallListInfo.setVisibility(View.VISIBLE);
  2022. rightCallListInfomation.setVisibility(View.INVISIBLE);
  2023. ivCallListPic.setVisibility(View.VISIBLE);
  2024. vRightPatientInfo.setVisibility(View.GONE);
  2025. vRightCallInfo.setVisibility(View.GONE);
  2026. tvCallListRoomMsg.setText(((MyApplication) getActivity().getApplication()).callEntityList.get(position).getRoomNumber() + "房" + "门口机呼叫...");
  2027. }
  2028. return;
  2029. }
  2030. if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
  2031. vRightCallListInfo.setVisibility(View.VISIBLE);
  2032. rightCallListInfomation.setVisibility(View.VISIBLE);
  2033. ivCallListPic.setVisibility(View.VISIBLE);
  2034. vRightPatientInfo.setVisibility(View.GONE);
  2035. vRightCallInfo.setVisibility(View.GONE);
  2036. }
  2037. setCallListMsg(callingEntity);
  2038. }
  2039. /**
  2040. * 设置呼叫列表的右侧病人个人信息
  2041. **/
  2042. private void setCallListMsg(UdpEntity udpEntity) {
  2043. LogUtil.d(CallingBedFragment.class, "udpEntitytostring==" + udpEntity.toString());
  2044. if (null != udpEntity) {
  2045. tvCallListRoomMsg.setText(udpEntity.getRoomNumber() + "房" + udpEntity.getBedNumber() + "床");
  2046. rightCallInfomationTwo.setText("护理等级:" + udpEntity.getLevel() + "级");
  2047. getPatientData(udpEntity.getHeadMachineID());
  2048. }
  2049. }
  2050. /**
  2051. * 请求数据失败后的清空操作
  2052. */
  2053. private void onErrorClean() {
  2054. tvCallListName.setText("--");
  2055. rightCallInfomation.setText("--");
  2056. rightCallInfomationOne.setText("--");
  2057. rightCallInfomationTwo.setText("--");
  2058. rightCallInfomationThree.setText("--");
  2059. rightCallInfomationFour.setText("--");
  2060. rightCallInfomationFive.setText("--");
  2061. rightCallInfomationSix.setText("--");
  2062. rightCallInfomationEight.setText("--");
  2063. //rightCallInfomationSeven.setText("--");
  2064. }
  2065. /**
  2066. * 自动开始呼叫的筛选操作
  2067. */
  2068. private void autoStartCall() {
  2069. // ===========暂时注掉20180408(Ping网:有时候 网络已经连上 但是ping不通)===============//
  2070. if (!filterSipToast()) {
  2071. return;
  2072. }
  2073. ArrayList<UdpEntity> callEntityList = ((MyApplication) getActivity().getApplication()).callEntityList;
  2074. if (callEntityList.size() > 0) {
  2075. for (int i = 0; i < callEntityList.size(); i++) {
  2076. if (!callEntityList.get(i).getType().equals(Constants.WSHROOM_CALL) && !callEntityList.get(i).getType().equals(Constants.ROOMHELP_CALL)) {
  2077. chooseCallItemUI(i);//拨打一个电话;因为卫生间和请求增援是不能呼叫的
  2078. ivCallPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
  2079. ivCallListPic.setImageResource(R.mipmap.ic_calling_sickbed_right_hang_up);
  2080. startCall(i);
  2081. break;
  2082. }
  2083. }
  2084. }
  2085. }
  2086. /**
  2087. * 开始呼叫
  2088. */
  2089. private void startCall(int position) {
  2090. if (Constants.CALL_STATE.equals(Constants.STANDBY)) {
  2091. String sipAddress = ((MyApplication) getActivity().getApplication()).callEntityList
  2092. .get(position).getSipAddress();
  2093. LogUtil.d("sipAddress", "startCall==sipAddress==" + sipAddress);
  2094. mainFragmentActivity.initiateCall(sipAddress,
  2095. ((MyApplication) getActivity().getApplication()).callEntityList.get(position)
  2096. .getType(), callingEntity.getDeviceMAC());
  2097. }
  2098. }
  2099. /**
  2100. * 结束呼叫
  2101. */
  2102. public void endCall() {
  2103. if (!Constants.CALL_STATE.equals(Constants.STANDBY)) {
  2104. mainFragmentActivity.endCalled();
  2105. }
  2106. }
  2107. /**
  2108. * 安卓端接通电话;通知外面点阵屏;
  2109. * 本来想将这段代码写到Calling()里面的;但固定列表不需要发送;为了保持原有代码的安全性,所以我另外写了这个方法!
  2110. */
  2111. public void callingNotifi(UdpEntity callEntity) {
  2112. InitDataEntity initdataentity = ((MainFragmentActivity) getActivity()).getInitDataEntity();
  2113. if ("call_1".equals(callEntity.getIndexes())) {//床位呼叫
  2114. UdpSendUtil.sendCalling(initdataentity, callEntity, "call_1_calling");
  2115. } else if ("call_2".equals(callEntity.getIndexes())) {//卫生间紧急呼叫
  2116. UdpSendUtil.sendCalling(initdataentity, callEntity, "call_2_calling");
  2117. } else if ("call_4".equals(callEntity.getIndexes())) {//请求增援呼叫
  2118. UdpSendUtil.sendCalling(initdataentity, callEntity, "call_4_calling");
  2119. } else if ("call_6".equals(callEntity.getIndexes())) {//门口机呼叫
  2120. UdpSendUtil.sendCalling(initdataentity, callEntity, "call_6_calling");
  2121. }
  2122. }
  2123. /**
  2124. * 安卓端挂断电话;通知外面点阵屏;
  2125. * 本来想将这段代码写到endCall()里面的;但固定列表不需要发送;为了保持原有代码的安全性,所以我另外写了这个方法!
  2126. */
  2127. public void endCallNotifi(UdpEntity callEntity) {
  2128. InitDataEntity initdataentity = ((MainFragmentActivity) getActivity()).getInitDataEntity();
  2129. if ("call_1".equals(callEntity.getIndexes()) || "call_1_hang_up".equals(callEntity.getIndexes())) {//add by waderson 20191111
  2130. UdpSendUtil.sendRingOff(initdataentity, callEntity, "call_1_ringoff");
  2131. } else if ("call_2".equals(callEntity.getIndexes())) {//卫生间紧急呼叫
  2132. UdpSendUtil.sendRingOff(initdataentity, callEntity, "call_2_ringoff");
  2133. } else if ("call_4".equals(callEntity.getIndexes())) {//请求增援呼叫
  2134. UdpSendUtil.sendRingOff(initdataentity, callEntity, "call_4_ringoff");
  2135. } else if ("call_6".equals(callEntity.getIndexes())) {
  2136. UdpSendUtil.sendRingOff(initdataentity, callEntity, "call_6_ringoff");
  2137. }
  2138. }
  2139. /**
  2140. * 设置免提
  2141. */
  2142. private void setHandsFree(boolean isHandsFree) {
  2143. // LogUtil.d(LogUtil.getTag(null), "是否需要免提==" + isHandsFree);
  2144. if (isHandsFree) {
  2145. if (null != serialPortUtil) {
  2146. serialPortUtil.sendCommand(SerialPortUtil.AUDIO, "0", "F");
  2147. handsFreeStatus = true;
  2148. }
  2149. } else {
  2150. if (null != serialPortUtil) {
  2151. serialPortUtil.sendCommand(SerialPortUtil.AUDIO, "1", "F");
  2152. handsFreeStatus = false;
  2153. }
  2154. }
  2155. }
  2156. /**
  2157. * 设置音频PA
  2158. */
  2159. private void setVolumePA(boolean isVolumePA) {
  2160. if (HAVA_PA) {
  2161. if (isVolumePA) {
  2162. if (null != serialPortUtil) {
  2163. serialPortUtil.sendCommand(SerialPortUtil.AUDIOPA, "1", "F");
  2164. Constants.volumePAStatus = true;
  2165. }
  2166. } else {
  2167. if (null != serialPortUtil) {
  2168. serialPortUtil.sendCommand(SerialPortUtil.AUDIOPA, "0", "F");
  2169. Constants.volumePAStatus = false;
  2170. }
  2171. }
  2172. }
  2173. }
  2174. /**
  2175. * 麦克风切换控制
  2176. */
  2177. private void setMIC(boolean haveMainMIC) {
  2178. if (haveMainMIC) {
  2179. if (null != serialPortUtil) {
  2180. serialPortUtil.sendCommand(SerialPortUtil.MIC, "0", "F");
  2181. isMainMIC = true;
  2182. }
  2183. } else {
  2184. if (null != serialPortUtil) {
  2185. serialPortUtil.sendCommand(SerialPortUtil.MIC, "1", "F");
  2186. isMainMIC = false;
  2187. }
  2188. }
  2189. }
  2190. /**
  2191. * 电源指示灯切换控制<br></>
  2192. * 0:灯灭 1:常亮 2:闪动
  2193. */
  2194. private void setPowerLed(String powerLedType) {
  2195. if ("0".equals(powerLedType) || "1".equals(powerLedType) || "2".equals(powerLedType)) {
  2196. if (null != serialPortUtil) {
  2197. serialPortUtil.sendCommand(SerialPortUtil.POWERLED, powerLedType, "F");
  2198. }
  2199. }
  2200. }
  2201. /**
  2202. * 上滑移除后发UDP通知外面
  2203. */
  2204. private void sendRemoveBack(UdpEntity udpEntity) {
  2205. if (null != udpEntity) {
  2206. InitDataEntity initdataentity = ((MainFragmentActivity) getActivity()).getInitDataEntity();
  2207. UdpSendUtil.sendNotificationRemove(udpEntity, initdataentity);
  2208. }
  2209. }
  2210. public static final long CLICK_DELAY_TIME = 500;
  2211. private long lastClickTime = 0;
  2212. private long currentTime;
  2213. @Override
  2214. public void queuingItemOnclick(View view, int position) {//呼叫记录列表的点击
  2215. //showToast("点击了=="+position);
  2216. }
  2217. public final String OUTBUTTONCLICK_CONTENT = "outbuttonclickcontent";
  2218. public final String SPRINGCLICK_CONTENT = "springclickcontent";
  2219. public final int OUTBUTTONCLICK = 201;
  2220. public final int SPRINGCLICK = 202;
  2221. boolean handTelephone = false;//是否拿起了电话
  2222. boolean handsFreeStatus = true;//是否是免提
  2223. boolean isMainMIC = true;//是否是外部MIC
  2224. @Override
  2225. public void serialPortBedOnclick(byte[] buffer) {
  2226. //按键串口的回调 (Waderson)
  2227. if (Constants.currentFragment != 0) {
  2228. return;
  2229. }
  2230. Message msg = handler.obtainMessage();
  2231. Bundle data = new Bundle();
  2232. data.putByteArray(OUTBUTTONCLICK_CONTENT, buffer);
  2233. msg.setData(data);
  2234. msg.what = OUTBUTTONCLICK;
  2235. handler.sendMessage(msg);
  2236. }
  2237. @Override
  2238. public void forkSpringData(int data) {
  2239. //叉簧开关 的状态(Waderson)
  2240. Message msg = handler.obtainMessage();
  2241. Bundle data_p = new Bundle();
  2242. data_p.putInt(SPRINGCLICK_CONTENT, data);
  2243. msg.setData(data_p);
  2244. msg.what = SPRINGCLICK;
  2245. handler.sendMessage(msg);
  2246. }
  2247. @Override
  2248. public void onRefresh() {
  2249. getHospitalData();
  2250. getRoomData();
  2251. }
  2252. @Override
  2253. protected int getContentLayout() {
  2254. return 0;
  2255. }
  2256. @Override
  2257. public void showInitError() {
  2258. }
  2259. @Override
  2260. public void onDestroy() {
  2261. super.onDestroy();
  2262. ButterKnife.unbind(this);
  2263. }
  2264. @OnClick(R.id.textView2)
  2265. public void a(View view) {
  2266. UdpSendUtil.sendNurseStationState(((MainFragmentActivity) getActivity()).getInitDataEntity(), 0);
  2267. }
  2268. @OnClick(R.id.textView8)
  2269. public void b(View view) {
  2270. UdpSendUtil.sendNurseStationState(((MainFragmentActivity) getActivity()).getInitDataEntity(), 1);
  2271. }
  2272. }