From 044e5d0e1491ef25976cf3e25cf7fdf2baf6cb7d Mon Sep 17 00:00:00 2001 From: kingno <30263@KINGNO> Date: 星期二, 01 四月 2025 17:27:22 +0800 Subject: [PATCH] 合并 --- src/Bro.M141.Process/M141Process.cs | 77 +++++++++++++++++++++++++++++++++++--- 1 files changed, 71 insertions(+), 6 deletions(-) diff --git a/src/Bro.M141.Process/M141Process.cs b/src/Bro.M141.Process/M141Process.cs index 91e0e62..4444bcc 100644 --- a/src/Bro.M141.Process/M141Process.cs +++ b/src/Bro.M141.Process/M141Process.cs @@ -97,6 +97,7 @@ _positionCheckTimeDict.Clear(); _positionSpecHeads.Clear(); + mysqlhelper.IniDBIP(M141Config.IPforall); if (ThHeartPlc == null) { @@ -263,6 +264,15 @@ if (isSaveDB) { + if (M141Config.Isreadbasketcode) + { + p.BasketCode = M141Config.basketcode; + } + else + { + p.BasketCode = mysqlhelper.Getbasketcode(p.SEQUENCE); + } + mysqlhelper.NewProduct(p); } @@ -294,7 +304,7 @@ p.PID = p.PID + "_" + sequence.Split('_')[sequence.Split('_').Length - 1]; p.Initial(M141Config.StationCode, M141Config.WorkPositionCollection.Where(u => u.IsEnabled).Select(u => u.PositionName).ToList()); - //LogAsync(DateTime.Now, EnumHelper.LogLevel.Warning, $"鏈兘浠庢暟鎹簱鑾峰彇浜у搧瀵硅薄锛屼娇鐢ㄤ复鏃舵柊寤轰骇鍝佸璞�"); + LogAsync(DateTime.Now, EnumHelper.LogLevel.Warning, $"鏈兘浠庢暟鎹簱鑾峰彇浜у搧瀵硅薄锛屼娇鐢ㄤ复鏃舵柊寤轰骇鍝佸璞�"); } NewProductIntoList(p, false); @@ -704,6 +714,7 @@ try { ConcurrentDictionary<MeasureBind, IImageSet> imgSetDicts = new ConcurrentDictionary<MeasureBind, IImageSet>(); + var positionSet = M141Config.WorkPositionCollection.Where(u => u.IsEnabled).FirstOrDefault(u => u.TriggerValue == triggerDatas[0]); measureBinds.AsParallel().ForAll(b => { @@ -715,6 +726,10 @@ try { imgSetDicts[b] = CollectHImage(camera, b.SnapshotOpConfig); + if (positionSet.ispiccover) + { + Plc1.WriteSingleAddress(positionSet.plcover,1,out _); + } } catch (Exception ea) { @@ -930,10 +945,8 @@ plcresult.Add(isOK); List<string> specHeads = new List<string>(); string head = p.GetCSVHead(ref specHeads, positionName); - if (!_positionSpecHeads.ContainsKey(positionName)) - { - _positionSpecHeads[positionName] = specHeads; - } + + _positionSpecHeads[positionName] = specHeads; string data = p.GetCSVData(_positionSpecHeads[positionName], positionName); CSVRecordAsync($"{positionName}_Record_{DateTime.Now.ToString("yyyyMMdd")}.csv", data, head); @@ -941,10 +954,15 @@ //UpdatePositionResultToDB(detail); var seqData = p.SEQUENCE.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries).ToList(); - + mysqlhelper.UpdateProduct(p); if (positionSet.IsLastPosition) { UpdateProductResultAsync(p); + mysqlhelper.NewForAll(p, M141Config.StationCode); + if (M141Config.IsfinDevice) + { + SummaryAllprodata(p); + } } }); ReplyPlcData(positionSet, plcresult); @@ -993,6 +1011,53 @@ } + + + + public void SummaryAllprodata(ProductModel p) + { + _taskFactory.StartNew(() => + { + try + { + + ProductModel newp = new ProductModel(); + newp.SEQUENCE = p.SEQUENCE; + newp.PID = p.PID; + newp.BasketCode = p.BasketCode; + newp.Result = p.Result; + newp.SN = p.SN; + newp.Details.AddRange(p.Details); + + var plist = mysqlhelper.GetProductList(p.SEQUENCE); + + if (plist != null) + { + foreach (var item in plist) + { + newp.Details.AddRange(item.Details); + } + } + + List<string> specHeadListforall = new List<string>(); + List<string> positionListforall = new List<string>(); + string csvHeadforall = p.GetCSVHead(ref specHeadListforall, ref positionListforall); + CSVRecordAsync($"AllDeviceProductRecord.csv", p.GetCSVData(specHeadListforall, positionListforall), csvHeadforall); + + } + catch(Exception exx) + { + LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, "AllDeviceProductRecord鏁版嵁姹囨�诲紓甯� " + exx.ToString()); + } + }); + + } + + + + + + #endregion } -- Gitblit v1.8.0