From 257d09aff7ec7b858b037607869d23ec61ac75bc Mon Sep 17 00:00:00 2001
From: helongyang <647556386@qq.com>
Date: 星期二, 19 八月 2025 09:03:49 +0800
Subject: [PATCH] 1
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/AGV/AGV_CSJExtend.cs | 119 ++++++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 80 insertions(+), 39 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/AGV/AGV_CSJExtend.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/AGV/AGV_CSJExtend.cs"
index c3ae198..9e7bf06 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/AGV/AGV_CSJExtend.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/AGV/AGV_CSJExtend.cs"
@@ -9,9 +9,11 @@
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_Model.Models;
-using static Dm.net.buffer.ByteArrayBuffer;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_DTO.Agv;
+using SqlSugar;
+using static Dm.net.buffer.ByteArrayBuffer;
+using WIDESEAWCS_Core.Enums;
namespace WIDESEAWCS_Tasks
{
@@ -24,17 +26,19 @@
{
try
{
- var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt() && nameof(AGV_CSJJob).Contains(x.DeviceCode)).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList();
- foreach (var agvTask in newTasks)
+ var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt() && !string.IsNullOrEmpty(x.DeviceCode) && nameof(AGV_CSJJob).Contains(x.DeviceCode)).OrderByDescending(x =>x.Grade).OrderBy(x=>x.CreateDate).ToList();
+ if (newTasks.Count>0)
{
- try
+ foreach (var agvTask in newTasks)
{
- AgvTaskDTO taskDTO = new AgvTaskDTO()
+ try
{
- ReqCode = Guid.NewGuid().ToString().Replace("-", ""),
- TaskTyp = AgvTaskType(agvTask.TaskType, agvTask.DeviceCode),
- PositionCodePath = new List<CodePath>()
- {
+ AgvTaskDTO taskDTO = new AgvTaskDTO()
+ {
+ ReqCode = Guid.NewGuid().ToString().Replace("-", ""),
+ TaskTyp = AgvTaskType(agvTask.TaskType, agvTask.DeviceCode),
+ PositionCodePath = new List<CodePath>()
+ {
new CodePath()
{
type="00",
@@ -45,35 +49,36 @@
type="00",
positionCode=agvTask.NextAddress
}
- },
- TaskCode = agvTask.AgvTaskNum,
- PodTyp = agvTask.PalletType < 3 ? "XX" : "DD",
- };
- WebResponseContent content = _taskService.AgvSendTask(taskDTO);
- if (content.Status)
- {
- agvTask.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt();
- //agvTask.Remark = content.Data.ObjToString();
- _taskService.UpdateTask(agvTask, TaskStatusEnum.AGV_Executing);
+ },
+ TaskCode = agvTask.AgvTaskNum,
+ PodTyp = agvTask.PalletType < 3 ? "ZC" : "DX",
+ };
+ WebResponseContent content = _taskService.AgvSendTask(taskDTO);
+ if (content.Status)
+ {
+ agvTask.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt();
+ //agvTask.Remark = content.Data.ObjToString();
+ _taskService.UpdateTask(agvTask, TaskStatusEnum.AGV_Executing);
+ }
+ else
+ {
+ agvTask.TaskState = TaskStatusEnum.Exception.ObjToInt();
+ //agvTask.Remark = content.Data.ObjToString();
+ agvTask.ExceptionMessage = content.Message;
+ }
}
- else
+ catch (Exception ex)
{
agvTask.TaskState = TaskStatusEnum.Exception.ObjToInt();
//agvTask.Remark = content.Data.ObjToString();
- agvTask.ExceptionMessage = content.Message;
+ agvTask.ExceptionMessage = ex.Message;
+ WriteError(nameof(AGV_CSJJob), ex.Message, ex);
}
}
- catch (Exception ex)
- {
- agvTask.TaskState = TaskStatusEnum.Exception.ObjToInt();
- //agvTask.Remark = content.Data.ObjToString();
- agvTask.ExceptionMessage = ex.Message;
- WriteError(nameof(AGV_CSJJob), ex.Message, ex);
- }
+ _taskService.UpdateData(newTasks);
}
- _taskService.UpdateData(newTasks);
//鍑哄簱缁戝畾鏌ヨ
- Dt_Task outBound = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.Exception.ObjToInt() && nameof(AGV_CSJJob).Contains(x.DeviceCode) && x.TaskType==TaskTypeEnum.Outbound.ObjToInt()).ToList().OrderBy(x => x.Grade).ThenBy(x=>x.CreateDate).First();
+ Dt_Task outBound = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.Exception.ObjToInt() && nameof(AGV_CSJJob).Contains(x.DeviceCode) && x.TaskType==TaskTypeEnum.Outbound.ObjToInt()).ToList().OrderByDescending(x => x.Grade).ThenBy(x=>x.CreateDate).First();
if (outBound != null)
{
AgvPodBerthAndMatDTO andMatDTO = new AgvPodBerthAndMatDTO()
@@ -103,7 +108,7 @@
{
try
{
- var WaitToTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_WaitToExecute.ObjToInt() && nameof(AGV_CSJJob).Contains(x.DeviceCode)).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList();
+ var WaitToTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_WaitToExecute.ObjToInt() && nameof(AGV_CSJJob).Contains(x.DeviceCode)).OrderBy(x => x.CreateDate).ToList();
foreach (var WaitToTask in WaitToTasks)
{
if (WaitToTask.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
@@ -186,6 +191,50 @@
}
}
_taskService.UpdateData(WaitToTasks);
+
+ //鍙栨斁璐у畬鎴愬啓鍏ュ紓甯稿鐞�
+ Dt_Task? TakeErroeTask = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_TakeError.ObjToInt() && nameof(AGV_CSJJob).Contains(x.DeviceCode)).First();
+ if (TakeErroeTask!=null)
+ {
+ Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == TakeErroeTask.CurrentAddress);
+ if (stationManger == null)
+ {
+ throw new Exception($"鏈壘鍒扮珯鍙伴厤缃�");
+ }
+ IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
+ if (device == null)
+ {
+ throw new Exception($"鏈壘鍒板搴旇澶�");
+ }
+ OtherDevice otherDevice = (OtherDevice)device;
+ otherDevice.SetValue(GroundStationDBName.W_TakeFinish, true, stationManger.StationCode);
+ Thread.Sleep(1000);
+ otherDevice.SetValue(GroundStationDBName.W_TakeFinish, false, stationManger.StationCode);
+ TakeErroeTask.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt();
+ var up = _taskRepository.DeleteAndMoveIntoHty(TakeErroeTask, OperateTypeEnum.鑷姩瀹屾垚);
+ _taskService.TaskCompleted(TakeErroeTask.TaskNum);
+ }
+ Dt_Task? PutErroeTask = _taskService.Db.Queryable<Dt_Task>().Where(x => x.TaskState == TaskStatusEnum.AGV_PutError.ObjToInt() && nameof(AGV_CSJJob).Contains(x.DeviceCode)).First();
+ if (PutErroeTask != null)
+ {
+ Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == PutErroeTask.NextAddress);
+ if (stationManger == null)
+ {
+ throw new Exception($"鏈壘鍒扮珯鍙伴厤缃�");
+ }
+ IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
+ if (device == null)
+ {
+ throw new Exception($"鏈壘鍒扮珯鍙伴厤缃�");
+ }
+ OtherDevice otherDevice = (OtherDevice)device;
+ otherDevice.SetValue(GroundStationDBName.W_PutFinish, true, stationManger.StationCode);
+ PutErroeTask.CurrentAddress = stationManger.StationCode;
+ PutErroeTask.NextAddress = "";
+ PutErroeTask.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt();
+ PutErroeTask.DeviceCode = "SC01_CSJ";
+ var up = _taskRepository.UpdateData(PutErroeTask);
+ }
}
catch (Exception ex)
{
@@ -200,14 +249,6 @@
case "AGV_CSJ":
{
return TaskType == TaskTypeEnum.ProductionReturn.ObjToInt() ? "23" : "24";
- }
- case "AGV_ZH":
- {
- if (TaskType == TaskTypeEnum.InboundXB.ObjToInt())
- return "20";
- else if (TaskType == TaskTypeEnum.InboundJT.ObjToInt())
- return "21";
- else return "22";
}
default:
throw new Exception($"璁惧缂栧彿閿欒");
--
Gitblit v1.9.3