From 8dfba1cab2ea59fca7b2c9cfad2da68e9f49b440 Mon Sep 17 00:00:00 2001 From: czw <selecti@yeah.net> Date: 星期三, 09 七月 2025 16:39:40 +0800 Subject: [PATCH] 1 --- 2025年6月12日/AuxAllWCS/Build/Project/代码/自定义类.cs | 193 ++++++++++++----------------------------------- 1 files changed, 51 insertions(+), 142 deletions(-) diff --git "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/\350\207\252\345\256\232\344\271\211\347\261\273.cs" "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/\350\207\252\345\256\232\344\271\211\347\261\273.cs" index 1252671..51db9f9 100644 --- "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/\350\207\252\345\256\232\344\271\211\347\261\273.cs" +++ "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/\350\207\252\345\256\232\344\271\211\347\261\273.cs" @@ -119,7 +119,7 @@ else { logger = LogFactory.CreateLogger(name); - if (logger != null) + if (logger != null && !loggers.Keys.Contains(name)) { loggers.Add(name, logger); } @@ -143,7 +143,7 @@ /// </summary> static LogFactory() { - var loggerNames = new List<string>() { "HosttoagvTask", "HosttoagvCar", "NDC", "鏉ゥ" }; + var loggerNames = new List<string>() { "HosttoagvTask", "HosttoagvCar", "NDC", "鏉ゥ","IP鍦ㄧ嚎妫�祴" }; LogManager.Configuration = DefaultConfig(loggerNames); } public static ILogger CreateLogger(string name) @@ -430,7 +430,10 @@ /// <summary> /// 1 缁村笇灏旀満姊拌噦 /// 2 鎹风灛鏈烘鑷傝噦 - /// 3 鎹风灛杈撻�绾�+ /// 3 楂樺啿鏈烘鎵�+ /// 4 SSXaAGV 浜や簰鐨勮緭閫佺嚎 绾や綋缂栧彿 + /// 5 瀹氬瓙涓婃枡鏈烘鎵�+ /// 6 杞瓙涓婃枡鏈烘鎵� /// </summary> public int deviceType { get; set; } public int enable { get; set; } @@ -519,15 +522,13 @@ { #region [鑷畾涔夌被][20250325131633664][SYSHelper] private static object locker = new object(); - internal static int GetSerialNumber(string snType, string prefix, string Vend = "0") + internal static int GetSerialNumber(string snType, string prefix) { - if (Vend == "1") - Vend = DateTime.Now.ToString("yyMMdd"); int result = 0; lock (locker) { SYSRepository sysservice = new SYSRepository(); - var sId = sysservice.FindEntity(a => a.CN_S_TYPE.Trim() == snType && a.CN_S_PRE.Trim() == prefix + Vend); + var sId = sysservice.FindEntity(a => a.CN_S_TYPE.Trim() == snType && a.CN_S_PRE.Trim() == prefix); if (sId != null) { @@ -549,7 +550,7 @@ } else { - sId = new SYSEntity { CN_S_TYPE = snType, CN_T_LAST = DateTime.Now, CN_S_PRE = prefix + Vend, CN_N_MAX = 0, CN_S_APP_TYPE = "WCS" }; + sId = new SYSEntity { CN_S_TYPE = snType, CN_T_LAST = DateTime.Now, CN_S_PRE = prefix , CN_N_MAX = 0, CN_S_APP_TYPE = "WCS" }; sysservice.Insert(sId); } } @@ -560,21 +561,26 @@ public class TaskProcess { #region [鑷畾涔夌被][20250325152141671][TaskProcess] - internal static bool CreateTask(string no, string from, string to, string taskType, int pri, List<string> cntrs, string workMode = "AGV", int cntrCount = 1, int startLayer = 1, int endLayer = 1) + internal static bool CreateTask(string no, string from, string to, string taskType, int pri, List<string> cntrs, string workMode = "AGV", string S_INDEX = "", int cntrCount = 1, int startLayer = 1, int endLayer = 1) { - LogHelper.Debug($"杈撻�绾縍GV绌烘墭浠诲姟 from:{from}>to {to}寮�鍒涘缓>"); + LogHelper.Info($"鍒涘缓浠诲姟 from:{from}>to {to}寮�鍒涘缓>"); var cntrInfo = string.Join(",", cntrs); ILocRepository locc = new LocRepository(); var fromLoc = locc.FindEntity(x => x.S_LOC_CODE == from); var endLoc = locc.FindEntity(x => x.S_LOC_CODE == to); - var s = Settings.deviceInfos.Find(x => x.location.Contains(from)) != null; - var e = Settings.deviceInfos.Find(x => x.location.Contains(to)) != null; - string t = "F01"; - if (s && !e) t = "A002"; - if (!s && e) t = "A003"; - if (s && e) t = "A004"; + string t = ""; + if (workMode == "AGV" && string.IsNullOrEmpty(S_INDEX)) + { + var s = Settings.deviceInfos.Find(x => x.location.Contains(from)) != null; + var e = Settings.deviceInfos.Find(x => x.location.Contains(to)) != null; + + t = "F01"; + if (s && !e) t = "A002"; + if (!s && e) t = "A003"; + if (s && e) t = "A004"; + } try { @@ -613,7 +619,7 @@ locc.Update(endLoc); } - LogHelper.Debug($"杈撻�绾縍GV绌烘墭浠诲姟 from:{from}>to {to} 鍒涘缓{wmsTask.S_TASK_NO}鎴愬姛"); + LogHelper.Info($"鍒涘缓浠诲姟 from:{from}>to {to} 鍒涘缓{wmsTask.S_TASK_NO}鎴愬姛"); return true; } catch (Exception ex) @@ -645,10 +651,10 @@ taskserice.Insert(action); } - public static System.String GenerateTaskNo() + public static System.String GenerateTaskNo(string snType = "浠诲姟鍙�) { - var id = SYSHelper.GetSerialNumber("浠诲姟鍙�, "TN", "1"); var date = DateTime.Now.ToString("yyMMdd"); + var id = SYSHelper.GetSerialNumber(snType, date); return $"TN{date}{id.ToString().PadLeft(4, '0')}"; } #endregion [鑷畾涔夌被][20250325152141671][TaskProcess] @@ -672,6 +678,7 @@ public string endBit { get; set; } public string reqCode { get; set; } public string cntrCode { get; set; } + public string materialCode { get; set; } internal static ReturnMsg CreatemesTask(CreateTask model) { @@ -693,12 +700,13 @@ S_DEPART_NAME = "", S_START_LOC = model.startBit, S_END_LOC = model.endBit, - S_TYPE = model.reqCode, + S_TYPE = model.taskType, S_SRC_NO = "",// N_PRIORITY = -88, S_WORK_MODE = "agv", S_B_STATE = "MES", S_CNTRS = model.cntrCode, + S_INDEX = model.materialCode,//mes浠诲姟涓�S_INDEX鏄�鐗╂枡缂栫爜銆�agv浠诲姟涓槸 agv浠诲姟绫诲瀷 N_START_LAYER = 1, N_END_LAYER = 1, N_CNTR_COUNT = 1 @@ -759,131 +767,11 @@ } } } - public static void ResMesTask() + public static void ResMesTask(Tag tag) { ///1. - TaskRepository taskservice = new TaskRepository(); - var tasks = taskservice.FindList(x => (x.S_B_STATE == "MES" || x.S_B_STATE == "People") && x.N_PRIORITY == -88); - var VERXs = Settings.deviceInfos?.FindAll(x => x.deviceType == 2); - //if (VERXs.Any()) - foreach (var task in tasks) - { - var sx = VERXs?.Find(x => x.location.Contains(task.S_END_LOC)); - if (sx == null) - { - //鐩存帴鐢熸垚瀵瑰簲浠诲姟銆�- var res = TaskProcess.CreateTask(task.S_TASK_NO, task.S_START_LOC, task.S_END_LOC, task.S_TYPE, 6, task.S_CNTRS.Split(',').ToList()); - if (res) - { - //task.N_PRIORITY = 0; - taskservice.dbcontext.Set<TaskEntity>().Attach(task); - taskservice.dbcontext.Entry(task).Property(x => x.N_PRIORITY).CurrentValue = 0; - taskservice.dbcontext.Entry(task).Property(x => x.N_PRIORITY).IsModified = true; - taskservice.dbcontext.SaveChanges(); - } - } - else - { - var sindex = sx.location.ToList().IndexOf(task.S_END_LOC); - LocRepository locRepository = new LocRepository(); - //鐢熸垚璺宠穬浠诲姟銆� -- 鎵樼洏璐т綅琛ㄣ� - var t1s = taskservice.FindList(x => x.S_SRC_NO == task.S_TASK_NO); - if (t1s.Any()) - { - var t1 = t1s.OrderBy(x => x.T_CREATE).LastOrDefault(); - if (t1.S_END_LOC == task.S_END_LOC) - { - task.N_PRIORITY = 0; - task.S_B_STATE = "MES_瀹屾垚"; - taskservice.Update(task); - continue; - } - if (t1.S_B_STATE == "瀹屾垚") - { - //1.缁堢偣鏄惁鏈夋墭鐩樸� 渚濇嵁鏄粓鐐圭殑浠诲姟鏄�浣滀负缁堢偣锛岃繕鏄捣鐐广� - //var ec = taskservice.FindList(x => (x.S_START_LOC == task.S_START_LOC || x.S_END_LOC == task.S_END_LOC) /*&& DateTime.Now.Subtract(x.T_CREATE).TotalHours < 5*/).OrderByDescending(x => x.T_CREATE).FirstOrDefault();//($"select top 1 * from TN_TASK WHERE S_START_LOC='{task.S_END_LOC}' OR S_END_LOC='{task.S_END_LOC}' ORDER BY T_CREATE DESC"); - //var ec = taskservice.FindList(x => x.S_START_LOC == task.S_START_LOC && x.S_END_LOC == task.S_START_LOC, new Common.Data.Pagination - // { - // page = 1, - // sidx = "T_CREATE", - // sord = "desc", - // rows = 1 - // }).FirstOrDefault(); - TaskEntity ec = null; - var dev = Conn.榛樿Redis.GetValue(sx.deviceName + "." + (sindex == 0 ? "D1224" : "D1225")); - if (dev?.Trim() == "1") - ec = taskservice.FindList(x => x.S_END_LOC == task.S_END_LOC && x.S_B_STATE == "瀹屾垚", new Common.Data.Pagination - { - page = 1, - sidx = "T_CREATE", - sord = "desc", - rows = 1 - }).FirstOrDefault(); - if (t1.S_START_LOC == task.S_START_LOC && ec != null)//!= task.S_END_LOC) - { - //绗簩娈点� - LocEntity endLoc = null; - var di = sx; - if (di != null) - { - foreach (var ssloc in di.deviceNo) - { - var endloc = locRepository.FindEntity(x => x.S_LOC_CODE == ssloc); - if (endloc != null && endloc.N_CURRENT_NUM == 0 && endloc.S_LOCK_STATE == "鏃�) - { - endLoc = endloc; - break; - } - } - if (endLoc != null) - { - var res = TaskProcess.CreateTask(task.S_TASK_NO, task.S_END_LOC, endLoc.S_LOC_CODE, task.S_TYPE + "涓嬬┖", 7, ec.S_CNTRS.Split(',').ToList()); - if (res) - { - task.N_PRIORITY = 0; taskservice.Update(task); - } - } - } - } - else - { - var res = TaskProcess.CreateTask(task.S_TASK_NO, t1.S_END_LOC, task.S_END_LOC, task.S_TYPE + "琛ユ弧", 6, task.S_CNTRS.Split(',').ToList()); - if (res) - { - task.N_PRIORITY = 0; taskservice.Update(task); - } - } - } - } - else - { - //鐢熸垚绗竴娈点� - LocEntity endLoc = null; - var di = sx; - if (di != null) - { - foreach (var ssloc in di.deviceNo) - { - var endloc = locRepository.FindEntity(x => x.S_LOC_CODE == ssloc); - if (endloc != null && endloc.N_CURRENT_NUM == 0 && endloc.S_LOCK_STATE == "鏃�) - { - endLoc = endloc; - break; - } - } - if (endLoc != null) - { - var res = TaskProcess.CreateTask("", task.S_START_LOC, endLoc.S_LOC_CODE, task.S_TYPE + "婊¤浆", 8, task.S_CNTRS.Split(',').ToList()); - if (res) - { - task.N_PRIORITY = 0; taskservice.Update(task); - } - } - } - } - } - } + AutoThread.InvokeMethod(AutoThread.Instance, "ResolveMesTask", new object[] { tag }); //var VERX = Settings.deviceInfos?.FindAll(x => x.deviceName.Contains("鎹风灛鎶撹噦")); //if () ///2 鐪嬬紦瀛樺尯銆�娌℃弧鐨勩� @@ -894,4 +782,25 @@ #endregion [鑷畾涔夌被][20250531152402452][ToWMSMES] } + public class ConsoleInterceptor : TextWriter + { + #region [鑷畾涔夌被][20250702112833751][ConsoleInterceptor] + private readonly TextWriter _originalOut; + + public ConsoleInterceptor() + { + _originalOut = Console.Out; + } + + public override Encoding Encoding => Encoding.UTF8; + + public override void WriteLine(string value = "") + { + string values = (string)AutoThread.InvokeMethod(AutoThread.Instance, "WriteLine", new object[] { value }); + //// 鍙互閫夋嫨缁х画杈撳嚭鍒板師鎺у埗鍙�+ if (!string.IsNullOrEmpty(values)) + _originalOut.WriteLine(values); + } + #endregion [鑷畾涔夌被][20250702112833751][ConsoleInterceptor] + } } \ No newline at end of file -- Gitblit v1.9.1