ソースを参照

汇总,汇总变更令数据

MaiXinRong 8 年 前
コミット
45a4e24597

+ 27 - 0
Report/ProjGather/rProjGatherTables.pas

@@ -271,6 +271,33 @@ const
     //--9
   );
 
+  SBGL_TransProj = 'r_BGL_TransProj';
+  tdBGL_TransProj: array [0..10] of TScFieldDef =(
+    // 与Bills表ID对应
+    (FieldName: 'ID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 对应于r_GatherProj中的ID字段
+    (FieldName: 'ProjID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
+    // 项目类型(r_Bills_SProj使用,用于标记非正常汇总项目)
+    (FieldName: 'ProjType'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+
+    // 变更令号
+    (FieldName: 'Code'; FieldType: ftString; Size: 50; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 名称
+    (FieldName: 'Name'; FieldType: ftString; Size: 100; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 金额
+    (FieldName: 'TotalPrice'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 变更部位及原因
+    (FieldName: 'Pos_Reason'; FieldType: ftMemo; Size: 60535; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 变更工程量说明
+    (FieldName: 'Direction'; FieldType: ftMemo; Size: 60535; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 变更图号
+    (FieldName: 'DrawingCode'; FieldType: ftString; Size: 50; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 批准文号
+    (FieldName: 'ApprovalCode'; FieldType: ftString; Size: 50; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 变更令类型:一般、较大、重大
+    (FieldName: 'BGLType'; FieldType: ftString; Size: 10; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+  );
+
 implementation
 
 end.

+ 62 - 1
Report/ProjGather/rpgGatherData.pas

@@ -4,7 +4,7 @@ interface
 
 uses
   ADODB, ProjGather, rpgGatherProjDm, rpgBillsDm, rpgBillsCalcDm, Classes,
-  ScAutoUpdateUnit, ProjGatherTree;
+  ScAutoUpdateUnit, ProjGatherTree, GatherProjInfo;
 
 type
   TrpgGatherData = class
@@ -27,10 +27,15 @@ type
 
     procedure TransposeProjCalc(AProjCount: Integer);
 
+    function GetCacheProjFile(AProj: TGatherProjInfo): string;
+    procedure CopyBGLData(const AFileName: string; AProjIndex, AProjType: Integer);
+    procedure CopyProjRelaGatherData(AProj: TGatherProjInfo; AProjIndex: Integer);
+
     function GetCurSpecialProjCount: Integer;
   protected
     procedure AddTables(AProjCount, ASProjCount: Integer; AUpdater: TScUpdater); virtual;
     procedure SaveGatherData(AGather: TProjGather); virtual;
+    procedure CopyRelaGatherData(AGather: TProjGather); virtual;
   public
     constructor Create;
     destructor Destroy; override;
@@ -65,6 +70,7 @@ begin
   AUpdater.AddTableDef(SBills_TransProj, @tdBills_Calc, Length(tdBills_Calc), False, False);
   for iProj := 0 to ASProjCount - 1 do
     AUpdater.AddTableDef(SBills_SProj+IntToStr(iProj+1), @tdBills_Calc, Length(tdBills_Calc), False, False);
+  AUpdater.AddTableDef(SBGL_TransProj, @tdBGL_TransProj, Length(tdBGL_TransProj), False, False);
 end;
 
 procedure TrpgGatherData.CalcDgnData(const ATableName: string);
@@ -132,6 +138,20 @@ begin
   end;
 end;
 
+procedure TrpgGatherData.CopyProjRelaGatherData(AProj: TGatherProjInfo;
+  AProjIndex: Integer);
+var
+  sTempFile: string;
+begin
+  try
+    sTempFile := GetCacheProjFile(AProj);
+    CopyBGLData(sTempFile, AProjIndex, AProj.ProjType);
+  finally
+    if FileExists(sTempFile) then
+      DeleteFile(sTempFile);
+  end;
+end;
+
 constructor TrpgGatherData.Create;
 begin
   FGatherFile := GetTempFileName;
@@ -185,6 +205,16 @@ begin
   end;
 end;
 
+procedure TrpgGatherData.CopyBGLData(const AFileName: string; AProjIndex, AProjType: Integer);
+const
+  sCopyBGL = 'Insert Into r_BGL_TransProj' +
+             '  Select ID, %d As ProjID, %d As ProjType,' +
+             '    Code, Name, TotalPrice, Pos_Reason, Direction, DrawingCode, ApprovalCode, BGLType' +
+             '  From BGL In ''%s''';
+begin
+  ExecuteSql(FConnection, Format(sCopyBGL, [AProjIndex, AProjType, AFileName]));
+end;
+
 procedure TrpgGatherData.LoadRelaData(AProjectID: Integer);
 const
   sCopyProperty = 'Select * Into r_ProjProperties'+
@@ -270,9 +300,12 @@ begin
   begin
     SaveBillsProjCalc(AGather.Tree, iProj);
     ExecuteSql(FConnection, Format(sInsert, [SBills_TransProj, SBills_Proj+IntToStr(iProj+1)]));
+    CopyProjRelaGatherData(TGatherProjInfo(AGather.CommonProj.Items[iProj]), iProj);
   end;
   for iProj := 0 to AGather.Tree.SpecialProjCount - 1 do
     SaveBillsSpecialProjCalc(AGather.Tree, iProj+1);
+  for iProj := 0 to AGather.SpecialProj.Count - 1 do
+    CopyProjRelaGatherData(TGatherProjInfo(AGather.SpecialProj.Items[iProj]), -3);
 end;
 
 procedure TrpgGatherData.SaveGatherProjInfo(AProjs, ASProjs: TList);
@@ -379,10 +412,38 @@ begin
   CreateDataTables(AGather.Tree.ProjCount, AGather.Tree.SpecialProjCount);
   SaveGatherData(AGather);
   CalcOtherData(AGather.Tree.ProjCount, AGather.Tree.SpecialProjCount);
+  //CopyRelaGatherData(AGather);
   // 集中处理TranProj时,最后一个标段数据丢失
   //TransposeProjCalc(AGather.Tree.ProjCount);
   if _IsDebugView then
     CopyFileOrFolder(FGatherFile, GetAppFilePath+'CommonProjGather.dat');
 end;
 
+procedure TrpgGatherData.CopyRelaGatherData(AGather: TProjGather);
+var
+  iProj: Integer;
+begin
+  for iProj := 0 to AGather.CommonProj.Count - 1 do
+    CopyProjRelaGatherData(TGatherProjInfo(AGather.CommonProj.Items[iProj]), iProj);
+  for iProj := 0 to AGather.SpecialProj.Count - 1 do
+    CopyProjRelaGatherData(TGatherProjInfo(AGather.SpecialProj.Items[iProj]), -3);
+end;
+
+function TrpgGatherData.GetCacheProjFile(AProj: TGatherProjInfo): string;
+var
+  vProjData: TProjectData;
+begin
+  Result := GetTempFileName;
+  vProjData := OpenProjectManager.FindProjectData(AProj.ProjectID);
+  if not Assigned(vProjData) then
+  begin
+    vProjData := TProjectData.Create;
+    vProjData.SimpleOpen(GetMyProjectsFilePath + AProj.FileName);
+    vProjData.SaveTempDataBaseFile(Result);
+    vProjData.Free;
+  end
+  else
+    vProjData.SaveTempDataBaseFile(Result);
+end;
+
 end.