| | |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEAWCS_DTO.WCSInfo; |
| | | using System.Transactions; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | | { |
| | |
| | | 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_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(); |
| | |
| | | #region ä¿®æ¹åºååè´§ä½ä¿¡æ¯ |
| | | task.TaskState = (int)InTaskStatusEnum.SC_InExecuting; |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = locationInfo.LocationCode;//使ç¨è´§ä½å¤æ³¨å段ï¼å¯¹åºå åæºæåå± |
| | | task.NextAddress = locationInfo.LocationCode; |
| | | task.TargetAddress = task.NextAddress; |
| | | string[] targetCodes = task.NextAddress.Split("-"); |
| | | var Row = Convert.ToInt16(targetCodes[0]); |
| | |
| | | return content; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·å空æçå
¥åºè´§ä½ |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent GetEmptyLocation(Dt_Task task) |
| | | { |
| | | try |
| | | { |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); |
| | | if (stockInfo == null) throw new Exception($"æªæ¾å°æç[{task.PalletCode}]çç»çä¿¡æ¯"); |
| | | Dt_StockInfoDetail? stockInfoDetail = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault(); |
| | | if (stockInfoDetail == null) throw new Exception($"æªæ¾å°æç[{task.PalletCode}]çç»ç详æ
"); |
| | | if (stockInfo.StockStatus != StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt() || !string.IsNullOrEmpty(stockInfo.LocationCode)) |
| | | throw new Exception($"æç[{task.PalletCode}],该ç»çç¶æä¸å¯å
¥åº"); |
| | | Dt_StockInfo? instockInfo = null; |
| | | Dt_LocationInfo? locationInfo = null; |
| | | string CarChargingStation = AppSettings.Configuration[nameof(CarChargingStation)];//è·åç©¿æ¢è½¦å
çµä½ç½® |
| | | var ChargingStations = CarChargingStation.Split(","); |
| | | Dt_StockInfoDetail instockInfoDetail = _stockService.StockInfoDetailService.Repository.QueryData(x => x.MaterielCode == stockInfoDetail.MaterielCode).OrderByDescending(x => x.CreateDate).First(); |
| | | if (instockInfoDetail != null) instockInfo = _stockService.StockInfoService.Repository.GetStockInfo(instockInfoDetail.StockId); |
| | | if (instockInfo != null)//æ åºå |
| | | { |
| | | locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == instockInfo.LocationCode); |
| | | if (ChargingStations.Contains(locationInfo.LocationCode)) |
| | | { |
| | | if (locationInfo.MaxQty - locationInfo.CurrentQty <= 1) locationInfo = null; |
| | | } |
| | | else if (locationInfo.MaxQty - locationInfo.CurrentQty < 1) |
| | | { |
| | | locationInfo = null; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | locationInfo = _basicService.LocationInfoService.AssignLocation(ChargingStations);//æ¥æ¾ç©¿æ¢è½¦å
çµè´§ä½ |
| | | } |
| | | if (locationInfo == null) locationInfo = _basicService.LocationInfoService.AssignLocation(2);//éæ°åé
è´§ä½ |
| | | if (locationInfo == null) throw new Exception($"æ å¯å
¥è´§ä½"); |
| | | |
| | | task.TaskState = (int)InTaskStatusEnum.SC_InExecuting; |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = locationInfo.LocationCode; |
| | | task.TargetAddress = task.NextAddress; |
| | | task.TargetIsPickPlace = locationInfo.Row > 1 ? locationInfo.MaxQty - locationInfo.CurrentQty == 1 : false; |
| | | task.SourceIsPickPlace = false; |
| | | stockInfo.LocationCode = locationInfo.LocationCode; |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºä¸.ObjToInt(); |
| | | stockInfoDetail.Status = StockStatusEmun.å
¥åºä¸.ObjToInt(); |
| | | locationInfo.CurrentQty++; |
| | | if (locationInfo.MaxQty < locationInfo.CurrentQty) throw new Exception(); |
| | | locationInfo.EnableStatus = EnableStatusEnum.OnlyOut.ObjToInt(); |
| | | locationInfo.LocationStatus = LocationStatusEnum.Inbounding.ObjToInt(); |
| | | |
| | | Db.Ado.BeginTran(); |
| | | UpdateData(task); |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfo); |
| | | _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetail); |
| | | _basicService.LocationInfoService.Repository.UpdateData(locationInfo); |
| | | Db.Ado.CommitTran(); |
| | | |
| | | return WebResponseContent.Instance.OK(data: new ReceiveWMSInfo() |
| | | { |
| | | TargetAddress = task.TargetAddress, |
| | | SourceIsPickPlace = task.SourceIsPickPlace, |
| | | TargetIsPickPlace = task.TargetIsPickPlace, |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |