diff --git a/Admin.Core.Repository/BASE/BaseRepository.cs b/Admin.Core.Repository/BASE/BaseRepository.cs index 26c72841..4916aff0 100644 --- a/Admin.Core.Repository/BASE/BaseRepository.cs +++ b/Admin.Core.Repository/BASE/BaseRepository.cs @@ -652,6 +652,11 @@ namespace Admin.Core.Repository { var insert = _db.Insertable(entity); + if(insert == null) + { + return 0; + } + return insert.ExecuteReturnIdentity(); } diff --git a/Admin.Core.Service/Service_New/RecordBoxFoamFixtureComplateServices.cs b/Admin.Core.Service/Service_New/RecordBoxFoamFixtureComplateServices.cs index ba249b1e..ef20ad2c 100644 --- a/Admin.Core.Service/Service_New/RecordBoxFoamFixtureComplateServices.cs +++ b/Admin.Core.Service/Service_New/RecordBoxFoamFixtureComplateServices.cs @@ -54,17 +54,17 @@ namespace Admin.Core.Service.Service_New foreach(var item in fixture) { //获取当前工位,前一条数据 - var lastFixtureList = _dal.Query(x => x.ProductionLine == "CX_01" && x.StationCode == "1002" && x.FixtureCode == item.FixtureCode); + var lastFixtureList = _dal.Query(x => x.ProductionLine == "CX_01" && x.StationCode == "1005" && x.FixtureCode == item.FixtureCode); if(lastFixtureList != null) { - if(lastFixtureList.Count > 0) + if (lastFixtureList.Count > 0) { RecordBoxFoamFixtureComplate lastFixtureComplate = lastFixtureList.OrderByDescending(x => x.RecordTime).First(); - if(lastFixtureComplate != null) + if (lastFixtureComplate != null) { - if(item.FixtureBoxType == lastFixtureComplate.FixtureBoxType) + if (item.FixtureBoxType == lastFixtureComplate.FixtureBoxType) { if (item.FixtureOutPut > lastFixtureComplate.FixtureOutPut) { @@ -72,14 +72,20 @@ namespace Admin.Core.Service.Service_New //更新生产计划 UpdatePlanInfo(item); + + _dal.Add(item); + + //更新小时数据 + UpdateHourInfo(item); + + break; } } } } } - var addResult = _dal.Add(item); - + _dal.Add(item); //更新小时数据 UpdateHourInfo(item); } @@ -102,15 +108,14 @@ namespace Admin.Core.Service.Service_New { try { - //可以完工执行计划 var boxFoamTypeList = _boxFoamTypeServices.Query(x => x.Boxtype == item.FixtureBoxType); //MaterialCode物料型号 if (boxFoamTypeList != null) { if (boxFoamTypeList.Count > 0) { - var boxFoamType = boxFoamTypeList.First(); - if (boxFoamType != null) + + foreach (var boxFoamType in boxFoamTypeList) { var boxPlanList = _boxFoamPlanServices.Query(x => x.MaterialCode == boxFoamType.MaterialCode && x.PlanAmount > x.CompleteAmount); if (boxPlanList != null) @@ -132,11 +137,14 @@ namespace Admin.Core.Service.Service_New { Console.WriteLine("生产计划更新失败"); } - } + break; + } } } } + + } } }catch (Exception ex) diff --git a/Aucma.Core.OldBoxFoam/Business/Collection.cs b/Aucma.Core.OldBoxFoam/Business/Collection.cs index 5e5cf513..d4042be2 100644 --- a/Aucma.Core.OldBoxFoam/Business/Collection.cs +++ b/Aucma.Core.OldBoxFoam/Business/Collection.cs @@ -111,7 +111,7 @@ namespace Aucma.Core.OldBoxFoam.Business fixtureComplates.Add(new RecordBoxFoamFixtureComplate() { ProductionLine = "CX_01", - StationCode = "1002", + StationCode = "1005", FixtureCode = x.ObjId, FixtureBoxType = x.FixtureBoxType, FixtureStatus = x.Status, diff --git a/Aucma.Core.OldBoxFoam/ViewModels/FoamPlanPageViewModel.cs b/Aucma.Core.OldBoxFoam/ViewModels/FoamPlanPageViewModel.cs index 6c0c9919..b2ccf148 100644 --- a/Aucma.Core.OldBoxFoam/ViewModels/FoamPlanPageViewModel.cs +++ b/Aucma.Core.OldBoxFoam/ViewModels/FoamPlanPageViewModel.cs @@ -13,6 +13,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows; @@ -26,15 +27,33 @@ namespace Aucma.Core.OldBoxFoam.ViewModels { protected readonly IBoxFoamPlanServices? _boxFoamPlanServices; private readonly ICurrentTeamTimeServices _currentTeamTimeServices; - public Collection collect= new Collection(); + + private Collection collection = new Collection(); + public FoamPlanPageViewModel() { _boxFoamPlanServices = App.ServiceProvider.GetService(); _currentTeamTimeServices = App.ServiceProvider.GetService(); WeakReferenceMessenger.Default.Register(this, Recive); - InitData(); + //InitData(); + + Task.Run(() => + { + while (true) + { + + App.Current.Dispatcher.BeginInvoke((Action)(() => + { + InitData(); + })); + + Thread.Sleep(1000 * 5); + }; + }); + } + #region 删除 /// /// 删除 @@ -53,17 +72,17 @@ namespace Aucma.Core.OldBoxFoam.ViewModels } #endregion - public async void InitData() + private void InitData() { ListItems1.Clear(); ListItems.Clear(); int count = 0; DateTime now=DateTime.Now; - CurrentTeamTime time = await _currentTeamTimeServices.FirstAsync(d => d.StartTime <= now && d.EndTime >= now); + CurrentTeamTime time = _currentTeamTimeServices.FirstAsync(d => d.StartTime <= now && d.EndTime >= now).Result; if (time == null) return; if (time.TeamName.Equals("早班")) { - List list = await _boxFoamPlanServices.QueryAsync(d=>d.ShiftType==1); + List list = _boxFoamPlanServices.QueryAsync(d=>d.ShiftType==1).Result; if (list == null) return; foreach (BoxFoamPlan item in list) { @@ -82,7 +101,7 @@ namespace Aucma.Core.OldBoxFoam.ViewModels if (time.TeamName.Equals("晚班")) { - List list = await _boxFoamPlanServices.QueryAsync(d => d.ShiftType == 1); + List list = _boxFoamPlanServices.QueryAsync(d => d.ShiftType == 1).Result; if (list == null) return; foreach (BoxFoamPlan item in list) { diff --git a/Aucma.Core.OldBoxFoam/Views/SplitPlanView.xaml b/Aucma.Core.OldBoxFoam/Views/SplitPlanView.xaml index bf4a1ac1..cd52a05e 100644 --- a/Aucma.Core.OldBoxFoam/Views/SplitPlanView.xaml +++ b/Aucma.Core.OldBoxFoam/Views/SplitPlanView.xaml @@ -189,6 +189,8 @@ + + diff --git a/Aucma.Core.OldBoxFoam/appsettings.json b/Aucma.Core.OldBoxFoam/appsettings.json index 2ef0518b..a6e1675e 100644 --- a/Aucma.Core.OldBoxFoam/appsettings.json +++ b/Aucma.Core.OldBoxFoam/appsettings.json @@ -194,7 +194,7 @@ }, "StationInfo": { "ProductLineCode": "CX_01", - "StationCode": "1100" + "StationCode": "1006" }, "PLCServer": [