From 90ac374a64e47e2bd97ee9245f4cafb50ad5dbbb Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期五, 17 四月 2026 17:31:02 +0800
Subject: [PATCH] 添加成品出库任务等待移库上报WMS
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs | 234 +++++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 156 insertions(+), 78 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
index 25fc196..0901fed 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
@@ -3,6 +3,7 @@
using NetTaste;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
@@ -106,19 +107,27 @@
else
{
bool Work = false;
- if (device.IsConnected)
+ try
{
- int i = 0;
- while (!Work && i <= 3)
+ if (device.IsConnected)
{
- i++;
- Work = device.SetValue(HoistEnum.Inboundboxon, 1, task.TargetAddress);
- Thread.Sleep(500);
+ int i = 0;
+ while (!Work && i <= 3)
+ {
+ i++;
+ Work = device.SetValue(HoistEnum.Inboundboxon, 1, task.TargetAddress);
+ Thread.Sleep(500);
+ }
+ }
+ if (!Work)
+ {
+ task.ExceptionMessage = $"銆恵task.TargetAddress}銆戝啓鍏�3妤煎叆搴撶鏀惧埌浣嶅け璐�";
+ task.Remark = $"{device.DeviceCode}_Inboundboxon_{1}_{task.TargetAddress}";
}
}
- if (!Work)
+ catch (Exception ex)
{
- task.ExceptionMessage = $"銆恵task.TargetAddress}銆戝啓鍏�3妤煎叆搴撶鏀惧埌浣嶅け璐�";
+ task.ExceptionMessage = $"銆恵task.TargetAddress}銆戝啓鍏�3妤煎叆搴撶鏀惧埌浣嶅け璐ワ紒{ex.Message}";
task.Remark = $"{device.DeviceCode}_Inboundboxon_{1}_{task.TargetAddress}";
}
}
@@ -133,21 +142,30 @@
else
{
bool Work = false;
- if (device.IsConnected)
+ try
{
- int i = 0;
- while (!Work && i <= 3)
+ if (device.IsConnected)
{
- i++;
- Work = device.SetValue(HoistEnum.Outboundboxon, 1, task.SourceAddress);//鍑哄簱瀹屾垚
- Thread.Sleep(500);
+ int i = 0;
+ while (!Work && i <= 3)
+ {
+ i++;
+ Work = device.SetValue(HoistEnum.Outboundboxon, 1, task.SourceAddress);//鍑哄簱瀹屾垚
+ Thread.Sleep(500);
+ }
+ }
+ if (!Work)
+ {
+ task.ExceptionMessage = $"銆恵task.SourceAddress}銆戝啓鍏�3妤煎嚭搴撶鏀惧埌浣嶅け璐�";
+ task.Remark = $"{device.DeviceCode}_Outboundboxon_{1}_{task.SourceAddress}";
}
}
- if (!Work)
+ catch (Exception ex)
{
task.ExceptionMessage = $"銆恵task.SourceAddress}銆戝啓鍏�3妤煎嚭搴撶鏀惧埌浣嶅け璐�";
- task.Remark = $"{device.DeviceCode}_Outboundboxon_{1}_{task.SourceAddress}";
+ task.Remark = $"{device.DeviceCode}_Outboundboxon_{1}_{task.SourceAddress}"; throw;
}
+
}
BaseDal.UpdateData(task);
}
@@ -159,21 +177,31 @@
else
{
bool Work = false;
- if (device.IsConnected)
+ try
{
- int i = 0;
- while (!Work && i <= 3)
+ if (device.IsConnected)
{
- i++;
- Work = device.SetValue(HoistEnum.Emptyboxplacedinposition, 1, task.TargetAddress);
- Thread.Sleep(500);
+ int i = 0;
+ while (!Work && i <= 3)
+ {
+ i++;
+ Work = device.SetValue(HoistEnum.Emptyboxplacedinposition, 1, task.TargetAddress);
+ Thread.Sleep(500);
+ }
+ }
+ if (!Work)
+ {
+ task.ExceptionMessage = $"銆恵task.TargetAddress}銆戝啓鍏�4妤肩┖绠辨斁鍒颁綅澶辫触";
+ task.Remark = $"{device.DeviceCode}_Emptyboxplacedinposition_{1}_{task.TargetAddress}";
}
}
- if (!Work)
+ catch (Exception ex)
{
+
task.ExceptionMessage = $"銆恵task.TargetAddress}銆戝啓鍏�4妤肩┖绠辨斁鍒颁綅澶辫触";
task.Remark = $"{device.DeviceCode}_Emptyboxplacedinposition_{1}_{task.TargetAddress}";
}
+
}
BaseDal.UpdateData(task);
}
@@ -185,21 +213,31 @@
else
{
bool Work = false;
- if (device.IsConnected)
+ try
{
- int i = 0;
- while (!Work && i <= 3)
+ if (device.IsConnected)
{
- i++;
- Work = device.SetValue(HoistEnum.Outboundboxretrievalcompleted, 1, task.SourceAddress);
- Thread.Sleep(500);
+ int i = 0;
+ while (!Work && i <= 3)
+ {
+ i++;
+ Work = device.SetValue(HoistEnum.Outboundboxretrievalcompleted, 1, task.SourceAddress);
+ Thread.Sleep(500);
+ }
+ }
+ if (!Work)
+ {
+ task.ExceptionMessage = $"銆恵task.SourceAddress}銆戝啓鍏�4妤煎嚭搴撳彇绠卞畬鎴愬け璐�";
+ task.Remark = $"{device.DeviceCode}_Outboundboxretrievalcompleted_{1}_{task.SourceAddress}";
}
}
- if (!Work)
+ catch (Exception ex)
{
+
task.ExceptionMessage = $"銆恵task.SourceAddress}銆戝啓鍏�4妤煎嚭搴撳彇绠卞畬鎴愬け璐�";
task.Remark = $"{device.DeviceCode}_Outboundboxretrievalcompleted_{1}_{task.SourceAddress}";
}
+
}
BaseDal.UpdateData(task);
}
@@ -212,21 +250,31 @@
{
bool Wok = false;
var Address = task.TaskType == TaskTypeEnum.Q3RK.ObjToInt() ? task.TargetAddress : task.SourceAddress;
- if (device.IsConnected)
+ try
{
- int i = 0;
- while (!Wok && i <= 3)
+ if (device.IsConnected)
{
- i++;
- Wok = device.SetValue(QualityInspectionCommandEnum.RequestToEnter, false, Address);
- Thread.Sleep(500);
+ int i = 0;
+ while (!Wok && i <= 3)
+ {
+ i++;
+ Wok = device.SetValue(QualityInspectionCommandEnum.RequestToEnter, false, Address);
+ Thread.Sleep(500);
+ }
+ }
+ if (!Wok)
+ {
+ task.ExceptionMessage = $"銆恵Address}銆戝叧闂姹傝繘鍏ュけ璐ワ紒";
+ task.Remark = $"{device.DeviceCode}_RequestToEnter_{false}_{Address}";
}
}
- if (!Wok)
+ catch (Exception ex)
{
+
task.ExceptionMessage = $"銆恵Address}銆戝叧闂姹傝繘鍏ュけ璐ワ紒";
task.Remark = $"{device.DeviceCode}_RequestToEnter_{false}_{Address}";
}
+
}
BaseDal.UpdateData(task);
}
@@ -246,21 +294,31 @@
else
{
bool Wok = false;
- if (device.IsConnected)
+ try
{
- int i = 0;
- while (!Wok && i <= 3)
+ if (device.IsConnected)
{
- i++;
- Wok = device.SetValue<HoistEnum, short>(HoistEnum.Codereadingtriggered, 1, "TSJR3F");
- Thread.Sleep(500);
+ int i = 0;
+ while (!Wok && i <= 3)
+ {
+ i++;
+ Wok = device.SetValue<HoistEnum, short>(HoistEnum.Codereadingtriggered, 1, "TSJR3F");
+ Thread.Sleep(500);
+ }
+ }
+ if (!Wok)
+ {
+ task.ExceptionMessage = $"銆怲SJR3F銆�3妤艰鐮佽Е鍙戝け璐ワ紒";
+ task.Remark = $"{device.DeviceCode}_Codereadingtriggered_{1}_TSJR3F";
}
}
- if (!Wok)
+ catch (Exception ex)
{
+
task.ExceptionMessage = $"銆怲SJR3F銆�3妤艰鐮佽Е鍙戝け璐ワ紒";
task.Remark = $"{device.DeviceCode}_Codereadingtriggered_{1}_TSJR3F";
}
+
}
task.TaskState = (int)TaskStatusEnum.CheckPalletCodeing;
BaseDal.UpdateData(task);
@@ -317,31 +375,40 @@
var task = BaseDal.QueryFirst(x => x.PalletCode == Rgv.content.podID);
if (task == null) throw new Exception($"鏈壘鍒颁换鍔�,浠诲姟缂栧彿銆恵Rgv.content.taskID}銆�");
//绉诲簱
- if (task.TaskType == TaskTypeEnum.CPMoveInventory.ObjToInt() && Rgv.messageType == 10 && Rgv.content.status == 4)
+ if (task.TaskType == TaskTypeEnum.CPMoveInventory.ObjToInt() && string.IsNullOrEmpty(task.WMSTaskNum))
{
- deviceName += "绉诲簱";
- WMSMoveLocationFeedback wMSMoveLocationFeedback = new WMSMoveLocationFeedback()
+ if (Rgv.messageType == 72)
{
- containerCode = task.PalletCode,
- fromStationCode = task.SourceAddress,
- toLocationCode = task.TargetAddress
- };
- Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(WMSMoveLocationFeedback));
- WMSReturn agvContent = null;
- if (apiInfo == null) task.ExceptionMessage = "鏈壘鍒扮Щ搴撳畬鎴愬弽棣圵MS鎺ュ彛閰嶇疆淇℃伅锛佽妫�鏌ユ帴鍙i厤缃�";
- else
+ task.TaskState = TaskStatusEnum.TakeFinish.ObjToInt();
+ BaseDal.UpdateData(task);
+ UpdateLocationStatus(task.SourceAddress, task.PalletCode, deviceTypeEnum, LocationStatusEnum.Free);
+ }
+ if (Rgv.messageType == 10 && Rgv.content.status == 4)
{
- task.TaskState = TaskStatusEnum.Finish.ObjToInt();
- string response = HttpHelper.Post(apiInfo.ApiAddress, wMSMoveLocationFeedback.Serialize());
- agvContent = response.DeserializeObject<WMSReturn>();
- content.OK(data: agvContent);
- if (agvContent.code != 200)
+ deviceName += "绉诲簱";
+ WMSMoveLocationFeedback wMSMoveLocationFeedback = new WMSMoveLocationFeedback()
{
- task.ExceptionMessage = agvContent.message;
- content.Error(agvContent.message);
+ containerCode = task.PalletCode,
+ fromStationCode = task.SourceAddress,
+ toLocationCode = task.TargetAddress
+ };
+ Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(WMSMoveLocationFeedback));
+ WMSReturn agvContent = null;
+ if (apiInfo == null) task.ExceptionMessage = "鏈壘鍒扮Щ搴撳畬鎴愬弽棣圵MS鎺ュ彛閰嶇疆淇℃伅锛佽妫�鏌ユ帴鍙i厤缃�";
+ else
+ {
+ task.TaskState = TaskStatusEnum.Finish.ObjToInt();
+ string response = HttpHelper.Post(apiInfo.ApiAddress, wMSMoveLocationFeedback.Serialize());
+ agvContent = response.DeserializeObject<WMSReturn>();
+ content.OK(data: agvContent);
+ if (agvContent.code != 200)
+ {
+ task.ExceptionMessage = agvContent.message;
+ content.Error(agvContent.message);
+ }
+ UpdateLocationStatus(task.TargetAddress, task.PalletCode, deviceTypeEnum, LocationStatusEnum.InStock);
+ BaseDal.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚);
}
- UpdateLocationStatus(task.TargetAddress, task.PalletCode, deviceTypeEnum, LocationStatusEnum.InStock);
- BaseDal.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚);
}
}
else
@@ -352,15 +419,18 @@
if (task.TaskType == (int)TaskTypeEnum.CPInbound && task.TaskState == (int)TaskStatusEnum.Execut)
{
task.TaskState = (int)TaskStatusEnum.WaiCheckShape;
- //BaseDal.UpdateData(task);//缁欒川妫�闂ㄥ啓鍏ュ惎鍔ㄤ俊鍙�
- var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "F1") as OtherDevice;
- if (device == null) task.ExceptionMessage = "鏈壘鍒�1妤艰川妫�闂ㄨ澶囦俊鎭�";
- else
+ if (task.SourceAddress != "OUT-01")
{
- if (device.IsConnected)
- device.SetValue(QualityInspectionCommandEnum.StartqualityInspection, true, task.SourceAddress);
+ //BaseDal.UpdateData(task);//缁欒川妫�闂ㄥ啓鍏ュ惎鍔ㄤ俊鍙�
+ var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "F1") as OtherDevice;
+ if (device == null) task.ExceptionMessage = "鏈壘鍒�1妤艰川妫�闂ㄨ澶囦俊鎭�";
else
- task.ExceptionMessage = "1妤艰川妫�闂ㄨ澶囪繛鎺ュけ璐�";
+ {
+ if (device.IsConnected)
+ device.SetValue(QualityInspectionCommandEnum.StartqualityInspection, true, task.SourceAddress);
+ else
+ task.ExceptionMessage = "1妤艰川妫�闂ㄨ澶囪繛鎺ュけ璐�";
+ }
}
TaskFeedback(task, 4);
}
@@ -397,16 +467,24 @@
{
task.ExceptionMessage = Rgv.content.errorReason;
var Error = _taskErrorMessageService.Repository.QueryFirst(x => x.ErrorCode == Rgv.content.errorCode && x.DeviceType == (int)deviceTypeEnum);
- if (Error != null)
+ if (task.TaskType == (int)TaskTypeEnum.CPOutbound && task.TaskState == (int)TaskStatusEnum.Execut && Rgv.content.errorCode == 1330003)//鎴愬搧鍑哄簱浠诲姟涓嬪彂鍚庡弽棣堟湁闃荤鎵橈紝淇敼浠诲姟鐘舵�佷负鏂板缓閲嶆柊鏌ヨ闃荤鎵樺叧绯�
{
- task.ExceptionMessage = Error.ExceptionMessage;
- MatchCollection matches = Regex.Matches(Rgv.content.errorReason, @"\(([^)]+)\)");
- if (matches.Count > 0)
- task.ExceptionMessage = ReplacePlaceholders(Rgv.content.errorReason, Error.ExceptionMessage);
- ErrorTaskFeedback(task, true, Error.ErrorCode.ToString());
+ task.TaskState = (int)TaskStatusEnum.New;
+ BaseDal.UpdateData(task);
}
else
- ErrorTaskFeedback(task, true);
+ {
+ if (Error != null)
+ {
+ task.ExceptionMessage = Error.ExceptionMessage;
+ MatchCollection matches = Regex.Matches(Rgv.content.errorReason, @"\(([^)]+)\)");
+ if (matches.Count > 0)
+ task.ExceptionMessage = ReplacePlaceholders(Rgv.content.errorReason, Error.ExceptionMessage);
+ ErrorTaskFeedback(task, true, Error.ErrorCode.ToString());
+ }
+ else
+ ErrorTaskFeedback(task, true);
+ }
}
}
}
--
Gitblit v1.9.3