mainLogic.cc 42 KB

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