rmBillsGatherDm.pas 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319
  1. unit rmBillsGatherDm;
  2. interface
  3. uses
  4. SysUtils, Classes, DB, DBClient, MCacheTree, ProjectData,
  5. sdDB, sdIDTree, rmCacheData, rmSelectProjectFrm;
  6. type
  7. {---------------------------------
  8. bgtFx: 分项汇总模式,按树结构汇总所选项目,汇总后结果写入cdsFxBills
  9. bgtXmj: 项目节汇总模式,按树结构汇总所选项目的项目节节点,汇总后结果写入cdsFxBills
  10. bgtGcl: 工程量清单汇总模式,汇总后结果写入cdsGclBills
  11. bgtMultiXmj: bgtXmj模式的扩展,汇总展示多项目数据模式,与bgtXmj的差异在于记录了每个项目的数据,而不是单纯累加
  12. 汇总结果写入cdsProjectBills
  13. bgtEstimate: 决算02表,bgtXmj模式的扩展,
  14. 分别汇总前两个项目的0号台账为初步设计、施工图设计,其后为所有项目按bgtXmj方式汇总。
  15. 汇总结果写入cdsEstimateBills
  16. bgtEstimate1: 决算02表(部颁格式),bgtXmj模式的扩展,
  17. 汇总第一个项目的0号台账为批准的概(预)算,其后为所有项目按bgtXmj方式汇总。汇总结果写入cdsEstimateBills
  18. bgtFinal07: 决算07表,bgtGcl模式的扩展,汇总暂时多项目数据及合计数据模式
  19. 与bgtGcl的差异在于,记录了每个项目的数据,且汇总了某些固定id节点的数据在最后。汇总结果写入cdsProjectGclBills
  20. bgtFinal08: 决算08表,bgtXmj的特殊情况,仅汇总第二部分下的所有项目节节点,而非全部项目节。汇总结果写入cdsFxBills
  21. bgtFinal09: 决算09表,bgtXmj的特殊情况,汇总第三部分及气候所有项目节节点,而非全部项目节。汇总结果写入cdsFxBills
  22. bgtFinal11: 决算11表,与bgtFinal07极度相似,仅汇总固定id节点的数据处不同。汇总结果写入cdsProjectGclBills
  23. bgtFinal12: 决算12表,流水式写入每个项目的变更令数据。汇总结果写入cdsBGLFlow
  24. bgtFinal16: 决算16表,bgtMultiXmj的基础上增加了工程量清单数据,且仅汇总计日工部分(固定id40)。汇总结果写入cdsProjectBills
  25. bgtFinal17: 决算17表,bgtFx的特殊情况,仅汇总收尾工程部分(固定id47),汇总结果写入cdsFxBills
  26. bgtFinal18: 决算18表,bgtFx的特殊情况,仅汇总报废工程部分(固定id48),汇总结果吸入cdsFxBills
  27. bgtFinal19: 决算19表,bgtFinal07和bgtFinal11中去除后面的固定id节点数据,汇总结果写入cdsProjectGclBills
  28. bgtG_Final06_1: 粤竣06-1表,bgtEstimate的特殊情况,仅汇总土地(固定id21),且汇总初步设计、施工图设计
  29. 可理解为bgtEstimate扩展为Fx,然后再限制为汇总固定id下的数据,汇总后的结果写入cdsEstimateBills
  30. bgtG_Final04: 粤竣04表,在bgtXmj的基础上增加了设计数量、经济指标等数据,且增加了一行公路基本造价汇总行
  31. ----------------------------------}
  32. TbgType = (bgtFx, bgtXmj, bgtGcl, bgtMultiXmj, bgtEstimate,
  33. bgtEstimate1, bgtFinal07, bgtFinal08, bgtFinal09, bgtFinal11,
  34. bgtFinal12, bgtFinal16, bgtFinal17, bgtFinal18, bgtFinal19,
  35. bgtG_Final06_1, bgtG_Final04);
  36. TrmBillsGatherData = class(TDataModule)
  37. // 决算04, 05[竣04]
  38. cdsFxBills: TClientDataSet;
  39. cdsFxBillsXiangCode: TStringField;
  40. cdsFxBillsMuCode: TStringField;
  41. cdsFxBillsJieCode: TStringField;
  42. cdsFxBillsXiMuCode: TStringField;
  43. cdsFxBillsCode: TStringField;
  44. cdsFxBillsB_Code: TStringField;
  45. cdsFxBillsName: TWideStringField;
  46. cdsFxBillsUnits: TWideStringField;
  47. cdsFxBillsAddDealQuantity: TFloatField;
  48. cdsFxBillsAddDealTotalPrice: TFloatField;
  49. cdsFxBillsAddQcQuantity: TFloatField;
  50. cdsFxBillsAddPcQuantity: TFloatField;
  51. cdsFxBillsAddQcTotalPrice: TFloatField;
  52. cdsFxBillsAddPcTotalPrice: TFloatField;
  53. cdsFxBillsPrice: TFloatField;
  54. cdsFxBillsAddGatherQuantity: TFloatField;
  55. cdsFxBillsAddGatherTotalPrice: TFloatField;
  56. cdsFxBillsMemoStr: TWideStringField;
  57. cdsFxBillsPercent: TFloatField;
  58. cdsFxBillsQuantity: TFloatField;
  59. cdsFxBillsTotalPrice: TFloatField;
  60. cdsFxBillsDgnQuantity1: TFloatField;
  61. cdsFxBillsDgnQuantity2: TFloatField;
  62. cdsFxBillsDgnQuantity: TStringField;
  63. cdsFxBillsDgnPrice1: TFloatField;
  64. cdsFxBillsDgnPrice2: TFloatField;
  65. cdsFxBillsDgnPrice: TStringField;
  66. cdsFxBillsRatioPercent: TFloatField;
  67. cdsFxBillsAddRatioPercent: TFloatField;
  68. // 决算05-2
  69. cdsGclBills: TClientDataSet;
  70. cdsGclBillsB_Code: TStringField;
  71. cdsGclBillsIndexCode: TStringField;
  72. cdsGclBillsName: TWideStringField;
  73. cdsGclBillsUnits: TWideStringField;
  74. cdsGclBillsPrice: TFloatField;
  75. cdsGclBillsAddDealQuantity: TFloatField;
  76. cdsGclBillsAddDealTotalPrice: TFloatField;
  77. cdsGclBillsAddQcQuantity: TFloatField;
  78. cdsGclBillsAddQcTotalPrice: TFloatField;
  79. cdsGclBillsAddPcQuantity: TFloatField;
  80. cdsGclBillsAddPcTotalPrice: TFloatField;
  81. cdsGclBillsAddGatherQuantity: TFloatField;
  82. cdsGclBillsAddGatherTotalPrice: TFloatField;
  83. cdsGclBillsPrecent: TFloatField;
  84. cdsGclBillsMemoStr: TWideStringField;
  85. // 决算04-1, 决算部颁12
  86. cdsProjectBills: TClientDataSet;
  87. cdsProjectBillsXiangCode: TStringField;
  88. cdsProjectBillsMuCode: TStringField;
  89. cdsProjectBillsJieCode: TStringField;
  90. cdsProjectBillsXiMuCode: TStringField;
  91. cdsProjectBillsCode: TStringField;
  92. cdsProjectBillsName: TWideStringField;
  93. cdsProjectBillsUnits: TWideStringField;
  94. cdsProjectBillsQuantity: TFloatField;
  95. cdsProjectBillsProjectID: TIntegerField;
  96. cdsProjectBillsTotalPrice: TFloatField;
  97. cdsProjectBillsP_Quantity: TFloatField;
  98. cdsProjectBillsP_TotalPrice: TFloatField;
  99. cdsProjectBillsEcoIndex: TFloatField;
  100. cdsProjectBillsPercent: TFloatField;
  101. cdsProjectBillsMemoStr: TWideStringField;
  102. cdsProjectBillsProjectName: TWideStringField;
  103. cdsProjectBillsSerialNo: TIntegerField;
  104. cdsProjectBillsB_Code: TStringField;
  105. cdsProjectBillsP_Price: TFloatField;
  106. // 决算02
  107. cdsEstimateBills: TClientDataSet;
  108. cdsEstimateBillsXiangCode: TStringField;
  109. cdsEstimateBillsMuCode: TStringField;
  110. cdsEstimateBillsJieCode: TStringField;
  111. cdsEstimateBillsXiMuCode: TStringField;
  112. cdsEstimateBillsCode: TStringField;
  113. cdsEstimateBillsName: TWideStringField;
  114. cdsEstimateBillsUnits: TWideStringField;
  115. cdsEstimateBillsPDQuantity: TFloatField;
  116. cdsEstimateBillsPDTotalPrice: TFloatField;
  117. cdsEstimateBillsCDDQuantity: TFloatField;
  118. cdsEstimateBillsCDDTotalPrice: TFloatField;
  119. cdsEstimateBillsAddDealQuantity: TFloatField;
  120. cdsEstimateBillsAddDealTotalPrice: TFloatField;
  121. cdsEstimateBillsAddCQuantity: TFloatField;
  122. cdsEstimateBillsAddCTotalPrice: TFloatField;
  123. cdsEstimateBillsAddGatherQuantity: TFloatField;
  124. cdsEstimateBillsAddGatherTotalPrice: TFloatField;
  125. cdsEstimateBillsQuantityAdjust: TFloatField;
  126. cdsEstimateBillsTotalPriceAdjust: TFloatField;
  127. cdsEstimateBillsMemoStr: TWideStringField;
  128. cdsEstimateBillsABQuantity: TFloatField; // 批准概算 - 数量
  129. cdsEstimateBillsABTotalPrice: TFloatField; // 批准概算 - 金额
  130. cdsEstimateBillsQuantity: TFloatField; // 0号台账 - 数量
  131. cdsEstimateBillsTotalPrice: TFloatField; // 0号台账 - 金额
  132. cdsEstimateBillsQuantityCompare1: TFloatField; // 数量比较 - (台账-批准)/批准
  133. cdsEstimateBillsTotalPriceCompare1: TFloatField; // 金额比较 - (台账-批准)/批准
  134. cdsEstimateBillsQuantityCompare2: TFloatField; // 数量比较 - (决算-批准)/批准
  135. cdsEstimateBillsQuantityCompare3: TFloatField; // 金额比较 - (决算-批准)/批准
  136. cdsEstimateBillsTotalPriceCompare2: TFloatField; // 数量比较 - (决算-合同)/合同
  137. cdsEstimateBillsTotalPriceCompare3: TFloatField; // 金额比较 - (决算-合同)/合同
  138. cdsEstimateBillsPDDgnQuantity: TStringField;
  139. cdsEstimateBillsPDDgnQuantity1: TFloatField;
  140. cdsEstimateBillsPDDgnQuantity2: TFloatField;
  141. cdsEstimateBillsCDDDgnQuantity: TStringField;
  142. cdsEstimateBillsCDDDgnQuantity1: TFloatField;
  143. cdsEstimateBillsCDDDgnQuantity2: TFloatField;
  144. cdsEstimateBillsDealDgnQuantity: TStringField;
  145. cdsEstimateBillsDealDgnQuantity1: TFloatField;
  146. cdsEstimateBillsDealDgnQuantity2: TFloatField;
  147. cdsEstimateBillsCDgnQuantity: TStringField;
  148. cdsEstimateBillsCDgnQuantity1: TFloatField;
  149. cdsEstimateBillsCDgnQuantity2: TFloatField;
  150. cdsEstimateBillsGatherDgnQuantity: TStringField;
  151. cdsEstimateBillsGatherDgnQuantity1: TFloatField;
  152. cdsEstimateBillsGatherDgnQuantity2: TFloatField;
  153. cdsEstimateBillsABDgnQuantity: TStringField;
  154. cdsEstimateBillsABDgnQuantity1: TFloatField;
  155. cdsEstimateBillsABDgnQuantity2: TFloatField;
  156. cdsEstimateBillsDgnQuantity: TStringField;
  157. cdsEstimateBillsDgnQuantity1: TFloatField;
  158. cdsEstimateBillsDgnQuantity2: TFloatField;
  159. cdsEstimateBillsDgnQuantityCompare1: TStringField;
  160. cdsEstimateBillsDgnQuantityCompare2: TStringField;
  161. cdsEstimateBillsDgnQuantityCompare3: TStringField;
  162. cdsEstimateBillsDgnQuantity1Compare1: TFloatField;
  163. cdsEstimateBillsDgnQuantity2Compare1: TFloatField;
  164. cdsEstimateBillsDgnQuantity1Compare2: TFloatField;
  165. cdsEstimateBillsDgnQuantity1Compare3: TFloatField;
  166. cdsEstimateBillsDgnQuantity2Compare2: TFloatField;
  167. cdsEstimateBillsDgnQuantity2Compare3: TFloatField;
  168. cdsEstimateBillsB_Code: TStringField;
  169. cdsEstimateBillsPrice: TFloatField;
  170. cdsEstimateBillsPDDgnPrice: TFloatField;
  171. cdsEstimateBillsCDDDgnPrice: TFloatField;
  172. cdsEstimateBillsABDgnPrice: TFloatField;
  173. // 决算部颁07, 11
  174. cdsProjectGclBills: TClientDataSet;
  175. cdsProjectGclBillsProjectID: TIntegerField;
  176. cdsProjectGclBillsProjectName: TWideStringField;
  177. cdsProjectGclBillsB_Code: TStringField;
  178. cdsProjectGclBillsIndexCode: TStringField;
  179. cdsProjectGclBillsName: TWideStringField;
  180. cdsProjectGclBillsUnits: TWideStringField;
  181. cdsProjectGclBillsQuantity: TFloatField;
  182. cdsProjectGclBillsPrice: TFloatField;
  183. cdsProjectGclBillsTotalPrice: TFloatField;
  184. cdsProjectGclBillsP_Price: TFloatField;
  185. cdsProjectGclBillsP_Quantity: TFloatField;
  186. cdsProjectGclBillsP_TotalPrice: TFloatField;
  187. cdsProjectGclBillsSerialNo: TIntegerField;
  188. cdsProjectGclBillsP_AddGatherQuantity: TFloatField;
  189. cdsProjectGclBillsP_AddGatherTotalPrice: TFloatField;
  190. cdsProjectGclBillsAddGatherQuantity: TFloatField;
  191. cdsProjectGclBillsAddGatherTotalPrice: TFloatField;
  192. // 决算部颁12
  193. cdsBGLFlow: TClientDataSet;
  194. cdsBGLFlowMergeBGLCode: TWideStringField;
  195. cdsBGLFlowBGLName: TWideStringField;
  196. cdsBGLFlowApprovalCode: TWideStringField;
  197. cdsBGLFlowSuggestion: TWideStringField;
  198. cdsBGLFlowBGReason: TWideStringField;
  199. cdsBGLFlowB_Code: TStringField;
  200. cdsBGLFlowName: TWideStringField;
  201. cdsBGLFlowUnits: TWideStringField;
  202. cdsBGLFlowQuantity: TFloatField;
  203. cdsBGLFlowPrice: TFloatField;
  204. cdsBGLFlowTotalPrice: TFloatField;
  205. cdsBGLFlowBGTotalPrice: TFloatField;
  206. private
  207. FCacheTree: TReportCacheTree;
  208. FGclList: TGclGatherList;
  209. FFixedIDList: TFixedIDBillsList;
  210. FProjectData: TProjectData;
  211. FProjectName: string;
  212. FGatherType: TbgType;
  213. FSerialNo: Integer;
  214. procedure OpenProjectData(AProject: TSelectProject; AProjectIndex: Integer);
  215. procedure FreeProjectData;
  216. function GetDgnQuantity(ANum1, ANum2: Double): string;
  217. function GetDgnPrice(ATotalPrice, ADgnQuantity: Double): Double;
  218. function GetCompare(ANum1, ANum2: Double): Double;
  219. {汇总树结构}
  220. function AddBillsNode(ANode: TsdIDTreeNode; AParent:
  221. TReportCacheNode; AProjectIndex: Integer;
  222. ASelectProject: TSelectProject): TReportCacheNode;
  223. // 递归模式(当前节点、子节点、后兄弟节点)
  224. procedure AddBills(ANode: TsdIDTreeNode; AParent: TReportCacheNode;
  225. AProjectIndex: Integer; ASelectProject: TSelectProject);
  226. // 遍历模式(当前节点、子节点)
  227. procedure AddBillsList(ANode: TsdIDTreeNode; AParent: TReportCacheNode;
  228. AProjectIndex: Integer; ASelectProject: TSelectProject);
  229. {汇总工程量清单}
  230. procedure FilterBillsNode(ANode: TsdIDTreeNode; AProjectIndex: Integer);
  231. procedure FilterBills(ANode: TsdIDTreeNode; AProjectIndex: Integer);
  232. {汇总固定ID项}
  233. procedure FilterFixedIDBills(ATree: TsdIDTree; AProjectIndex: Integer);
  234. procedure FilterSettlement(AProjectData: TProjectData; AProjectIndex: Integer);
  235. {写入流水数据}
  236. procedure WriteBGLFlowData(AProjectData: TProjectData);
  237. procedure WriteFlowData(AProjectData: TProjectData);
  238. procedure GatherProject(AProject: TSelectProject; AProjectIndex: Integer);
  239. procedure CalculateGatherData;
  240. procedure CalculateRatioPercent; // 计算各项费用所占比例,金额/总造价
  241. procedure WriteGatherCacheNode(const AGatherName: string);
  242. procedure WriteNode(ANode: TReportCacheNode);
  243. procedure WriteBillsData;
  244. procedure WriteGclNode;
  245. procedure WriteProjectsData;
  246. procedure WriteEstimateGatherNode;
  247. procedure WriteENodeData(ANode: TReportCacheNode);
  248. procedure ReWriteENodeDataAsGather(ANode: TReportCacheNode; AName: string);
  249. procedure WriteEstimateNode(ANode: TReportCacheNode);
  250. procedure WriteEstimateData;
  251. procedure WriteProjectsGclData;
  252. procedure WriteData;
  253. procedure BeforeGather(AProjects: TList);
  254. procedure AfterGather;
  255. public
  256. function AssignData(AProjects: TList): TDataSet;
  257. property GatherType: TbgType read FGatherType write FGatherType;
  258. end;
  259. implementation
  260. uses
  261. Globals, UtilMethods, Math, BGLDm;
  262. {$R *.dfm}
  263. { TrmBillsGatherData }
  264. procedure TrmBillsGatherData.AddBills(ANode: TsdIDTreeNode;
  265. AParent: TReportCacheNode; AProjectIndex: Integer; ASelectProject: TSelectProject);
  266. var
  267. ACur: TReportCacheNode;
  268. begin
  269. if not Assigned(ANode) then Exit;
  270. // 按设置的层次汇总(Level从0开始取值)
  271. case ReportConfig.GatherLevel of
  272. // 项
  273. 0: if ANode.Level > 1 then Exit;
  274. // 目
  275. 1: if ANode.Level > 2 then Exit;
  276. // 节
  277. 2: if ANode.Level > 3 then Exit;
  278. // 细目
  279. 3: if ANode.Level > 4 then Exit;
  280. // 项目节
  281. 4: if ANode.Rec.ValueByName('B_Code').AsString <> '' then Exit;
  282. end;
  283. if GatherType in [bgtXmj, bgtMultiXmj, bgtEstimate, bgtEstimate1, bgtFinal08, bgtFinal09] then
  284. if ANode.Rec.ValueByName('B_Code').AsString <> '' then Exit; // 仅汇总项目节
  285. ACur := AddBillsNode(ANode, AParent, AProjectIndex, ASelectProject);
  286. AddBills(ANode.FirstChild, ACur, AProjectIndex, ASelectProject);
  287. AddBills(ANode.NextSibling, AParent, AProjectIndex, ASelectProject);
  288. end;
  289. function TrmBillsGatherData.AddBillsNode(ANode: TsdIDTreeNode;
  290. AParent: TReportCacheNode; AProjectIndex: Integer;
  291. ASelectProject: TSelectProject): TReportCacheNode;
  292. var
  293. iGatherCompare: Integer;
  294. ANextSibling: TReportCacheNode;
  295. begin
  296. with ANode.Rec do
  297. begin
  298. if ANode.Rec.ValueByName('B_Code').AsString <> '' then
  299. iGatherCompare := ReportConfig.GclCompare
  300. else
  301. iGatherCompare := ReportConfig.XmjCompare;
  302. case iGatherCompare of
  303. // 按编号
  304. 0: if (ValueByName('Code').asString <> '') or (ValueByName('B_Code').asString <> '') then
  305. Result := FCacheTree.FindNode(AParent,
  306. ValueByName('Code').AsString, ValueByName('B_Code').AsString)
  307. else
  308. Result := FCacheTree.FindNode(AParent, ValueByName('Name').AsString);
  309. // 按名称
  310. 1: Result := FCacheTree.FindNode(AParent, ValueByName('Name').AsString);
  311. // 按编号+名称
  312. 2: Result := FCacheTree.FindNode(AParent, ValueByName('Code').AsString,
  313. ValueByName('B_Code').AsString, ValueByName('Name').AsString);
  314. end;
  315. if not Assigned(Result) then
  316. begin
  317. ANextSibling := FCacheTree.FindNextSibling(AParent,
  318. ValueByName('Code').AsString, ValueByName('B_Code').AsString);
  319. Result := FCacheTree.AddNode(AParent, ANextSibling);
  320. Result.Code := ValueByName('Code').AsString;
  321. Result.B_Code := ValueByName('B_Code').AsString;
  322. Result.Name := ValueByName('Name').AsString;
  323. Result.Units := ValueByName('Units').AsString;
  324. end;
  325. if (GatherType in [bgtEstimate, bgtG_Final06_1]) and (ASelectProject.IsPD or ASelectProject.IsCDD) then
  326. begin
  327. if ASelectProject.IsPD then
  328. begin
  329. Result.PDQuantity := ValueByName('Quantity').AsFloat;
  330. Result.PDTotalPrice := ValueByName('TotalPrice').AsFloat;
  331. Result.PDDesignQuantity1 := ValueByName('DgnQuantity1').AsFloat;
  332. Result.PDDesignQuantity2 := ValueByName('DgnQuantity2').AsFloat;
  333. Result.PDDesignPrice := ValueByName('DgnPrice').AsFloat;
  334. end
  335. else if ASelectProject.IsCDD then
  336. begin
  337. Result.CDDQuantity := ValueByName('Quantity').AsFloat;
  338. Result.CDDTotalPrice := ValueByName('TotalPrice').AsFloat;
  339. Result.CDDDesignQuantity1 := ValueByName('DgnQuantity1').AsFloat;
  340. Result.CDDDesignQuantity2 := ValueByName('DgnQuantity2').AsFloat;
  341. Result.CDDDesignPrice := ValueByName('DgnPrice').AsFloat;
  342. end
  343. end
  344. else if (GatherType = bgtEstimate1) and ASelectProject.IsAB then
  345. begin
  346. Result.ABQuantity := ValueByName('Quantity').AsFloat;
  347. Result.ABTotalPrice := ValueByName('TotalPrice').AsFloat;
  348. Result.ABDesignQuantity1 := ValueByName('DgnQuantity1').AsFloat;
  349. Result.ABDesignQuantity2 := ValueByName('DgnQuantity2').AsFloat;
  350. Result.ABDesignPrice := ValueByName('DgnPrice').AsFloat;
  351. end
  352. else
  353. begin
  354. Result.Price := ValueByName('Price').AsFloat;
  355. // 汇总的经济指标只能在汇总后计算得到
  356. Result.Quantity := Result.Quantity + ValueByName('Quantity').AsFloat;
  357. Result.TotalPrice := Result.TotalPrice + ValueByName('TotalPrice').AsFloat;
  358. Result.DesignQuantity1 := Result.DesignQuantity1 + ValueByName('DgnQuantity1').AsFloat;
  359. Result.DesignQuantity2 := Result.DesignQuantity2 + ValueByName('DgnQuantity2').AsFloat;
  360. Result.AddDealQuantity := Result.AddDealQuantity + ValueByName('AddDealQuantity').AsFloat;
  361. Result.AddDealTotalPrice := Result.AddDealTotalPrice + ValueByName('AddDealTotalPrice').AsFloat;
  362. Result.AddQcQuantity := Result.AddQcQuantity + ValueByName('AddQcQuantity').AsFloat;
  363. Result.AddQcTotalPrice := Result.AddQcTotalPrice + ValueByName('AddQcTotalPrice').AsFloat;
  364. Result.AddPcQuantity := Result.AddPcQuantity + ValueByName('AddPcQuantity').AsFloat;
  365. Result.AddPcTotalPrice := Result.AddPcTotalPrice + ValueByName('AddPcTotalPrice').AsFloat;
  366. Result.DealDesignQuantity1 := Result.DealDesignQuantity1 + ValueByName('DealDgnQuantity1').AsFloat;
  367. Result.DealDesignQuantity2 := Result.DealDesignQuantity2 + ValueByName('DealDgnQuantity2').AsFloat;
  368. Result.CDesignQuantity1 := Result.CDesignQuantity1 + ValueByName('CDgnQuantity1').AsFloat;
  369. Result.CDesignQuantity2 := Result.CDesignQuantity2 + ValueByName('CDgnQuantity2').AsFloat;
  370. Result.P_Price[AProjectIndex] := ValueByName('Price').AsFloat;
  371. Result.P_Quantity[AProjectIndex] := ValueByName('AddGatherQuantity').AsFloat;
  372. Result.P_TotalPrice[AProjectIndex] := ValueByName('AddGatherTotalPrice').AsFloat;
  373. end;
  374. end;
  375. end;
  376. procedure TrmBillsGatherData.AfterGather;
  377. begin
  378. cdsProjectBills.EnableControls;
  379. FGclList.Free;
  380. cdsGclBills.EnableControls;
  381. FCacheTree.Free;
  382. cdsFxBills.EnableControls;
  383. cdsEstimateBills.EnableControls;
  384. FFixedIDList.Free;
  385. cdsProjectGclBills.EnableControls;
  386. cdsBGLFlow.EnableControls;
  387. end;
  388. function TrmBillsGatherData.AssignData(AProjects: TList): TDataSet;
  389. var
  390. iProject: Integer;
  391. SelectProject: TSelectProject;
  392. begin
  393. BeforeGather(AProjects);
  394. try
  395. for iProject := 0 to AProjects.Count - 1 do
  396. GatherProject(TSelectProject(AProjects.Items[iProject]), iProject);
  397. CalculateGatherData;
  398. CalculateRatioPercent;
  399. WriteData;
  400. finally
  401. case GatherType of
  402. bgtFx, bgtXmj, bgtFinal08, bgtFinal09, bgtFinal17, bgtFinal18, bgtG_Final04:
  403. Result := cdsFxBills;
  404. bgtGcl: Result := cdsGclBills;
  405. bgtMultiXmj, bgtFinal16: Result := cdsProjectBills;
  406. bgtEstimate, bgtEstimate1, bgtG_Final06_1: Result := cdsEstimateBills;
  407. bgtFinal07, bgtFinal11, bgtFinal19: Result := cdsProjectGclBills;
  408. bgtFinal12: Result := cdsBGLFlow;
  409. end;
  410. AfterGather;
  411. end;
  412. end;
  413. procedure TrmBillsGatherData.BeforeGather(AProjects: TList);
  414. begin
  415. cdsFxBills.DisableControls;
  416. cdsFxBills.Active := True;
  417. cdsFxBills.EmptyDataSet;
  418. FCacheTree := TReportCacheTree.Create(AProjects.Count);
  419. cdsGclBills.DisableControls;
  420. cdsGclBills.Active := True;
  421. cdsGclBills.EmptyDataSet;
  422. if GatherType in [bgtFinal07, bgtFinal11, bgtFinal19] then
  423. FGclList := TGclGatherList.Create(AProjects.Count, False)
  424. else
  425. FGclList := TGclGatherList.Create(AProjects.Count);
  426. cdsProjectBills.DisableControls;
  427. cdsProjectBills.Active := True;
  428. cdsProjectBills.EmptyDataSet;
  429. cdsEstimateBills.DisableControls;
  430. cdsEstimateBills.Active := True;
  431. cdsEstimateBills.EmptyDataSet;
  432. cdsProjectGclBills.DisableControls;
  433. cdsProjectGclBills.Active := True;
  434. cdsProjectGclBills.EmptyDataSet;
  435. FFixedIDList := TFixedIDBillsList.Create(AProjects.Count);
  436. cdsBGLFlow.DisableControls;
  437. cdsBGLFlow.Active := True;
  438. cdsBGLFlow.EmptyDataSet;
  439. end;
  440. procedure TrmBillsGatherData.FilterBills(ANode: TsdIDTreeNode;
  441. AProjectIndex: Integer);
  442. begin
  443. if not Assigned(ANode) then Exit;
  444. if (not ANode.HasChildren) and (ANode.Rec.ValueByName('B_Code').AsString <> '') then
  445. FilterBillsNode(ANode, AProjectIndex);
  446. FilterBills(ANode.FirstChild, AProjectIndex);
  447. FilterBills(ANode.NextSibling, AProjectIndex);
  448. end;
  449. procedure TrmBillsGatherData.FilterBillsNode(ANode: TsdIDTreeNode;
  450. AProjectIndex: Integer);
  451. function CanGatherNode: Boolean;
  452. begin
  453. case GatherType of
  454. bgtFinal11: Result := ANode.Rec.ValueByName('TotalPrice').AsFloat <> 0;
  455. else Result := True;
  456. end;
  457. end;
  458. var
  459. GclNode: TGclGatherNode;
  460. begin
  461. if not Assigned(ANode) or not CanGatherNode then Exit;
  462. GclNode := FGclList.GetGclGatherNode(ANode.Rec);
  463. with ANode.Rec do
  464. begin
  465. GclNode.Quantity := GclNode.Quantity + ValueByName('Quantity').AsFloat;
  466. GclNode.TotalPrice := GclNode.TotalPrice + ValueByName('TotalPrice').AsFloat;
  467. GclNode.AddDealQuantity := GclNode.AddDealQuantity + ValueByName('AddDealQuantity').AsFloat;
  468. GclNode.AddDealTotalPrice := GclNode.AddDealTotalPrice + ValueByName('AddDealTotalPrice').AsFloat;
  469. GclNode.AddQcQuantity := GclNode.AddQcQuantity + ValueByName('AddQcQuantity').AsFloat;
  470. GclNode.AddQcTotalPrice := GclNode.AddQcTotalPrice + ValueByName('AddQcTotalPrice').AsFloat;
  471. GclNode.AddPcQuantity := GclNode.AddPcQuantity + ValueByName('AddPcQuantity').AsFloat;
  472. GclNode.AddPcTotalPrice := GclNode.AddPcTotalPrice + ValueByName('AddPcTotalPrice').AsFloat;
  473. GclNode.P_Price[AProjectIndex] := ValueByName('Price').AsFloat;
  474. GclNode.P_Quantity[AProjectIndex] := GclNode.P_Quantity[AProjectIndex] + ValueByName('Quantity').AsFloat;
  475. GclNode.P_TotalPrice[AProjectIndex] := GclNode.P_TotalPrice[AProjectIndex] + ValueByName('TotalPrice').AsFloat;
  476. GclNode.P_AddGatherQuantity[AProjectIndex] :=
  477. GclNode.P_AddGatherQuantity[AProjectIndex] + ValueByName('AddGatherQuantity').AsFloat;
  478. GclNode.P_AddGatherTotalPrice[AProjectIndex] :=
  479. GclNode.P_AddGatherTotalPrice[AProjectIndex] + ValueByName('AddGatherTotalPrice').AsFloat;
  480. end;
  481. end;
  482. procedure TrmBillsGatherData.FreeProjectData;
  483. begin
  484. if not Assigned(OpenProjectManager.FindProjectData(FProjectData.ProjectID)) then
  485. FProjectData.Free;
  486. end;
  487. procedure TrmBillsGatherData.GatherProject(AProject: TSelectProject;
  488. AProjectIndex: Integer);
  489. begin
  490. OpenProjectData(AProject, AProjectIndex);
  491. try
  492. case GatherType of
  493. bgtFinal08: // 08表 取第二部分下所有项目节
  494. AddBills(FProjectData.BillsCompileData.BillsCompileTree.FindNode(2).FirstChild, nil, AProjectIndex, AProject);
  495. bgtFinal09: // 09表 取第三部分及其后所有项目节
  496. AddBills(FProjectData.BillsCompileData.BillsCompileTree.FindNode(3), nil, AProjectIndex, AProject);
  497. bgtGcl, bgtFinal07, bgtFinal11, bgtFinal19: // 汇总工程量清单
  498. FilterBills(FProjectData.BillsCompileData.BillsCompileTree.FirstNode, AProjectIndex);
  499. bgtFinal12: // 不做数据汇总,直接流水式写入数据
  500. WriteFlowData(FProjectData);
  501. bgtFinal16: // 16表 仅汇总计日工及其子节点
  502. AddBillsList(FProjectData.BillsCompileData.BillsCompileTree.FindNode(40), nil, AProjectIndex, AProject);
  503. bgtFinal17: // 17表 仅汇总收尾工程及其子节点
  504. AddBillsList(FProjectData.BillsCompileData.BillsCompileTree.FindNode(47), nil, AProjectIndex, AProject);
  505. bgtFinal18: // 18表 仅汇总报废工程及其子节点
  506. AddBillsList(FProjectData.BillsCompileData.BillsCompileTree.FindNode(48), nil, AProjectIndex, AProject);
  507. bgtG_Final06_1: // 粤竣06-1表 仅汇总土地及其子节点
  508. AddBillsList(FProjectData.BillsCompileData.BillsCompileTree.FindNode(21), nil, AProjectIndex, AProject);
  509. else // 标准汇总方式,分项清单
  510. AddBills(FProjectData.BillsCompileData.BillsCompileTree.FirstNode, nil, AProjectIndex, AProject)
  511. end;
  512. if GatherType in [bgtFinal07, bgtFinal11, bgtFinal19] then
  513. FilterFixedIDBills(FProjectData.BillsCompileData.BillsCompileTree, AProjectIndex);
  514. if GatherType = bgtFinal11 then
  515. FilterSettlement(FProjectData, AProjectIndex);
  516. finally
  517. FreeProjectData;
  518. end;
  519. end;
  520. procedure TrmBillsGatherData.OpenProjectData(AProject: TSelectProject;
  521. AProjectIndex: Integer);
  522. var
  523. Rec: TsdDataRecord;
  524. begin
  525. FProjectData := OpenProjectManager.FindProjectData(AProject.ProjectID);
  526. Rec := ProjectManager.sddProjectsInfo.FindKey('idxID', AProject.ProjectID);
  527. if not Assigned(FProjectData) then
  528. begin
  529. FProjectData := TProjectData.Create;
  530. FProjectData.OpenForReport(GetMyProjectsFilePath + Rec.ValueByName('FileName').AsString);
  531. end;
  532. FProjectName := Rec.ValueByName('Name').AsString;
  533. FCacheTree.ProjectName[AProjectIndex] := Rec.ValueByName('Name').AsString;
  534. FGclList.ProjectName[AProjectIndex] := Rec.ValueByName('Name').AsString;
  535. end;
  536. procedure TrmBillsGatherData.WriteData;
  537. begin
  538. case GatherType of
  539. bgtFx, bgtXmj, bgtFinal08, bgtFinal09, bgtFinal17, bgtFinal18, bgtG_Final04:
  540. WriteBillsData;
  541. bgtGcl:
  542. WriteGclNode;
  543. bgtMultiXmj, bgtFinal16:
  544. WriteProjectsData;
  545. bgtEstimate, bgtEstimate1, bgtG_Final06_1:
  546. WriteEstimateData;
  547. bgtFinal07, bgtFinal11, bgtFinal19: // 07&11特别的,其中还写入了部分固定ID节点 !!丧心病狂的报表!!
  548. WriteProjectsGclData;
  549. end;
  550. end;
  551. procedure TrmBillsGatherData.WriteNode(ANode: TReportCacheNode);
  552. begin
  553. if not Assigned(ANode) then Exit;
  554. cdsFxBills.Append;
  555. cdsFxBillsXiangCode.AsString := ANode.XiangCode;
  556. cdsFxBillsMuCode.AsString := ANode.MuCode;
  557. cdsFxBillsJieCode.AsString := ANode.JieCode;
  558. cdsFxBillsXiMuCode.AsString := ANode.XiMuCode;
  559. cdsFxBillsCode.AsString := ANode.Code;
  560. cdsFxBillsB_Code.AsString := ANode.B_Code;
  561. cdsFxBillsName.AsString := ANode.Name;
  562. cdsFxBillsUnits.AsString := ANode.Units;
  563. cdsFxBillsPrice.AsFloat := ANode.Price;
  564. cdsFxBillsAddDealQuantity.AsFloat := ANode.AddDealQuantity;
  565. cdsFxBillsAddDealTotalPrice.AsFloat := ANode.AddDealTotalPrice;
  566. cdsFxBillsAddQcQuantity.AsFloat := ANode.AddQcQuantity;
  567. cdsFxBillsAddQcTotalPrice.AsFloat := ANode.AddQcTotalPrice;
  568. cdsFxBillsAddPcQuantity.AsFloat := ANode.AddPcQuantity;
  569. cdsFxBillsAddPcTotalPrice.AsFloat := ANode.AddPcTotalPrice;
  570. cdsFxBillsAddGatherQuantity.AsFloat := ANode.AddDealQuantity + ANode.AddQcQuantity;
  571. cdsFxBillsAddGatherTotalPrice.AsFloat := ANode.AddDealTotalPrice +
  572. ANode.AddQcTotalPrice + ANode.AddPcTotalPrice;
  573. cdsFxBillsAddRatioPercent.AsFloat := ANode.AddRatioPercent;
  574. cdsFxBillsQuantity.AsFloat := ANode.Quantity;
  575. cdsFxBillsTotalPrice.AsFloat := ANode.TotalPrice;
  576. cdsFxBillsRatioPercent.AsFloat := ANode.RatioPercent;
  577. cdsFxBillsDgnQuantity1.AsFloat := ANode.DesignQuantity1;
  578. cdsFxBillsDgnQuantity2.AsFloat := ANode.DesignQuantity2;
  579. cdsFxBillsDgnQuantity.AsString := GetDgnQuantity(ANode.DesignQuantity1, ANode.DesignQuantity2);
  580. if ANode.DesignQuantity1 <> 0 then
  581. cdsFxBillsDgnPrice1.AsFloat := PriceRoundTo(ANode.TotalPrice/ANode.DesignQuantity1);
  582. if ANode.DesignQuantity2 <> 0 then
  583. cdsFxBillsDgnPrice2.AsFloat := PriceRoundTo(ANode.TotalPrice/ANode.DesignQuantity2);
  584. if cdsFxBillsDgnPrice1.AsFloat <> 0 then
  585. cdsFxBillsDgnPrice.AsString := GetDgnQuantity(cdsFxBillsDgnPrice1.AsFloat, cdsFxBillsDgnPrice2.AsFloat);
  586. cdsFxBills.Post;
  587. WriteNode(TReportCacheNode(ANode.FirstChild));
  588. WriteNode(TReportCacheNode(ANode.NextSibling));
  589. end;
  590. procedure TrmBillsGatherData.WriteGclNode;
  591. var
  592. i: Integer;
  593. GclNode: TGclGatherNode;
  594. begin
  595. for i := 0 to FGclList.Count - 1 do
  596. begin
  597. GclNode := FGclList.Node[i];
  598. cdsGclBills.Append;
  599. cdsGclBillsB_Code.AsString := GclNode.B_Code;
  600. cdsGclBillsIndexCode.AsString := GclNode.IndexCode;
  601. cdsGclBillsName.AsString := GclNode.Name;
  602. cdsGclBillsUnits.AsString := GclNode.Units;
  603. cdsGclBillsPrice.AsFloat := GclNode.Price;
  604. cdsGclBillsAddDealQuantity.AsFloat := GclNode.AddDealQuantity;
  605. cdsGclBillsAddDealTotalPrice.AsFloat := GclNode.AddDealTotalPrice;
  606. cdsGclBillsAddQcQuantity.AsFloat := GclNode.AddQcQuantity;
  607. cdsGclBillsAddQcTotalPrice.AsFloat := GclNode.AddQcTotalPrice;
  608. cdsGclBillsAddPcQuantity.AsFloat := GclNode.AddPcQuantity;
  609. cdsGclBillsAddPcTotalPrice.AsFloat := GclNode.AddPcTotalPrice;
  610. cdsGclBillsAddGatherQuantity.AsFloat := GclNode.AddDealQuantity + GclNode.AddQcQuantity;
  611. cdsGclBillsAddDealTotalPrice.AsFloat := GclNode.AddDealTotalPrice +
  612. GclNode.AddQcTotalPrice + GclNode.AddPcTotalPrice;
  613. cdsGclBillsPrecent.AsFloat := 0;
  614. cdsGclBillsMemoStr.AsString := '';
  615. cdsGclBills.Post;
  616. end;
  617. end;
  618. procedure TrmBillsGatherData.WriteProjectsData;
  619. procedure WriteProjectData(ANode: TReportCacheNode; AProjectIndex: Integer);
  620. begin
  621. if not Assigned(ANode) then Exit;
  622. cdsProjectBills.Append;
  623. cdsProjectBillsProjectID.AsInteger := AProjectIndex;
  624. cdsProjectBillsProjectName.AsString := FCacheTree.ProjectName[AProjectIndex];
  625. cdsProjectBillsXiangCode.AsString := ANode.XiangCode;
  626. cdsProjectBillsMuCode.AsString := ANode.MuCode;
  627. cdsProjectBillsJieCode.AsString := ANode.JieCode;
  628. cdsProjectBillsXiMuCode.AsString := ANode.XiMuCode;
  629. cdsProjectBillsCode.AsString := ANode.Code;
  630. cdsProjectBillsB_Code.AsString := ANode.B_Code;
  631. cdsProjectBillsName.AsString := ANode.Name;
  632. cdsProjectBillsUnits.AsString := ANode.Units;
  633. // 此处数量与金额特指所有项目的累计完成数量与金额汇总。
  634. cdsProjectBillsQuantity.AsFloat := ANode.AddDealQuantity + ANode.AddQcQuantity;
  635. cdsProjectBillsTotalPrice.AsFloat := ANode.AddDealTotalPrice + ANode.AddQcTotalPrice + ANode.AddPcTotalPrice;
  636. cdsProjectBillsP_Quantity.AsFloat := ANode.P_Quantity[AProjectIndex];
  637. cdsProjectBillsP_TotalPrice.AsFloat := ANode.P_TotalPrice[AProjectIndex];
  638. cdsProjectBillsP_Price.AsFloat := ANode.P_Price[AProjectIndex];
  639. cdsProjectBillsSerialNo.AsInteger := FSerialNo;
  640. cdsProjectBills.Post;
  641. Inc(FSerialNo);
  642. WriteProjectData(TReportCacheNode(ANode.FirstChild), AProjectIndex);
  643. WriteProjectData(TReportCacheNode(ANode.NextSibling), AProjectIndex);
  644. end;
  645. procedure WriteProjectGatherData(AProjectIndex: Integer);
  646. begin
  647. cdsProjectBills.Append;
  648. cdsProjectBillsProjectID.AsInteger := AProjectIndex;
  649. cdsProjectBillsProjectName.AsString := FCacheTree.ProjectName[AProjectIndex];
  650. cdsProjectBillsName.AsString := '金额合计';
  651. with FCacheTree.GatherCacheNode do
  652. begin
  653. cdsProjectBillsTotalPrice.AsFloat := AddDealTotalPrice + AddQcTotalPrice + AddPcTotalPrice;
  654. cdsProjectBillsP_TotalPrice.AsFloat := P_TotalPrice[AProjectIndex];
  655. end;
  656. cdsProjectBillsSerialNo.AsInteger := FSerialNo;
  657. cdsProjectBills.Post;
  658. Inc(FSerialNo);
  659. cdsProjectBills.Append;
  660. cdsProjectBillsProjectID.AsInteger := AProjectIndex;
  661. cdsProjectBillsProjectName.AsString := FCacheTree.ProjectName[AProjectIndex];
  662. cdsProjectBillsName.AsString := Format('金额总计:%f', [FCacheTree.GatherCacheNode.GatherP_TotalPrice]);
  663. cdsProjectBillsSerialNo.AsInteger := FSerialNo;
  664. cdsProjectBills.Post;
  665. Inc(FSerialNo);
  666. end;
  667. var
  668. i: Integer;
  669. begin
  670. for i := 0 to FCacheTree.ProjectCount - 1 do
  671. begin
  672. FSerialNo := 0;
  673. WriteProjectData(TReportCacheNode(FCacheTree.FirstNode), i);
  674. if GatherType = bgtFinal16 then
  675. WriteProjectGatherData(i);
  676. end;
  677. end;
  678. procedure TrmBillsGatherData.WriteEstimateNode(ANode: TReportCacheNode);
  679. begin
  680. if not Assigned(ANode) then Exit;
  681. WriteENodeData(ANode);
  682. WriteEstimateNode(TReportCacheNode(ANode.FirstChild));
  683. WriteEstimateNode(TReportCacheNode(ANode.NextSibling));
  684. end;
  685. procedure TrmBillsGatherData.FilterFixedIDBills(ATree: TsdIDTree;
  686. AProjectIndex: Integer);
  687. var
  688. iIndex: Integer;
  689. stnNode: TsdIDTreeNode;
  690. FixedIDNode: TFixedIDBillsNode;
  691. begin
  692. for iIndex := 0 to ATree.Count - 1 do
  693. begin
  694. stnNode := ATree.Items[iIndex];
  695. if stnNode.ID >= 100 then Continue;
  696. FixedIDNode := FFixedIDList.GetFixedIDBillsNode(stnNode.ID);
  697. FixedIDNode.TotalPrice := FixedIDNode.TotalPrice
  698. + stnNode.Rec.ValueByName('TotalPrice').AsFloat;
  699. FixedIDNode.TotalPrice :=
  700. + stnNode.Rec.ValueByName('TotalPrice').AsFloat;
  701. FixedIDNode.AddGatherTotalPrice := FixedIDNode.AddGatherTotalPrice
  702. + stnNode.Rec.ValueByName('AddGatherTotalPrice').AsFloat;
  703. FixedIDNode.P_AddGatherTotalPrice[AProjectIndex] :=
  704. stnNode.Rec.ValueByName('AddGatherTotalPrice').AsFloat;
  705. end;
  706. end;
  707. procedure TrmBillsGatherData.WriteProjectsGclData;
  708. procedure WriteProjectGclData(AProjectIndex: Integer);
  709. var
  710. i: Integer;
  711. GclNode: TGclGatherNode;
  712. begin
  713. for i := 0 to FGclList.Count - 1 do
  714. begin
  715. GclNode := FGclList.Node[i];
  716. cdsProjectGclBills.Append;
  717. cdsProjectGclBillsProjectID.AsInteger := AProjectIndex;
  718. cdsProjectGclBillsProjectName.AsString := FGclList.ProjectName[AProjectIndex];
  719. cdsProjectGclBillsB_Code.AsString := GclNode.B_Code;
  720. cdsProjectGclBillsIndexCode.AsString := GclNode.IndexCode;
  721. cdsProjectGclBillsName.AsString := GclNode.Name;
  722. cdsProjectGclBillsUnits.AsString := GclNode.Units;
  723. cdsProjectGclBillsQuantity.AsFloat := GclNode.Quantity;
  724. cdsProjectGclBillsTotalPrice.AsFloat := GclNode.TotalPrice;
  725. // Price须填写合计平均单价
  726. if cdsProjectGclBillsQuantity.AsFloat <> 0 then
  727. cdsProjectGclBillsPrice.AsFloat := cdsProjectGclBillsTotalPrice.AsFloat/cdsProjectGclBillsQuantity.AsFloat;
  728. cdsProjectGclBillsP_Price.AsFloat := GclNode.P_Price[AProjectIndex];
  729. cdsProjectGclBillsP_Quantity.AsFloat := GclNode.P_Quantity[AProjectIndex];
  730. cdsProjectGclBillsP_TotalPrice.AsFloat := GclNode.P_TotalPrice[AProjectIndex];
  731. cdsProjectGclBillsP_AddGatherQuantity.AsFloat := GclNode.P_AddGatherQuantity[AProjectIndex];
  732. cdsProjectGclBillsP_AddGatherTotalPrice.AsFloat := GclNode.P_AddGatherTotalPrice[AProjectIndex];
  733. cdsProjectGclBillsAddGatherQuantity.AsFloat := GclNode.AddDealQuantity + GclNode.AddQcQuantity;
  734. cdsProjectGclBillsAddGatherTotalPrice.AsFloat := GclNode.AddDealTotalPrice
  735. + GclNode.AddQcTotalPrice + GclNode.AddPcTotalPrice;
  736. cdsProjectGclBillsSerialNo.AsInteger := FSerialNo;
  737. cdsProjectGclBills.Post;
  738. end;
  739. Inc(FSerialNo);
  740. end;
  741. procedure WriteGatherNodeData(AProjectIndex: Integer);
  742. begin
  743. cdsProjectGclBills.Append;
  744. cdsProjectGclBillsProjectID.AsInteger := AProjectIndex;
  745. cdsProjectGclBillsProjectName.AsString := FGclList.ProjectName[AProjectIndex];
  746. case GatherType of
  747. bgtFinal07: cdsProjectGclBillsName.AsString := '小计';
  748. bgtFinal11: cdsProjectGclBillsName.AsString := '第100章至900章清单合计';
  749. bgtFinal19: cdsProjectGclBillsName.AsString := '合计';
  750. end;
  751. cdsProjectGclBillsTotalPrice.AsFloat := FGclList.GatherNode.TotalPrice;
  752. cdsProjectGclBillsP_TotalPrice.AsFloat := FGclList.GatherNode.P_TotalPrice[AProjectIndex];
  753. cdsProjectGclBillsAddGatherTotalPrice.AsFloat := FGclList.GatherNode.AddDealTotalPrice
  754. + FGclList.GatherNode.AddQcTotalPrice + FGclList.GatherNode.AddPcTotalPrice;
  755. cdsProjectGclBillsP_AddGatherTotalPrice.AsFloat := FGclList.GatherNode.P_AddGatherTotalPrice[AProjectIndex];
  756. cdsProjectGclBillsSerialNo.AsInteger := FSerialNo;
  757. cdsProjectGclBills.Post;
  758. Inc(FSerialNo);
  759. end;
  760. procedure WriteFixedIDData(AProjectIndex: Integer; ANode: TFixedIDBillsNode; const AName: string);
  761. begin
  762. cdsProjectGclBills.Append;
  763. cdsProjectGclBillsProjectID.AsInteger := AProjectIndex;
  764. cdsProjectGclBillsProjectName.AsString := FGclList.ProjectName[AProjectIndex];
  765. cdsProjectGclBillsName.AsString := AName;
  766. if Assigned(ANode) then
  767. begin
  768. cdsProjectGclBillsTotalPrice.AsFloat := ANode.TotalPrice;
  769. cdsProjectGclBillsP_TotalPrice.AsFloat := ANode.P_TotalPrice[AProjectIndex];
  770. cdsProjectGclBillsAddGatherTotalPrice.AsFloat := ANode.AddGatherTotalPrice;
  771. cdsProjectGclBillsP_AddGatherTotalPrice.AsFloat := ANode.P_AddGatherTotalPrice[AProjectIndex];
  772. end;
  773. cdsProjectGclBillsSerialNo.AsInteger := FSerialNo;
  774. cdsProjectGclBills.Post;
  775. end;
  776. procedure WriteFixedIDBillsData07(AProjectIndex: Integer);
  777. var
  778. fTotalPrice, fP_TotalPrice, fAddGatherTotalPrice, fP_AddGatherTotalPrice: Double;
  779. Node54, Node45, Node40, Node51: TFixedIDBillsNode;
  780. begin
  781. fTotalPrice := FGclList.GatherNode.TotalPrice;
  782. fP_TotalPrice := FGclList.GatherNode.P_TotalPrice[AProjectIndex];
  783. fAddGatherTotalPrice := FGclList.GatherNode.AddDealTotalPrice
  784. + FGclList.GatherNode.AddQcTotalPrice + FGclList.GatherNode.AddPcTotalPrice;
  785. fP_AddGatherTotalPrice := FGclList.GatherNode.P_AddGatherTotalPrice[AProjectIndex];
  786. // 变更引起调整合计 全部取0
  787. cdsProjectGclBills.Append;
  788. cdsProjectGclBillsProjectID.AsInteger := AProjectIndex;
  789. cdsProjectGclBillsProjectName.AsString := FGclList.ProjectName[AProjectIndex];
  790. cdsProjectGclBillsName.AsString := '变更引起调整合计';
  791. cdsProjectGclBillsSerialNo.AsInteger := FSerialNo;
  792. cdsProjectGclBills.Post;
  793. Inc(FSerialNo);
  794. // 工程项目调价合计
  795. Node54 := FFixedIDList.FixedIDBillsNode(54);
  796. WriteFixedIDData(AProjectIndex, Node54, '工程项目调价合计');
  797. if Assigned(Node54) then
  798. begin
  799. fTotalPrice := fTotalPrice + Node54.TotalPrice;
  800. fP_TotalPrice := fP_TotalPrice + Node54.P_TotalPrice[AProjectIndex];
  801. fAddGatherTotalPrice := fAddGatherTotalPrice + Node54.AddGatherTotalPrice;
  802. fP_AddGatherTotalPrice := fP_AddGatherTotalPrice + Node54.P_AddGatherTotalPrice[AProjectIndex];
  803. end;
  804. // 工程项目索赔合计
  805. Node45 := FFixedIDList.FixedIDBillsNode(45);
  806. WriteFixedIDData(AProjectIndex, Node45, '工程项目索赔合计');
  807. if Assigned(Node45) then
  808. begin
  809. fTotalPrice := fTotalPrice + Node45.TotalPrice;
  810. fP_TotalPrice := fP_TotalPrice + Node45.P_TotalPrice[AProjectIndex];
  811. fAddGatherTotalPrice := fAddGatherTotalPrice + Node45.AddGatherTotalPrice;
  812. fP_AddGatherTotalPrice := fP_AddGatherTotalPrice + Node45.P_AddGatherTotalPrice[AProjectIndex];
  813. end;
  814. // 计日工支出合计
  815. Node40 := FFixedIDList.FixedIDBillsNode(40);
  816. WriteFixedIDData(AProjectIndex, Node40, '计日工支出合计');
  817. if Assigned(Node40) then
  818. begin
  819. fTotalPrice := fTotalPrice + Node40.TotalPrice;
  820. fP_TotalPrice := fP_TotalPrice + Node40.P_TotalPrice[AProjectIndex];
  821. fAddGatherTotalPrice := fAddGatherTotalPrice + Node40.AddGatherTotalPrice;
  822. fP_AddGatherTotalPrice := fP_AddGatherTotalPrice + Node40.P_AddGatherTotalPrice[AProjectIndex];
  823. end;
  824. // 金额合计
  825. cdsProjectGclBills.Append;
  826. cdsProjectGclBillsProjectID.AsInteger := AProjectIndex;
  827. cdsProjectGclBillsProjectName.AsString := FGclList.ProjectName[AProjectIndex];
  828. cdsProjectGclBillsName.AsString := '金额合计';
  829. cdsProjectGclBillsTotalPrice.AsFloat := fTotalPrice;
  830. cdsProjectGclBillsP_TotalPrice.AsFloat := fP_TotalPrice;
  831. cdsProjectGclBillsAddGatherTotalPrice.AsFloat := fAddGatherTotalPrice;
  832. cdsProjectGclBillsP_AddGatherTotalPrice.AsFloat := fP_AddGatherTotalPrice;
  833. cdsProjectGclBillsSerialNo.AsInteger := FSerialNo;
  834. cdsProjectGclBills.Post;
  835. Inc(FSerialNo);
  836. // 设备费
  837. Node51 := FFixedIDList.FixedIDBillsNode(51);
  838. WriteFixedIDData(AProjectIndex, Node51, '设备费');
  839. end;
  840. procedure WriteFixedIDBillsData11(AProjectIndex: Integer);
  841. var
  842. fTotalPrice, fP_TotalPrice, fAddGatherTotalPrice, fP_AddGatherTotalPrice: Double;
  843. Node19, Node40, NodeTotal: TFixedIDBillsNode;
  844. begin
  845. fTotalPrice := FGclList.GatherNode.TotalPrice;
  846. fP_TotalPrice := FGclList.GatherNode.P_TotalPrice[AProjectIndex];
  847. fAddGatherTotalPrice := FGclList.GatherNode.AddDealTotalPrice
  848. + FGclList.GatherNode.AddQcTotalPrice + FGclList.GatherNode.AddPcTotalPrice;
  849. fP_AddGatherTotalPrice := FGclList.GatherNode.P_AddGatherTotalPrice[AProjectIndex];
  850. // 计日工合计
  851. Node40 := FFixedIDList.FixedIDBillsNode(40);
  852. WriteFixedIDData(AProjectIndex, Node40, '计日工合计');
  853. if Assigned(Node40) then
  854. begin
  855. fTotalPrice := fTotalPrice + Node40.TotalPrice;
  856. fP_TotalPrice := fP_TotalPrice + Node40.P_TotalPrice[AProjectIndex];
  857. fAddGatherTotalPrice := fTotalPrice + Node40.AddGatherTotalPrice;
  858. fP_AddGatherTotalPrice := fP_TotalPrice + Node40.P_AddGatherTotalPrice[AProjectIndex];
  859. end;
  860. // 暂列金额合计
  861. Node19 := FFixedIDList.FixedIDBillsNode(19);
  862. WriteFixedIDData(AProjectIndex, Node19, '暂列金额合计');
  863. if Assigned(Node19) then
  864. begin
  865. fTotalPrice := fTotalPrice + Node19.TotalPrice;
  866. fP_TotalPrice := fP_TotalPrice + Node19.P_TotalPrice[AProjectIndex];
  867. fAddGatherTotalPrice := fTotalPrice + Node19.AddGatherTotalPrice;
  868. fP_AddGatherTotalPrice := fP_TotalPrice + Node19.P_AddGatherTotalPrice[AProjectIndex];
  869. end;
  870. // 其他类别费用合计&金额合计
  871. NodeTotal := FFixedIDList.FixedIDBillsNode(-1);
  872. // 其他类别费用 = 金额合计 - 第100章至900章合计 - 计日工合计 - 暂列金额合计
  873. if Assigned(NodeTotal) then
  874. begin
  875. fTotalPrice := NodeTotal.TotalPrice - fTotalPrice;
  876. fP_TotalPrice := NodeTotal.P_TotalPrice[AProjectIndex] - fP_TotalPrice;
  877. fAddGatherTotalPrice := NodeTotal.AddGatherTotalPrice - fAddGatherTotalPrice;
  878. fP_AddGatherTotalPrice := NodeTotal.P_AddGatherTotalPrice[AProjectIndex] - fP_AddGatherTotalPrice;
  879. end;
  880. cdsProjectGclBills.Append;
  881. cdsProjectGclBillsProjectID.AsInteger := AProjectIndex;
  882. cdsProjectGclBillsProjectName.AsString := FGclList.ProjectName[AProjectIndex];
  883. cdsProjectGclBillsName.AsString := '其他类别费用合计';
  884. cdsProjectGclBillsTotalPrice.AsFloat := fTotalPrice;
  885. cdsProjectGclBillsP_TotalPrice.AsFloat := fP_TotalPrice;
  886. cdsProjectGclBillsAddGatherTotalPrice.AsFloat := fAddGatherTotalPrice;
  887. cdsProjectGclBillsP_AddGatherTotalPrice.AsFloat := fP_AddGatherTotalPrice;
  888. cdsProjectGclBillsSerialNo.AsInteger := FSerialNo;
  889. cdsProjectGclBills.Post;
  890. Inc(FSerialNo);
  891. WriteFixedIDData(AProjectIndex, NodeTotal, '金额合计');
  892. end;
  893. var
  894. iProject: Integer;
  895. begin
  896. for iProject := 0 to FGclList.ProjectCount - 1 do
  897. begin
  898. FSerialNo := 0;
  899. WriteProjectGclData(iProject);
  900. WriteGatherNodeData(iProject);
  901. case GatherType of
  902. bgtFinal07: WriteFixedIDBillsData07(iProject);
  903. bgtFinal11: WriteFixedIDBillsData11(iProject);
  904. end;
  905. end;
  906. end;
  907. procedure TrmBillsGatherData.FilterSettlement(AProjectData: TProjectData;
  908. AProjectIndex: Integer);
  909. var
  910. FixedIDNode: TFixedIDBillsNode;
  911. begin
  912. // -1表示项目结算价
  913. FixedIDNode := FFixedIDList.GetFixedIDBillsNode(-1);
  914. FixedIDNode.TotalPrice := FixedIDNode.TotalPrice + AProjectData.BillsData.Settlement[0];
  915. FixedIDNode.P_TotalPrice[AProjectIndex] := AProjectData.BillsData.Settlement[0];
  916. FixedIDNode.AddGatherTotalPrice := FixedIDNode.AddGatherTotalPrice
  917. + AProjectData.BillsData.Settlement[4];
  918. FixedIDNode.P_AddGatherTotalPrice[AProjectIndex] :=
  919. AProjectData.BillsData.Settlement[4];
  920. end;
  921. procedure TrmBillsGatherData.WriteFlowData(AProjectData: TProjectData);
  922. begin
  923. case GatherType of
  924. bgtFinal12: WriteBGLFlowData(AProjectData);
  925. end;
  926. end;
  927. procedure TrmBillsGatherData.WriteBGLFlowData(AProjectData: TProjectData);
  928. procedure WriteBGLData(ABGLID: Integer);
  929. begin
  930. with AProjectData.BGLData do
  931. begin
  932. cdsBGBills.Filter := 'BGID = ' + IntToStr(ABGLID);
  933. cdsBGBills.Filtered := True;
  934. try
  935. if cdsBGBills.RecordCount = 0 then
  936. begin
  937. cdsBGLFlow.Append;
  938. cdsBGLFlowMergeBGLCode.AsString := cdsBGLCode.AsString;
  939. cdsBGLFlowBGLName.AsString := cdsBGLName.AsString;
  940. cdsBGLFlowApprovalCode.AsString := cdsBGLApprovalCode.AsString;
  941. cdsBGLFlowSuggestion.AsString := '同意';
  942. cdsBGLFlowBGReason.AsString := cdsBGLPos_Reason.AsString;
  943. cdsBGLFlowBGTotalPrice.AsFloat := cdsBGLTotalPrice.AsFloat;
  944. cdsBGLFlow.Post;
  945. Exit;
  946. end;
  947. cdsBGBills.First;
  948. while not cdsBGBills.Eof do
  949. begin
  950. cdsBGLFlow.Append;
  951. cdsBGLFlowMergeBGLCode.AsString := cdsBGLCode.AsString;
  952. cdsBGLFlowBGLName.AsString := cdsBGLName.AsString;
  953. cdsBGLFlowApprovalCode.AsString := cdsBGLApprovalCode.AsString;
  954. cdsBGLFlowSuggestion.AsString := '同意';
  955. cdsBGLFlowBGReason.AsString := cdsBGLPos_Reason.AsString;
  956. cdsBGLFlowBGTotalPrice.AsFloat := cdsBGLTotalPrice.AsFloat;
  957. cdsBGLFlowB_Code.AsString := cdsBGBillsB_Code.AsString;
  958. cdsBGLFlowName.AsString := cdsBGBillsName.AsString;
  959. cdsBGLFlowUnits.AsString := cdsBGBillsUnits.AsString;
  960. cdsBGLFlowQuantity.AsFloat := cdsBGBillsQuantity.AsFloat;
  961. cdsBGLFlowPrice.AsFloat := cdsBGBillsPrice.AsFloat;
  962. cdsBGLFlowTotalPrice.AsFloat := cdsBGBillsTotalPrice.AsFloat;
  963. cdsBGLFlow.Post;
  964. cdsBGBills.Next;
  965. end;
  966. finally
  967. cdsBGBills.Filtered := False;
  968. end;
  969. end;
  970. end;
  971. begin
  972. cdsBGLFlow.Append;
  973. cdsBGLFlowMergeBGLCode.AsString := AProjectData.ProjProperties.DealIndex;
  974. cdsBGLFlow.Post;
  975. with AProjectData.BGLData do
  976. begin
  977. cdsBGL.First;
  978. while not cdsBGL.Eof do
  979. begin
  980. WriteBGLData(cdsBGLID.AsInteger);
  981. cdsBGL.Next;
  982. end;
  983. end;
  984. end;
  985. procedure TrmBillsGatherData.AddBillsList(ANode: TsdIDTreeNode;
  986. AParent: TReportCacheNode; AProjectIndex: Integer;
  987. ASelectProject: TSelectProject);
  988. var
  989. ACur: TReportCacheNode;
  990. begin
  991. if not Assigned(ANode) then Exit;
  992. // 按设置的层次汇总
  993. case ReportConfig.GatherLevel of
  994. // 项
  995. 0: if ANode.Level > 2 then Exit;
  996. // 目
  997. 1: if ANode.Level > 3 then Exit;
  998. // 节
  999. 2: if ANode.Level > 4 then Exit;
  1000. // 细目
  1001. 3: if ANode.Level > 5 then Exit;
  1002. // 项目节
  1003. 4: if ANode.Rec.ValueByName('B_Code').AsString <> '' then Exit;
  1004. end;
  1005. if GatherType in [bgtXmj, bgtMultiXmj, bgtEstimate, bgtEstimate1] then
  1006. if ANode.Rec.ValueByName('B_Code').AsString <> '' then Exit;
  1007. ACur := AddBillsNode(ANode, AParent, AProjectIndex, ASelectProject);
  1008. AddBills(ANode.FirstChild, ACur, AProjectIndex, ASelectProject);
  1009. end;
  1010. procedure TrmBillsGatherData.WriteGatherCacheNode(const AGatherName: string);
  1011. begin
  1012. cdsFxBills.Append;
  1013. cdsFxBillsName.AsString := AGatherName;
  1014. with FCacheTree.GatherCacheNode do
  1015. begin
  1016. cdsFxBillsAddDealTotalPrice.AsFloat := AddDealTotalPrice;
  1017. cdsFxBillsAddQcTotalPrice.AsFloat := AddQcTotalPrice;
  1018. cdsFxBillsAddPcTotalPrice.AsFloat := AddPcTotalPrice;
  1019. cdsFxBillsAddGatherTotalPrice.AsFloat := AddDealTotalPrice +
  1020. AddQcTotalPrice + AddPcTotalPrice;
  1021. cdsFxBillsTotalPrice.AsFloat := TotalPrice;
  1022. end;
  1023. cdsFxBills.Post;
  1024. end;
  1025. procedure TrmBillsGatherData.CalculateGatherData;
  1026. begin
  1027. if GatherType in [bgtFinal08, bgtFinal16, bgtEstimate1, bgtG_Final04] then
  1028. FCacheTree.ReCalcGatherData;
  1029. if GatherType in [bgtFinal07, bgtFinal11, bgtFinal19] then
  1030. FGclList.ReCalcualteGatherNode;
  1031. end;
  1032. procedure TrmBillsGatherData.WriteBillsData;
  1033. begin
  1034. WriteNode(TReportCacheNode(FCacheTree.FirstNode));
  1035. case GatherType of
  1036. bgtFinal08: WriteGatherCacheNode('金额合计');
  1037. bgtG_Final04: WriteGatherCacheNode('公路基本造价');
  1038. end;
  1039. end;
  1040. procedure TrmBillsGatherData.WriteEstimateGatherNode;
  1041. begin
  1042. cdsEstimateBills.Append;
  1043. cdsEstimateBillsName.AsString := '公路基本造价';
  1044. with FCacheTree.GatherCacheNode do
  1045. begin
  1046. cdsEstimateBillsTotalPrice.AsFloat := TotalPrice;
  1047. cdsEstimateBillsAddDealTotalPrice.AsFloat := AddDealTotalPrice;
  1048. cdsEstimateBillsAddCTotalPrice.AsFloat := AddQcTotalPrice + AddPcTotalPrice;
  1049. cdsEstimateBillsAddGatherTotalPrice.AsFloat :=
  1050. cdsEstimateBillsAddDealTotalPrice.AsFloat + cdsEstimateBillsAddCTotalPrice.AsFloat;
  1051. cdsEstimateBillsTotalPriceAdjust.AsFloat :=
  1052. cdsEstimateBillsAddGatherTotalPrice.AsFloat - cdsEstimateBillsPDTotalPrice.AsFloat;
  1053. cdsEstimateBillsPDTotalPrice.AsFloat := PDTotalPrice;
  1054. cdsEstimateBillsCDDTotalPrice.AsFloat := CDDTotalPrice;
  1055. cdsEstimateBillsABTotalPrice.AsFloat := ABTotalPrice;
  1056. cdsEstimateBillsTotalPriceCompare1.AsFloat := GetCompare(ABTotalPrice, TotalPrice);
  1057. cdsEstimateBillsTotalPriceCompare2.AsFloat :=
  1058. GetCompare(ABTotalPrice, cdsEstimateBillsAddGatherTotalPrice.AsFloat);
  1059. cdsEstimateBillsTotalPriceCompare3.AsFloat :=
  1060. GetCompare(TotalPrice, cdsEstimateBillsAddGatherTotalPrice.AsFloat);
  1061. end;
  1062. cdsEstimateBills.Post;
  1063. end;
  1064. procedure TrmBillsGatherData.WriteEstimateData;
  1065. begin
  1066. WriteEstimateNode(TReportCacheNode(FCacheTree.FirstNode));
  1067. if GatherType = bgtG_Final06_1 then
  1068. ReWriteENodeDataAsGather(TReportCacheNode(FCacheTree.FirstNode), '土地征用及拆迁补偿费用合计');
  1069. if GatherType = bgtEstimate1 then
  1070. WriteEstimateGatherNode;
  1071. end;
  1072. function TrmBillsGatherData.GetCompare(ANum1, ANum2: Double): Double;
  1073. begin
  1074. Result := 0;
  1075. if ANum1 <> 0 then
  1076. Result := (ANum2 - ANum1)/ANum1*100;
  1077. end;
  1078. procedure TrmBillsGatherData.WriteENodeData(ANode: TReportCacheNode);
  1079. begin
  1080. cdsEstimateBills.Append;
  1081. cdsEstimateBillsXiangCode.AsString := ANode.XiangCode;
  1082. cdsEstimateBillsMuCode.AsString := ANode.MuCode;
  1083. cdsEstimateBillsJieCode.AsString := ANode.JieCode;
  1084. cdsEstimateBillsXiMuCode.AsString := ANode.XiMuCode;
  1085. cdsEstimateBillsCode.AsString := ANode.Code;
  1086. cdsEstimateBillsB_Code.AsString := ANode.B_Code;
  1087. cdsEstimateBillsName.AsString := ANode.Name;
  1088. cdsEstimateBillsUnits.AsString := ANode.Units;
  1089. cdsEstimateBillsPrice.AsFloat := ANode.Price;
  1090. cdsEstimateBillsQuantity.AsFloat := ANode.Quantity;
  1091. cdsEstimateBillsTotalPrice.AsFloat := ANode.TotalPrice;
  1092. cdsEstimateBillsDgnQuantity1.AsFloat := ANode.DesignQuantity1;
  1093. cdsEstimateBillsDgnQuantity2.AsFloat := ANode.DesignQuantity2;
  1094. cdsEstimateBillsDgnQuantity.AsString :=
  1095. GetDgnQuantity(cdsEstimateBillsDgnQuantity1.AsFloat, cdsEstimateBillsDgnQuantity2.AsFloat);
  1096. cdsEstimateBillsAddDealQuantity.AsFloat := ANode.AddDealQuantity;
  1097. cdsEstimateBillsAddDealTotalPrice.AsFloat := ANode.AddDealTotalPrice;
  1098. cdsEstimateBillsAddCQuantity.AsFloat := ANode.AddQcQuantity;
  1099. cdsEstimateBillsAddCTotalPrice.AsFloat := ANode.AddQcTotalPrice + ANode.AddPcTotalPrice;
  1100. cdsEstimateBillsAddGatherQuantity.AsFloat :=
  1101. cdsEstimateBillsAddDealQuantity.AsFloat + cdsEstimateBillsAddCQuantity.AsFloat;
  1102. cdsEstimateBillsAddGatherTotalPrice.AsFloat :=
  1103. cdsEstimateBillsAddDealTotalPrice.AsFloat + cdsEstimateBillsAddCTotalPrice.AsFloat;
  1104. cdsEstimateBillsQuantityAdjust.AsFloat :=
  1105. cdsEstimateBillsAddGatherQuantity.AsFloat - cdsEstimateBillsPDQuantity.AsFloat;
  1106. cdsEstimateBillsTotalPriceAdjust.AsFloat :=
  1107. cdsEstimateBillsAddGatherTotalPrice.AsFloat - cdsEstimateBillsPDTotalPrice.AsFloat;
  1108. cdsEstimateBillsDealDgnQuantity1.AsFloat := ANode.DealDesignQuantity1;
  1109. cdsEstimateBillsDealDgnQuantity2.AsFloat := ANode.DealDesignQuantity2;
  1110. cdsEstimateBillsDealDgnQuantity.AsString :=
  1111. GetDgnQuantity(cdsEstimateBillsDealDgnQuantity1.AsFloat, cdsEstimateBillsDealDgnQuantity2.AsFloat);
  1112. cdsEstimateBillsCDgnQuantity1.AsFloat := ANode.CDesignQuantity1;
  1113. cdsEstimateBillsCDgnQuantity2.AsFloat := ANode.CDesignQuantity2;
  1114. cdsEstimateBillsCDgnQuantity.AsString :=
  1115. GetDgnQuantity(cdsEstimateBillsCDgnQuantity1.AsFloat, cdsEstimateBillsCDgnQuantity2.AsFloat);
  1116. cdsEstimateBillsGatherDgnQuantity1.AsFloat :=
  1117. cdsEstimateBillsDealDgnQuantity1.AsFloat + cdsEstimateBillsCDgnQuantity1.AsFloat;
  1118. cdsEstimateBillsGatherDgnQuantity2.AsFloat :=
  1119. cdsEstimateBillsDealDgnQuantity2.AsFloat + cdsEstimateBillsCDgnQuantity2.AsFloat;;
  1120. cdsEstimateBillsGatherDgnQuantity.AsString :=
  1121. GetDgnQuantity(cdsEstimateBillsGatherDgnQuantity1.AsFloat, cdsEstimateBillsGatherDgnQuantity2.AsFloat);
  1122. cdsEstimateBillsPDQuantity.AsFloat := ANode.PDQuantity;
  1123. cdsEstimateBillsPDTotalPrice.AsFloat := ANode.PDTotalPrice;
  1124. cdsEstimateBillsPDDgnQuantity1.AsFloat := ANode.PDDesignQuantity1;
  1125. cdsEstimateBillsPDDgnQuantity2.AsFloat := ANode.PDDesignQuantity2;
  1126. cdsEstimateBillsPDDgnQuantity.AsString :=
  1127. GetDgnQuantity(cdsEstimateBillsPDDgnQuantity1.AsFloat, cdsEstimateBillsPDDgnQuantity2.AsFloat);
  1128. cdsEstimateBillsPDDgnPrice.AsFloat := ANode.PDDesignPrice;
  1129. cdsEstimateBillsCDDQuantity.AsFloat := ANode.CDDQuantity;
  1130. cdsEstimateBillsCDDTotalPrice.AsFloat := ANode.CDDTotalPrice;
  1131. cdsEstimateBillsCDDDgnQuantity1.AsFloat := ANode.CDDDesignQuantity1;
  1132. cdsEstimateBillsCDDDgnQuantity2.AsFloat := ANode.CDDDesignQuantity2;
  1133. cdsEstimateBillsCDDDgnQuantity.AsString :=
  1134. GetDgnQuantity(cdsEstimateBillsCDDDgnQuantity1.AsFloat, cdsEstimateBillsCDDDgnQuantity2.AsFloat);
  1135. cdsEstimateBillsCDDDgnPrice.AsFloat := ANode.CDDDesignPrice;
  1136. cdsEstimateBillsABQuantity.AsFloat := ANode.ABQuantity;
  1137. cdsEstimateBillsABTotalPrice.AsFloat := ANode.ABTotalPrice;
  1138. cdsEstimateBillsABDgnQuantity1.AsFloat := ANode.ABDesignQuantity1;
  1139. cdsEstimateBillsABDgnQuantity2.AsFloat := ANode.ABDesignQuantity2;
  1140. cdsEstimateBillsABDgnQuantity.AsString :=
  1141. GetDgnQuantity(cdsEstimateBillsABDgnQuantity1.AsFloat, cdsEstimateBillsABDgnQuantity2.AsFloat);
  1142. cdsEstimateBillsABDgnPrice.AsFloat := ANode.ABDesignPrice;
  1143. cdsEstimateBillsQuantityCompare1.AsFloat := GetCompare(ANode.ABQuantity, ANode.Quantity);
  1144. cdsEstimateBillsTotalPriceCompare1.AsFloat := GetCompare(ANode.ABTotalPrice, ANode.TotalPrice);
  1145. cdsEstimateBillsDgnQuantity1Compare1.AsFloat := GetCompare(
  1146. cdsEstimateBillsABDgnQuantity1.AsFloat, cdsEstimateBillsDgnQuantity1.AsFloat);
  1147. cdsEstimateBillsDgnQuantity2Compare1.AsFloat := GetCompare(
  1148. cdsEstimateBillsABDgnQuantity2.AsFloat, cdsEstimateBillsDgnQuantity2.AsFloat);
  1149. cdsEstimateBillsDgnQuantityCompare1.AsString := GetDgnQuantity(
  1150. cdsEstimateBillsDgnQuantity1Compare1.AsFloat, cdsEstimateBillsDgnQuantity2Compare1.AsFloat);
  1151. cdsEstimateBillsQuantityCompare2.AsFloat :=
  1152. GetCompare(ANode.ABQuantity, cdsEstimateBillsAddGatherQuantity.AsFloat);
  1153. cdsEstimateBillsTotalPriceCompare2.AsFloat :=
  1154. GetCompare(ANode.ABTotalPrice, cdsEstimateBillsAddGatherTotalPrice.AsFloat);
  1155. cdsEstimateBillsDgnQuantity1Compare2.AsFloat := GetCompare(
  1156. cdsEstimateBillsABDgnQuantity1.AsFloat, cdsEstimateBillsGatherDgnQuantity1.AsFloat);
  1157. cdsEstimateBillsDgnQuantity2Compare2.AsFloat := GetCompare(
  1158. cdsEstimateBillsABDgnQuantity2.AsFloat, cdsEstimateBillsGatherDgnQuantity2.AsFloat);
  1159. cdsEstimateBillsDgnQuantityCompare2.AsString := GetDgnQuantity(
  1160. cdsEstimateBillsDgnQuantity1Compare2.AsFloat, cdsEstimateBillsDgnQuantity2Compare2.AsFloat);
  1161. cdsEstimateBillsQuantityCompare3.AsFloat :=
  1162. GetCompare(ANode.Quantity, cdsEstimateBillsAddGatherQuantity.AsFloat);
  1163. cdsEstimateBillsTotalPriceCompare3.AsFloat :=
  1164. GetCompare(ANode.TotalPrice, cdsEstimateBillsAddGatherTotalPrice.AsFloat);
  1165. cdsEstimateBillsDgnQuantity1Compare3.AsFloat := GetCompare(
  1166. cdsEstimateBillsDgnQuantity1.AsFloat, cdsEstimateBillsGatherDgnQuantity1.AsFloat);
  1167. cdsEstimateBillsDgnQuantity2Compare3.AsFloat := GetCompare(
  1168. cdsEstimateBillsDgnQuantity2.AsFloat, cdsEstimateBillsGatherDgnQuantity2.AsFloat);
  1169. cdsEstimateBillsDgnQuantityCompare3.AsString := GetDgnQuantity(
  1170. cdsEstimateBillsDgnQuantity1Compare3.AsFloat, cdsEstimateBillsDgnQuantity2Compare3.AsFloat);
  1171. cdsEstimateBills.Post;
  1172. end;
  1173. procedure TrmBillsGatherData.ReWriteENodeDataAsGather(
  1174. ANode: TReportCacheNode; AName: string);
  1175. begin
  1176. WriteENodeData(ANode);
  1177. cdsEstimateBills.Edit;
  1178. cdsEstimateBillsXiangCode.AsString := '';
  1179. cdsEstimateBillsMuCode.AsString := '';
  1180. cdsEstimateBillsJieCode.AsString := '';
  1181. cdsEstimateBillsXiMuCode.AsString := '';
  1182. cdsEstimateBillsCode.AsString := '';
  1183. cdsEstimateBillsName.AsString := AName;
  1184. cdsEstimateBillsUnits.AsString := '';
  1185. cdsEstimateBills.Post;
  1186. end;
  1187. function TrmBillsGatherData.GetDgnQuantity(ANum1, ANum2: Double): string;
  1188. begin
  1189. Result := '';
  1190. if ANum1 <> 0 then
  1191. begin
  1192. Result := FloatToStr(ANum1);
  1193. if ANum2 <> 0 then
  1194. Result := Result + '/' + FloatToStr(ANum2);
  1195. end;
  1196. end;
  1197. procedure TrmBillsGatherData.CalculateRatioPercent;
  1198. begin
  1199. if GatherType = bgtG_Final04 then
  1200. FCacheTree.ReCalcGatherData;
  1201. end;
  1202. function TrmBillsGatherData.GetDgnPrice(ATotalPrice,
  1203. ADgnQuantity: Double): Double;
  1204. begin
  1205. if ADgnQuantity <> 0 then
  1206. Result := PriceRoundTo(ATotalPrice/ADgnQuantity)
  1207. else
  1208. Result := 0;
  1209. end;
  1210. end.