From 9f61c92fe6864d536a0e3a6e041cbd788dcec752 Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周四, 12 12月 2024 11:02:16 +0800 Subject: [PATCH] 222 --- CC/iWareCC_ASRS/ThreadService/02_BZ39工位(补板后工位)/Outbound/2、DataProcess_RobotBuffer_IssueOutboundTask.cs | 161 ++++++++++++++++++++++++++++++++--------------------- 1 files changed, 97 insertions(+), 64 deletions(-) diff --git "a/CC/iWareCC_ASRS/ThreadService/02_BZ39\345\267\245\344\275\215\357\274\210\350\241\245\346\235\277\345\220\216\345\267\245\344\275\215\357\274\211/Outbound/2\343\200\201DataProcess_RobotBuffer_IssueOutboundTask.cs" "b/CC/iWareCC_ASRS/ThreadService/02_BZ39\345\267\245\344\275\215\357\274\210\350\241\245\346\235\277\345\220\216\345\267\245\344\275\215\357\274\211/Outbound/2\343\200\201DataProcess_RobotBuffer_IssueOutboundTask.cs" index 2a87ab0..cca89f1 100644 --- "a/CC/iWareCC_ASRS/ThreadService/02_BZ39\345\267\245\344\275\215\357\274\210\350\241\245\346\235\277\345\220\216\345\267\245\344\275\215\357\274\211/Outbound/2\343\200\201DataProcess_RobotBuffer_IssueOutboundTask.cs" +++ "b/CC/iWareCC_ASRS/ThreadService/02_BZ39\345\267\245\344\275\215\357\274\210\350\241\245\346\235\277\345\220\216\345\267\245\344\275\215\357\274\211/Outbound/2\343\200\201DataProcess_RobotBuffer_IssueOutboundTask.cs" @@ -24,99 +24,132 @@ /// </summary> public static class DataProcess_RobotBuffer_IssueOutboundTask { + public static async void Handler() { var alertMsg = ""; - LogType logType = LogType.DataProcess_BZ39; + LogType logType = LogType.DataProcess_RobotBuffer_IssueOutboundTask; while (true) { - Thread.Sleep(2000);//浼戠湢2绉掞紝灏嗕紤鐪犲啓鍒板墠闈紝鏄负浜嗕笅闈㈢殑continue鏂规硶鎵ц鍚庝笉鏄剧ず閿欒淇℃伅鐨勬彁绀猴紒锛侊紒銆怑ditBy shaocx,2022-05-24銆� - SystemWarningMsg._lbl_alert_DataProcess_BZ39 = string.Empty; + Thread.Sleep(1000);//浼戠湢2绉掞紝灏嗕紤鐪犲啓鍒板墠闈紝鏄负浜嗕笅闈㈢殑continue鏂规硶鎵ц鍚庝笉鏄剧ず閿欒淇℃伅鐨勬彁绀猴紒锛侊紒銆怑ditBy shaocx,2022-05-24銆� + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = string.Empty; try - { - if (SystemValue.isAllowRuning_DataProcess_BZ39 && SystemValue.isStartedModel) + {//SystemValue.isAllowRuning_DataProcess_RobotBuffer_IssueOutboundTask && + if (SystemValue.isStartedModel) { var rgvLocation = StationLocationEnum.BZ39.ToString(); /* * 1銆佷粠鏁版嵁搴撲腑鍒ゆ柇鏄惁榻愬 * 2銆佹牴鎹綈濂楃粨鏋滐紝鎺ㄩ�佺粰PLC */ - var obj = FormCC.stationView.R_StationForReadCommList.Where(x => x.StationCode == rgvLocation.ToString()).FirstOrDefault(); - if (obj.R_ReqParseData) + + using (WmsDBModel wmsDB = new WmsDBModel()) { - var result = obj.R_ReadCodeResult; - if (string.IsNullOrEmpty(result)) - { - SystemWarningMsg._lbl_alert_DataProcess_BZ39 = $"{rgvLocation.ToString()}-璇锋眰浜嗚В鐮侊紝浣嗘槸缁撴灉鏄┖鐨�,姝ゆ寰幆缁撴潫"; - continue; - } - var upiCode = result; - var qitaoReault = false; - using (WmsDBModel wmsDB = new WmsDBModel()) - { - //瑕佹槸鏈夊凡涓嬪彂鐨勪换鍔★紝灏变笉瑕佹墽琛� - var isValidate = TaskHandler.ValidateIssueTaskForRobotBuffer(wmsDB); - if (!isValidate) - { - SystemWarningMsg._lbl_alert_DataProcess_BZ39 = $"{rgvLocation.ToString()}-鏈夆�樺凡涓嬪彂鈥欑殑浠诲姟锛屼笉鑳藉鐞�,姝ゆ寰幆缁撴潫"; - continue; - } - - - - var taskList = wmsDB.wms_rbline_task.Where(x => x.PlaceCode == obj.R_OutboundNumber - && x.RbTaskType == (int)RbTaskTypeEnum.鍑哄簱浠诲姟 - && x.TaskStatus == (int)TaskStatusEnum.鏂板缓).OrderBy(x => x.PackageCode).ToList(); - if (taskList == null) - { - SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()},鏍规嵁 R_OutboundNumber:{obj.R_OutboundNumber}娌℃湁鎵惧埌宸蹭笅鍙戠殑浠诲姟 "; - continue; - } - - var doTask = taskList.FirstOrDefault(); - - var upiObj = wmsDB.mes_batchOrderUPI_new.Where(x => x.UPI == upiCode).FirstOrDefault(); - if (upiObj == null) - { - SystemWarningMsg._lbl_alert_DataProcess_BZ39 = $"{rgvLocation.ToString()},鏍规嵁UPI:{upiCode}娌℃湁鎵惧埌瀵硅薄 "; - continue; - } - - //杩欓噷鏀逛负 涓嬪彂 鍑哄簱浠诲姟 + var noFinishOutTask = TaskHandler.ValidateIssueTaskForNoFinishTaskByOutStore(wmsDB); + if (noFinishOutTask == true) + {//琛ㄧず娌℃湁鏈粨鏉熺殑鍑哄簱浠诲姟锛岄偅涔堝氨 鍒濆鍖栬姹傚嚭搴撴寚浠� using (StationServiceClient client = new StationServiceClient()) { - //棣栧厛瑕佹竻鐞� - var res = await client.OutboundFinishConfirmAsync((int)EDevice.Station, true, rgvLocation); + var res = await client.WriteOutStoreTaskInfoAsync(true, (int)EDevice.Station, rgvLocation, "", 0); if (!res.result) { - SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()}-涓嬪彂鍑哄簱浠诲姟 澶辫触,OutboundFinishConfirmAsync 杩斿洖:{res.resMsg}"; + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()}-鍒濆鍖栬姹傚嚭搴撴寚浠� 澶辫触,WriteOutStoreTaskInfoAsync 杩斿洖:{res.resMsg}"; continue; } else { - Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-涓嬪彂鍑哄簱浠诲姟 鎴愬姛,OutboundFinishConfirmAsync锛屽弬鏁�: 绔欑偣{rgvLocation}"); - } - - res = await client.WriteOutStoreTaskInfoAsync((int)EDevice.Station, rgvLocation, doTask.PlaceCode, Convert.ToInt32(doTask.TaskNo)); - if (!res.result) - { - SystemWarningMsg._lbl_alert_DataProcess_BZ39 = $"{rgvLocation.ToString()}-涓嬪彂鍑哄簱浠诲姟 澶辫触,WriteOutStoreTaskInfoAsync 杩斿洖:{res.resMsg}"; - continue; - } - else - { - Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-涓嬪彂鍑哄簱浠诲姟 鎴愬姛,WriteOutStoreTaskInfoAsync锛屽弬鏁�: 绔欑偣{rgvLocation}"); + //Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-鍒濆鍖栬姹傚嚭搴撴寚浠� 鎴愬姛,WriteOutStoreTaskInfoAsync锛屽弬鏁�: 绔欑偣{rgvLocation}"); } } - - wmsDB.SaveChanges(); } + + //瑕佹槸鏈夊凡涓嬪彂鐨勪换鍔★紝灏变笉瑕佹墽琛� + var isValidate = TaskHandler.ValidateIssueOutTaskForRobotBuffer(wmsDB); + if (!isValidate) + { + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()}-鏈夆�樺凡涓嬪彂鈥欑殑浠诲姟锛屼笉鑳藉鐞�,姝ゆ寰幆缁撴潫"; + continue; + } + + //鍙栧垱寤烘椂闂存渶鏃╃殑閭d釜瑕佸嚭搴撶殑鍖� + if (string.IsNullOrEmpty(FormCC.currHandlerPackageCodeForIssueOutboundTask)) + { + var firstTask = wmsDB.wms_rbline_task.Where(x => + (x.RbTaskType == (int)RbTaskTypeEnum.榻愬寘鍑哄簱浠诲姟 || x.RbTaskType == (int)RbTaskTypeEnum.寮哄埗鍑哄簱浠诲姟) + && x.TaskStatus == (int)TaskStatusEnum.鏂板缓).OrderBy(x => x.CreateTime).FirstOrDefault(); + if (firstTask == null) + { + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()},鏍规嵁 娌℃湁鎵惧埌 鏂板缓 鐨勪换鍔� "; + FormCC.currHandlerPackageCodeForIssueOutboundTask = ""; + continue; + } + FormCC.currHandlerPackageCodeForIssueOutboundTask = firstTask.PackageCode; + } + else + { + var firstTask = wmsDB.wms_rbline_task.Where(x => + (x.RbTaskType == (int)RbTaskTypeEnum.榻愬寘鍑哄簱浠诲姟 || x.RbTaskType == (int)RbTaskTypeEnum.寮哄埗鍑哄簱浠诲姟) + && x.TaskStatus == (int)TaskStatusEnum.鏂板缓 + && x.PackageCode == FormCC.currHandlerPackageCodeForIssueOutboundTask + ).OrderBy(x => x.CreateTime).FirstOrDefault(); + if (firstTask == null) + { + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()},鏍规嵁 娌℃湁鎵惧埌 鏂板缓 鐨勪换鍔� "; + FormCC.currHandlerPackageCodeForIssueOutboundTask = ""; + continue; + } + } + + var taskList = wmsDB.wms_rbline_task.Where(x => + (x.RbTaskType == (int)RbTaskTypeEnum.榻愬寘鍑哄簱浠诲姟 || x.RbTaskType == (int)RbTaskTypeEnum.寮哄埗鍑哄簱浠诲姟) + && x.TaskStatus == (int)TaskStatusEnum.鏂板缓).Where(x => x.PackageCode == FormCC.currHandlerPackageCodeForIssueOutboundTask).OrderBy(x => x.CreateTime).ToList(); + if (taskList == null) + { + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()},鏍规嵁 娌℃湁鎵惧埌 鏂板缓 鐨勪换鍔� "; + continue; + } + + var doTask = taskList.FirstOrDefault(); + + + //杩欓噷涓嬪彂 鍑哄簱浠诲姟 + using (StationServiceClient client = new StationServiceClient()) + { + //棣栧厛瑕佹竻鐞� + //var res = await client.OutboundFinishConfirmAsync((int)EDevice.Station, false, rgvLocation); + //if (!res.result) + //{ + // SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()}-涓嬪彂鍑哄簱浠诲姟 澶辫触,OutboundFinishConfirmAsync 杩斿洖:{res.resMsg}"; + // continue; + //} + //else + //{ + // Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-涓嬪彂鍑哄簱浠诲姟 鎴愬姛,OutboundFinishConfirmAsync锛屽弬鏁�: 绔欑偣{rgvLocation}"); + //} + + var res = await client.WriteOutStoreTaskInfoAsync(false, (int)EDevice.Station, rgvLocation, doTask.PlaceCode, Convert.ToInt32(doTask.TaskNo)); + if (!res.result) + { + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask = $"{rgvLocation.ToString()}-涓嬪彂鍑哄簱浠诲姟 澶辫触,WriteOutStoreTaskInfoAsync 杩斿洖:{res.resMsg}"; + continue; + } + else + { + Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-涓嬪彂鍑哄簱浠诲姟 鎴愬姛,WriteOutStoreTaskInfoAsync锛屽弬鏁�: 绔欑偣{rgvLocation}"); + } + } + + doTask.TaskStatus = (int)TaskStatusEnum.宸蹭笅鍙�; + doTask.IssueTime = DateTime.Now; + + wmsDB.SaveChanges(); } + } } catch (Exception ex) { - SystemWarningMsg._lbl_alert_DataProcess_BZ39 += " 鍑虹幇寮傚父:" + ex.Message + SysGloble.SPLIT_STR; + SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_IssueOutboundTask += " 鍑虹幇寮傚父:" + ex.Message + SysGloble.SPLIT_STR; Log4NetHelper.WriteErrorLog(logType, " 鍑虹幇寮傚父锛�" + ex.Message, ex); } } -- Gitblit v1.9.3