wangxinhui
10 天以前 b466b3135cd7f3b08f570efda0ffb691daff5270
ÏîÄ¿´úÂë/WCSServices/WIDESEAWCS_Tasks/Ò»ÆÚÏßÌå/ConveyorLineJob1.cs
@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Components.Routing;
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using Quartz;
using System;
using System.Collections.Generic;
@@ -9,6 +10,7 @@
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Text.Unicode;
using System.Threading.Tasks;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.Helper;
@@ -54,7 +56,16 @@
            _routerService = routerService;
            _routerExtension = routerExtension;
        }
        /*
        1号位出库口允许放箱        0
        1号位放箱完成信号          21
        6号位拣选位料箱到达        1
        6号位拣选位料箱条码        2
        6号位拣选位料箱流动        22
        8号位入库口允许取箱        11
        8号位入库口料箱条码        12
        8号位机器人取箱完成        23
        */
        public Task Execute(IJobExecutionContext context)
        {
            try
@@ -65,13 +76,59 @@
                    OtherDevice device = (OtherDevice)value;
                    List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
                    
                    foreach (var item in stationMangers)
                    foreach (var station in stationMangers)
                    {
                        byte[] bytesPut = device.Communicator.Read("22", 1);
                       ;
                        device.Communicator.Write("22", new byte[] { 2, 0 });
                        byte[] bytesPuted = device.Communicator.Read("22",1);
                        device.Communicator.Write("22", new byte[] { 0, 0 });
                        if (station.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt())
                        {
                            //拣选申请
                            short pickArrived = device.Communicator.Read<short>("1");
                            if (pickArrived == 256)
                            {
                                byte[] bytesPick = device.Communicator.Read("2", 5);
                                string pickBarCode = Encoding.UTF8.GetString(bytesPick).Replace("\0", "").Replace("\\0", "");
                                //上报WMS料箱到达
                                if (pickBarCode.IsNotEmptyOrNull())
                                {
                                    WebResponseContent content = _taskService.WMSPickUp(station.PickStationCode, pickBarCode);
                                    if (content.Status)
                                    {
                                        WriteInfo(device.DeviceCode, $"{station.PickStationCode}拣选申请上报成功{pickBarCode}");
                                    }
                                    else
                                    {
                                        WriteError(device.DeviceCode, $"{station.PickStationCode}拣选申请上报WMS错误{pickBarCode},信息{content.Message}");
                                    }
                                }
                                else
                                {
                                    WriteError(device.DeviceCode, $"{station.PickStationCode}拣选申请为{pickArrived}条码为空值");
                                }
                            }
                        }
                        else
                        {
                            //入库申请
                            short InTake = device.Communicator.Read<short>("11");
                            byte[] bytesIn = device.Communicator.Read("12", 5);
                            string InBarCode = Encoding.UTF8.GetString(bytesIn).Replace("\0", "").Replace("\\0", "");
                            if (InTake==256 && InBarCode.IsNotEmptyOrNull())
                            {
                                //申请入库任务
                                Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == InBarCode && x.TaskType == TaskTypeEnum.Inbound.ObjToInt() && x.TaskState != TaskStatusEnum.CL_Executing.ObjToInt());
                                if (task != null) continue;
                                WebResponseContent content = _taskService.RequestInTask(station.StationCode, InBarCode);
                                if (content.Status)
                                {
                                    WriteInfo(device.DeviceCode, $"站台{station.StationCode}料箱{InBarCode}申请入库成功");
                                }
                                else
                                {
                                    WriteError(device.DeviceCode, $"站台{station.StationCode}料箱{InBarCode}申请入库任务错误,信息{content.Message}");
                                }
                            }
                        }
                    }
                }
            }