diff --git a/Admin.Core.Service/Service_New/BaseSpaceInfoServices.cs b/Admin.Core.Service/Service_New/BaseSpaceInfoServices.cs index 97df3a74..36230dda 100644 --- a/Admin.Core.Service/Service_New/BaseSpaceInfoServices.cs +++ b/Admin.Core.Service/Service_New/BaseSpaceInfoServices.cs @@ -37,7 +37,7 @@ namespace Admin.Core.Service - #region 入库通过物料类型获取指定货道,如果没有对应类型的货道返回空白类型的货道 + #region 入库通过物料类型获取指定货道,如果没有对应类型的货道停住 /// /// 入库通过物料类型获取指定货道,如果没有对应类型的货道返回空白类型的货道 /// @@ -50,15 +50,12 @@ namespace Admin.Core.Service List spaceInfos = null; try { - spaceInfos = await _baseSpaceInfoRepository.QueryAsync(x => x.StoreCode == store && x.MaterialType == materialType && x.SpaceStatus == 1); - if (spaceInfos==null || spaceInfos.Count == 0) //没有指定该类型物料的货道信息,需获取空白货道信息进行分配 - spaceInfos = await GetEmptySpaceInfo(store); + spaceInfos = await _baseSpaceInfoRepository.QueryAsync(x => x.StoreCode == store && (x.MaterialType == materialType || x.typeCodeB == materialType || x.typeCodeC == materialType ) && x.SpaceStatus == 1); + if (spaceInfos == null || spaceInfos.Count == 0) //没有指定该类型物料的货道信息,需获取空白货道信息进行分配 + return null; logHelper.Info($"根据仓库{store};物料:{materialType};获取到的货道信息:{spaceInfos.ToJson()}"); - //spaceInfo = InStoreFilter(spaceInfos); - //logHelper.Info($"仓库{store};物料:{materialType};匹配的入库货道信息:{spaceInfo.ToJson()}"); - - //spaceInfo.MaterialType = materialType; + } catch (Exception ex) { diff --git a/Admin.Core.Tasks/obj/Debug/net6.0/Admin.Core.Tasks.GeneratedMSBuildEditorConfig.editorconfig b/Admin.Core.Tasks/obj/Debug/net6.0/Admin.Core.Tasks.GeneratedMSBuildEditorConfig.editorconfig index d114eba8..aa57dd8c 100644 --- a/Admin.Core.Tasks/obj/Debug/net6.0/Admin.Core.Tasks.GeneratedMSBuildEditorConfig.editorconfig +++ b/Admin.Core.Tasks/obj/Debug/net6.0/Admin.Core.Tasks.GeneratedMSBuildEditorConfig.editorconfig @@ -8,4 +8,4 @@ build_property.PlatformNeutralAssembly = build_property.EnforceExtendedAnalyzerRules = build_property._SupportedPlatformList = Linux,macOS,Windows build_property.RootNamespace = Admin.Core.Tasks -build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.Tasks\ +build_property.ProjectDir = E:\c#\AUCMA\new\Admin.Core.Tasks\ diff --git a/Aucma.Core.BoxFoam/Business/CollectionFoamMachine.cs b/Aucma.Core.BoxFoam/Business/CollectionFoamMachine.cs index 9330ff24..15f418e3 100644 --- a/Aucma.Core.BoxFoam/Business/CollectionFoamMachine.cs +++ b/Aucma.Core.BoxFoam/Business/CollectionFoamMachine.cs @@ -11,6 +11,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Linq; +using System.Security.Cryptography; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -68,6 +69,7 @@ namespace Aucma.Core.BoxFoam.Business semaphore.WaitOne(); try { + Thread.Sleep(3000); var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamMachinePlc")); if (obj != null) @@ -79,6 +81,7 @@ namespace Aucma.Core.BoxFoam.Business ReadGunData(obj, "DB50.1084", gunKeys, "B1"); //B1枪数据 ReadGunData(obj, "DB50.1272", gunKeys, "A2"); //A2枪数据 ReadGunData(obj, "DB50.1460", gunKeys, "B2"); //A2枪数据 + RefreshSystemDataDelegateEvent?.Invoke(systemKeys); RefreshGunDataDelegateEvent?.Invoke(gunKeys); @@ -99,6 +102,7 @@ namespace Aucma.Core.BoxFoam.Business } tempKeys.Add(kvPair.Key, record); } + //有变化更新记录所有信息 if (!kvPair.Value.MixpistOff.Equals(tempKeys[kvPair.Key].MixpistOff)) { kvPair.Value.ProductLineCode = "CX_02"; @@ -107,6 +111,17 @@ namespace Aucma.Core.BoxFoam.Business int b = _lastShotRecordServices.AddAsync(kvPair.Value).Result; RefreshLastShotDataDelegateEvent?.Invoke(kvPair.Value); } + // 设备状态变化,更新设备状态 + if (kvPair.Value.SystemStatus!= tempKeys[kvPair.Key].SystemStatus) + { + BoxLastShotRecord record = _lastShotRecordServices.Query(x => x.System.Equals(kvPair.Value.System) && x.ProductLineCode.Equals(kvPair.Value.ProductLineCode) && x.GunCode.Equals(kvPair.Value.GunCode)).OrderByDescending(x => x.CreateTime).FirstOrDefault(); + if (record != null) + { + record.SystemStatus = kvPair.Value.SystemStatus; + bool flag = _lastShotRecordServices.UpdateAsync(record).Result; + } + + } } @@ -210,6 +225,8 @@ namespace Aucma.Core.BoxFoam.Business BoxLastShotRecord lastShotRecord = new BoxLastShotRecord(); lastShotRecord.System = gunCode.Substring(1, 1); lastShotRecord.GunCode = gunCode; + + // 系统状态 if(lastShotRecord.System == "1") { if(obj.plc.ReadBool("DB50.388.0")) diff --git a/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs b/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs index 0976264a..d5b8287d 100644 --- a/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs +++ b/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs @@ -110,12 +110,12 @@ namespace Aucma.Core.BoxFoam.Business { spaceAddresses.Add(spaceConfig.GetSpaceAddress(storeCode, space.SpaceCode)); } - // 模拟入库 - //Task.Run(() => - //{ - // Thread.Sleep(2000); - // InStore("B24010181060282920011"); - //}); + // 模拟入库 + Task.Run(() => + { + Thread.Sleep(5000); + InStore("B24010183025024860011"); + }); //实时监测入库任务下发和入库任务完成 StartPassDownAndRealInstoreFinish(); } @@ -272,6 +272,7 @@ namespace Aucma.Core.BoxFoam.Business BaseSpaceInfo spaceInfo = await GetSpaceInfoByMaterialType(storeCode, materialType); if (spaceInfo != null) { + logHelper.Info($"匹配货道:{spaceInfo.ToJson()}"); LogDelegateEvent?.Invoke($"匹配货道:{spaceInfo.ToJson()}"); @@ -298,6 +299,8 @@ namespace Aucma.Core.BoxFoam.Business else { //报警停线 + LogDelegateEvent?.Invoke($"未匹配到货道,请设置货道型号!"); + } } catch (Exception ex) @@ -364,18 +367,37 @@ namespace Aucma.Core.BoxFoam.Business BaseSpaceInfo result = null; try { - // List info = _spaceInfoService.GetBaseSpaceInfosByMaterialType(storeCode, materialType); + List info = await _baseSpaceInfoServices.InStoreGetSpaceInfoByMaterialType(storeCode, materialType); if (info != null) { if (info.Count > 0) { + // 更新货道库存 foreach (BaseSpaceInfo item in info) { var spaceInfo = ReadSpaceInfoByPlc(item); item.SpaceStock = spaceInfo.SpaceStock; - // item.OnRouteAmount = spaceInfo.OnRouteAmount; - // item.SpaceStatus = spaceInfo.SpaceStatus; + + if(item.typeCodeB.Equals(materialType) && (item.SpaceStock+item.OnRouteAmount)==0) + { + string str1 = item.typeCodeB; + string str2 = item.typeNameB; + item.typeCodeB = item.MaterialType; + item.typeNameB = item.typeNameA; + item.MaterialType = str1; + item.typeNameA = str2; + } + // 对调C型号和主型号 + else if(spaceInfo.typeCodeC.Equals(materialType) && (item.SpaceStock + item.OnRouteAmount) == 0) + { + string str1 = item.typeCodeC; + string str2 = item.typeNameC; + item.typeCodeC = item.MaterialType; + item.typeNameC = item.typeNameA; + item.MaterialType = str1; + item.typeNameA = str2; + } } info = info.Where(x => x.SpaceStatus == 1 && x.SpaceCapacity > (x.SpaceStock + x.OnRouteAmount)).ToList(); @@ -407,8 +429,7 @@ namespace Aucma.Core.BoxFoam.Business { SpaceAddress spaceAddress = spaceConfig.GetSpaceAddress(spaceInfo.StoreCode, spaceInfo.SpaceCode); spaceInfo.SpaceStock = obj.plc.ReadInt16(spaceAddress.onStore); - // spaceInfo.OnRouteAmount = obj.plc.ReadInt32(spaceAddress.onRoute); - // spaceInfo.SpaceStatus = obj.plc.ReadInt32(spaceAddress.spaceStatus); + } return spaceInfo; } @@ -551,12 +572,15 @@ namespace Aucma.Core.BoxFoam.Business #region Add By wenjy 2023-10-30 13:44:00 通过PLC获取货道信息 var item = ReadSpaceInfoByPlc(spaceInfo); spaceInfo.SpaceStock = item.SpaceStock; - // 入库完成,在途减1 - spaceInfo.OnRouteAmount -= 1; + if (spaceInfo.OnRouteAmount>0) + { + // 入库完成,在途减1 + spaceInfo.OnRouteAmount -= 1; + } #endregion - await _baseSpaceInfoServices.UpdateSpaceInfo(spaceInfo); + #region 添加货道明细 不控制出库,暂时未添加明细 BaseSpaceDetail spaceDetail = new BaseSpaceDetail(); @@ -580,10 +604,15 @@ namespace Aucma.Core.BoxFoam.Business recordInstore.InStoreTime = DateTime.Now; recordInstore.BarCodeCode = taskInfo.MaterialCode; #endregion - bool result = await _recordInstoreServices.SaveRecordToDb(recordInstore, taskInfo, spaceInfo, spaceDetail); + + await _baseSpaceInfoServices.UpdateSpaceInfo(spaceInfo); + _ = _recordInstoreServices.AddAsync(recordInstore).Result; + bool result = _realTaskInfoService.DeleteAsync(taskInfo).Result; + // bool result = await _recordInstoreServices.SaveRecordToDb(recordInstore, taskInfo, spaceInfo, spaceDetail); if (result) { LogDelegateEvent?.Invoke($"入库完成,更新数据库成功"); + RefreshDataGridDelegateEvent?.Invoke();//刷新datagrid 列表 } else { diff --git a/Aucma.Core.BoxFoam/Models/SpaceInfoModel.cs b/Aucma.Core.BoxFoam/Models/SpaceInfoModel.cs index c959cffc..571b9076 100644 --- a/Aucma.Core.BoxFoam/Models/SpaceInfoModel.cs +++ b/Aucma.Core.BoxFoam/Models/SpaceInfoModel.cs @@ -42,6 +42,10 @@ namespace Aucma.Core.BoxFoam.Models /// public string typeCodeB { get; set; } /// + /// 物料型号C + /// + public string typeCodeC { get; set; } + /// /// 入库状态 /// public string inStoreFlag { get; set; } diff --git a/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs b/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs index ae6056b7..509b9204 100644 --- a/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs +++ b/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs @@ -32,6 +32,7 @@ namespace Aucma.Core.BoxFoam.ViewModels // 设置型号 SubmitCommand = new RelayCommand(obj => SubmitCommandExecute(obj)); SubmitCommand2 = new RelayCommand(obj => SubmitCommandExecute2(obj)); + SubmitCommand3 = new RelayCommand(obj => SubmitCommandExecute3(obj)); _baseSpaceDetailServices = App.ServiceProvider.GetService(); _baseSpaceInfoServices = App.ServiceProvider.GetService(); SelectTypeViewModel.RefreshPageEvent += LoadSpaceStoreMedthAsync; @@ -59,6 +60,16 @@ namespace Aucma.Core.BoxFoam.ViewModels SelectType type = new SelectType(2, spaceCode); type.ShowDialog(); + } + + public RelayCommand SubmitCommand3 { get; set; } + + private void SubmitCommandExecute3(string spaceCode) + { + + SelectType type = new SelectType(3, spaceCode); + type.ShowDialog(); + } #endregion @@ -83,6 +94,7 @@ namespace Aucma.Core.BoxFoam.ViewModels model.totalAmount = item.SpaceStock + item.OnRouteAmount; model.materialType = item.MaterialType; model.typeCodeB = item.typeCodeB; + model.typeCodeC = item.typeCodeC; model.unusualFlag = item.UnusualFlag == 2 ? "Red" : "White"; if (item.SpaceStatus == 2) { diff --git a/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs index d177b7c1..ade2ece5 100644 --- a/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs +++ b/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs @@ -82,95 +82,104 @@ namespace Aucma.Core.BoxFoam.ViewModels /// private Task InitEveryDayMethod() { - ProductionHourList = new List(); - List listTime = _baseBomInfoServices.getWorkTime().Result; - foreach (WorkTime time in listTime) - { - ProductionHourList.Add(time.hourTime); - } - - // 货道列表 - List list = _boxFoamDataServices.QueryAsync(x=>x.ProductLineCode.Equals("CX_02") && x.StationCode=="1005").Result; - - if(list != null) + try { - ChartValues achievement = new ChartValues(); - //Achievement.Clear(); - #region 按时间统计 - if(list.Count > 0) { - achievement.Add(list.Sum(x => x.AnHour)); - achievement.Add(list.Sum(x => x.TwoHour)); - achievement.Add(list.Sum(x => x.ThreeHour)); - achievement.Add(list.Sum(x => x.FourHour)); - achievement.Add(list.Sum(x => x.FiveHour)); - achievement.Add(list.Sum(x => x.SixHour)); - achievement.Add(list.Sum(x => x.SevenHour)); - achievement.Add(list.Sum(x => x.EightHour)); - achievement.Add(list.Sum(x => x.NineHour)); - achievement.Add(list.Sum(x => x.TenHour)); - achievement.Add(list.Sum(x => x.ElevenHour)); - achievement.Add(list.Sum(x => x.TwelveHour)); + ProductionHourList = new List(); + List listTime = _baseBomInfoServices.getWorkTime().Result; + foreach (WorkTime time in listTime) + { + ProductionHourList.Add(time.hourTime); } - var column = new ColumnSeries(); - column.DataLabels = true; - column.Title = "当日小时产量统计"; - column.Values = achievement; - column.Foreground = Brushes.White; - // Achievement.Add(column); - if (Achievement.Count > 0) + // 货道列表 + List list = _boxFoamDataServices.QueryAsync(x => x.ProductLineCode.Equals("CX_02") && x.StationCode == "1005").Result; + + if (list != null) { - for(int i = 0; i < achievement.Count; i++) + ChartValues achievement = new ChartValues(); + //Achievement.Clear(); + #region 按时间统计 + if (list.Count > 0) { - Achievement.FirstOrDefault().Values[i] = achievement[i]; + achievement.Add(list.Sum(x => x.AnHour)); + achievement.Add(list.Sum(x => x.TwoHour)); + achievement.Add(list.Sum(x => x.ThreeHour)); + achievement.Add(list.Sum(x => x.FourHour)); + achievement.Add(list.Sum(x => x.FiveHour)); + achievement.Add(list.Sum(x => x.SixHour)); + achievement.Add(list.Sum(x => x.SevenHour)); + achievement.Add(list.Sum(x => x.EightHour)); + achievement.Add(list.Sum(x => x.NineHour)); + achievement.Add(list.Sum(x => x.TenHour)); + achievement.Add(list.Sum(x => x.ElevenHour)); + achievement.Add(list.Sum(x => x.TwelveHour)); } - } - else - { - Achievement.Add(column); - } - #endregion + var column = new ColumnSeries(); + column.DataLabels = true; + column.Title = "当日小时产量统计"; + column.Values = achievement; + column.Foreground = Brushes.White; + // Achievement.Add(column); + if (Achievement.Count > 0) + { + for (int i = 0; i < achievement.Count; i++) + { + Achievement.FirstOrDefault().Values[i] = achievement[i]; + } + } + else + { + Achievement.Add(column); + } + #endregion - #region 按类型统计 - MaterialNameList = new List(); - ChartValues achievement2 = new ChartValues(); - //foreach(BoxFoamData space in list) - //{ - // MaterialNameList.Add(space.Fixtureboxtype); - //} - var grouped = list.GroupBy(x => x.Fixtureboxtype); - foreach (var item in grouped) - { - var flattenedList = item.SelectMany(p => new[] { p.AnHour, p.TwoHour, p.ThreeHour, p.FourHour, p.FiveHour, p.SixHour, p.SevenHour, p.EightHour, p.NineHour, p.TenHour, p.ElevenHour, p.TwelveHour }).ToList(); - MaterialNameList.Add(item.Key); - achievement2.Add(flattenedList.Sum()); - } - // ModelStatistics.Clear(); - var column2 = new ColumnSeries(); - column2.DataLabels = true; - column2.Title = "当日型号产量统计"; - column2.Values = achievement2; - column2.Foreground = Brushes.White; - // ModelStatistics.Add(column2); - if (ModelStatistics.Count > 0) - { - for(int i=0;i< achievement2.Count; i++) + #region 按类型统计 + MaterialNameList = new List(); + ChartValues achievement2 = new ChartValues(); + //foreach(BoxFoamData space in list) + //{ + // MaterialNameList.Add(space.Fixtureboxtype); + //} + var grouped = list.GroupBy(x => x.Fixtureboxtype); + foreach (var item in grouped) { - ModelStatistics.FirstOrDefault().Values[i] = achievement2[i]; + var flattenedList = item.SelectMany(p => new[] { p.AnHour, p.TwoHour, p.ThreeHour, p.FourHour, p.FiveHour, p.SixHour, p.SevenHour, p.EightHour, p.NineHour, p.TenHour, p.ElevenHour, p.TwelveHour }).ToList(); + + MaterialNameList.Add(item.Key); + achievement2.Add(flattenedList.Sum()); } - } - else - { - ModelStatistics.Add(column2); + // ModelStatistics.Clear(); + var column2 = new ColumnSeries(); + column2.DataLabels = true; + column2.Title = "当日型号产量统计"; + column2.Values = achievement2; + column2.Foreground = Brushes.White; + // ModelStatistics.Add(column2); + if (ModelStatistics.Count > 0) + { + for (int i = 0; i < achievement2.Count; i++) + { + ModelStatistics.FirstOrDefault().Values[i] = achievement2[i]; + } + } + else + { + ModelStatistics.Add(column2); + } + + #endregion } - #endregion + + + } + catch (Exception ex) + { + Console.WriteLine(ex.Message.ToString()); } - - //await InitExecMethod(); return Task.CompletedTask; } diff --git a/Aucma.Core.BoxFoam/Views/UserPage/BeforeFoamingPageView.xaml b/Aucma.Core.BoxFoam/Views/UserPage/BeforeFoamingPageView.xaml index 04a5d322..c05a0511 100644 --- a/Aucma.Core.BoxFoam/Views/UserPage/BeforeFoamingPageView.xaml +++ b/Aucma.Core.BoxFoam/Views/UserPage/BeforeFoamingPageView.xaml @@ -106,7 +106,7 @@ - + @@ -148,7 +148,7 @@ - + @@ -170,14 +170,14 @@ - + diff --git a/Aucma.Core.BoxFoam/Views/UserPage/SelectType.xaml b/Aucma.Core.BoxFoam/Views/UserPage/SelectType.xaml index 500aa8dc..eaf00b86 100644 --- a/Aucma.Core.BoxFoam/Views/UserPage/SelectType.xaml +++ b/Aucma.Core.BoxFoam/Views/UserPage/SelectType.xaml @@ -179,7 +179,7 @@ - +