stgGatherCacheData.pas 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. unit stgGatherCacheData;
  2. interface
  3. uses
  4. CacheTree, SysUtils, BillsTree, Classes, sdDB, mDataRecord;
  5. const
  6. // 新增项目节
  7. iErrorXmjAdd = 1;
  8. // 存在同号项目节,但名称、单价不同
  9. iErrorXmjDiff = 2;
  10. // 项目节层次少于总包
  11. iErrorXmjLess = 3;
  12. // 新增工程量清单
  13. iErrorGclAdd = 11;
  14. // 存在同名工程量清单,但名称、单价不同
  15. iErrorGclDiff = 12;
  16. // 工程量清单层次多于总包
  17. iErrorGclMore = 13;
  18. // 工程量清单层次少于总包
  19. iErrorGclLess = 14;
  20. type
  21. TstgStageData = class
  22. private
  23. FDealQuantity: Double;
  24. FDealTotalPrice: Double;
  25. FQcQuantity: Double;
  26. FQcTotalPrice: Double;
  27. FQcBGLCode: string;
  28. FQcBGLNum: string;
  29. procedure AddBGLCodeAndNum(ACode, ANum: string);
  30. public
  31. procedure ClearData;
  32. procedure AddStageData(AStageData: TstgStageData);
  33. procedure AssignedData(AStageRecord: TStageRecord);
  34. property DealQuantity: Double read FDealQuantity;
  35. property DealTotalPrice: Double read FDealTotalPrice;
  36. property QcQuantity: Double read FQcQuantity;
  37. property QcTotalPrice: Double read FQcTotalPrice;
  38. property QcBGLCode: string read FQcBGLCode;
  39. property QcBGLNum: string read FQcBGLNum;
  40. end;
  41. TstgSubTenderDetailData = class
  42. private
  43. FSerialNo: Integer;
  44. FLeafXmjCode: string;
  45. FDetailStage: TstgStageData;
  46. public
  47. constructor Create(ANode: TMeasureBillsIDTreeNode);
  48. destructor Destroy; override;
  49. property SerialNo: Integer read FSerialNo;
  50. property LeafXmjCode: string read FLeafXmjCode;
  51. property DetailStage: TstgStageData read FDetailStage;
  52. end;
  53. TstgSubTenderStageData = class
  54. private
  55. FSubTenderID: Integer;
  56. FGather: TstgStageData;
  57. FDetails: TList;
  58. function GetDetail(AIndex: Integer): TstgSubTenderDetailData;
  59. function GetDetailCount: Integer;
  60. public
  61. constructor Create(ASubTenderID: Integer);
  62. destructor Destroy; override;
  63. function AddDetail(ANode: TMeasureBillsIDTreeNode): TstgSubTenderDetailData;
  64. procedure CalculateGather;
  65. property SubTenderID: Integer read FSubTenderID;
  66. property Gather: TstgStageData read FGather;
  67. property DetailCount: Integer read GetDetailCount;
  68. property Detail[AIndex: Integer]: TstgSubTenderDetailData read GetDetail;
  69. end;
  70. TstgGatherTreeNode = class(TCacheNode)
  71. private
  72. FCode: string;
  73. FB_Code: string;
  74. FName: string;
  75. FUnits: string;
  76. FIsSumBase: Boolean;
  77. FIsLeafXmj: Boolean;
  78. FIsLeaf: Boolean;
  79. FIsSubTender: Boolean;
  80. FGather: TstgStageData;
  81. FSubTenders: TList;
  82. function GetIsGclBills: Boolean;
  83. function GetSubTender(AIndex: Integer): TstgSubTenderStageData;
  84. function GetSubTenderCount: Integer;
  85. public
  86. constructor Create(ATree: TCacheTree; AID: Integer); override;
  87. destructor Destroy; override;
  88. function FindSubTender(ASubTenderID: Integer): TstgSubTenderStageData;
  89. function SafeSubTender(ASubTenderID: Integer): TstgSubTenderStageData;
  90. procedure CalculateGather;
  91. property Code: string read FCode write FCode;
  92. property B_Code: string read FB_Code write FB_Code;
  93. property Name: string read FName write FName;
  94. property Units: string read FUnits write FUnits;
  95. property IsSumBase: Boolean read FIsSumBase write FIsSumBase;
  96. property IsLeafXmj: Boolean read FIsLeafXmj write FIsLeafXmj;
  97. property IsLeaf: Boolean read FIsLeaf write FIsLeaf;
  98. property IsSubTender: Boolean read FIsSubTender write FIsSubTender;
  99. property IsGclBills: Boolean read GetIsGclBills;
  100. property SubTenderCount: Integer read GetSubTenderCount;
  101. property SubTender[AIndex: Integer]: TstgSubTenderStageData read GetSubTender;
  102. property Gather: TstgStageData read FGather;
  103. end;
  104. TstgGatherTree = class(TCacheTree)
  105. private
  106. FFixedNodes: TCacheNodeList;
  107. // -1的情况下默认自动赋值一个新的ID
  108. function GetNewNode(AID: Integer = -1): TstgGatherTreeNode; overload;
  109. function CheckLeafXmj(ANode: TstgGatherTreeNode): Boolean;
  110. public
  111. constructor Create; override;
  112. destructor Destroy; override;
  113. function FindNextSibling(AParent: TCacheNode; ACode, AB_Code: string): TstgGatherTreeNode;
  114. function FindNode(AParent: TCacheNode; AInfo: TBillsIDTreeNode): TstgGatherTreeNode; overload;
  115. function FindNode(AID: Integer): TstgGatherTreeNode; overload;
  116. function AddFixedNode(AParent: TCacheNode; ANextSibling:
  117. TCacheNode = nil; AFixedID: Integer = -1): TstgGatherTreeNode;
  118. function AddNode(AParent: TCacheNode; ANextSibling:
  119. TCacheNode = nil; ASumBaseID: Integer = -1): TstgGatherTreeNode;
  120. function AddSumBaseNode(AParent: TCacheNode; ASumBaseID: Integer): TstgGatherTreeNode;
  121. function AddSubTenderNode(AParent: TCacheNode; ANextSibling: TCacheNode; AFixedID: Integer = -1): TstgGatherTreeNode;
  122. // Only for Debugging lot of Data
  123. procedure SaveTreeToFile(const AFileName: string);
  124. procedure MarkLeafXmj;
  125. procedure CalculateAll;
  126. end;
  127. TstgGatherSubTender = class
  128. private
  129. FID: Integer;
  130. FRec: TsdDataRecord;
  131. public
  132. constructor Create(ARec: TsdDataRecord);
  133. property ID: Integer read FID;
  134. property Rec: TsdDataRecord read FRec;
  135. end;
  136. TstgErrorInfo = class
  137. private
  138. FRelaNode: TstgGatherTreeNode;
  139. FErrorType: Integer;
  140. FDetails: TList;
  141. function GetDetail(AIndex: Integer): TstgGatherTreeNode;
  142. function GetDetailCount: Integer;
  143. public
  144. constructor Create(ARelaNode: TstgGatherTreeNode);
  145. destructor Destroy; override;
  146. procedure AddErrorDetail(ARelaDetailNode: TstgGatherTreeNode);
  147. property RelaNode: TstgGatherTreeNode read FRelaNode;
  148. property ErrorType: Integer read FErrorType write FErrorType;
  149. property DetailCount: Integer read GetDetailCount;
  150. property Detail[AIndex: Integer]: TstgGatherTreeNode read GetDetail;
  151. end;
  152. TstgGatherCacheData = class
  153. private
  154. FGatherTree: TstgGatherTree;
  155. FSubTenders: TList;
  156. FErrors: TList;
  157. function FindError(ANode: TstgGatherTreeNode): TstgErrorInfo;
  158. function NewError(ANode: TstgGatherTreeNode; AErrorType: Integer): TstgErrorInfo;
  159. function GetSubTenderCount: Integer;
  160. function GetSubTender(AIndex: Integer): TstgGatherSubTender;
  161. function GetErrorCount: Integer;
  162. function GetError(AIndex: Integer): TstgErrorInfo;
  163. public
  164. constructor Create;
  165. destructor Destroy; override;
  166. function FindSubTender(AID: Integer): TstgGatherSubTender;
  167. function AddSubTender(ARec: TsdDataRecord): TstgGatherSubTender;
  168. procedure AddError(ANode, ALeafErrorNode: TstgGatherTreeNode; AErrorType: Integer);
  169. property SubTenderCount: Integer read GetSubTenderCount;
  170. property SubTender[AIndex: Integer]: TstgGatherSubTender read GetSubTender;
  171. property ErrorCount: Integer read GetErrorCount;
  172. property Error[AIndex: Integer]: TstgErrorInfo read GetError;
  173. property GatherTree: TstgGatherTree read FGatherTree;
  174. end;
  175. implementation
  176. uses
  177. ZhAPI, UtilMethods, Math;
  178. { TstgGatherTreeNode }
  179. procedure TstgGatherTreeNode.CalculateGather;
  180. var
  181. i: Integer;
  182. vSubTender: TstgSubTenderDetailData;
  183. begin
  184. FGather.ClearData;
  185. for i := 0 to FSubTenders.Count - 1 do
  186. begin
  187. SubTender[i].CalculateGather;
  188. FGather.AddStageData(SubTender[i].Gather);
  189. end;
  190. end;
  191. constructor TstgGatherTreeNode.Create(ATree: TCacheTree; AID: Integer);
  192. begin
  193. inherited Create(ATree, AID);
  194. FSubTenders := TList.Create;
  195. FGather := TstgStageData.Create;
  196. end;
  197. destructor TstgGatherTreeNode.Destroy;
  198. begin
  199. FGather.Free;
  200. ClearObjects(FSubTenders);
  201. FSubTenders.Free;
  202. inherited;
  203. end;
  204. function TstgGatherTreeNode.FindSubTender(
  205. ASubTenderID: Integer): TstgSubTenderStageData;
  206. var
  207. i: Integer;
  208. begin
  209. Result := nil;
  210. for i := 0 to FSubTenders.Count - 1 do
  211. begin
  212. if ASubTenderID = SubTender[i].SubTenderID then
  213. begin
  214. Result := SubTender[i];
  215. Break;
  216. end;
  217. end;
  218. end;
  219. function TstgGatherTreeNode.GetIsGclBills: Boolean;
  220. begin
  221. Result := FB_Code <> '';
  222. end;
  223. function TstgGatherTreeNode.GetSubTender(
  224. AIndex: Integer): TstgSubTenderStageData;
  225. begin
  226. Result := TstgSubTenderStageData(FSubTenders.Items[AIndex]);
  227. end;
  228. function TstgGatherTreeNode.GetSubTenderCount: Integer;
  229. begin
  230. Result := FSubTenders.Count;
  231. end;
  232. function TstgGatherTreeNode.SafeSubTender(
  233. ASubTenderID: Integer): TstgSubTenderStageData;
  234. begin
  235. Result := FindSubTender(ASubTenderID);
  236. if not Assigned(Result) then
  237. begin
  238. Result := TstgSubTenderStageData.Create(ASubTenderID);
  239. FSubTenders.Add(Result);
  240. end;
  241. end;
  242. { TstgGatherTree }
  243. function TstgGatherTree.AddFixedNode(AParent, ANextSibling: TCacheNode;
  244. AFixedID: Integer): TstgGatherTreeNode;
  245. begin
  246. Result := GetNewNode(AFixedID);
  247. if Assigned(ANextSibling) then
  248. ANextSibling.InsertPreSibling(Result)
  249. else if Assigned(AParent) then
  250. AParent.InsertChild(Result)
  251. else
  252. Root.InsertChild(Result);
  253. FFixedNodes.Add(Result);
  254. end;
  255. function TstgGatherTree.AddNode(AParent, ANextSibling: TCacheNode;
  256. ASumBaseID: Integer): TstgGatherTreeNode;
  257. begin
  258. Result := GetNewNode(ASumBaseID);
  259. if Assigned(ANextSibling) then
  260. ANextSibling.InsertPreSibling(Result)
  261. else if Assigned(AParent) then
  262. AParent.InsertChild(Result)
  263. else
  264. Root.InsertChild(Result);
  265. end;
  266. function TstgGatherTree.AddSubTenderNode(AParent, ANextSibling: TCacheNode;
  267. AFixedID: Integer): TstgGatherTreeNode;
  268. begin
  269. Result := GetNewNode(AFixedID);
  270. Result.IsSubTender := True;
  271. if Assigned(ANextSibling) then
  272. ANextSibling.InsertPreSibling(Result)
  273. else if Assigned(AParent) then
  274. AParent.InsertChild(Result)
  275. else
  276. Root.InsertChild(Result);
  277. end;
  278. function TstgGatherTree.AddSumBaseNode(AParent: TCacheNode;
  279. ASumBaseID: Integer): TstgGatherTreeNode;
  280. begin
  281. Result := GetNewNode(ASumBaseID);
  282. Result.IsSumBase := True;
  283. if Assigned(AParent) then
  284. AParent.InsertChild(Result)
  285. else
  286. Root.InsertChild(Result);
  287. end;
  288. procedure TstgGatherTree.CalculateAll;
  289. var
  290. i: Integer;
  291. begin
  292. for i := 0 to CacheNodes.Count - 1 do
  293. TstgGatherTreeNode(CacheNodes[i]).CalculateGather;
  294. end;
  295. function TstgGatherTree.CheckLeafXmj(ANode: TstgGatherTreeNode): Boolean;
  296. var
  297. iChild: Integer;
  298. vChild: TstgGatherTreeNode;
  299. begin
  300. Result := True;
  301. for iChild := 0 to ANode.Children.Count - 1 do
  302. begin
  303. vChild := TstgGatherTreeNode(ANode.Children.Items[iChild]);
  304. if vChild.FB_Code = '' then
  305. begin
  306. Result := False;
  307. Break;
  308. end;
  309. end;
  310. end;
  311. constructor TstgGatherTree.Create;
  312. begin
  313. inherited;
  314. FFixedNodes := TCacheNodeList.Create;
  315. NewNodeID := 100;
  316. end;
  317. destructor TstgGatherTree.Destroy;
  318. begin
  319. FFixedNodes.Free;
  320. inherited;
  321. end;
  322. function TstgGatherTree.FindNextSibling(AParent: TCacheNode;
  323. ACode, AB_Code: string): TstgGatherTreeNode;
  324. var
  325. vChild: TstgGatherTreeNode;
  326. begin
  327. Result := nil;
  328. if Assigned(AParent) then
  329. vChild := TstgGatherTreeNode(AParent.FirstChild)
  330. else
  331. vChild := TstgGatherTreeNode(Root.FirstChild);
  332. while not Assigned(Result) and Assigned(vChild) do
  333. begin
  334. if (CompareCode(ACode, vChild.Code) < 0) or (CompareCode(AB_Code, vChild.B_Code) < 0) then
  335. Result := vChild;
  336. vChild := TstgGatherTreeNode(vChild.NextSibling);
  337. end;
  338. end;
  339. function TstgGatherTree.FindNode(AID: Integer): TstgGatherTreeNode;
  340. var
  341. i: Integer;
  342. Node: TCacheNode;
  343. begin
  344. Result := nil;
  345. for i := 0 to FFixedNodes.Count - 1 do
  346. begin
  347. Node := FFixedNodes.Items[i];
  348. if Node.ID = AID then
  349. begin
  350. Result := TstgGatherTreeNode(Node);
  351. Break;
  352. end;
  353. end;
  354. end;
  355. function TstgGatherTree.FindNode(AParent: TCacheNode;
  356. AInfo: TBillsIDTreeNode): TstgGatherTreeNode;
  357. var
  358. vNode: TstgGatherTreeNode;
  359. begin
  360. Result := nil;
  361. if Assigned(AParent) then
  362. vNode := TstgGatherTreeNode(AParent.FirstChild)
  363. else
  364. vNode := TstgGatherTreeNode(Root.FirstChild);
  365. while Assigned(vNode) and not Assigned(Result) do
  366. begin
  367. if SameText(vNode.Code, Trim(AInfo.Rec.Code.AsString)) and SameText(vNode.B_Code, Trim(AInfo.Rec.B_Code.AsString))
  368. and SameText(vNode.Name, Trim(AInfo.Rec.Name.AsString)) and SameText(vNode.Units, Trim(AInfo.Rec.Units.AsString)) then
  369. Result := vNode;
  370. vNode := TstgGatherTreeNode(vNode.NextSibling);
  371. end;
  372. end;
  373. function TstgGatherTree.GetNewNode(AID: Integer): TstgGatherTreeNode;
  374. begin
  375. if AID = -1 then
  376. Result := TstgGatherTreeNode.Create(Self, GetNewNodeID)
  377. else
  378. Result := TstgGatherTreeNode.Create(Self, AID);
  379. NewNodeID := Max(NewNodeID, AID + 1);
  380. CacheNodes.Add(Result);
  381. if AID < 100 then
  382. FFixedNodes.Add(Result);
  383. end;
  384. procedure TstgGatherTree.MarkLeafXmj;
  385. var
  386. i: Integer;
  387. vNode: TstgGatherTreeNode;
  388. begin
  389. for i := 0 to CacheNodes.Count - 1 do
  390. begin
  391. vNode := TstgGatherTreeNode(CacheNodes.Items[i]);
  392. vNode.IsLeafXmj := CheckLeafXmj(vNode);
  393. end;
  394. end;
  395. procedure TstgGatherTree.SaveTreeToFile(const AFileName: string);
  396. var
  397. sgs: TStringList;
  398. I: Integer;
  399. Node: TstgGatherTreeNode;
  400. begin
  401. sgs := TStringList.Create;
  402. try
  403. for I := 0 to CacheNodes.Count - 1 do
  404. begin
  405. Node := TstgGatherTreeNode(CacheNodes.Items[I]);
  406. sgs.Add(Format('ID: %3d; ParentID: %3d; NextID: %3d; Code: %s; B_Code: %s; Name: %s;',
  407. [Node.ID, Node.ParentID, Node.NextSiblingID, Node.Code, Node.B_Code, Node.Name]));
  408. end;
  409. sgs.SaveToFile(AFileName);
  410. finally
  411. sgs.Free;
  412. end;
  413. end;
  414. { TstgGatherCacheData }
  415. procedure TstgGatherCacheData.AddError(ANode,
  416. ALeafErrorNode: TstgGatherTreeNode; AErrorType: Integer);
  417. var
  418. vError: TstgErrorInfo;
  419. begin
  420. vError := FindError(ANode);
  421. if not Assigned(vError) then
  422. vError := NewError(ANode, AErrorType);
  423. vError.AddErrorDetail(ALeafErrorNode);
  424. end;
  425. function TstgGatherCacheData.AddSubTender(
  426. ARec: TsdDataRecord): TstgGatherSubTender;
  427. begin
  428. Result := FindSubTender(ARec.ValueByName('ID').AsInteger);
  429. if not Assigned(Result) then
  430. begin
  431. Result := TstgGatherSubTender.Create(ARec);
  432. FSubTenders.Add(Result);
  433. end;
  434. end;
  435. constructor TstgGatherCacheData.Create;
  436. begin
  437. FGatherTree := TstgGatherTree.Create;
  438. FSubTenders := TList.Create;
  439. FErrors := TList.Create;
  440. end;
  441. destructor TstgGatherCacheData.Destroy;
  442. begin
  443. ClearObjects(FErrors);
  444. FErrors.Free;
  445. ClearObjects(FSubTenders);
  446. FSubTenders.Free;
  447. FGatherTree.Free;
  448. inherited;
  449. end;
  450. function TstgGatherCacheData.FindError(
  451. ANode: TstgGatherTreeNode): TstgErrorInfo;
  452. var
  453. i: Integer;
  454. begin
  455. Result := nil;
  456. for i := 0 to ErrorCount - 1 do
  457. begin
  458. if Error[i].RelaNode = ANode then
  459. begin
  460. Result := Error[i];
  461. Break;
  462. end;
  463. end;
  464. end;
  465. function TstgGatherCacheData.FindSubTender(
  466. AID: Integer): TstgGatherSubTender;
  467. var
  468. i: Integer;
  469. begin
  470. Result := nil;
  471. for i := 0 to SubTenderCount - 1 do
  472. begin
  473. if SubTender[i].ID = AID then
  474. begin
  475. Result := SubTender[i];
  476. Break;
  477. end;
  478. end;
  479. end;
  480. function TstgGatherCacheData.GetError(AIndex: Integer): TstgErrorInfo;
  481. begin
  482. Result := TstgErrorInfo(FErrors.Items[AIndex]);
  483. end;
  484. function TstgGatherCacheData.GetErrorCount: Integer;
  485. begin
  486. Result := FErrors.Count;
  487. end;
  488. function TstgGatherCacheData.GetSubTender(AIndex: Integer): TstgGatherSubTender;
  489. begin
  490. Result := TstgGatherSubTender(FSubTenders.Items[AIndex]);
  491. end;
  492. function TstgGatherCacheData.GetSubTenderCount: Integer;
  493. begin
  494. Result := FSubTenders.Count;
  495. end;
  496. function TstgGatherCacheData.NewError(
  497. ANode: TstgGatherTreeNode; AErrorType: Integer): TstgErrorInfo;
  498. begin
  499. Result := TstgErrorInfo.Create(ANode);
  500. Result.ErrorType := AErrorType;
  501. FErrors.Add(Result);
  502. end;
  503. { TstgGatherSubTender }
  504. constructor TstgGatherSubTender.Create(ARec: TsdDataRecord);
  505. begin
  506. FID := ARec.ValueByName('ID').AsInteger;
  507. FRec := ARec;
  508. end;
  509. { TstgStageData }
  510. procedure TstgStageData.AddBGLCodeAndNum(ACode, ANum: string);
  511. var
  512. sCode, sNum: string;
  513. begin
  514. sCode := FQcBGLCode;
  515. sNum := FQcBGLNum;
  516. MergeRelaBGLAndNum(sCode, sNum, ACode, ANum);
  517. FQcBGLCode := sCode;
  518. FQcBGLNum := sNum;
  519. end;
  520. procedure TstgStageData.AddStageData(AStageData: TstgStageData);
  521. begin
  522. FDealQuantity := FDealQuantity + AStageData.DealQuantity;
  523. FDealTotalPrice := FDealTotalPrice + AStageData.DealTotalPrice;
  524. FQcQuantity := FQcQuantity + AStageData.QcQuantity;
  525. FQcTotalPrice := FQcTotalPrice + AStageData.QcTotalPrice;
  526. AddBGLCodeAndNum(AStageData.QcBGLCode, AStageData.QcBGLNum);
  527. end;
  528. procedure TstgStageData.AssignedData(AStageRecord: TStageRecord);
  529. begin
  530. FDealQuantity := AStageRecord.DealQuantity.AsFloat;
  531. FDealTotalPrice := AStageRecord.DealTotalPrice.AsFloat;
  532. FQcQuantity := AStageRecord.QcQuantity.AsFloat;
  533. FQcTotalPrice := AStageRecord.QcTotalPrice.AsFloat;
  534. FQcBGLCode := AStageRecord.QcBGLCode.AsString;
  535. FQcBGLNum := AStageRecord.QcBGLNum.AsString;
  536. end;
  537. procedure TstgStageData.ClearData;
  538. begin
  539. FDealQuantity := 0;
  540. FDealTotalPrice := 0;
  541. FQcQuantity := 0;
  542. FQcTotalPrice := 0;
  543. FQcBGLCode := '';
  544. FQcBGLNum := '';
  545. end;
  546. { TstgSubTenderStageData }
  547. function TstgSubTenderStageData.AddDetail(
  548. ANode: TMeasureBillsIDTreeNode): TstgSubTenderDetailData;
  549. begin
  550. Result := TstgSubTenderDetailData.Create(ANode);
  551. FDetails.Add(Result);
  552. end;
  553. procedure TstgSubTenderStageData.CalculateGather;
  554. var
  555. i: Integer;
  556. begin
  557. FGather.ClearData;
  558. for i := 0 to DetailCount - 1 do
  559. FGather.AddStageData(Detail[i].DetailStage);
  560. end;
  561. constructor TstgSubTenderStageData.Create(ASubTenderID: Integer);
  562. begin
  563. FSubTenderID := ASubTenderID;
  564. FGather := TstgStageData.Create;
  565. FDetails := TList.Create;
  566. end;
  567. destructor TstgSubTenderStageData.Destroy;
  568. begin
  569. ClearObjects(FDetails);
  570. FDetails.Free;
  571. FGather.Free;
  572. inherited;
  573. end;
  574. function TstgSubTenderStageData.GetDetail(
  575. AIndex: Integer): TstgSubTenderDetailData;
  576. begin
  577. Result := TstgSubTenderDetailData(FDetails.Items[AIndex]);
  578. end;
  579. function TstgSubTenderStageData.GetDetailCount: Integer;
  580. begin
  581. Result := FDetails.Count;
  582. end;
  583. { TstgSubTenderDetailData }
  584. constructor TstgSubTenderDetailData.Create(ANode: TMeasureBillsIDTreeNode);
  585. begin
  586. FSerialNo := ANode.MajorIndex;
  587. FDetailStage := TstgStageData.Create;
  588. if Assigned(ANode.StageRec) then
  589. FDetailStage.AssignedData(ANode.StageRec);
  590. end;
  591. destructor TstgSubTenderDetailData.Destroy;
  592. begin
  593. FDetailStage.Free;
  594. inherited;
  595. end;
  596. { TstgErrorInfo }
  597. procedure TstgErrorInfo.AddErrorDetail(
  598. ARelaDetailNode: TstgGatherTreeNode);
  599. begin
  600. FDetails.Add(ARelaDetailNode);
  601. end;
  602. constructor TstgErrorInfo.Create(ARelaNode: TstgGatherTreeNode);
  603. begin
  604. FRelaNode := ARelaNode;
  605. FDetails := TList.Create;
  606. end;
  607. destructor TstgErrorInfo.Destroy;
  608. begin
  609. FDetails.Free;
  610. inherited;
  611. end;
  612. function TstgErrorInfo.GetDetail(AIndex: Integer): TstgGatherTreeNode;
  613. begin
  614. Result := TstgGatherTreeNode(FDetails.Items[AIndex]);
  615. end;
  616. function TstgErrorInfo.GetDetailCount: Integer;
  617. begin
  618. Result := FDetails.Count;
  619. end;
  620. end.