mainLogic.cc 25 KB

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