瀏覽代碼

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

callm 2 月之前
父節點
當前提交
8638072873

+ 126 - 0
UAS_MES_BG/FunctionCode/Make/Make_Repair.cs

@@ -3,6 +3,8 @@ using System.Collections;
 using System.Collections.Generic;
 using System.Data;
 using System.Drawing;
+using System.IO;
+using System.Net;
 using System.Text;
 using System.Windows.Forms;
 using UAS_MES_NEW.CustomControl.DataGrid_View;
@@ -563,6 +565,31 @@ namespace UAS_MES_NEW.Make
                 OperatResult.AppendText(">>" + ErrorMessage + "未维护不良原因\n", Color.Red);
                 return;
             }
+            DialogResult result = MessageBox.Show("是否需要上传图片", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
+            if(result == DialogResult.Yes)
+            {
+                using (OpenFileDialog openFileDialog = new OpenFileDialog())
+                {
+                    openFileDialog.Multiselect = true;
+                    openFileDialog.Title = "选择图片";
+                    openFileDialog.Filter = "图片文件|*.jpg;*.jpeg;*.png;*.bmp;*.gif;*.tiff;*.ico";
+
+                    if (openFileDialog.ShowDialog() == DialogResult.OK)
+                    {
+                        foreach (string path in openFileDialog.FileNames)
+                        {
+                           if (UploadFileToFtp(path, ms_sncode.Text.Trim()))
+                           {
+                                dh.ExecuteSql($@"INSERT INTO steptestdetail( std_id, std_makecode, std_sn, std_class, 
+                                                std_testresult, std_value1) 
+                                                VALUES( steptestdetail_seq.NEXTVAL, '{ms_makecode.Text}', '{ms_sncode.Text.Trim()}', '维修图片', 
+                                                'http://192.168.1.92:8088/ftp/mes/Picture/{ms_sncode.Text.Trim()}/{Path.GetFileName(path)}', nvl(std_value1, 0) + 1)", "insert");
+                           }
+                        }
+                    }
+                }
+            }
+
             //如果岗位资源对应工序的版面不为空的时候
             //if (dh.getFieldDataByCondition("makeserial left join step on ms_stepcode=st_code", "st_table", "ms_id='" + msid + "'").ToString() != "")
             //{
@@ -876,8 +903,10 @@ namespace UAS_MES_NEW.Make
         private void mbl_loc_KeyDown(object sender, KeyEventArgs e)
         {
             if (e.KeyCode == Keys.Enter)
+            {
                 QueryBadLocal();
                 SaveBadLocation_Click(sender, e);
+            }
         }
 
         private void QueryBadLocal()
@@ -1216,5 +1245,102 @@ namespace UAS_MES_NEW.Make
                 }
             }
         }
+
+        public bool UploadFileToFtp(string localFilePath,string Sn)
+        {
+            //string ftpServer = "ftp://10.8.0.208:21/mes/Picture/";
+            string ftpServer = "ftp://192.168.1.92:21/mes/Picture/";
+            string username = "vsftpd";
+            string password = "vsftpd3cd79018fl";
+
+            /*string currentDate = DateTime.Now.ToString("yyyyMMdd");
+            string ftpFullPath = $"{ftpServer.TrimEnd('/')}/{currentDate}";*/
+
+            string ftpFullPath = $"{ftpServer.TrimEnd('/')}/{Sn}";
+            string outResult = CreateFtpDirectoryIfNotExists(ftpFullPath, username, password);
+            if (outResult.Substring(0, 2) == "NG")
+            {
+                OperatResult.AppendText($">{outResult}\n", Color.Red);
+                return false;
+            }
+
+            string remoteFileName = Path.GetFileName(localFilePath);
+            string uri = $"{ftpFullPath}/{remoteFileName}";
+
+            try
+            {
+                var request = (FtpWebRequest)WebRequest.Create(uri);
+                request.Method = WebRequestMethods.Ftp.UploadFile;
+                request.Credentials = new NetworkCredential(username, password);
+                request.UsePassive = true;
+                request.UseBinary = true;
+                request.KeepAlive = false;
+
+                using (var fileStream = File.OpenRead(localFilePath))
+                using (var requestStream = request.GetRequestStream())
+                {
+                    byte[] buffer = new byte[4096];
+                    int bytesRead;
+                    while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) > 0)
+                    {
+                        requestStream.Write(buffer, 0, bytesRead);
+                    }
+                }
+
+                using (var response = (FtpWebResponse)request.GetResponse())
+                {
+                    OperatResult.AppendText($">文件: {localFilePath}上传成功,状态{response.StatusDescription}\n", Color.Green);
+                    return true;
+                }
+            }
+            catch (WebException ex)
+            {
+                if (ex.Response is FtpWebResponse response)
+                {
+                    OperatResult.AppendText($">FTP 错误码: {(int)response.StatusCode} - {response.StatusDescription}\n", Color.Red);
+                }
+                else
+                {
+                    OperatResult.AppendText($"Web异常: {ex.Message}", Color.Red);
+                }
+                return false;
+            }
+            catch (Exception ex)
+            {
+                OperatResult.AppendText($"上传失败: {ex.Message}", Color.Red);
+                return false;
+            }
+        }
+
+
+        private string CreateFtpDirectoryIfNotExists(string ftpDirectoryPath, string username, string password)
+        {
+            try
+            {
+                FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpDirectoryPath);
+                request.Method = WebRequestMethods.Ftp.MakeDirectory;
+                request.Credentials = new NetworkCredential(username, password);
+                request.UsePassive = true;
+                request.UseBinary = true;
+                request.KeepAlive = false;
+
+                using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
+                {
+                    response.Close();
+                    return "OK,目录创建成功: " + response.StatusDescription;
+                }
+            }
+            catch (WebException ex)
+            {
+                if (ex.Response is FtpWebResponse response && response.StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable)
+                {
+                    return "OK,目录已存在: " + response.StatusDescription;
+                }
+                else
+                {
+                    return "NG,创建目录时发生错误: " + ex.Message;
+                }
+            }
+        }
     }
 }

+ 16 - 0
UAS_MES_BG/FunctionCode/Make/Make_TestCollection.Designer.cs

@@ -81,6 +81,7 @@
             this.mc_restqty_label = new System.Windows.Forms.Label();
             this.mcd_inqty_label = new System.Windows.Forms.Label();
             this.ob_checkno = new System.Windows.Forms.Label();
+            this.new_softversion = new System.Windows.Forms.TextBox();
             this.ob_sendqty = new UAS_MES_NEW.CustomControl.ValueLabel.ValueLabel();
             this.ob_batchqty = new UAS_MES_NEW.CustomControl.ValueLabel.ValueLabel();
             this.ob_nowcheckqty = new UAS_MES_NEW.CustomControl.ValueLabel.ValueLabel();
@@ -209,6 +210,7 @@
             this.columnHeader9});
             this.WaitRejectList.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.WaitRejectList.FullRowSelect = true;
+            this.WaitRejectList.HideSelection = false;
             this.WaitRejectList.Location = new System.Drawing.Point(6, 423);
             this.WaitRejectList.Margin = new System.Windows.Forms.Padding(4);
             this.WaitRejectList.Name = "WaitRejectList";
@@ -290,6 +292,7 @@
             this.columnHeader8,
             this.columnHeader10});
             this.ChoosedRejectList.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ChoosedRejectList.HideSelection = false;
             this.ChoosedRejectList.Location = new System.Drawing.Point(552, 423);
             this.ChoosedRejectList.Margin = new System.Windows.Forms.Padding(4);
             this.ChoosedRejectList.Name = "ChoosedRejectList";
@@ -627,6 +630,16 @@
             this.ob_checkno.Tag = "ob_checkno";
             this.ob_checkno.Visible = false;
             // 
+            // new_softversion
+            // 
+            this.new_softversion.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.new_softversion.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.new_softversion.Location = new System.Drawing.Point(124, 169);
+            this.new_softversion.Name = "new_softversion";
+            this.new_softversion.Size = new System.Drawing.Size(237, 31);
+            this.new_softversion.TabIndex = 243;
+            this.new_softversion.KeyDown += new System.Windows.Forms.KeyEventHandler(this.new_softversion_KeyDown);
+            // 
             // ob_sendqty
             // 
             this.ob_sendqty.AutoSize = true;
@@ -798,6 +811,7 @@
             this.ma_softversion.Name = "ma_softversion";
             this.ma_softversion.Size = new System.Drawing.Size(0, 31);
             this.ma_softversion.TabIndex = 73;
+            this.ma_softversion.Visible = false;
             // 
             // Save
             // 
@@ -1007,6 +1021,7 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.SystemColors.Control;
             this.ClientSize = new System.Drawing.Size(1291, 788);
+            this.Controls.Add(this.new_softversion);
             this.Controls.Add(this.ob_checkno);
             this.Controls.Add(this.ob_sendqty);
             this.Controls.Add(this.label12);
@@ -1168,5 +1183,6 @@
         private CustomControl.ValueLabel.ValueLabel mcd_inqty;
         private System.Windows.Forms.Label mcd_inqty_label;
         private System.Windows.Forms.Label ob_checkno;
+        private System.Windows.Forms.TextBox new_softversion;
     }
 }

+ 67 - 8
UAS_MES_BG/FunctionCode/Make/Make_TestCollection.cs

@@ -38,7 +38,7 @@ namespace UAS_MES_NEW.Make
         Boolean startcheck = false;
         int getcheck = 0;
 
-        Dictionary <string,DateTime> dateTimeDictionary = new Dictionary<string, DateTime>();
+        Dictionary<string, DateTime> dateTimeDictionary = new Dictionary<string, DateTime>();
         /// <summary>
         /// 已选的不良
         /// </summary>
@@ -53,7 +53,7 @@ namespace UAS_MES_NEW.Make
         bool LockSn = false;
 
         DataTable Dbfind;
-       
+
 
         public Make_TestCollection()
         {
@@ -87,9 +87,19 @@ namespace UAS_MES_NEW.Make
             StepCount.LineCode = User.UserLineCode;
             StepCount.Dh = dh;
             StepCount.Start();
+
+
+            if (User.CurrentStepName != "程序烧写")
+            {
+                new_softversion.Enabled = false;
+            }
+            else
+            {
+                new_softversion.Enabled = true;
+            }
         }
 
-   
+
 
         private void text_getfocus(object sender, EventArgs e)
         {
@@ -198,6 +208,15 @@ namespace UAS_MES_NEW.Make
                 ChoosedRejectList.Items.Clear();
                 WaitList.Clear();
                 ChoosedList.Clear();
+
+                if (User.CurrentStepName == "程序烧写" && string.IsNullOrEmpty(new_softversion.Text))
+                {
+                    OperateResult.AppendText(">>请输入软件版本号\n", Color.Red);
+                    new_softversion.Focus();
+                    new_softversion.SelectAll();
+                    return;
+                }
+
                 if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
                 {
                     bool NoteAlready = LogicHandler.CheckDiffMakeCodeBeforeStepCheck(ms_sncode.Text, ma_code.Text, NoteForChange.Checked, out oMakeCode, out ErrorMessage);
@@ -223,6 +242,12 @@ namespace UAS_MES_NEW.Make
                                 LockMakeCode.Checked = true;
                             }
                         }
+
+                        if (User.CurrentStepName == "程序烧写")
+                        {
+                            dh.UpdateByCondition("makeserial", $"MS_SOFTVERSION='{new_softversion.Text.Trim()}'", "ms_sncode='" + ms_sncode.Text + "'");
+                        }
+
                         dt = (DataTable)dh.ExecuteSql("select ms_nextstepcode,ms_sncode,ms_reworkstatus,nvl(ms_ifrework,0)ms_ifrework,ms_stepcode,ms_status,nvl(st_ifrepair,0) st_ifrepair from makeserial left join step on ms_stepcode=st_code where ms_id='" + oMSID + "'", "select");
                         string status = dt.Rows[0]["ms_status"].ToString();
                         reworkstatus = dt.Rows[0]["ms_reworkstatus"].ToString();
@@ -909,6 +934,12 @@ namespace UAS_MES_NEW.Make
                 BaseUtil.CleanControlsText(mcd_inqty, mcd_remainqty, ob_batchqty, ob_nowcheckqty, ob_sendqty);
                 LoadCollectedNum();
                 LoadCheckQTY();
+
+                dt = (DataTable)dh.ExecuteSql($"select ma_softversion from make where ma_code = '{ma_code.Text}'", "select");
+                if (dt.Rows.Count > 0)
+                {
+                    new_softversion.Text = dt.Rows[0]["ma_softversion"].ToString();
+                }
             }
         }
 
@@ -990,7 +1021,7 @@ namespace UAS_MES_NEW.Make
         {
             if (e.KeyCode == Keys.Enter)
             {
-                if (SMTBind.Checked&& GoodProduct.Checked)
+                if (SMTBind.Checked && GoodProduct.Checked)
                 {
                     DataTable dt = (DataTable)dh.ExecuteSql("select A.SB_BARCODE from smtbind A LEFT JOIN SMTBIND B ON A.SB_MAINCODE = B.SB_MAINCODE WHERE B.SB_BARCODE = '" + ms_sncode.Text + "'", "select");
                     if (dt.Rows.Count > 0)
@@ -1117,19 +1148,19 @@ namespace UAS_MES_NEW.Make
             if (e.ChangeType == WatcherChangeTypes.Changed || e.ChangeType == WatcherChangeTypes.Created)
             {
                 Stream stream = null;
-          
+
                 while (true)
                 {
                     try
                     {
                         using (stream = File.Open(e.FullPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                         {
-                        
+
                             if (stream != null)
                                 stream.Close();
                             break;
                         }
-                    
+
                     }
                     catch (Exception ex)
                     {
@@ -1175,12 +1206,40 @@ namespace UAS_MES_NEW.Make
                         }
                     }
                 }
-              
+
                 _Sr.Close();
 
 
 
             }
         }
+
+        private void new_softversion_KeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.KeyCode == Keys.Enter)
+            {
+                if (string.IsNullOrEmpty(ma_code.Text))
+                {
+                    OperateResult.AppendText(">>更新软件版本,工单号不能为空\n", Color.Red);
+                    return;
+                }
+                string sv = new_softversion.Text.Trim();
+                new_softversion.Text = sv.Trim();
+                if (!string.IsNullOrEmpty(sv))
+                {
+                    dh.UpdateByCondition("make", $"ma_softversion='{sv}'", "ma_code='" + ma_code.Text.Trim() + "'");
+
+                    dt = (DataTable)dh.ExecuteSql($"select * from makeserial where ms_makecode = '{ma_code.Text.Trim()}' and MS_SOFTVERSION is not null", "select");
+                    if (dt.Rows.Count > 0)
+                    {
+                        dh.UpdateByCondition("makeserial", $"MS_SOFTVERSION='{sv}'", $"ms_makecode='{ma_code.Text.Trim()}' and MS_SOFTVERSION is not null");
+                    }
+
+                    OperateResult.AppendText(">>软件版本号更新成功\n", Color.Green);
+                    ms_sncode.Focus();
+                    ms_sncode.SelectAll();
+                }
+            }
+        }
     }
 }

+ 1 - 1
UAS_MES_BG/FunctionCode/Make/Make_TestCollection.resx

@@ -262,7 +262,7 @@
         RudN65tdA8sHzg46DF645Xrr8m2v29fvrLwzMBQydHc4cnjkLvvu5L2key/vZ9yff7DpIfph4SOpR+WP
         lR7X/aj3Y+uI5ciZUdfRvidBTx6Mscae/5T+04fx/Kfkp+UTqhONk2aTp6fcp24+W/1s/Hnq8/npgp+l
         f65+ofviu18cf+mbWTUz/pL/cuHX4lfyr468Xva6e9Z/9vGb5Dfzc4Vv5d8efcd41/s+7P3EfOYH7IeK
-        j3ofuz55f3q4kLyw8Bv3hPP74uYdwgAAAAlwSFlzAAALEwAACxMBAJqcGAAACfBJREFUeF7t3dtuFFcC
+        j3ofuz55f3q4kLyw8Bv3hPP74uYdwgAAAAlwSFlzAAALEgAACxIB0t1+/AAACfBJREFUeF7t3dtuFFcC
         heFc5VWQRsrL5T0iRcrDkJAjJOADNjbdbvD5iE9tu302RIq0Z6+ynWkmS6oZrlys/+KT8FJX3f2bcmPa
         X5RSAISyI4AMdgSQwY4AMtgRQAY7AshgRwAZ7Agggx0BZLAjgAx2BJDBjgAy2BFABjsCyGBHABnsCCCD
         HQFksCOADHYEkMGOADLYEUAGOwLIYEcAGewIIIMdAWSwI4AMdgSQwY4AMtgRQAY7AshgRwAZ7Agggx0B

+ 25 - 0
UAS_MES_XZC/UAS_MES_XZC.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.14.36202.13 d17.14
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UAS_MES_XZC", "UAS_MES_XZC.csproj", "{53E3A804-52BA-4E22-BBF0-172A96938DD4}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{53E3A804-52BA-4E22-BBF0-172A96938DD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{53E3A804-52BA-4E22-BBF0-172A96938DD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{53E3A804-52BA-4E22-BBF0-172A96938DD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{53E3A804-52BA-4E22-BBF0-172A96938DD4}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {49D619CA-C8C5-4EEC-B578-52C6EEB78AD9}
+	EndGlobalSection
+EndGlobal