mainLogic.cc 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. #pragma once
  2. #include "uart/ProtocolSender.h"
  3. #include "net/NetManager.h"
  4. #include "storage/StoragePreferences.h"
  5. #include "net/net.h"
  6. #include <system/Thread.h>
  7. #include "restclient-cpp/restclient.h"
  8. #include "curl/curl.h"
  9. #include <algorithm>
  10. #include "service/BusinessConfig.h"
  11. #include "core/sip_config.h"
  12. #include "manager/LanguageManager.h"
  13. #include "core/utilities.h"
  14. #include <string>
  15. #include "zkaudio.h"
  16. #include "base/strings.hpp"
  17. #include "base/http_client.h"
  18. #include "os/UpgradeMonitor.h"
  19. #include "core/update_assistant.h"
  20. #include "utils/TimeHelper.h"
  21. #define ETHERNETMANAGER NETMANAGER->getEthernetManager()
  22. #define WIFIMANAGER NETMANAGER->getWifiManager()
  23. /*
  24. *此文件由GUI工具生成
  25. *文件功能:用于处理用户的逻辑相应代码
  26. *功能说明:
  27. *========================onButtonClick_XXXX
  28. 当页面中的按键按下后系统会调用对应的函数,XXX代表GUI工具里面的[ID值]名称,
  29. 如Button1,当返回值为false的时候系统将不再处理这个按键,返回true的时候系统将会继续处理此按键。比如SYS_BACK.
  30. *========================onSlideWindowItemClick_XXXX(int index)
  31. 当页面中存在滑动窗口并且用户点击了滑动窗口的图标后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称,
  32. 如slideWindow1;index 代表按下图标的偏移值
  33. *========================onSeekBarChange_XXXX(int progress)
  34. 当页面中存在滑动条并且用户改变了进度后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称,
  35. 如SeekBar1;progress 代表当前的进度值
  36. *========================ogetListItemCount_XXXX()
  37. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表的总数目,XXX代表GUI工具里面的[ID值]名称,
  38. 如List1;返回值为当前列表的总条数
  39. *========================oobtainListItemData_XXXX(ZKListView::ZKListItem *pListItem, int index)
  40. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表当前条目下的内容信息,XXX代表GUI工具里面的[ID值]名称,
  41. 如List1;pListItem 是贴图中的单条目对象,index是列表总目的偏移量。具体见函数说明
  42. *========================常用接口===============
  43. *LOGD(...) 打印调试信息的接口
  44. *mTextXXXPtr->setText("****") 在控件TextXXX上显示文字****
  45. *mButton1Ptr->setSelected(true); 将控件mButton1设置为选中模式,图片会切换成选中图片,按钮文字会切换为选中后的颜色
  46. *mSeekBarPtr->setProgress(12) 在控件mSeekBar上将进度调整到12
  47. *mListView1Ptr->refreshListView() 让mListView1 重新刷新,当列表数据变化后调用
  48. *mDashbroadView1Ptr->setTargetAngle(120) 在控件mDashbroadView1上指针显示角度调整到120度
  49. *
  50. * 在Eclipse编辑器中 使用 “alt + /” 快捷键可以打开智能提示
  51. */
  52. static bool dataInit = false; // false表示需要从数据库里获取数据,true表示从缓存里获取数据
  53. PartSetting partSetting;
  54. Json::Value frameRoom;
  55. Json::Value frameBedList;
  56. Json::Value frameInfo; // 缓存房间名字等
  57. Json::Value rightTitleInfo; // 缓存分机右边医生和护士标题
  58. Json::Value painterInfo;
  59. Json::Value painterInfoList;
  60. static bool serverInfo = true; // 判断是否需要从服务器获取服务器信息,第一次要,后续不要
  61. static int inBedCount = 0;
  62. static int emptyBedCount = 0;
  63. #define HELP_TIMER_HANDLE 3 // 增援的定时器id
  64. #define EVENT_TIME_HANDLE 8 // 事件定时器
  65. #define SLEEP_STRAT_TIME_HANDLE 9 // 息屏
  66. void setMainTheme() {
  67. int themeInt = StoragePreferences::getInt(STORE_THEME, defaultThemeInt);
  68. LOGD("themeInt =====> %d", themeInt);
  69. if (themeInt == 1) {
  70. mRoomPainterPtr->setBackgroundPic("/main/roomBg.png");
  71. mRoomPrcPainterPtr->setBackgroundPic("/main/fang.png");
  72. mInBedNumTextViewPtr->setTextColor(buleDeepColour);
  73. mInBedPicPainterPtr->setBackgroundPic("/main/chuang-l.png");
  74. }
  75. else if (themeInt == 2) {
  76. mRoomPainterPtr->setBackgroundPic("/main/roomBg-pink.png");
  77. mRoomPrcPainterPtr->setBackgroundPic("/main/fang-pink.png");
  78. mInBedNumTextViewPtr->setTextColor(redDeepColour);
  79. mInBedPicPainterPtr->setBackgroundPic("/main/chuang-l-pink.png");
  80. }
  81. }
  82. static void getServerInfo(){
  83. string url = getHttpGateway() + "/ncs_url/server_info";
  84. LOGD("请求服务器信息. url = %s", url.c_str());
  85. //发起HTTP GET请求
  86. RestClient::Response r = RestClient::get(url);
  87. //解析json
  88. Json::Reader reader;
  89. Json::Value root;
  90. if (reader.parse(r.body, root, false)){
  91. // http
  92. StoragePreferences::putString(STORE_GATEWAY, root["http_local_ip"].asString());
  93. StoragePreferences::putInt(STORE_HTTP_PORT, root["http_port"].asInt());
  94. // tcp
  95. StoragePreferences::putString(STORE_TCP_LOCAL_IP, root["tcp_local_ip"].asString());
  96. StoragePreferences::putInt(STORE_TCP_PORT, root["tcp_port"].asInt());
  97. // sip
  98. StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString());
  99. StoragePreferences::putInt(SIP_REG_PORT, root["sip_port"].asInt());
  100. serverInfo = false; // 只有请求成功了,才不需要重复请求
  101. }
  102. }
  103. // 读取空间缓存的数据
  104. static void getFrameInfo() {
  105. mRoomNameTextViewPtr->setText(frameInfo["full_name"].asString());
  106. }
  107. static void getBedCount() {
  108. if (mActivityPtr == NULL) {
  109. return;
  110. }
  111. mInBedNumTextViewPtr->setText(inBedCount);
  112. mEmptyBedNumTextViewPtr->setText(emptyBedCount);
  113. }
  114. static void getFrameRoom(int frame_id) {
  115. string url = getHttpGateway() + "/deviceRoom/get_frame_room/" + to_string(frame_id);
  116. LOGD("请求房间信息. url = %s", url.c_str());
  117. //发起HTTP GET请求
  118. RestClient::Response r = RestClient::get(url);
  119. LOGD("获得房间信息. result = %s", r.body.c_str());
  120. //解析json
  121. Json::Reader reader;
  122. Json::Value root;
  123. if (reader.parse(r.body, root, false)){
  124. frameRoom = root;
  125. frameBedList = root["frame_bed_list"];
  126. inBedCount = 0;
  127. emptyBedCount = 0;
  128. if (frameBedList.size() > 0) {
  129. for (int i = 0; i < frameBedList.size(); i++) {
  130. string customerId = frameBedList[i]["customer_id"].asString();
  131. if (customerId != "") {
  132. inBedCount += 1;
  133. }
  134. }
  135. emptyBedCount = frameBedList.size() - inBedCount;
  136. getBedCount();
  137. }
  138. if (mBedListViewPtr != NULL) {
  139. mBedListViewPtr->refreshListView();
  140. }
  141. }
  142. }
  143. // 将医生和护士别称缓存起来
  144. static void setRightTitle(Json::Value partSetting) {
  145. rightTitleInfo["doctor_title"] = partSetting["doctor_title"].asString();
  146. rightTitleInfo["doctor_valid"] = partSetting["doctor_valid"].asInt();
  147. rightTitleInfo["nurse_title"] = partSetting["nurse_title"].asString();
  148. rightTitleInfo["nurse_valid"] = partSetting["nurse_valid"].asInt();
  149. }
  150. static void getPartSetting(string partId){
  151. string url = getHttpGateway() + "/deviceBed/getPartSetting/" + partId;
  152. LOGD("请求科室信息. url = %s", url.c_str());
  153. //发起HTTP GET请求
  154. RestClient::Response r = RestClient::get(url);
  155. LOGD("获得科室信息. result = %s", r.body.c_str());
  156. //解析json
  157. Json::Reader reader;
  158. Json::Value root;
  159. if (reader.parse(r.body, root, false)){
  160. partSetting.partId = root["part_id"].asInt();
  161. partSetting.dayStart = root["day_start"].asString();
  162. partSetting.dayLight = root["day_light"].asInt();
  163. partSetting.dayVol = root["day_vol"].asInt();
  164. partSetting.dayRingVol = root["day_ring_vol"].asInt();
  165. partSetting.dayRingTimes = root["day_ring_times"].asInt();
  166. partSetting.dayNurseLed = root["day_nurse_led"].asInt();
  167. partSetting.dayDoorVol = root["day_door_vol"].asInt();
  168. partSetting.dayBedVol = root["day_bed_vol"].asInt();
  169. partSetting.dayTransferBoxVol = root["day_transfer_box_vol"].asInt();
  170. partSetting.dayTransferBoxSystemVol = root["day_transfer_box_system_vol"].asInt();
  171. partSetting.nightStart = root["night_start"].asString();
  172. partSetting.nightLight = root["night_light"].asInt();
  173. partSetting.nightVol = root["night_vol"].asInt();
  174. partSetting.nightRingVol = root["night_ring_vol"].asInt();
  175. partSetting.nightRingTimes = root["night_ring_times"].asInt();
  176. partSetting.nightNurseLed = root["night_nurse_led"].asInt();
  177. partSetting.nightDoorVol = root["night_door_vol"].asInt();
  178. partSetting.nightBedVol = root["night_bed_vol"].asInt();
  179. partSetting.nightTransferBoxVol = root["night_transfer_box_vol"].asInt();
  180. partSetting.nightTransferBoxSystemVol = root["night_transfer_box_system_vol"].asInt();
  181. partSetting.sleepSecondsNurse = root["sleep_seconds_nurse"].asInt();
  182. partSetting.sleepSecondsDoor = root["sleep_seconds_door"].asInt();
  183. partSetting.sleepSecondsBed = root["sleep_seconds_bed"].asInt();
  184. partSetting.sipOvertime = root["sip_overtime"].asInt();
  185. partSetting.transferDuration = root["transfer_duration"].asInt();
  186. partSetting.transferDurationLeader = root["transfer_duration_leader"].asInt();
  187. partSetting.communicationModeBed = root["communication_mode_bed"].asInt();
  188. partSetting.communicationModeNurse = root["communication_mode_nurse"].asInt();
  189. partSetting.communicationModeMobile = root["communication_model_mobile"].asInt();
  190. partSetting.customizeRoleCallFirst = root["customize_role_call_first"].asInt();
  191. partSetting.customizeRoleCallSecond = root["customize_role_call_second"].asInt();
  192. partSetting.customizeRoleCallThird = root["customize_role_call_third"].asInt();
  193. partSetting.customizeRoleCallFourth = root["customize_role_call_fourth"].asInt();
  194. partSetting.customizeRoleCallFifth = root["customize_role_call_fifth"].asInt();
  195. partSetting.customizeHospitalCallFirst = root["customize_hospital_call_first"].asInt();
  196. partSetting.customizeHospitalCallFirstName = root["customize_hospital_call_first_name"].asString();
  197. partSetting.customizeHospitalCallSecond = root["customize_hospital_call_second"].asInt();
  198. partSetting.customizeHospitalCallSecondName = root["customize_hospital_second_name"].asString();
  199. partSetting.customizeHospitalCallThird = root["customize_hospital_call_third"].asInt();
  200. partSetting.customizeHospitalCallThirdName = root["customize_hospital_call_third_name"].asString();
  201. partSetting.doctorTitle = root["doctor_title"].asString();
  202. partSetting.doctorValid = root["doctor_valid"].asInt();
  203. partSetting.nurseTitle = root["nurse_title"].asString();
  204. partSetting.nurseValid = root["nurse_valid"].asInt();
  205. partSetting.doorNurseTitle = root["door_nurse_title"].asString();
  206. partSetting.doorNurseValid = root["door_nurse_valid"].asInt();
  207. partSetting.doorNursingTitle = root["door_nursing_title"].asString();
  208. partSetting.doorNursingValid = root["door_nursing_valid"].asInt();
  209. partSetting.upSeconds = root["up_seconds"].asInt();
  210. partSetting.autoAccept = root["auto_accept"].asInt();
  211. partSetting.eventForward = root["event_forward"].asInt();
  212. partSetting.nursingColorRgb = root["nursing_color_rgb"].asString();
  213. partSetting.twoColorDoorLightValid = root["two_color_door_light_valid"].asInt();
  214. partSetting.qrUrl = root["qr_url"].asString();
  215. partSetting.screenLight = root["screen_light"].asInt();
  216. partSetting.roomCallBed = root["room_call_bed"].asInt();
  217. partSetting.autoPosition = root["auto_position"].asInt();
  218. partSetting.customerAgeHiddenOnDoor = root["customer_age_hidden_on_door"].asInt();
  219. if (root.isMember("linux_bed_volume_native")) {
  220. partSetting.linuxDoorVolumeNative = root["linux_door_volume_native"].asInt();
  221. partSetting.linuxDoorGainSize = root["linux_door_gain_size"].asInt();
  222. zk_audio_input_set_volume_native(0, 0);
  223. zk_audio_input_set_volume_native(1, partSetting.linuxDoorVolumeNative);
  224. GetTelephone()->SetInputPcmGainSize(partSetting.linuxDoorGainSize);
  225. StoragePreferences::putInt(STORE_VOLUME_NATIVE, partSetting.linuxDoorVolumeNative);
  226. StoragePreferences::putInt(STORE_GAIN_SIZE, partSetting.linuxDoorGainSize);
  227. }
  228. StoragePreferences::putString(STORE_DAY_START, partSetting.dayStart);
  229. StoragePreferences::putInt(STORE_DAY_LIGHT,partSetting.dayLight);
  230. StoragePreferences::putInt(STORE_DAY_VOL,partSetting.dayBedVol);
  231. StoragePreferences::putInt(STORE_DAY_RING_TIMES,partSetting.dayRingTimes);
  232. StoragePreferences::putString(STORE_NIGHT_START, partSetting.nightStart);
  233. StoragePreferences::putInt(STORE_NIGHT_LIGHT,partSetting.nightLight);
  234. StoragePreferences::putInt(STORE_NIGHT_VOL,partSetting.nightBedVol);
  235. StoragePreferences::putInt(STORE_NIGHT_RING_TIMES,partSetting.nightRingTimes);
  236. StoragePreferences::putInt(STORE_SLEEP_TIME, partSetting.sleepSecondsDoor);
  237. StoragePreferences::putString(STORE_DOCTOR_TITLE, partSetting.doctorTitle);
  238. StoragePreferences::putBool(STORE_DOCTOR_VISIBLE, partSetting.doctorValid==1);
  239. StoragePreferences::putString(STORE_NURSE_TITLE, partSetting.nurseTitle);
  240. StoragePreferences::putBool(STORE_NURSE_VISIBLE, partSetting.nurseValid==1);
  241. StoragePreferences::putString(STORE_NURSING_COLOR_RGB, partSetting.nursingColorRgb);
  242. StoragePreferences::putBool(STORE_AUDO_ANSWER, partSetting.autoAccept==1);
  243. StoragePreferences::putInt(STORE_SCREEN_LIGHT, partSetting.screenLight);
  244. StoragePreferences::putInt(STORE_ROOM_CALL_BED, partSetting.roomCallBed);
  245. StoragePreferences::putInt(STORE_AUTO_POSITION, partSetting.autoPosition);
  246. setRightTitle(root);
  247. callBedButtonSetVisible();
  248. getFrameRoom(frameInfo["frame_id"].asInt());
  249. dataInit = true;
  250. }
  251. }
  252. static void getVersion() {
  253. std::string url = getHttpGateway() + "/deviceRoom/get_app_version?device_type=403&part_id=" + StoragePreferences::getString(STORE_PARTID, "");
  254. std::string content_type = std::string("application/json");
  255. LOGD("请求版本信息. url = %s", url.c_str());
  256. //发起HTTP POST请求
  257. RestClient::Response r = RestClient::post(url, content_type, "");
  258. if (r.code != 200) {
  259. LOGD("请求版本信息-> 错误代码: %d", r.code);
  260. return;
  261. }
  262. LOGD("获得版本信息. result = %s", r.body.c_str());
  263. //解析json
  264. Json::Reader reader;
  265. Json::Value root;
  266. if(reader.parse(r.body, root, false)) {
  267. int currentVersionNo = getVersionNo();
  268. int responseVersionNo = root["version_no"].asInt();
  269. std::string responseVersion = root["version_code"].asString();
  270. LOGD("服务器版本 : %s %d, 当前设备版本: %d", responseVersion.c_str(), responseVersionNo, currentVersionNo);
  271. if (currentVersionNo < responseVersionNo) {
  272. Intent* intent = new Intent();
  273. intent->putExtra(appUpdate, "true");
  274. EASYUICONTEXT->openActivity("updateActivity", intent);
  275. }
  276. }
  277. }
  278. static void getNfcInteraction() {
  279. std::string url = getHttpGateway() + "/deviceRoom/get_nfc_interaction_end_time_is_null/" + to_string(StoragePreferences::getInt(STORE_DEVICE_ID,0));
  280. LOGD("请求未完成的nfc记录. url = %s", url.c_str());
  281. //发起HTTP POST请求
  282. RestClient::Response r = RestClient::get(url);
  283. if (r.code != 200) {
  284. LOGD("请求未完成的nfc记录-> 错误代码: %d", r.code);
  285. return;
  286. }
  287. LOGD("获得未完成的nfc记录. result = %s", r.body.c_str());
  288. //解析json
  289. Json::Reader reader;
  290. Json::Value root;
  291. if(reader.parse(r.body, root, false)) {
  292. int clerkId = 0;
  293. for (int i = 0; i < root.size(); i++) {
  294. if (root[i]["components_type"].asCString() == TcpType::AUTH) {
  295. clerkId = root[i]["clerk_id"].asInt();
  296. setClerk(root[i]["clerk_name"].asCString(), root[i]["pass_no"].asCString(), root[i]["id"].asInt());
  297. }
  298. else if (root[i]["components_type"].asString() == "POSITION_COMPONENT") {
  299. setPosistionItId(root[i]["id"].asInt());
  300. setPositionButton(true);
  301. }
  302. else if (root[i]["components_type"].asString() == "ROOMCHECK_COMPONENT") {
  303. setRoomCheckItId(root[i]["id"].asInt());
  304. setRoomPatrolButton(true);
  305. }
  306. else if (root[i]["components_type"].asString() == "SCREEN_TIP_SET_COMPONENT") {
  307. time_t now = TimeHelper::getDateline();
  308. if (now <= 0) {
  309. continue;
  310. }
  311. Json::Reader Reader;
  312. Json::Value operationData;
  313. Reader.parse(root[i]["operation_data"].asString(), operationData);
  314. int seconds = operationData["seconds"].asInt();
  315. if (now - root[i]["start_time"].asInt() < seconds) {
  316. setPromptTimeItId(root[i]["id"].asInt());
  317. Intent* intent = new Intent();
  318. intent->putExtra(promptText2, operationData["tips"].asString());
  319. intent->putExtra(promptTime2, to_string(seconds - (now - root[i]["start_time"].asInt())));
  320. EASYUICONTEXT->openActivity("promptActivity", intent);
  321. }
  322. else {
  323. sendPromptQuit(root[i]["id"].asInt());
  324. }
  325. }
  326. }
  327. if (clerkId != 0) {
  328. goCare();
  329. }
  330. }
  331. }
  332. static void getDeviceInfo(){
  333. if (dataInit){
  334. getFrameInfo();
  335. getBedCount();
  336. return;
  337. }
  338. string url = getHttpGateway() + "/deviceRoom/get_device_by_eth_mac/" + StoragePreferences::getString(STORE_MAC_ADDR, "0.0.0.0");
  339. LOGD("请求设备信息. url = %s", url.c_str());
  340. //发起HTTP GET请求
  341. RestClient::Response r = RestClient::get(url);
  342. LOGD("获得设备信息. result = %s", r.body.c_str());
  343. //解析json
  344. Json::Reader reader;
  345. Json::Value root;
  346. if (reader.parse(r.body, root, false)){
  347. string partName = root["part_display"].asString();
  348. StoragePreferences::putString(STORE_PARTNAME,partName);
  349. NavibarSetPartName(partName);
  350. //设备
  351. StoragePreferences::putInt(STORE_DEVICE_ID, root["id"].asInt());
  352. StoragePreferences::putInt(STORE_DEVICE_TYPE, root["device_type"].asInt());
  353. //SIP存储
  354. // StoragePreferences::putString(SIP_REG_DOMAIN, root["sip_ip"].asString()); // 应该去找配置文件里的sip-ip
  355. StoragePreferences::putString(SIP_REG_ACCOUNT,root["sip_id"].asString());
  356. StoragePreferences::putString(SIP_REG_PASSWORD, root["sip_password"].asString());
  357. frameInfo["frame_id"] = root["frame_id"].asInt();
  358. frameInfo["full_name"] = root["full_name"].asString();
  359. frameInfo["part_id"] = root["part_id"].asInt();
  360. getFrameInfo();
  361. //获取科室设置
  362. string partId = root["part_id"].asString();
  363. StoragePreferences::putString(STORE_PARTID, partId);
  364. getPartSetting(partId);
  365. getVersion();
  366. getNfcInteraction();
  367. }
  368. }
  369. Json::Value getFrame() {
  370. return frameRoom;
  371. }
  372. // 收到tcp的时候,刷新数据
  373. void dataRefresh() {
  374. LOGD("DATA-REFRESH, 数据刷新");
  375. if (mActivityPtr == NULL) {
  376. return;
  377. }
  378. if (serverInfo) {
  379. getServerInfo();
  380. }
  381. dataInit = false;
  382. getDeviceInfo();
  383. mBedListViewPtr->refreshListView();
  384. }
  385. void getPartSetting() {
  386. getPartSetting(StoragePreferences::getString(STORE_PARTID, ""));
  387. }
  388. /**
  389. * 注册定时器
  390. * 填充数组用于注册定时器
  391. * 注意:id不能重复
  392. */
  393. static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
  394. //{0, 6000}, //定时器id=0, 时间间隔6秒
  395. //{1, 1000},
  396. };
  397. /**
  398. * 当界面构造时触发
  399. */
  400. static void onUI_init(){
  401. //run("this is thread name");
  402. //测试用
  403. LOGD("进入mainLogic页面, 触发 onUI_init");
  404. if (ETHERNETMANAGER->isConnected() || WIFIMANAGER->isConnected()) {
  405. if(serverInfo) { // 如果是false,就是不需要
  406. getServerInfo();
  407. }
  408. getDeviceInfo();
  409. }
  410. }
  411. /**
  412. * 当切换到该界面时触发
  413. */
  414. static void onUI_intent(const Intent *intentPtr) {
  415. if (intentPtr != NULL) {
  416. }
  417. }
  418. /*
  419. * 当界面显示时触发
  420. */
  421. static void onUI_show() {
  422. EASYUICONTEXT->showStatusBar();
  423. EASYUICONTEXT->showNaviBar();
  424. setMainTheme();
  425. }
  426. /*
  427. * 当界面隐藏时触发
  428. */
  429. static void onUI_hide() {
  430. }
  431. /*
  432. * 当界面完全退出时触发
  433. */
  434. static void onUI_quit() {
  435. //pthread_exit(NULL);
  436. }
  437. /**
  438. * 串口数据回调接口
  439. */
  440. static void onProtocolDataUpdate(const SProtocolData &data) {
  441. }
  442. /**
  443. * 定时器触发函数
  444. * 不建议在此函数中写耗时操作,否则将影响UI刷新
  445. * 参数: id
  446. * 当前所触发定时器的id,与注册时的id相同
  447. * 返回值: true
  448. * 继续运行当前定时器
  449. * false
  450. * 停止运行当前定时器
  451. */
  452. static bool onUI_Timer(int id){
  453. switch (id) {
  454. default:
  455. break;
  456. }
  457. return true;
  458. }
  459. /**
  460. * 有新的触摸事件时触发
  461. * 参数:ev
  462. * 新的触摸事件
  463. * 返回值:true
  464. * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上
  465. * false
  466. * 触摸事件将继续传递到控件上
  467. */
  468. static bool onmainActivityTouchEvent(const MotionEvent &ev) {
  469. switch (ev.mActionStatus) {
  470. case MotionEvent::E_ACTION_DOWN://触摸按下
  471. //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY);
  472. break;
  473. case MotionEvent::E_ACTION_MOVE://触摸滑动
  474. break;
  475. case MotionEvent::E_ACTION_UP: //触摸抬起
  476. break;
  477. default:
  478. break;
  479. }
  480. return false;
  481. }
  482. static int getListItemCount_BedListView(const ZKListView *pListView) {
  483. //LOGD("getListItemCount_BedListView !\n");
  484. return frameBedList.size();
  485. }
  486. static void obtainListItemData_BedListView(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
  487. //LOGD(" obtainListItemData_ BedListView !!!\n");
  488. if (frameBedList.size() > 0) {
  489. ZKListView::ZKListSubItem* bedNum = pListItem->findSubItemByID(ID_MAIN_BedNumSubItem);
  490. ZKListView::ZKListSubItem* name = pListItem->findSubItemByID(ID_MAIN_CustomerNameSubItem);
  491. ZKListView::ZKListSubItem* age = pListItem->findSubItemByID(ID_MAIN_AgeSubItem);
  492. ZKListView::ZKListSubItem* sex = pListItem->findSubItemByID(ID_MAIN_SexSubItem);
  493. ZKListView::ZKListSubItem* doctorTitle = pListItem->findSubItemByID(ID_MAIN_DoctorTitileSubItem);
  494. ZKListView::ZKListSubItem* nurseTitle = pListItem->findSubItemByID(ID_MAIN_NurseTitleSubItem);
  495. ZKListView::ZKListSubItem* doctor = pListItem->findSubItemByID(ID_MAIN_DoctorSubItem);
  496. ZKListView::ZKListSubItem* nurse = pListItem->findSubItemByID(ID_MAIN_NurseSubItem);
  497. int themeInt = StoragePreferences::getInt(STORE_THEME, defaultThemeInt);
  498. if (themeInt == 1) {
  499. bedNum->setBackgroundPic("/main/bedNameBg.png");
  500. }
  501. else if (themeInt == 2) {
  502. bedNum->setBackgroundPic("/main/bedNameBg-pink.png");
  503. }
  504. string frameBedName = frameBedList[index]["frame_bed"]["full_name"].asString();
  505. if (frameBedName == "") {
  506. bedNum->setText(LANGUAGEMANAGER->getValue("EmptyBed"));
  507. } else {
  508. int nPos = frameBedName.find("-");
  509. if (nPos != -1) {
  510. frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
  511. }
  512. bedNum->setText(frameBedName);
  513. }
  514. // 用户相关
  515. string customerName = frameBedList[index]["customer_name"].asString();
  516. if (customerName == "") {
  517. name->setText(LANGUAGEMANAGER->getValue("EmptyCustomer"));
  518. } else {
  519. name->setText(customerName);
  520. }
  521. if (partSetting.customerAgeHiddenOnDoor != 0) {
  522. if (frameBedList[index]["customer_age"].asString() == "") {
  523. age->setText("");
  524. } else {
  525. age->setText("*" + frameBedList[index]["customer_age_unit"].asString());
  526. }
  527. }
  528. else {
  529. age->setText(frameBedList[index]["customer_age"].asString() + frameBedList[index]["customer_age_unit"].asString());
  530. }
  531. string customerSex = frameBedList[index]["customer_sex"].asString();
  532. if (customerSex == "0") { // 如果性别为女性,替换成女性,底色为粉色
  533. sex->setText(LANGUAGEMANAGER->getValue("Woman"));
  534. sex->setTextColor(0xFF9F9F);
  535. sex->setBackgroundPic("main/woman.png");
  536. }
  537. else if (customerSex == "1") {
  538. sex->setText(LANGUAGEMANAGER->getValue("Man"));
  539. sex->setTextColor(0x3A78EF);
  540. sex->setBackgroundPic("main/man.png");
  541. }
  542. else {
  543. sex->setText(LANGUAGEMANAGER->getValue("Unknown"));
  544. sex->setTextColor(0x37B643);
  545. sex->setBackgroundPic("main/age.png");
  546. }
  547. // 医生护士相关
  548. if (rightTitleInfo["doctor_valid"] != 1){
  549. doctorTitle->setVisible(false);
  550. } else {
  551. doctorTitle->setText(rightTitleInfo["doctor_title"].asString());
  552. }
  553. if (rightTitleInfo["nurse_valid"] != 1){
  554. nurseTitle->setVisible(false);
  555. } else {
  556. nurseTitle->setText(rightTitleInfo["nurse_title"].asString());
  557. }
  558. doctor->setText(frameBedList[index]["doctor_name"].asString());
  559. nurse->setText(frameBedList[index]["nurse_name"].asString());
  560. // // 护理项相关
  561. // Json::Value nurseConfigList = frameBedList[index]["nurse_config_dtos"];
  562. // if (nurseConfigList.size() > 0) {
  563. // for (int i = 0; i < 5; i++) {
  564. // int nurseConfigColorNumber = ID_MAIN_NurseConfigColor1 + i;
  565. // int nurseConfigNumber = ID_MAIN_NurseConfig1 + i * 2;
  566. // int nurseOptionNumber = ID_MAIN_NurseOption1 + i * 2;
  567. // if (nurseConfigList.size() >= i) {
  568. // //颜色
  569. // string nurseConfigColot = nurseConfigList[i]["nurse_color_rbg"].asString();
  570. // uint32_t bgColor = 0xFFC0C0C0;
  571. // if (nurseConfigColot != "") {
  572. // string rgbStr = "FF" + nurseConfigColot;
  573. // transform(rgbStr.begin(), rgbStr.end(), rgbStr.begin(), ::toupper);
  574. // bgColor = strtoul(("0x" + rgbStr).c_str(), NULL,16);
  575. // }
  576. // pListItem->findSubItemByID(nurseConfigColorNumber)->setBackgroundColor(bgColor);
  577. // pListItem->findSubItemByID(nurseConfigNumber)->setText(nurseConfigList[i]["nurse_config_name"].asString());
  578. // string nurseOptionName = nurseConfigList[i]["nurse_option_name"].asString();
  579. // if (nurseOptionName == "") {
  580. // nurseOptionName = LANGUAGEMANAGER->getValue("None");
  581. // }
  582. // pListItem->findSubItemByID(nurseOptionNumber)->setText(nurseOptionName);
  583. //
  584. // } else {
  585. // //颜色
  586. // pListItem->findSubItemByID(nurseConfigColorNumber)->setBackgroundColor(0xFFC0C0C0);
  587. // pListItem->findSubItemByID(nurseConfigNumber)->setText(nurseConfigList[i]["nurse_config_name"].asString());
  588. // pListItem->findSubItemByID(nurseOptionNumber)->setText(LANGUAGEMANAGER->getValue("None"));
  589. // }
  590. // }
  591. // }
  592. // else {
  593. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor1)->setBackgroundColor(0xFFC0C0C0);
  594. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor2)->setBackgroundColor(0xFFC0C0C0);
  595. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor3)->setBackgroundColor(0xFFC0C0C0);
  596. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor4)->setBackgroundColor(0xFFC0C0C0);
  597. // pListItem->findSubItemByID(ID_MAIN_NurseConfigColor5)->setBackgroundColor(0xFFC0C0C0);
  598. // pListItem->findSubItemByID(ID_MAIN_NurseConfig1)->setText("");
  599. // pListItem->findSubItemByID(ID_MAIN_NurseConfig2)->setText("");
  600. // pListItem->findSubItemByID(ID_MAIN_NurseConfig3)->setText("");
  601. // pListItem->findSubItemByID(ID_MAIN_NurseConfig4)->setText("");
  602. // pListItem->findSubItemByID(ID_MAIN_NurseConfig5)->setText("");
  603. // pListItem->findSubItemByID(ID_MAIN_NurseOption1)->setText(LANGUAGEMANAGER->getValue("None"));
  604. // pListItem->findSubItemByID(ID_MAIN_NurseOption2)->setText(LANGUAGEMANAGER->getValue("None"));
  605. // pListItem->findSubItemByID(ID_MAIN_NurseOption3)->setText(LANGUAGEMANAGER->getValue("None"));
  606. // pListItem->findSubItemByID(ID_MAIN_NurseOption4)->setText(LANGUAGEMANAGER->getValue("None"));
  607. // pListItem->findSubItemByID(ID_MAIN_NurseOption5)->setText(LANGUAGEMANAGER->getValue("None"));
  608. // }
  609. }
  610. }
  611. static void onListItemClick_BedListView(ZKListView *pListView, int index, int id) {
  612. //LOGD(" onListItemClick_ BedListView !!!\n");
  613. }