mainLogic.cc 42 KB

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