| | |
| | | using AutoMapper; |
| | | using HslCommunication; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; |
| | | using Quartz; |
| | | using SqlSugar; |
| | | using System.Reflection; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Helper; |
| | |
| | | { |
| | | command.InteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | int count = string.IsNullOrEmpty(platform.Location) ? 0 + 1 : platform.Location.Split(',').Count() + 1; |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count }); |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform }); |
| | | } |
| | | } |
| | | else |
| | |
| | | { |
| | | command.InteractiveSignal = commandWrite.WriteInteractiveSignal; |
| | | int count = strings.Count - index; |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count }); |
| | | method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform }); |
| | | } |
| | | } |
| | | } |
| | |
| | | Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode); |
| | | if (task != null) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task); |
| | | taskCommand.InteractiveSignal = command.InteractiveSignal; |
| | | if (task.PalletCode != command.Barcode) |
| | | { |
| | | var NGAddress = _platFormRepository.QueryFirst(x => x.PlatCode == task.TargetAddress).Capacity; |
| | | taskCommand.TargetAddress = NGAddress; |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | } |
| | | else |
| | | { |
| | | taskCommand.TargetAddress = 0; |
| | | } |
| | | // TODO调用任务完成执行任务完成 |
| | | |
| | | #region 向WMS上报任务完成 |
| | | |
| | | WMSTaskDTO wMSTaskDTO = new WMSTaskDTO(); |
| | | var result = HttpHelper.PostAsync("http:127.0.0.1:8098/api/Task/CompleteTaskAsync", (new { taskNum = command.TaskNum }).ToJsonString()).Result; |
| | | |
| | | content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | |
| | | // 检查状态并返回 |
| | | if (!content.Status) |
| | | return; |
| | | |
| | | #endregion 向WMS请求空托盘任务 |
| | | |
| | | conveyorLine.SendCommand(taskCommand, childDeviceCode); |
| | | ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true); |
| | | WebResponseContent content = _taskService.UpdateTaskStatusToNext(task); |
| | | content = _taskService.UpdateTaskStatusToNext(task); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 创建任务并发送请求 |
| | | /// </summary> |
| | | private WebResponseContent CreateAndSendTask(WMSTaskDTO taskDTO) |
| | | public WebResponseContent CreateAndSendTask(WMSTaskDTO taskDTO) |
| | | { |
| | | var content = _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO }); |
| | | if (content.Status) |
| | |
| | | /// <param name="command">读取的请求信息</param> |
| | | /// <param name="childDeviceCode">子设备编号</param> |
| | | /// <param name="index">线体当前bool读取偏移地址</param> |
| | | public void EmptyTrayReturn(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int index) |
| | | public void EmptyTrayReturn(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int index, Platform platform) |
| | | { |
| | | CheckAndCreateTask((int)TaskOutboundTypeEnum.OutTray, childDeviceCode, index, "CHSC01", "001-001-001"); |
| | | TaskOutboundTypeEnum taskOutboundTypeEnum; |
| | | if (platform.PlatformType.Contains("OutTray")) |
| | | taskOutboundTypeEnum = TaskOutboundTypeEnum.OutTray; |
| | | else |
| | | taskOutboundTypeEnum = TaskOutboundTypeEnum.Outbound; |
| | | CheckAndCreateTask(TaskOutboundTypeEnum.OutTray, childDeviceCode, index, platform.Stacker.Split(',')[0], platform.Stacker.Split(',').ToList()); |
| | | } |
| | | |
| | | /// 静置空托盘出库 |
| | | /// </summary> |
| | | /// <param name="conveyorLine">输送线实例对象</param> |
| | | /// <param name="command">读取的请求信息</param> |
| | | /// <param name="childDeviceCode">子设备编号</param> |
| | | /// <param name="index">线体当前bool读取偏移地址</param> |
| | | public void EmptyTrayOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int index) |
| | | { |
| | | CheckAndCreateTask((int)TaskOutboundTypeEnum.OutTray, childDeviceCode, index, "JZSC01", "002-020-001"); |
| | | } |
| | | #region |
| | | ///// <summary> |
| | | ///// 陈化实盘出库) |
| | | ///// </summary> |
| | | ///// <param name="conveyorLine">输送线实例对象</param> |
| | | ///// <param name="command">读取的请求信息</param> |
| | | ///// <param name="childDeviceCode">子设备编号</param> |
| | | ///// <param name="index">线体当前bool读取偏移地址</param> |
| | | //public void ChuanhuaOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode) |
| | | //{ |
| | | // CheckAndCreateTask(TaskOutboundTypeEnum.Outbound, childDeviceCode, "CHSC01", "001-001-001"); |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 陈化出库(实盘) |
| | | /// </summary> |
| | | /// <param name="conveyorLine">输送线实例对象</param> |
| | | /// <param name="command">读取的请求信息</param> |
| | | /// <param name="childDeviceCode">子设备编号</param> |
| | | /// <param name="index">线体当前bool读取偏移地址</param> |
| | | public void ChuanhuaOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int index) |
| | | { |
| | | CheckAndCreateTask((int)TaskOutboundTypeEnum.Outbound, childDeviceCode, index, "CHSC01", "001-001-001"); |
| | | } |
| | | ///// 静置空托盘出库 |
| | | ///// </summary> |
| | | ///// <param name="conveyorLine">输送线实例对象</param> |
| | | ///// <param name="command">读取的请求信息</param> |
| | | ///// <param name="childDeviceCode">子设备编号</param> |
| | | ///// <param name="index">线体当前bool读取偏移地址</param> |
| | | //public void EmptyTrayOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int index) |
| | | //{ |
| | | // CheckAndCreateTask(TaskOutboundTypeEnum.OutTray, childDeviceCode, index, "JZSC01", "002-020-001"); |
| | | //} |
| | | ///// <summary> |
| | | ///// 静置实盘出库 |
| | | ///// </summary> |
| | | ///// <param name="conveyorLine">输送线实例对象</param> |
| | | ///// <param name="command">读取的请求信息</param> |
| | | ///// <param name="childDeviceCode">子设备编号</param> |
| | | ///// <param name="index">线体当前bool读取偏移地址</param> |
| | | //public void JingzhiOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int index) |
| | | //{ |
| | | // CheckAndCreateTask(TaskOutboundTypeEnum.Outbound, childDeviceCode, index, "JZSC01", "002-000-001"); |
| | | //} |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 检查任务并创建新任务 |
| | | /// </summary> |
| | | private void CheckAndCreateTask(int taskType, string childDeviceCode, int index, string roadWay, string sourceAddress) |
| | | private void CheckAndCreateTask(TaskOutboundTypeEnum taskType, string childDeviceCode, int index, string roadWay, List<string> roadways = null) |
| | | { |
| | | var tasks = _taskRepository.QueryData(x => x.TaskType == taskType && x.TargetAddress == childDeviceCode); |
| | | var tasks = _taskRepository.QueryData(x => x.TaskType == (int)taskType && x.TargetAddress == childDeviceCode); |
| | | if (tasks.Count < index) |
| | | { |
| | | var taskDTO = new WMSTaskDTO() |
| | | //var taskDTO = new WMSTaskDTO() |
| | | //{ |
| | | // TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), |
| | | // Grade = 1, |
| | | // PalletCode = DateTime.Now.ToString("yyyyMMddHHmmss"), |
| | | // RoadWay = roadWay, |
| | | // SourceAddress = sourceAddress, |
| | | // TargetAddress = childDeviceCode, |
| | | // TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | // Id = 0, |
| | | // TaskType = (int)taskType |
| | | //}; |
| | | #region 调用WMS获取出库任务 |
| | | WMSTaskDTO taskDTO = new WMSTaskDTO(); |
| | | dynamic dynamic = new |
| | | { |
| | | TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), |
| | | Grade = 1, |
| | | PalletCode = DateTime.Now.ToString("yyyyMMddHHmmss"), |
| | | RoadWay = roadWay, |
| | | SourceAddress = sourceAddress, |
| | | TargetAddress = childDeviceCode, |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | Id = 0, |
| | | TaskType = taskType |
| | | position = childDeviceCode, |
| | | tag = (int)taskType, |
| | | areaCdoe = roadWay, |
| | | roadways = roadways |
| | | }; |
| | | var result = HttpHelper.PostAsync("http:127.0.0.1:8098/api/Task/RequestTaskAsync", dynamic.ToJsonString()).Result; |
| | | |
| | | WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | |
| | | // 检查状态并返回 |
| | | if (!content.Status) |
| | | return; |
| | | |
| | | taskDTO = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString()); |
| | | #endregion |
| | | |
| | | CreateAndSendTask(taskDTO); |
| | | } |