| | |
| | | using SqlSugar; |
| | | using System.DirectoryServices.Protocols; |
| | | using System.Text.Json; |
| | | using WIDESEA_Common.Constants; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | stockInfo.LocationCode = location.LocationCode; |
| | | stockInfo.LocationId = location.Id; |
| | | stockInfo.OutboundDate = task.Roadway switch |
| | | |
| | | var now = DateTime.Now; |
| | | if (task.Roadway.Contains("GW")) |
| | | { |
| | | var r when r.Contains("GW") => DateTime.Now.AddHours(2), |
| | | var r when r.Contains("CW") => DateTime.Now.AddHours(1), |
| | | _ => DateTime.Now |
| | | }; |
| | | if (stockInfo.Remark.IsNullOrEmpty()) |
| | | { |
| | | stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_GW1_FIRST); |
| | | stockInfo.Remark = StockRemarkConstants.GW1; |
| | | } |
| | | else if (stockInfo.Remark == StockRemarkConstants.GW1) |
| | | { |
| | | stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_GW1_SECOND); |
| | | stockInfo.Remark = StockRemarkConstants.GW2; |
| | | } |
| | | else |
| | | { |
| | | stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_GW1_FIRST); |
| | | } |
| | | } |
| | | else if (task.Roadway.Contains("CW")) |
| | | { |
| | | if (stockInfo.Remark == StockRemarkConstants.GW2) |
| | | { |
| | | stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_CW1); |
| | | stockInfo.Remark = StockRemarkConstants.CW1; |
| | | } |
| | | else |
| | | { |
| | | stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_CW1); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | stockInfo.OutboundDate = now; |
| | | } |
| | | |
| | | stockInfo.StockStatus = StockStatusEmun.入库完成.GetHashCode(); |
| | | |
| | | location.LocationStatus = LocationStatusEnum.InStock.GetHashCode(); |
| | |
| | | if (!updateLocationResult || !updateStockResult) |
| | | return WebResponseContent.Instance.Error("任务完成失败"); |
| | | // 调用MES托盘进站 |
| | | var inboundRequest = new InboundInContainerRequest |
| | | { |
| | | EquipmentCode = "STK-GROUP-001", |
| | | ResourceCode = "STK-GROUP-001", |
| | | LocalTime = DateTime.Now, |
| | | ContainerCode = taskDto.PalletCode |
| | | }; |
| | | var inboundResult = _mesService.InboundInContainer(inboundRequest); |
| | | if (inboundResult == null || inboundResult.Data == null || !inboundResult.Data.IsSuccess) |
| | | { |
| | | return content.Error($"任务完成失败:MES进站失败: {inboundResult?.Data?.Msg ?? inboundResult?.ErrorMessage ?? "未知错误"}"); |
| | | } |
| | | //var inboundRequest = new InboundInContainerRequest |
| | | //{ |
| | | // EquipmentCode = "STK-GROUP-001", |
| | | // ResourceCode = "STK-GROUP-001", |
| | | // LocalTime = DateTime.Now, |
| | | // ContainerCode = taskDto.PalletCode |
| | | //}; |
| | | //var inboundResult = _mesService.InboundInContainer(inboundRequest); |
| | | //if (inboundResult == null || inboundResult.Data == null || !inboundResult.Data.IsSuccess) |
| | | //{ |
| | | // return content.Error($"任务完成失败:MES进站失败: {inboundResult?.Data?.Msg ?? inboundResult?.ErrorMessage ?? "未知错误"}"); |
| | | //} |
| | | return await CompleteTaskAsync(task, "入库完成"); |
| | | }); |
| | | } |
| | |
| | | return WebResponseContent.Instance.Error("任务完成失败"); |
| | | |
| | | // 调用MES托盘出站 |
| | | var outboundRequest = new OutboundInContainerRequest |
| | | { |
| | | EquipmentCode = "STK-GROUP-001", |
| | | ResourceCode = "STK-GROUP-001", |
| | | LocalTime = DateTime.Now, |
| | | ContainerCode = taskDto.PalletCode, |
| | | ParamList = new List<ParamItem>() |
| | | }; |
| | | var outboundResult = _mesService.OutboundInContainer(outboundRequest); |
| | | if (outboundResult == null || outboundResult.Data == null || !outboundResult.Data.IsSuccess) |
| | | { |
| | | return content.Error($"任务完成失败:MES出站失败: {outboundResult?.Data?.Msg ?? outboundResult?.ErrorMessage ?? "未知错误"}"); |
| | | } |
| | | //var outboundRequest = new OutboundInContainerRequest |
| | | //{ |
| | | // EquipmentCode = "STK-GROUP-001", |
| | | // ResourceCode = "STK-GROUP-001", |
| | | // LocalTime = DateTime.Now, |
| | | // ContainerCode = taskDto.PalletCode, |
| | | // ParamList = new List<ParamItem>() |
| | | //}; |
| | | //var outboundResult = _mesService.OutboundInContainer(outboundRequest); |
| | | //if (outboundResult == null || outboundResult.Data == null || !outboundResult.Data.IsSuccess) |
| | | //{ |
| | | // return content.Error($"任务完成失败:MES出站失败: {outboundResult?.Data?.Msg ?? outboundResult?.ErrorMessage ?? "未知错误"}"); |
| | | //} |
| | | |
| | | return await CompleteTaskAsync(task, "出库完成"); |
| | | }); |
| | |
| | | var taskList = new List<Dt_Task>(); |
| | | foreach (var stock in stocksToProcess) |
| | | { |
| | | // 根据巷道确定目标地址 |
| | | var targetAddress = DetermineTargetAddress( |
| | | // 根据巷道确定目标地址(优先根据 Remark 确定,Remark 为空则根据巷道配置) |
| | | var targetAddress = DetermineTargetAddressByRemark( |
| | | stock.Remark ?? "", |
| | | stock.LocationDetails?.RoadwayNo ?? "", |
| | | targetAddressMap); |
| | | |
| | |
| | | if (stockInfo.LocationId > 0 || !string.IsNullOrWhiteSpace(stockInfo.LocationCode)) |
| | | return WebResponseContent.Instance.Error($"托盘[{stockPalletCode}]库存已绑定货位,不能创建机械手{taskName}任务"); |
| | | } |
| | | var section = App.Configuration.GetSection("RobotTaskAddressRules").GetSection(targetLineNo).GetChildren().Select(c => c.Value).ToArray(); |
| | | var section = App.Configuration.GetSection("RobotTaskAddressRules").GetSection(targetLineNo).GetChildren().Select(c => c.Value).ToArray(); |
| | | |
| | | var task = new Dt_Task |
| | | { |