本文件定義了將大型實體檔案 CB_IMGPSScanImp.pas.bk 進行解耦與重構的標準流程。
核心策略在於「步驟間解耦(Step Decoupling)」,透過引入中介產出物,確保流程中斷時可從失敗步驟直接重試,無需重複耗時的掃描作業。
TCB_IMGPSScanX 類別的方法實體邊界,建立物理行號索引。^(procedure|function)\s+TCB_IMGPSScanX\.。lIndex:該方法宣告所在的起始行號(從 1 開始計算)。matcher:該行的完整原始碼字串。rIndex:將「下一個方法」的 lIndex - 1 作為當前方法的結束行;若為最後一個方法,則 rIndex 為檔案總行數。{{base_path}}/step1_raw_methods.json{{script_path}}/scanimpl_annalysis_extract_methods.js[{"matcher": "...", "lIndex": 120, "rIndex": 150}]{{base_path}}/step1_raw_methods.json。matcher 內容進行關鍵字匹配(分類規則詳見第 4 節)。UIView)與次標籤(如 UIView.treeView)。deps: [] 與 description: "" 欄位。{{base_path}}/step2_classified_methods.json{{base_path}}/scanimpl_annalysis_classify.js{{base_path}}/step2_classified_methods.json。{{base_path}}/scanimpl_annalysis.ScannerController.json{{base_path}}/scanimpl_annalysis.BusinessLogic.json{{base_path}}/scanimpl_annalysis.ImageProcessor.json{{base_path}}/scanimpl_annalysis.TransportManager.json{{base_path}}/scanimpl_annalysis.UIView.json{{script_path}}/scanimpl_annalysis_disaggregate.js{{script_path}}/scanimpl_annalysis_json.test.js):
matcher 必須精確等於原檔在 lIndex 行的內容。lIndex 與 rIndex 均 > 0,嚴禁出現 -1。remainings.txt。{{script_path}}/dist/scanimpl_annalysis.remainings.txt (死角清單)請根據以下關鍵字進行簡單的字串比對分類 (如果不在此列表內,則預設分類到 "UIView" / "UIView.misc"), tags 應允許多組:
* ScannerControl (硬體掃描控制模組)
* StatrTwainScan, OnAcquire, initkscan, CheckScannerConfig, PageEnd, PageDone, R_W_Scanini, GetDefScanIni -> ScannerControl.twainWrapper
DeskewImg, Rotate, CropImg, ImageReSize_FormID, ImageReSize_tmp, CheckNeedCrop -> ImageProcessor.transformerConvertToBW, ConvertToGray, Image_Smooth, NegativeImg, CleanupBorder -> ImageProcessor.converterMpsGetBarcode, Get_OMR -> ImageProcessor.barcodeRecognizerFindPoint, CheckSize, GetSiteOMR -> ImageProcessor.anchorAnalyzerTransportManager (安全傳輸與 API 通訊模組)
ProcessServlet, ProcessServlet_Get, ProcessServlet_FormData -> TransportManager.requestWrapperupFile, dnFile, dnFile_Get, GetftpInfo, SetFtpInfo, FtpCaseComplete -> TransportManager.fileTransferEn_DecryptionStr_Base64, LoadFileGetMD5, HTTPSClientCertificateValidate -> TransportManager.utilitiesZipMainFile, ZipMaskFile, ExecuteUnZip -> TransportManager.payloadArchiverBusinessLogic (業務邏輯與資料解析模組)
SetSQLData, GetSQLData, FindSQLData, GetSetInf1, GetSetInf2, GetSetInf3, GetSetInf4, GetSetInf5, GetSetInf6, GetSetInf7 -> BusinessLogic.paramStateBarCode2FormID, BarCode2CaseID, FormCode2DocNo, DocNo2DocName, DocNoNeedDiv, CreateDocNo_Info, CreateCustDocNo_Info -> BusinessLogic.entityMappingOMRCheckCase, OMRErr2ini, OMRErrini2List -> BusinessLogic.ormRuleEngineSetUseCase, GetUseCase, OldCasetoNewCase, ErrFormtoCurrentForm, DeleteDocNoFileForESCAN -> BusinessLogic.caseManagerUIView (UI 視圖與介面呈現模組)
TreeView 的方法 (如 TreeView1Click, DrawDocItem2 等) -> UIView.treeViewISB, ImageScrollBox, ScrollBox 的方法 (如 ISB1Click, CreatePreViewISB 等) -> UIView.scrollViewInitialLanguage, DownLanguage -> UIView.i18nDisplayMode, GoViewMode -> UIView.layoutsDataLoading, Timer2Timer, StatusBar1DblClick -> UIView.statusMessengerexample:pascal // CB_IMGPSScanImp.pas, 假定該分類為 ImageProcessor.anchorAnalyzer function TCB_IMGPSScanX.GetSiteOMR(FileName,Site:String;bt: Integer): Integer;
{
"matcher": "function TCB_IMGPSScanX.GetSiteOMR(FileName,Site:String;bt: Integer): Integer;",
"tags": [
"ImageProcessor",
"ImageProcessor.anchorAnalyzer"
],
"deps": [],
"lIndex": "5173",
"rIndex": "5226",
"description": ""
}