| | |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEAWCS_DTO.WCSInfo; |
| | | using System.Transactions; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | | { |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å åæºç³è¯·å
¥åºï¼ï¼ï¼ï¼ï¼ï¼ï¼å
¥åºåé
é»è¾å¾
å® |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent StackerCraneRequestInbound(ConveyorLineDTO lineDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent().OK(); |
| | | try |
| | | { |
| | | var task = BaseDal.QueryFirst(x => x.PalletCode == lineDTO.Barcode); |
| | | if (task == null) throw new Exception($"æªæ¾å°æçå·[{lineDTO.Barcode}]çå
¥åºä»»å¡"); |
| | | if (task.TaskStatus != (int)InTaskStatusEnum.Line_InFinish) 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()) |
| | | { |
| | | _basicService.LocationInfoService.Repository.UpdateData(locationInfo); |
| | | _stockService.StockInfoService.Repository.UpdateData(stockInfo); |
| | | scope.Complete(); |
| | | } |
| | | content.Data = new ReceiveWMSInfo() |
| | | { |
| | | TargetAddress = locationInfo.LocationCode, |
| | | IsPickPlace = locationInfo.MaxQty - locationInfo.CurrentQty == 1, |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// è¾é线ç³è¯·å
¥åº |
| | | /// </summary> |
| | | /// <param name="lineDTO"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent ConveyorLineRequestInbound(ConveyorLineDTO lineDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent().OK(); |
| | | try |
| | | { |
| | | var task = BaseDal.QueryFirst(x => x.PalletCode == lineDTO.Barcode); |
| | | if (task == null) throw new Exception($"æªæ¾å°æçå·[{lineDTO.Barcode}]çå
¥åºä»»å¡"); |
| | | if (task.TaskStatus != (int)InTaskStatusEnum.AGV_InFinish) throw new Exception($"æçå·[{lineDTO.Barcode}]çå
¥åºä»»å¡ç¶æä¸å¹é
"); |
| | | |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(lineDTO.Barcode); |
| | | (bool, string) result = CheckRequestInbound(lineDTO.stationCode, lineDTO.Barcode, true, stockInfo); |
| | | if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2); |
| | | |
| | | if (lineDTO.Spec != 1 || lineDTO.Weight != 500)//æ¡ä»¶éæ´æ¹ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ |
| | | { |
| | | task.NextAddress = "101"; |
| | | task.TaskStatus = (int)InTaskStatusEnum.InException; |
| | | task.Remark = $"æç[{lineDTO.Barcode}]ä¿¡æ¯ä¸åæ ¼"; |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºæ¤é.ObjToInt(); |
| | | } |
| | | else |
| | | { |
| | | task.NextAddress = "104"; |
| | | task.CurrentAddress = lineDTO.stationCode; |
| | | task.TaskStatus = (int)InTaskStatusEnum.Line_InExecuting; |
| | | stockInfo.StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(); |
| | | } |
| | | |
| | | #region äºå¡ |
| | | using (TransactionScope scope = new TransactionScope()) |
| | | { |
| | | BaseDal.UpdateData(task); |
| | | Db.Updateable(stockInfo); |
| | | scope.Complete(); |
| | | } |
| | | #endregion |
| | | |
| | | if (!string.IsNullOrEmpty(task.Remark)) throw new Exception(task.Remark); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Code = 404; |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// éªè¯æ°æ® |
| | | /// </summary> |
| | | /// <param name="stationCode">èµ·å§å°å</param> |
| | |
| | | /// <returns>è¿åå¤çç»æ</returns> |
| | | private (bool, string) CheckRequestInbound(string stationCode, string palletCode, bool isCheckStock = true, Dt_StockInfo? stockInfo = null) |
| | | { |
| | | if (BaseDal.QueryFirst(x => x.PalletCode == palletCode) != null) |
| | | //if (BaseDal.QueryFirst(x => x.PalletCode == palletCode) != null) |
| | | //{ |
| | | // return (false, "该æçå·å·²æä»»å¡"); |
| | | //} |
| | | if (BaseDal.QueryFirst(x => (x.SourceAddress == stationCode || x.CurrentAddress == stationCode) && x.TaskStatus == InTaskStatusEnum.AGV_InFinish.ObjToInt()) != null) |
| | | { |
| | | return (false, "该æçå·å·²æä»»å¡"); |
| | | } |
| | | if (BaseDal.QueryFirst(x => (x.SourceAddress == stationCode || x.CurrentAddress == stationCode) && x.TaskStatus == InTaskStatusEnum.InNew.ObjToInt()) != null) |
| | | { |
| | | return (false, "å½åå
¥åºç«å°å·²æä¸æ¡æ°å»ºä»»å¡"); |
| | | return (false, "å½åå
¥åºç«å°å·²æä¸æ¡ä»»å¡"); |
| | | } |
| | | if (isCheckStock) |
| | | { |