| | |
| | | locationInfo.LocationStatus = LocationStatusEnum.PalletLock.ObjToInt(); |
| | | if (isUpdateStock) |
| | | { |
| | | locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | locationInfo.LocationStatus = LocationStatusEnum.OutLock.ObjToInt(); |
| | | if (stockInfo != null && stockInfo.Details != null && stockInfo.Details.Count > 0) |
| | | { |
| | | orderNo = stockInfo.Details.FirstOrDefault()?.OrderNo ?? ""; |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å åæºç³è¯·å
¥åºï¼ï¼ï¼ï¼ï¼ï¼ï¼å
¥åºåé
é»è¾å¾
å® |
| | | /// å åæºç³è¯·å
¥åº |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent StackerCraneRequestInbound(ConveyorLineDTO lineDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent().OK(); |
| | | 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.Line_InFinish) throw new Exception($"æçå·[{lineDTO.Barcode}]çå
¥åºä»»å¡ç¶æä¸å¹é
"); |
| | | if (task.TaskState >= (int)InTaskStatusEnum.SC_InExecuting) throw new Exception($"æçå·[{lineDTO.Barcode}]çå
¥åºä»»å¡ç¶æä¸å¹é
"); |
| | | |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(lineDTO.Barcode); |
| | | if (stockInfo == null) throw new Exception($"æªæ¾å°æç[{lineDTO.Barcode}]çç»çä¿¡æ¯"); |
| | | if (stockInfo.StockStatus != StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt()) throw new Exception($"æç[{lineDTO.Barcode}],该ç»çç¶æä¸å¯å
¥åº"); |
| | | Dt_LocationInfo? locationInfo = _basicService.LocationInfoService.AssignLocation(lineDTO.stationCode, TaskTypeEnum.Inbound.ObjToInt()); |
| | | if (locationInfo == null) throw new Exception($"æ å¯å
¥è´§ä½"); |
| | | locationInfo.LocationStatus = LocationStatusEnum.Inbounding.ObjToInt(); |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºä¸.ObjToInt(); |
| | | using (TransactionScope scope = new TransactionScope()) |
| | | Dt_StockInfoDetail? stockInfoDetail = stockInfo.Details.Where(x => x.StockId == stockInfo.Id).FirstOrDefault(); |
| | | if (stockInfoDetail == null) throw new Exception($"æªæ¾å°æç[{lineDTO.Barcode}]çç»ç详æ
"); |
| | | if (stockInfo.StockStatus != StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt() || !string.IsNullOrEmpty(stockInfo.LocationCode)) |
| | | throw new Exception($"æç[{lineDTO.Barcode}],该ç»çç¶æä¸å¯å
¥åº"); |
| | | |
| | | Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(stockInfoDetail.OrderNo); |
| | | if (inboundOrder == null) throw new Exception($"æªæ¾å°æç[{lineDTO.Barcode}]çå
¥åºåä¿¡æ¯"); |
| | | |
| | | #region 夿æ¯å¦æå®è´§ä½ |
| | | Dt_InboundOrderDetail? orderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == stockInfoDetail.BatchNo); |
| | | if (orderDetail == null) throw new Exception($"æªæ¾å°æç[{lineDTO.Barcode}]çå
¥åºåæç»ä¿¡æ¯"); |
| | | Dt_LocationInfo? locationInfo = null; |
| | | if (!string.IsNullOrEmpty(orderDetail.LocationCode)) |
| | | { |
| | | _basicService.LocationInfoService.Repository.UpdateData(locationInfo); |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfo); |
| | | scope.Complete(); |
| | | locationInfo = _basicService.LocationInfoService.GetLocation(orderDetail.LocationCode); |
| | | } |
| | | content.Data = new ReceiveWMSInfo() |
| | | #endregion |
| | | |
| | | #region 夿å½åå
¥åºæçæ¹æ¬¡å·æ¯å¦åå¨å·²åé
å
¥åº |
| | | else |
| | | { |
| | | TargetAddress = locationInfo.LocationCode, |
| | | IsPickPlace = locationInfo.MaxQty - locationInfo.CurrentQty == 1, |
| | | }; |
| | | Dt_StockInfo? instockInfo = null; |
| | | Dt_StockInfoDetail instockInfoDetail = _stockService.StockInfoDetailService.Get_StockInfoDetail(stockInfoDetail.OrderNo, stockInfoDetail.BatchNo); |
| | | if (instockInfoDetail != null) instockInfo = _stockService.StockInfoService.Repository.GetStockInfo(instockInfoDetail.StockId); |
| | | if (instockInfo != null) |
| | | { |
| | | locationInfo = _basicService.LocationInfoService.GetLocation(instockInfo.LocationCode); |
| | | if (locationInfo.MaxQty <= locationInfo.CurrentQty) locationInfo = null; |
| | | } |
| | | #endregion |
| | | else |
| | | { |
| | | instockInfoDetail = _stockService.StockInfoDetailService.Get_StockInfoDetail(stockInfoDetail.OrderNo);//å
¥åºååå¨åºåï¼å¤æè´§ä½ |
| | | if (instockInfoDetail != null) instockInfo = _stockService.StockInfoService.Repository.GetStockInfo(instockInfoDetail.StockId); |
| | | if (instockInfo != null) |
| | | { |
| | | locationInfo = _basicService.LocationInfoService.GetLocation(instockInfo.LocationCode);//æ¥è¯¢å·²åå¨åºåè´§ä½ç¶æ |
| | | #region MyRegion |
| | | //if (locationInfo.MaxQty == 12) |
| | | //{ |
| | | // locationInfo.EnableStatus = EnableStatusEnum.OnlyOut.ObjToInt(); |
| | | // _basicService.LocationInfoService.Repository.UpdateData(locationInfo); |
| | | // locationInfo = null; |
| | | //} |
| | | //if (locationInfo.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt()) locationInfo = null; |
| | | #endregion |
| | | if (locationInfo.LocationStatus > LocationStatusEnum.Inbounding.ObjToInt()) locationInfo = null; |
| | | |
| | | else |
| | | { |
| | | #region å¤æè´§ä½ |
| | | if (locationInfo.Row == 1)//å¤ä¾§è´§ä½ï¼å¤æå
ä¾§è´§ä½ |
| | | { |
| | | var newLocation = Db.Queryable<Dt_LocationInfo>().Where(x => x.LocationCode != locationInfo.LocationCode && x.Remark == locationInfo.Remark).First(); |
| | | if (newLocation != null) |
| | | { |
| | | if (newLocation.LocationStatus == LocationStatusEnum.Free.ObjToInt() && |
| | | (newLocation.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || |
| | | newLocation.EnableStatus == EnableStatusEnum.Normal.ObjToInt())) |
| | | { |
| | | locationInfo = newLocation; |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | //List<Dt_StockInfoDetail> stockInfoDetails = _stockService.StockInfoDetailService.Get_StockInfoDetails(stockInfoDetail.OrderNo);//è·å工忿已å
¥åºæå
¥åºä¸åºå |
| | | //if (stockInfoDetails.GroupBy(x => x.BatchNo).Count() < 2) locationInfo.EnableStatus = EnableStatusEnum.OnlyOut.ObjToInt(); |
| | | //else locationInfo = null; |
| | | } |
| | | //if (locationInfo?.MaxQty <= locationInfo?.CurrentQty) locationInfo = null; |
| | | } |
| | | } |
| | | |
| | | if (locationInfo == null)//åé
æ°è´§ä½ |
| | | { |
| | | int inboundOrderCount = inboundOrder.Details.Count; |
| | | List<Dt_StockInfoDetail> stockInfoDetails = _stockService.StockInfoDetailService.Get_StockInfoDetails(stockInfoDetail.OrderNo);//è·å工忿已å
¥åºæå
¥åºä¸åºå |
| | | if (stockInfoDetails != null || stockInfoDetails.Count > 0) inboundOrderCount -= stockInfoDetails.GroupBy(x => x.BatchNo).Count(); |
| | | 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.IsPickPlace = locationInfo.MaxQty - locationInfo.CurrentQty == 1; |
| | | stockInfo.LocationCode = locationInfo.LocationCode; |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºä¸.ObjToInt(); |
| | | stockInfoDetail.Status = StockStatusEmun.å
¥åºä¸.ObjToInt(); |
| | | locationInfo.CurrentQty++; |
| | | if (locationInfo.MaxQty < locationInfo.CurrentQty) throw new Exception(); |
| | | if (locationInfo.MaxQty == 12) 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(); |
| | | #endregion |
| | | content.OK(data: new ReceiveWMSInfo() |
| | | { |
| | | TargetAddress = task.TargetAddress, |
| | | IsPickPlace = task.IsPickPlace, |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |