Browse Source

首件测试对接

yhluo 5 days ago
parent
commit
6ba3de182b

+ 223 - 0
UAS_MES_YTDZ/FunctionCode/Make/Make_FirstInspect.Designer.cs

@@ -0,0 +1,223 @@
+namespace UAS_MES_NEW.Make
+{
+    partial class Make_FirstInspect
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.label1 = new System.Windows.Forms.Label();
+            this.txtPath = new System.Windows.Forms.TextBox();
+            this.Choose = new System.Windows.Forms.Button();
+            this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
+            this.onWatch = new System.Windows.Forms.Button();
+            this.claerBtn = new System.Windows.Forms.Button();
+            this.allParse = new System.Windows.Forms.Button();
+            this.lstOk = new System.Windows.Forms.ListBox();
+            this.lstFiles = new System.Windows.Forms.ListBox();
+            this.openFileDialog2 = new System.Windows.Forms.OpenFileDialog();
+            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
+            this.generateRadio = new System.Windows.Forms.CheckBox();
+            this.panel1 = new System.Windows.Forms.Panel();
+            this.tableLayoutPanel1.SuspendLayout();
+            this.panel1.SuspendLayout();
+            this.SuspendLayout();
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label1.Location = new System.Drawing.Point(31, 43);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(123, 30);
+            this.label1.TabIndex = 4;
+            this.label1.Text = "文件夹路径";
+            // 
+            // txtPath
+            // 
+            this.txtPath.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.txtPath.Location = new System.Drawing.Point(149, 43);
+            this.txtPath.Name = "txtPath";
+            this.txtPath.Size = new System.Drawing.Size(387, 31);
+            this.txtPath.TabIndex = 3;
+            // 
+            // Choose
+            // 
+            this.Choose.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.Choose.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.Choose.Location = new System.Drawing.Point(557, 39);
+            this.Choose.Name = "Choose";
+            this.Choose.Size = new System.Drawing.Size(100, 35);
+            this.Choose.TabIndex = 4;
+            this.Choose.Text = "选择";
+            this.Choose.UseVisualStyleBackColor = true;
+            this.Choose.Click += new System.EventHandler(this.Choose_Click);
+            // 
+            // openFileDialog1
+            // 
+            this.openFileDialog1.FileName = "openFileDialog1";
+            this.openFileDialog1.RestoreDirectory = true;
+            // 
+            // onWatch
+            // 
+            this.onWatch.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.onWatch.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.onWatch.Location = new System.Drawing.Point(102, 173);
+            this.onWatch.Name = "onWatch";
+            this.onWatch.Size = new System.Drawing.Size(122, 38);
+            this.onWatch.TabIndex = 8;
+            this.onWatch.Text = "开启监控";
+            this.onWatch.UseVisualStyleBackColor = true;
+            this.onWatch.Click += new System.EventHandler(this.onWatch_Click);
+            // 
+            // claerBtn
+            // 
+            this.claerBtn.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.claerBtn.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.claerBtn.Location = new System.Drawing.Point(427, 172);
+            this.claerBtn.Name = "claerBtn";
+            this.claerBtn.Size = new System.Drawing.Size(122, 38);
+            this.claerBtn.TabIndex = 7;
+            this.claerBtn.Text = "清除";
+            this.claerBtn.UseVisualStyleBackColor = true;
+            this.claerBtn.Click += new System.EventHandler(this.claerBtn_Click);
+            // 
+            // allParse
+            // 
+            this.allParse.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.allParse.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.allParse.Location = new System.Drawing.Point(266, 173);
+            this.allParse.Name = "allParse";
+            this.allParse.Size = new System.Drawing.Size(122, 38);
+            this.allParse.TabIndex = 5;
+            this.allParse.Text = "手动解析";
+            this.allParse.UseVisualStyleBackColor = true;
+            this.allParse.Click += new System.EventHandler(this.allParse_Click);
+            // 
+            // lstOk
+            // 
+            this.lstOk.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.lstOk.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.lstOk.FormattingEnabled = true;
+            this.lstOk.ItemHeight = 24;
+            this.lstOk.Location = new System.Drawing.Point(3, 3);
+            this.lstOk.Name = "lstOk";
+            this.lstOk.Size = new System.Drawing.Size(1494, 249);
+            this.lstOk.TabIndex = 1;
+            // 
+            // lstFiles
+            // 
+            this.lstFiles.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.lstFiles.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
+            this.lstFiles.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.lstFiles.FormattingEnabled = true;
+            this.lstFiles.ItemHeight = 22;
+            this.lstFiles.Location = new System.Drawing.Point(3, 258);
+            this.lstFiles.Name = "lstFiles";
+            this.lstFiles.Size = new System.Drawing.Size(1494, 377);
+            this.lstFiles.TabIndex = 0;
+            this.lstFiles.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lstFiles_DrawItem);
+            // 
+            // openFileDialog2
+            // 
+            this.openFileDialog2.FileName = "openFileDialog2";
+            // 
+            // tableLayoutPanel1
+            // 
+            this.tableLayoutPanel1.ColumnCount = 1;
+            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
+            this.tableLayoutPanel1.Controls.Add(this.lstFiles, 0, 1);
+            this.tableLayoutPanel1.Controls.Add(this.lstOk, 0, 0);
+            this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 262);
+            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
+            this.tableLayoutPanel1.RowCount = 2;
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F));
+            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 60F));
+            this.tableLayoutPanel1.Size = new System.Drawing.Size(1500, 638);
+            this.tableLayoutPanel1.TabIndex = 8;
+            // 
+            // generateRadio
+            // 
+            this.generateRadio.AutoSize = true;
+            this.generateRadio.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.generateRadio.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.generateRadio.Location = new System.Drawing.Point(161, 97);
+            this.generateRadio.Name = "generateRadio";
+            this.generateRadio.Size = new System.Drawing.Size(227, 32);
+            this.generateRadio.TabIndex = 11;
+            this.generateRadio.Text = "是否生成首件任务单";
+            this.generateRadio.UseVisualStyleBackColor = true;
+            // 
+            // panel1
+            // 
+            this.panel1.Controls.Add(this.txtPath);
+            this.panel1.Controls.Add(this.generateRadio);
+            this.panel1.Controls.Add(this.Choose);
+            this.panel1.Controls.Add(this.allParse);
+            this.panel1.Controls.Add(this.onWatch);
+            this.panel1.Controls.Add(this.label1);
+            this.panel1.Controls.Add(this.claerBtn);
+            this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
+            this.panel1.Location = new System.Drawing.Point(0, 0);
+            this.panel1.Name = "panel1";
+            this.panel1.Size = new System.Drawing.Size(1500, 262);
+            this.panel1.TabIndex = 12;
+            // 
+            // Make_FirstInspect
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.BackColor = System.Drawing.SystemColors.Control;
+            this.ClientSize = new System.Drawing.Size(1500, 900);
+            this.Controls.Add(this.tableLayoutPanel1);
+            this.Controls.Add(this.panel1);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.Name = "Make_FirstInspect";
+            this.Text = "Make_ParseLog";
+            this.Load += new System.EventHandler(this.Make_ParseLog_Load);
+            this.tableLayoutPanel1.ResumeLayout(false);
+            this.panel1.ResumeLayout(false);
+            this.panel1.PerformLayout();
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.TextBox txtPath;
+        private System.Windows.Forms.Button Choose;
+        private System.Windows.Forms.OpenFileDialog openFileDialog1;
+        private System.Windows.Forms.Button allParse;
+        private System.Windows.Forms.OpenFileDialog openFileDialog2;
+        private System.Windows.Forms.ListBox lstFiles;
+        private System.Windows.Forms.Button claerBtn;
+        private System.Windows.Forms.Button onWatch;
+        private System.Windows.Forms.ListBox lstOk;
+        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
+        private System.Windows.Forms.CheckBox generateRadio;
+        private System.Windows.Forms.Panel panel1;
+    }
+}

+ 609 - 0
UAS_MES_YTDZ/FunctionCode/Make/Make_FirstInspect.cs

@@ -0,0 +1,609 @@
+using DevExpress.Utils.OAuth;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Sockets;
+using System.Security.Policy;
+using System.ServiceModel;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using UAS_MES_NEW.DataOperate;
+using UAS_MES_NEW.Entity;
+using UAS_MES_NEW.PublicMethod;
+
+namespace UAS_MES_NEW.Make
+{
+    public partial class Make_FirstInspect : Form
+    {
+        public Make_FirstInspect()
+        {
+            InitializeComponent();
+        }
+
+        DataHelper dh;
+        DataTable dt;
+
+        FileSystemWatcher watcher;
+        string currFileType , equiType ;
+
+        List<string> fileList = new List<string>();
+
+        string workOrder,line,sideType,sn;
+
+        private void Make_ParseLog_Load(object sender, EventArgs e)
+        {
+            dh = SystemInf.dh;
+
+            fileList.Add("E:\\4_奥维精密\\首件检测仪");
+            txtPath.Text = fileList[0];
+
+            currFileType = "txt";
+            equiType = "首件测试仪";
+
+            watcher = new FileSystemWatcher();
+            watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
+            watcher.Created += OnFileCreated;
+            /*watcher.Changed += OnFileChanged;
+            watcher.Deleted += OnFileChanged;
+            watcher.Renamed += OnFileChanged;*/
+
+        }
+
+
+        private void Choose_Click(object sender, EventArgs e)
+        {
+            using (var dialog = new FolderBrowserDialog())
+            {
+                if (dialog.ShowDialog() == DialogResult.OK)
+                {
+                    txtPath.Text = dialog.SelectedPath;
+                    txtPath.Enabled = false;
+                    watcher.EnableRaisingEvents = false;
+                }
+            }
+        }
+
+        private void claerBtn_Click(object sender, EventArgs e)
+        {
+            lstFiles.Items.Clear();
+        }
+
+        private async void allParse_Click(object sender, EventArgs e)
+        {
+            if (String.IsNullOrEmpty(txtPath.Text))
+            {
+                txtPath.Focus();
+                txtPath.SelectAll();
+                MessageBox.Show(this.ParentForm, "请选择解析路径", "提示");
+                return;
+            }
+
+            string[] txtFiles = Directory.GetFiles(txtPath.Text, $"*.{currFileType}");
+            if (txtFiles.Length == 0)
+            {
+                LogMessage(0, $"当前{txtPath.Text},没有{equiType}设备输出的{currFileType.ToLower()}文件");
+                return;
+            }
+
+            txtPath.Enabled = false;
+            Choose.Enabled = false;
+            generateRadio.Enabled = false;
+
+            try
+            {
+                await Task.Run(() => RefreshFileList());
+            }
+            catch (Exception ex)
+            {
+                LogMessage(0, $"处理失败: {ex.Message}");
+            }
+            finally
+            {
+                txtPath.Enabled = true;
+                Choose.Enabled = true;
+                generateRadio.Enabled = true;
+            }
+        }
+
+        private void onWatch_Click(object sender, EventArgs e)
+        {
+            if (String.IsNullOrEmpty(txtPath.Text))
+            {
+                txtPath.Focus();
+                txtPath.SelectAll();
+                MessageBox.Show(this.ParentForm, "请选择监控路径", "提示");
+                return;
+            }
+            try
+            {
+                watcher.Path = txtPath.Text;
+                watcher.Filter = $"*.{currFileType}";
+                if (onWatch.Text == "开启监控")
+                {
+                    onWatch.Text = "关闭监控";
+                    txtPath.Enabled = false;
+                    Choose.Enabled = false;
+                    generateRadio.Enabled = false;
+                    watcher.EnableRaisingEvents = true;
+                }
+                else
+                {
+                    onWatch.Text = "开启监控";
+                    txtPath.Enabled = true;
+                    Choose.Enabled = true;
+                    generateRadio.Enabled = true;
+                    watcher.EnableRaisingEvents = false;
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(this.ParentForm, ex.Message, "警告");
+            }
+        }
+
+        private async void OnFileCreated(object sender, FileSystemEventArgs e)
+        {
+            try
+            {
+                await Task.Delay(500);
+                await Task.Run(() => RefreshFileList());
+            }
+            catch (Exception ex)
+            {
+                LogMessage(0, $"监控文件处理失败: {ex.Message}");
+            }
+        }
+
+        private async void OnFileChanged(object sender, FileSystemEventArgs e)
+        {
+            if (e.ChangeType == WatcherChangeTypes.Changed)
+            {
+                try
+                {
+                    await Task.Delay(500);
+                    await Task.Run(() => RefreshFileList());
+                }
+                catch (Exception ex)
+                {
+                    LogMessage(0, $"监控文件变更处理失败: {ex.Message}");
+                }
+            }
+        }
+
+        private async Task RefreshFileList()
+        {
+            if (lstFiles.InvokeRequired)
+            {
+                await Task.Run(() =>
+                {
+                    lstFiles.Invoke(new Action(async () => await RefreshFileList()));
+                });
+                return;
+            }
+
+            try
+            {
+                if (!Directory.Exists(txtPath.Text))
+                {
+                    LogMessage(0, $"NG,目录不存在: {txtPath.Text}");
+                    return;
+                }
+
+                string[] txtFiles = Directory.GetFiles(txtPath.Text, $"*.{currFileType}");
+                if (txtFiles.Length == 0)
+                {
+                    return;
+                }
+
+                List<string> itemFileList = new List<string>();
+                foreach (string file in txtFiles)
+                {
+                    itemFileList.Clear();
+                    itemFileList.Add(file);
+
+                    byte[] bytes = File.ReadAllBytes(file);
+
+                    Encoding encoding = Encoding.GetEncoding("GB2312");
+                    string[] lines = File.ReadAllLines(file, encoding);
+                    foreach (string rowLine in lines)
+                    {
+                        if (rowLine.Contains("工单号"))
+                        {
+                            workOrder = rowLine.Replace("工单号:", "");
+                        }
+                        if (rowLine.Contains("生产线"))
+                        {
+                            line = rowLine.Replace("生产线:", "")  ;
+                        }
+                        if (rowLine.Contains("样品条码"))
+                        {
+                            sn = rowLine.Replace("样品条码:", "");
+                        }
+
+                        if (rowLine.Contains("板面"))
+                        {
+                            sideType = rowLine.Replace("板面:", "");
+                        }
+                    }
+
+                    string pdFile = Regex.Replace(file, ".{7}$", $"{sideType}.pdf");
+                    itemFileList.Add(pdFile);
+                }
+
+                await InsertDb(itemFileList);
+            }
+            catch (Exception ex)
+            {
+                LogMessage(0, $"Error: 解析文件列表失败: {ex.Message}");
+            }
+        }
+
+
+        private async Task InsertDb(List<string> itemFileList)
+        {
+            try
+            {
+                var checkTasks = itemFileList.Select(async filePath =>
+                {
+                    if (!File.Exists(filePath))
+                    {
+                        return $"NG,{Path.GetFileName(filePath)}日志文件不存在: {filePath}";
+                    }
+
+                    var content = File.ReadAllText(filePath);
+                    if (content.Length == 0)
+                    {
+                        return $"NG,日志文件中内容为空: {filePath}";
+                    }
+
+                    string outFileMsg = CheckFileAccess(filePath);
+                    if (outFileMsg != "OK")
+                    {
+                        return outFileMsg + ",请稍后再试";
+                    }
+
+                    return "OK";
+                });
+
+                var checkRes = await Task.WhenAll(checkTasks);
+                foreach (var checkItem in checkRes)
+                {
+                    if (checkItem != "OK")
+                    {
+                        LogMessage(0, checkItem);
+                        return;
+                    }
+                }
+
+                string isCheck = dh.getFieldDataByCondition("make", "nvl(ma_firstitemcheck, 0)", $"ma_code = '{workOrder}'").ToString();
+                string sr_code = dh.getFieldDataByCondition("spotcheckrecord", "sr_code",$"sr_type = '首件检验' AND sr_linecode = '{line}' AND sr_makecode = '{workOrder}'").ToString();
+
+                if (string.IsNullOrEmpty(sr_code))
+                {
+                    if (generateRadio.Checked && isCheck == "-1")
+                    {
+                        string v_macraftcode = dh.getFieldDataByCondition("make", "ma_craftcode", $"ma_code = '{workOrder}'").ToString();
+                        string v_maprodcode = dh.getFieldDataByCondition("make", "ma_prodcode", $"ma_code = '{workOrder}'").ToString();
+                        string em_name = dh.getFieldDataByCondition("craft,make", "cr_qcemp", $"ma_code = '{workOrder}' and cr_prodcode = ma_prodcode and ma_craftcode = cr_code").ToString();
+
+                        dh.ExecuteSql($@"INSERT INTO spotcheckrecord( sr_id, sr_code, sr_linecode, sr_craftcode, sr_indate, 
+                            sr_inman, sr_status, sr_statuscode, sr_makecode, sr_prodcode, sr_source, 
+                            sr_contractcode, sr_exportplace, sr_type) 
+                            VALUES ( spotcheckrecord_seq.NEXTVAL, 'C' || '{workOrder}', '{line}', '{v_macraftcode}', sysdate, 
+                            '{em_name}', '在录入', 'ENTERING', '{workOrder}', '{v_maprodcode}', '工单' || '{workOrder}' || 'SN投入系统自动生成', 
+                            '', '{sn}', '首件检验' )", "insert");
+                    }
+                    else
+                    {
+                        if (isCheck == "-1")
+                        {
+                            LogMessage(1, $"报告{itemFileList[1].Replace(txtPath.Text, "")},工单{workOrder}需检查首件,请检查是否需要生成首件任务单");
+                            return;
+                        }
+                        else
+                        {
+                            LogMessage(1, $"报告{itemFileList[1].Replace(txtPath.Text, "")},工单{workOrder}无需检查首件,请核对工单是否检查首件");
+                            return;
+                        }
+                    }
+                }
+                string sr_id = dh.getFieldDataByCondition("spotcheckrecord", "sr_id", $"sr_makecode = '{workOrder}' and sr_linecode = '{line}' and sr_type='首件检验'").ToString();
+
+                string cookie = "JSESSIONID=9A2D8BD2156087D2BB96CC2F6B6230D7; ";
+
+                string uploadFileApi = "http://192.168.41.232:8098/mes//common/uploadFiles.action";
+                var uploadFileParams = new Dictionary<string, string>
+                {
+                    { "em_code", $"{User.UserCode}" },
+                    { "caller", "checkFirst" }
+                };
+                string uploadFileRes = await HttpHelper.PostMultipartWithFileAsync(uploadFileApi, uploadFileParams, itemFileList[1], cookie);
+                //LogMessage(1, $"{uploadFileRes}");
+
+                JObject root = JObject.Parse(uploadFileRes);
+                if (root["success"]?.ToString() == "True")
+                {
+                    LogMessage(1, $"文件上传成功{itemFileList[1].Replace(txtPath.Text, "")}");
+
+                    JArray dataArr = (JArray)root["data"];
+                    foreach (JToken item in dataArr)
+                    {
+                        dh.ExecuteSql($@"UPDATE spotcheckrecord SET sr_prodtype = '{item["filepath"].ToString()};' WHERE sr_id = '{sr_id}'", "update");
+                        LogMessage(1, $"首件检验单:C{workOrder.ToUpper()} ,附件上传成功");
+                    }
+
+
+                    #region
+                    /*JArray dataArr = (JArray)root["data"];
+                    string updateApi = "http://192.168.41.232:8098/mes/common/attach/update.action";
+
+                    foreach (JToken item in dataArr)
+                    {
+                        var Params = new Dictionary<string, string>
+                        {
+                            { "caller", "checkFirst" },
+                            { "table", "SPOTCHECKRECORD" },
+                            { "update", $"sr_prodtype='{item["filepath"].ToString()};'" },
+                            { "condition", $"sr_id='{sr_id}'" },
+                            { "type", "添加附件" }
+                        };
+                        string updateRes = await HttpHelper.PostMultipartAsync(uploadFileApi, Params, cookie);
+                        LogMessage(1, $"{updateRes}");
+
+                        JObject root1 = JObject.Parse(updateRes);
+                        if (root["success"]?.ToString() == "True")
+                        {
+                            LogMessage(1, $"首件检验单:C{workOrder.ToUpper()} ,附件上传成功");
+                        }
+                    }*/
+                    #endregion
+                }
+
+            }
+            catch (Exception ex)
+            {
+                LogMessage(0, $"Error,处理解析异常: {ex.Message}");
+            }
+        }
+
+        public class HttpHelper
+        {
+            public static async Task<string> PostMultipartAsync(string url, Dictionary<string, string> parameters, string cookie = null)
+            {
+                try
+                {
+                    var handler = new HttpClientHandler();
+                    handler.UseCookies = true;
+                    handler.CookieContainer = new CookieContainer();
+
+                    if (!string.IsNullOrEmpty(cookie) && cookie.Contains("JSESSIONID="))
+                    {
+                        int start = cookie.IndexOf("JSESSIONID=") + 11;
+                        int end = cookie.IndexOf(";", start);
+                        if (end == -1) end = cookie.Length;
+                        string jsessionId = cookie.Substring(start, end - start).Trim();
+
+                        handler.CookieContainer.Add(new Uri(url), new Cookie("JSESSIONID", jsessionId));
+                    }
+
+                    using (var httpClient = new HttpClient(handler))
+                    {
+                        httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "PostmanRuntime/7.29.0");
+                        httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "*/*");
+                        httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Encoding", "gzip, deflate, br");
+                        httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Cache-Control", "no-cache");
+                        httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Connection", "keep-alive");
+
+                        string boundary = "----WebKitFormBoundary7MA4YWxkTrZu0gW";
+                        using (var memoryStream = new MemoryStream())
+                        {
+                            var writer = new StreamWriter(memoryStream, System.Text.Encoding.UTF8);
+
+                            foreach (var param in parameters)
+                            {
+                                await writer.WriteAsync($"--{boundary}\r\n");
+                                await writer.WriteAsync($"Content-Disposition: form-data; name=\"{param.Key}\"\r\n\r\n");
+                                await writer.WriteAsync($"{param.Value}\r\n");
+                            }
+
+                            await writer.WriteAsync($"--{boundary}--\r\n");
+                            await writer.FlushAsync();
+
+                            var content = new ByteArrayContent(memoryStream.ToArray());
+                            content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("multipart/form-data");
+                            content.Headers.ContentType.Parameters.Add(new System.Net.Http.Headers.NameValueHeaderValue("boundary", boundary));
+
+                            var response = await httpClient.PostAsync(url, content);
+                            string responseBody = await response.Content.ReadAsStringAsync();
+
+                            return responseBody;
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw new Exception($"HTTP请求失败: {ex.Message}");
+                }
+            }
+
+            public static async Task<string> PostMultipartWithFileAsync(string url, Dictionary<string, string> parameters, string filePath, string cookie = null)
+            {
+                try
+                {
+                    var handler = new HttpClientHandler();
+                    handler.UseCookies = true;
+                    handler.CookieContainer = new CookieContainer();
+
+                    if (!string.IsNullOrEmpty(cookie) && cookie.Contains("JSESSIONID="))
+                    {
+                        int start = cookie.IndexOf("JSESSIONID=") + 11;
+                        int end = cookie.IndexOf(";", start);
+                        if (end == -1) end = cookie.Length;
+                        string jsessionId = cookie.Substring(start, end - start).Trim();
+
+                        handler.CookieContainer.Add(new Uri(url), new Cookie("JSESSIONID", jsessionId));
+                    }
+
+                    using (var httpClient = new HttpClient(handler))
+                    {
+                        httpClient.DefaultRequestHeaders.ConnectionClose = true;
+
+                        httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "PostmanRuntime/7.29.0");
+                        httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "*/*");
+                        httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Encoding", "gzip, deflate, br");
+                        httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Cache-Control", "no-cache");
+
+                        string boundary = "----WebKitFormBoundary7MA4YWxkTrZu0gW";
+                        string fileName = Path.GetFileName(filePath);
+                        byte[] fileBytes = File.ReadAllBytes(filePath);
+
+                        using (var memoryStream = new MemoryStream())
+                        {
+                            var writer = new StreamWriter(memoryStream, System.Text.Encoding.UTF8);
+
+                            await writer.WriteAsync($"--{boundary}\r\n");
+                            await writer.WriteAsync($"Content-Disposition: form-data; name=\"em_code\"\r\n\r\n");
+                            await writer.WriteAsync($"{parameters["em_code"]}\r\n");
+
+                            await writer.WriteAsync($"--{boundary}\r\n");
+                            await writer.WriteAsync($"Content-Disposition: form-data; name=\"caller\"\r\n\r\n");
+                            await writer.WriteAsync($"{parameters["caller"]}\r\n");
+
+                            await writer.WriteAsync($"--{boundary}\r\n");
+                            await writer.WriteAsync($"Content-Disposition: form-data; name=\"file\"; filename=\"{fileName}\"\r\n");
+                            await writer.WriteAsync($"Content-Type: application/octet-stream\r\n\r\n");
+
+                            await writer.FlushAsync();
+                            await memoryStream.WriteAsync(fileBytes, 0, fileBytes.Length);
+                            await memoryStream.FlushAsync();
+
+                            writer.WriteLine();
+                            await writer.WriteAsync($"--{boundary}--\r\n");
+                            await writer.FlushAsync();
+
+                            var content = new ByteArrayContent(memoryStream.ToArray());
+                            content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("multipart/form-data");
+                            content.Headers.ContentType.Parameters.Add(new System.Net.Http.Headers.NameValueHeaderValue("boundary", boundary));
+
+                            var response = await httpClient.PostAsync(url, content);
+                            string responseBody = await response.Content.ReadAsStringAsync();
+                            return responseBody;
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    throw new Exception($"HTTP请求失败: {ex.Message}");
+                }
+            }
+        }
+
+        public string CheckFileAccess(string filePath)
+        {
+            try
+            {
+                using (FileStream fileStream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.None))
+                {
+                    return "OK";
+                }
+            }
+            catch (IOException ex)
+            {
+                return "NG,文件被占用: " + ex.Message;
+            }
+            catch (UnauthorizedAccessException ex)
+            {
+                return "NG,权限不足,无法访问文件: " + ex.Message;
+            }
+            catch (Exception ex)
+            {
+                return "NG," + ex.Message;
+            }
+        }
+
+        private bool ConsoleLog(string Content, string PathName,string SN)
+        {
+            try
+            {
+                string sourcePaht = Path.GetDirectoryName(PathName);
+                string changeName = Path.Combine(sourcePaht, $"{SN}.{currFileType}");
+
+                string newFolderName = "Logs";
+                string newFolderPath = Path.Combine(sourcePaht, newFolderName);
+
+                if (!Directory.Exists(newFolderPath))
+                {
+                    Directory.CreateDirectory(newFolderPath);
+                }
+
+                string newFileName = "Log_" + Path.GetFileName(changeName);
+                string newFilePath = Path.Combine(newFolderPath, newFileName);
+
+                File.AppendAllText(newFilePath, Content + Environment.NewLine);
+                return true;
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(this.ParentForm, ex.Message, "警告");
+                return false;
+            }
+        }
+
+        private void LogMessage(int type, string message)
+        {
+            if (type == 0)
+            {
+                if (lstFiles.InvokeRequired)
+                {
+                    lstFiles.Invoke(new Action<int, string>(LogMessage), new object[] { type, message });
+                    return;
+                }
+                lstFiles.Items.Add($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {message}");
+                lstFiles.TopIndex = lstFiles.Items.Count - 1;
+            }
+            else
+            {
+                if (lstOk.InvokeRequired)
+                {
+                    lstOk.Invoke(new Action<int, string>(LogMessage), new object[] { type, message });
+                    return;
+                }
+                lstOk.Items.Add($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {message}");
+                lstOk.TopIndex = lstOk.Items.Count - 1;
+            }
+        }
+
+        private void lstFiles_DrawItem(object sender, DrawItemEventArgs e)
+        {
+            if (e.Index < 0) return;
+
+            e.DrawBackground();
+            string txt = lstFiles.Items[e.Index].ToString().ToUpper();
+            Brush color = Brushes.Black;
+            if (txt.Contains("NG"))
+            {
+                color = Brushes.Red;
+            }
+            else if (txt.Contains("ERROR"))
+            {
+                color = Brushes.Red;
+            }
+            else
+            {
+                color = Brushes.Green;
+            }
+            e.DrawFocusRectangle();
+            e.Graphics.DrawString(lstFiles.Items[e.Index].ToString(), e.Font, color, e.Bounds, StringFormat.GenericDefault);
+        }
+    }
+}

+ 129 - 0
UAS_MES_YTDZ/FunctionCode/Make/Make_FirstInspect.resx

@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
+  <metadata name="openFileDialog2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>224, 17</value>
+  </metadata>
+  <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>173</value>
+  </metadata>
+</root>

+ 9 - 0
UAS_MES_YTDZ/UAS_MES_YTDZ.csproj

@@ -579,6 +579,12 @@
     <Compile Include="FunctionCode\Make\Make_NewPo.Designer.cs">
       <DependentUpon>Make_NewPo.cs</DependentUpon>
     </Compile>
+    <Compile Include="FunctionCode\Make\Make_FirstInspect.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="FunctionCode\Make\Make_FirstInspect.Designer.cs">
+      <DependentUpon>Make_FirstInspect.cs</DependentUpon>
+    </Compile>
     <Compile Include="FunctionCode\Make\Make_ParseLog.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -1369,6 +1375,9 @@
     <EmbeddedResource Include="FunctionCode\Make\Make_NewPo.resx">
       <DependentUpon>Make_NewPo.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="FunctionCode\Make\Make_FirstInspect.resx">
+      <DependentUpon>Make_FirstInspect.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="FunctionCode\Make\Make_ParseLog.resx">
       <DependentUpon>Make_ParseLog.cs</DependentUpon>
     </EmbeddedResource>