using Autofac.Core; using AutoMapper; using Quartz; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using WIDESEAWCS_Common; using WIDESEAWCS_Core; using WIDESEAWCS_Core.Helper; using WIDESEAWCS_IBasicInfoRepository; using WIDESEAWCS_ITaskInfoService; using WIDESEAWCS_Model.Models; using WIDESEAWCS_QuartzJob; using WIDESEAWCS_QuartzJob.DTO; using WIDESEAWCS_QuartzJob.Service; namespace WIDESEAWCS_Tasks { [DisallowConcurrentExecution] public partial class ConveyorLineJob2 : JobBase, IJob { public readonly ITaskService _taskService; private readonly ITaskExecuteDetailService _taskExecuteDetailService; private readonly IRouterService _routerService; private readonly IStationMangerRepository _stationMangerRepository; private readonly ILocationInfoRepository _locationInfoRepository; private readonly IMapper _mapper; public ConveyorLineJob2(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IStationMangerRepository stationMangerRepository, ILocationInfoRepository locationInfoRepository, IMapper mapper) { _taskService = taskService; _taskExecuteDetailService = taskExecuteDetailService; _routerService = routerService; _stationMangerRepository = stationMangerRepository; _locationInfoRepository = locationInfoRepository; _mapper = mapper; } public Task Execute(IJobExecutionContext context) { try { CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); if (conveyorLine != null) { #region 站台方式 List stationManagers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == conveyorLine.DeviceCode); foreach (var station in stationManagers) { if (station.StationType==StationTypeEnum.StationType_OnlyOutbound.ObjToInt()) //拣选申请 { bool PickRequest = conveyorLine.GetValue(ConveyorLineDBName.R_PickRequest, station.StationCode); if (PickRequest) { string PickBarCode = conveyorLine.GetValue(ConveyorLineDBName.R_PickBarCode, station.StationCode).Replace("\0", ""); //上报WMS料箱到达 if (PickBarCode.IsNotEmptyOrNull()) { WebResponseContent content = _taskService.WMSPickUp(station.PickStationCode, PickBarCode); if (content.Status) { //写入拣选确认 } } else { WriteError(nameof(conveyorLine.DeviceCode), $"{station.StationCode}拣选申请为{PickRequest}条码为空值"); } } } else { } } #endregion 站台方式 } } catch (Exception ex) { WriteError(nameof(ConveyorLineJob2), ex.Message); } return Task.CompletedTask; } } }