Ver Fonte

Z991239-4635 #comment 跨机优化(同步windows)

oilyang há 2 anos atrás
pai
commit
ed272a6b6c

+ 10 - 12
Module/mod_CardReadAdapter/CardReadAdapterFSM.cpp

@@ -2300,12 +2300,14 @@ int CCardReadAdapterFSM::NotifyPreonline(SpReqAnsContext<CardReadAdapterService_
 			m_crossCtx->Ans.cardPos = ctx->Req.cardPos;
 			m_crossCtx->Ans.findCard = ctx->Req.findCard;
 			m_crossCtx->Ans.result = ctx->Req.data;
-			CSimpleStringA outParam = CSimpleStringA::Format("NotifyPreOnline, cardPos:%d, findCard:%d, errCode:%d", ctx->Req.cardPos, ctx->Req.findCard, ctx->Req.errCode);
+			CSimpleStringA outParam = CSimpleStringA::Format("NotifyPreOnline, cardPos:%d, findCard:%d, errCode:%d, userErrCode:%d", ctx->Req.cardPos, ctx->Req.findCard, ctx->Req.errCode, ctx->Req.reserved1[0]);
 			LogWarn(Severity_Low, Error_Unexpect, CardIssuer_UserErrorCode_NotifyPreOnline_ParamInfo, outParam.GetData());
-			if (ctx->Req.errCode == Error_Duplication)//THE CardStore is issuing card
+			//oilyang@20230629
+			//compare with the "ctx->Req.errCode" or "ctx->Req.reserved1[0]" which is stand for UserErrorCode from CardStore
+			if (ctx->Req.errCode == Error_Duplication || ctx->Req.reserved1[0] == CardReadAdapter_UserErrorCode_CardIssuer_Is_Working)
 			{
 				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR040220327").setResultCode("RTA230Q")("卡库正在使用中");
-				LogWarn(Severity_Middle, Error_Unexpect, CardIssuer_UserErrorCode_CardActive_CardStore_Issuing, "卡库正在使用中");
+				LogWarn(Severity_Low, Error_Unexpect, CardReadAdapter_UserErrorCode_CardIssuer_Is_Working, "卡库正在使用中");
 				m_crossCtx->Answer(Error_DevNotAvailable, CardIssuer_UserErrorCode_DupCallPreOnline_WhileInWorking);
 			}
 			else if (ctx->Req.errCode == Error_TimeOut)//CardStore process cost too long!
@@ -2320,22 +2322,18 @@ int CCardReadAdapterFSM::NotifyPreonline(SpReqAnsContext<CardReadAdapterService_
 				LogWarn(Severity_Middle, Error_Unexpect, CardIssuer_UserErrorCode_CardActive_CardStore_OffLine, "跨机时卡库不在线");
 				m_crossCtx->Answer(Error_DevNotAvailable, CardIssuer_UserErrorCode_CardActive_CardStore_OffLine);
 			}
-			else if (ctx->Req.errCode == Error_DevNotAvailable)//CardStore maybe called by OTHER VTM
-			{
-				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR040220327").setResultCode("RTA2310")("卡库正在被其他VTM跨机调用");
-				LogWarn(Severity_Middle, Error_Unexpect, CardIssuer_UserErrorCode_CardActive_CardStore_CallByOther, "卡库正在被其他VTM跨机调用");
-				m_crossCtx->Answer(Error_DevNotAvailable, CardIssuer_UserErrorCode_CardActive_CardStore_CallByOther);
-			}
-			else if (ctx->Req.errCode == Error_Hardware)//CardStore's CardIssuer in fault state
+			else if (ctx->Req.reserved1[0] == CardIssuer_UserErrorCode_DevOpen_Failed)
 			{
 				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR040220327").setResultCode("RTA2311")("卡库卡机未成功打开");
-				LogWarn(Severity_Middle, Error_Unexpect, CardIssuer_UserErrorCode_CardActive_CardIssuer_InFaultState, "卡库卡机未成功打开");
-				m_crossCtx->Answer(Error_DevNotAvailable, CardIssuer_UserErrorCode_CardActive_CardIssuer_InFaultState);
+				LogWarn(Severity_Middle, Error_Unexpect, CardIssuer_UserErrorCode_DevOpen_Failed, "卡库卡机未成功打开");
+				m_crossCtx->Answer(Error_DevNotAvailable, CardIssuer_UserErrorCode_DevOpen_Failed);
 			}
 			else
 			{
 				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR040220327")("卡库异常:%d(0x%x)", ctx->Req.reserved1[0], ctx->Req.reserved1[0]);
 				m_crossCtx->Answer((ErrorCodeEnum)ctx->Req.errCode, MapErrorCodeWhileCallStore(ctx->Req.reserved1[0]));
+				LogWarn(Severity_Middle, Error_Unexpect, CardReadAdapter_UserErrorCode_CardActive_Unexpect,
+					CSimpleStringA::Format("卡库异常:%d(0x%x)", ctx->Req.reserved1[0], ctx->Req.reserved1[0]));
 			}
 		}
 		else {

+ 1 - 0
Module/mod_CardReadAdapter/CardReadAdapter_UserErrorCode.h

@@ -15,5 +15,6 @@
 #define CardReadAdapter_UserErrorCode_PreOnline_CardIssuer_Not_Ok			(CardReadAdapter_UserErrorCode_Start + 8)	//CardIssuer实体异常
 #define CardReadAdapter_UserErrorCode_CardIssuer_Is_Working					(CardReadAdapter_UserErrorCode_Start + 9)	//CardIssuer实体正忙
 #define CardReadAdapter_UserErrorCode_HBService_No_Return					(CardReadAdapter_UserErrorCode_Start + 10)	//心跳服务超时未返回
+#define CardReadAdapter_UserErrorCode_CardActive_Unexpect					(CardReadAdapter_UserErrorCode_Start + 11)	//跨机收到未处理的返回(某些返回可能在后期细化中提供处理)
 
 #endif //_CARDREADADAPTER_USER_ERRORCODE_H

+ 29 - 46
Module/mod_heartbeat/HeartBeatFSM.cpp

@@ -653,49 +653,9 @@ void CHeartBeatFSM::LocalPreOnline(int slot, CSimpleStringA fromTermNo,CSimpleSt
 		return;
 	}
 
-	//oilyang@20230316 check CardIssuer state first
-	CardReadAdapterService_GetDevInfo_Req reqInfo;
-	CardReadAdapterService_GetDevInfo_Ans ansInfo;
-	reqInfo.module = 1;//Module_CardIssuer
-	ErrorCodeEnum eErr = m_pCRAClient->GetDevInfo(reqInfo, ansInfo, 3000, dwUserCode);
-	CSimpleStringA errMsgData(true);
-	if (eErr == Error_InvalidState)
-	{
-		errMsgData = "CardIssuer in use";
-		if (m_pHandShakeConn && m_pHandShakeConn->IsConnectionOK())
-		{
-			m_pHandShakeConn->SendCardActive(1, slot, Error_Duplication, (const char*)termNo, (const char*)account,
-				account.GetLength(), errMsgData.GetData(), errMsgData.GetLength()+1, 9999, 9999, HeartBeat_UserErrorCode_CardStore_CardIssuer_In_Use);
-		}
-		LogWarn(Severity_Middle, Error_Unexpect, HeartBeat_UserErrorCode_CardStore_CardIssuer_In_Use, "CardIssuer in use");
-		return;
-	}
-	else if (eErr == Error_DevNotAvailable)
-	{
-		errMsgData = "CardIssuer not available(open failed)";
-		if (m_pHandShakeConn && m_pHandShakeConn->IsConnectionOK())
-		{
-			m_pHandShakeConn->SendCardActive(1, slot, Error_Hardware, (const char*)termNo, (const char*)account,
-				account.GetLength(), errMsgData.GetData(), errMsgData.GetLength() + 1, 9999, 9999, HeartBeat_UserErrorCode_CardIssuer_Open_Failed);
-		}
-		LogWarn(Severity_Middle, Error_Unexpect, HeartBeat_UserErrorCode_CardIssuer_Open_Failed, "CardIssuer not available(open failed)");
-		return;
-	}
-	else if (eErr != Error_Succeed || ansInfo.ModuleSN.GetCount() == 0 ||(ansInfo.ModuleSN.GetCount() == 1 && ansInfo.state[0] == 3))//3 for DEVICE_STATUS_FAULT defined in DevBaseClass.h
-	{
-		errMsgData = "CardIssuer in fault state";
-		if (m_pHandShakeConn && m_pHandShakeConn->IsConnectionOK())
-		{
-			m_pHandShakeConn->SendCardActive(1, slot, Error_Hardware, (const char*)termNo, (const char*)account,
-				account.GetLength(), errMsgData.GetData(), errMsgData.GetLength() + 1, 9999, 9999, HeartBeat_UserErrorCode_CardIssuer_In_Fault_State);
-		}
-		LogWarn(Severity_Middle, Error_Unexpect, HeartBeat_UserErrorCode_CardIssuer_In_Fault_State, "CardIssuer in fault state");
-		return;
-	}
-	Sleep(500);//oilyang@20230328 wait for entity CardReadAdapter to change back to normal state
 	CardReadAdapterService_PreOnline_Req req;
 	CardReadAdapterService_PreOnline_Ans ans;
-	CSimpleStringA outParam("");
+	CSimpleStringA errMsgData("");
 	req.businessData = data;
 	char buf[16];
 	ZeroMemory(buf, sizeof(buf));
@@ -708,15 +668,38 @@ void CHeartBeatFSM::LocalPreOnline(int slot, CSimpleStringA fromTermNo,CSimpleSt
 	req.reserved2[1] = account;
 	CSimpleStringA inParam = CSimpleStringA::Format("PreOnline, CardStore heartbeat invodk PreOnline, slot:%s, accountLen:%d", req.reserved2[0].GetData(), account.GetLength());
 	LogWarn(Severity_Low, Error_Unexpect, HeartBeat_UserErrorCode_Connect_CardStore_Invoke_PreOnline_Inparam, inParam.GetData());
-	eErr = m_pCRAClient->PreOnline(req, ans, 65000, dwUserCode);
+	ErrorCodeEnum eErr = m_pCRAClient->PreOnline(req, ans, 65000, dwUserCode);
 	if (eErr != Error_Succeed){
-		outParam = CSimpleStringA::Format("local preonline failed:%d(0x%x),dwUserCode:%d(0x%x)", eErr, eErr, dwUserCode, dwUserCode);
+		errMsgData = CSimpleStringA::Format("local preonline failed:%d(0x%x),dwUserCode:%d(0x%x)", eErr, eErr, dwUserCode, dwUserCode);
+		LogWarn(Severity_Middle, Error_Unexpect, HeartBeat_UserErrorCode_Connect_CardStore_Invoke_PreOnline_Falied, errMsgData.GetData());
 		if (eErr == Error_Duplication)
 		{
 			ReceivePreOnlineBack(Error_Duplication, "", 0, 0);
 			return;
 		}
-		LogWarn(Severity_Middle, Error_Unexpect, HeartBeat_UserErrorCode_Connect_CardStore_Invoke_PreOnline_Falied, outParam.GetData());
+		else if (eErr == Error_InvalidState)
+		{
+			errMsgData = "CardIssuer in use";
+			if (m_pHandShakeConn && m_pHandShakeConn->IsConnectionOK())
+			{
+				m_pHandShakeConn->SendCardActive(1, slot, Error_Duplication, (const char*)termNo, (const char*)account,
+					account.GetLength(), errMsgData.GetData(), errMsgData.GetLength() + 1, 9999, 9999, dwUserCode);
+			}
+			LogWarn(Severity_Middle, Error_Unexpect, HeartBeat_UserErrorCode_CardStore_CardIssuer_In_Use, "CardIssuer in use");
+			return;
+		}
+		else if (eErr == Error_DevNotAvailable)
+		{
+			errMsgData = "CardIssuer not available(open failed)";
+			if (m_pHandShakeConn && m_pHandShakeConn->IsConnectionOK())
+			{
+				m_pHandShakeConn->SendCardActive(1, slot, Error_Hardware, (const char*)termNo, (const char*)account,
+					account.GetLength(), errMsgData.GetData(), errMsgData.GetLength() + 1, 9999, 9999, dwUserCode);
+			}
+			LogWarn(Severity_Middle, Error_Unexpect, HeartBeat_UserErrorCode_CardIssuer_Open_Failed, "CardIssuer not available(open failed)");
+			return;
+		}
+		
 	}
 	Sleep(500);
 	CardReadAdapterService_QueryCardInfoOnStore_Req reqX;
@@ -725,8 +708,8 @@ void CHeartBeatFSM::LocalPreOnline(int slot, CSimpleStringA fromTermNo,CSimpleSt
 	eErrX = m_pCRAClient->QueryCardInfoOnStore(reqX, ansX,12000);
 	if (eErrX != Error_Succeed)
 	{
-		outParam = CSimpleStringA::Format("QueryCardInfoOnStore failed.%d",eErrX);
-		LogWarn(Severity_Low, Error_Unexpect, HeartBeat_UserErrorCode_Connect_CardStore_Invoke_QueryCardInfoOnStore_Falied, outParam.GetData());
+		errMsgData = CSimpleStringA::Format("QueryCardInfoOnStore failed.%d",eErrX);
+		LogWarn(Severity_Low, Error_Unexpect, HeartBeat_UserErrorCode_Connect_CardStore_Invoke_QueryCardInfoOnStore_Falied, errMsgData.GetData());
 		ansX.findCard = ansX.cardPos = 9999;
 	}
 	if (m_pHandShakeConn && m_pHandShakeConn->IsConnectionOK())