pan
2025-11-22 43d2d040be7416230db1c562526f2743e87d75ea
提交
已修改8个文件
138 ■■■■ 文件已修改
项目代码/WMS无仓储版/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/Dt_OutboundLockInfo.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutStockLockInfoService.cs 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/SplitPackageService.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs 74 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/CodeChunks.db-shm
Binary files differ
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.878.3237/SemanticSymbols.db-shm
Binary files differ
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_Model/Models/Outbound/Dt_OutboundLockInfo.cs
@@ -128,6 +128,9 @@
        public int? ParentLockId { get; set; }
        [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "操作者")]
        public string Operator { get; set; }
        [Navigate(NavigateType.OneToOne, nameof(StockInfo))]//一对一 SchoolId是StudentA类里面的
        public Dt_StockInfo StockInfo { get; set; } //不能赋值只能是null
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_OutboundService/OutStockLockInfoService.cs
@@ -57,20 +57,22 @@
            // ç¡®å®šæ¡ç 
            string targetBarcode;
            var  firstAvailableDetail=new Dt_StockInfoDetail();
            if (!string.IsNullOrEmpty(barcode))
            {
                // éªŒè¯æŒ‡å®šçš„æ¡ç æ˜¯å¦å­˜åœ¨
                var specifiedBarcodeDetail = stockDetails.FirstOrDefault(x => x.Barcode == barcode);
                if (specifiedBarcodeDetail == null)
                firstAvailableDetail = stockDetails.FirstOrDefault(x => x.Barcode == barcode);
                if (firstAvailableDetail == null)
                {
                    throw new Exception($"指定的条码[{barcode}]在库存中不存在");
                }
                targetBarcode = barcode;
            }
            else
            {
                // ä½¿ç”¨ç¬¬ä¸€ä¸ªå¯ç”¨æ¡ç 
                var firstAvailableDetail = stockDetails
                  firstAvailableDetail = stockDetails
                    .Where(x => x.StockQuantity > x.OutboundQuantity)
                    .OrderBy(x => x.CreateDate)
                    .FirstOrDefault();
@@ -83,13 +85,9 @@
            }
            return new Dt_OutStockLockInfo()
            {
                lineNo= outboundOrderDetail.lineNo,
            {
                PalletCode = outStock.PalletCode,
                AssignQuantity = assignQuantity,
                MaterielCode = outboundOrderDetail.MaterielCode,
                BatchNo = outboundOrderDetail.BatchNo ?? outStock.Details.FirstOrDefault()?.BatchNo,
                AssignQuantity = assignQuantity,
                LocationCode = outStock.LocationCode,
                MaterielName = outboundOrderDetail.MaterielName,
                OrderDetailId = outboundOrderDetail.Id,
@@ -99,16 +97,19 @@
                    .Where(x => x.MaterielCode == outboundOrderDetail.MaterielCode)
                    .Sum(x => x.StockQuantity),
                Status = (int)OutLockStockStatusEnum.已分配,
                StockId = outStock.Id,
                Unit = outboundOrderDetail.Unit,
                FactoryArea = outboundOrder.FactoryArea,
                StockId = outStock.Id,
                OrderType=outboundOrder.OrderType,
                SupplyCode = outboundOrderDetail.SupplyCode,
                WarehouseCode = outboundOrderDetail.WarehouseCode,
                SupplyCode = firstAvailableDetail.SupplyCode,
                WarehouseCode = firstAvailableDetail.WarehouseCode,
                // æ–°å¢žå­—段
                CurrentBarcode = targetBarcode,
                OriginalLockQuantity = assignQuantity,
                IsSplitted = 0
                IsSplitted = 0,
                MaterielCode = outboundOrderDetail.MaterielCode,
                BatchNo = firstAvailableDetail.BatchNo,
                Unit = firstAvailableDetail.Unit,
                FactoryArea = firstAvailableDetail.FactoryArea,
                lineNo = firstAvailableDetail.InboundOrderRowNo,
            };
        }
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundPickingService.cs
@@ -473,6 +473,7 @@
            // 5. æ›´æ–°åŽŸé”å®šä¿¡æ¯
            lockInfo.AssignQuantity = remainingStockQty;
            lockInfo.PickedQty = 0;
            lockInfo.Operator = App.User.UserName;
            await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
            // 6. è®¾ç½®ç»“æžœ
@@ -493,6 +494,7 @@
            // 2. æ›´æ–°é”å®šä¿¡æ¯
            lockInfo.PickedQty += actualQty;
            lockInfo.Status = (int)OutLockStockStatusEnum.拣选完成;
            lockInfo.Operator = App.User.UserName;
            await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
        }
@@ -511,6 +513,7 @@
            // 2. æ›´æ–°é”å®šä¿¡æ¯
            lockInfo.PickedQty += stockOutQty;
            lockInfo.AssignQuantity = remainingAssignQty;
            lockInfo.Operator = App.User.UserName;
            await _outStockLockInfoService.Db.Updateable(lockInfo).ExecuteCommandAsync();
            // 3. æ›´æ–°æ‹†åŒ…记录状态
@@ -1097,10 +1100,13 @@
        private async Task HandlePalletStockGoodsReturn(List<Dt_StockInfoDetail> palletStockGoods)
        {
            _logger.LogInformation($"回库操作:发现{palletStockGoods.Count}个库存明细需要回库,等待AGV搬运");
            foreach (var stockGood in palletStockGoods)
            {
                // æ¢å¤åº“存状态
                stockGood.OutboundQuantity = 0;
                _logger.LogInformation($"待回库货物 - æ¡ç : {stockGood.Barcode}, æ•°é‡: {stockGood.StockQuantity}, å½“前状态: {stockGood.Status}");
            // æ¢å¤åº“存状态
            stockGood.OutboundQuantity = 0;
                stockGood.Status = StockStatusEmun.入库确认.ObjToInt();
                await _stockInfoDetailService.Db.Updateable(stockGood).ExecuteCommandAsync();
@@ -1121,6 +1127,7 @@
        private async Task UpdateStockInfoStatus(Dt_StockInfo stockInfo)
        {
            _logger.LogInformation($"回库操作:托盘{stockInfo.PalletCode}等待AGV回库搬运");
            // æ›´æ–°åº“存主表状态
            stockInfo.StockStatus = StockStatusEmun.入库确认.ObjToInt();
            await _stockInfoService.Db.Updateable(stockInfo).ExecuteCommandAsync();
@@ -1337,7 +1344,7 @@
                    business_type = outboundOrder.BusinessType,
                    factoryArea = outboundOrder.FactoryArea,
                    operationType = 1,
                    Operator = outboundOrder.Operator,
                    Operator = App.User.UserName,
                    orderNo = outboundOrder.UpperOrderNo,
                    status = outboundOrder.OrderStatus,
                    details = new List<FeedbackOutboundDetailsModel>()
@@ -1422,7 +1429,12 @@
                CurrentBarcode = newBarcode,
                OriginalLockQuantity = quantity,
                IsSplitted = 1,
                ParentLockId = originalLock.Id
                ParentLockId = originalLock.Id,
                Operator=  App.User.UserName,
                FactoryArea=originalLock.FactoryArea,
                lineNo=originalLock.lineNo,
                WarehouseCode=originalLock.WarehouseCode,
            };
            var newLockId = await _outStockLockInfoService.Db.Insertable(newLockInfo).ExecuteReturnIdentityAsync();
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_OutboundService/SplitPackageService.cs
@@ -134,7 +134,11 @@
                    CurrentBarcode = newBarcode,
                    OriginalLockQuantity = request.SplitQuantity,
                    IsSplitted = 1,
                    ParentLockId = lockInfo.Id
                    ParentLockId = lockInfo.Id,
                     Operator = App.User.UserName,
                    FactoryArea = lockInfo.FactoryArea,
                    lineNo = lockInfo.lineNo,
                    WarehouseCode = lockInfo.WarehouseCode,
                };
                await _outStockLockInfoService.Db.Insertable(newLockInfo).ExecuteCommandAsync();
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -454,7 +454,7 @@
            }
        }
        public WebResponseContent InPickTaskCompleted(Dt_Task task)
        public async Task<WebResponseContent> InPickTaskCompleted(Dt_Task task)
        {
            _logger.LogInformation($"TaskService  InPickTaskCompleted: {task.TaskNum}");
            //查库存
@@ -467,7 +467,12 @@
            {
                return WebResponseContent.Instance.Error($"未找到该托盘库存明细信息");
            }
            //查货位
            Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
            if (locationInfo == null)
            {
                return WebResponseContent.Instance.Error($"未找到对应的终点货位信息");
            }
            // èŽ·å–æ‰€æœ‰å›žåº“ä¸­çš„å‡ºåº“é”å®šè®°å½•
            var returnLocks = _outStockLockInfoService.Db.Queryable<Dt_OutStockLockInfo>()
                .Where(it => it.OrderNo == task.OrderNo && it.PalletCode == task.PalletCode && it.Status == (int)OutLockStockStatusEnum.回库中)
@@ -479,12 +484,8 @@
            }
            _outStockLockInfoService.Db.Updateable(returnLocks).ExecuteCommand();
            //查货位
            Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
            if (locationInfo == null)
            {
                return WebResponseContent.Instance.Error($"未找到对应的终点货位信息");
            }
            await DeleteZeroQuantityStockDetails(stockInfo.Id);
            stockInfo.LocationCode = task.TargetAddress;
            stockInfo.StockStatus = StockStatusEmun.入库完成.ObjToInt();
            stockInfo.Details.ForEach(x =>
@@ -493,6 +494,9 @@
            });
            _stockService.StockInfoService.Repository.UpdateData(stockInfo);
            _stockService.StockInfoDetailService.Repository.UpdateData(stockInfo.Details);
            await ProcessStockDetailsForReturn(task, stockInfo.Id);
            if (stockInfo.PalletType == PalletTypeEnum.Empty.ObjToInt())
            {
@@ -511,6 +515,60 @@
            return WebResponseContent.Instance.OK();
        }
        /// <summary>
        /// åˆ é™¤åº“存数为0的库存明细记录
        /// </summary>
        private async Task DeleteZeroQuantityStockDetails(int stockId)
        {
            try
            {
                // åˆ é™¤åº“存数量为0的记录
                var deleteCount = await _stockService.StockInfoDetailService.Db.Deleteable<Dt_StockInfoDetail>()
                    .Where(x => x.StockId == stockId &&
                               x.StockQuantity == 0 &&
                               (x.Status==StockStatusEmun.出库完成.ObjToInt()|| x.Status==
                                          StockStatusEmun.入库完成.ObjToInt())) // åªåˆ é™¤å·²å®ŒæˆçŠ¶æ€çš„é›¶åº“å­˜
                    .ExecuteCommandAsync();
                if (deleteCount > 0)
                {
                    _logger.LogInformation($"删除{deleteCount}条零库存明细记录 - StockId: {stockId}");
                }
            }
            catch (Exception ex)
            {
                _logger.LogWarning($"删除零库存记录失败 - StockId: {stockId}, Error: {ex.Message}");
                // æ³¨æ„ï¼šåˆ é™¤å¤±è´¥ä¸åº”该影响主流程,记录日志后继续
            }
        }
        /// <summary>
        /// å¤„理回库相关的所有库存明细状态变更
        /// </summary>
        private async Task ProcessStockDetailsForReturn(Dt_Task returnTask, int stockId)
        {
            // èŽ·å–è¯¥æ‰˜ç›˜ä¸‹æ‰€æœ‰éœ€è¦å›žåº“çš„åº“å­˜æ˜Žç»†
            var stockDetails = await _stockService.StockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
                .Where(x => x.StockId == stockId &&
                           x.StockQuantity > 0 &&
                          ( x.Status == StockStatusEmun.出库锁定.ObjToInt()|| x.Status==
                                      StockStatusEmun.入库确认.ObjToInt()))  // åŒ…括出库锁定和入库确认的
                .ToListAsync();
            foreach (var detail in stockDetails)
            {
                detail.Status = StockStatusEmun.入库完成.ObjToInt();
                detail.OutboundQuantity = 0;  // æ¸…空出库数量
                _logger.LogInformation($"更新库存明细状态 - æ¡ç : {detail.Barcode}, æ•°é‡: {detail.StockQuantity}");
            }
            if (stockDetails.Any())
            {
                await _stockService.StockInfoDetailService.Db.Updateable(stockDetails).ExecuteCommandAsync();
                _logger.LogInformation($"共更新{stockDetails.Count}个库存明细状态为入库完成");
            }
        }
        public async Task<WebResponseContent> OutEmptyTaskCompleted(Dt_Task task)
        {
            WebResponseContent content = new WebResponseContent();
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs
@@ -206,7 +206,7 @@
                if (stockInfos != null && stockInfos.Count > 0 && outboundOrderDetails != null && outboundOrderDetails.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0)
                {
                    stockInfos.ForEach(x =>
                    {
                    {
                        x.StockStatus = StockStatusEmun.出库锁定.ObjToInt();
                    });
                    outboundOrderDetails.ForEach(x =>
@@ -218,6 +218,8 @@
                    {
                        _outboundOrderService.Repository.UpdateData(outboundOrder);
                    }
                    outboundOrder.Operator = App.User.UserName;
                    _outboundOrderService.Repository.UpdateData(outboundOrder);
                    WebResponseContent content = _outboundOrderDetailService.LockOutboundStockDataUpdate(stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks);
                    if (!content.Status)