dengjunjie
2025-04-19 9e579eda4601ed7b492b9d19a24e8146f6ebdf8d
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ShuttleCarJob/ShuttleCarJob.cs
@@ -11,7 +11,9 @@
using WIDESEAWCS_Common.ShuttleCarEnum;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Caches;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.System;
using WIDESEAWCS_DTO.WMSInfo;
using WIDESEAWCS_IShuttleCar;
using WIDESEAWCS_ITaskInfoRepository;
@@ -37,9 +39,10 @@
        private readonly IShuttleCarService _shuttleCarService;
        private readonly ITaskExecuteDetailService _taskExecuteDetailService;
        private readonly IRouterService _routerService;
        private readonly ICacheService _cacheService;
        private readonly IMapper _mapper;
        public CommonShuttleCarJob(ITaskService taskService, ITaskRepository taskRepository, ITaskHtyService taskHtyService, IShuttleCarService shuttleCarService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper)
        public CommonShuttleCarJob(ITaskService taskService, ITaskRepository taskRepository, ITaskHtyService taskHtyService, IShuttleCarService shuttleCarService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, ICacheService cacheService, IMapper mapper)
        {
            _taskService = taskService;
            _taskRepository = taskRepository;
@@ -47,6 +50,7 @@
            _shuttleCarService = shuttleCarService;
            _taskExecuteDetailService = taskExecuteDetailService;
            _routerService = routerService;
            _cacheService = cacheService;
            _mapper = mapper;
        }
@@ -59,6 +63,7 @@
                {
                    shuttleCar.Communicator.IsReadAfterWrite = false;
                    ShuttleCarTaskCommandR command = ReadCustomer<ShuttleCarTaskCommandR>(shuttleCar, shuttleCar.DeviceCode);//读取穿梭车信息
                    _cacheService.AddOrUpdate(shuttleCar.DeviceCode, command);
                    if (command != null && command.JoinStatus == 1)
                    {
                        #region ç©¿æ¢­è½¦ä»»åŠ¡å®Œæˆ
@@ -77,6 +82,7 @@
                        #region åˆ›å»ºç§»è½¦å……电任务
                        if (command.Err_Status == (short)ShuttleCarErr.LowBattery || command.ElectricQuantity <= (short)ShuttleCarErr.LowBattery)
                        {
                            var ShuttleCar = QueryCode(shuttleCar.DeviceCode);//在充电位直接让穿梭车去充电
                            //生成堆垛机移车任务&穿梭车充电任务,判断是否有穿梭车在充电
                            Dt_Task _Task = _taskRepository.QueryFirst(x => x.TaskType == TaskOtherTypeEnum.RelocationCarCharging.ObjToInt());
                            if (_Task != null)
@@ -89,8 +95,6 @@
                                    {
                                        if (command1.Status == (short)ShuttleCarStatus.Charging && command1.ElectricQuantity >= 50)
                                        {
                                            var ShuttleCar = QueryCode(shuttleCar1.DeviceCode);
                                            _taskService.AddRelocationCarTask(ShuttleCar.ShuttleCarPosition, "", ShuttleCar.ShuttleCarCode);
                                            shuttleCar1.SetValue(ShuttleCarDBName.TaskType, (short)ShuttleCarStatus.QuitCharging);
                                        }
                                    }
@@ -98,8 +102,16 @@
                            }
                            else
                            {
                                var ShuttleCar = QueryCode(shuttleCar.DeviceCode);
                                _taskService.AddRelocationCarTask(ShuttleCar.ShuttleCarPosition, "003-002-001", ShuttleCar.ShuttleCarCode, ShuttleCarTaskType.Charging.ToString());
                                //判断充电位是否有车
                                var ShuttleCar1 = _shuttleCarService.QueryShuttleCar("003-002-001");
                                if (ShuttleCar1 != null && ShuttleCar1.ShuttleCarCode != shuttleCar.DeviceCode)
                                {
                                    _taskService.AddRelocationCarTask(ShuttleCar1.ShuttleCarPosition, "", ShuttleCar1.ShuttleCarCode);
                                }
                                else
                                {
                                    _taskService.AddRelocationCarTask(ShuttleCar.ShuttleCarPosition, "003-002-001", ShuttleCar.ShuttleCarCode, ShuttleCarTaskType.Charging.ToString());
                                }
                            }
                        }
                        #endregion