wanshenmean
2024-11-06 98cd144e4d58dbfcc09a2ffb0dbb6925519088b3
最新代码更改
已修改16个文件
已添加5个文件
1340 ■■■■ 文件已修改
Code Management/WCS/WIDESEAWCS_Client/src/views/Login.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskEnumHelper.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskTypeEnum.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/ProcessParameters/Platform.cs 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ProcessParameters/IPlatFormRepository.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ProcessRepository/PlatFormRepository.cs 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/ConveyorLine/CommonConveyorLine.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs 476 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs 183 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/Dt_EquipmentProcess.cs 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/ResponeAgingInputDto.cs 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/AgingInOrOutInput/IAgingInOrOutInputService.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/BasicModel/DtBoxingInfoDetail.cs 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/BasicModel/DtStockInfo.cs 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs 58 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs 293 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Integration/AgingInOrOutController.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Client/src/views/Login.vue
@@ -95,9 +95,9 @@
    const loading = ref(false);
    const codeImgSrc = ref('');
    const userInfo = reactive({
      userName: '',
      password: '',
      verificationCode: '',
      userName: 'admin',
      password: '123456',
      verificationCode: '1234',
      UUID: undefined
    });
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskEnumHelper.cs
@@ -22,7 +22,7 @@
            {
                return TaskTypeGroup.OutbondGroup;
            }
            else if (!int.TryParse(Enum.Parse<TaskInStatusEnum>(taskType.ToString()).ToString(), out result))
            else if (!int.TryParse(Enum.Parse<TaskInboundTypeEnum>(taskType.ToString()).ToString(), out result))
            {
                return TaskTypeGroup.InboundGroup;
            }
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskTypeEnum.cs
@@ -71,6 +71,12 @@
        /// </summary>
        [Description("空托盘出库")]
        OutTray = 104,
        /// <summary>
        /// ç©ºæ‰˜ç›˜å‡ºåº“
        /// </summary>
        [Description("空托盘出库")]
        OutNG = 105,
    }
    public enum TaskRelocationTypeEnum
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs
@@ -73,6 +73,23 @@
        /// <returns></returns>
        Dt_Task QueryConveyorLineTask(string deviceNo, string currentAddress);
        /// <summary>
        /// æ ¹æ®è®¾å¤‡ç¼–号、当前地址查询输送线未执行的任务
        /// </summary>
        /// <param name="deviceNo">设备编号</param>
        /// <param name="currentAddress">当前地址</param>
        /// <returns></returns>
        Dt_Task QueryNextConveyorLineTask(string deviceNo, string currentAddress);
        /// <summary>
        /// æ ¹æ®æ‰˜ç›˜å·ã€å½“前地址查询输送线未执行的任务
        /// </summary>
        /// <param name="Barcode">托盘号</param>
        /// <param name="currentAddress">当前地址</param>
        /// <returns></returns>
        Dt_Task QueryBarCodeConveyorLineTask(string Barcode, string currentAddress);
        /// <summary>
        /// æ ¹æ®ä»»åŠ¡å·ã€ä¸‹ä¸€åœ°å€æŸ¥è¯¢è¾“é€çº¿æ‰§è¡Œä¸­çš„ä»»åŠ¡
        /// </summary>
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/ProcessParameters/Platform.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,94 @@
using Magicodes.ExporterAndImporter.Core;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core.DB.Models;
namespace WIDESEAWCS_Model.Models
{
    [SugarTable("Dt_Platform", "设备工艺参数")]
    public class Platform : BaseEntity
    {
        /// <summary>
        /// ä¸»é”®ID
        /// </summary>
        [ImporterHeader(Name = "主键")]
        [ExporterHeader(DisplayName = "主键")]
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主键")]
        public int Id { get; set; }
        /// <summary>
        /// ç«™å°ç¼–号,唯一标识每个站台的编号
        /// </summary>
        [ImporterHeader(Name = "站台编号,唯一标识每个站台的编号")]
        [ExporterHeader(DisplayName = "站台编号,唯一标识每个站台的编号")]
        [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "站台编号,唯一标识每个站台的编号")]
        public string PlatCode { get; set; }
        /// <summary>
        /// ç«™å°åç§°ï¼Œç«™å°çš„名称或描述
        /// </summary>
        [ImporterHeader(Name = "站台名称")]
        [ExporterHeader(DisplayName = "站台名称")]
        [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "站台名称")]
        public string PlatformName { get; set; }
        /// <summary>
        /// å¯¹åº”堆垛机
        /// </summary>
        [ImporterHeader(Name = "对应堆垛机")]
        [ExporterHeader(DisplayName = "对应堆垛机")]
        [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "对应堆垛机")]
        public string Stacker { get; set; }
        /// <summary>
        /// æ‰§è¡Œæ–¹æ³•
        /// </summary>
        [ImporterHeader(Name = "执行方法")]
        [ExporterHeader(DisplayName = "执行方法")]
        [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "执行方法")]
        public string ExecutionMethod { get; set; }
        /// <summary>
        /// ç«™å°ç±»åž‹ï¼Œç«™å°çš„类型
        /// </summary>
        [ImporterHeader(Name = "站台类型")]
        [ExporterHeader(DisplayName = "站台类型")]
        [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "站台类型")]
        public string PlatformType { get; set; }
        /// <summary>
        /// å¯¹åº”PLC编号,与站台对应的PLC的编号
        /// </summary>
        [ImporterHeader(Name = "对应PLC编号")]
        [ExporterHeader(DisplayName = "对应PLC编号")]
        [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "对应PLC编号")]
        public string PLCCode { get; set; }
        /// <summary>
        /// ç«™å°ä½ç½®
        /// </summary>
        [ImporterHeader(Name = "站台位置")]
        [ExporterHeader(DisplayName = "站台位置")]
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "站台位置")]
        public string Location { get; set; }
        /// <summary>
        /// ç«™å°å®¹é‡
        /// </summary>
        [ImporterHeader(Name = "站台容量")]
        [ExporterHeader(DisplayName = "站台容量")]
        [SugarColumn(IsNullable = true, ColumnDescription = "站台容量")]
        public int Capacity { get; set; }
        /// <summary>
        /// ç«™å°çŠ¶æ€ï¼Œé»˜è®¤ä¸º'Active'
        /// </summary>
        [ImporterHeader(Name = "站台状态")]
        [ExporterHeader(DisplayName = "站台状态")]
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "站台状态")]
        public string Status { get; set; } = "Active";
    }
}
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ProcessParameters/IPlatFormRepository.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,5 @@
namespace WIDESEAWCS_IProcessRepository;
public interface IPlatFormRepository : IRepository<Platform>
{
}
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ProcessRepository/PlatFormRepository.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
namespace WIDESEAWCS_ProcessRepository;
public class PlatFormRepository : RepositoryBase<Platform>, IPlatFormRepository
{
    public PlatFormRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage)
    {
    }
}
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/ConveyorLine/CommonConveyorLine.cs
@@ -224,7 +224,7 @@
            if (devicePro == null)
            {
                throw new Exception("未找到协议信息");
                throw new Exception("未找到协议信息:" + deviceChildCode);
            }
            else
            {
@@ -247,7 +247,7 @@
            if (devicePro == null)
            {
                throw new Exception("未找到协议信息");
                throw new Exception("未找到协议信息:" + deviceChildCode);
            }
            else
            {
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -192,6 +192,28 @@
        }
        /// <summary>
        /// æ ¹æ®è®¾å¤‡ç¼–号、当前地址查询输送线未执行的任务
        /// </summary>
        /// <param name="deviceNo">设备编号</param>
        /// <param name="currentAddress">当前地址</param>
        /// <returns></returns>
        public Dt_Task QueryNextConveyorLineTask(string deviceNo, string currentAddress)
        {
            return BaseDal.QueryFirst(x => (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.InNew || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish) && x.NextAddress == currentAddress, TaskOrderBy);
        }
        /// <summary>
        /// æ ¹æ®æ‰˜ç›˜å·ã€å½“前地址查询输送线未执行的任务
        /// </summary>
        /// <param name="Barcode">托盘号</param>
        /// <param name="currentAddress">当前地址</param>
        /// <returns></returns>
        public Dt_Task QueryBarCodeConveyorLineTask(string Barcode, string currentAddress)
        {
            return BaseDal.QueryFirst(x => (TaskInboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskInStatusEnum.InNew || TaskOutboundTypes.Contains(x.TaskType) && x.TaskState == (int)TaskOutStatusEnum.SC_OutFinish) && x.CurrentAddress == currentAddress && x.PalletCode == Barcode, TaskOrderBy);
        }
        /// <summary>
        /// æ ¹æ®ä»»åŠ¡å·ã€ä¸‹ä¸€åœ°å€æŸ¥è¯¢è¾“é€çº¿æ‰§è¡Œä¸­çš„ä»»åŠ¡
        /// </summary>
        /// <param name="taskNum">任务号</param>
@@ -397,10 +419,20 @@
                    if (task.TaskState == (int)TaskInStatusEnum.Line_InFinish)
                    {
                        Random random = new Random();
                        task.CurrentAddress = task.NextAddress;
                        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;
                        if (task.Roadway.Contains("CH"))
                        {
                            Random random = new Random();
                            task.CurrentAddress = task.NextAddress;
                            task.NextAddress = $"{random.Next(1, 1).ToString().PadLeft(3, '0')}-{random.Next(0, 0).ToString().PadLeft(3, '0')}-{random.Next(1, 1).ToString().PadLeft(3, '0')}";
                            task.TargetAddress = task.NextAddress;
                        }
                        else
                        {
                            Random random = new Random();
                            task.CurrentAddress = task.NextAddress;
                            task.NextAddress = "002-020-001";
                            task.TargetAddress = task.NextAddress;
                        }
                        #region çœŸå®žæ•°æ®
                        // TODO: è°ƒç”¨æŽ¥å£èŽ·å–ä¸‹ä¸€ä¸ªåœ°å€
@@ -524,7 +556,7 @@
                }
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting)
                {
                    //todo
                    //todo åŒæ­¥åˆ°WMS
                    int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>();
                    task.TaskState = nextStatus;
                    task.ModifyDate = DateTime.Now;
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -20,13 +20,16 @@
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;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_IProcessRepository;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
@@ -39,24 +42,23 @@
namespace WIDESEAWCS_Tasks
{
    [DisallowConcurrentExecution]
    public class CommonConveyorLineJob : JobBase, IJob
    public partial class CommonConveyorLineJob : JobBase, IJob
    {
        private readonly List<string> _deviceCodes1 = new List<string>() { "1063", "1061", "1060" };
        private readonly List<string> _deviceCodes2 = new List<string>() { "1067", "1069", "1068" };
        private readonly string[] HCTrayCode = { "1012", "1013" };
        private readonly ITaskService _taskService;
        public readonly ITaskService _taskService;
        private readonly ITaskRepository _taskRepository;
        private readonly ITaskExecuteDetailService _taskExecuteDetailService;
        private readonly IRouterService _routerService;
        private readonly IPlatFormRepository _platFormRepository;
        private readonly IMapper _mapper;
        public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, ITaskRepository taskRepository)
        public CommonConveyorLineJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, ITaskRepository taskRepository, IPlatFormRepository platFormRepository)
        {
            _taskService = taskService;
            _taskExecuteDetailService = taskExecuteDetailService;
            _routerService = routerService;
            _mapper = mapper;
            _taskRepository = taskRepository;
            _platFormRepository = platFormRepository;
        }
        public Task Execute(IJobExecutionContext context)
@@ -108,35 +110,49 @@
                                    }
                                }
                            }
                            Platform platform = _platFormRepository.QueryFirst(x => x.PLCCode == conveyorLine.DeviceCode && x.PlatCode == childDeviceCode && x.Status == "Active");
                            if (platform != null)
                            {
                                if (command.InteractiveSignal != 2)
                                {
                                    MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod);
                                    if (method != null)
                                    {
                                        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 });
                                    }
                                }
                                else
                                {
                                    if (!string.IsNullOrEmpty(platform.Location))
                                    {
                                        var strings = platform.Location.Split(',').ToList();
                                        foreach (var ite in strings)
                                        {
                                            int index = strings.FindIndex(p => p == ite);
                                            ConveyorLineTaskCommand command1 = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(ite);
                                            if (command1.InteractiveSignal != 2)
                                            {
                                                MethodInfo? method = GetType().GetMethod(platform.ExecutionMethod);
                                                if (method != null)
                                                {
                                                    command.InteractiveSignal = commandWrite.WriteInteractiveSignal;
                                                    int count = strings.Count - index;
                                                    method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count });
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        //});
                        //tasks.Add(task);
                        Task.WaitAll(tasks.ToArray());
                    }
                    //for (int i = 0; i < _deviceCodes1.Count; i++)
                    //{
                    //    ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(_deviceCodes1[i]);
                    //    if (command.InteractiveSignal != 2)
                    //    {
                    //        EmptyTrayReturn(conveyorLine, command, _deviceCodes1[_deviceCodes1.Count - 1], i);
                    //    }
                    //}
                    //for (int i = 0; i < _deviceCodes2.Count; i++)
                    //{
                    //    ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(_deviceCodes2[i]);
                    //    if (command.InteractiveSignal != 2)
                    //    {
                    //        EmptyTrayReturn(conveyorLine, command, _deviceCodes2[_deviceCodes1.Count - 1], i);
                    //    }
                    //}
                    foreach (var item in HCTrayCode)
                    {
                        ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(item);
                        if (command.InteractiveSignal != 2)
                        {
                            ChuanhuaOutbound(conveyorLine, command, HCTrayCode[0], 0);
                        }
                    }
                    Task.WaitAll(tasks.ToArray());
                }
            }
            catch (Exception ex)
@@ -148,6 +164,7 @@
                //WriteDebug("CommonConveyorLineJob", "test");
                //Console.Out.WriteLine(DateTime.Now);
            }
            return Task.CompletedTask;
        }
@@ -160,204 +177,139 @@
        /// <param name="ProtocalDetailValue">线体当前bool读取偏移地址</param>
        public void RequestInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        {
            var taskNew = _taskService.QueryCraneConveyorLineTask(command.Barcode.ObjToInt(), childDeviceCode);
            var Taskout = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
            if (Taskout != null)
            // èŽ·å–ä¸‹ä¸€ä¸ªä»»åŠ¡
            var task = _taskService.QueryBarCodeConveyorLineTask(command.Barcode, childDeviceCode);
            //var taskOut = _taskService.QueryNextConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
            //return;
            // å¤„理出库任务
            HandleTaskOut(conveyorLine, command, childDeviceCode, ProtocalDetailValue, task);
            // å¦‚果没有出库任务,处理新任务
            if (task == null)
            {
                // ç©ºæ‰˜ç›˜ä»»åŠ¡
                if (Taskout.TaskType == (int)TaskOutboundTypeEnum.OutTray)
                {
                    if (Taskout.TaskState == (int)TaskOutStatusEnum.SC_OutFinish)
                    {
                        ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(Taskout);
                        taskCommand.InteractiveSignal = command.InteractiveSignal;
                        if (command.Barcode == "")
                        {
                            taskCommand.TargetAddress = 1092;
                        }
                        conveyorLine.SendCommand(taskCommand, childDeviceCode);
                        ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                        _taskService.UpdateTaskStatusToNext(Taskout);
                    }
                    else if (Taskout.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting)
                    {
                        if (command.Barcode == "")
                        {
                            ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(Taskout);
                            taskCommand.InteractiveSignal = command.InteractiveSignal;
                            taskCommand.TargetAddress = 1092;
                            conveyorLine.SendCommand(taskCommand, childDeviceCode);
                            ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                            _taskService.UpdateTaskStatusToNext(Taskout);
                        }
                    }
                }
                else if (Taskout.TaskType == (int)TaskOutboundTypeEnum.Outbound)
                {
                    if (Taskout.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting)
                    {
                        ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(Taskout);
                        taskCommand.InteractiveSignal = command.InteractiveSignal;
                        if (command.Barcode == "")
                        {
                            //todo æ²¡æœ‰æ˜Žç¡®å¼‚常口,送到目标巷道的NG口
                            //taskCommand.TargetAddress = 1092;
                        }
                        conveyorLine.SendCommand(taskCommand, childDeviceCode);
                        ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                        _taskService.UpdateTaskStatusToNext(Taskout);
                    }
                    else if (Taskout.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting)
                    {
                        if (command.Barcode == "")
                        {
                            ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(Taskout);
                            taskCommand.InteractiveSignal = command.InteractiveSignal;
                            // todo  é€åˆ°ç›®æ ‡å··é“çš„NG口
                            taskCommand.TargetAddress = 1092;
                            conveyorLine.SendCommand(taskCommand, childDeviceCode);
                            ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                            _taskService.UpdateTaskStatusToNext(Taskout);
                        }
                        else
                        {
                            // todo è°ƒç”¨WMS任务完成接口
                            var x = new { taskNum = Taskout.TaskNum };
                            var result = HttpHelper.GetAsync("http:127.0.0.1:8098/api/Task/CompleteTaskAsync", x.ToJsonString()).Result;
                            WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result);
                            if (content.Status)
                            {
                                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                                _taskService.UpdateTaskStatusToNext(Taskout);
                            }
                        }
                    }
                }
                HandleNewTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue);
            }
            if (taskNew == null)
            {
                if (_taskService.RequestWMSTask(command.Barcode, childDeviceCode).Status)
                {
                    Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
                    if (task != null)
                    {
                        ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task);
                        taskCommand.InteractiveSignal = command.InteractiveSignal;
                        conveyorLine.SendCommand(taskCommand, childDeviceCode);
                        ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
            #region è€ç‰ˆæœ¬
                        _taskService.UpdateTaskStatusToNext(task);
                    }
                }
            }
        }
            //var taskNew = _taskService.QueryCraneConveyorLineTask(command.Barcode.ObjToInt(), childDeviceCode);
            //var Taskout = _taskService.QueryNextConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
            //if (Taskout != null)
            //{
            //    // ç©ºæ‰˜ç›˜ä»»åŠ¡
            //    if (Taskout.TaskType == (int)TaskOutboundTypeEnum.OutTray)
            //    {
            //        ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(Taskout);
            //        taskCommand.InteractiveSignal = command.InteractiveSignal;
            //        if (command.Barcode == "")
            //        {
            //            var NGAddress = _platFormRepository.QueryFirst(x => x.PlatCode == Taskout.TargetAddress).Capacity;
            //            taskCommand.TargetAddress = NGAddress;
            //        }
            //        conveyorLine.SendCommand(taskCommand, childDeviceCode);
        //
        /// <summary>
        /// ç©ºæ‰˜ç›˜å›žæµ
        /// </summary>
        /// <param name="conveyorLine">输送线实例对象</param>
        /// <param name="command">读取的请求信息</param>
        /// <param name="childDeviceCode">子设备编号</param>
        /// <param name="index">读取的第一个位置</param>
        public void EmptyTrayReturn(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int index)
        {
            var tasks = _taskRepository.QueryData(x => (x.TaskState == (int)TaskOutStatusEnum.OutNew || x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting) && x.TaskType == (int)TaskOutboundTypeEnum.OutTray);
            if (tasks.Count <= index)
            {
                WMSTaskDTO taskDTO = new WMSTaskDTO()
                {
                    TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
                    Grade = 1,
                    PalletCode = DateTime.Now.ToString("yyyyMMddHHmmss"),
                    RoadWay = "CHSC01",
                    SourceAddress = "001-001-001",
                    TargetAddress = childDeviceCode,
                    TaskState = (int)TaskOutStatusEnum.OutNew,
                    Id = 0,
                    TaskType = (int)TaskOutboundTypeEnum.OutTray
                };
            //        ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                #region çœŸå®žæ•°æ®
            //        _taskService.UpdateTaskStatusToNext(Taskout);
            //    }
            //    else if (Taskout.TaskType == (int)TaskOutboundTypeEnum.Outbound)
            //    {
            //        ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(Taskout);
            //        taskCommand.InteractiveSignal = command.InteractiveSignal;
            //        if (Taskout.TaskState == (int)TaskOutStatusEnum.SC_OutFinish)
            //        {
            //            if (command.Barcode == "")
            //            {
            //                var NGAddress = _platFormRepository.QueryFirst(x => x.PlatCode == Taskout.TargetAddress).Capacity;
            //                taskCommand.TargetAddress = NGAddress;
            //            }
            //            conveyorLine.SendCommand(taskCommand, childDeviceCode);
                // TODO: è°ƒç”¨æŽ¥å£èŽ·å–ä¸‹ä¸€ä¸ªåœ°å€
                //RequestTaskDto request = new RequestTaskDto()
                //{
                //    Position = sourceAddress,
                //    PalletCode = palletCode,
                //};
            //            ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                //// å‘送请求并等待响应
                //var result = HttpHelper.PostAsync("http:127.0.0.1:8098/api/Task/RequestTaskAsync", request.ToJsonString()).Result;
            //            _taskService.UpdateTaskStatusToNext(Taskout);
            //        }
            //        else if (Taskout.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting)
            //        {
            //            if (command.Barcode == "")
            //            {
            //                var NGAddress = _platFormRepository.QueryFirst(x => x.PlatCode == Taskout.TargetAddress).Capacity;
            //                taskCommand.TargetAddress = NGAddress;
                //// ååºåˆ—化响应内容
                //WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result);
            //                conveyorLine.SendCommand(taskCommand, childDeviceCode);
                //// æ£€æŸ¥çŠ¶æ€å¹¶è¿”å›ž
                ////if (!content.Status)
                ////    return content;
            //                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
            //                _taskService.UpdateTaskStatusToNext(Taskout);
            //            }
            //            else
            //            {
            //                // todo è°ƒç”¨WMS任务完成接口
            //                var x = new { taskNum = Taskout.TaskNum };
            //                var result = HttpHelper.GetAsync("http:127.0.0.1:8098/api/Task/CompleteTaskAsync", x.ToJsonString()).Result;
            //                WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result);
            //                if (content.Status)
            //                {
            //                    ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
            //                    _taskService.UpdateTaskStatusToNext(Taskout);
            //                }
            //            }
            //        }
            //    }
            //}
            //if (taskNew == null)
            //{
            //    // åŒ–成->陈化空托盘回流
            //    if (conveyorLine.DeviceCode == "1003" && childDeviceCode == "1016")
            //    {
            //        //TODO è°ƒç”¨WMS创建化成->陈化空托盘回流
            //        WMSTaskDTO taskDTO = new WMSTaskDTO()
            //        {
            //            TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
            //            Grade = 1,
            //            PalletCode = command.Barcode,
            //            RoadWay = "CHSC01",
            //            SourceAddress = childDeviceCode,
            //            TargetAddress = "CHSC01",
            //            TaskState = (int)TaskInStatusEnum.InNew,
            //            Id = 0,
            //            TaskType = (int)TaskInboundTypeEnum.InTray,
            //        };
            //        WebResponseContent content = CreateAndSendTask(taskDTO);
            //        if (content.Status)
            //        {
            //            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
            //            if (task != null)
            //            {
            //                ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task);
            //                taskCommand.InteractiveSignal = command.InteractiveSignal;
            //                conveyorLine.SendCommand(taskCommand, childDeviceCode);
                //// ååºåˆ—化任务数据
                //WMSTaskDTO task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
            //                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                #endregion
            //                _taskService.UpdateTaskStatusToNext(task);
            //            }
            //        }
            //    }
            //    else
            //    {
            //        if (_taskService.RequestWMSTask(command.Barcode, childDeviceCode).Status)
            //        {
            //            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
            //            if (task != null)
            //            {
            //                ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task);
            //                taskCommand.InteractiveSignal = command.InteractiveSignal;
            //                conveyorLine.SendCommand(taskCommand, childDeviceCode);
                var content = _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
                if (content.Status)
                {
                    Console.WriteLine("空托盘呼叫成功");
                }
            }
        }
            //                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
        /// <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)
        {
            var tasks = _taskRepository.QueryData(x => (x.TaskState == (int)TaskOutStatusEnum.OutNew || x.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting) && x.TaskType == (int)TaskOutboundTypeEnum.Outbound);
            if (tasks.Count <= index)
            {
                WMSTaskDTO taskDTO = new WMSTaskDTO()
                {
                    TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
                    Grade = 1,
                    PalletCode = DateTime.Now.ToString("MMddHHmmss"),
                    RoadWay = "CHSC01",
                    SourceAddress = "001-001-001",
                    TargetAddress = childDeviceCode,
                    TaskState = (int)TaskOutStatusEnum.OutNew,
                    Id = 0,
                    TaskType = (int)TaskOutboundTypeEnum.Outbound,
                };
            //                _taskService.UpdateTaskStatusToNext(task);
            //            }
            //        }
            //    }
            //}
                var content = _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
                if (content.Status)
                {
                    Console.WriteLine("出库呼叫成功");
                }
            }
            else
            {
                Dt_Task task = tasks[index];
                if (task != null)
                {
                    ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task);
                    taskCommand.InteractiveSignal = command.InteractiveSignal;
                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
                }
            }
            #endregion
        }
        /// <summary>
@@ -397,6 +349,7 @@
                //conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode);
                WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
                Console.Out.WriteLine(content.Serialize());
            }
        }
@@ -407,7 +360,8 @@
        /// <param name="conveyorLine">输送线实例对象</param>
        /// <param name="command">读取的请求信息</param>
        /// <param name="childDeviceCode">子设备编号</param>
        public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode)
        /// <param name="ProtocalDetailValue">线体当前bool读取偏移地址</param>
        public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        {
            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
            if (task != null)
@@ -416,6 +370,7 @@
                taskCommand.InteractiveSignal = command.InteractiveSignal;
                conveyorLine.SendCommand(taskCommand, childDeviceCode);
                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                _taskService.UpdateTaskStatusToNext(task);
            }
        }
@@ -447,14 +402,99 @@
        /// <param name="conveyorLine">输送线实例对象</param>
        /// <param name="command">读取的请求信息</param>
        /// <param name="childDeviceCode">子设备编号</param>
        public void ConveyorLineOutFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode)
        public void ConveyorLineOutFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        {
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            if (task != null)
            {
                conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode);
                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调用任务完成执行任务完成
                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
                Console.Out.WriteLine(content.Serialize());
            }
        }
        /// <summary>
        /// åˆ›å»ºä»»åŠ¡å¹¶å‘é€è¯·æ±‚
        /// </summary>
        private WebResponseContent CreateAndSendTask(WMSTaskDTO taskDTO)
        {
            var content = _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
            if (content.Status)
            {
                Console.WriteLine($"{taskDTO.TaskType}呼叫成功");
            }
            return content;
        }
        /// <summary>
        /// é™ˆåŒ–空托盘出库
        /// </summary>
        /// <param name="conveyorLine">输送线实例对象</param>
        /// <param name="command">读取的请求信息</param>
        /// <param name="childDeviceCode">子设备编号</param>
        /// <param name="index">线体当前bool读取偏移地址</param>
        public void EmptyTrayReturn(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int index)
        {
            CheckAndCreateTask((int)TaskOutboundTypeEnum.OutTray, 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((int)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 ChuanhuaOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int index)
        {
            CheckAndCreateTask((int)TaskOutboundTypeEnum.Outbound, childDeviceCode, index, "CHSC01", "001-001-001");
        }
        /// <summary>
        /// æ£€æŸ¥ä»»åŠ¡å¹¶åˆ›å»ºæ–°ä»»åŠ¡
        /// </summary>
        private void CheckAndCreateTask(int taskType, string childDeviceCode, int index, string roadWay, string sourceAddress)
        {
            var tasks = _taskRepository.QueryData(x => x.TaskType == taskType && x.TargetAddress == childDeviceCode);
            if (tasks.Count < index)
            {
                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 = taskType
                };
                CreateAndSendTask(taskDTO);
            }
        }
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,183 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_Core;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_Tasks.ConveyorLineJob;
using HslCommunication;
using OfficeOpenXml.ConditionalFormatting;
namespace WIDESEAWCS_Tasks
{
    partial class CommonConveyorLineJob
    {
        /// <summary>
        /// å¤„理出库任务
        /// </summary>
        private void HandleTaskOut(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue, Dt_Task taskOut)
        {
            // å¦‚果没有任务,直接返回
            if (taskOut == null) return;
            // æ˜ å°„任务命令
            var taskCommand = MapTaskCommand(taskOut, command);
            // æ ¹æ®ä¸åŒçš„任务类型和状态执行不同的逻辑
            bool isOutTray = taskOut.TaskType == (int)TaskOutboundTypeEnum.OutTray;
            bool isOutboundAndOutFinish = taskOut.TaskType == (int)TaskOutboundTypeEnum.Outbound && taskOut.TaskState == (int)TaskOutStatusEnum.SC_OutFinish;
            bool isOutboundAndLineOutExecuting = taskOut.TaskType == (int)TaskOutboundTypeEnum.Outbound && taskOut.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting;
            if (isOutTray || isOutboundAndOutFinish || isOutboundAndLineOutExecuting)
            {
                // å‘送命令到输送线
                conveyorLine.SendCommand(taskCommand, childDeviceCode);
                // æ ‡è®°å‘送完成
                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                // æ›´æ–°ä»»åŠ¡çŠ¶æ€
                _taskService.UpdateTaskStatusToNext(taskOut);
            }
            else if (taskOut.TaskType == (int)TaskOutboundTypeEnum.Outbound && taskOut.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting)
            {
                // å®ŒæˆWMS任务
                CompleteWmsTask(taskOut, command, conveyorLine, childDeviceCode, ProtocalDetailValue);
            }
        }
        /// <summary>
        /// å¤„理新任务
        /// </summary>
        private void HandleNewTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        {
            // ç‰¹å®šæ¡ä»¶ä¸‹åˆ›å»ºå¹¶å‘送空托盘入库任务
            if (conveyorLine.DeviceCode == "1003" && childDeviceCode == "1016")
            {
                CreateAndSendEmptyTrayTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue);
            }
            else if (conveyorLine.DeviceCode == "1001" && childDeviceCode == "1088")
            {
                // è¯·æ±‚WMS任务
                RequestWmsTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue);
            }
            else if ((conveyorLine.DeviceCode == "1001" && childDeviceCode == "1073") || (conveyorLine.DeviceCode == "1003" && childDeviceCode == "1002"))
            {
                //TODO å‘送直接去NG口任务
            }
        }
        /// <summary>
        /// æ˜ å°„任务命令
        /// </summary>
        private ConveyorLineTaskCommand MapTaskCommand(Dt_Task task, ConveyorLineTaskCommand command)
        {
            // ä½¿ç”¨mapper映射任务命令
            var comm = _mapper.Map<ConveyorLineTaskCommand>(task);
            comm.InteractiveSignal = command.InteractiveSignal;
            return comm;
        }
        /// <summary>
        /// å®ŒæˆWMS任务
        /// </summary>
        private void CompleteWmsTask(Dt_Task taskOut, ConveyorLineTaskCommand command, CommonConveyorLine conveyorLine, string childDeviceCode, int ProtocalDetailValue)
        {
            // å¦‚果没有条码信息,则设置目标地址为NG地址
            if (command.Barcode == "NoRead")
            {
                var NGAddress = _platFormRepository.QueryFirst(x => x.PlatCode == taskOut.TargetAddress).Capacity;
                taskOut.TargetAddress = NGAddress.ToString();
            }
            // TODO调用WMS任务完成接口
            var result = HttpHelper.GetAsync("http://127.0.0.1:8098/api/Task/CompleteTaskAsync", new { taskNum = taskOut.TaskNum }.ToJsonString()).Result;
            WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result);
            if (content.Status)
            {
                // æ ‡è®°å‘送完成
                ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                // æ›´æ–°ä»»åŠ¡çŠ¶æ€
                _taskService.UpdateTaskStatusToNext(taskOut);
            }
        }
        /// <summary>
        /// åˆ›å»ºå¹¶å‘送空托盘任务
        /// </summary>
        private void CreateAndSendEmptyTrayTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        {
            if (command.Barcode != "NoRead")
            {
                // åˆ›å»ºç©ºæ‰˜ç›˜ä»»åŠ¡DTO
                WMSTaskDTO taskDTO = CreateEmptyTrayTaskDto(command.Barcode, childDeviceCode);
                // åˆ›å»ºå¹¶å‘送任务
                WebResponseContent content = CreateAndSendTask(taskDTO);
                if (content.Status)
                {
                    // æŸ¥è¯¢ä»»åŠ¡
                    Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
                    if (task != null)
                    {
                        // æ˜ å°„任务命令
                        ConveyorLineTaskCommand taskCommand = MapTaskCommand(task, command);
                        // å‘送命令到输送线
                        conveyorLine.SendCommand(taskCommand, childDeviceCode);
                        // æ ‡è®°å‘送完成
                        ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                        // æ›´æ–°ä»»åŠ¡çŠ¶æ€
                        _taskService.UpdateTaskStatusToNext(task);
                    }
                }
            }
        }
        /// <summary>
        /// åˆ›å»ºç©ºæ‰˜ç›˜ä»»åŠ¡DTO
        /// </summary>
        private WMSTaskDTO CreateEmptyTrayTaskDto(string barcode, string childDeviceCode)
        {
            // åˆ›å»ºå¹¶è¿”回空托盘任务DTO
            return new WMSTaskDTO
            {
                TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
                Grade = 1,
                PalletCode = barcode,
                RoadWay = "CHSC01",
                SourceAddress = childDeviceCode,
                TargetAddress = "CHSC01",
                TaskState = (int)TaskInStatusEnum.InNew,
                Id = 0,
                TaskType = (int)TaskInboundTypeEnum.InTray,
            };
        }
        /// <summary>
        /// è¯·æ±‚WMS任务
        /// </summary>
        private void RequestWmsTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        {
            // è¯·æ±‚WMS任务
            if (_taskService.RequestWMSTask(command.Barcode, childDeviceCode).Status)
            {
                // æŸ¥è¯¢ä»»åŠ¡
                Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
                if (task != null)
                {
                    // æ˜ å°„任务命令
                    ConveyorLineTaskCommand taskCommand = MapTaskCommand(task, command);
                    // å‘送命令到输送线
                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
                    // æ ‡è®°å‘送完成
                    ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
                    // æ›´æ–°ä»»åŠ¡çŠ¶æ€
                    _taskService.UpdateTaskStatusToNext(task);
                }
            }
        }
    }
}
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -157,6 +157,10 @@
                    task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
                }
            }
            else if (task == null)
            {
                task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
            }
            return task;
        }
@@ -177,7 +181,7 @@
                    CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
                    //if (conveyorLine.IsOccupied(router.ChildPosi))//出库站台未被占用
                    //{
                        return task;
                    return task;
                    //}
                }
                else
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/Dt_EquipmentProcess.cs
@@ -2,6 +2,7 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -59,4 +60,71 @@
        [SugarColumn(IsNullable = false, Length = int.MaxValue, ColumnDescription = "工艺参数值")]
        public string ProcessValue { get; set; }
    }
    /// <summary>
    /// è¡¨ç¤ºå·¥è‰ºè·¯çº¿ä¸Šè®¾å¤‡å‚数信息的模型。
    /// </summary>
    public class EquipmentParameterInfo
    {
        /// <summary>
        /// å‚数编码。
        /// </summary>
        [Required(ErrorMessage = "参数编码是必填项。")]
        [StringLength(50, ErrorMessage = "参数编码长度不能超过50个字符。")]
        public string ParameterCode { get; set; }
        /// <summary>
        /// å‚数类型。
        /// </summary>
        [Required(ErrorMessage = "参数类型是必填项。")]
        [StringLength(50, ErrorMessage = "参数类型长度不能超过50个字符。")]
        public string ParameterType { get; set; }
        /// <summary>
        /// æŽ¨èå€¼ã€‚
        /// </summary>
        [StringLength(50, ErrorMessage = "推荐值长度不能超过50个字符。")]
        public string TargetValue { get; set; }
        /// <summary>
        /// å•位。
        /// </summary>
        public string UOMCode { get; set; }
        /// <summary>
        /// æŽ§åˆ¶ä¸Šé™å€¼ã€‚
        /// </summary>
        [StringLength(50, ErrorMessage = "控制上限值长度不能超过50个字符。")]
        public string UpperControlLimit { get; set; }
        /// <summary>
        /// æŽ§åˆ¶ä¸‹é™å€¼ã€‚
        /// </summary>
        [StringLength(50, ErrorMessage = "控制下限值长度不能超过50个字符。")]
        public string LowerControlLimit { get; set; }
        /// <summary>
        /// è§„格上限值。
        /// </summary>
        [StringLength(50, ErrorMessage = "规格上限值长度不能超过50个字符。")]
        public string UpperSpecificationsLimit { get; set; }
        /// <summary>
        /// è§„格下限值。
        /// </summary>
        [StringLength(50, ErrorMessage = "规格下限值长度不能超过50个字符。")]
        public string LowerSpecificationsLimit { get; set; }
        /// <summary>
        /// å‚数描述。
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        /// å·¥è‰ºè·¯çº¿ä¸Šå½“前设备参数信息是否可用。
        /// TRUE è¡¨ç¤ºå¯ç”¨ï¼ŒFALSE è¡¨ç¤ºä¸å¯ç”¨ã€‚
        /// </summary>
        [Required(ErrorMessage = "设备参数信息是否可用是必填项。")]
        public string EquipmentAvailabilityFlag { get; set; }
    }
}
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_DTO/MOM/ResponeAgingInputDto.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WIDESEA_DTO.MOM
{
    public class ResponeAgingInputDto : BasicResult
    {
        /// <summary>
        /// æ–™æ¡†å±žæ€§ï¼Œç”¨äºŽæ ‡è¯†æ–™æ¡†çš„唯一属性。
        /// </summary>
        public string TrayBarcodeProperty { get; set; }
        /// <summary>
        /// å·¥å•编码或产品型号,用于关联具体的生产任务。
        /// </summary>
        public string BindCode { get; set; }
        /// <summary>
        /// å…³è”工序返回时间,记录注液或静置时长。
        /// </summary>
        public string LinedProcessFeedbackTime { get; set; }
    }
}
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_IStoragIntegrationServices/MOM/AgingInOrOutInput/IAgingInOrOutInputService.cs
@@ -10,12 +10,12 @@
    /// </summary>
    /// <param name="input">入库数据</param>
    /// <returns></returns>
    Task<dynamic> GetOCVInputAsync(AgingInputDto input);
    Task<WebResponseContent> GetOCVInputAsync(AgingInputDto input);
    /// <summary>
    /// é™ç½®\陈化出库(整托盘)
    /// </summary>
    /// <param name="input">出库数据</param>
    /// <returns></returns>
    Task<dynamic> GetOCVOutputAsync(AgingOutputDto input);
    Task<WebResponseContent> GetOCVOutputAsync(AgingOutputDto input);
}
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/BasicModel/DtBoxingInfoDetail.cs
@@ -20,7 +20,7 @@
    public int BoxingInfoId { get; set; }
    /// <summary>
    /// ç‰©æ–™ç¼–码
    /// ç‰©æ–™ç¼–码 ç»‘定代码
    /// </summary>
    [Required]
    [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "物料编号")]
@@ -34,7 +34,7 @@
    public string MaterielName { get; set; }
    /// <summary>
    /// å•据编号
    /// å•据编号 / é€šé“
    /// </summary>
    [Required]
    [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "单据编号")]
@@ -48,7 +48,7 @@
    public string BatchNo { get; set; }
    /// <summary>
    /// åºåˆ—号
    /// åºåˆ—号(电芯)
    /// </summary>
    [Required]
    [SugarColumn(IsNullable = false, Length = 100, ColumnDescription = "序列号")]
@@ -68,14 +68,14 @@
    public decimal OutboundQuantity { get; set; }
    /// <summary>
    /// ç»„盘状态
    /// ç»„盘状态 ç”µèŠ¯çŠ¶æ€
    /// </summary>
    [Required]
    [SugarColumn(IsNullable = false, ColumnDescription = "组盘状态")]
    public int Status { get; set; }
    /// <summary>
    /// å¤‡æ³¨
    /// å¤‡æ³¨ // æ–™æ¡†å±žæ€§Json
    /// </summary>
    [SugarColumn(IsNullable = true, ColumnDescription = "备注")]
    public string Remark { get; set; }
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/BasicModel/DtStockInfo.cs
@@ -36,11 +36,18 @@
        public bool IsFull { get; set; }
        /// <summary>
        /// å¤‡æ³¨
        /// å¤‡æ³¨ (静制)
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "备注")]
        public string Remark { get; set; }
        /// <summary>
        /// åŒºåŸŸç¼–码
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "区域编码")]
        public string AreaCode { get; set; }
        /// <summary>
        /// åº“存明细
        /// </summary>
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/AgingInOrOutInput/AgingInOrOutInputService.cs
@@ -1,7 +1,9 @@
using LogLibrary.Log;
using Masuit.Tools;
using WIDESEA_Common;
using WIDESEA_Core;
using WIDESEA_DTO;
using WIDESEA_DTO.MOM;
using WIDESEA_IStoragIntegrationServices;
namespace WIDESEA_StoragIntegrationServices;
@@ -15,8 +17,9 @@
    /// </summary>
    /// <param name="input">入库数据</param>
    /// <returns></returns>
    public async Task<dynamic> GetOCVInputAsync(AgingInputDto input)
    public async Task<WebResponseContent> GetOCVInputAsync(AgingInputDto input)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            input.SessionId = Guid.NewGuid().ToString();
@@ -26,10 +29,7 @@
            input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
            var inputJson = input.ToDictionary();
            var x = await HttpsClient.PostAsync("http://ts-momapp01:12020/api/MachineIntegration/AgingInput", inputJson);
            if (x != null)
            {
            }
            content.OK(data: x);
            LogFactory.GetLog("静置陈化入库(整托盘)").Info(true, $"\r\r--------------------------------------");
            LogFactory.GetLog("静置陈化入库(整托盘)").Info(true, x);
@@ -40,7 +40,7 @@
            LogFactory.GetLog("静置陈化入库(整托盘)").Error(true, $"\r\r--------------------------------------");
            LogFactory.GetLog("静置陈化入库(整托盘)").Error(true, err.StackTrace);
        }
        return Task.FromResult<dynamic>(null);
        return content;
    }
    /// <summary>
@@ -48,8 +48,9 @@
    /// </summary>
    /// <param name="input">出库数据</param>
    /// <returns></returns>
    public async Task<dynamic> GetOCVOutputAsync(AgingOutputDto input)
    public async Task<WebResponseContent> GetOCVOutputAsync(AgingOutputDto input)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            input.SessionId = Guid.NewGuid().ToString();
@@ -61,13 +62,15 @@
            var x = await HttpsClient.PostAsync("http://ts-momapp01:12020/api/MachineIntegration/AgingOutput", inputJson);
            LogFactory.GetLog("静置陈化出库(整托盘)").Info(true, $"\r\r--------------------------------------");
            LogFactory.GetLog("静置陈化出库(整托盘)").Info(true, x);
            content.OK();
        }
        catch (Exception err)
        {
            Console.WriteLine(err.Message.ToString());
            LogFactory.GetLog("静置/陈化出库(整托盘)").Error(true, $"\r\r--------------------------------------");
            LogFactory.GetLog("静置/陈化出库(整托盘)").Error(true, err.StackTrace);
            content.Error(err.Message);
        }
        return Task.FromResult<dynamic>(null);
        return content;
    }
}
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MOM/CellState/CellStateService.cs
@@ -94,34 +94,36 @@
            input.RequestTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now).ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
            var inputJson = input.ToDictionary();
            var x = await HttpsClient.PostAsync("http://ts-momapp01:12020/api/MachineIntegration/TrayCellsStatus", inputJson);
            if (x != null)
            {
                ResultTrayCellsStatus result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(x);
                DtBoxingInfo boxingInfo = new DtBoxingInfo()
                {
                    IsFull = true,
                    PalletCode = result.TrayBarcode,
                };
                var details = new List<DtBoxingInfoDetail>();
                foreach (var item in result.SerialNos)
                {
                    DtBoxingInfoDetail detail = new DtBoxingInfoDetail()
                    {
                        SerialNumber = item.SerialNo,
                        OrderNo = item.PositionNo.ToString(),
                        Status = item.SerialNoStatus,
                        Remark = result.TrayBarcodePropertys.ToJsonString(),
                        MaterielCode = result.BindCode,
                    };
                    details.Add(detail);
                }
                boxingInfo.BoxingInfoDetails = details;
                var abc = await _boxingInfoService.AddBoxingInfoAsync(boxingInfo);
                if (abc.Status)
                    content.OK("组盘成功", result);
                else
                    content.Error("组盘失败");
            }
            //if (x != null)
            //{
            //    // ååºåˆ—化ResultTrayCellsStatus对象
            //    ResultTrayCellsStatus result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(x);
            //    // åˆ›å»ºDtBoxingInfo对象
            //    DtBoxingInfo boxingInfo = new DtBoxingInfo
            //    {
            //        IsFull = true,
            //        PalletCode = result.TrayBarcode,
            //    };
            //    // ä½¿ç”¨LINQ创建DtBoxingInfoDetail对象列表
            //    var details = result.SerialNos.Select(item => new DtBoxingInfoDetail
            //    {
            //        SerialNumber = item.SerialNo,
            //        OrderNo = item.PositionNo.ToString(),
            //        Status = item.SerialNoStatus,
            //        Remark = result.TrayBarcodePropertys.ToJsonString(),
            //        MaterielCode = result.BindCode,
            //    }).ToList();
            //    // èµ‹å€¼DtBoxingInfoDetails
            //    boxingInfo.BoxingInfoDetails = details;
            //    var abc = await _boxingInfoService.AddBoxingInfoAsync(boxingInfo);
            //    if (abc.Status)
            //        content.OK("组盘成功", result);
            //    else
            //        content.Error("组盘失败");
            //}
            LogFactory.GetLog("整盘电芯属性获取").Info(true, $"\r\r--------------------------------------");
            LogFactory.GetLog("整盘电芯属性获取").Info(true, x);
        }
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs
@@ -1,8 +1,11 @@
using Mapster;
using Masuit.Tools;
using WIDESEA_DTO.MOM;
using WIDESEA_DTO.WMS;
using WIDESEA_IStorageBasicRepository;
using WIDESEA_IStoragIntegrationServices;
using WIDESEA_StorageBasicRepository;
using WIDESEA_StoragIntegrationServices;
namespace WIDESEA_StorageOutTaskServices;
@@ -12,6 +15,7 @@
    private readonly IUnitOfWorkManage _unitOfWorkManage;
    private readonly IDt_OutOrderRepository _outOrderRepository;
    private readonly IStockInfoRepository _stockInfoRepository;
    private readonly IStockInfoDetailRepository _stockInfoDetailRepository;
    private readonly IDt_Task_HtyRepository _task_HtyRepository;
    private readonly IDt_OutOrderAndStockRepository _outOrderAndStockRepository;
    private readonly IDt_OutOrderAndStock_HtyRepository _outOrderAndStock_HtyRepository;
@@ -22,10 +26,11 @@
    private readonly IPointStackerRelationRepository _pointStackerRelationRepository;
    private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository;
    private readonly ILocationStatusChangeRecordRepository _locationStatusChangeRecordRepository;
    private readonly IBoxingInfoRepository _boxingInfoRepository;
    private readonly ICellStateService _cellStateService;
    private readonly IProcessApplyService _processApplyService;
    private readonly IDt_AreaInfoRepository _areaInfoRepository;
    private readonly IBoxingInfoRepository _boxingInfoRepository; //组盘
    private readonly ICellStateService _cellStateService; //电芯属性
    private readonly IProcessApplyService _processApplyService; //工艺路线
    private readonly IDt_AreaInfoRepository _areaInfoRepository; //区域
    private readonly IAgingInOrOutInputService _agingInOrOutInputService; //静置\陈化
    public Dt_TaskService(IDt_TaskRepository BaseDal,
                                IUnitOfWorkManage unitOfWorkManage,
@@ -44,7 +49,9 @@
                                IBoxingInfoRepository boxingInfoRepository,
                                ICellStateService cellStateService,
                                IProcessApplyService processApplyService,
                                IDt_AreaInfoRepository areaInfoRepository) : base(BaseDal)
                                IDt_AreaInfoRepository areaInfoRepository,
                                IAgingInOrOutInputService agingInOrOutInputService,
                                IStockInfoDetailRepository stockInfoDetailRepository) : base(BaseDal)
    {
        _unitOfWorkManage = unitOfWorkManage;
        _outOrderRepository = outOrderRepository;
@@ -63,14 +70,16 @@
        _cellStateService = cellStateService;
        _processApplyService = processApplyService;
        _areaInfoRepository = areaInfoRepository;
        _agingInOrOutInputService = agingInOrOutInputService;
        _stockInfoDetailRepository = stockInfoDetailRepository;
    }
    #region å¤–部接口方法
    #region å †åž›æœºå‡ºåº“任务完成
    #region å‡ºåº“任务完成
    /// <summary>
    /// å †åž›æœºå‡ºåº“任务完成
    /// å‡ºåº“任务完成
    /// </summary>
    /// <param name="saveModel">任务数据合集</param>
    /// <returns>返回结果集</returns>
@@ -79,17 +88,48 @@
        WebResponseContent content = new WebResponseContent();
        try
        {
            // æ›´æ–°åº“存状态
            // è®¾ç½®åº“位状态为空闲
            stock.LocationInfo.LocationStatus = LocationEnum.Free.ObjToInt();
            // è®¾ç½®åº“存状态为出库
            stock.StockInfoDetails.ForEach(x =>
            if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
            {
                x.Status = 2;
            });
                var process = await SqlSugarHelper.Db.Queryable<Dt_EquipmentProcess>()
                     .FirstAsync(x => x.EquipmentName == task.Roadway);
                EquipmentParameterInfo info = JsonConvert.DeserializeObject<EquipmentParameterInfo>(process.ProcessValue);
                AgingOutputDto agingOutputDto = new AgingOutputDto()
                {
                    OpFlag = 1,
                    EquipmentCode = stock.LocationInfo.RoadwayNo,
                    TrayBarcode = stock.PalletCode,
                    SerialNos = stock.StockInfoDetails.Select(x => new SerialNoOutDto()
                    {
                        SlotNo = x.OrderNo.ToInt32(),
                        SerialNo = x.SerialNumber,
                        SerialNoResult = true,
                        ParameterInfo = new List<ParameterInfo>()
                        {
                             new ParameterInfo()
                             {
                                  LowerLomit =info.LowerControlLimit,
                                   UpperLimit = info.UpperControlLimit,
                                   ParameterResult = info.EquipmentAvailabilityFlag,
                                   ParameterCode = info.ParameterCode,
                                    ParameterDesc = info.Description,
                                     TargetValue = info.TargetValue,
                                      Value = info.TargetValue,
                                       DefectCode = info.UOMCode
                             }
                        }
                    }).ToList()
                };
            }
            // æ›´æ–°åº“存状态
            var loation = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress);
            var detail = _stockInfoDetailRepository.QueryData(x => x.StockId == stock.Id);
            // è®¾ç½®åº“位状态为空闲
            loation.LocationStatus = LocationEnum.Free.ObjToInt();
            // æ›´æ–°ä»»åŠ¡çŠ¶æ€
            task.TaskState = TaskOutStatusEnum.SC_OutFinish.ObjToInt();
            task.TaskState = TaskOutStatusEnum.OutFinish.ObjToInt();
            task.CurrentAddress = task.NextAddress;
            task.NextAddress = task.TargetAddress;
@@ -98,13 +138,15 @@
            // äº‹åŠ¡å¤„ç†
            // å¼€å§‹äº‹åŠ¡
            _unitOfWorkManage.BeginTran();
            // æ›´æ–°åº“存信息
            var isStockUpdated = _stockInfoRepository.UpdateData(stock);
            // æ›´æ–°ä»»åŠ¡ä¿¡æ¯
            var isTaskUpdated = await Update(task);
            // åˆ é™¤åº“存信息
            var isStockUpdated = _stockInfoRepository.DeleteDataById(stock.Id);
            // åˆ é™¤åº“存信息
            var isStockDetailUpdated = _stockInfoDetailRepository.DeleteDataByIds(detail.Select(x => (object)x.Id).ToArray());
            // åˆ é™¤ä»»åŠ¡ä¿¡æ¯
            var isTaskUpdated = BaseDal.DeleteDataById(task.TaskId);
            // å¦‚果库存信息和任务信息都更新成功
            if (isStockUpdated && isTaskUpdated)
            if (isStockUpdated && isTaskUpdated && isStockDetailUpdated)
            {
                // è®°å½•日志
                LogFactory.GetLog("任务完成").InfoFormat(true, "堆垛机出库完成", $"事务处理完成,库存状态更新:{isStockUpdated},任务状态更新:{isTaskUpdated}");
@@ -179,28 +221,66 @@
        try
        {
            var boxing = await _boxingInfoRepository.QueryFirstNavAsync(x => x.PalletCode == task.PalletCode);
            var locationInf = await _locationRepository.QueryFirstAsync(x => x.LocationCode == task.TargetAddress);
            var boxDetail = boxing.BoxingInfoDetails.Adapt<List<DtStockInfoDetail>>();
            // åˆ›å»ºåº“存实例模型
            DtStockInfo stock = new DtStockInfo()
            {
                PalletCode = task.PalletCode,
                LocationCode = task.TargetAddress,
                CreateDate = DateTime.Now,
                Creater = "system",
                IsFull = boxing.IsFull,
                StockInfoDetails = boxDetail,
                LocationInfo = new DtLocationInfo()
            };
            locationInf.LocationStatus = (int)LocationEnum.InStock;
            // åˆ›å»ºåŽ†å²ä»»åŠ¡å®žä¾‹æ¨¡åž‹
            var taskHty = CreateHistoricalTask(task);
            // ä¿®æ”¹è´§ä½ä¿¡æ¯ä¸ºæœ‰è´§
            var locationInf = await _locationRepository.QueryFirstAsync(x => x.LocationCode == task.TargetAddress);
            locationInf.LocationStatus = (int)LocationEnum.InStock;
            // åˆ›å»ºåº“存实例模型
            DtStockInfo stock;
            if (boxing == null)
            {
                // ç©ºæ‰˜ç›˜
            LogFactory.GetLog("任务完成").InfoFormat(true, "入库任务完成", $"货位地址:{task.TargetAddress},修改后货位数据:{locationInf}");
                stock = new DtStockInfo()
                {
                    PalletCode = task.PalletCode,
                    LocationCode = task.TargetAddress,
                    CreateDate = DateTime.Now,
                    Creater = "system",
                    IsFull = boxing.IsFull,
                    StockInfoDetails = new List<DtStockInfoDetail>()
                    {
                        new DtStockInfoDetail()
                        {
                             MaterielCode = "空托盘",
                             Id = 0,
                        }
                    }
                };
            }
            else
            {
                // å®žç›˜
                var boxDetail = boxing.BoxingInfoDetails.Adapt<List<DtStockInfoDetail>>();
                // åˆ›å»ºåº“存实例模型
                stock = new DtStockInfo()
                {
                    PalletCode = task.PalletCode,
                    LocationCode = task.TargetAddress,
                    CreateDate = DateTime.Now,
                    Creater = "system",
                    IsFull = boxing.IsFull,
                    StockInfoDetails = boxDetail,
                };
                AgingInputDto agingInputDto = new AgingInputDto()
                {
                    SerialNos = boxing.BoxingInfoDetails
                        .Select(item => new SerialNoInDto { SerialNo = item.SerialNumber, PositionNo = item.OrderNo })
                        .ToList(),
                    TrayBarcode = task.PalletCode,
                    OpFlag = 1
                };
                var result = await _agingInOrOutInputService.GetOCVInputAsync(agingInputDto);
                stock.Remark = JsonConvert.DeserializeObject<ResponeAgingInputDto>(result.Data.ToString()).LinedProcessFeedbackTime;
                LogFactory.GetLog("任务完成").InfoFormat(true, "入库任务完成", $"货位地址:{task.TargetAddress},修改后货位数据:{locationInf}");
            }
            // æ‰§è¡Œæ•°æ®åº“事务
            bool isResult = await ExecuteTransaction(stock, taskHty, locationInf, task.TaskId);
@@ -249,10 +329,15 @@
                LogFactory.GetLog("任务完成").InfoFormat(true, "入库任务", "");
                return await CompleteInboundTaskAsync(task);
            }
            else if (task.TaskType == (int)TaskInboundTypeEnum.InTray)
            {
                LogFactory.GetLog("任务完成").InfoFormat(true, "空托盘入库", "");
                return await CompleteInboundTaskAsync(task);
            }
            else
            {
                LogFactory.GetLog("任务完成").InfoFormat(true, "库存不存在也不是入库任务", "");
                return content.Error("库存不存在");
                LogFactory.GetLog("任务完成").InfoFormat(true, "任务状态异常", "");
                return content.Error("任务状态异常");
            }
        }
        LogFactory.GetLog("任务完成").InfoFormat(true, "验证库存是否存在", JsonConvert.SerializeObject(stock));
@@ -260,15 +345,20 @@
        if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
        {
            LogFactory.GetLog("任务完成").InfoFormat(true, "出库任务", "");
            if (task.TaskState == TaskOutStatusEnum.SC_OutExecuting.ObjToInt())
            if (task.TaskState == TaskOutStatusEnum.Line_OutFinish.ObjToInt())
            {
                LogFactory.GetLog("任务完成").InfoFormat(true, "堆垛机出库完成", "");
                return await CompleteStackTaskAsync(task, stock);
            }
            else
            else if (task.TaskState == TaskOutStatusEnum.SC_OutExecuting.ObjToInt())
            {
                LogFactory.GetLog("任务完成").InfoFormat(true, "库存不存在也不是入库任务", "");
                return content.Error("库存不存在");
            }
            else
            {
                LogFactory.GetLog("任务完成").InfoFormat(true, "任务状态异常", "");
                return content.Error("任务状态异常");
            }
        }
        else if (task.TaskType == (int)TaskTypeEnum.RelocationIn)
@@ -310,8 +400,14 @@
            // å¦‚果状态为false,则返回content
            if (!content.Status) return content;
            // è°ƒç”¨GetProcessApplyAsync方法,获取工艺申请
            ProcessApplyDto process = await GetProcessApplyAsync(content);
            // æ·»åŠ ç»„ç›˜ä¿¡æ¯
            // å°†content.Data转换为ResultTrayCellsStatus对象
            var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.ToString());
            var boxing = await CreateBoxingInfo(result, input.PalletCode);
            // è°ƒç”¨GetProcessApplyAsync方法,获取工艺路线
            ProcessApplyDto process = await GetProcessApplyAsync(result);
            // å¦‚æžœprocess为null,则返回content
            if (process == null) return content;
@@ -322,6 +418,10 @@
            var task = await BaseDal.QueryFirstAsync(x => x.PalletCode == input.PalletCode);
            // å¦‚æžœtask不为null,则调用UpdateExistingTask方法,更新任务;否则调用CreateNewTask方法,创建新任务
            content = task != null ? await UpdateExistingTask(input, task) : await CreateNewTask(processResponse, input);
            if (content.Status)
            {
                var isBox = await _boxingInfoRepository.AddDataNavAsync(boxing);
            }
        }
        catch (Exception err)
        {
@@ -341,19 +441,32 @@
        return await _cellStateService.GetTrayCellStatusAsync(trayCells);
    }
    // èŽ·å–å·¥è‰ºç”³è¯·
    private async Task<ProcessApplyDto> GetProcessApplyAsync(WebResponseContent content)
    // èŽ·å–ç»„ç›˜ä¿¡æ¯
    private async Task<DtBoxingInfo> CreateBoxingInfo(ResultTrayCellsStatus result, string palletCode)
    {
        // å¦‚果状态为false,则返回null
        if (!content.Status) return null;
        return new DtBoxingInfo
        {
            PalletCode = palletCode,
            IsFull = true,
            BoxingInfoDetails = result.SerialNos.Select(serialNoObj => new DtBoxingInfoDetail
            {
                SerialNumber = serialNoObj.SerialNo,
                OrderNo = serialNoObj.PositionNo.ToString(),
                Status = serialNoObj.SerialNoStatus,
                MaterielCode = result.BindCode,
                Remark = result.TrayBarcodePropertys.ToJsonString(),
            }).ToList()
        };
    }
        // å°†content.Data转换为ResultTrayCellsStatus对象
        var result = JsonConvert.DeserializeObject<ResultTrayCellsStatus>(content.Data.ToString());
    // èŽ·å–å·¥è‰ºç”³è¯·
    private async Task<ProcessApplyDto> GetProcessApplyAsync(ResultTrayCellsStatus content)
    {
        // åˆ›å»ºä¸€ä¸ªProcessApplyDto对象,并赋值
        return new ProcessApplyDto()
        {
            WipOrderNo = result.BindCode,
            SerialNos = result.SerialNos.Select(item => new SerialNos
            //WipOrderNo = result.BindCode,
            SerialNos = content.SerialNos.Select(item => new SerialNos
            {
                SerialNo = item.SerialNo
            }).ToList()
@@ -381,6 +494,12 @@
                    .Where(x => x.EquipmentType == "陈化" && x.WipOrderNo == apply.WipOrderNo && x.ProductDesc == apply.ProductNo)
                    .ToList();
            case "1339":
            case "1406":
                return SqlSugarHelper.Db.Queryable<Dt_EquipmentProcess>()
                    .Where(x => x.EquipmentType == "静置" && x.WipOrderNo == apply.WipOrderNo && x.ProductDesc == apply.ProductNo)
                    .ToList();
            default:
                return new List<Dt_EquipmentProcess>();
        }
@@ -397,7 +516,7 @@
        {
            var area = _areaInfoRepository.QueryFirst(x => x.AreaCode == "CH");
            var stockInfo = _stockInfoRepository.QueryData(x => x.Remark == area.AreaCode && x.StockInfoDetails.Any(z => z.MaterielCode == "空托盘")).OrderBy(x => x.CreateDate).FirstOrDefault();
            var stockInfo = _stockInfoRepository.QueryData(x => x.LocationInfo.AreaId == area.AreaID && x.StockInfoDetails.Any(z => z.MaterielCode == "空托盘")).OrderBy(x => x.CreateDate).FirstOrDefault();
            // åˆ›å»ºæ–°ä»»åŠ¡å®žä¾‹
            var task = new Dt_Task
            {
@@ -444,6 +563,65 @@
    }
    #endregion è¯·æ±‚空托盘
    #region é™ˆåŒ–请求出库
    // é™ˆåŒ–请求出库
    public async Task<WebResponseContent> OutTrayByCh(string position)
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            var area = _areaInfoRepository.QueryFirst(x => x.AreaName == "陈化区");
            // æŸ¥è¯¢åº“存信息
            var stockInfo = _stockInfoRepository.QueryData(x => x.AreaCode == area.AreaCode && Convert.ToDateTime(x.Remark) < DateTime.Now && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock).OrderBy(x => x.CreateDate).FirstOrDefault();
            // åˆ›å»ºæ–°ä»»åŠ¡å®žä¾‹
            var task = new Dt_Task()
            {
                Grade = 1,
                Roadway = stockInfo.LocationInfo.RoadwayNo,
                TargetAddress = position,
                Dispatchertime = DateTime.Now,
                MaterialNo = "",
                NextAddress = position,
                OrderNo = null,
                PalletCode = stockInfo.PalletCode,
                SourceAddress = stockInfo.LocationCode,
                TaskState = (int)TaskOutStatusEnum.OutNew,
                TaskType = (int)TaskOutboundTypeEnum.OutTray,
                TaskNum = await BaseDal.GetTaskNo(),
                Creater = "Systeam"
            };
            var taskId = await BaseDal.AddDataAsync(task);
            bool isResult = taskId > 0;
            if (isResult)
            {
                WMSTaskDTO taskDTO = new WMSTaskDTO()
                {
                    TaskNum = task.TaskNum.Value,
                    Grade = 1,
                    PalletCode = DateTime.Now.ToString("MMddHHmmss"),
                    RoadWay = task.Roadway,
                    SourceAddress = stockInfo.LocationCode,
                    TargetAddress = task.Roadway,
                    TaskState = (int)TaskOutStatusEnum.OutNew,
                    Id = 0,
                    TaskType = (int)TaskOutboundTypeEnum.OutTray
                };
                stockInfo.LocationInfo.LocationStatus = (int)LocationEnum.InStockDisable;
                _locationRepository.UpdateData(stockInfo.LocationInfo);
                content.OK(data: taskDTO);
            }
        }
        catch (Exception ex)
        {
            throw;
        }
        return content;
    }
    #endregion é™ˆåŒ–请求出库
    #endregion å¤–部接口方法
@@ -745,15 +923,6 @@
        DtLocationInfo location = new DtLocationInfo();
        int beforeStatus = 0;
        // æ ¹æ®ä»»åŠ¡ç±»åž‹åˆ¤æ–­æ˜¯å‡ºåº“ä»»åŠ¡è¿˜æ˜¯å…¥åº“ä»»åŠ¡
        //if (input.Type == (int)TaskTypeEnum.Outbound)
        //{
        //    // å¤„理出库任务
        //    toAddress = await GetRoadWayAsync(areaId, task.Roadway, input.Direction, input.Area, input.Type);
        //    taskState = (int)TaskOutStatusEnum.SC_OutFinish;
        //}
        //else
        //{
        // å¤„理入库任务
        location = await GetLocationDistributeAsync(task.Roadway);
        toAddress = location.LocationCode;
@@ -762,10 +931,8 @@
        // æ›´æ–°è´§ä½ä¿¡æ¯
        location.LocationStatus = (int)LocationEnum.Lock;
        //}
        // æ›´æ–°ä»»åŠ¡ä¿¡æ¯
        //task.SourceAddress = input.Position;
        task.CurrentAddress = input.Position;
        task.TargetAddress = toAddress;
        task.NextAddress = toAddress;
@@ -843,6 +1010,7 @@
            TaskNum = await BaseDal.GetTaskNo(),
            Creater = "Systeam"
        };
        // å°è¯•添加新任务
        var taskId = await BaseDal.AddDataAsync(task);
        bool isResult = taskId > 0;
@@ -852,6 +1020,7 @@
            isResult = await _taskExecuteDetailRepository.AddDetailAsync(task, false, TaskDescription.GetTaskUpdateDescription(input.PalletCode, input.Position, ToAddress, TaskInStatusEnum.InNew.GetIntegralRuleTypeEnumDesc()));
            if (isResult)
            {
                // åˆ›å»ºWMS任务
                WMSTaskDTO taskDTO = new WMSTaskDTO()
                {
                    TaskNum = 0,
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Integration/AgingInOrOutController.cs
@@ -19,7 +19,7 @@
    /// <returns></returns>
    // POST: api/AgingInOrOut/OCVInput
    [HttpPost("OCVInput")]
    public Task<dynamic> GetOCVInputAsync([FromBody] AgingInputDto input)
    public Task<WebResponseContent> GetOCVInputAsync([FromBody] AgingInputDto input)
    {
        return _agingInOrOutInputService.GetOCVInputAsync(input);
    }
@@ -31,7 +31,7 @@
    /// <returns></returns>
    // POST: api/AgingInOrOut/OCVOutput
    [HttpPost("OCVOutput")]
    public Task<dynamic> GetOCVOutputAsync([FromBody] AgingOutputDto input)
    public Task<WebResponseContent> GetOCVOutputAsync([FromBody] AgingOutputDto input)
    {
        return _agingInOrOutInputService.GetOCVOutputAsync(input);
    }