From b4a18bfef6cb9f5d48a12b455dfa78f9ef67e348 Mon Sep 17 00:00:00 2001
From: kojingeun <diteam.co.kr>
Date: 수, 07 6월 2023 10:29:07 +0900
Subject: [PATCH] Revert "Ongoing50 #4517 CF AOI Review 결과 파일 찾기 실패 개선"

---
 ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp |  172 ++++++++++++++++-----------------------------------------
 1 files changed, 49 insertions(+), 123 deletions(-)

diff --git a/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp b/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp
index f772aac..4885de2 100644
--- a/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp
+++ b/ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp
@@ -40,11 +40,6 @@
 #include <fstream>
 #include <afxwin.h>
 
-#include <sstream> /* < KJG 20230605 - #4517 ADD >*/ 
-#include <filesystem> /* < KJG 20230605 - #4517 ADD >*/ 
-
-namespace fs = std::experimental::filesystem::v1; /* < KJG 20230605 - #4517 ADD >*/ 
-
 
 #define GLASS_GD_FILE_PATH			_T("GD")
 #define SIGNAL_SEND_RESULT_SUCCESS	_T("OK")
@@ -2900,18 +2895,6 @@
 
 BOOL CSequenceProcessor_CPJT::FindRawBinFile(CString strFileName)
 {
-	/* < KJG 20230605 - #4517 ADD Start >*/
-	auto FuncStringSplit = [](string Sentence, char Separator, vector<string>& vec)
-	{
-		stringstream ss(Sentence);
-		string tmp;
-
-		while (getline(ss, tmp, Separator)) {
-			vec.push_back(tmp);
-		}
-	};
-	/* < KJG 20230605 - #4517 ADD End >*/
-
 	//210128
 	CString strFilePath = _T("");
 	//pData->GetGlassData()->m_strFileName;
@@ -2933,117 +2916,60 @@
 			//#3359_LYW CF AOI Review REVIEW_LOADING_COMPLETE_TIMEOVER START
 			if (nReTryTime%2 == 0)
 			{
-				strFilePath = AOIRAWBIN_NETWORK_DRIVE_PATH;
+				strFilePath = AOIRAWBIN_PATH;
 			}
-			else strFilePath = AOIRAWBIN_PATH;
+			else strFilePath = AOIRAWBIN_NETWORK_DRIVE_PATH;
 
-			//strWild.Format("%s\\%s_*.bin", strFilePath, strFileName); /* < KJG 20230605 - #4517 DEL >*/
-			//akFileFinder.FindFile(strWild.GetBuffer(0), FALSE); /* < KJG 20230605 - #4517 DEL >*/
-
-			/* < KJG 20230605 - #4517 ADD Start >*/
-			auto timeStart = chrono::steady_clock::now();
-			g_pLog->DisplayMessage(_T("[GlassLoading][FindRawBinFile] Start Find Path = %s, File Name = %s, TryCount = %d"), strFilePath, strFileName, 30 - nReTryTime);
-
-			std::error_code err;
-			vector<std::string> vtFileList;
-			fs::path pathBinFile(strFilePath.GetBuffer(0));
-			int constexpr SaperatorCount = 4, DateSize = 8, TimeSize = 6; // GLASSID_STEPID_'YYYYMMDD'_'HHMMSS' �룷留� �솗�씤
-			for (auto iter = fs::directory_iterator(pathBinFile, err); iter != fs::directory_iterator(); iter++)
-			{
-				fs::path p = iter->path();
-				if (p.filename().stem().string().find(strFileName) != string::npos)
-				{
-					std::string strSearchFile = p.filename().stem().string();
-					if (p.extension().string() == _T(".bin"))
-					{
-						vtFileList.push_back(p.filename().stem().string());
-					}
-				}
-			}
-
-			for (auto iter = vtFileList.begin(); iter != vtFileList.end(); ) 
-			{
-				vector<string> vtSplit;
-				FuncStringSplit(*iter, _T('_'), vtSplit);
-
-				if (vtSplit.size() == SaperatorCount && vtSplit[2].size() == DateSize && vtSplit[3].size() == TimeSize)
-				{
-					iter++;
-				}
-				else
-				{
-					vtFileList.erase(iter);
-				}
-			}
-
-			sort(vtFileList.begin(), vtFileList.end(), greater<>()); // 理쒖떊�닚�쑝濡� �젙�젹
-
-			string strPickFileName = vtFileList.empty() ? _T("NULL") : vtFileList.front();
-			g_pLog->DisplayMessage(_T("[GlassLoading][FindRawBinFile] End File Count = %d, Pick File Name = %s, Tact = %d, ErrorCode = %d, ErrorMsg = %s"), vtFileList.size(), strPickFileName.c_str(), chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - timeStart).count(),err.value(), err.message().c_str());
-
-			if (vtFileList.empty() == FALSE)
-			{
-				vector<string> vtSplit;
-				FuncStringSplit(strPickFileName, _T('_'), vtSplit);
-				
-				CTime tmTemp(stoi(vtSplit[2].substr(0, 4)), stoi(vtSplit[2].substr(4, 2)), stoi(vtSplit[2].substr(6, 2)), stoi(vtSplit[3].substr(0, 2)), stoi(vtSplit[3].substr(2, 2)), stoi(vtSplit[3].substr(4, 2)));
-				CTimeSpan tmSpan = tmReviewLoading - tmTemp;
-				
-				if (tmSpan < nCloseTime)
-					break;
-			}
-			/* < KJG 20230605 - #4517 ADD End >*/
-
-			/* < KJG 20230605 - #4517 DEL Start >*/ 
+			strWild.Format("%s\\%s_*.bin", strFilePath, strFileName);
+			 akFileFinder.FindFile(strWild.GetBuffer(0), FALSE);
+			//LYW LOG
+			g_pLog->DisplayMessage(_T("[GlassLoading][FindRawBinFile] Find Path = %s, RetryCount = %d, ResultCode = [%d]"), strFilePath, 30-nReTryTime, GetLastError());
 			//#3359_LYW CF AOI Review REVIEW_LOADING_COMPLETE_TIMEOVER END
-			//VECFINDDATA* pFindData = akFileFinder.getFindData();
-			//int nFileNamePos = strlen(akFileFinder.getProcessPath());
-			//std::map<LONGLONG, CString> mapSpanFileName;
-			//for (int i = 0; i < pFindData->size(); i++)
-			//{
-			//	char* pFileName = &((*pFindData)[i]).name[nFileNamePos];
-			//	{
-			//		CakParser parser;
-			//		parser.process(pFileName, "_.");
-			//		if (parser.getTokNum() < 4) continue;
-			//		
-			//		if (parser.getTokNum() >= 6) continue; // 0401
-			//
-			//		int nDataTime[8] = {};
-			//		{
-			//			int nTokIndex = 0;
-			//			const char* pGlassId = parser.getTokStr(nTokIndex++);
-			//			const char* pStepId = parser.getTokStr(nTokIndex++);
-			//			char* pDate = &pFileName[parser.getTokPos(nTokIndex++)];
-			//			char* pTime = &pFileName[parser.getTokPos(nTokIndex++)];
-			//
-			//			nDataTime[0] = (pDate[0] - '0') * 1000 + (pDate[1] - '0') * 100 + (pDate[2] - '0') * 10 + (pDate[3] - '0') * 1;
-			//			nDataTime[1] = (pDate[4] - '0') * 10 + (pDate[5] - '0') * 1;
-			//			nDataTime[2] = (pDate[6] - '0') * 10 + (pDate[7] - '0') * 1;
-			//			nDataTime[3] = (pTime[0] - '0') * 10 + (pTime[1] - '0') * 1;
-			//			nDataTime[4] = (pTime[2] - '0') * 10 + (pTime[3] - '0') * 1;
-			//			nDataTime[5] = (pTime[4] - '0') * 10 + (pTime[5] - '0') * 1;
-			//		}
-			//
-			//		CTime tmTemp(nDataTime[0], nDataTime[1], nDataTime[2], nDataTime[3], nDataTime[4], nDataTime[5]);
-			//		CTimeSpan tmSpan = tmReviewLoading - tmTemp;
-			//		mapSpanFileName.insert(std::make_pair(tmSpan.GetTotalSeconds(), pFileName));
-			//	}
-			//}
-			//
-			//if (mapSpanFileName.empty() == FALSE)
-			//{
-			//	if (mapSpanFileName.begin()->first < nCloseTime)
-			//	{
-			//		strFindFile = mapSpanFileName.begin()->second;
-			//		break;
-			//	}
-			//}
-			//
-			//akFileFinder.clear();
-			/* < KJG 20230605 - #4517 DEL End >*/
+			VECFINDDATA* pFindData = akFileFinder.getFindData();
+			int nFileNamePos = strlen(akFileFinder.getProcessPath());
+			std::map<LONGLONG, CString> mapSpanFileName;
+			for (int i = 0; i < pFindData->size(); i++)
+			{
+				char* pFileName = &((*pFindData)[i]).name[nFileNamePos];
+				{
+					CakParser parser;
+					parser.process(pFileName, "_.");
+					if (parser.getTokNum() < 4) continue;
+					
+					if (parser.getTokNum() >= 6) continue; // 0401
 
+					int nDataTime[8] = {};
+					{
+						int nTokIndex = 0;
+						const char* pGlassId = parser.getTokStr(nTokIndex++);
+						const char* pStepId = parser.getTokStr(nTokIndex++);
+						char* pDate = &pFileName[parser.getTokPos(nTokIndex++)];
+						char* pTime = &pFileName[parser.getTokPos(nTokIndex++)];
 
+						nDataTime[0] = (pDate[0] - '0') * 1000 + (pDate[1] - '0') * 100 + (pDate[2] - '0') * 10 + (pDate[3] - '0') * 1;
+						nDataTime[1] = (pDate[4] - '0') * 10 + (pDate[5] - '0') * 1;
+						nDataTime[2] = (pDate[6] - '0') * 10 + (pDate[7] - '0') * 1;
+						nDataTime[3] = (pTime[0] - '0') * 10 + (pTime[1] - '0') * 1;
+						nDataTime[4] = (pTime[2] - '0') * 10 + (pTime[3] - '0') * 1;
+						nDataTime[5] = (pTime[4] - '0') * 10 + (pTime[5] - '0') * 1;
+					}
+
+					CTime tmTemp(nDataTime[0], nDataTime[1], nDataTime[2], nDataTime[3], nDataTime[4], nDataTime[5]);
+					CTimeSpan tmSpan = tmReviewLoading - tmTemp;
+					mapSpanFileName.insert(std::make_pair(tmSpan.GetTotalSeconds(), pFileName));
+				}
+			}
+
+			if (mapSpanFileName.empty() == FALSE)
+			{
+				if (mapSpanFileName.begin()->first < nCloseTime)
+				{
+					strFindFile = mapSpanFileName.begin()->second;
+					break;
+				}
+			}
+
+			akFileFinder.clear();
 			Sleep(100);
 		}
 	}

--
Gitblit v1.9.3