From c1eac732fc3ef407d51b76d288f311d2fa43e618 Mon Sep 17 00:00:00 2001
From: xby-y <2251528873@qq.com>
Date: 星期一, 12 一月 2026 15:18:41 +0800
Subject: [PATCH] 1

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |  290 ++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 201 insertions(+), 89 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..74a61e7 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"
@@ -546,7 +546,7 @@
             ApiResponse<object> apiResponse = new ApiResponse<object>();
             apiResponse.Message = Message;
             apiResponse.Success = Success;
-            apiResponse.Code = 1;
+            apiResponse.Code = Code;
             return apiResponse;
         }
 
@@ -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 ApiResponse<object> 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 MESresponse($"鏈壘鍒版墭鐩樼紪鐮佷负銆恵palletTaskDTO}銆戠殑浠诲姟淇℃伅", false, 0);
                 }
 
 
@@ -893,14 +910,15 @@
                 if (task.TaskType == TaskInboundTypeEnum.Inbound.ObjToInt() || task.TaskType == TaskRelocationTypeEnum.Relocation.ObjToInt())
                 {
                     stockmsseg = _stockRepository.QueryFirst(x => x.LocationCode == task.TargetAddress);
-                    if (stockmsseg == null) { return webResponse.Error("鏈壘鍒板簱瀛樹俊鎭�"); };
+                    if (stockmsseg == null) { return MESresponse($"鏈壘鍒板簱瀛樹俊鎭�", false, 0); }
+                    ;
                     stockmsseg.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
                      resstock = _stockRepository.UpdateData(stockmsseg);
                     if (task.TaskType == TaskRelocationTypeEnum.Relocation.ObjToInt())
                     {
                         locationmsseg1 = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress);
                         locationmsseg2 = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.CurrentAddress);
-                        if (locationmsseg1 == null || locationmsseg2 == null) { webResponse.Error("鏈壘鍒拌揣浣嶄俊鎭�"); }
+                        if (locationmsseg1 == null || locationmsseg2 == null) { return MESresponse($"鏈壘鍒拌揣浣嶄俊鎭�", false, 0); }
                         locationmsseg1.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
                         locationmsseg2.LocationStatus = LocationStatusEnum.Free.ObjToInt();
                         location1 = _locationInfoRepository.UpdateData(locationmsseg1);
@@ -909,7 +927,7 @@
                     else
                     {
                         locationmsseg1 = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress);
-                        if (locationmsseg1 == null) { webResponse.Error("鏈壘鍒拌揣浣嶄俊鎭�"); }
+                        if (locationmsseg1 == null) { return MESresponse($"鏈壘鍒拌揣浣嶄俊鎭�", false, 0); }
                         locationmsseg1.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
                         location1 = _locationInfoRepository.UpdateData(locationmsseg1);
                         
@@ -918,76 +936,170 @@
                 else
                 {
                     stockmsseg = _stockRepository.QueryFirst(x => x.LocationCode == task.CurrentAddress);
-                    if (stockmsseg == null) { return webResponse.Error("鏈壘鍒板簱瀛樹俊鎭�"); }
+                    if (stockmsseg == null) { return MESresponse($"鏈壘鍒板簱瀛樹俊鎭�", false, 0); }
                     resstock = _stockRepository.DeleteData(stockmsseg);
                     locationmsseg1 = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.CurrentAddress);
-                    if (locationmsseg1 == null) { webResponse.Error("鏈壘鍒拌揣浣嶄俊鎭�"); }
+                    if (locationmsseg1 == null) { return MESresponse($"鏈壘鍒拌揣浣嶄俊鎭�", false, 0); }
                     locationmsseg1.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
                     location1 = _locationInfoRepository.UpdateData(locationmsseg1);
                 }
 
                 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;
                 if (WCSReceiveTaskAPI == null)
                 {
                     _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error($"浠诲姟鎵嬪姩瀹屾垚澶辫触锛屾湭閰嶇疆WCS浠诲姟鎵嬪姩瀹屾垚鍙嶉鎺ュ彛");
-                }
-                var respon = HttpHelper.Get(WCSReceiveTaskAPI, JsonConvert.SerializeObject(task.TaskNum));
-                if (respon == null)
-                {
-                    _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�");
-                }
-                var response = JsonConvert.DeserializeObject<ApiResponse<object>>(respon);
-                if (!response.Success)
-                {
-                    _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}");
-                }
-                if (!(resstock && task_htymsseg && taskmsseg && task.TaskType ==TaskOutboundTypeEnum.Outbound.ObjToInt() ? location1 : (location1 && location2)))
-                    {
-                    _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error($"浠诲姟鎵嬪姩瀹屾垚澶辫触");
+                    return MESresponse($"浠诲姟鎵嬪姩瀹屾垚澶辫触锛屾湭閰嶇疆WCS浠诲姟鎵嬪姩瀹屾垚鍙嶉鎺ュ彛", false, 0);
                 }
 
-                //鑾峰彇鎺ュ彛杩涜璋冨彇
-                var MESConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_MES_IPAddress, SysConfigConst.MESmockComplete);      //鑾峰彇鍒皐cs鍏ㄩ儴绫诲瀷鐨勬帴鍙�
-                string MESmockComplete = ConfigsAPIInfo.ApiAddress + ConfigsAPIInfo.ApiName;
-                if (MESConfigsAPIInfo == null)
-                {
-                    _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error($"浠诲姟鎵嬪姩瀹屾垚澶辫触锛屾湭閰嶇疆WCS浠诲姟鎵嬪姩瀹屾垚鍙嶉鎺ュ彛");
-                }
-                var MES = new
-                {
-                    businessId = task.MESbusinessId,
-                    taskId = task.MEStaskId,
-                    palletCode = task.PalletCode
-            };
-                var MESrespon = HttpHelper.Post(MESmockComplete, JsonConvert.SerializeObject(MES));
+                string apiUrl = $"{WCSReceiveTaskAPI}?taskNum={task.TaskNum}";
+
+                var respon = HttpHelper.Get(apiUrl);
                 if (respon == null)
                 {
                     _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�");
+                    return MESresponse($"WCS璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�", false, 0);
                 }
-                var MESresponse = JsonConvert.DeserializeObject<ApiResponse<object>>(respon);
-                if (!response.Success)
+                var response = JsonConvert.DeserializeObject<ApiResponse<object>>(respon);
+                if (!response.status)
                 {
                     _unitOfWorkManage.RollbackTran();
-                    return webResponse.Error($"璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}");
+                    return MESresponse($"WCS璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}", false, 0);
+
+                }
+                if (!(resstock && task_htymsseg && taskmsseg && task.TaskType == TaskRelocationTypeEnum.Relocation.ObjToInt() ? (location1 && location2) : location1))
+                    {
+                    _unitOfWorkManage.RollbackTran();
+                    return MESresponse($"浠诲姟鎵嬪姩瀹屾垚澶辫触", false, 0);
+                }
+
+                ////鑾峰彇鎺ュ彛杩涜璋冨彇
+                //var MESConfigsAPIInfo = _dt_ApiInfoService.GetConfigsByAPIInfo(CateGoryConst.CONFIG_MES_IPAddress, SysConfigConst.MESmockComplete);      //鑾峰彇鍒皐cs鍏ㄩ儴绫诲瀷鐨勬帴鍙�
+                //string MESmockComplete = MESConfigsAPIInfo.ApiAddress + MESConfigsAPIInfo.ApiName;
+                //if (MESConfigsAPIInfo == null)
+                //{
+                //    _unitOfWorkManage.RollbackTran();
+                //    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($"MES璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁颁负绌�");
+                //}
+                //var MESresponse = JsonConvert.DeserializeObject<ApiResponse<object>>(MESrespon);
+                //if (!MESresponse.Success)
+                //{
+                //    _unitOfWorkManage.RollbackTran();
+                //    return webResponse.Error($"MES璋冨彇鎺ュ彛澶辫触锛屽弽棣堝弬鏁板師鍥狅細{response.Message}");
+                //}
+
+                WebResponseContent content;
+                switch (task.TaskType)
+                {
+                    case (int)TaskRelocationTypeEnum.Relocation:
+                        content = MES_TransferCompletionFeedback(task);
+                        break;
+                    case (int)TaskInboundTypeEnum.Inbound:
+                        content = TaskCompletionFeedback(task);
+                        break;
+                    case (int)TaskOutboundTypeEnum.Outbound:
+                        content = TaskCompletionFeedback(task);
+                        break;
+                    default: return MESresponse($"浠诲姟绫诲瀷閿欒锛屼换鍔″彿锛歿task.TaskNum}", false, 0);
+                }
+                if (!content.Status)
+                {
+                    _unitOfWorkManage.RollbackTran();
+                    return MESresponse($"鎵嬪姩鍚慚ES鎺ュ彛鎶ュ畬鎴愬け璐task.TaskNum}", false, 0);
                 }
                 _unitOfWorkManage.CommitTran();
-                return webResponse.OK("浠诲姟鎵嬪姩瀹屾垚鎴愬姛");
+                return MESresponse($"浠诲姟鎵嬪姩瀹屾垚鎴愬姛{task.TaskNum}", true, 1);
+
             }
             catch (Exception ex)
             {
                 _unitOfWorkManage.RollbackTran();
-                return webResponse.Error($"浠诲姟鎵嬪姩瀹屾垚澶辫触锛屽師鍥狅細{ex.Message}");
+                return MESresponse($"浠诲姟鎵嬪姩瀹屾垚澶辫触锛屽師鍥狅細{ex.Message}", false, 0);
+
+            }
+        }
+
+        /// <summary>
+        /// 鑾峰彇瀹炴椂浠诲姟鍒楄〃
+        /// </summary>
+        /// <returns></returns>
+        public WebResponseContent GetRealTimeTasks()
+        {
+            WebResponseContent content = new WebResponseContent();
+            try
+            {
+                // 鏌ヨ鏈�鏂扮殑10鏉′换鍔¤褰�
+                var tasks = Repository.Db.Queryable<Dt_Task>()
+                    .OrderByDescending(x => x.CreateDate)
+                    .Take(10)
+                    .ToList();
+
+                // 杞崲浠诲姟鏁版嵁涓哄墠绔渶瑕佺殑鏍煎紡
+                var result = tasks.Select(task => {
+                    // 杞崲浠诲姟绫诲瀷
+                    string taskTypeText = "鏈煡";
+                    switch ((TaskInboundTypeEnum)task.TaskType)
+                    {
+                        case TaskInboundTypeEnum.Inbound:
+                            taskTypeText = "鍏ュ簱";
+                            break;
+                        case (TaskInboundTypeEnum)TaskOutboundTypeEnum.Outbound:
+                            taskTypeText = "鍑哄簱";
+                            break;
+                        case (TaskInboundTypeEnum)TaskRelocationTypeEnum.Relocation:
+                            taskTypeText = "绉诲簱";
+                            break;
+                    }
+
+                    // 杞崲浠诲姟鐘舵��
+                        string taskStatusText = "鏈煡";
+                        if ((TaskOutStatusEnum)task.TaskStatus == TaskOutStatusEnum.OutNew) {
+                            taskStatusText = "寰呭鐞�";
+                        } else if (
+                            (TaskInStatusEnum)task.TaskStatus == TaskInStatusEnum.Line_InExecuting ||
+                            (TaskInStatusEnum)task.TaskStatus == TaskInStatusEnum.SC_InExecuting ||
+                            (TaskOutStatusEnum)task.TaskStatus == TaskOutStatusEnum.SC_OutExecuting ||
+                            (TaskOutStatusEnum)task.TaskStatus == TaskOutStatusEnum.Line_OutExecuting
+                        ) {
+                            taskStatusText = "杩愯涓�";
+                        } else if (
+                            (TaskInStatusEnum)task.TaskStatus == TaskInStatusEnum.InFinish ||
+                            (TaskOutStatusEnum)task.TaskStatus == TaskOutStatusEnum.OutFinish
+                        ) {
+                            taskStatusText = "宸插畬鎴�";
+                        }
+
+                        return new {
+                            id = task.TaskId,
+                            taskNum = task.TaskNum,
+                            taskType = taskTypeText,
+                            sourceAddress = task.SourceAddress,
+                            targetAddress = task.TargetAddress,
+                            taskStatus = taskStatusText
+                        };
+                }).ToList();
+
+                return content.OK(data: result);
+            }
+            catch (Exception ex)
+            {
+                return content.Error(ex.Message);
             }
         }
     }

--
Gitblit v1.9.3