medicalCareLogic.cc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. #pragma once
  2. #include "uart/ProtocolSender.h"
  3. #include "core/utilities.h"
  4. #include "base/strings.hpp"
  5. #include "service/BusinessConfig.h"
  6. #include "restclient-cpp/restclient.h"
  7. /*
  8. *此文件由GUI工具生成
  9. *文件功能:用于处理用户的逻辑相应代码
  10. *功能说明:
  11. *========================onButtonClick_XXXX
  12. 当页面中的按键按下后系统会调用对应的函数,XXX代表GUI工具里面的[ID值]名称,
  13. 如Button1,当返回值为false的时候系统将不再处理这个按键,返回true的时候系统将会继续处理此按键。比如SYS_BACK.
  14. *========================onSlideWindowItemClick_XXXX(int index)
  15. 当页面中存在滑动窗口并且用户点击了滑动窗口的图标后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称,
  16. 如slideWindow1;index 代表按下图标的偏移值
  17. *========================onSeekBarChange_XXXX(int progress)
  18. 当页面中存在滑动条并且用户改变了进度后系统会调用此函数,XXX代表GUI工具里面的[ID值]名称,
  19. 如SeekBar1;progress 代表当前的进度值
  20. *========================ogetListItemCount_XXXX()
  21. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表的总数目,XXX代表GUI工具里面的[ID值]名称,
  22. 如List1;返回值为当前列表的总条数
  23. *========================oobtainListItemData_XXXX(ZKListView::ZKListItem *pListItem, int index)
  24. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表当前条目下的内容信息,XXX代表GUI工具里面的[ID值]名称,
  25. 如List1;pListItem 是贴图中的单条目对象,index是列表总目的偏移量。具体见函数说明
  26. *========================常用接口===============
  27. *LOGD(...) 打印调试信息的接口
  28. *mTextXXXPtr->setText("****") 在控件TextXXX上显示文字****
  29. *mButton1Ptr->setSelected(true); 将控件mButton1设置为选中模式,图片会切换成选中图片,按钮文字会切换为选中后的颜色
  30. *mSeekBarPtr->setProgress(12) 在控件mSeekBar上将进度调整到12
  31. *mListView1Ptr->refreshListView() 让mListView1 重新刷新,当列表数据变化后调用
  32. *mDashbroadView1Ptr->setTargetAngle(120) 在控件mDashbroadView1上指针显示角度调整到120度
  33. *
  34. * 在Eclipse编辑器中 使用 “alt + /” 快捷键可以打开智能提示
  35. */
  36. Json::Value clerk;
  37. Json::Value clerkList;
  38. static string frameFullName;
  39. static string frameBedNameList = "";
  40. static bool isPosition = false;
  41. static bool isRoomPatrol = false;
  42. static bool isNursing = false;
  43. static int positionItId = 0;
  44. static int roomCheckItId = 0;
  45. static int authItId = 0;
  46. static int chooseId = 0;
  47. static bool isChoose = false;
  48. static int medicalCareThemeInt = defaultThemeInt;
  49. static uint32_t medicalCareColor = buleDeepColour;
  50. #define NURSEING_TIME_HANDLE 12 // 护理
  51. void setMedicalCareTheme() {
  52. medicalCareThemeInt = StoragePreferences::getInt(STORE_THEME, defaultThemeInt);
  53. if (medicalCareThemeInt == 1) {
  54. mLoginMsgPicPainterPtr->setBackgroundPic("/medicalCare/yanz.png");
  55. mLoginPicPainterPtr->setBackgroundPic("/medicalCare/dianhua.png");
  56. mPasswordEditTextPtr->setBackgroundPic("/medicalCare/input_253x44.png");
  57. mEnteringMedicalCareButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "/button/elliptic_bule.png");
  58. mNfcPicPainterPtr->setBackgroundPic("/medicalCare/nfc.png");
  59. mChooseMsgPicPainterPtr->setBackgroundPic("/medicalCare/yanz.png");
  60. mEnteringButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "/button/elliptic_bule.png");
  61. mLogoutButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "/button/elliptic_bule2.png");
  62. mPromptPainterPtr->setBackgroundPic("/medicalCare/tishi.png");
  63. medicalCareColor = buleDeepColour;
  64. }
  65. else if (medicalCareThemeInt == 2) {
  66. mLoginMsgPicPainterPtr->setBackgroundPic("/medicalCare/yanz-pink.png");
  67. mLoginPicPainterPtr->setBackgroundPic("/medicalCare/dianhua-pink.png");
  68. mPasswordEditTextPtr->setBackgroundPic("/medicalCare/input_pink_253x44.png");
  69. mEnteringMedicalCareButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "/button/elliptic_pink.png");
  70. mNfcPicPainterPtr->setBackgroundPic("/medicalCare/nfc-pink.png");
  71. mChooseMsgPicPainterPtr->setBackgroundPic("/medicalCare/yanz-pink.png");
  72. mEnteringButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "/button/elliptic_pink.png");
  73. mLogoutButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "/button/elliptic_pink2.png");
  74. mPromptPainterPtr->setBackgroundPic("/medicalCare/tishi-pink.png");
  75. medicalCareColor = redDeepColour;
  76. }
  77. mHelloTextViewPtr->setTextColor(medicalCareColor);
  78. }
  79. static void getClerkList() {
  80. string url = getHttpGateway() + "/deviceRoom/get_clerk_by_part_id/" + StoragePreferences::getString(STORE_PARTID, "");
  81. LOGD("请求科室所有员工. url = %s", url.c_str());
  82. //发起HTTP GET请求
  83. RestClient::Response r = RestClient::get(url);
  84. LOGD("获得科室所有员工列表. result = %s", r.body.c_str());
  85. //解析json
  86. Json::Reader reader;
  87. Json::Value root;
  88. if (reader.parse(r.body, root, false)){
  89. if (root.size() > 0) {
  90. Json::Value clerks;
  91. for (int i = 0; i < root.size(); i++) {
  92. if (root[i]["pass_no"].asString() != "") {
  93. clerks.append(root[i]);
  94. }
  95. }
  96. clerkList = clerks;
  97. }
  98. }
  99. }
  100. static bool getClerkByPartIdAndPassNo(std::string passNo) {
  101. string url = getHttpGateway() + "/deviceRoom/get_clerk_by_part_id_and_pass_no/" + StoragePreferences::getString(STORE_PARTID, "") + "/" + passNo;
  102. LOGD("根据科室id和卡号查询员工. url = %s", url.c_str());
  103. //发起HTTP GET请求
  104. RestClient::Response r = RestClient::get(url);
  105. LOGD("根据科室id和卡号查询员工. result = %s", r.body.c_str());
  106. //解析json
  107. Json::Reader reader;
  108. Json::Value root;
  109. if (reader.parse(r.body, root, false)){
  110. if (root.isMember("clerk_id")) {
  111. clerk = root;
  112. return true;
  113. }
  114. }
  115. return false;
  116. }
  117. std::string getClerkPassNo() {
  118. return clerk["pass_no"].asCString();
  119. }
  120. void setClerk(std::string clerk_name, std::string pass_no, int _authItid) {
  121. isChoose = true;
  122. clerk["clerk_name"] = clerk_name;
  123. clerk["pass_no"] = pass_no;
  124. authItId = _authItid;
  125. }
  126. int getAuthItId() {
  127. return authItId;
  128. }
  129. void setAuthItId(int id) {
  130. authItId = id;
  131. }
  132. void setPosistionItId(int id) {
  133. positionItId = id;
  134. }
  135. void setRoomCheckItId(int id) {
  136. roomCheckItId = id;
  137. }
  138. void setPositionButton(bool setPosition) {
  139. isPosition = setPosition;
  140. if (mActivityPtr == NULL) {
  141. return;
  142. }
  143. if (setPosition) {
  144. mPositionPainterPtr->setBackgroundPic("medicalCare/ding-y.png");
  145. mPositionButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "medicalCare/yellow_199x281.png");
  146. mPositionButtonPtr->setText(LANGUAGEMANAGER->getValue("Positioned"));
  147. mPositionButtonPtr->setTextColor(0xFFFFFFFF);
  148. mPositionTextViewPtr->setTextColor(0xFFFFFFFF);
  149. mPositionButtonPtr->setTouchable(false);
  150. }
  151. else {
  152. mPositionPainterPtr->setBackgroundPic("medicalCare/ding.png");
  153. mPositionButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "medicalCare/white_199x281.png");
  154. mPositionButtonPtr->setText(LANGUAGEMANAGER->getValue("Position"));
  155. mPositionButtonPtr->setTextColor(0xFF000000);
  156. mPositionTextViewPtr->setTextColor(0xFF7D7D7D);
  157. mPositionButtonPtr->setTouchable(true);
  158. }
  159. }
  160. void setPosition(bool setPosition) {
  161. if (setPosition) {
  162. setPositionButton(setPosition);
  163. Json::Value json;
  164. json["passNo"] = clerk["pass_no"].asCString();
  165. json["operationData"] = "";
  166. TcpModel tcpModel;
  167. tcpModel.tid = base::format("t%d", TimeHelper::getCurrentTime());
  168. tcpModel.type = TcpType::POSITION;
  169. tcpModel.action = PositionAction::POSITION_START;
  170. tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
  171. tcpModel.to_id = 0;
  172. tcpModel.json = json;
  173. sendTcpModel(tcpModel);
  174. }
  175. else {
  176. setPositionButton(setPosition);
  177. if (positionItId != 0) {
  178. // TcpModel tcpModel;
  179. // tcpModel.tid = base::format("t%d", TimeHelper::getCurrentTime());
  180. // tcpModel.type = TcpType::POSITION;
  181. // tcpModel.action = PositionAction::POSITION_END;
  182. // tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
  183. // tcpModel.to_id = 0;
  184. // tcpModel.data = to_string(positionItId);
  185. // sendTcpModel(tcpModel);
  186. positionItId = 0;
  187. }
  188. }
  189. }
  190. void setRoomPatrolButton(bool setRoomPatrol) {
  191. isRoomPatrol = setRoomPatrol;
  192. if (mActivityPtr == NULL) {
  193. return;
  194. }
  195. if (setRoomPatrol) {
  196. mRoomPatrolPainterPtr->setBackgroundPic("medicalCare/xun-y.png");
  197. mRoomPatrolButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "medicalCare/green_199x281.png");
  198. mRoomPatrolButtonPtr->setText(LANGUAGEMANAGER->getValue("RoomPatrolCompleted"));
  199. mRoomPatrolButtonPtr->setTextColor(0xFFFFFFFF);
  200. mRoomPatrolTextViewPtr->setTextColor(0xFFFFFFFF);
  201. mRoomPatrolButtonPtr->setTouchable(false);
  202. }
  203. else {
  204. mRoomPatrolPainterPtr->setBackgroundPic("medicalCare/xun.png");
  205. mRoomPatrolButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "medicalCare/white_199x281.png");
  206. mRoomPatrolButtonPtr->setText(LANGUAGEMANAGER->getValue("RoomPatrol"));
  207. mRoomPatrolButtonPtr->setTextColor(0xFF000000);
  208. mRoomPatrolTextViewPtr->setTextColor(0xFF7D7D7D);
  209. mRoomPatrolButtonPtr->setTouchable(true);
  210. }
  211. }
  212. void setRoomPatrol(bool setRoomPatrol) {
  213. if (setRoomPatrol) {
  214. setRoomPatrolButton(setRoomPatrol);
  215. Json::Value json;
  216. json["passNo"] = clerk["pass_no"].asCString();
  217. json["operationData"] = "";
  218. TcpModel tcpModel;
  219. tcpModel.tid = base::format("t%d", TimeHelper::getCurrentTime());
  220. tcpModel.type = TcpType::ROOMCHECK;
  221. tcpModel.action = RoomCheckAction::START;
  222. tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
  223. tcpModel.to_id = 0;
  224. tcpModel.json = json;
  225. sendTcpModel(tcpModel);
  226. }
  227. else {
  228. setRoomPatrolButton(setRoomPatrol);
  229. if (roomCheckItId != 0) {
  230. // TcpModel tcpModel;
  231. // tcpModel.tid = base::format("t%d", TimeHelper::getCurrentTime());
  232. // tcpModel.type = TcpType::ROOMCHECK;
  233. // tcpModel.action = RoomCheckAction::END;
  234. // tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
  235. // tcpModel.to_id = 0;
  236. // tcpModel.data = to_string(roomCheckItId);
  237. // sendTcpModel(tcpModel);
  238. //
  239. roomCheckItId = 0;
  240. }
  241. }
  242. }
  243. void setNursingEnd() {
  244. StoragePreferences::putBool(STORE_NURSING_TYPE, false);
  245. if (StoragePreferences::getString(STORE_NURSING_INTERACTION_ID, "") != "") { // 对比一下,json里面不为空的时候
  246. // 发送tcp, tcp_type = SIDE, tcp_action = NURSING_END
  247. TcpModel tcpModel;
  248. tcpModel.tid = base::format("t%d", TimeHelper::getCurrentTime());
  249. tcpModel.type = TcpType::SIDE;
  250. tcpModel.action = SideAction::NURSING_END;
  251. tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
  252. tcpModel.data = StoragePreferences::getString(STORE_NURSING_INTERACTION_ID, ""); // 获取nursingTcpModel里,id字段的数据
  253. sendTcpModel(tcpModel);
  254. // 需要把护理的interactionId清空
  255. StoragePreferences::putString(STORE_NURSING_INTERACTION_ID, "");
  256. }
  257. }
  258. void setNursingButton(bool setNursing) {
  259. isNursing = setNursing;
  260. if (mActivityPtr == NULL) {
  261. return;
  262. }
  263. if (setNursing) {
  264. mNursingPainterPtr->setBackgroundPic("medicalCare/hu-y.png");
  265. mNursingButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "medicalCare/pink_199x281.png");
  266. mNursingButtonPtr->setText(LANGUAGEMANAGER->getValue("InNursing"));
  267. mNursingButtonPtr->setTextColor(0xFFFFFFFF);
  268. mNursingTextViewPtr->setTextColor(0xFFFFFFFF);
  269. }
  270. else {
  271. mNursingPainterPtr->setBackgroundPic("medicalCare/hu.png");
  272. mNursingButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "medicalCare/white_199x281.png");
  273. mNursingButtonPtr->setText(LANGUAGEMANAGER->getValue("Nursing"));
  274. mNursingButtonPtr->setTextColor(0xFF000000);
  275. mNursingTextViewPtr->setTextColor(0xFF7D7D7D);
  276. }
  277. }
  278. void setNursing(bool setNursing) {
  279. if (setNursing) {
  280. setNursingButton(setNursing);
  281. // 门灯控制
  282. std::string color = StoragePreferences::getString(STORE_NURSING_COLOR_RGB, "010");
  283. if (color != "" && color.size() == 3) {
  284. color = color + "F";
  285. } else {
  286. color = "010F";
  287. }
  288. lightControl("DOORLED", color);
  289. // 发送tcp, tcp_type = SIDE, tcp_action = NURSING
  290. TcpModel tcpModel;
  291. tcpModel.tid = base::format("t%d",TimeHelper::getCurrentTime());
  292. tcpModel.type = TcpType::SIDE;
  293. tcpModel.action = SideAction::NURSING;
  294. tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
  295. tcpModel.to_id = 0;
  296. sendTcpModel(tcpModel);
  297. // 把护理状态缓存起来
  298. StoragePreferences::putBool(STORE_NURSING_TYPE, true);
  299. }
  300. else {
  301. setNursingButton(setNursing);
  302. lightControl("DOORLED", "000F");
  303. setNursingEnd();
  304. }
  305. }
  306. void setNursingTime(int time) {
  307. mActivityPtr->registerUserTimer(NURSEING_TIME_HANDLE, time * 60 * 1000); // 300秒
  308. setNursing(true);
  309. }
  310. void setNursingFalse() {
  311. mActivityPtr->unregisterUserTimer(NURSEING_TIME_HANDLE); // 300秒
  312. setNursing(false);
  313. }
  314. void logoutMedicalCare() {
  315. isChoose = false;
  316. setPosition(false);
  317. setRoomPatrol(false);
  318. setNursing(false);
  319. clerk.clear();
  320. if (mActivityPtr != NULL) {
  321. mPasswordEditTextPtr->setText("");
  322. mMedicalCareWindowPtr->hideWnd();
  323. mChooseClerkWindowPtr->hideWnd();
  324. mLoginWindowPtr->showWnd();
  325. }
  326. if (authItId != 0) {
  327. // 发送tcp, tcp_type = AUTH, tcp_action = LOGOUT
  328. TcpModel tcpModel;
  329. tcpModel.tid = base::format("t%d",TimeHelper::getCurrentTime());
  330. tcpModel.type = TcpType::AUTH;
  331. tcpModel.action = AuthAction::LOGOUT;
  332. tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
  333. tcpModel.to_id = 0;
  334. tcpModel.data = to_string(authItId);
  335. sendTcpModel(tcpModel);
  336. authItId = 0;
  337. }
  338. }
  339. void loginMedicalCare() {
  340. mLoginWindowPtr->hideWnd();
  341. mChooseClerkWindowPtr->hideWnd();
  342. mMedicalCareWindowPtr->showWnd();
  343. Json::Value json;
  344. json["passNo"] = clerk["pass_no"].asCString();
  345. json["operationData"] = "";
  346. // 发送tcp, tcp_type = AUTH, tcp_action = LOGIN
  347. TcpModel tcpModel;
  348. tcpModel.tid = base::format("t%d",TimeHelper::getCurrentTime());
  349. tcpModel.type = TcpType::AUTH;
  350. tcpModel.action = AuthAction::LOGIN;
  351. tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
  352. tcpModel.to_id = 0;
  353. tcpModel.json = json;
  354. sendTcpModel(tcpModel);
  355. if (StoragePreferences::getInt(STORE_AUTO_POSITION, 0)) {
  356. setPosition(true);
  357. }
  358. }
  359. void nfcLogin(std::string revStr) {
  360. if (mActivityPtr == NULL) {
  361. LOGD("不在医护界面");
  362. return;
  363. }
  364. if (isChoose) {
  365. LOGD("已经存在员工");
  366. return;
  367. }
  368. bool reslut = getClerkByPartIdAndPassNo(revStr);
  369. if (reslut) {
  370. isChoose = true;
  371. mClerkNameTextViewPtr->setText(clerk["clerk_name"].asString() + " " + clerk["role_name"].asString());
  372. loginMedicalCare();
  373. }
  374. else {
  375. Intent* intent = new Intent();
  376. intent->putExtra(functionWindows, "warn");
  377. intent->putExtra(warnText, LANGUAGEMANAGER->getValue("PassNoError"));
  378. EASYUICONTEXT->openActivity("functionActivity", intent);
  379. }
  380. }
  381. /**
  382. * 注册定时器
  383. * 填充数组用于注册定时器
  384. * 注意:id不能重复
  385. */
  386. static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
  387. //{0, 6000}, //定时器id=0, 时间间隔6秒
  388. //{1, 1000},
  389. };
  390. /**
  391. * 当界面构造时触发
  392. */
  393. static void onUI_init(){
  394. //Tips :添加 UI初始化的显示代码到这里,如:mText1Ptr->setText("123");
  395. Json::Value frameRoom = getFrame();
  396. frameFullName = frameRoom["frame_room"]["full_name"].asString();
  397. mPositionTextViewPtr->setText(frameFullName);
  398. mRoomPatrolTextViewPtr->setText(frameFullName);
  399. Json::Value frameBedList = frameRoom["frame_bed_list"];
  400. if (frameBedList.size() > 0) {
  401. for (int i = 0; i < frameBedList.size(); i++) {
  402. string frameBedName = frameBedList[i]["frame_bed"]["full_name"].asString();
  403. int nPos = frameBedName.find("-");
  404. if (nPos != -1) {
  405. frameBedName = frameBedName.substr(nPos + 1, frameBedName.length());
  406. }
  407. frameBedNameList += frameBedName;
  408. frameBedNameList += "、";
  409. }
  410. }
  411. frameBedNameList.substr(0, frameBedNameList.length() - 1);
  412. }
  413. /**
  414. * 当切换到该界面时触发
  415. */
  416. static void onUI_intent(const Intent *intentPtr) {
  417. if (intentPtr != NULL) {
  418. //TODO
  419. }
  420. }
  421. /*
  422. * 当界面显示时触发
  423. */
  424. static void onUI_show() {
  425. if (isChoose) {
  426. mClerkNameTextViewPtr->setText(clerk["clerk_name"].asString() + " " + clerk["role_name"].asString());
  427. mLoginWindowPtr->hideWnd();
  428. mChooseClerkWindowPtr->hideWnd();
  429. mMedicalCareWindowPtr->showWnd();
  430. setPositionButton(isPosition);
  431. setRoomPatrolButton(isRoomPatrol);
  432. setNursingButton(isNursing);
  433. }
  434. else {
  435. chooseId = 0;
  436. mLoginWindowPtr->showWnd();
  437. mChooseClerkWindowPtr->hideWnd();
  438. mMedicalCareWindowPtr->hideWnd();
  439. }
  440. EASYUICONTEXT->showStatusBar();
  441. EASYUICONTEXT->showNaviBar();
  442. setMedicalCareTheme();
  443. }
  444. /*
  445. * 当界面隐藏时触发
  446. */
  447. static void onUI_hide() {
  448. }
  449. /*
  450. * 当界面完全退出时触发
  451. */
  452. static void onUI_quit() {
  453. }
  454. /**
  455. * 串口数据回调接口
  456. */
  457. static void onProtocolDataUpdate(const SProtocolData &data) {
  458. }
  459. /**
  460. * 定时器触发函数
  461. * 不建议在此函数中写耗时操作,否则将影响UI刷新
  462. * 参数: id
  463. * 当前所触发定时器的id,与注册时的id相同
  464. * 返回值: true
  465. * 继续运行当前定时器
  466. * false
  467. * 停止运行当前定时器
  468. */
  469. static bool onUI_Timer(int id){
  470. switch (id) {
  471. case NURSEING_TIME_HANDLE:
  472. logoutMedicalCare();
  473. goHome();
  474. break;
  475. default:
  476. break;
  477. }
  478. return true;
  479. }
  480. /**
  481. * 有新的触摸事件时触发
  482. * 参数:ev
  483. * 新的触摸事件
  484. * 返回值:true
  485. * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上
  486. * false
  487. * 触摸事件将继续传递到控件上
  488. */
  489. static bool onmedicalCareActivityTouchEvent(const MotionEvent &ev) {
  490. switch (ev.mActionStatus) {
  491. case MotionEvent::E_ACTION_DOWN://触摸按下
  492. //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY);
  493. break;
  494. case MotionEvent::E_ACTION_MOVE://触摸滑动
  495. break;
  496. case MotionEvent::E_ACTION_UP: //触摸抬起
  497. break;
  498. default:
  499. break;
  500. }
  501. return false;
  502. }
  503. static void onEditTextChanged_JobNumberEditText(const std::string &text) {
  504. //LOGD(" onEditTextChanged_ JobNumberEditText %s !!!\n", text.c_str());
  505. }
  506. static void onEditTextChanged_PasswordEditText(const std::string &text) {
  507. //LOGD(" onEditTextChanged_ PasswordEditText %s !!!\n", text.c_str());
  508. }
  509. static bool onButtonClick_EnteringMedicalCareButton(ZKButton *pButton) {
  510. LOGD(" ButtonClick EnteringMedicalCareButton !!!\n");
  511. string password = mPasswordEditTextPtr->getText();
  512. //密码为当前日时
  513. struct tm *t = TimeHelper::getDateTime();
  514. char cpwd[10];
  515. sprintf(cpwd,"%02d%02d",t->tm_mday,t->tm_hour);
  516. LOGD("cpwd is %s", cpwd);
  517. if (password == cpwd) {
  518. getClerkList();
  519. if (clerkList.size() > 0) {
  520. mLoginWindowPtr->hideWnd();
  521. mChooseClerkWindowPtr->showWnd();
  522. }
  523. else {
  524. Intent* intent = new Intent();
  525. intent->putExtra(functionWindows, "warn");
  526. intent->putExtra(warnText, LANGUAGEMANAGER->getValue("ConfigureEmployeeID"));
  527. EASYUICONTEXT->openActivity("functionActivity", intent);
  528. }
  529. }
  530. else {
  531. Intent* intent = new Intent();
  532. intent->putExtra(functionWindows, "warn");
  533. intent->putExtra(warnText, LANGUAGEMANAGER->getValue("WrongPassword"));
  534. EASYUICONTEXT->openActivity("functionActivity", intent);
  535. }
  536. return false;
  537. }
  538. static bool onButtonClick_PositionButton(ZKButton *pButton) {
  539. LOGD(" ButtonClick PositionButton !!!\n");
  540. setPosition(true);
  541. Intent* intent = new Intent();
  542. intent->putExtra(functionWindows, "position");
  543. intent->putExtra(functionText, frameFullName);
  544. EASYUICONTEXT->openActivity("functionActivity", intent);
  545. return false;
  546. }
  547. static bool onButtonClick_RoomPatrolButton(ZKButton *pButton) {
  548. LOGD(" ButtonClick RoomPatrolButton !!!\n");
  549. setRoomPatrol(true);
  550. Intent* intent = new Intent();
  551. intent->putExtra(functionWindows, "roomPatrol");
  552. intent->putExtra(functionText, frameFullName);
  553. EASYUICONTEXT->openActivity("functionActivity", intent);
  554. return false;
  555. }
  556. static bool onButtonClick_NursingButton(ZKButton *pButton) {
  557. LOGD(" ButtonClick NursingButton !!!\n");
  558. if (!isNursing) {
  559. Intent* intent = new Intent();
  560. intent->putExtra(functionWindows, "nursing");
  561. intent->putExtra(functionText, frameBedNameList);
  562. intent->putExtra(nursingText, frameFullName);
  563. EASYUICONTEXT->openActivity("functionActivity", intent);
  564. }
  565. else {
  566. Intent* intent = new Intent();
  567. intent->putExtra(functionWindows, "nursingEnd");
  568. intent->putExtra(functionText, frameBedNameList);
  569. EASYUICONTEXT->openActivity("functionActivity", intent);
  570. }
  571. return false;
  572. }
  573. static bool onButtonClick_PromptButton(ZKButton *pButton) {
  574. LOGD(" ButtonClick PromptButton !!!\n");
  575. EASYUICONTEXT->openActivity("promptActivity");
  576. return false;
  577. }
  578. static bool onButtonClick_LogoutButton(ZKButton *pButton) {
  579. LOGD(" ButtonClick LogoutButton !!!\n");
  580. Intent* intent = new Intent();
  581. intent->putExtra(functionWindows, "logoutMedicalCare");
  582. intent->putExtra(goActivity, "");
  583. EASYUICONTEXT->openActivity("functionActivity", intent);
  584. return false;
  585. }
  586. static int getListItemCount_ClerkListView(const ZKListView *pListView) {
  587. //LOGD("getListItemCount_ClerkListView !\n");
  588. return clerkList.size();
  589. }
  590. static void obtainListItemData_ClerkListView(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index) {
  591. //LOGD(" obtainListItemData_ ClerkListView !!!\n");
  592. if (medicalCareThemeInt == 1) {
  593. pListItem->setButtonStatusPic(ZK_CONTROL_STATUS_SELECTED, "/medicalCare/blue_250x48.png");
  594. }
  595. else if (medicalCareThemeInt == 2) {
  596. pListItem->setButtonStatusPic(ZK_CONTROL_STATUS_SELECTED, "/medicalCare/pink_250x48.png");
  597. }
  598. pListItem->setTextStatusColor(ZK_CONTROL_STATUS_SELECTED, medicalCareColor);
  599. pListItem->setText(clerkList[index]["clerk_name"].asCString());
  600. if (index == chooseId) {
  601. pListItem->setSelected(true);
  602. clerk = clerkList[index];
  603. LOGD("clerk pass no == %s", clerk["pass_no"].asCString());
  604. }
  605. else {
  606. pListItem->setSelected(false);
  607. }
  608. }
  609. static void onListItemClick_ClerkListView(ZKListView *pListView, int index, int id) {
  610. //LOGD(" onListItemClick_ ClerkListView !!!\n");
  611. chooseId = index;
  612. }
  613. static bool onButtonClick_EnteringButton(ZKButton *pButton) {
  614. LOGD(" ButtonClick EnteringButton !!!\n");
  615. isChoose = true;
  616. mClerkNameTextViewPtr->setText(clerk["clerk_name"].asString() + " " + clerk["role_name"].asString());
  617. mChooseClerkWindowPtr->hideWnd();
  618. mMedicalCareWindowPtr->showWnd();
  619. loginMedicalCare();
  620. return false;
  621. }