|
@@ -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.
|