From afc3ef31921d5ca812f7db92dfb107e2c25eff4c Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周二, 01 4月 2025 16:41:45 +0800 Subject: [PATCH] 上一次码垛包装号和站点 LastPalletizingData 加上 第几块板和 upi --- CC/iWareCC_ASRS/ThreadService/03_BZ12(机器人码包工位)/1、DataProcess_BZ12.cs | 188 +++++++++++++++++++++++++++++++++------------- 1 files changed, 134 insertions(+), 54 deletions(-) diff --git "a/CC/iWareCC_ASRS/ThreadService/03_BZ12\050\346\234\272\345\231\250\344\272\272\347\240\201\345\214\205\345\267\245\344\275\215\051/1\343\200\201DataProcess_BZ12.cs" "b/CC/iWareCC_ASRS/ThreadService/03_BZ12\050\346\234\272\345\231\250\344\272\272\347\240\201\345\214\205\345\267\245\344\275\215\051/1\343\200\201DataProcess_BZ12.cs" index ef00399..de3b436 100644 --- "a/CC/iWareCC_ASRS/ThreadService/03_BZ12\050\346\234\272\345\231\250\344\272\272\347\240\201\345\214\205\345\267\245\344\275\215\051/1\343\200\201DataProcess_BZ12.cs" +++ "b/CC/iWareCC_ASRS/ThreadService/03_BZ12\050\346\234\272\345\231\250\344\272\272\347\240\201\345\214\205\345\267\245\344\275\215\051/1\343\200\201DataProcess_BZ12.cs" @@ -1,4 +1,5 @@ 锘縰sing Admin.NET.Application; +using iWareCC.Common.Helper; using iWareCC.StationService; using iWareCommon.Common.Globle; using iWareCommon.Utils; @@ -16,13 +17,13 @@ { public class DataProcess_BZ12 { - public static void Hander() + public static async void Hander() { var alertMsg = ""; LogType logType = LogType.DataProcess_BZ12; while (true) { - Thread.Sleep(2000);//浼戠湢2绉掞紝灏嗕紤鐪犲啓鍒板墠闈紝鏄负浜嗕笅闈㈢殑continue鏂规硶鎵ц鍚庝笉鏄剧ず閿欒淇℃伅鐨勬彁绀猴紒锛侊紒銆怑ditBy shaocx,2022-05-24銆� + Thread.Sleep(600);//浼戠湢2绉掞紝灏嗕紤鐪犲啓鍒板墠闈紝鏄负浜嗕笅闈㈢殑continue鏂规硶鎵ц鍚庝笉鏄剧ず閿欒淇℃伅鐨勬彁绀猴紒锛侊紒銆怑ditBy shaocx,2022-05-24銆� SystemWarningMsg._lbl_alert_DataProcess_BZ12 = string.Empty; try { @@ -33,6 +34,11 @@ * 1銆佷粠鏁版嵁搴撲腑鍒ゆ柇鏄惁榻愬 * 2銆佹牴鎹綈濂楃粨鏋滐紝鎺ㄩ�佺粰PLC */ + if (FormCC.stationView == null) + { + SystemWarningMsg._lbl_alert_DataProcess_BZ12 = $"{rgvLocation.ToString()}-鑾峰彇PLC瀵硅薄涓簄ull"; + continue; + } var obj = FormCC.stationView.R_StationForReadCommList.Where(x => x.StationCode == rgvLocation.ToString()).FirstOrDefault(); if (obj.R_PalletizingAck) { @@ -42,7 +48,7 @@ var res = client.WriteStation_ACK((int)EDevice.Station, false, rgvLocation); if (!res.result) { - SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTask = $"{rgvLocation.ToString()}-涓嬪彂鐮佹澘浠诲姟 澶辫触,SetPalletizingTaskFinishAck 杩斿洖:{res.resMsg}"; + SystemWarningMsg._lbl_alert_DataProcess_BZ12 = $"{rgvLocation.ToString()}-涓嬪彂鐮佹澘浠诲姟 澶辫触,SetPalletizingTaskFinishAck 杩斿洖:{res.resMsg}"; continue; } else @@ -63,23 +69,33 @@ } var upiCode = result.Replace("/r", ""); ; short lastnum = 0;//鏄惁鏈澘 - //short isrotate = 0;//鏄惁鏃嬭浆 - //short placeX = 0; - //short placeY = 0; - //short placeZ = 0; + string place = ""; using (WmsDBModel wmsDB = new WmsDBModel()) { //瑕佹槸鏈夊凡涓嬪彂鐨勪换鍔★紝灏变笉瑕佹墽琛� - var isValidate = TaskHandler.ValidateIssueTaskForNoFinishTaskByUpi(wmsDB, result); + var isValidate = TaskHandler.ValidateIssueTaskForNoFinishTaskByUpi(wmsDB, result, false); if (!isValidate) { - SystemWarningMsg._lbl_alert_DataProcess_BZ12 = $"{rgvLocation.ToString()}-鏈夆�樺凡涓嬪彂鈥欑殑浠诲姟锛屼笉鑳藉鐞�,姝ゆ寰幆缁撴潫"; + SystemWarningMsg._lbl_alert_DataProcess_BZ12 = $"{rgvLocation.ToString()}-upi锛歿result}鏈夆�樺凡涓嬪彂鈥欑殑浠诲姟锛屼笉鑳藉鐞�,姝ゆ寰幆缁撴潫"; continue; } + + /* + isValidate = TaskHandler.ValidateNoFinishOutTaskFor鐮佹澘浠诲姟(wmsDB); + if (!isValidate) + { + SystemWarningMsg._lbl_alert_DataProcess_BZ12 = $"{rgvLocation.ToString()}-鏈� 鏈粨鏉� 鐨勪换鍔★紝涓嶈兘澶勭悊,姝ゆ寰幆缁撴潫"; + continue; + } + //*/ + var upiObj = wmsDB.mes_batchOrderUPI_new.Where(x => x.UPI == upiCode).FirstOrDefault(); if (upiObj == null) { + //鍐欏叆鎶ヨ淇℃伅 + await MyExtendHelper.WriteBoolPlcDataForWarning(PlcWarningAddressGloble.Num_BZ12_1); + SystemWarningMsg._lbl_alert_DataProcess_BZ12 = $"{rgvLocation.ToString()},鏍规嵁UPI:{upiCode}娌℃湁鎵惧埌瀵硅薄 "; continue; } @@ -89,98 +105,158 @@ //placeZ = (short)upiObj.MachineZCenter; if (upiObj.UpiStatus == (int)UpiStatusEnum.宸茬爜鍨� || upiObj.UpiStatus == (int)UpiStatusEnum.鐮佸灈涓�) { + SystemWarningMsg._lbl_alert_DataProcess_BZ12 = $"{rgvLocation.ToString()},鏍规嵁UPI:{upiCode}鐘舵�佸凡鏄�'宸茬爜鍨�'鎴�'鐮佸灈涓�' "; + MyExtendHelper.SetValueControlRequestDicts(PlcWarningAddressGloble.Num_BZ12_3, false, SystemWarningMsg._lbl_alert_DataProcess_BZ12); + + var isAllow = MyExtendHelper.ValidateIsAllowRequest(PlcWarningAddressGloble.Num_BZ12_3, LogType.DataProcess_BZ12); + if (isAllow == false) + { + continue; + } + else + { + //鍐欏叆鎶ヨ淇℃伅 + await MyExtendHelper.WriteBoolPlcDataForWarning(PlcWarningAddressGloble.Num_BZ12_3); + } + continue; } + MyExtendHelper.SetValueControlRequestDicts(PlcWarningAddressGloble.Num_BZ12_3, true, ""); upiObj.UpiStatus = (int)UpiStatusEnum.鐮佸灈涓�; upiObj.AreaCode = (int)AreaCodeEnum.鐮佸灈鍖哄煙; //鏌ュ杩欏寘鎵�鏈夌殑鏁伴噺 var upiList = wmsDB.mes_batchOrderUPI_new.Where(x => x.PackageCode == upiObj.PackageCode).ToList(); //鏌ヨ鏄惁鏈澘骞朵笖鍒ゆ柇鏈夋病鏈夋贩鎵� - var wms_rbline_runmode = wmsDB.wms_rbline_runmode.FirstOrDefault(); - if (wms_rbline_runmode != null) + //澧炲姞瀵瑰弬鏁伴厤缃殑绠$悊 銆怑ditby shaocx,2024-12-13銆� + var sysConfig = wmsDB.SysConfig.Where(x => x.Code == "LastPalletizingData").FirstOrDefault(); + if (sysConfig == null) { - //鏌ヨ鏄惁娣锋壒 - if (!string.IsNullOrEmpty(wms_rbline_runmode.PalletizingUPI)) + SystemWarningMsg._lbl_alert_DataProcess_BZ01 = $"娌℃湁鑾峰彇鍒� LastPalletizingData 鐨勯厤缃俊鎭� "; + continue; + } + string palletizingUPI = ""; + int palletizingStation = 0; + + var config_value = sysConfig.Value; + if (config_value.IndexOf('|') > -1) + {//鏍煎紡涓� 鍖呰鍙穦绔欑偣 + var arr = config_value.Split('|'); + palletizingUPI = arr[0]; + palletizingStation = Convert.ToInt32(arr[1]); + } + else + {//琛ㄧず杩樻病鏈夐厤缃� + } + + //鏌ヨ鏄惁娣锋壒 + if (!string.IsNullOrEmpty(palletizingUPI)) + { + if (upiObj.PackageCode != palletizingUPI) { - if (upiObj.PackageCode != wms_rbline_runmode.PalletizingUPI) - { - SystemWarningMsg._lbl_alert_DataProcess_BZ12 = $"{rgvLocation.ToString()},UPI:{upiCode}鐮佸寘閮ㄤ欢娣锋壒 "; - continue; - } + //鍐欏叆鎶ヨ淇℃伅 + await MyExtendHelper.WriteBoolPlcDataForWarning(PlcWarningAddressGloble.Num_BZ12_4); + + SystemWarningMsg._lbl_alert_DataProcess_BZ12 = $"{rgvLocation.ToString()},UPI:{upiCode}鐮佸寘閮ㄤ欢娣锋壒 "; + continue; } - //鑾峰彇鐮佸灈鐩爣浣� - if (wms_rbline_runmode.PalletizingStation != 0) + } + //鑾峰彇鐮佸灈鐩爣浣� + if (palletizingStation != 0) + { + place = palletizingStation.ToString(); + } + else + {//琛ㄧず杩欐槸 鍖呯殑绗竴鍧楁澘 + palletizingUPI = upiObj.PackageCode; + if (obj.R_PalletizingStation1 == 1) { - place = wms_rbline_runmode.PalletizingStation.ToString(); + place = "1"; + } + else if (obj.R_PalletizingStation2 == 1) + { + place = "2"; + } else { - lastnum = 1; - wms_rbline_runmode.PalletizingUPI = upiObj.PackageCode; - if (obj.R_PalletizingStation1 == 1) - { - place = "1"; - } - else if (obj.R_PalletizingStation2 == 1) - { - place = "2"; + //鍘绘帀鎶ヨ锛屼笉鍐嶆牎楠岃繖涓簡 + place = "1"; + /* + //鍐欏叆鎶ヨ淇℃伅 + await MyExtendHelper.WriteBoolPlcDataForWarning(PlcWarningAddressGloble.Num_BZ12_6); - } - else - { - SystemWarningMsg._lbl_alert_DataProcess_BZ12 = $"{rgvLocation.ToString()},UPI:{upiCode}鏃犲彲鐢ㄧ爜鍨涚洰鏍囦綅 "; - continue; - } - wms_rbline_runmode.PalletizingStation = int.Parse(place); - } - //濡傛灉娆″簭绛変簬褰撻挶鍖呮�绘暟閲忥紝鏄惁鏈澘缃负true - if (upiObj.Shelf == upiList.Count()) - { - lastnum = 2; - wms_rbline_runmode.PalletizingUPI = null; - wms_rbline_runmode.PalletizingStation = 0; + SystemWarningMsg._lbl_alert_DataProcess_BZ12 = $"{rgvLocation.ToString()},UPI:{upiCode}鏃犲彲鐢ㄧ爜鍨涚洰鏍囦綅 "; + continue; + //*/ } + palletizingStation = int.Parse(place); } + //濡傛灉娆″簭绛変簬褰撻挶鍖呮�绘暟閲忥紝鏄惁鏈澘缃负true + if (upiObj.Shelf == upiList.Count()) + { + lastnum = 2;//锛�1棣栦欢锛�2鏈欢锛�0涓轰腑闂存澘锛� + palletizingUPI = null; + palletizingStation = 0; + } + else if (upiObj.Shelf == 1) + { + lastnum = 1;//锛�1棣栦欢锛�2鏈欢锛�0涓轰腑闂存澘锛� + } + else + { + lastnum = 0;//锛�1棣栦欢锛�2鏈欢锛�0涓轰腑闂存澘锛� + } + + //鏌ヨ鏈夋病鏈夋搴忓皬浜庡綋鍓嶆搴忓苟涓旀病鏈夌爜鍨涚殑 var oldupi = upiList.Where(x => x.Shelf < upiObj.Shelf && (x.UpiStatus != (int)UpiStatusEnum.宸茬爜鍨� && x.UpiStatus != (int)UpiStatusEnum.鐮佸灈涓�)).FirstOrDefault(); if (oldupi != null) { + //鍐欏叆鎶ヨ淇℃伅 + await MyExtendHelper.WriteBoolPlcDataForWarning(PlcWarningAddressGloble.Num_BZ12_5); + SystemWarningMsg._lbl_alert_DataProcess_BZ12 = $"{rgvLocation.ToString()},UPI:{upiCode}鐮佸寘椤哄簭閿欒 "; continue; } //璁板綍浠诲姟 var _id = Yitter.IdGenerator.YitIdHelper.NextId(); - var plcTaskNo = BusinessHelper.CreatePlcTaskIdForSrmTask(); + var plcTaskNo = BusinessHelper.CreatePlcTaskId(); + plcTaskNo = MyExtendHelper.GetNewTaskNo(wmsDB, RbTaskTypeEnum.鐮佹澘浠诲姟, plcTaskNo); var task = new wms_rbline_task() { Id = _id, TaskNo = plcTaskNo, - UPI = upiObj.UPI, + Upi = upiObj.UPI, Length = upiObj.Length, Width = upiObj.Width, Thk = upiObj.Thk, - IssueTime = DateTime.Now, + PlanNo = upiObj.PlanNo, OrderId = upiObj.OrderId, PackageCode = upiObj.PackageCode, RbTaskType = (int)RbTaskTypeEnum.鐮佹澘浠诲姟, - RbTaskTypeEnumName = RbTaskTypeEnum.鐮佹澘浠诲姟.ToString(), TaskStatus = (int)TaskStatusEnum.鏂板缓, - TaskStatusName = TaskStatusEnum.鏂板缓.ToString(), TaskMsg = "鐮佹澘", CreateTime = DateTime.Now, - CreateUserName = "CC", + CreateUserName = SysGloble.WCSSystem, UpdateTime = DateTime.Now, - UpdateUserName = "CC", + UpdateUserName = SysGloble.WCSSystem, PlaceCode = place, - LastNum = lastnum + LastNum = lastnum, + + Info17 = upiObj.Info17, + MachineXCenter = upiObj.MachineXCenter, + MachineYCenter = upiObj.MachineYCenter, + MachineZCenter = upiObj.MachineZCenter, + Sequence = upiObj.Sequence, }; wmsDB.wms_rbline_task.Add(task); - + //鏇存柊閰嶇疆 + sysConfig.Value = palletizingUPI + "|" + palletizingStation + "|" + upiObj.UPI + "|绗�" + upiObj.Shelf + "鍧�"; WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, "BZ12绔欑偣", "鐮佸寘"); @@ -188,11 +264,15 @@ wmsDB.SaveChanges(); } } + else + { + SystemWarningMsg._lbl_alert_DataProcess_BZ12 = $"{rgvLocation.ToString()}-娌℃湁瑕佸鐞嗙殑鏁版嵁"; + } } } catch (Exception ex) { - SystemWarningMsg._lbl_alert_DataProcess_BZ39 += " 鍑虹幇寮傚父:" + ex.Message + SysGloble.SPLIT_STR; + SystemWarningMsg._lbl_alert_DataProcess_BZ12 += " 鍑虹幇寮傚父:" + ex.Message + SysGloble.SPLIT_STR; Log4NetHelper.WriteErrorLog(logType, " 鍑虹幇寮傚父锛�" + ex.Message, ex); } } -- Gitblit v1.9.3