CallingBedFragment.java 119 KB

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