From 5ea48455463691678b806badbee198699a878b5a Mon Sep 17 00:00:00 2001
From: HuBingJie <3146306518@qq.com>
Date: 星期四, 25 十二月 2025 18:38:58 +0800
Subject: [PATCH] 1

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |  132 +++++++++++++++++++++++++------------------
 1 files changed, 76 insertions(+), 56 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index 2461430..17eab30 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -555,16 +555,16 @@
         /// </summary>
         /// <param name="taskNum">浠诲姟鍙�</param>
         /// <returns></returns>
-        public WebResponseContent Cancelinventory(int taskNum)
+        public ApiResponse<object> Cancelinventory(string palletTaskDTO)
         {
             WebResponseContent webResponse = new WebResponseContent();
             try
             {
                 // 鏌ユ壘浠诲姟
-                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum &&(x.TaskStatus == TaskOutStatusEnum.OutNew.ObjToInt()|| x.TaskStatus == TaskRelocationStatusEnum.RelocationNew.ObjToInt()|| x.TaskStatus == TaskInStatusEnum.Line_InExecuting.ObjToInt()));
+                Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == palletTaskDTO && (x.TaskStatus == TaskOutStatusEnum.OutNew.ObjToInt()|| x.TaskStatus == TaskRelocationStatusEnum.RelocationNew.ObjToInt()|| x.TaskStatus == TaskInStatusEnum.Line_InExecuting.ObjToInt()));
                 if (task == null)
                 {
-                    return webResponse.Error($"鏈壘鍒颁换鍔″彿涓恒�恵taskNum}銆戠殑浠诲姟淇℃伅");
+                    return MESresponse($"鏈壘鍒拌揣浣嶄俊鎭�,鏉$爜锛歿palletTaskDTO}", false, 0);
                 }
 
                 bool res;
@@ -583,7 +583,7 @@
                         res = false;
                         break;
                 }
-                if (!res) return WebResponseContent.Instance.Error("浠诲姟鐘舵�佸紓甯�");
+                if (!res) return MESresponse($"浠诲姟鐘舵�佸紓甯�", false, 0);
 
                 Dt_StockInfo stockInfo = _stockRepository.QueryFirst(x => x.PalletCode == task.PalletCode);
 
@@ -598,10 +598,18 @@
                   .SetColumns(x => x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt())
                   .Where(x => x.PalletCode == task.PalletCode)
                   .ExecuteCommand();
+                    if (stockmsseg<=0)
+                    {
+                        return MESresponse($"鏃犲簱瀛樹俊鎭�", false, 0);
+                    }
                     locationmsseg = _locationInfoRepository.Db.Updateable<Dt_LocationInfo>()
           .SetColumns(x => x.LocationStatus == LocationStatusEnum.InStock.ObjToInt())
           .Where(x => x.LocationCode == stockInfo.LocationCode)
           .ExecuteCommand();
+                    if (locationmsseg <= 0)
+                    {
+                        return MESresponse($"鏈壘鍒拌揣浣嶄俊鎭�,鏉$爜锛歿palletTaskDTO}", false, 0);
+                    }
                     taskmsseg = BaseDal.DeleteData(task);
                 }
                 else
@@ -610,10 +618,14 @@
                     .SetColumns(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt())
                     .Where(x => x.LocationCode == stockInfo.LocationCode)
                     .ExecuteCommand();
+                    if (locationmsseg <= 0)
+                    {
+                        return MESresponse($"鏈壘鍒拌揣浣嶄俊鎭�,鏉$爜锛歿palletTaskDTO}", false, 0);
+                    }
                     stockmsseg = _stockRepository.DeleteData(stockInfo).ObjToInt();
                     taskmsseg = BaseDal.DeleteData(task);
                 }
-                BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
+                BaseDal.DeleteAndMoveIntoHty(task,OperateTypeEnum.浜哄伐鍒犻櫎);
                 //鑾峰彇鎺ュ彛杩涜璋冨彇
                 var ConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_WCS_IPAddress, SysConfigConst.WCSCancelinventory);      //鑾峰彇鍒皐cs鍏ㄩ儴绫诲瀷鐨勬帴鍙�
                 string WCSReceiveTaskAPI = ConfigsAPIInfo.ApiAddress + ConfigsAPIInfo.ApiName;
@@ -621,62 +633,67 @@
                 {
                     _unitOfWorkManage.RollbackTran();
 
-                    return webResponse.Error($"浠诲姟鎵嬪姩鍙栨秷澶辫触锛屾湭閰嶇疆WCS浠诲姟鎵嬪姩鍙栨秷鍙嶉鎺ュ彛");
+                    return MESresponse($"鎵嬪姩鍙栨秷澶辫触鏈壘鍒皐cs鐨勯厤缃帴鍙�", false, 0);
                 }
-                var respon = HttpHelper.Get(WCSReceiveTaskAPI, JsonConvert.SerializeObject(task.TaskNum));
+                string apiUrl = $"{WCSReceiveTaskAPI}?taskNum={task.TaskNum}";
+                var respon = HttpHelper.Get(apiUrl);
 
                 if (respon == null)
                 {
                     _unitOfWorkManage.RollbackTran();
 
-                    return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�");
+                    return MESresponse($"wcs璋冨彇鎺ュ彛澶辫触杩斿洖鍙傛暟涓簄ull", false, 0);
                 }
                 var response = JsonConvert.DeserializeObject<ApiResponse<object>>(respon);
-                if (!response.Success)
+                if (!response.status)
                 {
                     _unitOfWorkManage.RollbackTran();
-
-                    return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}");
+                    return MESresponse($"WCS璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}", false, 0);
                 }
                 if (stockmsseg <= 0 && locationmsseg <= 0 && taskmsseg)
                     {
                     _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error("浠诲姟鍙栨秷澶辫触");
+                    return MESresponse($"浠诲姟鍙栨秷澶辫触", false, 0);
                     }
 
-                //鑾峰彇鎺ュ彛杩涜璋冨彇
-                var MESConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_MES_IPAddress, SysConfigConst.MEScancelTask);      //鑾峰彇鍒癕ES鍏ㄩ儴绫诲瀷鐨勬帴鍙�
-                string MEScancelTask = ConfigsAPIInfo.ApiAddress + ConfigsAPIInfo.ApiName;
-                if (MEScancelTask == null)
-                {
-                    _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error($"浠诲姟鎵嬪姩瀹屾垚澶辫触锛屾湭閰嶇疆WCS浠诲姟鎵嬪姩瀹屾垚鍙嶉鎺ュ彛");
-                }
-                var MES = new
-                {
-                    businessId = task.MESbusinessId,
-                    taskId = task.MEStaskId,
-                    palletCode = task.PalletCode
-                };
-                var MESrespon = HttpHelper.Post(MEScancelTask, JsonConvert.SerializeObject(MES));
-                if (respon == null)
-                {
-                    _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�");
-                }
-                var MESresponse = JsonConvert.DeserializeObject<ApiResponse<object>>(respon);
-                if (!response.Success)
-                {
-                    _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}");
-                }
+
+
+
+
+
+                ////鑾峰彇鎺ュ彛杩涜璋冨彇
+                //var MESConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_MES_IPAddress, SysConfigConst.MEScancelTask);      //鑾峰彇鍒癕ES鍏ㄩ儴绫诲瀷鐨勬帴鍙�
+                //string MEScancelTask = MESConfigsAPIInfo.ApiAddress + MESConfigsAPIInfo.ApiName;
+                //if (MEScancelTask == null)
+                //{
+                //    _unitOfWorkManage.RollbackTran();
+                //    return webResponse.Error($"浠诲姟鎵嬪姩鍙栨秷澶辫触锛屾湭閰嶇疆MES浠诲姟鎵嬪姩鍙栨秷鍙嶉鎺ュ彛");
+                //}
+                //var MES = new
+                //{
+                //    businessId = task.MESbusinessId,
+                //    taskId = task.MEStaskId,
+                //    palletCode = task.PalletCode
+                //};
+                //var MESrespon = HttpHelper.Post(MEScancelTask, JsonConvert.SerializeObject(MES));
+                //if (MESrespon == null)
+                //{
+                //    _unitOfWorkManage.RollbackTran();
+                //    return webResponse.Error($"MES璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�");
+                //}
+                //var MESresponse = JsonConvert.DeserializeObject<ApiResponse<object>>(MESrespon);
+                //if (!MESresponse.Success)
+                //{
+                //    _unitOfWorkManage.RollbackTran();
+                //    return webResponse.Error($"MES璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}");
+                //}
                 _unitOfWorkManage.CommitTran();
-                return webResponse.OK("浠诲姟鍙栨秷鎴愬姛");
+                return MESresponse($"浠诲姟鍙栨秷鎴愬姛", true, 1);
             }
             catch (Exception ex)
             {
                 _unitOfWorkManage.RollbackTran();
-                return webResponse.Error($"鍙栨秷浠诲姟澶辫触锛屽師鍥狅細{ex.Message}");
+                return  MESresponse($"鍙栨秷浠诲姟澶辫触锛屽師鍥狅細{ex.Message}", false, 0);
             }
         }
 
@@ -863,16 +880,16 @@
         /// <param name="taskNum"></param>
         /// <returns></returns>
         /// <exception cref="NotImplementedException"></exception>
-        public WebResponseContent ManualTaskCompleted(int taskNum)
+        public WebResponseContent ManualTaskCompleted(string palletTaskDTO)
         {
             WebResponseContent webResponse = new WebResponseContent();
             try
             {
                 // 鏌ユ壘浠诲姟
-                Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
+                Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == palletTaskDTO);
                 if (task == null)
                 {
-                    return webResponse.Error($"鏈壘鍒颁换鍔″彿涓恒�恵taskNum}銆戠殑浠诲姟淇℃伅");
+                    return webResponse.Error($"鏈壘鍒版墭鐩樼紪鐮佷负銆恵palletTaskDTO}銆戠殑浠诲姟淇℃伅");
                 }
 
 
@@ -928,7 +945,7 @@
 
                 taskmsseg = BaseDal.DeleteData(task);
 
-                task_htymsseg = BaseDal.DeleteAndMoveIntoHty(task,OperateTypeEnum.浜哄伐瀹屾垚);
+                task_htymsseg = BaseDal.DeleteAndMoveIntoHty(task, OperateTypeEnum.浜哄伐瀹屾垚);
                 //鑾峰彇鎺ュ彛杩涜璋冨彇
                 var ConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_WCS_IPAddress, SysConfigConst.WCSManualTaskCompleted);      //鑾峰彇鍒皐cs鍏ㄩ儴绫诲瀷鐨勬帴鍙�
                 string WCSReceiveTaskAPI = ConfigsAPIInfo.ApiAddress + ConfigsAPIInfo.ApiName;
@@ -937,19 +954,22 @@
                     _unitOfWorkManage.RollbackTran();
                     return webResponse.Error($"浠诲姟鎵嬪姩瀹屾垚澶辫触锛屾湭閰嶇疆WCS浠诲姟鎵嬪姩瀹屾垚鍙嶉鎺ュ彛");
                 }
-                var respon = HttpHelper.Get(WCSReceiveTaskAPI, JsonConvert.SerializeObject(task.TaskNum));
+
+                string apiUrl = $"{WCSReceiveTaskAPI}?taskNum={task.TaskNum}";
+
+                var respon = HttpHelper.Get(apiUrl);
                 if (respon == null)
                 {
                     _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�");
+                    return webResponse.Error($"WCS璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�");
                 }
                 var response = JsonConvert.DeserializeObject<ApiResponse<object>>(respon);
-                if (!response.Success)
+                if (!response.status)
                 {
                     _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}");
+                    return webResponse.Error($"WCS璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}");
                 }
-                if (!(resstock && task_htymsseg && taskmsseg && task.TaskType ==TaskOutboundTypeEnum.Outbound.ObjToInt() ? location1 : (location1 && location2)))
+                if (!(resstock && task_htymsseg && taskmsseg && task.TaskType == TaskRelocationTypeEnum.Relocation.ObjToInt() ? (location1 && location2) : location1))
                     {
                     _unitOfWorkManage.RollbackTran();
                     return webResponse.Error($"浠诲姟鎵嬪姩瀹屾垚澶辫触");
@@ -957,29 +977,29 @@
 
                 //鑾峰彇鎺ュ彛杩涜璋冨彇
                 var MESConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_MES_IPAddress, SysConfigConst.MESmockComplete);      //鑾峰彇鍒皐cs鍏ㄩ儴绫诲瀷鐨勬帴鍙�
-                string MESmockComplete = ConfigsAPIInfo.ApiAddress + ConfigsAPIInfo.ApiName;
+                string MESmockComplete = MESConfigsAPIInfo.ApiAddress + MESConfigsAPIInfo.ApiName;
                 if (MESConfigsAPIInfo == null)
                 {
                     _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error($"浠诲姟鎵嬪姩瀹屾垚澶辫触锛屾湭閰嶇疆WCS浠诲姟鎵嬪姩瀹屾垚鍙嶉鎺ュ彛");
+                    return webResponse.Error($"浠诲姟鎵嬪姩瀹屾垚澶辫触锛屾湭閰嶇疆MES浠诲姟鎵嬪姩瀹屾垚鍙嶉鎺ュ彛");
                 }
                 var MES = new
                 {
                     businessId = task.MESbusinessId,
                     taskId = task.MEStaskId,
                     palletCode = task.PalletCode
-            };
+                };
                 var MESrespon = HttpHelper.Post(MESmockComplete, JsonConvert.SerializeObject(MES));
                 if (respon == null)
                 {
                     _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�");
+                    return webResponse.Error($"MES璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�");
                 }
-                var MESresponse = JsonConvert.DeserializeObject<ApiResponse<object>>(respon);
-                if (!response.Success)
+                var MESresponse = JsonConvert.DeserializeObject<ApiResponse<object>>(MESrespon);
+                if (!MESresponse.Success)
                 {
                     _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}");
+                    return webResponse.Error($"MES璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}");
                 }
                 _unitOfWorkManage.CommitTran();
                 return webResponse.OK("浠诲姟鎵嬪姩瀹屾垚鎴愬姛");

--
Gitblit v1.9.3