huanghongfeng
4 天以前 1d8897348d578648421b024d0dc5ff3d626e05f9
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs
@@ -261,30 +261,75 @@
                            Locationtype = 10;
                        }
                        if (dt_StockInfo.MaterialType == (int)InventoryMaterialType.成品)
                        {
                            string[] targetCodes = dt_StockInfo.PalletCode.Split("*");
                            Dt_InboundOrder dt_Inbound = _inboundService.InbounOrderService.Repository.QueryFirst(x => x.OrderName == targetCodes[0]);
                            if (dt_Inbound.Startingcolumn != 0 || dt_Inbound.Terminationcolumn != 0)
                            {
                                newLocation = _basicService.LocationInfoService.GetLocation2(newSourceAddress.RoadwayNo, Locationtype, dt_Inbound.Startingcolumn, dt_Inbound.Terminationcolumn);
                                WriteLog.GetLog("库位获取日志,GetLocation").Write($"原材料入库获取库位,传入值,RoadwayNo:{newSourceAddress.RoadwayNo},类型:{Locationtype},区间为:{dt_Inbound.Startingcolumn}与{dt_Inbound.Terminationcolumn}=============获取到的库位为:{newLocation.LocationCode}", $"库位获取日志,GetLocation2");
                        int maxRetries = 20;
                        int retryCount = 0;
                        bool needRetry;
                        do
                        {
                            needRetry = false;  // é»˜è®¤ä¸éœ€è¦é‡è¯•
                            retryCount++;
                            if (dt_StockInfo.MaterialType == (int)InventoryMaterialType.成品)
                            {
                                string[] targetCodes = dt_StockInfo.PalletCode.Split("*");
                                Dt_InboundOrder dt_Inbound = _inboundService.InbounOrderService.Repository.QueryFirst(x => x.OrderName == targetCodes[0]);
                                if (dt_Inbound.Startingcolumn != 0 || dt_Inbound.Terminationcolumn != 0)
                                {
                                    newLocation = _basicService.LocationInfoService.GetLocation2(newSourceAddress.RoadwayNo, Locationtype, dt_Inbound.Startingcolumn, dt_Inbound.Terminationcolumn);
                                }
                                else
                                {
                                    newLocation = _basicService.LocationInfoService.GetLocation(newSourceAddress.RoadwayNo, Locationtype);
                                }
                            }
                            else
                            {
                                newLocation = _basicService.LocationInfoService.GetLocation(newSourceAddress.RoadwayNo, Locationtype);
                                WriteLog.GetLog("库位获取日志,GetLocation").Write($"原材料入库获取库位,传入值,RoadwayNo:{newSourceAddress.RoadwayNo},类型:{Locationtype},=============获取到的库位为:{newLocation.LocationCode}", $"库位获取日志,GetLocation,成品接口里面");
                            }
                        }
                        else
                            if (newLocation == null)
                            {
                                return WebResponseContent.Instance.Error("无法获取库位");
                            }
                            // 2. æ£€æŸ¥åº“å­˜
                            if (_stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == newLocation.LocationCode) !=null)
                            {
                                needRetry = true;
                                continue;  // ç›´æŽ¥è¿›å…¥ä¸‹ä¸€æ¬¡å¾ªçŽ¯ï¼ˆé‡è¯•ï¼‰
                            }
                            // 3. æ£€æŸ¥ä»»åŠ¡
                            if (BaseDal.QueryFirst(x => x.TargetAddress == newLocation.LocationCode) != null)
                            {
                                needRetry = true;
                                continue;
                            }
                            // 4. æ£€æŸ¥åŽ†å²ä»»åŠ¡
                            if (_taskHtyService.CrueeTaskHty(newLocation.LocationCode))
                            {
                                needRetry = true;
                                continue;
                            }
                        } while (needRetry && retryCount < maxRetries);
                        // æ£€æŸ¥æ˜¯å¦è¶…过最大重试次数
                        if (retryCount >= maxRetries)
                        {
                            newLocation = _basicService.LocationInfoService.GetLocation(newSourceAddress.RoadwayNo, Locationtype);
                            WriteLog.GetLog("库位获取日志,GetLocation").Write($"原材料入库获取库位,传入值,RoadwayNo:{newSourceAddress.RoadwayNo},类型:{Locationtype},=============获取到的库位为:{newLocation.LocationCode}", $"库位获取日志,GetLocation");
                            return WebResponseContent.Instance.Error($"无法找到可用库位(已尝试 {retryCount} æ¬¡ï¼‰");
                        }
                        //string[] Pallet = PalletCode.Split("-");
                        if (newLocation != null && newSourceAddress != null)
                        {
@@ -311,8 +356,13 @@
                            {
                                newLocation.LocationStatus = newSourceAddress.LocationType == (int)LocationTypeEnum.EmptyOut ? LocationStatusEnum.PalletLock.ObjToInt() : LocationStatusEnum.Lock.ObjToInt();
                            }
                            BaseDal.AddData(dt_Task);
                            else
                            {
                                return content = WebResponseContent.Instance.Error($"该库位{newSourceAddress.LocationCode}的货位状态异常,不可选");
                            }
                            _basicService.LocationInfoService.UpdateData(newLocation);
                            BaseDal.AddData(dt_Task);
                            _unitOfWorkManage.CommitTran();
@@ -335,6 +385,7 @@
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                return content = WebResponseContent.Instance.Error($"生成入库任务出错,出错信息:{ex.Message}");
                throw;
            }