dengjunjie
2024-10-30 680ccbedf08839143215f40dea5273dc2819100c
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -25,8 +25,10 @@
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Common.ConveyorLineEnum;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.WMSInfo;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
@@ -110,16 +112,39 @@
        /// <param name="childDeviceCode">子设备编号</param>
        public void RequestInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode)
        {
            if (_taskService.RequestWMSTask(command.Barcode, childDeviceCode).Status)//需添加和WMS接口!!!!!!!!!!!!!!!!!!!!
            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode, command.Barcode);
            if (task != null)
            {
                Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
                if (task != null)
                ConveyorLineDTO lineDTO = new ConveyorLineDTO()
                {
                    TaskNum = task.TaskNum,
                    stationCode = childDeviceCode,
                    Barcode = command.Barcode,
                    Spec = command.Spec,
                    Weight = command.Weight,
                };
                var content = _taskService.RequestWMSTask(lineDTO);
                if (content.Status)
                {
                    task.TargetAddress = "104";
                    task.NextAddress = "103";
                    ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(task);
                    conveyorLine.SendCommand(taskCommand, childDeviceCode);
                    _taskService.UpdateTaskStatusToNext(task);
                    if (conveyorLine.SendCommand(taskCommand, childDeviceCode))
                        _taskService.UpdateTaskStatusToNext(task);
                }
                else
                {
                    if (content.Code == 404)//修改终点地址
                    {
                        task.TargetAddress = "101";
                        task.NextAddress = "101";
                        task.ExceptionMessage = content.Message;
                        task.TaskState = (int)TaskInStatusEnum.InException;
                        ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(task);
                        if (conveyorLine.SendCommand(taskCommand, childDeviceCode)) _taskService.UpdateData(task);
                    }
                }
            }
        }
@@ -154,12 +179,20 @@
        public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode)
        {
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            if (task != null)
            if (task != null) _taskService.UpdateTaskStatusToNext(task);
            task = _taskService.QueryCompletedConveyorLineTask(command.TaskNum, childDeviceCode);
            if (task != null && string.IsNullOrEmpty(task.TargetAddress))
            {
                //conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode);
                WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
                //Console.Out.WriteLine(content.Serialize());
                _taskService.StackerCraneRequestInbound(task);
            }
            //if (task != null)
            //{
            //    //conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, 0, childDeviceCode);
            //    //向WMS更新任务状态,WMS返回入库任务终点
            //    WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
            //    //Console.Out.WriteLine(content.Serialize());
            //}
        }
        /// <summary>
@@ -170,7 +203,7 @@
        /// <param name="childDeviceCode">子设备编号</param>
        public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandR command, string childDeviceCode)
        {
            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
            Dt_Task task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode, command.Barcode);
            if (task != null)
            {
                ConveyorLineTaskCommandW taskCommand = _mapper.Map<ConveyorLineTaskCommandW>(task);