From c4e968254a4f1c5d538a9fd91284b4843ea08198 Mon Sep 17 00:00:00 2001 From: kazelee <1847801760@qq.com> Date: 星期五, 23 五月 2025 10:44:58 +0800 Subject: [PATCH] 内部联调,修复问题,添加取消任务功能 --- device/SnapManager.cs | 25 +- .vs/HH.WCS.Mobox3.AnGang/FileContentIndex/58a869dd-63a6-4ba3-b662-00952ac61ff8.vsidx | 0 Program.cs | 5 Properties/AssemblyInfo.cs | 4 wms/LocationHelper.cs | 7 core/Monitor.cs | 4 /dev/null | 0 Dispatch/GZRobot.cs | 1 Models/TN_Task.cs | 10 api/ApiModel.cs | 10 core/WCSCore.cs | 44 +++ api/DebugController.cs | 26 ++ device/SnapDevice.cs | 236 +++++++++++----------- .vs/HH.WCS.Mobox3.AnGang/FileContentIndex/b2175d53-106b-45a1-ad0e-0dd460928cd4.vsidx | 0 util/Settings.cs | 2 api/AgvController.cs | 2 api/ApiHelper.cs | 123 ++++++++++- api/MoboxController.cs | 92 +++++--- 18 files changed, 375 insertions(+), 216 deletions(-) diff --git a/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/3ea34f60-d704-4ad2-8e0f-2cf457081645.vsidx b/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/3ea34f60-d704-4ad2-8e0f-2cf457081645.vsidx deleted file mode 100644 index 987a584..0000000 --- a/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/3ea34f60-d704-4ad2-8e0f-2cf457081645.vsidx +++ /dev/null Binary files differ diff --git a/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/58a869dd-63a6-4ba3-b662-00952ac61ff8.vsidx b/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/58a869dd-63a6-4ba3-b662-00952ac61ff8.vsidx new file mode 100644 index 0000000..8b70775 --- /dev/null +++ b/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/58a869dd-63a6-4ba3-b662-00952ac61ff8.vsidx Binary files differ diff --git a/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/b2175d53-106b-45a1-ad0e-0dd460928cd4.vsidx b/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/b2175d53-106b-45a1-ad0e-0dd460928cd4.vsidx new file mode 100644 index 0000000..ea4154e --- /dev/null +++ b/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/b2175d53-106b-45a1-ad0e-0dd460928cd4.vsidx Binary files differ diff --git a/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/c1b1f263-3564-477c-bc41-41a75528f80c.vsidx b/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/c1b1f263-3564-477c-bc41-41a75528f80c.vsidx deleted file mode 100644 index 369f0c9..0000000 --- a/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/c1b1f263-3564-477c-bc41-41a75528f80c.vsidx +++ /dev/null Binary files differ diff --git a/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/d649a959-a553-4855-aaba-982999a405f5.vsidx b/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/d649a959-a553-4855-aaba-982999a405f5.vsidx deleted file mode 100644 index 98c4f54..0000000 --- a/.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/d649a959-a553-4855-aaba-982999a405f5.vsidx +++ /dev/null Binary files differ diff --git a/Dispatch/GZRobot.cs b/Dispatch/GZRobot.cs index 070607e..3542475 100644 --- a/Dispatch/GZRobot.cs +++ b/Dispatch/GZRobot.cs @@ -106,6 +106,7 @@ /// </summary> /// <returns></returns> public static GzResult orderStatusReport(orderStatusReportParme model) { + LogHelper.Info("RCS鍥借嚜AGV浠诲姟鐘舵�鍥炴姤锛� + JsonConvert.SerializeObject(model), "HosttoagvTask"); GzResult result = new GzResult(); AgvTaskState agv = new AgvTaskState(); diff --git a/Models/TN_Task.cs b/Models/TN_Task.cs index e129de9..0e1faa5 100644 --- a/Models/TN_Task.cs +++ b/Models/TN_Task.cs @@ -35,13 +35,13 @@ public string S_CNTR_CODE { get; set; } = ""; public string S_OP_NAME { get; set; } = ""; - + //public int N_CNTR_COUNT { get; internal set; } - ///// <summary> - ///// 浠诲姟鐨勮揣鐗╅噸閲�- ///// </summary> - //public float F_WEIGHT { get; set; } + /// <summary> + /// 浠诲姟鐨勮揣鐗╅噸閲�+ /// </summary> + public float F_WEIGHT { get; set; } = 0f; internal static string GetStateStr(int state) { //0绛夊緟 1宸叉帹閫� 2鎵ц 3瀹屾垚 4閿欒 diff --git a/Program.cs b/Program.cs index 2b99c54..02bf3c6 100644 --- a/Program.cs +++ b/Program.cs @@ -15,7 +15,7 @@ namespace HH.WCS.Mobox3.AnGang { internal class Program { - [STAThread] + //[STAThread] // TODO SNAP static void Main(string[] args) { //鍩虹璁剧疆淇℃伅鍒濆鍖�@@ -127,8 +127,7 @@ List<Task> tasks = new List<Task>(); // 娣诲姞浠诲姟鎺ㄩ�绾跨▼ tasks.Add(GetTask(WCSCore.Dispatch)); - tasks.Add(GetTask(Monitor.CheckCountOrder)); - + //tasks.Add(GetTask(Monitor.CheckCountOrder)); Task.WaitAll(tasks.ToArray()); } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 71b07bb..2ab0107 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -5,11 +5,11 @@ // 鏈夊叧绋嬪簭闆嗙殑涓�埇淇℃伅鐢变互涓� // 鎺у埗銆傛洿鏀硅繖浜涚壒鎬у�鍙慨鏀� // 涓庣▼搴忛泦鍏宠仈鐨勪俊鎭� -[assembly: AssemblyTitle("HH.WCS.Mobox3.DSZSH")] +[assembly: AssemblyTitle("HH.WCS.Mobox3.AnGang")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("HH.WCS.Mobox3.DSZSH")] +[assembly: AssemblyProduct("HH.WCS.Mobox3.AnGang")] [assembly: AssemblyCopyright("Copyright 漏 2023")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/api/AgvController.cs b/api/AgvController.cs index 1dcacb9..f3becc7 100644 --- a/api/AgvController.cs +++ b/api/AgvController.cs @@ -10,7 +10,6 @@ using System.Linq; using HH.WCS.Mobox3.AnGang.config; - using static HH.WCS.Mobox3.AnGang.api.ApiModel; namespace HH.WCS.Mobox3.AnGang.api @@ -42,6 +41,7 @@ [HttpPost] [Route("orderStatusReport")] public GzResult orderStatusReport(orderStatusReportParme model) { + //LogHelper.Info("RCS鍥借嚜AGV浠诲姟鐘舵�鍥炴姤锛� + JsonConvert.SerializeObject(model), "HosttoagvTask"); return GZRobot.orderStatusReport(model); } diff --git a/api/ApiHelper.cs b/api/ApiHelper.cs index cce68d9..e01d92b 100644 --- a/api/ApiHelper.cs +++ b/api/ApiHelper.cs @@ -31,7 +31,7 @@ .First(); if (startLoc == null) { - return BuildSimpleResult(1, $"璧风偣浣嶇疆{model.StartLoc}涓嶅瓨鍦紒"); + return BuildSimpleResult(1, $"璧风偣浣嶇疆{model.StartLoc}涓嶅瓨鍦ㄦ垨涓嶆弧瓒宠姹傦細闇�锛�锛夋病鏈夐攣鐘舵�锛�锛夊綋鍓嶆棤瀹瑰櫒锛�锛夊睘浜庡彇鏀捐揣鍖�); } // 瀹瑰櫒 ID 鍜�鐗╂枡 ID 鏈寚瀹氾紝鐢辩郴缁熺洿鎺ョ敓鎴�@@ -45,6 +45,7 @@ S_LOC_CODE = startLoc.S_CODE, S_CNTR_CODE = cntId, }; + var cgDetail = new TN_CG_Detail() { S_ITEM_CODE = cgId, S_CNTR_CODE = cntId, @@ -65,7 +66,7 @@ } var task = WCSHelper.BuildInboundTask(startLoc, endLocCode, cntId); - LocationHelper.LockLoc(ref startLoc, 1); // 璧风偣鍑哄簱閿�+ LocationHelper.LockLoc(ref startLoc, 2); // 璧风偣鍑哄簱閿� // 鏃犺鏄惁閫夋嫨缁堢偣璐ф灦锛岄兘绛夊埌绉伴噸涔嬪悗鍐嶈绠楃粓鐐硅揣浣� using (var tran = db.Ado.UseTran()) { @@ -122,6 +123,7 @@ try { // 浠诲姟鍙峰瓨鍦細缁堢偣璐ф灦鍜岀粓鐐逛綅缃负绌猴紝涓斾换鍔′负浜у搧鍏ュ簱(PDA) var task = db.Queryable<TN_Task>() + .Where(a => a.S_CODE == model.TaskNo) .Where(a => a.S_B_STATE == "鍙栬揣瀹屾垚" && a.S_TYPE == TaskName.浜у搧鍏ュ簱) .OrderBy(a => a.T_CREATE, SqlSugar.OrderByType.Desc).First(); @@ -141,22 +143,27 @@ } var endLoc = new TN_Location(); - if (cgDetail.F_QTY > 1500) { - // 閲嶉噺瓒呰繃1.5t锛岄渶瑕侀�鎷�-3灞傝揣鏋�+ if (cgDetail.F_QTY > 2000) { + // 閲嶉噺瓒呰繃2t锛屾姤閿�+ return BuildSimpleResult(8, $"鐗╂枡閲嶉噺{cgDetail.F_QTY}瓒呰繃2t"); + } + else if (cgDetail.F_QTY > 1500) { + // 閲嶉噺瓒呰繃1.5t锛岄渶瑕侀�鎷�-2灞傝揣鏋� endLoc = db.Queryable<TN_Location>() - .Where(a => a.S_CODE == model.endLoc) + .Where(a => a.S_CODE == model.EndLoc) .Where(a => a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y") .Where(a => a.N_CURRENT_NUM == 0) .Where(a => Settings.Areas[1].Contains(a.S_AREA_CODE)) - .Where(a => a.N_LAYER <= 3) + .Where(a => a.N_LAYER <= 2) .First(); } else if (cgDetail.F_QTY > 0) { endLoc = db.Queryable<TN_Location>() - .Where(a => a.S_CODE == model.endLoc) + .Where(a => a.S_CODE == model.EndLoc) .Where(a => a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y") .Where(a => a.N_CURRENT_NUM == 0) .Where(a => Settings.Areas[1].Contains(a.S_AREA_CODE)) + .OrderBy(a => a.N_LAYER > 2 ? 0 : 1) // 浼樺厛鍙栧ぇ浜�鐨� //.Where(a => a.N_LAYER <= 3) .First(); } @@ -166,7 +173,7 @@ // 娌℃湁绗﹀悎鏉′欢鐨勮揣浣� if (endLoc == null) { - return BuildSimpleResult(6, $"璐т綅{model.endLoc}涓嶅瓨鍦紝鎴栦笉婊¤冻绉伴噸鏀剧疆瑕佹眰"); + return BuildSimpleResult(6, $"璐т綅{model.EndLoc}涓嶅瓨鍦紝鎴栦笉婊¤冻绉伴噸鏀剧疆瑕佹眰"); } // 淇敼浠诲姟缁堢偣涓篜DA鎸囧畾缁堢偣 @@ -230,8 +237,8 @@ var cntId = locCntrRel.S_CNTR_CODE; var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, taskName); - LocationHelper.LockLoc(ref startLoc, 1); // 璧风偣鍑哄簱閿�- LocationHelper.LockLoc(ref endLoc, 2); // 缁堢偣鍏ュ簱閿�+ LocationHelper.LockLoc(ref startLoc, 2); // 璧风偣鍑哄簱閿�+ LocationHelper.LockLoc(ref endLoc, 1); // 缁堢偣鍏ュ簱閿� using (var tran = db.Ado.UseTran()) { if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new { @@ -294,8 +301,8 @@ var cntId = locCntrRel.S_CNTR_CODE; var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, taskName); - LocationHelper.LockLoc(ref startLoc, 1); // 璧风偣鍑哄簱閿�- LocationHelper.LockLoc(ref endLoc, 2); // 缁堢偣鍏ュ簱閿�+ LocationHelper.LockLoc(ref startLoc, 2); // 璧风偣鍑哄簱閿�+ LocationHelper.LockLoc(ref endLoc, 1); // 缁堢偣鍏ュ簱閿� using (var tran = db.Ado.UseTran()) { if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new { @@ -322,6 +329,90 @@ return BuildSimpleResult(0, $"鐢熸垚 {taskName} 鎴愬姛锛屽鍣ㄥ彿 {cntId} 锛岃捣鐐�{startLoc.S_CODE} 锛岀粓鐐硅揣鏋�{endLoc.S_CODE}"); } + } + catch (Exception ex) { + return BuildSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}"); + } + } + + public static SimpleResult CancelTask(CancelTaskInfo model) { + var db = new SqlHelper<object>().GetInstance(); + var info = ""; + try { + var task = db.Queryable<TN_Task>() + .Where(a => a.S_CODE == model.TaskNo) + .First(); + + if (task == null) { + return BuildSimpleResult(2, $"浠诲姟鍙穥model.TaskNo}涓嶅瓨鍦�); + } + + if (task.N_B_STATE == 0 && task.S_B_STATE == TN_Task.GetStateStr(0) + || task.N_B_STATE == 1 && task.S_B_STATE == TN_Task.GetStateStr(1)) { + + task.N_B_STATE = 4; + task.S_B_STATE = "鍙栨秷"; + + var starloc = db.Queryable<TN_Location>().First(a => a.S_CODE == task.S_START_LOC); + var endloc = db.Queryable<TN_Location>().First(a => a.S_CODE == task.S_END_LOC); + //var locCnt = db.Queryable<TN_Loc_Container>().First(a => a.S_CNTR_CODE == task.S_CNTR_CODE); + //var cg = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == task.S_CNTR_CODE); + + if (starloc != null) { + starloc.N_LOCK_STATE = 0; + starloc.S_LOCK_STATE = "鏃�; + //starloc.N_CURRENT_NUM = 0; + starloc.T_MODIFY = System.DateTime.Now; + } + + if (endloc != null) { + endloc.N_LOCK_STATE = 0; + endloc.S_LOCK_STATE = "鏃�; + //endloc.N_CURRENT_NUM = 0; + endloc.T_MODIFY = System.DateTime.Now; + } + + using (var tran = db.Ado.UseTran()) { + if (db.Updateable<TN_Location>(starloc).ExecuteCommand() <= 0) { + tran.RollbackTran(); + + info = $"浠诲姟{task.S_CODE}鍙栨秷澶辫触"; + + return BuildSimpleResult(0, info); + } + + if (endloc != null) { + if (db.Updateable<TN_Location>(endloc).ExecuteCommand() <= 0) { + tran.RollbackTran(); + + info = $"浠诲姟{task.S_CODE}鍙栨秷澶辫触"; + + return BuildSimpleResult(0, info); + } + } + + if (db.Updateable<TN_Task>(task).ExecuteCommand() <= 0) { + if (db.Updateable<TN_Location>(endloc).ExecuteCommand() <= 0) { + tran.RollbackTran(); + + info = $"浠诲姟{task.S_CODE}鍙栨秷澶辫触"; + + return BuildSimpleResult(0, info); + } + } + + tran.CommitTran(); + + info = $"浠诲姟{task.S_CODE}鍙栨秷鎴愬姛"; + + return BuildSimpleResult(0, info); + } + + } + else { + return BuildSimpleResult(3, $"鍙湁浠诲姟鍙风姸鎬佷负 绛夊緟 鎴�宸叉帹閫�鐨勪换鍔℃墠鑳藉彇娑�); + } + } catch (Exception ex) { return BuildSimpleResult(1, $"鍙戠敓浜嗗紓甯革細{ex.Message}"); @@ -496,8 +587,8 @@ var cntID = locCntrRel.S_CNTR_CODE; var task = WCSHelper.BuildTask(startLoc, endLoc, cntID, taskName); - LocationHelper.LockLoc(ref startLoc, 1); // 璧风偣鍑哄簱閿�- LocationHelper.LockLoc(ref endLoc, 2); // 缁堢偣鍏ュ簱閿�+ LocationHelper.LockLoc(ref startLoc, 2); // 璧风偣鍑哄簱閿�+ LocationHelper.LockLoc(ref endLoc, 1); // 缁堢偣鍏ュ簱閿� using (var tran = db.Ado.UseTran()) { if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new { @@ -559,8 +650,8 @@ var cntID = locCntrRel.S_CNTR_CODE; var task = WCSHelper.BuildTask(startLoc, endLoc, cntID, taskName); - LocationHelper.LockLoc(ref startLoc, 1); // 璧风偣鍑哄簱閿�- LocationHelper.LockLoc(ref endLoc, 2); // 缁堢偣鍏ュ簱閿�+ LocationHelper.LockLoc(ref startLoc, 2); // 璧风偣鍑哄簱閿�+ LocationHelper.LockLoc(ref endLoc, 1); // 缁堢偣鍏ュ簱閿� using (var tran = db.Ado.UseTran()) { if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new { diff --git a/api/ApiModel.cs b/api/ApiModel.cs index ae045d0..bc034a5 100644 --- a/api/ApiModel.cs +++ b/api/ApiModel.cs @@ -147,9 +147,11 @@ /// <summary> /// AGV灏忚溅鍙凤細NOTE 鍚庢湡鍙兘鐪佺暐锛屽洜涓哄彧鏈変竴杈嗚溅 /// </summary> - public string forklift_no { get; set; } + //public string forklift_no { get; set; } - public string endLoc { get; set; } + public string TaskNo { get; set; } + + public string EndLoc { get; set; } } /// <summary> @@ -167,6 +169,10 @@ public string endLoc { get; set; } } + public class CancelTaskInfo { + public string TaskNo { get; set; } + } + /// <summary> /// 浜у搧閮ㄥ垎鍑哄簱淇℃伅 /// </summary> diff --git a/api/DebugController.cs b/api/DebugController.cs index b113cf7..7f8d113 100644 --- a/api/DebugController.cs +++ b/api/DebugController.cs @@ -267,16 +267,34 @@ return "鎵句笉鍒板搴旂殑鐗╂枡淇℃伅"; } + var task = db.Queryable<TN_Task>() + .Where(t => t.S_CODE == model.TaskNo).First(); + + if (cgDetail == null) { + return "鎵句笉鍒板搴旂殑浠诲姟鍙�; + } + cgDetail.F_QTY = model.Weight; + task.F_WEIGHT = model.Weight; try { - if (db.Updateable<TN_CG_Detail>(cgDetail).UpdateColumns(it => it.F_QTY) + using (var tran = db.Ado.UseTran()) { + if (db.Updateable<TN_CG_Detail>(cgDetail).UpdateColumns(it => it.F_QTY) .ExecuteCommand() <= 0) { - return "淇敼澶辫触"; - } - return "淇敼鎴愬姛"; + tran.RollbackTran(); + return "淇敼澶辫触"; + } + if (db.Updateable<TN_Task>(task).UpdateColumns(it => it.F_WEIGHT).ExecuteCommand() <= 0) { + tran.RollbackTran(); + return "淇敼澶辫触"; + } + tran.CommitTran(); + } + LogHelper.Info($"妯℃嫙AGV浼犻�鐗╂枡閲嶉噺锛氫慨鏀逛换鍔″彿{task.S_CODE}閲嶉噺涓簕model.Weight}", "HosttoagvTask"); + return "淇敼鎴愬姛"; } + catch (Exception ex) { return ex.Message; diff --git a/api/MoboxController.cs b/api/MoboxController.cs index 153da7a..cae34ee 100644 --- a/api/MoboxController.cs +++ b/api/MoboxController.cs @@ -1,5 +1,7 @@ 锘縰sing System.Web.Http; +using HH.WCS.Mobox3.AnGang.wms; + using Newtonsoft.Json; using static HH.WCS.Mobox3.AnGang.api.ApiModel; @@ -29,7 +31,7 @@ /// <param name="model"></param> /// <returns></returns> [HttpPost] - [Route("SelectLocation")] + [Route("PDAFullInArea")] public SimpleResult SelectLocation(SelectLocationInfo model) { LogHelper.Info("瑙﹀彂API锛歅DA閫夋嫨缁堢偣璐т綅" + JsonConvert.SerializeObject(model), "API"); return ApiHelper.SelectLocation(model); @@ -60,40 +62,52 @@ } /// <summary> - /// 鍒涘缓鐩樼偣璁″垝鍗�WMS) + /// 鍙栨秷浠诲姟 /// </summary> /// <param name="model"></param> /// <returns></returns> [HttpPost] - [Route("CreateCountPlan")] - public SimpleResult CreateCountPlan(CreateCountPlanInfo model) { - LogHelper.Info("瑙﹀彂API锛氬垱寤虹洏鐐硅鍒掑崟(WMS)" + JsonConvert.SerializeObject(model), "API"); - return ApiHelper.CreateCountPlan(model); + [Route("CancelTask")] + public SimpleResult CancelTask(CancelTaskInfo model) { + LogHelper.Info("瑙﹀彂API锛氬彇娑堜换鍔� + JsonConvert.SerializeObject(model), "API"); + return ApiHelper.CancelTask(model); } - /// <summary> - /// 鍒涘缓鐩樼偣鍗�PDA) - /// </summary> - /// <param name="model"></param> - /// <returns></returns> - [HttpPost] - [Route("CreateCountOrder")] - public SimpleResult CreateCountOrder(CreateCountOrderInfo model) { - LogHelper.Info("瑙﹀彂API锛氬垱寤虹洏鐐瑰崟(PDA)" + JsonConvert.SerializeObject(model), "API"); - return ApiHelper.CreateCountOrder(model); - } + ///// <summary> + ///// 鍒涘缓鐩樼偣璁″垝鍗�WMS) + ///// </summary> + ///// <param name="model"></param> + ///// <returns></returns> + //[HttpPost] + //[Route("CreateCountPlan")] + //public SimpleResult CreateCountPlan(CreateCountPlanInfo model) { + // LogHelper.Info("瑙﹀彂API锛氬垱寤虹洏鐐硅鍒掑崟(WMS)" + JsonConvert.SerializeObject(model), "API"); + // return ApiHelper.CreateCountPlan(model); + //} - /// <summary> - /// 鐩樼偣鐞嗚揣(PDA) - /// </summary> - /// <param name="model"></param> - /// <returns></returns> - [HttpPost] - [Route("CountProduct")] - public SimpleResult CountProduct(CountProductInfo model) { - LogHelper.Info("瑙﹀彂API锛氱洏鐐圭悊璐�PDA)" + JsonConvert.SerializeObject(model), "API"); - return ApiHelper.CountProduct(model); - } + ///// <summary> + ///// 鍒涘缓鐩樼偣鍗�PDA) + ///// </summary> + ///// <param name="model"></param> + ///// <returns></returns> + //[HttpPost] + //[Route("CreateCountOrder")] + //public SimpleResult CreateCountOrder(CreateCountOrderInfo model) { + // LogHelper.Info("瑙﹀彂API锛氬垱寤虹洏鐐瑰崟(PDA)" + JsonConvert.SerializeObject(model), "API"); + // return ApiHelper.CreateCountOrder(model); + //} + + ///// <summary> + ///// 鐩樼偣鐞嗚揣(PDA) + ///// </summary> + ///// <param name="model"></param> + ///// <returns></returns> + //[HttpPost] + //[Route("CountProduct")] + //public SimpleResult CountProduct(CountProductInfo model) { + // LogHelper.Info("瑙﹀彂API锛氱洏鐐圭悊璐�PDA)" + JsonConvert.SerializeObject(model), "API"); + // return ApiHelper.CountProduct(model); + //} ///// <summary> ///// 鐩樼偣鐞嗚揣鍑哄簱(WMS) @@ -107,16 +121,16 @@ // return ApiHelper.CheckOutbound(model); //} - /// <summary> - /// 鐩樼偣鐞嗚揣鍥炲簱(WMS) - /// </summary> - /// <param name="model"></param> - /// <returns></returns> - [HttpPost] - [Route("CheckInbound")] - public SimpleResult CheckInbound(CheckInboundInfo model) { - LogHelper.Info("瑙﹀彂API锛氱洏鐐圭悊璐у洖搴�WMS)" + JsonConvert.SerializeObject(model), "API"); - return ApiHelper.CheckInbound(model); - } + ///// <summary> + ///// 鐩樼偣鐞嗚揣鍥炲簱(WMS) + ///// </summary> + ///// <param name="model"></param> + ///// <returns></returns> + //[HttpPost] + //[Route("CheckInbound")] + //public SimpleResult CheckInbound(CheckInboundInfo model) { + // LogHelper.Info("瑙﹀彂API锛氱洏鐐圭悊璐у洖搴�WMS)" + JsonConvert.SerializeObject(model), "API"); + // return ApiHelper.CheckInbound(model); + //} } } diff --git a/core/Monitor.cs b/core/Monitor.cs index 169c2db..ec87521 100644 --- a/core/Monitor.cs +++ b/core/Monitor.cs @@ -87,8 +87,8 @@ var cntId = detail.S_CNTR_CODE; var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, taskName); - LocationHelper.LockLoc(ref startLoc, 1); // 璧风偣鍑哄簱閿�- LocationHelper.LockLoc(ref endLoc, 2); // 缁堢偣鍏ュ簱閿�+ LocationHelper.LockLoc(ref startLoc, 2); // 璧风偣鍑哄簱閿�+ LocationHelper.LockLoc(ref endLoc, 1); // 缁堢偣鍏ュ簱閿� using (var tran = db.Ado.UseTran()) { if (db.Updateable<TN_Count_CG_Detail>(detail).UpdateColumns(it => it.N_B_STATE).ExecuteCommand() <= 0) { diff --git a/core/WCSCore.cs b/core/WCSCore.cs index cd27dda..61e832b 100644 --- a/core/WCSCore.cs +++ b/core/WCSCore.cs @@ -74,7 +74,7 @@ if (TN_Task.S_TYPE == TaskName.浜у搧鍏ュ簱 || TN_Task.S_TYPE == TaskName.浜у搧閮ㄥ垎鍥炲簱) { var captureTask = Task.Run(() => { CapturePic(TN_Task); - LogHelper.Info("鎷嶇収Task缁撴潫"); + LogHelper.Info($"{TN_Task}锛氭媿鐓ask缁撴潫"); }); } @@ -170,10 +170,27 @@ else { var weight = float.Parse(data[0].parameter_varchar200_up); cgDetail.F_QTY = weight; + tn_task.F_WEIGHT = weight; - if (db.Updateable<TN_CG_Detail>(cgDetail).UpdateColumns(it => it.F_QTY).ExecuteCommand() <= 0) { - LogHelper.Info("淇敼鐗╂枡琛ㄩ噸閲忓け璐�); - return; + using (var tran = db.Ado.UseTran()) { + if (db.Updateable<TN_CG_Detail>(cgDetail).UpdateColumns(it => it.F_QTY).ExecuteCommand() <= 0) { + tran.RollbackTran(); + LogHelper.Info("淇敼鐗╂枡琛ㄩ噸閲忓け璐�); + return; + } + + if (db.Updateable<TN_Task>(tn_task).UpdateColumns(it => it.F_WEIGHT).ExecuteCommand() <= 0) { + tran.RollbackTran(); + LogHelper.Info("淇敼浠诲姟琛ㄩ噸閲忓け璐�); + return; + } + + tran.CommitTran(); + } + + LogHelper.Info($"淇敼浠诲姟鍙穥tn_task.S_CODE}鐗╂枡閲嶉噺涓簕weight}", "HosttoagvTask"); + if (weight > 2000) { + LogHelper.Info($"鐗╂枡閲嶉噺瓒呰繃2t", "HosttoagvTask"); } } @@ -189,16 +206,23 @@ } // 鍙綋涔嬪墠鎸囧畾缁堢偣璐ф灦鍚庯紝鎵嶅皾璇曡绠楃粓鐐硅揣浣�- if (cgDetail.F_QTY > 1500) { - // 閲嶉噺瓒呰繃1.5t锛岄渶瑕侀�鎷�-3灞傝揣鏋�+ if (cgDetail.F_QTY > 2000) { + // 閲嶉噺瓒呰繃 2t + endLoc = null; + LogHelper.Info("閲嶉噺瓒呰繃2t锛屼笉鍏佽鍏ュ簱"); + return; + } + else if (cgDetail.F_QTY > 1500) { + // 閲嶉噺瓒呰繃1.5t锛岄渶瑕侀�鎷�-2灞傝揣鏋� endLoc = db.Queryable<TN_Location>() - .First(a => a.N_ROW == row && a.N_LAYER <= 3 + .First(a => a.N_ROW == row && a.N_LAYER <= 2 && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y"); } else if (cgDetail.F_QTY > 0) { // 閲嶉噺鏈秴杩�.5t锛屽湪鎸囧畾璐ф灦闅忎究閫夋嫨1涓�- endLoc = db.Queryable<TN_Location>().First(a => a.N_ROW == row - && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y"); + endLoc = db.Queryable<TN_Location>().Where(a => a.N_ROW == row + && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃� && a.C_ENABLE == "Y") + .OrderBy(a => a.N_LAYER > 2 ? 0 : 1).First(); // 浼樺厛閫夊眰绾ч珮鐨� } else { // 娌℃湁鎺ユ敹鍒伴噸閲忥紝鎴栭噸閲忓嚭閿�@@ -290,6 +314,8 @@ return; } + LogHelper.Info($"淇敼浠诲姟鍙穥tn_task.S_CODE}鐗╂枡閲嶉噺涓簕weight}", "HosttoagvTask"); + } catch (Exception ex) { LogHelper.Info($"鍙戠敓浜嗛敊璇細{ex.Message}"); diff --git a/device/SnapDevice.cs b/device/SnapDevice.cs index 62ae44f..c465b81 100644 --- a/device/SnapDevice.cs +++ b/device/SnapDevice.cs @@ -7,14 +7,14 @@ using System.Text; using System.Threading.Tasks; -using NetSDKCS; +//using NetSDKCS; // TODO SNAP namespace HH.WCS.Mobox3.AnGang.device { public class SnapDevice { private IntPtr _LoginID = IntPtr.Zero; private IntPtr _PlayID = IntPtr.Zero; //private fSnapRevCallBack _SnapRevCallBack; - private NET_DEVICEINFO_Ex _DeviceInfo = new NET_DEVICEINFO_Ex(); + //private NET_DEVICEINFO_Ex _DeviceInfo = new NET_DEVICEINFO_Ex(); // TODO SNAP private bool _IsSpanCapture = false; //private List<int> _channalList = new List<int>(); @@ -23,7 +23,7 @@ public SnapDevice() { try { //_SnapRevCallBack = new fSnapRevCallBack(SnapRevCallBack); - NETClient.Init(null, IntPtr.Zero, null); + //NETClient.Init(null, IntPtr.Zero, null); // TODO SNAP //NETClient.SetSnapRevCallBack(_SnapRevCallBack, IntPtr.Zero); } catch (Exception ex) { @@ -32,132 +32,134 @@ } ~SnapDevice() { - NETClient.Cleanup(); + //NETClient.Cleanup(); // TODO SNAP } - public void LoadInfo(Config.Snap snap) { - LoadInfo(snap.Ip, snap.Port, snap.Name, snap.Pwd); - } + //public void LoadInfo(Config.Snap snap) { + // LoadInfo(snap.Ip, snap.Port, snap.Name, snap.Pwd); + //} - public void LoadInfo(string ip, int port, string name, string pwd) { - if (IntPtr.Zero == _LoginID) { - ushort uPort = 0; - try { - uPort = Convert.ToUInt16(port); - } - catch { - LogHelper.Info("鍔犺浇Snap锛氱鍙e彿鏍煎紡閿欒"); - return; - } - _LoginID = NETClient.LoginWithHighLevelSecurity(ip, uPort, name, pwd, EM_LOGIN_SPAC_CAP_TYPE.TCP, IntPtr.Zero, ref _DeviceInfo); - if (IntPtr.Zero == _LoginID) { - LogHelper.Info("鐩告満鍒濆鍖栭敊璇細" + NETClient.GetLastError()); - return; - } - //_channalList.Clear(); - //for (int i = 0; i < _DeviceInfo.nChanNum; i++) { - // _channalList.Add(i + 1); - //} - _channalMax = _DeviceInfo.nChanNum; - } - else { - NETClient.Logout(_LoginID); - _LoginID = IntPtr.Zero; - if (_IsSpanCapture) { - _IsSpanCapture = false; + // TODO SNAP + + //public void LoadInfo(string ip, int port, string name, string pwd) { + // if (IntPtr.Zero == _LoginID) { + // ushort uPort = 0; + // try { + // uPort = Convert.ToUInt16(port); + // } + // catch { + // LogHelper.Info("鍔犺浇Snap锛氱鍙e彿鏍煎紡閿欒"); + // return; + // } + // _LoginID = NETClient.LoginWithHighLevelSecurity(ip, uPort, name, pwd, EM_LOGIN_SPAC_CAP_TYPE.TCP, IntPtr.Zero, ref _DeviceInfo); + // if (IntPtr.Zero == _LoginID) { + // LogHelper.Info("鐩告満鍒濆鍖栭敊璇細" + NETClient.GetLastError()); + // return; + // } + // //_channalList.Clear(); + // //for (int i = 0; i < _DeviceInfo.nChanNum; i++) { + // // _channalList.Add(i + 1); + // //} + // _channalMax = _DeviceInfo.nChanNum; + // } + // else { + // NETClient.Logout(_LoginID); + // _LoginID = IntPtr.Zero; + // if (_IsSpanCapture) { + // _IsSpanCapture = false; - } - } - } + // } + // } + //} - public bool SnapPictureToFileOK(ref string filePath, int channelIndex = 0) { - if (channelIndex >= _channalMax) { - LogHelper.Info($"閫氶亾鏁�'{channelIndex}' 瓒呭嚭閫氶亾鎬绘暟 '{_channalMax}'"); - //filePath = string.Empty; - return false; - } + //public bool SnapPictureToFileOK(ref string filePath, int channelIndex = 0) { + // if (channelIndex >= _channalMax) { + // LogHelper.Info($"閫氶亾鏁�'{channelIndex}' 瓒呭嚭閫氶亾鎬绘暟 '{_channalMax}'"); + // //filePath = string.Empty; + // return false; + // } - //DateTime now = DateTime.Now; - //string path = AppDomain.CurrentDomain.BaseDirectory + "image"; - //string fileName = string.Format("{0}{1}{2}{3}{4}{5}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) + ".jpg"; - //filePath = path + "\\" + fileName; + // //DateTime now = DateTime.Now; + // //string path = AppDomain.CurrentDomain.BaseDirectory + "image"; + // //string fileName = string.Format("{0}{1}{2}{3}{4}{5}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) + ".jpg"; + // //filePath = path + "\\" + fileName; - NET_SNAP_PARAMS asyncSnap = new NET_SNAP_PARAMS(); - //asyncSnap.Channel = (uint)this._channalList[channelIndex]; - asyncSnap.Channel = (uint)channelIndex; - asyncSnap.Quality = 6; - asyncSnap.ImageSize = 2; - asyncSnap.mode = 0; - asyncSnap.InterSnap = 0; + // NET_SNAP_PARAMS asyncSnap = new NET_SNAP_PARAMS(); + // //asyncSnap.Channel = (uint)this._channalList[channelIndex]; + // asyncSnap.Channel = (uint)channelIndex; + // asyncSnap.Quality = 6; + // asyncSnap.ImageSize = 2; + // asyncSnap.mode = 0; + // asyncSnap.InterSnap = 0; - NET_IN_SNAP_PIC_TO_FILE_PARAM inParam = new NET_IN_SNAP_PIC_TO_FILE_PARAM { - dwSize = (uint)Marshal.SizeOf(typeof(NET_IN_SNAP_PIC_TO_FILE_PARAM)), - stuParam = asyncSnap, - szFilePath = filePath, - }; + // NET_IN_SNAP_PIC_TO_FILE_PARAM inParam = new NET_IN_SNAP_PIC_TO_FILE_PARAM { + // dwSize = (uint)Marshal.SizeOf(typeof(NET_IN_SNAP_PIC_TO_FILE_PARAM)), + // stuParam = asyncSnap, + // szFilePath = filePath, + // }; - NET_OUT_SNAP_PIC_TO_FILE_PARAM outParam = new NET_OUT_SNAP_PIC_TO_FILE_PARAM() { - dwSize = (uint)Marshal.SizeOf(typeof(NET_OUT_SNAP_PIC_TO_FILE_PARAM)), - dwPicBufLen = 1024000, - szPicBuf = Marshal.AllocHGlobal(1024000), - }; + // NET_OUT_SNAP_PIC_TO_FILE_PARAM outParam = new NET_OUT_SNAP_PIC_TO_FILE_PARAM() { + // dwSize = (uint)Marshal.SizeOf(typeof(NET_OUT_SNAP_PIC_TO_FILE_PARAM)), + // dwPicBufLen = 1024000, + // szPicBuf = Marshal.AllocHGlobal(1024000), + // }; - bool ret = NETClient.SnapPictureToFile(_LoginID, ref inParam, ref outParam, 1000); - if (!ret) { - LogHelper.Info("鎶撳浘澶辫触"); - } - return ret; - } + // bool ret = NETClient.SnapPictureToFile(_LoginID, ref inParam, ref outParam, 1000); + // if (!ret) { + // LogHelper.Info("鎶撳浘澶辫触"); + // } + // return ret; + //} - public bool SnapPictureOk(int channelIndex = 0) { - if (channelIndex >= _channalMax) { - LogHelper.Info($"閫氶亾鏁�'{channelIndex}' 瓒呭嚭閫氶亾鎬绘暟 '{_channalMax}'"); - return false; - } + //public bool SnapPictureOk(int channelIndex = 0) { + // if (channelIndex >= _channalMax) { + // LogHelper.Info($"閫氶亾鏁�'{channelIndex}' 瓒呭嚭閫氶亾鎬绘暟 '{_channalMax}'"); + // return false; + // } - NET_SNAP_PARAMS asyncSnap = new NET_SNAP_PARAMS(); - //asyncSnap.Channel = (uint)this._channalList[channelIndex]; - asyncSnap.Channel = (uint)channelIndex; - asyncSnap.Quality = 6; - asyncSnap.ImageSize = 2; - asyncSnap.mode = 0; - asyncSnap.InterSnap = 0; - bool ret = NETClient.SnapPictureEx(_LoginID, asyncSnap, IntPtr.Zero); - if (!ret) { - LogHelper.Info(NETClient.GetLastError()); - return false; - } - return true; - } + // NET_SNAP_PARAMS asyncSnap = new NET_SNAP_PARAMS(); + // //asyncSnap.Channel = (uint)this._channalList[channelIndex]; + // asyncSnap.Channel = (uint)channelIndex; + // asyncSnap.Quality = 6; + // asyncSnap.ImageSize = 2; + // asyncSnap.mode = 0; + // asyncSnap.InterSnap = 0; + // bool ret = NETClient.SnapPictureEx(_LoginID, asyncSnap, IntPtr.Zero); + // if (!ret) { + // LogHelper.Info(NETClient.GetLastError()); + // return false; + // } + // return true; + //} - private void SnapRevCallBack(IntPtr lLoginID, IntPtr pBuf, uint RevLen, uint EncodeType, uint CmdSerial, IntPtr dwUser) { - string path = AppDomain.CurrentDomain.BaseDirectory + "image"; - if (!Directory.Exists(path)) { - Directory.CreateDirectory(path); - } - if (EncodeType == 10) //.jpg - { - DateTime now = DateTime.Now; - string fileName = string.Format("{0}-{1}-{2}-{3}-{4}-{5}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) + ".jpg"; - string filePath = path + "\\" + fileName; - byte[] data = new byte[RevLen]; - Marshal.Copy(pBuf, data, 0, (int)RevLen); - try { - //when the file is operate by local capture will throw expection. - using (FileStream stream = new FileStream(filePath, FileMode.OpenOrCreate)) { - stream.Write(data, 0, (int)RevLen); - stream.Flush(); - stream.Dispose(); - } - } - catch (Exception ex) { - LogHelper.Info($"鍙戠敓浜嗗紓甯革細{ex.Message}"); - return; - } - // 鏇夸唬Demo绋嬪簭鐨凢rame鍥剧墖灞曠ず - LogHelper.Info($"淇濆瓨鍥剧墖鍒帮細{filePath}"); - Process.Start(filePath); - } - } + //private void SnapRevCallBack(IntPtr lLoginID, IntPtr pBuf, uint RevLen, uint EncodeType, uint CmdSerial, IntPtr dwUser) { + // string path = AppDomain.CurrentDomain.BaseDirectory + "image"; + // if (!Directory.Exists(path)) { + // Directory.CreateDirectory(path); + // } + // if (EncodeType == 10) //.jpg + // { + // DateTime now = DateTime.Now; + // string fileName = string.Format("{0}-{1}-{2}-{3}-{4}-{5}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) + ".jpg"; + // string filePath = path + "\\" + fileName; + // byte[] data = new byte[RevLen]; + // Marshal.Copy(pBuf, data, 0, (int)RevLen); + // try { + // //when the file is operate by local capture will throw expection. + // using (FileStream stream = new FileStream(filePath, FileMode.OpenOrCreate)) { + // stream.Write(data, 0, (int)RevLen); + // stream.Flush(); + // stream.Dispose(); + // } + // } + // catch (Exception ex) { + // LogHelper.Info($"鍙戠敓浜嗗紓甯革細{ex.Message}"); + // return; + // } + // // 鏇夸唬Demo绋嬪簭鐨凢rame鍥剧墖灞曠ず + // LogHelper.Info($"淇濆瓨鍥剧墖鍒帮細{filePath}"); + // Process.Start(filePath); + // } + //} } } diff --git a/device/SnapManager.cs b/device/SnapManager.cs index 3a647a3..fd494b6 100644 --- a/device/SnapManager.cs +++ b/device/SnapManager.cs @@ -11,21 +11,24 @@ if (_snapDevice == null) { _snapDevice = new SnapDevice(); } - _snapDevice.LoadInfo(snap); + //_snapDevice.LoadInfo(snap); // TODO SNAP } public static string GetCapturePicturePath() { - DateTime now = DateTime.Now; - string path = Settings.CaptureUrl; - string fileName = string.Format("{0}{1}{2}{3}{4}{5}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) + ".jpg"; - string filePath = path + "\\" + fileName; + //DateTime now = DateTime.Now; + //string path = Settings.CaptureUrl; + //string fileName = string.Format("{0}{1}{2}{3}{4}{5}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) + ".jpg"; + //string filePath = path + "\\" + fileName; - if (_snapDevice.SnapPictureToFileOK(ref filePath)) { - return filePath; - } - else { - return string.Empty; - } + //if (_snapDevice.SnapPictureToFileOK(ref filePath)) { + // return filePath; + //} + //else { + // return string.Empty; + //} + + // TODO SNAP + return string.Empty; } } } diff --git a/util/Settings.cs b/util/Settings.cs index 20b169b..4072f54 100644 --- a/util/Settings.cs +++ b/util/Settings.cs @@ -19,7 +19,7 @@ public static int TCPServerPort { get; set; } //public static List<Config.Area> Areas { get; set; } public static List<List<string>> Areas { get; set; } = new List<List<string>>(); - public static List<Config.Snap> Snaps { get; set; } + public static List<Config.Snap> Snaps { get; set; } = new List<Config.Snap>(); public static string CaptureUrl { get; set; } /// <summary> diff --git a/wms/LocationHelper.cs b/wms/LocationHelper.cs index 50e1f21..38184c6 100644 --- a/wms/LocationHelper.cs +++ b/wms/LocationHelper.cs @@ -135,11 +135,10 @@ } /// <summary> - /// 鍏ュ簱閿佸畾缁堢偣锛屽嚭搴撻攣瀹氳捣鐐�- /// 浣犲垱寤轰换鍔¢攣瀹氳揣浣嶇殑鏃跺�锛屾妸閿佺殑鏉ユ簮灏辨槸浠诲姟鍙蜂篃鍐欎笂鍘伙紙鍔犻攣鐨勬柟娉曞姞涓弬鏁帮紝鍙┖鐨勫弬鏁帮級锛岃В閿佺殑鏃跺�鎶婃潵婧愮疆绌恒� + /// 璧风偣鍑哄簱閿侊細2 --- 缁堢偣鍏ュ簱閿侊細1 /// </summary> /// <param name="loc"></param> - /// <param name="lockState">1:鍏ュ簱閿併�2:鍑哄簱閿併�2:鍏跺畠閿�/param> + /// <param name="lockState">1:鍏ュ簱閿併�2:鍑哄簱閿併�3:鍏跺畠閿�/param> /// <param name="lockSource">閿佺殑鏉ユ簮=浠诲姟鍙�/param> /// <returns></returns> public static bool LockLoc(ref TN_Location loc, int lockState, string lockSource = "") { @@ -160,7 +159,7 @@ /// 浣犲垱寤轰换鍔¢攣瀹氳揣浣嶇殑鏃跺�锛屾妸閿佺殑鏉ユ簮灏辨槸浠诲姟鍙蜂篃鍐欎笂鍘伙紙鍔犻攣鐨勬柟娉曞姞涓弬鏁帮紝鍙┖鐨勫弬鏁帮級锛岃В閿佺殑鏃跺�鎶婃潵婧愮疆绌恒� /// </summary> /// <param name="loc"></param> - /// <param name="lockState">1:鍏ュ簱閿併�2:鍑哄簱閿併�2:鍏跺畠閿�/param> + /// <param name="lockState">1:鍏ュ簱閿併�2:鍑哄簱閿併�3:鍏跺畠閿�/param> /// <param name="lockSource">閿佺殑鏉ユ簮=浠诲姟鍙�/param> /// <returns></returns> public static bool LockLoc(string loc, int lockState, string lockSource = "") -- Gitblit v1.9.1