From 0187d7d752ee493b3691432a24cf97ededda2530 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期二, 24 三月 2026 08:48:40 +0800
Subject: [PATCH] 辊分下空筒、涂布上空筒,涂布缓存架存放空筒

---
 wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/Z_GFSB_UPTask.cs   |   56 ++++++++++
 涂布对接地址.xlsx                                                              |    0 
 wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/JobZ_0925.cs                         |    4 
 wcs-server-hbf/WIDESEA_WCS/JobsPart/AGV/UpdateAgvTaskText.cs             |    4 
 wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/F_TBSB_DownTask.cs |   76 ++++++++++++++-
 wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/Z_TBSB_DownTask.cs |   77 ++++++++++++++-
 辊分对接地址.png                                                               |    0 
 wcs-server-hbf/WIDESEA_WCSServer/modified_data.json                      |    2 
 wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/F_GFSB_UPTask.cs   |   56 ++++++++++
 wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/JobF_0925.cs                         |    4 
 10 files changed, 256 insertions(+), 23 deletions(-)

diff --git a/wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/JobF_0925.cs b/wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/JobF_0925.cs
index 9924d6c..ca3835d 100644
--- a/wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/JobF_0925.cs
+++ b/wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/JobF_0925.cs
@@ -32,10 +32,10 @@
                                 WriteLog.GetLog().Write($"寮�濮嬫椂闂磋礋鏋侊細{DateTime.Now} --------------", $"璐熸瀬璋冨害");
                                 StackerExecutor.F_BCK_Task();//璐熸瀬绠旀潗
 
-                                StackerExecutor.F_GFSB_UpTask();//璐熸瀬杈婂垎涓婃枡浠诲姟
+                                StackerExecutor.F_GFSB_UpTask();//璐熸瀬杈婂垎涓婃枡浠诲姟/杈婂垎涓嬬┖绛�
                                 StackerExecutor.F_GFSB_DownTask();//璐熸瀬杈婂垎涓嬫枡浠诲姟
 
-                                StackerExecutor.F_TBSB_DownTask(); //璐熸瀬娑傚竷涓嬫枡浠诲姟
+                                StackerExecutor.F_TBSB_DownTask(); //璐熸瀬娑傚竷涓嬫枡浠诲姟/娑傚竷涓婄┖绛�
                                 StackerExecutor.F_TBSB_UpTask();//璐熸瀬娑傚竷涓婃枡浠诲姟
 
                                 StackerExecutor.F_TSJ_DownTask();//璐熸瀬鎻愬崌鏈轰笅鏂欎换鍔�
diff --git a/wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/JobZ_0925.cs b/wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/JobZ_0925.cs
index 0a1848d..ac95759 100644
--- a/wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/JobZ_0925.cs
+++ b/wcs-server-hbf/WIDESEA_WCS/Jobs/AGV/JobZ_0925.cs
@@ -33,9 +33,9 @@
                                 StackerExecutor.Z_BCK_Task();//姝f瀬绠旀潗搴�
 
                                 StackerExecutor.Z_GFSB_DownTask();//姝f瀬杈婂垎涓嬫枡浠诲姟
-                                StackerExecutor.Z_GFSB_UpTask(); //姝f瀬杈婂垎涓婃枡浠诲姟
+                                StackerExecutor.Z_GFSB_UpTask(); //姝f瀬杈婂垎涓婃枡浠诲姟/杈婂垎涓嬬┖绛�
 
-                                StackerExecutor.Z_TBSB_DownTask();//姝f瀬娑傚竷涓嬫枡
+                                StackerExecutor.Z_TBSB_DownTask();//姝f瀬娑傚竷涓嬫枡/娑傚竷涓婄┖绛�
                                 StackerExecutor.Z_TBSB_UpTask();//姝f瀬娑傚竷涓婃枡浠诲姟
 
                                 StackerExecutor.Z_TSJ_DownTask();//姝f瀬鎻愬崌鏈轰笅鏂�
diff --git a/wcs-server-hbf/WIDESEA_WCS/JobsPart/AGV/UpdateAgvTaskText.cs b/wcs-server-hbf/WIDESEA_WCS/JobsPart/AGV/UpdateAgvTaskText.cs
index 8c37025..145a18a 100644
--- a/wcs-server-hbf/WIDESEA_WCS/JobsPart/AGV/UpdateAgvTaskText.cs
+++ b/wcs-server-hbf/WIDESEA_WCS/JobsPart/AGV/UpdateAgvTaskText.cs
@@ -292,7 +292,7 @@
                                     base_ware_location location = locationRepository.FindFirst(x => x.upper_code == agvTask.agv_fromaddress);
                                     if (location != null)
                                     {
-                                        if (!agvTask.agv_remark.Contains("鍒囧嵎涓婃枡鍥炵┖"))
+                                        if (!agvTask.agv_remark.Contains("鍒囧嵎涓婃枡鍥炵┖") && !agvTask.agv_remark.Contains("娑傚竷涓婄┖绛掍换鍔�"))
                                         {
                                             location.geartype = "鏆傛棤";
                                         }
@@ -509,7 +509,7 @@
                                     }
                                     else
                                     {
-                                        if (!agvTask.agv_remark.Contains("鍒囧嵎涓婃枡鍛煎彨"))
+                                        if (!agvTask.agv_remark.Contains("鍒囧嵎涓婃枡鍛煎彨") && !agvTask.agv_remark.Contains("杈婂垎涓嬬┖绛掍换鍔�"))
                                         {
                                             location.geartype = "鏆傛棤";
                                         }
diff --git a/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/F_GFSB_UPTask.cs b/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/F_GFSB_UPTask.cs
index 8f55668..048d9b6 100644
--- a/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/F_GFSB_UPTask.cs
+++ b/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/F_GFSB_UPTask.cs
@@ -51,7 +51,59 @@
                             //褰撳墠璁惧鏈夋病鏈変笂鏂欒姹�
                             OperateResult<bool> GYR_RFX = plc.MelsecPLCClient.MelsecMcNetClient.ReadBool("D5493.0");
                             Int16 tf = Convert.ToInt16(GYR_RFX.Content);
-                            if (GYR_RFX.Content)
+                            OperateResult<Int16> R_Type = plc.MelsecPLCClient.MelsecMcNetClient.ReadInt16("D5424");
+                            if (GYR_RFX.Content && R_Type.Content==Convert.ToInt16(2))
+                            {
+                                //鏌ョ湅褰撳墠杈婂垎鏈鸿澶囨槸鍚︽湁AGV浠诲姟
+                                var SBtask = agvRepository.FindFirst(f => f.agv_fromaddress == plc.EquipType);
+                                //鏈夌粨鏉熸湰娆″惊鐜�
+                                if (SBtask != null) { continue; }
+                                #region 璁板綍涓嬬┖绛掕姹備俊鍙�
+                                WriteLog.GetLog().Write($"{plc.PLCName}涓嬬┖绛掕姹傦細{GYR_RFX.Content}锛寋R_Type.Content}---{DateTime.Now}", $"璐熸瀬妫嶅垎涓嬬┖绛掕姹�");
+                                #endregion
+                                List<base_routing_table> Routing_Table = routingRepository.Find(d => d.route_end == plc.EquipType);
+                                List<string> begans = Routing_Table.Select(x=>x.route_began).ToList();
+                                base_ware_location ware_Location = locRepository.Find(d => begans.Contains(d.upper_code) && d.location_state == LoctionStateEnum.LocationState_Empty.ToString() && d.tpgd == 0 && d.area == "FJ-TBHCJ" && d.status == 1 && d.task == 2 && d.geartype == "C").OrderBy(d => d.update_time).FirstOrDefault();
+
+                                if (ware_Location != null)
+                                {
+                                    base_ware_location Location = ware_Location;
+                                    //鐢熸垚娑傚竷鏈轰笅鏂欎换鍔�
+                                    dt_agvtask agvtask = new dt_agvtask()
+                                    {
+                                        agv_id = Guid.NewGuid(),
+                                        agv_tasknum = "KH-" + IdenxManager.GetTaskNo(),
+                                        agv_fromaddress = plc.EquipType,//浠ヨ澶囦负璧风偣
+                                        agv_toaddress = Location.upper_code,
+                                        agv_code = "璐熸瀬AGV璋冨害",
+                                        agv_remark = "杈婂垎涓嬬┖绛掍换鍔�",
+                                        agv_taskstate = AGVTaskStateEnum.Create.ToString(),
+                                        agv_tasktype = AGVTaskTypeEnum.TaskType_Outbound.ToString(),
+                                        agv_worktype = 1,//宸ヤ綔绫诲瀷
+                                        agv_materielid = "",
+                                        agv_qty = 1,
+                                        agv_createtime = DateTime.Now,
+                                        agv_grade = 0,//浠诲姟浼樺厛绾�
+                                        agv_userid = "WCS",
+                                        agv_barcode = "",
+                                    };
+
+                                    //Location.update_time = DateTime.Now;
+                                    Location.update_time = DateTime.Now;
+                                    Location.task = 1;
+                                    var entry = locRepository.DbContext.ChangeTracker.Entries<base_ware_location>().FirstOrDefault();
+                                    if (entry != null)
+                                    {
+                                        entry.State = EntityState.Detached;
+                                    }
+                                    int a = locRepository.Update(Location, d => new { d.task, d.update_time }, true);
+                                    if (a == 1)
+                                    {
+                                        agvRepository.Add(agvtask, true);
+                                    }
+                                }
+                            }
+                            else if(GYR_RFX.Content)
                             {
                                 //鏌ョ湅褰撳墠杈婂垎鏈鸿澶囨槸鍚︽湁AGV浠诲姟
                                 var SBtask = agvRepository.FindFirst(f => f.agv_toaddress == plc.EquipType);
@@ -64,7 +116,7 @@
                                 List<base_ware_location> loctionList = new List<base_ware_location>();
                                 foreach (var item in Routing_Table)
                                 {
-                                    base_ware_location ware_Locations = locRepository.FindFirst(d => d.upper_code == item.route_began && d.status == 1 && d.location_state == LoctionStateEnum.LocationState_Stored.ToString() && d.logic_col == 1 && d.task == 2);
+                                    base_ware_location ware_Locations = locRepository.FindFirst(d => d.upper_code == item.route_began && d.status == 1 && d.location_state == LoctionStateEnum.LocationState_Stored.ToString() && d.logic_col == 1 && d.task == 2 && d.geartype == "鏆傛棤");
                                     if (ware_Locations == null)
                                     {
                                         continue;
diff --git a/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/F_TBSB_DownTask.cs b/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/F_TBSB_DownTask.cs
index d3ba8aa..cb624a6 100644
--- a/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/F_TBSB_DownTask.cs
+++ b/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/F_TBSB_DownTask.cs
@@ -51,15 +51,79 @@
                                 continue;
                             }
                             string SB_Up_Location = "FJXL-TBSB" + TBSB.Replace("娑傚竷鏈鸿礋鏋�", "");//鎷兼帴娑傚竷涓嬫枡鍙�
-                                                                                            //鏌ョ湅褰撳墠娑傚竷鏈鸿澶囨槸鍚︽湁AGV浠诲姟
-                            var SBtask = agvRepository.FindFirst(f => f.agv_fromaddress == SB_Up_Location);
-                            //鏈夌粨鏉熸湰娆″惊鐜�
-                            if (SBtask != null) { continue; }
                             //褰撳墠璁惧鏈夋病鏈変笂鏂欒姹�
                             bool GYR_RFX = plc.OmronPLCClient.OmronFinsNetClient.ReadBool("D11293.00").Content;
+                            Int16 R_Type = plc.OmronPLCClient.OmronFinsNetClient.ReadInt16("D11224").Content;
                             //Convert.ToBoolean(plc.ReadValue("R_Feedingrequest".ToString(), SB_Up_Location));
-                            if (GYR_RFX)
+                            if (GYR_RFX && R_Type == Convert.ToInt16(1))
                             {
+                                var SBtask = agvRepository.FindFirst(f => f.agv_toaddress == SB_Up_Location);
+                                //鏈夌粨鏉熸湰娆″惊鐜�
+                                if (SBtask != null) { continue; }
+                                #region 璁板綍涓婄┖绛掕姹備俊鍙�
+                                WriteLog.GetLog().Write($"{plc.PLCName}涓婄┖绛掕姹傦細{GYR_RFX}锛寋R_Type}---{DateTime.Now}", $"璐熸瀬娑傚竷涓婄┖绛掕姹�");
+                                #endregion
+                                //鎵惧埌璺敱瑙勫垯(浠ヨ澶囦负璧风偣鐨勮矾鐢辫鍒�)
+                                List<base_routing_table> Routing_Table = routingRepository.Find(d => d.route_began == SB_Up_Location);
+                                List<string> ends = Routing_Table.Select(x => x.route_end).ToList();
+                                if (Routing_Table.Count > 0)
+                                {
+                                    //鍙敤绌虹瓛缂撳瓨鏋�
+                                    base_ware_location location_TB = locRepository.Find(t => ends.Contains(t.upper_code) && t.location_state == LoctionStateEnum.LocationState_Stored.ToString() && t.tpgd == 1 && t.area == "FJ-TBHCJ" && t.status == 1 && t.task == 2 && t.geartype == "C").OrderBy(d => d.update_time).FirstOrDefault();
+                                    if (location_TB != null)
+                                    {
+                                        WebResponseContent content = new WebResponseContent();
+                                        locRepository.DbContextBeginTransaction(() =>
+                                        {
+                                            //鐢熸垚娑傚竷鏈轰笅鏂欎换鍔�
+                                            dt_agvtask agvtask = new dt_agvtask()
+                                            {
+                                                agv_id = Guid.NewGuid(),
+                                                agv_tasknum = "KH-" + IdenxManager.GetTaskNo(),
+                                                agv_fromaddress = location_TB.upper_code,//浠ヨ澶囨湭璧风偣
+                                                agv_toaddress = SB_Up_Location,
+                                                agv_code = "璐熸瀬AGV璋冨害",
+                                                agv_remark = "娑傚竷涓婄┖绛掍换鍔�",
+                                                agv_taskstate = AGVTaskStateEnum.Create.ToString(),
+                                                agv_tasktype = AGVTaskTypeEnum.TaskType_Outbound.ToString(),
+                                                agv_worktype = 1,//宸ヤ綔绫诲瀷
+                                                agv_materielid = "",
+                                                agv_qty = 1,
+                                                agv_createtime = DateTime.Now,
+                                                agv_grade = 0,//浠诲姟浼樺厛绾�
+                                                agv_userid = "WCS",
+                                                agv_barcode = "",
+                                            };
+
+                                            location_TB.update_time = DateTime.Now;
+                                            location_TB.task = 1;
+                                            var entry = locRepository.DbContext.ChangeTracker.Entries<base_ware_location>().FirstOrDefault();
+                                            if (entry != null)
+                                            {
+                                                entry.State = EntityState.Detached;
+                                            }
+                                            int x = locRepository.Update(location_TB, d => new { d.update_time, d.task }, true);
+                                            if (x == 1)
+                                            {
+                                                agvRepository.Add(agvtask, true);
+                                                //WriteDBLog.Info($"銆恵TBSB}銆戜笅鏂欎换鍔$敓鎴�").Write($"鐢熸垚浠诲姟:{agvtask.agv_tasknum},缁堢偣璐т綅銆恵location_TB.upper_code}銆戠姸鎬侊細鎵樼洏鍏夌數妫�娴嬶細{location_TB.tpgd},鐘舵�侊細{location_TB.location_state},鏇存柊鏃堕棿锛歿location_TB.wireless_time}", $"銆恵TBSB}銆戜笅鏂欎换鍔$敓鎴�");
+                                                //WriteDBLog.Info($"銆恵TBSB}銆戜笅鏂欎换鍔$敓鎴�").Write($"----------------浠诲姟鐢熸垚鎴愬姛  {DateTime.Now} -------------- {Environment.NewLine}", $"銆恵TBSB}銆戜笅鏂欎换鍔$敓鎴�");
+                                                return content.OK();
+                                            }
+                                            else
+                                            {
+                                                return content.Error();
+                                            }
+                                        });
+                                    }
+
+                                }
+                            }
+                            else if (GYR_RFX)
+                            {
+                                var SBtask = agvRepository.FindFirst(f => f.agv_fromaddress == SB_Up_Location);
+                                //鏈夌粨鏉熸湰娆″惊鐜�
+                                if (SBtask != null) { continue; }
                                 #region 璁板綍涓嬫枡璇锋眰淇″彿
                                 WriteLog.GetLog().Write($"{plc.PLCName}涓嬫枡璇锋眰锛歿GYR_RFX}---{DateTime.Now}", $"璐熸瀬娑傚竷涓嬫枡璇锋眰");
                                 #endregion
@@ -72,7 +136,7 @@
                                     foreach (var item in Routing_Table)
                                     {
                                         //鎵惧厛鎵炬秱甯冨尯鍩熺紦瀛樻灦
-                                        location_TB = locRepository.FindFirst(t => t.upper_code == item.route_end && t.location_state == LoctionStateEnum.LocationState_Empty.ToString() && t.area == "FJ-TBHCJ" && t.status == 1 && t.task == 2);
+                                        location_TB = locRepository.FindFirst(t => t.upper_code == item.route_end && t.location_state == LoctionStateEnum.LocationState_Empty.ToString() && t.area == "FJ-TBHCJ" && t.status == 1 && t.task == 2 && t.geartype == "鏆傛棤");
                                         if (location_TB != null)
                                         {
                                             // location = location_TB.FirstOrDefault();//濡傛灉鎵惧埌锛岃祴鍊煎悗閫�鍑哄惊鐜�
diff --git a/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/Z_GFSB_UPTask.cs b/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/Z_GFSB_UPTask.cs
index c5553f4..782a6f4 100644
--- a/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/Z_GFSB_UPTask.cs
+++ b/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/Z_GFSB_UPTask.cs
@@ -53,7 +53,59 @@
 
                             OperateResult<bool> GYR_RFX = plc.MelsecPLCClient.MelsecMcNetClient.ReadBool("D5493.0");
                             Int16 tf = Convert.ToInt16(GYR_RFX.Content);
-                            if (GYR_RFX.Content)
+                            OperateResult<Int16> R_Type = plc.MelsecPLCClient.MelsecMcNetClient.ReadInt16("D5424");
+                            if (GYR_RFX.Content && R_Type.Content == Convert.ToInt16(2))
+                            {
+                                //鏌ョ湅褰撳墠杈婂垎鏈鸿澶囨槸鍚︽湁AGV浠诲姟
+                                var SBtask = agvRepository.FindFirst(f => f.agv_fromaddress == plc.EquipType);
+                                //鏈夌粨鏉熸湰娆″惊鐜�
+                                if (SBtask != null) { continue; }
+                                #region 璁板綍涓嬬┖绛掕姹備俊鍙�
+                                WriteLog.GetLog().Write($"{plc.PLCName}涓嬬┖绛掕姹傦細{GYR_RFX.Content}锛寋R_Type.Content}---{DateTime.Now}", $"姝f瀬妫嶅垎涓嬬┖绛掕姹�");
+                                #endregion
+                                List<base_routing_table> Routing_Table = routingRepository.Find(d => d.route_end == plc.EquipType);
+                                List<string> begans = Routing_Table.Select(x => x.route_began).ToList();
+                                base_ware_location ware_Location = locRepository.Find(d => begans.Contains(d.upper_code) && d.location_state == LoctionStateEnum.LocationState_Empty.ToString() && d.tpgd == 0 && d.area == "ZJ-TBHCJ" && d.status == 1 && d.task == 2 && d.geartype == "C").OrderBy(d => d.update_time).FirstOrDefault();
+
+                                if (ware_Location != null)
+                                {
+                                    base_ware_location Location = ware_Location;
+                                    //鐢熸垚娑傚竷鏈轰笅鏂欎换鍔�
+                                    dt_agvtask agvtask = new dt_agvtask()
+                                    {
+                                        agv_id = Guid.NewGuid(),
+                                        agv_tasknum = "KH-" + IdenxManager.GetTaskNo(),
+                                        agv_fromaddress = plc.EquipType,//浠ヨ澶囦负璧风偣
+                                        agv_toaddress = Location.upper_code,
+                                        agv_code = "姝f瀬AGV璋冨害",
+                                        agv_remark = "杈婂垎涓嬬┖绛掍换鍔�",
+                                        agv_taskstate = AGVTaskStateEnum.Create.ToString(),
+                                        agv_tasktype = AGVTaskTypeEnum.TaskType_Outbound.ToString(),
+                                        agv_worktype = 1,//宸ヤ綔绫诲瀷
+                                        agv_materielid = "",
+                                        agv_qty = 1,
+                                        agv_createtime = DateTime.Now,
+                                        agv_grade = 0,//浠诲姟浼樺厛绾�
+                                        agv_userid = "WCS",
+                                        agv_barcode = "",
+                                    };
+
+                                    //Location.update_time = DateTime.Now;
+                                    Location.update_time = DateTime.Now;
+                                    Location.task = 1;
+                                    var entry = locRepository.DbContext.ChangeTracker.Entries<base_ware_location>().FirstOrDefault();
+                                    if (entry != null)
+                                    {
+                                        entry.State = EntityState.Detached;
+                                    }
+                                    int a = locRepository.Update(Location, d => new { d.task, d.update_time }, true);
+                                    if (a == 1)
+                                    {
+                                        agvRepository.Add(agvtask, true);
+                                    }
+                                }
+                            }
+                            else if (GYR_RFX.Content)
                             {
                                 //鏌ョ湅褰撳墠杈婂垎鏈鸿澶囨槸鍚︽湁AGV浠诲姟
                                 var SBtask = agvRepository.FindFirst(f => f.agv_toaddress == plc.EquipType);
@@ -66,7 +118,7 @@
                                 List<base_ware_location> loctionList = new List<base_ware_location>();
                                 foreach (var item in Routing_Table)
                                 {
-                                    base_ware_location ware_Locations = locRepository.FindFirst(d => d.upper_code == item.route_began && d.status == 1 && d.location_state == LoctionStateEnum.LocationState_Stored.ToString() && d.logic_col == 1 && d.task == 2);
+                                    base_ware_location ware_Locations = locRepository.FindFirst(d => d.upper_code == item.route_began && d.status == 1 && d.location_state == LoctionStateEnum.LocationState_Stored.ToString() && d.logic_col == 1 && d.task == 2 && d.geartype == "鏆傛棤");
                                     if (ware_Locations == null)
                                     {
                                         continue;
diff --git a/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/Z_TBSB_DownTask.cs b/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/Z_TBSB_DownTask.cs
index 1ba2181..bb7f28e 100644
--- a/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/Z_TBSB_DownTask.cs
+++ b/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/Z_TBSB_DownTask.cs
@@ -54,15 +54,80 @@
                             }
 
                             string SB_Up_Location = "ZJXL-TBSB" + TBSB.Replace("娑傚竷鏈烘鏋�", "");//鎷兼帴娑傚竷涓嬫枡鍙�
-                                                                                            //鏌ョ湅褰撳墠娑傚竷鏈鸿澶囨槸鍚︽湁AGV浠诲姟
-                            var SBtask = agvRepository.FindFirst(f => f.agv_fromaddress == SB_Up_Location);
-                            //鏈夌粨鏉熸湰娆″惊鐜�
-                            if (SBtask != null) { continue; }
                             //褰撳墠璁惧鏈夋病鏈変笅鏂欒姹�
                             bool GYR_RFX = plc.OmronPLCClient.OmronFinsNetClient.ReadBool("D11293.00").Content;
+                            Int16 R_Type = plc.OmronPLCClient.OmronFinsNetClient.ReadInt16("D11224").Content;
+                            WriteLog.GetLog().Write($"{plc.PLCName}璇锋眰绫诲瀷锛歿R_Type}---{DateTime.Now}", $"姝f瀬娑傚竷璇锋眰绫诲瀷");
                             //Convert.ToBoolean(plc.ReadValue("R_Feedingrequest".ToString(), SB_Up_Location));
-                            if (GYR_RFX)
+                            if (GYR_RFX && R_Type == Convert.ToInt16(1))
                             {
+                                var SBtask = agvRepository.FindFirst(f => f.agv_toaddress == SB_Up_Location);
+                                //鏈夌粨鏉熸湰娆″惊鐜�
+                                if (SBtask != null) { continue; }
+                                #region 璁板綍涓婄┖绛掕姹備俊鍙�
+                                WriteLog.GetLog().Write($"{plc.PLCName}涓婄┖绛掕姹傦細{GYR_RFX}锛寋R_Type}---{DateTime.Now}", $"姝f瀬娑傚竷涓婄┖绛掕姹�");
+                                #endregion
+                                //鎵惧埌璺敱瑙勫垯(浠ヨ澶囦负璧风偣鐨勮矾鐢辫鍒�)
+                                List<base_routing_table> Routing_Table = routingRepository.Find(d => d.route_began == SB_Up_Location);
+                                List<string> ends = Routing_Table.Select(x => x.route_end).ToList();
+                                if (Routing_Table.Count > 0)
+                                {
+                                    //鍙敤绌虹瓛缂撳瓨鏋�
+                                    base_ware_location location_TB = locRepository.Find(t => ends.Contains(t.upper_code)  && t.location_state == LoctionStateEnum.LocationState_Stored.ToString() && t.tpgd == 1 && t.area == "ZJ-TBHCJ" && t.status == 1 && t.task == 2 && t.geartype == "C").OrderBy(d => d.update_time).FirstOrDefault();
+                                    if (location_TB != null)
+                                    {
+                                        WebResponseContent content = new WebResponseContent();
+                                        locRepository.DbContextBeginTransaction(() =>
+                                        {
+                                            //鐢熸垚娑傚竷鏈轰笅鏂欎换鍔�
+                                            dt_agvtask agvtask = new dt_agvtask()
+                                            {
+                                                agv_id = Guid.NewGuid(),
+                                                agv_tasknum = "KH-" + IdenxManager.GetTaskNo(),
+                                                agv_fromaddress = location_TB.upper_code,//浠ヨ澶囨湭璧风偣
+                                                agv_toaddress = SB_Up_Location,
+                                                agv_code = "姝f瀬AGV璋冨害",
+                                                agv_remark = "娑傚竷涓婄┖绛掍换鍔�",
+                                                agv_taskstate = AGVTaskStateEnum.Create.ToString(),
+                                                agv_tasktype = AGVTaskTypeEnum.TaskType_Outbound.ToString(),
+                                                agv_worktype = 1,//宸ヤ綔绫诲瀷
+                                                agv_materielid = "",
+                                                agv_qty = 1,
+                                                agv_createtime = DateTime.Now,
+                                                agv_grade = 0,//浠诲姟浼樺厛绾�
+                                                agv_userid = "WCS",
+                                                agv_barcode = "",
+                                            };
+
+                                            location_TB.update_time = DateTime.Now;
+                                            location_TB.task = 1;
+                                            var entry = locRepository.DbContext.ChangeTracker.Entries<base_ware_location>().FirstOrDefault();
+                                            if (entry != null)
+                                            {
+                                                entry.State = EntityState.Detached;
+                                            }
+                                            int x = locRepository.Update(location_TB, d => new { d.update_time, d.task }, true);
+                                            if (x == 1)
+                                            {
+                                                agvRepository.Add(agvtask, true);
+                                                //WriteDBLog.Info($"銆恵TBSB}銆戜笅鏂欎换鍔$敓鎴�").Write($"鐢熸垚浠诲姟:{agvtask.agv_tasknum},缁堢偣璐т綅銆恵location_TB.upper_code}銆戠姸鎬侊細鎵樼洏鍏夌數妫�娴嬶細{location_TB.tpgd},鐘舵�侊細{location_TB.location_state},鏇存柊鏃堕棿锛歿location_TB.wireless_time}", $"銆恵TBSB}銆戜笅鏂欎换鍔$敓鎴�");
+                                                //WriteDBLog.Info($"銆恵TBSB}銆戜笅鏂欎换鍔$敓鎴�").Write($"----------------浠诲姟鐢熸垚鎴愬姛  {DateTime.Now} -------------- {Environment.NewLine}", $"銆恵TBSB}銆戜笅鏂欎换鍔$敓鎴�");
+                                                return content.OK();
+                                            }
+                                            else
+                                            {
+                                                return content.Error();
+                                            }
+                                        });
+                                    }
+
+                                }
+                            }
+                            else if (GYR_RFX)
+                            {
+                                var SBtask = agvRepository.FindFirst(f => f.agv_fromaddress == SB_Up_Location);
+                                //鏈夌粨鏉熸湰娆″惊鐜�
+                                if (SBtask != null) { continue; }
                                 #region 璁板綍涓嬫枡璇锋眰淇″彿
                                 WriteLog.GetLog().Write($"{plc.PLCName}涓嬫枡璇锋眰锛歿GYR_RFX}---{DateTime.Now}", $"姝f瀬娑傚竷涓嬫枡璇锋眰");
                                 #endregion
@@ -75,7 +140,7 @@
                                     foreach (var item in Routing_Table)
                                     {
                                         //鎵惧厛鎵炬秱甯冨尯鍩熺紦瀛樻灦
-                                        location_TB = locRepository.FindFirst(t => t.upper_code == item.route_end && t.location_state == LoctionStateEnum.LocationState_Empty.ToString() && t.tpgd == 0 && t.area == "ZJ-TBHCJ" && t.status == 1 && t.task == 2);
+                                        location_TB = locRepository.FindFirst(t => t.upper_code == item.route_end && t.location_state == LoctionStateEnum.LocationState_Empty.ToString() && t.tpgd == 0 && t.area == "ZJ-TBHCJ" && t.status == 1 && t.task == 2 && t.geartype== "鏆傛棤");
                                         if (location_TB != null)
                                         {
                                             //location = location_TB.FirstOrDefault();//濡傛灉鎵惧埌锛岃祴鍊煎悗閫�鍑哄惊鐜�
diff --git a/wcs-server-hbf/WIDESEA_WCSServer/modified_data.json b/wcs-server-hbf/WIDESEA_WCSServer/modified_data.json
index 1e06532..8fee6b2 100644
--- a/wcs-server-hbf/WIDESEA_WCSServer/modified_data.json
+++ b/wcs-server-hbf/WIDESEA_WCSServer/modified_data.json
@@ -1 +1 @@
-{"MM":"456","logtime":"2026-03-12"}
\ No newline at end of file
+{"MM":"456","logtime":"2026-03-20"}
\ No newline at end of file
diff --git "a/\346\266\202\345\270\203\345\257\271\346\216\245\345\234\260\345\235\200.xlsx" "b/\346\266\202\345\270\203\345\257\271\346\216\245\345\234\260\345\235\200.xlsx"
new file mode 100644
index 0000000..e8056dd
--- /dev/null
+++ "b/\346\266\202\345\270\203\345\257\271\346\216\245\345\234\260\345\235\200.xlsx"
Binary files differ
diff --git "a/\350\276\212\345\210\206\345\257\271\346\216\245\345\234\260\345\235\200.png" "b/\350\276\212\345\210\206\345\257\271\346\216\245\345\234\260\345\235\200.png"
new file mode 100644
index 0000000..9c4668c
--- /dev/null
+++ "b/\350\276\212\345\210\206\345\257\271\346\216\245\345\234\260\345\235\200.png"
Binary files differ

--
Gitblit v1.9.3