| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using Quartz; |
| | | using SqlSugar.Extensions; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection.Metadata; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common; |
| | | using WIDESEAWCS_Common.LocationEnum; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_DTO.WMS; |
| | | using WIDESEAWCS_IBasicInfoService; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | public partial class ScheduledTaskJob : JobBase, IJob |
| | | { |
| | | private readonly ITaskService _taskService; |
| | | private readonly IHKLocationInfoService _HKLocationInfoService; |
| | | private readonly IStationInfoService _StationInfoService; |
| | | private readonly IStationMangerService _stationMangerService; |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | public ScheduledTaskJob(ITaskService taskService, IApiInfoService apiInfoService, IHKLocationInfoService hKLocationInfoService, IStationInfoService stationInfoService, IStationMangerService stationMangerService, IUnitOfWorkManage unitOfWorkManage) |
| | | { |
| | | _taskService = taskService; |
| | | _HKLocationInfoService = hKLocationInfoService; |
| | | _StationInfoService = stationInfoService; |
| | | _stationMangerService = stationMangerService; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | } |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | | { |
| | | try |
| | | { |
| | | #region 䏿¥¼èªå¨ä»»å¡ |
| | | List<string> StationCodes = new() { "0321935CC0329515", "0321935CC0329015", "0321935CC0328485", "0321935CC0328005" }; |
| | | var stations = _StationInfoService.Repository.QueryData(x => StationCodes.Contains(x.StationCode)); |
| | | #region å
¥æåæºä»»å¡ |
| | | var station = stations.FirstOrDefault(x => x.StationStatus == (int)LocationStatusEnum.InStock); |
| | | if (station != null) |
| | | { |
| | | var tasknum = _taskService.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)); |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | TaskNum = tasknum, |
| | | WMSTaskNum = "GP" + tasknum, |
| | | Grade = 60, |
| | | PalletCode = station.PalletCode, |
| | | Roadway = "", |
| | | TaskState = (int)TaskStatusEnum.New, |
| | | TaskType = TaskTypeEnum.RK3F.ObjToInt(), |
| | | SourceAddress = station.StationCode, |
| | | CurrentAddress = station.StationCode, |
| | | NextAddress = "TSJR3F", |
| | | TargetAddress = "TSJR3F", |
| | | Creater = "WCS", |
| | | }; |
| | | var content = _taskService.SendHIKROBOTTask(dt_Task); |
| | | if (content.Status) |
| | | { |
| | | dt_Task.TaskState = (int)TaskStatusEnum.Execut; |
| | | dt_Task.Dispatchertime = DateTime.Now; |
| | | station.StationStatus = (int)LocationStatusEnum.OutLock; |
| | | _taskService.AddData(dt_Task); |
| | | _StationInfoService.UpdateData(station); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region åºæåæºä»»å¡ |
| | | var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "TSJ") as OtherDevice; |
| | | if (device != null && device.IsConnected) |
| | | { |
| | | if (device.GetValue<HoistEnum, short>(HoistEnum.SOutboundmaterialbox, "TSJC3F") == 1) |
| | | { |
| | | station = stations.FirstOrDefault(x => x.StationStatus == (int)LocationStatusEnum.Free); |
| | | if (station != null) |
| | | { |
| | | var tasknum = _taskService.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)); |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | TaskNum = tasknum, |
| | | WMSTaskNum = "GP" + tasknum, |
| | | Grade = 60, |
| | | PalletCode = station.PalletCode, |
| | | Roadway = "", |
| | | TaskState = (int)TaskStatusEnum.New, |
| | | TaskType = TaskTypeEnum.CK3F.ObjToInt(), |
| | | SourceAddress = "TSJC3F", |
| | | CurrentAddress = "TSJC3F", |
| | | NextAddress = station.StationCode, |
| | | TargetAddress = station.StationCode, |
| | | Creater = "WCS", |
| | | }; |
| | | var content = _taskService.SendHIKROBOTTask(dt_Task); |
| | | if (content.Status) |
| | | { |
| | | dt_Task.TaskState = (int)TaskStatusEnum.Execut; |
| | | dt_Task.Dispatchertime = DateTime.Now; |
| | | station.StationStatus = (int)LocationStatusEnum.InLock; |
| | | _taskService.AddData(dt_Task); |
| | | _StationInfoService.UpdateData(station); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | #region 忥¼èªå¨ä»»å¡ |
| | | List<string> LocationCodes = new() { "RGD0304A04011", "RG0105A04031", "RG0202A05021" }; |
| | | var hKLocationInfos = _HKLocationInfoService.Repository.QueryData(x => LocationCodes.Contains(x.LocationCode)); |
| | | #region å
¥æåæºä»»å¡ |
| | | var hKLocation = hKLocationInfos.FirstOrDefault(x => x.LocationStatus == (int)LocationStatusEnum.InStock); |
| | | if (hKLocation != null) |
| | | { |
| | | var tasknum = _taskService.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)); |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | TaskNum = tasknum, |
| | | WMSTaskNum = "GP" + tasknum, |
| | | Grade = 60, |
| | | PalletCode = hKLocation.PalletCode, |
| | | Roadway = "", |
| | | TaskState = (int)TaskStatusEnum.New, |
| | | TaskType = TaskTypeEnum.CHUKU1.ObjToInt(), |
| | | SourceAddress = hKLocation.LocationCode, |
| | | CurrentAddress = hKLocation.LocationCode, |
| | | NextAddress = "TSJR4F", |
| | | TargetAddress = "TSJR4F", |
| | | Creater = "WCS", |
| | | }; |
| | | var content = _taskService.SendHIKROBOTTask(dt_Task); |
| | | if (content.Status) |
| | | { |
| | | dt_Task.TaskState = (int)TaskStatusEnum.Execut; |
| | | dt_Task.Dispatchertime = DateTime.Now; |
| | | hKLocation.LocationStatus = (int)LocationStatusEnum.OutLock; |
| | | _taskService.AddData(dt_Task); |
| | | _HKLocationInfoService.UpdateData(hKLocation); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region åºæåæºä»»å¡ |
| | | if (device != null && device.IsConnected) |
| | | { |
| | | if (device.GetValue<HoistEnum, short>(HoistEnum.FOutboundmaterialbox, "TSJC3F") == 1) |
| | | { |
| | | hKLocation = hKLocationInfos.FirstOrDefault(x => x.LocationStatus == (int)LocationStatusEnum.Free); |
| | | if (hKLocation != null) |
| | | { |
| | | var tasknum = _taskService.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)); |
| | | Dt_Task dt_Task = new Dt_Task() |
| | | { |
| | | TaskNum = tasknum, |
| | | WMSTaskNum = "GP" + tasknum, |
| | | Grade = 60, |
| | | PalletCode = hKLocation.PalletCode, |
| | | Roadway = "", |
| | | TaskState = (int)TaskStatusEnum.New, |
| | | TaskType = TaskTypeEnum.Q1TSJ4.ObjToInt(), |
| | | SourceAddress = "TSJC4F", |
| | | CurrentAddress = "TSJC4F", |
| | | NextAddress = hKLocation.LocationCode, |
| | | TargetAddress = hKLocation.LocationCode, |
| | | Creater = "WCS", |
| | | }; |
| | | var content = _taskService.SendHIKROBOTTask(dt_Task); |
| | | if (content.Status) |
| | | { |
| | | dt_Task.TaskState = (int)TaskStatusEnum.Execut; |
| | | dt_Task.Dispatchertime = DateTime.Now; |
| | | hKLocation.LocationStatus = (int)LocationStatusEnum.InLock; |
| | | _taskService.AddData(dt_Task); |
| | | _HKLocationInfoService.UpdateData(hKLocation); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #endregion |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.Out.WriteLine(nameof(TaskJob) + ":" + ex.Message); |
| | | } |
| | | return Task.CompletedTask; |
| | | } |
| | | } |
| | | } |