From 5a15fa73d5f6a39917013871a65eb11a8c013391 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 05 十一月 2025 17:30:56 +0800
Subject: [PATCH] 1
---
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 91 ++++++++++++++++++++++++++++++++++++---------
1 files changed, 72 insertions(+), 19 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
index 4eec051..abf8b44 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
@@ -2,15 +2,20 @@
using Mapster;
using Microsoft.AspNetCore.Components.Routing;
using Newtonsoft.Json;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using Quartz;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using WIDESEAWCS_BasicInfoRepository;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_Communicator;
+using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Caches;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_Core.HttpContextUser;
+using WIDESEAWCS_DTO.TaskInfo;
+using WIDESEAWCS_DTO.WMS;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_ISystemServices;
using WIDESEAWCS_ITaskInfoRepository;
@@ -83,6 +88,7 @@
bool sendFlag = commonStackerCrane.SendCommand(stackerCraneTaskCommand);
if (sendFlag)
{
+ var isWorkType = commonStackerCrane.Communicator.WriteNoRead("DB100.18.0", Convert.ToInt16(1));
commonStackerCrane.LastTaskType = task.TaskType;
_taskService.UpdateTaskStatusToNext(task.TaskNum);
Thread.Sleep(1000);
@@ -225,6 +231,7 @@
{
if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.FinishConfirm) != 1)
{
+ Thread.Sleep(1000);
ConsoleHelper.WriteColorLine($"銆恵commonStackerCrane.DeviceName}銆戝爢鍨涙満浣滀笟鐘舵�侊細銆恵(int)commonStackerCrane.StackerCraneWorkStatusValue}銆戞椂闂淬�恵DateTime.Now}銆�", ConsoleColor.Magenta);
string str = $"銆恵commonStackerCrane.DeviceName}銆戜换鍔″畬鎴�,浠诲姟鍙凤細銆恵e.TaskNum}銆戞椂闂淬�恵DateTime.Now}銆�";
@@ -232,9 +239,13 @@
ConsoleHelper.WriteColorLine(str, ConsoleColor.Blue);
var task = _taskRepository.QueryFirst(x => x.TaskNum == e.TaskNum);
- if (task == null) commonStackerCrane.SetValue(StackerCraneDBName.FinishConfirm, 1);
+ if (task == null)
+ {
+ commonStackerCrane.SetValue(StackerCraneDBName.FinishConfirm, 1);
+ return;
+ }
string WorkStatus = $"銆恵commonStackerCrane.StackerCraneWorkStatusValue}銆�";
-
+ bool IsWrite = false;
var content = _taskService.StackCraneTaskCompleted(e.TaskNum);
if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
@@ -246,25 +257,25 @@
var structs = BitConverter.GetBytes(InteractiveSignal).Reverse().ToArray().ToBoolArray();
if (structs[0])
{
- bool x = conveyorLine.Communicator.WriteNoRead("DB100.0", 9999);
- if (!x)
+ //IsWrite = conveyorLine.Communicator.WriteNoRead("DB100.0", Convert.ToInt32(0));
+ //Thread.Sleep(1000);
+ IsWrite = conveyorLine.Communicator.WriteNoRead("DB100.0", Convert.ToInt32(9999));
+ conveyorLine.Communicator.WriteNoRead("DB100.4", Convert.ToInt16(task.TaskNum));
+ if (!IsWrite)
{
return;
}
}
}
- var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.TargetAddress);
- if (station != null)
- {
- _taskService.SendAgvTask(station.stationRemark, task.TaskNum);
- _taskService.UpdateTaskStatusToNext(task.TaskNum);
- }
+
+ _taskService.UpdateTaskStatusToNext(task.TaskNum);
}
- var isWorkType = commonStackerCrane.SetValue(StackerCraneDBName.FinishConfirm, 1);
+ //var isWorkType = commonStackerCrane.SetValue(StackerCraneDBName.FinishConfirm, 1);
+ var isWorkType = commonStackerCrane.Communicator.WriteNoRead("DB100.0", Convert.ToInt16(1));
- str = $"{commonStackerCrane.DeviceName}銆慦MS|WCS浠诲姟瀹屾垚锛氥�恵content.Status}{content.Message}銆�,鍫嗗灈鏈哄畬鎴愪俊鍙峰啓鍏ワ細銆恵isWorkType}銆�,浠诲姟鍙凤細銆恵e.TaskNum}銆戞椂闂淬�恵DateTime.Now}銆�";
+ str = $"{commonStackerCrane.DeviceName}銆慦MS|WCS浠诲姟瀹屾垚锛氥�恵content.Status}{content.Message}銆�,鍫嗗灈鏈哄畬鎴愪俊鍙峰啓鍏ワ細銆恵isWorkType}銆�,浠诲姟鍙凤細銆恵e.TaskNum}銆戞椂闂淬�恵DateTime.Now}銆戣緭閫佺嚎鍐欏叆{IsWrite}";
WriteInfo(commonStackerCrane.DeviceName, str + WorkStatus);
ConsoleHelper.WriteColorLine(str, ConsoleColor.Blue);
}
@@ -320,6 +331,47 @@
}
else
{
+ string[] sourceCodes = task.SourceAddress.Split("-");
+ if (sourceCodes[0].Contains("3"))
+ {
+ var taskDto = new RequestTaskDto()
+ {
+ Position = task.SourceAddress,
+ PalletCode = task.PalletCode,
+ TaskNum = task.TaskNum
+ };
+
+ // 鑾峰彇WMSip鍦板潃
+ var configz = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+ var wmsBasez = configz.Where(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE).FirstOrDefault()?.ConfigValue;
+ var requestLocation = configz.Where(x => x.ConfigKey == SysConfigKeyConst.StackerIsNeedRelocation).FirstOrDefault()?.ConfigValue;
+ if (wmsBasez == null || requestLocation == null)
+ {
+ throw new InvalidOperationException("WMS IP 鏈厤缃�");
+ }
+ var wmsIpAddrss = wmsBasez + requestLocation;
+
+ var result = HttpHelper.PostAsync(wmsIpAddrss, taskDto.ToJsonString()).Result;
+
+ WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result);
+
+ if (!content.Status)
+ {
+ task.ExceptionMessage = content.Message;
+ _taskRepository.UpdateData(task);
+ return null;
+ }
+
+ // 鍙嶅簭鍒楀寲浠诲姟鏁版嵁
+ var taskDTO = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
+
+ if (taskDTO.TaskNum != task.TaskNum)
+ {
+ _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
+ return _taskRepository.QueryFirst(x => x.TaskNum == taskDTO.TaskNum);
+ }
+ }
+
CommonConveyorLine? conveyorLine = Storage.Devices.FirstOrDefault(x=>x.DeviceCode =="1001") as CommonConveyorLine;
if (conveyorLine != null)
{
@@ -337,12 +389,14 @@
else
{
task.ExceptionMessage = "璇锋鏌ヨ緭閫佺嚎鏄惁鏄嚜鍔ㄦā寮忔垨宸茬粡绉诲姩鍒板嚭搴撳彛";
+ _taskRepository.UpdateData(task);
return null;
}
}
else
{
task.ExceptionMessage = "杈撻�佺嚎璁惧鏂紑杩炴帴";
+ _taskRepository.UpdateData(task);
return null;
}
}
@@ -433,14 +487,13 @@
stackerCraneTaskCommand.TaskNum = Convert.ToInt16(task.TaskNum);
stackerCraneTaskCommand.WorkType = Convert.ToInt16(1);
- stackerCraneTaskCommand.StartCommand = Convert.ToInt16(1);
if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍒ゆ柇鏄惁鏄叆搴撲换鍔�
{
var station = _stationManagerRepository.QueryFirst(x => x.stationType == 1 && x.stationChildCode == task.CurrentAddress);
string[] sourceCodes = station.stationLocation.Split("-");
if (sourceCodes.Length == 3)
{
- stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2;
+ stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]);
stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
}
@@ -453,7 +506,7 @@
string[] targetCodes = task.NextAddress.Split("-");
if (targetCodes.Length == 3)
{
- stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]) % 2 != 0 ? (short)1 : (short)2;
+ stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]);
stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]);
stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]);
}
@@ -469,7 +522,7 @@
string[] sourceCodes = task.CurrentAddress.Split("-");
if (sourceCodes.Length == 3)
{
- stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2;
+ stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]);
stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
}
@@ -483,7 +536,7 @@
string[] targetCodes = station.stationLocation.Split("-");
if (targetCodes.Length == 3)
{
- stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]) % 2 != 0 ? (short)1 : (short)2;
+ stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]);
stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]);
stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]);
}
@@ -500,7 +553,7 @@
string[] sourceCodes = task.CurrentAddress.Split("-");
if (sourceCodes.Length == 3)
{
- stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]) % 2 != 0 ? (short)1 : (short)2;
+ stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]);
stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
}
@@ -514,7 +567,7 @@
string[] targetCodes = task.NextAddress.Split("-");
if (targetCodes.Length == 3)
{
- stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]) % 2 != 0 ? (short)1 : (short)2;
+ stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]);
stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]);
stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]);
}
--
Gitblit v1.9.3