Jelajahi Sumber

Z991239-6293 #comment feat: 对图片的修改时间进行判断,若早于本次读证时间,则把告警设置为LEVEL2

陈纪林80310970 6 bulan lalu
induk
melakukan
dfffd1e762
2 mengubah file dengan 49 tambahan dan 40 penghapusan
  1. 45 39
      Module/mod_IDCertificate/IDCertFSM.cpp
  2. 4 1
      Module/mod_IDCertificate/IDCertFSM.h

+ 45 - 39
Module/mod_IDCertificate/IDCertFSM.cpp

@@ -499,9 +499,10 @@ int CIDCertFSM::ReadAndScanUTF8(SpReqAnsContext<IDCert_ReadAndScanUTF8_Req, IDCe
 	DeleteZP(Bmp_ZP | Bmp_SCAN, 1); //清理图片文件
 
 	//记录身份证相关图片的最近修改时间,用于上送信息调研,后续下掉 - 2025.6.13 CJL
-	headPhotoTime.Clear();
-	frontPhotoTime.Clear();
-	backPhotoTime.Clear();
+	headPhotoTimeStr.Clear(); headPhotoTime = 0;
+	frontPhotoTimeStr.Clear(); frontPhotoTime = 0;
+	backPhotoTimeStr.Clear(); backPhotoTime = 0;
+	currentSysTime = time(nullptr);
 
 	bool bExitWhenReading = false;
 	int curDeleteType = Bmp_ZP;
@@ -598,11 +599,7 @@ int CIDCertFSM::ReadAndScanUTF8(SpReqAnsContext<IDCert_ReadAndScanUTF8_Req, IDCe
 						}
 					}
 					DeleteZP(curDeleteType, 2);
-					//记录身份证相关图片的最近修改时间,用于上送信息调研,后续下掉 - 2025.6.13 CJL
-					CSimpleStringA fileTimeWarn = CSimpleStringA::Format("头像图片时间:[%s], 正面图片时间:[%s],背面图片时间:[%s]",
-						headPhotoTime.GetData(), frontPhotoTime.GetData(), backPhotoTime.GetData());
-					LogWarn(Severity_Low, Error_Succeed, IDCertificate_UserErrorCode_GetImgFileTime, fileTimeWarn);
-
+					WarnImgCreateTime(); //记录身份证相关图片的最近修改时间,用于上送信息调研,后续下掉 - 2025.6.13 CJL
 					break;
 				}
 			}
@@ -713,6 +710,12 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
 	LOG_FUNCTION();
 	DeleteZP(Bmp_ZP | Bmp_SCAN, 1); //清理图片文件
 
+	//记录身份证相关图片的最近修改时间,用于上送信息调研,后续下掉 - 2025.6.13 CJL
+	headPhotoTimeStr.Clear(); headPhotoTime = 0;
+	frontPhotoTimeStr.Clear(); frontPhotoTime = 0;
+	backPhotoTimeStr.Clear(); backPhotoTime = 0;
+	currentSysTime = time(nullptr);
+
 	bool bExitWhenReading = false;
 	int curDeleteType = Bmp_ZP;
 	DWORD elapsed = 0;
@@ -800,6 +803,7 @@ int CIDCertFSM::ReadAndScanUTF8JS(SpReqAnsContext<IDCert_ReadAndScanUTF8JS_Req,
 					}
 				}
 				DeleteZP(curDeleteType, 2);
+				WarnImgCreateTime(); //记录身份证相关图片的最近修改时间,用于上送信息调研,后续下掉 - 2025.6.13 CJL
 				break;
 			}
 		}
@@ -931,15 +935,15 @@ ErrorCodeEnum CIDCertFSM::GetPngBlobEx(CBlob &data, CSimpleStringA fileNamePrefi
 	//记录身份证相关图片的最近修改时间,用于上送信息调研,后续下掉 - 2025.6.13 CJL
 	if (fileNamePrefix ==  "zp")
 	{
-		headPhotoTime = GetFileLastModifyTime(strPath + ".bmp").GetData();
+		headPhotoTimeStr = GetFileLastModifyTime(strPath + ".bmp").GetData();
 	}
 	else if (fileNamePrefix == "idfront")
 	{
-		frontPhotoTime = GetFileLastModifyTime(strPath + ".bmp").GetData();
+		frontPhotoTimeStr = GetFileLastModifyTime(strPath + ".bmp").GetData();
 	}
 	else if (fileNamePrefix == "idback")
 	{
-		backPhotoTime = GetFileLastModifyTime(strPath + ".bmp").GetData();
+		backPhotoTimeStr = GetFileLastModifyTime(strPath + ".bmp").GetData();
 	}
 
 	IplImage *src = cvLoadImage(strPath + ".bmp");
@@ -1536,29 +1540,6 @@ CSimpleStringA CIDCertFSM::GetFileHashStr(CSimpleStringA filePath)
 
 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 "";
@@ -1567,10 +1548,22 @@ CSimpleStringA CIDCertFSM::GetFileLastModifyTime(CSimpleStringA filePath)
 	time_t modTime = fileStat.st_mtime;
 	struct tm* timeInfo = localtime(&modTime);
 
+	if (strstr(filePath.GetData(), "zp.bmp") != NULL) //头像图片时间
+	{
+		headPhotoTime = fileStat.st_mtime;
+	}
+	else if (strstr(filePath.GetData(), "idfront.bmp") != NULL) //正面图片时间
+	{
+		frontPhotoTime = fileStat.st_mtime;
+	}
+	else if (strstr(filePath.GetData(), "idback.bmp") != NULL) //背面图片时间
+	{
+		backPhotoTime = fileStat.st_mtime;
+	}
+
 	char buffer[20];
 	strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", timeInfo);
 	return buffer;
-#endif
 }
 
 template <typename T>
@@ -1665,7 +1658,7 @@ void CIDCertFSM::CopyIDCerDataToCtx(IDCerInfoEx2 idInfoEx2, T& ctx)
 		, (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 tIdcode = (char*)utf8Data->idno;
 	CSimpleStringA csIDLogInfo = CSimpleStringA::Format("IDNo:%s****%s"
 		, (const char*)tIdcode.SubString(0, 4), (const char*)tIdcode.SubString(tIdcode.GetLength() - 1, 1));
 #endif
@@ -1738,6 +1731,22 @@ BOOL CIDCertFSM::GetScanImg(IDCerInfoEx2 idInfoEx2, CBlob& frontImg, CBlob& back
 	return resFlag;
 }
 
+void CIDCertFSM::WarnImgCreateTime()
+{
+	//记录身份证相关图片的最近修改时间,用于上送信息调研,后续下掉 - 2025.6.13 CJL
+	CSimpleStringA fileTimeWarn = CSimpleStringA::Format("头像图片时间:[%s], 正面图片时间:[%s],背面图片时间:[%s]",
+		headPhotoTimeStr.GetData(), frontPhotoTimeStr.GetData(), backPhotoTimeStr.GetData());
+	SeverityLevelEnum ImgTimeWarnLevel = Severity_Low;
+	if ((headPhotoTime > 0 && headPhotoTime < currentSysTime) ||
+		(frontPhotoTime > 0 && frontPhotoTime < currentSysTime) ||
+		(backPhotoTime > 0 && backPhotoTime < currentSysTime))
+	{
+		ImgTimeWarnLevel = Severity_Middle;			//若生成图片的时间早于本次交易时间,则告LEVEL2
+	}
+	LogWarn(ImgTimeWarnLevel, Error_Succeed, IDCertificate_UserErrorCode_GetImgFileTime, fileTimeWarn);
+	return;
+}
+
 #ifdef RVC_OS_WIN
 char* CIDCertFSM::GetGBKString(UINT16* ucs2_code) //将UCS2字段转换为GBK,用于WIN打印日志或者其他中文使用
 {
@@ -1757,10 +1766,7 @@ char* CIDCertFSM::GetGBKString(UINT16* ucs2_code) //将UCS2字段转换为GBK,
 
 	return gbkData;
 }
-#endif // RVC_OS_WIN
-
 
-#ifdef RVC_OS_WIN
 void CIDCertFSM::HttpsLogCallBack(const char* logtxt)
 {
 	//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("%s", logtxt);

+ 4 - 1
Module/mod_IDCertificate/IDCertFSM.h

@@ -285,6 +285,8 @@ private:
 #ifdef RVC_OS_WIN
 	char* GetGBKString(UINT16* ucs2_code); //WIN打印源数据日志或其他中文用途
 #endif
+	//记录身份证相关图片的最近修改时间,用于上送信息调研,后续下掉 - 2025.6.13 CJL
+	void WarnImgCreateTime();
 
 public:
 		std::string checkImgURL;
@@ -312,7 +314,8 @@ private:
 	ULLINT IDCerGetDataEx2Time;
 	ULLINT ScanIDAndSaveImageTime;
 	//记录身份证相关图片的最近修改时间,用于上送信息调研,后续下掉 - 2025.6.13 CJL
-	CSimpleStringA headPhotoTime, frontPhotoTime, backPhotoTime;
+	CSimpleStringA headPhotoTimeStr, frontPhotoTimeStr, backPhotoTimeStr;
+	time_t headPhotoTime, frontPhotoTime, backPhotoTime, currentSysTime;
 };
 
 struct ReadAndScanUTF8Task : public ITaskSp  //ex8