From c3de7bb2097aa347a1f92c2f640d18753aff633a Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期六, 28 二月 2026 13:41:26 +0800
Subject: [PATCH] 添加HTTP客户端助手、枚举、DTO;更新URL
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 57 ++++++++++++++++++++++++++++++++-------------------------
1 files changed, 32 insertions(+), 25 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
index 16bc271..7ae869a 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -21,12 +21,15 @@
using SqlSugar;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
+using WIDESEA_Core;
using WIDESEAWCS_Common.HttpEnum;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Enums;
+using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_Core.Http;
+using WIDESEAWCS_DTO.Stock;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
@@ -42,6 +45,7 @@
private readonly ITaskExecuteDetailService _taskExecuteDetailService;
private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository;
private readonly IMapper _mapper;
+ private readonly HttpClientHelper _httpClientHelper;
private Dictionary<string, OrderByType> _taskOrderBy = new()
{
@@ -58,12 +62,13 @@
public List<int> TaskRobotTypes => typeof(TaskOtherTypeEnum).GetEnumIndexList();
- public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper) : base(BaseDal)
+ public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper, HttpClientHelper httpClientHelper) : base(BaseDal)
{
_routerService = routerService;
_taskExecuteDetailService = taskExecuteDetailService;
_taskExecuteDetailRepository = taskExecuteDetailRepository;
_mapper = mapper;
+ _httpClientHelper = httpClientHelper;
}
/// <summary>
@@ -364,20 +369,15 @@
// 璋冪敤WMS绯荤粺鎺ュ彛锛岃幏鍙栨渶缁堢洰鏍囧湴鍧�
CreateTaskDto taskDto = new CreateTaskDto()
{
- Roadway = task.TargetAddress,
PalletCode = task.PalletCode,
- SourceAddress = task.SourceAddress,
- // 鐩爣鍦板潃寰呭畾
- TargetAddress = "CLOutAreaA",
- TaskType = task.TaskType,
};
- content = HttpRequestHelper.HTTPPostAsync(nameof(Category.WMS), taskDto.ToString(), nameof(ConfigKey.GetTasksLocation)).Result;
- if (!content.Status)
+ var result = _httpClientHelper.Post<WebResponseContent>("WMS", taskDto.ToJson(), nameof(ConfigKey.GetTasksLocation));
+ if (!result.IsSuccess && !result.Data.Status)
{
return WebResponseContent.Instance.Error($"璋冪敤WMS鎺ュ彛鑾峰彇浠诲姟鐩爣鍦板潃澶辫触,浠诲姟鍙�:銆恵task.TaskNum}銆�,閿欒淇℃伅:銆恵content.Message}銆�");
}
- string wmsTargetAddress = content.Data?.ToString() ?? string.Empty;
+ string wmsTargetAddress = result.Data.Data?.ToString() ?? string.Empty;
if (string.IsNullOrEmpty(wmsTargetAddress))
{
return WebResponseContent.Instance.Error($"璋冪敤WMS鎺ュ彛鑾峰彇浠诲姟鐩爣鍦板潃澶辫触,浠诲姟鍙�:銆恵task.TaskNum}銆�,閿欒淇℃伅:銆愭湭鑾峰彇鍒版湁鏁堢殑鐩爣鍦板潃銆�");
@@ -486,13 +486,20 @@
BaseDal.UpdateData(task);
_taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍫嗗灈鏈哄嚭搴撳畬鎴�");
- //todo 鍚屾鍒癢MS
- //鏆備笉鑰冭檻澶氫釜鍑哄簱鍙�
+ var result = _httpClientHelper.Post<WebResponseContent>("WMS", (new StockInfoDTO() { PalletCode = task.PalletCode, TaskNum = task.TaskNum }).ToJson());
+ if (result.IsSuccess && result.Data.Status)
+ {
+ return content.Error($"閫氱煡WMS绯荤粺鍫嗗灈鏈哄嚭搴撳畬鎴愭垚鍔�,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�");
+
+ }
+ else
+ {
+ return content.Error($"閫氱煡WMS绯荤粺鍫嗗灈鏈哄嚭搴撳畬鎴愬け璐�,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�,閿欒淇℃伅:銆恵result.Data.Message}銆�");
+ }
}
else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting)
{
- //todo
int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>();
task.TaskState = nextStatus;
task.ModifyDate = DateTime.Now;
@@ -500,20 +507,20 @@
BaseDal.UpdateData(task);
_taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍫嗗灈鏈哄叆搴撳畬鎴�");
- WMSTaskDTO taskDTO = new WMSTaskDTO()
- {
- TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
- Grade = 1,
- PalletCode = task.PalletCode + "S",
- RoadWay = "SC01",
- SourceAddress = task.TargetAddress,
- TargetAddress = "CLOutAreaA",
- TaskState = (int)TaskOutStatusEnum.OutNew,
- Id = 0,
- TaskType = (int)TaskOutboundTypeEnum.Outbound
- };
- content = ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
+ var result = _httpClientHelper.Post<WebResponseContent>("WMS", (new CreateTaskDto()
+ {
+ PalletCode = task.PalletCode,
+ }).ToJson());
+
+ if (result.IsSuccess && result.Data.Status)
+ {
+ return content.Error($"閫氱煡WMS绯荤粺鍫嗗灈鏈哄叆搴撳畬鎴愭垚鍔�,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�");
+ }
+ else
+ {
+ return content.Error($"閫氱煡WMS绯荤粺鍫嗗灈鏈哄叆搴撳畬鎴愬け璐�,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�,閿欒淇℃伅:銆恵result.Data.Message}銆�");
+ }
}
else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
{
--
Gitblit v1.9.3