From f46564ce50e256a884db070b4a492e2e170de9cc Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周五, 13 12月 2024 17:03:42 +0800
Subject: [PATCH] 222

---
 CC/iWareCC_ASRS/ThreadService/02_BZ39工位(补板后工位)/Outbound/3、DataProcess_RobotBuffer_FinishTaskForOutbound.cs |  161 +++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 123 insertions(+), 38 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/3\343\200\201DataProcess_RobotBuffer_FinishTaskForOutbound.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/3\343\200\201DataProcess_RobotBuffer_FinishTaskForOutbound.cs"
index 73063b4..7da8129 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/3\343\200\201DataProcess_RobotBuffer_FinishTaskForOutbound.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/3\343\200\201DataProcess_RobotBuffer_FinishTaskForOutbound.cs"
@@ -8,6 +8,7 @@
 using System;
 using System.Linq;
 using System.Threading;
+using System.Threading.Tasks;
 
 namespace iWareCC.ThreadService
 {
@@ -77,53 +78,59 @@
 
                                 }
 
-                                var upiCode = task.Upi;
-                                var upiObj = wmsDB.mes_batchOrderUPI_new.Where(x => x.UPI == upiCode).FirstOrDefault();
-                                if (upiObj == null)
+                                var isSuccess = await HandlerData(wmsDB, task, rgvLocation, logType, false);
+                                if (isSuccess == false)
                                 {
-                                    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()},鏍规嵁UPI:{upiCode}娌℃湁鎵惧埌瀵硅薄 ";
                                     continue;
                                 }
-                                //鏇存柊鏉夸欢鐨勭姸鎬佸拰鍖哄煙
-                                if (task.RbTaskType == (int)RbTaskTypeEnum.榻愬寘鍑哄簱浠诲姟)
-                                {
-                                    upiObj.UpiStatus = (int)UpiStatusEnum.宸查綈鍖�;
-                                    upiObj.AreaCode = (int)AreaCodeEnum.鐮佸灈鍖哄煙;
-                                }
-                                else if (task.RbTaskType == (int)RbTaskTypeEnum.寮哄埗鍑哄簱浠诲姟)
-                                {
-                                    upiObj.UpiStatus = (int)UpiStatusEnum.宸蹭笅绾�;
-                                    upiObj.AreaCode = (int)AreaCodeEnum.涓嬬嚎鍖哄煙;
-                                }
 
-                                //搴撳瓨鍑忓皯
-                                wms_stock_quan qun = wmsDB.wms_stock_quan.Where(x => x.PlaceCode == task.PlaceCode).FirstOrDefault();
-                                wmsDB.wms_stock_quan.Remove(qun);
+                                //var upiCode = task.Upi;
+                                //var upiObj = wmsDB.mes_batchOrderUPI_new.Where(x => x.UPI == upiCode).FirstOrDefault();
+                                //if (upiObj == null)
+                                //{
+                                //    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()},鏍规嵁UPI:{upiCode}娌℃湁鎵惧埌瀵硅薄 ";
+                                //    continue;
+                                //}
+                                ////鏇存柊鏉夸欢鐨勭姸鎬佸拰鍖哄煙
+                                //if (task.RbTaskType == (int)RbTaskTypeEnum.榻愬寘鍑哄簱浠诲姟)
+                                //{
+                                //    upiObj.UpiStatus = (int)UpiStatusEnum.宸查綈鍖�;
+                                //    upiObj.AreaCode = (int)AreaCodeEnum.鐮佸灈鍖哄煙;
+                                //}
+                                //else if (task.RbTaskType == (int)RbTaskTypeEnum.寮哄埗鍑哄簱浠诲姟)
+                                //{
+                                //    upiObj.UpiStatus = (int)UpiStatusEnum.宸蹭笅绾�;
+                                //    upiObj.AreaCode = (int)AreaCodeEnum.涓嬬嚎鍖哄煙;
+                                //}
 
-                                task.TaskStatus = (int)TaskStatusEnum.宸插畬鎴�;
-                                task.FinishedTime = DateTime.Now;
+                                ////搴撳瓨鍑忓皯
+                                //wms_stock_quan qun = wmsDB.wms_stock_quan.Where(x => x.PlaceCode == task.PlaceCode).FirstOrDefault();
+                                //wmsDB.wms_stock_quan.Remove(qun);
 
-                                var place = StationHandler.GetPlaceByPlaceCode(task.PlaceCode, wmsDB);
-                                place.PlaceStatus = (int)PlaceStatusEnum.姝e父;
+                                //task.TaskStatus = (int)TaskStatusEnum.宸插畬鎴�;
+                                //task.FinishedTime = DateTime.Now;
 
-                                //缁橮LC鎺ㄩ�佷换鍔″畬鎴愮‘璁や俊鍙�
-                                using (StationServiceClient client = new StationServiceClient())
-                                {
-                                    var res = await client.OutboundFinishConfirmAsync((int)EDevice.Station, true, rgvLocation, true);
-                                    if (!res.result)
-                                    {
-                                        SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()}-涓嬪彂鍑哄簱浠诲姟 澶辫触,OutboundFinishConfirmAsync 杩斿洖:{res.resMsg}";
-                                        continue;
-                                    }
-                                    else
-                                    {
-                                        Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-涓嬪彂鍑哄簱浠诲姟 鎴愬姛,OutboundFinishConfirmAsync锛屽弬鏁�: 绔欑偣{rgvLocation}");
-                                    }
-                                }
+                                //var place = StationHandler.GetPlaceByPlaceCode(task.PlaceCode, wmsDB);
+                                //place.PlaceStatus = (int)PlaceStatusEnum.姝e父;
 
-                                WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, task.PlaceCode, $"鍑虹紦瀛樺簱锛歿task.PlaceCode}," + task.TaskMsg);
+                                ////缁橮LC鎺ㄩ�佷换鍔″畬鎴愮‘璁や俊鍙�
+                                //using (StationServiceClient client = new StationServiceClient())
+                                //{
+                                //    var res = await client.OutboundFinishConfirmAsync((int)EDevice.Station, true, rgvLocation, true);
+                                //    if (!res.result)
+                                //    {
+                                //        SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()}-涓嬪彂鍑哄簱浠诲姟 澶辫触,OutboundFinishConfirmAsync 杩斿洖:{res.resMsg}";
+                                //        continue;
+                                //    }
+                                //    else
+                                //    {
+                                //        Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-涓嬪彂鍑哄簱浠诲姟 鎴愬姛,OutboundFinishConfirmAsync锛屽弬鏁�: 绔欑偣{rgvLocation}");
+                                //    }
+                                //}
 
-                                wmsDB.SaveChanges();
+                                //WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, task.PlaceCode, $"鍑虹紦瀛樺簱锛歿task.PlaceCode}," + task.TaskMsg);
+
+                                //wmsDB.SaveChanges();
                             }
                         }
                         else
@@ -131,6 +138,26 @@
                             using (StationServiceClient client = new StationServiceClient())
                             {
                                 var res = await client.OutboundFinishConfirmAsync((int)EDevice.Station, false, rgvLocation, false);
+                            }
+
+                            using (WmsDBModel wmsDB = new WmsDBModel())
+                            {
+                                var task = wmsDB.wms_rbline_task.Where(x =>
+                                 x.IsFlagFinish == true
+                               && (x.RbTaskType == (int)RbTaskTypeEnum.榻愬寘鍑哄簱浠诲姟 || x.RbTaskType == (int)RbTaskTypeEnum.寮哄埗鍑哄簱浠诲姟)
+                                && x.TaskStatus == (int)TaskStatusEnum.宸蹭笅鍙�
+                                ).OrderByDescending(x => x.Id).FirstOrDefault();
+                                if (task == null)
+                                {
+                                    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()},娌℃湁鎵惧埌宸蹭笅鍙�,骞朵笖鏍囪寮哄埗瀹屾垚鐨勪换鍔� ";
+                                    continue;
+                                }
+
+                                var isSuccess = await HandlerData(wmsDB, task, rgvLocation, logType, true);
+                                if (isSuccess == false)
+                                {
+                                    continue;
+                                }
                             }
                         }
                     }
@@ -143,5 +170,63 @@
             }
         }
 
+
+        public static async Task<bool> HandlerData(WmsDBModel wmsDB, wms_rbline_task task, string rgvLocation, iWareCommon.Utils.LogType logType, bool isFlagFinish)
+        {
+            var upiCode = task.Upi;
+            var upiObj = wmsDB.mes_batchOrderUPI_new.Where(x => x.UPI == upiCode).FirstOrDefault();
+            if (upiObj == null)
+            {
+                SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()},鏍规嵁UPI:{upiCode}娌℃湁鎵惧埌瀵硅薄 ";
+                return false;
+            }
+            //鏇存柊鏉夸欢鐨勭姸鎬佸拰鍖哄煙
+            if (task.RbTaskType == (int)RbTaskTypeEnum.榻愬寘鍑哄簱浠诲姟)
+            {
+                upiObj.UpiStatus = (int)UpiStatusEnum.宸查綈鍖�;
+                upiObj.AreaCode = (int)AreaCodeEnum.鐮佸灈鍖哄煙;
+            }
+            else if (task.RbTaskType == (int)RbTaskTypeEnum.寮哄埗鍑哄簱浠诲姟)
+            {
+                upiObj.UpiStatus = (int)UpiStatusEnum.宸蹭笅绾�;
+                upiObj.AreaCode = (int)AreaCodeEnum.涓嬬嚎鍖哄煙;
+            }
+
+            //搴撳瓨鍑忓皯
+            wms_stock_quan qun = wmsDB.wms_stock_quan.Where(x => x.PlaceCode == task.PlaceCode).FirstOrDefault();
+            wmsDB.wms_stock_quan.Remove(qun);
+
+            task.TaskStatus = (int)TaskStatusEnum.宸插畬鎴�;
+            task.FinishedTime = DateTime.Now;
+
+            var place = StationHandler.GetPlaceByPlaceCode(task.PlaceCode, wmsDB);
+            place.PlaceStatus = (int)PlaceStatusEnum.姝e父;
+
+            if (isFlagFinish == false)
+            {
+                //缁橮LC鎺ㄩ�佷换鍔″畬鎴愮‘璁や俊鍙�
+                using (StationServiceClient client = new StationServiceClient())
+                {
+                    var res = await client.OutboundFinishConfirmAsync((int)EDevice.Station, true, rgvLocation, true);
+                    if (!res.result)
+                    {
+                        SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTaskForOutbound = $"{rgvLocation.ToString()}-涓嬪彂鍑哄簱浠诲姟 澶辫触,OutboundFinishConfirmAsync 杩斿洖:{res.resMsg}";
+                        return false;
+                    }
+                    else
+                    {
+                        Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-涓嬪彂鍑哄簱浠诲姟 鎴愬姛,OutboundFinishConfirmAsync锛屽弬鏁�: 绔欑偣{rgvLocation}");
+                    }
+                }
+            }
+
+            var flag = isFlagFinish ? "浜哄伐寮哄埗瀹屾垚" : "锛堣嚜鍔ㄥ畬鎴愶級";
+            WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, task.PlaceCode, $"鍑虹紦瀛樺簱锛歿task.PlaceCode}(" + flag + ")," + task.TaskMsg);
+
+            wmsDB.SaveChanges();
+
+            return true;
+        }
+
     }
 }

--
Gitblit v1.9.3