| | |
| | | }; |
| | | iTenant.AddConnection(connectionConfig); |
| | | } |
| | | |
| | | return iTenant.GetConnection(tenant.TenantId); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return db; |
| | | } |
| | | } |
| | |
| | | /// å°ä»»å¡ç¶æä¿®æ¹ä¸ºä¸ä¸ä¸ªç¶æ |
| | | /// </summary> |
| | | /// <param name="taskNum">ä»»å¡å·</param> |
| | | WebResponseContent UpdateTaskStatusToNext(int taskNum); |
| | | WebResponseContent UpdateTaskStatusToNext(int taskNum, int taskStatus = -1); |
| | | |
| | | WebResponseContent TCSendTask([NotNull] Dt_Task task, string Position); |
| | | |
| | |
| | | /// å°ä»»å¡ç¶æä¿®æ¹ä¸ºä¸ä¸ä¸ªç¶æ |
| | | /// </summary> |
| | | /// <param name="taskNum">ä»»å¡å·</param> |
| | | public WebResponseContent UpdateTaskStatusToNext(int taskNum) |
| | | public WebResponseContent UpdateTaskStatusToNext(int taskNum, int taskStatus = -1) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); |
| | | if (taskStatus > 0) |
| | | { |
| | | task = BaseDal.QueryFirst(x => x.TaskNum == taskNum && x.TaskState == taskStatus); |
| | | } |
| | | if (task == null) return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ä»»å¡ä¿¡æ¯,ä»»å¡å·:ã{taskNum}ã"); |
| | | return UpdateTaskStatusToNext(task); |
| | | } |
| | |
| | | } |
| | | finally |
| | | { |
| | | WriteDebug("CommonConveyorLineJob", "test"); |
| | | //WriteDebug("CommonConveyorLineJob", "test"); |
| | | //Console.Out.WriteLine(DateTime.Now); |
| | | } |
| | | return; |
| | |
| | | } |
| | | finally |
| | | { |
| | | WriteDebug("CommonConveyorLineTZJob", "test"); |
| | | //Console.Out.WriteLine(DateTime.Now); |
| | | } |
| | | return; |
| | |
| | | Dt_Task task = null; |
| | | if (station.stationChildCode == "TC05") |
| | | { |
| | | //var executeTaks = _taskRepository.QueryData(x => (x.Roadway == "SC02" || x.Roadway == "SC04") && x.TaskState <= (int)TaskOutStatusEnum.SC_OutFinish).OrderBy(x => x.CreateDate).FirstOrDefault(); |
| | | |
| | | var leftTask = _taskRepository.QueryData(x => (x.Roadway == "SC02" || x.Roadway == "SC04") && x.TaskState <= (int)TaskOutStatusEnum.SC_OutFinish).OrderBy(x => x.CreateDate).FirstOrDefault(); |
| | | |
| | | if (leftTask != null && leftTask.TaskState == (int)TaskOutStatusEnum.SC_OutFinish) |
| | | { |
| | | task = leftTask; |
| | | } |
| | | |
| | | if (task != null) |
| | | { |
| | | _taskService.UpdateTaskStatusToNext(task.TaskNum, (int)TaskOutStatusEnum.SC_OutFinish); |
| | | |
| | | var sattion = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.CurrentAddress); |
| | | WriteDebug("CommonConveyorLineTTJobä»»å¡", $"ä»»å¡ï¼{task.Serialize()}ï¼ç«å°ä¿¡æ¯ï¼{sattion.Serialize()}"); |
| | | conveyorLine.SetValue<ConveyorLineDBName, Int16>(ConveyorLineDBName.GetConvNo, Convert.ToInt16(sattion.stationTCLocation), station.stationChildCode); |
| | | conveyorLine.SetValue<ConveyorLineDBName, string>(ConveyorLineDBName.PVI_W, task.PVI, station.stationChildCode); |
| | | //conveyorLine.SetValue<ConveyorLineDBName, Int16>(ConveyorLineDBName.AllowRelease, 1, station.stationChildCode); |
| | | } |
| | | } |
| | | else if (station.stationChildCode == "TC06") |
| | |
| | | { |
| | | task = rightTask; |
| | | } |
| | | } |
| | | |
| | | //var task = _taskRepository.QueryData(X => X.NextAddress == station.stationChildCode).OrderBy(x => x.CreateDate).FirstOrDefault(); |
| | | if (task != null) |
| | | { |
| | | _taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | var sattion = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.CurrentAddress); |
| | | conveyorLine.SetValue<ConveyorLineDBName, Int16>(ConveyorLineDBName.GetConvNo, Convert.ToInt16(sattion.stationTCLocation), station.stationChildCode); |
| | | conveyorLine.SetValue<ConveyorLineDBName, string>(ConveyorLineDBName.PVI_W, task.PVI, station.stationChildCode); |
| | | //conveyorLine.SetValue<ConveyorLineDBName, Int16>(ConveyorLineDBName.AllowRelease, 1, station.stationChildCode); |
| | | if (task != null) |
| | | { |
| | | _taskService.UpdateTaskStatusToNext(task.TaskNum, (int)TaskOutStatusEnum.SC_OutFinish); |
| | | |
| | | var sattion = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.CurrentAddress); |
| | | WriteDebug("CommonConveyorLineTTJobä»»å¡", $"ä»»å¡ï¼{task.Serialize()}ï¼ç«å°ä¿¡æ¯ï¼{sattion.Serialize()}"); |
| | | conveyorLine.SetValue<ConveyorLineDBName, Int16>(ConveyorLineDBName.GetConvNo, Convert.ToInt16(sattion.stationTCLocation), station.stationChildCode); |
| | | conveyorLine.SetValue<ConveyorLineDBName, string>(ConveyorLineDBName.PVI_W, task.PVI, station.stationChildCode); |
| | | //conveyorLine.SetValue<ConveyorLineDBName, Int16>(ConveyorLineDBName.AllowRelease, 1, station.stationChildCode); |
| | | } |
| | | } |
| | | //; |
| | | } |
| | | |
| | | var Putrequest = conveyorLine.GetValue<ConveyorLineDBName, bool>(ConveyorLineDBName.Spare2, station.stationChildCode);//横移æºè½½è´§æ¾è½¦ä¿¡å· |
| | |
| | | { |
| | | if (station.stationChildCode == "TC05") |
| | | { |
| | | var task = _taskRepository.QueryData(X => X.TargetAddress == "RB043" && (X.NextAddress == station.stationChildCode /*|| X.CurrentAddress == station.stationChildCode*/)).OrderBy(x => x.CreateDate).FirstOrDefault(); |
| | | _taskService.UpdatePosition(task.TaskNum, station.stationChildCode); |
| | | conveyorLine.SetValue<ConveyorLineDBName, Int16>(ConveyorLineDBName.AllowRelease, 1, station.stationChildCode); |
| | | var task = _taskRepository.QueryData(X => X.TargetAddress == "RB043" && (X.NextAddress == station.stationChildCode && X.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting/*|| X.CurrentAddress == station.stationChildCode*/)).OrderBy(x => x.CreateDate).FirstOrDefault(); |
| | | |
| | | if (task != null) |
| | | { |
| | | _taskService.UpdatePosition(task.TaskNum, station.stationChildCode); |
| | | conveyorLine.SetValue<ConveyorLineDBName, Int16>(ConveyorLineDBName.AllowRelease, 1, station.stationChildCode); |
| | | } |
| | | } |
| | | else |
| | | { |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEA.QuartzJob |
| | | { |
| | | public interface ISchedulerCenter |
| | | { |
| | | /// <summary> |
| | | /// å¼å¯ä»»å¡è°åº¦ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | Task<ResponseContent> StartScheduleAsync(); |
| | | /// <summary> |
| | | /// 忢任å¡è°åº¦ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | Task<ResponseContent> StopScheduleAsync(); |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="sysSchedule"></param> |
| | | /// <returns></returns> |
| | | Task<ResponseContent> AddScheduleJobAsync(TasksQz sysSchedule); |
| | | /// <summary> |
| | | /// 忢ä¸ä¸ªä»»å¡ |
| | | /// </summary> |
| | | /// <param name="sysSchedule"></param> |
| | | /// <returns></returns> |
| | | Task<ResponseContent> StopScheduleJobAsync(TasksQz sysSchedule); |
| | | /// <summary> |
| | | /// æ£æµä»»å¡æ¯å¦åå¨ |
| | | /// </summary> |
| | | /// <param name="sysSchedule"></param> |
| | | /// <returns></returns> |
| | | Task<bool> IsExistScheduleJobAsync(TasksQz sysSchedule); |
| | | /// <summary> |
| | | /// æåæå®ç计åä»»å¡ |
| | | /// </summary> |
| | | /// <param name="sysSchedule"></param> |
| | | /// <returns></returns> |
| | | Task<ResponseContent> PauseJob(TasksQz sysSchedule); |
| | | /// <summary> |
| | | /// æ¢å¤ä¸ä¸ªä»»å¡ |
| | | /// </summary> |
| | | /// <param name="sysSchedule"></param> |
| | | /// <returns></returns> |
| | | Task<ResponseContent> ResumeJob(TasksQz sysSchedule); |
| | | |
| | | /// <summary> |
| | | /// è·åä»»å¡è§¦åå¨ç¶æ |
| | | /// </summary> |
| | | /// <param name="sysSchedule"></param> |
| | | /// <returns></returns> |
| | | Task<List<TaskInfoDto>> GetTaskStaus(TasksQz sysSchedule); |
| | | /// <summary> |
| | | /// è·å触å卿 è¯ |
| | | /// </summary> |
| | | /// <param name="key"></param> |
| | | /// <returns></returns> |
| | | string GetTriggerState(string key); |
| | | |
| | | /// <summary> |
| | | /// ç«å³æ§è¡ ä¸ä¸ªä»»å¡ |
| | | /// </summary> |
| | | /// <param name="tasksQz"></param> |
| | | /// <returns></returns> |
| | | Task<ResponseContent> ExecuteJobAsync(TasksQz tasksQz); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using Quartz; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Quartz.Spi; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | |
| | | namespace WIDESEA.QuartzJob |
| | | { |
| | | public class JobFactory : IJobFactory |
| | | { |
| | | /// <summary> |
| | | /// 注å
¥åå°è·åä¾èµå¯¹è±¡ |
| | | /// </summary> |
| | | private readonly IServiceProvider _serviceProvider; |
| | | public JobFactory(IServiceProvider serviceProvider) |
| | | { |
| | | _serviceProvider = serviceProvider; |
| | | } |
| | | /// <summary> |
| | | /// å®ç°æ¥å£Job |
| | | /// </summary> |
| | | /// <param name="bundle"></param> |
| | | /// <param name="scheduler"></param> |
| | | /// <returns></returns> |
| | | public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler) |
| | | { |
| | | try |
| | | { |
| | | var serviceScope = _serviceProvider.CreateScope(); |
| | | var job = serviceScope.ServiceProvider.GetService(bundle.JobDetail.JobType) as IJob; |
| | | return job; |
| | | |
| | | } |
| | | catch (Exception) |
| | | { |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | public void ReturnJob(IJob job) |
| | | { |
| | | var disposable = job as IDisposable; |
| | | if (disposable != null) |
| | | { |
| | | disposable.Dispose(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Quartz; |
| | | using Quartz.Spi; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | |
| | | namespace WIDESEA.QuartzJob |
| | | { |
| | | /// <summary> |
| | | /// ä»»å¡è°åº¦ å¯å¨æå¡ |
| | | /// </summary> |
| | | public static class JobSetup |
| | | { |
| | | public static void AddJobSetup(this IServiceCollection services) |
| | | { |
| | | if (services == null) throw new ArgumentNullException(nameof(services)); |
| | | |
| | | //services.AddSingleton<IJobFactory, JobFactory>(); |
| | | //services.AddTransient<AgvTaskJob>();//Job使ç¨ç¬æ¶ä¾èµæ³¨å
¥ |
| | | //services.AddSingleton<ISchedulerCenter, SchedulerCenterServer>(); |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | |
| | | namespace WIDESEA.QuartzJob |
| | | { |
| | | public class ResponseContent |
| | | { |
| | | public ResponseContent() |
| | | { |
| | | } |
| | | public ResponseContent(bool status) |
| | | { |
| | | Status = status; |
| | | } |
| | | public bool Status { get; set; } |
| | | public string Code { get; set; } |
| | | public string Message { get; set; } |
| | | public object Data { get; set; } |
| | | |
| | | public ResponseContent OK() |
| | | { |
| | | Status = true; |
| | | return this; |
| | | } |
| | | |
| | | public static ResponseContent Instance |
| | | { |
| | | get { return new ResponseContent(); } |
| | | } |
| | | public ResponseContent OK(string message = null, object data = null) |
| | | { |
| | | Status = true; |
| | | Message = message; |
| | | Data = data; |
| | | return this; |
| | | } |
| | | public ResponseContent Error(string message = null) |
| | | { |
| | | Status = false; |
| | | Message = message; |
| | | return this; |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using Quartz; |
| | | using Quartz.Impl; |
| | | using Quartz.Impl.Triggers; |
| | | using Quartz.Spi; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Collections.Specialized; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core.Helper; |
| | | |
| | | namespace WIDESEA.QuartzJob |
| | | { |
| | | public class SchedulerCenterServer : ISchedulerCenter |
| | | { |
| | | private Task<IScheduler> _scheduler; |
| | | private readonly IJobFactory _iocjobFactory; |
| | | public SchedulerCenterServer(IJobFactory jobFactory) |
| | | { |
| | | _iocjobFactory = jobFactory; |
| | | _scheduler = GetSchedulerAsync(); |
| | | } |
| | | private Task<IScheduler> GetSchedulerAsync() |
| | | { |
| | | if (_scheduler != null) |
| | | return _scheduler; |
| | | else |
| | | { |
| | | // ä»Factoryä¸è·åSchedulerå®ä¾ |
| | | NameValueCollection collection = new NameValueCollection |
| | | { |
| | | { "quartz.serializer.type", "binary" }, |
| | | }; |
| | | StdSchedulerFactory factory = new StdSchedulerFactory(collection); |
| | | return _scheduler = factory.GetScheduler(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å¼å¯ä»»å¡è°åº¦ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public async Task<ResponseContent> StartScheduleAsync() |
| | | { |
| | | var result = new ResponseContent(); |
| | | try |
| | | { |
| | | _scheduler.Result.JobFactory = _iocjobFactory; |
| | | if (!_scheduler.Result.IsStarted) |
| | | { |
| | | //çå¾
ä»»å¡è¿è¡å®æ |
| | | await _scheduler.Result.Start(); |
| | | |
| | | ConsoleHelper.WriteSuccessLine("ä»»å¡è°åº¦å¼å¯ï¼"); |
| | | result = ResponseContent.Instance.OK($"ä»»å¡è°åº¦å¼å¯æå"); |
| | | return result; |
| | | } |
| | | else |
| | | { |
| | | result = ResponseContent.Instance.OK($"ä»»å¡è°åº¦å·²ç»å¼å¯"); |
| | | return result; |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 忢任å¡è°åº¦ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public async Task<ResponseContent> StopScheduleAsync() |
| | | { |
| | | var result = new ResponseContent(); |
| | | try |
| | | { |
| | | if (!_scheduler.Result.IsShutdown) |
| | | { |
| | | //çå¾
ä»»å¡è¿è¡å®æ |
| | | await _scheduler.Result.Shutdown(); |
| | | //await Console.Out.WriteLineAsync("ä»»å¡è°åº¦åæ¢ï¼"); |
| | | result = ResponseContent.Instance.OK($"ä»»å¡è°åº¦åæ¢æå"); |
| | | return result; |
| | | } |
| | | else |
| | | { |
| | | result = ResponseContent.Instance.OK($"ä»»å¡è°åº¦å·²ç»åæ¢"); |
| | | return result; |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ·»å ä¸ä¸ªè®¡åä»»å¡ï¼æ å°ç¨åºéæå®IJobå®ç°ç±»ï¼ |
| | | /// </summary> |
| | | /// <typeparam name="T"></typeparam> |
| | | /// <param name="tasksQz"></param> |
| | | /// <returns></returns> |
| | | public async Task<ResponseContent> AddScheduleJobAsync(TasksQz tasksQz) |
| | | { |
| | | var result = new ResponseContent(); |
| | | |
| | | if (tasksQz != null) |
| | | { |
| | | try |
| | | { |
| | | JobKey jobKey = new JobKey(tasksQz.Id.ToString(), tasksQz.JobGroup); |
| | | if (await _scheduler.Result.CheckExists(jobKey)) |
| | | { |
| | | result = ResponseContent.Instance.OK($"该任å¡è®¡åå·²ç»å¨æ§è¡:ã{tasksQz.Name}ã,请å¿éå¤å¯å¨ï¼"); |
| | | return result; |
| | | } |
| | | #region 设置å¼å§æ¶é´åç»ææ¶é´ |
| | | |
| | | if (tasksQz.BeginTime == null) |
| | | { |
| | | tasksQz.BeginTime = DateTime.Now; |
| | | } |
| | | DateTimeOffset starRunTime = DateBuilder.NextGivenSecondDate(tasksQz.BeginTime, 1);//设置å¼å§æ¶é´ |
| | | if (tasksQz.EndTime == null) |
| | | { |
| | | tasksQz.EndTime = DateTime.MaxValue.AddDays(-1); |
| | | } |
| | | DateTimeOffset endRunTime = DateBuilder.NextGivenSecondDate(tasksQz.EndTime, 1);//设置æåæ¶é´ |
| | | |
| | | #endregion |
| | | |
| | | #region éè¿åå°è·åç¨åºéç±»ååç±» |
| | | |
| | | Assembly assembly = Assembly.Load(new AssemblyName(tasksQz.AssemblyName)); |
| | | Type jobType = assembly.GetType(tasksQz.AssemblyName + "." + tasksQz.ClassName); |
| | | |
| | | #endregion |
| | | //夿任å¡è°åº¦æ¯å¦å¼å¯ |
| | | //if (!_scheduler.Result.IsStarted) |
| | | //{ |
| | | // await StartScheduleAsync(); |
| | | //} |
| | | |
| | | //ä¼ å
¥åå°åºæ¥çæ§è¡ç¨åºé |
| | | IJobDetail job = new JobDetailImpl(tasksQz.Id.ToString(), tasksQz.JobGroup, jobType); |
| | | job.JobDataMap.Add("JobParam", tasksQz.JobParams); |
| | | ITrigger trigger; |
| | | |
| | | #region æ³åä¼ é |
| | | //IJobDetail job = JobBuilder.Create<T>() |
| | | // .WithIdentity(sysSchedule.Name, sysSchedule.JobGroup) |
| | | // .Build(); |
| | | #endregion |
| | | |
| | | if (tasksQz.Cron != null && CronExpression.IsValidExpression(tasksQz.Cron) && tasksQz.TriggerType > 0) |
| | | { |
| | | trigger = CreateCronTrigger(tasksQz); |
| | | |
| | | ((CronTriggerImpl)trigger).MisfireInstruction = MisfireInstruction.CronTrigger.DoNothing; |
| | | } |
| | | else |
| | | { |
| | | trigger = CreateSimpleTrigger(tasksQz); |
| | | } |
| | | |
| | | // åè¯Quartzä½¿ç¨æä»¬ç触å卿¥å®æä½ä¸ |
| | | await _scheduler.Result.ScheduleJob(job, trigger); |
| | | //await Task.Delay(TimeSpan.FromSeconds(120)); |
| | | //await Console.Out.WriteLineAsync("å
³éäºè°åº¦å¨ï¼"); |
| | | //await _scheduler.Result.Shutdown(); |
| | | result = ResponseContent.Instance.OK($"ã{tasksQz.Name}ãæå"); |
| | | return result; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result = ResponseContent.Instance.Error($"ä»»å¡è®¡åå¼å¸¸:ã{ex.Message}ã"); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result = ResponseContent.Instance.Error($"ä»»å¡è®¡åä¸åå¨:ã{tasksQz?.Name}ã"); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 任塿¯å¦åå¨? |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public async Task<bool> IsExistScheduleJobAsync(TasksQz sysSchedule) |
| | | { |
| | | JobKey jobKey = new JobKey(sysSchedule.Id.ToString(), sysSchedule.JobGroup); |
| | | if (await _scheduler.Result.CheckExists(jobKey)) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// æåä¸ä¸ªæå®ç计åä»»å¡ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public async Task<ResponseContent> StopScheduleJobAsync(TasksQz sysSchedule) |
| | | { |
| | | var result = new ResponseContent(); |
| | | try |
| | | { |
| | | JobKey jobKey = new JobKey(sysSchedule.Id.ToString(), sysSchedule.JobGroup); |
| | | if (!await _scheduler.Result.CheckExists(jobKey)) |
| | | { |
| | | result = ResponseContent.Instance.Error($"æªæ¾å°è¦æåçä»»å¡:ã{sysSchedule.Name}ã"); |
| | | return result; |
| | | } |
| | | else |
| | | { |
| | | await _scheduler.Result.DeleteJob(jobKey); |
| | | result = ResponseContent.Instance.OK($"ã{sysSchedule.Name}ãæå"); |
| | | return result; |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¢å¤æå®ç计åä»»å¡ |
| | | /// </summary> |
| | | /// <param name="sysSchedule"></param> |
| | | /// <returns></returns> |
| | | public async Task<ResponseContent> ResumeJob(TasksQz sysSchedule) |
| | | { |
| | | var result = new ResponseContent(); |
| | | try |
| | | { |
| | | JobKey jobKey = new JobKey(sysSchedule.Id.ToString(), sysSchedule.JobGroup); |
| | | if (!await _scheduler.Result.CheckExists(jobKey)) |
| | | { |
| | | result = ResponseContent.Instance.Error($"æªæ¾å°è¦æ¢å¤çä»»å¡:ã{sysSchedule.Name}ã"); |
| | | return result; |
| | | } |
| | | await _scheduler.Result.ResumeJob(jobKey); |
| | | result = ResponseContent.Instance.OK($"ã{sysSchedule.Name}ãæå"); |
| | | return result; |
| | | } |
| | | catch (Exception) |
| | | { |
| | | throw; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// æåæå®ç计åä»»å¡ |
| | | /// </summary> |
| | | /// <param name="sysSchedule"></param> |
| | | /// <returns></returns> |
| | | public async Task<ResponseContent> PauseJob(TasksQz sysSchedule) |
| | | { |
| | | var result = new ResponseContent(); |
| | | try |
| | | { |
| | | JobKey jobKey = new JobKey(sysSchedule.Id.ToString(), sysSchedule.JobGroup); |
| | | if (!await _scheduler.Result.CheckExists(jobKey)) |
| | | { |
| | | result = ResponseContent.Instance.Error($"æªæ¾å°è¦æåçä»»å¡:ã{sysSchedule.Name}ã"); |
| | | return result; |
| | | } |
| | | await _scheduler.Result.PauseJob(jobKey); |
| | | result = ResponseContent.Instance.Error($"ã{sysSchedule.Name}ãæå"); |
| | | return result; |
| | | } |
| | | catch (Exception) |
| | | { |
| | | throw; |
| | | } |
| | | } |
| | | #region ç¶æç¶æå¸®å©æ¹æ³ |
| | | public async Task<List<TaskInfoDto>> GetTaskStaus(TasksQz sysSchedule) |
| | | { |
| | | |
| | | var ls = new List<TaskInfoDto>(); |
| | | var noTask = new List<TaskInfoDto>{ new TaskInfoDto { |
| | | jobId = sysSchedule.Id.ToString(), |
| | | jobGroup = sysSchedule.JobGroup, |
| | | triggerId = "", |
| | | triggerGroup = "", |
| | | triggerStatus = "ä¸åå¨" |
| | | } }; |
| | | JobKey jobKey = new JobKey(sysSchedule.Id.ToString(), sysSchedule.JobGroup); |
| | | IJobDetail job = await _scheduler.Result.GetJobDetail(jobKey); |
| | | if (job == null) |
| | | { |
| | | return noTask; |
| | | } |
| | | //info.Append(string.Format("ä»»å¡ID:{0}\r\nä»»å¡åç§°:{1}\r\n", job.Key.Name, job.Description)); |
| | | var triggers = await _scheduler.Result.GetTriggersOfJob(jobKey); |
| | | if (triggers == null || triggers.Count == 0) |
| | | { |
| | | return noTask; |
| | | } |
| | | foreach (var trigger in triggers) |
| | | { |
| | | var triggerStaus = await _scheduler.Result.GetTriggerState(trigger.Key); |
| | | string state = GetTriggerState(triggerStaus.ToString()); |
| | | ls.Add(new TaskInfoDto |
| | | { |
| | | jobId = job.Key.Name, |
| | | jobGroup = job.Key.Group, |
| | | triggerId = trigger.Key.Name, |
| | | triggerGroup = trigger.Key.Group, |
| | | triggerStatus = state |
| | | }); |
| | | //info.Append(string.Format("触åå¨ID:{0}\r\n触åå¨åç§°:{1}\r\nç¶æ:{2}\r\n", item.Key.Name, item.Description, state)); |
| | | |
| | | } |
| | | return ls; |
| | | } |
| | | public string GetTriggerState(string key) |
| | | { |
| | | string state = null; |
| | | if (key != null) |
| | | key = key.ToUpper(); |
| | | switch (key) |
| | | { |
| | | case "1": |
| | | state = "æå"; |
| | | break; |
| | | case "2": |
| | | state = "宿"; |
| | | break; |
| | | case "3": |
| | | state = "åºé"; |
| | | break; |
| | | case "4": |
| | | state = "é»å¡"; |
| | | break; |
| | | case "0": |
| | | state = "æ£å¸¸"; |
| | | break; |
| | | case "-1": |
| | | state = "ä¸åå¨"; |
| | | break; |
| | | case "BLOCKED": |
| | | state = "é»å¡"; |
| | | break; |
| | | case "COMPLETE": |
| | | state = "宿"; |
| | | break; |
| | | case "ERROR": |
| | | state = "åºé"; |
| | | break; |
| | | case "NONE": |
| | | state = "ä¸åå¨"; |
| | | break; |
| | | case "NORMAL": |
| | | state = "æ£å¸¸"; |
| | | break; |
| | | case "PAUSED": |
| | | state = "æå"; |
| | | break; |
| | | } |
| | | return state; |
| | | } |
| | | #endregion |
| | | #region å建触åå¨å¸®å©æ¹æ³ |
| | | |
| | | /// <summary> |
| | | /// å建SimpleTrigger触åå¨ï¼ç®å触åå¨ï¼ |
| | | /// </summary> |
| | | /// <param name="sysSchedule"></param> |
| | | /// <param name="starRunTime"></param> |
| | | /// <param name="endRunTime"></param> |
| | | /// <returns></returns> |
| | | private ITrigger CreateSimpleTrigger(TasksQz sysSchedule) |
| | | { |
| | | if (sysSchedule.CycleRunTimes > 0) |
| | | { |
| | | ITrigger trigger = TriggerBuilder.Create() |
| | | .WithIdentity(sysSchedule.Id.ToString(), sysSchedule.JobGroup) |
| | | .StartAt(sysSchedule.BeginTime.Value) |
| | | .WithSimpleSchedule(x => x |
| | | .WithIntervalInSeconds(sysSchedule.IntervalSecond) |
| | | .WithRepeatCount(sysSchedule.CycleRunTimes - 1)) |
| | | .EndAt(sysSchedule.EndTime.Value) |
| | | .Build(); |
| | | return trigger; |
| | | } |
| | | else |
| | | { |
| | | ITrigger trigger = TriggerBuilder.Create() |
| | | .WithIdentity(sysSchedule.Id.ToString(), sysSchedule.JobGroup) |
| | | .StartAt(sysSchedule.BeginTime.Value) |
| | | .WithSimpleSchedule(x => x |
| | | .WithIntervalInSeconds(sysSchedule.IntervalSecond) |
| | | .RepeatForever() |
| | | ) |
| | | .EndAt(sysSchedule.EndTime.Value) |
| | | .Build(); |
| | | return trigger; |
| | | } |
| | | // 触åä½ä¸ç«å³è¿è¡ï¼ç¶åæ¯10ç§éå¤ä¸æ¬¡ï¼æ éå¾ªç¯ |
| | | |
| | | } |
| | | /// <summary> |
| | | /// å建类åCronç触åå¨ |
| | | /// </summary> |
| | | /// <param name="m"></param> |
| | | /// <returns></returns> |
| | | private ITrigger CreateCronTrigger(TasksQz sysSchedule) |
| | | { |
| | | // ä½ä¸è§¦åå¨ |
| | | return TriggerBuilder.Create() |
| | | .WithIdentity(sysSchedule.Id.ToString(), sysSchedule.JobGroup) |
| | | .StartAt(sysSchedule.BeginTime.Value)//å¼å§æ¶é´ |
| | | .EndAt(sysSchedule.EndTime.Value)//ç»ææ°æ® |
| | | .WithCronSchedule(sysSchedule.Cron)//æå®cronè¡¨è¾¾å¼ |
| | | .ForJob(sysSchedule.Id.ToString(), sysSchedule.JobGroup)//ä½ä¸åç§° |
| | | .Build(); |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | /// <summary> |
| | | /// ç«å³æ§è¡ ä¸ä¸ªä»»å¡ |
| | | /// </summary> |
| | | /// <param name="tasksQz"></param> |
| | | /// <returns></returns> |
| | | public async Task<ResponseContent> ExecuteJobAsync(TasksQz tasksQz) |
| | | { |
| | | var result = new ResponseContent(); |
| | | try |
| | | { |
| | | JobKey jobKey = new JobKey(tasksQz.Id.ToString(), tasksQz.JobGroup); |
| | | |
| | | //夿任塿¯å¦åå¨ï¼åå¨å 触å䏿¬¡ï¼ä¸åå¨åå
æ·»å ä¸ä¸ªä»»å¡ï¼è§¦å以åå åæ¢ä»»å¡ |
| | | if (!await _scheduler.Result.CheckExists(jobKey)) |
| | | { |
| | | //ä¸åå¨ å æ·»å ä¸ä¸ªè®¡åä»»å¡ |
| | | await AddScheduleJobAsync(tasksQz); |
| | | |
| | | //è§¦åæ§è¡ä¸æ¬¡ |
| | | await _scheduler.Result.TriggerJob(jobKey); |
| | | |
| | | //åæ¢ä»»å¡ |
| | | await StopScheduleJobAsync(tasksQz); |
| | | |
| | | result = ResponseContent.Instance.OK($"ç«å³æ§è¡è®¡åä»»å¡:ã{tasksQz.Name}ãæå"); |
| | | } |
| | | else |
| | | { |
| | | await _scheduler.Result.TriggerJob(jobKey); |
| | | result = ResponseContent.Instance.OK($"ç«å³æ§è¡è®¡åä»»å¡:ã{tasksQz.Name}ãæå"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result = ResponseContent.Instance.Error($"ç«å³æ§è¡è®¡åä»»å¡å¤±è´¥:ã{ex.Message}ã"); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | |
| | | namespace WIDESEA.QuartzJob |
| | | { |
| | | public class TaskInfoDto |
| | | { |
| | | /// <summary> |
| | | /// ä»»å¡ID |
| | | /// </summary> |
| | | public string jobId { get; set; } |
| | | /// <summary> |
| | | /// ä»»å¡åç§° |
| | | /// </summary> |
| | | public string jobName { get; set; } |
| | | /// <summary> |
| | | /// ä»»å¡åç» |
| | | /// </summary> |
| | | public string jobGroup { get; set; } |
| | | /// <summary> |
| | | /// 触åå¨ID |
| | | /// </summary> |
| | | public string triggerId { get; set; } |
| | | /// <summary> |
| | | /// 触åå¨åç§° |
| | | /// </summary> |
| | | public string triggerName { get; set; } |
| | | /// <summary> |
| | | /// 触åå¨åç» |
| | | /// </summary> |
| | | public string triggerGroup { get; set; } |
| | | /// <summary> |
| | | /// 触åå¨ç¶æ |
| | | /// </summary> |
| | | public string triggerStatus { get; set; } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | |
| | | namespace WIDESEA.QuartzJob |
| | | { |
| | | /// <summary> |
| | | /// ä»»å¡è®¡å表 |
| | | /// </summary> |
| | | public class TasksQz |
| | | { |
| | | /// <summary> |
| | | /// ä»»å¡åç§° |
| | | /// </summary> |
| | | public string Name { get; set; } |
| | | /// <summary> |
| | | /// ä»»å¡åç» |
| | | /// </summary> |
| | | public string JobGroup { get; set; } |
| | | /// <summary> |
| | | /// ä»»å¡è¿è¡æ¶é´è¡¨è¾¾å¼ |
| | | /// </summary> |
| | | public string Cron { get; set; } |
| | | /// <summary> |
| | | /// 任塿å¨DLL对åºçç¨åºéåç§° |
| | | /// </summary> |
| | | public string AssemblyName { get; set; } |
| | | /// <summary> |
| | | /// 任塿å¨ç±» |
| | | /// </summary> |
| | | public string ClassName { get; set; } |
| | | /// <summary> |
| | | /// ä»»å¡æè¿° |
| | | /// </summary> |
| | | public string Remark { get; set; } |
| | | /// <summary> |
| | | /// æ§è¡æ¬¡æ° |
| | | /// </summary> |
| | | public int RunTimes { get; set; } |
| | | /// <summary> |
| | | /// å¼å§æ¶é´ |
| | | /// </summary> |
| | | public DateTime? BeginTime { get; set; } |
| | | /// <summary> |
| | | /// ç»ææ¶é´ |
| | | /// </summary> |
| | | public DateTime? EndTime { get; set; } |
| | | /// <summary> |
| | | /// 触åå¨ç±»åï¼0ãsimple 1ãcronï¼ |
| | | /// </summary> |
| | | public int TriggerType { get; set; } |
| | | /// <summary> |
| | | /// æ§è¡é´éæ¶é´, ç§ä¸ºåä½ |
| | | /// </summary> |
| | | public int IntervalSecond { get; set; } |
| | | /// <summary> |
| | | /// å¾ªç¯æ§è¡æ¬¡æ° |
| | | /// </summary> |
| | | public int CycleRunTimes { get; set; } |
| | | /// <summary> |
| | | /// æ¯å¦å¯å¨ |
| | | /// </summary> |
| | | public bool IsStart { get; set; } = true; |
| | | /// <summary> |
| | | /// æ§è¡ä¼ å |
| | | /// </summary> |
| | | public string JobParams { get; set; } |
| | | |
| | | public bool? IsDeleted { get; set; } |
| | | /// <summary> |
| | | /// å建æ¶é´ |
| | | /// </summary> |
| | | public DateTime CreateTime { get; set; } = DateTime.Now; |
| | | /// <summary> |
| | | /// ä»»å¡å
åä¸çç¶æ |
| | | /// </summary> |
| | | public List<TaskInfoDto> Triggers { get; set; } |
| | | public int Id { get; set; } |
| | | } |
| | | } |
| | |
| | | <PackageReference Include="MiniProfiler.AspNetCore.Mvc" Version="4.3.8" /> |
| | | <PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> |
| | | <PackageReference Include="OfficeOpenXml.Core.ExcelPackage" Version="1.0.0" /> |
| | | <PackageReference Include="Quartz" Version="3.16.1" /> |
| | | <PackageReference Include="SkiaSharp" Version="2.88.8" /> |
| | | <PackageReference Include="SqlSugarCore" Version="5.1.4.152" /> |
| | | <PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.0" /> |
| | |
| | | <ItemGroup> |
| | | <Folder Include="Attribute\" /> |
| | | <Folder Include="ServiceExtensions\" /> |
| | | <Folder Include="Quartz\" /> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using Magicodes.ExporterAndImporter.Core; |
| | | using Org.BouncyCastle.Crypto.Utilities; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core.DB.Models; |
| | | |
| | | namespace WIDESEA_Model.Models |
| | | { |
| | | /// <summary> |
| | | /// æå¨é车åå² |
| | | /// </summary> |
| | | public class Dt_MESLockInfo_hty : BaseEntity |
| | | { |
| | | /// <summary> |
| | | /// ä¸»é® |
| | | /// </summary> |
| | | [ImporterHeader(Name = "主é®")] |
| | | [ExporterHeader(DisplayName = "主é®")] |
| | | [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主é®")] |
| | | public int Id { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 车身ID |
| | | /// </summary> |
| | | [ImporterHeader(Name = "车身ID")] |
| | | [ExporterHeader(DisplayName = "车身ID")] |
| | | [SugarColumn(IsNullable = true, Length = 20, ColumnDescription = "车身ID")] |
| | | public int carBodyID { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 车身对象 |
| | | /// </summary> |
| | | [Navigate(NavigateType.OneToOne, nameof(carBodyID), nameof(Dt_CarBodyInfo.Id))] |
| | | public Dt_CarBodyInfo CarBodyInfo { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç¶æ 0-æªä¸åä»»å¡ 1-å·²ä¸åä»»å¡ |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = false, Length = 20, ColumnDescription = "ç¶æ")] |
| | | public int LockStatue { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æå±æ¨ªç§»æºäº§çº¿ |
| | | /// </summary> |
| | | public string TCLine { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 顺åºå· |
| | | /// </summary> |
| | | public int sequenceNo { get; set; } |
| | | ///// <summary> |
| | | ///// åºä½ |
| | | ///// </summary> |
| | | //[ImporterHeader(Name = "åºä½")] |
| | | //[ExporterHeader(DisplayName = "åºä½")] |
| | | //[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "åºä½")] |
| | | //public int locaitonCode { get; set; } |
| | | |
| | | ///// <summary> |
| | | ///// PVI |
| | | ///// </summary> |
| | | //[ImporterHeader(Name = "PVI")] |
| | | //[ExporterHeader(DisplayName = "PVI")] |
| | | //[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "PVI")] |
| | | //public int PVI { get; set; } |
| | | |
| | | |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using Magicodes.ExporterAndImporter.Core; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core.DB.Models; |
| | | |
| | | namespace WIDESEA_Model.Models |
| | | { |
| | | [SugarTable(nameof(VV_MesLockInfo), "é车éåä¿¡æ¯")] |
| | | public class VV_MesLockInfo |
| | | { |
| | | /// <summary> |
| | | /// ä¸»é® |
| | | /// </summary> |
| | | [ImporterHeader(Name = "主é®")] |
| | | [ExporterHeader(DisplayName = "主é®")] |
| | | [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "主é®")] |
| | | public int Id { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 1-åå§å 2-å·²ä¸å |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "æå¨ç¶æ")] |
| | | public int LockStatue { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 横移æºäº§çº¿ 1-4ä¸ºå·¦ä¾§æ¨ªç§»æº 4-7为å³ä¾§æ¨ªç§»æº |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, ColumnDescription = " 横移æºäº§çº¿")] |
| | | public int TCLine { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å建è
|
| | | /// </summary> |
| | | [ImporterHeader(Name = "å建è
")] |
| | | [ExporterHeader(DisplayName = "å建è
")] |
| | | [SugarColumn(IsNullable = false, IsOnlyIgnoreUpdate = true, ColumnDescription = "å建è
")] |
| | | public string Creater { get; set; } = "Systeam"; |
| | | |
| | | /// <summary> |
| | | /// å建æ¶é´ |
| | | /// </summary> |
| | | [ImporterHeader(Name = "å建æ¶é´")] |
| | | [ExporterHeader(DisplayName = "å建æ¶é´")] |
| | | [SugarColumn(IsNullable = false, IsOnlyIgnoreUpdate = true, ColumnDescription = "å建æ¶é´")] |
| | | public DateTime CreateDate { get; set; } //= DateTime.Now; |
| | | |
| | | /// <summary> |
| | | /// æ´æ°è
|
| | | /// </summary> |
| | | [ImporterHeader(Name = "ä¿®æ¹äºº")] |
| | | [ExporterHeader(DisplayName = "ä¿®æ¹äºº")] |
| | | [SugarColumn(IsNullable = true, IsOnlyIgnoreInsert = true, ColumnDescription = "ä¿®æ¹äºº")] |
| | | public string Modifier { get; set; } = "System"; |
| | | |
| | | /// <summary> |
| | | /// ä¿®æ¹æ¥æ |
| | | /// </summary> |
| | | [ImporterHeader(Name = "ä¿®æ¹æ¥æ")] |
| | | [ExporterHeader(DisplayName = "ä¿®æ¹æ¥æ")] |
| | | [SugarColumn(IsNullable = true, IsOnlyIgnoreInsert = true, ColumnDescription = "ä¿®æ¹æ¥æ")] |
| | | public DateTime? ModifyDate { get; set; } //= DateTime.Now; |
| | | |
| | | /// <summary> |
| | | /// 顺åºå· |
| | | /// </summary> |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "顺åºå·")] |
| | | public int sequenceNo { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æå±å··é |
| | | /// </summary> |
| | | [ImporterHeader(Name = "æå±å··é")] |
| | | [ExporterHeader(DisplayName = "æå±å··é")] |
| | | [SugarColumn(IsNullable = true, Length = 20, ColumnDescription = "æå±å··é")] |
| | | public string RoadwayNo { get; set; } |
| | | |
| | | /// <summary> |
| | | /// è´§ä½ç¼å· |
| | | /// </summary> |
| | | [ImporterHeader(Name = "è´§ä½ç¼å·")] |
| | | [ExporterHeader(DisplayName = "è´§ä½ç¼å·")] |
| | | [SugarColumn(IsNullable = true, Length = 20, ColumnDescription = "è´§ä½ç¼å·")] |
| | | public string LocationCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 车身ID |
| | | /// </summary> |
| | | [ImporterHeader(Name = "车身ID")] |
| | | [ExporterHeader(DisplayName = "车身ID")] |
| | | [SugarColumn(IsNullable = true, Length = 20, ColumnDescription = "车身ID")] |
| | | public int carBodyID { get; set; } |
| | | /// <summary> |
| | | /// PVIç |
| | | /// </summary> |
| | | [ImporterHeader(Name = "PVIç ")] |
| | | [ExporterHeader(DisplayName = "PVIç ")] |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "PVIç ")] |
| | | public string PVI { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ»æ©å· |
| | | /// </summary> |
| | | [ImporterHeader(Name = "æ»æ©å·")] |
| | | [ExporterHeader(DisplayName = "æ»æ©å·")] |
| | | [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "æ»æ©å·")] |
| | | public string PalletCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 车å |
| | | /// </summary> |
| | | [ImporterHeader(Name = "车å")] |
| | | [ExporterHeader(DisplayName = "车å")] |
| | | [SugarColumn(IsNullable = true, Length = 20, ColumnDescription = "车å")] |
| | | public string vehicleCharacteristic { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 车身类å 1-ç½ 2-彩 3-ç©ºæ»æ© 4-空æ¬ç» |
| | | /// </summary> |
| | | [ImporterHeader(Name = "车身类å")] |
| | | [ExporterHeader(DisplayName = "车身类å")] |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "车身类å")] |
| | | public int CarType { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 订åç±»å |
| | | /// </summary> |
| | | [ImporterHeader(Name = "订åç±»å")] |
| | | [ExporterHeader(DisplayName = "订åç±»å")] |
| | | [SugarColumn(IsNullable = true, Length = 20, ColumnDescription = "订åç±»å")] |
| | | public string workOrderType { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 天çªç¹å¾ |
| | | /// </summary> |
| | | [ImporterHeader(Name = "天çªç¹å¾")] |
| | | [ExporterHeader(DisplayName = "天çªç¹å¾")] |
| | | [SugarColumn(IsNullable = true, Length = 40, ColumnDescription = "天çªç¹å¾")] |
| | | public string skylightCharacteristic { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 车身é¢è² |
| | | /// </summary> |
| | | [ImporterHeader(Name = "车身é¢è²")] |
| | | [ExporterHeader(DisplayName = "车身é¢è²")] |
| | | [SugarColumn(IsNullable = true, Length = 20, ColumnDescription = "车身é¢è²")] |
| | | public string carBodyCharacteristic { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç½è½¦èº«ç©æå· |
| | | /// </summary> |
| | | [ImporterHeader(Name = "ç½è½¦èº«ç©æå·")] |
| | | [ExporterHeader(DisplayName = "ç½è½¦èº«ç©æå·")] |
| | | [SugarColumn(IsNullable = true, Length = 40, ColumnDescription = "ç½è½¦èº«ç©æå·")] |
| | | public string biwMaterialCode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å½©è½¦èº«ç©æå· |
| | | /// </summary> |
| | | [ImporterHeader(Name = "å½©è½¦èº«ç©æå·")] |
| | | [ExporterHeader(DisplayName = "å½©è½¦èº«ç©æå·")] |
| | | [SugarColumn(IsNullable = true, Length = 40, ColumnDescription = "å½©è½¦èº«ç©æå·")] |
| | | public string pbMaterial { get; set; } |
| | | |
| | | /// <summary> |
| | | /// çè£
ä¸çº¿æ¶é´ |
| | | /// </summary> |
| | | [ImporterHeader(Name = "çè£
ä¸çº¿æ¶é´")] |
| | | [ExporterHeader(DisplayName = "çè£
ä¸çº¿æ¶é´")] |
| | | [SugarColumn(IsNullable = true, Length = 40, ColumnDescription = "çè£
ä¸çº¿æ¶é´")] |
| | | public DateTime? biwInPassTime { get; set; } |
| | | |
| | | /// <summary> |
| | | /// éå®ç¶æ 0-æªéå® 1-éå® |
| | | /// </summary> |
| | | [ImporterHeader(Name = "éå®ç¶æ")] |
| | | [ExporterHeader(DisplayName = "éå®ç¶æ")] |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "éå®ç¶æ")] |
| | | public int StockStatus { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æå¨éå® 0-æªæå¨ 1-æå¨ |
| | | /// </summary> |
| | | [ImporterHeader(Name = "æå¨éå®")] |
| | | [ExporterHeader(DisplayName = "æå¨éå®")] |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "æå¨éå®")] |
| | | public int LockOrder { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡ç¶æ 0-æ ä»»å¡ 1-ä»»å¡ä¸ |
| | | /// </summary> |
| | | [ImporterHeader(Name = "ä»»å¡ç¶æ")] |
| | | [ExporterHeader(DisplayName = "ä»»å¡ç¶æ")] |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "ä»»å¡ç¶æ")] |
| | | public int TaskStatus { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ä¿çç¶æ |
| | | /// </summary> |
| | | [ImporterHeader(Name = "ä¿çç¶æ")] |
| | | [ExporterHeader(DisplayName = "ä¿çç¶æ")] |
| | | [SugarColumn(IsNullable = true, ColumnDescription = "ä¿çç¶æ")] |
| | | public int StayStatus { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æå±å·¥å(é¢ç»å®) |
| | | /// </summary> |
| | | //[ImporterHeader(Name = "æå±å·¥å")] |
| | | //[ExporterHeader(DisplayName = "æå±å·¥å")] |
| | | //[SugarColumn(IsNullable = true, Length = 20, ColumnDescription = "æå±å·¥å")] |
| | | //public string OrderID { get; set; } |
| | | } |
| | | } |
| | |
| | | |
| | | namespace WIDESEA_Model.Models |
| | | { |
| | | [SugarTable(nameof(VV_StockInfo), "åºåä¿¡æ¯")] |
| | | //[SugarTable(nameof(VV_StockInfo), "åºåä¿¡æ¯")] |
| | | public class VV_StockInfo |
| | | { |
| | | /// <summary> |
| | |
| | | { |
| | | var orderinfo = _assemblyOrderInfoRepository.QueryFirst(x => x.workOrderNo == item.workOrderNo && x.orderType == item.orderType); |
| | | if (orderinfo == null) throw new Exception($"æªæ¾å°å·¥åå·{item.workOrderNo}å·¥åç±»å为{item.orderType}çæ»è£
å·¥å"); |
| | | |
| | | if (!string.IsNullOrEmpty(orderinfo.pvi)) throw new Exception($"æ»è£
å·¥åå·{item.workOrderNo}å·²æå¨é车ç车身工å䏿¯ææ¤æ"); |
| | | |
| | | _assemblyOrderInfoRepository.DeleteData(orderinfo); |
| | | } |
| | | } |
| | |
| | | using WIDESEA_Common.MES; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_DTO; |
| | | using WIDESEA_StorageBasicRepository; |
| | | |
| | | namespace WIDESEA_StoragIntegrationServices |
| | | { |
| | |
| | | |
| | | //è¿ç¹ä¿¡æ¯ |
| | | WebResponseContent content1 = _mesService.PassPoint(json); |
| | | if (!content1.Status) throw new Exception($"è¿ç¹å¤±è´¥ï¼{content1.msg},请æ±ä¿¡æ¯:{{json.ToJson()"); |
| | | if (!content1.Status) throw new Exception($"è¿ç¹å¤±è´¥ï¼{content1.msg},请æ±ä¿¡æ¯:{json.ToJson()}"); |
| | | |
| | | //è·åVINå· |
| | | WebResponseContent responseContent = _mesService.getCharacteristic(json); |
| | |
| | | VechicleModel = carinfo.vehicleCharacteristic, |
| | | }; |
| | | |
| | | var mesLock = _mesLockInfoRepository.QueryFirst(x => x.carBodyID == carinfo.Id); |
| | | if (mesLock != null) |
| | | { |
| | | mesLock.LockStatue = 2; |
| | | _mesLockInfoRepository.UpdateData(mesLock); |
| | | } |
| | | |
| | | content.OK(data: respon); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var carInfo = _carBodyInfoRepository.QueryFirst(x => x.RFID == json.Rfid); ///*x.PalletCode == json.PalletCode ||*/ |
| | | var carInfo = _carBodyInfoRepository.QueryFirst(x => x.RFID == json.PVI); ///*x.PalletCode == json.PalletCode ||*/ |
| | | if (carInfo != null) throw new Exception($"æ¶è£
ç´éæ»è£
失败:PVI{json.Rfid}å·²åå¨ã"); |
| | | |
| | | WebResponseContent responseContent = _mesService.issuedCharacter(json.PVI, json.Position, json.PalletCode); |
| | |
| | | //json.PVI = json.PVI.Substring(0, 9); |
| | | json.Position = "RB001"; |
| | | WebResponseContent content1 = _mesService.PassPoint(json); |
| | | if (!content1.Status) throw new Exception($"è¿ç¹å¤±è´¥ï¼{content1.msg}"); |
| | | if (!content1.Status) throw new Exception($"BDC02è¿ç¹å¤±è´¥ï¼{content1.msg}"); |
| | | |
| | | WebResponseContent webResponse = _mesService.bindWorkOrder("EL01RB", json.PVI); |
| | | if (!responseContent.Status) throw new Exception($"ç»å®å¤±è´¥ï¼{webResponse.msg}"); |
| | | if (!responseContent.Status) throw new Exception($"çæ¶ç»å®å¤±è´¥ï¼{webResponse.msg}"); |
| | | |
| | | //è¿ç¹ä¿¡æ¯ -BDC02 |
| | | json.Position = "EL01RB"; |
| | | WebResponseContent BDC02 = _mesService.PassPoint(json); |
| | | if (!BDC02.Status) throw new Exception($"è¿ç¹å¤±è´¥ï¼{BDC02.msg}"); |
| | | if (!BDC02.Status) throw new Exception($"BDC02è¿ç¹å¤±è´¥ï¼{BDC02.msg}"); |
| | | |
| | | ////è¿ç¹ä¿¡æ¯ -BDC03 |
| | | json.Position = "EL01RB01"; |
| | | WebResponseContent BDC03 = _mesService.PassPoint(json); |
| | | if (!BDC03.Status) throw new Exception($"è¿ç¹å¤±è´¥ï¼{BDC03.msg}"); |
| | | if (!BDC03.Status) throw new Exception($"BDC03è¿ç¹å¤±è´¥ï¼{BDC03.msg}"); |
| | | |
| | | content.OK(); |
| | | } |
| | |
| | | |
| | | private readonly LogFactory LogFactory = new LogFactory(); |
| | | |
| | | public WCSService(ILocationInfoRepository locationRepository, IDt_TaskRepository taskRepository, ISys_ConfigService configService, IDt_StationManagerRepository stationManagerRepository, IMESService mesService, IDt_PalletStockInfoRepository palletStockInfoRepository, IDt_CarBodyInfoRepository carBodyInfoRepository, IDt_RoadWayInfoRepository roadWayInfoRepository, IDt_RoadWayRepository roadWayRepository, IDt_TaskService taskService, IUnitOfWorkManage unitOfWorkManage) |
| | | public WCSService(ILocationInfoRepository locationRepository, IDt_TaskRepository taskRepository, ISys_ConfigService configService, IDt_StationManagerRepository stationManagerRepository, IMESService mesService, IDt_PalletStockInfoRepository palletStockInfoRepository, IDt_CarBodyInfoRepository carBodyInfoRepository, IDt_RoadWayInfoRepository roadWayInfoRepository, IDt_RoadWayRepository roadWayRepository, IDt_TaskService taskService, IUnitOfWorkManage unitOfWorkManage,IDt_MESLockInfoRepository mesLockInfoRepository) |
| | | { |
| | | _locationRepository = locationRepository; |
| | | _taskRepository = taskRepository; |
| | |
| | | _roadWayRepository = roadWayRepository; |
| | | _taskService = taskService; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _mesLockInfoRepository = mesLockInfoRepository; |
| | | } |
| | | } |
| | | } |
| | |
| | | using Masuit.Tools; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Microsoft.Extensions.Hosting; |
| | | using Microsoft.Extensions.Logging; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.Const; |
| | | using WIDESEA_DTO.WMS; |
| | | using WIDESEA_IServices; |
| | |
| | | { |
| | | public class MyBackgroundService : IHostedService, IDisposable |
| | | { |
| | | private readonly ILogger<MyBackgroundService> _logger; |
| | | private readonly IDt_PalletStockInfoRepository _palletStockInfoRepository; |
| | | private readonly IDt_AreaInfoRepository _areaInfoRepository; //åºå |
| | | private readonly IDt_TaskRepository _taskRepository; |
| | | private readonly IDt_StationManagerRepository _stationManagerRepository; |
| | | private readonly ISys_ConfigService _configService; |
| | | private readonly ILocationInfoRepository _locationRepository; |
| | | private readonly IVV_StockInfoRepository _VVStockInfoRepository; |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly IDt_MESLockInfoRepository _MESLockInfoRepository; |
| | | private ILogger<MyBackgroundService> _logger; |
| | | private IDt_PalletStockInfoRepository _palletStockInfoRepository; |
| | | private IDt_AreaInfoRepository _areaInfoRepository; //åºå |
| | | private IDt_TaskRepository _taskRepository; |
| | | private IDt_StationManagerRepository _stationManagerRepository; |
| | | private ISys_ConfigService _configService; |
| | | private ILocationInfoRepository _locationRepository; |
| | | private IVV_StockInfoRepository _VVStockInfoRepository; |
| | | private IUnitOfWorkManage _unitOfWorkManage; |
| | | private IDt_MESLockInfoRepository _MESLockInfoRepository; |
| | | |
| | | private Timer _timer; |
| | | |
| | | public MyBackgroundService(ILogger<MyBackgroundService> logger, ILocationInfoRepository locationRepository, IDt_AreaInfoRepository areaInfoRepository, IDt_TaskRepository taskRepository, IDt_StationManagerRepository stationManagerRepository, ISys_ConfigService configService, IDt_PalletStockInfoRepository palletStockInfoRepository, IVV_StockInfoRepository VV_StockInfoRepository, IUnitOfWorkManage unitOfWorkManage, IDt_MESLockInfoRepository MESLockInfoRepository) |
| | | public MyBackgroundService(/*ILogger<MyBackgroundService> logger, ILocationInfoRepository locationRepository, IDt_AreaInfoRepository areaInfoRepository, IDt_TaskRepository taskRepository, IDt_StationManagerRepository stationManagerRepository, ISys_ConfigService configService, IDt_PalletStockInfoRepository palletStockInfoRepository, IVV_StockInfoRepository VV_StockInfoRepository, IUnitOfWorkManage unitOfWorkManage, IDt_MESLockInfoRepository MESLockInfoRepository*/) |
| | | { |
| | | _logger = logger; |
| | | _locationRepository = locationRepository; |
| | | _areaInfoRepository = areaInfoRepository; |
| | | _taskRepository = taskRepository; |
| | | _stationManagerRepository = stationManagerRepository; |
| | | _configService = configService; |
| | | _palletStockInfoRepository = palletStockInfoRepository; |
| | | _VVStockInfoRepository = VV_StockInfoRepository; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _MESLockInfoRepository = MESLockInfoRepository; |
| | | |
| | | } |
| | | |
| | | public Task StartAsync(CancellationToken cancellationToken) |
| | | { |
| | | _timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromMinutes(5)); |
| | | //_timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromSeconds(15)); |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | IServiceScope scope = App.RootServices.CreateScope(); |
| | | _logger = scope.ServiceProvider.GetService<ILogger<MyBackgroundService>>(); |
| | | _locationRepository = scope.ServiceProvider.GetService<ILocationInfoRepository>(); |
| | | _areaInfoRepository = scope.ServiceProvider.GetService<IDt_AreaInfoRepository>(); |
| | | _taskRepository = scope.ServiceProvider.GetService<IDt_TaskRepository>(); |
| | | _stationManagerRepository = scope.ServiceProvider.GetService<IDt_StationManagerRepository>(); |
| | | _configService = scope.ServiceProvider.GetService<ISys_ConfigService>(); |
| | | _palletStockInfoRepository = scope.ServiceProvider.GetService<IDt_PalletStockInfoRepository>(); |
| | | _VVStockInfoRepository = scope.ServiceProvider.GetService<IVV_StockInfoRepository>(); |
| | | _unitOfWorkManage = scope.ServiceProvider.GetService<IUnitOfWorkManage>(); |
| | | _MESLockInfoRepository = scope.ServiceProvider.GetService<IDt_MESLockInfoRepository>(); |
| | | //var area = _areaInfoRepository.QueryFirst(x => x.AreaCode == "GWSC1"); |
| | | |
| | | //if (area == null) { return; } |
| | |
| | | |
| | | |
| | | if (lockInfo.Where(x => x.LockStatue == 1).Count() > 10) return; |
| | | if (lockInfo.Count == 0) return; |
| | | |
| | | var lockCar = lockInfo.Where(x => x.LockStatue == 0).First(); |
| | | |
| | | foreach (var item in lockInfo) |
| | | var lockCar = lockInfo.Where(x => x.LockStatue == 0).FirstOrDefault(); |
| | | if (lockCar == null) return; |
| | | var hasTask = _taskRepository.QueryFirst(x => x.PalletCode == lockCar.CarBodyInfo.PalletCode); |
| | | if (hasTask != null) |
| | | { |
| | | var hasTask = _taskRepository.QueryFirst(x => x.PalletCode == item.CarBodyInfo.PalletCode); |
| | | if (hasTask != null) |
| | | { |
| | | Console.WriteLine("å·²åå¨åºåºä»»å¡"); |
| | | continue; |
| | | } |
| | | |
| | | List<Dt_StationManager> stationLists = null; |
| | | if (item.CarBodyInfo.CarType == 1) |
| | | { |
| | | stationLists = _stationManagerRepository.QueryData(x => x.RoadwayNo == item.TCLine && x.stationType == 2 && x.stationStatus == "1" && x.stationArea == "3"); |
| | | } |
| | | else if (item.CarBodyInfo.CarType == 2) |
| | | { |
| | | stationLists = _stationManagerRepository.QueryData(x => x.RoadwayNo == item.TCLine && x.stationType == 2 && x.stationStatus == "1" && x.stationArea == "4"); |
| | | } |
| | | //else if (item.CarBodyInfo.CarType == 3) |
| | | //{ |
| | | // stationLists = _stationManagerRepository.QueryData(x => x.RoadwayNo == item.TCLine && x.stationType == 7 && x.stationStatus == "1" && x.stationArea == "3"); |
| | | //} |
| | | |
| | | var stock = _VVStockInfoRepository.QueryFirst(x => x.carBodyID == item.carBodyID); |
| | | var lockStock = _palletStockInfoRepository.QueryFirst(x => x.carBodyID == item.carBodyID); |
| | | var location = _locationRepository.QueryFirst(x => x.LocationCode == stock.LocationCode); |
| | | location.LocationStatus = (int)LocationEnum.InStockDisable; |
| | | item.LockStatue = 1; |
| | | lockStock.TaskStatus = 1; |
| | | if (stationLists == null || stationLists.Count == 0) throw new Exception("åºåºç«å°æªé
ç½®ææªå¯ç¨"); |
| | | |
| | | Dt_StationManager Outstation = null; |
| | | |
| | | //if (stationLists.Count > 1) |
| | | //{ |
| | | // var Outtask = BaseDal.QueryData(x => x.Roadway == stationLists.FirstOrDefault().Roadway && x.TaskType == (int)TaskTypeEnum.Outbound).OrderByDescending(x => x.CreateDate).FirstOrDefault(); |
| | | // if (Outtask != null) Outstation = stationLists.Where(x => x.stationChildCode != task.NextAddress && x.stationChildCode != Outtask.CurrentAddress).FirstOrDefault(); |
| | | // else Outstation = stationLists.FirstOrDefault(); |
| | | //} |
| | | //else |
| | | //{ |
| | | Outstation = stationLists.FirstOrDefault(); |
| | | //} |
| | | //var stationInfo = stationInfos.FirstOrDefault(); |
| | | |
| | | // å建并添å ä»»å¡å°æ°æ®åº |
| | | hasTask = new Dt_Task |
| | | { |
| | | Grade = 1, |
| | | Roadway = Outstation.Roadway, |
| | | TargetAddress = "RB043", |
| | | Dispatchertime = DateTime.Now, |
| | | NextAddress = Outstation.stationChildCode, |
| | | OrderNo = null, |
| | | PalletCode = stock.PalletCode, |
| | | PVI = stock.PVI, |
| | | SourceAddress = stock.LocationCode, |
| | | CurrentAddress = stock.LocationCode, |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | TaskType = (int)TaskOutboundTypeEnum.Outbound, |
| | | TaskNum = _taskRepository.GetTaskNo().Result, |
| | | Creater = "System", |
| | | CreateDate = DateTime.Now, |
| | | TaskId = 0, |
| | | }; |
| | | |
| | | // å建任å¡ä¼ è¾ç¨çDTO对象 |
| | | var taskDTO = CreateTaskDTO(hasTask); |
| | | |
| | | // è·åWMS IPå°åç¨äºåéä»»å¡è¯·æ± |
| | | var wmsIpAddress = GetWCSIpReceiveTask(); |
| | | if (wmsIpAddress == null) |
| | | { |
| | | throw new InvalidOperationException("WMS IP æªé
ç½®"); |
| | | } |
| | | |
| | | var tasks = new List<WMSTaskDTO>() { taskDTO }; |
| | | // åéä»»å¡è¯·æ±å°WMS |
| | | var result = HttpHelper.PostAsync(wmsIpAddress, tasks.ToJsonString()).Result; |
| | | WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | if (content.Status) |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | // æ·»å ä»»å¡å°æ°æ®åº |
| | | _taskRepository.AddData(hasTask); |
| | | // æ´æ°åºä½ä½ç½®ç¶æä¸ºä¸å¯ç¨ |
| | | _locationRepository.UpdateData(location); |
| | | _MESLockInfoRepository.UpdateData(item); |
| | | _palletStockInfoRepository.UpdateData(lockStock); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | Console.WriteLine("å·²åå¨åºåºä»»å¡"); |
| | | return; |
| | | } |
| | | |
| | | List<Dt_StationManager> stationLists = null; |
| | | if (lockCar.CarBodyInfo.CarType == 1) |
| | | { |
| | | stationLists = _stationManagerRepository.QueryData(x => x.RoadwayNo == lockCar.TCLine && x.stationType == 2 && x.stationStatus == "1" && x.stationArea == "3"); |
| | | } |
| | | else if (lockCar.CarBodyInfo.CarType == 2) |
| | | { |
| | | stationLists = _stationManagerRepository.QueryData(x => x.RoadwayNo == lockCar.TCLine && x.stationType == 2 && x.stationStatus == "1" && x.stationArea == "4"); |
| | | } |
| | | //else if (item.CarBodyInfo.CarType == 3) |
| | | //{ |
| | | // stationLists = _stationManagerRepository.QueryData(x => x.RoadwayNo == item.TCLine && x.stationType == 7 && x.stationStatus == "1" && x.stationArea == "3"); |
| | | //} |
| | | |
| | | var stock = _VVStockInfoRepository.QueryFirst(x => x.carBodyID == lockCar.carBodyID); |
| | | var lockStock = _palletStockInfoRepository.QueryFirst(x => x.carBodyID == lockCar.carBodyID); |
| | | var location = _locationRepository.QueryFirst(x => x.LocationCode == stock.LocationCode); |
| | | location.LocationStatus = (int)LocationEnum.InStockDisable; |
| | | lockCar.LockStatue = 1; |
| | | lockStock.TaskStatus = 1; |
| | | if (stationLists == null || stationLists.Count == 0) throw new Exception("åºåºç«å°æªé
ç½®ææªå¯ç¨"); |
| | | |
| | | Dt_StationManager Outstation = null; |
| | | |
| | | //if (stationLists.Count > 1) |
| | | //{ |
| | | // var Outtask = BaseDal.QueryData(x => x.Roadway == stationLists.FirstOrDefault().Roadway && x.TaskType == (int)TaskTypeEnum.Outbound).OrderByDescending(x => x.CreateDate).FirstOrDefault(); |
| | | // if (Outtask != null) Outstation = stationLists.Where(x => x.stationChildCode != task.NextAddress && x.stationChildCode != Outtask.CurrentAddress).FirstOrDefault(); |
| | | // else Outstation = stationLists.FirstOrDefault(); |
| | | //} |
| | | //else |
| | | //{ |
| | | Outstation = stationLists.FirstOrDefault(); |
| | | //} |
| | | //var stationInfo = stationInfos.FirstOrDefault(); |
| | | |
| | | // å建并添å ä»»å¡å°æ°æ®åº |
| | | hasTask = new Dt_Task |
| | | { |
| | | Grade = 1, |
| | | Roadway = Outstation.Roadway, |
| | | TargetAddress = "RB043", |
| | | Dispatchertime = DateTime.Now, |
| | | NextAddress = Outstation.stationChildCode, |
| | | OrderNo = null, |
| | | PalletCode = stock.PalletCode, |
| | | PVI = stock.PVI, |
| | | SourceAddress = stock.LocationCode, |
| | | CurrentAddress = stock.LocationCode, |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | TaskType = (int)TaskOutboundTypeEnum.Outbound, |
| | | TaskNum = _taskRepository.GetTaskNo().Result, |
| | | Creater = "System", |
| | | CreateDate = DateTime.Now, |
| | | TaskId = 0, |
| | | }; |
| | | |
| | | // å建任å¡ä¼ è¾ç¨çDTO对象 |
| | | var taskDTO = CreateTaskDTO(hasTask); |
| | | |
| | | // è·åWMS IPå°åç¨äºåéä»»å¡è¯·æ± |
| | | var wmsIpAddress = GetWCSIpReceiveTask(); |
| | | if (wmsIpAddress == null) |
| | | { |
| | | throw new InvalidOperationException("WMS IP æªé
ç½®"); |
| | | } |
| | | |
| | | var tasks = new List<WMSTaskDTO>() { taskDTO }; |
| | | // åéä»»å¡è¯·æ±å°WMS |
| | | var result = HttpHelper.PostAsync(wmsIpAddress, tasks.ToJsonString()).Result; |
| | | WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | if (content.Status) |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | // æ·»å ä»»å¡å°æ°æ®åº |
| | | _taskRepository.AddData(hasTask); |
| | | // æ´æ°åºä½ä½ç½®ç¶æä¸ºä¸å¯ç¨ |
| | | _locationRepository.UpdateData(location); |
| | | _MESLockInfoRepository.UpdateData(lockCar); |
| | | _palletStockInfoRepository.UpdateData(lockStock); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | |
| | | //foreach (var item in lockInfo) |
| | | //{ |
| | | // var hasTask = _taskRepository.QueryFirst(x => x.PalletCode == item.CarBodyInfo.PalletCode); |
| | | // if (hasTask != null) |
| | | // { |
| | | // Console.WriteLine("å·²åå¨åºåºä»»å¡"); |
| | | // continue; |
| | | // } |
| | | |
| | | // List<Dt_StationManager> stationLists = null; |
| | | // if (item.CarBodyInfo.CarType == 1) |
| | | // { |
| | | // stationLists = _stationManagerRepository.QueryData(x => x.RoadwayNo == item.TCLine && x.stationType == 2 && x.stationStatus == "1" && x.stationArea == "3"); |
| | | // } |
| | | // else if (item.CarBodyInfo.CarType == 2) |
| | | // { |
| | | // stationLists = _stationManagerRepository.QueryData(x => x.RoadwayNo == item.TCLine && x.stationType == 2 && x.stationStatus == "1" && x.stationArea == "4"); |
| | | // } |
| | | // //else if (item.CarBodyInfo.CarType == 3) |
| | | // //{ |
| | | // // stationLists = _stationManagerRepository.QueryData(x => x.RoadwayNo == item.TCLine && x.stationType == 7 && x.stationStatus == "1" && x.stationArea == "3"); |
| | | // //} |
| | | |
| | | // var stock = _VVStockInfoRepository.QueryFirst(x => x.carBodyID == item.carBodyID); |
| | | // var lockStock = _palletStockInfoRepository.QueryFirst(x => x.carBodyID == item.carBodyID); |
| | | // var location = _locationRepository.QueryFirst(x => x.LocationCode == stock.LocationCode); |
| | | // location.LocationStatus = (int)LocationEnum.InStockDisable; |
| | | // item.LockStatue = 1; |
| | | // lockStock.TaskStatus = 1; |
| | | // if (stationLists == null || stationLists.Count == 0) throw new Exception("åºåºç«å°æªé
ç½®ææªå¯ç¨"); |
| | | |
| | | // Dt_StationManager Outstation = null; |
| | | |
| | | // //if (stationLists.Count > 1) |
| | | // //{ |
| | | // // var Outtask = BaseDal.QueryData(x => x.Roadway == stationLists.FirstOrDefault().Roadway && x.TaskType == (int)TaskTypeEnum.Outbound).OrderByDescending(x => x.CreateDate).FirstOrDefault(); |
| | | // // if (Outtask != null) Outstation = stationLists.Where(x => x.stationChildCode != task.NextAddress && x.stationChildCode != Outtask.CurrentAddress).FirstOrDefault(); |
| | | // // else Outstation = stationLists.FirstOrDefault(); |
| | | // //} |
| | | // //else |
| | | // //{ |
| | | // Outstation = stationLists.FirstOrDefault(); |
| | | // //} |
| | | // //var stationInfo = stationInfos.FirstOrDefault(); |
| | | |
| | | // // å建并添å ä»»å¡å°æ°æ®åº |
| | | // hasTask = new Dt_Task |
| | | // { |
| | | // Grade = 1, |
| | | // Roadway = Outstation.Roadway, |
| | | // TargetAddress = "RB043", |
| | | // Dispatchertime = DateTime.Now, |
| | | // NextAddress = Outstation.stationChildCode, |
| | | // OrderNo = null, |
| | | // PalletCode = stock.PalletCode, |
| | | // PVI = stock.PVI, |
| | | // SourceAddress = stock.LocationCode, |
| | | // CurrentAddress = stock.LocationCode, |
| | | // TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | // TaskType = (int)TaskOutboundTypeEnum.Outbound, |
| | | // TaskNum = _taskRepository.GetTaskNo().Result, |
| | | // Creater = "System", |
| | | // CreateDate = DateTime.Now, |
| | | // TaskId = 0, |
| | | // }; |
| | | |
| | | // // å建任å¡ä¼ è¾ç¨çDTO对象 |
| | | // var taskDTO = CreateTaskDTO(hasTask); |
| | | |
| | | // // è·åWMS IPå°åç¨äºåéä»»å¡è¯·æ± |
| | | // var wmsIpAddress = GetWCSIpReceiveTask(); |
| | | // if (wmsIpAddress == null) |
| | | // { |
| | | // throw new InvalidOperationException("WMS IP æªé
ç½®"); |
| | | // } |
| | | |
| | | // var tasks = new List<WMSTaskDTO>() { taskDTO }; |
| | | // // åéä»»å¡è¯·æ±å°WMS |
| | | // var result = HttpHelper.PostAsync(wmsIpAddress, tasks.ToJsonString()).Result; |
| | | // WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | // if (content.Status) |
| | | // { |
| | | // _unitOfWorkManage.BeginTran(); |
| | | // // æ·»å ä»»å¡å°æ°æ®åº |
| | | // _taskRepository.AddData(hasTask); |
| | | // // æ´æ°åºä½ä½ç½®ç¶æä¸ºä¸å¯ç¨ |
| | | // _locationRepository.UpdateData(location); |
| | | // _MESLockInfoRepository.UpdateData(item); |
| | | // _palletStockInfoRepository.UpdateData(lockStock); |
| | | // _unitOfWorkManage.CommitTran(); |
| | | // } |
| | | //} |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ConsoleHelper.WriteErrorLine($"ï¼é误信æ¯ï¼" + ex.Message); |
| | | ConsoleHelper.WriteErrorLine($"æå¨é车åºè½¦é误信æ¯ï¼" + ex.Message); |
| | | } |
| | | ConsoleHelper.WriteSuccessLine($"ï¼" + DateTime.Now.ToString()); |
| | | ConsoleHelper.WriteSuccessLine($"æå¨é车ï¼" + DateTime.Now.ToString()); |
| | | } |
| | | |
| | | public Task StopAsync(CancellationToken cancellationToken) |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using Masuit.Tools; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Microsoft.Extensions.Logging; |
| | | using Quartz; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Core.Const; |
| | | using WIDESEA_DTO.WMS; |
| | | using WIDESEA_IServices; |
| | | using WIDESEAWCS_BasicInfoRepository; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | | namespace WIDESEA_StorageTaskServices |
| | | { |
| | | [DisallowConcurrentExecution] |
| | | public class BackgroundJob : IJob |
| | | { |
| | | private ILogger<BackgroundJob> _logger; |
| | | private IDt_PalletStockInfoRepository _palletStockInfoRepository; |
| | | private IDt_AreaInfoRepository _areaInfoRepository; //åºå |
| | | private IDt_TaskRepository _taskRepository; |
| | | private IDt_StationManagerRepository _stationManagerRepository; |
| | | private ISys_ConfigService _configService; |
| | | private ILocationInfoRepository _locationRepository; |
| | | private IVV_StockInfoRepository _VVStockInfoRepository; |
| | | private IUnitOfWorkManage _unitOfWorkManage; |
| | | private IDt_MESLockInfoRepository _MESLockInfoRepository; |
| | | |
| | | public BackgroundJob(ILogger<BackgroundJob> logger, IDt_PalletStockInfoRepository palletStockInfoRepository, IDt_AreaInfoRepository areaInfoRepository, IDt_TaskRepository taskRepository, IDt_StationManagerRepository stationManagerRepository, ISys_ConfigService configService, ILocationInfoRepository locationRepository, IVV_StockInfoRepository vVStockInfoRepository, IUnitOfWorkManage unitOfWorkManage, IDt_MESLockInfoRepository mESLockInfoRepository) |
| | | { |
| | | _logger = logger; |
| | | _palletStockInfoRepository = palletStockInfoRepository; |
| | | _areaInfoRepository = areaInfoRepository; |
| | | _taskRepository = taskRepository; |
| | | _stationManagerRepository = stationManagerRepository; |
| | | _configService = configService; |
| | | _locationRepository = locationRepository; |
| | | _VVStockInfoRepository = vVStockInfoRepository; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _MESLockInfoRepository = mESLockInfoRepository; |
| | | } |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | | { |
| | | try |
| | | { |
| | | //var area = _areaInfoRepository.QueryFirst(x => x.AreaCode == "GWSC1"); |
| | | |
| | | //if (area == null) { return; } |
| | | |
| | | //IDictionary<string, DtStockInfo>? stockInfos = _simpleCacheService.HashGetAll<DtStockInfo>(WIDESEA_Cache.CacheConst.Cache_DtStockInfo); |
| | | //List<DtStockInfo> stockInfoList = stockInfos.Values.ToList(); |
| | | |
| | | //var stockInfo = stockInfoList.Where(x => x.AreaCode == area.AreaCode && x.OutboundTime < DateTime.Now && x.IsFull == true) // è¿æ»¤æ¡ä»¶ |
| | | // .Where(x => x.LocationInfo != null && x.LocationInfo.LocationStatus == (int)LocationEnum.InStock && x.LocationInfo.AreaId == area.AreaID) // è¿æ»¤æ¡ä»¶ |
| | | // .OrderBy(x => x.OutboundTime) // æåº |
| | | // .ToList(); // è·å第ä¸ä¸ªå
ç´ |
| | | var lockInfo = _palletStockInfoRepository.Db.Queryable<Dt_MESLockInfo>() |
| | | //.Where(x => x.LockStatue == 0) |
| | | .Includes(x => x.CarBodyInfo) |
| | | .OrderBy(x => x.sequenceNo) // æåº |
| | | .ToList(); // è·å第ä¸ä¸ªå
ç´ |
| | | |
| | | |
| | | if (lockInfo.Where(x => x.LockStatue == 1).Count() > 10) return Task.CompletedTask; |
| | | if (lockInfo.Count == 0) return Task.CompletedTask; |
| | | |
| | | var lockCar = lockInfo.Where(x => x.LockStatue == 0).FirstOrDefault(); |
| | | if (lockCar == null) return Task.CompletedTask; |
| | | var hasTask = _taskRepository.QueryFirst(x => x.PalletCode == lockCar.CarBodyInfo.PalletCode); |
| | | if (hasTask != null) |
| | | { |
| | | Console.WriteLine("å·²åå¨åºåºä»»å¡"); |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | List<Dt_StationManager> stationLists = null; |
| | | if (lockCar.CarBodyInfo.CarType == 1) |
| | | { |
| | | stationLists = _stationManagerRepository.QueryData(x => x.RoadwayNo == lockCar.TCLine && x.stationType == 2 && x.stationStatus == "1" && x.stationArea == "3"); |
| | | } |
| | | else if (lockCar.CarBodyInfo.CarType == 2) |
| | | { |
| | | stationLists = _stationManagerRepository.QueryData(x => x.RoadwayNo == lockCar.TCLine && x.stationType == 2 && x.stationStatus == "1" && x.stationArea == "4"); |
| | | } |
| | | //else if (item.CarBodyInfo.CarType == 3) |
| | | //{ |
| | | // stationLists = _stationManagerRepository.QueryData(x => x.RoadwayNo == item.TCLine && x.stationType == 7 && x.stationStatus == "1" && x.stationArea == "3"); |
| | | //} |
| | | |
| | | var stock = _VVStockInfoRepository.QueryFirst(x => x.carBodyID == lockCar.carBodyID); |
| | | var lockStock = _palletStockInfoRepository.QueryFirst(x => x.carBodyID == lockCar.carBodyID); |
| | | var location = _locationRepository.QueryFirst(x => x.LocationCode == stock.LocationCode); |
| | | location.LocationStatus = (int)LocationEnum.InStockDisable; |
| | | lockCar.LockStatue = 1; |
| | | lockStock.TaskStatus = 1; |
| | | if (stationLists == null || stationLists.Count == 0) throw new Exception("åºåºç«å°æªé
ç½®ææªå¯ç¨"); |
| | | |
| | | Dt_StationManager Outstation = null; |
| | | |
| | | //if (stationLists.Count > 1) |
| | | //{ |
| | | // var Outtask = BaseDal.QueryData(x => x.Roadway == stationLists.FirstOrDefault().Roadway && x.TaskType == (int)TaskTypeEnum.Outbound).OrderByDescending(x => x.CreateDate).FirstOrDefault(); |
| | | // if (Outtask != null) Outstation = stationLists.Where(x => x.stationChildCode != task.NextAddress && x.stationChildCode != Outtask.CurrentAddress).FirstOrDefault(); |
| | | // else Outstation = stationLists.FirstOrDefault(); |
| | | //} |
| | | //else |
| | | //{ |
| | | Outstation = stationLists.FirstOrDefault(); |
| | | //} |
| | | //var stationInfo = stationInfos.FirstOrDefault(); |
| | | |
| | | // å建并添å ä»»å¡å°æ°æ®åº |
| | | hasTask = new Dt_Task |
| | | { |
| | | Grade = 1, |
| | | Roadway = Outstation.Roadway, |
| | | TargetAddress = "RB043", |
| | | Dispatchertime = DateTime.Now, |
| | | NextAddress = Outstation.stationChildCode, |
| | | OrderNo = null, |
| | | PalletCode = stock.PalletCode, |
| | | PVI = stock.PVI, |
| | | SourceAddress = stock.LocationCode, |
| | | CurrentAddress = stock.LocationCode, |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | TaskType = (int)TaskOutboundTypeEnum.Outbound, |
| | | TaskNum = _taskRepository.GetTaskNo().Result, |
| | | Creater = "System", |
| | | CreateDate = DateTime.Now, |
| | | TaskId = 0, |
| | | }; |
| | | |
| | | // å建任å¡ä¼ è¾ç¨çDTO对象 |
| | | var taskDTO = CreateTaskDTO(hasTask); |
| | | |
| | | // è·åWMS IPå°åç¨äºåéä»»å¡è¯·æ± |
| | | var wmsIpAddress = GetWCSIpReceiveTask(); |
| | | if (wmsIpAddress == null) |
| | | { |
| | | throw new InvalidOperationException("WMS IP æªé
ç½®"); |
| | | } |
| | | |
| | | var tasks = new List<WMSTaskDTO>() { taskDTO }; |
| | | // åéä»»å¡è¯·æ±å°WMS |
| | | var result = HttpHelper.PostAsync(wmsIpAddress, tasks.ToJsonString()).Result; |
| | | WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | if (content.Status) |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | // æ·»å ä»»å¡å°æ°æ®åº |
| | | _taskRepository.AddData(hasTask); |
| | | // æ´æ°åºä½ä½ç½®ç¶æä¸ºä¸å¯ç¨ |
| | | _locationRepository.UpdateData(location); |
| | | _MESLockInfoRepository.UpdateData(lockCar); |
| | | _palletStockInfoRepository.UpdateData(lockStock); |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | |
| | | //foreach (var item in lockInfo) |
| | | //{ |
| | | // var hasTask = _taskRepository.QueryFirst(x => x.PalletCode == item.CarBodyInfo.PalletCode); |
| | | // if (hasTask != null) |
| | | // { |
| | | // Console.WriteLine("å·²åå¨åºåºä»»å¡"); |
| | | // continue; |
| | | // } |
| | | |
| | | // List<Dt_StationManager> stationLists = null; |
| | | // if (item.CarBodyInfo.CarType == 1) |
| | | // { |
| | | // stationLists = _stationManagerRepository.QueryData(x => x.RoadwayNo == item.TCLine && x.stationType == 2 && x.stationStatus == "1" && x.stationArea == "3"); |
| | | // } |
| | | // else if (item.CarBodyInfo.CarType == 2) |
| | | // { |
| | | // stationLists = _stationManagerRepository.QueryData(x => x.RoadwayNo == item.TCLine && x.stationType == 2 && x.stationStatus == "1" && x.stationArea == "4"); |
| | | // } |
| | | // //else if (item.CarBodyInfo.CarType == 3) |
| | | // //{ |
| | | // // stationLists = _stationManagerRepository.QueryData(x => x.RoadwayNo == item.TCLine && x.stationType == 7 && x.stationStatus == "1" && x.stationArea == "3"); |
| | | // //} |
| | | |
| | | // var stock = _VVStockInfoRepository.QueryFirst(x => x.carBodyID == item.carBodyID); |
| | | // var lockStock = _palletStockInfoRepository.QueryFirst(x => x.carBodyID == item.carBodyID); |
| | | // var location = _locationRepository.QueryFirst(x => x.LocationCode == stock.LocationCode); |
| | | // location.LocationStatus = (int)LocationEnum.InStockDisable; |
| | | // item.LockStatue = 1; |
| | | // lockStock.TaskStatus = 1; |
| | | // if (stationLists == null || stationLists.Count == 0) throw new Exception("åºåºç«å°æªé
ç½®ææªå¯ç¨"); |
| | | |
| | | // Dt_StationManager Outstation = null; |
| | | |
| | | // //if (stationLists.Count > 1) |
| | | // //{ |
| | | // // var Outtask = BaseDal.QueryData(x => x.Roadway == stationLists.FirstOrDefault().Roadway && x.TaskType == (int)TaskTypeEnum.Outbound).OrderByDescending(x => x.CreateDate).FirstOrDefault(); |
| | | // // if (Outtask != null) Outstation = stationLists.Where(x => x.stationChildCode != task.NextAddress && x.stationChildCode != Outtask.CurrentAddress).FirstOrDefault(); |
| | | // // else Outstation = stationLists.FirstOrDefault(); |
| | | // //} |
| | | // //else |
| | | // //{ |
| | | // Outstation = stationLists.FirstOrDefault(); |
| | | // //} |
| | | // //var stationInfo = stationInfos.FirstOrDefault(); |
| | | |
| | | // // å建并添å ä»»å¡å°æ°æ®åº |
| | | // hasTask = new Dt_Task |
| | | // { |
| | | // Grade = 1, |
| | | // Roadway = Outstation.Roadway, |
| | | // TargetAddress = "RB043", |
| | | // Dispatchertime = DateTime.Now, |
| | | // NextAddress = Outstation.stationChildCode, |
| | | // OrderNo = null, |
| | | // PalletCode = stock.PalletCode, |
| | | // PVI = stock.PVI, |
| | | // SourceAddress = stock.LocationCode, |
| | | // CurrentAddress = stock.LocationCode, |
| | | // TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | // TaskType = (int)TaskOutboundTypeEnum.Outbound, |
| | | // TaskNum = _taskRepository.GetTaskNo().Result, |
| | | // Creater = "System", |
| | | // CreateDate = DateTime.Now, |
| | | // TaskId = 0, |
| | | // }; |
| | | |
| | | // // å建任å¡ä¼ è¾ç¨çDTO对象 |
| | | // var taskDTO = CreateTaskDTO(hasTask); |
| | | |
| | | // // è·åWMS IPå°åç¨äºåéä»»å¡è¯·æ± |
| | | // var wmsIpAddress = GetWCSIpReceiveTask(); |
| | | // if (wmsIpAddress == null) |
| | | // { |
| | | // throw new InvalidOperationException("WMS IP æªé
ç½®"); |
| | | // } |
| | | |
| | | // var tasks = new List<WMSTaskDTO>() { taskDTO }; |
| | | // // åéä»»å¡è¯·æ±å°WMS |
| | | // var result = HttpHelper.PostAsync(wmsIpAddress, tasks.ToJsonString()).Result; |
| | | // WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result); |
| | | // if (content.Status) |
| | | // { |
| | | // _unitOfWorkManage.BeginTran(); |
| | | // // æ·»å ä»»å¡å°æ°æ®åº |
| | | // _taskRepository.AddData(hasTask); |
| | | // // æ´æ°åºä½ä½ç½®ç¶æä¸ºä¸å¯ç¨ |
| | | // _locationRepository.UpdateData(location); |
| | | // _MESLockInfoRepository.UpdateData(item); |
| | | // _palletStockInfoRepository.UpdateData(lockStock); |
| | | // _unitOfWorkManage.CommitTran(); |
| | | // } |
| | | //} |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ConsoleHelper.WriteErrorLine($"æå¨é车åºè½¦é误信æ¯ï¼" + ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | ConsoleHelper.WriteSuccessLine($"æå¨é车ï¼" + DateTime.Now.ToString()); |
| | | } |
| | | |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å建任å¡å®ä¾ |
| | | /// </summary> |
| | | private Dt_Task CreateTask(DtStockInfo stockInfo, string position, int tag) |
| | | { |
| | | return new Dt_Task |
| | | { |
| | | Grade = 1, |
| | | Roadway = stockInfo.LocationInfo.RoadwayNo, |
| | | TargetAddress = position, |
| | | Dispatchertime = DateTime.Now, |
| | | NextAddress = position, |
| | | OrderNo = null, |
| | | PalletCode = stockInfo.PalletCode, |
| | | SourceAddress = stockInfo.LocationCode, |
| | | CurrentAddress = stockInfo.LocationCode, |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | TaskType = tag, |
| | | TaskNum = _taskRepository.GetTaskNo().Result, |
| | | Creater = "System", // ä¿®æ£æ¼åé误 |
| | | CreateDate = DateTime.Now, |
| | | TaskId = 0, |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å建任å¡DTO |
| | | /// </summary> |
| | | private WMSTaskDTO CreateTaskDTO(Dt_Task task) |
| | | { |
| | | return new WMSTaskDTO |
| | | { |
| | | TaskNum = task.TaskNum.Value, |
| | | Grade = task.Grade.Value, |
| | | PalletCode = task.PalletCode, |
| | | RoadWay = task.Roadway, |
| | | SourceAddress = task.SourceAddress, |
| | | TargetAddress = task.TargetAddress, |
| | | TaskState = task.TaskState.Value, |
| | | Id = 0, |
| | | TaskType = task.TaskType, |
| | | pvi = task.PVI, |
| | | NextAddress = task.NextAddress |
| | | |
| | | }; |
| | | } |
| | | |
| | | private string GetWCSIpReceiveTask() |
| | | { |
| | | var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); |
| | | var wmsBase = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.WCSIPAddress)?.ConfigValue; |
| | | var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.ReceiveTask)?.ConfigValue; |
| | | if (wmsBase == null || ipAddress == null) |
| | | { |
| | | return null; |
| | | } |
| | | return wmsBase + ipAddress; |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | using Microsoft.AspNetCore.Builder; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using WIDESEA.QuartzJob; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.Helper; |
| | | |
| | | namespace WIDESEA_StorageTaskServices |
| | | { |
| | | /// <summary> |
| | | /// Quartz å¯å¨æå¡ |
| | | /// </summary> |
| | | public static class QuartzJobMiddleWare |
| | | { |
| | | public static void UseQuartzJobMildd(this IApplicationBuilder app) |
| | | { |
| | | if (app == null) throw new ArgumentNullException(nameof(app)); |
| | | var schedulerCenter = app.ApplicationServices.GetService(typeof(ISchedulerCenter)) as ISchedulerCenter; |
| | | try |
| | | { |
| | | var allQzServices = new List<TasksQz>() |
| | | { |
| | | new TasksQz() |
| | | { |
| | | Id = 1, |
| | | AssemblyName = "WIDESEA_StorageTaskServices", |
| | | ClassName = "BackgroundJob", |
| | | CreateTime = DateTime.Now, |
| | | IntervalSecond = 10, |
| | | IsDeleted = false, |
| | | IsStart = false, |
| | | JobGroup = "WIDESEA_StorageTaskServices", |
| | | Name = "BackgroundJob", |
| | | TriggerType = 0 |
| | | } |
| | | }; |
| | | |
| | | //if(App.HostEnvironment.IsDevelopment()) |
| | | //{ |
| | | // return; |
| | | //} |
| | | foreach (var item in allQzServices) |
| | | { |
| | | var ResuleModel = schedulerCenter.AddScheduleJobAsync(item).Result; |
| | | if (ResuleModel.Status) |
| | | { |
| | | ConsoleHelper.WriteSuccessLine($"{item.ClassName}å¯å¨æå"); |
| | | } |
| | | else |
| | | { |
| | | Console.Out.WriteLine($"QuartzNetJob{item.Name}å¯å¨å¤±è´¥ï¼é误信æ¯ï¼{ResuleModel.Message}"); |
| | | } |
| | | } |
| | | schedulerCenter.StartScheduleAsync(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Quartz" Version="3.16.1" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\LogLibrary\LogLibrary.csproj" /> |
| | | <ProjectReference Include="..\WIDESEA_IBusinessServices\WIDESEA_IBusinessServices.csproj" /> |
| | | <ProjectReference Include="..\WIDESEA_IStorageBasicService\WIDESEA_IStorageBasicServices.csproj" /> |
| | |
| | | using Swashbuckle.AspNetCore.SwaggerGen; |
| | | using Microsoft.OpenApi.Models; |
| | | using WIDESEA_StorageTaskServices; |
| | | using Quartz.Spi; |
| | | using WIDESEA.QuartzJob; |
| | | |
| | | var builder = WebApplication.CreateBuilder(args); |
| | | |
| | |
| | | |
| | | builder.Services.AddSwaggerSetup(); |
| | | |
| | | builder.Services.AddJobSetup();//ä»»å¡è°åº¦ å¯å¨æå¡ |
| | | |
| | | builder.Services.AddSingleton<IJobFactory, JobFactory>(); |
| | | builder.Services.AddTransient<BackgroundJob>();//Job使ç¨ç¬æ¶ä¾èµæ³¨å
¥ |
| | | builder.Services.AddSingleton<ISchedulerCenter, SchedulerCenterServer>(); |
| | | |
| | | builder.Services.AddHttpContextSetup(); |
| | | |
| | |
| | | |
| | | var app = builder.Build(); |
| | | |
| | | app.UseQuartzJobMildd(); |
| | | // 3ãé
ç½®ä¸é´ä»¶ |
| | | app.UseMiniProfiler();//æ§è½åæå¨ |
| | | app.ConfigureApplication();//é
ç½®æä»¶ |