Browse Source

Task #1187 导入Excel--0号台账&分项清单,识别错漏数量

MaiXinRong 9 years ago
parent
commit
b70b038538
4 changed files with 35 additions and 17 deletions
  1. 3 3
      Units/DetailExcelImport.pas
  2. 2 2
      Units/ExcelImport.pas
  3. 24 10
      Units/ExcelImport_Bills.pas
  4. 6 2
      Units/MCacheTree.pas

+ 3 - 3
Units/DetailExcelImport.pas

@@ -245,13 +245,13 @@ begin
       vGclNode.B_Code := sB_Code;
       vGclNode.Name := sName;
       vGclNode.Units := sUnits;
-      vGclNode.Quantity := StrToFloatDef(GetCellValue(AXlsFile, FCurRow, FQuantityCol), 0);
+      vGclNode.OrgQuantity := StrToFloatDef(GetCellValue(AXlsFile, FCurRow, FQuantityCol), 0);
       vGclNode.Price := fPrice;
       vGclNode.DrawingCode := Trim(GetCellValue(AXlsFile, FCurRow, FDrawingCol));
       vGclNode.MemoStr := Trim(GetCellValue(AXlsFile, FCurRow, FMemoCol));
     end
     else
-      vGclNode.Quantity := vGclNode.Quantity + StrToFloatDef(GetCellValue(AXlsFile, FCurRow, FQuantityCol), 0);
+      vGclNode.OrgQuantity := vGclNode.OrgQuantity + StrToFloatDef(GetCellValue(AXlsFile, FCurRow, FQuantityCol), 0);
   end;
   Inc(FCurRow);
 end;
@@ -624,7 +624,7 @@ begin
   Rec.ValueByName('Name').AsString := ANode.Name;
   Rec.ValueByName('Units').AsString := ANode.Units;
   Rec.ValueByName('Price').AsFloat := PriceRoundTo(ANode.Price);
-  Rec.ValueByName('OrgQuantity').AsFloat := QuantityRoundTo(ANode.Quantity);
+  Rec.ValueByName('OrgQuantity').AsFloat := QuantityRoundTo(ANode.OrgQuantity);
   Rec.ValueByName('DrawingCode').AsString := ANode.DrawingCode;
   Rec.ValueByName('MemoStr').AsString := ANode.MemoStr;
   // 解锁前,新增清单为变更清单,解锁后,新增清单为0号台账清单

+ 2 - 2
Units/ExcelImport.pas

@@ -472,7 +472,7 @@ begin
   Node.Name := sName;
   Node.Units := GetCellTrimText(ASheet, FUnitsCol, FCurRow);
   Node.Price := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FPriceCol, FCurRow), ''), 0);
-  Node.Quantity := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FQuantityCol, FCurRow), ''), 0);
+  Node.OrgQuantity := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FQuantityCol, FCurRow), ''), 0);
   Node.DgnQuantity1 := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FDgnQuantity1Col, FCurRow), ''), 0);
   Node.DgnQuantity2 := StrToFloatDef(VarToStrDef(GetCellValue(ASheet, FDgnQuantity2Col, FCurRow), ''), 0);
   Node.DrawingCode := GetCellTrimText(ASheet, FDrawingCol, FCurRow);
@@ -514,7 +514,7 @@ begin
   Rec.Name.AsString := ANode.Name;
   Rec.Units.AsString := ANode.Units;
   Rec.Price.AsFloat := PriceRoundTo(ANode.Price);
-  Rec.OrgQuantity.AsFloat := QuantityRoundTo(ANode.Quantity);
+  Rec.OrgQuantity.AsFloat := QuantityRoundTo(ANode.OrgQuantity);
   Rec.DgnQuantity1.AsFloat := QuantityRoundTo(ANode.DgnQuantity1);
   Rec.DgnQuantity2.AsFloat := QuantityRoundTo(ANode.DgnQuantity2);
   Rec.DrawingCode.AsString := ANode.DrawingCode;

+ 24 - 10
Units/ExcelImport_Bills.pas

@@ -25,7 +25,9 @@ type
     FNameCol: Integer;
     FUnitsCol: Integer;
     FPriceCol: Integer;
-    FQuantityCol: Integer;
+    FOrgQuantityCol: Integer;
+    FMisQuantityCol: Integer;
+    FOthQuantityCol: Integer;
     FDgnQuantity1Col: Integer;
     FDgnQuantity2Col: Integer;
     FDrawingCol: Integer;
@@ -59,7 +61,7 @@ implementation
 
 uses
   Forms, Controls, ProgressHintFrm, ConstUnit, UtilMethods, ExcelImport,
-  SysUtils, mDataRecord;
+  SysUtils, mDataRecord, XLSAdapter;
 
 { Tdei_CustomBills }
 
@@ -240,18 +242,22 @@ begin
   FNameCol := -1;
   FUnitsCol := -1;
   FPriceCol := -1;
-  FQuantityCol := -1;
+  FOrgQuantityCol := -1;
+  FMisQuantityCol := -1;
+  FOthQuantityCol := -1;
   FDgnQuantity1Col := -1;
   FDgnQuantity2Col := -1;
   FDrawingCol := -1;
   FMemoCol := -1;
-  for iCol := 1 to Excel.XlsFile.MaxRow do
+  FLevelCol := -1;
+
+  for iCol := 1 to Excel.XlsFile.MaxCol do
   begin
     sColName := GetCellTrimStr(Excel.XlsFile, FCurRow, iCol);
 
-    if (sColName = '预算项目节') or (sColName = '项目节编号') then
+    if Pos('项目节', sColName) > 0 then
       FCodeCol := iCol
-    else if (sColName = '清单子目号') or (sColName = '清单编号') then
+    else if (sColName = '清单编号') or (Pos('子目号', sColName) > 0) then
       FB_CodeCol := iCol
     else if sColName = '名称' then
       FNameCol := iCol
@@ -259,8 +265,12 @@ begin
       FUnitsCol := iCol
     else if sColName = '单价' then
       FPriceCol := iCol
-    else if (sColName = '清单数量') or (sColName = '工程量') or (sColName = '数量') then
-      FQuantityCol := iCol
+    else if (sColName = '清单数量') or (sColName = '工程量') or (sColName = '数量') or (sColName = '施工图数量') then
+      FOrgQuantityCol := iCol
+    else if (sColName = '设计错漏数量') then
+      FMisQuantityCol := iCol
+    else if (sColName = '其他错漏数量') then
+      FOthQuantityCol := iCol
     else if (sColName = '设计数量1') or (sColName = '数量1') then
       FDgnQuantity1Col := iCol
     else if (sColName = '设计数量2') or (sColName = '数量2') then
@@ -334,7 +344,9 @@ begin
   Node.Name := sName;
   Node.Units := GetCellTrimStr(Excel.XlsFile, FCurRow, FUnitsCol);
   Node.Price := GetCellFloat(Excel.XlsFile, FCurRow, FPriceCol);
-  Node.Quantity := GetCellFloat(Excel.XlsFile, FCurRow, FQuantityCol);
+  Node.OrgQuantity := GetCellFloat(Excel.XlsFile, FCurRow, FOrgQuantityCol);
+  Node.MisQuantity := GetCellFloat(Excel.XlsFile, FCurRow, FMisQuantityCol);
+  Node.OthQuantity := GetCellFloat(Excel.XlsFile, FCurRow, FOthQuantityCol);
   Node.DgnQuantity1 := GetCellFloat(Excel.XlsFile, FCurRow, FDgnQuantity1Col);
   Node.DgnQuantity2 := GetCellFloat(Excel.XlsFile, FCurRow, FDgnQuantity2Col);
   Node.DrawingCode := GetCellTrimStr(Excel.XlsFile, FCurRow, FDrawingCol);
@@ -376,7 +388,9 @@ begin
   Rec.Name.AsString := ANode.Name;
   Rec.Units.AsString := ANode.Units;
   Rec.Price.AsFloat := PriceRoundTo(ANode.Price);
-  Rec.OrgQuantity.AsFloat := QuantityRoundTo(ANode.Quantity);
+  Rec.OrgQuantity.AsFloat := QuantityRoundTo(ANode.OrgQuantity);
+  Rec.MisQuantity.AsFloat := QuantityRoundTo(ANode.MisQuantity);
+  Rec.OthQuantity.AsFloat := QuantityRoundTo(ANode.OthQuantity);
   Rec.DgnQuantity1.AsFloat := QuantityRoundTo(ANode.DgnQuantity1);
   Rec.DgnQuantity2.AsFloat := QuantityRoundTo(ANode.DgnQuantity2);
   Rec.DrawingCode.AsString := ANode.DrawingCode;

+ 6 - 2
Units/MCacheTree.pas

@@ -16,7 +16,9 @@ type
     FName: string;
     FUnits: string;
     FCanDelete: Boolean;
-    FQuantity: Double;
+    FOrgQuantity: Double;
+    FMisQuantity: Double;
+    FOthQuantity: Double;
     FDgnQuantity1: Double;
     FDgnQuantity2: Double;
     FMemoStr: string;
@@ -30,7 +32,9 @@ type
     property Units: string read FUnits write FUnits;
     property CanDelete: Boolean read FCanDelete write FCanDelete;
     property Price: Double read FPrice write FPrice;
-    property Quantity: Double read FQuantity write FQuantity;
+    property OrgQuantity: Double read FOrgQuantity write FOrgQuantity;
+    property MisQuantity: Double read FMisQuantity write FMisQuantity;
+    property OthQuantity: Double read FOthQuantity write FOthQuantity;
     property DgnQuantity1: Double read FDgnQuantity1 write FDgnQuantity1;
     property DgnQuantity2: Double read FDgnQuantity2 write FDgnQuantity2;
     property DrawingCode: string read FDrawingCode write FDrawingCode;