diff --git a/Aucma.Scada.Business/InStoreBusiness.cs b/Aucma.Scada.Business/InStoreBusiness.cs index 8058ed7f..fb179dae 100644 --- a/Aucma.Scada.Business/InStoreBusiness.cs +++ b/Aucma.Scada.Business/InStoreBusiness.cs @@ -99,17 +99,17 @@ namespace Aucma.Scada.Business grabImage.RefreshLogMessageEvent += PrintLogInfoMessage; StartPassDown(); - //Task.Run(() => - //{ - // Thread.Sleep(6000); - // for (int i = 1; i < 2; i++) - // { - // //InStore(appConfig.shellStoreCode, "B2360000078110300" + i.ToString().PadLeft(2, '0')); - // //Thread.Sleep(1000); - // //InStore(appConfig.linerStoreCode, "L2360000078810240" + i.ToString().PadLeft(2, '0')); - // //Thread.Sleep(1000); - // } - //}); + Task.Run(() => + { + Thread.Sleep(6000); + for (int i = 1; i < 12; i++) + { + //InStore(appConfig.shellStoreCode, "B2360000078110600" + i.ToString().PadLeft(2, '0')); + //Thread.Sleep(1000*60*1); + //InStore(appConfig.linerStoreCode, "L2360000078110600" + i.ToString().PadLeft(2, '0')); + //Thread.Sleep(1000 * 60 * 1); + } + }); } @@ -131,6 +131,7 @@ namespace Aucma.Scada.Business if (spaceInfo != null) { PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}"); + spaceInfo.materialType = materialType; RefreshScanMateriaCodeEvent?.Invoke(materialCode, GetMaterialName(materialType), spaceInfo.spaceName, storeCode); //刷新界面扫码信息 var result = CreateInStoreTask(spaceInfo, materialCode); //创建入库任务 if (result) @@ -241,15 +242,7 @@ namespace Aucma.Scada.Business RefreshInStoreTaskEvent?.Invoke(taskInfo); - //if (shellSemaphore.Wait(TimeSpan.FromSeconds(20))) - //{ - // // 收到反馈 - // PrintLogInfoMessage("收到反馈,继续执行"); - //} - //else - //{ - // PrintLogInfoMessage("超时未反馈"); - //} + taskHandle.WritePlc(taskInfo.storeCode, taskInfo.spaceCode, false); shellSemaphore.Wait(); //一直堵塞直到信号量释放 @@ -289,15 +282,7 @@ namespace Aucma.Scada.Business RefreshInStoreTaskEvent?.Invoke(taskInfo); - //if (shellSemaphore.Wait(TimeSpan.FromSeconds(20))) - //{ - // // 收到反馈 - // PrintLogInfoMessage("收到反馈,继续执行"); - //} - //else - //{ - // PrintLogInfoMessage("超时未反馈"); - //} + taskHandle.WritePlc(taskInfo.storeCode, taskInfo.spaceCode, false); linerSemaphore.Wait(); //一直堵塞直到信号量释放 @@ -340,6 +325,11 @@ namespace Aucma.Scada.Business return taskInfo; } + /// + /// 任务反馈(入库完成) + /// + /// + /// private void TaskFeedback(string storeCode,string taskCode) { if(storeCode == appConfig.shellStoreCode) @@ -397,9 +387,8 @@ namespace Aucma.Scada.Business if (spaceInfo != null) { - - - spaceInfo.materialType = taskInfo.materialType; + taskHandle.WritePlc(spaceInfo.storeCode, spaceInfo.spaceCode, true); + //spaceInfo.materialType = taskInfo.materialType; spaceInfo.spaceStock = spaceInfo.spaceStock + 1; spaceInfo.onRouteAmount -= 1; @@ -425,7 +414,7 @@ namespace Aucma.Scada.Business _baseSpaceDetailService.InsertSpaceDetail(spaceDetail); #endregion - #region 添加入库任务 + #region 添加入库记录 RecordInstore recordInstore = new RecordInstore(); recordInstore.storeCode = taskInfo.storeCode; recordInstore.spaceCode = taskInfo.spaceCode; @@ -536,15 +525,14 @@ namespace Aucma.Scada.Business { if (info.Count > 0) { - foreach (BaseSpaceInfo item in info) + result = GetSpaceInfosByPlc(info); + + if(result == null) { - var spaceInfo = taskHandle.ReadSpaceInfoByPlc(item); - item.spaceStock = spaceInfo.spaceStock; - item.onRouteAmount = spaceInfo.onRouteAmount; - item.spaceStatus = spaceInfo.spaceStatus; - } + var list = _spaceInfoService.GetEmptySpaceInfo(storeCode); - result = info.Where(x=>x.spaceStatus == 1 && x.spaceStock > 0 ? x.spaceCapacity > (x.spaceStock + x.onRouteAmount) : 1 == 1).OrderByDescending(x => x.spaceStock).OrderBy(x=>x.spaceCode).First(); + result = GetSpaceInfosByPlc(list); + } } } @@ -555,5 +543,40 @@ namespace Aucma.Scada.Business return result; } + + /// + /// 读取PLC货道信息 + /// + /// + /// + private BaseSpaceInfo GetSpaceInfosByPlc(List info) + { + BaseSpaceInfo result = null; + if (info != null) + { + if (info.Count > 0) + { + foreach (BaseSpaceInfo item in info) + { + var spaceInfo = taskHandle.ReadSpaceInfoByPlc(item); + + item.spaceStock = spaceInfo.spaceStock; + item.onRouteAmount = spaceInfo.onRouteAmount; + item.spaceStatus = spaceInfo.spaceStatus; + + PrintLogInfoMessage($"通过PLC读取货道信息,货道:{spaceInfo.spaceName};在库数量:{item.spaceStock};在途数量:{item.onRouteAmount};货道状态:{item.spaceStatus}"); + } + + var list = info.Where(x => x.spaceStock > 0 ? x.spaceCapacity > (x.spaceStock + x.onRouteAmount) : 1 == 1 && x.spaceStatus == 1).ToList(); + + if(list.Count > 0) + { + result = list.OrderByDescending(x => x.spaceStock).OrderBy(x => x.spaceCode).First(); + } + + } + } + return result; + } } } diff --git a/Aucma.Scada.Business/InStoreTaskHandle.cs b/Aucma.Scada.Business/InStoreTaskHandle.cs index c646cd84..a6caa076 100644 --- a/Aucma.Scada.Business/InStoreTaskHandle.cs +++ b/Aucma.Scada.Business/InStoreTaskHandle.cs @@ -226,7 +226,7 @@ namespace Aucma.Scada.Business bool result = false; try { - IPlc _plc = _plcDictionary[taskInfo.storeCode]; + IPlc _plc = _plcDictionary[appConfig.linerStoreCode]; if (_plc != null) { @@ -269,7 +269,7 @@ namespace Aucma.Scada.Business lock (string.Empty) { bool isFlag = true; - IPlc _plc = _plcDictionary[appConfig.shellStoreCode]; + IPlc _plc = _plcDictionary[appConfig.linerStoreCode]; linerTaskCode = taskCode; try { @@ -393,5 +393,37 @@ namespace Aucma.Scada.Business return spaceInfo; } + + /// + /// 测试方法,联调时不用 + /// + /// + /// + /// + public void WritePlc(string storeCode, string spaceCode, bool flag) + { + var spaceAddress = spaceConfig.GetSpaceAddress(storeCode, spaceCode); + IPlc _plc = _plcDictionary[storeCode]; + + if (_plc != null) + { + if (_plc.IsConnected) + { + var spaceStock = _plc.readInt32ByAddress(spaceAddress.onStore); + var onRouteAmount = _plc.readInt32ByAddress(spaceAddress.onRoute); + + if (flag) + { + _plc.writeInt32ByAddress(spaceAddress.onStore, spaceStock + 1); + _plc.writeInt32ByAddress(spaceAddress.onRoute, onRouteAmount - 1); + } + else + { + _plc.writeInt32ByAddress(spaceAddress.onRoute, onRouteAmount + 1); + } + + } + } + } } } diff --git a/Aucma.Scada.Business/OutStoreTaskHandle.cs b/Aucma.Scada.Business/OutStoreTaskHandle.cs index d62ab996..0dc94665 100644 --- a/Aucma.Scada.Business/OutStoreTaskHandle.cs +++ b/Aucma.Scada.Business/OutStoreTaskHandle.cs @@ -81,7 +81,7 @@ namespace Aucma.Scada.Business bool result = false; try { - IPlc _plc = _plcDictionary[taskInfo.storeCode]; + IPlc _plc = _plcDictionary[appConfig.shellStoreCode]; if (_plc != null) { @@ -239,7 +239,7 @@ namespace Aucma.Scada.Business bool result = false; try { - IPlc _plc = _plcDictionary[taskInfo.storeCode]; + IPlc _plc = _plcDictionary[appConfig.linerStoreCode]; if (_plc != null) { diff --git a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.dll b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.dll index 27b6cbad..0b7054e3 100644 Binary files a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.dll and b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.dll differ diff --git a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.pdb b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.pdb index 4853fc75..638c9b6d 100644 Binary files a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.pdb and b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.pdb differ diff --git a/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.dll b/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.dll index 88796a59..2a14061f 100644 Binary files a/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.dll and b/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.dll differ diff --git a/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.pdb b/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.pdb index 25e920d1..20fbb588 100644 Binary files a/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.pdb and b/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.pdb differ diff --git a/Aucma.Scada.UI/bin/Debug/Aucma.Scada.Business.dll b/Aucma.Scada.UI/bin/Debug/Aucma.Scada.Business.dll index 27b6cbad..0b7054e3 100644 Binary files a/Aucma.Scada.UI/bin/Debug/Aucma.Scada.Business.dll and b/Aucma.Scada.UI/bin/Debug/Aucma.Scada.Business.dll differ diff --git a/Aucma.Scada.UI/bin/Debug/Aucma.Scada.Business.pdb b/Aucma.Scada.UI/bin/Debug/Aucma.Scada.Business.pdb index 4853fc75..638c9b6d 100644 Binary files a/Aucma.Scada.UI/bin/Debug/Aucma.Scada.Business.pdb and b/Aucma.Scada.UI/bin/Debug/Aucma.Scada.Business.pdb differ diff --git a/Aucma.Scada.UI/bin/Debug/Aucma.Scada.UI.exe b/Aucma.Scada.UI/bin/Debug/Aucma.Scada.UI.exe index 0f7bc51b..a09a9656 100644 Binary files a/Aucma.Scada.UI/bin/Debug/Aucma.Scada.UI.exe and b/Aucma.Scada.UI/bin/Debug/Aucma.Scada.UI.exe differ diff --git a/Aucma.Scada.UI/bin/Debug/Aucma.Scada.UI.pdb b/Aucma.Scada.UI/bin/Debug/Aucma.Scada.UI.pdb index 436c737f..7358635a 100644 Binary files a/Aucma.Scada.UI/bin/Debug/Aucma.Scada.UI.pdb and b/Aucma.Scada.UI/bin/Debug/Aucma.Scada.UI.pdb differ diff --git a/Aucma.Scada.UI/bin/Debug/HighWayIot.Repository.dll b/Aucma.Scada.UI/bin/Debug/HighWayIot.Repository.dll index 88796a59..2a14061f 100644 Binary files a/Aucma.Scada.UI/bin/Debug/HighWayIot.Repository.dll and b/Aucma.Scada.UI/bin/Debug/HighWayIot.Repository.dll differ diff --git a/Aucma.Scada.UI/bin/Debug/HighWayIot.Repository.pdb b/Aucma.Scada.UI/bin/Debug/HighWayIot.Repository.pdb index 25e920d1..20fbb588 100644 Binary files a/Aucma.Scada.UI/bin/Debug/HighWayIot.Repository.pdb and b/Aucma.Scada.UI/bin/Debug/HighWayIot.Repository.pdb differ diff --git a/Aucma.Scada.UI/bin/Debug/config/Plc.Ini b/Aucma.Scada.UI/bin/Debug/config/Plc.Ini index 95ab1420..44139439 100644 --- a/Aucma.Scada.UI/bin/Debug/config/Plc.Ini +++ b/Aucma.Scada.UI/bin/Debug/config/Plc.Ini @@ -2,7 +2,7 @@ PLCIP=127.0.0.1 PLC˿=6000 ڵPLCIP=127.0.0.1 -ڵPLC˿=6000 +ڵPLC˿=6001 #ַ [shell_inStore_address] diff --git a/Aucma.Scada.UI/viewModel/InStoreInfo/InStoreInfoViewModel.cs b/Aucma.Scada.UI/viewModel/InStoreInfo/InStoreInfoViewModel.cs index 108dfeb1..ad3a3547 100644 --- a/Aucma.Scada.UI/viewModel/InStoreInfo/InStoreInfoViewModel.cs +++ b/Aucma.Scada.UI/viewModel/InStoreInfo/InStoreInfoViewModel.cs @@ -300,19 +300,20 @@ namespace Aucma.Scada.UI.viewModel.InStoreInfo MaterialNameList = new List(); List info = inStoreBusiness.GetMaterialStock(); - if (info != null) + + App.Current.Dispatcher.BeginInvoke((Action)(() => { - Achievement.Clear(); - foreach (var item in info) + if (info != null) { - MaterialNameList.Add(item.parentMaterialName); - shellAchievement.Add(Convert.ToDouble(item.shellStock)); - linerAchievement.Add(Convert.ToDouble(item.linerStock)); + Achievement.Clear(); + foreach (var item in info) + { + MaterialNameList.Add(item.parentMaterialName); + shellAchievement.Add(Convert.ToDouble(item.shellStock)); + linerAchievement.Add(Convert.ToDouble(item.linerStock)); + } } - } - App.Current.Dispatcher.BeginInvoke((Action)(() => - { var shellColumn = new ColumnSeries(); shellColumn.DataLabels = true; shellColumn.Title = "箱壳"; diff --git a/HighWayIot.Repository/bin/Debug/HighWayIot.Repository.dll b/HighWayIot.Repository/bin/Debug/HighWayIot.Repository.dll index 88796a59..2a14061f 100644 Binary files a/HighWayIot.Repository/bin/Debug/HighWayIot.Repository.dll and b/HighWayIot.Repository/bin/Debug/HighWayIot.Repository.dll differ diff --git a/HighWayIot.Repository/bin/Debug/HighWayIot.Repository.pdb b/HighWayIot.Repository/bin/Debug/HighWayIot.Repository.pdb index 25e920d1..20fbb588 100644 Binary files a/HighWayIot.Repository/bin/Debug/HighWayIot.Repository.pdb and b/HighWayIot.Repository/bin/Debug/HighWayIot.Repository.pdb differ diff --git a/HighWayIot.Repository/service/IBaseSpaceInfoService.cs b/HighWayIot.Repository/service/IBaseSpaceInfoService.cs index 2dd5f70b..6483f875 100644 --- a/HighWayIot.Repository/service/IBaseSpaceInfoService.cs +++ b/HighWayIot.Repository/service/IBaseSpaceInfoService.cs @@ -62,5 +62,11 @@ namespace HighWayIot.Repository.service /// /// List GetMaterialStock(string shellStoreCode,string linerStoreCode); + + /// + /// 获取空货道:未分配物料型号的空白货道 + /// + /// + List GetEmptySpaceInfo(string store); } } diff --git a/HighWayIot.Repository/service/Impl/BaseSpaceInfoServiceImpl.cs b/HighWayIot.Repository/service/Impl/BaseSpaceInfoServiceImpl.cs index 390f019f..ac081286 100644 --- a/HighWayIot.Repository/service/Impl/BaseSpaceInfoServiceImpl.cs +++ b/HighWayIot.Repository/service/Impl/BaseSpaceInfoServiceImpl.cs @@ -84,7 +84,7 @@ namespace HighWayIot.Repository.service.Impl /// 获取空货道:未分配物料型号的空白货道 /// /// - private List GetEmptySpaceInfo(string store) + public List GetEmptySpaceInfo(string store) { List spaceInfos = null; try diff --git a/HighWayIot/bin/Debug/HighWayIot.Repository.dll b/HighWayIot/bin/Debug/HighWayIot.Repository.dll index 88796a59..2a14061f 100644 Binary files a/HighWayIot/bin/Debug/HighWayIot.Repository.dll and b/HighWayIot/bin/Debug/HighWayIot.Repository.dll differ diff --git a/HighWayIot/bin/Debug/HighWayIot.Repository.pdb b/HighWayIot/bin/Debug/HighWayIot.Repository.pdb index 25e920d1..20fbb588 100644 Binary files a/HighWayIot/bin/Debug/HighWayIot.Repository.pdb and b/HighWayIot/bin/Debug/HighWayIot.Repository.pdb differ