mainLogic.cc 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  1. #pragma once
  2. #include "uart/ProtocolSender.h"
  3. #include "net/NetManager.h"
  4. #include "storage/StoragePreferences.h"
  5. #include "net/net.h"
  6. #include <system/Thread.h>
  7. #include "restclient-cpp/restclient.h"
  8. #include "curl/curl.h"
  9. #include <algorithm>
  10. #include "service/BusinessConfig.h"
  11. #include "core/sip_config.h"
  12. #include "manager/LanguageManager.h"
  13. #include "core/utilities.h"
  14. #include <string>
  15. #include "zkaudio.h"
  16. #include "base/strings.hpp"
  17. #include "base/http_client.h"
  18. #include "os/UpgradeMonitor.h"
  19. #include "core/update_assistant.h"
  20. #include "utils/TimeHelper.h"
  21. #define ETHERNETMANAGER NETMANAGER->getEthernetManager()
  22. #define WIFIMANAGER NETMANAGER->getWifiManager()
  23. /*
  24. *此文件由GUI工具生成
  25. *文件功能:用于处理用户的逻辑相应代码
  26. *功能说明:
  27. *========================onButtonClick_XXXX
  28. 当页面中的按键按下后系统会调用对应的函数,XXX代表GUI工具里面的[ID值]名称,
  29. 如Button1,当返回值为false的时候系统将不再处理这个按键,返回true的时候系统将会继续处理此按键。比如SYS_BACK.
  30. *========================onSlideWindowItemClick_XXXX(int index)
  31. 当页面中存在滑动窗口并且用户点击了滑动窗口的图标后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称,
  32. 如slideWindow1;index 代表按下图标的偏移值
  33. *========================onSeekBarChange_XXXX(int progress)
  34. 当页面中存在滑动条并且用户改变了进度后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称,
  35. 如SeekBar1;progress 代表当前的进度值
  36. *========================ogetListItemCount_XXXX()
  37. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表的总数目,XXX代表GUI工具里面的[ID值]名称,
  38. 如List1;返回值为当前列表的总条数
  39. *========================oobtainListItemData_XXXX(ZKListView::ZKListItem *pListItem, int index)
  40. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表当前条目下的内容信息,XXX代表GUI工具里面的[ID值]名称,
  41. 如List1;pListItem 是贴图中的单条目对象,index是列表总目的偏移量。具体见函数说明
  42. *========================常用接口===============
  43. *LOGD(...) 打印调试信息的接口
  44. *mTextXXXPtr->setText("****") 在控件TextXXX上显示文字****
  45. *mButton1Ptr->setSelected(true); 将控件mButton1设置为选中模式,图片会切换成选中图片,按钮文字会切换为选中后的颜色
  46. *mSeekBarPtr->setProgress(12) 在控件mSeekBar上将进度调整到12
  47. *mListView1Ptr->refreshListView() 让mListView1 重新刷新,当列表数据变化后调用
  48. *mDashbroadView1Ptr->setTargetAngle(120) 在控件mDashbroadView1上指针显示角度调整到120度
  49. *
  50. * 在Eclipse编辑器中 使用 “alt + /” 快捷键可以打开智能提示
  51. */
  52. static bool dataInit = false; // false表示需要从数据库里获取数据,true表示从缓存里获取数据
  53. PartSetting partSetting;
  54. Json::Value frameRoom;
  55. Json::Value frameBedList;
  56. Json::Value frameInfo; // 缓存房间名字等
  57. Json::Value rightTitleInfo; // 缓存分机右边医生和护士标题
  58. Json::Value painterInfo;
  59. Json::Value painterInfoList;
  60. static bool serverInfo = true; // 判断是否需要从服务器获取服务器信息,第一次要,后续不要
  61. static int inBedCount = 0;
  62. static int emptyBedCount = 0;
  63. static int mainThemeInt = StoragePreferences::getInt(STORE_THEME, defaultThemeInt);
  64. static int mainModeInt = StoragePreferences::getInt(STORE_MODE, defaultModeInt);
  65. #define HELP_TIMER_HANDLE 3 // 增援的定时器id
  66. #define EVENT_TIME_HANDLE 8 // 事件定时器
  67. #define SLEEP_STRAT_TIME_HANDLE 9 // 息屏
  68. void setMainTheme() {
  69. LOGD("mainThemeInt =====> %d", mainThemeInt);
  70. if (mainThemeInt == 1) {
  71. mRoomPainterPtr->setBackgroundPic("/main/fang-bg.png");
  72. mRoomPrcPainterPtr->setBackgroundPic("/main/fang.png");
  73. mInBedNumTextViewPtr->setTextColor(buleDeepColour);
  74. mInBedPicPainterPtr->setBackgroundPic("/main/chuang-l.png");
  75. }
  76. else if (mainThemeInt == 2) {
  77. mRoomPainterPtr->setBackgroundPic("/main/fang-bg-pink.png");
  78. mRoomPrcPainterPtr->setBackgroundPic("/main/fang-pink.png");
  79. mInBedNumTextViewPtr->setTextColor(redDeepColour);
  80. mInBedPicPainterPtr->setBackgroundPic("/main/chuang-l-pink.png");
  81. }
  82. }
  83. void setMainMode() {
  84. if (mainModeInt == 3) {
  85. mDirectorPainterPtr->setVisible(true);
  86. mDirectLinePainterPtr->setVisible(true);
  87. mDirectorTitleTextViewPtr->setVisible(true);
  88. mDirectorTextViewPtr->setVisible(true);
  89. mNurseHeadPainterPtr->setVisible(true);
  90. mNurseHeadLinePainterPtr->setVisible(true);
  91. mNurseTitleTextViewPtr->setVisible(true);
  92. mNurseHeadTextViewPtr->setVisible(true);
  93. }
  94. }
  95. static void getServerInfo(){
  96. string url = getHttpGateway() + "/ncs_url/server_info";
  97. LOGD("请求服务器信息. url = %s", url.c_str());
  98. //发起HTTP GET请求
  99. RestClient::Response r = RestClient::get(url);
  100. //解析json
  101. Json::Reader reader;
  102. Json::Value root;
  103. if (reader.parse(r.body, root, false)){
  104. // http
  105. StoragePreferences::putString(STORE_GATEWAY, root["http_local_ip"].asString());
  106. StoragePreferences::putInt(STORE_HTTP_PORT, root["http_port"].asInt());
  107. // tcp
  108. StoragePreferences::putString(STORE_TCP_LOCAL_IP, root["tcp_local_ip"].asString());
  109. StoragePreferences::putInt(STORE_TCP_PORT, root["tcp_port"].asInt());
  110. // sip
  111. StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString());
  112. StoragePreferences::putInt(SIP_REG_PORT, root["sip_port"].asInt());
  113. serverInfo = false; // 只有请求成功了,才不需要重复请求
  114. }
  115. }
  116. // 读取空间缓存的数据
  117. static void getFrameInfo() {
  118. mRoomNameTextViewPtr->setText(frameInfo["full_name"].asString());
  119. }
  120. static void getBedCount() {
  121. if (mActivityPtr == NULL) {
  122. return;
  123. }
  124. mInBedNumTextViewPtr->setText(inBedCount);
  125. mEmptyBedNumTextViewPtr->setText(emptyBedCount);
  126. }
  127. static void getFrameRoom(int frame_id) {
  128. string url = getHttpGateway() + "/deviceRoom/get_frame_room/" + to_string(frame_id);
  129. LOGD("请求房间信息. url = %s", url.c_str());
  130. //发起HTTP GET请求
  131. RestClient::Response r = RestClient::get(url);
  132. LOGD("获得房间信息. result = %s", r.body.c_str());
  133. //解析json
  134. Json::Reader reader;
  135. Json::Value root;
  136. if (reader.parse(r.body, root, false)){
  137. frameRoom = root;
  138. frameBedList = root["frame_bed_list"];
  139. inBedCount = 0;
  140. emptyBedCount = 0;
  141. if (frameBedList.size() > 0) {
  142. for (int i = 0; i < frameBedList.size(); i++) {
  143. string customerId = frameBedList[i]["customer_id"].asString();
  144. if (customerId != "") {
  145. inBedCount += 1;
  146. }
  147. }
  148. emptyBedCount = frameBedList.size() - inBedCount;
  149. getBedCount();
  150. }
  151. if (mBedListViewPtr != NULL) {
  152. if (mainModeInt == 1) {
  153. mBedListViewPtr->refreshListView();
  154. }
  155. else if (mainModeInt == 2) {
  156. if (frameBedList.size() <= 3) {
  157. mBedListViewPtr->refreshListView();
  158. mBedListViewPtr->setVisible(true);
  159. mBedListView2Ptr->setVisible(false);
  160. mBedListView3Ptr->setVisible(false);
  161. }
  162. else if (frameBedList.size() > 3 && frameBedList.size() <= 6) {
  163. mBedListView2Ptr->refreshListView();
  164. mBedListViewPtr->setVisible(false);
  165. mBedListView2Ptr->setVisible(true);
  166. mBedListView3Ptr->setVisible(false);
  167. }
  168. else {
  169. mBedListView3Ptr->refreshListView();
  170. mBedListViewPtr->setVisible(false);
  171. mBedListView2Ptr->setVisible(false);
  172. mBedListView3Ptr->setVisible(true);
  173. }
  174. }
  175. else if (mainModeInt == 3) {
  176. mBedListView4Ptr->refreshListView();
  177. mBedListViewPtr->setVisible(false);
  178. mBedListView4Ptr->setVisible(true);
  179. }
  180. }
  181. }
  182. }
  183. // 将医生和护士别称缓存起来
  184. static void setRightTitle(Json::Value partSetting) {
  185. rightTitleInfo["doctor_title"] = partSetting["doctor_title"].asString();
  186. rightTitleInfo["doctor_valid"] = partSetting["doctor_valid"].asInt();
  187. rightTitleInfo["nurse_title"] = partSetting["nurse_title"].asString();
  188. rightTitleInfo["nurse_valid"] = partSetting["nurse_valid"].asInt();
  189. }
  190. static void setDirectorAndHeadNurse() {
  191. mDirectorTextViewPtr->setText(partSetting.partDirector);
  192. mNurseHeadTextViewPtr->setText(partSetting.partNurseHead);
  193. }
  194. static void getPartSetting(string partId){
  195. string url = getHttpGateway() + "/deviceBed/getPartSetting/" + partId;
  196. LOGD("请求科室信息. url = %s", url.c_str());
  197. //发起HTTP GET请求
  198. RestClient::Response r = RestClient::get(url);
  199. LOGD("获得科室信息. result = %s", r.body.c_str());
  200. //解析json
  201. Json::Reader reader;
  202. Json::Value root;
  203. if (reader.parse(r.body, root, false)){
  204. partSetting.partId = root["part_id"].asInt();
  205. partSetting.dayStart = root["day_start"].asString();
  206. partSetting.dayLight = root["day_light"].asInt();
  207. partSetting.dayVol = root["day_vol"].asInt();
  208. partSetting.dayRingVol = root["day_ring_vol"].asInt();
  209. partSetting.dayRingTimes = root["day_ring_times"].asInt();
  210. partSetting.dayNurseLed = root["day_nurse_led"].asInt();
  211. partSetting.dayDoorVol = root["day_door_vol"].asInt();
  212. partSetting.dayBedVol = root["day_bed_vol"].asInt();
  213. partSetting.dayTransferBoxVol = root["day_transfer_box_vol"].asInt();
  214. partSetting.dayTransferBoxSystemVol = root["day_transfer_box_system_vol"].asInt();
  215. partSetting.nightStart = root["night_start"].asString();
  216. partSetting.nightLight = root["night_light"].asInt();
  217. partSetting.nightVol = root["night_vol"].asInt();
  218. partSetting.nightRingVol = root["night_ring_vol"].asInt();
  219. partSetting.nightRingTimes = root["night_ring_times"].asInt();
  220. partSetting.nightNurseLed = root["night_nurse_led"].asInt();
  221. partSetting.nightDoorVol = root["night_door_vol"].asInt();
  222. partSetting.nightBedVol = root["night_bed_vol"].asInt();
  223. partSetting.nightTransferBoxVol = root["night_transfer_box_vol"].asInt();
  224. partSetting.nightTransferBoxSystemVol = root["night_transfer_box_system_vol"].asInt();
  225. partSetting.sleepSecondsNurse = root["sleep_seconds_nurse"].asInt();
  226. partSetting.sleepSecondsDoor = root["sleep_seconds_door"].asInt();
  227. partSetting.sleepSecondsBed = root["sleep_seconds_bed"].asInt();
  228. partSetting.sipOvertime = root["sip_overtime"].asInt();
  229. partSetting.transferDuration = root["transfer_duration"].asInt();
  230. partSetting.transferDurationLeader = root["transfer_duration_leader"].asInt();
  231. partSetting.communicationModeBed = root["communication_mode_bed"].asInt();
  232. partSetting.communicationModeNurse = root["communication_mode_nurse"].asInt();
  233. partSetting.communicationModeMobile = root["communication_model_mobile"].asInt();
  234. partSetting.customizeRoleCallFirst = root["customize_role_call_first"].asInt();
  235. partSetting.customizeRoleCallSecond = root["customize_role_call_second"].asInt();
  236. partSetting.customizeRoleCallThird = root["customize_role_call_third"].asInt();
  237. partSetting.customizeRoleCallFourth = root["customize_role_call_fourth"].asInt();
  238. partSetting.customizeRoleCallFifth = root["customize_role_call_fifth"].asInt();
  239. partSetting.customizeHospitalCallFirst = root["customize_hospital_call_first"].asInt();
  240. partSetting.customizeHospitalCallFirstName = root["customize_hospital_call_first_name"].asString();
  241. partSetting.customizeHospitalCallSecond = root["customize_hospital_call_second"].asInt();
  242. partSetting.customizeHospitalCallSecondName = root["customize_hospital_second_name"].asString();
  243. partSetting.customizeHospitalCallThird = root["customize_hospital_call_third"].asInt();
  244. partSetting.customizeHospitalCallThirdName = root["customize_hospital_call_third_name"].asString();
  245. partSetting.doctorTitle = root["doctor_title"].asString();
  246. partSetting.doctorValid = root["doctor_valid"].asInt();
  247. partSetting.nurseTitle = root["nurse_title"].asString();
  248. partSetting.nurseValid = root["nurse_valid"].asInt();
  249. partSetting.doorNurseTitle = root["door_nurse_title"].asString();
  250. partSetting.doorNurseValid = root["door_nurse_valid"].asInt();
  251. partSetting.doorNursingTitle = root["door_nursing_title"].asString();
  252. partSetting.doorNursingValid = root["door_nursing_valid"].asInt();
  253. partSetting.partDirector = root["part_director"].asString();
  254. partSetting.partNurseHead = root["part_nurse_head"].asString();
  255. partSetting.upSeconds = root["up_seconds"].asInt();
  256. partSetting.autoAccept = root["auto_accept"].asInt();
  257. partSetting.eventForward = root["event_forward"].asInt();
  258. partSetting.nursingColorRgb = root["nursing_color_rgb"].asString();
  259. partSetting.twoColorDoorLightValid = root["two_color_door_light_valid"].asInt();
  260. partSetting.qrUrl = root["qr_url"].asString();
  261. partSetting.screenLight = root["screen_light"].asInt();
  262. partSetting.roomCallBed = root["room_call_bed"].asInt();
  263. partSetting.autoPosition = root["auto_position"].asInt();
  264. partSetting.customerAgeHiddenOnDoor = root["customer_age_hidden_on_door"].asInt();
  265. if (root.isMember("linux_bed_volume_native")) {
  266. partSetting.linuxDoorVolumeNative = root["linux_door_volume_native"].asInt();
  267. partSetting.linuxDoorGainSize = root["linux_door_gain_size"].asInt();
  268. zk_audio_input_set_volume_native(0, 0);
  269. zk_audio_input_set_volume_native(1, partSetting.linuxDoorVolumeNative);
  270. GetTelephone()->SetInputPcmGainSize(partSetting.linuxDoorGainSize);
  271. StoragePreferences::putInt(STORE_VOLUME_NATIVE, partSetting.linuxDoorVolumeNative);
  272. StoragePreferences::putInt(STORE_GAIN_SIZE, partSetting.linuxDoorGainSize);
  273. }
  274. StoragePreferences::putString(STORE_DAY_START, partSetting.dayStart);
  275. StoragePreferences::putInt(STORE_DAY_LIGHT,partSetting.dayLight);
  276. StoragePreferences::putInt(STORE_DAY_VOL,partSetting.dayDoorVol);
  277. StoragePreferences::putInt(STORE_DAY_RING_TIMES,partSetting.dayRingTimes);
  278. StoragePreferences::putString(STORE_NIGHT_START, partSetting.nightStart);
  279. StoragePreferences::putInt(STORE_NIGHT_LIGHT,partSetting.nightLight);
  280. StoragePreferences::putInt(STORE_NIGHT_VOL,partSetting.nightDoorVol);
  281. StoragePreferences::putInt(STORE_NIGHT_RING_TIMES,partSetting.nightRingTimes);
  282. StoragePreferences::putInt(STORE_SLEEP_TIME, partSetting.sleepSecondsDoor);
  283. StoragePreferences::putString(STORE_DOCTOR_TITLE, partSetting.doctorTitle);
  284. StoragePreferences::putBool(STORE_DOCTOR_VISIBLE, partSetting.doctorValid==1);
  285. StoragePreferences::putString(STORE_NURSE_TITLE, partSetting.nurseTitle);
  286. StoragePreferences::putBool(STORE_NURSE_VISIBLE, partSetting.nurseValid==1);
  287. StoragePreferences::putString(STORE_NURSING_COLOR_RGB, partSetting.nursingColorRgb);
  288. StoragePreferences::putBool(STORE_AUDO_ANSWER, partSetting.autoAccept==1);
  289. StoragePreferences::putInt(STORE_SCREEN_LIGHT, partSetting.screenLight);
  290. StoragePreferences::putInt(STORE_ROOM_CALL_BED, partSetting.roomCallBed);
  291. StoragePreferences::putInt(STORE_AUTO_POSITION, partSetting.autoPosition);
  292. setRightTitle(root);
  293. // callBedButtonSetVisible();
  294. setDirectorAndHeadNurse();
  295. getFrameRoom(frameInfo["frame_id"].asInt());
  296. dataInit = true;
  297. }
  298. }
  299. static void getVersion() {
  300. std::string url = getHttpGateway() + "/deviceRoom/get_app_version?device_type=303&part_id=" + StoragePreferences::getString(STORE_PARTID, "");
  301. std::string content_type = std::string("application/json");
  302. LOGD("请求版本信息. url = %s", url.c_str());
  303. //发起HTTP POST请求
  304. RestClient::Response r = RestClient::post(url, content_type, "");
  305. if (r.code != 200) {
  306. LOGD("请求版本信息-> 错误代码: %d", r.code);
  307. return;
  308. }
  309. LOGD("获得版本信息. result = %s", r.body.c_str());
  310. //解析json
  311. Json::Reader reader;
  312. Json::Value root;
  313. if(reader.parse(r.body, root, false)) {
  314. int currentVersionNo = getVersionNo();
  315. int responseVersionNo = root["version_no"].asInt();
  316. std::string responseVersion = root["version_code"].asString();
  317. LOGD("服务器版本 : %s %d, 当前设备版本: %d", responseVersion.c_str(), responseVersionNo, currentVersionNo);
  318. if (currentVersionNo < responseVersionNo) {
  319. Intent* intent = new Intent();
  320. intent->putExtra(appUpdate, "true");
  321. EASYUICONTEXT->openActivity("updateActivity", intent);
  322. }
  323. }
  324. }
  325. static void getNfcInteraction() {
  326. std::string url = getHttpGateway() + "/deviceRoom/get_nfc_interaction_end_time_is_null/" + to_string(StoragePreferences::getInt(STORE_DEVICE_ID,0));
  327. LOGD("请求未完成的nfc记录. url = %s", url.c_str());
  328. //发起HTTP POST请求
  329. RestClient::Response r = RestClient::get(url);
  330. if (r.code != 200) {
  331. LOGD("请求未完成的nfc记录-> 错误代码: %d", r.code);
  332. return;
  333. }
  334. LOGD("获得未完成的nfc记录. result = %s", r.body.c_str());
  335. //解析json
  336. Json::Reader reader;
  337. Json::Value root;
  338. if(reader.parse(r.body, root, false)) {
  339. int clerkId = 0;
  340. for (int i = 0; i < root.size(); i++) {
  341. if (root[i]["components_type"].asCString() == TcpType::AUTH) {
  342. clerkId = root[i]["clerk_id"].asInt();
  343. setClerk(root[i]["clerk_name"].asCString(), root[i]["pass_no"].asCString(), root[i]["id"].asInt());
  344. }
  345. else if (root[i]["components_type"].asString() == "POSITION_COMPONENT") {
  346. setPosistionItId(root[i]["id"].asInt());
  347. setPositionButton(true);
  348. }
  349. else if (root[i]["components_type"].asString() == "ROOMCHECK_COMPONENT") {
  350. setRoomCheckItId(root[i]["id"].asInt());
  351. setRoomPatrolButton(true);
  352. }
  353. else if (root[i]["components_type"].asString() == "SCREEN_TIP_SET_COMPONENT") {
  354. time_t now = TimeHelper::getDateline();
  355. if (now <= 0) {
  356. continue;
  357. }
  358. Json::Reader Reader;
  359. Json::Value operationData;
  360. Reader.parse(root[i]["operation_data"].asString(), operationData);
  361. int seconds = operationData["seconds"].asInt();
  362. if (now - root[i]["start_time"].asInt() < seconds) {
  363. setPromptTimeItId(root[i]["id"].asInt());
  364. Intent* intent = new Intent();
  365. intent->putExtra(promptText2, operationData["tips"].asString());
  366. intent->putExtra(promptTime2, to_string(seconds - (now - root[i]["start_time"].asInt())));
  367. EASYUICONTEXT->openActivity("promptActivity", intent);
  368. }
  369. else {
  370. sendPromptQuit(root[i]["id"].asInt());
  371. }
  372. }
  373. }
  374. if (clerkId != 0) {
  375. goCare();
  376. }
  377. }
  378. }
  379. static void getDeviceInfo(){
  380. if (dataInit){
  381. getFrameInfo();
  382. getBedCount();
  383. setDirectorAndHeadNurse();
  384. return;
  385. }
  386. string url = getHttpGateway() + "/deviceRoom/get_device_by_eth_mac/" + StoragePreferences::getString(STORE_MAC_ADDR, "0.0.0.0");
  387. LOGD("请求设备信息. url = %s", url.c_str());
  388. //发起HTTP GET请求
  389. RestClient::Response r = RestClient::get(url);
  390. LOGD("获得设备信息. result = %s", r.body.c_str());
  391. //解析json
  392. Json::Reader reader;
  393. Json::Value root;
  394. if (reader.parse(r.body, root, false)){
  395. string partName = root["part_display"].asString();
  396. StoragePreferences::putString(STORE_PARTNAME,partName);
  397. NavibarSetPartName(partName);
  398. //设备
  399. StoragePreferences::putInt(STORE_DEVICE_ID, root["id"].asInt());
  400. StoragePreferences::putInt(STORE_DEVICE_TYPE, root["device_type"].asInt());
  401. //SIP存储
  402. // StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString()); // 应该去找配置文件里的sip-ip
  403. StoragePreferences::putString(SIP_REG_ACCOUNT,root["sip_id"].asString());
  404. StoragePreferences::putString(SIP_REG_PASSWORD, root["sip_password"].asString());
  405. frameInfo["frame_id"] = root["frame_id"].asInt();
  406. frameInfo["full_name"] = root["full_name"].asString();
  407. frameInfo["part_id"] = root["part_id"].asInt();
  408. getFrameInfo();
  409. //获取科室设置
  410. string partId = root["part_id"].asString();
  411. StoragePreferences::putString(STORE_PARTID, partId);
  412. getPartSetting(partId);
  413. getVersion();
  414. getNfcInteraction();
  415. }
  416. }
  417. Json::Value getFrame() {
  418. return frameRoom;
  419. }
  420. // 收到tcp的时候,刷新数据
  421. void dataRefresh() {
  422. LOGD("DATA-REFRESH, 数据刷新");
  423. if (mActivityPtr == NULL) {
  424. return;
  425. }
  426. if (serverInfo) {
  427. getServerInfo();
  428. }
  429. dataInit = false;
  430. getDeviceInfo();
  431. mBedListViewPtr->refreshListView();
  432. }
  433. void getPartSetting() {
  434. getPartSetting(StoragePreferences::getString(STORE_PARTID, ""));
  435. }
  436. /**
  437. * 注册定时器
  438. * 填充数组用于注册定时器
  439. * 注意:id不能重复
  440. */
  441. static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
  442. //{0, 6000}, //定时器id=0, 时间间隔6秒
  443. //{1, 1000},
  444. };
  445. /**
  446. * 当界面构造时触发
  447. */
  448. static void onUI_init(){
  449. //run("this is thread name");
  450. //测试用
  451. LOGD("进入mainLogic页面, 触发 onUI_init");
  452. if (ETHERNETMANAGER->isConnected() || WIFIMANAGER->isConnected()) {
  453. if(serverInfo) { // 如果是false,就是不需要
  454. getServerInfo();
  455. }
  456. getDeviceInfo();
  457. }
  458. setMainMode();
  459. }
  460. /**
  461. * 当切换到该界面时触发
  462. */
  463. static void onUI_intent(const Intent *intentPtr) {
  464. if (intentPtr != NULL) {
  465. }
  466. }
  467. /*
  468. * 当界面显示时触发
  469. */
  470. static void onUI_show() {
  471. EASYUICONTEXT->showStatusBar();
  472. EASYUICONTEXT->showNaviBar();
  473. setMainTheme();
  474. }
  475. /*
  476. * 当界面隐藏时触发
  477. */
  478. static void onUI_hide() {
  479. }
  480. /*
  481. * 当界面完全退出时触发
  482. */
  483. static void onUI_quit() {
  484. //pthread_exit(NULL);
  485. }
  486. /**
  487. * 串口数据回调接口
  488. */
  489. static void onProtocolDataUpdate(const SProtocolData &data) {
  490. }
  491. /**
  492. * 定时器触发函数
  493. * 不建议在此函数中写耗时操作,否则将影响UI刷新
  494. * 参数: id
  495. * 当前所触发定时器的id,与注册时的id相同
  496. * 返回值: true
  497. * 继续运行当前定时器
  498. * false
  499. * 停止运行当前定时器
  500. */
  501. static bool onUI_Timer(int id){
  502. switch (id) {
  503. default:
  504. break;
  505. }
  506. return true;
  507. }
  508. /**
  509. * 有新的触摸事件时触发
  510. * 参数:ev
  511. * 新的触摸事件
  512. * 返回值:true
  513. * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上
  514. * false
  515. * 触摸事件将继续传递到控件上
  516. */
  517. static bool onmainActivityTouchEvent(const MotionEvent &ev) {
  518. switch (ev.mActionStatus) {
  519. case MotionEvent::E_ACTION_DOWN://触摸按下
  520. //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY);
  521. break;
  522. case MotionEvent::E_ACTION_MOVE://触摸滑动
  523. break;
  524. case MotionEvent::E_ACTION_UP: //触摸抬起
  525. break;
  526. default:
  527. break;
  528. }
  529. return false;
  530. }
  531. static int getListItemCount_BedListView(const ZKListView *pListView) {
  532. //LOGD("getListItemCount_BedListView !\n");
  533. return frameBedList.size();
  534. }
  535. static void obtainListItemData_BedListView(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
  536. //LOGD(" obtainListItemData_ BedListView !!!\n");
  537. if (frameBedList.size() > 0) {
  538. ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem);
  539. ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem);
  540. ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem);
  541. ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem);
  542. ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitileSubItem);
  543. ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem);
  544. ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem);
  545. ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem);
  546. if (mainModeInt == 2) {
  547. if (frameBedList.size() > 3) {
  548. return;
  549. }
  550. }
  551. if (mainThemeInt == 1) {
  552. bedNum->setBackgroundPic("/9/chuanghao_bg.9.png");
  553. }
  554. else if (mainThemeInt == 2) {
  555. bedNum->setBackgroundPic("/9/chuanghao_bg_pink.9.png");
  556. }
  557. string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
  558. if (frameBedName == "") {
  559. bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
  560. } else {
  561. int nPos = frameBedName.find("-");
  562. if (nPos != -1) {
  563. frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
  564. }
  565. bedNum->setText(frameBedName);
  566. }
  567. // 用户相关
  568. string customerName = frameBedList[index]["customer_name"].asString();
  569. if (customerName == "") {
  570. name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
  571. } else {
  572. name->setText(customerName);
  573. }
  574. if (partSetting.customerAgeHiddenOnDoor != 0) {
  575. if (frameBedList[index]["customer_age"].asString() == "") {
  576. age->setText("");
  577. } else {
  578. age->setText("*" + frameBedList[index]["customer_age_unit"].asString());
  579. }
  580. }
  581. else {
  582. age->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
  583. }
  584. string customerSex = frameBedList[index]["customer_sex"].asString();
  585. if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
  586. sex->setText(LANGUAGEMANAGER->getValue("Woman"));
  587. sex->setTextColor(0xFF9F9F);
  588. sex->setBackgroundPic("9/lightRed.9.png");
  589. }
  590. else if (customerSex == "1") {
  591. sex->setText(LANGUAGEMANAGER->getValue("Man"));
  592. sex->setTextColor(0x3A78EF);
  593. sex->setBackgroundPic("9/lightBlue.9.png");
  594. }
  595. else if (customerSex == "") {
  596. sex->setText(customerSex);
  597. sex->setTextColor(0x37B643);
  598. sex->setBackgroundPic("9/lightGreen.9.png");
  599. }
  600. else {
  601. sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
  602. sex->setTextColor(0x37B643);
  603. sex->setBackgroundPic("9/lightGreen.9.png");
  604. }
  605. // 医生护士相关
  606. if (rightTitleInfo["doctor_valid"] != 1){
  607. doctorTitle->setVisible(false);
  608. } else {
  609. doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
  610. }
  611. if (rightTitleInfo["nurse_valid"] != 1){
  612. nurseTitle->setVisible(false);
  613. } else {
  614. nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
  615. }
  616. doctor->setText(frameBedList[index]["doctor_name"].asString());
  617. nurse->setText(frameBedList[index]["nurse_name"].asString());
  618. // // 护理项相关
  619. // Json::Value nurseConfigList = frameBedList[index]["nurse_config_dtos"];
  620. // if (nurseConfigList.size() > 0) {
  621. // for (int i = 0; i < 5; i++) {
  622. // int nurseConfigColorNumber = ID_MAIN_NurseConfigColor1 + i;
  623. // int nurseConfigNumber = ID_MAIN_NurseConfig1 + i * 2;
  624. // int nurseOptionNumber = ID_MAIN_NurseOption1 + i * 2;
  625. // if (nurseConfigList.size() >= i) {
  626. // //颜色
  627. // string nurseConfigColot = nurseConfigList[i]["nurse_color_rbg"].asString();
  628. // uint32_t bgColor = 0xFFC0C0C0;
  629. // if (nurseConfigColot != "") {
  630. // string rgbStr = "FF" + nurseConfigColot;
  631. // transform(rgbStr.begin(), rgbStr.end(), rgbStr.begin(), ::toupper);
  632. // bgColor = strtoul(("0x" + rgbStr).c_str(), NULL,16);
  633. // }
  634. // pListItem->findSubItemByID(nurseConfigColorNumber)->setBackgroundColor(bgColor);
  635. // pListItem->findSubItemByID(nurseConfigNumber)->setText(nurseConfigList[i]["nurse_config_name"].asString());
  636. // string nurseOptionName = nurseConfigList[i]["nurse_option_name"].asString();
  637. // if (nurseOptionName == "") {
  638. // nurseOptionName = LANGUAGEMANAGER->getValue("None");
  639. // }
  640. // pListItem->findSubItemByID(nurseOptionNumber)->setText(nurseOptionName);
  641. //
  642. // } else {
  643. // //颜色
  644. // pListItem->findSubItemByID(nurseConfigColorNumber)->setBackgroundColor(0xFFC0C0C0);
  645. // pListItem->findSubItemByID(nurseConfigNumber)->setText(nurseConfigList[i]["nurse_config_name"].asString());
  646. // pListItem->findSubItemByID(nurseOptionNumber)->setText(LANGUAGEMANAGER->getValue("None"));
  647. // }
  648. // }
  649. // }
  650. // else {
  651. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor1)->setBackgroundColor(0xFFC0C0C0);
  652. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor2)->setBackgroundColor(0xFFC0C0C0);
  653. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor3)->setBackgroundColor(0xFFC0C0C0);
  654. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor4)->setBackgroundColor(0xFFC0C0C0);
  655. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor5)->setBackgroundColor(0xFFC0C0C0);
  656. // pListItem->findSubItemByID(ID_MAIN_NurseConfig1)->setText("");
  657. // pListItem->findSubItemByID(ID_MAIN_NurseConfig2)->setText("");
  658. // pListItem->findSubItemByID(ID_MAIN_NurseConfig3)->setText("");
  659. // pListItem->findSubItemByID(ID_MAIN_NurseConfig4)->setText("");
  660. // pListItem->findSubItemByID(ID_MAIN_NurseConfig5)->setText("");
  661. // pListItem->findSubItemByID(ID_MAIN_NurseOption1)->setText(LANGUAGEMANAGER->getValue("None"));
  662. // pListItem->findSubItemByID(ID_MAIN_NurseOption2)->setText(LANGUAGEMANAGER->getValue("None"));
  663. // pListItem->findSubItemByID(ID_MAIN_NurseOption3)->setText(LANGUAGEMANAGER->getValue("None"));
  664. // pListItem->findSubItemByID(ID_MAIN_NurseOption4)->setText(LANGUAGEMANAGER->getValue("None"));
  665. // pListItem->findSubItemByID(ID_MAIN_NurseOption5)->setText(LANGUAGEMANAGER->getValue("None"));
  666. // }
  667. }
  668. }
  669. static void onListItemClick_BedListView(ZKListView *pListView, int index, int id) {
  670. //LOGD(" onListItemClick_ BedListView !!!\n");
  671. if (id == ID_MAIN_EventSubItem) {
  672. string _customerId = frameBedList[index]["customer_id"].asString();
  673. string _deviceId = frameBedList[index]["bed_device_id"].asString();
  674. Intent* intent = new Intent();
  675. intent->putExtra(transmitDeviceId, _deviceId);
  676. intent->putExtra(transmitCustomerId, _customerId);
  677. EASYUICONTEXT->openActivity("interactionActivity", intent);
  678. }
  679. else if (id == ID_MAIN_AffairSubItem) {
  680. string _customerId = frameBedList[index]["customer_id"].asString();
  681. string _deviceId = frameBedList[index]["bed_device_id"].asString();
  682. Intent* intent = new Intent();
  683. intent->putExtra(transmitDeviceId, _deviceId);
  684. intent->putExtra(transmitCustomerId, _customerId);
  685. EASYUICONTEXT->openActivity("customerAffairActivity", intent);
  686. }
  687. }
  688. static int getListItemCount_BedListView2(const ZKListView *pListView) {
  689. //LOGD("getListItemCount_BedListView2 !\n");
  690. return frameBedList.size();
  691. }
  692. static void obtainListItemData_BedListView2(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
  693. //LOGD(" obtainListItemData_ BedListView2 !!!\n");
  694. if (mainModeInt == 2) {
  695. if (frameBedList.size() <= 3 || frameBedList.size() > 6) {
  696. return;
  697. }
  698. }
  699. if (frameBedList.size() > 0) {
  700. ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem2);
  701. ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem2);
  702. ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem2);
  703. ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem2);
  704. ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitleSubItem2);
  705. ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem2);
  706. ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem2);
  707. ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem2);
  708. if (mainThemeInt == 1) {
  709. bedNum->setBackgroundPic("/9/chuanghao_bg.9.png");
  710. }
  711. else if (mainThemeInt == 2) {
  712. bedNum->setBackgroundPic("/9/chuanghao_bg_pink.9.png");
  713. }
  714. string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
  715. if (frameBedName == "") {
  716. bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
  717. } else {
  718. int nPos = frameBedName.find("-");
  719. if (nPos != -1) {
  720. frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
  721. }
  722. bedNum->setText(frameBedName);
  723. }
  724. // 用户相关
  725. string customerName = frameBedList[index]["customer_name"].asString();
  726. if (customerName == "") {
  727. name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
  728. } else {
  729. name->setText(customerName);
  730. }
  731. if (partSetting.customerAgeHiddenOnDoor != 0) {
  732. if (frameBedList[index]["customer_age"].asString() == "") {
  733. age->setText("");
  734. } else {
  735. age->setText("*" + frameBedList[index]["customer_age_unit"].asString());
  736. }
  737. }
  738. else {
  739. age->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
  740. }
  741. string customerSex = frameBedList[index]["customer_sex"].asString();
  742. if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
  743. sex->setText(LANGUAGEMANAGER->getValue("Woman"));
  744. sex->setTextColor(0xFF9F9F);
  745. sex->setBackgroundPic("9/lightRed.9.png");
  746. }
  747. else if (customerSex == "1") {
  748. sex->setText(LANGUAGEMANAGER->getValue("Man"));
  749. sex->setTextColor(0x3A78EF);
  750. sex->setBackgroundPic("9/lightBlue.9.png");
  751. }
  752. else if (customerSex == "") {
  753. sex->setText(customerSex);
  754. sex->setTextColor(0x37B643);
  755. sex->setBackgroundPic("9/lightGreen.9.png");
  756. }
  757. else {
  758. sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
  759. sex->setTextColor(0x37B643);
  760. sex->setBackgroundPic("9/lightGreen.9.png");
  761. }
  762. // 医生护士相关
  763. if (rightTitleInfo["doctor_valid"] != 1){
  764. doctorTitle->setVisible(false);
  765. } else {
  766. doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
  767. }
  768. if (rightTitleInfo["nurse_valid"] != 1){
  769. nurseTitle->setVisible(false);
  770. } else {
  771. nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
  772. }
  773. doctor->setText(frameBedList[index]["doctor_name"].asString());
  774. nurse->setText(frameBedList[index]["nurse_name"].asString());
  775. }
  776. }
  777. static void onListItemClick_BedListView2(ZKListView *pListView, int index, int id) {
  778. //LOGD(" onListItemClick_ BedListView2 !!!\n");
  779. }
  780. static int getListItemCount_BedListView3(const ZKListView *pListView) {
  781. //LOGD("getListItemCount_BedListView3 !\n");
  782. return frameBedList.size();
  783. }
  784. static void obtainListItemData_BedListView3(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
  785. //LOGD(" obtainListItemData_ BedListView3 !!!\n");
  786. if (mainModeInt == 2) {
  787. if (frameBedList.size() <= 6) {
  788. return;
  789. }
  790. }
  791. if (frameBedList.size() > 0) {
  792. ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem3);
  793. ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem3);
  794. ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem3);
  795. ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem3);
  796. ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitleSubItem3);
  797. ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem3);
  798. ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem3);
  799. ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem3);
  800. if (mainThemeInt == 1) {
  801. bedNum->setBackgroundPic("/9/chuanghao_bg.9.png");
  802. }
  803. else if (mainThemeInt == 2) {
  804. bedNum->setBackgroundPic("/9/chuanghao_bg_pink.9.png");
  805. }
  806. string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
  807. if (frameBedName == "") {
  808. bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
  809. } else {
  810. int nPos = frameBedName.find("-");
  811. if (nPos != -1) {
  812. frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
  813. }
  814. bedNum->setText(frameBedName);
  815. }
  816. // 用户相关
  817. string customerName = frameBedList[index]["customer_name"].asString();
  818. if (customerName == "") {
  819. name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
  820. } else {
  821. name->setText(customerName);
  822. }
  823. if (partSetting.customerAgeHiddenOnDoor != 0) {
  824. if (frameBedList[index]["customer_age"].asString() == "") {
  825. age->setText("");
  826. } else {
  827. age->setText("*" + frameBedList[index]["customer_age_unit"].asString());
  828. }
  829. }
  830. else {
  831. age->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
  832. }
  833. string customerSex = frameBedList[index]["customer_sex"].asString();
  834. if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
  835. sex->setText(LANGUAGEMANAGER->getValue("Woman"));
  836. sex->setTextColor(0xFF9F9F);
  837. sex->setBackgroundPic("9/lightRed.9.png");
  838. }
  839. else if (customerSex == "1") {
  840. sex->setText(LANGUAGEMANAGER->getValue("Man"));
  841. sex->setTextColor(0x3A78EF);
  842. sex->setBackgroundPic("9/lightBlue.9.png");
  843. }
  844. else if (customerSex == "") {
  845. sex->setText(customerSex);
  846. sex->setTextColor(0x37B643);
  847. sex->setBackgroundPic("9/lightGreen.9.png");
  848. }
  849. else {
  850. sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
  851. sex->setTextColor(0x37B643);
  852. sex->setBackgroundPic("9/lightGreen.9.png");
  853. }
  854. // 医生护士相关
  855. if (rightTitleInfo["doctor_valid"] != 1){
  856. doctorTitle->setVisible(false);
  857. } else {
  858. doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
  859. }
  860. if (rightTitleInfo["nurse_valid"] != 1){
  861. nurseTitle->setVisible(false);
  862. } else {
  863. nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
  864. }
  865. doctor->setText(frameBedList[index]["doctor_name"].asString());
  866. nurse->setText(frameBedList[index]["nurse_name"].asString());
  867. }
  868. }
  869. static void onListItemClick_BedListView3(ZKListView *pListView, int index, int id) {
  870. //LOGD(" onListItemClick_ BedListView3 !!!\n");
  871. }
  872. static int getListItemCount_BedListView4(const ZKListView *pListView) {
  873. //LOGD("getListItemCount_BedListView4 !\n");
  874. return frameBedList.size();
  875. }
  876. static void obtainListItemData_BedListView4(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
  877. //LOGD(" obtainListItemData_ BedListView4 !!!\n");
  878. if (mainModeInt == 3 && frameBedList.size()> 0) {
  879. ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem4);
  880. ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem4);
  881. ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem4);
  882. ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem4);
  883. ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitleSubItem4);
  884. ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem4);
  885. ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem4);
  886. ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem4);
  887. if (mainThemeInt == 1) {
  888. bedNum->setBackgroundPic("/9/chuanghao_bg.9.png");
  889. }
  890. else if (mainThemeInt == 2) {
  891. bedNum->setBackgroundPic("/9/chuanghao_bg_pink.9.png");
  892. }
  893. string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
  894. if (frameBedName == "") {
  895. bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
  896. } else {
  897. int nPos = frameBedName.find("-");
  898. if (nPos != -1) {
  899. frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
  900. }
  901. bedNum->setText(frameBedName);
  902. }
  903. // 用户相关
  904. string customerName = frameBedList[index]["customer_name"].asString();
  905. if (customerName == "") {
  906. name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
  907. } else {
  908. name->setText(customerName);
  909. }
  910. if (partSetting.customerAgeHiddenOnDoor != 0) {
  911. if (frameBedList[index]["customer_age"].asString() == "") {
  912. age->setText("");
  913. } else {
  914. age->setText("*" + frameBedList[index]["customer_age_unit"].asString());
  915. }
  916. }
  917. else {
  918. age->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
  919. }
  920. string customerSex = frameBedList[index]["customer_sex"].asString();
  921. if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
  922. sex->setText(LANGUAGEMANAGER->getValue("Woman"));
  923. sex->setTextColor(0xFF9F9F);
  924. sex->setBackgroundPic("9/lightRed.9.png");
  925. }
  926. else if (customerSex == "1") {
  927. sex->setText(LANGUAGEMANAGER->getValue("Man"));
  928. sex->setTextColor(0x3A78EF);
  929. sex->setBackgroundPic("9/lightBlue.9.png");
  930. }
  931. else {
  932. sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
  933. sex->setTextColor(0x37B643);
  934. sex->setBackgroundPic("9/lightGreen.9.png");
  935. }
  936. // 医生护士相关
  937. if (rightTitleInfo["doctor_valid"] != 1){
  938. doctorTitle->setVisible(false);
  939. } else {
  940. doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
  941. }
  942. if (rightTitleInfo["nurse_valid"] != 1){
  943. nurseTitle->setVisible(false);
  944. } else {
  945. nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
  946. }
  947. doctor->setText(frameBedList[index]["doctor_name"].asString());
  948. nurse->setText(frameBedList[index]["nurse_name"].asString());
  949. }
  950. }
  951. static void onListItemClick_BedListView4(ZKListView *pListView, int index, int id) {
  952. //LOGD(" onListItemClick_ BedListView4 !!!\n");
  953. }