12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316 |
- unit MCacheTree;
- // CacheTree For Measure, Inherit From CacheTree
- interface
- uses
- Classes, CacheTree, Math, ZhAPI, sdIDTree;
- type
- // For Import Temp Excel
- TBillsCacheNode = class(TCacheNode)
- private
- FLevelCode: string;
- FCode: string;
- FB_Code: string;
- FName: string;
- FUnits: string;
- FCanDelete: Boolean;
- FOrgQuantity: Double;
- FMisQuantity: Double;
- FOthQuantity: Double;
- FDgnQuantity1: Double;
- FDgnQuantity2: Double;
- FMemoStr: string;
- FPrice: Double;
- FDrawingCode: string;
- public
- property LevelCode: string read FLevelCode write FLevelCode;
- property Code: string read FCode write FCode;
- property B_Code: string read FB_Code write FB_Code;
- property Name: string read FName write FName;
- property Units: string read FUnits write FUnits;
- property CanDelete: Boolean read FCanDelete write FCanDelete;
- property Price: Double read FPrice write FPrice;
- property OrgQuantity: Double read FOrgQuantity write FOrgQuantity;
- property MisQuantity: Double read FMisQuantity write FMisQuantity;
- property OthQuantity: Double read FOthQuantity write FOthQuantity;
- property DgnQuantity1: Double read FDgnQuantity1 write FDgnQuantity1;
- property DgnQuantity2: Double read FDgnQuantity2 write FDgnQuantity2;
- property DrawingCode: string read FDrawingCode write FDrawingCode;
- property MemoStr: string read FMemoStr write FMemoStr;
- end;
- TBillsCacheTree = class(TCacheTree)
- private
- FLastNode: TCacheNode;
- FLastBlankNode: TCacheNode;
- FSeparateChar: Char;
- FAutoSort: Boolean;
- FFixedIDNodes: TList;
- function GetNewNode(AID: Integer = -1): TBillsCacheNode; overload;
- function FindNode(const ACode: string): TBillsCacheNode; overload;
- function FindNode(AParent: TBillsCacheNode; const ACode: string): TBillsCacheNode; overload;
- function FindFxNode(const ACode, AName: string): TBillsCacheNode; overload;
- function FindFxNode(AParent: TBillsCacheNode; const ACode, AName: string): TBillsCacheNode; overload;
- function FindParent(const ACode: string): TBillsCacheNode;
- function FindNextSibling(const ACode: string): TBillsCacheNode;
- procedure SetSeparateChar(const Value: Char);
- public
- constructor Create; override;
- destructor Destroy; override;
- function AddNode(AParent: TCacheNode; ANextSibling: TCacheNode = nil; AFixedID: Integer = -1): TBillsCacheNode;
- function AddNodeByCode(const ACode: string; AFixedID: Integer = -1): TBillsCacheNode;
- function AddNodeByCodeName(const ACode, AName: string): TBillsCacheNode;
- function AddLeafBillsNode(const AB_Code: string): TBillsCacheNode;
- function FindXmjChild(AParent: TBillsCacheNode; const ACode, AName: string): TBillsCacheNode;
- function FindGclChild(AParent: TBillsCacheNode; const AB_Code, AName, AUnits: string; APrice: Double): TBillsCacheNode;
- function FindFixedIDNode(AID: Integer): TBillsCacheNode;
- // Only for Debugging lot of Data
- procedure SaveTreeToFile(const AFileName: string);
- property SeparateChar: Char read FSeparateChar write SetSeparateChar;
- property AutoSort: Boolean read FAutoSort write FAutoSort;
- property FixedIDNodes: TList read FFixedIDNodes;
- end;
- // 此树仅用于导入工程量清单,禁止作为它用
- // 如须使用应遵守以下两点:1.完全清楚相关的导入方法类及需求 2.派生子类。
- TGclCacheNode = class(TCacheNode)
- private
- FB_Code: string;
- FName: string;
- FUnits: string;
- FPrice: Double;
- FQuantity: Double;
- public
- property B_Code: string read FB_Code write FB_Code;
- property Name: string read FName write FName;
- property Units: string read FUnits write FUnits;
- property Price: Double read FPrice write FPrice;
- property Quantity: Double read FQuantity write FQuantity;
- end;
- TGclCacheTree = class(TCacheTree)
- private
- FLastBlank1: TGclCacheNode;
- FLastNode: TGclCacheNode;
- function AddNodeByName(const AName: string): TGclCacheNode;
- function AddNodeByB_Code(const AB_Code: string): TGclCacheNode;
- protected
- function GetNewNode: TCacheNode; override;
- public
- function AddNodeByData(const AB_Code, AName: string): TGclCacheNode;
- procedure SaveTreeToFile(const AFileName: string);
- end;
- {For Report Memory(Gather or Compare Projects)}
- TDoubleArray = array of Double;
- TReportCacheNode = class(TCacheNode)
- private
- FCode: string;
- FB_Code: string;
- FName: string;
- FUnits: string;
- FMemoStr: string;
- FXiangCode: string;
- FMuCode: string;
- FJieCode: string;
- FXiMuCode: string;
- FPrice: Double;
- FQuantity: Double;
- FTotalPrice: Double;
- FRatioPercent: Double; // 0号台账 - 各项费用所占比例
- FDesignQuantity1: Double;
- FDesignQuantity2: Double;
- FAddQcQuantity: Double;
- FAddPcTotalPrice: Double;
- FAddQcTotalPrice: Double;
- FAddDealQuantity: Double;
- FAddDealTotalPrice: Double;
- FAddPcQuantity: Double;
- FAddRatioPercent: Double; // 决算 - 各项费用所占比例
- FDealDesignQuantity1: Double;
- FDealDesignQuantity2: Double;
- FCDesignQuantity1: Double;
- FCDesignQuantity2: Double;
- FPASQuantity: Double;
- FPASTotalPrice: Double;
- FPASDesignQuantity1: Double;
- FPASDesignQuantity2: Double;
- FPASDesignPrice: Double;
- FPDQuantity: Double;
- FPDTotalPrice: Double;
- FPDDesignQuantity1: Double;
- FPDDesignQuantity2: Double;
- FPDDesignPrice: Double;
- FCDDQuantity: Double;
- FCDDTotalPrice: Double;
- FCDDDesignQuantity1: Double;
- FCDDDesignQuantity2: Double;
- FCDDDesignPrice: Double;
- FABTotalPrice: Double;
- FABQuantity: Double;
- FABDesignQuantity1: Double;
- FABDesignQuantity2: Double;
- FABDesignPrice: Double;
- FProjectCount: Integer;
- FP_TotalPrice: TDoubleArray;
- FP_Quantity: TDoubleArray;
- FP_Price: TDoubleArray;
- FP_DgnQuantity1: TDoubleArray;
- FP_DgnQuantity2: TDoubleArray;
- procedure ResolveCode;
- function GetDoubleArrayTotal(ADoubleArray: TDoubleArray): Double;
- procedure SetCode(const Value: string);
- function GetGatherP_TotalPrice: Double;
- function GetAddGatherQuantity: Double;
- function GetAddGatherTotalPrice: Double;
- function GetDesignPrice: Double;
- function GetDifferPercent1: Double;
- function GetFinalDesignPrice: Double;
- public
- constructor Create(ACacheTree: TCacheTree; AID, AProjectCount: Integer);
- property Code: string read FCode write SetCode;
- property B_Code: string read FB_Code write FB_Code;
- property Name: string read FName write FName;
- property Units: string read FUnits write FUnits;
- property MemoStr: string read FMemoStr write FMemoStr;
- property XiangCode: string read FXiangCode;
- property MuCode: string read FMuCode;
- property JieCode: string read FJieCode;
- property XiMuCode: string read FXiMuCode;
- // 用于汇总多个项目的合同、变更(数量、金额)
- property Price: Double read FPrice write FPrice;
- // 0号台账合同
- property Quantity: Double read FQuantity write FQuantity;
- property TotalPrice: Double read FTotalPrice write FTotalPrice;
- property RatioPercent: Double read FRatioPercent write FRatioPercent;
- property DesignQuantity1: Double read FDesignQuantity1 write FDesignQuantity1;
- property DesignQuantity2: Double read FDesignQuantity2 write FDesignQuantity2;
- property DesignPrice: Double read GetDesignPrice;
- // 累计各值
- property AddDealQuantity: Double read FAddDealQuantity write FAddDealQuantity;
- property AddDealTotalPrice: Double read FAddDealTotalPrice write FAddDealTotalPrice;
- property AddQcQuantity: Double read FAddQcQuantity write FAddQcQuantity;
- property AddQcTotalPrice: Double read FAddQcTotalPrice write FAddQcTotalPrice;
- property AddPcQuantity: Double read FAddPcQuantity write FAddPcQuantity;
- property AddPcTotalPrice: Double read FAddPcTotalPrice write FAddPcTotalPrice;
- property AddGatherQuantity: Double read GetAddGatherQuantity;
- property AddGatherTotalPrice: Double read GetAddGatherTotalPrice;
- property AddRatioPercent: Double read FAddRatioPercent write FAddRatioPercent;
- // 合同&变更 设计数量
- property DealDesignQuantity1: Double read FDealDesignQuantity1 write FDealDesignQuantity1;
- property DealDesignQuantity2: Double read FDealDesignQuantity2 write FDealDesignQuantity2;
- property CDesignQuantity1: Double read FCDesignQuantity1 write FCDesignQuantity1;
- property CDesignQuantity2: Double read FCDesignQuantity2 write FCDesignQuantity2;
- property FinalDesignPrice: Double read GetFinalDesignPrice;
- property DifferPercent1: Double read GetDifferPercent1;
- // 初步设计 Preliminary Design
- property PASQuantity: Double read FPASQuantity write FPASQuantity;
- property PASTotalPrice: Double read FPASTotalPrice write FPASTotalPrice;
- property PASDesignQuantity1: Double read FPASDesignQuantity1 write FPASDesignQuantity1;
- property PASDesignQuantity2: Double read FPASDesignQuantity2 write FPASDesignQuantity2;
- property PASDesignPrice: Double read FPASDesignPrice write FPASDesignPrice;
- // ----仅用于汇总生成决算02表----
- // 初步设计 Preliminary Design
- property PDQuantity: Double read FPDQuantity write FPDQuantity;
- property PDTotalPrice: Double read FPDTotalPrice write FPDTotalPrice;
- property PDDesignQuantity1: Double read FPDDesignQuantity1 write FPDDesignQuantity1;
- property PDDesignQuantity2: Double read FPDDesignQuantity2 write FPDDesignQuantity2;
- property PDDesignPrice: Double read FPDDesignPrice write FPDDesignPrice;
- // 施工图设计 Construction Drawing Design
- property CDDQuantity: Double read FCDDQuantity write FCDDQuantity;
- property CDDTotalPrice: Double read FCDDTotalPrice write FCDDTotalPrice;
- property CDDDesignQuantity1: Double read FCDDDesignQuantity1 write FCDDDesignQuantity1;
- property CDDDesignQuantity2: Double read FCDDDesignQuantity2 write FCDDDesignQuantity2;
- property CDDDesignPrice: Double read FCDDDesignPrice write FCDDDesignPrice;
- // ------------------------------
- // ----仅用于汇总生成决算02表(部颁)----
- // 批准概(预算)算 Approved Budget
- property ABQuantity: Double read FABQuantity write FABQuantity;
- property ABTotalPrice: Double read FABTotalPrice write FABTotalPrice;
- property ABDesignQuantity1: Double read FABDesignQuantity1 write FABDesignQuantity1;
- property ABDesignQuantity2: Double read FABDesignQuantity2 write FABDesignQuantity2;
- property ABDesignPrice: Double read FABDesignPrice write FABDesignPrice;
- // ------------------------------------
- // 用于记录多个项目的数量、单价、金额、设计数量
- property P_Price: TDoubleArray read FP_Price write FP_Price;
- property P_Quantity: TDoubleArray read FP_Quantity write FP_Quantity;
- property P_TotalPrice: TDoubleArray read FP_TotalPrice write FP_TotalPrice;
- property P_DgnQuantity1: TDoubleArray read FP_DgnQuantity1 write FP_DgnQuantity1;
- property P_DgnQuantity2: TDoubleArray read FP_DgnQuantity2 write FP_DgnQuantity2;
- property GatherP_TotalPrice: Double read GetGatherP_TotalPrice;
- property ProjectCount: Integer read FProjectCount;
- end;
- TStringArray = array of string;
- TReportCacheTree = class(TCacheTree)
- private
- FProjectCount: Integer;
- FGatherCacheNode: TReportCacheNode;
- FProjectName: TStringArray;
- function GetNewNode(AProjectCount: Integer): TReportCacheNode; overload;
- public
- constructor Create(AProjectCount: Integer);
- destructor Destroy; override;
- function AddNode(AParent: TCacheNode; ANextSibling: TCacheNode = nil): TReportCacheNode;
- function FindNextSibling(AParent: TCacheNode; ACode, AB_Code: string): TReportCacheNode;
- function FindNode(AParent: TCacheNode; ACode, AB_Code: string): TReportCacheNode; overload;
- function FindNode(AParent: TCacheNode; AName: string): TReportCacheNode; overload;
- function FindNode(AParent: TCacheNode; ACode, AB_Code, AName: string): TReportCacheNode; overload;
- procedure ReCalcGatherData;
- // 调用此方法先须先调用ReCalcGatherData
- // RatioPercent = 金额/总金额,这里的总金额取GatherCacheNode的金额,故须先汇总计算GatherCacheNode。
- procedure ReCalcRatioPercent;
- // Only for Debugging lot of Data
- procedure SaveTreeToFile(const AFileName: string);
- property ProjectCount: Integer read FProjectCount;
- property GatherCacheNode: TReportCacheNode read FGatherCacheNode;
- property ProjectName: TStringArray read FProjectName write FProjectName;
- end;
- TapDoubleArray = array [1..50] of Double;
- TAllPhaseCacheNode = class(TCacheNode)
- private
- FCode: string;
- FB_Code: string;
- FName: string;
- FUnits: string;
- FPrice: Double;
- FQuantity: Double;
- FTotalPrice: Double;
- FMemoStr: string;
- public
- FP_Quantity: TapDoubleArray;
- FP_TotalPrice: TapDoubleArray;
- property Code: string read FCode write FCode;
- property B_Code: string read FB_Code write FB_Code;
- property Name: string read FName write FName;
- property Units: string read FUnits write FUnits;
- property Price: Double read FPrice write FPrice;
- property Quantity: Double read FQuantity write FQuantity;
- property TotalPrice: Double read FTotalPrice write FTotalPrice;
- property MemoStr: string read FMemoStr write FMemoStr;
- end;
- // 仅用于汇总同一项目的不同期数据
- TAllPhaseCacheTree = class(TCacheTree)
- private
- function GetNewNode(AID: Integer): TAllPhaseCacheNode;
- public
- function AddNode(AID: Integer; AParent: TCacheNode; ANextSibling: TCacheNode = nil): TAllPhaseCacheNode;
- function FindNode(AID: Integer): TAllPhaseCacheNode;
- // Only for Debugging lot of Data
- procedure SaveTreeToFile(const AFileName: string);
- end;
- TSpecPhaseCacheNode = class(TCacheNode)
- private
- FCode: string;
- FB_Code: string;
- FName: string;
- FUnits: string;
- FDgnQty1: Double;
- FDgnQty2: Double;
- FTotalPrice: Double;
- FEndDealTotalPrice: Double;
- FEndQcTotalPrice: Double;
- FhtDgnQty1: Double;
- FhtDgnQty2: Double;
- FbgDgnQty1: Double;
- FbgDgnQty2: Double;
- FcbDgnQty1: Double;
- FcbDgnQty2: Double;
- FcbTotalPrice: Double;
- FsscDgnQty1: Double;
- FsscDgnQty2: Double;
- FsscTotalPrice: Double;
- FshtDgnQty1: Double;
- FshtDgnQty2: Double;
- FshtTotalPrice: Double;
- public
- property Code: string read FCode write FCode;
- property B_Code: string read FB_Code write FB_Code;
- property Name: string read FName write FName;
- property Units: string read FUnits write FUnits;
- property DgnQty1: Double read FDgnQty1 write FDgnQty1;
- property DgnQty2: Double read FDgnQty2 write FDgnQty2;
- property TotalPrice: Double read FTotalPrice write FTotalPrice;
- property EndDealTotalPrice: Double read FEndDealTotalPrice write FEndDealTotalPrice;
- property EndQcTotalPrice: Double read FEndQcTotalPrice write FEndQcTotalPrice;
- property htDgnQty1: Double read FhtDgnQty1 write FhtDgnQty1;
- property htDgnQty2: Double read FhtDgnQty2 write FhtDgnQty2;
- property bgDgnQty1: Double read FbgDgnQty1 write FbgDgnQty1;
- property bgDgnQty2: Double read FbgDgnQty2 write FbgDgnQty2;
- property cbDgnQty1: Double read FcbDgnQty1 write FcbDgnQty1;
- property cbDgnQty2: Double read FcbDgnQty2 write FcbDgnQty2;
- property cbTotalPrice: Double read FcbTotalPrice write FcbTotalPrice;
-
- property sscDgnQty1: Double read FsscDgnQty1 write FsscDgnQty1;
- property sscDgnQty2: Double read FsscDgnQty2 write FsscDgnQty2;
- property sscTotalPrice: Double read FsscTotalPrice write FsscTotalPrice;
- property shtDgnQty1: Double read FshtDgnQty1 write FshtDgnQty1;
- property shtDgnQty2: Double read FshtDgnQty2 write FshtDgnQty2;
- property shtTotalPrice: Double read FshtTotalPrice write FshtTotalPrice;
- end;
- TSpecPhaseCacheTree = class(TCacheTree)
- private
- function GetNewNode: TSpecPhaseCacheNode;
- public
- function AddNode(AParent: TCacheNode; ANextSibling: TCacheNode = nil): TSpecPhaseCacheNode;
- function FindNextSibling(AParent: TCacheNode; ACode, AB_Code: string): TSpecPhaseCacheNode;
- function FindNode(AParent: TCacheNode; ACode, AB_Code: string): TSpecPhaseCacheNode; overload;
- function FindNode(AParent: TCacheNode; AName: string): TSpecPhaseCacheNode; overload;
- function FindNode(AParent: TCacheNode; ACode, AB_Code, AName: string): TSpecPhaseCacheNode; overload;
- end;
- implementation
- uses
- SysUtils, UtilMethods;
- { TBillsCacheTree }
- function TBillsCacheTree.AddNodeByCode(const ACode: string;
- AFixedID: Integer): TBillsCacheNode;
- var
- Parent, NextSibling: TBillsCacheNode;
- begin
- Result := FindNode(ACode);
- if Assigned(Result) then
- begin
- FLastNode := Result;
- Exit;
- end;
- Parent := FindParent(ACode);
- if AutoSort then
- NextSibling := FindNextSibling(ACode)
- else
- NextSibling := nil;
- Result := AddNode(Parent, NextSibling, AFixedID);
- Result.FLevelCode := ACode;
- FLastNode := Result;
- end;
- function TBillsCacheTree.FindNode(const ACode: string): TBillsCacheNode;
- begin
- Result := FindNode(TBillsCacheNode(Root), ACode);
- end;
- function TBillsCacheTree.FindNextSibling(
- const ACode: string): TBillsCacheNode;
- var
- Parent, Node: TBillsCacheNode;
- sCodeID, sCodeID2: string;
- begin
- Parent := FindParent(ACode);
- if Assigned(Parent) then
- Node := TBillsCacheNode(Parent.FirstChild)
- else
- Node := TBillsCacheNode(Root.FirstChild);
- Result := nil;
- sCodeID := ConvertDigitCode(ACode, 3, '-');
- while Assigned(Node) do
- begin
- sCodeID2 := ConvertDigitCode(Node.LevelCode, 3, SeparateChar);
- if sCodeID < sCodeID2 then
- begin
- Result := Node;
- Break;
- end;
- Node := TBillsCacheNode(Node.NextSibling);
- end;
- end;
- function TBillsCacheTree.FindNode(AParent: TBillsCacheNode;
- const ACode: string): TBillsCacheNode;
- begin
- Result := TBillsCacheNode(AParent.FirstChild);
- while Assigned(Result) do
- begin
- if Result.LevelCode = ACode then
- Break
- else if Pos(Result.LevelCode + SeparateChar, ACode) = 1 then
- begin
- Result := FindNode(Result, ACode);
- Break;
- end
- else
- Result := TBillsCacheNode(Result.NextSibling);
- end;
- end;
- function TBillsCacheTree.FindParent(const ACode: string): TBillsCacheNode;
- var
- sCode: string;
- begin
- Result := nil;
- sCode := GetPrefixOfCode(ACode, SeparateChar);
- while (Result = nil) and (sCode <> '') do
- begin
- Result := FindNode(sCode);
- sCode := GetPrefixOfCode(sCode, SeparateChar);
- end;
- end;
- function TBillsCacheTree.GetNewNode(AID: Integer): TBillsCacheNode;
- begin
- if AID = -1 then
- Result := TBillsCacheNode.Create(Self, GetNewNodeID)
- else
- Result := TBillsCacheNode.Create(Self, AID);
- CacheNodes.Add(Result);
- if Result.ID < 100 then
- FFixedIDNodes.Add(Result);
- end;
- function TBillsCacheTree.AddNode(AParent, ANextSibling: TCacheNode;
- AFixedID: Integer): TBillsCacheNode;
- begin
- Result := GetNewNode(AFixedID);
- if Assigned(ANextSibling) then
- ANextSibling.InsertPreSibling(Result)
- else if Assigned(AParent) then
- AParent.InsertChild(Result)
- else
- Root.InsertChild(Result);
- end;
- function TBillsCacheTree.AddLeafBillsNode(const AB_Code: string): TBillsCacheNode;
- function GetLastXmjParent: TBillsCacheNode;
- begin
- Result := TBillsCacheNode(FLastNode);
- while Assigned(Result) and Assigned(Result.Parent) and (Result.B_Code <> '') do
- Result := TBillsCacheNode(Result.Parent);
- end;
- function FindParent(AParent: TBillsCacheNode;
- const ACode: string): TBillsCacheNode;
- var
- i: Integer;
- sCode: string;
- begin
- Result := AParent;
- sCode := GetPrefixOfCode(ACode, SeparateChar);
- while (sCode <> '') do
- begin
- for i:= 0 to AParent.Children.Count - 1 do
- begin
- if TBillsCacheNode(AParent.Children.Items[i]).B_Code = ACode then
- begin
- Result := TBillsCacheNode(AParent.Children.Items[i]);
- Break;
- end;
- end;
- sCode := GetPrefixOfCode(sCode, SeparateChar);
- end;
- end;
- function FindNextSibling(AParent: TBillsCacheNode;
- const ACode: string): TBillsCacheNode;
- var
- Node: TBillsCacheNode;
- sCodeID, sCodeID2: string;
- begin
- Node := TBillsCacheNode(AParent.FirstChild);
- Result := nil;
- sCodeID := ConvertDigitCode(ACode, 3, '-');
- while Assigned(Node) do
- begin
- sCodeID2 := ConvertDigitCode(Node.LevelCode, 3, SeparateChar);
- if sCodeID < sCodeID2 then
- begin
- Result := Node;
- Break;
- end;
- Node := TBillsCacheNode(Node.NextSibling);
- end;
- end;
- function AddNodeByParent(AParent: TBillsCacheNode;
- const ACode: string): TBillsCacheNode;
- var
- Parent, NextSibling: TBillsCacheNode;
- begin
- Parent := FindParent(AParent, ACode);
- if AutoSort then
- NextSibling := FindNextSibling(AParent, ACode)
- else
- NextSibling := nil;
- Result := AddNode(Parent, NextSibling);
- Result.FLevelCode := ACode;
- end;
- var
- Parent: TBillsCacheNode;
- begin
- Parent := GetLastXmjParent;
- Result := AddNodeByParent(Parent, AB_Code);
- end;
- procedure TBillsCacheTree.SetSeparateChar(const Value: Char);
- var
- I: Integer;
- Node: TBillsCacheNode;
- begin
- for I := 0 to CacheNodes.Count - 1 do
- begin
- Node := TBillsCacheNode(CacheNodes.Items[I]);
- Node.FLevelCode := StringReplace(Node.FLevelCode, FSeparateChar, Value, [rfReplaceAll]);
- end;
- FSeparateChar := Value;
- end;
- procedure TBillsCacheTree.SaveTreeToFile(const AFileName: string);
- var
- sgs: TStringList;
- I: Integer;
- Node: TBillsCacheNode;
- begin
- sgs := TStringList.Create;
- try
- for I := 0 to CacheNodes.Count - 1 do
- begin
- Node := TBillsCacheNode(CacheNodes.Items[I]);
- sgs.Add(Format('ID: %3d; ParentID: %3d; NextID: %3d; Code: %s; B_Code: %s; Name: %s;',
- [Node.ID, Node.ParentID, Node.NextSiblingID, Node.Code, Node.B_Code, Node.Name]));
- end;
- sgs.SaveToFile(AFileName);
- finally
- sgs.Free;
- end;
- end;
- function TBillsCacheTree.FindGclChild(AParent: TBillsCacheNode;
- const AB_Code, AName, AUnits: string; APrice: Double): TBillsCacheNode;
- var
- vChild: TBillsCacheNode;
- begin
- Result := nil;
- if Assigned(AParent) then
- vChild := TBillsCacheNode(AParent.FirstChild)
- else
- vChild := TBillsCacheNode(Root.FirstChild);
- while Assigned(vChild) and not Assigned(Result) do
- begin
- if SameText(AB_Code, vChild.B_Code) and
- SameText(AName, vChild.Name) and
- SameText(AUnits, vChild.Units) and
- (APrice = vChild.Price) then
- Result := vChild;
- vChild := TBillsCacheNode(vChild.NextSibling);
- end;
- end;
- function TBillsCacheTree.FindXmjChild(AParent: TBillsCacheNode;
- const ACode, AName: string): TBillsCacheNode;
- var
- vChild: TBillsCacheNode;
- begin
- Result := nil;
- if Assigned(AParent) then
- vChild := TBillsCacheNode(AParent.FirstChild)
- else
- vChild := TBillsCacheNode(Root.FirstChild);
- while Assigned(vChild) and not Assigned(Result) do
- begin
- if SameText(ACode, vChild.Code) and SameText(AName, vChild.Name) then
- Result := vChild;
- vChild := TBillsCacheNode(vChild.NextSibling);
- end;
- end;
- constructor TBillsCacheTree.Create;
- begin
- inherited;
- FFixedIDNodes := TList.Create;
- end;
- destructor TBillsCacheTree.Destroy;
- begin
- FFixedIDNodes.Free;
- inherited;
- end;
- function TBillsCacheTree.FindFixedIDNode(AID: Integer): TBillsCacheNode;
- var
- iNode: Integer;
- vNode: TCacheNode;
- begin
- Result := nil;
- for iNode := 0 to FFixedIDNodes.Count - 1 do
- begin
- vNode := TCacheNode(FFixedIDNodes.Items[iNode]);
- if vNode.ID = AID then
- begin
- Result := TBillsCacheNode(vNode);
- Break;
- end;
- end;
- end;
- function TBillsCacheTree.AddNodeByCodeName(const ACode, AName: string): TBillsCacheNode;
- var
- Parent, NextSibling: TBillsCacheNode;
- begin
- Result := FindFxNode(ACode, AName);
- if Assigned(Result) then
- begin
- FLastNode := Result;
- if (ACode = '') then FLastBlankNode := Result;
- Exit;
- end;
- NextSibling := nil;
- if Pos('-', ACode) > 0 then
- begin
- Parent := FindParent(ACode);
- if AutoSort then
- NextSibling := FindNextSibling(ACode);
- end
- else if (AName = '其他费用项目') or (AName = '建设期贷款利息') or (Pos('公路功能以外的工程费用', AName) > 0) then
- Parent := TBillsCacheNode(Root)
- else
- Parent := TBillsCacheNode(FLastBlankNode);
- Result := AddNode(Parent, NextSibling);
- Result.FLevelCode := ACode;
- FLastNode := Result;
- if (ACode = '') then FLastBlankNode := Result;
- end;
- function TBillsCacheTree.FindFxNode(const ACode,
- AName: string): TBillsCacheNode;
- var
- i: Integer;
- begin
- if (ACode = '') then
- begin
- for i := 0 to CacheNodes.Count - 1 do
- begin
- Result := TBillsCacheNode(CacheNodes.Items[i]);
- if (Result.Code = ACode) And (Result.Name = AName) then
- Exit;
- end;
- Result := nil;
- end
- else
- Result := FindFxNode(TBillsCacheNode(Root), ACode, AName);
- end;
- function TBillsCacheTree.FindFxNode(AParent: TBillsCacheNode; const ACode,
- AName: string): TBillsCacheNode;
- begin
- Result := TBillsCacheNode(AParent.FirstChild);
- while Assigned(Result) do
- begin
- if (Result.Code = ACode) And (Result.Name = AName) then
- Break
- else if Pos(Result.LevelCode + SeparateChar, ACode) = 1 then
- begin
- Result := FindNode(Result, ACode);
- Break;
- end
- else
- Result := TBillsCacheNode(Result.NextSibling);
- end;
- end;
- { TReportCacheNode }
- constructor TReportCacheNode.Create(ACacheTree: TCacheTree; AID,
- AProjectCount: Integer);
- begin
- inherited Create(ACacheTree, AID);
- FProjectCount := AProjectCount;
- SetLength(FP_Quantity, AProjectCount);
- SetLength(FP_Price, AProjectCount);
- SetLength(FP_TotalPrice, AProjectCount);
- SetLength(FP_DgnQuantity1, AProjectCount);
- SetLength(FP_DgnQuantity2, AProjectCount);
- end;
- function TReportCacheNode.GetAddGatherQuantity: Double;
- begin
- Result := AddDealQuantity + AddQcQuantity;
- end;
- function TReportCacheNode.GetAddGatherTotalPrice: Double;
- begin
- Result := AddDealTotalPrice + AddQcTotalPrice + AddPcTotalPrice;
- end;
- function TReportCacheNode.GetDesignPrice: Double;
- begin
- if DesignQuantity1 <> 0 then
- Result := TotalPrice / DesignQuantity1
- else
- Result := 0;
- end;
- function TReportCacheNode.GetDifferPercent1: Double;
- begin
- if TotalPrice <> 0 then
- Result := (AddGatherTotalPrice - TotalPrice) / TotalPrice * 100
- else
- Result := 0;
- end;
- function TReportCacheNode.GetDoubleArrayTotal(
- ADoubleArray: TDoubleArray): Double;
- var
- i: Integer;
- begin
- Result := 0;
- for i := Low(ADoubleArray) to High(ADoubleArray) do
- Result := Result + ADoubleArray[i];
- end;
- function TReportCacheNode.GetFinalDesignPrice: Double;
- var
- fQuantity: Double;
- begin
- fQuantity := FDealDesignQuantity1 + FCDesignQuantity1;
- if fQuantity <> 0 then
- Result := AddGatherTotalPrice / fQuantity
- else
- Result := 0;
- end;
- function TReportCacheNode.GetGatherP_TotalPrice: Double;
- begin
- Result := GetDoubleArrayTotal(FP_TotalPrice);
- end;
- procedure TReportCacheNode.ResolveCode;
- var
- sgs: TStrings;
- i: Integer;
- begin
- sgs := TStringList.Create;
- try
- sgs.Delimiter := '-';
- sgs.DelimitedText := FCode;
- FXiangCode := '';
- FMuCode := '';
- FJieCode := '';
- FXiMuCode := '';
- case sgs.Count of
- 1: FXiangCode := '';
- 2: FXiangCode := ChinessNum(StrToIntDef(sgs[1], 0));
- 3: FMuCode := sgs[2];
- 4: FJieCode := sgs[3];
- else
- begin
- for i := 4 to sgs.Count - 1 do
- if FXiMuCode = '' then
- FXiMuCode := sgs[i]
- else
- FXiMuCode := FXiMuCode + '-' + sgs[i];
- end;
- end;
- finally
- sgs.Free;
- end;
- end;
- procedure TReportCacheNode.SetCode(const Value: string);
- begin
- FCode := Value;
- ResolveCode;
- end;
- { TReportCacheTree }
- function TReportCacheTree.AddNode(AParent,
- ANextSibling: TCacheNode): TReportCacheNode;
- begin
- Result := GetNewNode(FProjectCount);
- if Assigned(ANextSibling) then
- ANextSibling.InsertPreSibling(Result)
- else if Assigned(AParent) then
- AParent.InsertChild(Result)
- else
- Root.InsertChild(Result);
- end;
- constructor TReportCacheTree.Create(AProjectCount: Integer);
- begin
- inherited Create;
- FProjectCount := AProjectCount;
- FGatherCacheNode := TReportCacheNode.Create(nil, -2, AProjectCount);
- SetLength(FProjectName, AProjectCount);
- end;
- destructor TReportCacheTree.Destroy;
- begin
- FGatherCacheNode.Free;
- inherited;
- end;
- function TReportCacheTree.FindNextSibling(AParent: TCacheNode; ACode,
- AB_Code: string): TReportCacheNode;
- var
- Node: TReportCacheNode;
- sCodeID, sCodeID2, sB_CodeID, sB_CodeID2: string;
- begin
- if Assigned(AParent) then
- Node := TReportCacheNode(AParent.FirstChild)
- else
- Node := TReportCacheNode(Root.FirstChild);
- Result := nil;
- if (ACode = '') and (AB_Code = '') then Exit;
- sCodeID := ConvertDigitCode(ACode, 3, '-');
- sB_CodeID := ConvertDigitCode(AB_Code, 4, '-');
- while Assigned(Node) do
- begin
- sCodeID2 := ConvertDigitCode(Node.Code, 3, '-');
- sB_CodeID2 := ConvertDigitCode(Node.B_Code, 4, '-');
- if (sCodeID <> '') and (sCodeID < sCodeID2) then
- begin
- Result := Node;
- Break;
- end
- else if sB_CodeID < sB_CodeID2 then
- begin
- Result := Node;
- Break;
- end;
- Node := TReportCacheNode(Node.NextSibling);
- end;
- end;
- function TReportCacheTree.FindNode(AParent: TCacheNode; ACode,
- AB_Code: string): TReportCacheNode;
- var
- Node: TReportCacheNode;
- begin
- if Assigned(AParent) then
- Node := TReportCacheNode(AParent.FirstChild)
- else
- Node := TReportCacheNode(Root.FirstChild);
- Result := nil;
- while Assigned(Node) do
- begin
- if (Node.Code = ACode) and (Node.B_Code = AB_Code) then
- begin
- Result := Node;
- Break;
- end;
- Node := TReportCacheNode(Node.NextSibling);
- end;
- end;
- function TReportCacheTree.FindNode(AParent: TCacheNode;
- AName: string): TReportCacheNode;
- var
- Node: TReportCacheNode;
- begin
- if Assigned(AParent) then
- Node := TReportCacheNode(AParent.FirstChild)
- else
- Node := TReportCacheNode(Root.FirstChild);
- Result := nil;
- while Assigned(Node) do
- begin
- if SameText(Node.Name, AName) then
- begin
- Result := Node;
- Break;
- end;
- Node := TReportCacheNode(Node.NextSibling);
- end;
- end;
- function TReportCacheTree.FindNode(AParent: TCacheNode; ACode, AB_Code,
- AName: string): TReportCacheNode;
- var
- Node: TReportCacheNode;
- begin
- if Assigned(AParent) then
- Node := TReportCacheNode(AParent.FirstChild)
- else
- Node := TReportCacheNode(Root.FirstChild);
- Result := nil;
- while Assigned(Node) do
- begin
- if SameText(Node.Code, ACode) and SameText(Node.B_Code, AB_Code)
- and SameText(Node.Name, AName) then
- begin
- Result := Node;
- Break;
- end;
- Node := TReportCacheNode(Node.NextSibling);
- end;
- end;
- function TReportCacheTree.GetNewNode(
- AProjectCount: Integer): TReportCacheNode;
- begin
- Result := TReportCacheNode.Create(Self, GetNewNodeID, AProjectCount);
- CacheNodes.Add(Result);
- end;
- procedure TReportCacheTree.ReCalcGatherData;
- var
- i: Integer;
- CacheNode: TReportCacheNode;
- begin
- FGatherCacheNode.Free;
- FGatherCacheNode := TReportCacheNode.Create(nil, -2, FProjectCount);
- CacheNode := TReportCacheNode(FirstNode);
- while Assigned(CacheNode) do
- begin
- FGatherCacheNode.TotalPrice := FGatherCacheNode.TotalPrice + CacheNode.TotalPrice;
- FGatherCacheNode.AddDealTotalPrice := FGatherCacheNode.AddDealTotalPrice + CacheNode.AddDealTotalPrice;
- FGatherCacheNode.AddQcTotalPrice := FGatherCacheNode.AddQcTotalPrice + CacheNode.AddQcTotalPrice;
- FGatherCacheNode.AddPcTotalPrice := FGatherCacheNode.AddPcTotalPrice + CacheNode.AddPcTotalPrice;
- FGatherCacheNode.PASTotalPrice := FGatherCacheNode.PASTotalPrice + CacheNode.PASTotalPrice;
- FGatherCacheNode.PDTotalPrice := FGatherCacheNode.PDTotalPrice + CacheNode.PDTotalPrice;
- FGatherCacheNode.CDDTotalPrice := FGatherCacheNode.CDDTotalPrice + CacheNode.CDDTotalPrice;
- FGatherCacheNode.ABTotalPrice := FGatherCacheNode.ABTotalPrice + CacheNode.ABTotalPrice;
- for i := 0 to FProjectCount - 1 do
- FGatherCacheNode.P_TotalPrice[i] := FGatherCacheNode.P_TotalPrice[i] + CacheNode.P_TotalPrice[i];
- CacheNode := TReportCacheNode(CacheNode.NextSibling);
- end;
- end;
- procedure TReportCacheTree.ReCalcRatioPercent;
- var
- i: Integer;
- CacheNode: TReportCacheNode;
- begin
- for i := 0 to CacheNodes.Count - 1 do
- begin
- CacheNode := TReportCacheNode(CacheNodes.Items[i]);
- if GatherCacheNode.TotalPrice <> 0 then
- CacheNode.RatioPercent := AdvRoundTo(CacheNode.TotalPrice/GatherCacheNode.TotalPrice*100);
- if GatherCacheNode.AddGatherTotalPrice <> 0 then
- CacheNode.AddRatioPercent := AdvRoundTo(CacheNode.AddGatherTotalPrice/GatherCacheNode.AddGatherTotalPrice*100);
- end;
- end;
- procedure TReportCacheTree.SaveTreeToFile(const AFileName: string);
- var
- sgs: TStringList;
- I: Integer;
- Node: TReportCacheNode;
- begin
- sgs := TStringList.Create;
- try
- for I := 0 to CacheNodes.Count - 1 do
- begin
- Node := TReportCacheNode(CacheNodes.Items[I]);
- sgs.Add(Format('ID: %3d; ParentID: %3d; NextID: %3d; Code: %s; B_Code: %s; Name: %s;',
- [Node.ID, Node.ParentID, Node.NextSiblingID, Node.Code, Node.B_Code, Node.Name]));
- end;
- sgs.SaveToFile(AFileName);
- finally
- sgs.Free;
- end;
- end;
- { TAllPhaseCacheTree }
- function TAllPhaseCacheTree.AddNode(AID: Integer; AParent,
- ANextSibling: TCacheNode): TAllPhaseCacheNode;
- begin
- Result := GetNewNode(AID);
- if Assigned(ANextSibling) then
- ANextSibling.InsertPreSibling(Result)
- else if Assigned(AParent) then
- AParent.InsertChild(Result)
- else
- Root.InsertChild(Result);
- end;
- function TAllPhaseCacheTree.FindNode(AID: Integer): TAllPhaseCacheNode;
- var
- i: Integer;
- Node: TAllPhaseCacheNode;
- begin
- Result := nil;
- for i := 0 to CacheNodes.Count - 1 do
- begin
- Node := TAllPhaseCacheNode(CacheNodes.Items[i]);
- if Node.ID = AID then
- begin
- Result := Node;
- Break;
- end;
- end;
- end;
- function TAllPhaseCacheTree.GetNewNode(
- AID: Integer): TAllPhaseCacheNode;
- begin
- Result := TAllPhaseCacheNode.Create(Self, AID);
- CacheNodes.Add(Result);
- end;
- procedure TAllPhaseCacheTree.SaveTreeToFile(const AFileName: string);
- var
- sgs: TStringList;
- I: Integer;
- Node: TAllPhaseCacheNode;
- begin
- sgs := TStringList.Create;
- try
- for I := 0 to CacheNodes.Count - 1 do
- begin
- Node := TAllPhaseCacheNode(CacheNodes.Items[I]);
- sgs.Add(Format('ID: %3d; ParentID: %3d; NextID: %3d; Code: %s; B_Code: %s; Name: %s;',
- [Node.ID, Node.ParentID, Node.NextSiblingID, Node.Code, Node.B_Code, Node.Name]));
- end;
- sgs.SaveToFile(AFileName);
- finally
- sgs.Free;
- end;
- end;
- { TGclCacheTree }
- function TGclCacheTree.AddNodeByB_Code(
- const AB_Code: string): TGclCacheNode;
- function FindParent: TGclCacheNode;
- begin
- Result := FLastNode;
- while Assigned(Result) and (Result <> Root) and (Result.B_Code <> '') and (Pos(Result.B_Code + '-', AB_Code) <> 1) do
- Result := TGclCacheNode(Result.Parent);
- end;
- var
- vParent: TGclCacheNode;
- begin
- vParent := FindParent;
- Result := TGclCacheNode(AddNode(vParent));
- FLastNode := Result;
- end;
- function TGclCacheTree.AddNodeByData(const AB_Code,
- AName: string): TGclCacheNode;
- begin
- if AB_Code = '' then
- Result := AddNodeByName(AName)
- else
- Result := AddNodeByB_Code(AB_Code);
- end;
- function TGclCacheTree.AddNodeByName(const AName: string): TGclCacheNode;
- begin
- if Pos('第100章至', AName) <> 0 then
- begin
- Result := TGclCacheNode(AddNode(nil));
- FLastBlank1 := Result;
- end
- else
- Result := TGclCacheNode(AddNode(FLastBlank1));
- FLastNode := Result;
- end;
- function TGclCacheTree.GetNewNode: TCacheNode;
- begin
- Result := TGclCacheNode.Create(Self, GetNewNodeID);
- CacheNodes.Add(Result);
- end;
- procedure TGclCacheTree.SaveTreeToFile(const AFileName: string);
- var
- sgs: TStringList;
- I: Integer;
- Node: TGclCacheNode;
- begin
- sgs := TStringList.Create;
- try
- for I := 0 to CacheNodes.Count - 1 do
- begin
- Node := TGclCacheNode(CacheNodes.Items[I]);
- sgs.Add(Format('ID: %3d; ParentID: %3d; NextID: %3d; B_Code: %s; Name: %s;',
- [Node.ID, Node.ParentID, Node.NextSiblingID, Node.B_Code, Node.Name]));
- end;
- sgs.SaveToFile(AFileName);
- finally
- sgs.Free;
- end;
- end;
- { TSpecPhaseCacheTree }
- function TSpecPhaseCacheTree.AddNode(AParent,
- ANextSibling: TCacheNode): TSpecPhaseCacheNode;
- begin
- Result := GetNewNode();
- if Assigned(ANextSibling) then
- ANextSibling.InsertPreSibling(Result)
- else if Assigned(AParent) then
- AParent.InsertChild(Result)
- else
- Root.InsertChild(Result);
- end;
- function TSpecPhaseCacheTree.FindNextSibling(AParent: TCacheNode; ACode,
- AB_Code: string): TSpecPhaseCacheNode;
- var
- Node: TSpecPhaseCacheNode;
- sCodeID, sCodeID2, sB_CodeID, sB_CodeID2: string;
- begin
- if Assigned(AParent) then
- Node := TSpecPhaseCacheNode(AParent.FirstChild)
- else
- Node := TSpecPhaseCacheNode(Root.FirstChild);
- Result := nil;
- if (ACode = '') and (AB_Code = '') then Exit;
- sCodeID := ConvertDigitCode(ACode, 3, '-');
- sB_CodeID := ConvertDigitCode(AB_Code, 4, '-');
- while Assigned(Node) do
- begin
- sCodeID2 := ConvertDigitCode(Node.Code, 3, '-');
- sB_CodeID2 := ConvertDigitCode(Node.B_Code, 4, '-');
- if (sCodeID <> '') and (sCodeID < sCodeID2) then
- begin
- Result := Node;
- Break;
- end
- else if sB_CodeID < sB_CodeID2 then
- begin
- Result := Node;
- Break;
- end;
- Node := TSpecPhaseCacheNode(Node.NextSibling);
- end;
- end;
- function TSpecPhaseCacheTree.FindNode(AParent: TCacheNode; ACode,
- AB_Code: string): TSpecPhaseCacheNode;
- var
- Node: TSpecPhaseCacheNode;
- begin
- if Assigned(AParent) then
- Node := TSpecPhaseCacheNode(AParent.FirstChild)
- else
- Node := TSpecPhaseCacheNode(Root.FirstChild);
- Result := nil;
- while Assigned(Node) do
- begin
- if (Node.Code = ACode) and (Node.B_Code = AB_Code) then
- begin
- Result := Node;
- Break;
- end;
- Node := TSpecPhaseCacheNode(Node.NextSibling);
- end;
- end;
- function TSpecPhaseCacheTree.FindNode(AParent: TCacheNode;
- AName: string): TSpecPhaseCacheNode;
- var
- Node: TSpecPhaseCacheNode;
- begin
- if Assigned(AParent) then
- Node := TSpecPhaseCacheNode(AParent.FirstChild)
- else
- Node := TSpecPhaseCacheNode(Root.FirstChild);
- Result := nil;
- while Assigned(Node) do
- begin
- if SameText(Node.Name, AName) then
- begin
- Result := Node;
- Break;
- end;
- Node := TSpecPhaseCacheNode(Node.NextSibling);
- end;
- end;
- function TSpecPhaseCacheTree.FindNode(AParent: TCacheNode; ACode, AB_Code,
- AName: string): TSpecPhaseCacheNode;
- var
- Node: TSpecPhaseCacheNode;
- begin
- if Assigned(AParent) then
- Node := TSpecPhaseCacheNode(AParent.FirstChild)
- else
- Node := TSpecPhaseCacheNode(Root.FirstChild);
- Result := nil;
- while Assigned(Node) do
- begin
- if SameText(Node.Code, ACode) and SameText(Node.B_Code, AB_Code)
- and SameText(Node.Name, AName) then
- begin
- Result := Node;
- Break;
- end;
- Node := TSpecPhaseCacheNode(Node.NextSibling);
- end;
- end;
- function TSpecPhaseCacheTree.GetNewNode: TSpecPhaseCacheNode;
- begin
- Result := TSpecPhaseCacheNode.Create(Self, GetNewNodeID);
- CacheNodes.Add(Result);
- end;
- end.
|