diff --git a/LibDataBase/LibDataBase.csproj b/LibDataBase/LibDataBase.csproj
index 48f6df9..8392d0c 100644
--- a/LibDataBase/LibDataBase.csproj
+++ b/LibDataBase/LibDataBase.csproj
@@ -60,6 +60,7 @@
+
diff --git a/LibDataBase/OrderConfig.cs b/LibDataBase/OrderConfig.cs
new file mode 100644
index 0000000..8ecb9f6
--- /dev/null
+++ b/LibDataBase/OrderConfig.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace LibDataBase
+{
+ public class OrderConfig
+ {
+ public string QSV;
+ public int NumberOfLanes;
+ public Dictionary> OCRRequest = new Dictionary>();
+ public Dictionary OCRDesign = new Dictionary();
+ public string ProductStandard;
+ public double Width;
+ public double Height;
+ public double Gradient;
+ public bool ParseQSV;
+ public bool ParseProduct;
+ public bool ParseArrange;
+ public double DistX;
+ public double DistY;
+ public int ColorMax;
+ public string ColorArray;
+ }
+}
diff --git a/LibReadTetraExcel/Class1.cs b/LibReadTetraExcel/Class1.cs
deleted file mode 100644
index 7fd4aca..0000000
--- a/LibReadTetraExcel/Class1.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace LibReadTetraExcel
-{
- public class Class1
- {
- }
-}
diff --git a/LibReadTetraExcel/ExcelHelper.cs b/LibReadTetraExcel/ExcelHelper.cs
new file mode 100644
index 0000000..3c200b8
--- /dev/null
+++ b/LibReadTetraExcel/ExcelHelper.cs
@@ -0,0 +1,126 @@
+using LibDataBase;
+using OfficeOpenXml;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+namespace LibReadTetraExcel
+{
+ public class ExcelHelper
+ {
+ public static OrderConfig ReadOCROrder(string execlFileName, string order)
+ {
+ OrderConfig config = new OrderConfig();
+ try
+ {
+ ExcelPackage.License.SetNonCommercialOrganization("My Noncommercial organization");
+ using (ExcelPackage package = new ExcelPackage(execlFileName))
+ {
+ ExcelWorksheet sheet1 = package.Workbook.Worksheets["P2生成数据"];
+ config.ParseQSV = false;
+ config.ParseProduct = false;
+ config.ParseArrange = false;
+ config.QSV = "";
+ config.NumberOfLanes = 0;
+ for (int i = 1; i < sheet1.Dimension.Rows; i++)
+ {
+ if (sheet1.GetValue(i, 3) == null)
+ continue;
+ if (sheet1.Cells[i, 3].Value.ToString() != order)
+ continue;
+ config.QSV = sheet1.Cells[i, 4].Value.ToString();
+ config.NumberOfLanes = Convert.ToInt32(sheet1.Cells[i, 5].Value.ToString());
+ int num = 0;
+ for (int k = 0; k < 10; k++)
+ {
+ string lanes = sheet1.Cells[i + k, 6].Value.ToString();
+ string design = sheet1.Cells[i + k, 7].Value.ToString().Split('-')[1];
+ string[] tmp = lanes.Substring(1, lanes.Length - 2).Split(',');
+ num += tmp.Length;
+ List textOCR = ExecelGetOcrText(design, sheet1.Cells[i + k, 8].Value.ToString());
+ foreach (string lan in tmp)
+ {
+ int lanInt = Convert.ToInt32(lan);
+ config.OCRRequest[lanInt] = textOCR;
+ config.OCRDesign[lanInt] = design;
+ }
+
+ if (num >= config.NumberOfLanes)
+ {
+ config.ParseQSV = true;
+ break;
+ }
+ }
+ break;
+ }
+ if (!config.ParseQSV)
+ return config;
+
+ config.ProductStandard = "";
+ ExcelWorksheet sheet2 = package.Workbook.Worksheets["QSV对应产品规格和梯度"];
+ for (int j = 1; j <= sheet2.Dimension.Rows; j++)
+ {
+ if (sheet2.GetValue(j, 1) == null)
+ continue;
+ if (sheet2.Cells[j, 1].Value.ToString() != config.QSV)
+ continue;
+ config.ProductStandard = sheet2.Cells[j, 2].Value.ToString();
+ config.Width = Convert.ToDouble(sheet2.Cells[j, 3].Value.ToString());
+ config.Height = Convert.ToDouble(sheet2.Cells[j, 4].Value.ToString());
+ config.Gradient = Convert.ToDouble(sheet2.Cells[j, 5].Value.ToString());
+ config.ParseProduct = true;
+ break;
+ }
+ if (!config.ParseProduct)
+ return config;
+
+ ExcelWorksheet sheet3 = package.Workbook.Worksheets["产品规格对应排布方式"];
+ for (int n = 1; n < sheet3.Dimension.Rows; n++)
+ {
+ if (sheet3.GetValue(n, 1) == null)
+ continue;
+ if (sheet3.Cells[n, 1].Value.ToString() != config.ProductStandard)
+ continue;
+ string str = sheet3.Cells[n + config.OCRRequest[1].Count - 1, 4].Value.ToString();
+ string[] x_y = str.Split(',');
+ string[] X = x_y[0].Split(':');
+ string[] Y = x_y[1].Split(':');
+ config.DistX = Convert.ToDouble(X[1].Replace("mm", ""));
+ config.DistY = Convert.ToDouble(Y[1].Replace("mm", ""));
+
+ string alignColor = sheet3.Cells[n + config.OCRRequest[1].Count - 1, 3].Value.ToString();
+ if (alignColor.Contains("单排"))
+ config.ColorMax = config.OCRRequest.Values.Select(x => x.Count).Max();
+ else
+ config.ColorMax = alignColor.Replace("排布", "").Split(',').ToList().Select(int.Parse).Max();
+ config.ColorArray = alignColor;
+ config.ParseArrange = true;
+ break;
+ }
+ }
+ }
+ catch (Exception)
+ {
+
+ }
+ return config;
+ }
+ private static List ExecelGetOcrText(string design, string layer)
+ {
+ List result = new List();
+ string[] ll = layer.Replace("[", "").Replace("]", "").Split(',');
+ for (int i = 0; i < ll.Length; i++)
+ {
+ ll[i] = ll[i].Replace(" ", "");
+ string[] str = ll[i].Split('-');
+ if (str.Length < 2)
+ continue;
+ result.Add(design + str[1] + str[0]);
+ }
+ return result;
+ }
+ }
+}
diff --git a/LibReadTetraExcel/LibReadTetraExcel.csproj b/LibReadTetraExcel/LibReadTetraExcel.csproj
index 9c8f5e5..fc49353 100644
--- a/LibReadTetraExcel/LibReadTetraExcel.csproj
+++ b/LibReadTetraExcel/LibReadTetraExcel.csproj
@@ -1,6 +1,5 @@
-
Debug
@@ -52,20 +51,11 @@
prompt
-
- ..\packages\BouncyCastle.Cryptography.2.7.0-beta.98\lib\net461\BouncyCastle.Cryptography.dll
+
+ ..\packages\EPPlus.8.4.0\lib\net462\EPPlus.dll
-
- ..\packages\Enums.NET.5.0.0\lib\net461\Enums.NET.dll
-
-
- ..\packages\ExtendedNumerics.BigDecimal.3003.0.0.346\lib\net472\ExtendedNumerics.BigDecimal.dll
-
-
- ..\packages\SharpZipLib.1.4.2\lib\netstandard2.0\ICSharpCode.SharpZipLib.dll
-
-
- ..\packages\MathNet.Numerics.Signed.5.0.0\lib\net461\MathNet.Numerics.dll
+
+ ..\packages\EPPlus.Interfaces.8.4.0\lib\net462\EPPlus.Interfaces.dll
..\packages\Microsoft.Bcl.Cryptography.10.0.1\lib\net462\Microsoft.Bcl.Cryptography.dll
@@ -73,28 +63,14 @@
..\packages\Microsoft.IO.RecyclableMemoryStream.3.0.1\lib\netstandard2.0\Microsoft.IO.RecyclableMemoryStream.dll
-
- ..\packages\NPOI.2.7.5\lib\net472\NPOI.Core.dll
-
-
- ..\packages\NPOI.2.7.5\lib\net472\NPOI.OOXML.dll
-
-
- ..\packages\NPOI.2.7.5\lib\net472\NPOI.OpenXml4Net.dll
-
-
- ..\packages\NPOI.2.7.5\lib\net472\NPOI.OpenXmlFormats.dll
-
-
- ..\packages\NSax.1.0.2\lib\net472\NSax.dll
-
-
- ..\packages\SixLabors.Fonts.1.0.1\lib\netstandard2.0\SixLabors.Fonts.dll
-
+
..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll
+
+ ..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll
+
@@ -115,24 +91,15 @@
..\packages\System.Security.Cryptography.Xml.10.0.1\lib\net462\System.Security.Cryptography.Xml.dll
-
- ..\packages\System.Text.Encoding.CodePages.10.0.1\lib\net462\System.Text.Encoding.CodePages.dll
-
-
- ..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll
-
-
- ..\packages\ZString.2.6.0\lib\netstandard2.0\ZString.dll
-
-
+
@@ -146,12 +113,11 @@
+
这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
-
-
\ No newline at end of file
diff --git a/LibReadTetraExcel/packages.config b/LibReadTetraExcel/packages.config
index bd1fbc5..1167687 100644
--- a/LibReadTetraExcel/packages.config
+++ b/LibReadTetraExcel/packages.config
@@ -1,24 +1,15 @@
-
-
-
-
+
+
-
-
-
-
-
+
-
-
-
\ No newline at end of file
diff --git a/TestPackOCR/App.config b/TestPackOCR/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/TestPackOCR/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TestPackOCR/Form1.Designer.cs b/TestPackOCR/Form1.Designer.cs
new file mode 100644
index 0000000..fc5418a
--- /dev/null
+++ b/TestPackOCR/Form1.Designer.cs
@@ -0,0 +1,85 @@
+namespace TestPackOCR
+{
+ partial class Form1
+ {
+ ///
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows 窗体设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ this.txt_OrderNum = new System.Windows.Forms.TextBox();
+ this.button1 = new System.Windows.Forms.Button();
+ this.listBox1 = new System.Windows.Forms.ListBox();
+ this.SuspendLayout();
+ //
+ // txt_OrderNum
+ //
+ this.txt_OrderNum.Location = new System.Drawing.Point(216, 74);
+ this.txt_OrderNum.Name = "txt_OrderNum";
+ this.txt_OrderNum.Size = new System.Drawing.Size(131, 21);
+ this.txt_OrderNum.TabIndex = 0;
+ //
+ // button1
+ //
+ this.button1.Location = new System.Drawing.Point(353, 76);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(75, 23);
+ this.button1.TabIndex = 1;
+ this.button1.Text = "button1";
+ this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.button1_Click);
+ //
+ // listBox1
+ //
+ this.listBox1.FormattingEnabled = true;
+ this.listBox1.ItemHeight = 12;
+ this.listBox1.Location = new System.Drawing.Point(216, 120);
+ this.listBox1.Name = "listBox1";
+ this.listBox1.Size = new System.Drawing.Size(561, 88);
+ this.listBox1.TabIndex = 2;
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.listBox1);
+ this.Controls.Add(this.button1);
+ this.Controls.Add(this.txt_OrderNum);
+ this.Name = "Form1";
+ this.Text = "Form1";
+ this.Load += new System.EventHandler(this.Form1_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TextBox txt_OrderNum;
+ private System.Windows.Forms.Button button1;
+ private System.Windows.Forms.ListBox listBox1;
+ }
+}
+
diff --git a/TestPackOCR/Form1.cs b/TestPackOCR/Form1.cs
new file mode 100644
index 0000000..d9e3ea9
--- /dev/null
+++ b/TestPackOCR/Form1.cs
@@ -0,0 +1,83 @@
+using LibReadTetraExcel;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace TestPackOCR
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+ }
+
+ private void Form1_Load(object sender, EventArgs e)
+ {
+
+ }
+
+ private void button1_Click(object sender, EventArgs e)
+ {
+ string order = txt_OrderNum.Text;
+ if (string.IsNullOrEmpty(order))
+ {
+ Console.WriteLine("订单号为空,请输入订单号。");
+ return;
+ }
+
+ Console.WriteLine("当前订单号为:" + order);
+ var config = ExcelHelper.ReadOCROrder("OCR文件0602.xlsx", order);
+ if (config.ParseQSV)
+ {
+ Console.WriteLine("当前订单QSV:" + config.QSV);
+ Console.WriteLine("当前订单Number Of Lanes:" + config.NumberOfLanes);
+
+ var result = config.OCRDesign
+ .GroupBy(kvp => kvp.Value, kvp => kvp.Key)
+ .ToDictionary(g => g.Key, g => g.ToList());
+ foreach (var kvp in result)
+ {
+ listBox1.Items.Add(string.Join(",", kvp.Value));
+ listBox1.Items.Add(string.Join(",", config.OCRRequest[kvp.Value[0]]));
+ }
+ }
+ else
+ {
+ Console.WriteLine("QSV未找到,请检查订单号是否正确");
+ return;
+ }
+ if (config.ParseProduct)
+ {
+ Console.WriteLine("当前订单产品编号:" + config.ProductStandard);
+ Console.WriteLine("当前订单幅宽:" + config.Width);
+ Console.WriteLine ("当前订单幅高:" + config.Height);
+ Console.WriteLine("当前订单梯度:" + config.Gradient);
+ }
+ else
+ {
+ Console.WriteLine("ProductStandard未找到,请检查订单号是否正确");
+ return;
+ }
+ if (config.ParseArrange)
+ {
+ Console.WriteLine("当前订单X偏移:" + config.DistX);
+ Console.WriteLine("当前订单Y偏移:" + config.DistY);
+ Console.WriteLine("当前排布方式:" + config.ColorArray);
+ Console.WriteLine("单行最大数量:" + config.ColorMax.ToString());
+ }
+ else
+ {
+ Console.WriteLine("DistX,DistY未找到,请检查订单号是否正确");
+ return;
+ }
+ Console.WriteLine("相关数据已获取完成,且已显示在界面中,请查看。");
+ }
+ }
+}
diff --git a/TestPackOCR/Form1.resx b/TestPackOCR/Form1.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/TestPackOCR/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TestPackOCR/Program.cs b/TestPackOCR/Program.cs
new file mode 100644
index 0000000..4ad9020
--- /dev/null
+++ b/TestPackOCR/Program.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace TestPackOCR
+{
+ internal static class Program
+ {
+ ///
+ /// 应用程序的主入口点。
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
diff --git a/TestPackOCR/Properties/AssemblyInfo.cs b/TestPackOCR/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..233d533
--- /dev/null
+++ b/TestPackOCR/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("TestPackOCR")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("HP")]
+[assembly: AssemblyProduct("TestPackOCR")]
+[assembly: AssemblyCopyright("Copyright © HP 2025")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("717ba61b-8c31-473f-8a02-626337a90a5e")]
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/TestPackOCR/Properties/Resources.Designer.cs b/TestPackOCR/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..8b026a1
--- /dev/null
+++ b/TestPackOCR/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本: 4.0.30319.42000
+//
+// 对此文件的更改可能导致不正确的行为,如果
+// 重新生成代码,则所做更改将丢失。
+//
+//------------------------------------------------------------------------------
+
+namespace TestPackOCR.Properties
+{
+
+
+ ///
+ /// 强类型资源类,用于查找本地化字符串等。
+ ///
+ // 此类是由 StronglyTypedResourceBuilder
+ // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+ // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+ // (以 /str 作为命令选项),或重新生成 VS 项目。
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// 返回此类使用的缓存 ResourceManager 实例。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TestPackOCR.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 重写当前线程的 CurrentUICulture 属性,对
+ /// 使用此强类型资源类的所有资源查找执行重写。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/TestPackOCR/Properties/Resources.resx b/TestPackOCR/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/TestPackOCR/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TestPackOCR/Properties/Settings.Designer.cs b/TestPackOCR/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..8eacc29
--- /dev/null
+++ b/TestPackOCR/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace TestPackOCR.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/TestPackOCR/Properties/Settings.settings b/TestPackOCR/Properties/Settings.settings
new file mode 100644
index 0000000..3964565
--- /dev/null
+++ b/TestPackOCR/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/TestPackOCR/TestPackOCR.csproj b/TestPackOCR/TestPackOCR.csproj
new file mode 100644
index 0000000..e2a639b
--- /dev/null
+++ b/TestPackOCR/TestPackOCR.csproj
@@ -0,0 +1,113 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {717BA61B-8C31-473F-8A02-626337A90A5E}
+ WinExe
+ TestPackOCR
+ TestPackOCR
+ v4.7.2
+ 512
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ true
+ bin\x64\Debug\
+ DEBUG;TRACE
+ full
+ x64
+ 7.3
+ prompt
+ true
+
+
+ bin\x64\Release\
+ TRACE
+ true
+ pdbonly
+ x64
+ 7.3
+ prompt
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ Form1.cs
+
+
+
+
+ Form1.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
+ {d03a85cc-a53b-4434-a560-7a89563292e8}
+ LibDataBase
+
+
+ {b88b2fa9-0d9d-4ebb-a87a-4de2dc2dd70f}
+ LibReadTetraExcel
+
+
+
+
\ No newline at end of file
diff --git a/TetraPackOCR/Form1.cs b/TetraPackOCR/Form1.cs
index b359e85..ac1c3c0 100644
--- a/TetraPackOCR/Form1.cs
+++ b/TetraPackOCR/Form1.cs
@@ -39,6 +39,7 @@ using System.Windows.Documents;
using System.Windows.Forms;
using ThridLibray;
using LibDataBase;
+using LibReadTetraExcel;
namespace TetraPackOCR
{
@@ -63,34 +64,11 @@ namespace TetraPackOCR
/// 声明一个PaddleOCR对象
///
PaddleOCREngine Engine;
-
- ///
- ///对应表格"P2生成数据"这一页
- ///
- ExcelWorksheet sheet1;
- ///
- /// 对应表格"QSV对应产品规格和梯度"这一页
- ///
- ExcelWorksheet sheet2;
- ///
- /// 对应"产品规格对应排布方式"这一页
- ///
- ExcelWorksheet sheet3;
///
/// 表格路径
///
string execlFileName = AppDomain.CurrentDomain.BaseDirectory + "Data\\Excle\\OCR文件0602.xlsx";
-
- ///
- /// 共印依据 QSV Design, Layers, Colours,产品规格
- ///
- string m_ProductStandard;
- ///
- /// 幅数 包材宽 梯度 X距离 Y距离
- ///
- int NumberOfLanes;
- double m_width, m_Gradient, m_DistX, m_DistY, m_height;
- int m_ColorMax = 0;
+ OrderConfig config = null;
///
/// 定位Vpp文件
///
@@ -666,131 +644,65 @@ namespace TetraPackOCR
}
log.Info("当前订单号为:" + order);
- //读取表格内容
- ExcelPackage.License.SetNonCommercialOrganization("My Noncommercial organization");
- using (ExcelPackage package = new ExcelPackage(execlFileName))
+ config = ExcelHelper.ReadOCROrder(execlFileName, order);
+ if (config.ParseQSV)
{
- sheet1 = package.Workbook.Worksheets["P2生成数据"];
- sheet2 = package.Workbook.Worksheets["QSV对应产品规格和梯度"];
- sheet3 = package.Workbook.Worksheets["产品规格对应排布方式"];
- //根据订单遍历sheet1 找Sequence QSV NumOFLanes 字符
- string currentQSV = "";
- for (int i = 1; i < sheet1.Dimension.Rows; i++)
+ lbl_QSV.Text = config.QSV;
+ log.Info("当前订单QSV:" + config.QSV);
+ log.Info("当前订单Number Of Lanes:" + config.NumberOfLanes);
+ lbl_NO.Text = config.NumberOfLanes.ToString();
+
+ var result = config.OCRDesign
+ .GroupBy(kvp => kvp.Value, kvp => kvp.Key)
+ .ToDictionary(g => g.Key, g => g.ToList());
+ foreach (var kvp in result)
{
- if (sheet1.GetValue(i, 3) != null)
- {
- if (sheet1.Cells[i, 3].Value.ToString() == order)
- {
- currentQSV = sheet1.Cells[i, 4].Value.ToString();
- lbl_QSV.Text = currentQSV;
- log.Info("当前订单QSV:" + currentQSV);
- NumberOfLanes = Convert.ToInt32(sheet1.Cells[i, 5].Value.ToString());
- log.Info("当前订单Number Of Lanes:" + NumberOfLanes);
- lbl_NO.Text = sheet1.Cells[i, 5].Value.ToString();
-
- int num = 0;
- for (int k = 0; k < 10; k++)
- {
- string lanes = sheet1.Cells[i + k, 6].Value.ToString();
- string design = sheet1.Cells[i + k, 7].Value.ToString().Split('-')[1];
- lanes = lanes.Substring(1, lanes.Length - 2);
- string[] tmp = lanes.Split(',');
- num += tmp.Length;
- List textOCR = ExecelGetOcrText(design, sheet1.Cells[i + k, 8].Value.ToString());
- foreach (string lan in tmp)
- {
- int lanInt = Convert.ToInt32(lan);
- ocrTextRequest[lanInt] = textOCR;
- ocrTextDesign[lanInt] = design;
- }
- listBox1.Items.Add(sheet1.Cells[i + k, 6].Value.ToString());
- listBox1.Items.Add(string.Join(",", textOCR));
-
- if (num >= NumberOfLanes)
- break;
- }
- break;
- }
- }
- }
-
- if (!string.IsNullOrEmpty(currentQSV))
- {
- string qsv;
- //根据得到的QSV遍历sheet2 找产品规格和宽度梯度
- for (int j = 1; j <= sheet2.Dimension.Rows; j++)
- {
- qsv = sheet2.Cells[j, 1].Value.ToString();
- if (qsv == currentQSV)
- {
- m_ProductStandard = sheet2.Cells[j, 2].Value.ToString();
- lbl_ProductStandard.Text = m_ProductStandard;
- log.Info("当前订单产品编号:" + m_ProductStandard);
- m_width = Convert.ToDouble(sheet2.Cells[j, 3].Value.ToString());
- lbl_width.Text = sheet2.Cells[j, 3].Value.ToString();
- log.Info("当前订单幅宽:" + m_width);
- m_height = Convert.ToDouble(sheet2.Cells[j, 4].Value.ToString());
- lbl_height.Text = sheet2.Cells[j, 4].Value.ToString();
- log.Info("当前订单幅高:" + m_height);
- m_Gradient = Convert.ToDouble(sheet2.Cells[j, 5].Value.ToString());
- lbl_Gradient.Text = sheet2.Cells[j, 5].Value.ToString();
- log.Info("当前订单梯度:" + m_Gradient);
- break;
- }
- }
- if (string.IsNullOrEmpty(m_ProductStandard))
- {
- log.Debug("ProductStandard未找到,请检查订单号是否正确");
- btn_OrderNum.Enabled = true;
- btn_OrderNum.BackColor = Color.DeepSkyBlue;
- return;
- }
- //根据产品规格获取距离坐标
- for (int n = 1; n < sheet3.Dimension.Rows; n++)
- {
- if (sheet3.GetValue(n, 1) != null)
- {
- if (sheet3.Cells[n, 1].Value.ToString() == m_ProductStandard)
- {
- string str = sheet3.Cells[n + ocrTextRequest[1].Count - 1, 4].Value.ToString();
- string[] x_y = str.Split(',');
- string[] X = x_y[0].Split(':');
- string[] Y = x_y[1].Split(':');
- m_DistX = Convert.ToDouble(X[1].Replace("mm", ""));
- lbl_DistX.Text = X[1].Replace("mm", "");
- log.Info("当前订单X偏移:" + m_DistX);
- m_DistY = Convert.ToDouble(Y[1].Replace("mm", ""));
- lbl_DistY.Text = Y[1].Replace("mm", "");
- log.Info("当前订单Y偏移:" + m_DistY);
-
- string alignColor = sheet3.Cells[n + ocrTextRequest[1].Count - 1, 3].Value.ToString();
- if (alignColor.Contains("单排"))
- m_ColorMax = ocrTextRequest.Values.Select(x => x.Count).Max();// ocrTextRequest[1].Count;
- else
- m_ColorMax = alignColor.Replace("排布", "").Split(',').ToList().Select(int.Parse).Max();
- log.Info("当前排布方式:" + alignColor);
- log.Info("单行最大数量:" + m_ColorMax.ToString());
- break;
- }
- }
- }
- if (m_DistX == 0 || m_DistY == 0)
- {
- log.Debug("DistX,DistY未找到,请检查订单号是否正确");
- btn_OrderNum.Enabled = true;
- btn_OrderNum.BackColor = Color.DeepSkyBlue;
- return;
- }
- log.Info("相关数据已获取完成,且已显示在界面中,请查看。");
- }
- else
- {
- log.Debug("QSV未找到,请检查订单号是否正确");
- btn_OrderNum.Enabled = true;
- btn_OrderNum.BackColor = Color.DeepSkyBlue;
- return;
+ listBox1.Items.Add(string.Join(",", kvp.Value));
+ listBox1.Items.Add(string.Join(",", config.OCRRequest[kvp.Value[0]]));
}
}
+ else
+ {
+ log.Debug("QSV未找到,请检查订单号是否正确");
+ btn_OrderNum.Enabled = true;
+ btn_OrderNum.BackColor = Color.DeepSkyBlue;
+ return;
+ }
+ if (config.ParseProduct)
+ {
+ lbl_ProductStandard.Text = config.ProductStandard;
+ log.Info("当前订单产品编号:" + config.ProductStandard);
+ lbl_width.Text = config.Width.ToString();
+ log.Info("当前订单幅宽:" + config.Width);
+ lbl_height.Text = config.Height.ToString();
+ log.Info("当前订单幅高:" + config.Height);
+ lbl_Gradient.Text = config.Gradient.ToString();
+ log.Info("当前订单梯度:" + config.Gradient);
+ }
+ else
+ {
+ log.Debug("ProductStandard未找到,请检查订单号是否正确");
+ btn_OrderNum.Enabled = true;
+ btn_OrderNum.BackColor = Color.DeepSkyBlue;
+ return;
+ }
+ if (config.ParseArrange)
+ {
+ lbl_DistX.Text = config.DistX.ToString();
+ log.Info("当前订单X偏移:" + config.DistX);
+ lbl_DistY.Text = config.DistY.ToString();
+ log.Info("当前订单Y偏移:" + config.DistY);
+ log.Info("当前排布方式:" + config.ColorArray);
+ log.Info("单行最大数量:" + config.ColorMax.ToString());
+ }
+ else
+ {
+ log.Debug("DistX,DistY未找到,请检查订单号是否正确");
+ btn_OrderNum.Enabled = true;
+ btn_OrderNum.BackColor = Color.DeepSkyBlue;
+ return;
+ }
+ log.Info("相关数据已获取完成,且已显示在界面中,请查看。");
//判断当前Lans决定结果显示数量
InitLableColumn();
@@ -812,7 +724,7 @@ namespace TetraPackOCR
}
private void InitLableColumn()
{
- switch (NumberOfLanes)
+ switch (config.NumberOfLanes)
{
case 1:
Invoke(new Action(() =>
@@ -1004,7 +916,7 @@ namespace TetraPackOCR
m_GotoZero = false;
m_startTime = DateTime.Now;
- m_textWidth = 18 - (NumberOfLanes - 5);
+ m_textWidth = 18 - (config.NumberOfLanes - 5);
//m_textWidth = Convert.ToDouble(textBox1.Text);
ocrAcc.Clear();
autorunFlag = check_Autorun.Checked;
@@ -1039,9 +951,7 @@ namespace TetraPackOCR
///
void ClearData()
{
- m_ProductStandard = null;
- NumberOfLanes = 0; m_width = 0; m_Gradient = 0; m_DistX = 0; m_DistY = 0;
- m_height = 0;
+ config = new OrderConfig();
}
///
/// 清空上次订单显示区
@@ -1301,7 +1211,7 @@ namespace TetraPackOCR
fs.Close();
log.Info("OCR存图已完成");
- CutPicture(savePath + '\\' + strTime + ".bmp", 400 + 200 * (6 - m_ColorMax), 2000, 3400 + 200 * m_ColorMax, 1600);
+ CutPicture(savePath + '\\' + strTime + ".bmp", 400 + 200 * (6 - config.ColorMax), 2000, 3400 + 200 * config.ColorMax, 1600);
if (Engine == null)
{
log.Error("Engine未初始化");
@@ -1858,7 +1768,7 @@ namespace TetraPackOCR
return;
}
- if (NumberOfLanes + 1 == mMatchingStr)
+ if (config.NumberOfLanes + 1 == mMatchingStr)
{
Thread.Sleep(3000);
EnableStartDetect();
@@ -1964,27 +1874,27 @@ namespace TetraPackOCR
if (ocrTextRequest[1].Count == 0)
return;
- double xx = x - (m_textWidth * m_ColorMax) / 2.0;
+ double xx = x - (m_textWidth * config.ColorMax) / 2.0;
double yy = y;
double rr = r;
List locationXY = new List();
double ocrx = 0, ocry = 0;
- locationXY.Add((float)NumberOfLanes);
- int nol = Convert.ToInt32(NumberOfLanes);
+ locationXY.Add((float)config.NumberOfLanes);
+ int nol = Convert.ToInt32(config.NumberOfLanes);
log.Info("当前订单OCR区域共" + nol + "组:");
double degree = (rr * Math.PI) / 180;
for (int item = 0; item < nol; item++)
{
if (item == 0)
{
- ocrx = xx - m_DistX * Math.Cos(degree) - m_DistY * Math.Sin(degree);
- ocry = yy + m_DistY * Math.Cos(degree) - m_DistX * Math.Sin(degree);
+ ocrx = xx - config.DistX * Math.Cos(degree) - config.DistY * Math.Sin(degree);
+ ocry = yy + config.DistY * Math.Cos(degree) - config.DistX * Math.Sin(degree);
}
else
{
- ocrx = ocrx + m_width * Math.Cos(degree) + m_Gradient * Math.Sin(degree);
- ocry = ocry - m_Gradient * Math.Cos(degree) + m_width * Math.Sin(degree);
+ ocrx = ocrx + config.Width * Math.Cos(degree) + config.Gradient * Math.Sin(degree);
+ ocry = ocry - config.Gradient * Math.Cos(degree) + config.Width * Math.Sin(degree);
}
log.Info("第" + (item + 1) + "组坐标为:X:" + ocrx + ",Y:" + ocry + "。");
@@ -2001,14 +1911,14 @@ namespace TetraPackOCR
if (ocry < - 50)
{
- ocrx = ocrx - m_height * Math.Sin(degree);
- ocry = ocry + m_height * Math.Cos(degree);
+ ocrx = ocrx - config.Height * Math.Sin(degree);
+ ocry = ocry + config.Height * Math.Cos(degree);
log.Info("更新第" + (item + 1) + "组坐标为:X:" + ocrx + ",Y:" + ocry + "。");
}
else if (ocry > 400)
{
- ocrx = ocrx + m_height * Math.Sin(degree);
- ocry = ocry - m_height * Math.Cos(degree);
+ ocrx = ocrx + config.Height * Math.Sin(degree);
+ ocry = ocry - config.Height * Math.Cos(degree);
log.Info("更新第" + (item + 1) + "组坐标为:X:" + ocrx + ",Y:" + ocry + "。");
}
diff --git a/TetraPackOCR/TetraPackOCR.csproj b/TetraPackOCR/TetraPackOCR.csproj
index 827ace9..2a94f03 100644
--- a/TetraPackOCR/TetraPackOCR.csproj
+++ b/TetraPackOCR/TetraPackOCR.csproj
@@ -1,6 +1,5 @@
-
@@ -80,12 +79,6 @@
False
..\dll\Bjcve.Comm.FFP.dll
-
- ..\packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll
-
-
- ..\packages\BouncyCastle.Cryptography.2.7.0-beta.98\lib\net461\BouncyCastle.Cryptography.dll
-
..\dll\CLIDelegate.dll
@@ -125,9 +118,6 @@
False
..\dll\Cognex.VisionPro.ToolGroup.dll
-
- ..\packages\Enums.NET.5.0.0\lib\net461\Enums.NET.dll
-
..\packages\EPPlus.8.4.0\lib\net462\EPPlus.dll
@@ -137,12 +127,6 @@
..\packages\EPPlus.System.Drawing.8.4.0\lib\net462\EPPlus.System.Drawing.dll
-
- ..\packages\ExtendedNumerics.BigDecimal.3003.0.0.346\lib\net472\ExtendedNumerics.BigDecimal.dll
-
-
- ..\packages\SharpZipLib.1.4.2\lib\netstandard2.0\ICSharpCode.SharpZipLib.dll
-
False
..\dll\log4net.dll
@@ -150,9 +134,6 @@
..\dll\LogShowLib.dll
-
- ..\packages\MathNet.Numerics.Signed.5.0.0\lib\net461\MathNet.Numerics.dll
-
..\packages\Microsoft.Bcl.Cryptography.10.0.1\lib\net462\Microsoft.Bcl.Cryptography.dll
@@ -162,21 +143,6 @@
..\packages\Newtonsoft.Json.13.0.4\lib\net45\Newtonsoft.Json.dll
-
- ..\packages\NPOI.2.7.5\lib\net472\NPOI.Core.dll
-
-
- ..\packages\NPOI.2.7.5\lib\net472\NPOI.OOXML.dll
-
-
- ..\packages\NPOI.2.7.5\lib\net472\NPOI.OpenXml4Net.dll
-
-
- ..\packages\NPOI.2.7.5\lib\net472\NPOI.OpenXmlFormats.dll
-
-
- ..\packages\NSax.1.0.2\lib\net472\NSax.dll
-
..\packages\OpenCvSharp4.4.11.0.20250507\lib\netstandard2.0\OpenCvSharp.dll
@@ -192,9 +158,6 @@
-
- ..\packages\SixLabors.Fonts.1.0.1\lib\netstandard2.0\SixLabors.Fonts.dll
-
..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll
@@ -211,21 +174,6 @@
..\packages\System.Formats.Asn1.10.0.1\lib\net462\System.Formats.Asn1.dll
-
- ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll
- True
- True
-
-
- ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll
- True
- True
-
-
- ..\packages\System.IO.UnmanagedMemoryStream.4.3.0\lib\net46\System.IO.UnmanagedMemoryStream.dll
- True
- True
-
..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll
@@ -241,13 +189,7 @@
..\packages\System.Security.Cryptography.Xml.10.0.1\lib\net462\System.Security.Cryptography.Xml.dll
-
- ..\packages\System.Text.Encoding.CodePages.10.0.1\lib\net462\System.Text.Encoding.CodePages.dll
-
-
- ..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll
-
@@ -263,9 +205,6 @@
-
- ..\packages\ZString.2.6.0\lib\netstandard2.0\ZString.dll
-
@@ -344,7 +283,6 @@
-
diff --git a/TetraPackOCR/packages.config b/TetraPackOCR/packages.config
index 7ed510b..092e80b 100644
--- a/TetraPackOCR/packages.config
+++ b/TetraPackOCR/packages.config
@@ -1,40 +1,23 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/TetraPark.OCR.sln b/TetraPark.OCR.sln
index 5c95b1c..d51b075 100644
--- a/TetraPark.OCR.sln
+++ b/TetraPark.OCR.sln
@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibReadTetraExcel", "LibRea
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibDataBase", "LibDataBase\LibDataBase.csproj", "{D03A85CC-A53B-4434-A560-7A89563292E8}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestPackOCR", "TestPackOCR\TestPackOCR.csproj", "{717BA61B-8C31-473F-8A02-626337A90A5E}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -53,6 +55,14 @@ Global
{D03A85CC-A53B-4434-A560-7A89563292E8}.Release|Any CPU.Build.0 = Release|Any CPU
{D03A85CC-A53B-4434-A560-7A89563292E8}.Release|x64.ActiveCfg = Release|Any CPU
{D03A85CC-A53B-4434-A560-7A89563292E8}.Release|x64.Build.0 = Release|Any CPU
+ {717BA61B-8C31-473F-8A02-626337A90A5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {717BA61B-8C31-473F-8A02-626337A90A5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {717BA61B-8C31-473F-8A02-626337A90A5E}.Debug|x64.ActiveCfg = Debug|x64
+ {717BA61B-8C31-473F-8A02-626337A90A5E}.Debug|x64.Build.0 = Debug|x64
+ {717BA61B-8C31-473F-8A02-626337A90A5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {717BA61B-8C31-473F-8A02-626337A90A5E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {717BA61B-8C31-473F-8A02-626337A90A5E}.Release|x64.ActiveCfg = Release|Any CPU
+ {717BA61B-8C31-473F-8A02-626337A90A5E}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE