From 8f392cc88b0768b74efca3b68785cf5aa1c38e70 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期三, 06 十一月 2024 14:28:20 +0800
Subject: [PATCH] 代码更新

---
 wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/Z_TSJ_DownTask.cs |  143 ++++++++++++++++++++++++-----------------------
 1 files changed, 73 insertions(+), 70 deletions(-)

diff --git a/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/Z_TSJ_DownTask.cs b/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/Z_TSJ_DownTask.cs
index 73fda88..2798198 100644
--- a/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/Z_TSJ_DownTask.cs
+++ b/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/Z_TSJ_DownTask.cs
@@ -1,6 +1,7 @@
 锘縰sing HslCommunication;
 using System;
 using System.Threading;
+using System.Threading.Tasks;
 using WIDESEA_Common;
 using WIDESEA_Common.LoctionEnum;
 using WIDESEA_Common.Tools;
@@ -28,87 +29,89 @@
 
             if (Interlocked.Exchange(ref _readTSJDOWNSignalsoZTSJ, 1) == 0)
             {
-
-                try
+                Task.Run(() =>
                 {
-                    VOLContext Context = new VOLContext();
-                    WebResponseContent responseContent = new WebResponseContent();
-                    Idt_task_numberRepository tasknumberRep = new dt_task_numberRepository(Context);
-                    dt_task_numberService tasknumber = new dt_task_numberService(tasknumberRep);
-                    Ibase_ware_locationRepository locRepository = new base_ware_locationRepository(Context);
-                    Ibase_routing_tableRepository routingRepository = new base_routing_tableRepository(Context);
-                    Ibill_pda_groupdiskRepository pdaRepository = new bill_pda_groupdiskRepository(Context);
-                    Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
-                    Idt_agvtask_htyRepository agvhtyRepository = new dt_agvtask_htyRepository(Context);
-                    Ibill_group_stockRepository groupRepository = new bill_group_stockRepository(Context);
-
-                    PLCClient plc = WCSService.Clients.Find(v => v.PLCName == "姝f瀬绠旀潗鎻愬崌鏈�");
-                    if (plc == null)
+                    try
                     {
-                        //WriteLog.GetLog("TSJ涓嬫枡鍛煎彨").Write($"璁惧锛氭鏋佺當鏉愭彁鍗囨満  鍐呭锛氭湭杩炴帴PLC  鏃堕棿璁板綍:{DateTime.Now}", "TSJ涓嬫枡鍛煎彨");
-                        return;
-                    }
-                    //褰撳墠璁惧鏈夋病鏈変笅鏂欒姹�
-                    //bool TSJ_CL = Convert.ToBoolean(plc.ReadValue("R_Feedingrequest".ToString(), plc.PLCDescroption));
-                    OperateResult<bool> TSJ_CL = plc.SiemensPLCClient.SiemensS7NetClient.ReadBool("DB51.93");
-                    if (TSJ_CL.Content)
-                    {
-                        //鏌ョ湅褰撳墠杈婂垎鏈鸿澶囨槸鍚︽湁AGV浠诲姟
-                        var SBtask = agvRepository.FindFirst(f => f.agv_fromaddress == plc.PLCDescroption);
-                        //鏈夌粨鏉熸湰娆″惊鐜�
-                        if (SBtask != null) { return; }
+                        VOLContext Context = new VOLContext();
+                        WebResponseContent responseContent = new WebResponseContent();
+                        Idt_task_numberRepository tasknumberRep = new dt_task_numberRepository(Context);
+                        dt_task_numberService tasknumber = new dt_task_numberService(tasknumberRep);
+                        Ibase_ware_locationRepository locRepository = new base_ware_locationRepository(Context);
+                        Ibase_routing_tableRepository routingRepository = new base_routing_tableRepository(Context);
+                        Ibill_pda_groupdiskRepository pdaRepository = new bill_pda_groupdiskRepository(Context);
+                        Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
+                        Idt_agvtask_htyRepository agvhtyRepository = new dt_agvtask_htyRepository(Context);
+                        Ibill_group_stockRepository groupRepository = new bill_group_stockRepository(Context);
 
-
-                        base_ware_location ware_Locations = locRepository.FindFirst(d => d.upper_code == "ZJ-BCHCJ35" && d.location_state == LoctionStateEnum.LocationState_Empty.ToString() && d.tpgd == 0 && d.status == 1 && d.task == 2);
-                        if (ware_Locations != null)
+                        PLCClient plc = WCSService.Clients.Find(v => v.PLCName == "姝f瀬绠旀潗鎻愬崌鏈�");
+                        if (plc == null)
                         {
-                            //鐢熸垚鎻愬崌鏈烘満涓嬫枡浠诲姟
-                            dt_agvtask agvtask = new dt_agvtask()
+                            //WriteLog.GetLog("TSJ涓嬫枡鍛煎彨").Write($"璁惧锛氭鏋佺當鏉愭彁鍗囨満  鍐呭锛氭湭杩炴帴PLC  鏃堕棿璁板綍:{DateTime.Now}", "TSJ涓嬫枡鍛煎彨");
+                            return;
+                        }
+                        //褰撳墠璁惧鏈夋病鏈変笅鏂欒姹�
+                        //bool TSJ_CL = Convert.ToBoolean(plc.ReadValue("R_Feedingrequest".ToString(), plc.PLCDescroption));
+                        OperateResult<bool> TSJ_CL = plc.SiemensPLCClient.SiemensS7NetClient.ReadBool("DB51.93");
+                        if (TSJ_CL.Content)
+                        {
+                            //鏌ョ湅褰撳墠杈婂垎鏈鸿澶囨槸鍚︽湁AGV浠诲姟
+                            var SBtask = agvRepository.FindFirst(f => f.agv_fromaddress == plc.PLCDescroption);
+                            //鏈夌粨鏉熸湰娆″惊鐜�
+                            if (SBtask != null) { return; }
+
+
+                            base_ware_location ware_Locations = locRepository.FindFirst(d => d.upper_code == "ZJ-BCHCJ35" && d.location_state == LoctionStateEnum.LocationState_Empty.ToString() && d.tpgd == 0 && d.status == 1 && d.task == 2);
+                            if (ware_Locations != null)
                             {
-                                agv_id = Guid.NewGuid(),
-                                agv_tasknum = "KH-" + IdenxManager.GetTaskNo(),
-                                agv_fromaddress = plc.PLCDescroption,
-                                agv_toaddress = ware_Locations.upper_code,
-                                agv_code = "姝f瀬AGV璋冨害",
-                                agv_remark = "姝f瀬鎻愬崌鏈轰笅鏂�",
-                                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 = "",
-                            };
-                     
-                            ware_Locations.update_time = DateTime.Now;
-                            ware_Locations.task = 1;
-                          int a=  locRepository.Update(ware_Locations, d => new { d.task, d.update_time }, true);
-                            if (a==1)
-                            {
-                                agvRepository.Add(agvtask, true);
-                                WriteDBLog.Info($"姝f瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�").Write($"鐢熸垚浠诲姟:{agvtask.agv_tasknum},缁堢偣璐т綅銆恵ware_Locations.upper_code}銆戠姸鎬侊細鎵樼洏鍏夌數妫�娴嬶細{ware_Locations.tpgd},鐘舵�侊細{ware_Locations.location_state},鏇存柊鏃堕棿锛歿ware_Locations.wireless_time}", $"姝f瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�");
-                                WriteDBLog.Info($"姝f瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�").Write($"----------------浠诲姟鐢熸垚鎴愬姛  {DateTime.Now} -------------- {Environment.NewLine}", $"姝f瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�");
+                                //鐢熸垚鎻愬崌鏈烘満涓嬫枡浠诲姟
+                                dt_agvtask agvtask = new dt_agvtask()
+                                {
+                                    agv_id = Guid.NewGuid(),
+                                    agv_tasknum = "KH-" + IdenxManager.GetTaskNo(),
+                                    agv_fromaddress = plc.PLCDescroption,
+                                    agv_toaddress = ware_Locations.upper_code,
+                                    agv_code = "姝f瀬AGV璋冨害",
+                                    agv_remark = "姝f瀬鎻愬崌鏈轰笅鏂�",
+                                    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 = "",
+                                };
+
+                                ware_Locations.update_time = DateTime.Now;
+                                ware_Locations.task = 1;
+                                int a = locRepository.Update(ware_Locations, d => new { d.task, d.update_time }, true);
+                                if (a == 1)
+                                {
+                                    agvRepository.Add(agvtask, true);
+                                    //WriteDBLog.Info($"姝f瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�").Write($"鐢熸垚浠诲姟:{agvtask.agv_tasknum},缁堢偣璐т綅銆恵ware_Locations.upper_code}銆戠姸鎬侊細鎵樼洏鍏夌數妫�娴嬶細{ware_Locations.tpgd},鐘舵�侊細{ware_Locations.location_state},鏇存柊鏃堕棿锛歿ware_Locations.wireless_time}", $"姝f瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�");
+                                    //WriteDBLog.Info($"姝f瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�").Write($"----------------浠诲姟鐢熸垚鎴愬姛  {DateTime.Now} -------------- {Environment.NewLine}", $"姝f瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�");
+                                }
+                                //WriteLog.GetLog("璁惧鍛煎彨").Write($"璁惧{plc.PLCName}鍛煎彨鎴愬姛锛屼换鍔agvtask.agv_tasknum}鐢熸垚", "璁惧鍛煎彨");
                             }
-                            //WriteLog.GetLog("璁惧鍛煎彨").Write($"璁惧{plc.PLCName}鍛煎彨鎴愬姛锛屼换鍔agvtask.agv_tasknum}鐢熸垚", "璁惧鍛煎彨");
+
+
                         }
 
 
                     }
+                    catch (Exception ex)
+                    {
+                        WriteLog.GetLog().Write($"姝f瀬鎻愬崌鏈轰笅鏂欙細{DateTime.Now} --------------{ex}", $"姝f瀬鎻愬崌鏈轰笅鏂�");
+                    }
+                    finally
+                    {
 
-
-                }
-                catch (Exception)
-                {
-
-                    throw;
-                }
-                finally
-                {
-
-                    Interlocked.Exchange(ref _readTSJDOWNSignalsoZTSJ, 0);
-                }
+                        Interlocked.Exchange(ref _readTSJDOWNSignalsoZTSJ, 0);
+                    }
+                });
+                
             }
         }
 

--
Gitblit v1.9.3