stgGatherCacheData.pas 19 KB

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