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 | 111 +++++++++++++++++++++++++++++++++++++------------------
1 files changed, 75 insertions(+), 36 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 2332a12..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"
@@ -51,8 +51,31 @@
}
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,13 +84,13 @@
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
return content.Error($"涓嬪彂wcs澶辫触锛屽師鍥狅細{result.Message}");
}
@@ -78,7 +101,7 @@
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);
@@ -91,6 +114,7 @@
}
+ //鐢熸垚绉诲簱浠诲姟
public WebResponseContent GenerateTransferTask(string shallowLocation)
{
WebResponseContent webResponse = new WebResponseContent();
@@ -100,44 +124,59 @@
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();
- //杩涜鐢熸垚浠诲姟锛屼笅鍙戜换鍔¤嚦MES
- Dt_Task task = new Dt_Task();
- 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;
+ int TaskId = _taskService.Repository.AddData(task);
+ _locationInfoService.UpdateData(dt_Locations);
+ _stockInfoService.UpdateData(dt_StockInfo);
+ _unitOfWorkManage.CommitTran();
+ return webResponse.Error("宸茬敓鎴愮Щ搴撲换鍔�");
+ }
+ else
+ {
- OriginalLocation.LocationStatus = (int)LocationStatusEnum.Lock;
- newLocation.LocationStatus = (int)LocationStatusEnum.Lock;
- dt_StockInfo.StockStatus = (int)StockStatusEmun.绉诲簱閿佸畾;
+ 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杩斿洖涓虹┖");
+ }
- 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("宸茬敓鎴愮Щ搴撲换鍔�");
//杩涜涓嬪彂缁欏爢鍨涙満浠诲姟
/*WCSginseng result = _taskService.SC_IssueTasks(
TaskId,
@@ -160,7 +199,7 @@
return webResponse.Error($"涓嬪彂绉诲簱澶辫触,鍘熷洜锛歿result.Message}");
}*/
- /*MES_parameter mES_Parame = _taskService.ApplicationChangeStorageLocation(dt_StockInfo.PalletCode, OriginalLocation.LocationCode, newLocation.LocationCode);
+ /* MES_parameter mES_Parame = _taskService.ApplicationChangeStorageLocation(dt_StockInfo.PalletCode, OriginalLocation.LocationCode, newLocation.LocationCode);
if (mES_Parame != null)
{
if (mES_Parame.Result == "Y")
--
Gitblit v1.9.3