Browse Source

Z991239-5694 #comment feat: 身份证JS接口实现

陈纪林80310970 11 months ago
parent
commit
1d59d9df3d

+ 19 - 23
Module/mod_IDCertificate/IDCertFSM.cpp

@@ -538,12 +538,6 @@ ErrorCodeEnum CIDCertFSM::OnExit()
 int CIDCertFSM::ReadAndScanUTF8(SpReqAnsContext<IDCert_ReadAndScanUTF8_Req, IDCert_ReadAndScanUTF8_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
-	if (supportUCS2 == FALSE)
-	{
-		ctx->Ans.msgtype = 0;
-		ctx->Answer(Error_Succeed);
-		return 0;
-	}*/
 
 	DWORD elapsed = 0;
 	DWORD dwStart = SP::Module::Comm::RVCGetTickCount();
@@ -1093,18 +1087,12 @@ int CIDCertFSM::ReadAndScanUTF8(SpReqAnsContext<IDCert_ReadAndScanUTF8_Req, IDCe
 int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req, IDCert_ReadAndScanUTF8JS_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
-	if (supportUCS2 == FALSE)
-	{
-		ctx->Ans.msgtype = 0;
-		ctx->Answer(Error_Succeed);
-		return 0;
-	}
 
 	DWORD elapsed = 0;
 	DWORD dwStart = SP::Module::Comm::RVCGetTickCount();
 	DWORD dwEnd = SP::Module::Comm::RVCGetTickCount();
 	ErrorCodeEnum eErr = Error_Unexpect;
-	ErrorCodeEnum errRF = Error_Unexpect;
+	ErrorCodeEnum errRfOpen = Error_Unexpect;
 	ErrorCodeEnum errAuth = Error_Unexpect;
 	ErrorCodeEnum errRead = Error_Unexpect;
 	ErrorCodeEnum errReadEx = Error_Unexpect;
@@ -1150,11 +1138,11 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
 		if (!bOpenRF)
 		{
 			m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
-			errRF = m_hDevHelper->IDCerRFControl(true);
+			errRfOpen = m_hDevHelper->IDCerRFControl(true);
 			m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::IDCerRFControl").setCostTime(m_ullEndTime - m_ullBeginTime)
 				("RreadAndScanUTF8JS DevAdapter::IDCerRFControl");
-			if (Error_Succeed == errRF)
+			if (Error_Succeed == errRfOpen)
 			{
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("open rf succeed.");
 			}
@@ -1470,14 +1458,14 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
 	if (m_bExit)
 		bExitWhenReading = true;
 
-	if (!m_bExit && !bOpenRF && errRF != Error_Succeed)
+	if (!m_bExit && !bOpenRF && errRfOpen != Error_Succeed)
 	{
-		SetErrorAndLog(errRF, MEC_DEVAPI_IDCER_IDCerRFControl, "DevAdapter::IDCerRFControl", __FUNCTION__,
+		SetErrorAndLog(errRfOpen, MEC_DEVAPI_IDCER_IDCerRFControl, "DevAdapter::IDCerRFControl", __FUNCTION__,
 			true, m_ullEndTime - m_ullBeginTime, IDCertService_LogCode_ReadAndScanUTF8JS);
 
 		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)
-			.setResultCode(std::to_string(errRF).c_str())
-			("ReadAndScanUTF8JS::IDCerRFControl Open failed with errcode: %d", errRF);
+			.setResultCode(std::to_string(errRfOpen).c_str())
+			("ReadAndScanUTF8JS::IDCerRFControl Open failed with errcode: %d", errRfOpen);
 	}
 
 	m_bExit = false;
@@ -1570,12 +1558,12 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
 		//oilyang@20180531 add for close enter card
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("ReadAndScanUTF8JS")("Close RF again...");
 		m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
-		ErrorCodeEnum errRf = m_hDevHelper->IDCerRFControl(false);
+		ErrorCodeEnum errRfClose = m_hDevHelper->IDCerRFControl(false);
 		m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
-		if (errRf != Error_Succeed)
+		if (errRfClose != Error_Succeed)
 		{
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("exec IDCerRFControl(false) failed, force eject...");
-			SetErrorAndLog(errRF, MEC_DEVAPI_IDCER_IDCerRFControl, "DevAdapter::IDCerRFControl", __FUNCTION__,
+			SetErrorAndLog(errRfClose, MEC_DEVAPI_IDCER_IDCerRFControl, "DevAdapter::IDCerRFControl", __FUNCTION__,
 				false, m_ullEndTime - m_ullBeginTime, IDCertService_LogCode_ReadAndScanUTF8JS);
 
 			m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
@@ -1613,9 +1601,17 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
 					true, m_ullEndTime - m_ullBeginTime, IDCertService_LogCode_ReadAndScanUTF8JS);
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Invoke IDCerGetDataEx2(Timeout) failed: %s", SpStrError(eErr));
 
-				ctx->Answer(Error_Unexpect, MEC_DEVAPI_IDCER_IDCerGetDataEx2);
+				ctx->Answer(Error_Unexpect, MEC_DEVAPI_IDCER_IDCerGetDataEx2); //RTA2109
 			}
 		}
+		else if (!bOpenRF)
+		{
+			SetErrorAndLog(errRfOpen, MEC_DEVAPI_IDCER_IDCerRFControl, "DevAdapter::IDCerRFControl", __FUNCTION__,
+				true, m_ullEndTime - m_ullBeginTime, IDCertService_LogCode_ReadAndScanUTF8);
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Open IDCerRFControl(Timeout) failed: %s", SpStrError(errRfOpen));
+
+			ctx->Answer(Error_Unexpect, MEC_DEVAPI_IDCER_IDCerRFControl);
+		}
 		else
 		{
 			

+ 3 - 1
Module/mod_IDCertificate/IDCertFSM.h

@@ -98,8 +98,10 @@ typedef IDCertificate::IDCertService_CancelRead_Info IDCert_CancelRead_Info;
 typedef IDCertificate::IDCertService_ReadWaitMore_Info IDCert_ReadWaitMore_Info;
 typedef IDCertificate::IDCertService_ReadAndScanUTF8_Req IDCert_ReadAndScanUTF8_Req; //ex2
 typedef IDCertificate::IDCertService_ReadAndScanUTF8_Ans IDCert_ReadAndScanUTF8_Ans;
-typedef IDCertificate::IDCertService_ReadAndScanUTF8JS_Req IDCert_ReadAndScanUTF8JS_Req; //js
+typedef IDCertificate::IDCertService_ReadAndScanUTF8JS_Req IDCert_ReadAndScanUTF8JS_Req; //js ReadAndScanUTF8
 typedef IDCertificate::IDCertService_ReadAndScanUTF8JS_Ans IDCert_ReadAndScanUTF8JS_Ans;
+typedef IDCertificate::IDCertService_CancelReadJS_Req IDCert_CancelReadJS_Req; //js CancelRead
+typedef IDCertificate::IDCertService_CancelReadJS_Ans IDCert_CancelReadJS_Ans;
 typedef IDCertificate::IDCertService_GetDevInfo_Req IDCert_GetDevInfo_Req;
 typedef IDCertificate::IDCertService_GetDevInfo_Ans IDCert_GetDevInfo_Ans;
 #pragma endregion forsonar

+ 18 - 24
Module/mod_IDCertificate/IDCertificate_UserErrorCode.h

@@ -3,31 +3,25 @@
 #pragma once
 
 #define IDCertificate_UserErrorCode_Start 0x20100200
-#define IDCertificate_UserErrorCode_Open_RootCfg_Failed		(IDCertificate_UserErrorCode_Start + 1)	//打开Root.ini失败 201000201
-#define IDCertificate_UserErrorCode_LogInfoAboutTerm		(IDCertificate_UserErrorCode_Start + 2)	//告警上送终端模块信息
-#define IDCertificate_UserErrorCode_RootInfo			    (IDCertificate_UserErrorCode_Start + 4) //root信息
-#define IDCertificate_UserErrorCode_ScanIImageFailed        (IDCertificate_UserErrorCode_Start + 5) //扫描图像失败
-#define IDCertificate_UserErrorCode_InvalidStartDate		(IDCertificate_UserErrorCode_Start + 6) //告警开始日期非法
-#define IDCertificate_UserErrorCode_InvalidEndDate		    (IDCertificate_UserErrorCode_Start + 7) //告警结束日期非法
-#define IDCertificate_UserErrorCode_InvalidBirthDate		(IDCertificate_UserErrorCode_Start + 8) //告警生日日期非法
-#define IDCertificate_UserErrorCode_StartDate				(IDCertificate_UserErrorCode_Start + 9) //上传开始日期
-#define IDCertificate_UserErrorCode_EndDate					(IDCertificate_UserErrorCode_Start + 10) //上传结束日期
-#define IDCertificate_UserErrorCode_BirthDate				(IDCertificate_UserErrorCode_Start + 11) //上传生日日期
-#define IDCertificate_UserErrorCode_NotMatch         		(IDCertificate_UserErrorCode_Start + 12) //起止日期不匹配
-#define IDCertificate_UserErrorCode_DevOpenFailed			(IDCertificate_UserErrorCode_Start + 13) //实体打开失败 2010020d
-#define IDCertificate_UserErrorCode_DllLoadFailed			(IDCertificate_UserErrorCode_Start + 14) //厂商适配器加载失败 2010020e
-#define IDCertificate_UserErrorCode_Release_Object_Failed	(IDCertificate_UserErrorCode_Start + 15) //释放设备失败
-#define IDCertificate_UserErrorCode_CancelOperation			(IDCertificate_UserErrorCode_Start + 16)
-#define IDCertificate_UserErrorCode_DevOpen_Success			(IDCertificate_UserErrorCode_Start + 20) //身份证打开成功 20100214
-#define IDCertificate_UserErrorCode_GetDevCategory_Failed	(IDCertificate_UserErrorCode_Start + 21) //适配器GetDevCategory失败 20100215
-#define IDCertificate_UserErrorCode_Reading_Disconnected	(IDCertificate_UserErrorCode_Start + 22) //读证时蓝牙多合一断开
+#define IDCertificate_UserErrorCode_Open_RootCfg_Failed		0x20100201	//打开Root.ini失败 20100201
+#define IDCertificate_UserErrorCode_LogInfoAboutTerm		0x20100202	//告警上送终端模块信息
+#define IDCertificate_UserErrorCode_RootInfo			    0x20100204	//root信息
+#define IDCertificate_UserErrorCode_ScanIImageFailed        0x20100205	//扫描图像失败
 
-#define IDCertificate_UserErrorCode_ScanImg_Failed			(IDCertificate_UserErrorCode_Start + 25) //身份证图片检测失败 
-#define IDCertificate_UserErrorCode_ReadAndScan_Failed		(IDCertificate_UserErrorCode_Start + 26) //读取身份证失败 2010021a
-#define IDCertificate_UserErrorCode_ReadAndScan_Interrupt	(IDCertificate_UserErrorCode_Start + 27) //读取身份证异常退出 2010021b
-#define IDCertificate_UserErrorCode_ReadAndScan_NotHanZi	(IDCertificate_UserErrorCode_Start + 28) //读取身份证非汉字 错误码为 2010021c
-#define IDCertificate_UserErrorCode_ReadAndScan_GetIDInfo	(IDCertificate_UserErrorCode_Start + 29) //读取身份证信息 错误码为 2010021d
-#define IDCertificate_UserErrorCode_ReadAndScan_TransImgFaild (IDCertificate_UserErrorCode_Start + 30) // 扫描图片获取失败错误码为 2010021e
+#define IDCertificate_UserErrorCode_DevOpenFailed			0x2010020d	//设备打开失败 2010020d
+#define IDCertificate_UserErrorCode_DllLoadFailed			0x2010020e  //厂商适配器加载失败 2010020e
+#define IDCertificate_UserErrorCode_Release_Object_Failed	0x2010020f //释放设备失败
+
+#define IDCertificate_UserErrorCode_CancelOperation			0x20100210
+#define IDCertificate_UserErrorCode_DevOpen_Success			0x20100214 //身份证打开成功 20100214
+#define IDCertificate_UserErrorCode_GetDevCategory_Failed	0x20100215 //适配器GetDevCategory失败 20100215
+
+#define IDCertificate_UserErrorCode_ScanImg_Failed			0x20100219 //身份证图片检测失败 
+#define IDCertificate_UserErrorCode_ReadAndScan_Failed		0x2010021a //读取身份证失败 2010021a
+#define IDCertificate_UserErrorCode_ReadAndScan_Interrupt	0x2010021b //读取身份证异常退出 2010021b
+#define IDCertificate_UserErrorCode_ReadAndScan_NotHanZi	0x2010021c //读取身份证非汉字 错误码为 2010021c
+#define IDCertificate_UserErrorCode_ReadAndScan_GetIDInfo	0x2010021d //读取身份证信息 错误码为 2010021d
+#define IDCertificate_UserErrorCode_ReadAndScan_TransImgFaild	0x2010021e // 扫描图片获取失败错误码为 2010021e
 #define IDCertificate_UserErrorCode_ReadAndScan_NotOnReading	0x2010021f //实体不在读证状态
 
 

+ 8 - 0
Module/mod_IDCertificate/mod_IDCertificate.cpp

@@ -8,6 +8,14 @@ void IDCertServerSession::Handle_CancelRead(SpOnewayCallContext<IDCert_CancelRea
 	m_pEntity->CancelRead(ctx);
 }
 
+void IDCertServerSession::Handle_CancelReadJS(SpReqAnsContext<IDCert_CancelReadJS_Req, IDCert_CancelReadJS_Ans>::Pointer ctx)
+{
+	DbgToBeidou(ctx->link, __FUNCTION__)();
+	LOG_FUNCTION();
+	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI(__FUNCTION__)("Handle_CancelReadJS");
+	m_pEntity->CancelReadJS(ctx);
+}
+
 void IDCertServerSession::Handle_GetDevInfo(SpReqAnsContext<IDCert_GetDevInfo_Req, IDCert_GetDevInfo_Ans>::Pointer ctx)
 {
 	DbgToBeidou(ctx->link, __FUNCTION__)();

+ 21 - 0
Module/mod_IDCertificate/mod_IDCertificate.h

@@ -18,6 +18,7 @@ public:
 	IDCertServerSession(CIDCertEntity* pEntity) : m_pEntity(pEntity){}
 	virtual ~IDCertServerSession(){}
 	virtual void Handle_CancelRead(SpOnewayCallContext<IDCert_CancelRead_Info>::Pointer ctx);
+	virtual void Handle_CancelReadJS(SpReqAnsContext<IDCert_CancelReadJS_Req, IDCert_CancelReadJS_Ans>::Pointer ctx);
 	virtual void Handle_GetDevInfo(SpReqAnsContext<IDCert_GetDevInfo_Req, IDCert_GetDevInfo_Ans>::Pointer ctx);
 	virtual void Handle_ReadAndScanUTF8(SpReqAnsContext<IDCert_ReadAndScanUTF8_Req, IDCert_ReadAndScanUTF8_Ans>::Pointer ctx); //ex1
 	virtual void Handle_ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req, IDCert_ReadAndScanUTF8JS_Ans>::Pointer ctx);
@@ -71,6 +72,26 @@ public:
 		m_fsm.PostEventFIFO(e);
 	}
 
+	void CancelReadJS(SpReqAnsContext<IDCert_CancelReadJS_Req, IDCert_CancelReadJS_Ans>::Pointer ctx) //ex2
+	{
+		if (!m_fsm.GetDevInitFlag())
+		{
+			ctx->Answer(Error_DevNotAvailable, IDCertificate_UserErrorCode_DevOpenFailed);
+			LogWarn(Severity_Middle, Error_DevNotAvailable, IDCertificate_UserErrorCode_DevOpenFailed, "Open Dev failed.(ReadAndScanUTF8JS)");
+
+			return;
+		}
+		else if(!m_fsm.GetReadFlag())
+		{
+			ctx->Answer(Error_Unexpect, IDCertificate_UserErrorCode_ReadAndScan_NotOnReading);
+			return;
+		}
+
+		CancelReadEvent* e = new CancelReadEvent();
+		m_fsm.PostEventFIFO(e);
+		ctx->Answer(Error_Succeed);
+	}
+
 	void ReadAndScanUTF8(SpReqAnsContext<IDCert_ReadAndScanUTF8_Req, IDCert_ReadAndScanUTF8_Ans>::Pointer ctx) //ex2
 	{
 		if (!m_fsm.GetDevInitFlag())