From 06d6ba0da4d9036bf3eeab8a7cbef8df89565606 Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周一, 16 12月 2024 17:19:05 +0800
Subject: [PATCH] BZ01 齐包优化

---
 CC/iWareCC_ASRS/ThreadService/01_BZ01工位(清灰,洗板后工位)/DataProcess_BZ01.cs |  405 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 369 insertions(+), 36 deletions(-)

diff --git "a/CC/iWareCC_ASRS/ThreadService/01_BZ01\345\267\245\344\275\215\357\274\210\346\270\205\347\201\260\357\274\214\346\264\227\346\235\277\345\220\216\345\267\245\344\275\215\357\274\211/DataProcess_BZ01.cs" "b/CC/iWareCC_ASRS/ThreadService/01_BZ01\345\267\245\344\275\215\357\274\210\346\270\205\347\201\260\357\274\214\346\264\227\346\235\277\345\220\216\345\267\245\344\275\215\357\274\211/DataProcess_BZ01.cs"
index 3d3307b..ab98464 100644
--- "a/CC/iWareCC_ASRS/ThreadService/01_BZ01\345\267\245\344\275\215\357\274\210\346\270\205\347\201\260\357\274\214\346\264\227\346\235\277\345\220\216\345\267\245\344\275\215\357\274\211/DataProcess_BZ01.cs"
+++ "b/CC/iWareCC_ASRS/ThreadService/01_BZ01\345\267\245\344\275\215\357\274\210\346\270\205\347\201\260\357\274\214\346\264\227\346\235\277\345\220\216\345\267\245\344\275\215\357\274\211/DataProcess_BZ01.cs"
@@ -11,6 +11,7 @@
 using System.Linq;
 using System.Net.NetworkInformation;
 using System.Reflection.Emit;
+using System.Security.Cryptography.X509Certificates;
 using System.ServiceModel.Configuration;
 using System.Text;
 using System.Threading;
@@ -24,6 +25,8 @@
     /// </summary>
     public static class DataProcess_BZ01
     {
+        public static string timingForWait = "";//瀹氭椂鍣紝绛夊緟鏁版嵁
+
         /// <summary>
         /// BZ01宸ヤ綅锛堟竻鐏帮紝娲楁澘鍚庡伐浣嶏級
         /// </summary>
@@ -31,6 +34,8 @@
         {
             var alertMsg = "";
             LogType logType = LogType.DataProcess_BZ01;
+            string lastUpi = "";//鏈�鍚庤褰曠殑UPI鏁版嵁
+
             while (true)
             {
                 Thread.Sleep(1000);//浼戠湢2绉掞紝灏嗕紤鐪犲啓鍒板墠闈紝鏄负浜嗕笅闈㈢殑continue鏂规硶鎵ц鍚庝笉鏄剧ず閿欒淇℃伅鐨勬彁绀猴紒锛侊紒銆怑ditBy shaocx,2022-05-24銆�
@@ -44,6 +49,7 @@
                             SystemWarningMsg._lbl_alert_DataProcess_BZ01 = $"姝e湪骞插嚭搴撴ā寮忥紝姝ゆ柟娉曟殏鍋溿�傘�� ";
                             continue;
                         }
+
 
                         var rgvLocation = StationLocationEnum.BZ01.ToString();
                         /*
@@ -64,7 +70,14 @@
                                 SystemWarningMsg._lbl_alert_DataProcess_BZ01 = $"{rgvLocation.ToString()}-璇锋眰浜嗚В鐮侊紝浣嗘槸缁撴灉鏄┖鐨�,姝ゆ寰幆缁撴潫";
                                 continue;
                             }
+                            if (lastUpi == result)
+                            {
+                                SystemWarningMsg._lbl_alert_DataProcess_BZ01 = $"{rgvLocation.ToString()}-閲嶅鐨刄PI{result}";
+                                continue;
+                            }
                             var upiCode = result;
+                            lastUpi = upiCode;
+
                             var qitaoReault = false;//榻愬寘缁撴灉
                             using (WmsDBModel wmsDB = new WmsDBModel())
                             {
@@ -85,6 +98,97 @@
                                     continue;
                                 }
 
+                                //澧炲姞瀵瑰弬鏁伴厤缃殑绠$悊 銆怑ditby shaocx,2024-12-13銆�
+                                var sysConfig = wmsDB.SysConfig.Where(x => x.Code == "LastUpi_BZ01").FirstOrDefault();
+                                if (sysConfig == null)
+                                {
+                                    SystemWarningMsg._lbl_alert_DataProcess_BZ01 = $"娌℃湁鑾峰彇鍒� LastUpi_BZ01鐨勯厤缃俊鎭� ";
+                                    continue;
+                                }
+                                var config_value = sysConfig.Value;
+                                if (config_value.IndexOf('|') > -1)
+                                {//鏍煎紡涓�  鍖呭彿|UPI|娆″簭|榻愬寘鐘舵��
+                                    var arr = config_value.Split('|');
+                                    var lastPackageCode = arr[0];
+                                    var lastUpi_BZ01 = arr[1];
+                                    var lastShelf = Convert.ToInt32(arr[2]);
+                                    var lastQitaoReault = arr[3];
+
+                                    if (upiObj.PackageCode == lastPackageCode)
+                                    {
+                                        if (upiObj.Shelf == (lastShelf + 1))
+                                        {
+                                            //榻愬寘鐘舵��
+                                            if (lastQitaoReault == "榻愬寘")
+                                            {
+                                                qitaoReault = true;
+                                            }
+                                            else
+                                            {
+                                                qitaoReault = false;
+                                            }
+                                        }
+                                        else
+                                        {//涓嶉綈鍖�
+                                            qitaoReault = false;
+                                        }
+                                    }
+                                    else
+                                    {//璇存槑鏄崲浜嗗寘鍙凤紝閲嶆柊楠岃瘉 榻愬寘鐘舵��
+                                        #region 璁$畻鏄惁榻愬寘
+                                        qitaoReault = ValidateQiBao(wmsDB, upiObj);
+                                        #endregion
+                                    }
+                                }
+                                else
+                                {//琛ㄧず杩樻病鏈夐厤缃� 锛岄噸鏂伴獙璇� 榻愬寘鐘舵��
+                                    #region 璁$畻鏄惁榻愬寘
+                                    qitaoReault = ValidateQiBao(wmsDB, upiObj);
+                                    #endregion
+                                }
+
+                                //澧炲姞浼樺寲楠岃瘉 銆怑ditby shaocx,2024-12-16銆�
+                                if (qitaoReault == false)
+                                {
+                                    var lastPackageUpi_269 = FormCC.Globle_269_LastPackageUpi;
+                                    if (!string.IsNullOrEmpty(lastPackageUpi_269))
+                                    {
+                                        var arr = lastPackageUpi_269.Split('|');
+                                        if (upiObj.PackageCode == arr[0])
+                                        {//鏈�鍚庝竴娆″湪269鎵弿鐨勫寘鍙� 璺� 鐜板湪BZ01鐨勫寘鍙蜂竴鑷�,瑕佺瓑寰�
+                                         //wait
+                                            var isWaitOutTime = Wait269(wmsDB);
+                                            if (isWaitOutTime == false)
+                                            {
+                                                continue;
+                                            }
+                                        }
+                                        else
+                                        {
+                                            //缁х画寰�涓嬭蛋
+                                        }
+                                    }
+                                    else
+                                    {
+                                        //wait
+                                        var isWaitOutTime = Wait269(wmsDB);
+                                        if (isWaitOutTime == false)
+                                        {
+                                            continue;
+                                        }
+                                    }
+                                }
+
+                                timingForWait = "";//閲嶇疆鏁版嵁
+                                if (qitaoReault == false)
+                                {
+                                    upiObj.AreaCode = (int)AreaCodeEnum.缂撳瓨鍒嗘嫞鍖�;
+                                }
+                                else
+                                {
+                                    upiObj.AreaCode = (int)AreaCodeEnum.鐮佸灈鍖哄煙;
+                                }
+                                /*
                                 //鏌ヨ鏄惁榻愬寘
                                 var allList = wmsDB.mes_batchOrderUPI_new.Where(x => x.PackageCode == upiObj.PackageCode).ToList();
                                 var isQiTaoList = allList.Where(x => x.AreaCode == (int)AreaCodeEnum.寰呯紦瀛樺垎鎷e尯
@@ -119,47 +223,80 @@
                                         }
                                         else
                                         {
-                                            //杩橀渶瑕侀獙璇佸湪杩欎簺鍖哄煙涓紝鏄惁姝g‘鎺掗槦锛屽鏋滄病鏈夋纭帓闃燂紝閭d箞灏辫涓轰笉榻愬 銆怑ditby shaocx,2024-12-12銆�
-                                            var queueList = wmsDB.mes_upi_linequeue.Where(x => x.PackageCode == upiObj.PackageCode && x.AreaCode == queryAreaCode)
-                                                .OrderBy(x => x.Id).ToList();
-                                            var fisrtId = queueList.OrderBy(x => x.Id).First().Id;
-                                            var endId = queueList.OrderByDescending(x => x.Id).First().Id;
-                                            //缁х画鏌ヨ杩欎釜鏃堕棿娈靛唴鐨勯槦鍒楁暟鎹�
-                                            //閲嶅啓璇ラ槦鍒�
-                                            queueList = wmsDB.mes_upi_linequeue.Where(x => x.Id >= fisrtId && x.Id <= endId).OrderBy(x => x.Id).ToList();
-                                            var syCount = allList.Where(x => x.Shelf >= upiObj.Shelf).Count();
-                                            if (queueList.Count() != syCount)
+                                            var isJiXuValidate = true;
+                                            if (upiObj.Shelf != 1)
                                             {
-                                                qitaoReault = false;
-                                                upiObj.AreaCode = (int)AreaCodeEnum.缂撳瓨鍒嗘嫞鍖�;
-                                            }
-                                            else
-                                            {
-                                                //鍒ゆ柇鏄惁涔卞簭
-                                                bool isLuanXuan = false;
-                                                int temp_shelf = 0;
-                                                for (int i = 0; i < queueList.Count; i++)
+                                                var qianmianList = allList.Where(x => x.Shelf < upiObj.Shelf).ToList();
+                                                //鐪嬩互鍓嶇殑鏉垮湪鍝噷锛屽繀椤婚兘鍦� 鐮佸灈鍖哄煙
+                                                var yiqianQuyu = AreaCodeEnum.鐮佸灈鍖哄煙;
+                                                var count_MD = qianmianList.Where(x => x.AreaCode == (int)yiqianQuyu).Count();
+                                                if (count_MD != qianmianList.Count())
                                                 {
-                                                    if (i == 0)
+                                                    isJiXuValidate = false;
+                                                    qitaoReault = false;
+                                                    upiObj.AreaCode = (int)AreaCodeEnum.缂撳瓨鍒嗘嫞鍖�;
+                                                }
+                                            }
+
+                                            if (isJiXuValidate)
+                                            {//鏄惁缁х画楠岃瘉
+                                                //杩橀渶瑕侀獙璇佸湪杩欎簺鍖哄煙涓紝鏄惁姝g‘鎺掗槦锛屽鏋滄病鏈夋纭帓闃燂紝閭d箞灏辫涓轰笉榻愬 銆怑ditby shaocx,2024-12-12銆�
+                                                var queueList = wmsDB.mes_upi_linequeue.Where(x => x.PackageCode == upiObj.PackageCode && x.AreaCode == queryAreaCode)
+                                                    .OrderBy(x => x.Id).ToList();
+                                                var fisrtId = queueList.OrderBy(x => x.Id).First().Id;
+                                                var endId = queueList.OrderByDescending(x => x.Id).First().Id;
+                                                //缁х画鏌ヨ杩欎釜鏃堕棿娈靛唴鐨勯槦鍒楁暟鎹�
+                                                //閲嶅啓璇ラ槦鍒�
+                                                queueList = wmsDB.mes_upi_linequeue.Where(x => x.Id >= fisrtId && x.Id <= endId).OrderBy(x => x.Id).ToList();
+                                                var syCount = allList.Where(x => x.Shelf >= upiObj.Shelf).Count();
+                                                if (queueList.Count() != syCount)
+                                                {
+                                                    qitaoReault = false;
+                                                    upiObj.AreaCode = (int)AreaCodeEnum.缂撳瓨鍒嗘嫞鍖�;
+                                                }
+                                                else
+                                                {
+                                                    //鍒ゆ柇鏄惁涔卞簭
+                                                    bool isLuanXuan = false;
+                                                    int temp_shelf = 0;
+                                                    for (int i = 0; i < queueList.Count; i++)
                                                     {
-                                                        temp_shelf = queueList[i].Shelf;
-                                                    }
-                                                    else
-                                                    {
-                                                        if ((temp_shelf + 1) != queueList[i].Shelf)
-                                                        {//璁や负涔卞簭浜�
-                                                            qitaoReault = false;
-                                                            isLuanXuan = true;
-                                                            upiObj.AreaCode = (int)AreaCodeEnum.缂撳瓨鍒嗘嫞鍖�;
-                                                            break;//璺冲嚭寰幆
+                                                        if (i == 0)
+                                                        {
+                                                            temp_shelf = queueList[i].Shelf;
+                                                            if (temp_shelf != upiObj.Shelf)
+                                                            {
+                                                                qitaoReault = false;
+                                                                isLuanXuan = true;
+                                                                upiObj.AreaCode = (int)AreaCodeEnum.缂撳瓨鍒嗘嫞鍖�;
+                                                                break;//璺冲嚭寰幆
+                                                            }
+                                                            if (queueList[i].Upi != upiObj.UPI)
+                                                            {
+                                                                qitaoReault = false;
+                                                                isLuanXuan = true;
+                                                                upiObj.AreaCode = (int)AreaCodeEnum.缂撳瓨鍒嗘嫞鍖�;
+                                                                break;//璺冲嚭寰幆
+                                                            }
+                                                        }
+                                                        else
+                                                        {
+                                                            temp_shelf = temp_shelf + 1;
+                                                            if (temp_shelf != queueList[i].Shelf)
+                                                            {//璁や负涔卞簭浜�
+                                                                qitaoReault = false;
+                                                                isLuanXuan = true;
+                                                                upiObj.AreaCode = (int)AreaCodeEnum.缂撳瓨鍒嗘嫞鍖�;
+                                                                break;//璺冲嚭寰幆
+                                                            }
                                                         }
                                                     }
-                                                }
 
-                                                if (isLuanXuan == false)
-                                                {
-                                                    qitaoReault = true;
-                                                    upiObj.AreaCode = (int)AreaCodeEnum.鐮佸灈鍖哄煙;
+                                                    if (isLuanXuan == false)
+                                                    {
+                                                        qitaoReault = true;
+                                                        upiObj.AreaCode = (int)AreaCodeEnum.鐮佸灈鍖哄煙;
+                                                    }
                                                 }
                                             }
                                         }
@@ -168,6 +305,12 @@
                                         wmsDB.mes_upi_linequeue.Remove(lastUpiLineQueue);
                                     }
                                 }
+                                //*/
+                                //if (qitaoReault == false) {
+                                //    //涓存椂
+                                //    SystemWarningMsg._lbl_alert_DataProcess_BZ01 = $"妯℃嫙鍟婂晩锛屾殏鍋滃晩鍟�";
+                                //    continue;
+                                //}
 
                                 using (StationServiceClient client = new StationServiceClient())
                                 {
@@ -183,6 +326,19 @@
                                     }
                                 }
 
+                                var str_qitaoReault = (qitaoReault ? "榻愬寘" : "涓嶉綈鍖�");
+                                //璁板綍涓嬬粨鏋�
+                                sysConfig.Value = upiObj.PackageCode + "|" + upiObj.UPI + "|" + upiObj.Shelf + "|" + str_qitaoReault;
+
+                                //鍒犻櫎璇PI鐨勭紦瀛橀槦鍒楁暟鎹�
+                                int queryAreaCode2 = (int)AreaCodeEnum.寰呯紦瀛樺垎鎷e尯;
+                                var curUpiLineQueue = wmsDB.mes_upi_linequeue.Where(x => x.Upi == upiObj.UPI && x.AreaCode == queryAreaCode2)
+                               .FirstOrDefault();
+                                if (curUpiLineQueue != null)
+                                {
+                                    wmsDB.mes_upi_linequeue.Remove(curUpiLineQueue);
+                                }
+
                                 //鏇存柊UPI鐘舵��
                                 var upiObjList = wmsDB.mes_batchOrderUPI_new.Where(x => x.UPI == upiCode).ToList();
                                 foreach (var item in upiObjList)
@@ -196,13 +352,30 @@
                                         item.UpiStatus = (int)UpiStatusEnum.涓嶉綈鍖�;
                                     }
                                 }
+                                //鏇存柊鍖呯姸鎬� [Editby shaocx,2024-12-15]
+                                var packageObj = wmsDB.mes_package_gather.Where(x => x.PackageCode == upiObj.PackageCode).FirstOrDefault();
+                                if (packageObj != null)
+                                {
+                                    if (qitaoReault)
+                                    {
+                                        packageObj.UpiStatus = (int)UpiStatusEnum.宸查綈鍖�;
+                                        packageObj.IsQiBao = true;
+                                    }
+                                    else
+                                    {
+                                        packageObj.UpiStatus = (int)UpiStatusEnum.涓嶉綈鍖�;
+                                        packageObj.IsQiBao = false;
+                                    }
+                                }
+
                                 //鏇存柊 鏈�鍚庝竴娆″湪 BZ_01鐨勭郴缁熷鐞嗙殑鏉夸欢 鏁版嵁
                                 var rbRunMode = wmsDB.wms_rbline_runmode.FirstOrDefault();
+                                rbRunMode.UPI = upiObj.UPI;
                                 rbRunMode.PlanNo = upiObj.PlanNo;
                                 rbRunMode.OrderId = upiObj.OrderId;
                                 rbRunMode.PackageCode = upiObj.PackageCode;
 
-                                WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, "BZ01", "榻愬寘楠岃瘉:" + (qitaoReault ? "榻愬寘" : "涓嶉綈鍖�"));
+                                WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, "BZ01", "榻愬寘楠岃瘉:" + str_qitaoReault);
 
                                 wmsDB.SaveChanges();
                             }
@@ -225,6 +398,46 @@
             }
         }
 
+        /// <summary>
+        /// 瓒呮椂楠岃瘉
+        /// </summary>
+        /// <param name="wmsDB"></param>
+        /// <param name="time"></param>
+        /// <returns>true:瓒呮椂 false锛氭湭瓒呮椂</returns>
+        private static bool Wait269(WmsDBModel wmsDB)
+        {
+            var bz30Config = wmsDB.SysConfig.Where(x => x.Code == "Wait_269").FirstOrDefault();
+            if (bz30Config == null)
+            {
+                SystemWarningMsg._lbl_Alert_DataProcess_ValidateQiTao = $"娌℃湁閰嶇疆 Wait_269 鍊�";
+                return false;
+            }
+            int i = 0;
+            bool right = int.TryParse(bz30Config.Value, out i);
+            if (right == false)
+            {
+                SystemWarningMsg._lbl_Alert_DataProcess_ValidateQiTao = $"閰嶇疆 Wait_269 鍊间笉鏄暣鏁�";
+                return false;
+            }
+
+            if (string.IsNullOrEmpty(timingForWait))
+            {
+                timingForWait = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+            }
+
+            string time = timingForWait;
+            //鍦�269鎵弿鐨勬椂闂�
+            var time_269 = Convert.ToDateTime(time);
+            TimeSpan ts = DateTime.Now - time_269;
+            var sec = ts.Seconds;
+            if (sec >= i)
+            {
+                //瓒呮椂
+                return true;
+            }
+            SystemWarningMsg._lbl_Alert_DataProcess_ValidateQiTao = $"閰嶇疆 Wait_269 鍊兼槸{i},褰撳墠闂撮殧鏄瘂sec}绉�,鏈秴鏃躲�傚紑濮嬬瓑寰呮椂闂磠timingForWait}";
+            return false;
+        }
 
         /// <summary>
         /// 鏄惁鍙互鎵ц鍑哄簱妯″紡
@@ -234,6 +447,10 @@
         /// <returns></returns>
         private static bool IsAllloRunOutTaskMode(WmsDBModel wmsDB, mes_batchOrderUPI_new curUpiObj)
         {
+            //涓嶅啀鍒ゆ柇 銆怑ditby shaocx,2024-12-14銆�
+            return false;
+
+            /*
             //棣栧厛鏌ヨ鏁版嵁搴撲腑鏄惁鏈� 瑕佸嚭搴撶殑鏁版嵁
             var isExistOutTaskForNewCreated = wmsDB.wms_rbline_task.Where(x =>
             (x.RbTaskType == (int)RbTaskTypeEnum.榻愬寘鍑哄簱浠诲姟 || x.RbTaskType == (int)RbTaskTypeEnum.寮哄埗鍑哄簱浠诲姟)
@@ -301,7 +518,123 @@
 
             FormCC.IsAllowRunOutMode = true;
             return true;
+
+            //*/
         }
 
+        /// <summary>
+        /// 鍒ゆ柇鏄惁榻愬寘
+        /// </summary>
+        /// <param name="wmsDB"></param>
+        /// <param name="upiObj"></param>
+        /// <returns></returns>
+        private static bool ValidateQiBao(WmsDBModel wmsDB, mes_batchOrderUPI_new upiObj)
+        {
+            if (upiObj.Shelf != 1)
+            {
+                return false;
+            }
+            //鏌ヨ鏄惁榻愬寘
+            var allList = wmsDB.mes_batchOrderUPI_new.Where(x => x.PackageCode == upiObj.PackageCode).ToList();
+            var isQiTaoList = allList.Where(x => x.AreaCode == (int)AreaCodeEnum.寰呯紦瀛樺垎鎷e尯
+            ||
+            x.AreaCode == (int)AreaCodeEnum.鐮佸灈鍖哄煙
+            ).ToList();
+            if (isQiTaoList.Count() != allList.Count())
+            {//涓嶉綈鍖�
+                return false;
+            }
+            else
+            {//榻愬寘
+             //杩欓噷鍐嶅鍔犱釜閫昏緫锛屽繀椤绘槸鎸夌収娆″簭杩涘叆鐨勬墠鐪熸鐨勭畻榻愬寘 [Editby shaocx,2024-12-06]
+             //瀵绘壘鏈寘鍐呯殑鍓嶄竴鍧楁澘鐨勪綅缃�
+                int queryAreaCode = (int)AreaCodeEnum.寰呯紦瀛樺垎鎷e尯;
+                var lastUpiLineQueue = wmsDB.mes_upi_linequeue.Where(x => x.PackageCode == upiObj.PackageCode && x.AreaCode == queryAreaCode)
+                    .OrderBy(x => x.Id).FirstOrDefault();//鏌ヨ璇ュ寘闃熷垪鐨勭涓�鍧楁澘
+                if (lastUpiLineQueue == null)
+                {//璇存槑 闃熷垪涓病鏈夎鍖呯殑鏁版嵁
+                    return false;
+                }
+                else
+                {
+                    if (lastUpiLineQueue.Shelf != upiObj.Shelf)
+                    {
+                        return false;
+                    }
+                    else
+                    {
+                        var isJiXuValidate = true;
+                        if (upiObj.Shelf != 1)
+                        {
+                            var qianmianList = allList.Where(x => x.Shelf < upiObj.Shelf).ToList();
+                            //鐪嬩互鍓嶇殑鏉垮湪鍝噷锛屽繀椤婚兘鍦� 鐮佸灈鍖哄煙
+                            var yiqianQuyu = AreaCodeEnum.鐮佸灈鍖哄煙;
+                            var count_MD = qianmianList.Where(x => x.AreaCode == (int)yiqianQuyu).Count();
+                            if (count_MD != qianmianList.Count())
+                            {
+                                isJiXuValidate = false;
+                                return false;
+                            }
+                        }
+
+                        if (isJiXuValidate)
+                        {//鏄惁缁х画楠岃瘉
+                         //杩橀渶瑕侀獙璇佸湪杩欎簺鍖哄煙涓紝鏄惁姝g‘鎺掗槦锛屽鏋滄病鏈夋纭帓闃燂紝閭d箞灏辫涓轰笉榻愬 銆怑ditby shaocx,2024-12-12銆�
+                            var queueList = wmsDB.mes_upi_linequeue.Where(x => x.PackageCode == upiObj.PackageCode && x.AreaCode == queryAreaCode)
+                                .OrderBy(x => x.Id).ToList();
+                            var fisrtId = queueList.OrderBy(x => x.Id).First().Id;
+                            var endId = queueList.OrderByDescending(x => x.Id).First().Id;
+                            //缁х画鏌ヨ杩欎釜鏃堕棿娈靛唴鐨勯槦鍒楁暟鎹�
+                            //閲嶅啓璇ラ槦鍒�
+                            queueList = wmsDB.mes_upi_linequeue.Where(x => x.Id >= fisrtId && x.Id <= endId).OrderBy(x => x.Id).ToList();
+                            var syCount = allList.Where(x => x.Shelf >= upiObj.Shelf).Count();
+                            if (queueList.Count() != syCount)
+                            {
+                                return false;
+                            }
+                            else
+                            {
+                                //鍒ゆ柇鏄惁涔卞簭
+                                bool isLuanXuan = false;
+                                int temp_shelf = 0;
+                                for (int i = 0; i < queueList.Count; i++)
+                                {
+                                    if (i == 0)
+                                    {
+                                        temp_shelf = queueList[i].Shelf;
+                                        if (temp_shelf != upiObj.Shelf)
+                                        {
+                                            isLuanXuan = true;
+                                            return false;
+                                        }
+                                        if (queueList[i].Upi != upiObj.UPI)
+                                        {
+                                            isLuanXuan = true;
+                                            return false;
+                                        }
+                                    }
+                                    else
+                                    {
+                                        temp_shelf = temp_shelf + 1;
+                                        if (temp_shelf != queueList[i].Shelf)
+                                        {//璁や负涔卞簭浜�
+                                            isLuanXuan = true;
+                                            return false;
+                                        }
+                                    }
+                                }
+
+                                if (isLuanXuan == false)
+                                {
+                                    return true;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+
+            return false;
+        }
     }
 }

--
Gitblit v1.9.3