Commit 32e31c7f 贾鹏旭

1

1 个父辈 4426c22f
...@@ -8,6 +8,7 @@ using Asa.FaceControl; ...@@ -8,6 +8,7 @@ using Asa.FaceControl;
using Model; using Model;
using System.Windows.Forms; using System.Windows.Forms;
using DocumentFormat.OpenXml.Drawing; using DocumentFormat.OpenXml.Drawing;
using DocumentFormat.OpenXml.Spreadsheet;
namespace BLL namespace BLL
{ {
...@@ -124,8 +125,15 @@ namespace BLL ...@@ -124,8 +125,15 @@ namespace BLL
} }
}, },
}; };
Dictionary<string, object> R = new() { Dictionary<string, object> R;
{ "Type", "TextBox" }, bool isdis = ConfigHelper.Config.Get<bool>("DataSource_ShowBox",false);
string type = "TextBox";
if (key==Config.DataSource_DataTitle&&isdis)
{
type = "ComboBox";
}
R = new() {
{ "Type", type },
{ "Key", key }, { "Key", key },
{ "LinkName", key }, { "LinkName", key },
{ "CanClear", "True" }, { "CanClear", "True" },
...@@ -258,7 +266,10 @@ namespace BLL ...@@ -258,7 +266,10 @@ namespace BLL
} }
ctlY = startPoint.Y; ctlY = startPoint.Y;
for (int i = 0; i < rows.Length; i++) for (int i = 0; i < rows.Length; i++)
{
LoadRow(rows[i]); LoadRow(rows[i]);
}
currentExtension.Load(ctlGroup); currentExtension.Load(ctlGroup);
} }
...@@ -300,7 +311,7 @@ namespace BLL ...@@ -300,7 +311,7 @@ namespace BLL
{ {
Dictionary<string, object> dic = (Dictionary<string, object>)cols[i]; Dictionary<string, object> dic = (Dictionary<string, object>)cols[i];
if (!dic.ContainsKey("Type")) continue; if (!dic.ContainsKey("Type")) continue;
ControlBase ctl = dicControls[dic["Type"].ToString()].Invoke(); ControlBase ctl = dicControls[dic["Type"].ToString()].Invoke();
ctl.Location = new System.Drawing.Point(ctlX, ctlY); ctl.Location = new System.Drawing.Point(ctlX, ctlY);
panel.Controls.Add(ctl); panel.Controls.Add(ctl);
...@@ -339,7 +350,7 @@ namespace BLL ...@@ -339,7 +350,7 @@ namespace BLL
PropertyInfo info = type.GetProperty(key); PropertyInfo info = type.GetProperty(key);
if (info == null) continue; if (info == null) continue;
dicControlAttribute[info.PropertyType].Invoke(info, ctl, att[key]); dicControlAttribute[info.PropertyType].Invoke(info, ctl, att[key]);
} }
} }
private void LoadEvent(ControlBase ctl, Dictionary<string, object> att) private void LoadEvent(ControlBase ctl, Dictionary<string, object> att)
......
...@@ -71,7 +71,7 @@ namespace BLL ...@@ -71,7 +71,7 @@ namespace BLL
public void Load(List<ExtensionControl> extensions) public void Load(List<ExtensionControl> extensions)
{ {
this.extensions = extensions; this.extensions = extensions;
} }
static bool mesResult = false; static bool mesResult = false;
...@@ -94,7 +94,25 @@ namespace BLL ...@@ -94,7 +94,25 @@ namespace BLL
} }
} }
Application.DoEvents(); Application.DoEvents();
if (!string.IsNullOrEmpty(config.ReelIDKeyWord))
#region 判断指定关键字是否存在内容
bool isdisplay = true;
string str = ConfigHelper.Config.Get("DataSource_ForceMatching", "");
if (!string.IsNullOrWhiteSpace(str))
{
string[] arr = str.Split(',');
foreach (var item in arr)
{
key.TryGetValue(item, out string value);
if (string.IsNullOrEmpty(value))
{
isdisplay = false;
break;
}
}
}
#endregion
if (!string.IsNullOrEmpty(config.ReelIDKeyWord)&&isdisplay)
{ {
var Reelidstr = GetReelid(); var Reelidstr = GetReelid();
if (key.ContainsKey(config.ReelIDKeyWord)) if (key.ContainsKey(config.ReelIDKeyWord))
...@@ -139,6 +157,16 @@ namespace BLL ...@@ -139,6 +157,16 @@ namespace BLL
//第二次刷新界面 //第二次刷新界面
for (int i = 0; i < extensions.Count; i++) for (int i = 0; i < extensions.Count; i++)
{ {
#region 如果是下拉框加载内容
if (extensions[i].Type == "ComboBox")
{
var s = extensions[i].Control as Asa.FaceControl.FaceComboBox;
s.Items.AddRange(ExtraFileData.DataTitle.OrderBy(tit=>tit).ToArray());
s.Text = "";
s.SelectedIndex = -1;
s.Enabled = true;
}
#endregion
extensions[i].Control.ForeColor = System.Drawing.Color.White; extensions[i].Control.ForeColor = System.Drawing.Color.White;
if (key.ContainsKey(extensions[i].Key)) if (key.ContainsKey(extensions[i].Key))
{ {
...@@ -243,13 +271,15 @@ namespace BLL ...@@ -243,13 +271,15 @@ namespace BLL
} }
continue; continue;
} }
if (extensions!=null) if (extensions != null)
{ {
int index = extensions.FindIndex(match => match.Key == keys[i]); int index = extensions.FindIndex(match => match.Key == keys[i]);
if (index == -1) continue; if (index == -1) continue;
string oldValue = string.Format("[{0}]", keys[i]); string oldValue = string.Format("[{0}]", keys[i]);
matchID = matchID.Replace(oldValue, extensions[index].Control.Text); //matchID = matchID.Replace(oldValue, extensions[index].Control.Text);
}
matchID = matchID.Replace(oldValue, "");
}
} }
//SaveAddReelID(); //SaveAddReelID();
var reelID = ReadReelID(); var reelID = ReadReelID();
...@@ -311,16 +341,56 @@ namespace BLL ...@@ -311,16 +341,56 @@ namespace BLL
{ {
LogNet.log.Debug("Enter PrintLabel Method"); LogNet.log.Debug("Enter PrintLabel Method");
if (lastkey == null) return; if (lastkey == null) return;
//Dictionary<string, string> key = new();
for (int i = 0; i < extensions.Count; i++) for (int i = 0; i < extensions.Count; i++)
{ {
if (extensions[i].Key == "") continue; if (extensions[i].Key == "") continue;
if (lastkey.ContainsKey(extensions[i].Key)) if (lastkey.ContainsKey(extensions[i].Key))
lastkey[extensions[i].Key] = extensions[i].Control.Text; lastkey[extensions[i].Key] = extensions[i].Control.Text;
else else
lastkey.Add(extensions[i].Key, extensions[i].Control.Text); lastkey.Add(extensions[i].Key, extensions[i].Control.Text);
} }
#region 判断指定关键字是否存在内容
List<string> strings = new List<string>();
string str = ConfigHelper.Config.Get("DataSource_ForceMatching", "");
if (!string.IsNullOrWhiteSpace(str))
{
string[] arr = str.Split(',');
foreach (var item in arr)
{
lastkey.TryGetValue(item, out string value);
if (string.IsNullOrEmpty(value))
{
strings.Add(item);
}
}
}
#endregion
for (int i = 0; i < extensions.Count; i++)
{
if (strings.Contains(extensions[i].Key))
{
extensions[i].Control.BackColor = System.Drawing.Color.Red;
return;
}
}
#region 点击打印按钮,rid内容为空时,生成rid
if (!string.IsNullOrEmpty(config.ReelIDKeyWord))
{
if (lastkey.ContainsKey(config.ReelIDKeyWord))
{
string rid = lastkey[config.ReelIDKeyWord];
if (string.IsNullOrWhiteSpace(rid))
{
var Reelidstr = GetReelid();
lastkey[config.ReelIDKeyWord] = Reelidstr;
}
}
}
#endregion
Printing?.Invoke(lastkey); Printing?.Invoke(lastkey);
bool close = ConfigHelper.Config.Get("isprinclose", false); bool close = ConfigHelper.Config.Get("isprinclose", false);
if (close) if (close)
...@@ -334,6 +404,10 @@ namespace BLL ...@@ -334,6 +404,10 @@ namespace BLL
} }
//进行追溯配置保存 //进行追溯配置保存
SaveRetrospect?.Invoke(lastkey); SaveRetrospect?.Invoke(lastkey);
for (int i = 0; i < extensions.Count; i++)
{
extensions[i].Control.BackColor = System.Drawing.Color.FromArgb(255, 20, 20, 20);
}
} }
/// <summary> /// <summary>
/// ///
......
...@@ -14,6 +14,8 @@ namespace BLL ...@@ -14,6 +14,8 @@ namespace BLL
{ {
public static Dictionary<string, Dictionary<string, string>> AllData = new Dictionary<string, Dictionary<string, string>>(); public static Dictionary<string, Dictionary<string, string>> AllData = new Dictionary<string, Dictionary<string, string>>();
public static List<string> Titles = new List<string>(); public static List<string> Titles = new List<string>();
public static List<string> DataTitle = new List<string>();
public static void Init() { public static void Init() {
var ext = Path.GetExtension(Config.DataSource_FilePath); var ext = Path.GetExtension(Config.DataSource_FilePath);
if (string.IsNullOrEmpty(ext)) if (string.IsNullOrEmpty(ext))
...@@ -75,7 +77,11 @@ namespace BLL ...@@ -75,7 +77,11 @@ namespace BLL
} }
} }
if (!string.IsNullOrEmpty(keydata) && !AllData.ContainsKey(keydata)) if (!string.IsNullOrEmpty(keydata) && !AllData.ContainsKey(keydata))
{
AllData.Add(keydata, rowdata); AllData.Add(keydata, rowdata);
DataTitle.Add(keydata);
}
} }
} }
catch(Exception ex) { catch(Exception ex) {
...@@ -142,7 +148,10 @@ namespace BLL ...@@ -142,7 +148,10 @@ namespace BLL
} }
} }
if (!string.IsNullOrEmpty(keydata) && !AllData.ContainsKey(keydata)) if (!string.IsNullOrEmpty(keydata) && !AllData.ContainsKey(keydata))
{
AllData.Add(keydata, rowdata); AllData.Add(keydata, rowdata);
DataTitle.Add(keydata);
}
if (string.IsNullOrEmpty(keydata)) if (string.IsNullOrEmpty(keydata))
emptyrow++; emptyrow++;
......
...@@ -151,13 +151,17 @@ namespace BLL ...@@ -151,13 +151,17 @@ namespace BLL
MatchAnalysis.StartNewAnalysis(code); MatchAnalysis.StartNewAnalysis(code);
if (Config.Func_EnabledOCR) if (Config.Func_EnabledOCR)
{ {
Bitmap bitmaps =new Bitmap(CurrntBitmap); //LogNet.log.Info($"开始加载图片");
//Bitmap bitmaps = new Bitmap(CurrntBitmap);
//LogNet.log.Info($"加载结束图片");
//保存需要识别ocr的区域 //保存需要识别ocr的区域
//CurrntBitmap?.Save(@"ocr.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
string currentDirectory = System.Windows.Forms.Application.StartupPath; string currentDirectory = System.Windows.Forms.Application.StartupPath;
string filePath = System.IO.Path.Combine(currentDirectory, "ocr.jpg"); string filePath = System.IO.Path.Combine(currentDirectory, "ocr.jpg");
//CurrntBitmap?.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg); //CurrntBitmap?.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
bitmaps?.Save(filePath); LogNet.log.Info($"开始保存图片");
CurrntBitmap?.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
LogNet.log.Info($"保存图片");
regOcrCodes = OcrRecognize($"{currentDirectory}\\ocr.jpg"); regOcrCodes = OcrRecognize($"{currentDirectory}\\ocr.jpg");
LogNet.log.Info($"保存地址:{filePath};获取地址:{currentDirectory}\\ocr.jpg"); LogNet.log.Info($"保存地址:{filePath};获取地址:{currentDirectory}\\ocr.jpg");
LogNet.log.Info($"OCR 识别结果:{regOcrCodes}"); LogNet.log.Info($"OCR 识别结果:{regOcrCodes}");
...@@ -389,7 +393,7 @@ namespace BLL ...@@ -389,7 +393,7 @@ namespace BLL
xmlDoc.Save(temp.FilePath); xmlDoc.Save(temp.FilePath);
temp.State = TemplateState.Saved; temp.State = TemplateState.Saved;
} }
private bool TemplateExtract(int index, List<BarcodeInfo> code, out Dictionary<string, string> keyword, out AMatch aMatch) private bool TemplateExtract(int index, List<BarcodeInfo> code, out Dictionary<string, string> keyword, out AMatch aMatch)
{ {
......
...@@ -330,7 +330,11 @@ namespace BLL ...@@ -330,7 +330,11 @@ namespace BLL
{ {
barCode = null; barCode = null;
int index = labelTemp.FindIndex(match => match.Name == labelName); int index = labelTemp.FindIndex(match => match.Name == labelName);
if (index == -1) return; if (index == -1)
{
LogNet.log.Info("未找到标签!");
return;
}
SizeF sf; SizeF sf;
barCode = new string[labelTemp[index].Field.Count]; barCode = new string[labelTemp[index].Field.Count];
...@@ -360,7 +364,6 @@ namespace BLL ...@@ -360,7 +364,6 @@ namespace BLL
print.PrintPage += PrintLast_PrintPage; print.PrintPage += PrintLast_PrintPage;
interimLabel = labelTemp[index]; interimLabel = labelTemp[index];
print.Print(); print.Print();
} }
//==================================== //====================================
......
...@@ -308,12 +308,12 @@ namespace SmartScan ...@@ -308,12 +308,12 @@ namespace SmartScan
private Asa.FaceControl.FaceButton BtnTriggerIO; private Asa.FaceControl.FaceButton BtnTriggerIO;
private Asa.FaceControl.FaceLabel LblCameraExist; private Asa.FaceControl.FaceLabel LblCameraExist;
private Asa.FaceControl.FaceLabel LblIOExist; private Asa.FaceControl.FaceLabel LblIOExist;
private Asa.FaceControl.FacePictureBox PicShow;
private Asa.FaceControl.FacePanel PnlExtension; private Asa.FaceControl.FacePanel PnlExtension;
private Asa.FaceControl.FaceComboBox CboLanguage; private Asa.FaceControl.FaceComboBox CboLanguage;
private Asa.FaceControl.FaceButton BtnMatchedName; private Asa.FaceControl.FaceButton BtnMatchedName;
private Asa.FaceControl.FaceLabel LblVersion; private Asa.FaceControl.FaceLabel LblVersion;
private Asa.FaceControl.FaceLabel LblUserName; private Asa.FaceControl.FaceLabel LblUserName;
public Asa.FaceControl.FacePictureBox PicShow;
} }
} }
...@@ -250,6 +250,7 @@ namespace SmartScan ...@@ -250,6 +250,7 @@ namespace SmartScan
BtnSet.Enabled = BLLCommon.config.UserLevel == UserLevel.Admin; BtnSet.Enabled = BLLCommon.config.UserLevel == UserLevel.Admin;
FrmRetrospect.Print += Extension_Printing; FrmRetrospect.Print += Extension_Printing;
UsrWorkMode.Printing += Extension_Printing;
//扩展面板 //扩展面板
PnlExtension.Width = BLLCommon.config.ExtensionWidth; PnlExtension.Width = BLLCommon.config.ExtensionWidth;
PnlExtension.Left = Width - PnlExtension.Width - 12; PnlExtension.Left = Width - PnlExtension.Width - 12;
......
...@@ -229,6 +229,7 @@ namespace SmartScan ...@@ -229,6 +229,7 @@ namespace SmartScan
// FrmSetPlus // FrmSetPlus
// //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.AutoSize = true;
this.ClientSize = new System.Drawing.Size(1293, 788); this.ClientSize = new System.Drawing.Size(1293, 788);
this.Controls.Add(this.but_Labeling); this.Controls.Add(this.but_Labeling);
this.Controls.Add(this.Keywordlabeling); this.Controls.Add(this.Keywordlabeling);
......
...@@ -17,8 +17,8 @@ namespace SmartScan ...@@ -17,8 +17,8 @@ namespace SmartScan
//Language.SetLanguage(this); //Language.SetLanguage(this);
this.SizeChanged += FrmSetPlus_SizeChanged; this.SizeChanged += FrmSetPlus_SizeChanged;
this.FormClosing += FrmSetPlus_FormClosing; this.FormClosing += FrmSetPlus_FormClosing;
this.Width = 1024; //this.Width = 1024;
this.Height = 738; //this.Height = 738;
this.Top = 15; this.Top = 15;
this.Left = 0; this.Left = 0;
WebService.Open();//启动条码匹配服务 WebService.Open();//启动条码匹配服务
......
...@@ -229,7 +229,7 @@ namespace SmartScan ...@@ -229,7 +229,7 @@ namespace SmartScan
if (BLLCommon.config.TriggerOpenLight) if (BLLCommon.config.TriggerOpenLight)
{ {
BLLCommon.lightSource.TurnOn(); BLLCommon.lightSource.TurnOn();
System.Threading.Thread.Sleep(2000); //光源打开有一个由暗变亮的过程 System.Threading.Thread.Sleep(100); //光源打开有一个由暗变亮的过程
} }
List<Bitmap> image = new List<Bitmap>(Camera.CaptureAndGetCode(out workCodeInfo)); List<Bitmap> image = new List<Bitmap>(Camera.CaptureAndGetCode(out workCodeInfo));
if (image.Count > 0 && !BLL.Config.Backgrounder) picShow.Image = image[0]; if (image.Count > 0 && !BLL.Config.Backgrounder) picShow.Image = image[0];
...@@ -332,9 +332,8 @@ namespace SmartScan ...@@ -332,9 +332,8 @@ namespace SmartScan
private void SetKey(bool hasMatch) private void SetKey(bool hasMatch)
{ {
LogNet.log.Info("Work SetKey hasMatch:" + hasMatch); LogNet.log.Info("Work SetKey hasMatch:" + hasMatch);
if (workCodeKeyword.Count == 0) return; //if (workCodeKeyword.Count == 0){ return;}
BLLCommon.extension.SetKey(originalCodeText, workCodeKeyword, hasMatch, out _); BLLCommon.extension.SetKey(originalCodeText, workCodeKeyword, hasMatch, out _);
//if (workCodeKeyword.Count == 0) return;放前面执行
if (workCodeKeyword.Any(a => a.Value.StartsWith("<OCR>"))) if (workCodeKeyword.Any(a => a.Value.StartsWith("<OCR>")))
{ {
BLLCommon.extension.DrawTextBackground(workCodeKeyword); BLLCommon.extension.DrawTextBackground(workCodeKeyword);
......
...@@ -176,6 +176,6 @@ namespace SmartScan ...@@ -176,6 +176,6 @@ namespace SmartScan
{ {
string key = "[datetime:yyyyMMddHHmmss]"; string key = "[datetime:yyyyMMddHHmmss]";
TxtReelIDMatch.AppendText(key); TxtReelIDMatch.AppendText(key);
} }
} }
} }
...@@ -183,15 +183,28 @@ namespace SmartScan ...@@ -183,15 +183,28 @@ namespace SmartScan
if (System.IO.File.Exists(iamgepath)) if (System.IO.File.Exists(iamgepath))
{ {
ImgShow.Image = ObjConversion.ReadImageFile(iamgepath); ImgShow.Image = ObjConversion.ReadImageFile(iamgepath);
//ImgShow.Image = mateCopy[mateIndex].Image;
ImgShow.CodeCenterClear();
ImgShow.AddCodeCenter(LabelCenter());
LstCode.Items.Clear();
LstCode.Items.AddRange(FormatCode());
LstCode.SelectedIndex = -1;
bmp = ImgShow.Image;
}
else
{
ImgShow.Image = null;
ImgShow.CodeCenterClear();
LstCode.Items.Clear();
} }
} }
//ImgShow.Image = mateCopy[mateIndex].Image; else
ImgShow.CodeCenterClear(); {
ImgShow.AddCodeCenter(LabelCenter()); ImgShow.Image = null;
LstCode.Items.Clear(); ImgShow.CodeCenterClear();
LstCode.Items.AddRange(FormatCode()); LstCode.Items.Clear();
LstCode.SelectedIndex = -1; }
bmp = ImgShow.Image;
} }
private void BtnAddMate_Click(object sender, EventArgs e) private void BtnAddMate_Click(object sender, EventArgs e)
...@@ -514,6 +527,7 @@ namespace SmartScan ...@@ -514,6 +527,7 @@ namespace SmartScan
} }
private void BtnOcrCode_Click_1(object sender, EventArgs e) private void BtnOcrCode_Click_1(object sender, EventArgs e)
{ {
if (bmp == null) return; if (bmp == null) return;
LstCode.Items.Clear(); LstCode.Items.Clear();
//保存需要识别ocr的区域 //保存需要识别ocr的区域
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using Asa.FaceControl; using Asa.FaceControl;
using BLL; using BLL;
using ClosedXML.Excel;
using Model; using Model;
namespace SmartScan namespace SmartScan
...@@ -106,5 +110,73 @@ namespace SmartScan ...@@ -106,5 +110,73 @@ namespace SmartScan
BLLCommon.config.Save(); BLLCommon.config.Save();
} }
int i = 0;
private void but_Readfileprint_Click(object sender, EventArgs e)
{
Dictionary<int, Dictionary<string, string>> valuePairs = new Dictionary<int, Dictionary<string, string>>();
i++;
if (i==10)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Multiselect =false;
openFileDialog.Title = "请选择文件";
openFileDialog.Filter = "所有文件(*.*)|*.*";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string file=openFileDialog.FileName;
ContinuousPrinting(file);
}
i = 0;
}
}
public delegate void PrintDelegate(Dictionary<string, string> content);
public static event PrintDelegate Printing;
public void ContinuousPrinting(string filepath)
{
Dictionary<int, Dictionary<string, string>> valuePairs = new Dictionary<int, Dictionary<string, string>>();
if (!File.Exists(filepath))
{
MessageBox.Show("文件不存在");
return;
}
var Titles = ExtraFileData.ParseXLSFileTitle(filepath);
try
{
XLWorkbook wb = new XLWorkbook(filepath);
IXLWorksheet ws = wb.Worksheet(1);
int emptyrow = 0;
int currow = 1;
while (emptyrow < 3)
{
var rowdata = new Dictionary<string, string>();
for (int i = 0; i < Titles.Count; i++)
{
var v = ws.Row(currow + 1).Cell(i + 1).Value.ToString().Trim();
rowdata.Add(Titles[i], v);
}
currow++;
if (!valuePairs.ContainsKey(currow))
{
valuePairs.Add(currow, rowdata);
}
if (rowdata.Values.Contains(""))
{
emptyrow++;
}
}
}
catch (Exception ex)
{
LogNet.log.Info("数据源加载文件出错:" + ex.ToString());
}
foreach (var item in valuePairs)
{
Printing?.Invoke(item.Value);
}
}
} }
} }
...@@ -197,6 +197,7 @@ namespace SmartScan ...@@ -197,6 +197,7 @@ namespace SmartScan
bool rtn = BLLCommon.mateEdit.MatchingTemplate(workCodeInfo, BLLCommon.config.DefaultMaterialName, false, out string mateName, out workCodeKeyword, out AMatch aMatch); bool rtn = BLLCommon.mateEdit.MatchingTemplate(workCodeInfo, BLLCommon.config.DefaultMaterialName, false, out string mateName, out workCodeKeyword, out AMatch aMatch);
var point=new Point(-1,-1); var point=new Point(-1,-1);
int angle = 0; int angle = 0;
LogNet.log.Info("模板匹配结果:" + rtn);
if (rtn) if (rtn)
{ {
string key = ConfigHelper.Config.Get("Label_Key", ""); string key = ConfigHelper.Config.Get("Label_Key", "");
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!