From a1795465c5b51eb53d83d9a874c7923c9f5bfa85 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 10 三月 2026 16:05:06 +0800
Subject: [PATCH] 优化WMS任务下发接口
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/RGVLocationInfoService.cs | 13 ++
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RGVTaskMethods.cs | 49 +++++++-----
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs | 63 ++++++++++++---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 74 +++++++++++++++---
4 files changed, 151 insertions(+), 48 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/RGVLocationInfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/RGVLocationInfoService.cs"
index 58bc5ae..62c53d9 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/RGVLocationInfoService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/RGVLocationInfoService.cs"
@@ -40,10 +40,19 @@
/// </summary>
/// <param name="AreaCode"></param>
/// <returns></returns>
- public Dt_RGVLocationInfo GetInFreeLocationInfo(string AreaCode)
+ public Dt_RGVLocationInfo? GetInFreeLocationInfo(string AreaCode)
{
- Dt_RGVLocationInfo? rGVLocationInfo = BaseDal.QueryFirst(x => x.WarehouseId.ToString() == AreaCode && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt(), _emptyAssignOrderBy);
+ Dt_RGVLocationInfo? rGVLocationInfo = null;
+ List<Dt_RGVLocationInfo> rGVLocationInfos = BaseDal.QueryData(x => x.WarehouseId.ToString() == AreaCode && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt(), _emptyAssignOrderBy);
+ if (rGVLocationInfos == null || rGVLocationInfos.Count < 1) return rGVLocationInfo;
#region 鍒ゆ柇宸烽亾鏄惁鏈夎揣
+ List<string> LocationCodes = new List<string>();
+ foreach (var item in rGVLocationInfos)
+ {
+ Dt_RGVLocationInfo dt_RGVLocationInfo = BaseDal.QueryFirst(x => x.RoadwayNo == item.RoadwayNo && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.Depth < item.Depth && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt(), _emptyAssignOrderBy);
+ if (dt_RGVLocationInfo == null) return dt_RGVLocationInfo;
+ dt_RGVLocationInfo = BaseDal.QueryFirst(x => x.RoadwayNo == item.RoadwayNo && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.Depth > item.Depth && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt(), _DepthAscOrderBy);
+ }
if (rGVLocationInfo != null)
{
List<string> NoRoadwayNos = new List<string>();
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs"
index 708abe3..0761bf8 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/KLSTaskMethods.cs"
@@ -23,6 +23,7 @@
/// <returns></returns>
public WebResponseContent CreateKLSNewInTask(TaskDTO taskDTO, int taskType)
{
+ WebResponseContent content = new WebResponseContent();
try
{
int containerType = taskDTO.containerCode.Contains("LLM") ? LocationTypeEnum.LargePallet.ObjToInt() : LocationTypeEnum.SmallPallet.ObjToInt();
@@ -45,16 +46,33 @@
Creater = "WMS",
};
kLSLocationInfo.LocationStatus = LocationStatusEnum.InLock.ObjToInt();
- Db.Ado.BeginTran();
- BaseDal.AddData(dt_Task);
- _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo);
- Db.Ado.CommitTran();
- return WebResponseContent.Instance.OK();
+ try
+ {
+ Db.Ado.BeginTran();
+ BaseDal.AddData(dt_Task);
+ _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo);
+ Db.Ado.CommitTran();
+ }
+ catch (Exception ex)
+ {
+ Db.Ado.RollbackTran();
+ throw new Exception(ex.Message);
+ }
+
+ return content.OK(data: new
+ {
+ taskCode = taskDTO.taskCode,
+ Message = "鎴愬姛锛�"
+ });
}
catch (Exception ex)
{
- Db.Ado.RollbackTran();
- throw new Exception(ex.Message);
+ content.Data = new
+ {
+ taskCode = taskDTO.taskCode,
+ Message = $"澶辫触锛亄ex.Message}"
+ };
+ return content.Error(ex.Message);
}
}
/// <summary>
@@ -65,6 +83,7 @@
/// <returns></returns>
public WebResponseContent CreateKLSNewOutTask(TaskDTO taskDTO, int taskType)
{
+ WebResponseContent content = new WebResponseContent();
try
{
Dt_KLSLocationInfo? kLSLocationInfo = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode) ?? throw new Exception($"鏈壘鍒拌捣鐐瑰簱浣嶃�恵taskDTO.fromLocationCode}銆戯紒");
@@ -86,16 +105,32 @@
Creater = "WMS",
};
kLSLocationInfo.LocationStatus = LocationStatusEnum.OutLock.ObjToInt();
- Db.Ado.BeginTran();
- BaseDal.AddData(dt_Task);
- _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo);
- Db.Ado.CommitTran();
- return WebResponseContent.Instance.OK();
+ try
+ {
+ Db.Ado.BeginTran();
+ BaseDal.AddData(dt_Task);
+ _kLSLocationInfoService.Repository.UpdateData(kLSLocationInfo);
+ Db.Ado.CommitTran();
+ }
+ catch (Exception ex)
+ {
+ Db.Ado.RollbackTran();
+ throw new Exception(ex.Message);
+ }
+ return content.OK(data: new
+ {
+ taskCode = taskDTO.taskCode,
+ Message = "鎴愬姛锛�"
+ });
}
catch (Exception ex)
{
- Db.Ado.RollbackTran();
- throw new Exception(ex.Message);
+ content.Data = new
+ {
+ taskCode = taskDTO.taskCode,
+ Message = $"澶辫触锛亄ex.Message}"
+ };
+ return content.Error(ex.Message);
}
}
#endregion
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RGVTaskMethods.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RGVTaskMethods.cs"
index 055df4a..911a361 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RGVTaskMethods.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/RGVTaskMethods.cs"
@@ -10,6 +10,10 @@
using WIDESEAWCS_DTO.WMS;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_Core.Helper;
+using HslCommunication.Core.IMessage;
+using WIDESEAWCS_DTO.RGV.FOURBOT;
+using Newtonsoft.Json;
+using System.Reflection.Metadata;
namespace WIDESEAWCS_TaskInfoService
{
@@ -24,19 +28,14 @@
/// <returns></returns>
public WebResponseContent CreateRGVNewInTask(TaskDTO taskDTO, int taskType)
{
+ WebResponseContent content = new WebResponseContent();
try
{
- //List<Dt_RGVLocationInfo>? rGVLocationInfos = _rGVLocationInfoService.Repository.QueryData(x => x.WarehouseId.ToString() == taskDTO.toAreaCode && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt());
- //if (rGVLocationInfos.Count < 1) throw new Exception($"鏈壘鍒扮粓鐐瑰簱鍖恒�恵taskDTO.toAreaCode}銆戝彲鐢ㄧ┖璐т綅锛�");
- //var rGVLocationInfo = rGVLocationInfos.OrderBy(x => x.Depth).First();
- //var rGVLocationInfo = _rGVLocationInfoService.GetFreeLocationInfo(taskDTO.toAreaCode) ?? throw new Exception($"鏈壘鍒扮粓鐐瑰簱鍖恒�恵taskDTO.toAreaCode}銆戝彲鐢ㄧ┖璐т綅锛�");
Dt_StationManger stationManger = _stationMangerService.GetInStationInfo(taskDTO.fromLocationCode) ?? throw new Exception($"鏈壘鍒拌捣鐐逛綅缃�恵taskDTO.fromLocationCode}銆戠珯鍙颁俊鎭紒");
- //if (stationManger.IsOccupied == 1) throw new Exception($"璧风偣浣嶇疆銆恵taskDTO.fromLocationCode}銆戠珯鍙拌鍗犵敤锛岃閲婃斁锛�");
Dt_Task dt_Task = new()
{
TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
WMSTaskNum = taskDTO.taskCode,
- //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
Grade = taskDTO.taskPriority,
PalletCode = taskDTO.containerCode,
Roadway = taskDTO.toAreaCode,
@@ -44,22 +43,25 @@
TaskType = taskType,
SourceAddress = taskDTO.fromLocationCode,
CurrentAddress = taskDTO.fromLocationCode,
- NextAddress = stationManger.RGVStationCode,//鎵惧叆搴撶珯鍙板搴旂殑澶栧舰妫�娴嬬紪鍙�
+ NextAddress = stationManger.RGVStationCode,
TargetAddress = "",
- //Remark = taskDTO.toAreaCode,
Creater = "WMS",
};
- //rGVLocationInfo.LocationStatus = LocationStatusEnum.InLock.ObjToInt();
- //Db.Ado.BeginTran();
BaseDal.AddData(dt_Task);
- //_rGVLocationInfoService.Repository.UpdateData(rGVLocationInfo);
- //Db.Ado.CommitTran();
- return WebResponseContent.Instance.OK();
+ return content.OK(data: new
+ {
+ taskCode = taskDTO.taskCode,
+ Message = "鎴愬姛锛�"
+ });
}
catch (Exception ex)
{
- //Db.Ado.RollbackTran();
- throw new Exception(ex.Message);
+ content.Data = new
+ {
+ taskCode = taskDTO.taskCode,
+ Message = $"澶辫触锛亄ex.Message}"
+ };
+ return content.Error(ex.Message);
}
}
/// <summary>
@@ -70,17 +72,15 @@
/// <returns></returns>
public WebResponseContent CreateRGVNewOutTask(TaskDTO taskDTO, int taskType)
{
+ WebResponseContent content = new WebResponseContent();
try
{
- //Dt_Task dt_Task = BaseDal.QueryFirst(x => x.PalletCode == taskDTO.containerCode);
- //if (dt_Task != null) throw new Exception($"鎵樼洏鍙枫�恵taskDTO.containerCode}銆戝凡瀛樺湪浠诲姟");
Dt_RGVLocationInfo rGVLocationInfo = _rGVLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode) ?? throw new Exception($"鏈壘鍒拌捣鐐瑰簱浣嶃�恵taskDTO.fromLocationCode}銆戯紒");
if (rGVLocationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt()) throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戝綋鍓嶅簱浣嶇姸鎬佷笉鍙嚭搴擄紒");
Dt_Task dt_Task = new()
{
TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
WMSTaskNum = taskDTO.taskCode,
- //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
Grade = taskDTO.taskPriority,
PalletCode = taskDTO.containerCode,
Roadway = rGVLocationInfo.RoadwayNo,
@@ -105,11 +105,20 @@
Db.Ado.RollbackTran();
throw new Exception(ex.Message);
}
- return WebResponseContent.Instance.OK();
+ return content.OK(data: new
+ {
+ taskCode = taskDTO.taskCode,
+ Message = "鎴愬姛锛�"
+ });
}
catch (Exception ex)
{
- throw new Exception(ex.Message);
+ content.Data = new
+ {
+ taskCode = taskDTO.taskCode,
+ Message = $"澶辫触锛亄ex.Message}"
+ };
+ return content.Error(ex.Message);
}
}
#endregion
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
index 7249ad0..6a3b7df 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -89,49 +89,99 @@
WebResponseContent content = new WebResponseContent();
try
{
+ List<object> objects = new List<object>();
foreach (var item in taskDTOs)
{
foreach (var task in item.tasks)
{
+ #region 鍒ゆ柇
content = TaskHelpMethods.isOkTaskInfo(task, true, true);
- if (!content.Status) throw new Exception(content.Message);
+ if (!content.Status)
+ {
+ objects.Add(new
+ {
+ taskCode = task.taskCode,
+ Message = $"浠诲姟鍙枫�恵task.taskCode}銆憑content.Message}"
+ });
+ continue;
+ //throw new Exception(content.Message);
+ }
if (BaseDal.QueryFirst(x => x.WMSTaskNum == task.taskCode) != null)
- throw new Exception($"浠诲姟鍙枫�恵task.taskCode}銆戝凡瀛樺湪浠诲姟");
+ {
+ objects.Add(new
+ {
+ taskCode = task.taskCode,
+ Message = $"浠诲姟鍙枫�恵task.taskCode}銆戝凡瀛樺湪浠诲姟"
+ });
+ continue;
+ //throw new Exception($"浠诲姟鍙枫�恵task.taskCode}銆戝凡瀛樺湪浠诲姟");
+ }
if (BaseDal.QueryFirst(x => x.PalletCode == task.containerCode) != null)
- throw new Exception($"鎵樼洏鍙枫�恵task.containerCode}銆戝凡瀛樺湪浠诲姟");
+ {
+ objects.Add(new
+ {
+ taskCode = task.taskCode,
+ Message = $"鎵樼洏鍙枫�恵task.containerCode}銆戝凡瀛樺湪浠诲姟"
+ });
+ continue;
+ //throw new Exception($"鎵樼洏鍙枫�恵task.containerCode}銆戝凡瀛樺湪浠诲姟");
+ }
if (BaseDal.QueryFirst(x => x.SourceAddress == task.fromLocationCode) != null)
- throw new Exception($"璧风偣浣嶇疆銆恵task.containerCode}銆戝凡瀛樺湪浠诲姟");
+ {
+ objects.Add(new
+ {
+ taskCode = task.taskCode,
+ Message = $"璧风偣浣嶇疆銆恵task.containerCode}銆戝凡瀛樺湪浠诲姟"
+ });
+ continue;
+ //throw new Exception($"璧风偣浣嶇疆銆恵task.containerCode}銆戝凡瀛樺湪浠诲姟");
+ }
+ #endregion
switch (item.taskType)
{
case (int)TaskTypeEnum.MLInbound:
- CreateKLSNewInTask(task, item.taskType);
+ content = CreateKLSNewInTask(task, item.taskType);
+ objects.Add(content.Data);
break;
case (int)TaskTypeEnum.MLOutbound:
- CreateKLSNewOutTask(task, item.taskType);
+ content = CreateKLSNewOutTask(task, item.taskType);
+ objects.Add(content.Data);
break;
case (int)TaskTypeEnum.CPInbound:
- CreateRGVNewInTask(task, item.taskType);
+ content= CreateRGVNewInTask(task, item.taskType);
+ objects.Add(content.Data);
break;
case (int)TaskTypeEnum.CPOutbound:
- CreateRGVNewOutTask(task, item.taskType);
+ content= CreateRGVNewOutTask(task, item.taskType);
+ objects.Add(content.Data);
break;
case (int)TaskTypeEnum.CJInbound:
- CreateHKNewInTask(task, item.taskType);
+ content = CreateHKNewInTask(task, item.taskType);
+ objects.Add(content.Data);
break;
case (int)TaskTypeEnum.CJOutbound:
- CreateHKNewOutTask(task, item.taskType);
+ content = CreateHKNewOutTask(task, item.taskType);
+ objects.Add(content.Data);
break;
case (int)TaskTypeEnum.Carry:
- CarryTask(task, item.taskType);
+ content = CarryTask(task, item.taskType);
+ objects.Add(content.Data);
break;
case (int)TaskTypeEnum.CJCarry:
- CJCarryTaske(task, item.taskType);
+ content = CJCarryTaske(task, item.taskType);
+ objects.Add(content.Data);
break;
default:
+ objects.Add(new
+ {
+ taskCode = task.taskCode,
+ Message = $"鏈畾涔夌殑浠诲姟绫诲瀷"
+ });
break;
}
}
}
+ content.Data = objects;
}
catch (Exception ex)
{
--
Gitblit v1.9.3