Selaa lähdekoodia

打开变更令时,自动拉取新审批完成的变更令

MaiXinRong 7 vuotta sitten
vanhempi
commit
4c5c885a07

+ 6 - 0
DataModules/BGLDm.dfm

@@ -61,6 +61,12 @@ object BGLData: TBGLData
       FieldName = 'BGLType'
       Size = 10
     end
+    object cdsBGLIsCloud: TBooleanField
+      FieldName = 'IsCloud'
+    end
+    object cdsBGLWebID: TIntegerField
+      FieldName = 'WebID'
+    end
   end
   object cdsBGLView: TClientDataSet
     Aggregates = <>

+ 84 - 1
DataModules/BGLDm.pas

@@ -96,6 +96,8 @@ type
     cdsBGBillsViewQuantity: TFloatField;
     cdsBGBillsViewTotalPrice: TFloatField;
     cdsBGBillsViewUsedQuantity: TFloatField;
+    cdsBGLIsCloud: TBooleanField;
+    cdsBGLWebID: TIntegerField;
     procedure cdsBGBillsViewAfterInsert(DataSet: TDataSet);
     procedure cdsBGBillsViewAfterPost(DataSet: TDataSet);
     procedure cdsBGBillsViewQuantityChange(Sender: TField);
@@ -136,6 +138,9 @@ type
 
     function AllBGLTotalPrice: Double;
 
+    function AllCloudBGLWebID: string;
+    procedure LoadCloudBGL(const ABGLs: string);
+
     procedure AddBGL(const sCode: string);
     procedure ApplyBGL(AOrgBGL, ANewBGL: TBGLSelectInfo); overload;
 
@@ -147,7 +152,7 @@ type
 implementation
 
 uses
-  ZhAPI, Math, ProjectData, BillsDm, Variants, UtilMethods;
+  ZhAPI, Math, ProjectData, BillsDm, Variants, UtilMethods, superobject;
 
 {$R *.dfm}
 
@@ -652,4 +657,82 @@ begin
   end;
 end;
 
+function TBGLData.AllCloudBGLWebID: string;
+begin
+  Result := '';
+  cdsBGL.First;
+  while not cdsBGL.Eof do
+  begin
+   if cdsBGLIsCloud.AsBoolean then
+   begin
+    if Result = '' then
+      Result := IntToStr(cdsBGLWebID.AsInteger)
+    else
+      Result := Result + ',' + IntToStr(cdsBGLWebID.AsInteger);
+   end;
+   cdsBGL.Next;
+  end;
+end;
+
+procedure TBGLData.LoadCloudBGL(const ABGLs: string);
+
+  procedure AddCloudBGLBills(ABGLID: Integer; ABGBills: ISuperObject);
+  var
+    i, iNewID: Integer;
+    vJ: ISuperObject;
+  begin
+    for i := 0 to ABGBills.AsArray.Length - 1 do
+    begin
+      iNewID := GetNewIDOfIndex(cdsBGBills);
+      vJ := ABGBills.AsArray.O[i];
+      cdsBGBills.Append;
+      cdsBGBillsID.AsInteger := iNewID;
+      cdsBGBillsBGID.AsInteger := ABGLID;
+      cdsBGBillsB_Code.AsString := vJ.S['lnum'];
+      cdsBGBillsName.AsString := vJ.S['lname'];
+      cdsBGBillsUnits.AsString := vJ.S['unit'];
+      cdsBGBillsPrice.AsFloat := vJ.D['unitprice'];
+      cdsBGBillsQuantity.AsFloat := vJ.D['samount'];
+      cdsBGBillsTotalPrice.AsFloat := TotalPriceRoundTo(cdsBGBillsPrice.AsFloat * cdsBGBillsQuantity.AsFloat);
+      cdsBGBills.Post;
+      UpdateBGLTotalPrice(ABGLID, cdsBGBillsTotalPrice.AsFloat);
+    end;
+  end;
+
+  procedure AddCloudBGL(ABGL: ISuperObject);
+  var
+    iNewID, iCreatePhaseID: Integer;
+    vBGBills: ISuperObject;
+  begin
+    iNewID := GetNewIDOfIndex(cdsBGL);
+    iCreatePhaseID := TProjectData(FProjectData).PhaseIndex;
+    cdsBGL.Append;
+    cdsBGLID.AsInteger := iNewID;
+    cdsBGLCode.AsString := ABGL.S['pnum'];
+    cdsBGLName.AsString := ABGL.S['pname'];
+    cdsBGLPos_Reason.AsString := ABGL.S['description'];
+    cdsBGLDirection.AsString := ABGL.S['basis'];
+    cdsBGLDrawingCode.AsString := ABGL.S['cnum'];
+    cdsBGLApprovalCode.AsString := '';
+    cdsBGLCreatePhaseID.AsInteger := iCreatePhaseID;
+    cdsBGLBGLType.AsString := ABGL.S['changeNature'];
+    cdsBGLIsCloud.AsBoolean := True;
+    cdsBGLWebID.AsInteger := ABGL.I['cid'];
+    cdsBGL.Post;
+    AddCloudBGLBills(iNewID, ABGL.O['changeBills']);
+  end;
+
+var
+  vJ: ISuperObject;
+  i: Integer;
+begin
+  vJ := SO(ABGLs);
+  try
+    for i := 0 to vJ.AsArray.Length - 1 do
+      AddCloudBGL(vJ.AsArray.O[i]);
+  finally
+    vJ := nil;
+  end;
+end;
+
 end.

+ 12 - 7
DataModules/BillsGatherDm.pas

@@ -401,6 +401,17 @@ begin
 end;
 
 function TBillsGatherData.GetAllBillsJson: string;
+
+  function GetBillsJson(Rec: TsdDataRecord): ISuperObject;
+  begin
+    Result := SO;
+    Result.S['lnum'] := Rec.ValueByName('B_Code').AsString;
+    Result.S['lname'] := Rec.ValueByName('Name').AsString;
+    Result.S['unit'] := Rec.ValueByName('Units').AsString;
+    Result.D['unitprice'] := Rec.ValueByName('Price').AsFloat;
+    Result.D['amount'] := Rec.ValueByName('DealQuantity').AsFloat;
+  end;
+
 var
   vJa, vJbills: ISuperObject;
   i: Integer;
@@ -411,13 +422,7 @@ begin
     for i := 0 to sddGclBills.RecordCount - 1 do
     begin
       Rec := sddGclBills.Records[i];
-      vJbills := SO;
-      vJbills.S['lnum'] := Rec.ValueByName('B_Code').AsString;
-      vJbills.S['lname'] := Rec.ValueByName('Name').AsString;
-      vJbills.S['unit'] := Rec.ValueByName('Units').AsString;
-      vJbills.D['unitprice'] := Rec.ValueByName('Price').AsFloat;
-      vJbills.D['amount'] := Rec.ValueByName('DealQuantity').AsFloat;
-      vJa.AsArray.Add(vJbills);
+      vJa.AsArray.Add(GetBillsJson(Rec));
     end;
   finally
     Result := vJa.AsJSon;

+ 22 - 1
Frames/BGLFme.pas

@@ -64,13 +64,15 @@ type
     procedure PasteBGLBlock;
   public
     constructor Create(AParent: TFrame; ABGLData: TBGLData);
+
+    procedure LoadBGLFromCloud;
   end;
 
 implementation
 
 uses
   UtilMethods, MergeTextFrm, ProjectData, MainFrm, mEncryptEditions,
-  BGLClipboard, ConditionalDefines, ZjCells;
+  BGLClipboard, ConditionalDefines, ZjCells, PHPWebDm;
 
 {$R *.dfm}
 
@@ -248,4 +250,23 @@ begin
   end;
 end;
 
+procedure TBGLFrame.LoadBGLFromCloud;
+var
+  sgs: TStrings;
+  sUrl, sInfo: string;
+begin
+  Screen.Cursor := crHourGlass;
+  sgs := TStringList.Create;
+  try
+    sgs.Add(Format('filter=%s', [FBGLData.AllCloudBGLWebID]));
+    sUrl := PHPWeb.WebPath + Format('change/get/%d/list', [TProjectData(FBGLData.ProjectData).WebID]);
+    if PHPWeb.UrlGet(sUrl, sgs, sInfo) = 1 then
+      FBGLData.LoadCloudBGL(sInfo)
+    else if sInfo <> '' then
+      WarningMessage(sInfo);
+  finally
+    Screen.Cursor := crDefault;
+  end;
+end;
+
 end.

+ 1 - 0
Frames/BillsGatherFme.pas

@@ -253,6 +253,7 @@ begin
   sgsParam := TStringList.Create;
   try
     sgsParam.Add(Format('pmid=%d', [TProjectData(FBillsGatherData.ProjectData).WebID]));
+    //sgsParam.Add(Format('pmid=%d', [1595]));
     sgsParam.Add(Format('listjson=%s', [FBillsGatherData.GetAllBillsJson]));
     if PHPWeb.UrlGet(PHPWeb.MeasureURL + 'change/list/create', sgsParam, sResult) = 1 then
       TipMessage('ÉÏ´«³É¹¦¡£')

+ 2 - 0
Frames/ProjectFme.pas

@@ -310,6 +310,8 @@ begin
       jpsAssistant.ActivePageIndex := Tag;
       sbtnExpend.Tag := Tag;
       ControlAssistantButtonsDown(Tag);
+      if _IsCloud and (Tag = tobtnBGL.Tag) then
+        BGLFrame.LoadBGLFromCloud;
       jpsMain.ActivePage.Tag := Tag;
     end;
     SetAssistantViewVisible(Down);

+ 1 - 1
Units/Connections.pas

@@ -8,7 +8,7 @@ uses
 const
   ProductName = 'Measure';
   EmptyFileVersion = '1.0.0.0';
-  FileVersion = '1.0.1.17';
+  FileVersion = '1.0.1.18';
   EncryptVersion = 'Auto1.0';
   SAdoConnectStr = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s;' +
                    'User ID=Admin;Password='''';Persist Security Info=True';

+ 6 - 2
Units/DataBaseTables.pas

@@ -344,7 +344,7 @@ const
 
   {变更令}
   SBGL = 'BGL';
-  tdBGL: array [0..11] of TScFieldDef =(
+  tdBGL: array [0..13] of TScFieldDef =(
     (FieldName: 'ID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: True; PrimaryKey: True; ForceUpdate: False),
     // 变更令号
     (FieldName: 'Code'; FieldType: ftString; Size: 50; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
@@ -367,7 +367,11 @@ const
     // 已执行
     (FieldName: 'ExecutionRate'; FieldType: ftDouble; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
     // 变更令类型:一般、较大、重大
-    (FieldName: 'BGLType'; FieldType: ftString; Size: 10; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
+    (FieldName: 'BGLType'; FieldType: ftString; Size: 10; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 是否来自变更令系统
+    (FieldName: 'IsCloud'; FieldType: ftBoolean; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False),
+    // 变更令系统中ID
+    (FieldName: 'WebID'; FieldType: ftInteger; Size: 0; Precision: 0; NotNull: False; PrimaryKey: False; ForceUpdate: False)
   );
 
   SBGBills = 'BGBills';