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 | 407 ++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 339 insertions(+), 68 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 966532b..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"
@@ -1,4 +1,5 @@
锘縰sing MailKit.Search;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
@@ -9,6 +10,7 @@
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
+using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.LocationEnum;
@@ -21,6 +23,8 @@
using WIDESEA_Core.Helper;
using WIDESEA_DTO.Inbound;
using WIDESEA_DTO.Task;
+using WIDESEA_IStockService;
+using WIDESEA_ITaskInfoService;
using WIDESEA_Model.Models;
using static WIDESEA_ITaskInfoService.ITaskService;
@@ -28,10 +32,11 @@
{
public partial class TaskService
{
+ 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)
{
- WriteLog.GetLog("鎺ユ敹MES鍏ュ簱浠诲姟涓嬪彂").Write($"鍙傛暟锛歿mES_In.ToJson()}", $"浠诲姟鎺ユ敹鍙傛暟");
+ WriteLog.Write_Log("MES_鎺ユ敹鍏ュ簱浠诲姟涓嬪彂", $"浠诲姟鎺ユ敹鍙傛暟", "鎺ユ敹鍙傛暟", $"鍙傛暟锛歿mES_In.ToJson()}");
ApiResponse apiResponse = new ApiResponse();
try
{
@@ -45,20 +50,51 @@
if (string.IsNullOrWhiteSpace(mES_In.endPosition)) return apiResponse.Error("鐩爣浣嶇疆涓嶈兘涓虹┖");
if (string.IsNullOrWhiteSpace(mES_In.containerType)) return apiResponse.Error("杞藉叿绫诲瀷涓嶈兘涓虹┖"); //杞藉叿绫诲瀷锛屽竷鏂�-1锛屾澗甯冨嵎-2锛屾垚鍝�-1
+ 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);
- if (dt_Warehouse == null) return apiResponse.Error($"WMS鏈兘鏌ヨ閬撳搴斾粨搴擄紝浠撳簱缂栫爜锛歿mES_In.warehouseNo}");
int LocationType = 1;
- if (dt_Warehouse.WarehouseType == (int)WarehouseEnum.YMYL)
+ string Roadway = "0";
+
+ string SourceAddress = mES_In.startPosition;
+ string TargetAddress = "";
+ string CurrentAddress = mES_In.startPosition;
+ string NextAddress = "";
+ int WarehouseId = dt_Warehouse.WarehouseId;
+
+
+ if (dt_Warehouse.WarehouseCode == mES_In.endPosition)
{
- if (mES_In.containerType == "2") LocationType = 2;
+ if (dt_Warehouse.WarehouseType == (int)WarehouseEnum.YMYL)
+ {
+ if (mES_In.containerType == "2") LocationType = 2;
+ }
+ else if (dt_Warehouse.WarehouseType == (int)WarehouseEnum.YMCP)
+ {
+ LocationType = 3;
+ }
+ Roadway = _locationInfoService.AccessingTunnel(dt_Warehouse.WarehouseId, LocationType);
+ if (Roadway == "0") return apiResponse.Error($"WMS鏈兘鏌ヨ閬撳搴斿贩閬撶紪鍙凤紝浠撳簱缂栫爜锛歿mES_In.warehouseNo}");
+ //鑾峰彇瀵瑰簲PLC绔欏彴淇℃伅
+ Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(Roadway);
+ NextAddress = _Roadwayinfo.InStationCode;
}
-
- string Roadway = _locationInfoService.AccessingTunnel(dt_Warehouse.WarehouseId, LocationType);
- if (Roadway == "") return apiResponse.Error($"WMS鏈兘鏌ヨ閬撳搴斿贩閬撶紪鍙凤紝浠撳簱缂栫爜锛歿mES_In.warehouseNo}");
-
- //鑾峰彇瀵瑰簲PLC绔欏彴淇℃伅
- Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(Roadway);
-
+ else
+ {
+ if (dt_Warehouse.WarehouseType == (int)WarehouseEnum.YMYL)
+ {
+ Roadway="1";
+ }
+ else if (dt_Warehouse.WarehouseType == (int)WarehouseEnum.YMCP)
+ {
+ Roadway = "2";
+ }
+ TargetAddress = mES_In.endPosition;
+ NextAddress = mES_In.endPosition;
+ }
Dt_Task task = new Dt_Task();
task.TaskNum = mES_In.transNo;
@@ -67,35 +103,57 @@
task.Roadway = Roadway;
task.TaskType = (int)TaskTypeEnum.Inbound;
task.TaskStatus = (int)InTaskStatusEnum.InNew;
- task.SourceAddress = mES_In.startPosition;
- task.TargetAddress = "";
- task.CurrentAddress = mES_In.startPosition;
- task.NextAddress = _Roadwayinfo.InStationCode;
- task.WarehouseId = dt_Warehouse.WarehouseId;
+ task.SourceAddress = SourceAddress;
+ task.TargetAddress = TargetAddress;
+ task.CurrentAddress = CurrentAddress;
+ task.NextAddress = NextAddress;
+ task.WarehouseId = WarehouseId;
task.OrderNo = mES_In.transDate.ToString();
task.Grade = 1;
task.Creater = "MES";
task.CreateDate = DateTime.Now;
- Dt_StockInfo dt_StockInfo = new Dt_StockInfo();
- dt_StockInfo.PalletCode = task.PalletCode;
- dt_StockInfo.PalletType = task.PalletType;
- dt_StockInfo.WarehouseId = task.WarehouseId;
- dt_StockInfo.StockStatus = (int)StockStatusEmun.鍏ュ簱涓�;
- dt_StockInfo.Creater = "MWS";
- dt_StockInfo.CreateDate = DateTime.Now;
+ int taskid=BaseDal.AddData(task);
- _unitOfWorkManage.BeginTran();
- BaseDal.AddData(task);
- _stockInfoService.Repository.AddData(dt_StockInfo);
- _unitOfWorkManage.CommitTran();
- WriteLog.GetLog("鎺ユ敹MES鍏ュ簱浠诲姟涓嬪彂").Write($"鍙傛暟锛歿mES_In.containerNo}", $"鍏ュ簱浠诲姟娣诲姞鎴愬姛");
- return apiResponse.OK();
+ //鍒涘缓浠诲姟鍚庯紝鍒ゆ柇鏄惁鏄骇绾垮洖搴撶殑浠诲姟
+ if (!InStationareaList.Contains(task.SourceAddress))
+ {
+ WriteLog.Write_Log("MES_鎺ユ敹鍏ュ簱浠诲姟涓嬪彂", $"鍙嶉淇℃伅", "鎴愬姛", $"浠诲姟娣诲姞鎴愬姛锛屾墭鐩樻潯鐮侊細{task.PalletCode}");
+ return apiResponse.OK();
+ }
+ else
+ {
+ WCSginseng result = PLC_IssueTasks(
+ taskid, // 涓嶆槸task.Taskid
+ task.WarehouseId,
+ task.TaskNum,
+ task.PalletCode,
+ int.Parse(task.PalletType),
+ task.CurrentAddress,
+ task.NextAddress,
+ "");
+ if (result.IsSuccess)
+ {
+ Dt_Task deltaskin = BaseDal.QueryData(x => x.TaskId == taskid).FirstOrDefault();
+ deltaskin.TaskStatus = (int)InTaskStatusEnum.PLC_InExecuting;
+ string Result = MesInTaskStatusEnum.Start.GetDescription();
+ BaseDal.UpdateData(deltaskin);
+ //璋冨彇涓婃父绯荤粺鍙嶉寮�濮嬩换鍔�
+ InStoreDocCallback(task.TaskNum, Result, "鎿嶄綔鎴愬姛", task.PalletCode, "");
+ return apiResponse.OK();
+ }
+ else
+ {
+ Dt_Task deltask= BaseDal.QueryData(x => x.TaskId == taskid).FirstOrDefault();
+ BaseDal.DeleteData(deltask);
+ return apiResponse.Error($"涓嬪彂浠诲姟澶辫触锛屼笅鍙慦CS澶辫触锛屽師鍥狅細{result.Message}");
+ }
+ }
}
catch (Exception ex)
{
_unitOfWorkManage.RollbackTran();
- WriteLog.GetLog("鎺ユ敹MES鍏ュ簱浠诲姟涓嬪彂").Write($"鍘熷洜锛歿ex.Message}", $"鍏ュ簱浠诲姟娣诲姞");
+ WriteLog.Write_Log("MES_鎺ユ敹鍏ュ簱浠诲姟涓嬪彂", $"鍙嶉淇℃伅", "澶辫触", $"浠诲姟娣诲姞澶辫触锛屾墭鐩樻潯鐮侊細{mES_In.containerNo},绯荤粺鍑洪敊鍘熷洜锛歿ex.Message}");
return apiResponse.Error($"WMS浠诲姟娣诲姞閿欒锛屽師鍥狅細{ex.Message}");
}
@@ -105,7 +163,8 @@
//鍑哄簱浠诲姟
public ApiResponse AddOutStoreDoc(MES_InTask mES_In)
{
- WriteLog.GetLog("鎺ユ敹MES鍑哄簱浠诲姟涓嬪彂").Write($"鍙傛暟锛歿mES_In.ToJson()}", $"浠诲姟鎺ユ敹鍙傛暟");
+ WriteLog.Write_Log("MES_鎺ユ敹MES鍑哄簱浠诲姟涓嬪彂", $"浠诲姟鎺ユ敹鍙傛暟", "鎺ユ敹鍙傛暟", $"鍙傛暟锛歿mES_In.ToJson()}");
+
ApiResponse apiResponse = new ApiResponse();
try
{
@@ -117,48 +176,103 @@
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 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 setask = BaseDal.QueryData(x => x.PalletCode == mES_In.containerNo).FirstOrDefault();
+ if (setask != null) return apiResponse.Error($"WMS宸叉湁褰撳墠浠诲姟锛屼笉鍙噸澶嶄笅鍙戯紝鎵樼洏缂栧彿锛歿mES_In.containerNo}");
- dt_Stock.StockStatus = (int)StockStatusEmun.鍑哄簱涓�;
- dt_LocationInfo.LocationStatus = (int)LocationStatusEnum.Lock;
+ 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;
- _unitOfWorkManage.BeginTran();
- BaseDal.AddData(task);
- _stockInfoService.Repository.UpdateData(dt_Stock);
- _locationInfoService.Repository.UpdateData(dt_LocationInfo);
- _unitOfWorkManage.CommitTran();
+ dt_Stock.StockStatus = (int)StockStatusEmun.鍑哄簱涓�;
+ dt_LocationInfo.LocationStatus = (int)LocationStatusEnum.Lock;
- WriteLog.GetLog("鎺ユ敹MES鍑哄簱浠诲姟涓嬪彂").Write($"娣诲姞鎴愬姛锛屾墭鐩樻潯鐮侊細{dt_Stock.PalletCode}", $"鍑哄簱浠诲姟娣诲姞");
- return apiResponse.OK();
+ _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();
+ }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)
{
_unitOfWorkManage.RollbackTran();
- WriteLog.GetLog("鎺ユ敹MES鍑哄簱浠诲姟涓嬪彂").Write($"鍘熷洜锛歿ex.Message}", $"鍑哄簱浠诲姟娣诲姞");
+ WriteLog.Write_Log("MES_鎺ユ敹MES鍑哄簱浠诲姟涓嬪彂", $"鍑哄簱浠诲姟娣诲姞", "澶辫触", $"浠诲姟娣诲姞澶辫触锛屾墭鐩樻潯鐮侊細{mES_In.containerNo},绯荤粺鍑洪敊鍘熷洜锛歿ex.Message}");
return apiResponse.Error($"WMS浠诲姟娣诲姞閿欒锛屽師鍥狅細{ex.Message}");
}
}
@@ -166,11 +280,13 @@
//鍌ㄤ綅鏌ヨ鎺ュ彛
public ApiResponse GetLocationByContainer(MES_InTask mES_In)
{
+ WriteLog.Write_Log("MES_鍌ㄤ綅鏌ヨ鎺ュ彛", $"鍌ㄤ綅鏌ヨ鎺ュ彛", "鍙傛暟", $"鎵樼洏鏉$爜锛歿mES_In.ToJson()}");
+
ApiResponse apiResponse = new ApiResponse();
try
{
if (string.IsNullOrWhiteSpace(mES_In.containerNo)) return apiResponse.Error("鎵樼洏鐮佷笉鑳戒负绌�");
- Dt_StockInfo dt_Stock = _stockInfoService.Repository.QueryData(x => x.PalletCode == mES_In.containerNo).FirstOrDefault();
+ Dt_StockInfo dt_Stock = _stockInfoService.Repository.QueryData(x => x.PalletCode == mES_In.containerNo &&x.StockStatus==(int)StockStatusEmun.宸插叆搴�).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).FirstOrDefault();
if (dt_LocationInfo == null) return apiResponse.Error($"WMS鏈兘鏌ユ壘閬撹鎵樼洏鏉$爜鐨勫簱瀛樿揣浣嶄俊鎭紝鏉$爜锛歿mES_In.containerNo}锛屾湭鎵惧埌璐т綅鍙凤細{dt_Stock.LocationCode}");
@@ -195,7 +311,7 @@
}
catch (Exception ex)
{
- WriteLog.GetLog("鍌ㄤ綅鏌ヨ鎺ュ彛").Write($"鍘熷洜锛歿ex.Message}", $"鍌ㄤ綅鏌ヨ鏌ヨ澶辫触");
+ WriteLog.Write_Log("MES_鍌ㄤ綅鏌ヨ鎺ュ彛", $"鍌ㄤ綅鏌ヨ鎺ュ彛", "鏌ヨ澶辫触", $"鎵樼洏鏉$爜锛歿mES_In.ToJson()}");
return apiResponse.Error($"WMS鍌ㄤ綅鏌ヨ閿欒锛屽師鍥狅細{ex.Message}");
}
@@ -204,6 +320,7 @@
//浠诲姟鏌ヨ鎺ュ彛
public ApiResponse GetTaskInfo(MES_InTask mES_In)
{
+ WriteLog.Write_Log("MES_浠诲姟鏌ヨ鎺ュ彛", $"浠诲姟鏌ヨ鎺ュ彛", "鍙傛暟", $"鎺ユ敹鐨勫弬鏁帮細{mES_In.ToJson()}");
ApiResponse apiResponse = new ApiResponse();
try
{
@@ -230,7 +347,7 @@
}
catch (Exception ex)
{
- WriteLog.GetLog("浠诲姟鏌ヨ鎺ュ彛").Write($"鍘熷洜锛歿ex.Message}", $"浠诲姟鏌ヨ澶辫触");
+ WriteLog.Write_Log("MES_浠诲姟鏌ヨ鎺ュ彛", $"浠诲姟鏌ヨ鎺ュ彛", "澶辫触", $"鏉$爜锛歿mES_In.transNo}锛屽師鍥狅細{ex.Message}");
return apiResponse.Error($"WMS浠诲姟鏌ヨ鎺ュ彛閿欒锛屽師鍥狅細{ex.Message}");
}
}
@@ -243,23 +360,177 @@
{
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.TaskStatus== (int)InTaskStatusEnum.InNew || dt_Task.TaskStatus == (int)OutTaskStatusEnum.OutNew)
+ 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);
+ return apiResponse.OK();
+ }else if(dt_Task.TaskStatus == (int)OutTaskStatusEnum.OutNew)
+ {
+ Dt_StockInfo dt_StockInfo = _stockInfoService.Repository.QueryData(x => x.PalletCode == dt_Task.PalletCode).FirstOrDefault();
+ Dt_LocationInfo dt_LocationInfo= _locationInfoService.Repository.QueryData(x=>x.LocationCode== dt_StockInfo.LocationCode).FirstOrDefault();
+ dt_StockInfo.StockStatus = (int)StockStatusEmun.宸插叆搴�;
+ dt_LocationInfo.LocationStatus = (int)LocationStatusEnum.InStock;
+
+ _stockInfoService.Repository.UpdateData(dt_StockInfo);
+ _locationInfoService.Repository.UpdateData(dt_LocationInfo);
+ BaseDal.DeleteData(dt_Task);
+ WriteLog.Write_Log("MES_浠诲姟鍙栨秷鎺ュ彛", $"浠诲姟鍙栨秷鎺ュ彛", "鎴愬姛", $"鍗曟嵁缂栧彿锛歿mES_In.transNo}");
return apiResponse.OK();
}
else
{
+ WriteLog.Write_Log("MES_浠诲姟鍙栨秷鎺ュ彛", $"浠诲姟鍙栨秷鎺ュ彛", "澶辫触", $"鍗曟嵁缂栧彿锛歿mES_In.transNo},浠诲姟宸茬粡鍦ㄦ墽琛屼腑锛屼笉鍙彇娑�");
return apiResponse.Error("浠诲姟宸茬粡鍦ㄦ墽琛屼腑锛屼笉鍙彇娑�");
}
}
catch (Exception ex)
{
- WriteLog.GetLog("浠诲姟鍙栨秷鎺ュ彛").Write($"鍘熷洜锛歿ex.Message}", $"浠诲姟鍙栨秷澶辫触");
+ WriteLog.Write_Log("MES_浠诲姟鍙栨秷鎺ュ彛", $"浠诲姟鍙栨秷鎺ュ彛", "澶辫触", $"鍗曟嵁缂栧彿锛歿mES_In.transNo}锛屽師鍥狅細{ex.Message}");
return apiResponse.Error($"WMS浠诲姟鍙栨秷鎺ュ彛閿欒锛屽師鍥狅細{ex.Message}");
}
}
+
+ //鍏ュ簱浠诲姟鍙嶉鎺ュ彛
+ public MES_parameter InStoreDocCallback(string TransNo, string Result, string ResultMsg, string ContainerNo, string LocationCode)
+ {
+ MES_parameter mES_Parame= new MES_parameter();
+ try
+ {
+ MesInResultResponse mesInResult = new MesInResultResponse();
+ mesInResult.TransNo = TransNo;
+ mesInResult.Result = Result;
+ mesInResult.ResultMsg = ResultMsg;
+ mesInResult.ContainerNo = ContainerNo;
+ mesInResult.LocationCode = LocationCode;
+ mES_Parame = HttpHelper.Post<MES_parameter>(MES_InReporttask, mesInResult, "鍏ュ簱浠诲姟姹囨姤");
+
+ WriteLog.Write_Log("MES_鍏ュ簱浠诲姟鍙嶉鎺ュ彛", $"鍏ュ簱浠诲姟鍙嶉鎺ュ彛", "鎴愬姛", $"璁㈠崟缂栧彿锛歿TransNo}锛屾墽琛岀粨鏋滐細{Result}锛屾墽琛岀粨鏋滄弿杩帮細{ResultMsg}锛屾墭鐩樻潯鐮侊細{ContainerNo}锛屽簱浣嶇紪鍙凤細{LocationCode}锛屼笂浼犵殑鍙傛暟锛歿mesInResult.ToJson()}锛屽洖浼犵殑鍙傛暟锛歿mES_Parame.ToJson()}");
+ return mES_Parame;
+ }
+ catch (Exception ex)
+ {
+ mES_Parame.Result = "N";
+ mES_Parame.ResultMsg= $"鍏ュ簱锛歐MS绯荤粺涓婁紶澶辫触,鍘熷洜锛歿ex.Message}";
+ WriteLog.Write_Log("MES_鍏ュ簱浠诲姟鍙嶉鎺ュ彛", $"鍏ュ簱浠诲姟鍙嶉鎺ュ彛", "澶辫触", $"璁㈠崟缂栧彿锛歿TransNo}锛屾墽琛岀粨鏋滐細{Result}锛屾墽琛岀粨鏋滄弿杩帮細{ResultMsg}锛屾墭鐩樻潯鐮侊細{ContainerNo}锛屽簱浣嶇紪鍙凤細{LocationCode}锛屼笂浼犲け璐ワ紝鍘熷洜:{ex.Message}");
+ return mES_Parame;
+ }
+
+ }
+ //鍑哄簱浠诲姟鍙嶉鎺ュ彛
+ public MES_parameter OutStoreDocCallback(string TransNo,string Result,string ResultMsg)
+ {
+ MES_parameter mES_Parame = new MES_parameter();
+ try
+ {
+ MesOutResultResponse mesInResult = new MesOutResultResponse();
+ mesInResult.TransNo = TransNo;
+ mesInResult.Result = Result;
+ mesInResult.ResultMsg = ResultMsg;
+ mES_Parame = HttpHelper.Post<MES_parameter>(MES_OutReporttask, mesInResult, "鍑哄簱浠诲姟姹囨姤");
+ WriteLog.Write_Log("MES_鍑哄簱浠诲姟鍙嶉鎺ュ彛", $"鍑哄簱浠诲姟鍙嶉鎺ュ彛", "鎴愬姛", $"璁㈠崟缂栧彿锛歿TransNo}锛屾墽琛岀粨鏋滐細{Result}锛屾墽琛岀粨鏋滄弿杩帮細{ResultMsg}锛屼笂浼犵殑鍙傛暟锛歿mesInResult.ToJson()}锛屽洖浼犵殑鍙傛暟锛歿mES_Parame.ToJson()}");
+ return mES_Parame;
+ }
+ catch (Exception ex)
+ {
+ mES_Parame.Result = "N";
+ mES_Parame.ResultMsg = $"鍑哄簱锛歐MS绯荤粺涓婁紶澶辫触,鍘熷洜锛歿ex.Message}";
+ WriteLog.Write_Log("MES_鍑哄簱浠诲姟鍙嶉鎺ュ彛", $"鍑哄簱浠诲姟鍙嶉鎺ュ彛", "澶辫触", $"璁㈠崟缂栧彿锛歿TransNo}锛屾墽琛岀粨鏋滐細{Result}锛屾墽琛岀粨鏋滄弿杩帮細{ResultMsg}锛屼笂浼犲け璐ワ紝鍘熷洜:{ex.Message}");
+ return mES_Parame;
+ }
+ }
+
+ /// <summary>
+ /// 鍌ㄤ綅寮傚姩鐢宠
+ /// </summary>
+ /// <param name="ContainerNo">鎵樼洏鏉$爜</param>
+ /// <param name="OriginalLocationCode">鍘熷偍浣�</param>
+ /// <param name="NewLocationCode">鏂板偍浣�</param>
+ /// <returns></returns>
+ public MES_parameter ApplicationChangeStorageLocation(string ContainerNo,string OriginalLocationCode,string NewLocationCode)
+ {
+ MES_parameter mES_Parame = new MES_parameter();
+ try
+ {
+ MES_Storagelocation Storagelocation = new MES_Storagelocation();
+ Storagelocation.ContainerNo = ContainerNo;
+ Storagelocation.OriginalLocationCode = OriginalLocationCode;
+ Storagelocation.NewLocationCode = NewLocationCode;
+ mES_Parame = HttpHelper.Post<MES_parameter>(MES_InventoryUpdateApply, Storagelocation, "鍌ㄤ綅寮傚姩鐢宠");
+ WriteLog.Write_Log("MES_鍌ㄤ綅寮傚姩鐢宠", $"鍌ㄤ綅寮傚姩鐢宠", "鎴愬姛", $"鎵樼洏鏉$爜锛歿ContainerNo}锛屽師搴撲綅锛歿OriginalLocationCode}锛屾柊搴撲綅锛歿NewLocationCode}锛屼笂浼犵殑鍙傛暟锛歿Storagelocation.ToJson()}锛屽洖浼犵殑鍙傛暟锛歿mES_Parame.ToJson()}");
+ return mES_Parame;
+ }
+ catch (Exception ex)
+ {
+ mES_Parame.Result = "N";
+ mES_Parame.ResultMsg = $"鍌ㄤ綅寮傚姩鐢宠锛歐MS绯荤粺璋冨彇澶辫触,鍘熷洜锛歿ex.Message}";
+ WriteLog.Write_Log("MES_鍌ㄤ綅寮傚姩鐢宠", $"鍌ㄤ綅寮傚姩鐢宠", "澶辫触", $"鎵樼洏鏉$爜锛歿ContainerNo}锛屽師搴撲綅锛歿OriginalLocationCode}锛屾柊搴撲綅锛歿NewLocationCode}锛屼笂浼犲け璐ワ紝鍘熷洜:{ex.Message}");
+ return mES_Parame;
+ }
+ }
+
+ /// <summary>
+ /// 鍌ㄤ綅寮傚姩
+ /// </summary>
+ /// <param name="ContainerNo">鎵樼洏鏉$爜</param>
+ /// <param name="OriginalLocationCode">鍘熷偍浣�</param>
+ /// <param name="NewLocationCode">鏂板偍浣�</param>
+ /// <returns></returns>
+ public MES_parameter AbnormalStorageLocation(string ContainerNo, string OriginalLocationCode, string NewLocationCode)
+ {
+ MES_parameter mES_Parame = new MES_parameter();
+ try
+ {
+ MES_Storagelocation Storagelocation = new MES_Storagelocation();
+ Storagelocation.ContainerNo = ContainerNo;
+ Storagelocation.OriginalLocationCode = OriginalLocationCode;
+ Storagelocation.NewLocationCode = NewLocationCode;
+ mES_Parame = HttpHelper.Post<MES_parameter>(MES_InventoryUpdateCallback, Storagelocation, "鍌ㄤ綅寮傚姩");
+ WriteLog.Write_Log("MES_鍌ㄤ綅寮傚姩涓婁紶", $"鍌ㄤ綅寮傚姩涓婁紶", "鎴愬姛", $"鎵樼洏鏉$爜锛歿ContainerNo}锛屽師搴撲綅锛歿OriginalLocationCode}锛屾柊搴撲綅锛歿NewLocationCode}锛屼笂浼犵殑鍙傛暟锛歿Storagelocation.ToJson()}锛屽洖浼犵殑鍙傛暟锛歿mES_Parame.ToJson()}");
+ return mES_Parame;
+ }
+ catch (Exception ex)
+ {
+ mES_Parame.Result = "N";
+ mES_Parame.ResultMsg = $"鍌ㄤ綅寮傚姩锛歐MS绯荤粺璋冨彇澶辫触,鍘熷洜锛歿ex.Message}";
+ WriteLog.Write_Log("MES_鍌ㄤ綅寮傚姩涓婁紶", $"鍌ㄤ綅寮傚姩涓婁紶", "澶辫触", $"鎵樼洏鏉$爜锛歿ContainerNo}锛屽師搴撲綅锛歿OriginalLocationCode}锛屾柊搴撲綅锛歿NewLocationCode}锛屼笂浼犲け璐ワ紝鍘熷洜:{ex.Message}");
+ return mES_Parame;
+ }
+ }
+ /// <summary>
+ /// 浠诲姟寮傚父
+ /// </summary>
+ /// <param name="TransNo">鍗曟嵁缂栧彿</param>
+ /// <param name="EquipmentType">璁惧绫诲瀷</param>
+ /// <param name="EquipmentNumber">璁惧缂栫爜</param>
+ /// <param name="ErrorInfo">寮傚父鎶ユ枃</param>MES_TaskErrorInfoCallback
+ /// <returns></returns>
+ public MES_parameter ToMES_TaskException(string TransNo,string EquipmentType,string EquipmentNumber,string ErrorInfo)
+ {
+ MES_parameter mES_Parame = new MES_parameter();
+ try
+ {
+ MES_TaskException Storagelocation = new MES_TaskException();
+ Storagelocation.TransNo = TransNo;
+ Storagelocation.EquipmentType = EquipmentType;
+ Storagelocation.EquipmentNumber = EquipmentNumber;
+ Storagelocation.ErrorInfo = ErrorInfo;
+ mES_Parame = HttpHelper.Post<MES_parameter>(MES_TaskErrorInfoCallback, Storagelocation, "浠诲姟寮傚父");
+ WriteLog.Write_Log("MES_浠诲姟寮傚父", $"浠诲姟寮傚父", "鎴愬姛", $"鍗曟嵁缂栧彿锛歿TransNo}锛岃澶囩被鍨嬶細{EquipmentType}锛岃澶囩紪鐮侊細{EquipmentNumber}锛屽紓甯告姤鏂噞ErrorInfo}锛岋紝涓婁紶鐨勫弬鏁帮細{Storagelocation.ToJson()}锛屽洖浼犵殑鍙傛暟锛歿mES_Parame.ToJson()}");
+ return mES_Parame;
+ }
+ catch (Exception ex)
+ {
+ mES_Parame.Result = "N";
+ mES_Parame.ResultMsg = $"浠诲姟寮傚父锛歐MS绯荤粺璋冨彇澶辫触,鍘熷洜锛歿ex.Message}";
+ WriteLog.Write_Log("MES_浠诲姟寮傚父", $"浠诲姟寮傚父", "澶辫触", $"鍗曟嵁缂栧彿锛歿TransNo}锛岃澶囩被鍨嬶細{EquipmentType}锛岃澶囩紪鐮侊細{EquipmentNumber}锛屽紓甯告姤鏂噞ErrorInfo}锛屼笂浼犲け璐ワ紝鍘熷洜:{ex.Message}");
+ return mES_Parame;
+ }
+ }
}
}
--
Gitblit v1.9.3