| | |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEAWCS_DTO.WCSInfo; |
| | | using System.Transactions; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | | { |
| | |
| | | Roadway = locationInfo.RoadwayNo, |
| | | SourceAddress = stationCode, |
| | | TargetAddress = locationInfo.LocationCode, |
| | | TaskStatus = InTaskStatusEnum.InNew.ObjToInt(), |
| | | TaskState = InTaskStatusEnum.InNew.ObjToInt(), |
| | | TaskType = taskType, |
| | | }; |
| | | BaseDal.AddData(task); |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// éªè¯æ°æ® |
| | | /// å åæºç³è¯·å
¥åº |
| | | /// </summary> |
| | | /// <param name="stationCode">èµ·å§å°å</param> |
| | | /// <param name="palletCode">æçç¼å·</param> |
| | | /// <param name="isCheckStock">æ¯å¦æ£æ¥ç»çä¿¡æ¯--åºåç©æå
¥åºå空æå
¥åº</param> |
| | | /// <param name="stockInfo">ç»çä¿¡æ¯--å¯ç©º</param> |
| | | /// <returns>è¿åå¤çç»æ</returns> |
| | | private (bool, string) CheckRequestInbound(string stationCode, string palletCode, bool isCheckStock = true, Dt_StockInfo? stockInfo = null) |
| | | /// <param name="task"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent StackerCraneRequestInbound(ConveyorLineDTO lineDTO) |
| | | { |
| | | if (BaseDal.QueryFirst(x => x.PalletCode == palletCode) != null) |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | return (false, "该æçå·å·²æä»»å¡"); |
| | | } |
| | | if (BaseDal.QueryFirst(x => (x.SourceAddress == stationCode || x.CurrentAddress == stationCode) && x.TaskStatus == InTaskStatusEnum.InNew.ObjToInt()) != null) |
| | | { |
| | | return (false, "å½åå
¥åºç«å°å·²æä¸æ¡æ°å»ºä»»å¡"); |
| | | } |
| | | if (isCheckStock) |
| | | { |
| | | if (stockInfo == null) |
| | | { |
| | | return (false, "æªæ¾å°ç»çä¿¡æ¯"); |
| | | } |
| | | if (stockInfo.StockStatus != StockStatusEmun.ç»çæå.ObjToInt()) |
| | | { |
| | | return (false, "该ç»çç¶æä¸å¯å
¥åº"); |
| | | } |
| | | if (!string.IsNullOrEmpty(stockInfo.LocationCode)) |
| | | { |
| | | return (false, "该æçå·²ç»å®è´§ä½"); |
| | | } |
| | | if (stockInfo.Details == null || stockInfo.Details.Count == 0) |
| | | { |
| | | return (false, "没æåºåæç»ä¿¡æ¯"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (_stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == palletCode) != null) |
| | | { |
| | | return (false, "该æçå·²åå¨åºå
"); |
| | | } |
| | | } |
| | | 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}]çå
¥åºä»»å¡ç¶æä¸å¹é
"); |
| | | |
| | | return (true, "æå"); |
| | | 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(); |
| | | if (stockInfoDetail == null) throw new Exception($"æªæ¾å°æç[{lineDTO.Barcode}]çç»ç详æ
"); |
| | | if (stockInfo.StockStatus != StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt()) throw new Exception($"æç[{lineDTO.Barcode}],该ç»çç¶æä¸å¯å
¥åº"); |
| | | |
| | | Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(stockInfoDetail.OrderNo); |
| | | if (inboundOrder == null || inboundOrder.Details == null) throw new Exception($"æªæ¾å°æç[{lineDTO.Barcode}]çå
¥åºåæç»ä¿¡æ¯"); |
| | | Dt_StockInfo instockInfo = null; |
| | | Dt_LocationInfo locationInfo = null; |
| | | #region 夿å½åå
¥åºæçæ¹æ¬¡å·æ¯å¦åå¨å·²åé
å
¥åº |
| | | 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); |
| | | } |
| | | #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); |
| | | //if (locationInfo.MaxQty == 12) |
| | | //{ |
| | | // locationInfo.EnableStatus = EnableStatusEnum.OnlyOut.ObjToInt(); |
| | | // _basicService.LocationInfoService.Repository.UpdateData(locationInfo); |
| | | // locationInfo = null; |
| | | //} |
| | | if (locationInfo.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt()) locationInfo = null; |
| | | else |
| | | { |
| | | 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 == 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 == 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; |
| | | } |
| | | |
| | | |