From 490e62a0f7b33249dabb74e000725bd8555ca186 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期日, 22 三月 2026 12:56:52 +0800
Subject: [PATCH] 添加3F、4F循环任务;平库表添加状态和托盘号;海康AGV任务反馈添加更新平库货位信息
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/Dt_StationInfo.cs | 12 +++
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs | 18 ++++
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/ScheduledTaskJob.cs | 199 +++++++++++++++++++++++++++++++++++++++++++++++++
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 4
4 files changed, 230 insertions(+), 3 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/Dt_StationInfo.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/Dt_StationInfo.cs"
index 754cbff..42ed8e3 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/Dt_StationInfo.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Model/Models/BasicInfo/Dt_StationInfo.cs"
@@ -24,6 +24,12 @@
public string StationCode { get; set; }
/// <summary>
+ /// 鎵樼洏缂栧彿
+ /// </summary>
+ [SugarColumn(IsNullable = true, Length = 30, ColumnDescription = "鎵樼洏缂栧彿")]
+ public string PalletCode { get; set; }
+
+ /// <summary>
/// 绔欏彴鍚嶇О
/// </summary>
[SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "绔欏彴鍚嶇О")]
@@ -39,6 +45,12 @@
public int StationType { get; set; }
/// <summary>
+ /// 绔欏彴鐘舵��
+ /// </summary>
+ [SugarColumn(IsNullable = false, ColumnDescription = "绔欏彴鐘舵��")]
+ public int StationStatus { get; set; }
+
+ /// <summary>
/// 鎵�鍦ㄦゼ灞�,AA鏄�1妤硷紝BB鏄�2妤硷紝CC鏄�3妤硷紝DD鏄�4妤硷紝EE鏄�5妤硷紝FF鏄�6妤�
/// </summary>
[SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "鎵�鍦ㄦゼ灞�")]
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
index 914c4fe..b13e3a4 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
@@ -113,14 +113,14 @@
case "end"://浠诲姟瀹屾垚閫氱煡
{
///鍒ゆ柇浠诲姟鏄惁璺熻澶囨湁鍏�
- if(task.TaskType== TaskTypeEnum.RK3F.ObjToInt()&& task.TaskState == (int)TaskStatusEnum.CheckPalletCodeFinish)
+ if (task.TaskType == TaskTypeEnum.RK3F.ObjToInt() && task.TaskState == (int)TaskStatusEnum.CheckPalletCodeFinish)
{
var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "TSJ") as OtherDevice;
if (device == null) task.ExceptionMessage = "鏈壘鍒版彁鍗囨満淇℃伅";
else
{
if (device.IsConnected)
- device.SetValue(HoistEnum.Inboundboxon,1);
+ device.SetValue(HoistEnum.Inboundboxon, 1);
else
task.ExceptionMessage = "鎻愬崌鏈轰俊鎭澶囪繛鎺ュけ璐�";
}
@@ -378,6 +378,20 @@
dt_HKLocationInfo.LocationStatus = locationStatusEnum.ObjToInt();
_hKLocationInfoService.Repository.UpdateData(dt_HKLocationInfo);
}
+ Dt_StationInfo? stationInfo = _stationInfo.Repository.QueryFirst(x => x.StationCode == locationCode);
+ if (stationInfo != null)
+ {
+ if (locationStatusEnum == LocationStatusEnum.Free) //濡傛灉璧风偣瀹屾垚灏辩粰璐т綅璧嬪�兼墭鐩樺彿
+ {
+ stationInfo.PalletCode = "";
+ }
+ else
+ {
+ stationInfo.PalletCode = palletCode;
+ }
+ stationInfo.StationStatus = locationStatusEnum.ObjToInt();
+ _stationInfo.UpdateData(stationInfo);
+ }
}
else if (deviceTypeEnum == DeviceTypeEnum.YuanLiJuHe)
{
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
index cedaf63..297e7a7 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -55,6 +55,7 @@
private readonly IRepository<Dt_TaskExecuteDetail> _taskExecuteDetailRepository;
private readonly IApiInfoService _apiInfoService;
private readonly IStationMangerService _stationMangerService;
+ private readonly IStationInfoService _stationInfo;
private readonly IMapper _mapper;
private Dictionary<string, OrderByType> _taskOrderBy = new()
@@ -74,7 +75,7 @@
/// </summary>
public IRepository<Dt_Task> Repository => BaseDal;
- public TaskService(IRepository<Dt_Task> BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, IRepository<Dt_TaskExecuteDetail> taskExecuteDetailRepository, IMapper mapper, IKLSLocationInfoService kLSLocationInfoService, IRGVLocationInfoService rGVLocationInfoService, IHKLocationInfoService hKLocationInfoService, IApiInfoService apiInfoService, ITrackloginfoService trackloginfoService, IStationMangerService stationMangerService) : base(BaseDal)
+ public TaskService(IRepository<Dt_Task> BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, IRepository<Dt_TaskExecuteDetail> taskExecuteDetailRepository, IMapper mapper, IKLSLocationInfoService kLSLocationInfoService, IRGVLocationInfoService rGVLocationInfoService, IHKLocationInfoService hKLocationInfoService, IApiInfoService apiInfoService, ITrackloginfoService trackloginfoService, IStationMangerService stationMangerService, IStationInfoService stationInfo) : base(BaseDal)
{
_routerService = routerService;
_taskExecuteDetailService = taskExecuteDetailService;
@@ -86,6 +87,7 @@
_apiInfoService = apiInfoService;
_trackloginfoService = trackloginfoService;
_stationMangerService = stationMangerService;
+ _stationInfo = stationInfo;
}
public WebResponseContent ReceiveWMSTask([NotNull] List<WMSTasksDTO> taskDTOs)
{
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/ScheduledTaskJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/ScheduledTaskJob.cs"
new file mode 100644
index 0000000..b83c5ec
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/ScheduledTaskJob.cs"
@@ -0,0 +1,199 @@
+锘縰sing Quartz;
+using SqlSugar.Extensions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection.Metadata;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEAWCS_Common;
+using WIDESEAWCS_Common.LocationEnum;
+using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_Core.BaseRepository;
+using WIDESEAWCS_DTO.WMS;
+using WIDESEAWCS_IBasicInfoService;
+using WIDESEAWCS_ITaskInfoService;
+using WIDESEAWCS_Model.Models;
+using WIDESEAWCS_QuartzJob;
+
+namespace WIDESEAWCS_Tasks
+{
+ public partial class ScheduledTaskJob : JobBase, IJob
+ {
+ private readonly ITaskService _taskService;
+ private readonly IHKLocationInfoService _HKLocationInfoService;
+ private readonly IStationInfoService _StationInfoService;
+ private readonly IStationMangerService _stationMangerService;
+ private readonly IUnitOfWorkManage _unitOfWorkManage;
+ public ScheduledTaskJob(ITaskService taskService, IApiInfoService apiInfoService, IHKLocationInfoService hKLocationInfoService, IStationInfoService stationInfoService, IStationMangerService stationMangerService, IUnitOfWorkManage unitOfWorkManage)
+ {
+ _taskService = taskService;
+ _HKLocationInfoService = hKLocationInfoService;
+ _StationInfoService = stationInfoService;
+ _stationMangerService = stationMangerService;
+ _unitOfWorkManage = unitOfWorkManage;
+ }
+
+ public Task Execute(IJobExecutionContext context)
+ {
+ try
+ {
+ #region 涓夋ゼ鑷姩浠诲姟
+ List<string> StationCodes = new() { "0321935CC0329515", "0321935CC0329015", "0321935CC0328485", "0321935CC0328005" };
+ var stations = _StationInfoService.Repository.QueryData(x => StationCodes.Contains(x.StationCode));
+ #region 鍏ユ彁鍗囨満浠诲姟
+ var station = stations.FirstOrDefault(x => x.StationStatus == (int)LocationStatusEnum.InStock);
+ if (station != null)
+ {
+ var tasknum = _taskService.GetTaskNum(nameof(SequenceEnum.SeqTaskNum));
+ Dt_Task dt_Task = new Dt_Task()
+ {
+ TaskNum = tasknum,
+ WMSTaskNum = "GP" + tasknum,
+ Grade = 60,
+ PalletCode = station.PalletCode,
+ Roadway = "",
+ TaskState = (int)TaskStatusEnum.New,
+ TaskType = TaskTypeEnum.RK3F.ObjToInt(),
+ SourceAddress = station.StationCode,
+ CurrentAddress = station.StationCode,
+ NextAddress = "TSJR3F",
+ TargetAddress = "TSJR3F",
+ Creater = "WCS",
+ };
+ var content = _taskService.SendHIKROBOTTask(dt_Task);
+ if (content.Status)
+ {
+ dt_Task.TaskState = (int)TaskStatusEnum.Execut;
+ dt_Task.Dispatchertime = DateTime.Now;
+ station.StationStatus = (int)LocationStatusEnum.OutLock;
+ _taskService.AddData(dt_Task);
+ _StationInfoService.UpdateData(station);
+ }
+ }
+ #endregion
+
+ #region 鍑烘彁鍗囨満浠诲姟
+ var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "TSJ") as OtherDevice;
+ if (device != null && device.IsConnected)
+ {
+ if (device.GetValue<HoistEnum, short>(HoistEnum.SOutboundmaterialbox, "TSJC3F") == 1)
+ {
+ station = stations.FirstOrDefault(x => x.StationStatus == (int)LocationStatusEnum.Free);
+ if (station != null)
+ {
+ var tasknum = _taskService.GetTaskNum(nameof(SequenceEnum.SeqTaskNum));
+ Dt_Task dt_Task = new Dt_Task()
+ {
+ TaskNum = tasknum,
+ WMSTaskNum = "GP" + tasknum,
+ Grade = 60,
+ PalletCode = station.PalletCode,
+ Roadway = "",
+ TaskState = (int)TaskStatusEnum.New,
+ TaskType = TaskTypeEnum.CK3F.ObjToInt(),
+ SourceAddress = "TSJC3F",
+ CurrentAddress = "TSJC3F",
+ NextAddress = station.StationCode,
+ TargetAddress = station.StationCode,
+ Creater = "WCS",
+ };
+ var content = _taskService.SendHIKROBOTTask(dt_Task);
+ if (content.Status)
+ {
+ dt_Task.TaskState = (int)TaskStatusEnum.Execut;
+ dt_Task.Dispatchertime = DateTime.Now;
+ station.StationStatus = (int)LocationStatusEnum.InLock;
+ _taskService.AddData(dt_Task);
+ _StationInfoService.UpdateData(station);
+ }
+ }
+ }
+ }
+ #endregion
+
+ #endregion
+
+ #region 鍥涙ゼ鑷姩浠诲姟
+ List<string> LocationCodes = new() { "RGD0304A04011", "RG0105A04031", "RG0202A05021" };
+ var hKLocationInfos = _HKLocationInfoService.Repository.QueryData(x => LocationCodes.Contains(x.LocationCode));
+ #region 鍏ユ彁鍗囨満浠诲姟
+ var hKLocation = hKLocationInfos.FirstOrDefault(x => x.LocationStatus == (int)LocationStatusEnum.InStock);
+ if (hKLocation != null)
+ {
+ var tasknum = _taskService.GetTaskNum(nameof(SequenceEnum.SeqTaskNum));
+ Dt_Task dt_Task = new Dt_Task()
+ {
+ TaskNum = tasknum,
+ WMSTaskNum = "GP" + tasknum,
+ Grade = 60,
+ PalletCode = hKLocation.PalletCode,
+ Roadway = "",
+ TaskState = (int)TaskStatusEnum.New,
+ TaskType = TaskTypeEnum.CHUKU1.ObjToInt(),
+ SourceAddress = hKLocation.LocationCode,
+ CurrentAddress = hKLocation.LocationCode,
+ NextAddress = "TSJR4F",
+ TargetAddress = "TSJR4F",
+ Creater = "WCS",
+ };
+ var content = _taskService.SendHIKROBOTTask(dt_Task);
+ if (content.Status)
+ {
+ dt_Task.TaskState = (int)TaskStatusEnum.Execut;
+ dt_Task.Dispatchertime = DateTime.Now;
+ hKLocation.LocationStatus = (int)LocationStatusEnum.OutLock;
+ _taskService.AddData(dt_Task);
+ _HKLocationInfoService.UpdateData(hKLocation);
+ }
+ }
+ #endregion
+
+ #region 鍑烘彁鍗囨満浠诲姟
+ if (device != null && device.IsConnected)
+ {
+ if (device.GetValue<HoistEnum, short>(HoistEnum.FOutboundmaterialbox, "TSJC3F") == 1)
+ {
+ hKLocation = hKLocationInfos.FirstOrDefault(x => x.LocationStatus == (int)LocationStatusEnum.Free);
+ if (hKLocation != null)
+ {
+ var tasknum = _taskService.GetTaskNum(nameof(SequenceEnum.SeqTaskNum));
+ Dt_Task dt_Task = new Dt_Task()
+ {
+ TaskNum = tasknum,
+ WMSTaskNum = "GP" + tasknum,
+ Grade = 60,
+ PalletCode = hKLocation.PalletCode,
+ Roadway = "",
+ TaskState = (int)TaskStatusEnum.New,
+ TaskType = TaskTypeEnum.Q1TSJ4.ObjToInt(),
+ SourceAddress = "TSJC4F",
+ CurrentAddress = "TSJC4F",
+ NextAddress = hKLocation.LocationCode,
+ TargetAddress = hKLocation.LocationCode,
+ Creater = "WCS",
+ };
+ var content = _taskService.SendHIKROBOTTask(dt_Task);
+ if (content.Status)
+ {
+ dt_Task.TaskState = (int)TaskStatusEnum.Execut;
+ dt_Task.Dispatchertime = DateTime.Now;
+ hKLocation.LocationStatus = (int)LocationStatusEnum.InLock;
+ _taskService.AddData(dt_Task);
+ _HKLocationInfoService.UpdateData(hKLocation);
+ }
+ }
+ }
+ }
+ #endregion
+
+ #endregion
+ }
+ catch (Exception ex)
+ {
+ Console.Out.WriteLine(nameof(TaskJob) + ":" + ex.Message);
+ }
+ return Task.CompletedTask;
+ }
+ }
+}
--
Gitblit v1.9.3