From 5171d3f59b89389bf75293afd210cfa6de4ccff7 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 10 四月 2026 23:03:49 +0800
Subject: [PATCH] feat: 添加堆垛机相关常量类并重构代码使用常量
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs | 130 ++++++++++++++++++++++++++++++-------------
1 files changed, 90 insertions(+), 40 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs
index 71a7821..d4fde20 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs
@@ -4,6 +4,7 @@
using SqlSugar;
using System.DirectoryServices.Protocols;
using System.Text.Json;
+using WIDESEA_Common.Constants;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Common.StockEnum;
using WIDESEA_Common.TaskEnum;
@@ -193,12 +194,42 @@
WebResponseContent content = new WebResponseContent();
stockInfo.LocationCode = location.LocationCode;
stockInfo.LocationId = location.Id;
- stockInfo.OutboundDate = task.Roadway switch
+
+ var now = DateTime.Now;
+ if (task.Roadway.Contains("GW"))
{
- var r when r.Contains("GW") => DateTime.Now.AddHours(2),
- var r when r.Contains("CW") => DateTime.Now.AddHours(1),
- _ => DateTime.Now
- };
+ if (stockInfo.Remark.IsNullOrEmpty())
+ {
+ stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_GW1_FIRST);
+ stockInfo.Remark = StockRemarkConstants.GW1;
+ }
+ else if (stockInfo.Remark == StockRemarkConstants.GW1)
+ {
+ stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_GW1_SECOND);
+ stockInfo.Remark = StockRemarkConstants.GW2;
+ }
+ else
+ {
+ stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_GW1_FIRST);
+ }
+ }
+ else if (task.Roadway.Contains("CW"))
+ {
+ if (stockInfo.Remark == StockRemarkConstants.GW2)
+ {
+ stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_CW1);
+ stockInfo.Remark = StockRemarkConstants.CW1;
+ }
+ else
+ {
+ stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_CW1);
+ }
+ }
+ else
+ {
+ stockInfo.OutboundDate = now;
+ }
+
stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.GetHashCode();
location.LocationStatus = LocationStatusEnum.InStock.GetHashCode();
@@ -208,18 +239,18 @@
if (!updateLocationResult || !updateStockResult)
return WebResponseContent.Instance.Error("浠诲姟瀹屾垚澶辫触");
// 璋冪敤MES鎵樼洏杩涚珯
- var inboundRequest = new InboundInContainerRequest
- {
- EquipmentCode = "STK-GROUP-001",
- ResourceCode = "STK-GROUP-001",
- LocalTime = DateTime.Now,
- ContainerCode = taskDto.PalletCode
- };
- var inboundResult = _mesService.InboundInContainer(inboundRequest);
- if (inboundResult == null || inboundResult.Data == null || !inboundResult.Data.IsSuccess)
- {
- return content.Error($"浠诲姟瀹屾垚澶辫触锛歁ES杩涚珯澶辫触: {inboundResult?.Data?.Msg ?? inboundResult?.ErrorMessage ?? "鏈煡閿欒"}");
- }
+ //var inboundRequest = new InboundInContainerRequest
+ //{
+ // EquipmentCode = "STK-GROUP-001",
+ // ResourceCode = "STK-GROUP-001",
+ // LocalTime = DateTime.Now,
+ // ContainerCode = taskDto.PalletCode
+ //};
+ //var inboundResult = _mesService.InboundInContainer(inboundRequest);
+ //if (inboundResult == null || inboundResult.Data == null || !inboundResult.Data.IsSuccess)
+ //{
+ // return content.Error($"浠诲姟瀹屾垚澶辫触锛歁ES杩涚珯澶辫触: {inboundResult?.Data?.Msg ?? inboundResult?.ErrorMessage ?? "鏈煡閿欒"}");
+ //}
return await CompleteTaskAsync(task, "鍏ュ簱瀹屾垚");
});
}
@@ -272,19 +303,19 @@
return WebResponseContent.Instance.Error("浠诲姟瀹屾垚澶辫触");
// 璋冪敤MES鎵樼洏鍑虹珯
- var outboundRequest = new OutboundInContainerRequest
- {
- EquipmentCode = "STK-GROUP-001",
- ResourceCode = "STK-GROUP-001",
- LocalTime = DateTime.Now,
- ContainerCode = taskDto.PalletCode,
- ParamList = new List<ParamItem>()
- };
- var outboundResult = _mesService.OutboundInContainer(outboundRequest);
- if (outboundResult == null || outboundResult.Data == null || !outboundResult.Data.IsSuccess)
- {
- return content.Error($"浠诲姟瀹屾垚澶辫触锛歁ES鍑虹珯澶辫触: {outboundResult?.Data?.Msg ?? outboundResult?.ErrorMessage ?? "鏈煡閿欒"}");
- }
+ //var outboundRequest = new OutboundInContainerRequest
+ //{
+ // EquipmentCode = "STK-GROUP-001",
+ // ResourceCode = "STK-GROUP-001",
+ // LocalTime = DateTime.Now,
+ // ContainerCode = taskDto.PalletCode,
+ // ParamList = new List<ParamItem>()
+ //};
+ //var outboundResult = _mesService.OutboundInContainer(outboundRequest);
+ //if (outboundResult == null || outboundResult.Data == null || !outboundResult.Data.IsSuccess)
+ //{
+ // return content.Error($"浠诲姟瀹屾垚澶辫触锛歁ES鍑虹珯澶辫触: {outboundResult?.Data?.Msg ?? outboundResult?.ErrorMessage ?? "鏈煡閿欒"}");
+ //}
return await CompleteTaskAsync(task, "鍑哄簱瀹屾垚");
});
@@ -426,6 +457,13 @@
{
try
{
+ var dt_Task = await BaseDal.QueryFirstAsync(x => x.TargetAddress == taskDto.TargetAddress);
+ if (!dt_Task.IsNullOrEmpty())
+ {
+ var taskDTO = dt_Task.Adapt<WMSTaskDTO>();
+ return WebResponseContent.Instance.OK("浠诲姟鍒涘缓鎴愬姛", taskDTO);
+ }
+
var stockInfo = await _stockInfoService.Repository.QueryDataNavFirstAsync(x => x.LocationDetails.WarehouseId == taskDto.WarehouseId && x.LocationDetails.LocationStatus == LocationStatusEnum.InStock.GetHashCode() && x.StockStatus == StockStatusEmun.绌烘墭鐩樺簱瀛�.GetHashCode());
if (stockInfo == null)
return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑搴撳瓨淇℃伅");
@@ -446,12 +484,22 @@
TaskNum = await BaseDal.GetTaskNo(),
Creater = "system",
};
- var taskDtos = task.Adapt<WMSTaskDTO>();
- var addResult = await BaseDal.AddDataAsync(task) > 0;
- if (!addResult)
- return WebResponseContent.Instance.Error("浠诲姟鍒涘缓澶辫触");
- return WebResponseContent.Instance.OK("浠诲姟鍒涘缓鎴愬姛", taskDtos);
+ return await ExecuteWithinTransactionAsync(async () =>
+ {
+ var locationInfo = await _locationInfoService.GetLocationInfoAsync(stockInfo.LocationId);
+ locationInfo.LocationStatus = LocationStatusEnum.InStockLock.GetHashCode();
+ var updateLocationResult = await _locationInfoService.UpdateLocationInfoAsync(locationInfo);
+ if (!updateLocationResult)
+ return WebResponseContent.Instance.Error("浠诲姟鍒涘缓澶辫触");
+
+ var taskDtos = task.Adapt<WMSTaskDTO>();
+
+ var addResult = await BaseDal.AddDataAsync(task) > 0;
+ if (!addResult)
+ return WebResponseContent.Instance.Error("浠诲姟鍒涘缓澶辫触");
+ return WebResponseContent.Instance.OK("浠诲姟鍒涘缓鎴愬姛", taskDtos);
+ });
}
catch (Exception ex)
{
@@ -590,8 +638,9 @@
var taskList = new List<Dt_Task>();
foreach (var stock in stocksToProcess)
{
- // 鏍规嵁宸烽亾纭畾鐩爣鍦板潃
- var targetAddress = DetermineTargetAddress(
+ // 鏍规嵁宸烽亾纭畾鐩爣鍦板潃锛堜紭鍏堟牴鎹� Remark 纭畾锛孯emark 涓虹┖鍒欐牴鎹贩閬撻厤缃級
+ var targetAddress = DetermineTargetAddressByRemark(
+ stock.Remark ?? "",
stock.LocationDetails?.RoadwayNo ?? "",
targetAddressMap);
@@ -776,6 +825,7 @@
if (stockInfo.LocationId > 0 || !string.IsNullOrWhiteSpace(stockInfo.LocationCode))
return WebResponseContent.Instance.Error($"鎵樼洏[{stockPalletCode}]搴撳瓨宸茬粦瀹氳揣浣嶏紝涓嶈兘鍒涘缓鏈烘鎵媨taskName}浠诲姟");
}
+ var section = App.Configuration.GetSection("RobotTaskAddressRules").GetSection(targetLineNo).GetChildren().Select(c => c.Value).ToArray();
var task = new Dt_Task
{
@@ -785,9 +835,9 @@
Roadway = stock.Roadway ?? string.Empty,
TaskType = taskType.GetHashCode(),
TaskStatus = TaskRobotStatusEnum.RobotNew.GetHashCode(),
- SourceAddress = sourceLineNo,
- TargetAddress = targetLineNo,
- CurrentAddress = sourceLineNo,
+ SourceAddress = section[0],
+ TargetAddress = section[1],
+ CurrentAddress = targetLineNo,
NextAddress = targetLineNo,
WarehouseId = stockInfo?.WarehouseId ?? 1,
Grade = 1,
--
Gitblit v1.9.3