Forráskód Böngészése

上传SOP功能优化

callm 3 napja
szülő
commit
ffc1843afd

+ 216 - 115
UAS_MES_ZKLH/FunctionCode/Query/Query_SOP.Designer.cs

@@ -39,23 +39,34 @@ namespace UAS_MES_NEW.Query
             this.label2 = new System.Windows.Forms.Label();
             this.OperatResult = new System.Windows.Forms.RichTextBox();
             this.SendSop = new System.Windows.Forms.Button();
-            this.label3 = new System.Windows.Forms.Label();
-            this.label4 = new System.Windows.Forms.Label();
-            this.pr_detail = new System.Windows.Forms.Label();
             this.JPG = new System.Windows.Forms.RadioButton();
-            this.pr_spec = new System.Windows.Forms.RichTextBox();
             this.label5 = new System.Windows.Forms.Label();
             this.SendDGV = new System.Windows.Forms.DataGridView();
+            this.ChooseALL = new System.Windows.Forms.Button();
+            this.GetSOP = new System.Windows.Forms.Button();
+            this.ChoosePrint = new System.Windows.Forms.Button();
+            this.PrintPath = new System.Windows.Forms.TextBox();
+            this.label3 = new System.Windows.Forms.Label();
+            this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.li_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
+            this.ps_prodcode = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
             this.CheckColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.fp_name = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.fp_path = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.psd_iskey = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.issend = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.ChooseALL = new System.Windows.Forms.Button();
-            this.ps_prodcode = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
-            this.li_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
-            this.GetSOP = new System.Windows.Forms.Button();
+            this.label4 = new System.Windows.Forms.Label();
+            this.label6 = new System.Windows.Forms.Label();
+            this.label7 = new System.Windows.Forms.Label();
+            this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
+            this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
             ((System.ComponentModel.ISupportInitialize)(this.SendDGV)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
             this.SuspendLayout();
             // 
             // richTextBox1
@@ -139,38 +150,6 @@ namespace UAS_MES_NEW.Query
             this.SendSop.UseVisualStyleBackColor = true;
             this.SendSop.Click += new System.EventHandler(this.SendSop_Click);
             // 
-            // label3
-            // 
-            this.label3.AutoSize = true;
-            this.label3.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label3.Location = new System.Drawing.Point(19, 22);
-            this.label3.Name = "label3";
-            this.label3.Size = new System.Drawing.Size(146, 41);
-            this.label3.TabIndex = 14;
-            this.label3.Text = "产品名称";
-            this.label3.Visible = false;
-            // 
-            // label4
-            // 
-            this.label4.AutoSize = true;
-            this.label4.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label4.Location = new System.Drawing.Point(19, 115);
-            this.label4.Name = "label4";
-            this.label4.Size = new System.Drawing.Size(146, 41);
-            this.label4.TabIndex = 15;
-            this.label4.Text = "产品规格";
-            this.label4.Visible = false;
-            // 
-            // pr_detail
-            // 
-            this.pr_detail.AutoSize = true;
-            this.pr_detail.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.pr_detail.Location = new System.Drawing.Point(211, 22);
-            this.pr_detail.Name = "pr_detail";
-            this.pr_detail.Size = new System.Drawing.Size(0, 41);
-            this.pr_detail.TabIndex = 16;
-            this.pr_detail.Visible = false;
-            // 
             // JPG
             // 
             this.JPG.AutoSize = true;
@@ -183,17 +162,6 @@ namespace UAS_MES_NEW.Query
             this.JPG.Text = "图片";
             this.JPG.UseVisualStyleBackColor = true;
             // 
-            // pr_spec
-            // 
-            this.pr_spec.Enabled = false;
-            this.pr_spec.Location = new System.Drawing.Point(218, 123);
-            this.pr_spec.Name = "pr_spec";
-            this.pr_spec.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
-            this.pr_spec.Size = new System.Drawing.Size(580, 94);
-            this.pr_spec.TabIndex = 19;
-            this.pr_spec.Text = "";
-            this.pr_spec.Visible = false;
-            // 
             // label5
             // 
             this.label5.AutoSize = true;
@@ -223,6 +191,132 @@ namespace UAS_MES_NEW.Query
             this.SendDGV.Size = new System.Drawing.Size(1068, 759);
             this.SendDGV.TabIndex = 22;
             // 
+            // ChooseALL
+            // 
+            this.ChooseALL.Location = new System.Drawing.Point(865, 61);
+            this.ChooseALL.Name = "ChooseALL";
+            this.ChooseALL.Size = new System.Drawing.Size(80, 42);
+            this.ChooseALL.TabIndex = 23;
+            this.ChooseALL.Text = "全选";
+            this.ChooseALL.UseVisualStyleBackColor = true;
+            this.ChooseALL.Click += new System.EventHandler(this.ChooseALL_Click);
+            // 
+            // GetSOP
+            // 
+            this.GetSOP.Location = new System.Drawing.Point(638, 379);
+            this.GetSOP.Name = "GetSOP";
+            this.GetSOP.Size = new System.Drawing.Size(160, 42);
+            this.GetSOP.TabIndex = 26;
+            this.GetSOP.Text = "获取SOP";
+            this.GetSOP.UseVisualStyleBackColor = true;
+            this.GetSOP.Click += new System.EventHandler(this.GetSOP_Click);
+            // 
+            // ChoosePrint
+            // 
+            this.ChoosePrint.Location = new System.Drawing.Point(651, 779);
+            this.ChoosePrint.Name = "ChoosePrint";
+            this.ChoosePrint.Size = new System.Drawing.Size(160, 42);
+            this.ChoosePrint.TabIndex = 27;
+            this.ChoosePrint.Text = "选择电子章";
+            this.ChoosePrint.UseVisualStyleBackColor = true;
+            this.ChoosePrint.Click += new System.EventHandler(this.ChoosePrint_Click);
+            // 
+            // PrintPath
+            // 
+            this.PrintPath.Enabled = false;
+            this.PrintPath.Location = new System.Drawing.Point(218, 785);
+            this.PrintPath.Name = "PrintPath";
+            this.PrintPath.Size = new System.Drawing.Size(416, 35);
+            this.PrintPath.TabIndex = 28;
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.label3.Location = new System.Drawing.Point(12, 779);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(178, 41);
+            this.label3.TabIndex = 29;
+            this.label3.Text = "添加电子章";
+            // 
+            // dataGridViewCheckBoxColumn1
+            // 
+            this.dataGridViewCheckBoxColumn1.DataPropertyName = "CheckColumn";
+            this.dataGridViewCheckBoxColumn1.HeaderText = "勾选";
+            this.dataGridViewCheckBoxColumn1.MinimumWidth = 100;
+            this.dataGridViewCheckBoxColumn1.Name = "dataGridViewCheckBoxColumn1";
+            this.dataGridViewCheckBoxColumn1.Width = 200;
+            // 
+            // dataGridViewTextBoxColumn1
+            // 
+            this.dataGridViewTextBoxColumn1.DataPropertyName = "fp_name";
+            this.dataGridViewTextBoxColumn1.HeaderText = "文件名";
+            this.dataGridViewTextBoxColumn1.MinimumWidth = 10;
+            this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
+            this.dataGridViewTextBoxColumn1.Width = 200;
+            // 
+            // dataGridViewTextBoxColumn2
+            // 
+            this.dataGridViewTextBoxColumn2.DataPropertyName = "fp_path";
+            this.dataGridViewTextBoxColumn2.HeaderText = "路径";
+            this.dataGridViewTextBoxColumn2.MinimumWidth = 10;
+            this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
+            this.dataGridViewTextBoxColumn2.Width = 200;
+            // 
+            // dataGridViewTextBoxColumn3
+            // 
+            this.dataGridViewTextBoxColumn3.DataPropertyName = "psd_iskey";
+            this.dataGridViewTextBoxColumn3.HeaderText = "是否关键工序";
+            this.dataGridViewTextBoxColumn3.MinimumWidth = 10;
+            this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
+            this.dataGridViewTextBoxColumn3.Width = 200;
+            // 
+            // dataGridViewTextBoxColumn4
+            // 
+            this.dataGridViewTextBoxColumn4.DataPropertyName = "issend";
+            this.dataGridViewTextBoxColumn4.HeaderText = "是否成功发送";
+            this.dataGridViewTextBoxColumn4.MinimumWidth = 10;
+            this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
+            this.dataGridViewTextBoxColumn4.Visible = false;
+            this.dataGridViewTextBoxColumn4.Width = 200;
+            // 
+            // li_code
+            // 
+            this.li_code.AllPower = null;
+            this.li_code.Caller = null;
+            this.li_code.Condition = null;
+            this.li_code.DBTitle = null;
+            this.li_code.FormName = null;
+            this.li_code.Location = new System.Drawing.Point(218, 580);
+            this.li_code.Name = "li_code";
+            this.li_code.Power = null;
+            this.li_code.ReturnData = null;
+            this.li_code.SelectField = null;
+            this.li_code.SetValueField = null;
+            this.li_code.Size = new System.Drawing.Size(582, 41);
+            this.li_code.TabIndex = 25;
+            this.li_code.TableName = null;
+            this.li_code.TextBoxEnable = false;
+            // 
+            // ps_prodcode
+            // 
+            this.ps_prodcode.AllPower = null;
+            this.ps_prodcode.Caller = null;
+            this.ps_prodcode.Condition = null;
+            this.ps_prodcode.DBTitle = null;
+            this.ps_prodcode.FormName = null;
+            this.ps_prodcode.Location = new System.Drawing.Point(216, 311);
+            this.ps_prodcode.Name = "ps_prodcode";
+            this.ps_prodcode.Power = null;
+            this.ps_prodcode.ReturnData = null;
+            this.ps_prodcode.SelectField = null;
+            this.ps_prodcode.SetValueField = null;
+            this.ps_prodcode.Size = new System.Drawing.Size(582, 41);
+            this.ps_prodcode.TabIndex = 24;
+            this.ps_prodcode.TableName = null;
+            this.ps_prodcode.TextBoxEnable = false;
+            this.ps_prodcode.UserControlTextChanged += new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox.OnTextChange(this.ps_prodcode_UserControlTextChanged);
+            // 
             // CheckColumn
             // 
             this.CheckColumn.DataPropertyName = "CheckColumn";
@@ -264,79 +358,75 @@ namespace UAS_MES_NEW.Query
             this.issend.Visible = false;
             this.issend.Width = 200;
             // 
-            // ChooseALL
-            // 
-            this.ChooseALL.Location = new System.Drawing.Point(865, 61);
-            this.ChooseALL.Name = "ChooseALL";
-            this.ChooseALL.Size = new System.Drawing.Size(80, 42);
-            this.ChooseALL.TabIndex = 23;
-            this.ChooseALL.Text = "全选";
-            this.ChooseALL.UseVisualStyleBackColor = true;
-            this.ChooseALL.Click += new System.EventHandler(this.ChooseALL_Click);
-            // 
-            // ps_prodcode
-            // 
-            this.ps_prodcode.AllPower = null;
-            this.ps_prodcode.Caller = null;
-            this.ps_prodcode.Condition = null;
-            this.ps_prodcode.DBTitle = null;
-            this.ps_prodcode.FormName = null;
-            this.ps_prodcode.Location = new System.Drawing.Point(216, 311);
-            this.ps_prodcode.Name = "ps_prodcode";
-            this.ps_prodcode.Power = null;
-            this.ps_prodcode.ReturnData = null;
-            this.ps_prodcode.SelectField = null;
-            this.ps_prodcode.SetValueField = null;
-            this.ps_prodcode.Size = new System.Drawing.Size(582, 41);
-            this.ps_prodcode.TabIndex = 24;
-            this.ps_prodcode.TableName = null;
-            this.ps_prodcode.TextBoxEnable = false;
-            this.ps_prodcode.UserControlTextChanged += new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox.OnTextChange(this.ps_prodcode_UserControlTextChanged);
-            // 
-            // li_code
-            // 
-            this.li_code.AllPower = null;
-            this.li_code.Caller = null;
-            this.li_code.Condition = null;
-            this.li_code.DBTitle = null;
-            this.li_code.FormName = null;
-            this.li_code.Location = new System.Drawing.Point(218, 580);
-            this.li_code.Name = "li_code";
-            this.li_code.Power = null;
-            this.li_code.ReturnData = null;
-            this.li_code.SelectField = null;
-            this.li_code.SetValueField = null;
-            this.li_code.Size = new System.Drawing.Size(582, 41);
-            this.li_code.TabIndex = 25;
-            this.li_code.TableName = null;
-            this.li_code.TextBoxEnable = false;
-            // 
-            // GetSOP
+            // label4
             // 
-            this.GetSOP.Location = new System.Drawing.Point(638, 379);
-            this.GetSOP.Name = "GetSOP";
-            this.GetSOP.Size = new System.Drawing.Size(160, 42);
-            this.GetSOP.TabIndex = 26;
-            this.GetSOP.Text = "获取SOP";
-            this.GetSOP.UseVisualStyleBackColor = true;
-            this.GetSOP.Click += new System.EventHandler(this.GetSOP_Click);
+            this.label4.AutoSize = true;
+            this.label4.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.label4.Location = new System.Drawing.Point(12, 860);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(178, 41);
+            this.label4.TabIndex = 30;
+            this.label4.Text = "电子章坐标";
+            // 
+            // label6
+            // 
+            this.label6.AutoSize = true;
+            this.label6.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.label6.Location = new System.Drawing.Point(211, 860);
+            this.label6.Name = "label6";
+            this.label6.Size = new System.Drawing.Size(39, 41);
+            this.label6.TabIndex = 31;
+            this.label6.Text = "X";
+            // 
+            // label7
+            // 
+            this.label7.AutoSize = true;
+            this.label7.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.label7.Location = new System.Drawing.Point(405, 860);
+            this.label7.Name = "label7";
+            this.label7.Size = new System.Drawing.Size(37, 41);
+            this.label7.TabIndex = 32;
+            this.label7.Text = "Y";
+            // 
+            // numericUpDown1
+            // 
+            this.numericUpDown1.Location = new System.Drawing.Point(258, 866);
+            this.numericUpDown1.Name = "numericUpDown1";
+            this.numericUpDown1.Size = new System.Drawing.Size(120, 35);
+            this.numericUpDown1.TabIndex = 33;
+            // 
+            // numericUpDown2
+            // 
+            this.numericUpDown2.Location = new System.Drawing.Point(464, 866);
+            this.numericUpDown2.Name = "numericUpDown2";
+            this.numericUpDown2.Size = new System.Drawing.Size(120, 35);
+            this.numericUpDown2.TabIndex = 34;
+            this.numericUpDown2.Value = new decimal(new int[] {
+            18,
+            0,
+            0,
+            0});
             // 
             // Query_SOP
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1945, 1234);
+            this.Controls.Add(this.numericUpDown2);
+            this.Controls.Add(this.numericUpDown1);
+            this.Controls.Add(this.label7);
+            this.Controls.Add(this.label6);
+            this.Controls.Add(this.label4);
+            this.Controls.Add(this.label3);
+            this.Controls.Add(this.PrintPath);
+            this.Controls.Add(this.ChoosePrint);
             this.Controls.Add(this.GetSOP);
             this.Controls.Add(this.li_code);
             this.Controls.Add(this.ps_prodcode);
             this.Controls.Add(this.ChooseALL);
             this.Controls.Add(this.SendDGV);
             this.Controls.Add(this.label5);
-            this.Controls.Add(this.pr_spec);
             this.Controls.Add(this.JPG);
-            this.Controls.Add(this.pr_detail);
-            this.Controls.Add(this.label4);
-            this.Controls.Add(this.label3);
             this.Controls.Add(this.SendSop);
             this.Controls.Add(this.OperatResult);
             this.Controls.Add(this.label2);
@@ -352,7 +442,9 @@ namespace UAS_MES_NEW.Query
             this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
             this.Load += new System.EventHandler(this.Form3_Load);
             ((System.ComponentModel.ISupportInitialize)(this.SendDGV)).EndInit();
-            this.ResumeLayout(true);
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
+            this.ResumeLayout(false);
             this.PerformLayout();
 
         }
@@ -367,11 +459,7 @@ namespace UAS_MES_NEW.Query
         private System.Windows.Forms.Label label2;
         private System.Windows.Forms.RichTextBox OperatResult;
         private System.Windows.Forms.Button SendSop;
-        private System.Windows.Forms.Label label3;
-        private System.Windows.Forms.Label label4;
-        private System.Windows.Forms.Label pr_detail;
         private System.Windows.Forms.RadioButton JPG;
-        private System.Windows.Forms.RichTextBox pr_spec;
         private System.Windows.Forms.Label label5;
         private System.Windows.Forms.DataGridView SendDGV;
         private System.Windows.Forms.Button ChooseALL;
@@ -383,5 +471,18 @@ namespace UAS_MES_NEW.Query
         private System.Windows.Forms.DataGridViewTextBoxColumn fp_path;
         private System.Windows.Forms.DataGridViewTextBoxColumn psd_iskey;
         private System.Windows.Forms.DataGridViewTextBoxColumn issend;
+        private System.Windows.Forms.Button ChoosePrint;
+        private System.Windows.Forms.TextBox PrintPath;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn1;
+        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
+        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
+        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
+        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.Label label6;
+        private System.Windows.Forms.Label label7;
+        private System.Windows.Forms.NumericUpDown numericUpDown1;
+        private System.Windows.Forms.NumericUpDown numericUpDown2;
     }
 }

+ 92 - 103
UAS_MES_ZKLH/FunctionCode/Query/Query_SOP.cs

@@ -62,7 +62,6 @@ namespace UAS_MES_NEW.Query
             BaseUtil.SetFormValue(this.Controls, Dbfind);
         }
 
-
         void uploadfile()
         {
             if (FilePath.Text == "")
@@ -84,51 +83,105 @@ namespace UAS_MES_NEW.Query
                 dh.ExecuteSql("delete from ProductSOPdetail where psd_psid='" + ps_id + "'", "delete");
                 ps_prodcode.Text = dt.Rows[0]["ps_prodcode"].ToString();
             }
-
             Workbook workbook = new Workbook(FilePath.Text);
             List<Worksheet> list = new List<Worksheet>();
             List<string> filename = new List<string>();
             dh.ExecuteSql("update ProductSOP set ps_attachsop='' where ps_prodcode='" + ps_prodcode.Text + "'", "update");
             OperatResult.AppendText("一共Sheet: " + workbook.Worksheets.Count + "\n");
-            //try
-            //{
             for (int i = 0; i < workbook.Worksheets.Count; i++)
             {
                 if (workbook.Worksheets[i].Name != "物料清单")
                 {
                     OperatResult.AppendText("正在解析Sheet" + workbook.Worksheets[i].Name + "\n");
+                    string path = Application.StartupPath + @"\" + ps_prodcode.Text + @"\";
                     Worksheet she = workbook.Worksheets[i];
                     if (JPG.Checked)
                     {
-                        var myThread = new Thread(() => SaveFileToJPG(she));
-                        myThread.Start();
+                        try
+                        {
+                            if (!Directory.Exists(Application.StartupPath + @"\" + ps_prodcode.Text))
+                            {
+                                Directory.CreateDirectory(Application.StartupPath + @"\" + ps_prodcode.Text);
+                            }
+                            string sheetname = she.Name;
+
+                            // 获取工作表中的所有图片
+                            List<Picture> pictures = new List<Picture>();
+                            foreach (Aspose.Cells.Drawing.Picture picture in she.Pictures)
+                            {
+                                pictures.Add(picture);
+                            }
+
+                            // 获取使用的行数
+                            int totalRows = she.Cells.MaxDataRow + 1;
+                            int imageIndex = 1;
+
+                            // 每40行生成一张图片
+                            for (int startRow = 0; startRow < totalRows; startRow += 40)
+                            {
+                                int endRow = Math.Min(startRow + 39, totalRows - 1);
+                                // 创建图片选项
+                                ImageOrPrintOptions options = new ImageOrPrintOptions();
+                                options.ImageFormat = ImageFormat.Png;
+                                options.OnePagePerSheet = false;
+                                options.PrintingPage = PrintingPageType.IgnoreBlank;
+
+                                she.PageSetup.PrintArea = $"A{startRow + 1}:AH{endRow + 1}";
+                                she.Pictures.Add(0, 18, @"电子受控章.png");
+                                //she.Pictures.Add(0, 15, @"图片\签名.png");
+                                // 设置只渲染指定的行范围
+
+                                // 创建SheetRender对象
+                                SheetRender sr = new SheetRender(she, options);
+
+                                string imagename = $"{she.Name}_{imageIndex}.png";
+                                // 获取渲染后的图像
+                                Bitmap bitmap = sr.ToImage(0);
+                                string imagePath = "";
+                                // 如果有图片在当前行范围内,将它们添加到最终图像中
+                                if (pictures.Count > 0)
+                                {
+                                    using (Bitmap finalImage = new Bitmap(bitmap.Width, bitmap.Height))
+                                    using (Graphics g = Graphics.FromImage(finalImage))
+                                    {
+                                        // 绘制Excel内容
+                                        g.DrawImage(bitmap, 0, 0);
+
+                                        // 绘制原始Excel中的图片
+                                        int yOffset = bitmap.Height;
+                                        // 保存图像
+                                        imagePath = Path.Combine(path, $"{she.Name}_{imageIndex}.png");
+                                        finalImage.Save(imagePath, ImageFormat.Png);
+                                        Console.WriteLine($"Saved: {imagePath}");
+                                    }
+                                }
+                                else
+                                {
+                                    // 如果没有图片,直接保存渲染的图像
+                                    imagePath = Path.Combine(path, $"{she.Name}_{imageIndex}.png");
+                                    bitmap.Save(imagePath, ImageFormat.Png);
+                                    Console.WriteLine($"Saved: {imagePath}");
+                                }
+                                imageIndex++;
+                                OperatResult.AppendText("解析图片【" + imagePath + ".jpg】" + "\n");
+                                Dictionary<string, object> dic = new Dictionary<string, object>();
+                                dic.Add("em_name", "管理员");
+                                dic.Add("em_code", "ADMIN");
+                                dic.Add("caller", "ProductSOP");
+                                OperatResult.AppendText("上传文件【" + imagePath + ".jpg" + "】\n");
+                                string fp_id = UploadFilesToRemoteUrl("http://15033224.uttcare.com:8099/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + ps_prodcode.Text + @"\" + imagename, dic);
+                                string ps_id = dh.getFieldDataByCondition("ProductSOP", "ps_id", "ps_prodcode='" + ps_prodcode.Text + "'").ToString();
+                                dh.ExecuteSql("insert into ProductSOPdetail(psd_id,psd_psid,psd_attach) select ProductSOPdetail_seq.nextval,ps_id,'" + imagename + ";" + fp_id + "' from ProductSOP where ps_prodcode='" + ps_prodcode.Text + "'", "insert");
+                            }
+                        }
+                        catch (Exception ex)
+                        {
+                            OperatResult.AppendText(ex.Message + ex.StackTrace);
+                        }
                         filename.Add(she.Name + ".jpg");
                     }
                 }
             }
-            //}
-            //catch (Exception ex)
-            //{
-            //    OperatResult.AppendText(ex.Message + "\n");
-            //}
-        }
-
-        private void SaveFileToJPG(Worksheet sheet)
-        {
-            try
-            {
-                //OperatResult.AppendText("解析图片【" + sheet.Name + ".jpg】添加水印" + "\n");
-                if (!Directory.Exists(Application.StartupPath + @"\" + ps_prodcode.Text))
-                {
-                    Directory.CreateDirectory(Application.StartupPath + @"\" + ps_prodcode.Text);
-                }
-                string sheetname = sheet.Name;
-                ProcessWorksheet(sheet, Application.StartupPath + @"\" + ps_prodcode.Text + @"\");
-            }
-            catch (Exception ex)
-            {
-                OperatResult.AppendText(ex.Message + ex.StackTrace);
-            }
         }
 
         /// <summary>
@@ -259,8 +312,6 @@ namespace UAS_MES_NEW.Query
             OperatResult.ScrollToCaret();
         }
 
-
-
         private void SendSop_Click(object sender, EventArgs e)
         {
             try
@@ -375,78 +426,6 @@ namespace UAS_MES_NEW.Query
                 AllChecked = true;
             }
         }
-
-        private void ProcessWorksheet(Worksheet worksheet, string outputFolder)
-        {
-            // 获取工作表中的所有图片
-            List<Picture> pictures = new List<Picture>();
-            foreach (Aspose.Cells.Drawing.Picture picture in worksheet.Pictures)
-            {
-                pictures.Add(picture);
-            }
-
-            // 获取使用的行数
-            int totalRows = worksheet.Cells.MaxDataRow + 1;
-            int imageIndex = 1;
-
-            // 每30行生成一张图片
-            for (int startRow = 0; startRow < totalRows; startRow += 30)
-            {
-                int endRow = Math.Min(startRow + 29, totalRows - 1);
-
-                // 创建图片选项
-                ImageOrPrintOptions options = new ImageOrPrintOptions();
-                options.ImageFormat = ImageFormat.Png;
-                options.OnePagePerSheet = false;
-                options.PrintingPage = PrintingPageType.IgnoreBlank;
-
-                worksheet.PageSetup.PrintArea = $"A{startRow + 1}:AC{endRow + 1}";
-                // 设置只渲染指定的行范围
-
-                // 创建SheetRender对象
-                SheetRender sr = new SheetRender(worksheet, options);
-
-                string imagename = $"{worksheet.Name}_{imageIndex}.png";
-                // 获取渲染后的图像
-                Bitmap bitmap = sr.ToImage(0);
-                string imagePath = "";
-                // 如果有图片在当前行范围内,将它们添加到最终图像中
-                if (pictures.Count > 0)
-                {
-                    using (Bitmap finalImage = new Bitmap(bitmap.Width, bitmap.Height))
-                    using (Graphics g = Graphics.FromImage(finalImage))
-                    {
-                        // 绘制Excel内容
-                        g.DrawImage(bitmap, 0, 0);
-
-                        // 绘制原始Excel中的图片
-                        int yOffset = bitmap.Height;
-                        // 保存图像
-                        imagePath = Path.Combine(outputFolder, $"{worksheet.Name}_{imageIndex}.png");
-                        finalImage.Save(imagePath, ImageFormat.Png);
-                        Console.WriteLine($"Saved: {imagePath}");
-                    }
-                }
-                else
-                {
-                    // 如果没有图片,直接保存渲染的图像
-                    imagePath = Path.Combine(outputFolder, $"{worksheet.Name}_{imageIndex}.png");
-                    bitmap.Save(imagePath, ImageFormat.Png);
-                    Console.WriteLine($"Saved: {imagePath}");
-                }
-                imageIndex++;
-                OperatResult.AppendText("解析图片【" + imagePath + ".jpg】" + "\n");
-                Dictionary<string, object> dic = new Dictionary<string, object>();
-                dic.Add("em_name", "管理员");
-                dic.Add("em_code", "ADMIN");
-                dic.Add("caller", "ProductSOP");
-                OperatResult.AppendText("上传文件【" + imagePath + ".jpg" + "】\n");
-                string fp_id = UploadFilesToRemoteUrl("http://120.24.241.233:8099/mes/MEScommon/uploadFiles.action?_noc=1", Application.StartupPath + @"\" + ps_prodcode.Text + @"\" + imagename, dic);
-                string ps_id = dh.getFieldDataByCondition("ProductSOP", "ps_id", "ps_prodcode='" + ps_prodcode.Text + "'").ToString();
-                dh.ExecuteSql("insert into ProductSOPdetail(psd_id,psd_psid,psd_attach) select ProductSOPdetail_seq.nextval,ps_id,'" + imagename + ";" + fp_id + "' from ProductSOP where ps_prodcode='" + ps_prodcode.Text + "'", "insert");
-            }
-        }
-
         private void ps_prodcode_UserControlTextChanged(object sender, EventArgs e)
         {
             LoadPrCode();
@@ -456,5 +435,15 @@ namespace UAS_MES_NEW.Query
         {
             LoadPrCode();
         }
+
+        private void ChoosePrint_Click(object sender, EventArgs e)
+        {
+            ChoosePath.Filter = "(*.png)|*.png";
+            DialogResult result = ChoosePath.ShowDialog();
+            if (result == DialogResult.OK)
+            {
+                PrintPath.Text = ChoosePath.FileName;
+            }
+        }
     }
 }

+ 15 - 0
UAS_MES_ZKLH/FunctionCode/Query/Query_SOP.resx

@@ -135,4 +135,19 @@
   <metadata name="issend.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="CheckColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="fp_name.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="fp_path.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="psd_iskey.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="issend.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
 </root>