From 31ede0734942598bc3b3f6e7527f31c842c2c5b4 Mon Sep 17 00:00:00 2001 From: liuwf Date: Fri, 11 Oct 2024 17:27:26 +0800 Subject: [PATCH] =?UTF-8?q?change-=E5=8E=BB=E9=99=A4=E6=9C=AC=E5=9C=B0sqli?= =?UTF-8?q?te=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9A=84=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.Business/ProdCompletionBusiness.cs | 8 +- SlnMesnac.Business/ProdMgmtBusiness.cs | 128 ++++++----- SlnMesnac.Config/DebugConfig.cs | 9 + SlnMesnac.Model/domain/WcsTaskManual.cs | 203 ++++++++++++++++++ SlnMesnac.WPF/MainWindow.xaml | 9 +- SlnMesnac.WPF/Page/DevMonitorPage.xaml.cs | 9 +- SlnMesnac.WPF/Page/ManualDeliveryWindow.xaml | 4 +- .../ViewModel/MainWindowViewModel.cs | 15 +- 8 files changed, 317 insertions(+), 68 deletions(-) create mode 100644 SlnMesnac.Model/domain/WcsTaskManual.cs diff --git a/SlnMesnac.Business/ProdCompletionBusiness.cs b/SlnMesnac.Business/ProdCompletionBusiness.cs index 2d54e03..aa5ff75 100644 --- a/SlnMesnac.Business/ProdCompletionBusiness.cs +++ b/SlnMesnac.Business/ProdCompletionBusiness.cs @@ -262,7 +262,7 @@ namespace SlnMesnac.Business if (plc == null) { - _logger.LogInformation("读取小包出口信号,PLC连接信息为空......"); + _logger.LogInformation("2F读取小包出口信号,PLC连接信息为空......"); Thread.Sleep(3000); continue; } @@ -271,7 +271,7 @@ namespace SlnMesnac.Business if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("2楼小包出口到位信号"))) { - _logger.LogInformation("等待小包出口信号触发......"); + // _logger.LogInformation("等待小包出口信号触发......"); Thread.Sleep(5000); continue; } @@ -280,7 +280,7 @@ namespace SlnMesnac.Business if (!string.IsNullOrWhiteSpace(rfid)) { - _logger.LogInformation("小包出口已经有RFID了,无需再读"); + //_logger.LogInformation("小包出口已经有RFID了,无需再读"); Thread.Sleep(5000); continue; } @@ -331,7 +331,7 @@ namespace SlnMesnac.Business continue; } - RefreshMessage($"小包出口读取到RFID条码{epcStr},开始绑定流程:"); + RefreshMessage($"2F小包出口读取到RFID条码{epcStr},开始绑定流程:"); _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); if (productPlanDto == null) diff --git a/SlnMesnac.Business/ProdMgmtBusiness.cs b/SlnMesnac.Business/ProdMgmtBusiness.cs index b5be52e..94e3a9d 100644 --- a/SlnMesnac.Business/ProdMgmtBusiness.cs +++ b/SlnMesnac.Business/ProdMgmtBusiness.cs @@ -85,7 +85,7 @@ namespace SlnMesnac.Business _configInfoBusiness = configInfoBusiness; - TestTran(); + // TestTran(); } @@ -93,7 +93,7 @@ namespace SlnMesnac.Business public void TestTran() { - + //try //{ // sqlSugarClient.AsTenant().BeginTran(); @@ -204,34 +204,48 @@ namespace SlnMesnac.Business continue; } - MesProductPlan prodPlan = _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); - if (prodPlan == null || productPlanDto == null) + if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("璁惧鍙枡"))) { - //throw new ArgumentException($"鏈幏鍙栧埌闇瑕佹墽琛岀殑鐢熶骇璁″垝"); - RefreshMessage($"鏈幏鍙栧埌闇瑕佹墽琛岀殑鐢熶骇璁″垝"); + // RefreshMessage("3F绛夊緟璁惧鍙枡淇″彿瑙﹀彂......"); Thread.Sleep(5000); continue; } - - BaseRealTask task = _baseRealTaskService.GetExeTask(); - if (task != null) + MesProductPlan prodPlan = _mesProductPlanService.GetStartedProdPlan(out MesProductPlanDto productPlanDto); + if (prodPlan == null || productPlanDto == null) { - RefreshMessage("宸茬粡鍙枡锛岃绛夊緟AGV閫佹枡......"); - + //throw new ArgumentException($"鏈幏鍙栧埌闇瑕佹墽琛岀殑鐢熶骇璁″垝"); + RefreshMessage($"3F鏈幏鍙栧埌闇瑕佹墽琛岀殑鐢熶骇璁″垝"); Thread.Sleep(5000); continue; } + + - if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("璁惧鍙枡"))) + WcsTaskManual wcsTaskManual = sqlSugarClient.AsTenant().GetConnection("mes").Queryable().Where(x=>x.TaskType==999).First(); + WcsTask wcsTask = sqlSugarClient.AsTenant().GetConnection("mes").Queryable().Where(x=>x.NextPointId==9 && x.TaskType==41).First(); + if(wcsTaskManual!=null || wcsTask != null) { - RefreshMessage("绛夊緟璁惧鍙枡淇″彿瑙﹀彂......"); + RefreshMessage("3F宸茬粡鍙枡锛岃绛夊緟AGV閫佹枡......"); + Thread.Sleep(5000); continue; } - RefreshMessage("璁惧瑕佹枡淇″彿瑙﹀彂鎴愬姛"); + + //BaseRealTask task = _baseRealTaskService.GetExeTask(); + //if (task != null) + //{ + // RefreshMessage("宸茬粡鍙枡锛岃绛夊緟AGV閫佹枡......"); + + // Thread.Sleep(5000); + // continue; + //} + + + + RefreshMessage("3F璁惧瑕佹枡淇″彿瑙﹀彂鎴愬姛"); RefreshProdPlanExecEvent?.Invoke(prodPlan); @@ -253,17 +267,17 @@ namespace SlnMesnac.Business if (ApplyDeliveryHandle(wmsRaw.rawOutstockId.ToString())) { - RefreshMessage("鏍规嵁璁″垝鑷姩鐢宠鍙枡鎴愬姛"); + RefreshMessage("3F鏍规嵁璁″垝鑷姩鐢宠鍙枡鎴愬姛"); #region 鏈湴鍒涘缓涓涓彨鏂欎换鍔 - BaseRealTask realTask = new BaseRealTask(); - realTask.PlanCode = prodPlan.PlanCode; - realTask.PlanAmount = prodPlan.PlanAmount; - realTask.PlanComplete = prodPlan.CompleteAmount; - realTask.MaterialId = prodPlan.MaterialId; - realTask.Status = 1; - realTask.CreateTime = DateTime.Now; - realTask.UpdateTime = DateTime.Now; - _baseRealTaskService.InsertTask(realTask); + //BaseRealTask realTask = new BaseRealTask(); + //realTask.PlanCode = prodPlan.PlanCode; + //realTask.PlanAmount = prodPlan.PlanAmount; + //realTask.PlanComplete = prodPlan.CompleteAmount; + //realTask.MaterialId = prodPlan.MaterialId; + //realTask.Status = 1; + //realTask.CreateTime = DateTime.Now; + //realTask.UpdateTime = DateTime.Now; + //_baseRealTaskService.InsertTask(realTask); #endregion plc.writeBoolByAddress(GetPlcAddressByConfigKey("璁惧鍙枡"), false); } @@ -297,34 +311,44 @@ namespace SlnMesnac.Business //mes璁″垝 MesProductPlan prodPlan = null; //鏈湴鍙枡浠诲姟 - BaseRealTask localPlan = null; + // BaseRealTask localPlan = null; try { - localPlan = _baseRealTaskService.GetExeTask(); + // localPlan = _baseRealTaskService.GetExeTask(); - if (localPlan == null) - { - RefreshMessage("鏈湴鏈幏鍙栧埌鍙枡浠诲姟......"); - Thread.Sleep(3000); - continue; - } + //if (localPlan == null) + //{ + // RefreshMessage("鏈湴鏈幏鍙栧埌鍙枡浠诲姟......"); + // Thread.Sleep(3000); + // continue; + //} if (plc == null) { - RefreshMessage("璇诲彇鐗╂枡鍒颁綅淇″彿,PLC杩炴帴淇℃伅涓虹┖......"); + // RefreshMessage("璇诲彇鐗╂枡鍒颁綅淇″彿,PLC杩炴帴淇℃伅涓虹┖......"); Thread.Sleep(3000); continue; } - + //鍒ゆ柇璇锋眰缈昏浆淇″彿 if (!plc.readBoolByAddress(GetPlcAddressByConfigKey("鐗╂枡鍒颁綅"))) { - RefreshMessage("绛夊緟鐗╂枡鍒颁綅淇″彿瑙﹀彂......"); + // RefreshMessage("绛夊緟鐗╂枡鍒颁綅淇″彿瑙﹀彂......"); Thread.Sleep(3000); continue; } + + WcsTask wcsTask = sqlSugarClient.AsTenant().GetConnection("mes").Queryable().Where(x => x.NextPointId == 9 && (x.TaskType == 41 || x.TaskType == 42)).First(); + if (wcsTask == null) + { + RefreshMessage("3F鍒颁綅淇″彿瑙﹀彂,浣嗘槸鏈娴嬪埌鏈夊師鏉愭枡鍑哄簱浠诲姟......"); + Thread.Sleep(5000); + continue; + } + + // TODO 鎶曟枡鏃堕棿鏍¢獙 bool timeCheck = JudgeProductTime(); if (!timeCheck) @@ -332,13 +356,13 @@ namespace SlnMesnac.Business Thread.Sleep(1000 * 15); continue; } - RefreshMessage($"鎶曟枡鏃堕棿鏍¢獙閫氳繃"); + RefreshMessage($"3F鎶曟枡鏃堕棿鏍¢獙閫氳繃"); // 璋冪敤璋冨害鎺ュ彛锛屽垽鏂瑼GV灏忚溅鏄惁宸茬粡绂诲紑鍒颁綅锛屽惁鍒欎笉鍏佽鎶曟枡 bool positionCheck = JudgeAgvPosition(); if (!positionCheck) { - RefreshMessage($"鏀跺埌鐗╂枡鍒颁綅淇″彿,浣嗘槸AGV杩樻湭绂诲紑,绂佹鎶曟枡"); + RefreshMessage($"3F鏀跺埌鐗╂枡鍒颁綅淇″彿,浣嗘槸AGV杩樻湭绂诲紑,绂佹鎶曟枡"); Thread.Sleep(1000 * 5); continue; } @@ -348,7 +372,7 @@ namespace SlnMesnac.Business if (productPlanDto == null || prodPlan == null) { - RefreshMessage($"鏀跺埌鐗╂枡鍒颁綅淇″彿,鏈幏鍙栧埌姝e湪鎵ц鐨勭敓浜ц鍒,璇峰紑濮嬫墽琛岃鍒"); + RefreshMessage($"3F鏀跺埌鐗╂枡鍒颁綅淇″彿,鏈幏鍙栧埌姝e湪鎵ц鐨勭敓浜ц鍒,璇峰紑濮嬫墽琛岃鍒"); Thread.Sleep(5000); continue; @@ -396,21 +420,17 @@ namespace SlnMesnac.Business sqlSugarClient.AsTenant().BeginTran(); //1.瀹屾垚鏈湴璁″垝 - if (localPlan != null) - { - List localList = _baseRealTaskService.Query(x => x.Status != 2); - foreach (var item in localList) - { - item.Status = 2; - item.UpdateTime = DateTime.Now; - } - sqlSugarClient.AsTenant().GetConnection("local").Updateable(localList).ExecuteCommand(); - //localPlan.Status = 2; - //localPlan.UpdateTime = DateTime.Now; - //sqlSugarClient.AsTenant().GetConnection("local").Updateable(localPlan).ExecuteCommand(); - - - } + //if (localPlan != null) + //{ + // List localList = _baseRealTaskService.Query(x => x.Status != 2); + // foreach (var item in localList) + // { + // item.Status = 2; + // item.UpdateTime = DateTime.Now; + // } + // sqlSugarClient.AsTenant().GetConnection("local").Updateable(localList).ExecuteCommand(); + + //} //2.鐢熸垚灏忓寘鏉$爜 GenerateBarcode(40); @@ -604,7 +624,7 @@ namespace SlnMesnac.Business } else { - RefreshMessage($"鏀跺埌鐗╂枡鍒颁綅璇锋眰鎶曟枡淇″彿,浣嗘槸璺濈涓婃鎶曟枡涓嶆弧20min,绂佹鎶曟枡"); + RefreshMessage($"鏀跺埌鐗╂枡鍒颁綅璇锋眰鎶曟枡淇″彿,鎶曟枡闂撮殧锛歿IntervalMin}min,璺濅笂娆℃姇鏂:{systemRunTime}min,绂佹鎶曟枡"); return false; } } diff --git a/SlnMesnac.Config/DebugConfig.cs b/SlnMesnac.Config/DebugConfig.cs index a84d94d..df66cde 100644 --- a/SlnMesnac.Config/DebugConfig.cs +++ b/SlnMesnac.Config/DebugConfig.cs @@ -110,6 +110,15 @@ namespace SlnMesnac.Config set { iniHelper.IniWriteValue("system", "SpiralTwoTime", value); } } + /// + ///3F鎶曟枡鐢熶骇妯″紡锛岄粯璁ゆ墜鍔紝1-鎵嬪姩妯″紡锛2-鑷姩妯″紡 + /// + public string ProductMode + { + get { return iniHelper.IniReadValue("system", "ProductMode"); } + set { iniHelper.IniWriteValue("system", "ProductMode", value); } + } + /// ///鏃犺鍒掓椂锛屾寜鐓ф棤璁″垝璁㈠崟澶勭悊锛孧aterialId鍙慨鏀 diff --git a/SlnMesnac.Model/domain/WcsTaskManual.cs b/SlnMesnac.Model/domain/WcsTaskManual.cs new file mode 100644 index 0000000..d031670 --- /dev/null +++ b/SlnMesnac.Model/domain/WcsTaskManual.cs @@ -0,0 +1,203 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SlnMesnac.Model.domain +{ + [SugarTable("wcs_task_manual"), TenantAttribute("mes")] + public class WcsTaskManual + { + /// + /// 涓婚敭 + /// + [SugarColumn(ColumnName = "objid", IsPrimaryKey = true)] + public long ObjId { get; set; } + + /// + /// wcs_warehouse_order 涓婚敭id + /// + [SugarColumn(ColumnName = "master_id")] + public long? MasterId { get; set; } + + /// + /// wms鍑哄叆搴撹褰曡〃id + /// + [SugarColumn(ColumnName = "order_id")] + public long? OrderId { get; set; } + + /// + /// 娴佹按鍙 + /// + [SugarColumn(ColumnName = "serial_no")] + public long? SerialNo { get; set; } + + /// + /// 璁惧缂栧彿 + /// + [SugarColumn(ColumnName = "equipment_no")] + public string EquipmentNo { get; set; } + + /// + /// 瀹瑰櫒鍙(鎵樼洏鎴栬呯鍙) + /// + [SugarColumn(ColumnName = "container_no")] + public string ContainerNo { get; set; } + + /// + /// 浠诲姟绫诲瀷,瀛楀吀琛 + /// + [SugarColumn(ColumnName = "task_type")] + public int? TaskType { get; set; } + + /// + /// 浠诲姟鐘舵,瀛楀吀琛 + /// + [SugarColumn(ColumnName = "task_status")] + public int? TaskStatus { get; set; } + + /// + /// 鐗╂枡ID + /// + [SugarColumn(ColumnName = "material_id")] + public long? MaterialId { get; set; } + + /// + /// 鐗╂枡鍙 + /// + [SugarColumn(ColumnName = "material_no")] + public string MaterialNo { get; set; } + + /// + /// 鏁伴噺 + /// + [SugarColumn(ColumnName = "qty")] + public int? Qty { get; set; } + + /// + /// 璧峰鐐圭紪鍙 + /// + [SugarColumn(ColumnName = "start_point_no")] + public string StartPointNo { get; set; } + + /// + /// 璧峰鐐筰d + /// + [SugarColumn(ColumnName = "start_point_id")] + public long? StartPointId { get; set; } + + /// + /// 褰撳墠鐐圭紪鍙 + /// + [SugarColumn(ColumnName = "curr_point_no")] + public string CurrPointNo { get; set; } + + /// + /// 褰撳墠鐐筰d + /// + [SugarColumn(ColumnName = "curr_point_id")] + public long? CurrPointId { get; set; } + + /// + /// 涓嬩竴鐐逛綅id + /// + [SugarColumn(ColumnName = "next_point_id")] + public long? NextPointId { get; set; } + + /// + /// 涓嬩竴鐐逛綅缂栧彿 + /// + [SugarColumn(ColumnName = "next_point_no")] + public string NextPointNo { get; set; } + + /// + /// 缁撴潫鐐圭紪鍙 + /// + [SugarColumn(ColumnName = "end_point_no")] + public string EndPointNo { get; set; } + + /// + /// 缁撴潫鐐筰d + /// + [SugarColumn(ColumnName = "end_point_id")] + public long? EndPointId { get; set; } + + /// + /// 鎵灞炴ゼ灞 + /// + [SugarColumn(ColumnName = "floor_no")] + public int? FloorNo { get; set; } + + /// + /// 鏄惁鍙敤 0:涓嶅彲鐢 1:鍙敤 + /// + [SugarColumn(ColumnName = "use_flag")] + public int UseFlag { get; set; } + + /// + /// 鍒涘缓鑰 + /// + [SugarColumn(ColumnName = "create_by")] + public string CreateBy { get; set; } + + /// + /// 鍒涘缓鏃堕棿 + /// + [SugarColumn(ColumnName = "create_time")] + public DateTime? CreateTime { get; set; } + + /// + /// 鏇存柊鑰 + /// + [SugarColumn(ColumnName = "update_by")] + public string UpdateBy { get; set; } + + /// + /// 鏇存柊鏃堕棿 + /// + [SugarColumn(ColumnName = "update_time")] + public DateTime? UpdateTime { get; set; } + + /// + /// 澶囩敤瀛楁1 + /// + [SugarColumn(ColumnName = "ud1")] + public int? Ud1 { get; set; } + + /// + /// 澶囩敤瀛楁2 + /// + [SugarColumn(ColumnName = "ud2")] + public string Ud2 { get; set; } + + /// + /// 澶囩敤瀛楁3 + /// + [SugarColumn(ColumnName = "ud3")] + public string Ud3 { get; set; } + + /// + /// 澶囨敞 + /// + [SugarColumn(ColumnName = "remark")] + public string Remark { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "from_floor_no")] + public int? FromFloorNo { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "is_empty")] + public string IsEmpty { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ctu_execute")] + public string CtuExecute { get; set; } + } +} diff --git a/SlnMesnac.WPF/MainWindow.xaml b/SlnMesnac.WPF/MainWindow.xaml index 469652e..7638814 100644 --- a/SlnMesnac.WPF/MainWindow.xaml +++ b/SlnMesnac.WPF/MainWindow.xaml @@ -35,8 +35,9 @@ - - + + + @@ -71,7 +72,7 @@