From f4302a3078545c8e3e2075bdfd4b01804dc79a5b Mon Sep 17 00:00:00 2001 From: cjs <2216046164@qq.com> Date: 星期二, 10 六月 2025 17:31:56 +0800 Subject: [PATCH] 111 --- ams/Hanhe.iWCS.JingmenGEMTwoProtocol/PLCControl.cs | 90 ++++++++++++++++++++++ ams/Hanhe.iWCS.JingmenGEMTwoProtocol/.vs/Hanhe.iWCS.JingmenGEMTwoProtocol/v17/DocumentLayout.backup.json | 22 +++++ ams/Hanhe.iWCS.JingmenGEMTwoTCP/WCSServer.cs | 4 + ams/Hanhe.iWCS.JingmenGEMTwoProtocol/ProcessHelper.cs | 34 +++---- ams/Hanhe.iWCS.JingmenGEMTwoProtocol/EnentListen.cs | 35 ++++++++ 5 files changed, 162 insertions(+), 23 deletions(-) diff --git a/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/.vs/Hanhe.iWCS.JingmenGEMTwoProtocol/v17/DocumentLayout.backup.json b/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/.vs/Hanhe.iWCS.JingmenGEMTwoProtocol/v17/DocumentLayout.backup.json index 3042840..1ccf668 100644 --- a/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/.vs/Hanhe.iWCS.JingmenGEMTwoProtocol/v17/DocumentLayout.backup.json +++ b/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/.vs/Hanhe.iWCS.JingmenGEMTwoProtocol/v17/DocumentLayout.backup.json @@ -1,7 +1,12 @@ { "Version": 1, "WorkspaceRootPath": "C:\\software\\A-\u5DE5\u4F5C\\\u6E90\u7801\\GIT\\\u8346\u95E8\u683C\u6797\u7F8E\u5357\u533A\\ams\\Hanhe.iWCS.JingmenGEMTwoProtocol\\", - "Documents": [], + "Documents": [ + { + "AbsoluteMoniker": "D:0:0:{BCE5B4FC-C2CD-459E-AAD0-34D4900B4528}|Hanhe.iWCS.JingmenGEMTwoProtocol.csproj|c:\\software\\a-\u5DE5\u4F5C\\\u6E90\u7801\\git\\\u8346\u95E8\u683C\u6797\u7F8E\u5357\u533A\\ams\\hanhe.iwcs.jingmengemtwoprotocol\\enentlisten.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{BCE5B4FC-C2CD-459E-AAD0-34D4900B4528}|Hanhe.iWCS.JingmenGEMTwoProtocol.csproj|solutionrelative:enentlisten.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + } + ], "DocumentGroupContainers": [ { "Orientation": 0, @@ -9,7 +14,7 @@ "DocumentGroups": [ { "DockedWidth": 16, - "SelectedChildIndex": -1, + "SelectedChildIndex": 7, "Children": [ { "$type": "Bookmark", @@ -38,6 +43,19 @@ { "$type": "Bookmark", "Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}" + }, + { + "$type": "Document", + "DocumentIndex": 0, + "Title": "EnentListen.cs", + "DocumentMoniker": "C:\\software\\A-\u5DE5\u4F5C\\\u6E90\u7801\\GIT\\\u8346\u95E8\u683C\u6797\u7F8E\u5357\u533A\\ams\\Hanhe.iWCS.JingmenGEMTwoProtocol\\EnentListen.cs", + "RelativeDocumentMoniker": "EnentListen.cs", + "ToolTip": "C:\\software\\A-\u5DE5\u4F5C\\\u6E90\u7801\\GIT\\\u8346\u95E8\u683C\u6797\u7F8E\u5357\u533A\\ams\\Hanhe.iWCS.JingmenGEMTwoProtocol\\EnentListen.cs", + "RelativeToolTip": "EnentListen.cs", + "ViewState": "AgIAACoAAAAAAAAAAAAAAGAAAAA2AAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2025-06-03T09:14:58.365Z", + "EditorCaption": "" } ] }, diff --git a/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/EnentListen.cs b/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/EnentListen.cs index 13e758a..50fd600 100644 --- a/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/EnentListen.cs +++ b/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/EnentListen.cs @@ -362,12 +362,43 @@ } #endregion - #region 10015-MES鍏ュ簱鍙嶉 - if (currActionModel.CN_N_ACTION_CODE == 10015) + #region 10016-MES鍏ュ簱鍙嶉 + if (currActionModel.CN_N_ACTION_CODE == 10016) { ERPService.SendMESTaskCompleteFunc(); } #endregion + + #region 鍥涢挻 + + #region 10017-A鍙�+ if (currActionModel.CN_N_ACTION_CODE == 10017) + { + var plc = Settings.GetPlcInfo().Where(a => a.enable == 1 && a.deviceType == "41").FirstOrDefault(); + if (plc != null) + { + PLCControl.AMachine(plc); + } + } + #endregion + + #region 10018-C鍙�+ if (currActionModel.CN_N_ACTION_CODE == 10018) + { + var list = Settings.GetPlcInfo().Where(a => a.enable == 1 && a.deviceType == "42").ToList(); + if (list.Count > 0) + { + list.ForEach(a => + { + PLCControl.CMachine(a); + }); + } + Thread.Sleep(3000); + + } + #endregion + + #endregion return bResult; } diff --git a/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/PLCControl.cs b/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/PLCControl.cs index cced9a5..890bb65 100644 --- a/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/PLCControl.cs +++ b/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/PLCControl.cs @@ -4478,6 +4478,96 @@ CMMLog.Info($"鍦ㄩ�閬搟plc.writeAddr + 2}涓啓鍏JsonConvert.SerializeObject(num)}锛宨p锛歿plc.ip}锛岀鍙o細{plc.port}"); } + /// <summary> + /// 鍥涢挻A锛堟礂鏉跨儤骞叉満缁勶級璁惧涓婄┖涓嬫弧 + /// </summary> + /// <param name="plc"></param> + /// <exception cref="NotImplementedException"></exception> + internal static void AMachine(Settings.PlcInfo plc) + { + if (PickUpStartFree(plc.location) && PickUpEndFree(plc.location)) + { + try + { + var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel + { + dataNum = 1, + addr = plc.readAddr, + host = plc.ip, + port = plc.port + }); + if (result != null && result.errCode == 0) + { + if (result.result[0] == 1) + { + //閫佺┖ + bool req = WMSHelper.WMSOut(plc.location, "", ""); + if (req) CMMLog.Debug($"鍥涢挻A璁惧 璋冪敤WMS鑾峰彇绌烘墭鍑哄簱鐢熸垚浠诲姟鎴愬姛锛�);//鐜板湪浠诲姟鐢盬MS鑷繁涓嬪彂锛孉MS鍋氭嫤鎴鐞嗭紙鏌ヨext1閲岄潰瀵瑰簲鐨勪换鍔$被鍨嬶紝骞舵洿鏀逛换鍔$被鍨嬶級 + else CMMLog.Debug($"鍥涢挻A璁惧 璋冪敤WMS鑾峰彇绌烘墭鍑哄簱鐢熸垚浠诲姟澶辫触锛�); + } + if (result.result[0] == 2) + { + //鍙栨弧 + string wmstaskno = ""; + string traycode = ""; + bool req = WMSHelper.WMSIn(plc.location, "", ref wmstaskno, ref traycode); + if (req) CMMLog.Debug($"鍥涢挻A璁惧 璋冪敤WMS鑾峰彇婊℃墭鍏ュ簱鐢熸垚浠诲姟鎴愬姛锛�);//鐜板湪浠诲姟鐢盬MS鑷繁涓嬪彂锛孉MS鍋氭嫤鎴鐞嗭紙鏌ヨext1閲岄潰瀵瑰簲鐨勪换鍔$被鍨嬶紝骞舵洿鏀逛换鍔$被鍨嬶級 + else CMMLog.Debug($"鍥涢挻A璁惧 璋冪敤WMS鑾峰彇婊℃墭鍏ュ簱鐢熸垚浠诲姟澶辫触锛�); + } + } + } + catch (Exception ex) + { + CMMLog.Info($"鍥涢挻A璁惧 err:{ex.Message}"); + } + } + } + + /// <summary> + /// 鍥涢挻C锛堥挻鏉垮壀鍒囨満缁勶級璁惧涓婃弧涓嬬┖ + /// </summary> + /// <param name="a"></param> + /// <exception cref="NotImplementedException"></exception> + internal static void CMachine(Settings.PlcInfo plc) + { + if (PickUpStartFree(plc.location) && PickUpEndFree(plc.location)) + { + try + { + var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel + { + dataNum = 1, + addr = plc.readAddr, + host = plc.ip, + port = plc.port + }); + if (result != null && result.errCode == 0) + { + if (result.result[0] == 1) + { + //閫佹弧 + bool req = WMSHelper.WMSOut(plc.location, "", ""); + if (req) CMMLog.Debug($"鍥涢挻C璁惧 璋冪敤WMS鑾峰彇婊℃墭鍑哄簱鐢熸垚浠诲姟鎴愬姛锛�);//鐜板湪浠诲姟鐢盬MS鑷繁涓嬪彂锛孉MS鍋氭嫤鎴鐞嗭紙鏌ヨext1閲岄潰瀵瑰簲鐨勪换鍔$被鍨嬶紝骞舵洿鏀逛换鍔$被鍨嬶級 + else CMMLog.Debug($"鍥涢挻C璁惧 璋冪敤WMS鑾峰彇婊℃墭鍑哄簱鐢熸垚浠诲姟澶辫触锛�); + } + if (result.result[0] == 2) + { + //鍙栫┖ + string wmstaskno = ""; + string traycode = ""; + bool req = WMSHelper.WMSIn(plc.location, "", ref wmstaskno, ref traycode); + if (req) CMMLog.Debug($"鍥涢挻C璁惧 璋冪敤WMS鑾峰彇绌烘墭鍏ュ簱鐢熸垚浠诲姟鎴愬姛锛�);//鐜板湪浠诲姟鐢盬MS鑷繁涓嬪彂锛孉MS鍋氭嫤鎴鐞嗭紙鏌ヨext1閲岄潰瀵瑰簲鐨勪换鍔$被鍨嬶紝骞舵洿鏀逛换鍔$被鍨嬶級 + else CMMLog.Debug($"鍥涢挻C璁惧 璋冪敤WMS鑾峰彇绌烘墭鍏ュ簱鐢熸垚浠诲姟澶辫触锛�); + } + } + } + catch (Exception ex) + { + CMMLog.Info($"鍥涢挻C璁惧 err:{ex.Message}"); + } + } + } + #endregion public class WMS_STOCK_VIEW diff --git a/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/ProcessHelper.cs b/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/ProcessHelper.cs index 598fb2b..d0ac375 100644 --- a/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/ProcessHelper.cs +++ b/ams/Hanhe.iWCS.JingmenGEMTwoProtocol/ProcessHelper.cs @@ -96,25 +96,25 @@ internal static void recordInfo(string taskName,string errMsg) { - //var errInfo = MongoDBSingleton.Instance.FindOne<errInfoTable>(Query.EQ("taskName", taskName), "errInfoTable"); - //if(errInfo != null) - //{ - // MongoDBSingleton.Instance.Update<errInfoTable>(Query.EQ("_id", errInfo._id), Update.Set("errMsg", errMsg).Set("dateTime", DateTime.Now), UpdateFlags.None); - //} - //else - //{ - // MongoDBSingleton.Instance.Insert<errInfoTable>(new errInfoTable - // { - // taskName = taskName, - // errMsg = errMsg, - // dateTime = DateTime.Now - // }); - //} + var errInfo = MongoDBSingleton.Instance.FindOne<errInfoTable>(Query.EQ("taskName", taskName), "errInfoTable"); + if(errInfo != null) + { + MongoDBSingleton.Instance.Update<errInfoTable>(Query.EQ("_id", errInfo._id), Update.Set("errMsg", errMsg).Set("dateTime", DateTime.Now), UpdateFlags.None); + } + else + { + MongoDBSingleton.Instance.Insert<errInfoTable>(new errInfoTable + { + taskName = taskName, + errMsg = errMsg, + dateTime = DateTime.Now + }); + } } internal static void deleteInfo(string taskName) { - //MongoDBSingleton.Instance.Remove<errInfoTable>(Query.EQ("taskName", taskName), RemoveFlags.None); + MongoDBSingleton.Instance.Remove<errInfoTable>(Query.EQ("taskName", taskName), RemoveFlags.None); } @@ -740,14 +740,12 @@ #endregion - CMMLog.Info($"OutWareTask 11111"); string ssx01 = plc[0].location; string ssx02 = plc[1].location; //CMMLog.Info($"鏌ヨ杈撻�绾垮綋鍓嶇偣浣嶏細{a.location}"); var slptInfo1 = MongoDBSingleton.Instance.FindOne<SLPTLoc>(Query.EQ("locCode", ssx01), "SLPTLoc"); if (slptInfo1 == null) { - CMMLog.Info($"OutWareTask 222222"); endMachLoc = ssx01; slptInfo1 = new SLPTLoc { @@ -758,7 +756,6 @@ } else { - CMMLog.Info($"OutWareTask 3333333"); var slptInfo2 = MongoDBSingleton.Instance.FindOne<SLPTLoc>(Query.EQ("locCode", ssx02), "SLPTLoc"); if (slptInfo2 == null) { @@ -772,7 +769,6 @@ } else { - CMMLog.Info($"OutWareTask 44444444444"); var loc = slptInfo1.taskNum <= slptInfo2.taskNum ? slptInfo1 : slptInfo2; CMMLog.Info("OutWareTask :" + JsonConvert.SerializeObject(loc)); if (loc.taskNum < 2) diff --git a/ams/Hanhe.iWCS.JingmenGEMTwoTCP/WCSServer.cs b/ams/Hanhe.iWCS.JingmenGEMTwoTCP/WCSServer.cs index daa46d2..949d20f 100644 --- a/ams/Hanhe.iWCS.JingmenGEMTwoTCP/WCSServer.cs +++ b/ams/Hanhe.iWCS.JingmenGEMTwoTCP/WCSServer.cs @@ -113,6 +113,10 @@ IEnentListen insertMidTable = DataAccess.CreateEnentListen(); insertMidTable.EnentSubscribe(new TN_I_TASK_DTL_ACTION() { CN_N_ACTION_CODE = 10015 }); + //MES鍏ュ簱鍙嶉 + IEnentListen SendMESTaskCompleteFunc = DataAccess.CreateEnentListen(); + SendMESTaskCompleteFunc.EnentSubscribe(new TN_I_TASK_DTL_ACTION() { CN_N_ACTION_CODE = 10016 }); + } public class YourReceiveFilter : IReceiveFilterFactory<BinaryRequestInfo> { public IReceiveFilter<BinaryRequestInfo> CreateFilter(IAppServer appServer, IAppSession appSession, System.Net.IPEndPoint remoteEndPoint) { -- Gitblit v1.9.1