mainLogic.cc 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122
  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 {
  596. sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
  597. sex->setTextColor(0x37B643);
  598. sex->setBackgroundPic("9/lightGreen.9.png");
  599. }
  600. // 医生护士相关
  601. if (rightTitleInfo["doctor_valid"] != 1){
  602. doctorTitle->setVisible(false);
  603. } else {
  604. doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
  605. }
  606. if (rightTitleInfo["nurse_valid"] != 1){
  607. nurseTitle->setVisible(false);
  608. } else {
  609. nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
  610. }
  611. doctor->setText(frameBedList[index]["doctor_name"].asString());
  612. nurse->setText(frameBedList[index]["nurse_name"].asString());
  613. // // 护理项相关
  614. // Json::Value nurseConfigList = frameBedList[index]["nurse_config_dtos"];
  615. // if (nurseConfigList.size() > 0) {
  616. // for (int i = 0; i < 5; i++) {
  617. // int nurseConfigColorNumber = ID_MAIN_NurseConfigColor1 + i;
  618. // int nurseConfigNumber = ID_MAIN_NurseConfig1 + i * 2;
  619. // int nurseOptionNumber = ID_MAIN_NurseOption1 + i * 2;
  620. // if (nurseConfigList.size() >= i) {
  621. // //颜色
  622. // string nurseConfigColot = nurseConfigList[i]["nurse_color_rbg"].asString();
  623. // uint32_t bgColor = 0xFFC0C0C0;
  624. // if (nurseConfigColot != "") {
  625. // string rgbStr = "FF" + nurseConfigColot;
  626. // transform(rgbStr.begin(), rgbStr.end(), rgbStr.begin(), ::toupper);
  627. // bgColor = strtoul(("0x" + rgbStr).c_str(), NULL,16);
  628. // }
  629. // pListItem->findSubItemByID(nurseConfigColorNumber)->setBackgroundColor(bgColor);
  630. // pListItem->findSubItemByID(nurseConfigNumber)->setText(nurseConfigList[i]["nurse_config_name"].asString());
  631. // string nurseOptionName = nurseConfigList[i]["nurse_option_name"].asString();
  632. // if (nurseOptionName == "") {
  633. // nurseOptionName = LANGUAGEMANAGER->getValue("None");
  634. // }
  635. // pListItem->findSubItemByID(nurseOptionNumber)->setText(nurseOptionName);
  636. //
  637. // } else {
  638. // //颜色
  639. // pListItem->findSubItemByID(nurseConfigColorNumber)->setBackgroundColor(0xFFC0C0C0);
  640. // pListItem->findSubItemByID(nurseConfigNumber)->setText(nurseConfigList[i]["nurse_config_name"].asString());
  641. // pListItem->findSubItemByID(nurseOptionNumber)->setText(LANGUAGEMANAGER->getValue("None"));
  642. // }
  643. // }
  644. // }
  645. // else {
  646. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor1)->setBackgroundColor(0xFFC0C0C0);
  647. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor2)->setBackgroundColor(0xFFC0C0C0);
  648. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor3)->setBackgroundColor(0xFFC0C0C0);
  649. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor4)->setBackgroundColor(0xFFC0C0C0);
  650. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor5)->setBackgroundColor(0xFFC0C0C0);
  651. // pListItem->findSubItemByID(ID_MAIN_NurseConfig1)->setText("");
  652. // pListItem->findSubItemByID(ID_MAIN_NurseConfig2)->setText("");
  653. // pListItem->findSubItemByID(ID_MAIN_NurseConfig3)->setText("");
  654. // pListItem->findSubItemByID(ID_MAIN_NurseConfig4)->setText("");
  655. // pListItem->findSubItemByID(ID_MAIN_NurseConfig5)->setText("");
  656. // pListItem->findSubItemByID(ID_MAIN_NurseOption1)->setText(LANGUAGEMANAGER->getValue("None"));
  657. // pListItem->findSubItemByID(ID_MAIN_NurseOption2)->setText(LANGUAGEMANAGER->getValue("None"));
  658. // pListItem->findSubItemByID(ID_MAIN_NurseOption3)->setText(LANGUAGEMANAGER->getValue("None"));
  659. // pListItem->findSubItemByID(ID_MAIN_NurseOption4)->setText(LANGUAGEMANAGER->getValue("None"));
  660. // pListItem->findSubItemByID(ID_MAIN_NurseOption5)->setText(LANGUAGEMANAGER->getValue("None"));
  661. // }
  662. }
  663. }
  664. static void onListItemClick_BedListView(ZKListView *pListView, int index, int id) {
  665. //LOGD(" onListItemClick_ BedListView !!!\n");
  666. }
  667. static int getListItemCount_BedListView2(const ZKListView *pListView) {
  668. //LOGD("getListItemCount_BedListView2 !\n");
  669. return frameBedList.size();
  670. }
  671. static void obtainListItemData_BedListView2(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
  672. //LOGD(" obtainListItemData_ BedListView2 !!!\n");
  673. if (mainModeInt == 2) {
  674. if (frameBedList.size() <= 3 || frameBedList.size() > 6) {
  675. return;
  676. }
  677. }
  678. if (frameBedList.size() > 0) {
  679. ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem2);
  680. ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem2);
  681. ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem2);
  682. ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem2);
  683. ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitleSubItem2);
  684. ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem2);
  685. ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem2);
  686. ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem2);
  687. if (mainThemeInt == 1) {
  688. bedNum->setBackgroundPic("/9/chuanghao_bg.9.png");
  689. }
  690. else if (mainThemeInt == 2) {
  691. bedNum->setBackgroundPic("/9/chuanghao_bg_pink.9.png");
  692. }
  693. string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
  694. if (frameBedName == "") {
  695. bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
  696. } else {
  697. int nPos = frameBedName.find("-");
  698. if (nPos != -1) {
  699. frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
  700. }
  701. bedNum->setText(frameBedName);
  702. }
  703. // 用户相关
  704. string customerName = frameBedList[index]["customer_name"].asString();
  705. if (customerName == "") {
  706. name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
  707. } else {
  708. name->setText(customerName);
  709. }
  710. if (partSetting.customerAgeHiddenOnDoor != 0) {
  711. if (frameBedList[index]["customer_age"].asString() == "") {
  712. age->setText("");
  713. } else {
  714. age->setText("*" + frameBedList[index]["customer_age_unit"].asString());
  715. }
  716. }
  717. else {
  718. age->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
  719. }
  720. string customerSex = frameBedList[index]["customer_sex"].asString();
  721. if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
  722. sex->setText(LANGUAGEMANAGER->getValue("Woman"));
  723. sex->setTextColor(0xFF9F9F);
  724. sex->setBackgroundPic("9/lightRed.9.png");
  725. }
  726. else if (customerSex == "1") {
  727. sex->setText(LANGUAGEMANAGER->getValue("Man"));
  728. sex->setTextColor(0x3A78EF);
  729. sex->setBackgroundPic("9/lightBlue.9.png");
  730. }
  731. else {
  732. sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
  733. sex->setTextColor(0x37B643);
  734. sex->setBackgroundPic("9/lightGreen.9.png");
  735. }
  736. // 医生护士相关
  737. if (rightTitleInfo["doctor_valid"] != 1){
  738. doctorTitle->setVisible(false);
  739. } else {
  740. doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
  741. }
  742. if (rightTitleInfo["nurse_valid"] != 1){
  743. nurseTitle->setVisible(false);
  744. } else {
  745. nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
  746. }
  747. doctor->setText(frameBedList[index]["doctor_name"].asString());
  748. nurse->setText(frameBedList[index]["nurse_name"].asString());
  749. }
  750. }
  751. static void onListItemClick_BedListView2(ZKListView *pListView, int index, int id) {
  752. //LOGD(" onListItemClick_ BedListView2 !!!\n");
  753. }
  754. static int getListItemCount_BedListView3(const ZKListView *pListView) {
  755. //LOGD("getListItemCount_BedListView3 !\n");
  756. return frameBedList.size();
  757. }
  758. static void obtainListItemData_BedListView3(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
  759. //LOGD(" obtainListItemData_ BedListView3 !!!\n");
  760. if (mainModeInt == 2) {
  761. if (frameBedList.size() <= 6) {
  762. return;
  763. }
  764. }
  765. if (frameBedList.size() > 0) {
  766. ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem3);
  767. ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem3);
  768. ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem3);
  769. ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem3);
  770. ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitleSubItem3);
  771. ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem3);
  772. ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem3);
  773. ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem3);
  774. if (mainThemeInt == 1) {
  775. bedNum->setBackgroundPic("/9/chuanghao_bg.9.png");
  776. }
  777. else if (mainThemeInt == 2) {
  778. bedNum->setBackgroundPic("/9/chuanghao_bg_pink.9.png");
  779. }
  780. string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
  781. if (frameBedName == "") {
  782. bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
  783. } else {
  784. int nPos = frameBedName.find("-");
  785. if (nPos != -1) {
  786. frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
  787. }
  788. bedNum->setText(frameBedName);
  789. }
  790. // 用户相关
  791. string customerName = frameBedList[index]["customer_name"].asString();
  792. if (customerName == "") {
  793. name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
  794. } else {
  795. name->setText(customerName);
  796. }
  797. if (partSetting.customerAgeHiddenOnDoor != 0) {
  798. if (frameBedList[index]["customer_age"].asString() == "") {
  799. age->setText("");
  800. } else {
  801. age->setText("*" + frameBedList[index]["customer_age_unit"].asString());
  802. }
  803. }
  804. else {
  805. age->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
  806. }
  807. string customerSex = frameBedList[index]["customer_sex"].asString();
  808. if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
  809. sex->setText(LANGUAGEMANAGER->getValue("Woman"));
  810. sex->setTextColor(0xFF9F9F);
  811. sex->setBackgroundPic("9/lightRed.9.png");
  812. }
  813. else if (customerSex == "1") {
  814. sex->setText(LANGUAGEMANAGER->getValue("Man"));
  815. sex->setTextColor(0x3A78EF);
  816. sex->setBackgroundPic("9/lightBlue.9.png");
  817. }
  818. else {
  819. sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
  820. sex->setTextColor(0x37B643);
  821. sex->setBackgroundPic("9/lightGreen.9.png");
  822. }
  823. // 医生护士相关
  824. if (rightTitleInfo["doctor_valid"] != 1){
  825. doctorTitle->setVisible(false);
  826. } else {
  827. doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
  828. }
  829. if (rightTitleInfo["nurse_valid"] != 1){
  830. nurseTitle->setVisible(false);
  831. } else {
  832. nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
  833. }
  834. doctor->setText(frameBedList[index]["doctor_name"].asString());
  835. nurse->setText(frameBedList[index]["nurse_name"].asString());
  836. }
  837. }
  838. static void onListItemClick_BedListView3(ZKListView *pListView, int index, int id) {
  839. //LOGD(" onListItemClick_ BedListView3 !!!\n");
  840. }
  841. static int getListItemCount_BedListView4(const ZKListView *pListView) {
  842. //LOGD("getListItemCount_BedListView4 !\n");
  843. return frameBedList.size();
  844. }
  845. static void obtainListItemData_BedListView4(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
  846. //LOGD(" obtainListItemData_ BedListView4 !!!\n");
  847. if (mainModeInt == 3 && frameBedList.size()> 0) {
  848. ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem4);
  849. ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem4);
  850. ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem4);
  851. ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem4);
  852. ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitleSubItem4);
  853. ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem4);
  854. ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem4);
  855. ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem4);
  856. if (mainThemeInt == 1) {
  857. bedNum->setBackgroundPic("/9/chuanghao_bg.9.png");
  858. }
  859. else if (mainThemeInt == 2) {
  860. bedNum->setBackgroundPic("/9/chuanghao_bg_pink.9.png");
  861. }
  862. string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
  863. if (frameBedName == "") {
  864. bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
  865. } else {
  866. int nPos = frameBedName.find("-");
  867. if (nPos != -1) {
  868. frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
  869. }
  870. bedNum->setText(frameBedName);
  871. }
  872. // 用户相关
  873. string customerName = frameBedList[index]["customer_name"].asString();
  874. if (customerName == "") {
  875. name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
  876. } else {
  877. name->setText(customerName);
  878. }
  879. if (partSetting.customerAgeHiddenOnDoor != 0) {
  880. if (frameBedList[index]["customer_age"].asString() == "") {
  881. age->setText("");
  882. } else {
  883. age->setText("*" + frameBedList[index]["customer_age_unit"].asString());
  884. }
  885. }
  886. else {
  887. age->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
  888. }
  889. string customerSex = frameBedList[index]["customer_sex"].asString();
  890. if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
  891. sex->setText(LANGUAGEMANAGER->getValue("Woman"));
  892. sex->setTextColor(0xFF9F9F);
  893. sex->setBackgroundPic("9/lightRed.9.png");
  894. }
  895. else if (customerSex == "1") {
  896. sex->setText(LANGUAGEMANAGER->getValue("Man"));
  897. sex->setTextColor(0x3A78EF);
  898. sex->setBackgroundPic("9/lightBlue.9.png");
  899. }
  900. else {
  901. sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
  902. sex->setTextColor(0x37B643);
  903. sex->setBackgroundPic("9/lightGreen.9.png");
  904. }
  905. // 医生护士相关
  906. if (rightTitleInfo["doctor_valid"] != 1){
  907. doctorTitle->setVisible(false);
  908. } else {
  909. doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
  910. }
  911. if (rightTitleInfo["nurse_valid"] != 1){
  912. nurseTitle->setVisible(false);
  913. } else {
  914. nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
  915. }
  916. doctor->setText(frameBedList[index]["doctor_name"].asString());
  917. nurse->setText(frameBedList[index]["nurse_name"].asString());
  918. }
  919. }
  920. static void onListItemClick_BedListView4(ZKListView *pListView, int index, int id) {
  921. //LOGD(" onListItemClick_ BedListView4 !!!\n");
  922. }
  923. static bool onButtonClick_Button1(ZKButton *pButton) {
  924. LOGD(" ButtonClick Button1 !!!\n");
  925. sendCurtainCommon("100", 11947);
  926. return false;
  927. }
  928. static bool onButtonClick_Button2(ZKButton *pButton) {
  929. LOGD(" ButtonClick Button2 !!!\n");
  930. sendCurtainCommon("0", 11947);
  931. return false;
  932. }
  933. static bool onButtonClick_Button3(ZKButton *pButton) {
  934. LOGD(" ButtonClick Button3 !!!\n");
  935. sendSwitchCommon("1", 11944);
  936. return false;
  937. }
  938. static bool onButtonClick_Button4(ZKButton *pButton) {
  939. LOGD(" ButtonClick Button4 !!!\n");
  940. sendSwitchCommon("0", 11944);
  941. return false;
  942. }
  943. static bool onButtonClick_Button9(ZKButton *pButton) {
  944. LOGD(" ButtonClick Button9 !!!\n");
  945. sendSwitchCommon("100", 11946);
  946. return false;
  947. }
  948. static bool onButtonClick_Button10(ZKButton *pButton) {
  949. LOGD(" ButtonClick Button10 !!!\n");
  950. sendSwitchCommon("000", 11946);
  951. return false;
  952. }
  953. static bool onButtonClick_Button11(ZKButton *pButton) {
  954. LOGD(" ButtonClick Button11 !!!\n");
  955. sendSwitchCommon("001", 11946);
  956. return false;
  957. }
  958. static bool onButtonClick_Button12(ZKButton *pButton) {
  959. LOGD(" ButtonClick Button12 !!!\n");
  960. sendSwitchCommon("000", 11946);
  961. return false;
  962. }
  963. static bool onButtonClick_Button13(ZKButton *pButton) {
  964. LOGD(" ButtonClick Button13 !!!\n");
  965. sendCurtainQuery(11947);
  966. return false;
  967. }
  968. static bool onButtonClick_Button14(ZKButton *pButton) {
  969. LOGD(" ButtonClick Button14 !!!\n");
  970. sendSwitchQuery(11946);
  971. return false;
  972. }