Commit 169b3ee9 刘韬

修正字符串切割模板bug

1 个父辈 8f614d2c
......@@ -36,6 +36,7 @@ namespace BLL
}
public static void AddMatch(string matchKey, bool isMatch, int codeID, string colName,string matchDesc) {
LogNet.log.Info($"Match {matchKey},isMatch:{isMatch},{colName},matchDesc:{matchDesc}");
Match match = new Match(matchKey, isMatch, codeID, colName,matchDesc);
var ms = MatchTemplateList[CurrnetTemplateName].BarcodeMatchs[CurrnetBarcode.Text].MatchCollections;
......
......@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;
namespace BLL
......@@ -445,6 +446,7 @@ namespace BLL
}
}
LogNet.log.Info($"{mateTemp[index].Name} 匹配数量 [关键字数量:{keyword.Count} = 匹配数量:{matchCount}]");
if (matchCount != 0 && keyword.Count == matchCount)
{
isMatch = true;
......@@ -677,6 +679,7 @@ namespace BLL
text = codeMatch[i].CaseSensitive ? codeMatch[i].MiddleText : codeMatch[i].MiddleText.ToUpper();
if (text == "") return null;
index = count = 0;
while ((index = code.IndexOf(text, index)) != -1)
{
count++;
......@@ -692,7 +695,7 @@ namespace BLL
ismatch = false;
var mode = codeMatch[i].MatchMiddleType == 0 ? "相等" : codeMatch[i].MatchMiddleType == 1 ? "至多" : "至少";
MatchAnalysis.AddMatch(codeMatch[i].Keyword, ismatch, codeMatch[i].CodeID, $"中间字符:\"{text}\",{mode}匹配:{codeMatch[i].MiddleTextCount}次", ismatch ? "OK" : "NG");
MatchAnalysis.AddMatch(codeMatch[i].Keyword, ismatch, codeMatch[i].CodeID, $"中间字符:\"{text}\",{mode}匹配:{codeMatch[i].MiddleTextCount}次,实际:{count}", ismatch ? "OK" : "NG");
//if (!ismatch) return null;
}
......@@ -710,7 +713,11 @@ namespace BLL
if (index >= arr.Length)
ismatch = false;
else
{
code = arr[index];
if (string.IsNullOrEmpty(code))
code = " ";
}
}
else
{
......@@ -722,7 +729,8 @@ namespace BLL
}
//截取
if (!ismatch) continue;
if (!ismatch)
continue;
int startIndex = codeMatch[i].SubstringStart;
int length = codeMatch[i].SubstringLength;
if (startIndex >= code.Length)
......@@ -743,18 +751,17 @@ namespace BLL
if (codeMatch[i].MatchISNumber)
{
LogNet.log.Info($"开始匹配数字 [{filtercode}]");
filtercode = filtercode.Trim().ToLower().Replace("pcs", "");
filtercode = filtercode.Replace(",", "");
string analysisReason = filtercode;
if (!int.TryParse(filtercode, out int res))
string analysisReason = filtercode.Trim();
analysisReason = filtercode.Replace(",", "");
var m = Regex.Match(analysisReason, @"^(\d+)\w{0,3}$");
if (!m.Success)
{
ismatch = false;
analysisReason += $" NG";
}
else
{
filtercode = res.ToString();
filtercode = m.Groups[1].Value;
analysisReason += $" OK";
}
MatchAnalysis.AddMatch(codeMatch[i].Keyword, ismatch, codeMatch[i].CodeID, $"是否为数字", analysisReason);
......
......@@ -84,7 +84,7 @@ namespace SmartScan
private void AddMatch(MaterialCodeMatch match)
{
FaceButton btn = new() { Text = string.Format("[{0}]", match.Keyword), Margin = new Padding(0, 0, 6, 6), Width = 100, Height = 50 };
FaceButton btn = new() { Text = string.Format("[{0}]", match.Keyword), Margin = new Padding(0, 0, 6, 6), Width = 100, Height = 28 };
btn.Click += Btn_Click;
btn.Tag = "not";
flowLayoutPanel1.Controls.Add(btn);
......
......@@ -22,7 +22,7 @@ namespace SmartScan
//this.Height = 738;
this.Top = 15;
this.Left = 0;
WebService.Open(BLLCommon.config.WebService);//启动条码匹配服务
//WebService.Open(BLLCommon.config.WebService);//启动条码匹配服务
LogNet.log = log4net.LogManager.GetLogger("SmartScan");
}
......
......@@ -310,6 +310,7 @@ namespace SmartScan.PlusSettingFrm
if (isvaor)
{
bool isbarcode = true;
if (codeType.StartsWith("QR Code"))
{
int deg = Angle;
......@@ -317,23 +318,38 @@ namespace SmartScan.PlusSettingFrm
if (deg > 360)
deg = deg - 360;
angle = ScanningCameraAngle(deg,0);
isbarcode = false;
LogUtil.info($"QR Code转换后角度,Angle:{Angle}, deg:{angle}");
Angle = angle;
}
else if (codeType.StartsWith("Data Matrix"))
{
angle = ScanningCameraAngle(Angle, 0);
int deg = Angle;
angle = ScanningCameraAngle(deg, 0);
isbarcode = false;
LogUtil.info($"Data Matrix转换后角度,Angle:{Angle}, deg:{angle}");
Angle = angle;
}
Angle = Angle + 270;
var dc1 = LabelingPosition.distance(LabelingPosition.PointWithAngle(lable, Angle, 50), centrality);
var dc2 = LabelingPosition.distance(LabelingPosition.PointWithAngle(lable, Angle + 180, 50), centrality);
//if (dc2 > dc1)
// Angle = Angle + 180;
if (Angle > 360)
Angle = Angle - 360;
LogUtil.info($"结合盘心计算后, dc1:{dc1}, dc2:{dc2}, deg:{Angle}");
//Angle = Angle + 270;
if (isbarcode)
{
var dc1 = LabelingPosition.distance(LabelingPosition.PointWithAngle(lable, Angle, 50), centrality);
var dc2 = LabelingPosition.distance(LabelingPosition.PointWithAngle(lable, Angle + 180, 50), centrality);
if (dc2 > dc1)
Angle = Angle + 180;
if (Angle > 360)
Angle = Angle - 360;
LogUtil.info($"结合盘心计算后, dc1:{dc1}, dc2:{dc2}, deg:{Angle}");
}
else
{
LogUtil.info($"二维码转换后角度, deg:{Angle}");
}
angle = Angle + 83 + labelangle;
angle = Angle + 83 + labelangle;
if (angle > 360)
angle = angle - 360;
if (angle > 360)
......@@ -356,13 +372,13 @@ namespace SmartScan.PlusSettingFrm
int rotationAngle = RotateAngle;// 83;
if (angles < 0)
{
angle = angles * -1 + rotationAngle;
angle = -1 * angles + rotationAngle;
}
else
{
angle = 360 - angles + rotationAngle;
}
angle += 90;
angle -= 90;
if (angle >= 360)
{
angle -= 360;
......
using BLL;
using Model;
using SmartScan.PlusSettingFrm;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
......@@ -24,6 +26,8 @@ namespace SmartScan
[STAThread]
static void Main(string[] args)
{
//UsrKeywordlabeling.Overwritelabel(new Point() { X = 2050, Y = 1770 },new Point() { X = 2678, Y = 1675 }, true, 0, 91, 0, 180, out int angle, "Data Matrix");
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.ThreadException += Application_ThreadException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
......
......@@ -238,6 +238,7 @@ namespace SmartScan
BLLCommon.mateEdit.CurrntBitmap = WebCallWork.DeepClone(image[0]);
if (!BLL.Config.Backgrounder)
picShow.Image = image[0];
Application.DoEvents();
if (BLLCommon.mateEdit.CurrntBitmap!=null)
_ = UnifiedDataHandler.PostSmfImageAsync(BLLCommon.mateEdit.CurrntBitmap, new Dictionary<string, string> { { "cid", BLLCommon.config.CID + "_1" } }, BLLCommon.mateEdit.CurrntBitmap.Width, BLLCommon.mateEdit.CurrntBitmap.Height);
}else
......@@ -272,6 +273,7 @@ namespace SmartScan
if (!BLL.Config.Backgrounder)
picShow.Image = bmp;
BLLCommon.mateEdit.CurrntBitmap = bmp;
Application.DoEvents();
});
return true;
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!