From 75f34e9ba2e8b249c96333f3d7936c8968e12ec7 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期三, 11 二月 2026 14:44:12 +0800
Subject: [PATCH] 集成WMS调用与入库任务处理
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 90 +++++++++++++++++++++++++++++++++++++++-----
1 files changed, 79 insertions(+), 11 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
index 5f9e946..2c57b09 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -1,4 +1,5 @@
锘�#region << 鐗� 鏈� 娉� 閲� >>
+
/*----------------------------------------------------------------
* 鍛藉悕绌洪棿锛歐IDESEAWCS_TaskInfoService
* 鍒涘缓鑰咃細鑳$搴�
@@ -11,17 +12,21 @@
* 淇敼鏃堕棿锛�
* 鐗堟湰锛歏1.0.1
* 淇敼璇存槑锛�
- *
+ *
*----------------------------------------------------------------*/
+
#endregion << 鐗� 鏈� 娉� 閲� >>
using AutoMapper;
using SqlSugar;
using System.Diagnostics.CodeAnalysis;
+using System.Text.Json;
+using WIDESEAWCS_Common.HttpEnum;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseServices;
using WIDESEAWCS_Core.Enums;
+using WIDESEAWCS_Core.Http;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
@@ -44,11 +49,14 @@
{nameof(Dt_Task.CreateDate),OrderByType.Asc},
};
- public Dictionary<string, OrderByType> TaskOrderBy { get { return _taskOrderBy; } set { _taskOrderBy = value; } }
+ public Dictionary<string, OrderByType> TaskOrderBy
+ { get { return _taskOrderBy; } set { _taskOrderBy = value; } }
public List<int> TaskInboundTypes => typeof(TaskInboundTypeEnum).GetEnumIndexList();
public List<int> TaskOutboundTypes => typeof(TaskOutboundTypeEnum).GetEnumIndexList();
+
+ public List<int> TaskRobotTypes => typeof(TaskOtherTypeEnum).GetEnumIndexList();
public TaskService(ITaskRepository BaseDal, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IMapper mapper) : base(BaseDal)
{
@@ -353,11 +361,48 @@
if (task.TaskState == (int)TaskInStatusEnum.Line_InFinish)
{
- Random random = new Random();
+ //Random random = new Random();
+ //task.CurrentAddress = task.NextAddress;
+ //task.NextAddress = $"{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}";
+ //task.TargetAddress = task.NextAddress;
+
+ // 璋冪敤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)
+ {
+ return WebResponseContent.Instance.Error($"璋冪敤WMS鎺ュ彛鑾峰彇浠诲姟鐩爣鍦板潃澶辫触,浠诲姟鍙�:銆恵task.TaskNum}銆�,閿欒淇℃伅:銆恵content.Message}銆�");
+ }
+
+ string wmsTargetAddress = content.Data?.ToString() ?? string.Empty;
+ if (string.IsNullOrEmpty(wmsTargetAddress))
+ {
+ return WebResponseContent.Instance.Error($"璋冪敤WMS鎺ュ彛鑾峰彇浠诲姟鐩爣鍦板潃澶辫触,浠诲姟鍙�:銆恵task.TaskNum}銆�,閿欒淇℃伅:銆愭湭鑾峰彇鍒版湁鏁堢殑鐩爣鍦板潃銆�");
+ }
+
+ task.NextAddress = wmsTargetAddress;
+ task.TargetAddress = wmsTargetAddress;
task.CurrentAddress = task.NextAddress;
- task.NextAddress = $"{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}-{random.Next(1, 100).ToString().PadLeft(3, '0')}";
- task.TargetAddress = task.NextAddress;
}
+ }
+ else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OtherGroup)
+ {
+ if (task.TaskState >= (int)TaskRobotStatusEnum.RobotNew)
+ {
+ return content = WebResponseContent.Instance.Error($"璇ヤ换鍔$姸鎬佷笉鍙烦杞埌涓嬩竴姝�,浠诲姟鍙�:銆恵task.TaskNum}銆�,浠诲姟鐘舵��:銆恵task.TaskState}銆�");
+ }
+
+ int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskRobotStatusEnum>();
+
+ task.TaskState = nextStatus;
}
else
{
@@ -400,11 +445,11 @@
string oldCurrentPos = task.CurrentAddress;
string oldNextPos = task.NextAddress;
- List<Dt_Router> routers = _routerService.QueryNextRoutes(task.NextAddress, task.TargetAddress);
- if (!routers.Any()) throw new Exception($"鏈壘鍒拌澶囪矾鐢变俊鎭�");
+ Dt_Router routers = _routerService.QueryNextRoute(task.CurrentAddress);
+ if (routers == null) throw new Exception($"鏈壘鍒拌澶囪矾鐢变俊鎭�");
task.CurrentAddress = task.NextAddress;
- task.NextAddress = routers.FirstOrDefault().ChildPosi;
+ task.NextAddress = routers.ChildPosi;
task.ModifyDate = DateTime.Now;
task.Modifier = "System";
@@ -452,7 +497,7 @@
}
else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting)
{
- //todo
+ //todo
int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskInStatusEnum>();
task.TaskState = nextStatus;
task.ModifyDate = DateTime.Now;
@@ -481,7 +526,6 @@
}
else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OtherGroup)
{
-
}
else
{
@@ -598,5 +642,29 @@
BaseDal.DeleteAndMoveIntoHty(tasks, OperateTypeEnum.浜哄伐鍒犻櫎);
return WebResponseContent.Instance.OK($"鎴愬姛鍒犻櫎{tasks.Count}鏉℃暟鎹�");
}
+
+ /// <summary>
+ /// 鏍规嵁璁惧缂栧彿銆佸綋鍓嶅湴鍧�鎸夌収浼樺厛绾т互鍙婂垱寤烘椂闂存帓搴忔煡璇换鍔℃睜鏂板鐨勪换鍔�
+ /// </summary>
+ /// <param name="deviceNo">璁惧缂栧彿</param>
+ /// <param name="currentAddress">褰撳墠鍦板潃</param>
+ /// <returns>杩斿洖浠诲姟瀹炰綋瀵硅薄锛屽彲鑳戒负null</returns>
+ public Dt_Task QueryRobotCraneTask(string deviceNo, string currentAddress = "")
+ {
+ if (string.IsNullOrEmpty(currentAddress))
+ return BaseDal.QueryFirst(x => x.Roadway == deviceNo && (TaskRobotTypes.Contains(x.TaskType) && x.TaskState <= (int)TaskRobotStatusEnum.RobotExecuting), TaskOrderBy);
+ else
+ return BaseDal.QueryFirst(x => x.Roadway == deviceNo && TaskRobotTypes.Contains(x.TaskType) && x.CurrentAddress == currentAddress && x.TaskState <= (int)TaskRobotStatusEnum.RobotExecuting, TaskOrderBy);
+ }
+
+ /// <summary>
+ /// 鑾峰彇涓庢寚瀹氫换鍔$紪鍙峰叧鑱旂殑浠诲姟銆�
+ /// </summary>
+ /// <param name="taskNum">瑕佽幏鍙栫殑浠诲姟鐨勫敮涓�鏍囪瘑绗︺��</param>
+ /// <returns>琛ㄧず鎸囧畾缂栧彿浠诲姟鐨�<see cref="Dt_Task"/>瀵硅薄锛屽鏋滀笉瀛樺湪璇ヤ换鍔″垯杩斿洖<c>null</c>銆�</returns>
+ public Dt_Task QueryByTaskNum(int taskNum)
+ {
+ return BaseDal.QueryFirst(x => x.TaskNum == taskNum);
+ }
}
-}
+}
\ No newline at end of file
--
Gitblit v1.9.3