| | |
| | |
|
| | | #endregion << 版 本 注 释 >>
|
| | |
|
| | | using Autofac.Core;
|
| | | using MapsterMapper;
|
| | | using Masuit.Tools;
|
| | | using Microsoft.Extensions.Configuration;
|
| | | using Newtonsoft.Json;
|
| | | using Newtonsoft.Json.Linq;
|
| | | using Serilog;
|
| | | using SqlSugar;
|
| | | using System.Diagnostics;
|
| | | using System.Diagnostics.CodeAnalysis;
|
| | | using System.Text;
|
| | | using WIDESEA_Core;
|
| | | using WIDESEAWCS_Common;
|
| | | using WIDESEAWCS_Common.HttpEnum;
|
| | |
| | | _taskExecuteDetailService = taskExecuteDetailService;
|
| | | _logger = logger;
|
| | | }
|
| | |
|
| | | public override WebResponseContent DeleteData(object[] keys)
|
| | | {
|
| | | List<int> taskKeys = new List<int>();
|
| | |
| | | List<Dt_RobotTask> tasks = BaseDal.QueryData(x => taskKeys.Contains(x.RobotTaskId));
|
| | | BaseDal.DeleteAndMoveIntoHty(tasks, OperateTypeEnum.人工删除);
|
| | | return WebResponseContent.Instance.OK($"成功删除{tasks.Count}条数据");
|
| | |
|
| | | }
|
| | |
|
| | | public bool DeleteRobotTask(int id)
|
| | | {
|
| | | Dt_RobotTask task = BaseDal.QueryFirst(x => x.RobotTaskId == id);
|
| | |
| | |
|
| | | public Dt_RobotTask? QueryRobotCraneTask(string deviceCode)
|
| | | {
|
| | | return BaseDal.QueryFirst(x => x.RobotRoadway == deviceCode && x.RobotTaskState != (int)TaskRobotStatusEnum.RobotExecuting, TaskOrderBy);
|
| | | return BaseDal.QueryFirst(x => x.RobotRoadway == deviceCode, TaskOrderBy);
|
| | | }
|
| | |
|
| | | public Dt_RobotTask? QueryRobotCraneExecutingTask(string deviceCode)
|
| | |
| | | /// 获取机械手任务总数量。
|
| | | /// 组盘任务固定48,换盘和拆盘任务通过托盘号查询WMS库存明细数量。
|
| | | /// </summary>
|
| | | private int GetRobotTaskTotalNum(int taskType, string? palletCode)
|
| | | public int GetRobotTaskTotalNum(int taskType, string? palletCode)
|
| | | {
|
| | | if (taskType == (int)RobotTaskTypeEnum.GroupPallet)
|
| | | return 48;
|
| | |
| | |
|
| | | try
|
| | | {
|
| | | QuartzLogHelper.LogInfo(_logger, $"开始调用WMS接口获取库存明细数量,托盘号:【{palletCode}】", "RobotTaskService");
|
| | | string url = $"{BaseAPI.WMSBaseUrl}Stock/GetStockDetailCount?palletCode={Uri.EscapeDataString(palletCode)}";
|
| | | var result = _httpClientHelper.Get(url);
|
| | | QuartzLogHelper.LogInfo(_logger, $"调用WMS获取库存明细数量接口,请求URL:【{url}】,响应数据:【{result.Content}】,耗时:{result.Duration}ms", "RobotTaskService");
|
| | | if (!result.IsSuccess || string.IsNullOrEmpty(result.Content))
|
| | | return 1;
|
| | |
|
| | |
| | | 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;
|
| | | var detailCount = (response.Data as JObject)?["detailCount"]?.Value<int>();
|
| | | return detailCount.HasValue && detailCount.Value > 0 ? detailCount.Value : 1;
|
| | | }
|
| | | catch
|
| | | {
|
| | |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
|
| | |
|
| | | DeviceProDTO? devicePro = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(ConveyorLineDBNameNew.Barcode) && x.DeviceChildCode == sourceLineNo);
|
| | | //conveyorLine.Communicator.Read(devicePro.DeviceProAddress, 20);
|
| | | //ConveyorLineTaskCommandNew command = conveyorLine.ReadCustomer<ConveyorLineTaskCommandNew>(sourceLineNo); // 测试用
|
| | | var barcode = conveyorLine.GetValue<ConveyorLineDBNameNew, string>(ConveyorLineDBNameNew.Barcode, sourceLineNo);
|
| | | var bytes = conveyorLine.Communicator.Read(devicePro.DeviceProAddress, 20);
|
| | | var barcode = Encoding.Default.GetString(bytes).Trim();
|
| | | stock.SourcePalletNo = string.IsNullOrEmpty(barcode) ? string.Empty : barcode;
|
| | | }
|
| | | }
|
| | |
| | | .Where(x => !string.IsNullOrWhiteSpace(x.Key) && !string.IsNullOrWhiteSpace(x.Value))
|
| | | .ToDictionary(x => x.Key.Trim(), x => x.Value!.Trim());
|
| | | }
|
| | |
|
| | | public WebResponseContent CreateRobotTaskManually(ManualRobotTaskDto request)
|
| | | {
|
| | | try
|
| | | {
|
| | | Dt_RobotTask robotTask = new Dt_RobotTask();
|
| | | robotTask.RobotTaskNum = Random.Shared.StrictNext();
|
| | | robotTask.RobotRoadway = request.RobotRoadway;
|
| | | if (request.RobotRoadway == RobotTaskTypeEnum.GroupPallet.ToString())
|
| | | {
|
| | | robotTask.RobotTaskType = (int)RobotTaskTypeEnum.GroupPallet;
|
| | | robotTask.RobotTaskState = (int)TaskRobotStatusEnum.RobotNew;
|
| | | robotTask.RobotTaskTotalNum = request.RobotTaskTotalNum;
|
| | | robotTask.RobotDispatchertime = DateTime.Now;
|
| | | robotTask.RobotRemark = "人工手动创建";
|
| | | robotTask.RobotTargetAddressPalletCode = request.RobotTargetAddressPalletCode;
|
| | | robotTask.RobotTargetAddressLineCode = "11068";
|
| | | }
|
| | | else if (request.RobotRoadway == RobotTaskTypeEnum.ChangePallet.ToString())
|
| | | {
|
| | | switch (request.Forward)
|
| | | {
|
| | | case 1:
|
| | | robotTask.RobotSourceAddress = "1";
|
| | | robotTask.RobotSourceAddressLineCode = "11010";
|
| | | robotTask.RobotTargetAddress = "3";
|
| | | robotTask.RobotTargetAddressLineCode = "2103";
|
| | | break;
|
| | | case 2:
|
| | | robotTask.RobotSourceAddress = "2";
|
| | | robotTask.RobotSourceAddressLineCode = "11001";
|
| | | robotTask.RobotTargetAddress = "4";
|
| | | robotTask.RobotTargetAddressLineCode = "2101";
|
| | | break;
|
| | | case 3:
|
| | | robotTask.RobotSourceAddress = "3";
|
| | | robotTask.RobotSourceAddressLineCode = "2103";
|
| | | robotTask.RobotTargetAddress = "1";
|
| | | robotTask.RobotTargetAddressLineCode = "11010";
|
| | | break;
|
| | | case 4:
|
| | | robotTask.RobotSourceAddress = "4";
|
| | | robotTask.RobotSourceAddressLineCode = "2101";
|
| | | robotTask.RobotTargetAddress = "2";
|
| | | robotTask.RobotTargetAddressLineCode = "11001";
|
| | | break;
|
| | | default:
|
| | | return WebResponseContent.Instance.Error($"添加机器人任务失败,方向不对");
|
| | | }
|
| | | robotTask.RobotTaskType = (int)RobotTaskTypeEnum.ChangePallet;
|
| | | robotTask.RobotTaskState = (int)TaskRobotStatusEnum.RobotNew;
|
| | | robotTask.RobotTaskTotalNum = request.RobotTaskTotalNum;
|
| | | robotTask.RobotDispatchertime = DateTime.Now;
|
| | | robotTask.RobotRemark = "人工手动创建";
|
| | | robotTask.RobotSourceAddressPalletCode = request.RobotSourceAddressPalletCode;
|
| | | robotTask.RobotTargetAddressPalletCode = request.RobotTargetAddressPalletCode;
|
| | | }
|
| | | else if (request.RobotRoadway == RobotTaskTypeEnum.SplitPallet.ToString())
|
| | | {
|
| | | robotTask.RobotTaskType = (int)RobotTaskTypeEnum.SplitPallet;
|
| | | robotTask.RobotTaskState = (int)TaskRobotStatusEnum.RobotNew;
|
| | | robotTask.RobotTaskTotalNum = request.RobotTaskTotalNum;
|
| | | robotTask.RobotDispatchertime = DateTime.Now;
|
| | | robotTask.RobotRemark = "人工手动创建";
|
| | | robotTask.RobotSourceAddressPalletCode = request.RobotSourceAddressPalletCode;
|
| | | }
|
| | | else
|
| | | {
|
| | | return WebResponseContent.Instance.Error($"添加机器人任务失败,机器人名称错误{request.RobotRoadway}");
|
| | | }
|
| | | return base.AddData(robotTask);
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | return WebResponseContent.Instance.Error($"添加机器人任务失败: {ex.Message}");
|
| | | }
|
| | | }
|
| | | }
|
| | | } |