From bfcd7f5b405e431a5c07fe3fa77d74c892d4e66b Mon Sep 17 00:00:00 2001
From: xiazhengtongxue <133085197+xiazhengtongxue@users.noreply.github.com>
Date: 星期四, 19 三月 2026 15:52:42 +0800
Subject: [PATCH] fix: 修复出入库冲突拦截,系统位置与实际位置的映射和修复
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MESTaskService.cs | 124 ++++++++++++++++++++++++++++++-----------
1 files changed, 90 insertions(+), 34 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MESTaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MESTaskService.cs"
index 180d7b5..d1595b2 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MESTaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MESTaskService.cs"
@@ -32,7 +32,7 @@
{
public partial class TaskService
{
- public static List<string> InStationareaList = new List<string>() { "1113", "1114", "1115", "1116", "1117", "1118", "1119", "1120", "1121", "1122" };
+ public static List<string> InStationareaList = new List<string>() { "1113", "1114", "1115", "1116", "1117", "1118", "1119", "1120", "1121", "1122" ,"1123"};
//鍏ュ簱锛岀┖鐩樺洖搴�
public ApiResponse AddInStoreDoc(MES_InTask mES_In)
{
@@ -52,6 +52,7 @@
Dt_Task setask = BaseDal.QueryData(x => x.PalletCode == mES_In.containerNo).FirstOrDefault();
if (setask != null) return apiResponse.Error($"WMS宸叉湁褰撳墠浠诲姟锛屼笉鍙噸澶嶄笅鍙戯紝鎵樼洏缂栧彿锛歿mES_In.containerNo}");
+
// 鍒ゆ柇涓嬪彂鐨勬墭鐩樼紪鍙锋槸鍚﹀簱瀛樻墭鐩樼紪鍙锋湁閲嶅
if (_stockInfoService.IsContainerNoExist(mES_In.containerNo)) return apiResponse.Error($"褰撳墠搴撲綅宸叉湁璇ユ墭鐩樼紪鍙凤紝鎵樼洏缂栧彿锛歿mES_In.containerNo}");
Dt_Warehouse dt_Warehouse = _warehouseService.QueryWarehouse(mES_In.warehouseNo);
@@ -175,47 +176,98 @@
if (string.IsNullOrWhiteSpace(mES_In.containerNo)) return apiResponse.Error("鎵樼洏鐮佷笉鑳戒负绌�");
if (string.IsNullOrWhiteSpace(mES_In.endPosition)) return apiResponse.Error("鐩爣浣嶇疆涓嶈兘涓虹┖");
-
- Dt_StockInfo dt_Stock=_stockInfoService.Repository.QueryData(x=>x.PalletCode== mES_In.containerNo && x.StockStatus== (int)StockStatusEmun.宸插叆搴�).FirstOrDefault();
+ // 褰撳墠浠诲姟mES_In.endPosition鐩爣浣嶇疆1113 - 1122
+ var restrictedPositions = new List<string> { "1113", "1114", "1115", "1116", "1117", "1118", "1119", "1120", "1121", "1122", "1123" };
+ bool isRestrictedPosition = restrictedPositions.Contains(mES_In.endPosition);
+ if (isRestrictedPosition)
+ {
+ bool hasExistingTask = BaseDal.QueryData(x => x.TargetAddress == mES_In.endPosition).Any();
+ if (hasExistingTask)
+ {
+ // 鐩爣浣嶇疆鍦�1113-1122鑼冨洿鍐呯殑澶勭悊閫昏緫
+ return apiResponse.Error($"褰撳墠鏈夊幓鐩爣浣嶇疆{mES_In.endPosition}鐨勪换鍔★紝璇烽噸鏂版搷浣�");
+ }
+ }
+ Dt_StockInfo dt_Stock=_stockInfoService.Repository.QueryData(x=>x.PalletCode== mES_In.containerNo).FirstOrDefault();
if (dt_Stock == null) return apiResponse.Error($"WMS鏈兘鏌ユ壘閬撹鎵樼洏鏉$爜鐨勫簱瀛樿揣浣嶄俊鎭紝鏉$爜锛歿mES_In.containerNo}");
- Dt_LocationInfo dt_LocationInfo = _locationInfoService.Repository.QueryData(x => x.LocationCode == dt_Stock.LocationCode && x.LocationStatus== (int)LocationStatusEnum.InStock).FirstOrDefault();
- if (dt_LocationInfo == null) return apiResponse.Error($"WMS鏈兘鏌ユ壘閬撹鎵樼洏鏉$爜鐨勫簱瀛樿揣浣嶄俊鎭紝鏉$爜锛歿mES_In.containerNo}锛屾湭鎵惧埌璐т綅鍙凤細{dt_Stock.LocationCode}");
+ if(dt_Stock.StockStatus == (int)StockStatusEmun.宸插叆搴�)
+ {
+ Dt_LocationInfo dt_LocationInfo = _locationInfoService.Repository.QueryData(x => x.LocationCode == dt_Stock.LocationCode && x.LocationStatus == (int)LocationStatusEnum.InStock).FirstOrDefault();
+ if (dt_LocationInfo == null) return apiResponse.Error($"WMS鏈兘鏌ユ壘閬撹鎵樼洏鏉$爜鐨勫簱瀛樿揣浣嶄俊鎭紝鏉$爜锛歿mES_In.containerNo}锛屾湭鎵惧埌璐т綅鍙凤細{dt_Stock.LocationCode}");
- Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(dt_LocationInfo.RoadwayNo);
+ Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(dt_LocationInfo.RoadwayNo);
- Dt_Task setask = BaseDal.QueryData(x => x.PalletCode == mES_In.containerNo).FirstOrDefault();
- if (setask != null) return apiResponse.Error($"WMS宸叉湁褰撳墠浠诲姟锛屼笉鍙噸澶嶄笅鍙戯紝鎵樼洏缂栧彿锛歿mES_In.containerNo}");
+ Dt_Task setask = BaseDal.QueryData(x => x.PalletCode == mES_In.containerNo).FirstOrDefault();
+ if (setask != null) return apiResponse.Error($"WMS宸叉湁褰撳墠浠诲姟锛屼笉鍙噸澶嶄笅鍙戯紝鎵樼洏缂栧彿锛歿mES_In.containerNo}");
- Dt_Task task = new Dt_Task();
- task.TaskNum = mES_In.transNo;
- task.PalletCode = dt_Stock.PalletCode;
- task.PalletType = dt_Stock.PalletType;
- task.Roadway = dt_LocationInfo.RoadwayNo;
- task.TaskType = (int)TaskTypeEnum.Outbound;
- task.TaskStatus = (int)OutTaskStatusEnum.OutNew;
- task.SourceAddress = dt_LocationInfo.LocationCode;
- task.TargetAddress = mES_In.endPosition;
- task.CurrentAddress = dt_LocationInfo.LocationCode;
- task.NextAddress = _Roadwayinfo.OutSCStationCode;
- task.WarehouseId = dt_LocationInfo.WarehouseId;
- task.OrderNo = mES_In.transDate.ToString();
- task.Grade = 1;
- task.Creater = "MES";
- task.CreateDate = DateTime.Now;
+ Dt_Task task = new Dt_Task();
+ task.TaskNum = mES_In.transNo;
+ task.PalletCode = dt_Stock.PalletCode;
+ task.PalletType = dt_Stock.PalletType;
+ task.Roadway = dt_LocationInfo.RoadwayNo;
+ task.TaskType = (int)TaskTypeEnum.Outbound;
+ task.TaskStatus = (int)OutTaskStatusEnum.OutNew;
+ task.SourceAddress = dt_LocationInfo.LocationCode;
+ task.TargetAddress = mES_In.endPosition;
+ task.CurrentAddress = dt_LocationInfo.LocationCode;
+ task.NextAddress = _Roadwayinfo.OutSCStationCode;
+ task.WarehouseId = dt_LocationInfo.WarehouseId;
+ task.OrderNo = mES_In.transDate.ToString();
+ task.Grade = 1;
+ task.Creater = "MES";
+ task.CreateDate = DateTime.Now;
- dt_Stock.StockStatus = (int)StockStatusEmun.鍑哄簱涓�;
- dt_LocationInfo.LocationStatus = (int)LocationStatusEnum.Lock;
+ dt_Stock.StockStatus = (int)StockStatusEmun.鍑哄簱涓�;
+ dt_LocationInfo.LocationStatus = (int)LocationStatusEnum.Lock;
- _unitOfWorkManage.BeginTran();
- BaseDal.AddData(task);
- _stockInfoService.Repository.UpdateData(dt_Stock);
- _locationInfoService.Repository.UpdateData(dt_LocationInfo);
- _unitOfWorkManage.CommitTran();
+ _unitOfWorkManage.BeginTran();
+ BaseDal.AddData(task);
+ _stockInfoService.Repository.UpdateData(dt_Stock);
+ _locationInfoService.Repository.UpdateData(dt_LocationInfo);
+ _unitOfWorkManage.CommitTran();
- WriteLog.Write_Log("MES_鎺ユ敹MES鍑哄簱浠诲姟涓嬪彂", $"鍑哄簱浠诲姟娣诲姞", "鎴愬姛", $"娣诲姞鎴愬姛锛屾墭鐩樻潯鐮侊細{dt_Stock.PalletCode}");
- return apiResponse.OK();
+ WriteLog.Write_Log("MES_鎺ユ敹MES鍑哄簱浠诲姟涓嬪彂", $"鍑哄簱浠诲姟娣诲姞", "鎴愬姛", $"娣诲姞鎴愬姛锛屾墭鐩樻潯鐮侊細{dt_Stock.PalletCode}");
+ return apiResponse.OK();
+ }else if(dt_Stock.StockStatus == (int)StockStatusEmun.绉诲簱閿佸畾)
+ {
+ Dt_LocationInfo dt_LocationInfo = _locationInfoService.Repository.QueryData(x => x.LocationCode == dt_Stock.LocationCode && x.LocationStatus == (int)LocationStatusEnum.Lock).FirstOrDefault();
+ if (dt_LocationInfo == null) return apiResponse.Error($"WMS鏈兘鏌ユ壘閬撹鎵樼洏鏉$爜鐨勫簱瀛樿揣浣嶄俊鎭紝鏉$爜锛歿mES_In.containerNo}锛屾湭鎵惧埌璐т綅鍙凤細{dt_Stock.LocationCode}");
+
+ Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(dt_LocationInfo.RoadwayNo);
+
+ Dt_Task task = new Dt_Task();
+ task.TaskNum = mES_In.transNo;
+ task.PalletCode = dt_Stock.PalletCode;
+ task.PalletType = dt_Stock.PalletType;
+ task.Roadway = dt_LocationInfo.RoadwayNo;
+ task.TaskType = (int)TaskTypeEnum.Outbound;
+ task.TaskStatus = (int)OutTaskStatusEnum.OutWait;
+ task.SourceAddress = dt_LocationInfo.LocationCode;
+ task.TargetAddress = mES_In.endPosition;
+ task.CurrentAddress = dt_LocationInfo.LocationCode;
+ task.NextAddress = _Roadwayinfo.OutSCStationCode;
+ task.WarehouseId = dt_LocationInfo.WarehouseId;
+ task.OrderNo = mES_In.transDate.ToString();
+ task.Grade = 1;
+ task.Creater = "MES";
+ task.CreateDate = DateTime.Now;
+
+ _unitOfWorkManage.BeginTran();
+ BaseDal.AddData(task);
+ _unitOfWorkManage.CommitTran();
+ WriteLog.Write_Log("MES_鎺ユ敹MES鍑哄簱浠诲姟涓嬪彂", $"鍑哄簱浠诲姟娣诲姞", "鎴愬姛", $"娣诲姞鎴愬姛锛屾墭鐩樻潯鐮侊細{dt_Stock.PalletCode}");
+ return apiResponse.OK();
+
+ }
+ else
+ {
+ WriteLog.Write_Log("MES_鎺ユ敹MES鍑哄簱浠诲姟涓嬪彂", $"鍑哄簱浠诲姟娣诲姞", $"澶辫触,鎵樼洏鏉$爜锛歿dt_Stock.PalletCode}", $"搴撳瓨鐘舵�侀敊璇紝璇锋煡鐪媁MS绯荤粺搴撳瓨,搴撳瓨鐘舵�侊細{dt_Stock.StockStatus}");
+ return apiResponse.Error("搴撳瓨鐘舵�侀敊璇紝璇锋煡鐪媁MS绯荤粺搴撳瓨");
+ }
+
+
}
catch (Exception ex)
{
@@ -308,7 +360,11 @@
{
if (string.IsNullOrWhiteSpace(mES_In.transNo)) return apiResponse.Error("鍗曟嵁缂栧彿涓嶈兘涓虹┖");
Dt_Task dt_Task = BaseDal.QueryData(x => x.TaskNum == mES_In.transNo).FirstOrDefault();
- if (dt_Task == null) return apiResponse.Error($"WMS鏈兘鏌ユ壘閬撳搴斿崟鎹换鍔★紝鏉$爜锛歿mES_In.transNo}");
+ if (dt_Task == null) {
+ WriteLog.Write_Log("MES_浠诲姟鍙栨秷鎺ュ彛", $"浠诲姟鍙栨秷鎺ュ彛", "鎴愬姛", $"鍗曟嵁缂栧彿锛歿mES_In.transNo}锛屾敞鎰忥紒锛乄MS鏈兘鏌ユ壘閬撳搴斿崟鎹换鍔�");
+ return apiResponse.OK();
+ //return apiResponse.Error($"WMS鏈兘鏌ユ壘閬撳搴斿崟鎹换鍔★紝鏉$爜锛歿mES_In.transNo}");
+ }
if(dt_Task.TaskStatus== (int)InTaskStatusEnum.InNew)
{
BaseDal.DeleteData(dt_Task);
--
Gitblit v1.9.3