From 9a886d711d8b21adc335fdf8c39350584c7ba6fd Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期二, 14 十月 2025 02:12:14 +0800
Subject: [PATCH] 更新代码,取消MES出库单号同步标识,平库转立库功能,寄售周期判断取消,精品标识等
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/成品仓/AGV_CPExtend.cs | 387 +++++++++++++++---------------------------------------
1 files changed, 109 insertions(+), 278 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/AGV_CPExtend.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/AGV_CPExtend.cs"
index 2ad1a7e..c42b857 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/AGV_CPExtend.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/AGV_CPExtend.cs"
@@ -28,153 +28,33 @@
var newTasksIn = AllTasks.Where(x => (x.TaskState == TaskStatusEnum.AGV_Execute.ObjToInt()) && x.TaskType>=TaskTypeEnum.Inbound.ObjToInt() && nameof(AGV_CPJob).Contains(x.DeviceCode) && !string.IsNullOrEmpty(x.DeviceCode) && x.TaskType!=999).ToList().OrderByDescending(x => x.Grade).ThenBy(x => x.CreateDate).ToList();
if (newTasksIn.Count>0)
{
- foreach (var task in newTasksIn)
- {
- try
- {
- if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
- task.CurrentAddress = GetAGVAddress(task.CurrentAddress);
- else
- task.NextAddress = GetAGVAddress(task.NextAddress);
- AgvTaskDTO taskDTO = new AgvTaskDTO()
- {
- TaskCode = task.AgvTaskNum,
- ReqCode = DateTime.Now.ToString("yyMMdd") + task.AgvTaskNum,
- TaskTyp = task.TaskType < TaskTypeEnum.Inbound.ObjToInt() ? "CPC" : "CPR",
- ctnrCode = task.PalletCode,
- PositionCodePath = new List<CodePath>()
- {
- new CodePath()
- {
- type = "05",
- positionCode = task.CurrentAddress
- },
- new CodePath()
- {
- type = "05",
- positionCode = task.NextAddress
- }
- }
- };
- if (taskDTO.TaskTyp== "CPC")
- {
- taskDTO.Priority = task.Grade.ToString();
- }
- if (task.GroupId.IsNotEmptyOrNull())
- {
- taskDTO.GroupId=task.GroupId;
- }
- if (task.TaskType==TaskTypeEnum.OutMesRworkProduct.ObjToInt())
- {
- taskDTO.Priority = "127";
- }
- //鍙戦�丄GV浠诲姟
- WebResponseContent content = _taskService.AgvSendTask(taskDTO, APIEnum.Agv_CPSendTask);
- if (!content.Status)
- throw new Exception(content.Message);
- if (taskDTO.TaskTyp == "CPC")
- {
- task.Dispatchertime = DateTime.Now;
- _taskService.UpdateTask(task, TaskStatusEnum.AGV_Executing);
- }
- else
- {
- task.Dispatchertime = DateTime.Now;
- _taskService.UpdateTask(task, TaskStatusEnum.AGV_Takeing);
- }
- Thread.Sleep(500);
- }
- catch (Exception ex)
- {
- task.TaskState = TaskStatusEnum.Exception.ObjToInt();
- task.ExceptionMessage = ex.Message;
- }
- }
- if (newTasksIn.Count > 0)
- {
- _taskService.UpdateData(newTasksIn);
- }
+ SendAgvTasks(newTasksIn);
}
}
#endregion
+ DateTime _taskStartTime = DateTime.Today;
#region 鍑哄簱鎺ㄩ�佷换鍔�1绾�
{
- var newTasksOut1 = AllTasks.Where(x => (x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.TaskType < TaskTypeEnum.Inbound.ObjToInt() && x.NextAddress=="5236").OrderByDescending(x => x.Grade).ThenBy(x => x.GroupId).Take(5).ToList();
+ //鎸夋椂闂存煡鎵�
+ var timeTasksOut1 = AllTasks.Where(x => (x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.TaskType < TaskTypeEnum.Inbound.ObjToInt() && x.NextAddress == "5236" && x.CreateDate<= _taskStartTime).OrderByDescending(x => x.Grade).ThenBy(x => x.CreateDate).Take(5).ToList();
+
+ //鏂板垱寤轰换鍔�
+ var newTasksOut1 = AllTasks.Where(x => (x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.TaskType < TaskTypeEnum.Inbound.ObjToInt() && x.NextAddress=="5236").OrderByDescending(x => x.Grade).ThenBy(x => x.CreateDate).Take(5).ToList();
+
+ var pushTasks1= timeTasksOut1.Count<=0 ? newTasksOut1 : timeTasksOut1;
+ //褰撳墠绾夸綋浠诲姟
var downTasksOut1 = AllTasks.Where(x => (x.TaskState > TaskStatusEnum.New.ObjToInt()) && x.TaskType < TaskTypeEnum.Inbound.ObjToInt() && x.NextAddress == "5236").ToList();
+
Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.AGVStationCode == "5236");
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
if (device != null)
{
OtherDevice otherDevice = (OtherDevice)device;
short stationCurrentStatus = device.Communicator.Read<short>("DB29.112");
- if (newTasksOut1.Count > 0 && downTasksOut1.Count <= 0 && stationCurrentStatus == 1)
+ if (pushTasks1.Count > 0 && downTasksOut1.Count <= 0 && stationCurrentStatus == 1)
{
- foreach (var task in newTasksOut1)
- {
- try
- {
- if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
- task.CurrentAddress = GetAGVAddress(task.CurrentAddress);
- else
- task.NextAddress = GetAGVAddress(task.NextAddress);
- AgvTaskDTO taskDTO = new AgvTaskDTO()
- {
- TaskCode = task.AgvTaskNum,
- ReqCode = DateTime.Now.ToString("yyMMdd") + task.AgvTaskNum,
- TaskTyp = task.TaskType < TaskTypeEnum.Inbound.ObjToInt() ? "CPC" : "CPR",
- ctnrCode = task.PalletCode,
- PositionCodePath = new List<CodePath>()
- {
- new CodePath()
- {
- type = "05",
- positionCode = task.CurrentAddress
- },
- new CodePath()
- {
- type = "05",
- positionCode = task.NextAddress
- }
- }
- };
- if (taskDTO.TaskTyp == "CPC")
- {
- taskDTO.Priority = task.Grade.ToString();
- }
- if (task.GroupId.IsNotEmptyOrNull())
- {
- taskDTO.GroupId = task.GroupId;
- }
- if (task.TaskType == TaskTypeEnum.OutMesRworkProduct.ObjToInt())
- {
- taskDTO.Priority = "127";
- }
- //鍙戦�丄GV浠诲姟
- WebResponseContent content = _taskService.AgvSendTask(taskDTO, APIEnum.Agv_CPSendTask);
- if (!content.Status)
- throw new Exception(content.Message);
- if (taskDTO.TaskTyp == "CPC")
- {
- task.Dispatchertime = DateTime.Now;
- _taskService.UpdateTask(task, TaskStatusEnum.AGV_Executing);
- }
- else
- {
- task.Dispatchertime = DateTime.Now;
- _taskService.UpdateTask(task, TaskStatusEnum.AGV_Takeing);
- }
- }
- catch (Exception ex)
- {
- task.TaskState = TaskStatusEnum.Exception.ObjToInt();
- task.ExceptionMessage = ex.Message;
- }
- }
- if (newTasksOut1.Count > 0)
- {
- _taskService.UpdateData(newTasksOut1);
- }
- WriteInfo("5236", $"1绾�5236鏃犱换鍔★紝鐘舵�亄stationCurrentStatus}鍙笅鍙戯紝涓嬪彂浠诲姟锛歿newTasksOut1.Select(x => x.TaskNum)}");
+ SendAgvTasks(pushTasks1);
+ WriteInfo("5236", $"1绾�5236鏃犱换鍔★紝鐘舵�亄stationCurrentStatus}鍙笅鍙戯紝涓嬪彂浠诲姟锛歿pushTasks1.Select(x => x.TaskNum)}");
}
}
@@ -182,174 +62,56 @@
#endregion
#region 鍑哄簱鎺ㄩ�佷换鍔�2绾�
{
- var newTasksOut2 = AllTasks.Where(x => (x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.TaskType < TaskTypeEnum.Inbound.ObjToInt() && x.NextAddress == "5243").OrderByDescending(x => x.Grade).ThenBy(x => x.GroupId).Take(5).ToList();
+ //鎸夋椂闂存煡鎵�
+ var timeTasksOut2 = AllTasks.Where(x => (x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.TaskType < TaskTypeEnum.Inbound.ObjToInt() && x.NextAddress == "5243" && x.CreateDate <= _taskStartTime).OrderByDescending(x => x.Grade).ThenBy(x => x.CreateDate).Take(5).ToList();
+
+ //鏂板垱寤轰换鍔�
+ var newTasksOut2 = AllTasks.Where(x => (x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.TaskType < TaskTypeEnum.Inbound.ObjToInt() && x.NextAddress == "5243").OrderByDescending(x => x.Grade).ThenBy(x => x.CreateDate).Take(5).ToList();
+
+ var pushTasks2 = timeTasksOut2.Count <= 0 ? newTasksOut2 : timeTasksOut2;
+
+ //褰撳墠绾夸綋浠诲姟
var downTasksOut2 = AllTasks.Where(x => (x.TaskState > TaskStatusEnum.New.ObjToInt()) && x.TaskType < TaskTypeEnum.Inbound.ObjToInt() && x.NextAddress == "5243").ToList();
+
Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.AGVStationCode == "5243");
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
if (device != null)
{
OtherDevice otherDevice = (OtherDevice)device;
short stationCurrentStatus = device.Communicator.Read<short>("DB29.126");
- if (newTasksOut2.Count > 0 && downTasksOut2.Count <= 0 && stationCurrentStatus == 1)
+ if (pushTasks2.Count > 0 && downTasksOut2.Count <= 0 && stationCurrentStatus == 1)
{
- foreach (var task in newTasksOut2)
- {
- try
- {
- if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
- task.CurrentAddress = GetAGVAddress(task.CurrentAddress);
- else
- task.NextAddress = GetAGVAddress(task.NextAddress);
- AgvTaskDTO taskDTO = new AgvTaskDTO()
- {
- TaskCode = task.AgvTaskNum,
- ReqCode = DateTime.Now.ToString("yyMMdd") + task.AgvTaskNum,
- TaskTyp = task.TaskType < TaskTypeEnum.Inbound.ObjToInt() ? "CPC" : "CPR",
- ctnrCode = task.PalletCode,
- PositionCodePath = new List<CodePath>()
- {
- new CodePath()
- {
- type = "05",
- positionCode = task.CurrentAddress
- },
- new CodePath()
- {
- type = "05",
- positionCode = task.NextAddress
- }
- }
- };
- if (taskDTO.TaskTyp == "CPC")
- {
- taskDTO.Priority = task.Grade.ToString();
- }
- if (task.GroupId.IsNotEmptyOrNull())
- {
- taskDTO.GroupId = task.GroupId;
- }
- if (task.TaskType == TaskTypeEnum.OutMesRworkProduct.ObjToInt())
- {
- taskDTO.Priority = "127";
- }
- //鍙戦�丄GV浠诲姟
- WebResponseContent content = _taskService.AgvSendTask(taskDTO, APIEnum.Agv_CPSendTask);
- if (!content.Status)
- throw new Exception(content.Message);
- if (taskDTO.TaskTyp == "CPC")
- {
- task.Dispatchertime = DateTime.Now;
- _taskService.UpdateTask(task, TaskStatusEnum.AGV_Executing);
- }
- else
- {
- task.Dispatchertime = DateTime.Now;
- _taskService.UpdateTask(task, TaskStatusEnum.AGV_Takeing);
- }
- }
- catch (Exception ex)
- {
- task.TaskState = TaskStatusEnum.Exception.ObjToInt();
- task.ExceptionMessage = ex.Message;
- }
- }
- if (newTasksOut2.Count > 0)
- {
- _taskService.UpdateData(newTasksOut2);
- }
- WriteInfo("5243", $"2绾�5243鏃犱换鍔★紝鐘舵�亄stationCurrentStatus}鍙笅鍙戯紝涓嬪彂浠诲姟锛歿newTasksOut2.Select(x => x.TaskNum)}");
+ SendAgvTasks(pushTasks2);
+ WriteInfo("5243", $"2绾�5243鏃犱换鍔★紝鐘舵�亄stationCurrentStatus}鍙笅鍙戯紝涓嬪彂浠诲姟锛歿pushTasks2.Select(x => x.TaskNum)}");
}
- //else
- //{
- // WriteInfo(nameof(AGV_CPJob), $"2绾挎棤浠诲姟锛岀姸鎬亄stationCurrentStatus}");
- //}
}
}
#endregion
#region 鍑哄簱鎺ㄩ�佷换鍔�3绾�
{
- var newTasksOut3 = AllTasks.Where(x => (x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.TaskType < TaskTypeEnum.Inbound.ObjToInt() && x.NextAddress == "5250").OrderByDescending(x => x.Grade).ThenBy(x => x.GroupId).Take(5).ToList();
+ //鎸夋椂闂存煡鎵�
+ var timeTasksOut3 = AllTasks.Where(x => (x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.TaskType < TaskTypeEnum.Inbound.ObjToInt() && x.NextAddress == "5250" && x.CreateDate <= _taskStartTime).OrderByDescending(x => x.Grade).ThenBy(x => x.CreateDate).Take(5).ToList();
+
+ //鏂板垱寤轰换鍔�
+ var newTasksOut3 = AllTasks.Where(x => (x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.TaskType < TaskTypeEnum.Inbound.ObjToInt() && x.NextAddress == "5250").OrderByDescending(x => x.Grade).ThenBy(x => x.CreateDate).Take(5).ToList();
+
+ var pushTasks3 = timeTasksOut3.Count <= 0 ? newTasksOut3 : timeTasksOut3;
+
+ //褰撳墠绾夸綋浠诲姟
var downTasksOut3 = AllTasks.Where(x => (x.TaskState > TaskStatusEnum.New.ObjToInt()) && x.TaskType < TaskTypeEnum.Inbound.ObjToInt() && x.NextAddress == "5250").ToList();
+
Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.AGVStationCode == "5250");
IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
if (device != null)
{
OtherDevice otherDevice = (OtherDevice)device;
short stationCurrentStatus = device.Communicator.Read<short>("DB29.140");
- if (newTasksOut3.Count > 0 && downTasksOut3.Count <= 0 && stationCurrentStatus == 1)
+ if (pushTasks3.Count > 0 && downTasksOut3.Count <= 0 && stationCurrentStatus == 1)
{
- foreach (var task in newTasksOut3)
- {
- try
- {
- if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
- task.CurrentAddress = GetAGVAddress(task.CurrentAddress);
- else
- task.NextAddress = GetAGVAddress(task.NextAddress);
- AgvTaskDTO taskDTO = new AgvTaskDTO()
- {
- TaskCode = task.AgvTaskNum,
- ReqCode = DateTime.Now.ToString("yyMMdd") + task.AgvTaskNum,
- TaskTyp = task.TaskType < TaskTypeEnum.Inbound.ObjToInt() ? "CPC" : "CPR",
- ctnrCode = task.PalletCode,
- PositionCodePath = new List<CodePath>()
- {
- new CodePath()
- {
- type = "05",
- positionCode = task.CurrentAddress
- },
- new CodePath()
- {
- type = "05",
- positionCode = task.NextAddress
- }
- }
- };
- if (taskDTO.TaskTyp == "CPC")
- {
- taskDTO.Priority = task.Grade.ToString();
- }
- if (task.GroupId.IsNotEmptyOrNull())
- {
- taskDTO.GroupId = task.GroupId;
- }
- if (task.TaskType == TaskTypeEnum.OutMesRworkProduct.ObjToInt())
- {
- taskDTO.Priority = "127";
- }
- //鍙戦�丄GV浠诲姟
- WebResponseContent content = _taskService.AgvSendTask(taskDTO, APIEnum.Agv_CPSendTask);
- if (!content.Status)
- throw new Exception(content.Message);
- if (taskDTO.TaskTyp == "CPC")
- {
- task.Dispatchertime = DateTime.Now;
- _taskService.UpdateTask(task, TaskStatusEnum.AGV_Executing);
- }
- else
- {
- task.Dispatchertime = DateTime.Now;
- _taskService.UpdateTask(task, TaskStatusEnum.AGV_Takeing);
- }
- }
- catch (Exception ex)
- {
- task.TaskState = TaskStatusEnum.Exception.ObjToInt();
- task.ExceptionMessage = ex.Message;
- }
- }
- if (newTasksOut3.Count > 0)
- {
- _taskService.UpdateData(newTasksOut3);
- }
- WriteInfo("5250", $"3绾�5250鏃犱换鍔★紝鐘舵�亄stationCurrentStatus}鍙笅鍙戯紝涓嬪彂浠诲姟锛歿newTasksOut3.Select(x => x.TaskNum)}");
+ SendAgvTasks(pushTasks3);
+ WriteInfo("5250", $"3绾�5250鏃犱换鍔★紝鐘舵�亄stationCurrentStatus}鍙笅鍙戯紝涓嬪彂浠诲姟锛歿pushTasks3.Select(x => x.TaskNum)}");
}
- //else
- //{
- // WriteInfo(nameof(AGV_CPJob), $"3绾挎棤浠诲姟锛岀姸鎬亄stationCurrentStatus}");
- //}
}
}
@@ -498,6 +260,75 @@
}
}
/// <summary>
+ /// 涓嬪彂AGV浠诲姟
+ /// </summary>
+ /// <param name="tasks"></param>
+ public void SendAgvTasks(List<Dt_Task> tasks)
+ {
+ foreach (var task in tasks)
+ {
+ try
+ {
+ if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
+ task.CurrentAddress = GetAGVAddress(task.CurrentAddress);
+ else
+ task.NextAddress = GetAGVAddress(task.NextAddress);
+ AgvTaskDTO taskDTO = new AgvTaskDTO()
+ {
+ TaskCode = task.AgvTaskNum,
+ ReqCode = DateTime.Now.ToString("yyMMdd") + task.AgvTaskNum,
+ TaskTyp = task.TaskType < TaskTypeEnum.Inbound.ObjToInt() ? "CPC" : "CPR",
+ ctnrCode = task.PalletCode,
+ PositionCodePath = new List<CodePath>()
+ {
+ new CodePath()
+ {
+ type = "05",
+ positionCode = task.CurrentAddress
+ },
+ new CodePath()
+ {
+ type = "05",
+ positionCode = task.NextAddress
+ }
+ }
+ };
+ if (taskDTO.TaskTyp == "CPC")
+ {
+ taskDTO.Priority = task.Grade.ToString();
+ }
+ if (task.GroupId.IsNotEmptyOrNull())
+ {
+ taskDTO.GroupId = task.GroupId;
+ }
+ if (task.TaskType == TaskTypeEnum.OutMesRworkProduct.ObjToInt())
+ {
+ taskDTO.Priority = "127";
+ }
+ //鍙戦�丄GV浠诲姟
+ WebResponseContent content = _taskService.AgvSendTask(taskDTO, APIEnum.Agv_CPSendTask);
+ if (!content.Status)
+ throw new Exception(content.Message);
+ if (taskDTO.TaskTyp == "CPC")
+ {
+ task.Dispatchertime = DateTime.Now;
+ _taskService.UpdateTask(task, TaskStatusEnum.AGV_Executing);
+ }
+ else
+ {
+ task.Dispatchertime = DateTime.Now;
+ _taskService.UpdateTask(task, TaskStatusEnum.AGV_Takeing);
+ }
+ }
+ catch (Exception ex)
+ {
+ task.TaskState = TaskStatusEnum.Exception.ObjToInt();
+ task.ExceptionMessage = ex.Message;
+ _taskService.UpdateTask(task, TaskStatusEnum.Exception);
+ }
+ }
+ }
+ /// <summary>
/// 鑾峰彇AGV鍦板潃
/// </summary>
/// <param name="Address"></param>
--
Gitblit v1.9.3