From b0327633d7d0c19693a4e577d1e17b3b22e8274e Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期日, 12 四月 2026 01:23:56 +0800
Subject: [PATCH] refactor(WCS&WMS): 新增手动下发输送线任务
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs | 153 ++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 128 insertions(+), 25 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_WCS.cs
index 8d2a3ac..9c14375 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;
@@ -199,29 +200,29 @@
{
if (stockInfo.Remark.IsNullOrEmpty())
{
- stockInfo.OutboundDate = now.AddHours(16);
- stockInfo.Remark = "GW_1";
+ stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_GW1_FIRST);
+ stockInfo.Remark = StockRemarkConstants.GW1;
}
- else if (stockInfo.Remark == "GW_1")
+ else if (stockInfo.Remark == StockRemarkConstants.GW1)
{
- stockInfo.OutboundDate = now.AddHours(24);
- stockInfo.Remark = "GW_2";
+ stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_GW1_SECOND);
+ stockInfo.Remark = StockRemarkConstants.GW2;
}
else
{
- stockInfo.OutboundDate = now.AddHours(16);
+ stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_GW1_FIRST);
}
}
else if (task.Roadway.Contains("CW"))
{
- if (stockInfo.Remark == "GW_2")
+ if (stockInfo.Remark == StockRemarkConstants.GW2)
{
- stockInfo.OutboundDate = now.AddHours(12);
- stockInfo.Remark = "CW_1";
+ stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_CW1);
+ stockInfo.Remark = StockRemarkConstants.CW1;
}
else
{
- stockInfo.OutboundDate = now.AddHours(12);
+ stockInfo.OutboundDate = now.AddHours(OutboundTimeConstants.OUTBOUND_HOURS_CW1);
}
}
else
@@ -301,22 +302,40 @@
if (!updateLocationResult || !updateStockResult)
return WebResponseContent.Instance.Error("浠诲姟瀹屾垚澶辫触");
- // 璋冪敤MES鎵樼洏鍑虹珯
- var outboundRequest = new OutboundInContainerRequest
+ // 楂樻俯2鍙峰嚭搴撳埌CWSC1鏃讹紝鑷姩鍒涘缓鍏ュ簱浠诲姟鍒板父娓�1鍙峰贩閬�
+ WMSTaskDTO? inboundTaskDto = null;
+ if (task.TargetAddress == TaskAddressConstants.GW2_ADDRESS)
{
- 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 inboundTask = new Dt_Task
+ {
+ TaskNum = await BaseDal.GetTaskNo(),
+ PalletCode = task.PalletCode,
+ PalletType = task.PalletType,
+ Roadway = "CW1",
+ TaskType = TaskInboundTypeEnum.Inbound.GetHashCode(),
+ TaskStatus = TaskInStatusEnum.InNew.GetHashCode(),
+ SourceAddress = task.TargetAddress,
+ TargetAddress = task.TargetAddress,
+ CurrentAddress = task.TargetAddress,
+ NextAddress = task.TargetAddress,
+ WarehouseId = (int)WarehouseEnum.CW1,
+ Grade = 1,
+ Creater = "system_auto"
+ };
+ await Repository.AddDataAsync(inboundTask);
+ inboundTaskDto = _mapper.Map<WMSTaskDTO>(inboundTask);
}
- return await CompleteTaskAsync(task, "鍑哄簱瀹屾垚");
+ var completeResult = await CompleteTaskAsync(task, "鍑哄簱瀹屾垚");
+ if (!completeResult.Status)
+ return completeResult;
+
+ // 杩斿洖鍏ュ簱浠诲姟淇℃伅锛堝鏋滄湁锛�
+ if (inboundTaskDto != null)
+ {
+ return content.OK("鍑哄簱瀹屾垚锛屽凡鍒涘缓鍏ュ簱浠诲姟", inboundTaskDto);
+ }
+ return content.OK("鍑哄簱瀹屾垚");
});
}
catch (Exception ex)
@@ -637,8 +656,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);
@@ -856,6 +876,89 @@
}
}
+ /// <summary>
+ /// 鎵嬪姩鍒涘缓浠诲姟
+ /// </summary>
+ /// <param name="dto">鎵嬪姩鍒涘缓浠诲姟鍙傛暟</param>
+ /// <returns></returns>
+ public async Task<WebResponseContent> CreateManualTaskAsync(CreateManualTaskDto dto)
+ {
+ try
+ {
+ // 1. 鏍规嵁浠诲姟绫诲瀷瀛楃涓茬‘瀹� TaskType 鍜� TaskStatus
+ int taskType;
+ int taskStatus;
+ switch (dto.TaskType)
+ {
+ case "鍏ュ簱":
+ taskType = TaskTypeEnum.Inbound.GetHashCode();
+ taskStatus = TaskInStatusEnum.InNew.GetHashCode();
+ break;
+ case "鍑哄簱":
+ taskType = TaskTypeEnum.Outbound.GetHashCode();
+ taskStatus = TaskOutStatusEnum.OutNew.GetHashCode();
+ break;
+ case "绉诲簱":
+ taskType = TaskTypeEnum.Relocation.GetHashCode();
+ taskStatus = TaskRelocationStatusEnum.RelocationNew.GetHashCode();
+ break;
+ default:
+ return WebResponseContent.Instance.Error($"涓嶆敮鎸佺殑浠诲姟绫诲瀷: {dto.TaskType}");
+ }
+
+ // 2. 鐢熸垚浠诲姟鍙�
+ int taskNum = await BaseDal.GetTaskNo();
+
+ // 3. 鏋勫缓浠诲姟瀹炰綋
+ var task = new Dt_Task
+ {
+ TaskNum = taskNum,
+ PalletCode = dto.Barcode,
+ SourceAddress = dto.SourceAddress,
+ TargetAddress = dto.TargetAddress,
+ TaskType = taskType,
+ TaskStatus = taskStatus,
+ Grade = dto.Grade,
+ WarehouseId = dto.WarehouseId,
+ CurrentAddress = dto.SourceAddress,
+ NextAddress = dto.TargetAddress,
+ Creater = "manual",
+ CreateDate = DateTime.Now,
+ ModifyDate = DateTime.Now
+ };
+
+ // 4. 淇濆瓨鍒版暟鎹簱
+ var result = await BaseDal.AddDataAsync(task) > 0;
+ if (!result)
+ return WebResponseContent.Instance.Error("鍒涘缓浠诲姟澶辫触");
+
+ // 5. 鍙戦�佸埌 WCS
+ var wmsTaskDto = new WMSTaskDTO
+ {
+ TaskNum = task.TaskNum,
+ PalletCode = task.PalletCode,
+ SourceAddress = task.SourceAddress,
+ TargetAddress = task.TargetAddress,
+ TaskType = task.TaskType,
+ TaskStatus = task.TaskStatus,
+ WarehouseId = task.WarehouseId
+ };
+
+ var wcsResult = _httpClientHelper.Post<WebResponseContent>(
+ "http://localhost:9292/api/Task/ReceiveManualTask",
+ wmsTaskDto.ToJson());
+
+ if (!wcsResult.IsSuccess || !wcsResult.Data.Status)
+ return WebResponseContent.Instance.Error($"浠诲姟宸插垱寤轰絾鍙戦�佺粰WCS澶辫触: {wcsResult.Data?.Message}");
+
+ return WebResponseContent.Instance.OK($"鎵嬪姩鍒涘缓浠诲姟鎴愬姛锛屼换鍔″彿: {taskNum}");
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error($"鎵嬪姩鍒涘缓浠诲姟寮傚父: {ex.Message}");
+ }
+ }
+
#endregion WCS閫昏緫澶勭悊
}
}
\ No newline at end of file
--
Gitblit v1.9.3