瀏覽代碼

优化表格提取

Eson 2 周之前
父節點
當前提交
9f157932f8
共有 2 個文件被更改,包括 20 次插入16 次删除
  1. 18 14
      LocalhostMES/Helpers/KeyPartExcelImporter.cs
  2. 2 2
      LocalhostMES/Models/MesModel.cs

+ 18 - 14
LocalhostMES/Helpers/KeyPartExcelImporter.cs

@@ -39,7 +39,10 @@ namespace LocalhostMES.Helpers
                 {
                     continue;
                 }
-
+                if (row.WireHarness.Trim().Length<3)
+                {
+                    row.WireHarness = "";
+                }
                 var isLeft = (row.HandlePosition ?? string.Empty).Contains("左");
                 var side = isLeft ? "L" : "R";
 
@@ -51,16 +54,17 @@ namespace LocalhostMES.Helpers
                     string.Empty,
                     string.Empty,
                     1m));
-
-                parts.Add(CreatePart(
-                    StationType.OP20L,
-                    row.WireHarness,
-                    row.MaterialCode,
-                    "线束",
-                    "HANDLE-ZP01-L-02",
-                    "HANDLE-ZP01-L-02-015",
-                    1m));
-
+                if (side == "L")
+                {
+                    parts.Add(CreatePart(
+                        StationType.OP20L,
+                        row.WireHarness,
+                        row.MaterialCode,
+                        "线束",
+                        "HANDLE-ZP01-L-02",
+                        "HANDLE-ZP01-L-02-01",
+                        1m));
+                }
                 parts.Add(CreatePart(
                     StationType.OP20R,
                     row.WireHarness,
@@ -118,7 +122,7 @@ namespace LocalhostMES.Helpers
 
             return parts
                 .Where(p => p != null)
-                .GroupBy(p => new { p.StationType, p.PartNum })
+                .GroupBy(p => new { p.StationType, p.MaterialCode })
                 .Select(g => g.Last())
                 .ToList();
         }
@@ -132,7 +136,7 @@ namespace LocalhostMES.Helpers
             string positionCode,
             decimal partQty)
         {
-            var pn = (partNum ?? string.Empty).Trim();
+            var pn = (materialCode ?? string.Empty).Trim();
             var material = (materialCode ?? string.Empty).Trim();
             if (string.IsNullOrWhiteSpace(pn))
             {
@@ -142,7 +146,7 @@ namespace LocalhostMES.Helpers
             return new LocalhostPartInfo
             {
                 StationType = stationType,
-                PartNum = pn,
+                PartNum = partNum,
                 MaterialCode = material,
                 PartInfoName = (partInfoName ?? string.Empty).Trim(),
                 StationCode = (stationCode ?? string.Empty).Trim(),

+ 2 - 2
LocalhostMES/Models/MesModel.cs

@@ -200,11 +200,11 @@ namespace LocalhostMES.Models
 
         [SqlSugar.SugarColumn(IsPrimaryKey = true)]
         public StationType StationType { get => _stationType; set => SetProperty(ref _stationType, value); }
-
-        [SqlSugar.SugarColumn(IsPrimaryKey = true, Length = 128)]
         public string PartNum { get => _partNum; set => SetProperty(ref _partNum, value); }
 
         public decimal PartQty { get => _partQty; set => SetProperty(ref _partQty, value); }
+
+        [SqlSugar.SugarColumn(IsPrimaryKey = true)]
         public string MaterialCode { get => _materialCode; set => SetProperty(ref _materialCode, value); }
         public string StationCode { get => _stationCode; set => SetProperty(ref _stationCode, value); }
         public string PositionCode { get => _positionCode; set => SetProperty(ref _positionCode, value); }