From 7ca9651f81d7b84f054194d3d46fdbd1d9c8b922 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期三, 09 七月 2025 22:55:27 +0800
Subject: [PATCH] 增加质检出入库逻辑

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs |  113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 113 insertions(+), 0 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 3b78bf9..40f37d5 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"
@@ -149,6 +149,119 @@
             }
             return content;
         }
+        /// <summary>
+        /// 鍫嗗灈鏈虹敵璇峰叆搴�
+        /// </summary>
+        /// <param name="lineDTO"></param>
+        /// <returns></returns>
+        public WebResponseContent NewStackerCraneRequestInbound(ConveyorLineDTO lineDTO)
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                Dt_RoadwayInfo roadwayInfo = _basicRepository.RoadwayInfoRepository.QueryFirst(x => x.InStationCode == lineDTO.stationCode) ?? throw new Exception("鏈壘鍒拌绔欏彴瀵瑰簲鐨勫贩閬擄紝璇锋鏌ュ熀纭�閰嶇疆淇℃伅");
+                if (roadwayInfo.EnableStatus != EnableStatusEnum.Normal.ObjToInt() && roadwayInfo.EnableStatus != EnableStatusEnum.OnlyIn.ObjToInt())
+                {
+                    throw new Exception("璇ュ贩閬撲笉鍙叆搴擄紝璇锋鏌ュ贩閬撶鐢ㄤ俊鎭�");
+                }
+                if (roadwayInfo.AreaId > 0)
+                {
+                    Dt_AreaInfo areaInfo = _basicRepository.AreaInfoRepository.QueryFirst(x => x.Id == roadwayInfo.AreaId);
+                    if (areaInfo != null && areaInfo.AreaStatus == EnableEnum.Disable.ObjToInt())
+                    {
+                        throw new Exception("鍖哄煙琚鐢紝涓嶅彲鍏ュ簱");
+                    }
+                }
+                var task = BaseDal.QueryFirst(x => x.PalletCode == lineDTO.Barcode);
+                if (task == null) throw new Exception($"鏈壘鍒版墭鐩樺彿[{lineDTO.Barcode}]鐨勫叆搴撲换鍔�");
+                if (task.TaskState >= (int)InTaskStatusEnum.SC_InExecuting) throw new Exception($"鎵樼洏鍙穂{lineDTO.Barcode}]鐨勫叆搴撲换鍔$姸鎬佷笉鍖归厤");
+
+                #region 鍒ゆ柇鏄惁涓虹┖鎵樺叆搴�
+                if (task.TaskType == TaskTypeEnum.PalletInbound.ObjToInt())
+                    return GetEmptyLocation(task);
+                #endregion
+
+                Dt_InventoryInfo inventoryInfo = _stockService.InventoryInfoService.Repository.QueryFirst(x => x.PalletCode == lineDTO.Barcode);
+                if (inventoryInfo == null) throw new Exception($"鏈壘鍒版墭鐩榌{lineDTO.Barcode}]鐨勭粍鐩樹俊鎭�");
+                if (inventoryInfo.StockStatus != StockStatusEmun.鍏ュ簱纭.ObjToInt()) throw new Exception($"鎵樼洏[{lineDTO.Barcode}],璇ョ粍鐩樼姸鎬佷笉鍙叆搴�");
+                if (!string.IsNullOrEmpty(inventoryInfo.LocationCode)) throw new Exception($"鎵樼洏[{lineDTO.Barcode}],宸插垎閰嶇粓鐐瑰湴鍧�");
+
+                Dt_InboundOrderDetail inboundOrderDetail = _inboundService.InboundOrderDetailService.Repository.QueryFirst(x => x.BatchNo == inventoryInfo.BatchNo);
+                if (inboundOrderDetail == null) throw new Exception($"鏈壘鍒版墭鐩榌{lineDTO.Barcode}]鐨勫叆搴撳崟鏄庣粏淇℃伅");
+                Dt_LocationInfo? locationInfo = null;
+
+                if (!string.IsNullOrEmpty(inboundOrderDetail.LocationCode))
+                {
+                    locationInfo = _basicService.LocationInfoService.GetLocation(inboundOrderDetail.LocationCode);
+                }
+                else
+                {
+                    Dt_InventoryInfo? _InventoryInfo = _stockService.InventoryInfoService.Repository.QueryData(x => x.BatchNo == inventoryInfo.BatchNo && (x.StockStatus == StockStatusEmun.鍏ュ簱涓�.ObjToInt() || x.StockStatus == StockStatusEmun.宸插叆搴�.ObjToInt())).OrderByDescending(x => x.ModifyDate).FirstOrDefault();
+
+                    if (_InventoryInfo != null)
+                    {
+                        locationInfo = _basicService.LocationInfoService.GetLocation(_InventoryInfo.LocationCode);
+                        if (locationInfo?.MaxQty <= locationInfo?.CurrentQty) locationInfo = null;
+                    }
+                    if (locationInfo == null)//鍒嗛厤鏂拌揣浣�
+                    {
+                        var Qty = Convert.ToInt32(inboundOrderDetail.OrderQuantity - inboundOrderDetail.OverInQuantity);
+                        var ts = Qty / 320;
+                        if (Qty % 320 > 0) ts++;
+                        int inboundOrderCount = ts > 12 ? 2 : 1;
+                        locationInfo = _basicService.LocationInfoService.AssignLocation(inboundOrderCount);//閲嶆柊鍒嗛厤璐т綅
+                    }
+                }
+                if (locationInfo == null) throw new Exception($"鏃犲彲鍏ヨ揣浣�");
+
+                #region 淇敼搴撳瓨鍙婅揣浣嶄俊鎭�
+                task.TaskState = (int)InTaskStatusEnum.SC_InExecuting;
+                task.CurrentAddress = task.NextAddress;
+                task.NextAddress = locationInfo.LocationCode;
+                task.TargetAddress = task.NextAddress;
+                task.TargetIsPickPlace = locationInfo.MaxQty - locationInfo.CurrentQty == 1;
+                task.SourceIsPickPlace = false;
+                inventoryInfo.LocationCode = locationInfo.LocationCode;
+                inventoryInfo.StockStatus = StockStatusEmun.鍏ュ簱涓�.ObjToInt();
+                locationInfo.CurrentQty++;
+                if (locationInfo.MaxQty < locationInfo.CurrentQty) locationInfo.CurrentQty = locationInfo.MaxQty;
+                inventoryInfo.SerialNumber = locationInfo.CurrentQty;
+                inboundOrderDetail.OverInQuantity = inboundOrderDetail.OverInQuantity + inventoryInfo.StockQuantity;
+                if (inboundOrderDetail.OverInQuantity > inboundOrderDetail.ReceiptQuantity)
+                    inboundOrderDetail.OverInQuantity = inboundOrderDetail.ReceiptQuantity;
+                locationInfo.EnableStatus = EnableStatusEnum.OnlyOut.ObjToInt();
+                locationInfo.LocationStatus = LocationStatusEnum.Inbounding.ObjToInt();
+
+                Db.Ado.BeginTran();
+                UpdateData(task);
+                _stockService.InventoryInfoService.Repository.UpdateData(inventoryInfo);
+                if (inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity)
+                {
+                    inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
+                    Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.Repository.QueryFirst(x => x.Id == inboundOrderDetail.OrderId);
+                    inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt();
+                    _inboundService.InbounOrderService.Repository.DeleteAndMoveIntoHty(inboundOrder, OperateType.鑷姩瀹屾垚);
+                    _inboundService.InboundOrderDetailService.Repository.DeleteAndMoveIntoHty(inboundOrderDetail, OperateType.鑷姩瀹屾垚);
+                }
+                else
+                    _inboundService.InboundOrderDetailService.Repository.UpdateData(inboundOrderDetail);
+                _basicService.LocationInfoService.Repository.UpdateData(locationInfo);
+                Db.Ado.CommitTran();
+                #endregion
+                content.OK(data: new ReceiveWMSInfo()
+                {
+                    TargetAddress = task.TargetAddress,
+                    SourceIsPickPlace = task.SourceIsPickPlace,
+                    TargetIsPickPlace = task.TargetIsPickPlace,
+                });
+            }
+            catch (Exception ex)
+            {
+                Db.Ado.RollbackTran();
+                content.Error(ex.Message);
+            }
+            return content;
+        }
 
         /// <summary>
         /// 鍫嗗灈鏈虹敵璇峰叆搴�

--
Gitblit v1.9.3