SDC C-Project CF Review 프로그램
kojingeun
2023-06-07 b4a18bfef6cb9f5d48a12b455dfa78f9ef67e348
Revert "Ongoing50 #4517 CF AOI Review 결과 파일 찾기 실패 개선"

This reverts commit 4114d380bd594385fa6f10bb36a9eef4d19e8db1.
3개 파일 변경됨
172 ■■■■ 파일 변경됨
ReviewSystem/ReviewSystem/SequenceProcessor_CPJT.cpp 172 ●●●● 패치 | 보기 | raw | blame | 히스토리
ReviewSystem/bin/ReviewSystem.exe 패치 | 보기 | raw | blame | 히스토리
ReviewSystem/bin/ReviewSystem.pdb 패치 | 보기 | raw | blame | 히스토리
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);
        }
    }
ReviewSystem/bin/ReviewSystem.exe
Binary files differ
ReviewSystem/bin/ReviewSystem.pdb
Binary files differ