rmBillsGatherDm.pas 56 KB

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