medicalCareLogic.cc 22 KB

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