| | |
| | | using System.Diagnostics; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using WIDESEA_Core; |
| | | using WIDESEAWCS_Common;
|
| | | using WIDESEAWCS_Common.HttpEnum; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | |
| | | RobotTargetAddress = section[1]!, |
| | | RobotSourceAddressLineCode = stock?.SourceLineNo ?? string.Empty, |
| | | RobotTargetAddressLineCode = stock?.TargetLineNo ?? string.Empty, |
| | | RobotRoadway = stock?.TargetLineNo == "11068" ? "注液组盘机械手" : "换盘机械手" ?? string.Empty, // todo |
| | | RobotRoadway = stock?.TargetLineNo switch
|
| | | {
|
| | | "11068" => "注液组盘机械手",
|
| | | "1000" => "拆盘机械手",
|
| | | "2000" => "成品组盘机械手",
|
| | | _ => "换盘机械手"
|
| | | },
|
| | | RobotSourceAddressPalletCode = stock?.SourcePalletNo ?? string.Empty, |
| | | RobotTargetAddressPalletCode = stock?.TargetPalletNo ?? string.Empty, |
| | | RobotTaskType = taskType, |
| | | RobotTaskState = (int)TaskRobotStatusEnum.RobotNew, |
| | | RobotGrade = task.Grade, |
| | | Creater = "WCS_Local", |
| | | RobotTaskTotalNum = taskType == (int)RobotTaskTypeEnum.GroupPallet ? 48 : 1, |
| | | RobotTaskTotalNum = GetRobotTaskTotalNum(taskType, stock.SourcePalletNo),
|
| | | CreateDate = DateTime.Now |
| | | }; |
| | | |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取机械手任务总数量。
|
| | | /// 组盘任务固定48,换盘和拆盘任务通过托盘号查询WMS库存明细数量。
|
| | | /// </summary>
|
| | | private int GetRobotTaskTotalNum(int taskType, string? palletCode)
|
| | | {
|
| | | if (taskType == (int)RobotTaskTypeEnum.GroupPallet)
|
| | | return 48;
|
| | |
|
| | | if (string.IsNullOrWhiteSpace(palletCode))
|
| | | return 1;
|
| | |
|
| | | try
|
| | | {
|
| | | string url = $"{BaseAPI.WMSBaseUrl}Stock/GetStockDetailCount?palletCode={Uri.EscapeDataString(palletCode)}";
|
| | | var result = _httpClientHelper.Get(url);
|
| | | if (!result.IsSuccess || string.IsNullOrEmpty(result.Content))
|
| | | return 1;
|
| | |
|
| | | var response = JsonConvert.DeserializeObject<WebResponseContent>(result.Content);
|
| | | if (response == null || !response.Status)
|
| | | return 1;
|
| | |
|
| | | var detailCount = response.Data?.GetType().GetProperty("DetailCount")?.GetValue(response.Data);
|
| | | return detailCount is int count and > 0 ? count : 1;
|
| | | }
|
| | | catch
|
| | | {
|
| | | return 1;
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 将配置键映射到机械手任务类型枚举值。 |
| | | /// </summary> |
| | | /// <param name="configKey">配置键名称</param> |