소스 검색

三华日规客户ACAS与SN防呆处理

jianfeng1.wang 2 년 전
부모
커밋
de15f068f1
3개의 변경된 파일54개의 추가작업 그리고 1개의 파일을 삭제
  1. 42 0
      FactoryTool_CShare/Business/CommonMethod.cs
  2. 6 0
      FactoryTool_CShare/Views/Main.cs
  3. 6 1
      FactoryTool_CShare/Views/OperationPanel.cs

+ 42 - 0
FactoryTool_CShare/Business/CommonMethod.cs

@@ -37,6 +37,7 @@ namespace MOKA_Factory_Tools
 
         private static string lastOrder = "";
         private static List<string> ListACASSN = new List<string>();
+        private static Dictionary<string,string> SN_ACAS_MAP = new Dictionary<string,string>();
 
         private static LoginInput loginInput = new LoginInput();
 
@@ -1927,6 +1928,45 @@ end:
             return true;
         }
 
+        /// <summary>
+        /// 读取指定订单号的文件内容;
+        /// </summary>
+        /// <param name="order"></param>
+        public static void ReadSNACASID(string order)
+        {
+            string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\SN-ACAS";
+            if (!Directory.Exists(path))
+                return;
+
+            string fileName = path + "\\" + order + ".txt";
+            if (!File.Exists(fileName))
+                return;
+
+            try 
+            {
+                IEnumerable<string> lines = File.ReadLines(fileName);
+                foreach (string line in lines)
+                {// key=SN val=ACAS
+                    SN_ACAS_MAP.Add(line.Split(';')[0], line.Split(';')[1]);
+                }
+            }
+            catch(Exception ex) { }
+        }
+
+        /// <summary>
+        /// 判断SN和ACAS是否已存在;
+        /// </summary>
+        /// <param name="sn"></param>
+        /// <param name="acas"></param>
+        /// <returns></returns>
+        public static bool IsSNAndACASExist(string sn, string acas)
+        {
+            if ( SN_ACAS_MAP.Keys.Contains(sn) || SN_ACAS_MAP.Values.Contains(acas))
+                return true;
+
+            return false;
+        }
+
         /// <summary>
         /// 导出日本的SN与ACASID到文本中;
         /// </summary>
@@ -1944,6 +1984,7 @@ end:
             if (!lastOrder.Equals(ordernum))
             {
                 lastOrder = ordernum;
+                ReadSNACASID(ordernum);
                 ListACASSN.Clear();
             }
 
@@ -1954,6 +1995,7 @@ end:
             }
 
             ListACASSN.Add(msg);
+            SN_ACAS_MAP.Add(sn, acasid);
             string fileName = path + "\\" + ordernum + ".txt";
             var stream = new StreamWriter(fileName, true);
             stream.WriteLine(msg);

+ 6 - 0
FactoryTool_CShare/Views/Main.cs

@@ -198,6 +198,12 @@ namespace MOKA_Factory_Tools
             functionSetting1.WBInit = WBInit.Checked;
             functionSetting1.WBPath = WBPath.Text;
 
+            // 读取指定订单号的SN和ACAS值;
+            if (functionSetting1.ExportSNACASID)
+            {
+                CommonMethod.ReadSNACASID(OrderText.Text);
+            }
+
             if (!LocalWrite)
             {
                 if (Preload.Checked)

+ 6 - 1
FactoryTool_CShare/Views/OperationPanel.cs

@@ -1971,8 +1971,13 @@ namespace MOKA_Factory_Tools
                     goto end;
                 }
 
-                //strACASID=data.ToString();
                 strACASID = Encoding.ASCII.GetString(data);
+                if (CommonMethod.IsSNAndACASExist(SN, strACASID))
+                {
+                    ErrMsg = $"SN={SN} or ACASID={strACASID} Exist";
+                    Log.WriteErrorLog(ErrMsg);
+                    goto end;
+                }
             }
 
             //获取key