From 4b483d9d06bead231b88ca212fd799196668a057 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期二, 28 四月 2026 22:58:27 +0800
Subject: [PATCH] fix(任务服务): 修复出库任务选择逻辑和货位分配问题
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs | 44 ++++++++++++++++++++++++++++++--------------
1 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs
index 2db6032..c34af94 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs
@@ -1,5 +1,4 @@
-锘縰sing Autofac;
-using Newtonsoft.Json;
+锘縰sing Newtonsoft.Json;
using Serilog;
using System.Diagnostics.CodeAnalysis;
using WIDESEA_Core;
@@ -12,6 +11,7 @@
using WIDESEAWCS_DTO;
using WIDESEAWCS_DTO.Stock;
using WIDESEAWCS_DTO.TaskInfo;
+using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob.Models;
@@ -29,9 +29,10 @@
private readonly IRouterService _routerService;
private readonly HttpClientHelper _httpClientHelper;
private readonly IRobotTaskService _robotTaskService;
- private readonly IComponentContext _componentContext;
+ private readonly ITaskRepository _taskRepository;
private readonly IUnitOfWorkManage _unitOfWorkManage;
private readonly ILogger _logger;
+ private Func<List<WMSTaskDTO>, WebResponseContent> _receiveWMSTaskFunc;
/// <summary>
/// 鍒濆鍖栧嚭搴撲换鍔℃祦绋嬫湇鍔°��
@@ -39,21 +40,33 @@
/// <param name="routerService">璺敱鏈嶅姟銆�</param>
/// <param name="httpClientHelper">WMS鎺ュ彛璋冪敤甯姪绫汇��</param>
/// <param name="robotTaskService">鏈烘鎵嬩换鍔℃湇鍔°��</param>
- /// <param name="componentContext">Autofac缁勪欢涓婁笅鏂囷紙鐢ㄤ簬寤惰繜瑙f瀽ITaskService浠ラ伩鍏嶅惊鐜緷璧栵級銆�</param>
- public OutboundTaskFlowService(IRouterService routerService, HttpClientHelper httpClientHelper, IRobotTaskService robotTaskService, IComponentContext componentContext, IUnitOfWorkManage unitOfWorkManage, ILogger logger)
+ /// <param name="taskRepository">浠诲姟浠撳偍锛堢敤浜庡垹闄�/褰掓。浠诲姟锛夈��</param>
+ /// <param name="unitOfWorkManage">宸ヤ綔鍗曞厓绠$悊鍣ㄣ��</param>
+ /// <param name="logger">鏃ュ織璁板綍鍣ㄣ��</param>
+ public OutboundTaskFlowService(
+ IRouterService routerService,
+ HttpClientHelper httpClientHelper,
+ IRobotTaskService robotTaskService,
+ ITaskRepository taskRepository,
+ IUnitOfWorkManage unitOfWorkManage,
+ ILogger logger)
{
_routerService = routerService;
_httpClientHelper = httpClientHelper;
_robotTaskService = robotTaskService;
- _componentContext = componentContext;
+ _taskRepository = taskRepository;
_unitOfWorkManage = unitOfWorkManage;
_logger = logger;
}
/// <summary>
- /// 寤惰繜瑙f瀽ITaskService浠ラ伩鍏嶅惊鐜緷璧�
+ /// 璁剧疆鎺ユ敹WMS浠诲姟鐨勫鎵橈紙鐢盩askService鍦ㄦ瀯閫犲悗璋冪敤锛岄伩鍏嶅惊鐜緷璧栵級銆�
/// </summary>
- private ITaskService TaskService => _componentContext.Resolve<ITaskService>();
+ /// <param name="receiveWMSTaskFunc">鎺ユ敹WMS浠诲姟鐨勬柟娉曞鎵樸��</param>
+ public void SetReceiveWMSTaskDelegate(Func<List<WMSTaskDTO>, WebResponseContent> receiveWMSTaskFunc)
+ {
+ _receiveWMSTaskFunc = receiveWMSTaskFunc;
+ }
/// <summary>
/// 鎺ユ敹WMS浠诲姟鏃跺垵濮嬪寲鍑哄簱浠诲姟銆�
@@ -99,7 +112,7 @@
if (task.TaskStatus == (int)TaskOutStatusEnum.Line_OutFinish && task.TaskType == (int)TaskOutboundTypeEnum.OutEmpty)
{
- _robotTaskService.GetWMSRobotTask(task);
+ return _robotTaskService.CreateLocalRobotTask(task);
//if (!content.Status)
//{
// return content;
@@ -143,7 +156,7 @@
task.Modifier = "System";
// 閫氱煡WMS鍑哄簱瀹屾垚骞惰幏鍙栬繑鍥炵粨鏋�
- return NotifyWMSOutboundFinish(task);
+ return NotifyWMSOutboundFinish(task);
}
/// <summary>
@@ -180,14 +193,14 @@
_unitOfWorkManage.BeginTran(() =>
{
// 鍏堝垹闄ゆ湰鍦板嚭搴撲换鍔★紝閬垮厤鎵樼洏鍙峰敮涓�閿啿绐�
- bool isDeleted = TaskService.Repository.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚);
+ bool isDeleted = _taskRepository.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚);
if (!isDeleted)
{
return content.Error($"鍒犻櫎鏈湴鍑哄簱浠诲姟澶辫触,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�");
}
- // 璋冪敤ReceiveWMSTask鍒涘缓鏈湴鍏ュ簱浠诲姟
- var receiveResult = TaskService.ReceiveWMSTask(new List<WMSTaskDTO> { inboundTaskDto });
+ // 璋冪敤ReceiveWMSTask濮旀墭鍒涘缓鏈湴鍏ュ簱浠诲姟
+ var receiveResult = _receiveWMSTaskFunc(new List<WMSTaskDTO> { inboundTaskDto });
if (!receiveResult.Status)
{
return content.Error($"鍒涘缓鏈湴鍏ュ簱浠诲姟澶辫触: {receiveResult.Message}");
@@ -228,7 +241,10 @@
if (wMSTask == null)
return WebResponseContent.Instance.Error($"鑾峰彇WMS绯荤粺绌烘墭鐩樺嚭搴撲换鍔″け璐�,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�,閿欒淇℃伅:銆怶MS鏈繑鍥炴湁鏁堜换鍔℃暟鎹��");
- return WebResponseContent.Instance.OK("鎴愬姛", new List<WMSTaskDTO> { wMSTask });
+ if (_receiveWMSTaskFunc(new List<WMSTaskDTO> { wMSTask }).Status)
+ return WebResponseContent.Instance.OK("鎴愬姛");
+
+ return WebResponseContent.Instance.Error("鎺ユ敹WMS浠诲姟澶辫触");
}
/// <summary>
--
Gitblit v1.9.3