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/F_TSJ_DownTask.cs | 151 +++++++++++++++++++++++++------------------------ 1 files changed, 77 insertions(+), 74 deletions(-) diff --git a/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/F_TSJ_DownTask.cs b/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/F_TSJ_DownTask.cs index 3ad74e2..439081a 100644 --- a/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/F_TSJ_DownTask.cs +++ b/wcs-server-hbf/WIDESEA_WCS/SchedulerExecute/Equipment/F_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,86 +29,88 @@ if (Interlocked.Exchange(ref _readTSJDOWNSignalsoFTSJ, 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); + try + { + 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); - if (WCSService.Clients == null) - { - return; - } - PLCClient plc = WCSService.Clients.Find(v => v.PLCName == "璐熸瀬绠旀潗鎻愬崌鏈�"); - if (plc == null) - { - 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 == "FJ-BCHCJ37" && d.location_state == LoctionStateEnum.LocationState_Empty.ToString() && d.tpgd == 0 && d.status == 1 && d.task == 2); - if (ware_Locations != null) + if (WCSService.Clients == null) { - //鐢熸垚鎻愬崌鏈烘満涓嬫枡浠诲姟 - 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 = "璐熸瀬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 = "", - }; - - ware_Locations.task = 1; - ware_Locations.update_time = DateTime.Now; - int a= locRepository.Update(ware_Locations, d => new { d.task, d.update_time }, true); - if (a==1) - { - agvRepository.Add(agvtask, true); - WriteDBLog.Info($"璐熸瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�").Write($"鐢熸垚浠诲姟:{agvtask.agv_tasknum},缁堢偣璐т綅銆恵ware_Locations.upper_code}銆戠姸鎬侊細鎵樼洏鍏夌數妫�娴嬶細{ware_Locations.tpgd},鐘舵�侊細{ware_Locations.location_state},鏇存柊鏃堕棿锛歿ware_Locations.wireless_time}", $"璐熸瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�"); - WriteDBLog.Info($"璐熸瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�").Write($"----------------浠诲姟鐢熸垚鎴愬姛 {DateTime.Now} -------------- {Environment.NewLine}", $"璐熸瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�"); - } - //WriteLog.GetLog("璁惧鍛煎彨").Write($"璁惧 {plc.PLCDescroption} 鍛煎彨鎴愬姛锛屼换鍔agvtask.agv_tasknum}鐢熸垚", "璁惧鍛煎彨"); + return; } + PLCClient plc = WCSService.Clients.Find(v => v.PLCName == "璐熸瀬绠旀潗鎻愬崌鏈�"); + if (plc == null) + { + 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 == "FJ-BCHCJ37" && d.location_state == LoctionStateEnum.LocationState_Empty.ToString() && d.tpgd == 0 && d.status == 1 && d.task == 2); + if (ware_Locations != null) + { + //鐢熸垚鎻愬崌鏈烘満涓嬫枡浠诲姟 + 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 = "璐熸瀬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 = "", + }; + + ware_Locations.task = 1; + ware_Locations.update_time = DateTime.Now; + int a = locRepository.Update(ware_Locations, d => new { d.task, d.update_time }, true); + if (a == 1) + { + agvRepository.Add(agvtask, true); + //WriteDBLog.Info($"璐熸瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�").Write($"鐢熸垚浠诲姟:{agvtask.agv_tasknum},缁堢偣璐т綅銆恵ware_Locations.upper_code}銆戠姸鎬侊細鎵樼洏鍏夌數妫�娴嬶細{ware_Locations.tpgd},鐘舵�侊細{ware_Locations.location_state},鏇存柊鏃堕棿锛歿ware_Locations.wireless_time}", $"璐熸瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�"); + //WriteDBLog.Info($"璐熸瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�").Write($"----------------浠诲姟鐢熸垚鎴愬姛 {DateTime.Now} -------------- {Environment.NewLine}", $"璐熸瀬鎻愬崌鏈轰笅鏂欎换鍔$敓鎴�"); + } + //WriteLog.GetLog("璁惧鍛煎彨").Write($"璁惧 {plc.PLCDescroption} 鍛煎彨鎴愬姛锛屼换鍔agvtask.agv_tasknum}鐢熸垚", "璁惧鍛煎彨"); + } + } + + } + catch (Exception ex) + { + WriteLog.GetLog().Write($"璐熸瀬鎻愬崌鏈轰笅鏂欙細{DateTime.Now} --------------{ex}", $"璐熸瀬鎻愬崌鏈轰笅鏂欒皟搴�"); + } + finally + { - - } - catch (Exception) - { - - throw; - } - finally - { - - Interlocked.Exchange(ref _readTSJDOWNSignalsoFTSJ, 0); - } + Interlocked.Exchange(ref _readTSJDOWNSignalsoFTSJ, 0); + } + }); + } } -- Gitblit v1.9.3