mainLogic.cc 41 KB

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