|
@@ -17,20 +17,23 @@ type
|
|
|
|
|
|
procedure ClearHistoryData;
|
|
|
|
|
|
- procedure CreateDataTables(AProjCount: Integer);
|
|
|
+ procedure CreateDataTables(AProjCount, ASProjCount: Integer);
|
|
|
|
|
|
- procedure SaveGatherProjInfo(AProjs: TList);
|
|
|
+ procedure SaveGatherProjInfo(AProjs, ASProjs: TList);
|
|
|
procedure SaveBills(ATree: TProjGatherTree);
|
|
|
procedure SaveBillsGatherCalc(ATree: TProjGatherTree);
|
|
|
procedure SaveBillsProjCalc(ATree: TProjGatherTree; AProjIndex: Integer);
|
|
|
+ procedure SaveBillsSpecialProjCalc(ATree: TProjGatherTree; AProjType: Integer);
|
|
|
procedure SaveGatherData(AGather: TProjGather);
|
|
|
|
|
|
procedure CalcDgnData(const ATableName: string);
|
|
|
- procedure CalcOtherData(AProjCount: Integer);
|
|
|
+ procedure CalcOtherData(AProjCount, ASProjCount: Integer);
|
|
|
|
|
|
procedure TransposeProjCalc(AProjCount: Integer);
|
|
|
+
|
|
|
+ function GetCurSpecialProjCount: Integer;
|
|
|
protected
|
|
|
- procedure AddTables(AProjCount: Integer; AUpdater: TScUpdater); virtual;
|
|
|
+ procedure AddTables(AProjCount, ASProjCount: Integer; AUpdater: TScUpdater); virtual;
|
|
|
public
|
|
|
constructor Create;
|
|
|
destructor Destroy; override;
|
|
@@ -38,6 +41,7 @@ type
|
|
|
procedure WriteGatherData(AGather: TProjGather);
|
|
|
|
|
|
procedure LoadRelaData(AProjectID: Integer);
|
|
|
+ procedure UpdateDataBase(ASpecialProjTypes: TStrings);
|
|
|
|
|
|
property GatherFile: string read FGatherFile;
|
|
|
property Connection: TADOConnection read FConnection;
|
|
@@ -51,7 +55,7 @@ uses
|
|
|
|
|
|
{ TrpgGatherData }
|
|
|
|
|
|
-procedure TrpgGatherData.AddTables(AProjCount: Integer;
|
|
|
+procedure TrpgGatherData.AddTables(AProjCount, ASProjCount: Integer;
|
|
|
AUpdater: TScUpdater);
|
|
|
var
|
|
|
iProj: Integer;
|
|
@@ -62,6 +66,8 @@ begin
|
|
|
for iProj := 0 to AProjCount - 1 do
|
|
|
AUpdater.AddTableDef(SBills_Proj+IntToStr(iProj+1), @tdBills_Calc, Length(tdBills_Calc), False, False);
|
|
|
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);
|
|
|
end;
|
|
|
|
|
|
procedure TrpgGatherData.CalcDgnData(const ATableName: string);
|
|
@@ -93,13 +99,15 @@ begin
|
|
|
ExecuteSql(Format(sDgn, [ATableName]));
|
|
|
end;
|
|
|
|
|
|
-procedure TrpgGatherData.CalcOtherData(AProjCount: Integer);
|
|
|
+procedure TrpgGatherData.CalcOtherData(AProjCount, ASProjCount: Integer);
|
|
|
var
|
|
|
iProj: Integer;
|
|
|
begin
|
|
|
CalcDgnData(SBills_Gather);
|
|
|
for iProj := 0 to AProjCount - 1 do
|
|
|
- CalcDgnData(SBills_Proj+IntToStr(iProj+1));
|
|
|
+ CalcDgnData(SBills_Proj+IntToStr(iProj+1));
|
|
|
+ for iProj := 0 to ASProjCount - 1 do
|
|
|
+ CalcDgnData(SBills_SProj+IntToStr(iProj+1));
|
|
|
end;
|
|
|
|
|
|
procedure TrpgGatherData.ClearHistoryData;
|
|
@@ -140,7 +148,7 @@ begin
|
|
|
FQuery.Connection := FConnection;
|
|
|
end;
|
|
|
|
|
|
-procedure TrpgGatherData.CreateDataTables(AProjCount: Integer);
|
|
|
+procedure TrpgGatherData.CreateDataTables(AProjCount, ASProjCount: Integer);
|
|
|
var
|
|
|
Updater: TScUpdater;
|
|
|
begin
|
|
@@ -148,7 +156,7 @@ begin
|
|
|
try
|
|
|
Updater.ForceUpdate := True;
|
|
|
Updater.Open('', FConnection, '', '');
|
|
|
- AddTables(AProjCount, Updater);
|
|
|
+ AddTables(AProjCount, ASProjCount, Updater);
|
|
|
Updater.ExcuteUpdate;
|
|
|
finally
|
|
|
Updater.Free;
|
|
@@ -165,10 +173,27 @@ begin
|
|
|
end;
|
|
|
|
|
|
procedure TrpgGatherData.ExecuteSql(const ASql: string);
|
|
|
+var
|
|
|
+ vQuery: TADOQuery;
|
|
|
begin
|
|
|
- FQuery.SQL.Clear;
|
|
|
+ vQuery := TADOQuery.Create(nil);
|
|
|
+ try
|
|
|
+ vQuery.Connection := FConnection;
|
|
|
+ vQuery.SQL.Add(ASql);
|
|
|
+ vQuery.ExecSQL;
|
|
|
+ finally
|
|
|
+ vQuery.Free;
|
|
|
+ end;
|
|
|
+
|
|
|
+ {FQuery.SQL.Clear;
|
|
|
FQuery.SQL.Add(ASql);
|
|
|
- FQuery.ExecSQL;
|
|
|
+ FQuery.ExecSQL;}
|
|
|
+end;
|
|
|
+
|
|
|
+function TrpgGatherData.GetCurSpecialProjCount: Integer;
|
|
|
+begin
|
|
|
+ Result := 0;
|
|
|
+
|
|
|
end;
|
|
|
|
|
|
procedure TrpgGatherData.LoadRelaData(AProjectID: Integer);
|
|
@@ -230,24 +255,44 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
+procedure TrpgGatherData.SaveBillsSpecialProjCalc(ATree: TProjGatherTree;
|
|
|
+ AProjType: Integer);
|
|
|
+var
|
|
|
+ vBillsCalcData: TrpgBillsCalcData;
|
|
|
+begin
|
|
|
+ vBillsCalcData := TrpgBillsCalcData.Create(FConnection);
|
|
|
+ try
|
|
|
+ vBillsCalcData.SaveSpecialProjDataTo(ATree, AProjType, SBills_SProj+IntToStr(AProjType));
|
|
|
+ finally
|
|
|
+ vBillsCalcData.Free;
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TrpgGatherData.SaveGatherData(AGather: TProjGather);
|
|
|
+const
|
|
|
+ sInsert = 'Insert Into %s Select * From %s';
|
|
|
var
|
|
|
iProj: Integer;
|
|
|
begin
|
|
|
- SaveGatherProjInfo(AGather.Projs);
|
|
|
+ SaveGatherProjInfo(AGather.CommonProj, AGather.SpecialProj);
|
|
|
SaveBills(AGather.Tree);
|
|
|
SaveBillsGatherCalc(AGather.Tree);
|
|
|
- for iProj := 0 to AGather.Projs.Count - 1 do
|
|
|
+ for iProj := 0 to AGather.CommonProj.Count - 1 do
|
|
|
+ begin
|
|
|
SaveBillsProjCalc(AGather.Tree, iProj);
|
|
|
+ ExecuteSql(Format(sInsert, [SBills_TransProj, SBills_Proj+IntToStr(iProj+1)]));
|
|
|
+ end;
|
|
|
+ for iProj := 0 to AGather.Tree.SpecialProjCount - 1 do
|
|
|
+ SaveBillsSpecialProjCalc(AGather.Tree, iProj+1);
|
|
|
end;
|
|
|
|
|
|
-procedure TrpgGatherData.SaveGatherProjInfo(AProjs: TList);
|
|
|
+procedure TrpgGatherData.SaveGatherProjInfo(AProjs, ASProjs: TList);
|
|
|
var
|
|
|
vGatherInfoData: TrpgGatherProjData;
|
|
|
begin
|
|
|
vGatherInfoData := TrpgGatherProjData.Create(FConnection);
|
|
|
try
|
|
|
- vGatherInfoData.SaveDataTo(AProjs, SGatherProj);
|
|
|
+ vGatherInfoData.SaveDataTo(AProjs, ASProjs, SGatherProj);
|
|
|
finally
|
|
|
vGatherInfoData.Free;
|
|
|
end;
|
|
@@ -259,17 +304,79 @@ const
|
|
|
var
|
|
|
iProj: Integer;
|
|
|
begin
|
|
|
- for iProj := 0 to AProjCount - 1 do
|
|
|
+ for iProj := 0 to AProjCount - 1 do
|
|
|
ExecuteSql(Format(sInsert, [SBills_TransProj, SBills_Proj+IntToStr(iProj+1)]));
|
|
|
end;
|
|
|
|
|
|
+procedure TrpgGatherData.UpdateDataBase(ASpecialProjTypes: TStrings);
|
|
|
+const
|
|
|
+ sUpdateSql = 'Insert Into %s (BillsID, ProjID, ProjType,' +
|
|
|
+ ' OrgQuantity, OrgTotalPrice, OrgTotalPrice_Rc,' +
|
|
|
+ ' MisQuantity, MisTotalPrice, MisTotalPrice_Rc,' +
|
|
|
+ ' OthQuantity, OthTotalPrice, OthTotalPrice_Rc,' +
|
|
|
+ ' Quantity, TotalPrice, TotalPrice_Rc,' +
|
|
|
+ ' DgnQuantity1, DgnQuantity2, DgnQuantity,' +
|
|
|
+ ' DgnPrice1, DgnPrice2, DgnPrice,' +
|
|
|
+ ' DgnPrice1_Rc, DgnPrice2_Rc, DgnPrice_Rc,' +
|
|
|
+ ' DealDgnQuantity1, DealDgnQuantity2, DealDgnQuantity,' +
|
|
|
+ ' CDgnQuantity1, CDgnQuantity2, CDgnQuantity,' +
|
|
|
+ ' FinalDgnQuantity1, FinalDgnQuantity2, FinalDgnQuantity,' +
|
|
|
+ ' FinalDgnPrice1, FinalDgnPrice2, FinalDgnPrice,' +
|
|
|
+ ' FinalDgnPrice1_Rc, FinalDgnPrice2_Rc, FinalDgnPrice_Rc,' +
|
|
|
+ ' AddDealQuantity, AddDealTotalPrice, AddDealTotalPrice_Rc,' +
|
|
|
+ ' AddQcQuantity, AddQcTotalPrice, AddQcTotalPrice_Rc,' +
|
|
|
+ ' AddGatherQuantity, AddGatherTotalPrice, AddGatherTotalPrice_Rc,' +
|
|
|
+ ' CurDealQuantity, CurDealTotalPrice, CurDealTotalPrice_Rc,' +
|
|
|
+ ' CurQcQuantity, CurQcTotalPrice, CurQcTotalPrice_Rc,' +
|
|
|
+ ' CurGatherQuantity, CurGatherTotalPrice, CurGatherTotalPrice_Rc,' +
|
|
|
+ ' PreDealQuantity, PreDealTotalPrice, PreDealTotalPrice_Rc,' +
|
|
|
+ ' PreQcQuantity, PreQcTotalPrice, PreQcTotalPrice_Rc,' +
|
|
|
+ ' PreGatherQuantity, PreGatherTotalPrice, PreGatherTotalPrice_Rc,' +
|
|
|
+ ' EndDealQuantity, EndDealTotalPrice, EndDealTotalPrice_Rc,' +
|
|
|
+ ' EndQcQuantity, EndQcTotalPrice, EndQcTotalPrice_Rc,' +
|
|
|
+ ' EndGatherQuantity, EndGatherTotalPrice, EndGatherTotalPrice_Rc,' +
|
|
|
+ ' Select BillsID, %d, %d,'+
|
|
|
+ ' 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'+ // 台账明细
|
|
|
+ ' 0, 0, 0,'+ // 台账
|
|
|
+ ' 0, 0, '''', 0, 0, '''', 0, 0, '''','+ // 台账--设计数量、经济指标
|
|
|
+ ' 0, 0, '''', 0, 0, '''','+ // 计量--设计数量
|
|
|
+ ' 0, 0, '''', 0, 0, '''', 0, 0, '''','+ // 计量--经济指标
|
|
|
+ ' 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'+ // 累计数据
|
|
|
+ ' 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'+ // 本期
|
|
|
+ ' 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'+ // 截止上期
|
|
|
+ ' 0, 0, 0, 0, 0, 0, 0, 0, 0, 0'+ // 截止本期
|
|
|
+ ' From r_Bills_Gather';
|
|
|
+var
|
|
|
+ Updater: TScUpdater;
|
|
|
+ iProj, iSpecialProjCount: Integer;
|
|
|
+begin
|
|
|
+ iSpecialProjCount := GetCurSpecialProjCount;
|
|
|
+ if ASpecialProjTypes.Count > iSpecialProjCount then
|
|
|
+ begin
|
|
|
+ Updater := TScUpdater.Create;
|
|
|
+ try
|
|
|
+ Updater.ForceUpdate := True;
|
|
|
+ Updater.Open('', FConnection, '', '');
|
|
|
+ for iProj := iSpecialProjCount to ASpecialProjTypes.Count - 1 do
|
|
|
+ Updater.AddTableDef(SBills_SProj+IntToStr(iProj+1), @tdBills_Calc, Length(tdBills_Calc), False, False);
|
|
|
+ Updater.ExcuteUpdate;
|
|
|
+ finally
|
|
|
+ Updater.Free;
|
|
|
+ end;
|
|
|
+
|
|
|
+ for iProj := iSpecialProjCount to ASpecialProjTypes.Count - 1 do
|
|
|
+ ExecuteSql(Format(sUpdateSql, [SBills_SProj+IntToStr(iProj+1), iProj, iProj+1]));
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TrpgGatherData.WriteGatherData(AGather: TProjGather);
|
|
|
begin
|
|
|
ClearHistoryData;
|
|
|
- CreateDataTables(AGather.Projs.Count);
|
|
|
+ CreateDataTables(AGather.Tree.ProjCount, AGather.Tree.SpecialProjCount);
|
|
|
SaveGatherData(AGather);
|
|
|
- CalcOtherData(AGather.Projs.Count);
|
|
|
- TransposeProjCalc(AGather.Projs.Count);
|
|
|
+ CalcOtherData(AGather.Tree.ProjCount, AGather.Tree.SpecialProjCount);
|
|
|
+ // 集中处理TranProj时,最后一个标段数据丢失
|
|
|
+ //TransposeProjCalc(AGather.Tree.ProjCount);
|
|
|
if _IsDebugView then
|
|
|
CopyFileOrFolder(FGatherFile, GetAppFilePath+'CommonProjGather.dat');
|
|
|
end;
|