{ ============================================================================== 方法名稱:Path2DocDir 引用相依:FileExists, LoadFromFile 方法描述:將實體路徑轉換為案件內的文件目錄名稱。透過比對路徑字串與 CaseDocNo.da t 中的清單來識別對應的目錄。 ============================================================================== } Function TCB_IMGPSScanX.Path2DocDir(Path,CaseID:String):String; var i : Integer; DocnoList : TStringlist; begin Result := ''; DocNoList := TStringlist.Create; try if FileExists(ImageSavePath+CaseID+'\CaseDocNo.dat') then DocNoList.LoadFromFile(ImageSavePath+CaseID+'\CaseDocNo.dat'); if Path[length(Path)]<>'\' then path := path+'\'; for i := 0 to DocNoList.Count - 1 do begin if (path=ImageSavePath+CaseID+'\'+DocNoList.Strings[i]+'\') then begin Result := DocNoList.Strings[i]; Break; end; end; finally DocNoList.Free; end; end; { ============================================================================== 方法名稱:FormCode2FormName 引用相依: 方法描述:將表單代碼轉換為易讀的文件名稱。優先查詢系統定義表,若無則至自定義文件 清單中搜尋。 ============================================================================== } Function TCB_IMGPSScanX.FormCode2FormName(CaseID,FormCode:String):String; //用FormCode轉成文件名稱 var i,v,ln : Integer; DelBarCode : String; CusDocNo,CusDocName : String; begin Result := ''; if (FormCode = '') or (FormCode = 'Attach') or (FormCode = 'S_Attach') then Result := _Msg('未歸類') //showmessage('a'); //stringtofile(FORM_INF_List.Text,'D:\121.txt'); Else If FindSQLData(FORM_INF_List,'T1.FORM_ID,T1.FORM_DESC','T1.FORM_ID',FormCode,0,FindResult) then Result := GetFindResult('T1.FORM_DESC'); ////// 到自訂文件找////// if Result = '' then Result := GetCustomDocName(ImageSavePath+CaseID+'\',FormCode2DocNo(FormCode)); {for i := 0 to Cust_DocNoList.Count - 1 do begin v := Pos('_',Cust_DocNoList.Strings[i]); ln := Length(Cust_DocNoList.Strings[i]); CusDocNo := copy(Cust_DocNoList.Strings[i],1,v-1); CusDocName := Copy(Cust_DocNoList.Strings[i],v+1,ln-v); if CusDocNo = FormCode2DocNo(FormCode) then Result := DocNo2DocName(CusDocNo); end;} {DelBarCode := '**'+FormCode; for I := 0 to FormCodeList.Count - 1 do begin if FindDel then //要找下架的 begin if (FormCode = FormCodeList.Strings[i]) or (DelBarCode = FormCodeList.Strings[i]) then begin Result := FormNameList.Strings[i]; Break; end; end Else begin if (FormCode = FormCodeList.Strings[i]) or (DelBarCode = FormCodeList.Strings[i]) then begin Result := FormNameList.Strings[i]; Break; end; end; end; } end; { ============================================================================== 方法名稱:FormCode2FileName 引用相依: 方法描述:在指定的檔案清單中,根據表單代碼尋找其對應的第一個影像檔名。 ============================================================================== } Function TCB_IMGPSScanX.FormCode2FileName(FormCode:String;List:TStrings):String; //用FormCode找出檔名(第一頁) var i : Integer; v,v1 : Integer; begin Result := ''; for i := 0 to List.Count - 1 do begin V := pos('_',List.Strings[i]); v1 := pos('.',List.Strings[i]); if (FormCode = '') and (V = 0)then //FormCode 為空的則找附件出來 begin Result := List.Strings[i]; Break; end; IF FormCode = Copy(List.Strings[i],v+1,v1-v-1) then begin Result := List.Strings[i]; Break; end; end; end; { ============================================================================== 方法名稱:FileName2FormCode 引用相依: 方法描述:從影像檔名中提取表單代碼(底線與點號之間的部分)。若檔名格式不符則視為 附件並回傳空字串。 ============================================================================== } Function TCB_IMGPSScanX.FileName2FormCode(FileName:String):String; //從檔名取出FormCode var v,v1 : Integer; begin FileName := ExtractFileName(FileName); v := Pos('_',FileName); v1 := Pos('.',FileName); if v > 0 then begin Result := Copy(FileName,v+1,v1-v-1); end Else //附件 begin Result := ''; end; end; { ============================================================================== 方法名稱:FileName2FormName 引用相依: 方法描述:根據案件編號與檔案名稱,先取得表單代碼,再轉換為對應的表單名稱。 ============================================================================== } Function TCB_IMGPSScanX.FileName2FormName(CaseID,FileName:String):String; //從檔名取出文件名稱 begin Result := FormCode2FormName(CaseID,FileName2FormCode(FileName)); end; { ============================================================================== 方法名稱:FileName2ScanPage 引用相依: 方法描述:從檔案名稱中提取掃描頁碼。透過尋找底線或點號的位置,截取檔名前段並轉換 為整數。 ============================================================================== } Function TCB_IMGPSScanX.FileName2ScanPage(FileName:String):Integer; //從檔名轉出掃瞄頁數 Var v : Integer; FName : String; begin FName := ExtractFileName(FileName); v := Pos('_',FName); if v = 0 then //附件 v := pos('.',FName); Result := Strtoint(Copy(FName,1,v-1)); end; { ============================================================================== 方法名稱:FileName2NoQuene_Filename 引用相依: 方法描述:從檔案名稱中移除序號部分,僅保留從底線或點號開始的剩餘檔名結構。 ============================================================================== } Function TCB_IMGPSScanX.FileName2NoQuene_Filename(FileName:String):String; //取出沒有序號的檔名 var v,v1 : Integer; FName : String; begin FName := ExtractFileName(FileName); v := Pos('_',FName); if v = 0 then //附件 v := pos('.',FName); v1 := length(FName); Result := Copy(FName,v,v1-v+1); end; { ============================================================================== 方法名稱:FileName2Index 引用相依: 方法描述:在 ContextList 清單中搜尋指定的檔案名稱,並回傳其所在的索引位置。 ============================================================================== } Function TCB_IMGPSScanX.FileName2Index(FileName:String):Integer; //從檔名取出在ContextList的序號 var i : Integer; begin for i := 0 to ContextList.Count - 1 do begin if FileName = ContextList.Strings[i] then begin Result := i; Break; end; end; end; { ============================================================================== 方法名稱:FileName2NowDcoNo 引用相依: 方法描述:從檔案名稱對應的 CTList 中尋找索引,並從 DNList 取得其歸屬的文件代號。 ============================================================================== } Function TCB_IMGPSScanX.FileName2NowDcoNo(FileName:String;CtList,DNList:TStrings):String; //從檔名取出歸屬的文件代號 var i : Integer; begin for I := 0 to CTList.Count -1 do begin if FileName = CTList.Strings[i] then begin Result := DNList.Strings[i]; break; end; end; end; { ============================================================================== 方法名稱:FormCode2DocNo 引用相依: 方法描述:將表單代碼 (FormCode) 轉換為對應的文件編號 (DocNo)。方法遍歷預載的 Fo rmID_List,若找到匹配的表單代碼,則返回 DocNo_List 中相同索引位置的數 值。若表單代碼不在清單中(通常為使用者自訂的文件),則預設截取代碼的前 8 位字元作為文件編號返回。 ============================================================================== } Function TCB_IMGPSScanX.FormCode2DocNo(FormCode:String):String; //FormCode轉Docno Var i : Integer; begin Result := ''; for i := 0 to FormID_List.Count-1 do begin if FormID_List.Strings[i] = FormCode then begin Result := DocNo_List.Strings[i]; Break; end; end; if (FormCode <> '') and (Result = '') then //是自訂文件 begin Result := Copy(FormCode,1,8); //20170224 DocNo 固定長度8碼 end; {If FindSQLData(FORM_INF_List,'T1.DOC_NO','T1.FORM_ID',FormCode,0,FindResult) Then //20130403太慢了..換掉 begin Result := GetFindResult('T1.DOC_NO'); end;} end; { ============================================================================== 方法名稱:FormCode2Version 引用相依: 方法描述:從表單代碼(FormCode)的特定位置(第 11 位開始取 5 位)提取版本資訊。 ============================================================================== } Function TCB_IMGPSScanX.FormCode2Version(FormCode:String):String; //FormCode轉版本 begin Result := Copy(FormCode,11,5); end; { ============================================================================== 方法名稱:FormCode2Page 引用相依: 方法描述:從表單代碼(FormCode)的特定位置(第 9 位開始取 2 位)提取頁數資訊。 ============================================================================== } Function TCB_IMGPSScanX.FormCode2Page(FormCode:String):String; //FormCode轉頁數 begin Result := Copy(FormCode,9,2) end; { ============================================================================== 方法名稱:DocNo2DocName 引用相依: 方法描述:解析文件編號對應的描述性名稱。優先權邏輯為: 1. 若編號符合附件名稱 (AttName),返回「未歸類」。 2. 從系統定義快取 (Doc_Inf_List) 中搜尋對應的描述 (DOC_U_DESC)。 3. 若系統定義查無結果,則呼叫 GetCustomDocName 從案件本地的自訂文件設 定中尋找對應名稱。此方法確保 UI 上能顯示人類可讀的文件類別名稱。 ============================================================================== } Function TCB_IMGPSScanX.DocNo2DocName(CaseID,DocNo:String):String; //Docno轉Doc名稱 var i,v,ln : Integer; CusDocNo,CusDocName : String; begin Result := ''; if DocNo = AttName then begin Result := _Msg('未歸類'); end Else begin If FindSQLData(Doc_Inf_List,'DOC_U_DESC','DOC_NO',DocNo,0,FindResult) Then begin //ShowMessage(FindResult.Text); Result := GetFindResult('DOC_U_DESC'); end; end; if Result = '' then //去自訂文件裡找 begin Result := GetCustomDocName(ImageSavePath+CaseID+'\',DocNo); {for i := 0 to Cust_DocNoList.Count - 1 do begin v := Pos('_',Cust_DocNoList.Strings[i]); ln := length(Cust_DocNoList.Strings[i]); CusDocNo := Copy(Cust_DocNoList.Strings[i],1,v-1); CusDocName := Copy(Cust_DocNoList.Strings[i],v+1,ln-v); if DocNo = CusDocNo then begin Result := CusDocName; Break; end; end;} end; end; { ============================================================================== 方法名稱:DocNo2FileName 引用相依: 方法描述:根據文件代號,在指定的檔案清單中搜尋並回傳該文件第一頁的檔案名稱。 ============================================================================== } Function TCB_IMGPSScanX.DocNo2FileName(DocNo:String;List:TStrings):String; //用DocNo找出檔名(第一頁) var i : Integer; begin Result := ''; for i := 0 to List.Count - 1 do begin IF DocNo = FormCode2DocNo(FileName2FormCode(List.Strings[i])) then begin Result := List.Strings[i]; Break; end; end; end; { ============================================================================== 方法名稱:FormCode2WorkNo 引用相依: 方法描述:透過 FORM_INF_List 查詢表單代碼對應的作業別(WORK_NO)。 ============================================================================== } Function TCB_IMGPSScanX.FormCode2WorkNo(FormCode:String):String; //用FormCode取出作業別 begin Result := ''; If FindSQLData(FORM_INF_List,'T1.WORK_NO','T1.FORM_ID',FormCode,0,FindResult) Then begin Result := GetFindResult('T1.WORK_NO'); end; end; { ============================================================================== 方法名稱:DocNo2WorkNo 引用相依: 方法描述:透過 Doc_Inf_List 查詢文件代號對應的作業別(WORK_NO)。 ============================================================================== } Function TCB_IMGPSScanX.DocNo2WorkNo(DocNo:String):String; //用DocNo取出作業別 begin Result := ''; If FindSQLData(Doc_Inf_List,'WORK_NO','DOC_NO',DocNo,0,FindResult) Then begin Result := GetFindResult('WORK_NO'); end; end; { ============================================================================== 方法名稱:DocNoNeedDiv 引用相依: 方法描述:檢查指定的文件類型是否需要執行頁面拆分(分份數)。方法透過 FindSQLData 在 Doc_Inf_List 中查詢該編號的 'IS_DOC_DIV' 欄位,若旗標值為 'Y' 則返 回 True,否則返回 False。此設定決定了掃瞄流程中是否需要根據條碼自動切 分文件目錄。 ============================================================================== } Function TCB_IMGPSScanX.DocNoNeedDiv(DocNo:String):Boolean; //是否是需分份數的文件代號 var NeedDiv : String; begin Result := False; If FindSQLData(Doc_Inf_List,'IS_DOC_DIV','DOC_NO',DocNo,0,FindResult) Then begin NeedDiv := GetFindResult('IS_DOC_DIV'); if NeedDiv = 'Y' then Result := True; end; end; { ============================================================================== 方法名稱:CaseNode2Info 引用相依: 方法描述:從樹狀結構的案件節點文字中,根據指定的模式提取案件編號或案件頁數。 ============================================================================== } Function TCB_IMGPSScanX.CaseNode2Info(Node:TTreeNode;Mode:Char):String; //案件Node取案件編號 Mode: I:Caseno;P:Page var v,ln : Integer; begin //XXXXXX-XX頁 V := Pos('-',Node.Text); ln := Length(Node.Text); case Mode of 'I': Result := Copy(Node.Text,1,v-1); //CaseID 'P': Result := Copy(Node.Text,v+1,ln-v-1); //CasePage end; end; { ============================================================================== 方法名稱:DocNode2Info 引用相依: 方法描述:從樹狀結構的文件節點文字中提取詳細資訊。節點文字格式預期為「文件名稱@ 組數{文件代號}-XX頁」。此函式會根據傳入的模式(Mode),利用分隔符號(@, {, }, -)定位並截取回傳文件代號(I)、文件名稱(N)、文件頁碼(P)或文件組別(G) 。 ============================================================================== } Function TCB_IMGPSScanX.DocNode2Info(Node:TTreeNode;Mode:Char):String; //文件Node取文件代號 Mode: I:Docno;N:Docname;P:Page;G:Group var v,v1,v2,v3,ln :integer; begin //文件名稱@組數{文件代號}-XX頁 V := PosEnd('@',Node.Text); v1 := PosEnd('{',Node.Text); v2 := PosEnd('}',Node.Text); v3 := PosEnd('-',Node.Text); ln := Length(Node.Text); case Mode of 'I': Result := Copy(Node.Text,v1+1,v2-v1-1); //DocNo 'N': Result := Copy(Node.Text,1,v-1); //DocName 'P': Result := Copy(Node.Text,v3+1,ln-v3-1); //DocPage 'G': Result := Copy(Node.Text,v+1,v1-v-1); //DocGroup end; end; { ============================================================================== 方法名稱:FormNode2Info 引用相依: 方法描述:從樹狀結構的表單節點文字中提取資訊。節點文字格式預期為「表單代號{表單 名稱}-XX頁」。根據模式(Mode)參數,解析並回傳表單代號(I)、表單名稱(N)或頁 碼(P)。 ============================================================================== } Function TCB_IMGPSScanX.FormNode2Info(Node:TTreeNode;Mode:Char):String; //表單Node取表單代號 Mode: I:FormID;N:FormName;P:Page var v,v1,v2,ln :integer; begin //表單代號{表單名稱}-XX頁 v := Pos('{',Node.Text); v1 := PosEnd('}',Node.Text); v2 := PosEnd('-',Node.Text); ln := Length(Node.Text); case Mode of 'I': Result := Copy(Node.Text,1,v-1); //FormID 'N': Result := Copy(Node.Text,v1+1,v2-v1-1); //FormName 'P': Result := Copy(Node.Text,v2+1,ln-v2-1); //Page end; end;