Ver código fonte

#IQRV #comment: 准入错误信息补全

陈纪林80310970 11 meses atrás
pai
commit
49169e841e

+ 27 - 5
Module/mod_accessauth/AccessAuthFSM.cpp

@@ -832,9 +832,9 @@ DWORD CAccessAuthFSM::GetEncTerminalInfoWithKey(CBlob& encInfo, BYTE* key)
 	osVersion = GetOsVersion();
 
 #ifdef RVC_OS_WIN
-	termInfo["OSType"] = "Windows";
+	termInfo["osType"] = "Windows";
 #else
-	termInfo["OSType"] = "UOS";
+	termInfo["osType"] = "UOS";
 #endif // RVC_OS_WIN
 	termInfo["osVersion"] = osVersion.GetData();
 	termInfo["ip"] = ip.GetData();
@@ -999,12 +999,19 @@ void CAccessAuthFSM::GetNetMsg(SpReqAnsContext<AccessAuthService_GetNetMsg_Req,
 
 CSimpleStringA CAccessAuthFSM::GetOsVersion()
 {
+	std::map<std::string, std::string> errInfo;
+	CSimpleStringA errMsg;
+	errInfo["errcode"] = "RTA5219";
+	errInfo["msg"] = "调用系统api获取操作系统版本失败";
+
 #if defined(RVC_OS_WIN)
 	CSimpleStringA runInfoPath;
 	ErrorCodeEnum eErr = GetEntityBase()->GetFunction()->GetPath("runinfo", runInfoPath);
 	if (eErr != Error_Succeed) {
 		DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("GetPath runinfo error=%s.", SpStrError(eErr));
-		return "";
+		errInfo["getLastErr"] = GetLastError();
+		errMsg = generateJsonStr(errInfo).second.c_str();
+		return errMsg;
 	}
 	runInfoPath += "\\runcfg\\osverion";
 	ifstream is;
@@ -1013,7 +1020,9 @@ CSimpleStringA CAccessAuthFSM::GetOsVersion()
 	{
 		DWORD dwErr = GetLastError();
 		DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open runcfg\\osverion file failed. [%d]", dwErr);
-		return "";
+		errInfo["getLastErr"] = GetLastError();
+		errMsg = generateJsonStr(errInfo).second.c_str();
+		return errMsg;
 	}
 	string line;
 	while (!is.eof()) {
@@ -1025,7 +1034,10 @@ CSimpleStringA CAccessAuthFSM::GetOsVersion()
 		else
 			continue;
 	}
-	return "";
+
+	errInfo["getLastErr"] = GetLastError();
+	errMsg = generateJsonStr(errInfo).second.c_str();
+	return errMsg;
 #else
 	std::map<std::string, std::string> osInfo;
 	const char filePath[] = "/etc/os-version";
@@ -1053,9 +1065,19 @@ void CAccessAuthFSM::GetIPandMac(CSimpleStringA& ip, CSimpleStringA& mac)
 {
 	CAutoArray<SP::Module::Net::NetworkAdapterItem> netList;
 	ErrorCodeEnum rc = SP::Module::Net::GetINETMacAddresses(netList);
+	std::map<std::string, std::string> errInfo;
 	if (rc != Error_Succeed)
 	{
 		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Get sys netinfo failed!. rc=%d.", rc);
+		errInfo["errcode"] = "RTA5216";
+		errInfo["msg"] = "调用系统api获取ip失败";
+		errInfo["getLastErr"] = GetLastError();
+		ip = generateJsonStr(errInfo).second.c_str();
+
+		errInfo["errcode"] = "RTA5217";
+		errInfo["msg"] = "调用系统api获取mac地址失败";
+		errInfo["getLastErr"] = GetLastError();
+		mac = generateJsonStr(errInfo).second.c_str();
 		return;
 	}
 

+ 30 - 4
Module/mod_accessauth/mod_AccessAuth.cpp

@@ -817,7 +817,7 @@ ErrorCodeEnum CAccessAuthEntity::GetPinPadModel(CSimpleStringA& pinpadModel, boo
 	bPinPadOnline = false;
 	CSimpleStringA strErrMsg;
 	CSmartPointer<IEntityFunction> spFunction = this->GetFunction();
-
+	std::map<std::string, std::string> errInfo;
 	//oilyang@20210514 
 	if (!IsMachineTypeConfigurePinPad(m_info.strMachineType))
 		return Error_Succeed;
@@ -856,7 +856,7 @@ ErrorCodeEnum CAccessAuthEntity::GetPinPadModel(CSimpleStringA& pinpadModel, boo
 		else if(rc == Error_NotInit)
 		{
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("pinpad NOT INIT!, state: %d", ans.state);
-			return nRet; //此时nRet = -1, pinpad调用失败
+			return nRet; 
 		}
 		else
 		{
@@ -866,12 +866,33 @@ ErrorCodeEnum CAccessAuthEntity::GetPinPadModel(CSimpleStringA& pinpadModel, boo
 			string outStr = GetOutPutStr("%s%08X%s%s", "GetDevInfo", rc, "strErrMsg", strErrMsg.GetData());
 			m_FSM.doWarnMsg(ERR_ACCESSAUTH_FROM_PINPAD, outStr.c_str());
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5205")(outStr.c_str());
+
+			errInfo["errcode"] = "RTA5205";
+			errInfo["msg"] = "调用PinPad发生错误";
+			errInfo["getLastErr"] = GetLastError();
+			pinpadModel = generateJsonStr(errInfo).second.c_str();
 			
-			return nRet; //此时nRet = -1, pinpad调用失败
+			return nRet;
 		}
 
 		pPinPadClient->GetFunction()->CloseSession();
 	}
+	else if (rc == Error_NetBroken)
+	{
+		strErrMsg = "PinPad实体未启动, 连接密码键盘失败";
+		SetAuthErrMsg((const char*)strErrMsg);
+
+		m_FSM.doWarnMsg(ERR_ACCESSAUTH_CONNECT_PINPAD_UNLOAD,
+			GetOutPutStr("%s%08X%s%s", "Connect", rc, "strErrMsg", "PinPad实体未启动, 连接密码键盘失败").c_str());
+		pPinPadClient->SafeDelete();
+
+		errInfo["errcode"] = "RTA5218";
+		errInfo["msg"] = "PinPad实体未启动";
+		errInfo["getLastErr"] = GetLastError();
+		pinpadModel = generateJsonStr(errInfo).second.c_str();
+
+		return nRet; 
+	}
 	else
 	{
 		strErrMsg = "连接PinPad实体失败";
@@ -882,6 +903,11 @@ ErrorCodeEnum CAccessAuthEntity::GetPinPadModel(CSimpleStringA& pinpadModel, boo
 		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5204")("连接密码键盘异常");
 		pPinPadClient->SafeDelete();
 
+		errInfo["errcode"] = "RTA5204";
+		errInfo["msg"] = "PinPad实体启动成功,但连接PinPad实体失败";
+		errInfo["getLastErr"] = GetLastError();
+		pinpadModel = generateJsonStr(errInfo).second.c_str();
+
 		return nRet; //此时nRet = -1, pinpad调用失败
 	}
 
@@ -1107,7 +1133,7 @@ bool CAccessAuthEntity::SendInitMKReqACS(CInitlizerMKReq& initMKReq)
 	}
 
 	CBlob encInfo;
-	char* key = "s5da69gnh4!963@6s5da69gnh4!963@6";
+	char* key = "s5da69gnh4!9631";
 	nRet = (ErrorCodeEnum)m_FSM.GetEncTerminalInfoWithKey(encInfo, (BYTE*)key);
 	if (( m_FSM.GetEncTerminalInfoWithKey(encInfo, (BYTE*)key)) != Error_Succeed)
 	{