From 19724b0969eb2f91b38efb262a6ef4de04d6b0c5 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期二, 14 十月 2025 12:07:58 +0800
Subject: [PATCH] 新增“有货状态”显示及数据处理逻辑支持在Home.vue和 LineComponent.vue中新增了“有货状态”显示功能,为 RGV 和堆垛机对象添加了 InStock属性。 修改了 Home.vue 的 created生命周期和 LineComponent.vue的 update 方法,增加了对 inStock数据的处理逻辑。删除了三个旧的二进制文件,新增了六个新的二进制文件,可能与项目构建或依赖更新相关。优化了任务分配和状态判断逻辑,确保任务执行更加准确和高效。
---
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs | 213 +++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 166 insertions(+), 47 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs"
index 227a2e1..772c2af 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/Task/RequestInbound.cs"
@@ -1,17 +1,25 @@
锘縰sing HslCommunication;
using Mapster;
using Newtonsoft.Json;
+using SqlSugar;
+using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
+using WIDESEA_Common.Log;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_DTO.StackerHandTask;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_Model.BasicInfo;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
+using WIDESEAWCS_QuartzJob.DeviceBase;
+using WIDESEAWCS_QuartzJob.DTO;
+using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_Tasks.ConveyorLineJob;
+using WIDESEAWCS_Tasks.StackerCraneJob;
namespace WIDESEAWCS_Tasks
{
@@ -26,28 +34,20 @@
case 1:
await RequestTask(conveyorLine, command, childDeviceCode, stationManager);
break;
-
+ case 9:
+ RequestWMSTask(conveyorLine, stationManager);
+ break;
case 2:
case 3:
- RequestInOrOutbound(command, conveyorLine, stationManager, task);
+ RequestNextAddress(command, conveyorLine, stationManager, task);
break;
- default:
- break;
- }
- }
-
- public void HandleFinishTaskAsync(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, Dt_Task task=null)
- {
- var stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == childDeviceCode && x.stationPLC == conveyorLine.DeviceCode);
-
- switch (stationManager.stationType)
- {
case 4:
case 5:
- ConveyorLineInOrOutFinish(conveyorLine, command, stationManager, task);
- break;
- case 7:
- ConveyorLineOutFinish(conveyorLine, command, stationManager, task);
+ task = _taskService.QueryConveyorLineFinishTask(stationManager.stationChildCode, command.TaskNum);
+ if (task != null)
+ {
+ _taskService.UpdateTaskStatusToNext(task);
+ }
break;
default:
break;
@@ -56,44 +56,163 @@
private async Task RequestTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, Dt_StationManager stationManager)
{
- var hasTask = await _taskRepository.QueryFirstAsync(x => x.SourceAddress == childDeviceCode);
- if (hasTask != null)
+ try
{
- var log = $"銆恵conveyorLine._deviceName}銆戜换鍔″彿锛氥�恵hasTask.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵hasTask.PalletCode}銆戝凡鍒拌揪銆恵childDeviceCode}銆戣緭閫佺嚎瀛樺湪浠诲姟";
- ConsoleHelper.WriteWarningLine(log);
-
- await _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
- WriteInfo(conveyorLine.DeviceName, log);
- return;
- }
- var RGVName = string.Empty;
- if (stationManager.stationFloor == "1F")
- {
- var RGVOne = _taskRepository.QueryData(x => x.RGVName == "RGV01").ToList();
- var RGVTwo = _taskRepository.QueryData(x => x.RGVName == "RGV02").ToList();
- if (RGVOne.Count > RGVTwo.Count)
+ var hasTask = await _taskRepository.QueryFirstAsync(x => x.SourceAddress == childDeviceCode && x.TaskState < (int)TaskInStatusEnum.RGV_InExecutingFinish && x.TaskState >= (int)TaskInStatusEnum.InNew);
+ if (hasTask != null)
{
- RGVName = "RGV01";
+ var log = $"銆恵conveyorLine._deviceName}銆戜换鍔″彿锛氥�恵hasTask.TaskNum}銆�,鎵樼洏鏉$爜锛氥�恵hasTask.PalletCode}銆戝凡鍒拌揪銆恵childDeviceCode}銆戣緭閫佺嚎瀛樺湪浠诲姟";
+ ConsoleHelper.WriteWarningLine(log);
+
+ await _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
+ WriteInfo(conveyorLine.DeviceName, log);
+ return;
+ }
+ var RGVName = string.Empty;
+ if (stationManager.stationFloor == "1F")
+ {
+ RGVName = stationManager.RGVName;
}
else
{
- RGVName = "RGV02";
+ RGVName = "RGV03";
+ }
+ int targetStation = 0;
+ if (childDeviceCode == "1004" || childDeviceCode == "1039" || childDeviceCode == "1040" || childDeviceCode == "1013" || childDeviceCode == "1014")
+ {
+ targetStation = 14;
+ }
+ else if (childDeviceCode == "1015" || childDeviceCode == "1016" || childDeviceCode == "1027" || childDeviceCode == "1028" || childDeviceCode == "1029" || childDeviceCode == "1030")
+ {
+ targetStation = 1;
+ }
+ else
+ {
+ targetStation = 0;
+ }
+ Dt_Task task = new Dt_Task()
+ {
+ TaskNum = _taskRepository.GetTaskNo().Result,
+ TaskType = (int)TaskInboundTypeEnum.Inbound,
+ TaskState = (int)TaskInStatusEnum.InNew,
+ SourceAddress = childDeviceCode,
+ Dispatchertime = DateTime.Now,
+ Grade = 1,
+ Creater = "System",
+ Floor = stationManager.stationFloor,
+ RGVName = RGVName,
+ SourceStation = stationManager.remark,
+ TargetStation = targetStation,
+ };
+
+ _taskRepository.AddData(task);
+ }
+ catch (Exception ex)
+ {
+ var log = $"銆恵conveyorLine._deviceName}銆戣緭閫佺嚎銆恵childDeviceCode}銆戙�恵ex.Message}銆�";
+ ConsoleHelper.WriteWarningLine(log);
+
+ await _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
+ WriteInfo(conveyorLine.DeviceName, log);
+ }
+
+ }
+ private void RequestWMSTask(CommonConveyorLine conveyorLine, Dt_StationManager stationManager)
+ {
+ if (stationManager.stationChildCode == "3002")
+ {
+
+ var newTask = _taskRepository.QueryFirst(x => x.TargetAddress == "3004");
+ if (newTask != null)
+ {
+ return;
+ }
+
+ DeviceProDTO? devicePro = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == stationManager.stationChildCode && x.DeviceProParamName == "ConveyorLineBarcode").FirstOrDefault();
+ var x = conveyorLine.Communicator.Read(devicePro.DeviceProAddress, 10);
+
+ string Barcode = Encoding.UTF8.GetString(x);
+
+ if (Barcode == null || Barcode==""|| Barcode.Trim().Contains("\0"))
+ {
+ conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, Convert.ToSByte(3), stationManager.stationChildCode);
+ }
+ var task = _taskRepository.QueryFirst(x => x.PalletCode == Barcode && x.TaskState == (int)TaskInStatusEnum.HoistNew);
+
+ if (task != null)
+ {
+ ConveyorLineTaskCommandWrite taskCommand = new ConveyorLineTaskCommandWrite()
+ {
+ TaskNum = Convert.ToInt16(task.TaskNum),
+ TargetAddress = Convert.ToInt16(task.NextAddress),
+ WriteInteractiveSignal = task.TaskType == (int)TaskOutboundTypeEnum.Outbound ? (byte)Convert.ToSByte(2) : (byte)Convert.ToSByte(1)
+ };
+ var result = SendCommand(taskCommand, conveyorLine, stationManager.stationChildCode);
+ if (result)
+ {
+ task.TaskState = (int)TaskInStatusEnum.HoistInExecuting;
+ _taskRepository.UpdateData(task);
+ }
+ }
+ else
+ {
+ var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+ var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
+ var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTask)?.ConfigValue;
+
+ WMSTaskDTO taskDTO = new WMSTaskDTO()
+ {
+ TPbarcode = Barcode,
+ WhCode = "1001",
+ BeginPoint = stationManager.stationChildCode
+ };
+ if (wmsBase == null || requestTask == null)
+ {
+ throw new InvalidOperationException("WMS IP 鏈厤缃�");
+ }
+ var wmsIpAddress = wmsBase + requestTask;
+ var result = WIDESEA_Comm.Http.HttpHelper.PostAsync(wmsIpAddress, taskDTO.ToJsonString()).Result;
+ WriteLog.GetLog("WMS鎺ュ彛杩斿洖淇℃伅").Write(JsonConvert.SerializeObject(result), "WMS鎺ュ彛杩斿洖淇℃伅");
}
}
-
- Dt_Task task = new Dt_Task()
+ else
{
- TaskNum = _taskRepository.GetTaskNo().Result,
- TaskType = (int)TaskInboundTypeEnum.Inbound,
- TaskState = (int)TaskInStatusEnum.InNew,
- SourceAddress = childDeviceCode,
- Dispatchertime = DateTime.Now,
- Grade = 1, // 璁剧疆榛樿浼樺厛绾т负1
- Creater = "System",
- Floor = stationManager.stationFloor,
- RGVName = stationManager.RGVName != null ? stationManager.RGVName : RGVName,
- };
- _taskRepository.AddData(task);
+ DeviceProDTO? devicePro = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == stationManager.stationNextChildCode && x.DeviceProParamName == "ConveyorLineBarcode").FirstOrDefault();
+ var x = conveyorLine.Communicator.Read(devicePro.DeviceProAddress, 10);
+
+ string Barcode = Encoding.UTF8.GetString(x);
+
+ if (Barcode == null || Barcode == "" || Barcode.Trim().Contains("\0"))
+ {
+ conveyorLine.SetValue(ConveyorLineDBName.WriteInteractiveSignal, Convert.ToSByte(3), stationManager.stationChildCode);
+ }
+ var task = _taskRepository.QueryFirst(x => x.PalletCode == Barcode);
+ if (task != null)
+ {
+ var log = $"銆恵conveyorLine._deviceName}銆戠珯鍙般�恵stationManager.stationChildCode}銆戣姹傚彇璐с�佸凡瀛樺湪浠诲姟浠诲姟鍙穥task.TaskNum}";
+ LogAndWarn(conveyorLine.DeviceName, log);
+ }
+ else
+ {
+ var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+ var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
+ var requestTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTask)?.ConfigValue;
+
+ WMSTaskDTO taskDTO = new WMSTaskDTO()
+ {
+ TPbarcode = Barcode,
+ WhCode = "1001",
+ BeginPoint = stationManager.stationChildCode
+ };
+ if (wmsBase == null || requestTask == null)
+ {
+ throw new InvalidOperationException("WMS IP 鏈厤缃�");
+ }
+ var wmsIpAddress = wmsBase + requestTask;
+ var result = WIDESEA_Comm.Http.HttpHelper.PostAsync(wmsIpAddress, taskDTO.ToJsonString()).Result;
+ WriteLog.GetLog("WMS鎺ュ彛杩斿洖淇℃伅").Write(JsonConvert.SerializeObject(result), "WMS鎺ュ彛杩斿洖淇℃伅");
+ }
+ }
}
}
}
--
Gitblit v1.9.3