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

---
 CC/iWareCC_ASRS/ThreadService/02_BZ39工位(补板后工位)/Inbound/3、DataProcess_RobotBuffer_FinishTask.cs |  195 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 145 insertions(+), 50 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/Inbound/3\343\200\201DataProcess_RobotBuffer_FinishTask.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/Inbound/3\343\200\201DataProcess_RobotBuffer_FinishTask.cs"
index 1e72172..545466a 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/Inbound/3\343\200\201DataProcess_RobotBuffer_FinishTask.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/Inbound/3\343\200\201DataProcess_RobotBuffer_FinishTask.cs"
@@ -1,5 +1,6 @@
 锘縰sing Admin.NET.Application;
 using iWareCC.Common.Helper;
+using iWareCC.SrmService;
 using iWareCC.StationService;
 using iWareCommon.Common.Globle;
 using iWareCommon.Utils;
@@ -9,6 +10,7 @@
 using iWareSql.WmsDBModel;
 using System;
 using System.Collections.Generic;
+using System.Data.Entity.Core.Metadata.Edm;
 using System.Linq;
 using System.ServiceModel.Configuration;
 using System.Text;
@@ -16,6 +18,7 @@
 using System.Threading.Tasks;
 using WZ.Useful.Commons;
 using XiGang.Core.Model;
+using LogType = iWareCommon.Utils.LogType;
 
 namespace iWareCC.ThreadService
 {
@@ -34,7 +37,7 @@
                 SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTask = string.Empty;
                 try
                 {
-                    if ( SystemValue.isStartedModel)//SystemValue.isAllowRuning_DataProcess_RobotBuffer_FinishTask &&
+                    if (SystemValue.isStartedModel)//SystemValue.isAllowRuning_DataProcess_RobotBuffer_FinishTask &&
                     {
                         var rgvLocation = StationLocationEnum.BZ39.ToString();
                         if (FormCC.stationView == null)
@@ -51,86 +54,92 @@
                                 SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTask = $"{rgvLocation.ToString()}- 鍏ュ簱浠诲姟鍙锋槸绌虹殑,姝ゆ寰幆缁撴潫";
                                 continue;
                             }
-                         
+
                             using (WmsDBModel wmsDB = new WmsDBModel())
                             {
                                 var task = wmsDB.wms_rbline_task.Where(x =>
                                  x.TaskNo == obj.R_Inbound_TaskID.ToString()
                                 && x.RbTaskType == (int)RbTaskTypeEnum.鍏ュ簱浠诲姟
-                                ).OrderByDescending(x=>x.Id).FirstOrDefault();
+                                ).OrderByDescending(x => x.Id).FirstOrDefault();
                                 if (task == null)
                                 {
                                     SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTask = $"{rgvLocation.ToString()},鏍规嵁 R_InboundNumber:{obj.R_InboundNumber}娌℃湁鎵惧埌宸蹭笅鍙戠殑浠诲姟 ";
                                     continue;
                                 }
-                                else 
+                                else
                                 {
                                     if (task.TaskStatus == (int)TaskStatusEnum.宸插畬鎴�)
                                     {
                                         using (StationServiceClient client = new StationServiceClient())
                                         {
                                             var res = await client.InboundFinishConfirmAsync((int)EDevice.Station, true, rgvLocation);
-                             
+
                                         }
                                         continue;
                                     }
                                 }
 
-                                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_FinishTask = $"{rgvLocation.ToString()},鏍规嵁UPI:{upiCode}娌℃湁鎵惧埌瀵硅薄 ";
                                     continue;
                                 }
-                                //澧炲姞搴撳瓨
-                                wms_stock_quan qun = new wms_stock_quan()
-                                {
-                                    Id = Yitter.IdGenerator.YitIdHelper.NextId(),
-                                    Upi = upiCode,
-                                    PlanNo = task.PlanNo,
-                                    DetailName = upiObj.DetailName,
-                                    OrderId = task.OrderId,
-                                    CreateTime = DateTime.Now,
-                                    CreateUserName = "CC",
-                                    InTime = DateTime.Now,
-                                    OperReason = "鍏ュ簱",
-                                    PackageCode = task.PackageCode,
-                                    Length = task.Length,
-                                    Width = task.Width,
-                                    Thk = task.Thk,
-                                    PlaceCode = task.PlaceCode,
-                                    StockStatus = (int)StockStatusEnum.鍦ㄥ簱,
-                                    StockStatusName = StockStatusEnum.鍦ㄥ簱.ToString(),
 
-                                };
-                                wmsDB.wms_stock_quan.Add(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_FinishTask = $"{rgvLocation.ToString()},鏍规嵁UPI:{upiCode}娌℃湁鎵惧埌瀵硅薄 ";
+                                //    continue;
+                                //}
+                                ////澧炲姞搴撳瓨
+                                //wms_stock_quan qun = new wms_stock_quan()
+                                //{
+                                //    Id = Yitter.IdGenerator.YitIdHelper.NextId(),
+                                //    Upi = upiCode,
+                                //    PlanNo = task.PlanNo,
+                                //    DetailName = upiObj.DetailName,
+                                //    OrderId = task.OrderId,
+                                //    CreateTime = DateTime.Now,
+                                //    CreateUserName = "CC",
+                                //    InTime = DateTime.Now,
+                                //    OperReason = "鍏ュ簱",
+                                //    PackageCode = task.PackageCode,
+                                //    Length = task.Length,
+                                //    Width = task.Width,
+                                //    Thk = task.Thk,
+                                //    PlaceCode = task.PlaceCode,
+                                //    StockStatus = (int)StockStatusEnum.鍦ㄥ簱,
+                                //    StockStatusName = StockStatusEnum.鍦ㄥ簱.ToString(),
 
-                                task.TaskStatus = (int)TaskStatusEnum.宸插畬鎴�;
-                                task.FinishedTime = DateTime.Now;
+                                //};
+                                //wmsDB.wms_stock_quan.Add(qun);
+
+                                //task.TaskStatus = (int)TaskStatusEnum.宸插畬鎴�;
+                                //task.FinishedTime = DateTime.Now;
 
 
-                                var place = StationHandler.GetPlaceByPlaceCode(task.PlaceCode, wmsDB);
-                                place.PlaceStatus = (int)PlaceStatusEnum.姝e父;
+                                //var place = StationHandler.GetPlaceByPlaceCode(task.PlaceCode, wmsDB);
+                                //place.PlaceStatus = (int)PlaceStatusEnum.姝e父;
 
-                                //缁橮LC鎺ㄩ�佷换鍔″畬鎴愮‘璁や俊鍙�
-                                using (StationServiceClient client = new StationServiceClient())
-                                {
-                                    var res = await client.InboundFinishConfirmAsync((int)EDevice.Station, true, rgvLocation);
-                                    if (!res.result)
-                                    {
-                                        SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTask = $"{rgvLocation.ToString()}-涓嬪彂鍏ュ簱浠诲姟 澶辫触,InboundFinishConfirmAsync 杩斿洖:{res.resMsg}";
-                                        continue;
-                                    }
-                                    else
-                                    {
-                                        Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-涓嬪彂鍏ュ簱浠诲姟 鎴愬姛,InboundFinishConfirmAsync锛屽弬鏁�: 绔欑偣{rgvLocation}");
-                                    }
-                                }
+                                ////缁橮LC鎺ㄩ�佷换鍔″畬鎴愮‘璁や俊鍙�
+                                //using (StationServiceClient client = new StationServiceClient())
+                                //{
+                                //    var res = await client.InboundFinishConfirmAsync((int)EDevice.Station, true, rgvLocation);
+                                //    if (!res.result)
+                                //    {
+                                //        SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTask = $"{rgvLocation.ToString()}-涓嬪彂鍏ュ簱浠诲姟 澶辫触,InboundFinishConfirmAsync 杩斿洖:{res.resMsg}";
+                                //        continue;
+                                //    }
+                                //    else
+                                //    {
+                                //        Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-涓嬪彂鍏ュ簱浠诲姟 鎴愬姛,InboundFinishConfirmAsync锛屽弬鏁�: 绔欑偣{rgvLocation}");
+                                //    }
+                                //}
 
-                                WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, task.PlaceCode, "缂撳瓨鍏ュ簱瀹屾垚:"+ task.PlaceCode);
+                                //WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, task.PlaceCode, "缂撳瓨鍏ュ簱瀹屾垚:" + task.PlaceCode);
 
-                                wmsDB.SaveChanges();
+                                //wmsDB.SaveChanges();
                             }
                         }
                         else
@@ -144,6 +153,26 @@
 
                             }
 
+                            using (WmsDBModel wmsDB = new WmsDBModel())
+                            {
+                                var task = wmsDB.wms_rbline_task.Where(x =>
+                                 x.IsFlagFinish == true
+                                && x.RbTaskType == (int)RbTaskTypeEnum.鍏ュ簱浠诲姟
+                                && x.TaskStatus == (int)TaskStatusEnum.宸蹭笅鍙�
+                                ).OrderByDescending(x => x.Id).FirstOrDefault();
+                                if (task == null)
+                                {
+                                    SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTask = $"{rgvLocation.ToString()},娌℃湁鎵惧埌宸蹭笅鍙�,骞朵笖鏍囪寮哄埗瀹屾垚鐨勪换鍔� ";
+                                    continue;
+                                }
+
+                                var isSuccess = await HandlerData(wmsDB, task, rgvLocation, logType, true);
+                                if (isSuccess == false)
+                                {
+                                    continue;
+                                }
+                            }
+
                         }
                     }
                 }
@@ -155,5 +184,71 @@
             }
         }
 
+
+        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_FinishTask = $"{rgvLocation.ToString()},鏍规嵁UPI:{upiCode}娌℃湁鎵惧埌瀵硅薄 ";
+                return false;
+            }
+            //澧炲姞搴撳瓨
+            wms_stock_quan qun = new wms_stock_quan()
+            {
+                Id = Yitter.IdGenerator.YitIdHelper.NextId(),
+                Upi = upiCode,
+                PlanNo = task.PlanNo,
+                DetailName = upiObj.DetailName,
+                OrderId = task.OrderId,
+                CreateTime = DateTime.Now,
+                CreateUserName = "CC",
+                InTime = DateTime.Now,
+                OperReason = "鍏ュ簱",
+                PackageCode = task.PackageCode,
+                Length = task.Length,
+                Width = task.Width,
+                Thk = task.Thk,
+                PlaceCode = task.PlaceCode,
+                StockStatus = (int)StockStatusEnum.鍦ㄥ簱,
+                StockStatusName = StockStatusEnum.鍦ㄥ簱.ToString(),
+
+            };
+            wmsDB.wms_stock_quan.Add(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.InboundFinishConfirmAsync((int)EDevice.Station, true, rgvLocation);
+                    if (!res.result)
+                    {
+                        SystemWarningMsg._lbl_Alert_DataProcess_RobotBuffer_FinishTask = $"{rgvLocation.ToString()}-涓嬪彂鍏ュ簱浠诲姟 澶辫触,InboundFinishConfirmAsync 杩斿洖:{res.resMsg}";
+                        return false;
+                    }
+                    else
+                    {
+                        Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-涓嬪彂鍏ュ簱浠诲姟 鎴愬姛,InboundFinishConfirmAsync锛屽弬鏁�: 绔欑偣{rgvLocation}");
+                    }
+                }
+            }
+
+
+            WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, task.PlaceCode, "缂撳瓨鍏ュ簱瀹屾垚:" + task.PlaceCode);
+
+            wmsDB.SaveChanges();
+
+            return true;
+        }
+
     }
 }

--
Gitblit v1.9.3