Commit e778911b 王海洋

Merge branch 'master' of http://106.15.194.121:8083/zdl/NS100

2 个父辈 34242b4e 8f614d2c
...@@ -20,7 +20,7 @@ namespace BLL ...@@ -20,7 +20,7 @@ namespace BLL
public static List<string> extraKey=new List<string>(); public static List<string> extraKey=new List<string>();
//public static Dictionary<string, Dictionary<string, string>> extraData = new Dictionary<string, Dictionary<string, string>>(); //public static Dictionary<string, Dictionary<string, string>> extraData = new Dictionary<string, Dictionary<string, string>>();
public static int mateMaxCodeID; public static int mateMaxCodeID;
public static readonly string[] CODE_SPLIT = new string[] { ",", ";", ":", "@", "#", "$", "%", "&", "-", "_", "+", "|", "!", "^", "*", "?", "/", "\\", "[Space]", "[Tab]","[GS]","[RS]"}; public static readonly string[] CODE_SPLIT = new string[] { ",", ";", ":", "@", "#", "$", "%", "&", "-", "_", "+", "|", "!", "^", "*", "?", "/", "\\", "[Space]", "[Tab]","[GS]","[RS]","[LF]"};
public static List<AutoGenRule> AutoGenRules; public static List<AutoGenRule> AutoGenRules;
} }
......
...@@ -68,11 +68,10 @@ namespace BLL ...@@ -68,11 +68,10 @@ namespace BLL
{ {
//return; //return;
foreach (var tp in MatchTemplateList) { foreach (var tp in MatchTemplateList) {
LogNet.log.Info($"开始解析模版:{tp.Key}"); LogNet.log.Info($"===开始解析模版:{tp.Key}");
foreach (var m in tp.Value.MatchCollections) { foreach (var m in tp.Value.MatchCollections) {
LogNet.log.Info($"开始解析关键字:{m.Key}"); LogNet.log.Info($"开始解析关键字:{m.Key}");
//LogNet.log.Info($"匹配到关键字:{m.Key}");
string matchlist = m.Value.barcodeInfo.Text + "\t/\t"; string matchlist = m.Value.barcodeInfo.Text + "\t/\t";
foreach (var item in m.Value.Matchs) foreach (var item in m.Value.Matchs)
{ {
...@@ -80,6 +79,7 @@ namespace BLL ...@@ -80,6 +79,7 @@ namespace BLL
} }
LogNet.log.Info(matchlist); LogNet.log.Info(matchlist);
} }
LogNet.log.Info($"===结束解析模版:{tp.Key}");
} }
} }
public class TemplateCollection public class TemplateCollection
......
...@@ -619,8 +619,11 @@ namespace BLL ...@@ -619,8 +619,11 @@ namespace BLL
{ {
int matchCount = 0; int matchCount = 0;
var codeText = codeinfo.Text; var codeText = codeinfo.Text;
codeText = codeText.Replace("\r", ""); if (codeinfo.CodeType == "OCR")
codeText = codeText.Replace("\n", ""); {
codeText = codeText.Replace("\r", "");
codeText = codeText.Replace("\n", "");
}
MatchAnalysis.SetBarcode(codeinfo); MatchAnalysis.SetBarcode(codeinfo);
code = codeMatch[i].CaseSensitive ? codeText : codeText.ToUpper(); code = codeMatch[i].CaseSensitive ? codeText : codeText.ToUpper();
bool ismatch = true; bool ismatch = true;
...@@ -649,7 +652,7 @@ namespace BLL ...@@ -649,7 +652,7 @@ namespace BLL
if (!code.StartsWith(text)) if (!code.StartsWith(text))
ismatch = false; ismatch = false;
MatchAnalysis.AddMatch(codeMatch[i].Keyword, ismatch, codeMatch[i].CodeID, $"开头字符:\"{text}\"", $"NG"); MatchAnalysis.AddMatch(codeMatch[i].Keyword, ismatch, codeMatch[i].CodeID, $"开头字符:\"{text}\"", ismatch ? "OK" : "NG");
//if (!ismatch) return null; //if (!ismatch) return null;
} }
...@@ -662,7 +665,7 @@ namespace BLL ...@@ -662,7 +665,7 @@ namespace BLL
if (!code.EndsWith(text)) if (!code.EndsWith(text))
ismatch = false; ismatch = false;
MatchAnalysis.AddMatch(codeMatch[i].Keyword, ismatch, codeMatch[i].CodeID, $"结尾字符:\"{text}\"", $"NG"); MatchAnalysis.AddMatch(codeMatch[i].Keyword, ismatch, codeMatch[i].CodeID, $"结尾字符:\"{text}\"", ismatch ? "OK" : "NG");
//if (!ismatch) return null; //if (!ismatch) return null;
} }
...@@ -689,7 +692,7 @@ namespace BLL ...@@ -689,7 +692,7 @@ namespace BLL
ismatch = false; ismatch = false;
var mode = codeMatch[i].MatchMiddleType == 0 ? "相等" : codeMatch[i].MatchMiddleType == 1 ? "至多" : "至少"; var mode = codeMatch[i].MatchMiddleType == 0 ? "相等" : codeMatch[i].MatchMiddleType == 1 ? "至多" : "至少";
MatchAnalysis.AddMatch(codeMatch[i].Keyword, ismatch, codeMatch[i].CodeID, $"中间字符:\"{text}\",{mode}匹配:{codeMatch[i].MiddleTextCount}次", $"NG"); MatchAnalysis.AddMatch(codeMatch[i].Keyword, ismatch, codeMatch[i].CodeID, $"中间字符:\"{text}\",{mode}匹配:{codeMatch[i].MiddleTextCount}次", ismatch ? "OK" : "NG");
//if (!ismatch) return null; //if (!ismatch) return null;
} }
...@@ -702,7 +705,7 @@ namespace BLL ...@@ -702,7 +705,7 @@ namespace BLL
string str = MaterialAsciiCode.GetAsciiCode(codeMatch[i].SplitText); string str = MaterialAsciiCode.GetAsciiCode(codeMatch[i].SplitText);
if(codeText.Contains(str)) if(codeText.Contains(str))
{ {
string[] arr = codeText.Split(new string[] { str }, StringSplitOptions.RemoveEmptyEntries); string[] arr = codeText.Split(str.ToCharArray());
index = codeMatch[i].SplitPart - 1; index = codeMatch[i].SplitPart - 1;
if (index >= arr.Length) if (index >= arr.Length)
ismatch = false; ismatch = false;
...@@ -714,7 +717,7 @@ namespace BLL ...@@ -714,7 +717,7 @@ namespace BLL
ismatch = false; ismatch = false;
} }
MatchAnalysis.AddMatch(codeMatch[i].Keyword, ismatch, codeMatch[i].CodeID, $"分割符:{codeMatch[i].SplitText},第:{codeMatch[i].SplitPart}位", $"NG"); MatchAnalysis.AddMatch(codeMatch[i].Keyword, ismatch, codeMatch[i].CodeID, $"分割符:{codeMatch[i].SplitText},第:{codeMatch[i].SplitPart}位", ismatch ? "OK" : "NG");
//if (!ismatch) return null; //if (!ismatch) return null;
} }
...@@ -740,13 +743,14 @@ namespace BLL ...@@ -740,13 +743,14 @@ namespace BLL
if (codeMatch[i].MatchISNumber) if (codeMatch[i].MatchISNumber)
{ {
LogNet.log.Info($"开始匹配数字 [{filtercode}]"); LogNet.log.Info($"开始匹配数字 [{filtercode}]");
string analysisReason = $"\"{filtercode}\""; filtercode = filtercode.Trim().ToLower().Replace("pcs", "");
filtercode = filtercode.Replace(",", "");
string analysisReason = filtercode;
if (!int.TryParse(filtercode, out int res)) if (!int.TryParse(filtercode, out int res))
{ {
ismatch = false; ismatch = false;
analysisReason += $" NG"; analysisReason += $" NG";
} }
else else
{ {
...@@ -765,7 +769,7 @@ namespace BLL ...@@ -765,7 +769,7 @@ namespace BLL
//bool ismatch = true; //bool ismatch = true;
if (code.Length < codeMatch[i].MinLength) if (code.Length < codeMatch[i].MinLength)
ismatch = false; ismatch = false;
MatchAnalysis.AddMatch(codeMatch[i].Keyword, ismatch, codeMatch[i].CodeID, $"长度小于:{codeMatch[i].MatchMinLength}", $"NG"); MatchAnalysis.AddMatch(codeMatch[i].Keyword, ismatch, codeMatch[i].CodeID, $"长度最小:{codeMatch[i].MinLength}", ismatch ? "OK" : "NG");
//if (!ismatch) return null; //if (!ismatch) return null;
} }
...@@ -776,7 +780,7 @@ namespace BLL ...@@ -776,7 +780,7 @@ namespace BLL
//bool ismatch = true; //bool ismatch = true;
if (code.Length > codeMatch[i].MaxLength) if (code.Length > codeMatch[i].MaxLength)
ismatch = false; ismatch = false;
MatchAnalysis.AddMatch(codeMatch[i].Keyword, ismatch, codeMatch[i].CodeID, $"长度最大:{codeMatch[i].MatchMaxLength}", $"NG"); MatchAnalysis.AddMatch(codeMatch[i].Keyword, ismatch, codeMatch[i].CodeID, $"长度最大:{codeMatch[i].MaxLength}", ismatch ? "OK" : "NG");
} }
if (!ismatch) if (!ismatch)
......
...@@ -12,19 +12,19 @@ namespace Model ...@@ -12,19 +12,19 @@ namespace Model
/// </summary> /// </summary>
public static class FilePath public static class FilePath
{ {
public static readonly string LANGUAGE_DIR = Environment.CurrentDirectory + "\\Language\\"; public static readonly string LANGUAGE_DIR = Application.StartupPath + "\\Language\\";
public static readonly string MATERIAL_DIR = Environment.CurrentDirectory + "\\Material\\"; public static readonly string MATERIAL_DIR = Application.StartupPath + "\\Material\\";
public static readonly string RETROSPECT_DIR = Application.StartupPath + "\\Retrospect\\"; public static readonly string RETROSPECT_DIR = Application.StartupPath + "\\Retrospect\\";
public static readonly string PRINT_LABEL_DIR = Environment.CurrentDirectory + "\\PrintLabel\\"; public static readonly string PRINT_LABEL_DIR = Application.StartupPath + "\\PrintLabel\\";
public static readonly string CONFIG_DIR = Environment.CurrentDirectory + "\\Config\\"; public static readonly string CONFIG_DIR = Application.StartupPath + "\\Config\\";
public static readonly string CONFIG_APP = Environment.CurrentDirectory + "\\Config\\app.config"; public static readonly string CONFIG_APP = Application.StartupPath + "\\Config\\app.config";
public static readonly string CONFIG_CAMERA = Environment.CurrentDirectory + "\\Config\\Camera.json"; public static readonly string CONFIG_CAMERA = Application.StartupPath + "\\Config\\Camera.json";
public static readonly string CONFIG_MACRO_KEY = Environment.CurrentDirectory + "\\Config\\MacroKey.txt"; public static readonly string CONFIG_MACRO_KEY = Application.StartupPath + "\\Config\\MacroKey.txt";
public static readonly string CONFIG_HTTP_TEST_DATA = Environment.CurrentDirectory + "\\Config\\HttpTestData.json"; public static readonly string CONFIG_HTTP_TEST_DATA = Application.StartupPath + "\\Config\\HttpTestData.json";
public static readonly string CONFIG_EXTENSION = Environment.CurrentDirectory + "\\Config\\Extension.json"; public static readonly string CONFIG_EXTENSION = Application.StartupPath + "\\Config\\Extension.json";
public static readonly string CONFIG_REELID = Environment.CurrentDirectory + "\\Config\\ReelID"; public static readonly string CONFIG_REELID = Application.StartupPath + "\\Config\\ReelID";
public static readonly string CONFIG_DATABASE = Environment.CurrentDirectory + "\\Config\\Database.db3"; public static readonly string CONFIG_DATABASE = Application.StartupPath + "\\Config\\Database.db3";
public static readonly string CONFIG_AUTOGENRULES = Environment.CurrentDirectory + "\\Config\\AutoGenRules.json"; public static readonly string CONFIG_AUTOGENRULES = Application.StartupPath + "\\Config\\AutoGenRules.json";
} }
} }
...@@ -8,7 +8,7 @@ namespace Model ...@@ -8,7 +8,7 @@ namespace Model
{ {
public static class MaterialAsciiCode public static class MaterialAsciiCode
{ {
private static readonly Dictionary<string, string> ASCII_CODE = new() { { "[space]", " " }, { "[tab]", "\t" },{ "[gs]",((char)29).ToString()},{ "[rs]", ((char)30).ToString() } }; private static readonly Dictionary<string, string> ASCII_CODE = new() { { "[space]", " " }, { "[tab]", "\t" },{ "[gs]",((char)29).ToString()},{ "[rs]", ((char)30).ToString() }, { "[lf]", ((char)10).ToString() } };
public static string GetAsciiCode(string code) public static string GetAsciiCode(string code)
{ {
......
...@@ -29,8 +29,12 @@ namespace SmartScan ...@@ -29,8 +29,12 @@ namespace SmartScan
{ {
InitializeComponent(); InitializeComponent();
windowHeight = this.Height; windowHeight = this.Height;
codeText = codeText.Replace("\r", ""); this.codeText = codeText;
this.codeText = codeText.Replace("\n", ""); if (codeType == "OCR")
{
codeText = codeText.Replace("\r", "");
this.codeText = codeText.Replace("\n", "");
}
this.codeID = codeID; this.codeID = codeID;
this.codeType = codeType; this.codeType = codeType;
TxtMatchingEndText.Tag = "not"; TxtMatchingEndText.Tag = "not";
......
...@@ -102,6 +102,7 @@ namespace SmartScan ...@@ -102,6 +102,7 @@ namespace SmartScan
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
//BLL.Config.Backgrounder = true; //BLL.Config.Backgrounder = true;
bool back = BLL.Config.Backgrounder; bool back = BLL.Config.Backgrounder;
bool hide = false; bool hide = false;
if (args.Length > 0) if (args.Length > 0)
hide = args[0].ToLower() == "hide"; hide = args[0].ToLower() == "hide";
......
...@@ -130,7 +130,7 @@ namespace SmartScan ...@@ -130,7 +130,7 @@ namespace SmartScan
//string outup = codeText; //string outup = codeText;
//AsciiToCharReplacer asciiToChar = new AsciiToCharReplacer(); //AsciiToCharReplacer asciiToChar = new AsciiToCharReplacer();
//outup= asciiToChar.AsciiToString(outup); //outup= asciiToChar.AsciiToString(outup);
string[] arr = text.Split(new string[] { str }, StringSplitOptions.RemoveEmptyEntries); string[] arr = text.Split(str.ToCharArray());
//string[] arr = codeText.Split(new string[] { str }, StringSplitOptions.RemoveEmptyEntries); //string[] arr = codeText.Split(new string[] { str }, StringSplitOptions.RemoveEmptyEntries);
int index = Convert.ToInt32(NudSplitPart.Value) - 1; int index = Convert.ToInt32(NudSplitPart.Value) - 1;
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Imaging;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.UI.WebControls; using System.Web.UI.WebControls;
using System.Windows.Forms; using System.Windows.Forms;
using Asa.FaceControl; using Asa.FaceControl;
...@@ -310,13 +313,23 @@ namespace SmartScan ...@@ -310,13 +313,23 @@ namespace SmartScan
bmp = ObjConversion.ReadImageFile(dlg.FileName); bmp = ObjConversion.ReadImageFile(dlg.FileName);
LstCode.Items.Clear(); LstCode.Items.Clear();
ImgShow.CodeCenterClear(); ImgShow.CodeCenterClear();
//ImgShow.Image = null;
mateCopy[mateIndex].State = TemplateState.Unsaved; mateCopy[mateIndex].State = TemplateState.Unsaved;
mateCopy[mateIndex].ImagePath = ""; mateCopy[mateIndex].ImagePath = "";
mateCopy[mateIndex].Image = bmp; mateCopy[mateIndex].Image = bmp;
ImgShow.Image = bmp; Application.DoEvents();
ImgShow.Image = bmp;// ConvertTo24bppRgb(bmp);
iscamp = false; iscamp = false;
} }
public Bitmap ConvertTo24bppRgb(Bitmap argbImage)
{
Bitmap rgbImage = new Bitmap(argbImage.Width, argbImage.Height, PixelFormat.Format24bppRgb);
using (Graphics g = Graphics.FromImage(rgbImage))
{
g.DrawImage(argbImage, new Rectangle(0, 0, rgbImage.Width, rgbImage.Height));
}
return rgbImage;
}
public bool iscamp = true; public bool iscamp = true;
private void BtnScanCode_Click(object sender, EventArgs e) private void BtnScanCode_Click(object sender, EventArgs e)
{ {
...@@ -329,7 +342,8 @@ namespace SmartScan ...@@ -329,7 +342,8 @@ namespace SmartScan
return; return;
} }
List<BarcodeInfo> info = null; List<BarcodeInfo> info = null;
LstCode.Items.Clear();
ImgShow.CodeCenterClear();
if (iscamp&&Camera.useIDCamera) if (iscamp&&Camera.useIDCamera)
{ {
Bitmap[] result = Camera.CaptureAndGetCode(out info); Bitmap[] result = Camera.CaptureAndGetCode(out info);
...@@ -345,8 +359,7 @@ namespace SmartScan ...@@ -345,8 +359,7 @@ namespace SmartScan
} }
//info = Camera.GetBarCode(bmp); //info = Camera.GetBarCode(bmp);
LstCode.Items.Clear();
ImgShow.CodeCenterClear();
mateCopy[mateIndex].Match.Clear(); mateCopy[mateIndex].Match.Clear();
mateCopy[mateIndex].Code.Clear(); mateCopy[mateIndex].Code.Clear();
mateCopy[mateIndex].Ocr.Clear(); mateCopy[mateIndex].Ocr.Clear();
...@@ -767,8 +780,11 @@ namespace SmartScan ...@@ -767,8 +780,11 @@ namespace SmartScan
{ {
int matchCount = 0; int matchCount = 0;
var codeText = codeinfo.Text; var codeText = codeinfo.Text;
codeText = codeText.Replace("\r", ""); if (codeinfo.CodeType == "OCR")
codeText = codeText.Replace("\n", ""); {
codeText = codeText.Replace("\r", "");
codeText = codeText.Replace("\n", "");
}
code = codeMatch[i].CaseSensitive ? codeText : codeText.ToUpper(); code = codeMatch[i].CaseSensitive ? codeText : codeText.ToUpper();
bool ismatch = true; bool ismatch = true;
//匹配CodeType //匹配CodeType
...@@ -831,7 +847,7 @@ namespace SmartScan ...@@ -831,7 +847,7 @@ namespace SmartScan
string str = MaterialAsciiCode.GetAsciiCode(codeMatch[i].SplitText); string str = MaterialAsciiCode.GetAsciiCode(codeMatch[i].SplitText);
if (codeText.Contains(str)) if (codeText.Contains(str))
{ {
string[] arr = codeText.Split(new string[] { str }, StringSplitOptions.RemoveEmptyEntries); string[] arr = codeText.Split(str.ToCharArray());
index = codeMatch[i].SplitPart - 1; index = codeMatch[i].SplitPart - 1;
if (index >= arr.Length) if (index >= arr.Length)
ismatch = false; ismatch = false;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!