From bfdb25c51958e6458fdbe5b3b2c0040a803ce4ef Mon Sep 17 00:00:00 2001
From: quanzhou <quan.zhou@broconcentric.com>
Date: 星期五, 09 一月 2026 17:17:43 +0800
Subject: [PATCH] 修改mes篮具扫码确认收到单号才修改产品单号,以及S9打印条码与plc的交互完成信号
---
src/Bro.M141.Process/M141Process.cs | 561 ++++++++++++++++++++++++++++++++------------------------
1 files changed, 320 insertions(+), 241 deletions(-)
diff --git a/src/Bro.M141.Process/M141Process.cs b/src/Bro.M141.Process/M141Process.cs
index 4c0649f..f5dc4c0 100644
--- a/src/Bro.M141.Process/M141Process.cs
+++ b/src/Bro.M141.Process/M141Process.cs
@@ -25,11 +25,14 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing.Imaging;
+using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Text;
using Windows.ApplicationModel.Appointments;
+using Windows.Devices.PointOfService;
using ZXing;
+using ZXing.QrCode;
using static Bro.Common.Helper.EnumHelper;
using static Bro.Process.ProcessControl;
using static Org.BouncyCastle.Math.EC.ECCurve;
@@ -80,6 +83,8 @@
ThHeartPlc.IsBackground = true;
ThHeartPlc.Start();
}
+
+ printDocument1.PrintPage += new PrintPageEventHandler(printDocument_Print);
}
public override void ProcessRunStateChanged()
@@ -98,6 +103,7 @@
public PLCBase Plc1;
bool devicestate = false;
PLCBase Plc2;
+ public PLCBase Plc3;
public Thread ThHeartPlc;
public RabbitMQHelper mqtt;
@@ -122,6 +128,8 @@
}
_errorSpec = M141Config.SpecCollection.FirstOrDefault(u => u.Code == M141Config.CheckErrorSpecCode) as Spec;
+
+
//InitialProductList();
NetWarmUp();
@@ -138,8 +146,12 @@
mqtt = new RabbitMQHelper(M141Config.zIP, M141Config.zport, M141Config.zuser, M141Config.zpassword);
mqtt.Connect(M141Config.MESchannel);
}
+ else
+ {
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"宸插叧闂笂浼爉es");
+ }
- InitialContinuousNGAlarm();
+ InitialContinuousNGAlarm();
}
@@ -191,6 +203,7 @@
Dictionary<string, List<int>> StateDIC = new Dictionary<string, List<int>>();
List<string> AlarmTypeList = new List<string>();
+
int numplc = 0;
while (true)
@@ -235,18 +248,18 @@
// numsum = 0;
- // using (FileStream fileStream = new FileStream(_statisticFilePath, FileMode.OpenOrCreate, FileAccess.Write))
- // {
- // fileStream.Seek(0L, SeekOrigin.Begin);
- // string s = JsonConvert.SerializeObject(StatisticRecordsFull);
- // byte[] bytes = Encoding.UTF8.GetBytes(s);
- // fileStream.Write(bytes, 0, bytes.Length);
- // fileStream.SetLength(bytes.Length);
- // fileStream.Flush();
- // fileStream.Close();
- // }
- // }
- //}
+ // using (FileStream fileStream = new FileStream(_statisticFilePath, FileMode.OpenOrCreate, FileAccess.Write))
+ // {
+ // fileStream.Seek(0L, SeekOrigin.Begin);
+ // string s = JsonConvert.SerializeObject(StatisticRecordsFull);
+ // byte[] bytes = Encoding.UTF8.GetBytes(s);
+ // fileStream.Write(bytes, 0, bytes.Length);
+ // fileStream.SetLength(bytes.Length);
+ // fileStream.Flush();
+ // fileStream.Close();
+ // }
+ // }
+ //}
}
catch (Exception ex)
{
@@ -290,9 +303,7 @@
var alrams = item1.AlarmDetails;
var plcdev = DeviceCollection.FirstOrDefault(u => u.Id == item1.plcname) as PLCBase;
-
-
-
+
foreach (var item in alrams.GroupBy(u => u.address))
{
int add = item.Key;
@@ -312,7 +323,7 @@
AlarmTypeList.Add(item2.alarmtype);
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"鎶ヨ绫诲埆{item2.alarmtype}鍔犲叆闃熷垪,闃熷垪涓暟涓簕AlarmTypeList.Count}");
+
}
}
}
@@ -328,45 +339,36 @@
{
StateDIC[StateDICKey] = new List<int>();
-
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"鎶ヨ绫诲埆{StateDICKey}鍔犲叆瀛楀吀锛歋tateDIC");
+
}
- //if (!StateDIC.ContainsKey(plcdev.Name))
- //{
-
- // StateDIC[plcdev.Name] = new List<int>();
- //}
}
+
+ List<int> list = new List<int>();
Dictionary<string, AlarmTypeData> AlarmType = new Dictionary<string, AlarmTypeData>();
- List<int> list = new List<int>();
-
foreach (var item in alrams)
{
- if (!AlarmType.ContainsKey(item.alarmtype))
+ string key = item.alarmtype;
+
+ if (!AlarmType.TryGetValue(key, out var alarmData))
{
- AlarmType.Add(item.alarmtype, new AlarmTypeData()
+ // 涓嶅瓨鍦紝鍒涘缓鏂扮殑
+ alarmData = new AlarmTypeData()
{
CSVhead = csvhead,
CSVdata = csvdata,
- });
+ };
+ AlarmType.Add(item.alarmtype, alarmData);
}
- if (AlarmType.ContainsKey(item.alarmtype))
- {
- AlarmType[item.alarmtype].CSVhead += $",{item.alarmname}";
+ alarmData.CSVhead += $",{item.alarmname}";
+ alarmData.CSVdata += $",{(item.value == 1 ? "1" : "")}";
+ alarmData.AlarmTypeValue.Add(item.value);
- AlarmType[item.alarmtype].CSVdata += $",{(item.value == 1 ? "1" : "")}";
-
- AlarmType[item.alarmtype].AlarmTypeValue.Add(item.value);
-
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"鎶ヨ绫诲埆{item.alarmtype}锛涙暟鍊納item.value}鍔犲叆瀛楀吀锛欰larmType");
- }
-
}
foreach(var item in AlarmType.Keys)
{
@@ -377,13 +379,13 @@
if (!StateDIC[key].SequenceEqual(list))
{
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{plcdev.Name}鎶ヨ绫诲瀷锛歿item}鐨勪俊鍙峰彂鐢熷彉鍖�");
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{plcdev.Name}鎶ヨ绫诲瀷锛歿item}鐨勪俊鍙峰彂鐢熷彉鍖�,淇濆瓨鐨勬暟鎹负{AlarmType[item].CSVdata}");
StateDIC[key].Clear();
StateDIC[key].AddRange(list);
- CSVRecordAsync($"PLCstate_{key}.csv", AlarmType[item].CSVhead, AlarmType[item].CSVdata);
+ CSVRecordAsync($"PLCstate_{DateTime.Now.ToString("yyyyMMdd")}_{key}.csv", AlarmType[item].CSVdata, AlarmType[item].CSVhead);
var showdata = alrams.Where(u => u.value == 1).Select(u => u.alarmname).ToList();
@@ -404,9 +406,9 @@
}
}
- catch
+ catch(Exception EXC)
{
-
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"PLC鎶ヨ瀛樺偍璁板綍鍙戠敓寮傚父 {EXC.ToString()}");
}
}
}
@@ -442,7 +444,7 @@
public class AlarmTypeData
{
- public List <int> AlarmTypeValue;
+ public List <int> AlarmTypeValue = new List<int>();
public string CSVhead;
@@ -640,6 +642,10 @@
if (measureBind.WorkPosition == "P1" && M141Config.StationCode == "S5" && detectResults.GetDefectDescList().Count == 0)
{
+ var defecttem1 = detectResults.SelectMany(u => u.AllNetResults).SelectMany(m => m.DetectDetails).Select(detail => detail.ClassName).ToList();
+
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{products[0].SN} S3S5妫�娴� 缂洪櫡鍚嶇О闆嗗悎涓簕string.Join(",", defecttem1)}");
+
var defecttem = detectResults.SelectMany(u => u.AllNetResults.SelectMany(m => m.DetectDetails)).Where(u => u.ClassName == M141Config.defectname).ToList();
List<Netdefectdetail> Netdefectdetails = mysqlhelper.GetNetdefectdetails(products[0].SEQUENCE);
@@ -891,7 +897,6 @@
});
}
-
public async Task RunImageCheckAsync(List<ProductModel> products, string triggerText, string triggerSource, MeasureBind measureBind)
{
await Task.Run(() =>
@@ -970,7 +975,6 @@
});
}
-
private void RunCustomizedMethod(List<ProductModel> products, string triggerText, string triggerSource, IImageSet imgSet, string methodId, List<DetectResult> resultList)
{
try
@@ -1017,10 +1021,6 @@
LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鑷畾涔夋娴嬭繃绋嬪紓甯革紝{ex.GetExceptionMessage()}");
}
}
-
-
-
-
#region plc
public ResponseMessage RunImageCheck_plc(IOperationConfig config)
@@ -1099,7 +1099,6 @@
CheckPositionDoneAsync_plc(measureBinds[0].WorkPosition, inputSequence, config, cameraIds);
-
return msg;
}
@@ -1150,8 +1149,6 @@
LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鐩告満{camera.Name}妫�娴嬪墠娓呯悊缂撳瓨瀹屾垚");
}
});
-
-
inputSequence = triggerDatas[triggerDatas.Length - 1];
@@ -1237,13 +1234,12 @@
public async Task<List<ProductModel>> CheckPositionDoneAsync_plc(string positionName, string inputSequence, IOperationConfig config, List<string> cameraIds)
{
-
+
string triggerSource = config.TriggerSource;
return await _taskFactory.StartNew(() =>
{
try
{
-
string index = config.TriggerStr.Split(',')[1];
var positionSet = M141Config.WorkPositionCollection.FirstOrDefault(u => u.PositionName == positionName);
@@ -1408,208 +1404,212 @@
}
_ct = DateTime.Now;
- if (M141Config.ISupMES && (M141Config.MESchannel == -1 || M141Config.MESchannel == 1))
- {
- if (M141Config.numpro >= 50)
- {
- M141Config.numpro = 0;
- }
+ //if (M141Config.ISupMES && (M141Config.MESchannel == -1 || M141Config.MESchannel == 1))
+ //{
+ // if (M141Config.numpro >= 50)
+ // {
+ // M141Config.numpro = 0;
+ // }
- string Msgreceice = null;
+ // string Msgreceice = null;
- if (pList[0].Result == "OK")
- {
- M141Config.numpro++;
- Msgreceice = Task.Run(() => mqtt.MESForProduceAsync(pList[0], M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
- }
- else
- {
- if (M141Config.ISupNG)
- {
- Msgreceice = Task.Run(() => mqtt.MESForProduceAsync(pList[0], M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鍚姩NG涓婁紶");
+ // if (pList[0].Result == "OK")
+ // {
+ // //M141Config.numpro++;
+ // //Msgreceice = Task.Run(() => mqtt.MESForProduceAsync(pList[0], M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}姹囨�籓K鏆傛椂涓嶄笂浼�");
+ // }
+ // else
+ // {
+ // if (M141Config.ISupNG)
+ // {
+ // Msgreceice = Task.Run(() => mqtt.MESForProduceAsync(pList[0], M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鍚姩NG涓婁紶");
- }
- else
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鍏抽棴NG涓婁紶");
- }
- }
- M141Config.mesnum2++;
- if (Msgreceice == null && !M141Config.ISupNG)
- {
- if (!M141Config.ISupNG)
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鏁版嵁NG锛屽紑鍚叧闂璑G涓婁紶MES");
- }
- else
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES寮傚父 杩斿洖鏁版嵁涓簄ull");
- }
- }
- else
- {
- try
- {
- var obj = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(Msgreceice);
+ // }
+ // else
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鍏抽棴NG涓婁紶");
+ // }
+ // }
+ // M141Config.mesnum2++;
+ // if (Msgreceice == null && !M141Config.ISupNG)
+ // {
+ // if (!M141Config.ISupNG)
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鏁版嵁NG锛屽紑鍚叧闂璑G涓婁紶MES");
+ // }
+ // else
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES寮傚父 杩斿洖鏁版嵁涓簄ull");
+ // }
+ // }
+ // else
+ // {
+ // try
+ // {
+ // var obj = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(Msgreceice);
- if (obj.zstatus == "200")
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES鎴愬姛 {Msgreceice}");
- }
- else
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES澶辫触 {Msgreceice}");
- }
- }
- catch
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES寮傚父 {Msgreceice}");
- }
- }
+ // if (obj.zstatus == "200")
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES鎴愬姛 {Msgreceice}");
+ // if (M141Config.Isprint && !string.IsNullOrEmpty(obj.tary_label))
+ // {
+ // StartPrint(obj.tary_label, "Honeywell PX240S(300 dpi)");
+ // }
+ // }
+ // else
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES澶辫触 {Msgreceice}");
+ // }
+ // }
+ // catch
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES寮傚父 {Msgreceice}");
+ // }
+ // }
+ // int numplca = Convert.ToInt32(pList[0].SEQUENCE.Split('_')[0]);
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"plc缁欏嚭鐨勪骇鍝佸簭鍙蜂负{numplca}");
- int numplca = Convert.ToInt32(pList[0].SEQUENCE.Split('_')[0]);
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"plc缁欏嚭鐨勪骇鍝佸簭鍙蜂负{numplca}");
+ // lock (plcnumlock)//1-29999
+ // {
- lock (plcnumlock)//1-29999
- {
+ // if (PlcNumForAll == -1)
+ // {
+ // PlcNumForAll = numplca;
+ // }
- if (PlcNumForAll == -1)
- {
- PlcNumForAll = numplca;
- }
+ // int differ = numplca - PlcNumForAll;
- int differ = numplca - PlcNumForAll;
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"涓や釜浜у搧涓棿鐨勫樊鍊糳iffer涓簕differ}");
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"涓や釜浜у搧涓棿鐨勫樊鍊糳iffer涓簕differ}");
+ // if (differ > 1)
+ // {
+ // for (int i = PlcNumForAll + 1; i < numplca; i++)
+ // {
+ // try
+ // {
+ // var plist = mysqlhelper.GetProductList(i + "_1");
+ // ProductModel newp = new ProductModel();
+ // newp.SEQUENCE = plist[0].SEQUENCE;
+ // newp.PID = plist[0].PID;
+ // newp.BasketCode = plist[0].BasketCode;
+ // newp.Zword = plist[0].Zword;
+ // newp.Result = "NG";
+ // newp.SN = plist[0].SN;
- if (differ > 1)
- {
- for (int i = PlcNumForAll + 1; i < numplca; i++)
- {
- try
- {
- var plist = mysqlhelper.GetProductList(i + "_1");
- ProductModel newp = new ProductModel();
- newp.SEQUENCE = plist[0].SEQUENCE;
- newp.PID = plist[0].PID;
- newp.BasketCode = plist[0].BasketCode;
- newp.Zword = plist[0].Zword;
- newp.Result = "NG";
- newp.SN = plist[0].SN;
+ // if (M141Config.IsfinDevice)
+ // {
+ // SummaryAllprodata(newp);
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鎻愬墠NG鍔犲叆姹囨�绘暟鎹姤琛ㄧ粺璁�");
+ // }
+ // if (M141Config.ISupNG)
+ // {
+ // var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+ // M141Config.mesnum2++;
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍚姩NG涓婁紶");
+ // }
+ // else
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍏抽棴NG涓婁紶");
+ // }
- if (M141Config.IsfinDevice)
- {
- SummaryAllprodata(newp);
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鎻愬墠NG鍔犲叆姹囨�绘暟鎹姤琛ㄧ粺璁�");
- }
- if (M141Config.ISupNG)
- {
- var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
- M141Config.mesnum2++;
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍚姩NG涓婁紶");
- }
- else
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍏抽棴NG涓婁紶");
- }
+ // }
+ // catch
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{i + "_1"}涓婁紶澶辫触");
+ // }
+ // }
+ // }
+ // else if (differ == -29998 && differ == 1 && differ == 0)
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"鐢熶骇杩囩▼涓湭澶卞幓浜у搧");
+ // }
+ // else if (differ < 0 && differ > -29998)
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"PlcNumForAll涓簕PlcNumForAll}锛宯umplca涓簕numplca}");
+ // //浜у搧浠庢柊璁℃暟鏃�
+ // for (int i = PlcNumForAll + 1; i <= 29999; i++)
+ // {
+ // try
+ // {
+ // var plist = mysqlhelper.GetProductList(i + "_1");
+ // ProductModel newp = new ProductModel();
+ // newp.SEQUENCE = plist[0].SEQUENCE;
+ // newp.PID = plist[0].PID;
+ // newp.Zword = plist[0].Zword;
+ // newp.BasketCode = plist[0].BasketCode;
+ // newp.Result = "NG";
+ // newp.SN = plist[0].SN;
+ // if (M141Config.IsfinDevice)
+ // {
+ // SummaryAllprodata(newp);
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鎻愬墠NG鍔犲叆姹囨�绘暟鎹姤琛ㄧ粺璁�");
+ // }
+ // if (M141Config.ISupNG)
+ // {
+ // var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+ // M141Config.mesnum2++;
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍚姩NG涓婁紶");
+ // }
+ // else
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍏抽棴NG涓婁紶");
+ // }
- }
- catch
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{i + "_1"}涓婁紶澶辫触");
- }
- }
- }
- else if (differ == -29998 && differ == 1 && differ == 0)
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"鐢熶骇杩囩▼涓湭澶卞幓浜у搧");
- }
- else if (differ < 0 && differ > -29998)
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"PlcNumForAll涓簕PlcNumForAll}锛宯umplca涓簕numplca}");
- //浜у搧浠庢柊璁℃暟鏃�
- for (int i = PlcNumForAll + 1; i <= 29999; i++)
- {
- try
- {
- var plist = mysqlhelper.GetProductList(i + "_1");
- ProductModel newp = new ProductModel();
- newp.SEQUENCE = plist[0].SEQUENCE;
- newp.PID = plist[0].PID;
- newp.Zword = plist[0].Zword;
- newp.BasketCode = plist[0].BasketCode;
- newp.Result = "NG";
- newp.SN = plist[0].SN;
- if (M141Config.IsfinDevice)
- {
- SummaryAllprodata(newp);
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鎻愬墠NG鍔犲叆姹囨�绘暟鎹姤琛ㄧ粺璁�");
- }
- if (M141Config.ISupNG)
- {
- var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
- M141Config.mesnum2++;
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍚姩NG涓婁紶");
- }
- else
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍏抽棴NG涓婁紶");
- }
- //var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
- //M141Config.mesnum2++;
- //LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"PlcNumForAll锛屽墠绔橬G鎺掓枡涓攑lc瑙﹀彂娓呴浂浜у搧{newp.PID}鏁版嵁涓婁紶,缁撴灉涓簕newp.Result}");
+ // }
+ // catch
+ // {
- }
- catch
- {
+ // }
+ // }
+ // for (int i = 1; i < numplca; i++)
+ // {
+ // try
+ // {
+ // var plist = mysqlhelper.GetProductList(i + "_1");
+ // ProductModel newp = new ProductModel();
+ // newp.SEQUENCE = plist[0].SEQUENCE;
+ // newp.PID = plist[0].PID;
+ // newp.BasketCode = plist[0].BasketCode;
+ // newp.Zword = plist[0].Zword;
+ // newp.Result = "NG";
+ // newp.SN = plist[0].SN;
+ // if (M141Config.IsfinDevice)
+ // {
+ // SummaryAllprodata(newp);
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鎻愬墠NG鍔犲叆姹囨�绘暟鎹姤琛ㄧ粺璁�");
+ // }
+ // if (M141Config.ISupNG)
+ // {
+ // var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+ // M141Config.mesnum2++;
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍚姩NG涓婁紶");
+ // }
+ // else
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍏抽棴NG涓婁紶");
+ // }
- }
- }
- for (int i = 1; i < numplca; i++)
- {
- try
- {
- var plist = mysqlhelper.GetProductList(i + "_1");
- ProductModel newp = new ProductModel();
- newp.SEQUENCE = plist[0].SEQUENCE;
- newp.PID = plist[0].PID;
- newp.BasketCode = plist[0].BasketCode;
- newp.Zword = plist[0].Zword;
- newp.Result = "NG";
- newp.SN = plist[0].SN;
- if (M141Config.IsfinDevice)
- {
- SummaryAllprodata(newp);
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鎻愬墠NG鍔犲叆姹囨�绘暟鎹姤琛ㄧ粺璁�");
- }
- if (M141Config.ISupNG)
- {
- var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
- M141Config.mesnum2++;
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍚姩NG涓婁紶");
- }
- else
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍏抽棴NG涓婁紶");
- }
+ // //var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+ // //M141Config.mesnum2++;
+ // //LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"numplca锛屽墠绔橬G鎺掓枡涓攑lc瑙﹀彂娓呴浂浜у搧{newp.PID}鏁版嵁涓婁紶,缁撴灉涓簕newp.Result}");
+ // }
+ // catch
+ // {
+ // }
+ // }
+ // }
+ // PlcNumForAll = numplca;
+ // }
- //var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
- //M141Config.mesnum2++;
- //LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"numplca锛屽墠绔橬G鎺掓枡涓攑lc瑙﹀彂娓呴浂浜у搧{newp.PID}鏁版嵁涓婁紶,缁撴灉涓簕newp.Result}");
- }
- catch
- {
- }
- }
- }
- PlcNumForAll = numplca;
- }
-
- }
-
+ //}
+ //else
+ //{
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"宸插叧闂璵es杩炴帴鎴栬�呮暟鎹笂浼犳帴鍙�");
+ //}
}
//ReplyPlcData(positionName, config.TriggerValue);
@@ -1690,7 +1690,7 @@
data += "NA,";
}
}
- CSVRecordAsync($"AllDeviceProductRecord.csv", data, Head);
+ CSVRecordAsync($"AllDeviceProductRecord_{DateTime.Now.ToString("yyyyMMdd")}.csv", data, Head);
}
catch (Exception exx)
@@ -1882,6 +1882,85 @@
return new ResponseMessage();
}
+
+
+ #region 鎵撳嵃鏈虹浉鍏�
+ PrintDocument printDocument1 = new PrintDocument();
+ string Printmessage = "";
+
+ public void StartPrint(string str, string PrinterName)
+ {
+ try
+ {
+ int ttwith = 240;
+ int ttheigh = 80;
+ Printmessage = str;
+
+ this.printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = PrinterName;
+ this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Custum", ttwith, ttheigh);
+
+ this.printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
+ this.printDocument1.Print();
+
+ }
+ catch(Exception ex)
+ {
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鎵撳嵃鏈烘墦鍗板嚭閿�:{ex.ToString()}");
+ }
+
+ }
+
+
+
+ //C229M2508250500002
+ private void printDocument_Print(object sender, PrintPageEventArgs e)
+ {
+ Font fntTxt = new Font("榛戜綋", 15, System.Drawing.FontStyle.Bold);//姝f枃鏂囧瓧
+ System.Drawing.Brush brush = new SolidBrush(System.Drawing.Color.Black);//鐢诲埛
+ try
+ {
+ var g = e.Graphics;
+ g.Clear(Color.White);
+ BarcodeWriter writer = new BarcodeWriter();
+ writer.Format = BarcodeFormat.QR_CODE;
+ QrCodeEncodingOptions options = new QrCodeEncodingOptions()
+ {
+ DisableECI = true,//璁剧疆鍐呭缂栫爜
+ CharacterSet = "UTF-8", //璁剧疆浜岀淮鐮佺殑瀹藉害鍜岄珮搴�
+ Width = 60,
+ Height = 60,
+ Margin = 1//璁剧疆浜岀淮鐮佺殑杈硅窛,鍗曚綅涓嶆槸鍥哄畾鍍忕礌
+ };
+
+ writer.Options = options;
+ Bitmap map = writer.Write(Printmessage);
+ e.Graphics.DrawImage(map, new System.Drawing.Point(90, 4));
+
+ // 鍦ㄤ簩缁寸爜涓嬫柟鐢诲唴瀹规枃瀛�
+ using (Font font = new Font("Arial", 10))
+ using (Brush brush3 = new SolidBrush(Color.Black))
+ {
+ // 璁╂枃瀛楀眳涓埌浜岀淮鐮佷笅鏂�
+ SizeF textSize = e.Graphics.MeasureString(Printmessage, font);
+ float textX = 90 + (map.Width - textSize.Width) / 2;
+ float textY = 1 + map.Height;
+
+ e.Graphics.DrawString(Printmessage, font, brush3, textX, textY);
+ }
+
+ }
+ catch (Exception ee)
+ {
+
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, ee.ToString());
+ }
+ }
+
+
+
+
+ #endregion
+
}
public class DefectNGRecord
--
Gitblit v1.8.0