From 46e98339480d853fc78a014c34d7ff9fcaf13890 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期四, 05 十二月 2024 14:09:02 +0800
Subject: [PATCH] 产线协议

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs |   59 +++++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 39 insertions(+), 20 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs"
index bd475f9..48c0576 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs"
@@ -161,47 +161,63 @@
             {
                 var task = BaseDal.QueryFirst(x => x.PalletCode == lineDTO.Barcode);
                 if (task == null) throw new Exception($"鏈壘鍒版墭鐩樺彿[{lineDTO.Barcode}]鐨勫叆搴撲换鍔�");
-                if (task.TaskState >= (int)InTaskStatusEnum.Line_InFinish) throw new Exception($"鎵樼洏鍙穂{lineDTO.Barcode}]鐨勫叆搴撲换鍔$姸鎬佷笉鍖归厤");
+                if (task.TaskState >= (int)InTaskStatusEnum.SC_InExecuting) throw new Exception($"鎵樼洏鍙穂{lineDTO.Barcode}]鐨勫叆搴撲换鍔$姸鎬佷笉鍖归厤");
 
                 Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(lineDTO.Barcode);
                 if (stockInfo == null) throw new Exception($"鏈壘鍒版墭鐩榌{lineDTO.Barcode}]鐨勭粍鐩樹俊鎭�");
                 Dt_StockInfoDetail? stockInfoDetail = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault();
                 if (stockInfoDetail == null) throw new Exception($"鏈壘鍒版墭鐩榌{lineDTO.Barcode}]鐨勭粍鐩樿鎯�");
-                if (stockInfo.StockStatus != StockStatusEmun.鍏ュ簱纭.ObjToInt()) throw new Exception($"鎵樼洏[{lineDTO.Barcode}],璇ョ粍鐩樼姸鎬佷笉鍙叆搴�");
+                if (stockInfo.StockStatus != StockStatusEmun.鍏ュ簱纭.ObjToInt() || !string.IsNullOrEmpty(stockInfo.LocationCode))
+                    throw new Exception($"鎵樼洏[{lineDTO.Barcode}],璇ョ粍鐩樼姸鎬佷笉鍙叆搴�");
 
                 Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(stockInfoDetail.OrderNo);
                 if (inboundOrder == null || inboundOrder.Details == null) throw new Exception($"鏈壘鍒版墭鐩榌{lineDTO.Barcode}]鐨勫叆搴撳崟鏄庣粏淇℃伅");
-                Dt_StockInfo instockInfo = null;
                 Dt_LocationInfo locationInfo = null;
-                #region 鍒ゆ柇褰撳墠鍏ュ簱鎵樼洏鎵规鍙锋槸鍚﹀瓨鍦ㄥ凡鍒嗛厤鍏ュ簱
-                Dt_StockInfoDetail instockInfoDetail = _stockService.StockInfoDetailService.Get_StockInfoDetail(stockInfoDetail.OrderNo, stockInfoDetail.BatchNo);
-                if (instockInfoDetail != null) instockInfo = _stockService.StockInfoService.Repository.GetStockInfo(instockInfoDetail.StockId);
-                if (instockInfo != null)
+
+                #region 鍒ゆ柇鏄惁鎸囧畾璐т綅
+                Dt_InboundOrderDetail orderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == stockInfoDetail.BatchNo);
+                if (orderDetail != null && !string.IsNullOrEmpty(orderDetail.LocationCode))
                 {
-                    locationInfo = _basicService.LocationInfoService.GetLocation(instockInfo.LocationCode);
+                    locationInfo = _basicService.LocationInfoService.GetLocation(orderDetail.LocationCode);
                 }
                 #endregion
+
+                #region 鍒ゆ柇褰撳墠鍏ュ簱鎵樼洏鎵规鍙锋槸鍚﹀瓨鍦ㄥ凡鍒嗛厤鍏ュ簱
                 else
                 {
-                    instockInfoDetail = _stockService.StockInfoDetailService.Get_StockInfoDetail(stockInfoDetail.OrderNo);//鍏ュ簱鍗曞瓨鍦ㄥ簱瀛橈紝鍒ゆ柇璐т綅
+                    Dt_StockInfo instockInfo = null;
+                    Dt_StockInfoDetail instockInfoDetail = _stockService.StockInfoDetailService.Get_StockInfoDetail(stockInfoDetail.OrderNo, stockInfoDetail.BatchNo);
                     if (instockInfoDetail != null) instockInfo = _stockService.StockInfoService.Repository.GetStockInfo(instockInfoDetail.StockId);
                     if (instockInfo != null)
                     {
                         locationInfo = _basicService.LocationInfoService.GetLocation(instockInfo.LocationCode);
-                        //if (locationInfo.MaxQty == 12)
-                        //{
-                        //    locationInfo.EnableStatus = EnableStatusEnum.OnlyOut.ObjToInt();
-                        //    _basicService.LocationInfoService.Repository.UpdateData(locationInfo);
-                        //    locationInfo = null;
-                        //}
-                        if (locationInfo.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt()) locationInfo = null;
-                        else
+                        if (locationInfo?.MaxQty <= locationInfo?.CurrentQty) locationInfo = null;
+                    }
+                    #endregion
+                    else
+                    {
+                        instockInfoDetail = _stockService.StockInfoDetailService.Get_StockInfoDetail(stockInfoDetail.OrderNo);//鍏ュ簱鍗曞瓨鍦ㄥ簱瀛橈紝鍒ゆ柇璐т綅
+                        if (instockInfoDetail != null) instockInfo = _stockService.StockInfoService.Repository.GetStockInfo(instockInfoDetail.StockId);
+                        if (instockInfo != null)
                         {
-                            List<Dt_StockInfoDetail> stockInfoDetails = _stockService.StockInfoDetailService.Get_StockInfoDetails(stockInfoDetail.OrderNo);//鑾峰彇宸ュ崟鎵�鏈夊凡鍏ュ簱鎴栧叆搴撲腑搴撳瓨
-                            if (stockInfoDetails.GroupBy(x => x.BatchNo).Count() < 2) locationInfo.EnableStatus = EnableStatusEnum.OnlyOut.ObjToInt();
-                            else locationInfo = null;
+                            locationInfo = _basicService.LocationInfoService.GetLocation(instockInfo.LocationCode);
+                            //if (locationInfo.MaxQty == 12)
+                            //{
+                            //    locationInfo.EnableStatus = EnableStatusEnum.OnlyOut.ObjToInt();
+                            //    _basicService.LocationInfoService.Repository.UpdateData(locationInfo);
+                            //    locationInfo = null;
+                            //}
+                            if (locationInfo.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt()) locationInfo = null;
+                            else
+                            {
+                                List<Dt_StockInfoDetail> stockInfoDetails = _stockService.StockInfoDetailService.Get_StockInfoDetails(stockInfoDetail.OrderNo);//鑾峰彇宸ュ崟鎵�鏈夊凡鍏ュ簱鎴栧叆搴撲腑搴撳瓨
+                                if (stockInfoDetails.GroupBy(x => x.BatchNo).Count() < 2) locationInfo.EnableStatus = EnableStatusEnum.OnlyOut.ObjToInt();
+                                else locationInfo = null;
+                            }
+                            if (locationInfo?.MaxQty <= locationInfo?.CurrentQty) locationInfo = null;
                         }
                     }
+
                     if (locationInfo == null)
                     {
                         int inboundOrderCount = inboundOrder.Details.Count;
@@ -210,6 +226,8 @@
                         locationInfo = _basicService.LocationInfoService.AssignLocation(inboundOrderCount);//閲嶆柊鍒嗛厤璐т綅
                     }
                 }
+                
+
                 if (locationInfo == null) throw new Exception($"鏃犲彲鍏ヨ揣浣�");
 
                 #region 淇敼搴撳瓨鍙婅揣浣嶄俊鎭�
@@ -222,6 +240,7 @@
                 stockInfo.StockStatus = StockStatusEmun.鍏ュ簱涓�.ObjToInt();
                 stockInfoDetail.Status = StockStatusEmun.鍏ュ簱涓�.ObjToInt();
                 locationInfo.CurrentQty++;
+                if (locationInfo.MaxQty < locationInfo.CurrentQty) throw new Exception();
                 if (locationInfo.MaxQty == 12) locationInfo.EnableStatus = EnableStatusEnum.OnlyOut.ObjToInt();
                 locationInfo.LocationStatus = LocationStatusEnum.Inbounding.ObjToInt();
 

--
Gitblit v1.9.3