From daca75da47c4ba7e2927bd07d59d4316a4e6ac6d Mon Sep 17 00:00:00 2001 From: cjs <2216046164@qq.com> Date: 星期一, 14 七月 2025 17:22:27 +0800 Subject: [PATCH] 11 --- ams/Hanhe.iWCS.JingmenGLMNorthProtocol/PLCControl.cs | 66 ++++++++++++++++++++++----------- 1 files changed, 44 insertions(+), 22 deletions(-) diff --git a/ams/Hanhe.iWCS.JingmenGLMNorthProtocol/PLCControl.cs b/ams/Hanhe.iWCS.JingmenGLMNorthProtocol/PLCControl.cs index 6217aaf..62c61ff 100644 --- a/ams/Hanhe.iWCS.JingmenGLMNorthProtocol/PLCControl.cs +++ b/ams/Hanhe.iWCS.JingmenGLMNorthProtocol/PLCControl.cs @@ -201,13 +201,21 @@ if (ERPService.ERPSwitch01 == "0") MongoDBSingleton.Instance.Remove<MachineInfoTwo>(Query.EQ("machineNo", pmInfo.location), "MachineInfoTwo", RemoveFlags.None); CMMLog.Debug($"鍖呰涓嬬嚎娴佺▼-{pmInfo.location}锛氬彔鎵樺眰鏁颁负0锛屼笉鍏佽鐢熸垚浠诲姟"); } - else if (tray.trayCode != "0" && !string.IsNullOrEmpty(tray.trayCode)) + if (string.IsNullOrEmpty(tray.lotNo)) + { + MongoDBSingleton.Instance.Remove<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo", RemoveFlags.None); + if (ERPService.ERPSwitch01 == "0") MongoDBSingleton.Instance.Remove<MachineInfoTwo>(Query.EQ("machineNo", pmInfo.location), "MachineInfoTwo", RemoveFlags.None); + CMMLog.Debug($"鍖呰涓嬬嚎娴佺▼-{pmInfo.location}锛氭壒娆″彿涓虹┖锛屼笉鍏佽鐢熸垚浠诲姟"); + + } + if (tray.trayCode != "0" && !string.IsNullOrEmpty(tray.trayCode)) { string timeStamp = ProcessHelper.GetTimeStamp(31, 1, 1); HHAmsExecuteResult req = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), pmInfo.location, PlcBit02, "3妤煎寘瑁呭彇鏂�, 0, tray.trayCode, timeStamp); if (req.success) { string weight = (double.Parse(tray.oneTrayWeight1) / 100).ToString(); + //CMMLog.Debug("鍖楀尯娴嬭瘯鏁版嵁锛氬寘瑁呬笅绾块噸閲忥細"+(decimal.Parse(tray.oneTrayWeight1) / 100).ToString("F2")); //int weight = int.Parse(tray.oneTrayWeight) / 100; ERPService.packageInfo(tray.machineNo, tray.trayCode, tray.lotNo, weight,1); } @@ -402,7 +410,14 @@ if (ERPService.ERPSwitch01 == "0") MongoDBSingleton.Instance.Remove<MachineInfoTwo>(Query.EQ("machineNo", pmInfo.location), "MachineInfoTwo", RemoveFlags.None); CMMLog.Debug($"鍖呰涓嬬嚎娴佺▼-{pmInfo.location}锛氬彔鎵樺眰鏁颁负0锛屼笉鍏佽鐢熸垚浠诲姟"); } - else if (tray.trayCode != "0" && !string.IsNullOrEmpty(tray.trayCode)) + if (string.IsNullOrEmpty(tray.lotNo)) + { + MongoDBSingleton.Instance.Remove<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo", RemoveFlags.None); + if (ERPService.ERPSwitch01 == "0") MongoDBSingleton.Instance.Remove<MachineInfoTwo>(Query.EQ("machineNo", pmInfo.location), "MachineInfoTwo", RemoveFlags.None); + CMMLog.Debug($"鍖呰涓嬬嚎娴佺▼-{pmInfo.location}锛氭壒娆″彿涓虹┖锛屼笉鍏佽鐢熸垚浠诲姟"); + + } + if (tray.trayCode != "0" && !string.IsNullOrEmpty(tray.trayCode)) { string timeStamp = ProcessHelper.GetTimeStamp(31, 1, 1); HHAmsExecuteResult req = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), pmInfo.location, PlcBit02, "3妤煎寘瑁呭彇鏂�, 0, tray.trayCode, timeStamp); @@ -1153,15 +1168,12 @@ { CMMLog.Info($"SecondWeightActionOne: machine:{query.machineNo},trayCode:{query.trayCode},weight:{query.weight}"); //璇诲彇澶嶇О骞冲彴鐨勯噸閲�- //Convert.ToInt32(Completion(result[8]) + Completion(result[9]), 2).ToString() - //(decimal.Parse(tray.oneTrayWeight1) / 100).ToString("F2"); - //string weight = (decimal.Parse(Convert.ToInt32(Completion(result.result[4]) + Completion(result.result[5]), 2).ToString()) / 100).ToString("F2"); - string weight = ((result.result[4] * 65536 + result.result[5]) / 100).ToString(); + //string weight = ((result.result[3] * 65536 + result.result[4]) / 100).ToString(); + string weight = ((double)Convert.ToInt32(Completion(result.result[3]) + Completion(result.result[4]), 2) / 100).ToString(); + //CMMLog.Debug("鍖楀尯娴嬭瘯鏁版嵁锛氬绉伴噸閲忥細" + ((double)Convert.ToInt32(Completion(result.result[3]) + Completion(result.result[4]), 2) / 100).ToString()); - CMMLog.Debug($"SecondWeightActionOne: 璇诲彇璁惧{plc.location},ip:{plc.ip}閫氶亾{plc.readAddr + 4}閲岄潰鏁版嵁涓簕result.result[4]}."); - CMMLog.Debug($"SecondWeightActionOne: 璇诲彇璁惧{plc.location},ip:{plc.ip}閫氶亾{plc.readAddr + 5}閲岄潰鏁版嵁涓簕result.result[5]}."); - //double x = (double)Convert.ToInt32(Completion(result[8]) + Completion(result[9]), 2) / 100; - //CMMLog.Info($"SecondWeightActionOne: 璇诲彇璁惧{plc.location},ip:{plc.ip}閫氶亾{plc.readAddr + 4}閲岄潰鏁版嵁涓簕result.result[3]}."); + CMMLog.Info($"SecondWeightActionOne: 璇诲彇璁惧{plc.location},ip:{plc.ip}閫氶亾{plc.readAddr + 4}閲岄潰鏁版嵁涓簕result.result[3]}."); + CMMLog.Info($"SecondWeightActionOne: 璇诲彇璁惧{plc.location},ip:{plc.ip}閫氶亾{plc.readAddr + 5}閲岄潰鏁版嵁涓簕result.result[4]}."); CMMLog.Info($"SecondWeightActionOne: weight:{weight}"); //閲嶉噺宸� @@ -1418,7 +1430,7 @@ //璇诲彇閫氶亾1閲岄潰鍙傛暟鏄惁涓�锛屽垽鏂彔鐩樻満鏄惁闇�涓婃枡 var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel { - dataNum = 1, + dataNum = 3, addr = pmInfo.readAddr + 1, host = pmInfo.ip, port = pmInfo.port @@ -1428,14 +1440,20 @@ //鍙傛暟1琛ㄧず鍙犳墭鐐圭敵璇峰叆鏂� if (result.result[0] == 1) { + CMMLog.Debug($"鑾峰彇纰熺洏鏈轰俊鍙凤細{JsonConvert.SerializeObject(result)}"); var tasks = MongoDBSingleton.Instance.Find<TN_I_TASK_MST>(Query.EQ("CN_S_END_BIT", pmInfo.location), "TN_I_TASK_MST"); //鍒ゆ柇涓�笅褰撳墠鍙犳墭鐐规槸鍚︽湁浠诲姟鍗犵敤 if (ProcessHelper.CheckEndFree(pmInfo.location) && tasks.Count == 0) { - //鍙互鐢熸垚浠诲姟锛岃皟WMS鎺ュ彛鑾峰彇浠诲姟淇℃伅 - bool req = WMSHelper.WMSOut(pmInfo.location, ""); - if (req) CMMLog.Debug($"璋冪敤WMS鑾峰彇纰熺洏鍑哄簱鐢熸垚浠诲姟鎴愬姛锛�);//鐜板湪浠诲姟鐢盬MS鑷繁涓嬪彂锛孉MS鍋氭嫤鎴鐞嗭紙鏌ヨext1閲岄潰瀵瑰簲鐨勪换鍔$被鍨嬶紝骞舵洿鏀逛换鍔$被鍨嬶級 - else CMMLog.Debug($"璋冪敤WMS鑾峰彇纰熺洏鍑哄簱鐢熸垚浠诲姟澶辫触锛�); + string trayType = result.result[2] == 1 ? "鐢板瓧鎵� : result.result[2] == 2 ? "宸濆瓧鎵� : ""; + if (result.result[2] >= 1 && result.result[2] <= 2) + { + //鍙互鐢熸垚浠诲姟锛岃皟WMS鎺ュ彛鑾峰彇浠诲姟淇℃伅 + bool req = WMSHelper.WMSOut(pmInfo.location, "",trayType); + if (req) CMMLog.Debug($"璋冪敤WMS鑾峰彇纰熺洏鍑哄簱鐢熸垚浠诲姟鎴愬姛锛�);//鐜板湪浠诲姟鐢盬MS鑷繁涓嬪彂锛孉MS鍋氭嫤鎴鐞嗭紙鏌ヨext1閲岄潰瀵瑰簲鐨勪换鍔$被鍨嬶紝骞舵洿鏀逛换鍔$被鍨嬶級 + else CMMLog.Debug($"璋冪敤WMS鑾峰彇纰熺洏鍑哄簱鐢熸垚浠诲姟澶辫触锛�); + } + } else CMMLog.Debug($"妫�煡褰撳墠鍙犳墭鐐规槸鍚︽湁浠诲姟鍗犵敤锛屾垨鑰匨ST涓昏〃涓湁缂撳瓨鏋跺叆鍙犵洏鏈虹殑浠诲姟锛�); } @@ -1573,6 +1591,7 @@ host = plc.ip, port = plc.port }); + CMMLog.Debug($"缂撳瓨鏋跺叆鍙犳墭锛岃鍙栧彔鍖呭彛淇″彿锛歿JsonConvert.SerializeObject(readres)}"); if (readres != null) { var taskInfo = MongoDBSingleton.Instance.FindOne<TN_I_TASK_MST>(Query.EQ("CN_S_TASK_NO", taskNo), "TN_I_TASK_MST"); @@ -1993,7 +2012,7 @@ //RegisterReadInPut 璇诲彇杈撳叆瀵勫瓨鍣ㄨ繕鏄緭鍑哄瘎瀛樺櫒寰呭畾,璇诲彇閫氶亾1鐨勬暟鎹� var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel { - dataNum = 1, + dataNum = 2, addr = plc.readAddr+1, host = plc.ip, port = plc.port @@ -2008,7 +2027,10 @@ { string wmstaskno = ""; string traycode = ""; - bool req = WMSHelper.WMSEmptyOut(plc.location, "", ref wmstaskno, ref traycode); + string trayType = ""; + if (result.result[1] == 1) trayType = "鐢板瓧鎵�; + else trayType = "宸濆瓧鎵�; + bool req = WMSHelper.WMSEmptyOut(plc.location, "",trayType, ref wmstaskno, ref traycode); if (req) CMMLog.Debug($"璋冪敤WMS鑾峰彇涓夋ゼ鎷嗙洏鏈虹敓鎴愪换鍔℃垚鍔燂紒"); else CMMLog.Debug($"璋冪敤WMS鑾峰彇涓夋ゼ鎷嗙洏鏈虹敓鎴愪换鍔″け璐ワ紒"); } @@ -3000,7 +3022,7 @@ info.productWeight = Convert.ToInt32(Completion(result[4]) + Completion(result[5]), 2).ToString(); info.oneTrayWeight1 = Convert.ToInt32(Completion(result[6]) + Completion(result[7]), 2).ToString(); info.oneTrayWeight = Convert.ToInt32(Completion(result[8]) + Completion(result[9]), 2).ToString(); - //info.oneTrayWeight = Convert.ToInt32(Completion(result[10]) + Completion(result[11]), 2).ToString(); + info.trayType = Convert.ToInt32(Completion(result[10]), 2).ToString(); info.addState = Convert.ToInt32(Completion(result[11]), 2); info.packageCode = Convert.ToInt32(Completion(result[12]), 2).ToString(); @@ -3012,7 +3034,7 @@ CMMLog.Info($"鏁版嵁澶勭悊娴佺▼锛氳幏鍙朚ODBUS杞崲鍚庣殑鏁版嵁淇℃伅锛歭ocation:{info.location},trayCode:{info.trayCode},productWeight:{info.productWeight}" + - $",oneTrayWeight1:{info.oneTrayWeight1},oneTrayWeight:{info.oneTrayWeight} "+ + $",oneTrayWeight1:{info.oneTrayWeight1},oneTrayWeight:{info.oneTrayWeight},trayType:{info.trayType} "+ $"addState:{info.addState},packageCode:{info.packageCode}"); #endregion @@ -3068,7 +3090,7 @@ var query1 = Query.And(Query.EQ("machineNo", location), Query.EQ("trayCode", "0")); UpdateBuilder updateBuider = Update.Set("location", info.location). Set("trayCode", info.trayCode).Set("productWeight", info.productWeight). - Set("oneTrayWeight", info.oneTrayWeight).Set("oneTrayWeight1", info.oneTrayWeight1). + Set("oneTrayWeight", info.oneTrayWeight).Set("oneTrayWeight1", info.oneTrayWeight1).Set("trayType", info.trayType). Set("addWeight", info.addWeight).Set("packNg", info.packNg).Set("secondNg", info.secondNg).Set("addState", info.addState). Set("packageCode", info.packageCode).Set("jsonData", json).Set("modify", DateTime.Now); MongoDBSingleton.Instance.Update<MachineInfo>(query1, updateBuider, "MachineInfo", UpdateFlags.None); @@ -3086,7 +3108,7 @@ { UpdateBuilder updateBuider = Update.Set("location", info.location). Set("trayCode", info.trayCode).Set("productWeight", info.productWeight). - Set("oneTrayWeight", info.oneTrayWeight).Set("oneTrayWeight1", info.oneTrayWeight1). + Set("oneTrayWeight", info.oneTrayWeight).Set("oneTrayWeight1", info.oneTrayWeight1).Set("trayType", info.trayType). Set("addWeight", info.addWeight).Set("packNg", info.packNg).Set("secondNg", info.secondNg).Set("addState", info.addState). Set("packageCode", info.packageCode).Set("jsonData", json).Set("modify", DateTime.Now); MongoDBSingleton.Instance.Update<MachineInfo>(query2, updateBuider, "MachineInfo", UpdateFlags.None); @@ -3455,7 +3477,7 @@ num[b] = Convert.ToInt32(Convert.ToString(int.Parse(machine.oneTrayWeight), 2).PadLeft(32, '0').ToString().Substring(k, 16), 2); } //for (int b = 10; b <= 11; b++) num[b] = 0;// 鍙犲寘鍚庡疄闄呴噸閲�&& 澶嶇О缁撴灉 榛樿锛� - num[10] = string.IsNullOrEmpty(machine.palletLayers) ? 0 : int.Parse(machine.palletLayers); //鏄惁闇�鍙犳墭鐩�+ num[10] = int.Parse(machineInfoTwo.trayType); //鎵樼洏绫诲瀷 num[11] = machine.addState; //鏄惁闇�鍙犲寘 num[12] = int.Parse(machine.packageCode); //琚嬪彿 //鍛樺伐缂栧彿 -- Gitblit v1.9.1