| | |
| | | using System; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// å
¥ç©ºç®± |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WebResponseContent InEmpty(string barcode, string address, int WarehouseId) |
| | | { |
| | | try |
| | | { |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == WarehouseId); |
| | | if (warehouse == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°åºåº"); |
| | | } |
| | | Dt_StockInfo stockInfo = _stockRepository.StockInfoRepository.QueryFirst(x => x.PalletCode == barcode && x.StockStatus != StockStatusEmun.åºåºå®æ.ObjToInt()); |
| | | if (stockInfo != null) throw new Exception($"æçå·å·²åå¨"); |
| | | stockInfo = new Dt_StockInfo() |
| | | { |
| | | PalletCode = barcode, |
| | | StockStatus = StockStatusEmun.å
¥åºç¡®è®¤.ObjToInt(), |
| | | WarehouseId = WarehouseId, |
| | | PalletType = PalletTypeEnum.Empty.ObjToInt(), |
| | | Details = new List<Dt_StockInfoDetail>() |
| | | }; |
| | | Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.WarehouseId == WarehouseId); |
| | | if (locationInfo == null) return WebResponseContent.Instance.Error($"æªæ¾å°å½ååºåºè´§ä½ä¿¡æ¯"); |
| | | locationInfo = _basicService.LocationInfoService.AssignLocation(locationInfo.RoadwayNo, (PalletTypeEnum)stockInfo.PalletType, stockInfo.WarehouseId); |
| | | if (locationInfo == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"è´§ä½åé
失败,æªæ¾å°å¯åé
è´§ä½"); |
| | | } |
| | | |
| | | Dt_Task newTask = new Dt_Task() |
| | | { |
| | | CurrentAddress = address, |
| | | Grade = 0, |
| | | NextAddress = locationInfo.LocationCode, |
| | | PalletCode = barcode, |
| | | Roadway = locationInfo.RoadwayNo, |
| | | SourceAddress = address, |
| | | TargetAddress = locationInfo.LocationCode, |
| | | TaskType = TaskTypeEnum.Inbound.ObjToInt(), |
| | | TaskStatus = TaskStatusEnum.New.ObjToInt(), |
| | | WarehouseId = stockInfo.WarehouseId, |
| | | PalletType = stockInfo.PalletType |
| | | }; |
| | | |
| | | _unitOfWorkManage.BeginTran(); |
| | | int taskId = BaseDal.AddData(newTask); |
| | | newTask.TaskId = taskId; |
| | | _stockRepository.StockInfoRepository.AddData(stockInfo); |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | PutFinish(address); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | public WebResponseContent OutEmpty(int qty, string address, int WarehouseId) |
| | | { |
| | | try |
| | | { |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == WarehouseId); |
| | | if (warehouse == null) |
| | | { |
| | | return WebResponseContent.Instance.Error($"æªæ¾å°åºåº"); |
| | | } |
| | | var stockInfos = _stockRepository.StockInfoRepository.QueryData(x => x.WarehouseId == WarehouseId && x.PalletType == PalletTypeEnum.Empty.ObjToInt() && x.StockStatus == StockStatusEmun.å
¥åºå®æ.ObjToInt(), qty, nameof(Dt_StockInfo.CreateDate)); |
| | | if (stockInfos == null) return WebResponseContent.Instance.Error($"{warehouse.WarehouseName}æªæ¾å°ç©ºç®±åºå"); |
| | | if (stockInfos.Count < qty) return WebResponseContent.Instance.Error($"{warehouse.WarehouseName}空箱åºåä¸è¶³,åºåæ°ã{stockInfos.Count}ã"); |
| | | List<Dt_Task> tasks = GetTasks(stockInfos); |
| | | stockInfos.ForEach(x => |
| | | { |
| | | x.StockStatus = StockStatusEmun.åºåºéå®.ObjToInt(); |
| | | }); |
| | | _unitOfWorkManage.BeginTran(); |
| | | BaseDal.AddData(tasks); |
| | | _stockRepository.StockInfoRepository.UpdateData(stockInfos); |
| | | _unitOfWorkManage.CommitTran(); |
| | | PushTasksToWCS(tasks); |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | public WebResponseContent DeviceRequestInboundTask(string stationCode, string roadwayNo, string palletCode) |
| | | { |
| | | try |
| | |
| | | WMSTaskDTO wMSTaskDTO = _mapper.Map<WMSTaskDTO>(newTask); |
| | | |
| | | PushTasksToWCS(new List<Dt_Task> { newTask }); |
| | | if (newTask.WarehouseId == 5) PutFinish(stationCode); |
| | | return WebResponseContent.Instance.OK(data: wMSTaskDTO); |
| | | } |
| | | catch (Exception ex) |