From 73a9951bb6a5919ec481fa6fef37d5aa338b31db Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期一, 20 四月 2026 10:03:15 +0800
Subject: [PATCH] 1
---
项目代码/WIDESEA_WCSServer/WIDESEAWCS_Tasks/AGV/CommonAGVJob.cs | 79 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 77 insertions(+), 2 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WCSServer/WIDESEAWCS_Tasks/AGV/CommonAGVJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WCSServer/WIDESEAWCS_Tasks/AGV/CommonAGVJob.cs"
index 110d9cc..4b89083 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WCSServer/WIDESEAWCS_Tasks/AGV/CommonAGVJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WCSServer/WIDESEAWCS_Tasks/AGV/CommonAGVJob.cs"
@@ -10,12 +10,15 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using WIDESEA_Common.Log;
using WIDESEAWCS_Common;
+using WIDESEAWCS_Common.APIEnum;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_DTO.Agv;
using WIDESEAWCS_DTO.TaskInfo;
-using WIDESEAWCS_DTO.WMS;
+using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_ISystemServices;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
@@ -30,15 +33,87 @@
private readonly ITaskRepository _taskRepository;
private readonly ITaskService _taskService;
private readonly ISys_ConfigService _sys_ConfigService;
- public CommonAGVJob(ITaskRepository taskRepository,ITaskService taskService,ISys_ConfigService configService)
+ private readonly IDt_StationManagerRepository _stationManagerRepository;
+ public CommonAGVJob(ITaskRepository taskRepository,ITaskService taskService,ISys_ConfigService configService,IDt_StationManagerRepository stationManagerRepository)
{
_taskRepository = taskRepository;
_taskService = taskService;
_sys_ConfigService = configService;
+ _stationManagerRepository = stationManagerRepository;
}
public Task Execute(IJobExecutionContext context)
{
+ var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => (x.TaskState == TaskAGVCarryStatusEnum.AGV_CarryNew.ObjToInt())).ToList().OrderBy(x => x.Grade).ThenBy(x => x.TaskNum).ToList();
+ #region 浠诲姟涓嬪彂
+ if (newTasks.Count > 0)
+ {
+ WriteLog.Write_Log("AGV浠诲姟涓嬪彂", "浠诲姟涓嬪彂鎺ュ彛", "娣诲姞浠诲姟", $"浠诲姟锛歿newTasks.ToJson()}");
+ try
+ {
+ AgvTaskSendDTO agvTaskSend = new AgvTaskSendDTO()
+ {
+ MissionData = new List<MissionDataItem>()
+ };
+ string taskGroupId = Guid.NewGuid().ToString().Replace("-", "");
+
+ foreach (var task in newTasks)
+ {
+ //鑾峰彇鐩爣鐐硅揣浣�
+ Dt_StationManager stationManagerStart = _stationManagerRepository.QueryFirst(x => x.stationLocation == task.CurrentAddress);
+ //鑾峰彇鎷i�夊嚭搴撶珯鍙�
+ Dt_StationManager stationManagerEnd = _stationManagerRepository.QueryFirst(x => x.stationLocation == task.NextAddress);
+
+ if (stationManagerStart == null || stationManagerStart == null) throw new Exception($"鏈壘鍒颁换鍔″彿${task.TaskNum}璧峰鐐箋task.CurrentAddress}鎴栫洰鏍囩偣{task.NextAddress}浣嶇疆淇℃伅");
+ agvTaskSend.RequestId = taskGroupId;
+ agvTaskSend.MissionCode = task.TaskNum.ToString();
+ agvTaskSend.ViewBoardType = "W01";
+ //鏂欑瀛愭惉杩愪换鍔�
+ MissionDataItem missionDataItem = new MissionDataItem()
+ {
+ Sequence = task.TaskNum,
+ BinCode = task.PalletCode,
+ StartPosition = stationManagerStart.stationLocation,
+ EndPosition = stationManagerEnd.stationLocation,
+ TakeActionConfirm = false,
+ TakeActionInform = false,
+ PutActionConfirm = true,
+ PutActionInform = true,
+ };
+ agvTaskSend.MissionData.Add(missionDataItem);
+ }
+ if (newTasks.OrderByDescending(x => x.Grade).FirstOrDefault()?.Grade == 0)
+ {
+ agvTaskSend.Priority = 99;
+ }
+ else
+ {
+ agvTaskSend.Priority = 99 - newTasks.OrderByDescending(x => x.Grade).FirstOrDefault().Grade;
+ }
+ //鍙戦�丄GV浠诲姟
+ WebResponseContent content = _taskService.AgvSendTask(agvTaskSend, APIEnum.AgvSendTask);
+ if (!content.Status)
+ throw new Exception(content.Message);
+ newTasks.ForEach(x =>
+ {
+ x.Dispatchertime = DateTime.Now;
+ x.TaskState = TaskAGVCarryStatusEnum.AGV_CarryExecuting.ObjToInt();
+ });
+ _taskService.UpdateData(newTasks);
+ Thread.Sleep(500);
+ }
+ catch (Exception ex)
+ {
+ newTasks.ForEach(x =>
+ {
+ x.TaskState = TaskAGVCarryStatusEnum.AGV_CarryException.ObjToInt();
+ x.ExceptionMessage = ex.Message;
+ });
+ _taskService.UpdateData(newTasks);
+ }
+
+ }
+ #endregion
return Task.CompletedTask;
}
--
Gitblit v1.9.3