Bläddra i källkod

Task 1039 报表数据准备--工程量清单汇总

MaiXinRong 9 år sedan
förälder
incheckning
cb45088912

+ 2 - 2
DataModules/BillsGatherDm.pas

@@ -28,7 +28,7 @@ type
   private
     FProjectData: TObject;
 
-    procedure WriteGatherRecord(AGcls: TList);
+    procedure WriteGatherRecord(AGcls, AXmjs: TList);
 
     function GetMainBillsTree: TsdIDTree;
   public
@@ -108,7 +108,7 @@ begin
   end;
 end;
 
-procedure TBillsGatherData.WriteGatherRecord(AGcls: TList);
+procedure TBillsGatherData.WriteGatherRecord(AGcls, AXmjs: TList);
 
   procedure DisableAndClearDataSet(ADataSet: TsdDataSet);
   begin

+ 2 - 2
DataModules/PriceMarginBillsDm.pas

@@ -32,7 +32,7 @@ type
       AValue: TsdValue; AColumn: TsdViewColumn; var Allow: Boolean);
   private
     FProjectData: TObject;
-    procedure WriteGclBillsData(AGcls: TList);
+    procedure WriteGclBillsData(AGcls, AXmjs: TList);
     function GetMainBillsTree: TBillsIDTree;
   public
     constructor Create(AProjectData: TObject);
@@ -100,7 +100,7 @@ begin
   end;
 end;
 
-procedure TPriceMarginBillsData.WriteGclBillsData(AGcls: TList);
+procedure TPriceMarginBillsData.WriteGclBillsData(AGcls, AXmjs: TList);
 
   procedure BeforeWrite;
   begin

+ 2 - 2
DataModules/ReportMemoryDm/rmGcl_XmjBillsDm.pas

@@ -70,7 +70,7 @@ type
     procedure WriteFlowGclNode(AGclNode: TGclNode);
     procedure WriteFlowGclTypeData(AGcls: TList);
 
-    procedure WriteData(AGcls: TList);
+    procedure WriteData(AGcls, AXmjs: TList);
 
     procedure GatherData;
   public
@@ -131,7 +131,7 @@ begin
   end;
 end;
 
-procedure TrmGcl_XmjBillsData.WriteData(AGcls: TList);
+procedure TrmGcl_XmjBillsData.WriteData(AGcls, AXmjs: TList);
 begin
   case FGXType of
     gxtTopGcl, gxtWithoutXmj: WriteTopGclTypeData(AGcls);

+ 10 - 10
Forms/ReportsFrm.dfm

@@ -82,23 +82,23 @@ object ReportsForm: TReportsForm
   end
   object pnlReports: TPanel
     Left = 0
-    Top = 81
+    Top = 76
     Width = 1107
-    Height = 425
+    Height = 430
     Align = alClient
     BevelOuter = bvNone
     TabOrder = 6
     object sprReportPreview: TSplitter
       Left = 211
       Top = 0
-      Height = 425
+      Height = 430
       AutoSnap = False
     end
     object pnlReportsList: TPanel
       Left = 0
       Top = 0
       Width = 211
-      Height = 425
+      Height = 430
       Align = alLeft
       BevelOuter = bvNone
       TabOrder = 0
@@ -106,7 +106,7 @@ object ReportsForm: TReportsForm
         Left = 0
         Top = 35
         Width = 211
-        Height = 390
+        Height = 395
         Align = alClient
         Font.Charset = DEFAULT_CHARSET
         Font.Color = clWindowText
@@ -193,7 +193,7 @@ object ReportsForm: TReportsForm
       Left = 214
       Top = 0
       Width = 893
-      Height = 425
+      Height = 430
       HorzScrollBar.Increment = 48
       HorzScrollBar.Tracking = True
       VertScrollBar.Increment = 32
@@ -216,7 +216,7 @@ object ReportsForm: TReportsForm
     Font.Charset = DEFAULT_CHARSET
     Font.Color = clWindowText
     Font.Height = -12
-    Font.Name = #24494#36719#38597#40657
+    Font.Name = #23435#20307
     Font.Style = []
     Bars = <
       item
@@ -313,7 +313,7 @@ object ReportsForm: TReportsForm
         Caption = #33539#22260#36755#20986
         DockedDockingStyle = dsTop
         DockedLeft = 0
-        DockedTop = 52
+        DockedTop = 47
         DockingStyle = dsTop
         FloatLeft = 602
         FloatTop = 414
@@ -343,7 +343,7 @@ object ReportsForm: TReportsForm
         Caption = #25253#34920#36873#39033
         DockedDockingStyle = dsTop
         DockedLeft = 308
-        DockedTop = 52
+        DockedTop = 47
         DockingStyle = dsTop
         FloatLeft = 484
         FloatTop = 279
@@ -388,7 +388,7 @@ object ReportsForm: TReportsForm
     DockControlHeights = (
       0
       0
-      81
+      76
       0)
     object xlbPrint: TdxBarLargeButton
       Caption = #25171#21360

+ 18 - 2
Forms/ReportsFrm.pas

@@ -9,7 +9,7 @@ interface
 
 uses
   ProjectData, ScFileArchiver, ReportManager, ConditionalDefines,
-  PrintComTypeDefUnit, ADODB, DB,
+  PrintComTypeDefUnit, ADODB, DB, ReportPrepare,
   AuditSelectFrm,
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, PrintCom, PrintComXML, ExtCtrls, ExTreeView, ImgList,
@@ -100,6 +100,9 @@ type
 
     FLockForm: Boolean;
 
+    // 报表数据准备
+    FReportDataPrepare: TReportPrepare;
+
     procedure InitPageSettings;
     procedure InitFont;
     procedure InitPaperSettings;
@@ -143,6 +146,8 @@ type
     function GetExcelMode: TOutputExcelMode;
     function GetIsExcel2010: Boolean;
   public
+    destructor Destroy; override;
+
     procedure InitFormView;
     procedure InitReportSettings;
 
@@ -168,7 +173,8 @@ implementation
 
 uses
   UtilMethods, Math, DirectPrintUnit, Globals, ZhAPI, ReportAdjustFrm,
-  Contnrs, mEncryptUnit, Printers, WinSpool, MainFrm, ConstUnit;
+  Contnrs, mEncryptUnit, Printers, WinSpool, MainFrm, ConstUnit,
+  GclBillsGatherModel;
 
 {$R *.dfm}
 
@@ -282,6 +288,9 @@ begin
   // 交互表
   if vTemplateNode.InteractFlag <> 0 then
     SaveReportInteractData(vTemplateNode);
+  // 准备额外数据
+  if vTemplateNode.DataPrepareFlag <> 0 then
+    FReportDataPrepare.PrepareData(vTemplateNode.DataPrepareFlag);
 
   Screen.Cursor := crHourGlass;
   try
@@ -301,6 +310,7 @@ end;
 procedure TReportsForm.SetProjectData(const Value: TProjectData);
 begin
   FProjectData := Value;
+  FReportDataPrepare := TReportPrepare.Create(FProjectData);
   extvReport.Selected := extvReport.Items[0];
   LoadReportTemplets;
   LoadTempletAndDisplay;
@@ -1480,4 +1490,10 @@ begin
   end;
 end;
 
+destructor TReportsForm.Destroy;
+begin
+  FReportDataPrepare.Free;
+  inherited;
+end;
+
 end.

+ 354 - 0
Report/DataPrepare/rdpBillsGatherDm.dfm

@@ -0,0 +1,354 @@
+object rdpBillsGatherData: TrdpBillsGatherData
+  OldCreateOrder = False
+  Left = 790
+  Top = 258
+  Height = 302
+  Width = 322
+  object sdpGclBills: TsdADOProvider
+    TableName = 'rdp_GclBills'
+    Left = 40
+    Top = 16
+  end
+  object sddGclBills: TsdDataSet
+    Active = False
+    Provider = sdpGclBills
+    Left = 40
+    Top = 72
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D650606425F436F6465094669656C644E616D65
+      0606425F436F64650844617461547970650218084461746153697A6502320549
+      734B6579080F4E65656450726F636573734E616D65090001044E616D65060949
+      6E646578436F6465094669656C644E616D650609496E646578436F6465084461
+      7461547970650218084461746153697A6502320549734B6579080F4E65656450
+      726F636573734E616D65090001044E616D6506044E616D65094669656C644E61
+      6D6506044E616D650844617461547970650218084461746153697A6503FF0005
+      49734B6579080F4E65656450726F636573734E616D65090001044E616D650605
+      556E697473094669656C644E616D650605556E69747308446174615479706502
+      18084461746153697A6502140549734B6579080F4E65656450726F636573734E
+      616D65090001044E616D6506055072696365094669656C644E616D6506055072
+      6963650844617461547970650206084461746153697A6502080549734B657908
+      0F4E65656450726F636573734E616D65090001044E616D65060B4F7267517561
+      6E74697479094669656C644E616D65060B4F72675175616E7469747908446174
+      61547970650206084461746153697A6502080549734B6579080F4E6565645072
+      6F636573734E616D65090001044E616D65060D4F7267546F74616C5072696365
+      094669656C644E616D65060D4F7267546F74616C507269636508446174615479
+      70650206084461746153697A6502080549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D65060B4D69735175616E74697479094669656C
+      644E616D65060B4D69735175616E746974790844617461547970650206084461
+      746153697A6502080549734B6579080F4E65656450726F636573734E616D6509
+      0001044E616D65060D4D6973546F74616C5072696365094669656C644E616D65
+      060D4D6973546F74616C50726963650844617461547970650206084461746153
+      697A6502080549734B6579080F4E65656450726F636573734E616D6509000104
+      4E616D65060B4F74685175616E74697479094669656C644E616D65060B4F7468
+      5175616E746974790844617461547970650206084461746153697A6502080549
+      734B6579080F4E65656450726F636573734E616D65090001044E616D65060D4F
+      7468546F74616C5072696365094669656C644E616D65060D4F7468546F74616C
+      50726963650844617461547970650206084461746153697A6502080549734B65
+      79080F4E65656450726F636573734E616D65090001044E616D6506085175616E
+      74697479094669656C644E616D6506085175616E746974790844617461547970
+      650206084461746153697A6502080549734B6579080F4E65656450726F636573
+      734E616D65090001044E616D65060A546F74616C5072696365094669656C644E
+      616D65060A546F74616C50726963650844617461547970650206084461746153
+      697A6502080549734B6579080F4E65656450726F636573734E616D6509000104
+      4E616D65060F4375724465616C5175616E74697479094669656C644E616D6506
+      0F4375724465616C5175616E7469747908446174615479706502060844617461
+      53697A6502080549734B6579080F4E65656450726F636573734E616D65090001
+      044E616D6506114375724465616C546F74616C5072696365094669656C644E61
+      6D6506114375724465616C546F74616C50726963650844617461547970650206
+      084461746153697A6502080549734B6579080F4E65656450726F636573734E61
+      6D65090001044E616D65060D43757251635175616E74697479094669656C644E
+      616D65060D43757251635175616E746974790844617461547970650206084461
+      746153697A6502080549734B6579080F4E65656450726F636573734E616D6509
+      0001044E616D65060F4375725163546F74616C5072696365094669656C644E61
+      6D65060F4375725163546F74616C507269636508446174615479706502060844
+      61746153697A6502080549734B6579080F4E65656450726F636573734E616D65
+      090001044E616D6506114375724761746865725175616E74697479094669656C
+      644E616D6506114375724761746865725175616E746974790844617461547970
+      650206084461746153697A6502080549734B6579080F4E65656450726F636573
+      734E616D65090001044E616D650613437572476174686572546F74616C507269
+      6365094669656C644E616D650613437572476174686572546F74616C50726963
+      650844617461547970650206084461746153697A6502080549734B6579080F4E
+      65656450726F636573734E616D65090001044E616D65060F5072654465616C51
+      75616E74697479094669656C644E616D65060F5072654465616C5175616E7469
+      74790844617461547970650206084461746153697A6502080549734B6579080F
+      4E65656450726F636573734E616D65090001044E616D6506115072654465616C
+      546F74616C5072696365094669656C644E616D6506115072654465616C546F74
+      616C50726963650844617461547970650206084461746153697A650208054973
+      4B6579080F4E65656450726F636573734E616D65090001044E616D65060D5072
+      6551635175616E74697479094669656C644E616D65060D50726551635175616E
+      746974790844617461547970650206084461746153697A6502080549734B6579
+      080F4E65656450726F636573734E616D65090001044E616D65060F5072655163
+      546F74616C5072696365094669656C644E616D65060F5072655163546F74616C
+      50726963650844617461547970650206084461746153697A6502080549734B65
+      79080F4E65656450726F636573734E616D65090001044E616D65061150726547
+      61746865725175616E74697479094669656C644E616D65061150726547617468
+      65725175616E746974790844617461547970650206084461746153697A650208
+      0549734B6579080F4E65656450726F636573734E616D65090001044E616D6506
+      13507265476174686572546F74616C5072696365094669656C644E616D650613
+      507265476174686572546F74616C507269636508446174615479706502060844
+      61746153697A6502080549734B6579080F4E65656450726F636573734E616D65
+      090001044E616D65060F456E644465616C5175616E74697479094669656C644E
+      616D65060F456E644465616C5175616E74697479084461746154797065020608
+      4461746153697A6502080549734B6579080F4E65656450726F636573734E616D
+      65090001044E616D650611456E644465616C546F74616C507269636509466965
+      6C644E616D650611456E644465616C546F74616C507269636508446174615479
+      70650206084461746153697A6502080549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D65060D456E6451635175616E74697479094669
+      656C644E616D65060D456E6451635175616E7469747908446174615479706502
+      06084461746153697A6502080549734B6579080F4E65656450726F636573734E
+      616D65090001044E616D65060F456E645163546F74616C507269636509466965
+      6C644E616D65060F456E645163546F74616C5072696365084461746154797065
+      0206084461746153697A6502080549734B6579080F4E65656450726F63657373
+      4E616D65090001044E616D650611456E644761746865725175616E7469747909
+      4669656C644E616D650611456E644761746865725175616E7469747908446174
+      61547970650206084461746153697A6502080549734B6579080F4E6565645072
+      6F636573734E616D65090001044E616D650613456E64476174686572546F7461
+      6C5072696365094669656C644E616D650613456E64476174686572546F74616C
+      50726963650844617461547970650206084461746153697A6502080549734B65
+      79080F4E65656450726F636573734E616D65090001044E616D65060F41646444
+      65616C5175616E74697479094669656C644E616D65060F4164644465616C5175
+      616E746974790844617461547970650206084461746153697A6502080549734B
+      6579080F4E65656450726F636573734E616D65090001044E616D650611416464
+      4465616C546F74616C5072696365094669656C644E616D650611416464446561
+      6C546F74616C50726963650844617461547970650206084461746153697A6502
+      080549734B6579080F4E65656450726F636573734E616D65090001044E616D65
+      060D41646451635175616E74697479094669656C644E616D65060D4164645163
+      5175616E746974790844617461547970650206084461746153697A6502080549
+      734B6579080F4E65656450726F636573734E616D65090001044E616D65060F41
+      64645163546F74616C5072696365094669656C644E616D65060F416464516354
+      6F74616C50726963650844617461547970650206084461746153697A65020805
+      49734B6579080F4E65656450726F636573734E616D65090001044E616D650611
+      4164644761746865725175616E74697479094669656C644E616D650611416464
+      4761746865725175616E74697479084461746154797065020608446174615369
+      7A6502080549734B6579080F4E65656450726F636573734E616D65090001044E
+      616D650613416464476174686572546F74616C5072696365094669656C644E61
+      6D650613416464476174686572546F74616C5072696365084461746154797065
+      0206084461746153697A6502080549734B6579080F4E65656450726F63657373
+      4E616D65090001044E616D65060C4465616C5175616E74697479094669656C64
+      4E616D65060C4465616C5175616E746974790844617461547970650206084461
+      746153697A6502080549734B6579080F4E65656450726F636573734E616D6509
+      0001044E616D65060E4465616C546F74616C5072696365094669656C644E616D
+      65060E4465616C546F74616C5072696365084461746154797065020608446174
+      6153697A6502080549734B6579080F4E65656450726F636573734E616D650900
+      01044E616D65060B42474C5175616E74697479094669656C644E616D65060B42
+      474C5175616E746974790844617461547970650206084461746153697A650208
+      0549734B6579080F4E65656450726F636573734E616D65090001044E616D6506
+      0D42474C546F74616C5072696365094669656C644E616D65060D42474C546F74
+      616C50726963650844617461547970650206084461746153697A650208054973
+      4B6579080F4E65656450726F636573734E616D65090000}
+  end
+  object sdpDetailGclBills: TsdADOProvider
+    TableName = 'rdp_DetailGclBills'
+    Left = 40
+    Top = 136
+  end
+  object sddDetailGclBills: TsdDataSet
+    Active = False
+    Provider = sdpDetailGclBills
+    Left = 40
+    Top = 192
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D65060742696C6C734944094669656C644E616D
+      65060742696C6C7349440844617461547970650203084461746153697A650204
+      0549734B6579080F4E65656450726F636573734E616D65090001044E616D6506
+      0C5472656553657269616C4E6F094669656C644E616D65060C54726565536572
+      69616C4E6F0844617461547970650203084461746153697A6502040549734B65
+      79080F4E65656450726F636573734E616D65090001044E616D65060B52656C61
+      42696C6C734944094669656C644E616D65060B52656C6142696C6C7349440844
+      617461547970650203084461746153697A6502040549734B6579080F4E656564
+      50726F636573734E616D65090001044E616D6506094C656166586D6A49440946
+      69656C644E616D6506094C656166586D6A494408446174615479706502030844
+      61746153697A6502040549734B6579080F4E65656450726F636573734E616D65
+      090001044E616D6506085175616E74697479094669656C644E616D6506085175
+      616E746974790844617461547970650206084461746153697A6502080549734B
+      6579080F4E65656450726F636573734E616D65090001044E616D65060A546F74
+      616C5072696365094669656C644E616D65060A546F74616C5072696365084461
+      7461547970650206084461746153697A6502080549734B6579080F4E65656450
+      726F636573734E616D65090001044E616D65060F4375724465616C5175616E74
+      697479094669656C644E616D65060F4375724465616C5175616E746974790844
+      617461547970650206084461746153697A6502080549734B6579080F4E656564
+      50726F636573734E616D65090001044E616D6506114375724465616C546F7461
+      6C5072696365094669656C644E616D6506114375724465616C546F74616C5072
+      6963650844617461547970650206084461746153697A6502080549734B657908
+      0F4E65656450726F636573734E616D65090001044E616D65060D437572516351
+      75616E74697479094669656C644E616D65060D43757251635175616E74697479
+      0844617461547970650206084461746153697A6502080549734B6579080F4E65
+      656450726F636573734E616D65090001044E616D65060F4375725163546F7461
+      6C5072696365094669656C644E616D65060F4375725163546F74616C50726963
+      650844617461547970650206084461746153697A6502080549734B6579080F4E
+      65656450726F636573734E616D65090001044E616D6506114375724761746865
+      725175616E74697479094669656C644E616D6506114375724761746865725175
+      616E746974790844617461547970650206084461746153697A6502080549734B
+      6579080F4E65656450726F636573734E616D65090001044E616D650613437572
+      476174686572546F74616C5072696365094669656C644E616D65061343757247
+      6174686572546F74616C50726963650844617461547970650206084461746153
+      697A6502080549734B6579080F4E65656450726F636573734E616D6509000104
+      4E616D65060F5072654465616C5175616E74697479094669656C644E616D6506
+      0F5072654465616C5175616E7469747908446174615479706502060844617461
+      53697A6502080549734B6579080F4E65656450726F636573734E616D65090001
+      044E616D6506115072654465616C546F74616C5072696365094669656C644E61
+      6D6506115072654465616C546F74616C50726963650844617461547970650206
+      084461746153697A6502080549734B6579080F4E65656450726F636573734E61
+      6D65090001044E616D65060D50726551635175616E74697479094669656C644E
+      616D65060D50726551635175616E746974790844617461547970650206084461
+      746153697A6502080549734B6579080F4E65656450726F636573734E616D6509
+      0001044E616D65060F5072655163546F74616C5072696365094669656C644E61
+      6D65060F5072655163546F74616C507269636508446174615479706502060844
+      61746153697A6502080549734B6579080F4E65656450726F636573734E616D65
+      090001044E616D6506115072654761746865725175616E74697479094669656C
+      644E616D6506115072654761746865725175616E746974790844617461547970
+      650206084461746153697A6502080549734B6579080F4E65656450726F636573
+      734E616D65090001044E616D650613507265476174686572546F74616C507269
+      6365094669656C644E616D650613507265476174686572546F74616C50726963
+      650844617461547970650206084461746153697A6502080549734B6579080F4E
+      65656450726F636573734E616D65090001044E616D65060F456E644465616C51
+      75616E74697479094669656C644E616D65060F456E644465616C5175616E7469
+      74790844617461547970650206084461746153697A6502080549734B6579080F
+      4E65656450726F636573734E616D65090001044E616D650611456E644465616C
+      546F74616C5072696365094669656C644E616D650611456E644465616C546F74
+      616C50726963650844617461547970650206084461746153697A650208054973
+      4B6579080F4E65656450726F636573734E616D65090001044E616D65060D456E
+      6451635175616E74697479094669656C644E616D65060D456E6451635175616E
+      746974790844617461547970650206084461746153697A6502080549734B6579
+      080F4E65656450726F636573734E616D65090001044E616D65060F456E645163
+      546F74616C5072696365094669656C644E616D65060F456E645163546F74616C
+      50726963650844617461547970650206084461746153697A6502080549734B65
+      79080F4E65656450726F636573734E616D65090001044E616D650611456E6447
+      61746865725175616E74697479094669656C644E616D650611456E6447617468
+      65725175616E746974790844617461547970650206084461746153697A650208
+      0549734B6579080F4E65656450726F636573734E616D65090001044E616D6506
+      13456E64476174686572546F74616C5072696365094669656C644E616D650613
+      456E64476174686572546F74616C507269636508446174615479706502060844
+      61746153697A6502080549734B6579080F4E65656450726F636573734E616D65
+      090001044E616D65060F4164644465616C5175616E74697479094669656C644E
+      616D65060F4164644465616C5175616E74697479084461746154797065020608
+      4461746153697A6502080549734B6579080F4E65656450726F636573734E616D
+      65090001044E616D6506114164644465616C546F74616C507269636509466965
+      6C644E616D6506114164644465616C546F74616C507269636508446174615479
+      70650206084461746153697A6502080549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D65060D41646451635175616E74697479094669
+      656C644E616D65060D41646451635175616E7469747908446174615479706502
+      06084461746153697A6502080549734B6579080F4E65656450726F636573734E
+      616D65090001044E616D65060F4164645163546F74616C507269636509466965
+      6C644E616D65060F4164645163546F74616C5072696365084461746154797065
+      0206084461746153697A6502080549734B6579080F4E65656450726F63657373
+      4E616D65090001044E616D6506114164644761746865725175616E7469747909
+      4669656C644E616D6506114164644761746865725175616E7469747908446174
+      61547970650206084461746153697A6502080549734B6579080F4E6565645072
+      6F636573734E616D65090001044E616D650613416464476174686572546F7461
+      6C5072696365094669656C644E616D650613416464476174686572546F74616C
+      50726963650844617461547970650206084461746153697A6502080549734B65
+      79080F4E65656450726F636573734E616D65090000}
+  end
+  object sdpDetailBGLBills: TsdADOProvider
+    TableName = 'rdp_DetailBGLBills'
+    Left = 144
+    Top = 136
+  end
+  object sddDetailBGLBills: TsdDataSet
+    Active = False
+    Provider = sdpDetailBGLBills
+    Left = 144
+    Top = 192
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D65060742696C6C734944094669656C644E616D
+      65060742696C6C7349440844617461547970650203084461746153697A650204
+      0549734B6579080F4E65656450726F636573734E616D65090001044E616D6506
+      09424742696C6C734944094669656C644E616D650609424742696C6C73494408
+      44617461547970650203084461746153697A6502040549734B6579080F4E6565
+      6450726F636573734E616D65090001044E616D65060542474C4944094669656C
+      644E616D65060542474C49440844617461547970650203084461746153697A65
+      02040549734B6579080F4E65656450726F636573734E616D65090001044E616D
+      65060742474C436F6465094669656C644E616D65060742474C436F6465084461
+      7461547970650218084461746153697A6502320549734B6579080F4E65656450
+      726F636573734E616D65090001044E616D65060742474C4E616D65094669656C
+      644E616D65060742474C4E616D65084461746154797065021808446174615369
+      7A6503FF000549734B6579080F4E65656450726F636573734E616D6509000104
+      4E616D65060F42474C417070726F76616C436F6465094669656C644E616D6506
+      0F42474C417070726F76616C436F646508446174615479706502180844617461
+      53697A6503FF000549734B6579080F4E65656450726F636573734E616D650900
+      01044E616D65060E42474C44726177696E67436F6465094669656C644E616D65
+      060E42474C44726177696E67436F646508446174615479706502180844617461
+      53697A6503FF000549734B6579080F4E65656450726F636573734E616D650900
+      01044E616D6506085175616E74697479094669656C644E616D6506085175616E
+      746974790844617461547970650206084461746153697A6502080549734B6579
+      080F4E65656450726F636573734E616D65090001044E616D65060A546F74616C
+      5072696365094669656C644E616D65060A546F74616C50726963650844617461
+      547970650206084461746153697A6502080549734B6579080F4E65656450726F
+      636573734E616D65090000}
+  end
+  object sdpDetailDealBills: TsdADOProvider
+    TableName = 'rdp_DetailDealBills'
+    Left = 248
+    Top = 136
+  end
+  object sddDetailDealBills: TsdDataSet
+    Active = False
+    Provider = sdpDetailDealBills
+    Left = 248
+    Top = 192
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D65060742696C6C734944094669656C644E616D
+      65060742696C6C7349440844617461547970650203084461746153697A650204
+      0549734B6579080F4E65656450726F636573734E616D65090001044E616D6506
+      064465616C4944094669656C644E616D6506064465616C494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D6506085175616E74697479094669656C644E61
+      6D6506085175616E746974790844617461547970650206084461746153697A65
+      02080549734B6579080F4E65656450726F636573734E616D65090001044E616D
+      65060A546F74616C5072696365094669656C644E616D65060A546F74616C5072
+      6963650844617461547970650206084461746153697A6502080549734B657908
+      0F4E65656450726F636573734E616D65090000}
+  end
+  object sdpLeafXmjs: TsdADOProvider
+    TableName = 'rdp_LeafXmjs'
+    Left = 136
+    Top = 16
+  end
+  object sddLeafXmjs: TsdDataSet
+    Active = False
+    Provider = sdpLeafXmjs
+    Left = 136
+    Top = 72
+    FieldListData = {
+      0101044E616D6506024944094669656C644E616D650602494408446174615479
+      70650203084461746153697A6502040549734B6579080F4E65656450726F6365
+      73734E616D65090001044E616D650604436F6465094669656C644E616D650604
+      436F64650844617461547970650218084461746153697A6502320549734B6579
+      080F4E65656450726F636573734E616D65090001044E616D6506044E616D6509
+      4669656C644E616D6506044E616D650844617461547970650218084461746153
+      697A6503FF000549734B6579080F4E65656450726F636573734E616D65090001
+      044E616D650605556E697473094669656C644E616D650605556E697473084461
+      7461547970650218084461746153697A6502140549734B6579080F4E65656450
+      726F636573734E616D65090001044E616D65060A4E616D6544616E5765690946
+      69656C644E616D65060A4E616D6544616E576569084461746154797065021808
+      4461746153697A6503FF000549734B6579080F4E65656450726F636573734E61
+      6D65090001044E616D6506094E616D6546656E4275094669656C644E616D6506
+      094E616D6546656E42750844617461547970650218084461746153697A6503FF
+      000549734B6579080F4E65656450726F636573734E616D65090001044E616D65
+      060C4E616D6546656E5869616E67094669656C644E616D65060C4E616D654665
+      6E5869616E670844617461547970650218084461746153697A6503FF00054973
+      4B6579080F4E65656450726F636573734E616D65090001044E616D6506084E61
+      6D65556E6974094669656C644E616D6506084E616D65556E6974084461746154
+      7970650218084461746153697A6503FF000549734B6579080F4E65656450726F
+      636573734E616D65090001044E616D650603506567094669656C644E616D6506
+      035065670844617461547970650218084461746153697A6503FF000549734B65
+      79080F4E65656450726F636573734E616D65090001044E616D6506095065674C
+      656E677468094669656C644E616D6506095065674C656E677468084461746154
+      7970650206084461746153697A6502080549734B6579080F4E65656450726F63
+      6573734E616D65090001044E616D65060C52656C61506F736974696F6E094669
+      656C644E616D65060C52656C61506F736974696F6E0844617461547970650218
+      084461746153697A6503FF000549734B6579080F4E65656450726F636573734E
+      616D65080001044E616D65060B44726177696E67436F6465094669656C644E61
+      6D65060B44726177696E67436F64650844617461547970650218084461746153
+      697A6502320549734B6579080F4E65656450726F636573734E616D65090000}
+  end
+end

+ 316 - 0
Report/DataPrepare/rdpBillsGatherDm.pas

@@ -0,0 +1,316 @@
+unit rdpBillsGatherDm;
+// Report Data Prepare -- Gcl_Bills_Gather
+
+interface
+
+uses
+  SysUtils, Classes, sdProvider, sdDB, ADODB, GclBillsGatherModel,
+  ProjectData;
+
+type
+  TrdpBillsGatherData = class(TDataModule)
+    sdpGclBills: TsdADOProvider;
+    sddGclBills: TsdDataSet;
+    sdpDetailGclBills: TsdADOProvider;
+    sddDetailGclBills: TsdDataSet;
+    sdpDetailBGLBills: TsdADOProvider;
+    sddDetailBGLBills: TsdDataSet;
+    sdpDetailDealBills: TsdADOProvider;
+    sddDetailDealBills: TsdDataSet;
+    sdpLeafXmjs: TsdADOProvider;
+    sddLeafXmjs: TsdDataSet;
+  private
+    FProjectData: TProjectData;
+
+    procedure BeforeWrite;
+    procedure AfterWrite;
+
+    procedure WriteDetailDealNode(AGclNode: TGclNode);
+    procedure WriteDetailBGLNode(AGclNode: TGclNode);
+    procedure WriteDetailGclNode(AGclNode: TGclNode);
+    procedure WriteGclNode(AGclNode: TGclNode);
+    procedure WriteLeafXmjNode(ALeafXmj: TLeafXmjNode);
+    procedure WriteGatherRecord(AGcls, AXmjs: TList);
+  public
+    constructor Create(AProjectData: TProjectData);
+    destructor Destroy; override;
+
+    procedure LoadGclBillsGatherData;
+  end;
+
+implementation
+
+uses
+  mPegFilter;
+
+{$R *.dfm}
+
+{ TrdpBillsGatherData }
+
+procedure TrdpBillsGatherData.AfterWrite;
+begin
+  sddGclBills.EndUpdate;
+  sddLeafXmjs.EndUpdate;
+  sddDetailGclBills.EndUpdate;
+  sddDetailBGLBills.EndUpdate;
+  sddDetailDealBills.EndUpdate;
+end;
+
+procedure TrdpBillsGatherData.BeforeWrite;
+begin
+  sddGclBills.BeginUpdate;
+  sddLeafXmjs.BeginUpdate;
+  sddDetailGclBills.BeginUpdate;
+  sddDetailBGLBills.BeginUpdate;
+  sddDetailDealBills.BeginUpdate;
+end;
+
+constructor TrdpBillsGatherData.Create(AProjectData: TProjectData);
+begin
+  inherited Create(nil);
+  FProjectData := AProjectData;
+  sdpLeafXmjs.Connection := FProjectData.ADOConnection;
+  sddLeafXmjs.Open;
+  sdpGclBills.Connection := FProjectData.ADOConnection;
+  sddGclBills.Open;
+  sdpDetailGclBills.Connection := FProjectData.ADOConnection;
+  sddDetailGclBills.Open;
+  sdpDetailBGLBills.Connection := FProjectData.ADOConnection;
+  sddDetailBGLBills.Open;
+  sdpDetailDealBills.Connection := FProjectData.ADOConnection;
+  sddDetailDealBills.Open;
+end;
+
+destructor TrdpBillsGatherData.Destroy;
+begin
+  sddLeafXmjs.Save;
+  sddGclBills.Save;
+  sddDetailGclBills.Save;
+  sddDetailBGLBills.Save;
+  sddDetailDealBills.Save;
+  inherited;
+end;
+
+procedure TrdpBillsGatherData.LoadGclBillsGatherData;
+var
+  Gather: TGclGatherModel;
+begin
+  Gather := TGclGatherModel.Create(FProjectData);
+  try
+    Gather.WriteGatherData := WriteGatherRecord;
+    Gather.Execute;
+  finally
+    Gather.Free;
+  end;
+end;
+
+procedure TrdpBillsGatherData.WriteDetailBGLNode(AGclNode: TGclNode);
+var
+  iBGL: Integer;
+  vBGL: TDetailBGLNode;
+  Rec: TsdDataRecord;
+begin
+  for iBGL := 0 to AGclNode.DetailBGLCount - 1 do
+  begin
+    vBGL := AGclNode.DetailBGL[iBGL];
+    Rec := sddDetailBGLBills.Add;
+
+    Rec.ValueByName('ID').AsInteger := vBGL.ID;
+    Rec.ValueByName('BillsID').AsInteger := AGclNode.ID;
+    Rec.ValueByName('BGBillsID').AsInteger := vBGL.BGBillsID;
+    Rec.ValueByName('BGLID').AsInteger := vBGL.BGLID;
+
+    Rec.ValueByName('BGLCode').AsString := vBGL.BGLCode;
+    Rec.ValueByName('BGLName').AsString := vBGL.BGLName;
+    Rec.ValueByName('BGLApprovalCode').AsString := vBGL.BGLApprovalCode;
+    Rec.ValueByName('BGLDrawingCode').AsString := vBGL.BGLDrawingCode;
+
+    Rec.ValueByName('Quantity').AsFloat := vBGL.Quantity;
+    Rec.ValueByName('TotalPrice').AsFloat := vBGL.TotalPrice;
+  end;
+end;
+
+procedure TrdpBillsGatherData.WriteDetailDealNode(AGclNode: TGclNode);
+var
+  iDeal: Integer;
+  vDeal: TDetailDealNode;
+  Rec: TsdDataRecord;
+begin
+  for iDeal := 0 to AGclNode.DetailDealCount - 1 do
+  begin
+    vDeal := AGclNode.DetailDeal[iDeal];
+    Rec := sddDetailDealBills.Add;
+    Rec.ValueByName('ID').AsInteger := vDeal.ID;
+    Rec.ValueByName('BillsID').AsInteger := AGclNode.ID;
+    Rec.ValueByName('DealID').AsInteger := vDeal.DealID;
+
+    Rec.ValueByName('Quantity').AsFloat := vDeal.Quantity;
+    Rec.ValueByName('TotalPrice').AsFloat := vDeal.TotalPrice;
+  end;
+end;
+
+procedure TrdpBillsGatherData.WriteDetailGclNode(AGclNode: TGclNode);
+var
+  iDetailGcl: Integer;
+  vDetailGcl: TDetailGclNode;
+  Rec: TsdDataRecord;
+begin
+  for iDetailGcl := 0 to AGclNode.DetailGclCount -1 do
+  begin
+    vDetailGcl := AGclNode.DetailGcl[iDetailGcl];
+
+    Rec := sddDetailGclBills.Add;
+    Rec.ValueByName('ID').AsInteger := vDetailGcl.ID;
+    Rec.ValueByName('BillsID').AsInteger := AGclNode.ID;
+    Rec.ValueByName('TreeSerialNo').AsInteger := vDetailGcl.TreeSerialNo;
+    Rec.ValueByName('RelaBillsID').AsInteger := vDetailGcl.BillsID;
+
+    if Assigned(vDetailGcl.LeafXmj) then
+      Rec.ValueByName('LeafXmjID').AsInteger := vDetailGcl.LeafXmj.ID
+    else
+      Rec.ValueByName('LeafXmjID').AsInteger := -1;
+
+    Rec.ValueByName('Quantity').AsFloat := vDetailGcl.Quantity;
+    Rec.ValueByName('TotalPrice').AsFloat := vDetailGcl.TotalPrice;
+
+    Rec.ValueByName('CurDealQuantity').AsFloat := vDetailGcl.CurDealQuantity;
+    Rec.ValueByName('CurDealTotalPrice').AsFloat := vDetailGcl.CurDealTotalPrice;
+    Rec.ValueByName('CurQcQuantity').AsFloat := vDetailGcl.CurQcQuantity;
+    Rec.ValueByName('CurQcTotalPrice').AsFloat := vDetailGcl.CurQcTotalPrice;
+    Rec.ValueByName('CurGatherQuantity').AsFloat := vDetailGcl.CurGatherQuantity;
+    Rec.ValueByName('CurGatherTotalPrice').AsFloat := vDetailGcl.CurGatherTotalPrice;
+
+    Rec.ValueByName('PreDealQuantity').AsFloat := vDetailGcl.PreDealQuantity;
+    Rec.ValueByName('PreDealTotalPrice').AsFloat := vDetailGcl.PreDealTotalPrice;
+    Rec.ValueByName('PreQcQuantity').AsFloat := vDetailGcl.PreQcQuantity;
+    Rec.ValueByName('PreQcTotalPrice').AsFloat := vDetailGcl.PreQcTotalPrice;
+    Rec.ValueByName('PreGatherQuantity').AsFloat := vDetailGcl.PreGatherQuantity;
+    Rec.ValueByName('PreGatherTotalPrice').AsFloat := vDetailGcl.PreGatherTotalPrice;
+
+    Rec.ValueByName('EndDealQuantity').AsFloat := vDetailGcl.EndDealQuantity;
+    Rec.ValueByName('EndDealTotalPrice').AsFloat := vDetailGcl.EndDealTotalPrice;
+    Rec.ValueByName('EndQcQuantity').AsFloat := vDetailGcl.EndQcQuantity;
+    Rec.ValueByName('EndQcTotalPrice').AsFloat := vDetailGcl.EndQcTotalPrice;
+    Rec.ValueByName('EndGatherQuantity').AsFloat := vDetailGcl.EndGatherQuantity;
+    Rec.ValueByName('EndGatherTotalPrice').AsFloat := vDetailGcl.EndGatherTotalPrice;
+
+    Rec.ValueByName('AddDealQuantity').AsFloat := vDetailGcl.AddDealQuantity;
+    Rec.ValueByName('AddDealTotalPrice').AsFloat := vDetailGcl.AddDealTotalPrice;
+    Rec.ValueByName('AddQcQuantity').AsFloat := vDetailGcl.AddQcQuantity;
+    Rec.ValueByName('AddQcTotalPrice').AsFloat := vDetailGcl.AddQcTotalPrice;
+    Rec.ValueByName('AddGatherQuantity').AsFloat := vDetailGcl.AddGatherQuantity;
+    Rec.ValueByName('AddGatherTotalPrice').AsFloat := vDetailGcl.AddGatherTotalPrice;
+  end;
+end;
+
+procedure TrdpBillsGatherData.WriteGatherRecord(AGcls, AXmjs: TList);
+var
+  iGcl, iXmj: Integer;
+  vGclNode: TGclNode;
+  vLeafXmj: TLeafXmjNode;
+begin
+  BeforeWrite;
+  try
+    for iGcl := 0 to AGcls.Count - 1 do
+    begin
+      vGclNode := TGclNode(AGcls.Items[iGcl]);
+      WriteGclNode(vGclNode);
+    end;
+
+    for iXmj := 0 to AXmjs.Count - 1 do
+    begin
+      vLeafXmj := TLeafXmjNode(AXmjs.Items[iXmj]);
+      WriteLeafXmjNode(vLeafXmj);
+    end;
+  finally
+    AfterWrite;
+  end;
+end;
+
+procedure TrdpBillsGatherData.WriteGclNode(AGclNode: TGclNode);
+var
+  Rec: TsdDataRecord;
+begin
+  Rec := sddGclBills.Add;
+  Rec.ValueByName('ID').AsInteger := AGclNode.ID;
+
+  Rec.ValueByName('IndexCode').AsString := AGclNode.IndexCode;
+  Rec.ValueByName('B_Code').AsString := AGclNode.B_Code;
+  Rec.ValueByName('Name').AsString := AGclNode.Name;
+  Rec.ValueByName('Units').AsString := AGclNode.Units;
+  Rec.ValueByName('Price').AsFloat := AGclNode.Price;
+
+  Rec.ValueByName('OrgQuantity').AsFloat := AGclNode.OrgQuantity;
+  Rec.ValueByName('OrgTotalPrice').AsFloat := AGclNode.OrgTotalPrice;
+  Rec.ValueByName('MisQuantity').AsFloat := AGclNode.MisQuantity;
+  Rec.ValueByName('MisTotalPrice').AsFloat := AGclNode.MisTotalPrice;
+  Rec.ValueByName('OthQuantity').AsFloat := AGclNode.OthQuantity;
+  Rec.ValueByName('OthTotalPrice').AsFloat := AGclNode.OthTotalPrice;
+
+  Rec.ValueByName('Quantity').AsFloat := AGclNode.Quantity;
+  Rec.ValueByName('TotalPrice').AsFloat := AGclNode.TotalPrice;
+
+  Rec.ValueByName('CurDealQuantity').AsFloat := AGclNode.CurDealQuantity;
+  Rec.ValueByName('CurDealTotalPrice').AsFloat := AGclNode.CurDealTotalPrice;
+  Rec.ValueByName('CurQcQuantity').AsFloat := AGclNode.CurQcQuantity;
+  Rec.ValueByName('CurQcTotalPrice').AsFloat := AGclNode.CurQcTotalPrice;
+  Rec.ValueByName('CurGatherQuantity').AsFloat := AGclNode.CurGatherQuantity;
+  Rec.ValueByName('CurGatherTotalPrice').AsFloat := AGclNode.CurGatherTotalPrice;
+
+  Rec.ValueByName('PreDealQuantity').AsFloat := AGclNode.PreDealQuantity;
+  Rec.ValueByName('PreDealTotalPrice').AsFloat := AGclNode.PreDealTotalPrice;
+  Rec.ValueByName('PreQcQuantity').AsFloat := AGclNode.PreQcQuantity;
+  Rec.ValueByName('PreQcTotalPrice').AsFloat := AGclNode.PreQcTotalPrice;
+  Rec.ValueByName('PreGatherQuantity').AsFloat := AGclNode.PreGatherQuantity;
+  Rec.ValueByName('PreGatherTotalPrice').AsFloat := AGclNode.PreGatherTotalPrice;
+
+  Rec.ValueByName('EndDealQuantity').AsFloat := AGclNode.EndDealQuantity;
+  Rec.ValueByName('EndDealTotalPrice').AsFloat := AGclNode.EndDealTotalPrice;
+  Rec.ValueByName('EndQcQuantity').AsFloat := AGclNode.EndQcQuantity;
+  Rec.ValueByName('EndQcTotalPrice').AsFloat := AGclNode.EndQcTotalPrice;
+  Rec.ValueByName('EndGatherQuantity').AsFloat := AGclNode.EndGatherQuantity;
+  Rec.ValueByName('EndGatherTotalPrice').AsFloat := AGclNode.EndGatherTotalPrice;
+
+  Rec.ValueByName('AddDealQuantity').AsFloat := AGclNode.AddDealQuantity;
+  Rec.ValueByName('AddDealTotalPrice').AsFloat := AGclNode.AddDealTotalPrice;
+  Rec.ValueByName('AddQcQuantity').AsFloat := AGclNode.AddQcQuantity;
+  Rec.ValueByName('AddQcTotalPrice').AsFloat := AGclNode.AddQcTotalPrice;
+  Rec.ValueByName('AddGatherQuantity').AsFloat := AGclNode.AddGatherQuantity;
+  Rec.ValueByName('AddGatherTotalPrice').AsFloat := AGclNode.AddGatherTotalPrice;
+
+  Rec.ValueByName('DealQuantity').AsFloat := AGclNode.DealQuantity;
+  Rec.ValueByName('DealTotalPrice').AsFloat := AGclNode.DealTotalPrice;
+
+  Rec.ValueByName('BGLQuantity').AsFloat := AGclNode.BGLQuantity;
+  Rec.ValueByName('BGLTotalPrice').AsFloat := AGclNode.BGLTotalPrice;
+
+  WriteDetailGclNode(AGclNode);
+  WriteDetailDealNode(AGclNode);
+  WriteDetailBGLNode(AGclNode);
+end;
+
+procedure TrdpBillsGatherData.WriteLeafXmjNode(ALeafXmj: TLeafXmjNode);
+var
+  Rec: TsdDataRecord;
+begin
+  Rec := sddLeafXmjs.Add;
+
+  Rec.ValueByName('ID').AsInteger := ALeafXmj.ID;
+  Rec.ValueByName('Code').AsString := ALeafXmj.XmjCode;
+  Rec.ValueByName('Name').AsString := ALeafXmj.XmjName;
+  Rec.ValueByName('Units').AsString := ALeafXmj.XmjUnits;
+
+  Rec.ValueByName('NameDanWei').AsString := ALeafXmj.NameDanWei;
+  Rec.ValueByName('NameFenBu').AsString := ALeafXmj.NameFenBu;
+  Rec.ValueByName('NameFenXiang').AsString := ALeafXmj.NameFenXiang;
+  Rec.ValueByName('NameUnit').AsString := ALeafXmj.NameUnit;
+
+  Rec.ValueByName('Peg').AsString := ALeafXmj.Peg;
+  if PegFilter.Filter(ALeafXmj.Peg) then
+    Rec.ValueByName('PegLength').AsFloat := PegFilter.EndPegNum - PegFilter.BeginPegNum;
+
+  Rec.ValueByName('RelaPosition').AsString := ALeafXmj.Position;
+  Rec.ValueByName('DrawingCode').AsString := ALeafXmj.DrawingCode;
+end;
+
+end.

+ 269 - 0
Report/DataPrepare/rdpTables.pas

@@ -0,0 +1,269 @@
+unit rdpTables;
+
+interface
+
+uses
+  DataBaseTables;
+
+const
+  {GclBillsGather}
+  S_rdpLeafXmjs = 'rdp_LeafXmjs';
+  td_rdpLeafXmjs: array [0..11] of TScFieldDef =(
+    // Key -- 可直接关联Bills中的ID得到最底层项目节数据
+    (FieldName: 'ID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+
+    // 通过ID关联Bills所得
+    // 编号
+    (FieldName: 'Code'; FieldType: ftString; Size: 50; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 名称
+    (FieldName: 'Name'; FieldType: ftString; Size: 255; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 单位
+    (FieldName: 'Units'; FieldType: ftString; Size: 20; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 图号
+    (FieldName: 'DrawingCode'; FieldType: ftString; Size: 255; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 根据最底层项目节及其父项的名称运算得到
+    // 单位工程
+    (FieldName: 'NameDanWei'; FieldType: ftString; Size: 255; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 分部工程
+    (FieldName: 'NameFenBu'; FieldType: ftString; Size: 255; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 分项工程
+    (FieldName: 'NameFenXiang'; FieldType: ftString; Size: 255; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 计量单元
+    (FieldName: 'NameUnit'; FieldType: ftString; Size: 255; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 位置
+    (FieldName: 'RelaPosition'; FieldType: ftString; Size: 255; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 桩号
+    (FieldName: 'Peg'; FieldType: ftString; Size: 255; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 桩号长度
+    (FieldName: 'PegLength'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+  );
+
+  S_rdpGclBills = 'rdp_GclBills';
+  td_rdpGclBills: array [0..41] of TScFieldDef =(
+    (FieldName: 'ID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+
+    // 索引编号 - B_Code转化为排序用
+    (FieldName: 'IndexCode'; FieldType: ftString; Size: 50; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 清单编号
+    (FieldName: 'B_Code'; FieldType: ftString; Size: 50; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 名称
+    (FieldName: 'Name'; FieldType: ftString; Size: 255; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 单位
+    (FieldName: 'Units'; FieldType: ftString; Size: 20; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 单价
+    (FieldName: 'Price'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 施工图原设计 -- 数量
+    (FieldName: 'OrgQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 施工图原设计 -- 金额
+    (FieldName: 'OrgTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 设计错漏增减 -- 数量
+    (FieldName: 'MisQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 设计错漏增减 -- 金额
+    (FieldName: 'MisTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 其他原因增减 -- 数量
+    (FieldName: 'OthQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 其他原因增减 -- 金额
+    (FieldName: 'OthTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 合同 - 数量
+    (FieldName: 'Quantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 合同 - 金额
+    (FieldName: 'TotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 本期 - 合同计量 - 数量
+    (FieldName: 'CurDealQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 - 合同计量 - 金额
+    (FieldName: 'CurDealTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 - 数量变更 - 数量
+    (FieldName: 'CurQcQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 - 数量变更 - 金额
+    (FieldName: 'CurQcTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 - 完成计量 - 数量
+    (FieldName: 'CurGatherQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 - 完成计量 - 金额
+    (FieldName: 'CurGatherTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 截止上期 - 合同计量 - 数量
+    (FieldName: 'PreDealQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期 - 合同计量 - 金额
+    (FieldName: 'PreDealTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期 - 数量变更 - 数量
+    (FieldName: 'PreQcQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期 - 数量变更 - 金额
+    (FieldName: 'PreQcTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期 - 完成计量 - 数量
+    (FieldName: 'PreGatherQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期 - 完成计量 - 金额
+    (FieldName: 'PreGatherTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 截止本期 - 合同计量 - 数量
+    (FieldName: 'EndDealQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止本期 - 合同计量 - 金额
+    (FieldName: 'EndDealTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止本期 - 数量变更 - 数量
+    (FieldName: 'EndQcQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止本期 - 数量变更 - 金额
+    (FieldName: 'EndQcTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止本期 - 完成计量 - 数量
+    (FieldName: 'EndGatherQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止本期 - 完成计量 - 金额
+    (FieldName: 'EndGatherTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 累计 - 合同计量 - 数量
+    (FieldName: 'AddDealQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 累计 - 合同计量 - 金额
+    (FieldName: 'AddDealTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 累计 - 数量变更 - 数量
+    (FieldName: 'AddQcQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 累计 - 数量变更 - 金额
+    (FieldName: 'AddQcTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 累计 - 完成计量 - 数量
+    (FieldName: 'AddGatherQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 累计 - 完成计量 - 金额
+    (FieldName: 'AddGatherTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 签约清单 - 数量
+    (FieldName: 'DealQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 签约清单 - 金额
+    (FieldName: 'DealTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 变更令 - 数量
+    (FieldName: 'BGLQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 变更令 - 金额
+    (FieldName: 'BGLTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+  );
+
+  S_rdpDetailGclBills = 'rdp_DetailGclBills';
+  td_rdpDetailGclBills: array [0..36] of TScFieldDef =(
+    // Key
+    (FieldName: 'ID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 关联 rdp_GclBills中的ID字段
+    (FieldName: 'BillsID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 使用RelaBillsID关联的数据行中SerialNo的取值
+    (FieldName: 'TreeSerialNo'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 关联 Bills中的ID字段
+    (FieldName: 'RelaBillsID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 关联 rdp_LeafXmjs中的ID字段
+    (FieldName: 'LeafXmjID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+
+
+    // 施工图原设计 -- 数量
+    (FieldName: 'OrgQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 施工图原设计 -- 金额
+    (FieldName: 'OrgTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 设计错漏增减 -- 数量
+    (FieldName: 'MisQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 设计错漏增减 -- 金额
+    (FieldName: 'MisTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 其他原因增减 -- 数量
+    (FieldName: 'OthQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 其他原因增减 -- 金额
+    (FieldName: 'OthTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 合同 - 数量
+    (FieldName: 'Quantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 合同 - 金额
+    (FieldName: 'TotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 本期 - 合同计量 - 数量
+    (FieldName: 'CurDealQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 - 合同计量 - 金额
+    (FieldName: 'CurDealTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 - 数量变更 - 数量
+    (FieldName: 'CurQcQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 - 数量变更 - 金额
+    (FieldName: 'CurQcTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 - 完成计量 - 数量
+    (FieldName: 'CurGatherQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 本期 - 完成计量 - 金额
+    (FieldName: 'CurGatherTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 截止上期 - 合同计量 - 数量
+    (FieldName: 'PreDealQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期 - 合同计量 - 金额
+    (FieldName: 'PreDealTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期 - 数量变更 - 数量
+    (FieldName: 'PreQcQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期 - 数量变更 - 金额
+    (FieldName: 'PreQcTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期 - 完成计量 - 数量
+    (FieldName: 'PreGatherQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止上期 - 完成计量 - 金额
+    (FieldName: 'PreGatherTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 截止本期 - 合同计量 - 数量
+    (FieldName: 'EndDealQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止本期 - 合同计量 - 金额
+    (FieldName: 'EndDealTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止本期 - 数量变更 - 数量
+    (FieldName: 'EndQcQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止本期 - 数量变更 - 金额
+    (FieldName: 'EndQcTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止本期 - 完成计量 - 数量
+    (FieldName: 'EndGatherQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 截止本期 - 完成计量 - 金额
+    (FieldName: 'EndGatherTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 累计 - 合同计量 - 数量
+    (FieldName: 'AddDealQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 累计 - 合同计量 - 金额
+    (FieldName: 'AddDealTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 累计 - 数量变更 - 数量
+    (FieldName: 'AddQcQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 累计 - 数量变更 - 金额
+    (FieldName: 'AddQcTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 累计 - 完成计量 - 数量
+    (FieldName: 'AddGatherQuantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 累计 - 完成计量 - 金额
+    (FieldName: 'AddGatherTotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+  );
+
+  S_rdpDetailDealBills = 'rdp_DetailDealBills';
+  td_rdpDetailDealBills: array [0..4] of TScFieldDef =(
+    // Key
+    (FieldName: 'ID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 关联 rdp_GclBills中的ID字段
+    (FieldName: 'BillsID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 关联 DealBils中的ID字段
+    (FieldName: 'DealID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+
+    // 通过DealID关联DealBills所得数据
+    // 签约 - 数量
+    (FieldName: 'Quantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 签约 - 金额
+    (FieldName: 'TotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+  );
+
+  S_rdpDetailBGLBills = 'rdp_DetailBGLBills';
+  td_rdpDetailBGLBills: array [0..9] of TScFieldDef =(
+    // Key
+    (FieldName: 'ID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 关联 rdp_GclBills中的ID字段
+    (FieldName: 'BillsID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 关联 BGBills中的ID字段
+    (FieldName: 'BGBillsID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 关联 BGL中的ID字段
+    (FieldName: 'BGLID'; FieldType: ftInteger; Size: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+
+    // 通过BGLID关联BGL所得数据
+    // 变更令 -- 变更令号
+    (FieldName: 'BGLCode'; FieldType: ftString; Size: 50; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 变更令 -- 名称
+    (FieldName: 'BGLName'; FieldType: ftString; Size: 255; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 变更令 -- 批复文号
+    (FieldName: 'BGLApprovalCode'; FieldType: ftString; Size: 50; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 变更令 -- 变更图号
+    (FieldName: 'BGLDrawingCode'; FieldType: ftString; Size: 50; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 通过BGBillsID关联BGBills所得数据
+    // 变更清单 - 数量
+    (FieldName: 'Quantity'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 变更清单 - 金额
+    (FieldName: 'TotalPrice'; FieldType: ftDouble; Size: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+  );
+
+implementation
+
+end.

+ 97 - 0
Report/ReportPrepare.pas

@@ -0,0 +1,97 @@
+unit ReportPrepare;
+
+interface
+
+uses
+  rdpBillsGatherDm, ProjectData;
+
+type
+  TReportPrepare = class
+  private
+    FProjectData: TProjectData;
+    FPrepareGclGather: Boolean;
+
+    procedure GatherGclAndSave;
+    procedure UpdateGclGatherTables;
+    procedure PrepareGclGatherData;
+  public
+    constructor Create(AProjectData: TProjectData);
+    destructor Destroy;
+
+    procedure PrepareData(AFlag: Integer);
+  end;
+
+implementation
+
+uses
+  ScAutoUpdateUnit, rdpTables, ComObj, UtilMethods, ZhAPI, Classes,
+  ConstUnit;
+
+{ TReportPrepare }
+
+constructor TReportPrepare.Create(AProjectData: TProjectData);
+begin
+  FProjectData := AProjectData;
+  FPrepareGclGather := False;
+end;
+
+destructor TReportPrepare.Destroy;
+begin
+  FProjectData.ClearReportPrepareData;
+end;
+
+procedure TReportPrepare.GatherGclAndSave;
+var
+  DataSaver: TrdpBillsGatherData;
+begin
+  DataSaver := TrdpBillsGatherData.Create(FProjectData);
+  try
+    DataSaver.LoadGclBillsGatherData;
+  finally
+    DataSaver.Free;
+  end;
+end;
+
+procedure TReportPrepare.PrepareData(AFlag: Integer);
+begin
+  case AFlag of
+    1: PrepareGclGatherData;
+  end;
+  // For Test
+  if G_IsTest then
+    FProjectData.SaveDebugFile(GetAppFilePath+'ReportDataPrepare.dat');
+end;
+
+procedure TReportPrepare.PrepareGclGatherData;
+begin
+  if FPrepareGclGather then Exit;
+
+  try
+    UpdateGclGatherTables;
+    GatherGclAndSave;
+    FPrepareGclGather := True;
+  except
+    FPrepareGclGather := False;
+  end;
+end;
+
+procedure TReportPrepare.UpdateGclGatherTables;
+var
+  Updater: TScUpdater;
+begin
+  Updater := TScUpdater.Create;
+  try
+    Updater.ForceUpdate := True;
+    Updater.Open('', FProjectData.ADOConnection, '', '');
+    Updater.AddTableDef(S_rdpLeafXmjs, @td_rdpLeafXmjs, Length(td_rdpLeafXmjs), False, False);
+    Updater.AddTableDef(S_rdpGclBills, @td_rdpGclBills, Length(td_rdpGclBills), False, False);
+    Updater.AddTableDef(S_rdpDetailGclBills, @td_rdpDetailGclBills, Length(td_rdpDetailGclBills), False, False);
+    Updater.AddTableDef(S_rdpDetailDealBills, @td_rdpDetailDealBills, Length(td_rdpDetailDealBills), False, False);
+    Updater.AddTableDef(S_rdpDetailBGLBills, @td_rdpDetailBGLBills, Length(td_rdpDetailBGLBills), False, False);
+    Updater.ExcuteUpdate;
+  finally
+    Updater.Free;
+  end;
+end;
+
+end.

+ 7 - 0
Units/Connections.pas

@@ -79,6 +79,7 @@ type
     procedure Save; override;
 
     procedure UpdateFileVersion;
+    procedure SaveDebugFile(const AFileName: string);
 
     property NeedUpdate: Boolean read GetNeedUpdate;
     property OverExe: Boolean read GetOverExe;
@@ -405,6 +406,12 @@ begin
   Result := CompareCode(FileVersion, FFileHead.FileVersion, '.') < 0;
 end;
 
+procedure TEncryptConnection.SaveDebugFile(const AFileName: string);
+begin
+  CopyFile(PChar(FFileName), PChar(AFileName), False);
+  RecoverFileHead(AFileName);
+end;
+
 { TConnection }
 
 procedure TConnection.Close;

+ 2 - 2
Units/GclBillsGatherModel.pas

@@ -7,7 +7,7 @@ uses
   Classes, mDataRecord, BillsTree;
 
 type
-  TGatherDataWriteEvent = procedure (AGLJs: TList) of object;
+  TGatherDataWriteEvent = procedure (AGcls, AXmjs: TList) of object;
 
   TLeafXmjNode = class
   private
@@ -509,7 +509,7 @@ begin
     GatherBGLData;
     CalculateAll;
     if Assigned(FWriteGatherData) then
-      FWriteGatherData(FGcls);
+      FWriteGatherData(FGcls, FXmjs);
   finally
     EndGather;
   end;

+ 26 - 7
Units/ProjectData.pas

@@ -63,7 +63,8 @@ type
 
     procedure SaveInfoToManager;
 
-    procedure ExecuteSql(const ASql: string);
+    procedure DropCacheTable(const AKey: string);
+
     // 备份0号台账的历史数据
     procedure CopyLedgerHistoryData(AAudit: Integer);
     // 备份各期的截止本期累计完成数据
@@ -127,6 +128,7 @@ type
     {OpenForReport3: OpenForReport2的基础上打开最后一个审核人数据,打开BillsMeasureTree不打开BillsCompileTree,链接BillsMeasureTree跟StageData}
     procedure OpenForReport3(const AFileName: string);
     //-----------------------  End ---后台打开 ------------------------
+    procedure SaveDebugFile(const AFileName: string);
 
     procedure SaveLastestPhaseMainData;
 
@@ -165,6 +167,8 @@ type
     {For Reports: 复制当期的全部数据到项目数据中}
     procedure CopyPhaseData;
     procedure ClearReportCacheData;
+    procedure ClearReportPrepareData;
+    procedure ExecuteSql(const ASql: string);
 
     procedure CalculateAll;
     procedure CalculatePriceMargin;
@@ -1761,6 +1765,24 @@ begin
 end;
 
 procedure TProjectData.ClearReportCacheData;
+begin
+  DropCacheTable('P_');
+end;
+
+function TProjectData.GetCanInsertNormalBills: Boolean;
+begin
+  if FProjProperties.PhaseCount > 0 then
+    Result := CanUnlockInfo
+  else
+    Result := True;
+end;
+
+procedure TProjectData.ClearReportPrepareData;
+begin
+  DropCacheTable('rdp_');
+end;
+
+procedure TProjectData.DropCacheTable(const AKey: string);
 var
   FTableList: TStringList;
   iIndex: Integer;
@@ -1772,7 +1794,7 @@ begin
     iIndex := 0;
     while iIndex < FTableList.Count do
     begin
-      if Pos('P_', FTableList.Strings[iIndex]) = 1 then
+      if Pos(AKey, FTableList.Strings[iIndex]) = 1 then
       begin
         sDeleteTableSql := Format('Drop Table %s', [FTableList.Strings[iIndex]]);
         ExecuteSql(sDeleteTableSql);
@@ -1784,12 +1806,9 @@ begin
   end;
 end;
 
-function TProjectData.GetCanInsertNormalBills: Boolean;
+procedure TProjectData.SaveDebugFile(const AFileName: string);
 begin
-  if FProjProperties.PhaseCount > 0 then
-    Result := CanUnlockInfo
-  else
-    Result := True;
+  FConnection.SaveDebugFile(AFileName);
 end;
 
 end.

+ 14 - 1
Units/ReportManager.pas

@@ -32,6 +32,8 @@ type
     FInteractSubFlag: Integer;
 
     FInteractInfo: TInteractInfo;
+    FDataPrepareFlag: Integer;
+    FDataBaseFlag: Integer;
 
     procedure ReadPropertyStr;
     procedure AnalyzePropertyStr;
@@ -60,6 +62,11 @@ type
     property InteractFlag: Integer read FInteractFlag;
     property InteractSubFlag: Integer read FInteractSubFlag;
 
+    // 数据准备类型
+    property DataPrepareFlag: Integer read FDataPrepareFlag;
+    // 链接数据库
+    property DataBaseFlag: Integer read FDataBaseFlag;
+
     property InteractInfo: TInteractInfo read FInteractInfo;
   end;
 
@@ -276,7 +283,11 @@ begin
         else if SameText(sgs.Names[I], '交互类型') then
           FInteractFlag := StrToIntDef(sgs.Values[sgs.Names[I]], 0)
         else if SameText(sgs.Names[I], '交互子类型') then
-          FInteractSubFlag := StrToIntDef(sgs.Values[sgs.Names[I]], 0);
+          FInteractSubFlag := StrToIntDef(sgs.Values[sgs.Names[I]], 0)
+        else if SameText(sgs.Names[I], '数据准备') then
+          FDataPrepareFlag := StrToIntDef(sgs.Values[sgs.Names[I]], 0)
+        else if SameText(sgs.Names[I], '数据库') then
+          FDataPrepareFlag := StrToIntDef(sgs.Values[sgs.Names[I]], 0);
       end;
     finally
       sgs.Free;
@@ -289,6 +300,8 @@ begin
   FFileName := AFileName;
   FInteractFlag := 0;
   FInteractSubFlag := 0;
+  FDataPrepareFlag := 0;
+  FDataBaseFlag := 0;
   LoadTemplateProperties;
 end;