From b31d961a3f0bcd2e555ea12b76c30c453826deba Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期一, 28 七月 2025 09:42:58 +0800
Subject: [PATCH] 代码提交

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs |  234 ++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 161 insertions(+), 73 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
index 2fdd7d6..59d937f 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -106,96 +106,155 @@
                     // 鍒ゆ柇浠诲姟绫诲瀷鏄惁涓哄嚭搴撲换鍔�
                     if (item.TaskType == "2")
                     {
-                        string[] targetCodes = item.BeginPoint.Split("-");
-
-                        Dt_StationManager stationManagerEnd = _stationManagerRepository.QueryFirst(x => x.stationChildCode==item.EndPoint);
-                        if (stationManagerEnd == null)
+                        if (Convert.ToInt32(item.EndPoint) > 1999 && Convert.ToInt32(item.EndPoint) < 3000)
                         {
-                            return content.Error("鏈壘鍒板嚭搴撶珯鍙颁俊鎭�");
-                        }
-
-                        Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == GetScCode(Convert.ToInt32(targetCodes[0])) && x.stationType == 2 && x.stationFloor == stationManagerEnd.stationFloor);
-
-                        var RGVName = string.Empty;
-                        if (stationManager.stationFloor == "1F")
-                        {
-                            var deviceCode = _deviceInfoRepository.Db.Queryable<Dt_DeviceInfo>().Where(x => x.DeviceStatus == "1" && x.DeviceRemark == "OneFloor").Where(x => x.DeviceCode.Contains("RGV")).ToList().Select(x => x.DeviceCode).ToList();
-                            if (deviceCode != null && deviceCode.Count() > 0)
+                            Dt_StationManager stationManagerStart = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.EndPoint);
+                            if (stationManagerStart == null)
                             {
-                                if (deviceCode.Contains("RGV01")&& deviceCode.Contains("RGV02"))
+                                return content.Error("鏈壘鍒板嚭搴撶珯鍙颁俊鎭�");
+                            }
+                            Dt_Task taskIn = new Dt_Task()
+                            {
+                                TaskNum = BaseDal.GetTaskNo().Result,
+                                Creater = "WMS",
+                                WMSTaskNum = item.TaskId,
+                                Grade = 1,
+                                PalletCode = item.TPbarcode,
+                                TaskType = (int)TaskOutboundTypeEnum.Outbound,
+                                TaskState = (int)TaskOutStatusEnum.OutNew,
+                                SourceAddress = item.BeginPoint,
+                                CurrentAddress = item.BeginPoint,
+                                Roadway = stationManagerStart.Roadway,
+                                NextAddress = item.EndPoint,
+                                TargetAddress = item.EndPoint,
+                                Floor = stationManagerStart.stationFloor,
+                                RGVName = ""
+                            };
+                            BaseDal.AddData(taskIn);
+                        }
+                        else
+                        {
+
+                            string[] targetCodes = item.BeginPoint.Split("-");
+
+                            Dt_StationManager stationManagerEnd = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.EndPoint);
+                            if (stationManagerEnd == null)
+                            {
+                                return content.Error("鏈壘鍒板嚭搴撶珯鍙颁俊鎭�");
+                            }
+
+                            Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == GetScCode(Convert.ToInt32(targetCodes[0])) && x.stationType == 2 && x.stationFloor == stationManagerEnd.stationFloor);
+
+                            var RGVName = string.Empty;
+                            if (stationManager.stationFloor == "1F")
+                            {
+                                var deviceCode = _deviceInfoRepository.Db.Queryable<Dt_DeviceInfo>().Where(x => x.DeviceStatus == "1" && x.DeviceRemark == "1F").Where(x => x.DeviceCode.Contains("RGV")).ToList().Select(x => x.DeviceCode).ToList();
+                                if (deviceCode != null && deviceCode.Count() > 0)
                                 {
-                                    var RGVOne = BaseDal.QueryData(x => x.RGVName == "RGV01").ToList();
-                                    var RGVTwo = BaseDal.QueryData(x => x.RGVName == "RGV02").ToList();
-                                    if (RGVOne.Count > RGVTwo.Count)
+                                    if (deviceCode.Contains("RGV01") && deviceCode.Contains("RGV02"))
                                     {
-                                        RGVName = "RGV01";
+                                        var RGVOne = BaseDal.QueryData(x => x.RGVName == "RGV01").ToList();
+                                        var RGVTwo = BaseDal.QueryData(x => x.RGVName == "RGV02").ToList();
+                                        if (RGVOne.Count > RGVTwo.Count)
+                                        {
+                                            RGVName = "RGV01";
+                                        }
+                                        else
+                                        {
+                                            RGVName = "RGV02";
+                                        }
                                     }
                                     else
                                     {
-                                        RGVName = "RGV02";
+                                        RGVName = deviceCode[0];
                                     }
                                 }
                                 else
                                 {
-                                    RGVName = deviceCode[0];
+                                    RGVName = "RGV01";
                                 }
                             }
-                            else
+                            Dt_Task taskOut = new Dt_Task()
                             {
-                                RGVName = "RGV01";
-                            }
+                                TaskNum = BaseDal.GetTaskNo().Result,
+                                Creater = "WMS",
+                                WMSTaskNum = item.TaskId,
+                                Grade = 1,
+                                PalletCode = item.TPbarcode,
+                                TaskType = (int)TaskOutboundTypeEnum.Outbound,
+                                TaskState = (int)TaskOutStatusEnum.OutNew,
+                                SourceAddress = item.BeginPoint,
+                                CurrentAddress = item.BeginPoint,
+                                Roadway = GetScCode(Convert.ToInt32(targetCodes[0])),
+                                NextAddress = stationManager.stationChildCode,
+                                TargetAddress = item.EndPoint,
+                                RGVName = stationManager.RGVName != null ? stationManager.RGVName : RGVName,
+                                Floor = stationManager.stationFloor,
+                            };
+                            BaseDal.AddData(taskOut);
                         }
-                        Dt_Task taskOut = new Dt_Task()
-                        {
-                            TaskNum = BaseDal.GetTaskNo().Result,
-                            Creater = "WMS",
-                            WMSTaskNum=item.TaskId,
-                            Grade = 1,
-                            PalletCode = item.TPbarcode,
-                            TaskType = (int)TaskOutboundTypeEnum.Outbound,
-                            TaskState = (int)TaskOutStatusEnum.OutNew,
-                            SourceAddress = item.BeginPoint,
-                            CurrentAddress = item.BeginPoint,
-                            Roadway = GetScCode(Convert.ToInt32(targetCodes[0])),
-                            NextAddress = stationManager.stationChildCode,
-                            TargetAddress = item.EndPoint,
-                            RGVName = stationManager.RGVName != null ? stationManager.RGVName : RGVName,
-                            Floor= stationManager.stationFloor,
-                        };
-                        BaseDal.AddData(taskOut);
                     }
                     // 鍒ゆ柇浠诲姟绫诲瀷鏄惁涓哄叆搴撲换鍔�
                     else if (item.TaskType == "1")
                     {
-                        var task = BaseDal.QueryFirst(x => x.PalletCode == item.TPbarcode);
-                        if (task != null)
+                        if (Convert.ToInt32(item.BeginPoint) > 1999 && Convert.ToInt32(item.BeginPoint) < 3000)
                         {
-                            task.Creater = "WMS";
-                            task.Grade = 1;
-                            task.PalletCode = item.TPbarcode;
-                        
-                        task.TaskType = (int)TaskInboundTypeEnum.Inbound;
-
-                        task.TaskState = (int)TaskInStatusEnum.RGV_IndispatchFinish;
-
-                        task.CurrentAddress = item.BeginPoint;
-
-                        task.WMSTaskNum = item.TaskId;
-
-                        task.TargetAddress = item.EndPoint;
-
-                        string[] targetCodes = item.EndPoint.Split("-");
-
-                        task.Roadway = GetScCode(Convert.ToInt32(targetCodes[0]));
-
-                        Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 3);
-
-                        task.NextAddress = stationManager.stationChildCode;
-                        BaseDal.UpdateData(task);
+                            Dt_StationManager stationManagerStart = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.BeginPoint);
+                            if (stationManagerStart == null)
+                            {
+                                return content.Error("鏈壘鍒板嚭搴撶珯鍙颁俊鎭�");
+                            }
+                            Dt_Task taskIn = new Dt_Task()
+                            {
+                                TaskNum = BaseDal.GetTaskNo().Result,
+                                Creater = "WMS",
+                                WMSTaskNum = item.TaskId,
+                                Grade = 1,
+                                PalletCode = item.TPbarcode,
+                                TaskType = (int)TaskInboundTypeEnum.Inbound,
+                                TaskState = (int)TaskInStatusEnum.Line_InFinish,
+                                SourceAddress = item.BeginPoint,
+                                CurrentAddress = stationManagerStart.stationChildCode,
+                                Roadway = stationManagerStart.Roadway,
+                                NextAddress = item.EndPoint,
+                                TargetAddress = item.EndPoint,
+                                Floor = stationManagerStart.stationFloor,
+                                RGVName = ""
+                            };
+                            BaseDal.AddData(taskIn);
                         }
                         else
                         {
-                            return content.Error($"鏈壘鍒拌鎵樼洏銆恵item.TPbarcode}銆戜换鍔�");
+                            var task = BaseDal.QueryFirst(x => x.PalletCode == item.TPbarcode);
+                            if (task != null)
+                            {
+                                task.Creater = "WMS";
+                                task.Grade = 1;
+                                task.PalletCode = item.TPbarcode;
+
+                                task.TaskType = (int)TaskInboundTypeEnum.Inbound;
+
+                                task.TaskState = (int)TaskInStatusEnum.RGV_IndispatchFinish;
+
+                                task.CurrentAddress = item.BeginPoint;
+
+                                task.WMSTaskNum = item.TaskId;
+
+                                task.TargetAddress = item.EndPoint;
+
+                                string[] targetCodes = item.EndPoint.Split("-");
+
+                                task.Roadway = GetScCode(Convert.ToInt32(targetCodes[0]));
+
+                                Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 3 && x.stationFloor == task.Floor);
+
+                                task.NextAddress = stationManager.stationChildCode;
+                                BaseDal.UpdateData(task);
+                            }
+                            else
+                            {
+                                return content.Error($"鏈壘鍒拌鎵樼洏銆恵item.TPbarcode}銆戜换鍔�");
+                            }
                         }
                     }
                     else if (item.TaskType == "3")
@@ -770,17 +829,37 @@
 
                 if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting)
                 {
-                    task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish;
+                    if (Convert.ToInt32(task.TargetAddress) > 1999 && Convert.ToInt32(task.TargetAddress) < 3000)
+                    {
+                        task.TaskState = (int)TaskOutStatusEnum.OutFinish; ;
+                        task.ModifyDate = DateTime.Now;
+                        task.Modifier = "System";
 
-                    Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 2 && x.stationFloor == task.Floor);
+                        Dt_Task_Hty task_Hty = _mapper.Map<Dt_Task_Hty>(task);
+                        task_Hty.TaskId = 0;
 
-                    task.CurrentAddress = task.NextAddress;
+                        BaseDal.DeleteData(task);
+                        _taskHtyRepository.AddData(task_Hty);
+                        _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍫嗗灈鏈哄嚭搴撳畬鎴�");
+                    }
+                    else
+                    {
+                        task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish;
 
-                    task.NextAddress = stationManager.stationNextChildCode;
+                        Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationType == 2 && x.stationFloor == task.Floor);
 
-                    BaseDal.UpdateData(task);
+                        task.CurrentAddress = task.NextAddress;
 
-                    _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍫嗗灈鏈哄嚭搴撳畬鎴�");
+                        task.NextAddress = stationManager.stationNextChildCode;
+
+                        BaseDal.UpdateData(task);
+
+                        _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskId, $"鍫嗗灈鏈哄嚭搴撳畬鎴�");
+                    }    
+                }
+                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TaskState == (int)TaskOutStatusEnum.SC_OutFinish)
+                {
+
                 }
                 else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting)
                 {
@@ -1002,5 +1081,14 @@
                 return WebResponseContent.Instance.Error(ex.Message);
             }
         }
+        public WebResponseContent text(int taskNum)
+        {
+            WebResponseContent content = new WebResponseContent();
+            var result = _stationManagerRepository.Db.Queryable<Dt_StationManager>()
+                .Where(t => SqlFunc.Abs(t.LevelPointFist - taskNum) <= 10)
+                .ToList();
+
+            return content.OK(data: result);
+        }
     }
 }

--
Gitblit v1.9.3