Kaynağa Gözat

增加nfc功能,增加按钮

vothin 1 yıl önce
ebeveyn
işleme
dc39f199f8

+ 3 - 0
i18n/zh_CN.tr

@@ -90,6 +90,8 @@
     <string name="InputMedicalPasswordMsg">密码由数字组成</string>
     <string name="JobNumber">工号</string>
     <string name="Password">密码</string>
+    <string name="NfcText">请在刷卡处刷NFC卡进入医护</string>
+    <string name="NfcMsgText">使用有效NFC卡刷卡成功后直接进入医护</string>
     <string name="EnteringMedicalCare">进入医护</string>
     <string name="ChooseMsg">请选择对应员工,进入医护功能</string>
     <string name="Hello">您好,</string>
@@ -188,6 +190,7 @@
     <string name="AccountPasswordError">账号或者密码错误</string>
     <string name="WrongPassword">密码错误</string>
     <string name="ConfigureEmployeeID">请先配置员工工号</string>
+    <string name="PassNoError">未找到该卡员工</string>
     <!-- 版本界面 -->
     <string name="VersionTitle">版本升级</string>
     <string name="VersionInfo">版本信息</string>

+ 12 - 0
jni/activity/medicalCareActivity.cpp

@@ -4,6 +4,10 @@
 #include "medicalCareActivity.h"
 
 /*TAG:GlobalVariable全局变量*/
+static ZKTextView* mNfcMsgTextViewPtr;
+static ZKTextView* mNfcTextViewPtr;
+static ZKPainter* mNfcPicPainterPtr;
+static ZKPainter* mNfcPainterPtr;
 static ZKListView* mClerkListViewPtr;
 static ZKButton* mEnteringButtonPtr;
 static ZKPainter* mChooseMsgPicPainterPtr;
@@ -159,6 +163,10 @@ medicalCareActivity::~medicalCareActivity() {
     unregisterProtocolDataUpdateListener(onProtocolDataUpdate);
     onUI_quit();
     mActivityPtr = NULL;
+    mNfcMsgTextViewPtr = NULL;
+    mNfcTextViewPtr = NULL;
+    mNfcPicPainterPtr = NULL;
+    mNfcPainterPtr = NULL;
     mClerkListViewPtr = NULL;
     mEnteringButtonPtr = NULL;
     mChooseMsgPicPainterPtr = NULL;
@@ -205,6 +213,10 @@ const char* medicalCareActivity::getAppName() const{
 //TAG:onCreate
 void medicalCareActivity::onCreate() {
 	Activity::onCreate();
+    mNfcMsgTextViewPtr = (ZKTextView*)findControlByID(ID_MEDICALCARE_NfcMsgTextView);
+    mNfcTextViewPtr = (ZKTextView*)findControlByID(ID_MEDICALCARE_NfcTextView);
+    mNfcPicPainterPtr = (ZKPainter*)findControlByID(ID_MEDICALCARE_NfcPicPainter);
+    mNfcPainterPtr = (ZKPainter*)findControlByID(ID_MEDICALCARE_NfcPainter);
     mClerkListViewPtr = (ZKListView*)findControlByID(ID_MEDICALCARE_ClerkListView);if(mClerkListViewPtr!= NULL){mClerkListViewPtr->setListAdapter(this);mClerkListViewPtr->setItemClickListener(this);}
     mEnteringButtonPtr = (ZKButton*)findControlByID(ID_MEDICALCARE_EnteringButton);
     mChooseMsgPicPainterPtr = (ZKPainter*)findControlByID(ID_MEDICALCARE_ChooseMsgPicPainter);

+ 4 - 0
jni/activity/medicalCareActivity.h

@@ -27,6 +27,10 @@
 #include "window/ZKSlideWindow.h"
 
 /*TAG:Macro宏ID*/
+#define ID_MEDICALCARE_NfcMsgTextView    50014
+#define ID_MEDICALCARE_NfcTextView    50013
+#define ID_MEDICALCARE_NfcPicPainter    52015
+#define ID_MEDICALCARE_NfcPainter    52014
 #define ID_MEDICALCARE_ClerkListView    80001
 #define ID_MEDICALCARE_EnteringButton    20007
 #define ID_MEDICALCARE_ChooseMsgPicPainter    52013

+ 74 - 19
jni/logic/medicalCareLogic.cc

@@ -73,6 +73,25 @@ static void getClerkList() {
 	}
 }
 
+static bool getClerkByPartIdAndPassNo(std::string passNo) {
+    string url = getHttpGateway() + "/deviceRoom/get_clerk_by_part_id_and_pass_no/" + StoragePreferences::getString(STORE_PARTID, "") + "/" + passNo;
+    LOGD("根据科室id和卡号查询员工. url = %s", url.c_str());
+    //发起HTTP GET请求
+    RestClient::Response r = RestClient::get(url);
+    LOGD("根据科室id和卡号查询员工. result = %s", r.body.c_str());
+    //解析json
+    Json::Reader reader;
+    Json::Value root;
+    if (reader.parse(r.body, root, false)){
+        if (root.isMember("clerk_id")) {
+            clerk = root;
+            return true;
+        }
+    }
+    return false;
+}
+
+
 std::string getClerkPassNo() {
 	return clerk["pass_no"].asCString();
 }
@@ -345,6 +364,60 @@ void logoutMedicalCare() {
 	}
 }
 
+void loginMedicalCare() {
+    mLoginWindowPtr->hideWnd();
+    mChooseClerkWindowPtr->hideWnd();
+    mMedicalCareWindowPtr->showWnd();
+
+    Json::Value json;
+    json["passNo"] = clerk["pass_no"].asCString();
+    json["operationData"] = "";
+
+    // 发送tcp, tcp_type = AUTH, tcp_action = LOGIN
+    TcpModel tcpModel;
+    tcpModel.tid = base::format("t%d",TimeHelper::getCurrentTime());
+    tcpModel.type = TcpType::AUTH;
+    tcpModel.action = AuthAction::LOGIN;
+    tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
+    tcpModel.to_id = 0;
+    tcpModel.json = json;
+
+    sendTcpModel(tcpModel);
+
+    if (StoragePreferences::getInt(STORE_AUTO_POSITION, 0)) {
+        setPosition(true);
+    }
+}
+
+void nfcLogin(std::string revStr) {
+    if (mActivityPtr == NULL) {
+        LOGD("不在医护界面");
+        return;
+    }
+
+    if (isChoose) {
+        LOGD("已经存在员工");
+        return;
+    }
+
+    bool reslut = getClerkByPartIdAndPassNo(revStr);
+    if (reslut) {
+        isChoose = true;
+        mClerkNameTextViewPtr->setText(clerk["clerk_name"].asString() + " " + clerk["role_name"].asString());
+
+        loginMedicalCare();
+    }
+    else {
+        Intent* intent = new Intent();
+        intent->putExtra(functionWindows, "warn");
+        intent->putExtra(warnText, LANGUAGEMANAGER->getValue("PassNoError"));
+        EASYUICONTEXT->openActivity("functionActivity", intent);
+    }
+
+}
+
+
+
 /**
  * 注册定时器
  * 填充数组用于注册定时器
@@ -606,25 +679,7 @@ static bool onButtonClick_EnteringButton(ZKButton *pButton) {
 	mChooseClerkWindowPtr->hideWnd();
 	mMedicalCareWindowPtr->showWnd();
 
-	Json::Value json;
-	json["passNo"] = clerk["pass_no"].asCString();
-	json["operationData"] = "";
-
-	// 发送tcp, tcp_type = AUTH, tcp_action = LOGIN
-	TcpModel tcpModel;
-	tcpModel.tid = base::format("t%d",TimeHelper::getCurrentTime());
-	tcpModel.type = TcpType::AUTH;
-	tcpModel.action = AuthAction::LOGIN;
-	tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
-	tcpModel.to_id = 0;
-	tcpModel.json = json;
-
-	sendTcpModel(tcpModel);
-
-	if (StoragePreferences::getInt(STORE_AUTO_POSITION, 0)) {
-		setPosition(true);
-	}
-
+    loginMedicalCare();
     return false;
 }
 

+ 30 - 9
jni/logic/startLogic.cc

@@ -846,10 +846,37 @@ static void onProtocolDataUpdate(const SProtocolData &data) {
 					setCheckbox("KEY<");
 					return;
 				}
-				if (isSleep) {
+
+				if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
+					if (isSleep) {
+						scrrenOn();
+					}
+					else {
+						voip::CallInfo info = GetTelephone()->GetCallInfo();
+						//拨打 或 挂断
+						if (CallingStatus::instance()->busy()){
+							callActivityFinish(CallFinishType::A1CLICK);
+						} else {
+							Intent* intent = new Intent();
+							intent->putExtra(isOutgoing, "true");
+							intent->putExtra(audioOnly, "true");
+							EASYUICONTEXT->openActivity("callActivity", intent);
+						}
+					}
+				}
+				else {
 					scrrenOn();
+					voip::CallInfo info = GetTelephone()->GetCallInfo();
+					//拨打 或 挂断
+					if (CallingStatus::instance()->busy()){
+						callActivityFinish(CallFinishType::A1CLICK);
+					} else {
+						Intent* intent = new Intent();
+						intent->putExtra(isOutgoing, "true");
+						intent->putExtra(audioOnly, "true");
+						EASYUICONTEXT->openActivity("callActivity", intent);
+					}
 				}
-//				heartStr = "DOORLED,000F";
 			}
 			else if (data.cmd == "KEY>") {	// key>是面板挂断按钮
 				if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
@@ -881,20 +908,14 @@ static void onProtocolDataUpdate(const SProtocolData &data) {
 				if (isSleep) {
 					scrrenOn();
 				}
-//				heartStr = "DOORLED,111F";
 				lightControl("DOORLED", "111F");
 			}
 			else {
 				if (isSleep) {
 					scrrenOn();
 				}
-//				heartStr = "DOORLED,000F";
-				lightControl("DOORLED", "000F");
+//				lightControl("DOORLED", "000F");
 			}
-
-			// 发送给板子的指令
-//			const char* sendMsg = heartStr.c_str();
-//			sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
 		}
 	}
 }

+ 2 - 0
jni/service/BusinessConfig.h

@@ -176,6 +176,8 @@ void setClerk(std::string clerk_name, std::string pass_no, int _authItid);
 
 void goHome();
 
+void nfcLogin(std::string revStr);
+
 enum CallFinishType {
 	CANCEL,
 	REJECT,

+ 16 - 0
jni/uart/UartContext.cpp

@@ -13,6 +13,7 @@
 #include "uart/UartContext.h"
 #include "utils/Log.h"
 #include "base/strings.hpp"
+#include "service/BusinessConfig.h"
 
 #define UART_DATA_BUF_LEN			16384	// 16KB
 
@@ -208,6 +209,21 @@ bool UartContext::threadLoop() {
 				//LOGD(" %s",logInfo.c_str());
 				buildProtocolData(revStr);
 			}
+            else if (buffer[0] == 0xfe && buffer[2] == 0x03) {
+                if (buffer[1] == 0x08) {
+                    std::string revStr = "";
+                    for (int i = 0; i < ret; ++i) {
+                        if (i==0 || i==1 || i==2 || i==3 || i==4 || i==ret-1){
+                            continue;
+                        }
+                        char buf[1024];
+                        sprintf(buf, "%02x", buffer[i]);
+                        revStr += buf;
+                    }
+                    LOGD("revStr == %s", revStr.c_str());
+                    nfcLogin(revStr);
+                }
+            }
 		} else {
 		  //没收到数据时,休眠50ms,防止过度消耗cpu
 		  usleep(1000 * 50);

BIN
libs/armeabi/libzkgui.so


BIN
obj/activity/medicalCareActivity.o


BIN
obj/activity/startActivity.o


BIN
obj/service/time.o


BIN
obj/uart/UartContext.o


BIN
resources/medicalCare/nfc.png


BIN
resources/medicalCare/white_420x408.png


BIN
ui/medicalCare.ftu