1
zhangchengsong
22 小时以前 efc0923ff1e1dc995f6981c2559227df24da7623
ÏîÄ¿´úÂë/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -27,6 +27,7 @@
using WIDESEAWCS_ISystemServices;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_Model.Models.System;
using WIDESEAWCS_QuartzJob;
@@ -49,17 +50,21 @@
        private readonly ITaskRepository _taskRepository;
        private readonly IRouterService _routerService;
        private readonly IDt_PlatformStationService _DtPlatformStationService;
        private readonly IDt_roadwayinfoService _Dt_roadwayinfoService;
        public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IRouterService routerService, IDt_PlatformStationService dt_PlatformStationService)
        public CommonStackerCraneJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IDt_roadwayinfoService dt_roadwayinfoService, ITaskRepository taskRepository, IRouterService routerService, IDt_PlatformStationService dt_PlatformStationService)
        {
            _taskService = taskService;
            _taskExecuteDetailService = taskExecuteDetailService;
            _taskRepository = taskRepository;
            _routerService = routerService;
            _DtPlatformStationService = dt_PlatformStationService;
            _Dt_roadwayinfoService = dt_roadwayinfoService;
        }
        private static readonly Dictionary<string, bool> _deviceLastStatus = new Dictionary<string, bool>();
        public string urlWMSdeverror = WIDESEAWCS_Core.Helper.AppSettings.Configuration["urlWMSdeverror"];
        private static readonly StackerFault[] _stackerFaultEnumCache = Enum.GetValues(typeof(StackerFault)).Cast<StackerFault>().ToArray();
        public Task Execute(IJobExecutionContext context)
@@ -124,7 +129,7 @@
                            WebResponseContent webResponse = _taskService.StackCraneTaskCompleted(commonStackerCrane.CurrentTaskNum, PalletCode);
                            if (webResponse.Status)
                            {
                                Task.Run(() => WriteLog.Write_Log("堆垛机任务上报完成信息", "堆垛机任务上报完成信息", $"【{commonStackerCrane.DeviceCode}】库堆垛机上报任务号:【{commonStackerCrane.CurrentTaskNum}】完成信号!"));
                               WriteLog.Write_Log("堆垛机任务上报完成信息", "堆垛机任务上报完成信息", $"【{commonStackerCrane.DeviceCode}】库堆垛机上报任务号:【{commonStackerCrane.CurrentTaskNum}】完成信号!");
                                bool ddjfk = commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5);
                            }
@@ -257,12 +262,9 @@
        {
            try
            {
                CommonConveyorLine? conveyorLine = null;
                lock (Storage.Devices)
                {
                    CommonConveyorLine? conveyorLine = null;
                    string deviceCode = Roadway == "C" ? "1004" : "1003";
                    conveyorLine = Storage.Devices.FirstOrDefault(x => x.DeviceCode == deviceCode) as CommonConveyorLine;
                }
                if (conveyorLine == null) return false;
                DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == NextAddress && x.DeviceProParamName == "StationNum");
@@ -291,11 +293,8 @@
            {
                CommonConveyorLine? conveyorLine = null;
                lock (Storage.Devices)
                {
                    string deviceCode = Roadway == "C" ? "1004" : "1003";
                    conveyorLine = Storage.Devices.FirstOrDefault(x => x.DeviceCode == deviceCode) as CommonConveyorLine;
                }
                if (conveyorLine == null) return false;
                DeviceProDTO? deviceProDTO = conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SourceAddress && x.DeviceProParamName == "StationNum");
@@ -305,7 +304,7 @@
                int StationNum = conveyorLine.Communicator.Read<ushort>(deviceProDTO.DeviceProAddress);
                int HandShake = conveyorLine.Communicator.Read<ushort>(HandShakeprodto.DeviceProAddress);
                WriteLog.Write_Log("入库库口状态信息", "入库库口状态信息", $"库口是【{SourceAddress}】,申请状态地址:【{HandShakeprodto.DeviceProAddress}】,读取的数据:【{HandShake}】\n库口是否有货状态地址:【{deviceProDTO.DeviceProAddress}】,读取的数据【{StationNum}】");
                return (StationNum == 1 && HandShake == 0) ? true : false;
                return StationNum == 1;
            }
            catch (Exception ex)
            {
@@ -474,7 +473,14 @@
                {
                    var dtTask = _taskRepository.QueryFirst(x => x.TaskNum == taskNum);
                    if (dtTask == null) return;
                //堆垛机放货中是任务状态回调拿pickup
                if (dtTask.TaskType == 200 && stackerCraneWorkStatusDes == "放货中")
                    {
                        string Result = WMSTaskStatusEnum.pickup.GetDescription();
                        Dt_roadwayinfo roadwayinfo = _Dt_roadwayinfoService.GetRoadwayinfo(dtTask.Roadway);
                        CommandResult command = _taskService.taskreturn(int.Parse(dtTask.WMStaskid), Result, roadwayinfo.WarehouseInvType, "");
                        return;
                    }
                    string[] targets = { "G02", "G03", "G04", "C02", "C01" };
                    if (dtTask.TaskType != 100 || !targets.Contains(dtTask.TargetAddress)) return;
@@ -499,18 +505,21 @@
                    conveyorLine.Communicator.Write<short>(handShake.DeviceProAddress, writeValue);
                }
                catch
                { }
                catch(Exception e)
                {
                    WriteLog.Write_Log("出库屏蔽光栅/堆垛入库要放货异常", "错误", e.ToString());
                }
        }
        /// <summary>
        /// è¯»å–故障(优化GC)
        /// æ•…障信息
        /// </summary>
        /// <param name="crane"></param>
        /// <returns></returns>
        public string ReadStackerFaults(CommonStackerCrane crane)
        {
            try
            {
                foreach (StackerFault fault in Enum.GetValues(typeof(StackerFault)))
                foreach (StackerFault fault in _stackerFaultEnumCache)
                {
                    try
                    {
@@ -518,13 +527,10 @@
                        if (isFault)
                            return fault.GetDesc();
                    }
                    catch { }
                    catch { continue; }
                }
            }
            catch (Exception ex)
            {
                WriteLog.Write_Log("DB107故障读取异常", "错误", ex.ToString());
            }
            catch { }
            return string.Empty;
        }
    }