yanjinhui
9 小时以前 52ba6b195a4126df405ef453d52ba6eaab6521da
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/TaskJob.cs
@@ -11,8 +11,10 @@
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_BasicInfoService;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Communicator;
using WIDESEAWCS_Core.BaseRepository;
@@ -38,8 +40,9 @@
        private readonly ITrackloginfoService _trackloginfoService;
        private readonly IUnitOfWorkManage _unitOfWorkManage;
        private readonly IAGVCartInfoService _agvcartInfoService;
        private readonly IStationInfoService _stationInfoService;
        public TaskJob(ITaskService taskService, IApiInfoService apiInfoService, IRGVLocationInfoService rGVLocationInfoService, IStationMangerService stationMangerService, ITrackloginfoService trackloginfoService, IUnitOfWorkManage unitOfWorkManage, IAGVCartInfoService agvcartInfoService)
        public TaskJob(ITaskService taskService, IApiInfoService apiInfoService, IRGVLocationInfoService rGVLocationInfoService, IStationMangerService stationMangerService, ITrackloginfoService trackloginfoService, IUnitOfWorkManage unitOfWorkManage, IAGVCartInfoService agvcartInfoService, IStationInfoService stationInfoService)
        {
            _taskService = taskService;//娉ㄥ叆
            _apiInfoService = apiInfoService;
@@ -48,6 +51,7 @@
            _trackloginfoService = trackloginfoService;
            _unitOfWorkManage = unitOfWorkManage;
            _agvcartInfoService = agvcartInfoService;
            _stationInfoService = stationInfoService;
        }
        public Task Execute(IJobExecutionContext context)
@@ -58,28 +62,8 @@
                SendWaitToTask();
                #region 澶勭悊鍐欏叆璁惧淇″彿寮傚父浠诲姟
                var tasks = _taskService.Repository.QueryData(x => x.TaskState == TaskStatusEnum.Finish.ObjToInt() && !string.IsNullOrEmpty(x.Remark));
                if (tasks.Count > 0)
                {
                    List<Dt_Task> list = new List<Dt_Task>();
                    foreach (var item in tasks)
                    {
                        var infos = item.Remark.Split("_");
                        var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == infos[0]) as OtherDevice;
                        if (device != null && device.IsConnected)
                        {
                            DeviceProDTO? devicePro = device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == infos[1] && x.DeviceChildCode == infos[3]);
                            if (devicePro != null)
                            {
                                var W = device.Communicator.WriteObj(devicePro.DeviceProAddress, devicePro.DeviceDataType, infos[2]);
                                if (W) list.Add(item);
                            }
                        }
                    }
                    _taskService.Repository.DeleteAndMoveIntoHty(list, OperateTypeEnum.鑷姩鍒犻櫎);
                }
                #endregion
                HandleTasks();
            }
            catch (Exception ex)
            {