medicalCareLogic.cc 23 KB

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