| | |
| | | using Quartz; |
| | | using HslCommunication; |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using System.Collections.Concurrent; |
| | | using System.Net.Sockets; |
| | | using System.Text.Json; |
| | | using WIDESEAWCS_Common.HttpEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_Core.Http; |
| | | using WIDESEAWCS_DTO.Stock; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | |
| | | /// <returns></returns> |
| | | private async Task<string?> _TcpSocket_MessageReceived(string message, bool isJson, TcpClient client, RobotSocketState state) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | string messageLower = message.ToLowerInvariant(); |
| | | |
| | | if (IsSimpleCommand(messageLower, state)) |
| | |
| | | |
| | | if (cmd.StartsWith("pickfinished")) |
| | | { |
| | | StockDTO stockDTO = new StockDTO |
| | | { |
| | | SourceLineNo = state.CurrentTask?.RobotSourceAddressLineCode, |
| | | SourcePalletNo = state.CurrentTask?.RobotSourceAddressPalletCode, |
| | | TargetPalletNo = state.CurrentTask?.RobotTargetAddressPalletCode, |
| | | TargetLineNo = state.CurrentTask?.RobotTargetAddressLineCode, |
| | | Details = positions |
| | | .Where(x => x > 0) |
| | | .OrderBy(x => x) |
| | | .Select((x, idx) => new StockDetailDTO |
| | | { |
| | | Quantity = state.CurrentTask?.RobotTaskTotalNum ?? 1, |
| | | Channel = x > 0 ? x : throw new ArgumentOutOfRangeException(nameof(x), "Channel must be positive"), |
| | | CellBarcode = state.CellBarcode[idx] |
| | | }) |
| | | .ToList() |
| | | }; |
| | | state.LastPickPositions = positions; |
| | | |
| | | var result = await HttpRequestHelper.HTTPPostAsync(nameof(Category.WMS), stockDTO.ToJsonString(), state.CurrentTask?.RobotTaskType == 2 ? nameof(ConfigKey.ChangePalletAsync) : nameof(ConfigKey.SplitPalletAsync)); |
| | | content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | |
| | | if (content.Status) |
| | | { |
| | | state.CurrentAction = "PickFinished"; |
| | | } |
| | | } |
| | | else if (cmd.StartsWith("putfinished")) |
| | | { |
| | | state.LastPutPositions = positions; |
| | | if (state.CurrentTask?.RobotTaskType == 1) |
| | | { |
| | | // 发送数据给WMS组盘/换盘 |
| | | StockDTO stockDTO = new StockDTO |
| | | { |
| | |
| | | }) |
| | | .ToList() |
| | | }; |
| | | var result = await HttpRequestHelper.HTTPPostAsync(nameof(Category.WMS), stockDTO.ToJsonString(), nameof(ConfigKey.GroupPalletAsync)); |
| | | content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | |
| | | if (content.Status) |
| | | { |
| | | state.CurrentAction = "PutFinished"; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch { } |
| | | |
| | | return null; |