1
huanghongfeng
10 天以前 f49fa4b5027cfdc27b429985d023e8002abcca2e
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs
@@ -245,6 +245,17 @@
                            _stockService.StockInfoService.Repository.AddData(dt_Stock);
                        }
                    }
                    /*else if(generate.SourceAddress == "R01-002-042-001-01")
                    {
                        WebResponseContent webResponse= Queryinventory(generate);
                        if (!webResponse.Status)
                        {
                            return content = WebResponseContent.Instance.Error($"组盘失败:{webResponse.Message}");
                        }
                    }*/
                    Dt_StockInfo dt_StockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == generate.PalletCode && x.StockStatus== (int)StockStatusEmun.组盘暂存);
                    if (dt_StockInfo != null)
                    {
@@ -261,30 +272,76 @@
                            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 +368,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 +397,7 @@
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                return content = WebResponseContent.Instance.Error($"生成入库任务出错,出错信息:{ex.Message}");
                throw;
            }
@@ -551,7 +614,16 @@
                            {
                                if (dt_StockInfo.StockStatus == (int)StockStatusEmun.组盘暂存)
                                {
                                    return content = WebResponseContent.Instance.OK(data: 1);
                                    List<Dt_Task> dt_Tasks= BaseDal.QueryData(x => x.PalletCode.Contains(PalletCodetarget));
                                    if (dt_Tasks.Count > 0)
                                    {
                                        return content = WebResponseContent.Instance.Error($"库存已有该条码,条码信息:{generate.PalletCode}");
                                    }
                                    else
                                    {
                                        return content = WebResponseContent.Instance.OK(data: 1);
                                    }
                                }
                                else
                                {