mainLogic.cc 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155
  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 net::Conn* udpConn;
  96. class UdpThread: public Thread {
  97. public:
  98. static void getServerInfo(){
  99. string url = getHttpGateway() + "/ncs_url/server_info";
  100. LOGD("请求服务器信息. url = %s", url.c_str());
  101. //发起HTTP GET请求
  102. RestClient::Response r = RestClient::get(url);
  103. //解析json
  104. Json::Reader reader;
  105. Json::Value root;
  106. if (reader.parse(r.body, root, false)){
  107. // http
  108. StoragePreferences::putString(STORE_GATEWAY, root["http_local_ip"].asString());
  109. StoragePreferences::putInt(STORE_HTTP_PORT, root["http_port"].asInt());
  110. // tcp
  111. StoragePreferences::putString(STORE_TCP_LOCAL_IP, root["tcp_local_ip"].asString());
  112. StoragePreferences::putInt(STORE_TCP_PORT, root["tcp_port"].asInt());
  113. // sip
  114. StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString());
  115. StoragePreferences::putInt(SIP_REG_PORT, root["sip_port"].asInt());
  116. serverInfo = false; // 只有请求成功了,才不需要重复请求
  117. }
  118. }
  119. static void getDeviceInfo(){
  120. if (dataInit){
  121. getFrameInfo();
  122. getBedCount();
  123. setDirectorAndHeadNurse();
  124. return;
  125. }
  126. if (!isConnectServer()) {
  127. return;
  128. }
  129. string url = getHttpGateway() + "/deviceRoom/get_device_by_eth_mac/" + StoragePreferences::getString(STORE_MAC_ADDR, "0.0.0.0");
  130. LOGD("请求设备信息. url = %s", url.c_str());
  131. //发起HTTP GET请求
  132. RestClient::Response r = RestClient::get(url);
  133. LOGD("获得设备信息. result = %s", r.body.c_str());
  134. //解析json
  135. Json::Reader reader;
  136. Json::Value root;
  137. if (reader.parse(r.body, root, false)){
  138. string partName = root["part_display"].asString();
  139. StoragePreferences::putString(STORE_PARTNAME,partName);
  140. NavibarSetPartName(partName);
  141. //设备
  142. StoragePreferences::putInt(STORE_DEVICE_ID, root["id"].asInt());
  143. StoragePreferences::putInt(STORE_DEVICE_TYPE, root["device_type"].asInt());
  144. //SIP存储
  145. // StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString()); // 应该去找配置文件里的sip-ip
  146. StoragePreferences::putString(SIP_REG_ACCOUNT,root["sip_id"].asString());
  147. StoragePreferences::putString(SIP_REG_PASSWORD, root["sip_password"].asString());
  148. frameInfo["frame_id"] = root["frame_id"].asInt();
  149. frameInfo["full_name"] = root["full_name"].asString();
  150. frameInfo["part_id"] = root["part_id"].asInt();
  151. getFrameInfo();
  152. //获取科室设置
  153. string partId = root["part_id"].asString();
  154. StoragePreferences::putString(STORE_PARTID, partId);
  155. getPartSetting(partId);
  156. getVersion();
  157. getNfcInteraction();
  158. }
  159. }
  160. // 读取空间缓存的数据
  161. static void getFrameInfo() {
  162. mRoomNameTextViewPtr->setText(frameInfo["full_name"].asString());
  163. }
  164. static void getBedCount() {
  165. if (mActivityPtr == NULL) {
  166. return;
  167. }
  168. mInBedNumTextViewPtr->setText(inBedCount);
  169. mEmptyBedNumTextViewPtr->setText(emptyBedCount);
  170. }
  171. static void getFrameRoom(int frame_id) {
  172. string url = getHttpGateway() + "/deviceRoom/get_frame_room/" + to_string(frame_id);
  173. LOGD("请求房间信息. url = %s", url.c_str());
  174. //发起HTTP GET请求
  175. RestClient::Response r = RestClient::get(url);
  176. LOGD("获得房间信息. result = %s", r.body.c_str());
  177. //解析json
  178. Json::Reader reader;
  179. Json::Value root;
  180. if (reader.parse(r.body, root, false)){
  181. frameRoom = root;
  182. frameBedList = root["frame_bed_list"];
  183. inBedCount = 0;
  184. emptyBedCount = 0;
  185. if (frameBedList.size() > 0) {
  186. for (int i = 0; i < frameBedList.size(); i++) {
  187. string customerId = frameBedList[i]["customer_id"].asString();
  188. if (customerId != "") {
  189. inBedCount += 1;
  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. /**
  424. * 线程创建成功后会调用该函数,可以在该函数中做一些初始化操作
  425. * return true 继续线程
  426. * false 退出线程
  427. */
  428. virtual bool readyToRun() {
  429. LOGD("Thread 已经创建完成");
  430. return true;
  431. }
  432. /**
  433. * 线程循环函数
  434. *
  435. * return true 继续线程循环
  436. * false 推出线程
  437. */
  438. virtual bool threadLoop() {
  439. LOGD("线程循环函数");
  440. //检查是否有退出线程的请求,如果有,则返回false,立即退出线程
  441. if (exitPending()) {
  442. return false;
  443. }
  444. udpConn = net::Dial("udp", "192.168.1.255:10010");
  445. if (udpConn) {
  446. byte buf[1024] = {0};
  447. const char* req = "search_server";
  448. //发送
  449. udpConn->Write((byte*)req, strlen(req));
  450. while (true && !exitPending()) {
  451. //读取,超时10*1000毫秒
  452. int n = udpConn->Read(buf, sizeof(buf) - 1, 10*1000);
  453. if (n > 0) {
  454. buf[n] = 0;
  455. char serverStr[1024];
  456. sprintf(serverStr,"%s",buf);
  457. LOGD("读取 %d字节: %s", n, serverStr);
  458. //解析json
  459. Json::Reader reader;
  460. Json::Value root;
  461. if (reader.parse(serverStr, root, false)){
  462. if (root.isMember("success") && root["success"].asBool()){
  463. serverIP = root["data"]["third_server"].asString();
  464. serverHttpPort = root["data"]["third_server_port"].asInt();
  465. StoragePreferences::putString(STORE_GATEWAY, serverIP);
  466. StoragePreferences::putInt(STORE_HTTP_PORT, serverHttpPort);
  467. //先获取服务器信息
  468. //getServerInfo();
  469. //就当在获取服务器信息完成后获取用户信息,这里测试用
  470. //getCustomerInfo();
  471. //退出UDP线程
  472. pthread_exit(NULL);
  473. break;
  474. }
  475. }
  476. } else if (n == 0) {
  477. LOGD("连接正常断开");
  478. break;
  479. } else if (n == net::E_TIMEOUT) {
  480. udpConn->Write((byte*)req, strlen(req));
  481. LOGD("读取超时");
  482. } else {
  483. LOGD("出错");
  484. break;
  485. }
  486. }
  487. //关闭连接
  488. udpConn->Close();
  489. //释放内存
  490. delete udpConn;
  491. udpConn = NULL;
  492. }
  493. //返回真,继续下次线程循环
  494. return true;
  495. }
  496. };
  497. static UdpThread udp_thread;
  498. Json::Value getFrame() {
  499. return frameRoom;
  500. }
  501. // 收到tcp的时候,刷新数据
  502. void dataRefresh() {
  503. LOGD("DATA-REFRESH, 数据刷新");
  504. if (mActivityPtr == NULL) {
  505. return;
  506. }
  507. if (serverInfo) {
  508. udp_thread.getServerInfo();
  509. }
  510. dataInit = false;
  511. udp_thread.getDeviceInfo();
  512. mBedListViewPtr->refreshListView();
  513. }
  514. void getPartSetting() {
  515. udp_thread.getPartSetting(StoragePreferences::getString(STORE_PARTID, ""));
  516. }
  517. /**
  518. * 注册定时器
  519. * 填充数组用于注册定时器
  520. * 注意:id不能重复
  521. */
  522. static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
  523. //{0, 6000}, //定时器id=0, 时间间隔6秒
  524. //{1, 1000},
  525. };
  526. /**
  527. * 当界面构造时触发
  528. */
  529. static void onUI_init(){
  530. //run("this is thread name");
  531. //测试用
  532. LOGD("进入mainLogic页面, 触发 onUI_init");
  533. if(serverInfo && isConnectServer()) { // 如果是false,就是不需要
  534. udp_thread.getServerInfo();
  535. }
  536. udp_thread.getDeviceInfo();
  537. setMainMode();
  538. }
  539. /**
  540. * 当切换到该界面时触发
  541. */
  542. static void onUI_intent(const Intent *intentPtr) {
  543. if (intentPtr != NULL) {
  544. }
  545. }
  546. /*
  547. * 当界面显示时触发
  548. */
  549. static void onUI_show() {
  550. EASYUICONTEXT->showStatusBar();
  551. EASYUICONTEXT->showNaviBar();
  552. setMainTheme();
  553. }
  554. /*
  555. * 当界面隐藏时触发
  556. */
  557. static void onUI_hide() {
  558. }
  559. /*
  560. * 当界面完全退出时触发
  561. */
  562. static void onUI_quit() {
  563. //pthread_exit(NULL);
  564. }
  565. /**
  566. * 串口数据回调接口
  567. */
  568. static void onProtocolDataUpdate(const SProtocolData &data) {
  569. }
  570. /**
  571. * 定时器触发函数
  572. * 不建议在此函数中写耗时操作,否则将影响UI刷新
  573. * 参数: id
  574. * 当前所触发定时器的id,与注册时的id相同
  575. * 返回值: true
  576. * 继续运行当前定时器
  577. * false
  578. * 停止运行当前定时器
  579. */
  580. static bool onUI_Timer(int id){
  581. switch (id) {
  582. default:
  583. break;
  584. }
  585. return true;
  586. }
  587. /**
  588. * 有新的触摸事件时触发
  589. * 参数:ev
  590. * 新的触摸事件
  591. * 返回值:true
  592. * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上
  593. * false
  594. * 触摸事件将继续传递到控件上
  595. */
  596. static bool onmainActivityTouchEvent(const MotionEvent &ev) {
  597. switch (ev.mActionStatus) {
  598. case MotionEvent::E_ACTION_DOWN://触摸按下
  599. //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY);
  600. break;
  601. case MotionEvent::E_ACTION_MOVE://触摸滑动
  602. break;
  603. case MotionEvent::E_ACTION_UP: //触摸抬起
  604. break;
  605. default:
  606. break;
  607. }
  608. return false;
  609. }
  610. static int getListItemCount_BedListView(const ZKListView *pListView) {
  611. //LOGD("getListItemCount_BedListView !\n");
  612. return frameBedList.size();
  613. }
  614. static void obtainListItemData_BedListView(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
  615. //LOGD(" obtainListItemData_ BedListView !!!\n");
  616. if (frameBedList.size() > 0) {
  617. ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem);
  618. ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem);
  619. ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem);
  620. ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem);
  621. ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitileSubItem);
  622. ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem);
  623. ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem);
  624. ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem);
  625. if (mainModeInt == 2) {
  626. if (frameBedList.size() > 3) {
  627. return;
  628. }
  629. }
  630. if (mainThemeInt == 1) {
  631. bedNum->setBackgroundPic("/9/chuanghao_bg.9.png");
  632. }
  633. else if (mainThemeInt == 2) {
  634. bedNum->setBackgroundPic("/9/chuanghao_bg_pink.9.png");
  635. }
  636. string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
  637. if (frameBedName == "") {
  638. bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
  639. } else {
  640. int nPos = frameBedName.find("-");
  641. if (nPos != -1) {
  642. frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
  643. }
  644. bedNum->setText(frameBedName);
  645. }
  646. // 用户相关
  647. string customerName = frameBedList[index]["customer_name"].asString();
  648. if (customerName == "") {
  649. name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
  650. } else {
  651. name->setText(customerName);
  652. }
  653. if (partSetting.customerAgeHiddenOnDoor != 0) {
  654. if (frameBedList[index]["customer_age"].asString() == "") {
  655. age->setText("");
  656. } else {
  657. age->setText("*" + frameBedList[index]["customer_age_unit"].asString());
  658. }
  659. }
  660. else {
  661. age->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
  662. }
  663. string customerSex = frameBedList[index]["customer_sex"].asString();
  664. if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
  665. sex->setText(LANGUAGEMANAGER->getValue("Woman"));
  666. sex->setTextColor(0xFF9F9F);
  667. sex->setBackgroundPic("9/lightRed.9.png");
  668. }
  669. else if (customerSex == "1") {
  670. sex->setText(LANGUAGEMANAGER->getValue("Man"));
  671. sex->setTextColor(0x3A78EF);
  672. sex->setBackgroundPic("9/lightBlue.9.png");
  673. }
  674. else {
  675. sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
  676. sex->setTextColor(0x37B643);
  677. sex->setBackgroundPic("9/lightGreen.9.png");
  678. }
  679. // 医生护士相关
  680. if (rightTitleInfo["doctor_valid"] != 1){
  681. doctorTitle->setVisible(false);
  682. } else {
  683. doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
  684. }
  685. if (rightTitleInfo["nurse_valid"] != 1){
  686. nurseTitle->setVisible(false);
  687. } else {
  688. nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
  689. }
  690. doctor->setText(frameBedList[index]["doctor_name"].asString());
  691. nurse->setText(frameBedList[index]["nurse_name"].asString());
  692. // // 护理项相关
  693. // Json::Value nurseConfigList = frameBedList[index]["nurse_config_dtos"];
  694. // if (nurseConfigList.size() > 0) {
  695. // for (int i = 0; i < 5; i++) {
  696. // int nurseConfigColorNumber = ID_MAIN_NurseConfigColor1 + i;
  697. // int nurseConfigNumber = ID_MAIN_NurseConfig1 + i * 2;
  698. // int nurseOptionNumber = ID_MAIN_NurseOption1 + i * 2;
  699. // if (nurseConfigList.size() >= i) {
  700. // //颜色
  701. // string nurseConfigColot = nurseConfigList[i]["nurse_color_rbg"].asString();
  702. // uint32_t bgColor = 0xFFC0C0C0;
  703. // if (nurseConfigColot != "") {
  704. // string rgbStr = "FF" + nurseConfigColot;
  705. // transform(rgbStr.begin(), rgbStr.end(), rgbStr.begin(), ::toupper);
  706. // bgColor = strtoul(("0x" + rgbStr).c_str(), NULL,16);
  707. // }
  708. // pListItem->findSubItemByID(nurseConfigColorNumber)->setBackgroundColor(bgColor);
  709. // pListItem->findSubItemByID(nurseConfigNumber)->setText(nurseConfigList[i]["nurse_config_name"].asString());
  710. // string nurseOptionName = nurseConfigList[i]["nurse_option_name"].asString();
  711. // if (nurseOptionName == "") {
  712. // nurseOptionName = LANGUAGEMANAGER->getValue("None");
  713. // }
  714. // pListItem->findSubItemByID(nurseOptionNumber)->setText(nurseOptionName);
  715. //
  716. // } else {
  717. // //颜色
  718. // pListItem->findSubItemByID(nurseConfigColorNumber)->setBackgroundColor(0xFFC0C0C0);
  719. // pListItem->findSubItemByID(nurseConfigNumber)->setText(nurseConfigList[i]["nurse_config_name"].asString());
  720. // pListItem->findSubItemByID(nurseOptionNumber)->setText(LANGUAGEMANAGER->getValue("None"));
  721. // }
  722. // }
  723. // }
  724. // else {
  725. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor1)->setBackgroundColor(0xFFC0C0C0);
  726. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor2)->setBackgroundColor(0xFFC0C0C0);
  727. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor3)->setBackgroundColor(0xFFC0C0C0);
  728. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor4)->setBackgroundColor(0xFFC0C0C0);
  729. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor5)->setBackgroundColor(0xFFC0C0C0);
  730. // pListItem->findSubItemByID(ID_MAIN_NurseConfig1)->setText("");
  731. // pListItem->findSubItemByID(ID_MAIN_NurseConfig2)->setText("");
  732. // pListItem->findSubItemByID(ID_MAIN_NurseConfig3)->setText("");
  733. // pListItem->findSubItemByID(ID_MAIN_NurseConfig4)->setText("");
  734. // pListItem->findSubItemByID(ID_MAIN_NurseConfig5)->setText("");
  735. // pListItem->findSubItemByID(ID_MAIN_NurseOption1)->setText(LANGUAGEMANAGER->getValue("None"));
  736. // pListItem->findSubItemByID(ID_MAIN_NurseOption2)->setText(LANGUAGEMANAGER->getValue("None"));
  737. // pListItem->findSubItemByID(ID_MAIN_NurseOption3)->setText(LANGUAGEMANAGER->getValue("None"));
  738. // pListItem->findSubItemByID(ID_MAIN_NurseOption4)->setText(LANGUAGEMANAGER->getValue("None"));
  739. // pListItem->findSubItemByID(ID_MAIN_NurseOption5)->setText(LANGUAGEMANAGER->getValue("None"));
  740. // }
  741. }
  742. }
  743. static void onListItemClick_BedListView(ZKListView *pListView, int index, int id) {
  744. //LOGD(" onListItemClick_ BedListView !!!\n");
  745. }
  746. static int getListItemCount_BedListView2(const ZKListView *pListView) {
  747. //LOGD("getListItemCount_BedListView2 !\n");
  748. return frameBedList.size();
  749. }
  750. static void obtainListItemData_BedListView2(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
  751. //LOGD(" obtainListItemData_ BedListView2 !!!\n");
  752. if (mainModeInt == 2) {
  753. if (frameBedList.size() <= 3 || frameBedList.size() > 6) {
  754. return;
  755. }
  756. }
  757. if (frameBedList.size() > 0) {
  758. ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem2);
  759. ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem2);
  760. ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem2);
  761. ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem2);
  762. ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitleSubItem2);
  763. ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem2);
  764. ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem2);
  765. ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem2);
  766. if (mainThemeInt == 1) {
  767. bedNum->setBackgroundPic("/9/chuanghao_bg.9.png");
  768. }
  769. else if (mainThemeInt == 2) {
  770. bedNum->setBackgroundPic("/9/chuanghao_bg_pink.9.png");
  771. }
  772. string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
  773. if (frameBedName == "") {
  774. bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
  775. } else {
  776. int nPos = frameBedName.find("-");
  777. if (nPos != -1) {
  778. frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
  779. }
  780. bedNum->setText(frameBedName);
  781. }
  782. // 用户相关
  783. string customerName = frameBedList[index]["customer_name"].asString();
  784. if (customerName == "") {
  785. name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
  786. } else {
  787. name->setText(customerName);
  788. }
  789. if (partSetting.customerAgeHiddenOnDoor != 0) {
  790. if (frameBedList[index]["customer_age"].asString() == "") {
  791. age->setText("");
  792. } else {
  793. age->setText("*" + frameBedList[index]["customer_age_unit"].asString());
  794. }
  795. }
  796. else {
  797. age->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
  798. }
  799. string customerSex = frameBedList[index]["customer_sex"].asString();
  800. if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
  801. sex->setText(LANGUAGEMANAGER->getValue("Woman"));
  802. sex->setTextColor(0xFF9F9F);
  803. sex->setBackgroundPic("9/lightRed.9.png");
  804. }
  805. else if (customerSex == "1") {
  806. sex->setText(LANGUAGEMANAGER->getValue("Man"));
  807. sex->setTextColor(0x3A78EF);
  808. sex->setBackgroundPic("9/lightBlue.9.png");
  809. }
  810. else {
  811. sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
  812. sex->setTextColor(0x37B643);
  813. sex->setBackgroundPic("9/lightGreen.9.png");
  814. }
  815. // 医生护士相关
  816. if (rightTitleInfo["doctor_valid"] != 1){
  817. doctorTitle->setVisible(false);
  818. } else {
  819. doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
  820. }
  821. if (rightTitleInfo["nurse_valid"] != 1){
  822. nurseTitle->setVisible(false);
  823. } else {
  824. nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
  825. }
  826. doctor->setText(frameBedList[index]["doctor_name"].asString());
  827. nurse->setText(frameBedList[index]["nurse_name"].asString());
  828. }
  829. }
  830. static void onListItemClick_BedListView2(ZKListView *pListView, int index, int id) {
  831. //LOGD(" onListItemClick_ BedListView2 !!!\n");
  832. }
  833. static int getListItemCount_BedListView3(const ZKListView *pListView) {
  834. //LOGD("getListItemCount_BedListView3 !\n");
  835. return frameBedList.size();
  836. }
  837. static void obtainListItemData_BedListView3(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
  838. //LOGD(" obtainListItemData_ BedListView3 !!!\n");
  839. if (mainModeInt == 2) {
  840. if (frameBedList.size() <= 6) {
  841. return;
  842. }
  843. }
  844. if (frameBedList.size() > 0) {
  845. ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem3);
  846. ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem3);
  847. ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem3);
  848. ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem3);
  849. ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitleSubItem3);
  850. ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem3);
  851. ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem3);
  852. ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem3);
  853. if (mainThemeInt == 1) {
  854. bedNum->setBackgroundPic("/9/chuanghao_bg.9.png");
  855. }
  856. else if (mainThemeInt == 2) {
  857. bedNum->setBackgroundPic("/9/chuanghao_bg_pink.9.png");
  858. }
  859. string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
  860. if (frameBedName == "") {
  861. bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
  862. } else {
  863. int nPos = frameBedName.find("-");
  864. if (nPos != -1) {
  865. frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
  866. }
  867. bedNum->setText(frameBedName);
  868. }
  869. // 用户相关
  870. string customerName = frameBedList[index]["customer_name"].asString();
  871. if (customerName == "") {
  872. name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
  873. } else {
  874. name->setText(customerName);
  875. }
  876. if (partSetting.customerAgeHiddenOnDoor != 0) {
  877. if (frameBedList[index]["customer_age"].asString() == "") {
  878. age->setText("");
  879. } else {
  880. age->setText("*" + frameBedList[index]["customer_age_unit"].asString());
  881. }
  882. }
  883. else {
  884. age->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
  885. }
  886. string customerSex = frameBedList[index]["customer_sex"].asString();
  887. if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
  888. sex->setText(LANGUAGEMANAGER->getValue("Woman"));
  889. sex->setTextColor(0xFF9F9F);
  890. sex->setBackgroundPic("9/lightRed.9.png");
  891. }
  892. else if (customerSex == "1") {
  893. sex->setText(LANGUAGEMANAGER->getValue("Man"));
  894. sex->setTextColor(0x3A78EF);
  895. sex->setBackgroundPic("9/lightBlue.9.png");
  896. }
  897. else {
  898. sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
  899. sex->setTextColor(0x37B643);
  900. sex->setBackgroundPic("9/lightGreen.9.png");
  901. }
  902. // 医生护士相关
  903. if (rightTitleInfo["doctor_valid"] != 1){
  904. doctorTitle->setVisible(false);
  905. } else {
  906. doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
  907. }
  908. if (rightTitleInfo["nurse_valid"] != 1){
  909. nurseTitle->setVisible(false);
  910. } else {
  911. nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
  912. }
  913. doctor->setText(frameBedList[index]["doctor_name"].asString());
  914. nurse->setText(frameBedList[index]["nurse_name"].asString());
  915. }
  916. }
  917. static void onListItemClick_BedListView3(ZKListView *pListView, int index, int id) {
  918. //LOGD(" onListItemClick_ BedListView3 !!!\n");
  919. }
  920. static int getListItemCount_BedListView4(const ZKListView *pListView) {
  921. //LOGD("getListItemCount_BedListView4 !\n");
  922. return frameBedList.size();
  923. }
  924. static void obtainListItemData_BedListView4(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
  925. //LOGD(" obtainListItemData_ BedListView4 !!!\n");
  926. if (mainModeInt == 3 && frameBedList.size()> 0) {
  927. ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem4);
  928. ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem4);
  929. ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem4);
  930. ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem4);
  931. ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitleSubItem4);
  932. ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem4);
  933. ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem4);
  934. ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem4);
  935. if (mainThemeInt == 1) {
  936. bedNum->setBackgroundPic("/9/chuanghao_bg.9.png");
  937. }
  938. else if (mainThemeInt == 2) {
  939. bedNum->setBackgroundPic("/9/chuanghao_bg_pink.9.png");
  940. }
  941. string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
  942. if (frameBedName == "") {
  943. bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
  944. } else {
  945. int nPos = frameBedName.find("-");
  946. if (nPos != -1) {
  947. frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
  948. }
  949. bedNum->setText(frameBedName);
  950. }
  951. // 用户相关
  952. string customerName = frameBedList[index]["customer_name"].asString();
  953. if (customerName == "") {
  954. name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
  955. } else {
  956. name->setText(customerName);
  957. }
  958. if (partSetting.customerAgeHiddenOnDoor != 0) {
  959. if (frameBedList[index]["customer_age"].asString() == "") {
  960. age->setText("");
  961. } else {
  962. age->setText("*" + frameBedList[index]["customer_age_unit"].asString());
  963. }
  964. }
  965. else {
  966. age->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
  967. }
  968. string customerSex = frameBedList[index]["customer_sex"].asString();
  969. if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
  970. sex->setText(LANGUAGEMANAGER->getValue("Woman"));
  971. sex->setTextColor(0xFF9F9F);
  972. sex->setBackgroundPic("9/lightRed.9.png");
  973. }
  974. else if (customerSex == "1") {
  975. sex->setText(LANGUAGEMANAGER->getValue("Man"));
  976. sex->setTextColor(0x3A78EF);
  977. sex->setBackgroundPic("9/lightBlue.9.png");
  978. }
  979. else {
  980. sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
  981. sex->setTextColor(0x37B643);
  982. sex->setBackgroundPic("9/lightGreen.9.png");
  983. }
  984. // 医生护士相关
  985. if (rightTitleInfo["doctor_valid"] != 1){
  986. doctorTitle->setVisible(false);
  987. } else {
  988. doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
  989. }
  990. if (rightTitleInfo["nurse_valid"] != 1){
  991. nurseTitle->setVisible(false);
  992. } else {
  993. nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
  994. }
  995. doctor->setText(frameBedList[index]["doctor_name"].asString());
  996. nurse->setText(frameBedList[index]["nurse_name"].asString());
  997. }
  998. }
  999. static void onListItemClick_BedListView4(ZKListView *pListView, int index, int id) {
  1000. //LOGD(" onListItemClick_ BedListView4 !!!\n");
  1001. }