Explorar el Código

读取excel 添加进关键件管理数据库

刘彬 hace 2 semanas
padre
commit
878cb357e7

+ 2 - 2
LocalhostMES/DataBase/DatabaseHelper.cs

@@ -387,7 +387,7 @@ namespace LocalhostMES.DataBase
         }
 
 
-        public static List<LocalhostPartInfo> SelectPartInfo(KeyPartStationType stationType)
+        public static List<LocalhostPartInfo> SelectPartInfo(StationType stationType)
         {
             return Db.Queryable<LocalhostPartInfo>().Where(it => it.StationType == stationType).ToList();
         }
@@ -419,7 +419,7 @@ namespace LocalhostMES.DataBase
             return affected;
         }
 
-        public static bool DeletePartInfo(KeyPartStationType stationType, string partNum)
+        public static bool DeletePartInfo(StationType stationType, string partNum)
         {
             var ok = Db.Deleteable<LocalhostPartInfo>()
                 .Where(it => it.StationType == stationType && it.PartNum == partNum)

+ 0 - 24
LocalhostMES/Enums/KeyPartStationType.cs

@@ -1,24 +0,0 @@
-namespace LocalhostMES.Enums
-{
-    /// <summary>
-    /// 关键件维护工站类型:OP10 不分左右,其余工站按左右区分。
-    /// </summary>
-    public enum KeyPartStationType
-    {
-        OP10,
-        OP20L,
-        OP20R,
-        OP30L,
-        OP30R,
-        OP40L,
-        OP40R,
-        OP50L,
-        OP50R,
-        OP60L,
-        OP60R,
-        OP70L,
-        OP70R,
-        OP80L,
-        OP80R
-    }
-}

+ 9 - 9
LocalhostMES/Helpers/KeyPartExcelImporter.cs

@@ -44,7 +44,7 @@ namespace LocalhostMES.Helpers
                 var side = isLeft ? "L" : "R";
 
                 parts.Add(CreatePart(
-                    KeyPartStationType.OP10,
+                    StationType.OP10,
                     row.MaterialCode,
                     row.MaterialCode,
                     "把手零件号",
@@ -53,7 +53,7 @@ namespace LocalhostMES.Helpers
                     1m));
 
                 parts.Add(CreatePart(
-                    KeyPartStationType.OP20L,
+                    StationType.OP20L,
                     row.WireHarness,
                     row.MaterialCode,
                     "线束",
@@ -62,7 +62,7 @@ namespace LocalhostMES.Helpers
                     1m));
 
                 parts.Add(CreatePart(
-                    KeyPartStationType.OP20R,
+                    StationType.OP20R,
                     row.WireHarness,
                     row.MaterialCode,
                     "线束",
@@ -71,7 +71,7 @@ namespace LocalhostMES.Helpers
                     1m));
 
                 parts.Add(CreatePart(
-                    isLeft ? KeyPartStationType.OP30L : KeyPartStationType.OP30R,
+                    isLeft ? StationType.OP30L : StationType.OP30R,
                     row.MaterialCode,
                     row.MaterialCode,
                     string.Empty,
@@ -80,7 +80,7 @@ namespace LocalhostMES.Helpers
                     1m));
 
                 parts.Add(CreatePart(
-                    isLeft ? KeyPartStationType.OP40L : KeyPartStationType.OP40R,
+                    isLeft ? StationType.OP40L : StationType.OP40R,
                     row.MaterialCode,
                     row.MaterialCode,
                     string.Empty,
@@ -89,7 +89,7 @@ namespace LocalhostMES.Helpers
                     1m));
 
                 parts.Add(CreatePart(
-                    isLeft ? KeyPartStationType.OP50L : KeyPartStationType.OP50R,
+                    isLeft ? StationType.OP50L : StationType.OP50R,
                     row.MaterialCode,
                     row.MaterialCode,
                     string.Empty,
@@ -98,7 +98,7 @@ namespace LocalhostMES.Helpers
                     1m));
 
                 parts.Add(CreatePart(
-                    isLeft ? KeyPartStationType.OP60L : KeyPartStationType.OP60R,
+                    isLeft ? StationType.OP60L : StationType.OP60R,
                     row.CoverPlate,
                     row.MaterialCode,
                     "盖板",
@@ -107,7 +107,7 @@ namespace LocalhostMES.Helpers
                     1m));
 
                 parts.Add(CreatePart(
-                    isLeft ? KeyPartStationType.OP70L : KeyPartStationType.OP70R,
+                    isLeft ? StationType.OP70L : StationType.OP70R,
                     row.Actuator,
                     row.MaterialCode,
                     "执行器",
@@ -124,7 +124,7 @@ namespace LocalhostMES.Helpers
         }
 
         private static LocalhostPartInfo CreatePart(
-            KeyPartStationType stationType,
+            StationType stationType,
             string partNum,
             string materialCode,
             string partInfoName,

+ 2 - 1
LocalhostMES/LocalhostMES.csproj

@@ -306,6 +306,8 @@
       <Private>True</Private>
       <Private>True</Private>
     </Reference>
+    <Reference Include="System.IO.Compression" />
+    <Reference Include="System.IO.Compression.FileSystem" />
     <Reference Include="System.IO.Pipelines, Version=10.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
       <HintPath>..\packages\System.IO.Pipelines.10.0.1\lib\net462\System.IO.Pipelines.dll</HintPath>
     </Reference>
@@ -427,7 +429,6 @@
     <Compile Include="Core\TrayIconManager.cs" />
     <Compile Include="DataBase\DatabaseHelper.cs" />
     <Compile Include="Enums\FormulaPartType.cs" />
-    <Compile Include="Enums\KeyPartStationType.cs" />
     <Compile Include="Enums\StationType.cs" />
     <Compile Include="Models\MesModel.cs" />
     <Compile Include="Converters\ResultColorConverter.cs" />

+ 2 - 2
LocalhostMES/Models/MesModel.cs

@@ -190,7 +190,7 @@ namespace LocalhostMES.Models
     /// </summary>
     public class LocalhostPartInfo : BindableBase
     {
-        private KeyPartStationType _stationType;
+        private StationType _stationType;
         private string _partNum;
         private decimal _partQty;
         private string _materialCode;
@@ -199,7 +199,7 @@ namespace LocalhostMES.Models
         private string _partInfoName;
 
         [SqlSugar.SugarColumn(IsPrimaryKey = true)]
-        public KeyPartStationType StationType { get => _stationType; set => SetProperty(ref _stationType, value); }
+        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); }

+ 1 - 1
LocalhostMES/Views/Tabs/KeyPartManagementView.xaml

@@ -41,7 +41,7 @@
                 </Grid.RowDefinitions>
                 <Label Grid.Row="0" Grid.Column="0">工站类型:</Label>
                 <ComboBox Grid.Row="0" Grid.Column="1" Margin="4,0" MinWidth="120"
-                          ItemsSource="{enums:EnumBindingSource EnumType={x:Type enums:KeyPartStationType}}"
+                          ItemsSource="{enums:EnumBindingSource EnumType={x:Type enums:StationType}}"
                           SelectedItem="{Binding NewPart.StationType}" />
                 <Label Grid.Row="0" Grid.Column="2">关键件号:</Label>
                 <TextBox Grid.Row="0" Grid.Column="3" Margin="4,0" MinWidth="160"