Quellcode durchsuchen

Merge repos.ubtob.net:usoft/mes-client

callm vor 2 Tagen
Ursprung
Commit
6741e19992

+ 8 - 1
UAS_MES_HYSX/FunctionCode/Make/Make_ListenSocket.cs

@@ -36,7 +36,14 @@ namespace UAS_MES_NEW.Make
 
         private void Start_Click(object sender, EventArgs e)
         {
-
+            if(Start.Text == "开启监听")
+            {
+                Start.Text = "关闭监听";
+            }
+            else if (Start.Text == "关闭监听")
+            {
+                Start.Text = "开启监听";
+            }
         }
     }
 }

+ 11 - 5
UAS_MES_HYSX/FunctionCode/Make/Make_ParseLog.cs

@@ -622,11 +622,17 @@ namespace UAS_MES_NEW.Make
             string username = "vsftpd";
             string password = "vsftpd3ef41637hy";
 
-            string currentDate = DateTime.Now.ToString("yyyyMMdd");
-            //string ftpFullPath = $"{ftpServer.TrimEnd('/')}/{currentDate}";
-            string ftpFullPath = $"{ftpServer.TrimEnd('/')}/{currentDate}/{Sn}";
-            string outResult = CreateFtpDirectoryIfNotExists(ftpFullPath, username, password);
-            if (outResult.Substring(0, 2) == "NG")
+            string ftpTimePath = $"{ftpServer.TrimEnd('/')}/{DateTime.Now.ToString("yyyyMMdd")}";
+            string outResult = CreateFtpDirectoryIfNotExists(ftpTimePath, username, password);
+            if (outResult.Substring(0, 2) != "OK")
+            {
+                LogMessage(0, outResult);
+                return false;
+            }
+
+            string ftpFullPath = $"{ftpTimePath}/{Sn}";
+            outResult = CreateFtpDirectoryIfNotExists(ftpFullPath, username, password);
+            if (outResult.Substring(0, 2) != "OK")
             {
                 LogMessage(0, outResult);
                 return false;

+ 86 - 73
UAS_MES_HYSX/FunctionCode/Make/Make_ThruputLog.cs

@@ -49,107 +49,120 @@ namespace UAS_MES_NEW.Make
             passPath = Path.Combine(logsPath, "pass"); 
             failPath = Path.Combine(logsPath, "fail");
 
-            string[] passFiles = Directory.GetFiles(passPath, $"*up.log");
+            string upRes, downRes;
+
+            List<string> SNArr = new List<string> { };
+            string[] passFiles = Directory.GetFiles(passPath, $"*.log");
             foreach (string currLog in passFiles)
             {
-                string upRes = ParseIperfBitrate(currLog);
-
-                string sn = Path.GetFileName(currLog).Split('_')[0];
-                UpdateSN("L", sn);
-
-                SQL.Clear();
-                SQL.Append($@"SELECT ms_sncode,ma_code,pr_code,pr_spec FROM makeserial,make,product WHERE ms_sncode = '{sn}' AND ms_makecode = ma_code AND ms_prodcode = pr_code");
-                dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
-                if (dt.Rows.Count == 0)
+                if (Path.GetFileName(currLog).Contains("up"))
                 {
-                    ShowMsg(0, $"序列号无归属工单");
-                    continue;
-                }
-                string wo = dt.Rows[0]["ma_code"].ToString();
-                string logPath = Path.GetDirectoryName(currLog);
-                string downLog = Path.Combine(logPath, $"{sn}_down.log");
+                    upRes = ParseIperfBitrate(currLog);
+                    string sn = Path.GetFileName(currLog).Split('_')[0];
+                    UpdateSN("L", sn);
+                    SNArr.Add(sn);
+                    if (SNArr.IndexOf(sn) > 0)  continue;
+
+                    SQL.Clear();
+                    SQL.Append($@"SELECT ms_sncode,ma_code,pr_code,pr_spec FROM makeserial,make,product WHERE ms_sncode = '{sn.Replace(";", ";")}' AND ms_makecode = ma_code AND ms_prodcode = pr_code");
+                    dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
+                    if (dt.Rows.Count == 0)
+                    {
+                        ShowMsg(0, $"序列号:{sn.Replace(";", ";")},无归属工单");
+                        continue;
+                    }
+                    string wo = dt.Rows[0]["ma_code"].ToString();
+                    string logPath = Path.GetDirectoryName(currLog);
+                    string downLog = Path.Combine(logPath, $"{Path.GetFileName(currLog).Replace("up", "down")}");
 
-                string downRes = ParseIperfBitrate(downLog);
-                string tDetail = $"upRate/{upRes};downRate/{downRes}";
+                    downRes = ParseIperfBitrate(downLog);
+                    string tDetail = $"upRate/{upRes};downRate/{downRes}";
 
-                CheckPassStation(wo, sn, "PASS", tDetail);
+                    CheckPassStation(wo, sn, "PASS", tDetail);
 
-                using (StreamReader SR = new StreamReader(currLog, Encoding.GetEncoding("GBK")))
-                {
-                    string Content = SR.ReadToEnd();
-                    SR.Close();
-                    SR.Dispose();
-                    if (ConsoleLog(Content, currLog, $"{sn}_up.log"))
+                    using (StreamReader SR = new StreamReader(currLog, Encoding.GetEncoding("GBK")))
                     {
-                        File.WriteAllText(currLog, string.Empty);
-                        File.Delete(currLog);
+                        string Content = SR.ReadToEnd();
+                        SR.Close();
+                        SR.Dispose();
+                        if (ConsoleLog(Content, currLog, $"{Path.GetFileName(currLog)}"))
+                        {
+                            File.WriteAllText(currLog, string.Empty);
+                            File.Delete(currLog);
+                        }
                     }
-                }
 
-                using (StreamReader SR = new StreamReader(downLog, Encoding.GetEncoding("GBK")))
-                {
-                    string Content = SR.ReadToEnd();
-                    SR.Close();
-                    SR.Dispose();
-                    if (ConsoleLog(Content, currLog, $"{sn}_down.log"))
+                    using (StreamReader SR = new StreamReader(downLog, Encoding.GetEncoding("GBK")))
                     {
-                        File.WriteAllText(currLog, string.Empty);
-                        File.Delete(currLog);
+                        string Content = SR.ReadToEnd();
+                        SR.Close();
+                        SR.Dispose();
+                        if (ConsoleLog(Content, currLog, $"{Path.GetFileName(currLog).Replace("up", "down")}"))
+                        {
+                            File.WriteAllText(currLog, string.Empty);
+                            File.Delete(currLog);
+                        }
                     }
                 }
             }
 
-            string[] failFiles = Directory.GetFiles(failPath, $"*up.log");
+            string[] failFiles = Directory.GetFiles(failPath, $"*.log");
             foreach (string currLog in failFiles)
             {
-                string upRes = ParseIperfBitrate(currLog);
-                string sn = Path.GetFileName(currLog).Split('_')[0];
-                UpdateSN("L", sn);
-
-                SQL.Clear();
-                SQL.Append($@"SELECT ms_sncode,ma_code,pr_code,pr_spec FROM makeserial,make,product WHERE ms_sncode = '{sn}' AND ms_makecode = ma_code AND ms_prodcode = pr_code");
-                dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
-                if (dt.Rows.Count == 0)
+                if (Path.GetFileName(currLog).Contains("up"))
                 {
-                    ShowMsg(0, $"序列号无归属工单");
-                    continue;
-                }
-                string wo = dt.Rows[0]["ma_code"].ToString();
-                string logPath = Path.GetDirectoryName(currLog);
-                string downLog = Path.Combine(logPath, $"{sn}_down.log");
+                    upRes = ParseIperfBitrate(currLog);
+                    string sn = Path.GetFileName(currLog).Split('_')[0];
+                    UpdateSN("L", sn);
+                    SNArr.Add(sn);
+                    if (SNArr.IndexOf(sn) > 0)  continue;
+
+                    SQL.Clear();
+                    SQL.Append($@"SELECT ms_sncode,ma_code,pr_code,pr_spec FROM makeserial,make,product WHERE ms_sncode = '{sn.Replace(";", ";")}' AND ms_makecode = ma_code AND ms_prodcode = pr_code");
+                    dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
+                    if (dt.Rows.Count == 0)
+                    {
+                        ShowMsg(0, $"序列号:{sn.Replace(";", ";")},无归属工单");
+                        continue;
+                    }
+                    string wo = dt.Rows[0]["ma_code"].ToString();
+                    string logPath = Path.GetDirectoryName(currLog);
+                    string downLog = Path.Combine(logPath, $"{Path.GetFileName(currLog).Replace("up", "down")}");
 
-                string downRes = ParseIperfBitrate(downLog);
-                string tDetail = $"upRate/{upRes};downRate/{downRes}";
+                    downRes = ParseIperfBitrate(downLog);
+                    string tDetail = $"upRate/{upRes};downRate/{downRes}";
 
-                CheckPassStation(wo, sn, "PASS", tDetail);
+                    CheckPassStation(wo, sn, "PASS", tDetail);
 
-                using (StreamReader SR = new StreamReader(currLog, Encoding.GetEncoding("GBK")))
-                {
-                    string Content = SR.ReadToEnd();
-                    SR.Close();
-                    SR.Dispose();
-                    if (ConsoleLog(Content, currLog, $"{sn}_up.log"))
+                    using (StreamReader SR = new StreamReader(currLog, Encoding.GetEncoding("GBK")))
                     {
-                        File.WriteAllText(currLog, string.Empty);
-                        File.Delete(currLog);
+                        string Content = SR.ReadToEnd();
+                        SR.Close();
+                        SR.Dispose();
+                        if (ConsoleLog(Content, currLog, $"{Path.GetFileName(currLog)}"))
+                        {
+                            File.WriteAllText(currLog, string.Empty);
+                            File.Delete(currLog);
+                        }
                     }
-                }
 
-                using (StreamReader SR = new StreamReader(downLog, Encoding.GetEncoding("GBK")))
-                {
-                    string Content = SR.ReadToEnd();
-                    SR.Close();
-                    SR.Dispose();
-                    if (ConsoleLog(Content, currLog, $"{sn}_down.log"))
+                    using (StreamReader SR = new StreamReader(downLog, Encoding.GetEncoding("GBK")))
                     {
-                        File.WriteAllText(currLog, string.Empty);
-                        File.Delete(currLog);
+                        string Content = SR.ReadToEnd();
+                        SR.Close();
+                        SR.Dispose();
+                        if (ConsoleLog(Content, currLog, $"{Path.GetFileName(currLog).Replace("up", "down")}"))
+                        {
+                            File.WriteAllText(currLog, string.Empty);
+                            File.Delete(currLog);
+                        }
                     }
                 }
             }
         }
         private void CheckPassStation(string wo,string sn, string testRes, string testDetail)
         {
+            sn = sn.Replace(";", ";");
             List<string> param = new List<string>() { };
             string outMsg = "";
             param.Add(wo);
@@ -165,7 +178,7 @@ namespace UAS_MES_NEW.Make
             dh.CallProcedure("cs_insert_testrejects", ref paramList);
             if (paramList[8].Substring(0, 2) == "OK")
             {
-                ShowMsg(1, $"序列号{sn}采集成功:测试结果为{testRes}");
+                ShowMsg(1, $"序列号{sn}采集成功:测试结果为{testRes},{testDetail}");
                 LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, workOrder.Text, User.UserLineCode, User.UserSourceCode, "无线吞吐量", "无线吞吐量过站成功", sn, "");
             }
 
@@ -181,7 +194,7 @@ namespace UAS_MES_NEW.Make
             {
                 if (LogicHandler.SetStepResult(oWO, User.UserSourceCode, sn, "无线吞吐量", "OK", User.UserCode, out oErrMsg))
                 {
-                    ShowMsg(0, $"序列号{sn},过站记录成功");
+                    ShowMsg(1, $"序列号{sn},过站记录成功");
                 }
                 else
                 {

+ 11 - 3
UAS_MES_HYSX/FunctionCode/Make/Make_WirelessThroughput.cs

@@ -172,7 +172,7 @@ namespace UAS_MES_NEW.Make
             {
                 if (LogicHandler.SetStepResult(oWO, User.UserSourceCode, sn, "无线吞吐量", "OK", User.UserCode, out oErrMsg))
                 {
-                    ShowMsg(0, $"序列号{sn},过站记录成功");
+                    ShowMsg(1, $"序列号{sn},过站记录成功");
                 }
                 else
                 {
@@ -312,8 +312,6 @@ namespace UAS_MES_NEW.Make
 
                 Msg.Clear();
                 Msg.Append(StartIperfTest(cmdType));
-                if (Msg.ToString().StartsWith("NG")) return Msg.ToString();
-
 
                 return Msg.ToString();
             }
@@ -398,6 +396,11 @@ namespace UAS_MES_NEW.Make
                         downRate = ParseIperfBitrate(downLog);
 
                         Close();
+
+                        if(string.IsNullOrEmpty(upRate) || string.IsNullOrEmpty(downRate))
+                        {
+                            return $"NG,指令一无法获测试结果,请核对指令或使用吞吐量日志解析";
+                        }
                         return $"OK,{upRate}|{downRate}";
                     }
                     else
@@ -430,6 +433,11 @@ namespace UAS_MES_NEW.Make
                         downRate = ParseIperfBitrate(downLog);
 
                         Close();
+
+                        if (string.IsNullOrEmpty(upRate) || string.IsNullOrEmpty(downRate))
+                        {
+                            return $"NG,指令二获取测试结果,请核对指令或使用吞吐量日志解析";
+                        }
                         return $"OK,{upRate}|{downRate}";
                     }
                 }