From 92417fc26db8af34d2f88602aa5dc846d0a67665 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 10 九月 2025 09:25:46 +0800
Subject: [PATCH] 1
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/AGVController.cs | 44 ++++++++++++++++++++++++++++++++++----------
1 files changed, 34 insertions(+), 10 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/AGVController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/AGVController.cs"
index 5511010..9ea87aa 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/AGVController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/AGVController.cs"
@@ -1,5 +1,6 @@
锘縰sing Microsoft.AspNetCore.Mvc;
using NewLife.Net;
+using System.Threading.Tasks;
using WIDESEA_DTO.AGV;
using WIDESEA_IStoragIntegrationServices;
using WIDESEA_StorageSocketServices;
@@ -15,6 +16,7 @@
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IAGVService _service;
+ public static bool Islock = true; // 閿侊紝闃叉閲嶅璇锋眰
public AGVController(IAGVService service, IHttpContextAccessor httpContextAccessor)
{
@@ -24,8 +26,7 @@
/// <summary>
/// 璇锋眰鍏ュ簱浠诲姟
/// </summary>
- /// <param name="TaskNum"></param>
- /// <param name="SourceAddress"></param>
+ /// <param name="aGVDTO"></param>
/// <returns></returns>
[HttpGet, HttpPost, Route("RequestInTask"), AllowAnonymous]
public WebResponseContent RequestInTask([FromBody] AGVDTO aGVDTO)
@@ -47,8 +48,7 @@
/// <summary>
/// AGV浠诲姟寮�濮嬫垨缁撴潫
/// </summary>
- /// <param name="Status"></param>
- /// <param name="TaskNum"></param>
+ /// <param name="aGVDTO"></param>
/// <returns></returns>
[HttpGet, HttpPost, Route("AGVStartOrEndJob"), AllowAnonymous]
public WebResponseContent AGVStartOrEndJob([FromBody] AGVDTO aGVDTO)
@@ -59,8 +59,7 @@
/// <summary>
/// 璁惧鐘舵�佷笂鎶�
/// </summary>
- /// <param name="Message"></param>
- /// <param name="PallteCode"></param>
+ /// <param name="aGVDTO"></param>
/// <returns></returns>
[HttpGet, HttpPost, Route("DeviceErrorResponse"), AllowAnonymous]
public WebResponseContent DeviceErrorResponse([FromBody] AGVDTO aGVDTO)
@@ -71,13 +70,38 @@
/// <summary>
/// 璁惧寮傚父涓婃姤
/// </summary>
- /// <param name="Message"></param>
- /// <param name="PallteCode"></param>
+ /// <param name="DTO"></param>
/// <returns></returns>
[HttpGet, HttpPost, Route("DeviceWarning"), AllowAnonymous]
- public WebResponseContent DeviceWarning([FromBody] AGVDTO DTO)
+ [TypeFilter(typeof(ThrottleFilter), Arguments = new object[] { 10 })] // 10绉掕妭娴�
+ public async Task<WebResponseContent> DeviceWarning([FromBody] AGVDTO DTO)
{
- return _service.DeviceWarning(DTO);
+ WebResponseContent responseContent = new WebResponseContent();
+ try
+ {
+ // 浣跨敤鐪熸鐨勯攣缁撴瀯
+ if (Islock)
+ {
+ Islock = false;
+ try
+ {
+ return await Task.Run(()=> _service.DeviceWarning(DTO));
+ }
+ finally
+ {
+ Islock = true;
+ }
+ }
+ else
+ {
+ return responseContent.Error("璇锋眰杩囦簬棰戠箒锛岃绋嶅悗鍐嶈瘯");
+ }
+ }
+ catch (Exception ex)
+ {
+ // 涓嶉渶瑕佸湪杩欓噷閲婃斁閿侊紝鍥犱负TryEnter鎴愬姛鍚庝細鍦╢inally涓噴鏀�
+ return responseContent.Error($"璁惧寮傚父涓婃姤澶辫触: {ex.Message}");
+ }
}
}
}
--
Gitblit v1.9.3