rmBillsGatherDm.pas 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303
  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. var
  452. GclNode: TGclGatherNode;
  453. begin
  454. if not Assigned(ANode) then Exit;
  455. GclNode := FGclList.GetGclGatherNode(ANode.Rec);
  456. with ANode.Rec do
  457. begin
  458. GclNode.Quantity := GclNode.Quantity + ValueByName('Quantity').AsFloat;
  459. GclNode.TotalPrice := GclNode.TotalPrice + ValueByName('TotalPrice').AsFloat;
  460. GclNode.AddDealQuantity := GclNode.AddDealQuantity + ValueByName('AddDealQuantity').AsFloat;
  461. GclNode.AddDealTotalPrice := GclNode.AddDealTotalPrice + ValueByName('AddDealTotalPrice').AsFloat;
  462. GclNode.AddQcQuantity := GclNode.AddQcQuantity + ValueByName('AddQcQuantity').AsFloat;
  463. GclNode.AddQcTotalPrice := GclNode.AddQcTotalPrice + ValueByName('AddQcTotalPrice').AsFloat;
  464. GclNode.AddPcQuantity := GclNode.AddPcQuantity + ValueByName('AddPcQuantity').AsFloat;
  465. GclNode.AddPcTotalPrice := GclNode.AddPcTotalPrice + ValueByName('AddPcTotalPrice').AsFloat;
  466. GclNode.P_Price[AProjectIndex] := ValueByName('Price').AsFloat;
  467. GclNode.P_Quantity[AProjectIndex] := GclNode.P_Quantity[AProjectIndex] + ValueByName('Quantity').AsFloat;
  468. GclNode.P_TotalPrice[AProjectIndex] := GclNode.P_TotalPrice[AProjectIndex] + ValueByName('TotalPrice').AsFloat;
  469. GclNode.P_AddGatherQuantity[AProjectIndex] :=
  470. GclNode.P_AddGatherQuantity[AProjectIndex] + ValueByName('AddGatherQuantity').AsFloat;
  471. GclNode.P_AddGatherTotalPrice[AProjectIndex] :=
  472. GclNode.P_AddGatherTotalPrice[AProjectIndex] + ValueByName('AddGatherTotalPrice').AsFloat;
  473. end;
  474. end;
  475. procedure TrmBillsGatherData.FreeProjectData;
  476. begin
  477. if not Assigned(OpenProjectManager.FindProjectData(FProjectData.ProjectID)) then
  478. FProjectData.Free;
  479. end;
  480. procedure TrmBillsGatherData.GatherProject(AProject: TSelectProject;
  481. AProjectIndex: Integer);
  482. begin
  483. OpenProjectData(AProject, AProjectIndex);
  484. try
  485. case GatherType of
  486. bgtFinal08: // 08表 取第二部分下所有项目节
  487. AddBills(FProjectData.BillsCompileData.BillsCompileTree.FindNode(2).FirstChild, nil, AProjectIndex, AProject);
  488. bgtFinal09: // 09表 取第三部分及其后所有项目节
  489. AddBills(FProjectData.BillsCompileData.BillsCompileTree.FindNode(3), nil, AProjectIndex, AProject);
  490. bgtGcl, bgtFinal07, bgtFinal11, bgtFinal19:
  491. FilterBills(FProjectData.BillsCompileData.BillsCompileTree.FirstNode, AProjectIndex);
  492. bgtFinal12: // 不做数据汇总,直接流水式写入数据
  493. WriteFlowData(FProjectData);
  494. bgtFinal16: // 16表 仅汇总计日工及其子节点
  495. AddBillsList(FProjectData.BillsCompileData.BillsCompileTree.FindNode(40), nil, AProjectIndex, AProject);
  496. bgtFinal17: // 17表 仅汇总收尾工程及其子节点
  497. AddBillsList(FProjectData.BillsCompileData.BillsCompileTree.FindNode(47), nil, AProjectIndex, AProject);
  498. bgtFinal18: // 18表 仅汇总报废工程及其子节点
  499. AddBillsList(FProjectData.BillsCompileData.BillsCompileTree.FindNode(48), nil, AProjectIndex, AProject);
  500. bgtG_Final06_1: // 粤竣06-1表 仅汇总土地及其子节点
  501. AddBillsList(FProjectData.BillsCompileData.BillsCompileTree.FindNode(21), nil, AProjectIndex, AProject);
  502. else
  503. AddBills(FProjectData.BillsCompileData.BillsCompileTree.FirstNode, nil, AProjectIndex, AProject)
  504. end;
  505. if GatherType in [bgtFinal07, bgtFinal11, bgtFinal19] then
  506. FilterFixedIDBills(FProjectData.BillsCompileData.BillsCompileTree, AProjectIndex);
  507. if GatherType = bgtFinal11 then
  508. FilterSettlement(FProjectData, AProjectIndex);
  509. finally
  510. FreeProjectData;
  511. end;
  512. end;
  513. procedure TrmBillsGatherData.OpenProjectData(AProject: TSelectProject;
  514. AProjectIndex: Integer);
  515. var
  516. Rec: TsdDataRecord;
  517. begin
  518. FProjectData := OpenProjectManager.FindProjectData(AProject.ProjectID);
  519. Rec := ProjectManager.sddProjectsInfo.FindKey('idxID', AProject.ProjectID);
  520. if not Assigned(FProjectData) then
  521. begin
  522. FProjectData := TProjectData.Create;
  523. FProjectData.OpenForReport(GetMyProjectsFilePath + Rec.ValueByName('FileName').AsString);
  524. end;
  525. FProjectName := Rec.ValueByName('Name').AsString;
  526. FCacheTree.ProjectName[AProjectIndex] := Rec.ValueByName('Name').AsString;
  527. FGclList.ProjectName[AProjectIndex] := Rec.ValueByName('Name').AsString;
  528. end;
  529. procedure TrmBillsGatherData.WriteData;
  530. begin
  531. case GatherType of
  532. bgtFx, bgtXmj, bgtFinal08, bgtFinal09, bgtFinal17, bgtFinal18, bgtG_Final04:
  533. WriteBillsData;
  534. bgtGcl:
  535. WriteGclNode;
  536. bgtMultiXmj, bgtFinal16:
  537. WriteProjectsData;
  538. bgtEstimate, bgtEstimate1, bgtG_Final06_1:
  539. WriteEstimateData;
  540. bgtFinal07, bgtFinal11, bgtFinal19: // 07&11特别的,其中还写入了部分固定ID节点 !!丧心病狂的报表!!
  541. WriteProjectsGclData;
  542. end;
  543. end;
  544. procedure TrmBillsGatherData.WriteNode(ANode: TReportCacheNode);
  545. begin
  546. if not Assigned(ANode) then Exit;
  547. cdsFxBills.Append;
  548. cdsFxBillsXiangCode.AsString := ANode.XiangCode;
  549. cdsFxBillsMuCode.AsString := ANode.MuCode;
  550. cdsFxBillsJieCode.AsString := ANode.JieCode;
  551. cdsFxBillsXiMuCode.AsString := ANode.XiMuCode;
  552. cdsFxBillsCode.AsString := ANode.Code;
  553. cdsFxBillsB_Code.AsString := ANode.B_Code;
  554. cdsFxBillsName.AsString := ANode.Name;
  555. cdsFxBillsUnits.AsString := ANode.Units;
  556. cdsFxBillsPrice.AsFloat := ANode.Price;
  557. cdsFxBillsAddDealQuantity.AsFloat := ANode.AddDealQuantity;
  558. cdsFxBillsAddDealTotalPrice.AsFloat := ANode.AddDealTotalPrice;
  559. cdsFxBillsAddQcQuantity.AsFloat := ANode.AddQcQuantity;
  560. cdsFxBillsAddQcTotalPrice.AsFloat := ANode.AddQcTotalPrice;
  561. cdsFxBillsAddPcQuantity.AsFloat := ANode.AddPcQuantity;
  562. cdsFxBillsAddPcTotalPrice.AsFloat := ANode.AddPcTotalPrice;
  563. cdsFxBillsAddGatherQuantity.AsFloat := ANode.AddDealQuantity + ANode.AddQcQuantity;
  564. cdsFxBillsAddGatherTotalPrice.AsFloat := ANode.AddDealTotalPrice +
  565. ANode.AddQcTotalPrice + ANode.AddPcTotalPrice;
  566. cdsFxBillsAddRatioPercent.AsFloat := ANode.AddRatioPercent;
  567. cdsFxBillsQuantity.AsFloat := ANode.Quantity;
  568. cdsFxBillsTotalPrice.AsFloat := ANode.TotalPrice;
  569. cdsFxBillsRatioPercent.AsFloat := ANode.RatioPercent;
  570. cdsFxBillsDgnQuantity1.AsFloat := ANode.DesignQuantity1;
  571. cdsFxBillsDgnQuantity2.AsFloat := ANode.DesignQuantity2;
  572. cdsFxBillsDgnQuantity.AsString := GetDgnQuantity(ANode.DesignQuantity1, ANode.DesignQuantity2);
  573. if ANode.DesignQuantity1 <> 0 then
  574. cdsFxBillsDgnPrice1.AsFloat := PriceRoundTo(ANode.TotalPrice/ANode.DesignQuantity1);
  575. if ANode.DesignQuantity2 <> 0 then
  576. cdsFxBillsDgnPrice2.AsFloat := PriceRoundTo(ANode.TotalPrice/ANode.DesignQuantity2);
  577. if cdsFxBillsDgnPrice1.AsFloat <> 0 then
  578. cdsFxBillsDgnPrice.AsString := GetDgnQuantity(cdsFxBillsDgnPrice1.AsFloat, cdsFxBillsDgnPrice2.AsFloat);
  579. cdsFxBills.Post;
  580. WriteNode(TReportCacheNode(ANode.FirstChild));
  581. WriteNode(TReportCacheNode(ANode.NextSibling));
  582. end;
  583. procedure TrmBillsGatherData.WriteGclNode;
  584. var
  585. i: Integer;
  586. GclNode: TGclGatherNode;
  587. begin
  588. for i := 0 to FGclList.Count - 1 do
  589. begin
  590. GclNode := FGclList.Node[i];
  591. cdsGclBills.Append;
  592. cdsGclBillsB_Code.AsString := GclNode.B_Code;
  593. cdsGclBillsIndexCode.AsString := GclNode.IndexCode;
  594. cdsGclBillsName.AsString := GclNode.Name;
  595. cdsGclBillsUnits.AsString := GclNode.Units;
  596. cdsGclBillsPrice.AsFloat := GclNode.Price;
  597. cdsGclBillsAddDealQuantity.AsFloat := GclNode.AddDealQuantity;
  598. cdsGclBillsAddDealTotalPrice.AsFloat := GclNode.AddDealTotalPrice;
  599. cdsGclBillsAddQcQuantity.AsFloat := GclNode.AddQcQuantity;
  600. cdsGclBillsAddQcTotalPrice.AsFloat := GclNode.AddQcTotalPrice;
  601. cdsGclBillsAddPcQuantity.AsFloat := GclNode.AddPcQuantity;
  602. cdsGclBillsAddPcTotalPrice.AsFloat := GclNode.AddPcTotalPrice;
  603. cdsGclBillsAddGatherQuantity.AsFloat := GclNode.AddDealQuantity + GclNode.AddQcQuantity;
  604. cdsGclBillsAddDealTotalPrice.AsFloat := GclNode.AddDealTotalPrice +
  605. GclNode.AddQcTotalPrice + GclNode.AddPcTotalPrice;
  606. cdsGclBillsPrecent.AsFloat := 0;
  607. cdsGclBillsMemoStr.AsString := '';
  608. cdsGclBills.Post;
  609. end;
  610. end;
  611. procedure TrmBillsGatherData.WriteProjectsData;
  612. procedure WriteProjectData(ANode: TReportCacheNode; AProjectIndex: Integer);
  613. begin
  614. if not Assigned(ANode) then Exit;
  615. cdsProjectBills.Append;
  616. cdsProjectBillsProjectID.AsInteger := AProjectIndex;
  617. cdsProjectBillsProjectName.AsString := FCacheTree.ProjectName[AProjectIndex];
  618. cdsProjectBillsXiangCode.AsString := ANode.XiangCode;
  619. cdsProjectBillsMuCode.AsString := ANode.MuCode;
  620. cdsProjectBillsJieCode.AsString := ANode.JieCode;
  621. cdsProjectBillsXiMuCode.AsString := ANode.XiMuCode;
  622. cdsProjectBillsCode.AsString := ANode.Code;
  623. cdsProjectBillsB_Code.AsString := ANode.B_Code;
  624. cdsProjectBillsName.AsString := ANode.Name;
  625. cdsProjectBillsUnits.AsString := ANode.Units;
  626. // 此处数量与金额特指所有项目的累计完成数量与金额汇总。
  627. cdsProjectBillsQuantity.AsFloat := ANode.AddDealQuantity + ANode.AddQcQuantity;
  628. cdsProjectBillsTotalPrice.AsFloat := ANode.AddDealTotalPrice + ANode.AddQcTotalPrice + ANode.AddPcTotalPrice;
  629. cdsProjectBillsP_Quantity.AsFloat := ANode.P_Quantity[AProjectIndex];
  630. cdsProjectBillsP_TotalPrice.AsFloat := ANode.P_TotalPrice[AProjectIndex];
  631. cdsProjectBillsP_Price.AsFloat := ANode.P_Price[AProjectIndex];
  632. cdsProjectBillsSerialNo.AsInteger := FSerialNo;
  633. cdsProjectBills.Post;
  634. Inc(FSerialNo);
  635. WriteProjectData(TReportCacheNode(ANode.FirstChild), AProjectIndex);
  636. WriteProjectData(TReportCacheNode(ANode.NextSibling), AProjectIndex);
  637. end;
  638. procedure WriteProjectGatherData(AProjectIndex: Integer);
  639. begin
  640. cdsProjectBills.Append;
  641. cdsProjectBillsProjectID.AsInteger := AProjectIndex;
  642. cdsProjectBillsProjectName.AsString := FCacheTree.ProjectName[AProjectIndex];
  643. cdsProjectBillsName.AsString := '金额合计';
  644. with FCacheTree.GatherCacheNode do
  645. begin
  646. cdsProjectBillsTotalPrice.AsFloat := AddDealTotalPrice + AddQcTotalPrice + AddPcTotalPrice;
  647. cdsProjectBillsP_TotalPrice.AsFloat := P_TotalPrice[AProjectIndex];
  648. end;
  649. cdsProjectBillsSerialNo.AsInteger := FSerialNo;
  650. cdsProjectBills.Post;
  651. Inc(FSerialNo);
  652. cdsProjectBills.Append;
  653. cdsProjectBillsProjectID.AsInteger := AProjectIndex;
  654. cdsProjectBillsProjectName.AsString := FCacheTree.ProjectName[AProjectIndex];
  655. cdsProjectBillsName.AsString := Format('金额总计:%f', [FCacheTree.GatherCacheNode.GatherP_TotalPrice]);
  656. cdsProjectBillsSerialNo.AsInteger := FSerialNo;
  657. cdsProjectBills.Post;
  658. Inc(FSerialNo);
  659. end;
  660. var
  661. i: Integer;
  662. begin
  663. for i := 0 to FCacheTree.ProjectCount - 1 do
  664. begin
  665. FSerialNo := 0;
  666. WriteProjectData(TReportCacheNode(FCacheTree.FirstNode), i);
  667. if GatherType = bgtFinal16 then
  668. WriteProjectGatherData(i);
  669. end;
  670. end;
  671. procedure TrmBillsGatherData.WriteEstimateNode(ANode: TReportCacheNode);
  672. begin
  673. if not Assigned(ANode) then Exit;
  674. WriteENodeData(ANode);
  675. WriteEstimateNode(TReportCacheNode(ANode.FirstChild));
  676. WriteEstimateNode(TReportCacheNode(ANode.NextSibling));
  677. end;
  678. procedure TrmBillsGatherData.FilterFixedIDBills(ATree: TsdIDTree;
  679. AProjectIndex: Integer);
  680. var
  681. iIndex: Integer;
  682. stnNode: TsdIDTreeNode;
  683. FixedIDNode: TFixedIDBillsNode;
  684. begin
  685. for iIndex := 0 to ATree.Count - 1 do
  686. begin
  687. stnNode := ATree.Items[iIndex];
  688. if stnNode.ID >= 100 then Continue;
  689. FixedIDNode := FFixedIDList.GetFixedIDBillsNode(stnNode.ID);
  690. FixedIDNode.AddGatherTotalPrice := FixedIDNode.AddGatherTotalPrice
  691. + stnNode.Rec.ValueByName('AddGatherTotalPrice').AsFloat;
  692. FixedIDNode.P_AddGatherTotalPrice[AProjectIndex] :=
  693. stnNode.Rec.ValueByName('AddGatherTotalPrice').AsFloat;
  694. end;
  695. end;
  696. procedure TrmBillsGatherData.WriteProjectsGclData;
  697. procedure WriteProjectGclData(AProjectIndex: Integer);
  698. var
  699. i: Integer;
  700. GclNode: TGclGatherNode;
  701. begin
  702. for i := 0 to FGclList.Count - 1 do
  703. begin
  704. GclNode := FGclList.Node[i];
  705. cdsProjectGclBills.Append;
  706. cdsProjectGclBillsProjectID.AsInteger := AProjectIndex;
  707. cdsProjectGclBillsProjectName.AsString := FGclList.ProjectName[AProjectIndex];
  708. cdsProjectGclBillsB_Code.AsString := GclNode.B_Code;
  709. cdsProjectGclBillsIndexCode.AsString := GclNode.IndexCode;
  710. cdsProjectGclBillsName.AsString := GclNode.Name;
  711. cdsProjectGclBillsUnits.AsString := GclNode.Units;
  712. cdsProjectGclBillsQuantity.AsFloat := GclNode.Quantity;
  713. cdsProjectGclBillsTotalPrice.AsFloat := GclNode.TotalPrice;
  714. // Price须填写合计平均单价
  715. if cdsProjectGclBillsQuantity.AsFloat <> 0 then
  716. cdsProjectGclBillsPrice.AsFloat := cdsProjectGclBillsTotalPrice.AsFloat/cdsProjectGclBillsQuantity.AsFloat;
  717. cdsProjectGclBillsP_Price.AsFloat := GclNode.P_Price[AProjectIndex];
  718. cdsProjectGclBillsP_Quantity.AsFloat := GclNode.P_Quantity[AProjectIndex];
  719. cdsProjectGclBillsP_TotalPrice.AsFloat := GclNode.P_TotalPrice[AProjectIndex];
  720. cdsProjectGclBillsP_AddGatherQuantity.AsFloat := GclNode.P_AddGatherQuantity[AProjectIndex];
  721. cdsProjectGclBillsP_AddGatherTotalPrice.AsFloat := GclNode.P_AddGatherTotalPrice[AProjectIndex];
  722. cdsProjectGclBillsAddGatherQuantity.AsFloat := GclNode.AddDealQuantity + GclNode.AddQcQuantity;
  723. cdsProjectGclBillsAddGatherTotalPrice.AsFloat := GclNode.AddDealTotalPrice
  724. + GclNode.AddQcTotalPrice + GclNode.AddPcTotalPrice;
  725. cdsProjectGclBillsSerialNo.AsInteger := FSerialNo;
  726. cdsProjectGclBills.Post;
  727. end;
  728. Inc(FSerialNo);
  729. end;
  730. procedure WriteGatherNodeData(AProjectIndex: Integer);
  731. begin
  732. cdsProjectGclBills.Append;
  733. cdsProjectGclBillsProjectID.AsInteger := AProjectIndex;
  734. cdsProjectGclBillsProjectName.AsString := FGclList.ProjectName[AProjectIndex];
  735. case GatherType of
  736. bgtFinal07: cdsProjectGclBillsName.AsString := '小计';
  737. bgtFinal11: cdsProjectGclBillsName.AsString := '第100章至900章清单合计';
  738. bgtFinal19: cdsProjectGclBillsName.AsString := '合计';
  739. end;
  740. cdsProjectGclBillsTotalPrice.AsFloat := FGclList.GatherNode.TotalPrice;
  741. cdsProjectGclBillsP_TotalPrice.AsFloat := FGclList.GatherNode.P_TotalPrice[AProjectIndex];
  742. cdsProjectGclBillsAddGatherTotalPrice.AsFloat := FGclList.GatherNode.AddDealTotalPrice
  743. + FGclList.GatherNode.AddQcTotalPrice + FGclList.GatherNode.AddPcTotalPrice;
  744. cdsProjectGclBillsP_AddGatherTotalPrice.AsFloat := FGclList.GatherNode.P_AddGatherTotalPrice[AProjectIndex];
  745. cdsProjectGclBillsSerialNo.AsInteger := FSerialNo;
  746. cdsProjectGclBills.Post;
  747. Inc(FSerialNo);
  748. end;
  749. procedure WriteFixedIDData(AProjectIndex: Integer; ANode: TFixedIDBillsNode; const AName: string);
  750. begin
  751. cdsProjectGclBills.Append;
  752. cdsProjectGclBillsProjectID.AsInteger := AProjectIndex;
  753. cdsProjectGclBillsProjectName.AsString := FGclList.ProjectName[AProjectIndex];
  754. cdsProjectGclBillsName.AsString := AName;
  755. if Assigned(ANode) then
  756. begin
  757. cdsProjectGclBillsTotalPrice.AsFloat := ANode.TotalPrice;
  758. cdsProjectGclBillsP_TotalPrice.AsFloat := ANode.P_TotalPrice[AProjectIndex];
  759. cdsProjectGclBillsAddGatherTotalPrice.AsFloat := ANode.AddGatherTotalPrice;
  760. cdsProjectGclBillsP_AddGatherTotalPrice.AsFloat := ANode.P_AddGatherTotalPrice[AProjectIndex];
  761. end;
  762. cdsProjectGclBillsSerialNo.AsInteger := FSerialNo;
  763. cdsProjectGclBills.Post;
  764. end;
  765. procedure WriteFixedIDBillsData07(AProjectIndex: Integer);
  766. var
  767. fTotalPrice, fP_TotalPrice, fAddGatherTotalPrice, fP_AddGatherTotalPrice: Double;
  768. Node17, Node45, Node40, Node51: TFixedIDBillsNode;
  769. begin
  770. fTotalPrice := FGclList.GatherNode.TotalPrice;
  771. fP_TotalPrice := FGclList.GatherNode.P_TotalPrice[AProjectIndex];
  772. fAddGatherTotalPrice := FGclList.GatherNode.AddDealTotalPrice
  773. + FGclList.GatherNode.AddQcTotalPrice + FGclList.GatherNode.AddPcTotalPrice;
  774. fP_AddGatherTotalPrice := FGclList.GatherNode.P_AddGatherTotalPrice[AProjectIndex];
  775. // 变更引起调整合计 全部取0
  776. cdsProjectGclBills.Append;
  777. cdsProjectGclBillsProjectID.AsInteger := AProjectIndex;
  778. cdsProjectGclBillsProjectName.AsString := FGclList.ProjectName[AProjectIndex];
  779. cdsProjectGclBillsName.AsString := '变更引起调整合计';
  780. cdsProjectGclBillsSerialNo.AsInteger := FSerialNo;
  781. cdsProjectGclBills.Post;
  782. Inc(FSerialNo);
  783. // 工程项目调价合计
  784. Node17 := FFixedIDList.FixedIDBillsNode(17);
  785. WriteFixedIDData(AProjectIndex, Node17, '工程项目调价合计');
  786. if Assigned(Node17) then
  787. begin
  788. fTotalPrice := fTotalPrice + Node17.TotalPrice;
  789. fP_TotalPrice := fP_TotalPrice + Node17.P_TotalPrice[AProjectIndex];
  790. fAddGatherTotalPrice := fAddGatherTotalPrice + Node17.AddGatherTotalPrice;
  791. fP_AddGatherTotalPrice := fP_AddGatherTotalPrice + Node17.P_AddGatherTotalPrice[AProjectIndex];
  792. end;
  793. // 工程项目索赔合计
  794. Node45 := FFixedIDList.FixedIDBillsNode(45);
  795. WriteFixedIDData(AProjectIndex, Node45, '工程项目索赔合计');
  796. if Assigned(Node45) then
  797. begin
  798. fTotalPrice := fTotalPrice + Node45.TotalPrice;
  799. fP_TotalPrice := fP_TotalPrice + Node45.P_TotalPrice[AProjectIndex];
  800. fAddGatherTotalPrice := fAddGatherTotalPrice + Node45.AddGatherTotalPrice;
  801. fP_AddGatherTotalPrice := fP_AddGatherTotalPrice + Node45.P_AddGatherTotalPrice[AProjectIndex];
  802. end;
  803. // 计日工支出合计
  804. Node40 := FFixedIDList.FixedIDBillsNode(40);
  805. WriteFixedIDData(AProjectIndex, Node40, '计日工支出合计');
  806. if Assigned(Node40) then
  807. begin
  808. fTotalPrice := fTotalPrice + Node40.TotalPrice;
  809. fP_TotalPrice := fP_TotalPrice + Node40.P_TotalPrice[AProjectIndex];
  810. fAddGatherTotalPrice := fAddGatherTotalPrice + Node40.AddGatherTotalPrice;
  811. fP_AddGatherTotalPrice := fP_AddGatherTotalPrice + Node40.P_AddGatherTotalPrice[AProjectIndex];
  812. end;
  813. // 金额合计
  814. cdsProjectGclBills.Append;
  815. cdsProjectGclBillsProjectID.AsInteger := AProjectIndex;
  816. cdsProjectGclBillsProjectName.AsString := FGclList.ProjectName[AProjectIndex];
  817. cdsProjectGclBillsName.AsString := '金额合计';
  818. cdsProjectGclBillsTotalPrice.AsFloat := fTotalPrice;
  819. cdsProjectGclBillsP_TotalPrice.AsFloat := fP_TotalPrice;
  820. cdsProjectGclBillsAddGatherTotalPrice.AsFloat := fAddGatherTotalPrice;
  821. cdsProjectGclBillsP_AddGatherTotalPrice.AsFloat := fP_AddGatherTotalPrice;
  822. cdsProjectGclBillsSerialNo.AsInteger := FSerialNo;
  823. cdsProjectGclBills.Post;
  824. Inc(FSerialNo);
  825. // 设备费
  826. Node51 := FFixedIDList.FixedIDBillsNode(51);
  827. WriteFixedIDData(AProjectIndex, Node51, '设备费');
  828. end;
  829. procedure WriteFixedIDBillsData11(AProjectIndex: Integer);
  830. var
  831. fTotalPrice, fP_TotalPrice, fAddGatherTotalPrice, fP_AddGatherTotalPrice: Double;
  832. Node19, Node40, NodeTotal: TFixedIDBillsNode;
  833. begin
  834. fTotalPrice := FGclList.GatherNode.TotalPrice;
  835. fP_TotalPrice := FGclList.GatherNode.P_TotalPrice[AProjectIndex];
  836. fAddGatherTotalPrice := FGclList.GatherNode.AddDealTotalPrice
  837. + FGclList.GatherNode.AddQcTotalPrice + FGclList.GatherNode.AddPcTotalPrice;
  838. fP_AddGatherTotalPrice := FGclList.GatherNode.P_AddGatherTotalPrice[AProjectIndex];
  839. // 计日工合计
  840. Node40 := FFixedIDList.FixedIDBillsNode(40);
  841. WriteFixedIDData(AProjectIndex, Node40, '计日工合计');
  842. if Assigned(Node40) then
  843. begin
  844. fTotalPrice := fTotalPrice + Node40.TotalPrice;
  845. fP_TotalPrice := fP_TotalPrice + Node40.P_TotalPrice[AProjectIndex];
  846. fAddGatherTotalPrice := fTotalPrice + Node40.AddGatherTotalPrice;
  847. fP_AddGatherTotalPrice := fP_TotalPrice + Node40.P_AddGatherTotalPrice[AProjectIndex];
  848. end;
  849. // 暂列金额合计
  850. Node19 := FFixedIDList.FixedIDBillsNode(19);
  851. WriteFixedIDData(AProjectIndex, Node19, '暂列金额合计');
  852. if Assigned(Node19) then
  853. begin
  854. fTotalPrice := fTotalPrice + Node19.TotalPrice;
  855. fP_TotalPrice := fP_TotalPrice + Node19.P_TotalPrice[AProjectIndex];
  856. fAddGatherTotalPrice := fTotalPrice + Node19.AddGatherTotalPrice;
  857. fP_AddGatherTotalPrice := fP_TotalPrice + Node19.P_AddGatherTotalPrice[AProjectIndex];
  858. end;
  859. // 其他类别费用合计&金额合计
  860. NodeTotal := FFixedIDList.FixedIDBillsNode(-1);
  861. // 其他类别费用 = 金额合计 - 第100章至900章合计 - 计日工合计 - 暂列金额合计
  862. if Assigned(NodeTotal) then
  863. begin
  864. fTotalPrice := NodeTotal.TotalPrice - fTotalPrice;
  865. fP_TotalPrice := NodeTotal.P_TotalPrice[AProjectIndex] - fP_TotalPrice;
  866. fAddGatherTotalPrice := NodeTotal.AddGatherTotalPrice - fAddGatherTotalPrice;
  867. fP_AddGatherTotalPrice := NodeTotal.P_AddGatherTotalPrice[AProjectIndex] - fP_AddGatherTotalPrice;
  868. end;
  869. cdsProjectGclBills.Append;
  870. cdsProjectGclBillsProjectID.AsInteger := AProjectIndex;
  871. cdsProjectGclBillsProjectName.AsString := FGclList.ProjectName[AProjectIndex];
  872. cdsProjectGclBillsName.AsString := '其他类别费用合计';
  873. cdsProjectGclBillsTotalPrice.AsFloat := fTotalPrice;
  874. cdsProjectGclBillsP_TotalPrice.AsFloat := fP_TotalPrice;
  875. cdsProjectGclBillsAddGatherTotalPrice.AsFloat := fAddGatherTotalPrice;
  876. cdsProjectGclBillsP_AddGatherTotalPrice.AsFloat := fP_AddGatherTotalPrice;
  877. cdsProjectGclBillsSerialNo.AsInteger := FSerialNo;
  878. cdsProjectGclBills.Post;
  879. Inc(FSerialNo);
  880. WriteFixedIDData(AProjectIndex, NodeTotal, '金额合计');
  881. end;
  882. var
  883. iProject: Integer;
  884. begin
  885. for iProject := 0 to FGclList.ProjectCount - 1 do
  886. begin
  887. FSerialNo := 0;
  888. WriteProjectGclData(iProject);
  889. WriteGatherNodeData(iProject);
  890. case GatherType of
  891. bgtFinal07: WriteFixedIDBillsData07(iProject);
  892. bgtFinal11: WriteFixedIDBillsData11(iProject);
  893. end;
  894. end;
  895. end;
  896. procedure TrmBillsGatherData.FilterSettlement(AProjectData: TProjectData;
  897. AProjectIndex: Integer);
  898. var
  899. FixedIDNode: TFixedIDBillsNode;
  900. begin
  901. // -1表示项目结算价
  902. FixedIDNode := FFixedIDList.GetFixedIDBillsNode(-1);
  903. FixedIDNode.TotalPrice := FixedIDNode.TotalPrice + AProjectData.BillsData.Settlement[0];
  904. FixedIDNode.P_TotalPrice[AProjectIndex] := AProjectData.BillsData.Settlement[0];
  905. FixedIDNode.AddGatherTotalPrice := FixedIDNode.AddGatherTotalPrice
  906. + AProjectData.BillsData.Settlement[4];
  907. FixedIDNode.P_AddGatherTotalPrice[AProjectIndex] :=
  908. AProjectData.BillsData.Settlement[4];
  909. end;
  910. procedure TrmBillsGatherData.WriteFlowData(AProjectData: TProjectData);
  911. begin
  912. case GatherType of
  913. bgtFinal12: WriteBGLFlowData(AProjectData);
  914. end;
  915. end;
  916. procedure TrmBillsGatherData.WriteBGLFlowData(AProjectData: TProjectData);
  917. procedure WriteBGLData(ABGLID: Integer);
  918. begin
  919. with AProjectData.BGLData do
  920. begin
  921. cdsBGBills.Filter := 'BGID = ' + IntToStr(ABGLID);
  922. cdsBGBills.Filtered := True;
  923. try
  924. if cdsBGBills.RecordCount = 0 then
  925. begin
  926. cdsBGLFlow.Append;
  927. cdsBGLFlowMergeBGLCode.AsString := cdsBGLCode.AsString;
  928. cdsBGLFlowBGLName.AsString := cdsBGLName.AsString;
  929. cdsBGLFlowApprovalCode.AsString := cdsBGLApprovalCode.AsString;
  930. cdsBGLFlowSuggestion.AsString := '同意';
  931. cdsBGLFlowBGReason.AsString := cdsBGLPos_Reason.AsString;
  932. cdsBGLFlowBGTotalPrice.AsFloat := cdsBGLTotalPrice.AsFloat;
  933. cdsBGLFlow.Post;
  934. Exit;
  935. end;
  936. cdsBGBills.First;
  937. while not cdsBGBills.Eof do
  938. begin
  939. cdsBGLFlow.Append;
  940. cdsBGLFlowMergeBGLCode.AsString := cdsBGLCode.AsString;
  941. cdsBGLFlowBGLName.AsString := cdsBGLName.AsString;
  942. cdsBGLFlowApprovalCode.AsString := cdsBGLApprovalCode.AsString;
  943. cdsBGLFlowSuggestion.AsString := '同意';
  944. cdsBGLFlowBGReason.AsString := cdsBGLPos_Reason.AsString;
  945. cdsBGLFlowBGTotalPrice.AsFloat := cdsBGLTotalPrice.AsFloat;
  946. cdsBGLFlowB_Code.AsString := cdsBGBillsB_Code.AsString;
  947. cdsBGLFlowName.AsString := cdsBGBillsName.AsString;
  948. cdsBGLFlowUnits.AsString := cdsBGBillsUnits.AsString;
  949. cdsBGLFlowQuantity.AsFloat := cdsBGBillsQuantity.AsFloat;
  950. cdsBGLFlowPrice.AsFloat := cdsBGBillsPrice.AsFloat;
  951. cdsBGLFlowTotalPrice.AsFloat := cdsBGBillsTotalPrice.AsFloat;
  952. cdsBGLFlow.Post;
  953. cdsBGBills.Next;
  954. end;
  955. finally
  956. cdsBGBills.Filtered := False;
  957. end;
  958. end;
  959. end;
  960. begin
  961. cdsBGLFlow.Append;
  962. cdsBGLFlowMergeBGLCode.AsString := AProjectData.ProjProperties.DealIndex;
  963. cdsBGLFlow.Post;
  964. with AProjectData.BGLData do
  965. begin
  966. cdsBGL.First;
  967. while not cdsBGL.Eof do
  968. begin
  969. WriteBGLData(cdsBGLID.AsInteger);
  970. cdsBGL.Next;
  971. end;
  972. end;
  973. end;
  974. procedure TrmBillsGatherData.AddBillsList(ANode: TsdIDTreeNode;
  975. AParent: TReportCacheNode; AProjectIndex: Integer;
  976. ASelectProject: TSelectProject);
  977. var
  978. ACur: TReportCacheNode;
  979. begin
  980. if not Assigned(ANode) then Exit;
  981. // 按设置的层次汇总
  982. case ReportConfig.GatherLevel of
  983. // 项
  984. 0: if ANode.Level > 2 then Exit;
  985. // 目
  986. 1: if ANode.Level > 3 then Exit;
  987. // 节
  988. 2: if ANode.Level > 4 then Exit;
  989. // 细目
  990. 3: if ANode.Level > 5 then Exit;
  991. // 项目节
  992. 4: if ANode.Rec.ValueByName('B_Code').AsString <> '' then Exit;
  993. end;
  994. if GatherType in [bgtXmj, bgtMultiXmj, bgtEstimate, bgtEstimate1] then
  995. if ANode.Rec.ValueByName('B_Code').AsString <> '' then Exit;
  996. ACur := AddBillsNode(ANode, AParent, AProjectIndex, ASelectProject);
  997. AddBills(ANode.FirstChild, ACur, AProjectIndex, ASelectProject);
  998. end;
  999. procedure TrmBillsGatherData.WriteGatherCacheNode(const AGatherName: string);
  1000. begin
  1001. cdsFxBills.Append;
  1002. cdsFxBillsName.AsString := AGatherName;
  1003. with FCacheTree.GatherCacheNode do
  1004. begin
  1005. cdsFxBillsAddDealTotalPrice.AsFloat := AddDealTotalPrice;
  1006. cdsFxBillsAddQcTotalPrice.AsFloat := AddQcTotalPrice;
  1007. cdsFxBillsAddPcTotalPrice.AsFloat := AddPcTotalPrice;
  1008. cdsFxBillsAddGatherTotalPrice.AsFloat := AddDealTotalPrice +
  1009. AddQcTotalPrice + AddPcTotalPrice;
  1010. cdsFxBillsTotalPrice.AsFloat := TotalPrice;
  1011. end;
  1012. cdsFxBills.Post;
  1013. end;
  1014. procedure TrmBillsGatherData.CalculateGatherData;
  1015. begin
  1016. if GatherType in [bgtFinal08, bgtFinal16, bgtEstimate1, bgtG_Final04] then
  1017. FCacheTree.ReCalcGatherData;
  1018. if GatherType in [bgtFinal07, bgtFinal11, bgtFinal19] then
  1019. FGclList.ReCalcualteGatherNode;
  1020. end;
  1021. procedure TrmBillsGatherData.WriteBillsData;
  1022. begin
  1023. WriteNode(TReportCacheNode(FCacheTree.FirstNode));
  1024. case GatherType of
  1025. bgtFinal08: WriteGatherCacheNode('金额合计');
  1026. bgtG_Final04: WriteGatherCacheNode('公路基本造价');
  1027. end;
  1028. end;
  1029. procedure TrmBillsGatherData.WriteEstimateGatherNode;
  1030. begin
  1031. cdsEstimateBills.Append;
  1032. cdsEstimateBillsName.AsString := '公路基本造价';
  1033. with FCacheTree.GatherCacheNode do
  1034. begin
  1035. cdsEstimateBillsTotalPrice.AsFloat := TotalPrice;
  1036. cdsEstimateBillsAddDealTotalPrice.AsFloat := AddDealTotalPrice;
  1037. cdsEstimateBillsAddCTotalPrice.AsFloat := AddQcTotalPrice + AddPcTotalPrice;
  1038. cdsEstimateBillsAddGatherTotalPrice.AsFloat :=
  1039. cdsEstimateBillsAddDealTotalPrice.AsFloat + cdsEstimateBillsAddCTotalPrice.AsFloat;
  1040. cdsEstimateBillsTotalPriceAdjust.AsFloat :=
  1041. cdsEstimateBillsAddGatherTotalPrice.AsFloat - cdsEstimateBillsPDTotalPrice.AsFloat;
  1042. cdsEstimateBillsPDTotalPrice.AsFloat := PDTotalPrice;
  1043. cdsEstimateBillsCDDTotalPrice.AsFloat := CDDTotalPrice;
  1044. cdsEstimateBillsABTotalPrice.AsFloat := ABTotalPrice;
  1045. cdsEstimateBillsTotalPriceCompare1.AsFloat := GetCompare(ABTotalPrice, TotalPrice);
  1046. cdsEstimateBillsTotalPriceCompare2.AsFloat :=
  1047. GetCompare(ABTotalPrice, cdsEstimateBillsAddGatherTotalPrice.AsFloat);
  1048. cdsEstimateBillsTotalPriceCompare3.AsFloat :=
  1049. GetCompare(TotalPrice, cdsEstimateBillsAddGatherTotalPrice.AsFloat);
  1050. end;
  1051. cdsEstimateBills.Post;
  1052. end;
  1053. procedure TrmBillsGatherData.WriteEstimateData;
  1054. begin
  1055. WriteEstimateNode(TReportCacheNode(FCacheTree.FirstNode));
  1056. if GatherType = bgtG_Final06_1 then
  1057. ReWriteENodeDataAsGather(TReportCacheNode(FCacheTree.FirstNode), '土地征用及拆迁补偿费用合计');
  1058. if GatherType = bgtEstimate1 then
  1059. WriteEstimateGatherNode;
  1060. end;
  1061. function TrmBillsGatherData.GetCompare(ANum1, ANum2: Double): Double;
  1062. begin
  1063. Result := 0;
  1064. if ANum1 <> 0 then
  1065. Result := (ANum2 - ANum1)/ANum1*100;
  1066. end;
  1067. procedure TrmBillsGatherData.WriteENodeData(ANode: TReportCacheNode);
  1068. begin
  1069. cdsEstimateBills.Append;
  1070. cdsEstimateBillsXiangCode.AsString := ANode.XiangCode;
  1071. cdsEstimateBillsMuCode.AsString := ANode.MuCode;
  1072. cdsEstimateBillsJieCode.AsString := ANode.JieCode;
  1073. cdsEstimateBillsXiMuCode.AsString := ANode.XiMuCode;
  1074. cdsEstimateBillsCode.AsString := ANode.Code;
  1075. cdsEstimateBillsB_Code.AsString := ANode.B_Code;
  1076. cdsEstimateBillsName.AsString := ANode.Name;
  1077. cdsEstimateBillsUnits.AsString := ANode.Units;
  1078. cdsEstimateBillsPrice.AsFloat := ANode.Price;
  1079. cdsEstimateBillsQuantity.AsFloat := ANode.Quantity;
  1080. cdsEstimateBillsTotalPrice.AsFloat := ANode.TotalPrice;
  1081. cdsEstimateBillsDgnQuantity1.AsFloat := ANode.DesignQuantity1;
  1082. cdsEstimateBillsDgnQuantity2.AsFloat := ANode.DesignQuantity2;
  1083. cdsEstimateBillsDgnQuantity.AsString :=
  1084. GetDgnQuantity(cdsEstimateBillsDgnQuantity1.AsFloat, cdsEstimateBillsDgnQuantity2.AsFloat);
  1085. cdsEstimateBillsAddDealQuantity.AsFloat := ANode.AddDealQuantity;
  1086. cdsEstimateBillsAddDealTotalPrice.AsFloat := ANode.AddDealTotalPrice;
  1087. cdsEstimateBillsAddCQuantity.AsFloat := ANode.AddQcQuantity;
  1088. cdsEstimateBillsAddCTotalPrice.AsFloat := ANode.AddQcTotalPrice + ANode.AddPcTotalPrice;
  1089. cdsEstimateBillsAddGatherQuantity.AsFloat :=
  1090. cdsEstimateBillsAddDealQuantity.AsFloat + cdsEstimateBillsAddCQuantity.AsFloat;
  1091. cdsEstimateBillsAddGatherTotalPrice.AsFloat :=
  1092. cdsEstimateBillsAddDealTotalPrice.AsFloat + cdsEstimateBillsAddCTotalPrice.AsFloat;
  1093. cdsEstimateBillsQuantityAdjust.AsFloat :=
  1094. cdsEstimateBillsAddGatherQuantity.AsFloat - cdsEstimateBillsPDQuantity.AsFloat;
  1095. cdsEstimateBillsTotalPriceAdjust.AsFloat :=
  1096. cdsEstimateBillsAddGatherTotalPrice.AsFloat - cdsEstimateBillsPDTotalPrice.AsFloat;
  1097. cdsEstimateBillsDealDgnQuantity1.AsFloat := ANode.DealDesignQuantity1;
  1098. cdsEstimateBillsDealDgnQuantity2.AsFloat := ANode.DealDesignQuantity2;
  1099. cdsEstimateBillsDealDgnQuantity.AsString :=
  1100. GetDgnQuantity(cdsEstimateBillsDealDgnQuantity1.AsFloat, cdsEstimateBillsDealDgnQuantity2.AsFloat);
  1101. cdsEstimateBillsCDgnQuantity1.AsFloat := ANode.CDesignQuantity1;
  1102. cdsEstimateBillsCDgnQuantity2.AsFloat := ANode.CDesignQuantity2;
  1103. cdsEstimateBillsCDgnQuantity.AsString :=
  1104. GetDgnQuantity(cdsEstimateBillsCDgnQuantity1.AsFloat, cdsEstimateBillsCDgnQuantity2.AsFloat);
  1105. cdsEstimateBillsGatherDgnQuantity1.AsFloat :=
  1106. cdsEstimateBillsDealDgnQuantity1.AsFloat + cdsEstimateBillsDealDgnQuantity1.AsFloat;
  1107. cdsEstimateBillsGatherDgnQuantity2.AsFloat :=
  1108. cdsEstimateBillsDealDgnQuantity2.AsFloat + cdsEstimateBillsDealDgnQuantity2.AsFloat;;
  1109. cdsEstimateBillsGatherDgnQuantity.AsString :=
  1110. GetDgnQuantity(cdsEstimateBillsGatherDgnQuantity1.AsFloat, cdsEstimateBillsGatherDgnQuantity2.AsFloat);
  1111. cdsEstimateBillsPDQuantity.AsFloat := ANode.PDQuantity;
  1112. cdsEstimateBillsPDTotalPrice.AsFloat := ANode.PDTotalPrice;
  1113. cdsEstimateBillsPDDgnQuantity1.AsFloat := ANode.PDDesignQuantity1;
  1114. cdsEstimateBillsPDDgnQuantity2.AsFloat := ANode.PDDesignQuantity2;
  1115. cdsEstimateBillsPDDgnQuantity.AsString :=
  1116. GetDgnQuantity(cdsEstimateBillsPDDgnQuantity1.AsFloat, cdsEstimateBillsPDDgnQuantity2.AsFloat);
  1117. cdsEstimateBillsPDDgnPrice.AsFloat := ANode.PDDesignPrice;
  1118. cdsEstimateBillsCDDQuantity.AsFloat := ANode.CDDQuantity;
  1119. cdsEstimateBillsCDDTotalPrice.AsFloat := ANode.CDDTotalPrice;
  1120. cdsEstimateBillsCDDDgnQuantity1.AsFloat := ANode.CDDDesignQuantity1;
  1121. cdsEstimateBillsCDDDgnQuantity2.AsFloat := ANode.CDDDesignQuantity2;
  1122. cdsEstimateBillsCDDDgnQuantity.AsString :=
  1123. GetDgnQuantity(cdsEstimateBillsCDDDgnQuantity1.AsFloat, cdsEstimateBillsCDDDgnQuantity2.AsFloat);
  1124. cdsEstimateBillsCDDDgnPrice.AsFloat := ANode.CDDDesignPrice;
  1125. cdsEstimateBillsABQuantity.AsFloat := ANode.ABQuantity;
  1126. cdsEstimateBillsABTotalPrice.AsFloat := ANode.ABTotalPrice;
  1127. cdsEstimateBillsABDgnQuantity1.AsFloat := ANode.ABDesignQuantity1;
  1128. cdsEstimateBillsABDgnQuantity2.AsFloat := ANode.ABDesignQuantity2;
  1129. cdsEstimateBillsABDgnQuantity.AsString :=
  1130. GetDgnQuantity(cdsEstimateBillsABDgnQuantity1.AsFloat, cdsEstimateBillsABDgnQuantity2.AsFloat);
  1131. cdsEstimateBillsABDgnPrice.AsFloat := ANode.ABDesignPrice;
  1132. cdsEstimateBillsQuantityCompare1.AsFloat := GetCompare(ANode.ABQuantity, ANode.Quantity);
  1133. cdsEstimateBillsTotalPriceCompare1.AsFloat := GetCompare(ANode.ABTotalPrice, ANode.TotalPrice);
  1134. cdsEstimateBillsDgnQuantity1Compare1.AsFloat := GetCompare(
  1135. cdsEstimateBillsABDgnQuantity1.AsFloat, cdsEstimateBillsDgnQuantity1.AsFloat);
  1136. cdsEstimateBillsDgnQuantity2Compare1.AsFloat := GetCompare(
  1137. cdsEstimateBillsABDgnQuantity2.AsFloat, cdsEstimateBillsDgnQuantity2.AsFloat);
  1138. cdsEstimateBillsDgnQuantityCompare1.AsString := GetDgnQuantity(
  1139. cdsEstimateBillsDgnQuantity1Compare1.AsFloat, cdsEstimateBillsDgnQuantity2Compare1.AsFloat);
  1140. cdsEstimateBillsQuantityCompare2.AsFloat :=
  1141. GetCompare(ANode.ABQuantity, cdsEstimateBillsAddGatherQuantity.AsFloat);
  1142. cdsEstimateBillsTotalPriceCompare2.AsFloat :=
  1143. GetCompare(ANode.ABTotalPrice, cdsEstimateBillsAddGatherTotalPrice.AsFloat);
  1144. cdsEstimateBillsDgnQuantity1Compare2.AsFloat := GetCompare(
  1145. cdsEstimateBillsABDgnQuantity1.AsFloat, cdsEstimateBillsGatherDgnQuantity1.AsFloat);
  1146. cdsEstimateBillsDgnQuantity2Compare2.AsFloat := GetCompare(
  1147. cdsEstimateBillsABDgnQuantity2.AsFloat, cdsEstimateBillsGatherDgnQuantity2.AsFloat);
  1148. cdsEstimateBillsDgnQuantityCompare2.AsString := GetDgnQuantity(
  1149. cdsEstimateBillsDgnQuantity1Compare2.AsFloat, cdsEstimateBillsDgnQuantity2Compare2.AsFloat);
  1150. cdsEstimateBillsQuantityCompare3.AsFloat :=
  1151. GetCompare(ANode.Quantity, cdsEstimateBillsAddGatherQuantity.AsFloat);
  1152. cdsEstimateBillsTotalPriceCompare3.AsFloat :=
  1153. GetCompare(ANode.TotalPrice, cdsEstimateBillsAddGatherTotalPrice.AsFloat);
  1154. cdsEstimateBillsDgnQuantity1Compare3.AsFloat := GetCompare(
  1155. cdsEstimateBillsDgnQuantity1.AsFloat, cdsEstimateBillsGatherDgnQuantity1.AsFloat);
  1156. cdsEstimateBillsDgnQuantity2Compare3.AsFloat := GetCompare(
  1157. cdsEstimateBillsDgnQuantity2.AsFloat, cdsEstimateBillsGatherDgnQuantity2.AsFloat);
  1158. cdsEstimateBillsDgnQuantityCompare3.AsString := GetDgnQuantity(
  1159. cdsEstimateBillsDgnQuantity1Compare3.AsFloat, cdsEstimateBillsDgnQuantity2Compare3.AsFloat);
  1160. cdsEstimateBills.Post;
  1161. end;
  1162. procedure TrmBillsGatherData.ReWriteENodeDataAsGather(
  1163. ANode: TReportCacheNode; AName: string);
  1164. begin
  1165. WriteENodeData(ANode);
  1166. cdsEstimateBills.Edit;
  1167. cdsEstimateBillsXiangCode.AsString := '';
  1168. cdsEstimateBillsMuCode.AsString := '';
  1169. cdsEstimateBillsJieCode.AsString := '';
  1170. cdsEstimateBillsXiMuCode.AsString := '';
  1171. cdsEstimateBillsCode.AsString := '';
  1172. cdsEstimateBillsName.AsString := AName;
  1173. cdsEstimateBillsUnits.AsString := '';
  1174. cdsEstimateBills.Post;
  1175. end;
  1176. function TrmBillsGatherData.GetDgnQuantity(ANum1, ANum2: Double): string;
  1177. begin
  1178. Result := '';
  1179. if ANum1 <> 0 then
  1180. begin
  1181. Result := FloatToStr(ANum1);
  1182. if ANum2 <> 0 then
  1183. Result := Result + '/' + FloatToStr(ANum2);
  1184. end;
  1185. end;
  1186. procedure TrmBillsGatherData.CalculateRatioPercent;
  1187. begin
  1188. if GatherType = bgtG_Final04 then
  1189. FCacheTree.ReCalcGatherData;
  1190. end;
  1191. function TrmBillsGatherData.GetDgnPrice(ATotalPrice,
  1192. ADgnQuantity: Double): Double;
  1193. begin
  1194. if ADgnQuantity <> 0 then
  1195. Result := PriceRoundTo(ATotalPrice/ADgnQuantity)
  1196. else
  1197. Result := 0;
  1198. end;
  1199. end.