فهرست منبع

完成启动后重新获取小组件记录,并且还原登录状态、提示语等

vothin 1 سال پیش
والد
کامیت
308156e7e1

+ 6 - 0
jni/include/utils/TimeHelper.h

@@ -70,6 +70,12 @@ public:
 		std::string result = timeStr;
 		return result;
 	}
+
+	static time_t getDateline() {
+		time_t now;
+		time(&now);
+		return now;
+	}
 };
 
 #endif /* _UTILS_TIME_HELPER_H_ */

+ 59 - 1
jni/logic/mainLogic.cc

@@ -148,6 +148,7 @@ public:
 			StoragePreferences::putString(STORE_PARTID, partId);
 			getPartSetting(partId);
 			getVersion();
+			getNfcInteraction();
 		}
 	}
 	// 读取空间缓存的数据
@@ -188,7 +189,9 @@ public:
 	}
 
 	static void getBedCount() {
-
+		if (mActivityPtr == NULL) {
+			return;
+		}
 		mInBedNumTextViewPtr->setText(inBedCount);
 		mEmptyBedNumTextViewPtr->setText(emptyBedCount);
 	}
@@ -261,6 +264,7 @@ public:
 			partSetting.qrUrl = root["qr_url"].asString();
 			partSetting.screenLight = root["screen_light"].asInt();
 			partSetting.roomCallBed = root["room_call_bed"].asInt();
+			partSetting.autoPosition = root["auto_position"].asInt();
 
             if (root.isMember("linux_bed_volume_native")) {
 				partSetting.linuxDoorVolumeNative = root["linux_door_volume_native"].asInt();
@@ -295,6 +299,7 @@ public:
 			StoragePreferences::putBool(STORE_AUDO_ANSWER, partSetting.autoAccept==1);
 			StoragePreferences::putInt(STORE_SCREEN_LIGHT, partSetting.screenLight);
 			StoragePreferences::putInt(STORE_ROOM_CALL_BED, partSetting.roomCallBed);
+			StoragePreferences::putInt(STORE_AUTO_POSITION, partSetting.autoPosition);
 
 			setRightTitle(root);
 			callBedButtonSetVisible();
@@ -344,7 +349,60 @@ public:
 				EASYUICONTEXT->openActivity("updateActivity", intent);
 			}
 		}
+	}
+
+	static void getNfcInteraction() {
+		std::string url = getHttpGateway() + "/deviceRoom/get_nfc_interaction_end_time_is_null/" + to_string(StoragePreferences::getInt(STORE_DEVICE_ID,0));
+
+		LOGD("请求未完成的nfc记录. url = %s", url.c_str());
+		//发起HTTP POST请求
+		RestClient::Response r = RestClient::get(url);
+		if (r.code != 200) {
+			LOGD("请求未完成的nfc记录-> 错误代码: %d", r.code);
+			return;
+		}
+
+		LOGD("获得未完成的nfc记录. result = %s", r.body.c_str());
+		//解析json
+		Json::Reader reader;
+		Json::Value root;
 
+		if(reader.parse(r.body, root, false)) {
+			int clerkId = 0;
+			for (int i = 0; i < root.size(); i++) {
+				if (root[i]["components_type"].asCString() == TcpType::AUTH) {
+					clerkId = root[i]["clerk_id"].asInt();
+					setClerk(root[i]["clerk_name"].asCString(), root[i]["pass_no"].asCString(), root[i]["id"].asInt());
+				}
+				else if (root[i]["components_type"].asString() == "POSITION_COMPONENT") {
+					setPosistionItId(root[i]["id"].asInt());
+					setPositionButton(true);
+				}
+				else if (root[i]["components_type"].asString() == "ROOMCHECK_COMPONENT") {
+					setRoomCheckItId(root[i]["id"].asInt());
+					setRoomPatrolButton(true);
+				}
+				else if (root[i]["components_type"].asString() == "SCREEN_TIP_SET_COMPONENT") {
+					time_t now = TimeHelper::getDateline();
+
+					Json::Reader Reader;
+					Json::Value operationData;
+					Reader.parse(root[i]["operation_data"].asString(), operationData);
+					int seconds = operationData["seconds"].asInt();
+					if (now - root[i]["start_time"].asInt() > seconds) {
+						setPromptTimeItId(root[i]["id"].asInt());
+
+						Intent* intent = new Intent();
+						intent->putExtra(promptText2, operationData["tips"].asString());
+						intent->putExtra(promptTime2, to_string(seconds));
+						EASYUICONTEXT->openActivity("promptActivity", intent);
+					}
+					else {
+						sendPromptQuit(root[i]["id"].asInt());
+					}
+				}
+			}
+		}
 	}
 
 

+ 76 - 11
jni/logic/medicalCareLogic.cc

@@ -46,7 +46,9 @@ static bool isRoomPatrol = false;
 static bool isNursing = false;
 static int positionItId = 0;
 static int roomCheckItId = 0;
+static int authItId = 0;
 static int chooseId = 0;
+static bool isChoose = false;
 
 
 static void getClerkList() {
@@ -75,6 +77,18 @@ std::string getClerkPassNo() {
 	return clerk["pass_no"].asCString();
 }
 
+void setClerk(std::string clerk_name, std::string pass_no, int _authItid) {
+	isChoose = true;
+	clerk["clerk_name"] = clerk_name;
+	clerk["pass_no"] = pass_no;
+
+	authItId = _authItid;
+}
+
+void setAuthItId(int id) {
+	authItId = id;
+}
+
 void setPosistionItId(int id) {
 	positionItId = id;
 }
@@ -84,8 +98,13 @@ void setRoomCheckItId(int id) {
 }
 
 void setPositionButton(bool setPosition) {
+	isPosition = setPosition;
+
+	if (mActivityPtr == NULL) {
+		return;
+	}
+
 	if (setPosition) {
-		isPosition = setPosition;
 		mPositionPainterPtr->setBackgroundPic("medicalCare/ding-y.png");
 
 		mPositionButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "medicalCare/yellow_199x281.png");
@@ -96,7 +115,6 @@ void setPositionButton(bool setPosition) {
 		mPositionButtonPtr->setTouchable(false);
 	}
 	else {
-		isPosition = setPosition;
 		mPositionPainterPtr->setBackgroundPic("medicalCare/ding.png");
 
 		mPositionButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "medicalCare/white_199x281.png");
@@ -145,8 +163,13 @@ void setPosition(bool setPosition) {
 
 
 void setRoomPatrolButton(bool setRoomPatrol) {
+	isRoomPatrol = setRoomPatrol;
+
+	if (mActivityPtr == NULL) {
+		return;
+	}
+
 	if (setRoomPatrol) {
-		isRoomPatrol = setRoomPatrol;
 		mRoomPatrolPainterPtr->setBackgroundPic("medicalCare/xun-y.png");
 
 		mRoomPatrolButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "medicalCare/green_199x281.png");
@@ -157,7 +180,6 @@ void setRoomPatrolButton(bool setRoomPatrol) {
 		mRoomPatrolButtonPtr->setTouchable(false);
 	}
 	else {
-		isRoomPatrol = setRoomPatrol;
 		mRoomPatrolPainterPtr->setBackgroundPic("medicalCare/xun.png");
 
 		mRoomPatrolButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "medicalCare/white_199x281.png");
@@ -227,8 +249,13 @@ void setNursingEnd() {
 }
 
 void setNursingButton(bool setNursing) {
+	isNursing = setNursing;
+
+	if (mActivityPtr == NULL) {
+		return;
+	}
+
 	if (setNursing) {
-		isNursing = setNursing;
 		mNursingPainterPtr->setBackgroundPic("medicalCare/hu-y.png");
 
 		mNursingButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "medicalCare/pink_199x281.png");
@@ -237,7 +264,6 @@ void setNursingButton(bool setNursing) {
 		mNursingTextViewPtr->setTextColor(0xFFFFFFFF);
 	}
 	else {
-		isNursing = setNursing;
 		mNursingPainterPtr->setBackgroundPic("medicalCare/hu.png");
 
 		mNursingButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "medicalCare/white_199x281.png");
@@ -285,16 +311,33 @@ void setNursing(bool setNursing) {
 
 
 void logoutMedicalCare() {
+	isChoose = false;
 	setPosition(false);
 	setRoomPatrol(false);
 	setNursing(false);
 
 	clerk.clear();
-	mPasswordEditTextPtr->setText("");
 
-	mMedicalCareWindowPtr->hideWnd();
-	mChooseClerkWindowPtr->hideWnd();
-	mLoginWindowPtr->showWnd();
+	if (mActivityPtr != NULL) {
+		mPasswordEditTextPtr->setText("");
+
+		mMedicalCareWindowPtr->hideWnd();
+		mChooseClerkWindowPtr->hideWnd();
+		mLoginWindowPtr->showWnd();
+	}
+
+	if (authItId != 0) {
+		// 发送tcp, tcp_type = AUTH, tcp_action = LOGOUT
+		TcpModel tcpModel;
+		tcpModel.tid = base::format("t%d",TimeHelper::getCurrentTime());
+		tcpModel.type = TcpType::AUTH;
+		tcpModel.action = AuthAction::LOGOUT;
+		tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
+		tcpModel.to_id = 0;
+		tcpModel.data = to_string(authItId);
+
+		sendTcpModel(tcpModel);
+	}
 }
 
 /**
@@ -346,7 +389,7 @@ static void onUI_intent(const Intent *intentPtr) {
  * 当界面显示时触发
  */
 static void onUI_show() {
-	if (clerk.size() > 0) {
+	if (isChoose) {
     	mClerkNameTextViewPtr->setText(clerk["clerk_name"].asString() + " " + clerk["role_name"].asString());
 
     	mLoginWindowPtr->hideWnd();
@@ -550,10 +593,32 @@ static void onListItemClick_ClerkListView(ZKListView *pListView, int index, int
 
 static bool onButtonClick_EnteringButton(ZKButton *pButton) {
     LOGD(" ButtonClick EnteringButton !!!\n");
+    isChoose = true;
+
 	mClerkNameTextViewPtr->setText(clerk["clerk_name"].asString() + " " + clerk["role_name"].asString());
 
 	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);
+	}
+
     return false;
 }
 

+ 16 - 10
jni/logic/navibar.cc

@@ -36,9 +36,24 @@
 
 */
 
+void goHome() {
+    msys_homePtr->setBackgroundPic("button/elliptic_white.png");
+    msys_homePtr->setTextColor(0x3A78EF);
+    mHealthCareButtonPtr->setBackgroundPic("");
+    mHealthCareButtonPtr->setTextColor(0xFFFFFF);
+    mMoreButtonPtr->setBackgroundPic("");
+    mMoreButtonPtr->setTextColor(0xFFFFFF);
 
+    EASYUICONTEXT->openActivity("mainActivity");
+    EASYUICONTEXT->closeActivity("moreActivity");
+    EASYUICONTEXT->closeActivity("medicalCareActivity");
+}
 
 void callBedButtonSetVisible() {
+	if (mnavibarPtr == NULL) {
+		return;
+	}
+
 	int roomCallBed = StoragePreferences::getInt(STORE_ROOM_CALL_BED, 1);
 	if (!roomCallBed) {
 		// 如果roomCallBed是0的话,那就隐藏
@@ -141,16 +156,7 @@ static bool onnavibarActivityTouchEvent(const MotionEvent &ev) {
 
 static bool onButtonClick_sys_home(ZKButton *pButton) {
     LOGD(" ButtonClick sys_home !!!\n");
-    msys_homePtr->setBackgroundPic("button/elliptic_white.png");
-    msys_homePtr->setTextColor(0x3A78EF);
-    mHealthCareButtonPtr->setBackgroundPic("");
-    mHealthCareButtonPtr->setTextColor(0xFFFFFF);
-    mMoreButtonPtr->setBackgroundPic("");
-    mMoreButtonPtr->setTextColor(0xFFFFFF);
-
-    EASYUICONTEXT->openActivity("mainActivity");
-    EASYUICONTEXT->closeActivity("moreActivity");
-    EASYUICONTEXT->closeActivity("medicalCareActivity");
+    goHome();
     return false;
 }
 

+ 30 - 28
jni/logic/promptLogic.cc

@@ -49,6 +49,29 @@ void setPromptTimeItId(int id) {
 	promptTimeItId = id;
 }
 
+void sendPromptQuit(int id) {
+	TcpModel tcpModel;
+	tcpModel.tid = base::format("t%d", TimeHelper::getCurrentTime());
+	tcpModel.type = TcpType::SCREEN_TIP;
+	tcpModel.action = ScreenTipAction::QUIT;
+	tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
+	tcpModel.to_id = 0;
+	tcpModel.data = to_string(id);
+	sendTcpModel(tcpModel);
+
+	promptTimeItId = 0;
+}
+
+void promptStrat(string text, int time) {
+    mPromptTextViewPtr->setText(text);
+	mCustomInputEditTextPtr->setText("");
+
+	mActivityPtr->registerUserTimer(PROMPT_TIME_HANDLE, time * 1000);
+
+    mSetPromptWindowPtr->hideWnd();
+    mPromptWindowPtr->showWnd();
+}
+
 static void getPromptList() {
 	string url = getHttpGateway() + "/deviceRoom/getPartScreenTips/" + StoragePreferences::getString(STORE_PARTID, "");
 	LOGD("请求科室屏幕提示语配置列表. url = %s", url.c_str());
@@ -90,6 +113,9 @@ static void onUI_init(){
 static void onUI_intent(const Intent *intentPtr) {
     if (intentPtr != NULL) {
         //TODO
+    	string _promptText = intentPtr->getExtra(promptText2);
+    	string _time = intentPtr->getExtra(promptTime2);
+    	promptStrat(_promptText, std::atoi(_time.c_str()));
     }
 }
 
@@ -108,6 +134,7 @@ static void onUI_show() {
 	getPromptList();
 
 	chooseId = 0;
+
 }
 
 /*
@@ -149,16 +176,7 @@ static bool onUI_Timer(int id){
 
 
 		    if (promptTimeItId != 0) {
-				TcpModel tcpModel;
-				tcpModel.tid = base::format("t%d", TimeHelper::getCurrentTime());
-				tcpModel.type = TcpType::SCREEN_TIP;
-				tcpModel.action = ScreenTipAction::QUIT;
-				tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
-				tcpModel.to_id = 0;
-				tcpModel.data = to_string(promptTimeItId);
-				sendTcpModel(tcpModel);
-
-				promptTimeItId = 0;
+		    	sendPromptQuit(promptTimeItId);
 		    }
 			return false;
 			break;
@@ -255,14 +273,7 @@ static bool onButtonClick_StartPromptButton(ZKButton *pButton) {
     if (mCustomInputEditTextPtr->getText() != "") {
     	promptText = mCustomInputEditTextPtr->getText();
     }
-
-    mPromptTextViewPtr->setText(promptText);
-	mCustomInputEditTextPtr->setText("");
-
-	mActivityPtr->registerUserTimer(PROMPT_TIME_HANDLE, promptTime * 60 * 1000);
-
-    mSetPromptWindowPtr->hideWnd();
-    mPromptWindowPtr->showWnd();
+    promptStrat(promptText, promptTime * 60);
 
 	Json::Value json;
 	json["passNo"] = getClerkPassNo();
@@ -292,16 +303,7 @@ static bool onButtonClick_ExitPromptButton(ZKButton *pButton) {
     mSetPromptWindowPtr->showWnd();
 
     if (promptTimeItId != 0) {
-		TcpModel tcpModel;
-		tcpModel.tid = base::format("t%d", TimeHelper::getCurrentTime());
-		tcpModel.type = TcpType::SCREEN_TIP;
-		tcpModel.action = ScreenTipAction::QUIT;
-		tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
-		tcpModel.to_id = 0;
-		tcpModel.data = to_string(promptTimeItId);
-		sendTcpModel(tcpModel);
-
-		promptTimeItId = 0;
+    	sendPromptQuit(promptTimeItId);
     }
     return false;
 }

+ 17 - 0
jni/logic/startLogic.cc

@@ -455,6 +455,23 @@ void handleMsg(byte* inBytes){
 			setPromptTimeItId(tcpModel.json["id"].asInt());
 		}
 	}
+	else if (tcpModel.type == TcpType::AUTH) {
+		if (tcpModel.action == AuthAction::LOGIN) {
+			// 需要判断fromId跟自己是不是一样的,一样的就代表是自己发送出去,不一样的就代表员工已经登录到其他设备去了
+			if (tcpModel.from_id == StoragePreferences::getInt(STORE_DEVICE_ID, 0)) {
+				LOGD("id ===> %d", tcpModel.json["id"].asInt());
+				setAuthItId(tcpModel.json["id"].asInt());
+			}
+			else {
+				logoutMedicalCare();
+				const char* currentAppName = EASYUICONTEXT->currentAppName();
+				string _currentAppName = currentAppName;
+				if (_currentAppName == "medicalCareActivity") {
+					goHome();
+				}
+			}
+		}
+	}
 }
 
 bool getSleepTimerRegistered() {

+ 8 - 0
jni/net/tcp_model.h

@@ -31,6 +31,7 @@ public:
 	inline static std::string COUNTDOWN = "COUNTDOWN";
 	inline static std::string ROOMCHECK = "ROOMCHECK";
 	inline static std::string SCREEN_TIP = "SCREEN_TIP";
+	inline static std::string AUTH = "AUTH";
 };
 
 class VoiceAction {
@@ -144,6 +145,13 @@ public:
 	inline static std::string QUIT = "QUIT";	// 提示语退出
 };
 
+
+class AuthAction {
+public:
+	inline static std::string LOGIN = "LOGIN";	// 登录
+	inline static std::string LOGOUT = "LOGOUT";	// 退出登录
+};
+
 class TcpAction{
 	VoiceAction voiceAction;
 };

+ 14 - 0
jni/service/BusinessConfig.h

@@ -52,6 +52,7 @@
 #define STORE_AUDO_ANSWER "auto_answer"
 #define STORE_SCREEN_LIGHT "screen_light"
 #define STORE_ROOM_CALL_BED "room_call_bed"
+#define STORE_AUTO_POSITION "auto_position"
 
 #define STORE_LIGHT "light"
 #define STORE_VOLUME "volume"
@@ -154,8 +155,18 @@ void setPosistionItId(int id);
 void setRoomCheckItId(int id);
 void setPromptTimeItId(int id);
 
+void setPositionButton(bool setPosition);
+void setRoomPatrolButton(bool setRoomPatrol);
+void sendPromptQuit(int id);
+
+void setAuthItId(int id);
+
 std::string getClerkPassNo();
 
+void setClerk(std::string clerk_name, std::string pass_no, int _authItid);
+
+void goHome();
+
 enum CallFinishType {
 	CANCEL,
 	REJECT,
@@ -236,6 +247,7 @@ public:
 	inline static std::string qrUrl;
 	inline static int screenLight;
 	inline static int roomCallBed;
+	inline static int autoPosition;
 	inline static int linuxBedVolumeNative;
 	inline static int linuxBedGainSize;
 	inline static int linuxDoorVolumeNative;
@@ -277,6 +289,8 @@ static std::string functionWindows = "functionWindows";
 static std::string functionText = "functionText";
 static std::string nursingText = "nursingText";
 static std::string warnText = "warnText";
+static std::string promptText2 = "promptText2";
+static std::string promptTime2 = "promptTime2";
 
 class CallingStatus{
 public:

BIN
libs/armeabi/libzkgui.so


BIN
obj/activity/callActivity.o


BIN
obj/activity/deviceInfoActivity.o


BIN
obj/activity/functionActivity.o


BIN
obj/activity/mainActivity.o


BIN
obj/activity/medicalCareActivity.o


BIN
obj/activity/navibar.o


BIN
obj/activity/promptActivity.o


BIN
obj/activity/settingActivity.o


BIN
obj/activity/sipTestActivity.o


BIN
obj/activity/startActivity.o


BIN
obj/activity/statusbar.o


BIN
obj/activity/updateActivity.o


BIN
obj/core/update_assistant.o


BIN
obj/net/tcp_client.o


BIN
obj/net/tcp_model.o


BIN
obj/server/http_server.o


BIN
obj/service/BusinessConfig.o


BIN
obj/service/time.o