From 0b2869539598059704e1d208e2bcb18603b0fe0f Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 01 五月 2026 00:00:30 +0800
Subject: [PATCH] feat(出库时效): 添加出库时效配置功能
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs | 172 ++++++++++++++++++++++++--------------------------------
1 files changed, 74 insertions(+), 98 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
index 8b45c00..fa281cd 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
@@ -1,16 +1,11 @@
using MapsterMapper;
using Masuit.Tools;
-using Microsoft.Extensions.Configuration;
-using Newtonsoft.Json;
using Quartz;
using Serilog;
using SqlSugar;
using WIDESEA_Core;
-using WIDESEAWCS_Common.HttpEnum;
using WIDESEAWCS_Common.TaskEnum;
-using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
-using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
@@ -88,7 +83,7 @@
/// </summary>
/// <remarks>
/// </remarks>
- private static List<string> AddressToDeviceType = new List<string> { "11020", "11028", "2125" };
+ private static List<string> AddressToDeviceType = new List<string> { "11020", "11028", "2125", "11062" };
/// <summary>
/// 鎵樼洏妫�鏌ヤ綅缃殑鏈�杩戞墽琛屾椂闂达紙鐢ㄤ簬30绉掗棿闅旈檺鍒讹級
@@ -168,57 +163,57 @@
// ========== 妫�鏌ョ壒瀹氫綅缃槸鍚︽湁鎵樼洏 ==========
// 浠庨厤缃腑璇诲彇闇�瑕佹鏌ユ墭鐩樼殑浣嶇疆鍒楄〃
- var checkPalletPositions = App.Configuration.GetSection("CheckPalletPositions")
- .Get<List<CheckPalletPosition>>() ?? new List<CheckPalletPosition>();
+ //var checkPalletPositions = App.Configuration.GetSection("CheckPalletPositions")
+ // .Get<List<CheckPalletPosition>>() ?? new List<CheckPalletPosition>();
- // 濡傛灉褰撳墠璁惧鍦ㄦ鏌ュ垪琛ㄤ腑
- if (checkPalletPositions.Any(x => x.Code == childDeviceCode))
- {
- // 30绉掗棿闅旈檺鍒�
- if (_lastPalletCheckTime.TryGetValue(childDeviceCode, out var lastTime) &&
- (DateTime.Now - lastTime).TotalSeconds < 30)
- {
- continue;
- }
+ //// 濡傛灉褰撳墠璁惧鍦ㄦ鏌ュ垪琛ㄤ腑
+ //if (checkPalletPositions.Any(x => x.Code == childDeviceCode))
+ //{
+ // // 30绉掗棿闅旈檺鍒�
+ // if (_lastPalletCheckTime.TryGetValue(childDeviceCode, out var lastTime) &&
+ // (DateTime.Now - lastTime).TotalSeconds < 30)
+ // {
+ // continue;
+ // }
- // 妫�鏌ヨ緭閫佺嚎鐘舵�侊紙鏄惁鏈夋墭鐩橈級
- if (command.CV_State == 2)
- {
- // 妫�鏌ヨ浣嶇疆鏄惁宸叉湁浠诲姟
- var existingTask = _taskService.Db.Queryable<Dt_Task>().Count(x => x.TargetAddress == childDeviceCode);
- if (existingTask < 5)
- {
- // 娌℃湁浠诲姟锛屽悜 WMS 璇锋眰鍑哄簱鎵樼洏浠诲姟
- var position = checkPalletPositions.FirstOrDefault(x => x.Code == childDeviceCode);
+ // // 妫�鏌ヨ緭閫佺嚎鐘舵�侊紙鏄惁鏈夋墭鐩橈級
+ // if (command.CV_State == 2)
+ // {
+ // // 妫�鏌ヨ浣嶇疆鏄惁宸叉湁浠诲姟
+ // var existingTask = _taskService.Db.Queryable<Dt_Task>().Count(x => x.TargetAddress == childDeviceCode);
+ // if (existingTask < 5)
+ // {
+ // // 娌℃湁浠诲姟锛屽悜 WMS 璇锋眰鍑哄簱鎵樼洏浠诲姟
+ // var position = checkPalletPositions.FirstOrDefault(x => x.Code == childDeviceCode);
- string configKey = "GetOutBoundTrayTaskAsync";
- string requestParam = new CreateTaskDto()
- {
- WarehouseId = position.WarehouseId,
- TargetAddress = childDeviceCode
- }.Serialize();
- DateTime startTime = DateTime.Now;
+ // string configKey = "GetOutBoundTrayTaskAsync";
+ // string requestParam = new CreateTaskDto()
+ // {
+ // WarehouseId = position.WarehouseId,
+ // TargetAddress = childDeviceCode
+ // }.Serialize();
+ // DateTime startTime = DateTime.Now;
- var responseResult = _httpClientHelper.Post<WebResponseContent>(configKey, requestParam);
+ // var responseResult = _httpClientHelper.Post<WebResponseContent>(configKey, requestParam);
- _lastPalletCheckTime[childDeviceCode] = DateTime.Now;
+ // _lastPalletCheckTime[childDeviceCode] = DateTime.Now;
- // 濡傛灉璇锋眰鎴愬姛锛屾帴鏀� WMS 杩斿洖鐨勪换鍔�
- if (responseResult.IsSuccess && responseResult.Data.Status)
- {
- QuartzLogHelper.LogInfo(_logger, $"璋冪敤WMS鎺ュ彛鎴愬姛,鎺ュ彛:銆恵configKey}銆�,璇锋眰鍙傛暟:銆恵requestParam}銆�,鍝嶅簲鏁版嵁:銆恵responseResult.Data?.Data}銆�,鑰楁椂:{(DateTime.Now - startTime).TotalMilliseconds}ms", conveyorLine.DeviceCode);
- var wmsTask = JsonConvert.DeserializeObject<WMSTaskDTO>(responseResult.Data.Data.ToString());
- List<WMSTaskDTO> taskDTOs = new List<WMSTaskDTO> { wmsTask };
- if (wmsTask != null)
- _taskService.ReceiveWMSTask(taskDTOs);
- }
- else
- {
- QuartzLogHelper.LogError(_logger, $"璋冪敤WMS鎺ュ彛澶辫触,鎺ュ彛:銆恵configKey}銆�,璇锋眰鍙傛暟:銆恵requestParam}銆�,閿欒淇℃伅:銆恵responseResult.Data?.Message}銆�", conveyorLine.DeviceCode);
- }
- }
- }
- }
+ // // 濡傛灉璇锋眰鎴愬姛锛屾帴鏀� WMS 杩斿洖鐨勪换鍔�
+ // if (responseResult.IsSuccess && responseResult.Data.Status)
+ // {
+ // QuartzLogHelper.LogInfo(_logger, $"璋冪敤WMS鎺ュ彛鎴愬姛,鎺ュ彛:銆恵configKey}銆�,璇锋眰鍙傛暟:銆恵requestParam}銆�,鍝嶅簲鏁版嵁:銆恵responseResult.Data?.Data}銆�,鑰楁椂:{(DateTime.Now - startTime).TotalMilliseconds}ms", conveyorLine.DeviceCode);
+ // var wmsTask = JsonConvert.DeserializeObject<WMSTaskDTO>(responseResult.Data.Data.ToString());
+ // List<WMSTaskDTO> taskDTOs = new List<WMSTaskDTO> { wmsTask };
+ // if (wmsTask != null)
+ // _taskService.ReceiveWMSTask(taskDTOs);
+ // }
+ // else
+ // {
+ // QuartzLogHelper.LogError(_logger, $"璋冪敤WMS鎺ュ彛澶辫触,鎺ュ彛:銆恵configKey}銆�,璇锋眰鍙傛暟:銆恵requestParam}銆�,閿欒淇℃伅:銆恵responseResult.Data?.Message}銆�", conveyorLine.DeviceCode);
+ // }
+ // }
+ // }
+ //}
#endregion 妫�娴嬫槸鍚﹂渶瑕佺┖鎵樼洏
@@ -228,7 +223,11 @@
{
// 濡傛灉 WCS_ACK 涓� 1锛屽厛娓呴櫎锛堣〃绀哄鐞嗚繃涓婁竴娆¤姹傦級
if (command.WCS_ACK == 1)
- conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, (short)0, childDeviceCode);
+ {
+ conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, (byte)0, childDeviceCode);
+ //Thread.Sleep(300);
+ //conveyorLine.SetValue(ConveyorLineDBNameNew.Target, (short)0, childDeviceCode);
+ }
// 澶勭悊鎵嬪姩鍏ュ簱浠诲姟锛堣捣鐐逛负绾夸綋鐐逛綅鐨勪换鍔★級
try
@@ -247,17 +246,36 @@
}
continue;
}
+ else
+ {
+ if (childDeviceCode == "2103" || childDeviceCode == "2101")
+ {
+ try
+ {
+ var task = _taskService.QueryManualInboundTask(childDeviceCode);
+ if (task != null)
+ {
+ QuartzLogHelper.LogInfo(_logger, $"鑾峰彇鍒拌緭閫佺嚎寮�濮嬩换鍔★紝浠诲姟鍙凤細{task.TaskNum}锛岀姸鎬�: {task.TaskStatus},褰撳墠鍦板潃锛歿conveyorLine.DeviceCode}", conveyorLine.DeviceCode);
+ var handler = new ManualInboundTaskHandler(_taskService, _logger);
+ handler.WriteTaskToPlc(conveyorLine, childDeviceCode, task);
+ }
+ }
+ catch (Exception ex)
+ {
+ QuartzLogHelper.LogError(_logger, ex, "澶勭悊鎵嬪姩鍏ュ簱浠诲姟寮傚父", $"澶勭悊鎵嬪姩鍏ュ簱浠诲姟寮傚父: {ex.Message}", "CommonConveyorLineNewJob");
+ }
+ }
+ }
- // ========== 澶勭悊鏃犳墭鐩樻潯鐮佺殑鎯呭喌 ==========
- // 鏃犳墭鐩樻潯鐮佹椂锛岃姹傚嚭搴撲换鍔�
- if (command.Barcode.IsNullOrEmpty() || command.Barcode.Replace("\0", "") == "")
+ // 濡傛灉 PLC_STB 涓� 1锛屼絾娌℃湁浠诲姟鍙凤紝鍙兘鏄柊浠诲姟鐨勫紑濮嬶紝鍏堣姹傚嚭搴撲换鍔★紙閫傜敤浜庢棤鏉$爜鐨勬儏鍐碉級
+ if (command.TaskNo == 1000)
{
_conveyorLineDispatch.RequestOutbound(conveyorLine, command, childDeviceCode);
continue;
}
// ========== 澶勭悊宸叉湁浠诲姟鍙风殑鎯呭喌 ==========
- if (command.TaskNo > 0 && !command.Barcode.IsNullOrEmpty())
+ if (command.TaskNo > 0)
{
// 鏌ヨ姝e湪鎵ц鐨勪换鍔�
Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNo, childDeviceCode);
@@ -297,48 +315,6 @@
{
QuartzLogHelper.LogInfo(_logger, $"鐢熶骇鏈烘鎵嬩换鍔℃垚鍔燂紝 {robotTask.RobotTaskNum}锛岀姸鎬�: {robotTask.RobotTaskState},褰撳墠鍦板潃锛歿conveyorLine.DeviceCode}", conveyorLine.DeviceCode);
conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, (short)1, childDeviceCode);
- }
- }
- else if (!command.Barcode.IsNullOrEmpty() && (childDeviceCode == "11001" || childDeviceCode == "11010"))
- {
- var isWcsTask = _taskService.Db.Queryable<Dt_Task>().Any(x => x.PalletCode == command.Barcode && (x.TaskStatus == (int)TaskOutStatusEnum.OutNew || x.TaskStatus == (int)TaskInStatusEnum.InNew));
- var isRobotTask = _robotTaskService.Db.Queryable<Dt_RobotTask>().Any(x => x.RobotTargetAddressPalletCode == command.Barcode);
- if (isWcsTask || isRobotTask)
- {
- continue;
- }
-
- // 璋冪敤 WMS 鍒涘缓绌烘墭鐩樺叆搴撲换鍔�
- string configKey = nameof(ConfigKey.CreateTaskInboundAsync);
- string requestParam = new CreateTaskDto()
- {
- PalletCode = command.Barcode,
- SourceAddress = childDeviceCode,
- TargetAddress = "GWSC1", // 鐩爣鍦板潃
- Roadway = "GWSC1", // 宸烽亾
- WarehouseId = 1, // 浠撳簱 ID
- PalletType = 1, // 鎵樼洏绫诲瀷锛堥粯璁や负1锛�
- TaskType = TaskTypeEnum.InEmpty.GetHashCode() // 浠诲姟绫诲瀷锛堝叆搴�/绌烘墭鐩樺叆搴擄級
- }.Serialize();
- DateTime startTime = DateTime.Now;
-
- var responseResult = _httpClientHelper.Post<WebResponseContent>(configKey, requestParam);
-
- if (responseResult.IsSuccess && responseResult.Data.Status)
- {
- QuartzLogHelper.LogInfo(_logger, $"璋冪敤WMS鎺ュ彛鎴愬姛,鎺ュ彛:銆恵configKey}銆�,璇锋眰鍙傛暟:銆恵requestParam}銆�,鍝嶅簲鏁版嵁:銆恵responseResult.Data?.Data}銆�,鑰楁椂:{(DateTime.Now - startTime).TotalMilliseconds}ms", conveyorLine.DeviceCode);
- var wmsTask = JsonConvert.DeserializeObject<WMSTaskDTO>(responseResult?.Data?.Data?.ToString());
- List<WMSTaskDTO> taskDTOs = new List<WMSTaskDTO> { wmsTask };
- if (wmsTask == null) continue;
-
- if (_taskService.ReceiveWMSTask(taskDTOs).Status)
- {
- conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, (short)1, childDeviceCode);
- }
- }
- else
- {
- QuartzLogHelper.LogError(_logger, $"璋冪敤WMS鎺ュ彛澶辫触,鎺ュ彛:銆恵configKey}銆�,璇锋眰鍙傛暟:銆恵requestParam}銆�,閿欒淇℃伅:銆恵responseResult.Data?.Message}銆�", conveyorLine.DeviceCode);
}
}
}
--
Gitblit v1.9.3