From 7d6194cf002b8f54d41cdc50b7f1b1843c1da636 Mon Sep 17 00:00:00 2001
From: Admin <Admin@ADMIN>
Date: 星期四, 15 一月 2026 13:14:21 +0800
Subject: [PATCH] MES接口

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MESTaskService.cs |  155 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 153 insertions(+), 2 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..f19a9d6 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"
@@ -52,12 +52,19 @@
                 {
                     if (mES_In.containerType == "2") LocationType = 2;
                 }
+                else if (dt_Warehouse.WarehouseType == (int)WarehouseEnum.YMCP)
+                {
+                    LocationType = 3;
+                }
 
                 string Roadway = _locationInfoService.AccessingTunnel(dt_Warehouse.WarehouseId, LocationType);
                 if (Roadway == "") return apiResponse.Error($"WMS鏈兘鏌ヨ閬撳搴斿贩閬撶紪鍙凤紝浠撳簱缂栫爜锛歿mES_In.warehouseNo}");
 
                 //鑾峰彇瀵瑰簲PLC绔欏彴淇℃伅
                 Dt_roadwayinfo _Roadwayinfo = _roadWayinfoService.QbtainPlatform(Roadway);
+
+                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();
@@ -126,6 +133,9 @@
 
                 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 task = new Dt_Task();
                 task.TaskNum = mES_In.transNo;
                 task.PalletCode = dt_Stock.PalletCode;
@@ -166,11 +176,12 @@
         //鍌ㄤ綅鏌ヨ鎺ュ彛
         public ApiResponse GetLocationByContainer(MES_InTask mES_In)
         {
+            WriteLog.GetLog("鍌ㄤ綅鏌ヨ鎺ュ彛").Write($"鍙傛暟锛歿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}");
@@ -244,8 +255,22 @@
                 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.TaskStatus== (int)InTaskStatusEnum.InNew)
                 {
+                    Dt_StockInfo dt_StockInfo=_stockInfoService.Repository.QueryData(x=>x.PalletCode==dt_Task.PalletCode).FirstOrDefault();
+                    if (dt_StockInfo == null) return apiResponse.Error("鍙栨秷澶辫触锛學MS璁板綍鐨勬墭鐩樺簱瀛樻煡鎵惧け璐�");
+                    _stockInfoService.Repository.DeleteData(dt_StockInfo);
+                    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);
                     return apiResponse.OK();
                 }
@@ -261,5 +286,131 @@
                 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, "鍏ュ簱浠诲姟姹囨姤");
+                return mES_Parame;
+            }
+            catch (Exception ex)
+            {
+                mES_Parame.Result = "N";
+                mES_Parame.ResultMsg= $"鍏ュ簱锛歐MS绯荤粺涓婁紶澶辫触,鍘熷洜锛歿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, "鍑哄簱浠诲姟姹囨姤");
+                return mES_Parame;
+            }
+            catch (Exception ex)
+            {
+                mES_Parame.Result = "N";
+                mES_Parame.ResultMsg = $"鍑哄簱锛歐MS绯荤粺涓婁紶澶辫触,鍘熷洜锛歿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, "鍌ㄤ綅寮傚姩鐢宠");
+                return mES_Parame;
+            }
+            catch (Exception ex)
+            {
+                mES_Parame.Result = "N";
+                mES_Parame.ResultMsg = $"鍌ㄤ綅寮傚姩鐢宠锛歐MS绯荤粺璋冨彇澶辫触,鍘熷洜锛歿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, "鍌ㄤ綅寮傚姩");
+                return mES_Parame;
+            }
+            catch (Exception ex)
+            {
+                mES_Parame.Result = "N";
+                mES_Parame.ResultMsg = $"鍌ㄤ綅寮傚姩锛歐MS绯荤粺璋冨彇澶辫触,鍘熷洜锛歿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, "浠诲姟寮傚父");
+                return mES_Parame;
+            }
+            catch (Exception ex)
+            {
+                mES_Parame.Result = "N";
+                mES_Parame.ResultMsg = $"浠诲姟寮傚父锛歐MS绯荤粺璋冨彇澶辫触,鍘熷洜锛歿ex.Message}";
+                return mES_Parame;
+            }
+        }
     }
 }

--
Gitblit v1.9.3