mainLogic.cc 46 KB

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