From b0b5deb5825684bca5b3fa7c2ab59f60ce0e799f Mon Sep 17 00:00:00 2001
From: xiazhengtongxue <133085197+xiazhengtongxue@users.noreply.github.com>
Date: 星期二, 07 四月 2026 16:36:57 +0800
Subject: [PATCH] fix: 修复移库任务号重复问题,优化策略优先处理正常任务,避免任务堵塞
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Partial/SCExecutionBlock.cs | 133 +++++++++++++++++++++++++++++++++++++-------
1 files changed, 112 insertions(+), 21 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Partial/SCExecutionBlock.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Partial/SCExecutionBlock.cs"
index 914a397..8e63a99 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Partial/SCExecutionBlock.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/Partial/SCExecutionBlock.cs"
@@ -47,12 +47,35 @@
if (dt_Location.Depth == 1 && dt_Task.TaskType == (int)TaskTypeEnum.Inbound)
{
if (shallowLocation.LocationStatus == (int)LocationStatusEnum.InStock) return content.OK();
- return content.Error();
+ return content.Error($"鍏ュ簱鑷虫繁搴撲綅锛屼絾鏄祬璐т綅鏈夎揣锛屼换鍔″彿锛歿dt_Task.TaskId},鎵樼洏鏉$爜");
}
if (shallowLocation.LocationStatus == (int)LocationStatusEnum.Free) return content.OK();
- //鍒ゆ柇鏄惁鏈夌Щ搴撲换鍔�
+ //鍒ゆ柇褰撳墠娴呰揣浣嶆槸鍚︽湁鍑哄簱浠诲姟
+ var OutTask = _taskService.GeOutCuTaskQueue(shallowLocation.LocationCode);
+ if (OutTask != null)
+ {
+ //杩涜涓嬪彂缁欏爢鍨涙満浠诲姟
+ WCSginseng outresult = _taskService.SC_IssueTasks(OutTask.TaskId, int.Parse(OutTask.Roadway), OutTask.TaskNum, OutTask.PalletCode, int.Parse(OutTask.PalletType), OutTask.CurrentAddress, OutTask.NextAddress, OutTask.TargetAddress);
+ if (outresult.IsSuccess)
+ {
+
+ OutTask.TaskStatus = (int)OutTaskStatusEnum.SC_OutExecuting;
+ OutTask.Dispatchertime = DateTime.Now;
+ _taskService.UpdateData(OutTask);
+ return content.OK();
+ }
+ else
+ {
+ UpdateTaskStatus(dt_Task, outresult,0, 1);
+
+ return content.Error($"涓嬪彂wcs澶辫触锛屽師鍥狅細{outresult.Message}");
+ }
+ }
+
+
+ //鍒ゆ柇鏄惁鏈夌Щ搴撲换鍔�
var TransferTask = _taskService.GeRelocationTaskQueue(shallowLocation.LocationCode);
if (TransferTask != null)
{
@@ -61,38 +84,37 @@
if (result.IsSuccess)
{
TransferTask.TaskStatus = (int)RelocationTaskStatusEnum.RelocationExecuting;
+ TransferTask.Dispatchertime = DateTime.Now;
_taskService.UpdateData(TransferTask);
return content.OK();
}
else
{
- UpdateTaskStatus(dt_Task, result,
- successStatus: dt_Task.TaskStatus == (int)InTaskStatusEnum.PLC_InFinish ? (int)InTaskStatusEnum.SC_IntExecuting : (int)OutTaskStatusEnum.SC_OutExecuting, 1);
+ UpdateTaskStatus(dt_Task, result,0,1); //榛樿涓嶉渶瑕佹洿鏀圭姸鎬佷紶0
- WriteLog.Write_Log("WMS_鍒ゆ柇宸烽亾鍐呯Щ搴�", $"鍒ゆ柇绉诲簱", "澶辫触", $"鍘熷洜锛歿result.Message}");
- return content.Error();
+ return content.Error($"涓嬪彂wcs澶辫触锛屽師鍥狅細{result.Message}");
}
}
var CuttTransferTask = _taskService.RelocationTaskProgress(dt_Task.Roadway);
//鍒ゆ柇褰撳墠鏄惁鏈夌Щ搴撲换鍔�
- if (CuttTransferTask != null) return content.Error();
+ if (CuttTransferTask) return content.Error("褰撳墠鏈夌Щ搴撲换鍔★紝涓嶅彲涓嬪彂");
- if (shallowLocation.LocationStatus != (int)LocationStatusEnum.InStock) return content.Error();
+ if (shallowLocation.LocationStatus != (int)LocationStatusEnum.InStock) return content.Error($"搴撲綅鐘舵�佸紓甯革紝褰撳墠鐘舵�侊細{(LocationStatusEnum)shallowLocation.LocationStatus}锛屽簲涓猴細{LocationStatusEnum.InStock}");
//鐢熸垚绉诲簱浠诲姟
return content = GenerateTransferTask(shallowLocation.LocationCode);
}
catch (Exception ex)
{
- WriteLog.Write_Log("WMS_鍒ゆ柇宸烽亾鍐呯Щ搴�", $"鍒ゆ柇绉诲簱", "澶辫触,鏂规硶鍐呮晠闅�", $"鍘熷洜锛歿ex.Message}");
- return content.Error();
+ return content.Error($"鍒ゆ柇宸烽亾鍐呯Щ搴�,澶辫触,鏂规硶鍐呮晠闅�,鍘熷洜锛歿ex.Message}");
}
}
+ //鐢熸垚绉诲簱浠诲姟
public WebResponseContent GenerateTransferTask(string shallowLocation)
{
WebResponseContent webResponse = new WebResponseContent();
@@ -102,8 +124,82 @@
Dt_StockInfo dt_StockInfo = _stockInfoService.Repository.QueryData(x => x.LocationCode == shallowLocation).FirstOrDefault();
Dt_LocationInfo newLocation = _locationInfoService.GetLocation(OriginalLocation.RoadwayNo, OriginalLocation.LocationType);
List<Dt_LocationInfo> dt_Locations = new List<Dt_LocationInfo>();
-
+ var TransferTask = _taskService.GeRelocationTaskQueue(shallowLocation);
MES_parameter mES_Parame = _taskService.ApplicationChangeStorageLocation(dt_StockInfo.PalletCode, OriginalLocation.LocationCode, newLocation.LocationCode);
+ if (mES_Parame != null)
+ {
+ if (mES_Parame.Result == "Y")
+ {
+ //杩涜鐢熸垚浠诲姟锛屼笅鍙戜换鍔¤嚦MES
+ Dt_Task task = new Dt_Task();
+ task.TaskNum = $"REL{DateTime.Now:yyyyMMddHHmmss}{new Random().Next(1000, 9999)}";
+ //task.TaskNum = "0";
+ task.PalletCode = dt_StockInfo.PalletCode;
+ task.PalletType = dt_StockInfo.PalletType;
+ task.Roadway = OriginalLocation.RoadwayNo;
+ task.TaskType = (int)TaskTypeEnum.Relocation;
+ task.TaskStatus = (int)RelocationTaskStatusEnum.RelocationNew;
+ task.SourceAddress = OriginalLocation.LocationCode;
+ task.TargetAddress = newLocation.LocationCode;
+ task.CurrentAddress = OriginalLocation.LocationCode;
+ task.NextAddress = newLocation.LocationCode;
+ task.WarehouseId = OriginalLocation.WarehouseId;
+ task.OrderNo = "";
+ task.Grade = 1;
+ task.Creater = "MES";
+ task.CreateDate = DateTime.Now;
+
+ OriginalLocation.LocationStatus = (int)LocationStatusEnum.Lock;
+ newLocation.LocationStatus = (int)LocationStatusEnum.Lock;
+ dt_StockInfo.StockStatus = (int)StockStatusEmun.绉诲簱閿佸畾;
+
+ dt_Locations.Add(OriginalLocation);
+ dt_Locations.Add(newLocation);
+
+ _unitOfWorkManage.BeginTran();
+
+ int TaskId = _taskService.Repository.AddData(task);
+ _locationInfoService.UpdateData(dt_Locations);
+ _stockInfoService.UpdateData(dt_StockInfo);
+ _unitOfWorkManage.CommitTran();
+ return webResponse.Error("宸茬敓鎴愮Щ搴撲换鍔�");
+ }
+ else
+ {
+
+ WriteLog.Write_Log("WMS_绉诲簱鏁呴殰", $"EMS鐢宠鍌ㄤ綅寮傚姩杩斿洖澶辫触鍐呭", "澶辫触", $"MES涓嶅厑璁哥Щ鍔�====>>>>杩斿洖鍐呭锛歿mES_Parame.ToJson()}");
+ return webResponse.Error($"鐢宠鍌ㄤ綅寮傚姩锛孧ES涓嶅厑璁哥Щ鍔�====>>>>杩斿洖鍐呭锛歿mES_Parame.ToJson()}");
+ }
+ }
+ else
+ {
+ WriteLog.Write_Log("WMS_绉诲簱鏁呴殰", $"EMS鐢宠鍌ㄤ綅寮傚姩杩斿洖澶辫触鍐呭", "澶辫触", $"鐢宠鍌ㄤ綅寮傚姩锛孧ES杩斿洖涓虹┖");
+ return webResponse.Error("鐢宠鍌ㄤ綅寮傚姩锛孧ES杩斿洖涓虹┖");
+ }
+
+ //杩涜涓嬪彂缁欏爢鍨涙満浠诲姟
+ /*WCSginseng result = _taskService.SC_IssueTasks(
+ TaskId,
+ int.Parse(task.Roadway),
+ task.TaskNum,
+ task.PalletCode,
+ int.Parse(task.PalletType),
+ task.CurrentAddress,
+ task.NextAddress,
+ task.TargetAddress);
+ if (result.IsSuccess)
+ {
+ Dt_Task dt_Task=_taskService.Repository.QueryFirst(x=>x.TaskId== task.TaskId);
+ dt_Task.TaskStatus = (int)RelocationTaskStatusEnum.RelocationExecuting;
+ _taskService.UpdateData(dt_Task);
+ return webResponse.OK();
+ }
+ else
+ {
+ return webResponse.Error($"涓嬪彂绉诲簱澶辫触,鍘熷洜锛歿result.Message}");
+ }*/
+
+ /* MES_parameter mES_Parame = _taskService.ApplicationChangeStorageLocation(dt_StockInfo.PalletCode, OriginalLocation.LocationCode, newLocation.LocationCode);
if (mES_Parame != null)
{
if (mES_Parame.Result == "Y")
@@ -160,28 +256,23 @@
}
else
{
- WriteLog.Write_Log("WMS_鍒ゆ柇宸烽亾鍐呯Щ搴�", $"绉诲簱浠诲姟鐢熸垚鏂规硶", "涓嬪彂绉诲簱澶辫触", $"鍘熷洜锛歿result.Message}");
-
- return webResponse.Error();
+ return webResponse.Error($"涓嬪彂绉诲簱澶辫触,鍘熷洜锛歿result.Message}");
}
}
else
{
- WriteLog.Write_Log("WMS_鍒ゆ柇宸烽亾鍐呯Щ搴�", $"绉诲簱浠诲姟鐢熸垚鏂规硶", "鐢宠MES绉诲簱", $"鐢宠鍌ㄤ綅寮傚姩锛孧ES涓嶅厑璁哥Щ鍔�");
- return webResponse.Error();
+ return webResponse.Error($"鐢宠鍌ㄤ綅寮傚姩锛孧ES涓嶅厑璁哥Щ鍔�====>>>>杩斿洖鍐呭锛歿mES_Parame.ToJson()}");
}
}
else
{
- WriteLog.Write_Log("WMS_鍒ゆ柇宸烽亾鍐呯Щ搴�", $"绉诲簱浠诲姟鐢熸垚鏂规硶", "鐢宠MES绉诲簱,杩斿洖绌�", $"鐢宠鍌ㄤ綅寮傚姩锛孧ES杩斿洖涓虹┖");
- return webResponse.Error();
- }
+ return webResponse.Error("鐢宠鍌ㄤ綅寮傚姩锛孧ES杩斿洖涓虹┖");
+ }*/
}
catch (Exception ex)
{
_unitOfWorkManage.RollbackTran();
- WriteLog.Write_Log("WMS_鍒ゆ柇宸烽亾鍐呯Щ搴�", $"绉诲簱浠诲姟鐢熸垚鏂规硶", "绯荤粺鏁呴殰", $"鍘熷洜锛歿ex.Message}");
- return webResponse.Error();
+ return webResponse.Error($"绉诲簱浠诲姟鐢熸垚鏂规硶锛岀郴缁熸晠闅�,鍘熷洜锛歿ex.Message}");
}
}
--
Gitblit v1.9.3