|
@@ -7,6 +7,7 @@
|
|
|
#include <cv.h>
|
|
|
#include <cxcore.h>
|
|
|
#include <fstream>
|
|
|
+#include <iomanip>
|
|
|
#ifdef RVC_OS_LINUX
|
|
|
#include "CommDevEntityErrorCode.h"
|
|
|
#include <iostream>
|
|
@@ -30,15 +31,15 @@ using namespace SP::Module::Comm;
|
|
|
#define IDCER_AUTH_INTERVAL 300
|
|
|
|
|
|
#ifdef DEVOPS_ON_ST /*DevOps流水线编译,ST环境*/
|
|
|
-#define IMAGE_DETECT_URL "https://carddetect.paasst.cmbchina.cn/api/card/image-detect";
|
|
|
+#define IMAGE_DETECT_URL "https://carddetect.paasst.cmbchina.cn/api/card/image-detect"
|
|
|
#elif defined(DEVOPS_ON_UAT)/*DevOps流水线编译,UAT环境*/
|
|
|
-#define IMAGE_DETECT_URL "https://carddetect.paasuat.cmbchina.cn/api/card/image-detect";
|
|
|
+#define IMAGE_DETECT_URL "https://carddetect.paasuat.cmbchina.cn/api/card/image-detect"
|
|
|
#elif defined(DEVOPS_ON_PRD)/*DevOps流水线编译,PRD环境*/
|
|
|
-#define IMAGE_DETECT_URL "https://carddetect.paas.cmbchina.cn/api/card/image-detect";
|
|
|
+#define IMAGE_DETECT_URL "https://carddetect.paas.cmbchina.cn/api/card/image-detect"
|
|
|
#elif defined(DEVOPS_ON_DEV)/*DevOps流水线编译,Dev&生产环境*/
|
|
|
-#define IMAGE_DETECT_URL "https://carddetect.paas.cmbchina.cn/api/card/image-detect";
|
|
|
+#define IMAGE_DETECT_URL "https://carddetect.paas.cmbchina.cn/api/card/image-detect"
|
|
|
#else/*本地编译等非DevOps环境编译的版本*/
|
|
|
-#define IMAGE_DETECT_URL "https://carddetect.paasst.cmbchina.cn/api/card/image-detect";
|
|
|
+#define IMAGE_DETECT_URL "https://carddetect.paasst.cmbchina.cn/api/card/image-detect"
|
|
|
#endif
|
|
|
|
|
|
#ifdef RVC_OS_WIN
|
|
@@ -546,7 +547,7 @@ int CIDCertFSM::ReadAndScanUTF8(SpReqAnsContext<IDCert_ReadAndScanUTF8_Req, IDCe
|
|
|
ErrorCodeEnum errReadEx2 = Error_Unexpect;
|
|
|
LogEvent(Severity_Middle, LOG_EVT_IDCERTIFICATE_GREEN_ON, "IDCer warning on");
|
|
|
|
|
|
- DeleteZP(Bmp_ZP | Bmp_SCAN);
|
|
|
+ DeleteZP(Bmp_ZP | Bmp_SCAN, 1);
|
|
|
|
|
|
bool bOpenRF = false, bGetIDCert = false;
|
|
|
IDCerInfoEx2 idInfoEx2;
|
|
@@ -809,8 +810,10 @@ int CIDCertFSM::ReadAndScanUTF8(SpReqAnsContext<IDCert_ReadAndScanUTF8_Req, IDCe
|
|
|
GetPngBlobEx(ctx->Ans.headphoto, "zp"); //转换头像图片
|
|
|
|
|
|
ctx->Ans.hasscan = 0;
|
|
|
+ int curDeleteType = Bmp_ZP;
|
|
|
if (igestionVer == TRUE) //吸入式设备才调用正反扫描功能
|
|
|
{
|
|
|
+ curDeleteType = Bmp_ZP | Bmp_SCAN;
|
|
|
m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
|
|
|
eErr = m_hDevHelper->ScanIDAndSaveImage();
|
|
|
m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
|
|
@@ -833,7 +836,7 @@ int CIDCertFSM::ReadAndScanUTF8(SpReqAnsContext<IDCert_ReadAndScanUTF8_Req, IDCe
|
|
|
//idfront.bmp" and "idback.bmp
|
|
|
ErrorCodeEnum eErrFront, eErrBack;
|
|
|
eErrFront = GetPngBlobEx(ctx->Ans.frontphoto, "idfront");
|
|
|
- eErrBack = GetPngBlobEx(ctx->Ans.backphoto, "idback", true);
|
|
|
+ eErrBack = GetPngBlobEx(ctx->Ans.backphoto, "idback");
|
|
|
if (eErrFront == Error_Succeed && eErrBack == Error_Succeed)
|
|
|
{
|
|
|
ctx->Ans.hasscan = 1;
|
|
@@ -886,7 +889,7 @@ int CIDCertFSM::ReadAndScanUTF8(SpReqAnsContext<IDCert_ReadAndScanUTF8_Req, IDCe
|
|
|
LogWarn(Severity_Low, Error_Succeed, IDCertificate_UserErrorCode_ReadAndScan_GetIDInfo, csIDLogInfo.GetData());
|
|
|
|
|
|
ctx->Ans.photodata = ctx->Ans.headphoto;
|
|
|
- DeleteZP(Bmp_ZP);
|
|
|
+ DeleteZP(curDeleteType, 2);
|
|
|
|
|
|
bGetIDCert = true;
|
|
|
break;
|
|
@@ -1042,8 +1045,14 @@ int CIDCertFSM::ReadAndScanUTF8(SpReqAnsContext<IDCert_ReadAndScanUTF8_Req, IDCe
|
|
|
{
|
|
|
if (errAuth == Error_DevMedia)
|
|
|
{
|
|
|
- SetErrorAndLog(errAuth, MEC_DEVAPI_IDCER_IDCerAuthenticate_NotIDCard, "DevAdapter::IDCerAuthenticate", __FUNCTION__,
|
|
|
- false, m_ullEndTime - m_ullBeginTime, IDCertService_LogCode_ReadAndScanUTF8); //RTA2108
|
|
|
+ LogWarn(Severity_Low, Error_Unexpect, IDCertificate_UserErrorCode_Timeout_OtherCard, "读证超时,插入的卡片非身份.");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(IDCertService_LogCode_ReadAndScanUTF8)();
|
|
|
+ ctx->Answer(Error_Unexpect, GetAlarmDEC());
|
|
|
+ }
|
|
|
+ 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_ReadAndScanUTF8)();
|
|
|
ctx->Answer(Error_Unexpect, GetAlarmDEC());
|
|
|
}
|
|
|
else
|
|
@@ -1100,7 +1109,7 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
|
|
|
ErrorCodeEnum errReadEx2 = Error_Unexpect;
|
|
|
LogEvent(Severity_Middle, LOG_EVT_IDCERTIFICATE_GREEN_ON, "IDCer warning on");
|
|
|
|
|
|
- DeleteZP(Bmp_ZP | Bmp_SCAN);
|
|
|
+ DeleteZP(Bmp_ZP | Bmp_SCAN, 1);
|
|
|
|
|
|
bool bOpenRF = false, bGetIDCert = false;
|
|
|
IDCerInfoEx2 idInfoEx2;
|
|
@@ -1361,10 +1370,12 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
|
|
|
memcpy(ctx->Ans.othercode_utf8.m_pData, englishNameEx, strlen((char*)englishNameEx)); //英文名备用字段
|
|
|
|
|
|
ctx->Ans.hasscan = 0;
|
|
|
- GetPngBlobEx(ctx->Ans.headphoto, "zp", true); //转换头像图片
|
|
|
+ GetPngBlobEx(ctx->Ans.headphoto, "zp"); //转换头像图片
|
|
|
|
|
|
- if (igestionVer == TRUE)//吸入式设备才调用正反扫描功能
|
|
|
+ int curDeleteType = Bmp_ZP;
|
|
|
+ if (igestionVer == TRUE) //吸入式设备才调用正反扫描功能
|
|
|
{
|
|
|
+ curDeleteType = Bmp_ZP | Bmp_SCAN;
|
|
|
m_ullBeginTime = SP::Module::Comm::RVCGetTickCount();
|
|
|
eErr = m_hDevHelper->ScanIDAndSaveImage();
|
|
|
m_ullEndTime = SP::Module::Comm::RVCGetTickCount();
|
|
@@ -1386,7 +1397,7 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
|
|
|
//idfront.bmp" and "idback.bmp
|
|
|
ErrorCodeEnum eErrFront, eErrBack;
|
|
|
eErrFront = GetPngBlobEx(ctx->Ans.frontphoto, "idfront");
|
|
|
- eErrBack = GetPngBlobEx(ctx->Ans.backphoto, "idback", true);
|
|
|
+ eErrBack = GetPngBlobEx(ctx->Ans.backphoto, "idback");
|
|
|
if (eErrFront == Error_Succeed && eErrBack == Error_Succeed)
|
|
|
{
|
|
|
ctx->Ans.hasscan = 1;
|
|
@@ -1439,7 +1450,7 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
|
|
|
LogWarn(Severity_Low, Error_Succeed, IDCertificate_UserErrorCode_ReadAndScan_GetIDInfo, csIDLogInfo.GetData());
|
|
|
|
|
|
ctx->Ans.photodata = ctx->Ans.headphoto;
|
|
|
- DeleteZP(Bmp_ZP);
|
|
|
+ DeleteZP(curDeleteType, 2);
|
|
|
|
|
|
bGetIDCert = true;
|
|
|
break;
|
|
@@ -1615,17 +1626,22 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
|
|
|
else
|
|
|
{
|
|
|
|
|
|
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("ReadAndScanUTF8::IDCerAuthenticate(Timeout) failed with errcode: %d", errAuth);
|
|
|
if (errAuth == Error_DevMedia)
|
|
|
{
|
|
|
- SetErrorAndLog(errAuth, MEC_DEVAPI_IDCER_IDCerAuthenticate_NotIDCard, "DevAdapter::IDCerAuthenticate", __FUNCTION__,
|
|
|
- false, m_ullEndTime - m_ullBeginTime, IDCertService_LogCode_ReadAndScanUTF8JS); //RTA2108
|
|
|
+ LogWarn(Severity_Low, Error_Unexpect, IDCertificate_UserErrorCode_Timeout_OtherCard, "读证超时,插入的卡片非身份.");
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(IDCertService_LogCode_ReadAndScanUTF8)();
|
|
|
+ ctx->Answer(Error_Unexpect, GetAlarmDEC());
|
|
|
+ }
|
|
|
+ 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_ReadAndScanUTF8)();
|
|
|
ctx->Answer(Error_Unexpect, GetAlarmDEC());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
SetErrorAndLog(errAuth, MEC_DEVAPI_IDCER_IDCerAuthenticate, "DevAdapter::IDCerAuthenticate", __FUNCTION__,
|
|
|
- false, m_ullEndTime - m_ullBeginTime, IDCertService_LogCode_ReadAndScanUTF8JS); //RTA2107
|
|
|
+ false, m_ullEndTime - m_ullBeginTime, IDCertService_LogCode_ReadAndScanUTF8); //RTA2107
|
|
|
ctx->Answer(Error_Unexpect, GetAlarmDEC());
|
|
|
}
|
|
|
}
|
|
@@ -1755,7 +1771,7 @@ void CIDCertFSM::SelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionCon
|
|
|
pTransactionContext->SendAnswer(m_testResult);
|
|
|
}
|
|
|
|
|
|
-ErrorCodeEnum CIDCertFSM::DeleteFileIfExisted(LPCTSTR fileName)
|
|
|
+ErrorCodeEnum CIDCertFSM::DeleteFileIfExisted(LPCTSTR fileName, int deleteTiming)
|
|
|
{
|
|
|
if(strlen(fileName) == 0 || strchr(fileName, (int)'*') != NULL)
|
|
|
{
|
|
@@ -1769,8 +1785,22 @@ ErrorCodeEnum CIDCertFSM::DeleteFileIfExisted(LPCTSTR fileName)
|
|
|
strAimPath = strAimPath + SPLIT_SLASH_STR + fileName;
|
|
|
UpdateAndWarnFileFindInDepBak(strAimPath, fileName, IDCertificate_UserErrorCode_FindFile_in_DepBak);
|
|
|
|
|
|
+ map<string, string> errInfo;
|
|
|
+ CSimpleStringA errMsg;
|
|
|
if (ExistsFileA((LPCTSTR)strAimPath))
|
|
|
{
|
|
|
+ if (deleteTiming == 1) //检测到上次读证残留图片
|
|
|
+ {
|
|
|
+ errInfo["path"] = strAimPath.GetData();
|
|
|
+ errInfo["hash"] = GetFileHashStr(strAimPath).GetData();
|
|
|
+ errInfo["modifytime"] = GetFileLastModifyTime(strAimPath).GetData();
|
|
|
+
|
|
|
+ errMsg = generateJsonStr(errInfo).second.c_str();
|
|
|
+
|
|
|
+ //CSimpleStringA errMsg = CSimpleStringA::Format("检测到上次读证残留图片:[%s]", strAimPath.GetData());
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA2112").setAPI("DeleteFileIfExisted")(errMsg.GetData());
|
|
|
+ }
|
|
|
+
|
|
|
if (RemoveFileA((LPCTSTR)strAimPath))
|
|
|
{
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("RemoveFileA(%s) suc.", (LPCTSTR)strAimPath);
|
|
@@ -1778,12 +1808,34 @@ ErrorCodeEnum CIDCertFSM::DeleteFileIfExisted(LPCTSTR fileName)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("DeleteFile(%s) failed LastError(%d).", (LPCTSTR)strAimPath, GetLastError());
|
|
|
+ CSimpleStringA rtaCode = "";
|
|
|
+ if (deleteTiming == 1) //删除上次读证残留图片失败
|
|
|
+ {
|
|
|
+ rtaCode = "RTA2113";
|
|
|
+ }
|
|
|
+ else if (deleteTiming == 2) //删除本次读证生成图片失败
|
|
|
+ {
|
|
|
+ rtaCode = "RTA2115";
|
|
|
+ }
|
|
|
+
|
|
|
+ errInfo.clear();
|
|
|
+ errInfo["path"] = strAimPath.GetData();
|
|
|
+ errInfo["lasterror"] = to_string(GetLastError());
|
|
|
+ errMsg = generateJsonStr(errInfo).second.c_str();
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode(rtaCode.GetData()).setAPI("DeleteFileIfExisted")
|
|
|
+ (errMsg.GetData());
|
|
|
return Error_Unexpect;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ if (deleteTiming == 2) //未发现本次读证生成的图片
|
|
|
+ {
|
|
|
+ errInfo.clear();
|
|
|
+ errInfo["path"] = strAimPath.GetData();
|
|
|
+ errMsg = generateJsonStr(errInfo).second.c_str();
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA2114").setAPI("DeleteFileIfExisted")(errMsg.GetData());
|
|
|
+ }
|
|
|
return Error_Succeed;
|
|
|
}
|
|
|
}
|
|
@@ -1836,24 +1888,19 @@ int CIDCertFSM::WaitFetchIDCard()
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
-void CIDCertFSM::DeleteZP(int type)
|
|
|
+void CIDCertFSM::DeleteZP(int type, int deleteTiming)
|
|
|
{
|
|
|
if ((type&Bmp_ZP) == Bmp_ZP)
|
|
|
{
|
|
|
- DeleteFileIfExisted("zp.JPEG");
|
|
|
- DeleteFileIfExisted("zp.jpg");
|
|
|
- DeleteFileIfExisted("zp.bmp"); //All
|
|
|
- DeleteFileIfExisted("wz.txt"); //Sankyo
|
|
|
- DeleteFileIfExisted("xp.wlt");
|
|
|
- DeleteFileIfExisted("ImgTemp.bmp"); //Nantian
|
|
|
- DeleteFileIfExisted("BP8913_ID.bmp"); //Nantian
|
|
|
+ DeleteFileIfExisted("zp.jpg", deleteTiming);
|
|
|
+ DeleteFileIfExisted("zp.bmp", deleteTiming); //All
|
|
|
}
|
|
|
if ((type&Bmp_SCAN) == Bmp_SCAN)
|
|
|
{
|
|
|
- DeleteFileIfExisted("idfront.bmp");
|
|
|
- DeleteFileIfExisted("idback.bmp");
|
|
|
- DeleteFileIfExisted("idfront.jpg");
|
|
|
- DeleteFileIfExisted("idback.jpg");
|
|
|
+ DeleteFileIfExisted("idfront.bmp", deleteTiming);
|
|
|
+ DeleteFileIfExisted("idback.bmp", deleteTiming);
|
|
|
+ DeleteFileIfExisted("idfront.jpg", deleteTiming);
|
|
|
+ DeleteFileIfExisted("idback.jpg", deleteTiming);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2307,6 +2354,71 @@ void CIDCertFSM::CheckEjectCardRes(ErrorCodeEnum errRf, ErrorCodeEnum errForceID
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+CSimpleStringA CIDCertFSM::GetFileHashStr(CSimpleStringA filePath)
|
|
|
+{
|
|
|
+ //calculate file hash value
|
|
|
+ CSimpleStringA strHash;
|
|
|
+ char* strFileHash = new char[128];
|
|
|
+ if (ExistsFileA(filePath.GetData()))
|
|
|
+ {
|
|
|
+ BYTE fileHash[32];
|
|
|
+ SM3File(const_cast<char*>(filePath.GetData()), fileHash);
|
|
|
+ ZeroMemory(strFileHash, 128);
|
|
|
+ SP::Module::Util::HexBuf2StrBuf(fileHash, &strFileHash, 32);
|
|
|
+ strHash = strFileHash;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ memset(strFileHash, '\0', sizeof(char) * 128);
|
|
|
+ }
|
|
|
+ if (strFileHash != nullptr)
|
|
|
+ {
|
|
|
+ delete[] strFileHash;
|
|
|
+ strFileHash = nullptr;
|
|
|
+ }
|
|
|
+
|
|
|
+ return strHash;
|
|
|
+}
|
|
|
+
|
|
|
+CSimpleStringA CIDCertFSM::GetFileLastModifyTime(CSimpleStringA filePath)
|
|
|
+{
|
|
|
+#if defined(_WIN32)
|
|
|
+ WIN32_FILE_ATTRIBUTE_DATA fileInfo;
|
|
|
+ if (!GetFileAttributesExA(filePath.GetData(), GetFileExInfoStandard, &fileInfo)) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ FILETIME localFileTime;
|
|
|
+ FileTimeToLocalFileTime(&fileInfo.ftLastWriteTime, &localFileTime);
|
|
|
+
|
|
|
+ SYSTEMTIME sysTime;
|
|
|
+ FileTimeToSystemTime(&localFileTime, &sysTime);
|
|
|
+
|
|
|
+ std::ostringstream oss;
|
|
|
+ oss << std::setfill('0')
|
|
|
+ << sysTime.wYear << "-"
|
|
|
+ << std::setw(2) << sysTime.wMonth << "-"
|
|
|
+ << std::setw(2) << sysTime.wDay << " "
|
|
|
+ << std::setw(2) << sysTime.wHour << ":"
|
|
|
+ << std::setw(2) << sysTime.wMinute << ":"
|
|
|
+ << std::setw(2) << sysTime.wSecond;
|
|
|
+ return oss.str().c_str();
|
|
|
+
|
|
|
+#else
|
|
|
+ struct stat fileStat;
|
|
|
+ if (stat(filePath.GetData(), &fileStat) != 0) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ time_t modTime = fileStat.st_mtime;
|
|
|
+ struct tm* timeInfo = localtime(&modTime);
|
|
|
+
|
|
|
+ char buffer[20];
|
|
|
+ strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", timeInfo);
|
|
|
+ return buffer;
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
#ifdef RVC_OS_WIN
|
|
|
void CIDCertFSM::HttpsLogCallBack(const char* logtxt)
|
|
|
{
|