GclBillsGatherModel.pas 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103
  1. unit GclBillsGatherModel;
  2. // 单项目的工程量清单汇总
  3. interface
  4. uses
  5. Classes, mDataRecord, BillsTree, CalcDecimal;
  6. type
  7. TGatherDataWriteEvent = procedure (AGcls, AXmjs: TList) of object;
  8. TLeafXmjNode = class
  9. private
  10. FID: Integer;
  11. FXmjCode: string;
  12. FXmjName: string;
  13. FXmjUnits: string;
  14. FPeg: string;
  15. FNameDanWei: string;
  16. FNameFenBu: string;
  17. FNameFenXiang: string;
  18. FNameUnit: string;
  19. FPosition: string;
  20. FDrawingCode: string;
  21. public
  22. constructor Create(ALeafXmj, APeg: TBillsIDTreeNode);
  23. property ID: Integer read FID;
  24. property XmjCode: string read FXmjCode;
  25. property XmjName: string read FXmjName;
  26. property XmjUnits: string read FXmjUnits;
  27. property Peg: string read FPeg;
  28. property NameDanWei: string read FNameDanWei;
  29. property NameFenBu: string read FNameFenBu;
  30. property NameFenXiang: string read FNameFenXiang;
  31. property NameUnit: string read FNameUnit;
  32. property Position: string read FPosition;
  33. property DrawingCode: string read FDrawingCode;
  34. end;
  35. TDetailGclNode = class
  36. private
  37. FID: Integer;
  38. FBillsID: Integer;
  39. FTreeSerialNo: Integer;
  40. FOrgQuantity: Double;
  41. FOrgTotalPrice: Double;
  42. FMisQuantity: Double;
  43. FMisTotalPrice: Double;
  44. FOthQuantity: Double;
  45. FOthTotalPrice: Double;
  46. FQuantity: Double;
  47. FTotalPrice: Double;
  48. FCurDealQuantity: Double;
  49. FCurDealTotalPrice: Double;
  50. FCurQcQuantity: Double;
  51. FCurQcTotalPrice: Double;
  52. FCurGatherQuantity: Double;
  53. FCurGatherTotalPrice: Double;
  54. FPreDealQuantity: Double;
  55. FPreDealTotalPrice: Double;
  56. FPreQcQuantity: Double;
  57. FPreQcTotalPrice: Double;
  58. FPreGatherQuantity: Double;
  59. FPreGatherTotalPrice: Double;
  60. FEndDealQuantity: Double;
  61. FEndDealTotalPrice: Double;
  62. FEndQcQuantity: Double;
  63. FEndQcTotalPrice: Double;
  64. FEndGatherQuantity: Double;
  65. FEndGatherTotalPrice: Double;
  66. FAddDealQuantity: Double;
  67. FAddDealTotalPrice: Double;
  68. FAddQcQuantity: Double;
  69. FAddQcTotalPrice: Double;
  70. FAddGatherQuantity: Double;
  71. FAddGatherTotalPrice: Double;
  72. FPM_PreTotalPrice: Double;
  73. FPM_TotalPrice: Double;
  74. FLeafXmj: TLeafXmjNode;
  75. function GetPercent: Double;
  76. public
  77. constructor Create(AID: Integer);
  78. property ID: Integer read FID;
  79. property BillsID: Integer read FBillsID write FBillsID;
  80. property TreeSerialNo: Integer read FTreeSerialNo write FTreeSerialNo;
  81. property OrgQuantity: Double read FOrgQuantity write FOrgQuantity;
  82. property OrgTotalPrice: Double read FOrgTotalPrice write FOrgTotalPrice;
  83. property MisQuantity: Double read FMisQuantity write FMisQuantity;
  84. property MisTotalPrice: Double read FMisTotalPrice write FMisTotalPrice;
  85. property OthQuantity: Double read FOthQuantity write FOthQuantity;
  86. property OthTotalPrice: Double read FOthTotalPrice write FOthTotalPrice;
  87. property Quantity: Double read FQuantity write FQuantity;
  88. property TotalPrice: Double read FTotalPrice write FTotalPrice;
  89. property CurDealQuantity: Double read FCurDealQuantity write FCurDealQuantity;
  90. property CurDealTotalPrice: Double read FCurDealTotalPrice write FCurDealTotalPrice;
  91. property CurQcQuantity: Double read FCurQcQuantity write FCurQcQuantity;
  92. property CurQcTotalPrice: Double read FCurQcTotalPrice write FCurQcTotalPrice;
  93. property CurGatherQuantity: Double read FCurGatherQuantity write FCurGatherQuantity;
  94. property CurGatherTotalPrice: Double read FCurGatherTotalPrice write FCurGatherTotalPrice;
  95. property PreDealQuantity: Double read FPreDealQuantity write FPreDealQuantity;
  96. property PreDealTotalPrice: Double read FPreGatherTotalPrice write FPreGatherTotalPrice;
  97. property PreQcQuantity: Double read FPreQcQuantity write FPreQcQuantity;
  98. property PreQcTotalPrice: Double read FPreQcTotalPrice write FPreQcTotalPrice;
  99. property PreGatherQuantity: Double read FPreGatherQuantity write FPreGatherQuantity;
  100. property PreGatherTotalPrice: Double read FPreGatherTotalPrice write FPreGatherTotalPrice;
  101. property EndDealQuantity: Double read FEndDealQuantity write FEndDealQuantity;
  102. property EndDealTotalPrice: Double read FEndDealTotalPrice write FEndDealTotalPrice;
  103. property EndQcQuantity: Double read FEndQcQuantity write FEndQcQuantity;
  104. property EndQcTotalPrice: Double read FEndQcTotalPrice write FEndQcTotalPrice;
  105. property EndGatherQuantity: Double read FEndGatherQuantity write FEndGatherQuantity;
  106. property EndGatherTotalPrice: Double read FEndGatherTotalPrice write FEndGatherTotalPrice;
  107. property Percent: Double read GetPercent;
  108. property AddDealQuantity: Double read FAddDealQuantity write FAddDealQuantity;
  109. property AddDealTotalPrice: Double read FAddDealTotalPrice write FAddDealTotalPrice;
  110. property AddQcQuantity: Double read FAddQcQuantity write FAddQcQuantity;
  111. property AddQcTotalPrice: Double read FAddQcTotalPrice write FAddQcQuantity;
  112. property AddGatherQuantity: Double read FAddGatherQuantity write FAddGatherQuantity;
  113. property AddGatherTotalPrice: Double read FAddGatherTotalPrice write FAddGatherTotalPrice;
  114. property PM_PreTotalPrice: Double read FPM_PreTotalPrice write FPM_PreTotalPrice;
  115. property PM_TotalPrice: Double read FPM_TotalPrice write FPM_TotalPrice;
  116. property LeafXmj: TLeafXmjNode read FLeafXmj write FLeafXmj;
  117. end;
  118. TDetailDealNode = class
  119. private
  120. FID: Integer;
  121. FDealID: Integer;
  122. FQuantity: Double;
  123. FTotalPrice: Double;
  124. public
  125. constructor Create(AID: Integer);
  126. property ID: Integer read FID;
  127. property DealID: Integer read FDealID write FDealID;
  128. property Quantity: Double read FQuantity write FQuantity;
  129. property TotalPrice: Double read FTotalPrice write FTotalPrice;
  130. end;
  131. TDetailBGLNode = class
  132. private
  133. FID: Integer;
  134. FBGBillsID: Integer;
  135. FBGLID: Integer;
  136. FBGLCode: string;
  137. FBGLName: string;
  138. FBGLApprovalCode: string;
  139. FBGLDrawingCode: string;
  140. FQuantity: Double;
  141. FTotalPrice: Double;
  142. public
  143. constructor Create(AID: Integer);
  144. property ID: Integer read FID;
  145. property BGBillsID: Integer read FBGBillsID write FBGBillsID;
  146. property BGLID: Integer read FBGLID write FBGLID;
  147. property BGLCode: string read FBGLCode write FBGLCode;
  148. property BGLName: string read FBGLName write FBGLName;
  149. property BGLApprovalCode: string read FBGLApprovalCode write FBGLApprovalCode;
  150. property BGLDrawingCode: string read FBGLDrawingCode write FBGLDrawingCode;
  151. property Quantity: Double read FQuantity write FQuantity;
  152. property TotalPrice: Double read FTotalPrice write FTotalPrice;
  153. end;
  154. TGclNode = class
  155. private
  156. FDetailGcls: TList;
  157. FDetailDeals: TList;
  158. FDetailBGLs: TList;
  159. FLeafXmjs: TList;
  160. FID: Integer;
  161. FB_Code: string;
  162. FIndexCode: string;
  163. FName: string;
  164. FUnits: string;
  165. FPrice: Double;
  166. FOrgQuantity: Double;
  167. FOrgTotalPrice: Double;
  168. FMisQuantity: Double;
  169. FMisTotalPrice: Double;
  170. FOthQuantity: Double;
  171. FOthTotalPrice: Double;
  172. FQuantity: Double;
  173. FTotalPrice: Double;
  174. FCurDealQuantity: Double;
  175. FCurDealTotalPrice: Double;
  176. FCurQcQuantity: Double;
  177. FCurQcTotalPrice: Double;
  178. FCurGatherQuantity: Double;
  179. FCurGatherTotalPrice: Double;
  180. FPreDealQuantity: Double;
  181. FPreDealTotalPrice: Double;
  182. FPreQcQuantity: Double;
  183. FPreQcTotalPrice: Double;
  184. FPreGatherQuantity: Double;
  185. FPreGatherTotalPrice: Double;
  186. FEndDealQuantity: Double;
  187. FEndDealTotalPrice: Double;
  188. FEndQcQuantity: Double;
  189. FEndQcTotalPrice: Double;
  190. FEndGatherQuantity: Double;
  191. FEndGatherTotalPrice: Double;
  192. FAddDealQuantity: Double;
  193. FAddDealTotalPrice: Double;
  194. FAddQcQuantity: Double;
  195. FAddQcTotalPrice: Double;
  196. FAddGatherQuantity: Double;
  197. FAddGatherTotalPrice: Double;
  198. FDealQuantity: Double;
  199. FDealTotalPrice: Double;
  200. FBGLQuantity: Double;
  201. FBGLTotalPrice: Double;
  202. FDeal_BGLQuantity: Double;
  203. FDeal_BGLTotalPrice: Double;
  204. FDeal_BGLPercent: Double;
  205. FDecimal: TCalcDecimal;
  206. procedure InitCalculate;
  207. procedure GatherDetailGcl;
  208. procedure GatherDetailDeal;
  209. procedure GatherDetailBGL;
  210. procedure CalculateOther;
  211. procedure SetB_Code(const Value: string);
  212. function GetDetailBGL(AIndex: Integer): TDetailBGLNode;
  213. function GetDetailBGLCount: Integer;
  214. function GetDetailDeal(AIndex: Integer): TDetailDealNode;
  215. function GetDetailDealCount: Integer;
  216. function GetDetailGcl(AIndex: Integer): TDetailGclNode;
  217. function GetDetailGclCount: Integer;
  218. function GetLeafXmjCount: Integer;
  219. function GetLeafXmj(AIndex: Integer): TLeafXmjNode;
  220. public
  221. constructor Create(AID: Integer; ADecimal: TCalcDecimal);
  222. destructor Destroy; override;
  223. procedure AddLeafXmj(ALeafXmj: TLeafXmjNode);
  224. function AddDetailGcl(AID: Integer): TDetailGclNode;
  225. function AddDetailDeal(AID: Integer): TDetailDealNode;
  226. function AddDetailBGL(AID: Integer): TDetailBGLNode;
  227. procedure Calculate;
  228. property ID: Integer read FID;
  229. property B_Code: string read FB_Code write SetB_Code;
  230. property IndexCode: string read FIndexCode;
  231. property Name: string read FName write FName;
  232. property Units: string read FUnits write FUnits;
  233. property Price: Double read FPrice write FPrice;
  234. property OrgQuantity: Double read FOrgQuantity;
  235. property OrgTotalPrice: Double read FOrgTotalPrice;
  236. property MisQuantity: Double read FMisQuantity;
  237. property MisTotalPrice: Double read FMisTotalPrice;
  238. property OthQuantity: Double read FOthQuantity;
  239. property OthTotalPrice: Double read FOthTotalPrice;
  240. property Quantity: Double read FQuantity;
  241. property TotalPrice: Double read FTotalPrice;
  242. property CurDealQuantity: Double read FCurDealQuantity;
  243. property CurDealTotalPrice: Double read FCurDealTotalPrice;
  244. property CurQcQuantity: Double read FCurQcQuantity;
  245. property CurQcTotalPrice: Double read FCurQcTotalPrice;
  246. property CurGatherQuantity: Double read FCurGatherQuantity;
  247. property CurGatherTotalPrice: Double read FCurGatherTotalPrice;
  248. property PreDealQuantity: Double read FPreDealQuantity;
  249. property PreDealTotalPrice: Double read FPreGatherTotalPrice;
  250. property PreQcQuantity: Double read FPreQcQuantity;
  251. property PreQcTotalPrice: Double read FPreQcTotalPrice;
  252. property PreGatherQuantity: Double read FPreGatherQuantity;
  253. property PreGatherTotalPrice: Double read FPreGatherTotalPrice;
  254. property EndDealQuantity: Double read FEndDealQuantity;
  255. property EndDealTotalPrice: Double read FEndDealTotalPrice;
  256. property EndQcQuantity: Double read FEndQcQuantity;
  257. property EndQcTotalPrice: Double read FEndQcTotalPrice;
  258. property EndGatherQuantity: Double read FEndGatherQuantity;
  259. property EndGatherTotalPrice: Double read FEndGatherTotalPrice;
  260. property AddDealQuantity: Double read FAddDealQuantity;
  261. property AddDealTotalPrice: Double read FAddGatherTotalPrice;
  262. property AddQcQuantity: Double read FAddQcQuantity;
  263. property AddQcTotalPrice: Double read FAddQcTotalPrice;
  264. property AddGatherQuantity: Double read FAddGatherQuantity;
  265. property AddGatherTotalPrice: Double read FAddGatherTotalPrice;
  266. property DealQuantity: Double read FDealQuantity;
  267. property DealTotalPrice: Double read FDealTotalPrice;
  268. property BGLQuantity: Double read FBGLQuantity;
  269. property BGLTotalPrice: Double read FBGLTotalPrice;
  270. // ---------- Calculate --------------
  271. property Deal_BGLQuantity: Double read FDeal_BGLQuantity;
  272. property Deal_BGLTotalPrice: Double read FDeal_BGLTotalPrice;
  273. property Deal_BGLPercent: Double read FDeal_BGLPercent;
  274. // -----------------------------------
  275. property DetailGclCount: Integer read GetDetailGclCount;
  276. property DetailGcl[AIndex: Integer]: TDetailGclNode read GetDetailGcl;
  277. property LeafXmjCount: Integer read GetLeafXmjCount;
  278. property LeafXmj[AIndex: Integer]: TLeafXmjNode read GetLeafXmj;
  279. property DetailDealCount: Integer read GetDetailDealCount;
  280. property DetailDeal[AIndex: Integer]: TDetailDealNode read GetDetailDeal;
  281. property DetailBGLCount: Integer read GetDetailBGLCount;
  282. property DetailBGL[AIndex: Integer]: TDetailBGLNode read GetDetailBGL;
  283. property Decimal: TCalcDecimal read FDecimal;
  284. end;
  285. TGclGatherModel = class
  286. private
  287. FProjectData: TObject;
  288. FBillsTree: TBillsIDTree;
  289. FMergeDetailGcl: Boolean;
  290. FGatherDeal: Boolean;
  291. FGatherBGL: Boolean;
  292. FGcls: TList;
  293. FXmjs: TList;
  294. FNewGclID: Integer;
  295. FNewDetailGclID: Integer;
  296. FNewDetailDealID: Integer;
  297. FNewDetailBGLID: Integer;
  298. FWriteGatherData: TGatherDataWriteEvent;
  299. FDecimal: TCalcDecimal;
  300. procedure BeginGather;
  301. procedure EndGather;
  302. function FindLeafXmj(ALeafXmj: TBillsIDTreeNode): TLeafXmjNode;
  303. function NewLeafXmj(ALeafXmj: TBillsIDTreeNode): TLeafXmjNode;
  304. function GetLeafXmj(ANode: TBillsIDTreeNode): TLeafXmjNode;
  305. function FindGclNode(const AB_Code, AName, AUnits: string; APrice: Double): TGclNode;
  306. function NewGclNode(const AB_Code, AName, AUnits: string; APrice: Double): TGclNode;
  307. function GetGclNode(const AB_Code, AName, AUnits: string; APrice: Double): TGclNode; overload;
  308. function GetGclNode(ARec: TBillsRecord): TGclNode; overload;
  309. procedure AddBillsNode(ANode: TMeasureBillsIDTreeNode);
  310. procedure GatherBillsData;
  311. procedure GatherDealData;
  312. procedure GatherBGLData;
  313. procedure CalculateAll;
  314. function GetNewDetailBGLID: Integer;
  315. function GetNewDetailDealID: Integer;
  316. function GetNewDetailGclID: Integer;
  317. public
  318. constructor Create(AProjectData: TObject);
  319. destructor Destroy; override;
  320. procedure Execute;
  321. property GatherDeal: Boolean read FGatherDeal write FGatherDeal;
  322. property GatherBGL: Boolean read FGatherBGL write FGatherBGL;
  323. property NewDetailGclID: Integer read GetNewDetailGclID;
  324. property NewDetailDealID: Integer read GetNewDetailDealID;
  325. property NewDetailBGLID: Integer read GetNewDetailBGLID;
  326. // 在使用汇总模型的数据单元创建数据库写入方法,并赋值,否则汇总数据不写入
  327. property WriteGatherData: TGatherDataWriteEvent read FWriteGatherData write FWriteGatherData;
  328. property Decimal: TCalcDecimal read FDecimal;
  329. end;
  330. implementation
  331. uses
  332. ZhAPI, SysUtils, ProjectData, UtilMethods, sdDB, sdIDTree, BGLDm, DB,
  333. Math;
  334. { TGclGatherModel }
  335. procedure TGclGatherModel.AddBillsNode(ANode: TMeasureBillsIDTreeNode);
  336. var
  337. vGclNode: TGclNode;
  338. vDetailGclNode: TDetailGclNode;
  339. vLeafXmj: TLeafXmjNode;
  340. begin
  341. vGclNode := GetGclNode(ANode.Rec);
  342. vDetailGclNode := vGclNode.AddDetailGcl(NewDetailGclID);
  343. vDetailGclNode.BillsID := ANode.ID;
  344. vDetailGclNode.TreeSerialNo := ANode.MajorIndex;
  345. vDetailGclNode.OrgQuantity := ANode.Rec.OrgQuantity.AsFloat;
  346. vDetailGclNode.OrgTotalPrice := ANode.Rec.OrgTotalPrice.AsFloat;
  347. vDetailGclNode.MisQuantity := ANode.Rec.MisQuantity.AsFloat;
  348. vDetailGclNode.MisTotalPrice := ANode.Rec.MisTotalPrice.AsFloat;
  349. vDetailGclNode.OthQuantity := ANode.Rec.OthQuantity.AsFloat;
  350. vDetailGclNode.OthTotalPrice := ANode.Rec.OthTotalPrice.AsFloat;
  351. vDetailGclNode.Quantity := ANode.Rec.Quantity.AsFloat;
  352. vDetailGclNode.TotalPrice := ANode.Rec.TotalPrice.AsFloat;
  353. if Assigned(ANode.StageRec) then
  354. begin
  355. vDetailGclNode.CurDealQuantity := ANode.StageRec.DealQuantity.AsFloat;
  356. vDetailGclNode.CurDealTotalPrice := ANode.StageRec.DealTotalPrice.AsFloat;
  357. vDetailGclNode.CurQcQuantity := ANode.StageRec.QcQuantity.AsFloat;
  358. vDetailGclNode.CurQcTotalPrice := ANode.StageRec.QcTotalPrice.AsFloat;
  359. vDetailGclNode.CurGatherQuantity := ANode.StageRec.GatherQuantity.AsFloat;
  360. vDetailGclNode.CurGatherTotalPrice := ANode.StageRec.GatherTotalPrice.AsFloat;
  361. vDetailGclNode.PreDealQuantity := ANode.StageRec.PreDealQuantity.AsFloat;
  362. vDetailGclNode.PreDealTotalPrice := ANode.StageRec.PreDealTotalPrice.AsFloat;
  363. vDetailGclNode.PreQcQuantity := ANode.StageRec.PreQcQuantity.AsFloat;
  364. vDetailGclNode.PreQcTotalPrice := ANode.StageRec.PreQcTotalPrice.AsFloat;
  365. vDetailGclNode.PreGatherQuantity := ANode.StageRec.PreGatherQuantity.AsFloat;
  366. vDetailGclNode.PreGatherTotalPrice := ANode.StageRec.PreGatherTotalPrice.AsFloat;
  367. vDetailGclNode.EndDealQuantity := ANode.StageRec.EndDealQuantity.AsFloat;
  368. vDetailGclNode.EndDealTotalPrice := ANode.StageRec.EndDealTotalPrice.AsFloat;
  369. vDetailGclNode.EndQcQuantity := ANode.StageRec.EndQcQuantity.AsFloat;
  370. vDetailGclNode.EndQcTotalPrice := ANode.StageRec.EndQcTotalPrice.AsFloat;
  371. vDetailGclNode.EndGatherQuantity := ANode.StageRec.EndGatherQuantity.AsFloat;
  372. vDetailGclNode.EndGatherTotalPrice := ANode.StageRec.EndGatherTotalPrice.AsFloat;
  373. vDetailGclNode.PM_PreTotalPrice := ANode.StageRec.PM_PreTotalPrice.AsFloat;
  374. vDetailGclNode.PM_TotalPrice := ANode.StageRec.PM_TotalPrice.AsFloat;
  375. end;
  376. vDetailGclNode.AddDealQuantity := ANode.Rec.AddDealQuantity.AsFloat;
  377. vDetailGclNode.AddDealTotalPrice := ANode.Rec.AddDealTotalPrice.AsFloat;
  378. vDetailGclNode.AddQcQuantity := ANode.Rec.AddQcQuantity.AsFloat;
  379. vDetailGclNode.AddQcTotalPrice := ANode.Rec.AddQcTotalPrice.AsFloat;
  380. vDetailGclNode.AddGatherQuantity := ANode.Rec.AddGatherQuantity.AsFloat;
  381. vDetailGclNode.AddGatherTotalPrice := ANode.Rec.AddGatherTotalPrice.AsFloat;
  382. vDetailGclNode.LeafXmj := GetLeafXmj(ANode);
  383. vGclNode.AddLeafXmj(vDetailGclNode.LeafXmj);
  384. end;
  385. procedure TGclGatherModel.BeginGather;
  386. begin
  387. FGcls := TList.Create;
  388. FXmjs := TList.Create;
  389. end;
  390. procedure TGclGatherModel.CalculateAll;
  391. var
  392. iGcl: Integer;
  393. begin
  394. for iGcl := 0 to FGcls.Count - 1 do
  395. TGclNode(FGcls.Items[iGcl]).Calculate;
  396. end;
  397. constructor TGclGatherModel.Create(AProjectData: TObject);
  398. begin
  399. FProjectData := AProjectData;
  400. FBillsTree := TProjectData(FProjectData).BillsMeasureData.BillsMeasureTree;
  401. FGatherDeal := False;
  402. FGatherBGL := False;
  403. FDecimal := TProjectData(FProjectData).ProjProperties.DecimalManager.Common;
  404. end;
  405. destructor TGclGatherModel.Destroy;
  406. begin
  407. inherited;
  408. end;
  409. procedure TGclGatherModel.EndGather;
  410. begin
  411. ClearObjects(FXmjs);
  412. FXmjs.Free;
  413. ClearObjects(FGcls);
  414. FGcls.Free;
  415. end;
  416. procedure TGclGatherModel.Execute;
  417. begin
  418. BeginGather;
  419. try
  420. GatherBillsData;
  421. GatherDealData;
  422. GatherBGLData;
  423. CalculateAll;
  424. if Assigned(FWriteGatherData) then
  425. FWriteGatherData(FGcls, FXmjs);
  426. finally
  427. EndGather;
  428. end;
  429. end;
  430. function TGclGatherModel.FindGclNode(const AB_Code, AName, AUnits: string;
  431. APrice: Double): TGclNode;
  432. var
  433. i: Integer;
  434. vGcl: TGclNode;
  435. begin
  436. Result := nil;
  437. for i := 0 to FGcls.Count - 1 do
  438. begin
  439. vGcl := TGclNode(FGcls.Items[i]);
  440. if SameText(vGcl.B_Code, TrimRight(AB_Code)) and
  441. SameText(vGcl.Name, TrimRight(AName)) and
  442. SameText(vGcl.Units, TrimRight(AUnits)) and
  443. (abs(vGcl.Price - APrice) < 0.001) then
  444. begin
  445. Result := vGcl;
  446. Break;
  447. end;
  448. end;
  449. end;
  450. function TGclGatherModel.FindLeafXmj(
  451. ALeafXmj: TBillsIDTreeNode): TLeafXmjNode;
  452. var
  453. iXmj: Integer;
  454. vLeafXmj: TLeafXmjNode;
  455. begin
  456. Result := nil;
  457. for iXmj := 0 to FXmjs.Count - 1 do
  458. begin
  459. vLeafXmj := TLeafXmjNode(FXmjs.Items[iXmj]);
  460. if vLeafXmj.ID = ALeafXmj.ID then
  461. begin
  462. Result := vLeafXmj;
  463. Break;
  464. end;
  465. end;
  466. end;
  467. procedure TGclGatherModel.GatherBGLData;
  468. var
  469. vGclNode: TGclNode;
  470. DetailBGL: TDetailBGLNode;
  471. begin
  472. if not FGatherBGL then Exit;
  473. with TProjectData(FProjectData).BGLData do
  474. begin
  475. cdsBGBills.First;
  476. while not cdsBGBills.Eof do
  477. begin
  478. vGclNode := GetGclNode(cdsBGBillsB_Code.AsString, cdsBGBillsName.AsString,
  479. cdsBGBillsUnits.AsString, cdsBGBillsPrice.AsFloat);
  480. if cdsBGL.FindKey([cdsBGBillsBGID.AsInteger]) then
  481. begin
  482. DetailBGL := vGclNode.AddDetailBGL(NewDetailBGLID);
  483. DetailBGL.BGBillsID := cdsBGBillsID.AsInteger;
  484. DetailBGL.BGLCode := cdsBGLCode.AsString;
  485. DetailBGL.BGLName := cdsBGLName.AsString;
  486. DetailBGL.BGLApprovalCode := cdsBGLApprovalCode.AsString;
  487. DetailBGL.BGLDrawingCode := cdsBGLDrawingCode.AsString;
  488. DetailBGL.BGLID := cdsBGBillsBGID.AsInteger;
  489. DetailBGL.Quantity := cdsBGBillsQuantity.AsFloat;
  490. DetailBGL.TotalPrice := cdsBGBillsTotalPrice.AsFloat;
  491. end;
  492. cdsBGBills.Next;
  493. end;
  494. end;
  495. end;
  496. procedure TGclGatherModel.GatherBillsData;
  497. var
  498. i: Integer;
  499. vNode: TMeasureBillsIDTreeNode;
  500. begin
  501. for i := 0 to FBillsTree.Count - 1 do
  502. begin
  503. vNode := TMeasureBillsIDTreeNode(FBillsTree.Items[i]);
  504. if not vNode.HasChildren and (vNode.Rec.B_Code.AsString <> '') then
  505. AddBillsNode(vNode);
  506. end;
  507. end;
  508. procedure TGclGatherModel.GatherDealData;
  509. var
  510. vGclNode: TGclNode;
  511. vDetailDeal: TDetailDealNode;
  512. iDeal: Integer;
  513. Rec: TsdDataRecord;
  514. begin
  515. if not FGatherDeal then Exit;
  516. with TProjectData(FProjectData).DealBillsData do
  517. for iDeal := 0 to sddDealBills.RecordCount - 1 do
  518. begin
  519. Rec := sddDealBills.Records[iDeal];
  520. vGclNode := GetGclNode(Rec.ValueByName('B_Code').AsString, Rec.ValueByName('Name').AsString,
  521. Rec.ValueByName('Units').AsString, Rec.ValueByName('Price').AsFloat);
  522. vDetailDeal := vGclNode.AddDetailDeal(NewDetailDealID);
  523. vDetailDeal.Quantity := Rec.ValueByName('Quantity').AsFloat;
  524. vDetailDeal.TotalPrice := Rec.ValueByName('TotalPrice').AsFloat;
  525. end;
  526. end;
  527. function TGclGatherModel.GetGclNode(ARec: TBillsRecord): TGclNode;
  528. begin
  529. Result := GetGclNode(ARec.B_Code.AsString, ARec.Name.AsString,
  530. ARec.Units.AsString, ARec.Price.AsFloat);
  531. end;
  532. function TGclGatherModel.GetGclNode(const AB_Code, AName, AUnits: string;
  533. APrice: Double): TGclNode;
  534. begin
  535. Result := FindGclNode(AB_Code, AName, AUnits, APrice);
  536. if not Assigned(Result) then
  537. Result := NewGclNode(AB_Code, AName, AUnits, APrice);
  538. end;
  539. function TGclGatherModel.GetLeafXmj(
  540. ANode: TBillsIDTreeNode): TLeafXmjNode;
  541. function GetFirstXmjParent: TBillsIDTreeNode;
  542. begin
  543. Result := ANode;
  544. while Assigned(Result) and (Result.Rec.B_Code.AsString <> '') do
  545. Result := TBillsIDTreeNode(Result.Parent);
  546. end;
  547. var
  548. vFirstXmjParent: TBillsIDTreeNode;
  549. begin
  550. vFirstXmjParent := GetFirstXmjParent;
  551. Result := nil;
  552. if not Assigned(vFirstXmjParent) then Exit;
  553. Result := FindLeafXmj(vFirstXmjParent);
  554. if not Assigned(Result) then
  555. Result := NewLeafXmj(vFirstXmjParent);
  556. end;
  557. function TGclGatherModel.GetNewDetailBGLID: Integer;
  558. begin
  559. Result := FNewDetailBGLID;
  560. Inc(FNewDetailBGLID)
  561. end;
  562. function TGclGatherModel.GetNewDetailDealID: Integer;
  563. begin
  564. Result := FNewDetailDealID;
  565. Inc(FNewDetailDealID);
  566. end;
  567. function TGclGatherModel.GetNewDetailGclID: Integer;
  568. begin
  569. Result := FNewDetailGclID;
  570. Inc(FNewDetailGclID);
  571. end;
  572. function TGclGatherModel.NewGclNode(const AB_Code, AName, AUnits: string;
  573. APrice: Double): TGclNode;
  574. begin
  575. Result := TGclNode.Create(FNewGclID, FDecimal);
  576. FGcls.Add(Result);
  577. Result.B_Code := TrimRight(AB_Code);
  578. Result.Name := TrimRight(AName);
  579. Result.Units := TrimRight(AUnits);
  580. Result.Price := APrice;
  581. Inc(FNewGclID);
  582. end;
  583. function TGclGatherModel.NewLeafXmj(
  584. ALeafXmj: TBillsIDTreeNode): TLeafXmjNode;
  585. function GetPegNode(ANode: TBillsIDTreeNode): TBillsIDTreeNode;
  586. begin
  587. Result := nil;
  588. if not Assigned(ANode) then Exit;
  589. if CheckPeg(ANode.Rec.Name.AsString) then
  590. Result := ANode
  591. else
  592. Result := GetPegNode(TBillsIDTreeNode(ANode.Parent));
  593. end;
  594. var
  595. vPeg: TBillsIDTreeNode;
  596. begin
  597. vPeg := GetPegNode(ALeafXmj);
  598. Result := TLeafXmjNode.Create(ALeafXmj, vPeg);
  599. FXmjs.Add(Result);
  600. end;
  601. { TGclNode }
  602. function TGclNode.AddDetailBGL(AID: Integer): TDetailBGLNode;
  603. begin
  604. Result := TDetailBGLNode.Create(AID);
  605. FDetailBGLs.Add(Result);
  606. end;
  607. function TGclNode.AddDetailDeal(AID: Integer): TDetailDealNode;
  608. begin
  609. Result := TDetailDealNode.Create(AID);
  610. FDetailDeals.Add(Result);
  611. end;
  612. function TGclNode.AddDetailGcl(AID: Integer): TDetailGclNode;
  613. begin
  614. Result := TDetailGclNode.Create(AID);
  615. FDetailGcls.Add(Result);
  616. end;
  617. procedure TGclNode.AddLeafXmj(ALeafXmj: TLeafXmjNode);
  618. begin
  619. if FLeafXmjs.IndexOf(ALeafXmj) = -1 then
  620. FLeafXmjs.Add(ALeafXmj);
  621. end;
  622. procedure TGclNode.Calculate;
  623. begin
  624. InitCalculate;
  625. GatherDetailGcl;
  626. GatherDetailDeal;
  627. GatherDetailBGL;
  628. CalculateOther;
  629. end;
  630. procedure TGclNode.CalculateOther;
  631. begin
  632. FDeal_BGLQuantity := Decimal.Quantity.RoundTo(FQuantity + FBGLQuantity);
  633. FDeal_BGLTotalPrice := Decimal.TotalPrice.RoundTo(FTotalPrice + FBGLTotalPrice);
  634. if FDeal_BGLTotalPrice <> 0 then
  635. FDeal_BGLPercent := CommonRoundTo(FEndGatherTotalPrice/FDeal_BGLTotalPrice*100, -2)
  636. else
  637. FDeal_BGLPercent := 0;
  638. end;
  639. constructor TGclNode.Create(AID: Integer; ADecimal: TCalcDecimal);
  640. begin
  641. FID := AID;
  642. FDetailGcls := TList.Create;
  643. FDetailDeals := TList.Create;
  644. FDetailBGLs := TList.Create;
  645. FLeafXmjs := TList.Create;
  646. FDecimal := ADecimal;
  647. end;
  648. destructor TGclNode.Destroy;
  649. begin
  650. FLeafXmjs.Free;
  651. ClearObjects(FDetailBGLs);
  652. FDetailBGLs.Free;
  653. ClearObjects(FDetailDeals);
  654. FDetailDeals.Free;
  655. ClearObjects(FDetailGcls);
  656. FDetailGcls.Free;
  657. inherited;
  658. end;
  659. procedure TGclNode.GatherDetailBGL;
  660. var
  661. iBGL: Integer;
  662. vDetailBGL: TDetailBGLNode;
  663. begin
  664. for iBGL := 0 to DetailBGLCount - 1 do
  665. begin
  666. vDetailBGL := DetailBGL[iBGL];
  667. FBGLQuantity := FBGLQuantity + vDetailBGL.Quantity;
  668. FBGLTotalPrice := FBGLTotalPrice + vDetailBGL.TotalPrice;
  669. end;
  670. end;
  671. procedure TGclNode.GatherDetailDeal;
  672. var
  673. iDeal: Integer;
  674. vDetailDeal: TDetailDealNode;
  675. begin
  676. for iDeal := 0 to DetailDealCount - 1 do
  677. begin
  678. vDetailDeal := DetailDeal[iDeal];
  679. FDealQuantity := FDealQuantity + vDetailDeal.Quantity;
  680. FDealTotalPrice := FDealTotalPrice + vDetailDeal.TotalPrice;
  681. end;
  682. end;
  683. procedure TGclNode.GatherDetailGcl;
  684. var
  685. iGcl: Integer;
  686. vDetailGcl: TDetailGclNode;
  687. begin
  688. for iGcl := 0 to DetailGclCount - 1 do
  689. begin
  690. vDetailGcl := DetailGcl[iGcl];
  691. FOrgQuantity := FOrgQuantity + vDetailGcl.OrgQuantity;
  692. FOrgTotalPrice := FOrgTotalPrice + vDetailGcl.OrgTotalPrice;
  693. FMisQuantity := FMisQuantity + vDetailGcl.MisQuantity;
  694. FMisTotalPrice := FMisTotalPrice + vDetailGcl.MisTotalPrice;
  695. FOthQuantity := FOthQuantity + vDetailGcl.OthQuantity;
  696. FOthTotalPrice := FOthTotalPrice + vDetailGcl.OthTotalPrice;
  697. FQuantity := FQuantity + vDetailGcl.Quantity;
  698. FTotalPrice := FTotalPrice + vDetailGcl.TotalPrice;
  699. FCurDealQuantity := FCurDealQuantity + vDetailGcl.CurDealQuantity;
  700. FCurDealTotalPrice := FCurDealTotalPrice + vDetailGcl.CurDealTotalPrice;
  701. FCurQcQuantity := FCurQcQuantity + vDetailGcl.CurQcQuantity;
  702. FCurQcTotalPrice := FCurQcTotalPrice + vDetailGcl.CurQcTotalPrice;
  703. FCurGatherQuantity := FCurGatherQuantity + vDetailGcl.CurGatherQuantity;
  704. FCurGatherTotalPrice := FCurGatherTotalPrice + vDetailGcl.CurGatherTotalPrice;
  705. FPreDealQuantity := FPreDealQuantity + vDetailGcl.PreDealQuantity;
  706. FPreDealTotalPrice := FPreDealTotalPrice + vDetailGcl.PreDealTotalPrice;
  707. FPreQcQuantity := FPreQcQuantity + vDetailGcl.PreQcQuantity;
  708. FPreQcTotalPrice := FPreQcTotalPrice + vDetailGcl.PreQcTotalPrice;
  709. FPreGatherQuantity := FPreGatherQuantity + vDetailGcl.PreGatherQuantity;
  710. FPreGatherTotalPrice := FPreGatherTotalPrice + vDetailGcl.PreGatherTotalPrice;
  711. FEndDealQuantity := FEndDealQuantity + vDetailGcl.EndDealQuantity;
  712. FEndDealTotalPrice := FEndDealTotalPrice + vDetailGcl.EndDealTotalPrice;
  713. FEndQcQuantity := FEndQcQuantity + vDetailGcl.EndQcQuantity;
  714. FEndQcTotalPrice := FEndQcTotalPrice + vDetailGcl.EndQcTotalPrice;
  715. FEndGatherQuantity := FEndGatherQuantity + vDetailGcl.EndGatherQuantity;
  716. FEndGatherTotalPrice := FEndGatherTotalPrice + vDetailGcl.EndGatherTotalPrice;
  717. FAddDealQuantity := FAddDealQuantity + vDetailGcl.AddDealQuantity;
  718. FAddDealTotalPrice := FAddDealTotalPrice + vDetailGcl.AddDealTotalPrice;
  719. FAddQcQuantity := FAddQcQuantity + vDetailGcl.AddQcQuantity;
  720. FAddQcTotalPrice := FAddQcTotalPrice + vDetailGcl.AddQcTotalPrice;
  721. FAddGatherQuantity := FAddGatherQuantity + vDetailGcl.AddGatherQuantity;
  722. FAddGatherTotalPrice := FAddGatherTotalPrice + vDetailGcl.AddGatherTotalPrice;
  723. end;
  724. end;
  725. function TGclNode.GetDetailBGL(AIndex: Integer): TDetailBGLNode;
  726. begin
  727. Result := TDetailBGLNode(FDetailBGLs.Items[AIndex]);
  728. end;
  729. function TGclNode.GetDetailBGLCount: Integer;
  730. begin
  731. Result := FDetailBGLs.Count;
  732. end;
  733. function TGclNode.GetDetailDeal(AIndex: Integer): TDetailDealNode;
  734. begin
  735. Result := TDetailDealNode(FDetailDeals.Items[AIndex]);
  736. end;
  737. function TGclNode.GetDetailDealCount: Integer;
  738. begin
  739. Result := FDetailDeals.Count;
  740. end;
  741. function TGclNode.GetDetailGcl(AIndex: Integer): TDetailGclNode;
  742. begin
  743. Result := TDetailGclNode(FDetailGcls.Items[AIndex]);
  744. end;
  745. function TGclNode.GetDetailGclCount: Integer;
  746. begin
  747. Result := FDetailGcls.Count;
  748. end;
  749. function TGclNode.GetLeafXmj(AIndex: Integer): TLeafXmjNode;
  750. begin
  751. Result := TLeafXmjNode(FLeafXmjs.Items[AIndex]);
  752. end;
  753. function TGclNode.GetLeafXmjCount: Integer;
  754. begin
  755. Result := FLeafXmjs.Count;
  756. end;
  757. procedure TGclNode.InitCalculate;
  758. begin
  759. FOrgQuantity := 0;
  760. FOrgTotalPrice := 0;
  761. FMisQuantity := 0;
  762. FMisTotalPrice := 0;
  763. FOthQuantity := 0;
  764. FOthTotalPrice := 0;
  765. FQuantity := 0;
  766. FTotalPrice := 0;
  767. FCurDealQuantity := 0;
  768. FCurDealTotalPrice := 0;
  769. FCurQcQuantity := 0;
  770. FCurQcTotalPrice := 0;
  771. FCurGatherQuantity := 0;
  772. FCurGatherTotalPrice := 0;
  773. FPreDealQuantity := 0;
  774. FPreDealTotalPrice := 0;
  775. FPreQcQuantity := 0;
  776. FPreQcTotalPrice := 0;
  777. FPreGatherQuantity := 0;
  778. FPreGatherTotalPrice := 0;
  779. FEndDealQuantity := 0;
  780. FEndDealTotalPrice := 0;
  781. FEndQcQuantity := 0;
  782. FEndQcTotalPrice := 0;
  783. FEndGatherQuantity := 0;
  784. FEndGatherTotalPrice := 0;
  785. FAddDealQuantity := 0;
  786. FAddDealTotalPrice := 0;
  787. FAddQcQuantity := 0;
  788. FAddQcTotalPrice := 0;
  789. FAddGatherQuantity := 0;
  790. FAddGatherTotalPrice := 0;
  791. FDealQuantity := 0;
  792. FDealTotalPrice := 0;
  793. FBGLQuantity := 0;
  794. FBGLTotalPrice := 0;
  795. FDeal_BGLQuantity := 0;
  796. FDeal_BGLTotalPrice := 0;
  797. FDeal_BGLPercent := 0;
  798. end;
  799. procedure TGclNode.SetB_Code(const Value: string);
  800. begin
  801. FB_Code := Value;
  802. FIndexCode := B_CodeToIndexCode(FB_Code);
  803. end;
  804. { TDetailGclNode }
  805. constructor TDetailGclNode.Create(AID: Integer);
  806. begin
  807. FID := AID;
  808. end;
  809. function TDetailGclNode.GetPercent: Double;
  810. var
  811. fTotal: Double;
  812. begin
  813. fTotal := abs(FQuantity + FEndQcQuantity);
  814. if fTotal <> 0 then
  815. Result := CommonRoundTo(abs(FEndGatherQuantity) / fTotal * 100, -2)
  816. else
  817. Result := 0;
  818. end;
  819. { TDetailBGLNode }
  820. constructor TDetailBGLNode.Create(AID: Integer);
  821. begin
  822. FID := AID;
  823. end;
  824. { TDetailDealNode }
  825. constructor TDetailDealNode.Create(AID: Integer);
  826. begin
  827. FID := AID;
  828. end;
  829. { TLeafXmjNode }
  830. constructor TLeafXmjNode.Create(ALeafXmj, APeg: TBillsIDTreeNode);
  831. function GetPegName: string;
  832. begin
  833. if Assigned(APeg) then
  834. Result := APeg.Rec.Name.AsString
  835. else
  836. Result := '';
  837. end;
  838. // 取树结构的第ALevel层节点的名称(level从0开始)
  839. function GetNameByLevel(ANode: TBillsIDTreeNode; ALevel: Integer): string;
  840. begin
  841. Result := '';
  842. if not Assigned(ANode) then Exit;
  843. if ANode.Level = ALevel then
  844. Result := ANode.Rec.Name.AsString
  845. else if ANode.Level > ALevel then
  846. Result := GetNameByLevel(TBillsIDTreeNode(ANode.Parent), ALevel);
  847. end;
  848. function GetNameDanWei(ANode: TBillsIDTreeNode): string;
  849. begin
  850. // 取树结构的第二层节点的名称
  851. Result := GetNameByLevel(ANode, 1);
  852. end;
  853. // ANode为计量单元节点,APegNode为桩号节点
  854. function GetNameFenBu(ANode, APegNode: TBillsIDTreeNode): string;
  855. var
  856. vCurNode: TBillsIDTreeNode;
  857. begin
  858. // 如果计量单元节点的名称为桩号(转化为判断计量单元节点与桩号节点为同一个)
  859. if not Assigned(APegNode) or (ANode.ID = APegNode.ID) then
  860. // 取树结构的第三层节点的名称
  861. Result := GetNameByLevel(ANode, 2)
  862. // 否则,取桩号节点的子节点的名称
  863. else
  864. begin
  865. vCurNode := ANode;
  866. while vCurNode.Level > APegNode.Level + 1 do
  867. vCurNode := TBillsIDTreeNode(vCurNode.Parent);
  868. Result := vCurNode.Rec.Name.AsString;
  869. end;
  870. end;
  871. // ANode为计量单元节点,APegNode为桩号节点
  872. function GetNameFenXiang(ANode, APegNode: TBillsIDTreeNode): string;
  873. var
  874. iTopLevel: Integer;
  875. vCurNode: TBillsIDTreeNode;
  876. begin
  877. if Assigned(APegNode) then
  878. begin
  879. iTopLevel := 3;
  880. if APegNode.ID <> ANode.ID then
  881. iTopLevel := APegNode.Level + 2;
  882. Result := '';
  883. vCurNode := TBillsIDTreeNode(ANode.Parent);
  884. while vCurNode.Level >= iTopLevel do
  885. begin
  886. Result := vCurNode.Rec.Name.AsString + ';' + Result;
  887. vCurNode := TBillsIDTreeNode(vCurNode.Parent);
  888. end;
  889. end
  890. else
  891. Result := GetNameByLevel(ANode, 3);
  892. end;
  893. function GetNameUnit(ANode: TBillsIDTreeNode): string;
  894. begin
  895. Result := ANode.Rec.Name.AsString;
  896. end;
  897. function GetDrawingCode(ANode: TBillsIDTreeNode): string;
  898. begin
  899. Result := '';
  900. if not Assigned(ANode) then Exit;
  901. Result := ANode.Rec.DrawingCode.AsString;
  902. if Result = '' then
  903. Result := GetDrawingCode(TBillsIDTreeNode(ANode.Parent));
  904. end;
  905. function GetPosition(ANode, APegNode: TBillsIDTreeNode): string;
  906. begin
  907. // 如果计量单元节点的名称为桩号(转化为判断计量单元节点与桩号节点为同一个)
  908. if not Assigned(APegNode) or (ANode.ID = APegNode.ID) then
  909. // 取分部工程
  910. Result := GetNameFenXiang(ANode, APegNode)
  911. // 反之,取分项工程+计量单元
  912. else
  913. Result := GetNameFenXiang(ANode, APegNode) + GetNameUnit(ANode);
  914. end;
  915. begin
  916. if not Assigned(ALeafXmj) then Exit;
  917. FID := ALeafXmj.ID;
  918. FXmjCode := ALeafXmj.Rec.Code.AsString;
  919. FXmjName := ALeafXmj.Rec.Name.AsString;
  920. FXmjUnits := ALeafXmj.Rec.Units.AsString;
  921. FPeg := GetPegName;
  922. FNameDanWei := GetNameDanWei(ALeafXmj);
  923. FNameFenBu := GetNameFenBu(ALeafXmj, APeg);
  924. FNameFenXiang := GetNameFenXiang(ALeafXmj, APeg);
  925. FNameUnit := GetNameUnit(ALeafXmj);
  926. FPosition := GetPosition(ALeafXmj, APeg);
  927. FDrawingCode := GetDrawingCode(ALeafXmj);
  928. end;
  929. end.