Browse Source

Z991239-6279 #comment feat: js接口改用优化后函数

陈纪林80310970 3 months ago
parent
commit
1f100e8071

+ 2 - 1
DevAdapter/include/DevErrorCode.h

@@ -1136,7 +1136,7 @@ typedef short DECRESULT;
 #define MEC_DEVAPI_IDCER_(funcName)	( MEC_DEVAPI_IDCER_##funcName )
 #define MEC_DEVAPI_IDCER_DevOpen				     (DEC_NO_E_IDCERTIFICATE_START + 1) //20100001
 #define MEC_DEVAPI_IDCER_IDCerRFControl				 (DEC_NO_E_IDCERTIFICATE_START + 2) //20100002
-#define MEC_DEVAPI_IDCER_IDCerAuthenticate			 (DEC_NO_E_IDCERTIFICATE_START + 3) //20100003
+#define MEC_DEVAPI_IDCER_IDCerAuthenticate_Error	 (DEC_NO_E_IDCERTIFICATE_START + 3) //20100003
 #define MEC_DEVAPI_IDCER_IDCerAuthenticate_NotIDCard (DEC_NO_E_IDCERTIFICATE_START + 4) //20100004
 #define MEC_DEVAPI_IDCER_IDCerGetDataEx2			 (DEC_NO_E_IDCERTIFICATE_START + 5) //20100005
 #define MEC_DEVAPI_IDCER_ForceIDEject				 (DEC_NO_E_IDCERTIFICATE_START + 6) //20100006
@@ -1145,6 +1145,7 @@ typedef short DECRESULT;
 #define MEC_DEVAPI_IDCER_GetDevCategory              (DEC_NO_E_IDCERTIFICATE_START + 9) //20100009
 #define MEC_DEVAPI_IDCER_Reset                       (DEC_NO_E_IDCERTIFICATE_START + 10) //2010000A
 #define MEC_DEVAPI_IDCER_DevClose                    (DEC_NO_E_IDCERTIFICATE_START + 11) //2010000B
+#define MEC_DEVAPI_IDCER_IDCerAuthenticate_NoCard    (DEC_NO_E_IDCERTIFICATE_START + 12) //2010000C
 
 
 #define DEC_NO_E_IDCERTIFICATE (DEC_NO_E_IDCERTIFICATE_START + CAPACITY_FOR_MEC_DEVAPI)

+ 48 - 309
Module/mod_IDCertificate/IDCertFSM.cpp

@@ -496,7 +496,6 @@ ErrorCodeEnum CIDCertFSM::OnExit()
 int CIDCertFSM::ReadAndScanUTF8(SpReqAnsContext<IDCert_ReadAndScanUTF8_Req, IDCert_ReadAndScanUTF8_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
-
 	DeleteZP(Bmp_ZP | Bmp_SCAN, 1); //清理图片文件
 
 	bool bExitWhenReading = false;
@@ -672,19 +671,19 @@ int CIDCertFSM::ReadAndScanUTF8(SpReqAnsContext<IDCert_ReadAndScanUTF8_Req, IDCe
 				LogWarn(Severity_Low, Error_Unexpect, IDCertificate_UserErrorCode_Timeout_OtherCard, "读证超时,插入的卡片非身份.");
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(IDCertService_LogCode_IDCerAuthenticate)
 					.setAPI("DevAdapter::IDCerAuthenticate").setCostTime(IDCerAuthenticateTime)();
-				ctx->Answer(Error_TimeOut, GetAlarmDEC());
+				ctx->Answer(Error_TimeOut);
 			}
 			else if (errAuth == Error_Dev_IDCardNotFound)
 			{
 				LogWarn(Severity_Low, Error_Unexpect, IDCertificate_UserErrorCode_Timeout_NoCard, "读证超时,未检测到有卡片插入.");
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(IDCertService_LogCode_IDCerAuthenticate)
 					.setAPI("DevAdapter::IDCerAuthenticate").setCostTime(IDCerAuthenticateTime)();
-				ctx->Answer(Error_TimeOut, GetAlarmDEC());
+				ctx->Answer(Error_TimeOut);
 			}
 			else
 			{
-				SetErrorAndLog(errAuth, MEC_DEVAPI_IDCER_IDCerAuthenticate, "DevAdapter::IDCerAuthenticate", __FUNCTION__,
-					false, IDCerAuthenticateTime, IDCertService_LogCode_IDCerAuthenticate); //RTA2107
+				SetErrorAndLog(errAuth, MEC_DEVAPI_IDCER_IDCerAuthenticate_Error, "DevAdapter::IDCerAuthenticate", __FUNCTION__,
+					false, IDCerAuthenticateTime, IDCertService_LogCode_IDCerAuthenticate); //RTA2116
 				ctx->Answer(Error_TimeOut, GetAlarmDEC());
 			}
 		}
@@ -716,62 +715,36 @@ int CIDCertFSM::ReadAndScanUTF8(SpReqAnsContext<IDCert_ReadAndScanUTF8_Req, IDCe
 int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req, IDCert_ReadAndScanUTF8JS_Ans>::Pointer ctx)
 {
 	LOG_FUNCTION();
+	DeleteZP(Bmp_ZP | Bmp_SCAN, 1); //清理图片文件
 
-	ULLINT OpenRFControlTime = 0;
-	ULLINT CloseRFControlTime = 0;
-	ULLINT IDCerAuthenticateTime = 0;
-	ULLINT IDCerGetDataEx2Time = 0;
-	ULLINT ScanIDAndSaveImageTime = 0;
-
+	bool bExitWhenReading = false;
+	int curDeleteType = Bmp_ZP;
 	DWORD elapsed = 0;
 	DWORD dwStart = SP::Module::Comm::RVCGetTickCount();
 	DWORD dwEnd = SP::Module::Comm::RVCGetTickCount();
-	ErrorCodeEnum eErr = Error_Unexpect;
 	ErrorCodeEnum errRfOpen = Error_Unexpect;
 	ErrorCodeEnum errAuth = Error_Unexpect;
-	ErrorCodeEnum errRead = Error_Unexpect;
-	ErrorCodeEnum errReadEx = Error_Unexpect;
 	ErrorCodeEnum errReadEx2 = Error_Unexpect;
-	LogEvent(Severity_Middle, LOG_EVT_IDCERTIFICATE_GREEN_ON, "IDCer warning on");
-
-	DeleteZP(Bmp_ZP | Bmp_SCAN, 1);
-
-	bool bOpenRF = false, bGetIDCert = false;
-	IDCerInfoEx2 idInfoEx2;
-	IDCerInfoEx idInfo;
-	IDCerInfo idInfoOld;
-
-	memset(&idInfoEx2, 0, sizeof(idInfoEx2));
-	memset(&idInfo, 0, sizeof(idInfo));
-	memset(&idInfoOld, 0, sizeof(idInfoOld));
+	ErrorCodeEnum errRfClose = Error_Unexpect;
 
 	m_bCancelRead = false;
 	m_bReading = true;
 	m_bExit = false;
-	bool bReadSuccess = false;
-	bool bInvokeReadEx = false;
-	bool bInvokeReadEx2 = false;
-	bool bExitWhenReading = false;
-	bool bIDCerAuthenticate = false;
-	int curDeleteType = Bmp_ZP;
 
-	while (elapsed < IDCER_READ_TIMEOUT && !bGetIDCert && !m_bCancelRead)
+	LogEvent(Severity_Middle, LOG_EVT_IDCERTIFICATE_GREEN_ON, "IDCer warning on");
+	while (elapsed < IDCER_READ_TIMEOUT && (errReadEx2 != Error_Succeed) && !m_bCancelRead)
 	{
 		if (m_bExit)
 		{
 			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("exit");
 			break;
 		}
-		bReadSuccess = false;
-		bInvokeReadEx = false;
-		bInvokeReadEx2 = false;
-		if (!bOpenRF)
+		if (errRfOpen != Error_Succeed)
 		{
 			m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
 			errRfOpen = m_hDevHelper->IDCerRFControl(true);
 			m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
 			OpenRFControlTime = m_ullEndTime - m_ullBeginTime;
-			
 			if (Error_Succeed == errRfOpen)
 			{
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)
@@ -786,15 +759,12 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
 				continue;
 			}
 		}
-
-		bOpenRF = true;
 		Sleep(IDCER_AUTH_INTERVAL);
-		bIDCerAuthenticate = false;
+
 		m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
 		errAuth = m_hDevHelper->IDCerAuthenticate();
 		m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
 		IDCerAuthenticateTime = m_ullEndTime - m_ullBeginTime;
-
 		if (Error_Succeed != errAuth)
 		{
 			dwEnd = SP::Module::Comm::RVCGetTickCount();
@@ -803,9 +773,11 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
 		}
 		else
 		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)
-				.setAPI("DevAdapter::IDCerAuthenticate").setCostTime(IDCerAuthenticateTime)();
-			bIDCerAuthenticate = true;
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)
+				.setAPI("DevAdapter::IDCerAuthenticate").setLogCode(IDCertService_LogCode_IDCerAuthenticate).setCostTime(IDCerAuthenticateTime)();
+
+			IDCerInfoEx2 idInfoEx2;
+			memset(&idInfoEx2, 0, sizeof(idInfoEx2));
 
 			m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
 			errReadEx2 = m_hDevHelper->IDCerGetDataEx2(idInfoEx2);
@@ -820,262 +792,38 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
 			{
 				ctx->Ans.msgtype = 1; //新字段传递,UTF8、二进制传递文字信息
 				//ex2数据读取功能代码、UCS2转UTF8代码
-				bInvokeReadEx2 = true;
-				if (errReadEx2 != Error_Succeed)
-				{
-					bReadSuccess = false;
-				}
-				else
+				if (errReadEx2 == Error_Succeed)
 				{
-					unsigned char name[1024]; memset(name, 0, 1024);
-					unsigned char sex[1024]; memset(sex, 0, 1024);
-					unsigned char nation[1024]; memset(nation, 0, 1024);
-					unsigned char birthday[1024]; memset(birthday, 0, 1024);
-					unsigned char address[1024]; memset(address, 0, 1024);
-					unsigned char idno[1024]; memset(idno, 0, 1024);
-					unsigned char department[1024]; memset(department, 0, 1024);
-					unsigned char startDate[1024]; memset(startDate, 0, 1024);
-					unsigned char endDate[1024]; memset(endDate, 0, 1024);
-					unsigned char englishName[1024]; memset(englishName, 0, 1024);
-					unsigned char nationality[1024]; memset(nationality, 0, 1024);
-					unsigned char idVersion[1024]; memset(idVersion, 0, 1024);
-					unsigned char idType[1024]; memset(idType, 0, 1024);
-
-					unsigned char reserved[1024]; memset(reserved, 0, 1024);//外国人永居证旧证件关联字段
-					unsigned char englishNameEx[1024]; memset(englishNameEx, 0, 1024); //英文名备用字段
-					unsigned char IssuedSN[1024]; memset(IssuedSN, 0, 1024); //换证次数
-
 					DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER)
-						.setAPI("DevAdapter::IDCerGetDataEx2").setCostTime(IDCerGetDataEx2Time)();
-					bReadSuccess = true;
+						.setAPI("DevAdapter::IDCerGetDataEx2").setLogCode(IDCertService_LogCode_IDCerGetDataEx2).setCostTime(IDCerGetDataEx2Time)();
 					LogEvent(Severity_Middle, LOG_EVT_IDCERTIFICATE_OP, "IDCertifacate op.");
 
-					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("各字段长度-姓名:%d; 性别:%d; 民族:%d; 身份证:%d;",
-						GetUCS2ByteLength((UINT16*)idInfoEx2.name.data), GetUCS2ByteLength((UINT16*)idInfoEx2.sex.data),
-						GetUCS2ByteLength((UINT16*)idInfoEx2.nation.data), GetUCS2ByteLength((UINT16*)idInfoEx2.idno.data));
-					//去除首尾空格
-					RemoveUCS2Blank((UINT16*)idInfoEx2.name.data);
-					CheckHanZi((UINT16*)idInfoEx2.name.data); //检测汉字编码
-
-					RemoveUCS2Blank((UINT16*)idInfoEx2.sex.data);
-					RemoveUCS2Blank((UINT16*)idInfoEx2.nation.data);
-					RemoveUCS2Blank((UINT16*)idInfoEx2.birthday.data);
-					RemoveUCS2Blank((UINT16*)idInfoEx2.address.data);
-					RemoveUCS2Blank((UINT16*)idInfoEx2.idno.data);
-					RemoveUCS2Blank((UINT16*)idInfoEx2.department.data);
-					RemoveUCS2Blank((UINT16*)idInfoEx2.startDate.data);
-					RemoveUCS2Blank((UINT16*)idInfoEx2.endDate.data);
-					RemoveUCS2Blank((UINT16*)idInfoEx2.englishName.data);
-					RemoveUCS2Blank((UINT16*)idInfoEx2.nationality.data);
-					RemoveUCS2Blank((UINT16*)idInfoEx2.idVersion.data);
-					RemoveUCS2Blank((UINT16*)idInfoEx2.idType.data);
-
-					RemoveUCS2Blank((UINT16*)idInfoEx2.reserved.data); //外国人永居证旧证件关联字段
-					RemoveUCS2Blank((UINT16*)idInfoEx2.reserved2.data); //英文名备用字段
-					RemoveUCS2Blank((UINT16*)idInfoEx2.issuedSN.data); //换证次数
-#ifdef RVC_OS_WIN
-					//转换成GBK用于debug上传
-					char* tSex = new char[32];
-					char* tNation = new char[32];
-					char* tBirthday = new char[32];
-					char* tStartDate = new char[32];
-					char* tEndDate = new char[32];
-					char* tIDcode = new char[1024];
-					char* tIDtype = new char[8];
-					char* tName = new char[128];
-					char* tNationality = new char[8];
-					char* tChecKNum = new char[8];
-					memcpy(tSex, idInfoEx2.sex.data, 32);
-					memcpy(tNation, idInfoEx2.nation.data, 32);
-					memcpy(tBirthday, idInfoEx2.birthday.data, 32);
-					memcpy(tStartDate, idInfoEx2.startDate.data, 32);
-					memcpy(tEndDate, idInfoEx2.endDate.data, 32);
-					memcpy(tIDcode, idInfoEx2.idno.data, 1024);
-					memcpy(tIDtype, idInfoEx2.idType.data, 8);
-					memcpy(tName, idInfoEx2.name.data, 128);
-					memcpy(tNationality, idInfoEx2.nationality.data, 8);
-					memcpy(tChecKNum, idInfoEx2.issuedSN.data, 8);
-					char* gbkSex, * gbkNation, * gbkBirthday, * gbkStartDate, * gbkEndDate, * gbkIDcode, * gbkIDtype, * gbkName, * gbkNationality, * gbktCheckNum;
-					int iSize;
-					//sex
-					iSize = WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tSex, -1, NULL, 0, NULL, NULL);
-					gbkSex = (char*)malloc((iSize + 1));
-					WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tSex, -1, gbkSex, iSize, NULL, NULL);
-					//nation
-					iSize = WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tNation, -1, NULL, 0, NULL, NULL);
-					gbkNation = (char*)malloc((iSize + 1));
-					WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tNation, -1, gbkNation, iSize, NULL, NULL);
-					//birthday
-					iSize = WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tBirthday, -1, NULL, 0, NULL, NULL);
-					gbkBirthday = (char*)malloc((iSize + 1));
-					WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tBirthday, -1, gbkBirthday, iSize, NULL, NULL);
-					//startdate
-					iSize = WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tStartDate, -1, NULL, 0, NULL, NULL);
-					gbkStartDate = (char*)malloc((iSize + 1));
-					WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tStartDate, -1, gbkStartDate, iSize, NULL, NULL);
-					//endate
-					iSize = WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tEndDate, -1, NULL, 0, NULL, NULL);
-					gbkEndDate = (char*)malloc((iSize + 1));
-					WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tEndDate, -1, gbkEndDate, iSize, NULL, NULL);
-					//idcode
-					iSize = WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tIDcode, -1, NULL, 0, NULL, NULL);
-					gbkIDcode = (char*)malloc((iSize + 1));
-					WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tIDcode, -1, gbkIDcode, iSize, NULL, NULL);
-					//idtype
-					iSize = WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tIDtype, -1, NULL, 0, NULL, NULL);
-					gbkIDtype = (char*)malloc((iSize + 1));
-					WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tIDtype, -1, gbkIDtype, iSize, NULL, NULL);
-					//name
-					iSize = WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tName, -1, NULL, 0, NULL, NULL);
-					gbkName = (char*)malloc((iSize + 1));
-					WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tName, -1, gbkName, iSize, NULL, NULL);
-					//natinality
-					iSize = WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tNationality, -1, NULL, 0, NULL, NULL);
-					gbkNationality = (char*)malloc((iSize + 1));
-					WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tNationality, -1, gbkNationality, iSize, NULL, NULL);
-					//issuedSN
-					iSize = WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tChecKNum, -1, NULL, 0, NULL, NULL);
-					gbktCheckNum = (char*)malloc((iSize + 1));
-					WideCharToMultiByte(CP_ACP, 0, (wchar_t*)tChecKNum, -1, gbktCheckNum, iSize, NULL, NULL);
-					//gbk转换结束
-#endif
-					UCS2_to_UTF8((UINT16*)idInfoEx2.name.data, name);
-					//UCS2_to_UTF8((UINT16*)idInfoEx2.sex.data, sex);
-					GetSexUTF8String((UINT16*)idInfoEx2.sex.data, sex);
-					//UCS2_to_UTF8((UINT16*)idInfoEx2.nation.data, nation);
-					GetNationalUTF8String((UINT16*)idInfoEx2.nation.data, nation);
-					//UCS2_to_UTF8((UINT16*)idInfoEx2.birthday.data, birthday);
-					GetDateStandardFormatUTF8((UINT16*)idInfoEx2.birthday.data, birthday);
-					UCS2_to_UTF8((UINT16*)idInfoEx2.address.data, address);
-					UCS2_to_UTF8((UINT16*)idInfoEx2.idno.data, idno);
-					UCS2_to_UTF8((UINT16*)idInfoEx2.department.data, department);
-					//UCS2_to_UTF8((UINT16*)idInfoEx2.startDate.data, startDate);
-					GetDateStandardFormatUTF8((UINT16*)idInfoEx2.startDate.data, startDate);
-					//UCS2_to_UTF8((UINT16*)idInfoEx2.endDate.data, endDate);
-					GetDateStandardFormatUTF8((UINT16*)idInfoEx2.endDate.data, endDate);
-					UCS2_to_UTF8((UINT16*)idInfoEx2.englishName.data, englishName);
-					UCS2_to_UTF8((UINT16*)idInfoEx2.nationality.data, nationality);
-					UCS2_to_UTF8((UINT16*)idInfoEx2.idVersion.data, idVersion);
-					UCS2_to_UTF8((UINT16*)idInfoEx2.idType.data, idType);
-
-					UCS2_to_UTF8((UINT16*)idInfoEx2.reserved.data, reserved);
-					UCS2_to_UTF8((UINT16*)idInfoEx2.reserved2.data, englishNameEx);
-					UCS2_to_UTF8((UINT16*)idInfoEx2.issuedSN.data, IssuedSN);
-
-					ctx->Ans.name_utf8.Alloc(strlen((char*)name));
-					ctx->Ans.sex_utf8.Alloc(strlen((char*)sex));
-					ctx->Ans.nation_utf8.Alloc(strlen((char*)nation));
-					ctx->Ans.birthday_utf8.Alloc(strlen((char*)birthday));
-					ctx->Ans.address_utf8.Alloc(strlen((char*)address));
-					ctx->Ans.idcode_utf8.Alloc(strlen((char*)idno));
-					ctx->Ans.department_utf8.Alloc(strlen((char*)department));
-					ctx->Ans.startdate_utf8.Alloc(strlen((char*)startDate));
-					ctx->Ans.enddate_utf8.Alloc(strlen((char*)endDate));
-					ctx->Ans.englishname_utf8.Alloc(strlen((char*)englishName));
-					ctx->Ans.nationality_utf8.Alloc(strlen((char*)nationality));
-					ctx->Ans.idversion_utf8.Alloc(strlen((char*)idVersion));
-					ctx->Ans.idtype_utf8.Alloc(strlen((char*)idType));
-					ctx->Ans.reserved_utf8.Alloc(strlen((char*)reserved)); //新外国人永居证关联字段
-					ctx->Ans.othercode_utf8.Alloc(strlen((char*)englishNameEx)); //英文名备用字段
-
-					memcpy(ctx->Ans.name_utf8.m_pData, name, strlen((char*)name));
-					memcpy(ctx->Ans.sex_utf8.m_pData, sex, strlen((char*)sex));
-					memcpy(ctx->Ans.nation_utf8.m_pData, nation, strlen((char*)nation));
-					memcpy(ctx->Ans.birthday_utf8.m_pData, birthday, strlen((char*)birthday));
-					memcpy(ctx->Ans.address_utf8.m_pData, address, strlen((char*)address));
-					memcpy(ctx->Ans.idcode_utf8.m_pData, idno, strlen((char*)idno));
-					memcpy(ctx->Ans.department_utf8.m_pData, department, strlen((char*)department));
-					memcpy(ctx->Ans.startdate_utf8.m_pData, startDate, strlen((char*)startDate));
-					memcpy(ctx->Ans.enddate_utf8.m_pData, endDate, strlen((char*)endDate));
-					memcpy(ctx->Ans.englishname_utf8.m_pData, englishName, strlen((char*)englishName));
-					memcpy(ctx->Ans.nationality_utf8.m_pData, nationality, strlen((char*)nationality));
-					memcpy(ctx->Ans.idversion_utf8.m_pData, idVersion, strlen((char*)idVersion));
-					memcpy(ctx->Ans.idtype_utf8.m_pData, idType, strlen((char*)idType));
-					memcpy(ctx->Ans.reserved_utf8.m_pData, reserved, strlen((char*)reserved)); //新外国人永居证关联字段
-					memcpy(ctx->Ans.othercode_utf8.m_pData, englishNameEx, strlen((char*)englishNameEx)); //英文名备用字段
-
+					//转换数据并赋值至传出字段
+					CopyTextIDCerDataToCtx(idInfoEx2, ctx);
+					//转换头像图片
+					GetPngBlobEx(ctx->Ans.headphoto, "zp");
+					ctx->Ans.photodata = ctx->Ans.headphoto;
 					ctx->Ans.hasscan = 0;
-					GetPngBlobEx(ctx->Ans.headphoto, "zp"); //转换头像图片
-
 					if (igestionVer == TRUE) //吸入式设备才调用正反扫描功能
 					{
-						m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
-						eErr = m_hDevHelper->ScanIDAndSaveImage();
-						m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
-						ScanIDAndSaveImageTime = m_ullEndTime - m_ullBeginTime;
-
-						if (eErr == Error_Succeed)
+						if (GetAndCheckScanImg(idInfoEx2, ctx->Ans.frontphoto, ctx->Ans.backphoto))
 						{
 							curDeleteType = Bmp_ZP | Bmp_SCAN;
-							DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::ScanIDAndSaveImage")
-								.setCostTime(ScanIDAndSaveImageTime)();
-							
-							transImgMsg.Clear();
-							//idfront.bmp" and "idback.bmp
-							ErrorCodeEnum eErrFront, eErrBack;
-							eErrFront = GetPngBlobEx(ctx->Ans.frontphoto, "idfront");
-							eErrBack = GetPngBlobEx(ctx->Ans.backphoto, "idback");
-							if (eErrFront == Error_Succeed && eErrBack == Error_Succeed)
-							{
-								ctx->Ans.hasscan = 1;
-#ifdef RVC_OS_WIN
-								if (!closeImgCheck)
-								{
-									ImgChekTask* frontImgCheck = new ImgChekTask(this);
-									frontImgCheck->idNum =/* ctx->Ans.idcode_utf8.m_pData*/gbkIDcode;
-									frontImgCheck->inName = /*ctx->Ans.name_utf8.m_pData*/gbkName;
-									frontImgCheck->inNationality = /*ctx->Ans.nationality_utf8.m_pData*/gbkNationality;
-									frontImgCheck->inIdType = /*ctx->Ans.idtype_utf8.m_pData*/gbkIDtype;
-									frontImgCheck->imgInput = ctx->Ans.frontphoto;
-									frontImgCheck->imgType = "正面";
-									GetEntityBase()->GetFunction()->PostThreadPoolTask(frontImgCheck);
-
-									ImgChekTask* backImgCheck = new ImgChekTask(this);
-									backImgCheck->idNum = /*ctx->Ans.idcode_utf8.m_pData*/gbkIDcode;
-									backImgCheck->inName = /*ctx->Ans.name_utf8.m_pData*/gbkName;
-									backImgCheck->inNationality = /*ctx->Ans.nationality_utf8.m_pData*/gbkNationality;
-									backImgCheck->inIdType = /*ctx->Ans.idtype_utf8.m_pData*/gbkIDtype;
-									backImgCheck->imgInput = ctx->Ans.backphoto;
-									frontImgCheck->imgType = "背面";
-									GetEntityBase()->GetFunction()->PostThreadPoolTask(backImgCheck);
-								}
-#endif
-							}
-							else
-							{
-								CSimpleStringA warnMsg = "ScanIDAndSaveImage() suc. But GetPngBlobEx() failed.";
-								if (transImgMsg.GetLength() != 0)
-								{
-									warnMsg = warnMsg + transImgMsg;
-								}
-								LogWarn(Severity_Middle, Error_Succeed,
-									IDCertificate_UserErrorCode_ReadAndScan_TransImgFaild, warnMsg.GetData());
-							}
-						}
-						else
-						{
-							if(eErr != Error_NotImpl)
-							SetErrorAndLog(eErr, MEC_DEVAPI_IDCER_ScanIDAndSaveImage, "DevAdapter::ScanIDAndSaveImage", __FUNCTION__,
-								false, ScanIDAndSaveImageTime);
+							ctx->Ans.hasscan = 1;
 						}
 					}
 
 #ifdef RVC_OS_WIN
 					CSimpleStringA csIDLogInfo = CSimpleStringA::Format("IDNo:%s****%s"
-						, (const char*)CSimpleStringA(gbkIDcode).SubString(0, 4)
-						, (const char*)CSimpleStringA(gbkIDcode).SubString(CSimpleStringA(gbkIDcode).GetLength() - 1, 1));
+						, (const char*)CSimpleStringA(GetGBKString((UINT16*)idInfoEx2.idno.data)).SubString(0, 4)
+						, (const char*)CSimpleStringA(GetGBKString((UINT16*)idInfoEx2.idno.data)).SubString(CSimpleStringA(GetGBKString((UINT16*)idInfoEx2.idno.data)).GetLength() - 1, 1));
 #else
 					CSimpleStringA tIdcode = (char*)idno;
 					CSimpleStringA csIDLogInfo = CSimpleStringA::Format("IDNo:%s****%s"
 						, (const char*)tIdcode.SubString(0, 4), (const char*)tIdcode.SubString(tIdcode.GetLength() - 1, 1));
 #endif
-
 					LogWarn(Severity_Low, Error_Succeed, IDCertificate_UserErrorCode_ReadAndScan_GetIDInfo, csIDLogInfo.GetData());
-
-					ctx->Ans.photodata = ctx->Ans.headphoto;
 					DeleteZP(curDeleteType, 2);
-
-					bGetIDCert = true;
 					break;
 				}
 			}
@@ -1083,24 +831,25 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
 		dwEnd = SP::Module::Comm::RVCGetTickCount();
 		elapsed = dwEnd - dwStart;
 	}
-
 	DeleteZP(curDeleteType);
 
 	if (m_bExit)
+	{
 		bExitWhenReading = true;
+	}
 
 	m_bExit = false;
 	m_bReading = false;
 	LogEvent(Severity_Middle, LOG_EVT_IDCERTIFICATE_GREEN_OFF, "IDCer warning off");
 
 	m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
-	ErrorCodeEnum eErr1 = m_hDevHelper->IDCerRFControl(false);
+	errRfClose = m_hDevHelper->IDCerRFControl(false);
 	m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
 	CloseRFControlTime = m_ullEndTime - m_ullBeginTime;
 
-	if (eErr1 != Error_Succeed)
+	if (errRfClose != Error_Succeed)
 	{
-		SetErrorAndLog(eErr1, MEC_DEVAPI_IDCER_IDCerRFControl, "DevAdapter::IDCerRFControl", __FUNCTION__,
+		SetErrorAndLog(errRfClose, MEC_DEVAPI_IDCER_IDCerRFControl, "DevAdapter::IDCerRFControl", __FUNCTION__,
 			false, CloseRFControlTime, IDCertService_LogCode_CloseIDCerRFControl);
 	}
 	else
@@ -1110,7 +859,7 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
 			.setCostTime(CloseRFControlTime)();
 	}
 
-	if (bGetIDCert)
+	if (errReadEx2 == Error_Succeed)
 	{
 		ctx->Answer(Error_Succeed);
 	}
@@ -1120,53 +869,44 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
 	}
 	else if (elapsed >= IDCER_READ_TIMEOUT)
 	{
-		if (bIDCerAuthenticate) {
-			if (bInvokeReadEx2 && !bReadSuccess) {
+		if (errAuth == Error_Succeed) {
+			if (errReadEx2 != Error_Succeed) {
 
 				SetErrorAndLog(errReadEx2, MEC_DEVAPI_IDCER_IDCerGetDataEx2, "DevAdapter::IDCerGetDataEx2", __FUNCTION__,
-					true, IDCerGetDataEx2Time);
-				//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Invoke IDCerGetDataEx2(Timeout) failed: %s", SpStrError(errReadEx2));
-
-				ctx->Answer(Error_TimeOut, GetAlarmDEC()); //RTA2109
+					true, IDCerGetDataEx2Time, IDCertService_LogCode_IDCerGetDataEx2);
+				ctx->Answer(Error_Unexpect, GetAlarmDEC()); //RTA2109
 			}
 		}
-		else if (!bOpenRF)
+		else if (errRfOpen != Error_Succeed)
 		{
 			SetErrorAndLog(errRfOpen, MEC_DEVAPI_IDCER_IDCerRFControl, "DevAdapter::IDCerRFControl", __FUNCTION__,
 				true, OpenRFControlTime, IDCertService_LogCode_OpenIDCerRFControl);
-			//DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Open IDCerRFControl(Timeout) failed: %s", SpStrError(errRfOpen));
-
-			ctx->Answer(Error_TimeOut, GetAlarmDEC());
+			ctx->Answer(Error_Unexpect, GetAlarmDEC()); //RTA2106
 		}
 		else
 		{
-			
 			if (errAuth == Error_DevMedia)
 			{
 				LogWarn(Severity_Low, Error_Unexpect, IDCertificate_UserErrorCode_Timeout_OtherCard, "读证超时,插入的卡片非身份.");
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::IDCerAuthenticate").setCostTime(IDCerAuthenticateTime)();
-				ctx->Answer(Error_TimeOut);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(IDCertService_LogCode_IDCerAuthenticate)
+					.setAPI("DevAdapter::IDCerAuthenticate").setCostTime(IDCerAuthenticateTime)();
+				ctx->Answer(Error_Unexpect, GetAlarmDEC(MEC_DEVAPI_IDCER_IDCerAuthenticate_NotIDCard)); //RTA2108
 			}
 			else if (errAuth == Error_Dev_IDCardNotFound)
 			{
 				LogWarn(Severity_Low, Error_Unexpect, IDCertificate_UserErrorCode_Timeout_NoCard, "读证超时,未检测到有卡片插入.");
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setAPI("DevAdapter::IDCerAuthenticate").setCostTime(IDCerAuthenticateTime)();
-				ctx->Answer(Error_TimeOut);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(IDCertService_LogCode_IDCerAuthenticate)
+					.setAPI("DevAdapter::IDCerAuthenticate").setCostTime(IDCerAuthenticateTime)();
+				ctx->Answer(Error_Unexpect, GetAlarmDEC(MEC_DEVAPI_IDCER_IDCerAuthenticate_NoCard)); //RTA2107
 			}
 			else
 			{
-				SetErrorAndLog(errAuth, MEC_DEVAPI_IDCER_IDCerAuthenticate, "DevAdapter::IDCerAuthenticate", __FUNCTION__,
-					false, IDCerAuthenticateTime); //RTA2107
+				SetErrorAndLog(errAuth, MEC_DEVAPI_IDCER_IDCerAuthenticate_Error, "DevAdapter::IDCerAuthenticate", __FUNCTION__,
+					false, IDCerAuthenticateTime, IDCertService_LogCode_IDCerAuthenticate); //RTA2116
 				ctx->Answer(Error_Unexpect, GetAlarmDEC());
 			}
 		}
 	}
-	else
-	{
-		DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_USER).setResultCode("RTA2104")("ReadAndScanUTF8JS some thing wrong.");
-		ctx->Answer(Error_Unexpect, IDCertificate_UserErrorCode_ReadAndScan_Failed);
-		LogError(Severity_High, Error_Unexpect, IDCertificate_UserErrorCode_ReadAndScan_Failed, "ReadAndScanUTF8 some thing wrong.");
-	}
 
 	if (m_bCancelRead)
 	{
@@ -1181,7 +921,6 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
 
 		return 2;
 	}
-
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("return 0");
 	return 0;
 }

+ 1 - 1
Module/mod_IDCertificate/IDCertificate_UserErrorCode.h

@@ -25,7 +25,7 @@
 #define IDCertificate_UserErrorCode_ReadAndScan_NotOnReading	0x2010021f //实体不在读证状态
 #define IDCertificate_UserErrorCode_FindFile_in_DepBak			0x20100220 //旧dep目录下获取到厂商文件
 #define IDCertificate_UserErrorCode_Timeout_NoCard			0x20100221 //超时未插卡
-#define IDCertificate_UserErrorCode_Timeout_OtherCard		0x20100221 //插入其他卡片(非身份证)
+#define IDCertificate_UserErrorCode_Timeout_OtherCard		0x20100222 //插入其他卡片(非身份证)
 
 
 //#define IDCertificate_UserErrorCode_Real_Root_Config		(IDCertificate_UserErrorCode_Start + 31) //加载实际的root配置