From f7ec7a32e8cddcb976093c826e3a0d1ed61fb335 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期日, 12 四月 2026 13:09:43 +0800
Subject: [PATCH] feat(任务服务): 扩展任务更新接口以支持地址信息
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs | 64 +++++++++++++++++++++++++++-----
1 files changed, 54 insertions(+), 10 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs
index 0aa7b14..6082140 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs
@@ -1,16 +1,18 @@
-锘縰sing Newtonsoft.Json;
+锘縰sing Autofac;
+using Newtonsoft.Json;
using System.Diagnostics.CodeAnalysis;
+using WIDESEA_Core;
using WIDESEAWCS_Common.HttpEnum;
using WIDESEAWCS_Common.TaskEnum;
-using WIDESEA_Core;
using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.BaseRepository;
+using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO;
using WIDESEAWCS_DTO.Stock;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
-using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Service;
@@ -25,6 +27,8 @@
private readonly IRouterService _routerService;
private readonly HttpClientHelper _httpClientHelper;
private readonly IRobotTaskService _robotTaskService;
+ private readonly IComponentContext _componentContext;
+ private readonly IUnitOfWorkManage _unitOfWorkManage;
/// <summary>
/// 鍒濆鍖栧嚭搴撲换鍔℃祦绋嬫湇鍔°��
@@ -32,12 +36,20 @@
/// <param name="routerService">璺敱鏈嶅姟銆�</param>
/// <param name="httpClientHelper">WMS鎺ュ彛璋冪敤甯姪绫汇��</param>
/// <param name="robotTaskService">鏈烘鎵嬩换鍔℃湇鍔°��</param>
- public OutboundTaskFlowService(IRouterService routerService, HttpClientHelper httpClientHelper, IRobotTaskService robotTaskService)
+ /// <param name="componentContext">Autofac缁勪欢涓婁笅鏂囷紙鐢ㄤ簬寤惰繜瑙f瀽ITaskService浠ラ伩鍏嶅惊鐜緷璧栵級銆�</param>
+ public OutboundTaskFlowService(IRouterService routerService, HttpClientHelper httpClientHelper, IRobotTaskService robotTaskService, IComponentContext componentContext, IUnitOfWorkManage unitOfWorkManage)
{
_routerService = routerService;
_httpClientHelper = httpClientHelper;
_robotTaskService = robotTaskService;
+ _componentContext = componentContext;
+ _unitOfWorkManage = unitOfWorkManage;
}
+
+ /// <summary>
+ /// 寤惰繜瑙f瀽ITaskService浠ラ伩鍏嶅惊鐜緷璧�
+ /// </summary>
+ private ITaskService TaskService => _componentContext.Resolve<ITaskService>();
/// <summary>
/// 鎺ユ敹WMS浠诲姟鏃跺垵濮嬪寲鍑哄簱浠诲姟銆�
@@ -122,13 +134,45 @@
task.ModifyDate = DateTime.Now;
task.Modifier = "System";
- content = NotifyWMSOutboundFinish(task);
- if (!content.Status)
+ // 閫氱煡WMS鍑哄簱瀹屾垚骞惰幏鍙栬繑鍥炵粨鏋�
+ var result = _httpClientHelper.Post<WebResponseContent>(
+ nameof(ConfigKey.OutboundFinishTaskAsync),
+ new StockInfoDTO { PalletCode = task.PalletCode, TaskNum = task.TaskNum }.ToJson());
+
+ if (!result.IsSuccess || !result.Data.Status)
{
- return content;
+ return content.Error($"閫氱煡WMS绯荤粺鍫嗗灈鏈哄嚭搴撳畬鎴愬け璐�,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�,閿欒淇℃伅:銆恵result.Data?.Message}銆�");
}
- return content.Error($"閫氱煡WMS绯荤粺鍫嗗灈鏈哄嚭搴撳畬鎴愭垚鍔�,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�");
+ // 澶勭悊WMS杩斿洖鐨勫叆搴撲换鍔★紙濡傛灉鏈夛級
+ if (result.Data?.Data != null)
+ {
+ var inboundTaskJson = result.Data.Data.ToString();
+ var inboundTaskDto = JsonConvert.DeserializeObject<WMSTaskDTO>(inboundTaskJson);
+
+ if (inboundTaskDto != null)
+ {
+ _unitOfWorkManage.BeginTran(() =>
+ {
+ // 鍏堝垹闄ゆ湰鍦板嚭搴撲换鍔★紝閬垮厤鎵樼洏鍙峰敮涓�閿啿绐�
+ bool isDeleted = TaskService.Repository.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚);
+ if (!isDeleted)
+ {
+ return content.Error($"鍒犻櫎鏈湴鍑哄簱浠诲姟澶辫触,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�");
+ }
+
+ // 璋冪敤ReceiveWMSTask鍒涘缓鏈湴鍏ュ簱浠诲姟
+ var receiveResult = TaskService.ReceiveWMSTask(new List<WMSTaskDTO> { inboundTaskDto });
+ if (!receiveResult.Status)
+ {
+ return content.Error($"鍒涘缓鏈湴鍏ュ簱浠诲姟澶辫触: {receiveResult.Message}");
+ }
+ return content.OK("鍒涘缓鏈湴鍏ュ簱浠诲姟鎴愬姛");
+ });
+ }
+ }
+
+ return content.OK($"閫氱煡WMS绯荤粺鍫嗗灈鏈哄嚭搴撳畬鎴愭垚鍔�,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�");
}
/// <summary>
@@ -181,7 +225,7 @@
{
var result = _httpClientHelper.Post<WebResponseContent>(
nameof(ConfigKey.UpdateTaskByStatus),
- new UpdateTaskDto { Id = task.TaskNum, NewStatus = task.TaskStatus }.ToJson());
+ new UpdateTaskDto { Id = task.TaskNum, NewStatus = task.TaskStatus, NextAddress = task.NextAddress, CurrentAddress = task.CurrentAddress }.ToJson());
if (!result.IsSuccess || !result.Data.Status)
return WebResponseContent.Instance.Error($"璋冪敤WMS鎺ュ彛鏇存柊浠诲姟鐘舵�佸け璐�,浠诲姟鍙�:銆恵task.TaskNum}銆�,閿欒淇℃伅:銆恵result.Data?.Message}銆�");
@@ -206,4 +250,4 @@
return WebResponseContent.Instance.OK();
}
}
-}
+}
\ No newline at end of file
--
Gitblit v1.9.3