Commit b237d193 刘韬

SO1340 定制添加删除含有NA字样的条码

1 个父辈 9a16b822
...@@ -43,9 +43,9 @@ namespace AutoScanAndLabel ...@@ -43,9 +43,9 @@ namespace AutoScanAndLabel
this.tableLayoutPanel.ColumnCount = 2; this.tableLayoutPanel.ColumnCount = 2;
this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 12.98701F)); this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 12.98701F));
this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 87.01299F)); this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 87.01299F));
this.tableLayoutPanel.Controls.Add(this.labelCopyright, 1, 2);
this.tableLayoutPanel.Controls.Add(this.labelProductName, 1, 0); this.tableLayoutPanel.Controls.Add(this.labelProductName, 1, 0);
this.tableLayoutPanel.Controls.Add(this.labelVersion, 1, 1); this.tableLayoutPanel.Controls.Add(this.labelVersion, 1, 1);
this.tableLayoutPanel.Controls.Add(this.labelCopyright, 1, 2);
this.tableLayoutPanel.Controls.Add(this.labelCompanyName, 1, 3); this.tableLayoutPanel.Controls.Add(this.labelCompanyName, 1, 3);
this.tableLayoutPanel.Controls.Add(this.textBoxDescription, 1, 4); this.tableLayoutPanel.Controls.Add(this.textBoxDescription, 1, 4);
this.tableLayoutPanel.Controls.Add(this.okButton, 1, 5); this.tableLayoutPanel.Controls.Add(this.okButton, 1, 5);
...@@ -97,6 +97,7 @@ namespace AutoScanAndLabel ...@@ -97,6 +97,7 @@ namespace AutoScanAndLabel
this.labelCopyright.Name = "labelCopyright"; this.labelCopyright.Name = "labelCopyright";
this.labelCopyright.Size = new System.Drawing.Size(354, 16); this.labelCopyright.Size = new System.Drawing.Size(354, 16);
this.labelCopyright.TabIndex = 21; this.labelCopyright.TabIndex = 21;
this.labelCopyright.Tag = "not";
this.labelCopyright.Text = "版权"; this.labelCopyright.Text = "版权";
this.labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
// //
...@@ -124,6 +125,7 @@ namespace AutoScanAndLabel ...@@ -124,6 +125,7 @@ namespace AutoScanAndLabel
this.textBoxDescription.Size = new System.Drawing.Size(354, 116); this.textBoxDescription.Size = new System.Drawing.Size(354, 116);
this.textBoxDescription.TabIndex = 23; this.textBoxDescription.TabIndex = 23;
this.textBoxDescription.TabStop = false; this.textBoxDescription.TabStop = false;
this.textBoxDescription.Tag = "not";
this.textBoxDescription.Text = "说明"; this.textBoxDescription.Text = "说明";
// //
// okButton // okButton
......
...@@ -18,7 +18,7 @@ namespace AutoScanAndLabel ...@@ -18,7 +18,7 @@ namespace AutoScanAndLabel
this.Text = String.Format(crc.GetString("Res0001", "关于 {0}"), crc.GetString("App_Title", "自动贴标机")); this.Text = String.Format(crc.GetString("Res0001", "关于 {0}"), crc.GetString("App_Title", "自动贴标机"));
this.labelProductName.Text = AssemblyProduct; this.labelProductName.Text = AssemblyProduct;
this.labelVersion.Text = String.Format(crc.GetString("Res0002", "版本 {0}"), AssemblyVersion); this.labelVersion.Text = String.Format(crc.GetString("Res0002", "版本 {0}"), AssemblyVersion);
this.labelCopyright.Text = crc.GetString("Res0219", "版权 © 2021"); this.labelCopyright.Text = AssemblyCopyright;
this.labelCompanyName.Text = AssemblyCompany; this.labelCompanyName.Text = AssemblyCompany;
this.textBoxDescription.Text = AssemblyDescription; this.textBoxDescription.Text = AssemblyDescription;
} }
...@@ -63,10 +63,10 @@ namespace AutoScanAndLabel ...@@ -63,10 +63,10 @@ namespace AutoScanAndLabel
{ {
int days = Convert.ToInt32(strArray[2]); int days = Convert.ToInt32(strArray[2]);
int seconds = Convert.ToInt32(strArray[3]); int seconds = Convert.ToInt32(strArray[3]);
DateTime d1 = DateTime.Parse("2024-06-06"); DateTime d1 = DateTime.Parse("2000-01-01");
//var newData = d1.AddDays(days); var newData = d1.AddDays(days);
//newData = newData.AddSeconds(seconds * 2); newData = newData.AddSeconds(seconds * 2);
updatetime = $"{crc.GetString("Res0220", "最后更新时间:")}" + d1.ToString("yyyy-MM-dd HH:mm:ss"); updatetime = $"{crc.GetString("Res0220", "最后更新时间:")}" + newData.ToString("yyyy-MM-dd HH:mm:ss");
} }
if (attributes.Length == 0) if (attributes.Length == 0)
......
...@@ -73,6 +73,7 @@ namespace AutoScanAndLabel ...@@ -73,6 +73,7 @@ namespace AutoScanAndLabel
} }
Environment.CurrentDirectory = Application.StartupPath; Environment.CurrentDirectory = Application.StartupPath;
XmlConfigurator.Configure(); XmlConfigurator.Configure();
Config.LoadMyConfig(typeof(Setting_Init));
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); Application.Run(new Form1());
......
...@@ -10,7 +10,7 @@ using System.Runtime.InteropServices; ...@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Neotel")] [assembly: AssemblyCompany("Neotel")]
[assembly: AssemblyProduct("NS200")] [assembly: AssemblyProduct("NS200")]
[assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
......
using System; using ConfigHelper;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
...@@ -74,5 +75,14 @@ namespace OnlineStore.Common ...@@ -74,5 +75,14 @@ namespace OnlineStore.Common
public static string SMB_StorageUnitValue = "SMB_StorageUnitValue"; public static string SMB_StorageUnitValue = "SMB_StorageUnitValue";
[MyConfigComment("设备项目号")]
public static MyConfig<Procjet_NO> ProcjetNO = Procjet_NO.General;
}
public enum Procjet_NO
{
General,
SO1340
} }
} }
using CodeLibrary;
using ConfigHelper;
using Newtonsoft.Json;
using OnlineStore.Common; using OnlineStore.Common;
using OnlineStore.Common.util;
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.Runtime.ExceptionServices; using System.Runtime.ExceptionServices;
using System.Text;
using System.Windows.Forms;
using CodeLibrary;
using System.Drawing.Imaging;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Windows.Forms;
using ConfigHelper;
using System.Reflection.Emit;
using static RemoteDecodeHelper_mod; using static RemoteDecodeHelper_mod;
using System.Web;
using log4net;
using OnlineStore.Common.util;
using Newtonsoft.Json;
namespace DeviceLibrary namespace DeviceLibrary
{ {
...@@ -53,7 +48,7 @@ namespace DeviceLibrary ...@@ -53,7 +48,7 @@ namespace DeviceLibrary
} }
LoadCamera(false); LoadCamera(false);
iscode= Config.Get<bool>("isStartscanningcode", true); iscode = Config.Get<bool>("isStartscanningcode", true);
LogUtil.info("加载到扫码相机"); LogUtil.info("加载到扫码相机");
if (!iscode) if (!iscode)
{ {
...@@ -143,7 +138,7 @@ namespace DeviceLibrary ...@@ -143,7 +138,7 @@ namespace DeviceLibrary
} }
[HandleProcessCorruptedStateExceptions] [HandleProcessCorruptedStateExceptions]
public static (List<CodeInfo>, Dictionary<string, string>, string, Dictionary<string, int>) CameraScan(List<string> cameraNameList,int PlateW) public static (List<CodeInfo>, Dictionary<string, string>, string, Dictionary<string, int>) CameraScan(List<string> cameraNameList, int PlateW)
{ {
List<CodeInfo> codeList = new List<CodeInfo>(); List<CodeInfo> codeList = new List<CodeInfo>();
Dictionary<string, string> keyword = new Dictionary<string, string>(); Dictionary<string, string> keyword = new Dictionary<string, string>();
...@@ -174,11 +169,11 @@ namespace DeviceLibrary ...@@ -174,11 +169,11 @@ namespace DeviceLibrary
_ = Camera._cam.CaptureOnImage(cameraName, out bmp, out List<CodeInfo> codes, nohalcon); _ = Camera._cam.CaptureOnImage(cameraName, out bmp, out List<CodeInfo> codes, nohalcon);
if (bmp == null) if (bmp == null)
{ {
LogUtil.error(" 【" + cameraName + "】取图片失败[" + Camera._cam.ErrInfo + "],关闭相机,重试:"+ retry); LogUtil.error(" 【" + cameraName + "】取图片失败[" + Camera._cam.ErrInfo + "],关闭相机,重试:" + retry);
Camera._cam.CloseAll(); Camera._cam.CloseAll();
//LoadCamera(true); //LoadCamera(true);
retry++; retry++;
if (retry>2) if (retry > 2)
continue; continue;
goto retry; goto retry;
} }
...@@ -186,15 +181,26 @@ namespace DeviceLibrary ...@@ -186,15 +181,26 @@ namespace DeviceLibrary
WebResultCode webResult = null; WebResultCode webResult = null;
if (iscode) if (iscode)
{ {
if (codes.Count==0) if (codes.Count == 0)
{ {
//throw new FileNotFoundException("扫码相机未扫描到任何条码!"); //throw new FileNotFoundException("扫码相机未扫描到任何条码!");
LogUtil.error("扫码相机未扫描到任何条码!"); LogUtil.error("扫码相机未扫描到任何条码!");
return (codeList, keyword, bitmapfilename, newpointanlge); return (codeList, keyword, bitmapfilename, newpointanlge);
} }
LogUtil.info("识别条码为:" + JsonConvert.SerializeObject(codes)); LogUtil.info("识别条码为:" + JsonConvert.SerializeObject(codes));
if (Setting_Init.ProcjetNO == Procjet_NO.SO1340)
{
var rc = codes.RemoveAll(c =>
{
var ss = c.CodeStr.Count(cs => cs == ';');
return (ss == 9 || ss == 10) && c.CodeStr.Contains(";NA;");
});
LogUtil.info($"SO1340 删除NA后条码 count:{rc} :" + JsonConvert.SerializeObject(codes));
}
LogUtil.info($"开始请求ns100服务"); LogUtil.info($"开始请求ns100服务");
webResult =NeoSacnRequest(BitmapToBase64(bmp), codes, PlateW, RobotManage.Config.Right_Batch_X, RobotManage.Config.Right_Batch_Y); webResult = NeoSacnRequest(BitmapToBase64(bmp), codes, PlateW, RobotManage.Config.Right_Batch_X, RobotManage.Config.Right_Batch_Y);
} }
else else
{ {
...@@ -233,20 +239,20 @@ namespace DeviceLibrary ...@@ -233,20 +239,20 @@ namespace DeviceLibrary
} }
} }
newpointanlge.Add("PointX",webResult.positionAngle.X); newpointanlge.Add("PointX", webResult.positionAngle.X);
newpointanlge.Add("PointY", webResult.positionAngle.Y); newpointanlge.Add("PointY", webResult.positionAngle.Y);
newpointanlge.Add("Angle", webResult.positionAngle.Angle); newpointanlge.Add("Angle", webResult.positionAngle.Angle);
if (webResult.positionAngle.IsCodeUsed!=null) if (webResult.positionAngle.IsCodeUsed != null)
{ {
newpointanlge.Add("IsCodeUsed", Array.FindIndex(webResult.positionAngle.IsCodeUsed, x => x)); ; newpointanlge.Add("IsCodeUsed", Array.FindIndex(webResult.positionAngle.IsCodeUsed, x => x)); ;
} }
LogUtil.info($"贴标数据X={webResult.positionAngle.X};Y={webResult.positionAngle.Y};角度={webResult.positionAngle.Angle}"); LogUtil.info($"贴标数据X={webResult.positionAngle.X};Y={webResult.positionAngle.Y};角度={webResult.positionAngle.Angle}");
if (bmp!=null) if (bmp != null)
{ {
string cid = ConfigHelper.Config.Get("CID"); string cid = ConfigHelper.Config.Get("CID");
_ = UnifiedDataHandler.PostSmfImageAsync(bmp,new Dictionary<string, string> { { "cid", cid+"_1" } }); _ = UnifiedDataHandler.PostSmfImageAsync(bmp, new Dictionary<string, string> { { "cid", cid + "_1" } });
} }
LogUtil.info(" 【" + cameraName + "】" + " 扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】" ); LogUtil.info(" 【" + cameraName + "】" + " 扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】");
} }
} }
catch (AccessViolationException e) catch (AccessViolationException e)
...@@ -269,11 +275,11 @@ namespace DeviceLibrary ...@@ -269,11 +275,11 @@ namespace DeviceLibrary
} }
catch (AccessViolationException e) catch (AccessViolationException e)
{ {
LogUtil.error( " 扫码出现AccessViolationException异常:" + e.ToString()); LogUtil.error(" 扫码出现AccessViolationException异常:" + e.ToString());
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error( " 扫码出错:" + ex.ToString()); LogUtil.error(" 扫码出错:" + ex.ToString());
} }
return (codeList, keyword, bitmapfilename, newpointanlge); return (codeList, keyword, bitmapfilename, newpointanlge);
} }
...@@ -349,7 +355,8 @@ namespace DeviceLibrary ...@@ -349,7 +355,8 @@ namespace DeviceLibrary
/// <param name="pX"></param> /// <param name="pX"></param>
/// <param name="pY"></param> /// <param name="pY"></param>
/// <returns>x,y</returns> /// <returns>x,y</returns>
static (int, int) PointRoate270(int imgWidth, int imgHeight, int pX, int pY) { static (int, int) PointRoate270(int imgWidth, int imgHeight, int pX, int pY)
{
int x = pY; int x = pY;
int y = imgWidth - pX; int y = imgWidth - pX;
return (x, y); return (x, y);
...@@ -357,7 +364,7 @@ namespace DeviceLibrary ...@@ -357,7 +364,7 @@ namespace DeviceLibrary
private static string SaveImageToFile(string deviceName, string cameraName, Bitmap bitmap) private static string SaveImageToFile(string deviceName, string cameraName, Bitmap bitmap)
{ {
string date = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + DateTime.Now.Millisecond; string date = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + DateTime.Now.Millisecond;
string dire = Application.StartupPath+@"\image\" + deviceName.Trim().Replace('_', '-') + @"\" + cameraName.Trim().Replace('_', '-').Replace(':', '-') + @"\"; string dire = Application.StartupPath + @"\image\" + deviceName.Trim().Replace('_', '-') + @"\" + cameraName.Trim().Replace('_', '-').Replace(':', '-') + @"\";
string iamgeName = date + ".bmp"; string iamgeName = date + ".bmp";
try try
{ {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!