From fc9cba5f058089887aa7061d2e6b4006b9e04a9a Mon Sep 17 00:00:00 2001
From: 陈勇 <竞男@ASUNA>
Date: 星期二, 10 三月 2026 09:46:43 +0800
Subject: [PATCH] 同步
---
项目代码/WMS/WMSServer/WIDESEA_Core/WIDESEA_Core.csproj | 2
项目代码/WCS/WCSServer/WIDESEAWCS_Tasks/TT/CommonConveyorLineTTJob.cs | 43
项目代码/WMS/WMSServer/WIDESEA_StorageTaskServices/AutoTask/BackgroundJob.cs | 327 ++++++++++
项目代码/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/WCSService.cs | 3
项目代码/WCS/WCSServer/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs | 2
项目代码/WMS/WMSServer/WIDESEA_Model/Models/BasicInfo/Dt_MESLockInfo_hty.cs | 73 ++
项目代码/WMS/WMSServer/WIDESEA_Core/Quartz/JobFactory.cs | 51 +
项目代码/WMS/WMSServer/WIDESEA_Core/Quartz/ISchedulerCenter.cs | 71 ++
项目代码/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/Partial/Queue.cs | 10
项目代码/WMS/WMSServer/WIDESEA_Core/Quartz/TaskInfoDto.cs | 38 +
项目代码/WCS/WCSServer/WIDESEAWCS_Core/BaseRepository/RepositoryBase.cs | 2
项目代码/WMS/WMSServer/WIDESEA_Core/Quartz/TasksQz.cs | 80 ++
项目代码/WMS/WMSServer/WIDESEA_Model/Models/BasicModel/Stock/VV_StockInfo.cs | 2
项目代码/WMS/WMSServer/WIDESEA_StorageTaskServices/AutoTask/AspNetCoreSchedule.cs | 327 ++++++---
项目代码/WMS/WMSServer/WIDESEA_Core/Quartz/ResponseContent.cs | 45 +
项目代码/WMS/WMSServer/WIDESEA_Core/Quartz/SchedulerCenterServer.cs | 470 ++++++++++++++
项目代码/WMS/WMSServer/WIDESEA_Core/Quartz/JobSetup.cs | 26
项目代码/WMS/WMSServer/WIDESEA_WMSServer/Program.cs | 8
项目代码/WCS/WCSServer/WIDESEAWCS_Tasks/ConveyorLineJobTZ/CommonConveyorLineTZJob.cs | 1
项目代码/WMS/WMSServer/WIDESEA_Model/Models/BasicModel/Stock/VV_MesLockInfo.cs | 216 ++++++
项目代码/WMS/WMSServer/WIDESEA_StoragIntegrationServices/MES/Partial/removeWorkOrderInfo.cs | 3
项目代码/WMS/WMSServer/WIDESEA_StorageTaskServices/AutoTask/QuartzJobMildd.cs | 64 ++
项目代码/WMS/WMSServer/WIDESEA_StorageTaskServices/WIDESEA_StorageTaskServices.csproj | 4
项目代码/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/Partial/TZPassZZ.cs | 10
项目代码/WCS/WCSServer/WIDESEAWCS_ITaskInfoService/ITaskService.cs | 2
项目代码/WCS/WCSServer/WIDESEAWCS_TaskInfoService/TaskService.cs | 6
26 files changed, 1,742 insertions(+), 144 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Core/BaseRepository/RepositoryBase.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Core/BaseRepository/RepositoryBase.cs"
index da6b068..883b209 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Core/BaseRepository/RepositoryBase.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Core/BaseRepository/RepositoryBase.cs"
@@ -57,12 +57,10 @@
};
iTenant.AddConnection(connectionConfig);
}
-
return iTenant.GetConnection(tenant.TenantId);
}
}
}
-
return db;
}
}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_ITaskInfoService/ITaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_ITaskInfoService/ITaskService.cs"
index fbf45cd..77d4147 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_ITaskInfoService/ITaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_ITaskInfoService/ITaskService.cs"
@@ -229,7 +229,7 @@
/// 灏嗕换鍔$姸鎬佷慨鏀逛负涓嬩竴涓姸鎬�
/// </summary>
/// <param name="taskNum">浠诲姟鍙�</param>
- WebResponseContent UpdateTaskStatusToNext(int taskNum);
+ WebResponseContent UpdateTaskStatusToNext(int taskNum, int taskStatus = -1);
WebResponseContent TCSendTask([NotNull] Dt_Task task, string Position);
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_TaskInfoService/TaskService.cs"
index e57cee0..c2a3cde 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -380,12 +380,16 @@
/// 灏嗕换鍔$姸鎬佷慨鏀逛负涓嬩竴涓姸鎬�
/// </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);
}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs"
index eaab7f1..30adf7f 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs"
@@ -210,7 +210,7 @@
}
finally
{
- WriteDebug("CommonConveyorLineJob", "test");
+ //WriteDebug("CommonConveyorLineJob", "test");
//Console.Out.WriteLine(DateTime.Now);
}
return;
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Tasks/ConveyorLineJobTZ/CommonConveyorLineTZJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Tasks/ConveyorLineJobTZ/CommonConveyorLineTZJob.cs"
index 37a26d6..c7ecc34 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Tasks/ConveyorLineJobTZ/CommonConveyorLineTZJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Tasks/ConveyorLineJobTZ/CommonConveyorLineTZJob.cs"
@@ -330,7 +330,6 @@
}
finally
{
- WriteDebug("CommonConveyorLineTZJob", "test");
//Console.Out.WriteLine(DateTime.Now);
}
return;
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Tasks/TT/CommonConveyorLineTTJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Tasks/TT/CommonConveyorLineTTJob.cs"
index 9fc8e9d..344a59d 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Tasks/TT/CommonConveyorLineTTJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WCSServer/WIDESEAWCS_Tasks/TT/CommonConveyorLineTTJob.cs"
@@ -105,11 +105,24 @@
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")
@@ -120,18 +133,18 @@
{
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);//妯Щ鏈鸿浇璐ф斁杞︿俊鍙�
@@ -144,9 +157,13 @@
{
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
{
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/ISchedulerCenter.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/ISchedulerCenter.cs"
new file mode 100644
index 0000000..5d250f6
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/ISchedulerCenter.cs"
@@ -0,0 +1,71 @@
+锘縰sing 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);
+ }
+}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/JobFactory.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/JobFactory.cs"
new file mode 100644
index 0000000..6ace563
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/JobFactory.cs"
@@ -0,0 +1,51 @@
+锘縰sing 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();
+ }
+
+ }
+ }
+}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/JobSetup.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/JobSetup.cs"
new file mode 100644
index 0000000..e71cb53
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/JobSetup.cs"
@@ -0,0 +1,26 @@
+锘縰sing 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>();
+ }
+ }
+}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/ResponseContent.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/ResponseContent.cs"
new file mode 100644
index 0000000..3029388
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/ResponseContent.cs"
@@ -0,0 +1,45 @@
+锘縰sing 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;
+ }
+ }
+}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/SchedulerCenterServer.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/SchedulerCenterServer.cs"
new file mode 100644
index 0000000..733cd88
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/SchedulerCenterServer.cs"
@@ -0,0 +1,470 @@
+锘縰sing 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
+ {
+ // 浠嶧actory涓幏鍙朣cheduler瀹炰緥
+ 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>
+ /// 娣诲姞涓�涓鍒掍换鍔★紙鏄犲皠绋嬪簭闆嗘寚瀹欼Job瀹炵幇绫伙級
+ /// </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("瑙﹀彂鍣↖D:{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 = "姝e父";
+ break;
+ case "-1":
+ state = "涓嶅瓨鍦�";
+ break;
+ case "BLOCKED":
+ state = "闃诲";
+ break;
+ case "COMPLETE":
+ state = "瀹屾垚";
+ break;
+ case "ERROR":
+ state = "鍑洪敊";
+ break;
+ case "NONE":
+ state = "涓嶅瓨鍦�";
+ break;
+ case "NORMAL":
+ state = "姝e父";
+ 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;
+ }
+ }
+}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/TaskInfoDto.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/TaskInfoDto.cs"
new file mode 100644
index 0000000..69f43b2
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/TaskInfoDto.cs"
@@ -0,0 +1,38 @@
+锘縰sing 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>
+ /// 瑙﹀彂鍣↖D
+ /// </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; }
+ }
+}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/TasksQz.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/TasksQz.cs"
new file mode 100644
index 0000000..66377cc
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/Quartz/TasksQz.cs"
@@ -0,0 +1,80 @@
+锘縰sing 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>
+ /// 浠诲姟鎵�鍦―LL瀵瑰簲鐨勭▼搴忛泦鍚嶇О
+ /// </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銆乻imple 1銆乧ron锛�
+ /// </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; }
+ }
+}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/WIDESEA_Core.csproj" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/WIDESEA_Core.csproj"
index ebc0ae3..f1ad7ee 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/WIDESEA_Core.csproj"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Core/WIDESEA_Core.csproj"
@@ -25,6 +25,7 @@
<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" />
@@ -36,6 +37,7 @@
<ItemGroup>
<Folder Include="Attribute\" />
<Folder Include="ServiceExtensions\" />
+ <Folder Include="Quartz\" />
</ItemGroup>
</Project>
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Model/Models/BasicInfo/Dt_MESLockInfo_hty.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Model/Models/BasicInfo/Dt_MESLockInfo_hty.cs"
new file mode 100644
index 0000000..32d802c
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Model/Models/BasicInfo/Dt_MESLockInfo_hty.cs"
@@ -0,0 +1,73 @@
+锘縰sing 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; }
+
+
+ }
+}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Model/Models/BasicModel/Stock/VV_MesLockInfo.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Model/Models/BasicModel/Stock/VV_MesLockInfo.cs"
new file mode 100644
index 0000000..29d2e2d
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Model/Models/BasicModel/Stock/VV_MesLockInfo.cs"
@@ -0,0 +1,216 @@
+锘縰sing 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; }
+ }
+}
\ No newline at end of file
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Model/Models/BasicModel/Stock/VV_StockInfo.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Model/Models/BasicModel/Stock/VV_StockInfo.cs"
index ff3d14b..59d38a5 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Model/Models/BasicModel/Stock/VV_StockInfo.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_Model/Models/BasicModel/Stock/VV_StockInfo.cs"
@@ -9,7 +9,7 @@
namespace WIDESEA_Model.Models
{
- [SugarTable(nameof(VV_StockInfo), "搴撳瓨淇℃伅")]
+ //[SugarTable(nameof(VV_StockInfo), "搴撳瓨淇℃伅")]
public class VV_StockInfo
{
/// <summary>
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/MES/Partial/removeWorkOrderInfo.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/MES/Partial/removeWorkOrderInfo.cs"
index c75058a..06f4032 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/MES/Partial/removeWorkOrderInfo.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/MES/Partial/removeWorkOrderInfo.cs"
@@ -44,6 +44,9 @@
{
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);
}
}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/Partial/Queue.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/Partial/Queue.cs"
index 7ca7cb4..af8ed5f 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/Partial/Queue.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/Partial/Queue.cs"
@@ -9,6 +9,7 @@
using WIDESEA_Common.MES;
using WIDESEA_Core;
using WIDESEA_DTO;
+using WIDESEA_StorageBasicRepository;
namespace WIDESEA_StoragIntegrationServices
{
@@ -49,7 +50,7 @@
//杩囩偣淇℃伅
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);
@@ -64,6 +65,13 @@
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)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/Partial/TZPassZZ.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/Partial/TZPassZZ.cs"
index 5231589..37d8417 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/Partial/TZPassZZ.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/Partial/TZPassZZ.cs"
@@ -17,7 +17,7 @@
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);
@@ -30,20 +30,20 @@
//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();
}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/WCSService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/WCSService.cs"
index 7ae1824..f4907a4 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/WCSService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StoragIntegrationServices/WCS/WCSService.cs"
@@ -32,7 +32,7 @@
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;
@@ -45,6 +45,7 @@
_roadWayRepository = roadWayRepository;
_taskService = taskService;
_unitOfWorkManage = unitOfWorkManage;
+ _mesLockInfoRepository = mesLockInfoRepository;
}
}
}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StorageTaskServices/AutoTask/AspNetCoreSchedule.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StorageTaskServices/AutoTask/AspNetCoreSchedule.cs"
index 9463982..8cde817 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StorageTaskServices/AutoTask/AspNetCoreSchedule.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StorageTaskServices/AutoTask/AspNetCoreSchedule.cs"
@@ -1,7 +1,9 @@
锘縰sing 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;
@@ -13,36 +15,27 @@
{
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;
}
@@ -50,6 +43,17 @@
{
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; }
@@ -69,107 +73,198 @@
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)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StorageTaskServices/AutoTask/BackgroundJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StorageTaskServices/AutoTask/BackgroundJob.cs"
new file mode 100644
index 0000000..710ef80
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StorageTaskServices/AutoTask/BackgroundJob.cs"
@@ -0,0 +1,327 @@
+锘縰sing 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;
+ }
+ }
+}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StorageTaskServices/AutoTask/QuartzJobMildd.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StorageTaskServices/AutoTask/QuartzJobMildd.cs"
new file mode 100644
index 0000000..4801322
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StorageTaskServices/AutoTask/QuartzJobMildd.cs"
@@ -0,0 +1,64 @@
+锘�
+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;
+ }
+ }
+ }
+}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StorageTaskServices/WIDESEA_StorageTaskServices.csproj" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StorageTaskServices/WIDESEA_StorageTaskServices.csproj"
index 8b2f84d..63851e4 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StorageTaskServices/WIDESEA_StorageTaskServices.csproj"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_StorageTaskServices/WIDESEA_StorageTaskServices.csproj"
@@ -15,6 +15,10 @@
</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" />
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_WMSServer/Program.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_WMSServer/Program.cs"
index b9b5901..b66dbe8 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_WMSServer/Program.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServer/WIDESEA_WMSServer/Program.cs"
@@ -20,6 +20,8 @@
using Swashbuckle.AspNetCore.SwaggerGen;
using Microsoft.OpenApi.Models;
using WIDESEA_StorageTaskServices;
+using Quartz.Spi;
+using WIDESEA.QuartzJob;
var builder = WebApplication.CreateBuilder(args);
@@ -54,7 +56,10 @@
builder.Services.AddSwaggerSetup();
-builder.Services.AddJobSetup();//任务调度 启动服务
+
+builder.Services.AddSingleton<IJobFactory, JobFactory>();
+builder.Services.AddTransient<BackgroundJob>();//Job使用瞬时依赖注入
+builder.Services.AddSingleton<ISchedulerCenter, SchedulerCenterServer>();
builder.Services.AddHttpContextSetup();
@@ -115,6 +120,7 @@
var app = builder.Build();
+app.UseQuartzJobMildd();
// 3、配置中间件
app.UseMiniProfiler();//性能分析器
app.ConfigureApplication();//配置文件
--
Gitblit v1.9.3