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_GFSB_UPTask.cs | 186 ++++++++++++++++++++++++----------------------
1 files changed, 96 insertions(+), 90 deletions(-)
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 8b9e902..c5553f4 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
@@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
+using System.Threading.Tasks;
using WIDESEA_Common;
using WIDESEA_Common.LoctionEnum;
using WIDESEA_Common.Tools;
@@ -27,107 +28,112 @@
{
if (Interlocked.Exchange(ref _readGFBUPSignalsoZ, 1) == 0)
{
-
- try
+ Task.Run(() =>
{
- VOLContext Context = new VOLContext();
- Ibase_ware_locationRepository locRepository = new base_ware_locationRepository(Context);
- Ibase_routing_tableRepository routingRepository = new base_routing_tableRepository(Context);
- Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
- List<string> TBSBS = new List<string> { "杈婂垎鏈烘鏋�1", "杈婂垎鏈烘鏋�2", "杈婂垎鏈烘鏋�3", "杈婂垎鏈烘鏋�4" };
-
- foreach (var TBSB in TBSBS)
+ try
{
- //string SBID = TBSB.Replace("杈婂垎鏈烘鏋�", "");//璁惧鍙�
- PLCClient plc = WCSService.Clients.Find(v => v.PLCName == TBSB);
- if (plc == null)
- {
- //WriteLog.GetLog("GFZ涓婃枡鍛煎彨").Write($"璁惧锛歿TBSB} 鍐呭锛氭湭杩炴帴PLC 鏃堕棿璁板綍:{DateTime.Now}", "GFZ涓婃枡鍛煎彨");
- continue;
- }
- //褰撳墠璁惧鏈夋病鏈変笂鏂欒姹�
- //bool GYR_RFX = Convert.ToBoolean(plc.ReadValue("R_Feedingrequest".ToString(), plc.EquipType));
- //if (GYR_RFX)
+ VOLContext Context = new VOLContext();
+ Ibase_ware_locationRepository locRepository = new base_ware_locationRepository(Context);
+ Ibase_routing_tableRepository routingRepository = new base_routing_tableRepository(Context);
+ Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
+ List<string> TBSBS = new List<string> { "杈婂垎鏈烘鏋�1", "杈婂垎鏈烘鏋�2", "杈婂垎鏈烘鏋�3", "杈婂垎鏈烘鏋�4" };
- OperateResult<bool> GYR_RFX = plc.MelsecPLCClient.MelsecMcNetClient.ReadBool("D5493.0");
- Int16 tf = Convert.ToInt16(GYR_RFX.Content);
- if (GYR_RFX.Content)
+ foreach (var TBSB in TBSBS)
{
- //鏌ョ湅褰撳墠杈婂垎鏈鸿澶囨槸鍚︽湁AGV浠诲姟
- var SBtask = agvRepository.FindFirst(f => f.agv_toaddress == plc.EquipType);
- //鏈夌粨鏉熸湰娆″惊鐜�
- if (SBtask != null) { continue; }
- List<base_routing_table> Routing_Table = routingRepository.Find(d => d.route_end == plc.EquipType);
- List<base_ware_location> loctionList = new List<base_ware_location>();
- foreach (var item in Routing_Table)
+ //string SBID = TBSB.Replace("杈婂垎鏈烘鏋�", "");//璁惧鍙�
+ PLCClient plc = WCSService.Clients.Find(v => v.PLCName == TBSB);
+ if (plc == null)
{
- 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);
- if (ware_Locations == null)
+ //WriteLog.GetLog("GFZ涓婃枡鍛煎彨").Write($"璁惧锛歿TBSB} 鍐呭锛氭湭杩炴帴PLC 鏃堕棿璁板綍:{DateTime.Now}", "GFZ涓婃枡鍛煎彨");
+ continue;
+ }
+ //褰撳墠璁惧鏈夋病鏈変笂鏂欒姹�
+ //bool GYR_RFX = Convert.ToBoolean(plc.ReadValue("R_Feedingrequest".ToString(), plc.EquipType));
+ //if (GYR_RFX)
+
+ OperateResult<bool> GYR_RFX = plc.MelsecPLCClient.MelsecMcNetClient.ReadBool("D5493.0");
+ Int16 tf = Convert.ToInt16(GYR_RFX.Content);
+ if (GYR_RFX.Content)
+ {
+ //鏌ョ湅褰撳墠杈婂垎鏈鸿澶囨槸鍚︽湁AGV浠诲姟
+ var SBtask = agvRepository.FindFirst(f => f.agv_toaddress == plc.EquipType);
+ //鏈夌粨鏉熸湰娆″惊鐜�
+ if (SBtask != null) { continue; }
+ #region 璁板綍涓婃枡璇锋眰淇″彿
+ WriteLog.GetLog().Write($"{plc.PLCName}涓婃枡璇锋眰锛歿GYR_RFX.Content}---{DateTime.Now}", $"姝f瀬妫嶅垎涓婃枡璇锋眰");
+ #endregion
+ List<base_routing_table> Routing_Table = routingRepository.Find(d => d.route_end == plc.EquipType);
+ List<base_ware_location> loctionList = new List<base_ware_location>();
+ foreach (var item in Routing_Table)
{
- continue;
+ 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);
+ if (ware_Locations == null)
+ {
+ continue;
+ }
+ loctionList.Add(ware_Locations);
}
- loctionList.Add(ware_Locations);
+
+ if (loctionList.Count != 0)
+ {
+ base_ware_location Location = loctionList.OrderBy(d => d.update_time).FirstOrDefault();
+
+
+ //鐢熸垚杈婂垎鏈轰笂鏂欎换鍔�
+ dt_agvtask agvtask = new dt_agvtask()
+ {
+ agv_id = Guid.NewGuid(),
+ agv_tasknum = "KH-" + IdenxManager.GetTaskNo(),
+ agv_fromaddress = Location.upper_code,
+ agv_toaddress = plc.EquipType,
+ 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.task = 1;
+ Location.logic_col = 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.logic_col }, true);
+ if (a == 1)
+ {
+ agvRepository.Add(agvtask, true);
+ //WriteDBLog.Info($"銆恵TBSB}銆戜笂鏂欎换鍔$敓鎴�").Write($"鐢熸垚浠诲姟:{agvtask.agv_tasknum},璧风偣璐т綅鐘舵�侊細鎵樼洏鍏夌數妫�娴嬶細{Location.tpgd},鐘舵�侊細{Location.location_state},鏇存柊鏃堕棿锛歿Location.wireless_time}", $"銆恵TBSB}銆戜笂鏂欎换鍔$敓鎴�");
+ //WriteDBLog.Info($"銆恵TBSB}銆戜笂鏂欎换鍔$敓鎴�").Write($"----------------浠诲姟鐢熸垚鎴愬姛 {DateTime.Now} -------------- {Environment.NewLine}", $"銆恵TBSB}銆戜笂鏂欎换鍔$敓鎴�");
+ }
+
+ }
+
+
}
- if (loctionList.Count != 0)
- {
- base_ware_location Location = loctionList.OrderBy(d => d.update_time).FirstOrDefault();
-
-
- //鐢熸垚杈婂垎鏈轰笂鏂欎换鍔�
- dt_agvtask agvtask = new dt_agvtask()
- {
- agv_id = Guid.NewGuid(),
- agv_tasknum = "KH-" + IdenxManager.GetTaskNo(),
- agv_fromaddress = Location.upper_code,
- agv_toaddress = plc.EquipType,
- 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.task = 1;
- Location.logic_col = 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.logic_col }, true);
- if (a==1)
- {
- agvRepository.Add(agvtask, true);
- WriteDBLog.Info($"銆恵TBSB}銆戜笂鏂欎换鍔$敓鎴�").Write($"鐢熸垚浠诲姟:{agvtask.agv_tasknum},璧风偣璐т綅鐘舵�侊細鎵樼洏鍏夌數妫�娴嬶細{Location.tpgd},鐘舵�侊細{Location.location_state},鏇存柊鏃堕棿锛歿Location.wireless_time}", $"銆恵TBSB}銆戜笂鏂欎换鍔$敓鎴�");
- WriteDBLog.Info($"銆恵TBSB}銆戜笂鏂欎换鍔$敓鎴�").Write($"----------------浠诲姟鐢熸垚鎴愬姛 {DateTime.Now} -------------- {Environment.NewLine}", $"銆恵TBSB}銆戜笂鏂欎换鍔$敓鎴�");
- }
-
- }
-
-
}
-
}
- }
- catch (Exception)
- {
-
- throw;
- }
- finally
- {
- Interlocked.Exchange(ref _readGFBUPSignalsoZ, 0);
- }
+ catch (Exception ex)
+ {
+ WriteLog.GetLog().Write($"姝f瀬妫嶅垎涓婃枡锛歿DateTime.Now} --------------{ex}", $"姝f瀬妫嶅垎涓婃枡");
+ }
+ finally
+ {
+ Interlocked.Exchange(ref _readGFBUPSignalsoZ, 0);
+ }
+ });
+
}
}
--
Gitblit v1.9.3