mainLogic.cc 48 KB

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