浏览代码

Z991239-5787 #comment feat: 优化JS读卡异常信息上送日志

Signed-Off-By: commit-hook
刘文涛80174520 11 月之前
父节点
当前提交
d7a3a4fece
共有 2 个文件被更改,包括 111 次插入15 次删除
  1. 109 15
      Module/mod_cardissuerstore/CardIssuerFSM.cpp
  2. 2 0
      Module/mod_cardissuerstore/CardIssuerFSM.h

+ 109 - 15
Module/mod_cardissuerstore/CardIssuerFSM.cpp

@@ -7327,6 +7327,39 @@ CSimpleStringA CCardIssuerFSM::generateJsonString(std::map<std::string, JsonElem
 	return CSimpleStringA(csRet);
 }
 
+void CCardIssuerFSM::GetCardProcessLastErr(ErrorCodeEnum& eErrCode, CSimpleStringA& ApiName, CSimpleStringA& alarmMsg, CSimpleStringA& csErrMsgWithReturnCode)
+{
+	if (m_pCardProcess == NULL) {
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("GetCardProcessLastErr m_pCardProcess is null");
+		eErrCode = Error_Null;
+		ApiName = "";
+		alarmMsg = "";
+		csErrMsgWithReturnCode = "";
+		return;
+	}
+	
+	ErrorCodeEnum lastErrCode = Error_Succeed;
+	CSimpleStringA lastErrMsg = "";
+	CSimpleStringA lastApiName = "";
+	m_pCardProcess->getCardAssistLastErr(lastErrCode, lastErrMsg, lastApiName);
+	
+	const CSimpleStringA alarmMsgStr = CSimpleStringA::Format("{\"Function\":\"%s\", \"DevApi\":\"%s\", \"ReturnCode\":\"%s\", \"Msg\":%s, \"Context\":%s}"
+		, __FUNCTION__, lastApiName.GetData(), SpStrError(lastErrCode), lastErrMsg.GetData(), "");
+
+	std::map<std::string, std::string> msgInfo;
+	msgInfo["ReturnCode"] = SpStrError(lastErrCode);
+	msgInfo["ErrMsg"] = lastErrMsg.GetData();
+	msgInfo["Context"] = "";
+	std::pair<bool, std::string> strResult;
+	strResult = generateJsonStr(msgInfo);
+	CSimpleStringA csErrMsgWithReturnCodeStr = strResult.second.c_str();
+	
+	eErrCode = lastErrCode;
+	ApiName = lastApiName;
+	alarmMsg = alarmMsgStr.GetData();
+	csErrMsgWithReturnCode = csErrMsgWithReturnCodeStr.GetData();
+}
+
 int CCardIssuerFSM::EjectJS(SpReqAnsContext<CardIssuerStoreService_EjectJS_Req, CardIssuerStoreService_EjectJS_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
@@ -9505,41 +9538,71 @@ int CCardIssuerFSM::PreOnlineJS_Contact(SpReqAnsContext<CardIssuerStoreService_R
 
 	if (retDetectAndRead < 0)
 	{
+		ErrorCodeEnum eErrCode = Error_Unexpect;
+		CSimpleStringA ApiName = "";
+		CSimpleStringA alarmMsg = "";
+		CSimpleStringA csErrMsgWithReturnCode = "";
+
 		if (IfUseRf()) {
 			bContinue = true; //继续后面的非接流程
 			if (retDetectAndRead == -1) {
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("检测卡片类型时上电失败");
+				GetCardProcessLastErr(eErrCode, ApiName, alarmMsg, csErrMsgWithReturnCode);
+
 				if (m_issueStatus) {
-					SetErrorAndLog(Error_Unexpect, CardIssuerStore_UserErrorCode_IssueCard_ActiveICCard_Failed, "PreOnlineJS_Contact::DetectIfICCard", __FUNCTION__, false, l_endTime - l_beginTime, "QLR040222040", "PreOnlineJS_Contact::DetectAndReadICData(-1) err");
+					DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setAPI(ApiName.GetData()).setCostTime(l_endTime - l_beginTime).setLogCode("QLR040222040").setResultCode("RTA2W0V")(csErrMsgWithReturnCode.GetData());
+					LogWarn(Severity_Middle, Error_Unexpect, CardIssuerStore_UserErrorCode_IssueCard_ActiveICCard_Failed, alarmMsg.GetData());
 				}
 				else {
-					SetErrorAndLog(Error_Unexpect, CardIssuerStore_UserErrorCode_ActiveICCard_Failed, "PreOnlineJS_Contact::DetectIfICCard", __FUNCTION__, false, l_endTime - l_beginTime, "QLR040222040", "PreOnlineJS_Contact::DetectAndReadICData(-1) err");
+					DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setAPI(ApiName.GetData()).setCostTime(l_endTime - l_beginTime).setLogCode("QLR040222040").setResultCode("RTA2W0M")(csErrMsgWithReturnCode.GetData());
+					LogWarn(Severity_Middle, Error_Unexpect, CardIssuerStore_UserErrorCode_ActiveICCard_Failed, alarmMsg.GetData());
 				}
 			}
 			else if (retDetectAndRead == -2) {
-				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_ICCommand, "DevAdapter::ICCommand", __FUNCTION__, false, l_endTime - l_beginTime, "QLR040222040", "PreOnlineJS_Contact::DetectAndReadICData(-2) err");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("读取IC数据失败");
+				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_ICCommand, "DevAdapter::ICCommand", __FUNCTION__, false, l_endTime - l_beginTime, "QLR040222040", "");
 			}
 			else if (retDetectAndRead == -3) {
-				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_ICCommand, "DevAdapter::ICCommand", __FUNCTION__, false, l_endTime - l_beginTime, "QLR040222040", "PreOnlineJS_Contact::DetectAndReadICData(-3) err");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("IC卡建立应用列表失败");
+				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_ICCommand, "DevAdapter::ICCommand", __FUNCTION__, false, l_endTime - l_beginTime, "QLR040222040", "");
 			}
 		}
 		else {
 			if (retDetectAndRead == -1) {
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("检测卡片类型时上电失败");
+				GetCardProcessLastErr(eErrCode, ApiName, alarmMsg, csErrMsgWithReturnCode);
+
 				if (m_issueStatus) {
-					SetErrorAndLog(Error_Unexpect, CardIssuerStore_UserErrorCode_IssueCard_ActiveICCard_Failed, "PreOnlineCrossJS_Contact::DetectIfICCard", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "PreOnlineJS_Contact::DetectAndReadICData(-1) err");
+					if (IsInBusiness()) {
+						DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_USER).setAPI(ApiName.GetData()).setCostTime(l_endTime - l_beginTime).setLogCode("QLR040222040").setResultCode("RTA2W0V")(csErrMsgWithReturnCode.GetData());
+						LogError(Severity_Middle, Error_Unexpect, CardIssuerStore_UserErrorCode_IssueCard_ActiveICCard_Failed, alarmMsg.GetData());
+					}
+					else {
+						DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setAPI(ApiName.GetData()).setCostTime(l_endTime - l_beginTime).setLogCode("QLR040222040").setResultCode("RTA2W0V")(csErrMsgWithReturnCode.GetData());
+						LogWarn(Severity_Middle, Error_Unexpect, CardIssuerStore_UserErrorCode_IssueCard_ActiveICCard_Failed, alarmMsg.GetData());
+					}
 					ctx->Answer(Error_Unexpect, CardIssuerStore_UserErrorCode_IssueCard_ActiveICCard_Failed);
 				}
 				else {
-					SetErrorAndLog(Error_Unexpect, CardIssuerStore_UserErrorCode_ActiveICCard_Failed, "PreOnlineCrossJS_Contact::DetectIfICCard", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "PreOnlineJS_Contact::DetectAndReadICData(-1) err");
+					if (IsInBusiness()) {
+						DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_USER).setAPI(ApiName.GetData()).setCostTime(l_endTime - l_beginTime).setLogCode("QLR040222040").setResultCode("RTA2W0M")(csErrMsgWithReturnCode.GetData());
+						LogError(Severity_Middle, Error_Unexpect, CardIssuerStore_UserErrorCode_ActiveICCard_Failed, alarmMsg.GetData());
+					}
+					else {
+						DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setAPI(ApiName.GetData()).setCostTime(l_endTime - l_beginTime).setLogCode("QLR040222040").setResultCode("RTA2W0M")(csErrMsgWithReturnCode.GetData());
+						LogWarn(Severity_Middle, Error_Unexpect, CardIssuerStore_UserErrorCode_ActiveICCard_Failed, alarmMsg.GetData());
+					}
 					ctx->Answer(Error_Unexpect, CardIssuerStore_UserErrorCode_ActiveICCard_Failed);
 				}
-
 			}
 			else if (retDetectAndRead == -2) {
-				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_ICCommand, "DevAdapter::ICCommand", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "PreOnlineJS_Contact::DetectAndReadICData(-2) err");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("读取IC数据失败");
+				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_ICCommand, "DevAdapter::ICCommand", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "");
 				ctx->Answer(Error_Unexpect, GetAlarmDEC());
 			}
 			else if (retDetectAndRead == -3) {
-				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_ICCommand, "DevAdapter::ICCommand", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "PreOnlineJS_Contact::DetectAndReadICData(-3) err");
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("IC卡建立应用列表失败");
+				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_ICCommand, "DevAdapter::ICCommand", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "");
 				ctx->Answer(Error_Unexpect, GetAlarmDEC());
 			}
 		}
@@ -9829,31 +9892,62 @@ int CCardIssuerFSM::PreOnlineJS_RF(SpReqAnsContext<CardIssuerStoreService_ReadJS
 
 	if (retDetectAndRead < 0)
 	{
+		ErrorCodeEnum eErrCode = Error_Unexpect;
+		CSimpleStringA ApiName = "";
+		CSimpleStringA alarmMsg = "";
+		CSimpleStringA csErrMsgWithReturnCode = "";
+
 		if (retDetectAndRead == -1) {
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("检测卡片类型时上电失败(非接)");
+			GetCardProcessLastErr(eErrCode, ApiName, alarmMsg, csErrMsgWithReturnCode);
+
 			if (m_issueStatus) {
-				SetErrorAndLog(Error_Unexpect, CardIssuerStore_UserErrorCode_IssueCard_ActiveRF_Failed, "PreOnlineJS_RF::DetectIfICCard", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "PreOnlineJS_RF::DetectAndReadICData(-1) err.");
+				if (IsInBusiness())
+				{
+					DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_USER).setAPI(ApiName.GetData()).setCostTime(l_endTime - l_beginTime).setLogCode("QLR040222040").setResultCode("RTA2W27")(csErrMsgWithReturnCode.GetData());
+					LogError(Severity_Middle, Error_Unexpect, CardIssuerStore_UserErrorCode_IssueCard_ActiveRF_Failed, alarmMsg.GetData());
+				}
+				else {
+					DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setAPI(ApiName.GetData()).setCostTime(l_endTime - l_beginTime).setLogCode("QLR040222040").setResultCode("RTA2W27")(csErrMsgWithReturnCode.GetData());
+					LogWarn(Severity_Middle, Error_Unexpect, CardIssuerStore_UserErrorCode_IssueCard_ActiveRF_Failed, alarmMsg.GetData());
+				}
+
 				ctx->Answer(Error_Unexpect, CardIssuerStore_UserErrorCode_IssueCard_ActiveRF_Failed);
 			}
 			else {
-				SetErrorAndLog(Error_Unexpect, CardIssuerStore_UserErrorCode_ActiveContactlessICCard_Failed, "PreOnlineJS_RF::DetectIfICCard", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "PreOnlineJS_RF::DetectAndReadICData(-1) err.");
+				if (IsInBusiness())
+				{
+					DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_USER).setAPI(ApiName.GetData()).setCostTime(l_endTime - l_beginTime).setLogCode("QLR040222040").setResultCode("RTA2W26")(csErrMsgWithReturnCode.GetData());
+					LogError(Severity_Middle, Error_Unexpect, CardIssuerStore_UserErrorCode_ActiveContactlessICCard_Failed, alarmMsg.GetData());
+				}
+				else
+				{
+					DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setAPI(ApiName.GetData()).setCostTime(l_endTime - l_beginTime).setLogCode("QLR040222040").setResultCode("RTA2W26")(csErrMsgWithReturnCode.GetData());
+					LogWarn(Severity_Middle, Error_Unexpect, CardIssuerStore_UserErrorCode_ActiveContactlessICCard_Failed, alarmMsg.GetData());
+				}
+
 				ctx->Answer(Error_Unexpect, CardIssuerStore_UserErrorCode_ActiveContactlessICCard_Failed);
 			}
 		}
 		else if (retDetectAndRead == -2) {
+
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("读取IC数据失败");
 			if (m_issueStatus) {
-				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_RFTypeABCommand, "DevAdapter::RFTypeABCommand", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "PreOnlineJS_RF::DetectAndReadICData(-2) err.");
+				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_RFTypeABCommand, "DevAdapter::RFTypeABCommand", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "");
 			}
 			else {
-				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_RFTypeABCommand, "DevAdapter::RFTypeABCommand", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "PreOnlineJS_RF::DetectAndReadICData(-2) err.");
+				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_RFTypeABCommand, "DevAdapter::RFTypeABCommand", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "");
 			}
 			ctx->Answer(Error_Unexpect, GetAlarmDEC());
 		}
 		else if (retDetectAndRead == -3) {
+
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("IC卡建立应用列表失败");
 			if (m_issueStatus) {
-				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_RFTypeABCommand, "DevAdapter::RFTypeABCommand", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "PreOnlineJS_RF::DetectAndReadICData(-3) err");
+				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_RFTypeABCommand, "DevAdapter::RFTypeABCommand", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "");
 			}
 			else {
-				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_RFTypeABCommand, "DevAdapter::RFTypeABCommand", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "PreOnlineJS_RF::DetectAndReadICData(-3) err");
+				SetErrorAndLog(Error_Unexpect, MEC_DEVAPI_CARDISSUER_RFTypeABCommand, "DevAdapter::RFTypeABCommand", __FUNCTION__, IsInBusiness(), l_endTime - l_beginTime, "QLR040222040", "");
 			}
 			ctx->Answer(Error_Unexpect, GetAlarmDEC());
 		}

+ 2 - 0
Module/mod_cardissuerstore/CardIssuerFSM.h

@@ -1386,6 +1386,8 @@ private:
 		return (m_bCrossPreOnline || m_iInWhatPage == PageType_Other);
 	}
 
+	void GetCardProcessLastErr(ErrorCodeEnum& eErrCode, CSimpleStringA& lastApiName,CSimpleStringA& alarmMsg,CSimpleStringA& csErrMsgWithReturnCode);
+
 #pragma region JS接口具体实现方法
 public:
 	int EjectJS(SpReqAnsContext<CardIssuerStoreService_EjectJS_Req, CardIssuerStoreService_EjectJS_Ans>::Pointer ctx);