mainLogic.cc 30 KB

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