| | |
| | | #region << 版 本 注 释 >> |
| | | |
| | | /*---------------------------------------------------------------- |
| | | * 命名空间:WIDESEAWCS_TaskInfoService |
| | | * 创建者:胡童庆 |
| | |
| | | * 修改时间: |
| | | * 版本:V1.0.1 |
| | | * 修改说明: |
| | | * |
| | | * |
| | | *----------------------------------------------------------------*/ |
| | | |
| | | #endregion << 版 本 注 释 >> |
| | | |
| | | using AutoMapper; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | | using HslCommunication; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Diagnostics.CodeAnalysis; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Enums; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_DTO.WMS; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob.Models; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | | { |
| | |
| | | {nameof(Dt_Task.CreateDate),OrderByType.Asc}, |
| | | }; |
| | | |
| | | public Dictionary<string, OrderByType> TaskOrderBy { get { return _taskOrderBy; } set { _taskOrderBy = value; } } |
| | | public Dictionary<string, OrderByType> TaskOrderBy |
| | | { get { return _taskOrderBy; } set { _taskOrderBy = value; } } |
| | | |
| | | public List<int> TaskInboundTypes => typeof(TaskInboundTypeEnum).GetEnumIndexList(); |
| | | |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | #region 真实数据 |
| | | // TODO: 调用接口获取下一个地址 |
| | | //// 创建请求对象 |
| | | //RequestTaskDto request = new RequestTaskDto() |
| | | //{ |
| | | // Position = sourceAddress, |
| | | // PalletCode = palletCode, |
| | | //}; |
| | | |
| | | //// 发送请求并等待响应 |
| | | //var result = HttpHelper.PostAsync("http:127.0.0.1:8098/api/Task/RequestTaskAsync", request.ToJsonString()).Result; |
| | | |
| | | //// 反序列化响应内容 |
| | | //content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | |
| | | //// 检查状态并返回 |
| | | //if (!content.Status) |
| | | // return content; |
| | | |
| | | //// 反序列化任务数据 |
| | | //WMSTaskDTO task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString()); |
| | | |
| | | //// 处理任务并返回结果 |
| | | //content = ReceiveWMSTask(new List<WMSTaskDTO> { task }); |
| | | |
| | | #endregion |
| | | |
| | | WMSTaskDTO taskDTO = new WMSTaskDTO() |
| | | { |
| | | TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), |
| | | Grade = 1, |
| | | PalletCode = palletCode, |
| | | RoadWay = "SC01", |
| | | RoadWay = "CHSC01", |
| | | SourceAddress = sourceAddress, |
| | | TargetAddress = "SC01", |
| | | TargetAddress = "CHSC01", |
| | | TaskState = (int)TaskInStatusEnum.InNew, |
| | | Id = 0, |
| | | TaskType = (int)TaskInboundTypeEnum.Inbound |
| | |
| | | public Dt_Task QueryCompletedConveyorLineTask(int taskNum, string currentAddress) |
| | | { |
| | | return BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.CurrentAddress == currentAddress && (x.TaskState == (int)TaskInStatusEnum.Line_InFinish || x.TaskState == (int)TaskOutStatusEnum.Line_OutFinish), TaskOrderBy); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据任务号、当前地址查询输送线新建的任务 |
| | | /// </summary> |
| | | /// <param name="taskNum">任务号</param> |
| | | /// <param name="currentAddress">当前地址</param> |
| | | /// <returns></returns> |
| | | public Dt_Task QueryCraneConveyorLineTask(int taskNum, string currentAddress) |
| | | { |
| | | return BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.CurrentAddress == currentAddress && (x.TaskState == (int)TaskInStatusEnum.InNew || x.TaskState == (int)TaskOutStatusEnum.OutNew), TaskOrderBy); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | Random random = new Random(); |
| | | task.CurrentAddress = task.NextAddress; |
| | | task.NextAddress = $"{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}"; |
| | | task.NextAddress = $"{random.Next(1, 1).ToString().PadLeft(3, '0')}-{random.Next(1, 1).ToString().PadLeft(3, '0')}-{random.Next(1, 1).ToString().PadLeft(3, '0')}"; |
| | | task.TargetAddress = task.NextAddress; |
| | | |
| | | #region 真实数据 |
| | | // TODO: 调用接口获取下一个地址 |
| | | //// 创建请求对象 |
| | | //RequestTaskDto request = new RequestTaskDto() |
| | | //{ |
| | | // Position = task.NextAddress, |
| | | // PalletCode = task.PalletCode, |
| | | //}; |
| | | |
| | | //// 发送请求并等待响应 |
| | | //var result = HttpHelper.PostAsync("http:127.0.0.1:8098/api/Task/RequestTaskAsync", request.ToJsonString()).Result; |
| | | |
| | | //// 反序列化响应内容 |
| | | //content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | |
| | | //// 检查状态并返回 |
| | | //if (!content.Status) |
| | | // return content; |
| | | |
| | | //// 反序列化任务数据 |
| | | //WMSTaskDTO taskResult = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString()); |
| | | |
| | | //task.CurrentAddress = task.NextAddress; |
| | | //task.NextAddress = taskResult.TargetAddress; |
| | | //task.TargetAddress = task.NextAddress; |
| | | #endregion |
| | | |
| | | } |
| | | } |
| | | else |
| | |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting) |
| | | { |
| | | //todo |
| | | //todo |
| | | int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>(); |
| | | task.TaskState = nextStatus; |
| | | task.ModifyDate = DateTime.Now; |
| | |
| | | BaseDal.UpdateData(task); |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"堆垛机入库完成"); |
| | | |
| | | WMSTaskDTO taskDTO = new WMSTaskDTO() |
| | | { |
| | | TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), |
| | | Grade = 1, |
| | | PalletCode = task.PalletCode + "S", |
| | | RoadWay = "SC01", |
| | | SourceAddress = task.TargetAddress, |
| | | TargetAddress = "CLOutAreaA", |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | Id = 0, |
| | | TaskType = (int)TaskOutboundTypeEnum.Outbound |
| | | }; |
| | | |
| | | content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO }); |
| | | //var x = new { taskNum = taskNum }; |
| | | //var result = HttpHelper.GetAsync("http:127.0.0.1:8098/api/Task/CompleteTaskAsync", x.ToJsonString()).Result; |
| | | //content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | |
| | | //WMSTaskDTO taskDTO = new WMSTaskDTO() |
| | | //{ |
| | | // TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")), |
| | | // Grade = 1, |
| | | // PalletCode = task.PalletCode + "S", |
| | | // RoadWay = "SC01", |
| | | // SourceAddress = task.TargetAddress, |
| | | // TargetAddress = "CLOutAreaA", |
| | | // TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | // Id = 0, |
| | | // TaskType = (int)TaskOutboundTypeEnum.Outbound |
| | | //}; |
| | | |
| | | //content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO }); |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) |
| | | { |
| | |
| | | } |
| | | else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OtherGroup) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | throw new Exception($"任务类型错误,未找到该任务类型,任务号:【{taskNum}】,任务类型:【{task.TaskType}】"); |
| | | } |
| | | content = WebResponseContent.Instance.OK(); |
| | | //content = WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | return content; |
| | | } |
| | | } |
| | | } |
| | | } |