diff --git a/Admin.Core.IService/IService_New/IBaseBomInfoServices.cs b/Admin.Core.IService/IService_New/IBaseBomInfoServices.cs index 20750a23..bcd8f966 100644 --- a/Admin.Core.IService/IService_New/IBaseBomInfoServices.cs +++ b/Admin.Core.IService/IService_New/IBaseBomInfoServices.cs @@ -1,5 +1,6 @@ using Admin.Core.IService; using Admin.Core.Model; +using Admin.Core.Model.ViewModels; using System.Collections.Generic; using System.Threading.Tasks; @@ -11,6 +12,10 @@ namespace Admin.Core.IService public interface IBaseBomInfoServices : IBaseServices { + /// + /// 获取系统班组时间 + /// + public Task> getWorkTime(); /// /// 根据成品物料码获取自己BOM信息 /// diff --git a/Admin.Core.IService/IService_New/IOffLineInfoServices.cs b/Admin.Core.IService/IService_New/IOffLineInfoServices.cs index 1b854f37..169ab02f 100644 --- a/Admin.Core.IService/IService_New/IOffLineInfoServices.cs +++ b/Admin.Core.IService/IService_New/IOffLineInfoServices.cs @@ -2,6 +2,7 @@ using Admin.Core.Model; using Admin.Core.Model.Model_New; using Admin.Core.Model.ViewModels; +using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -12,7 +13,11 @@ namespace Admin.Core.IService /// public interface IOffLineInfoServices : IBaseServices { + /// + /// 图表统计,按白夜班时间 + /// + public Task> QueryCharts(DateTime startTime, DateTime endTime); + - } } \ No newline at end of file diff --git a/Admin.Core.Model/ViewModels/ChartsByTime.cs b/Admin.Core.Model/ViewModels/ChartsByTime.cs new file mode 100644 index 00000000..85f366f4 --- /dev/null +++ b/Admin.Core.Model/ViewModels/ChartsByTime.cs @@ -0,0 +1,18 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Admin.Core.Model.ViewModels +{ + [SugarTable("PRODUCT_OFFLINE", "AUCMA_SCADA")] + public class ChartsByTime + { + [SugarColumn(ColumnName = "HourlyTime")] + public string time { get; set; } + [SugarColumn(ColumnName = "AMOUNT")] + public int Amount { get; set; } + } +} diff --git a/Admin.Core.Model/ViewModels/WorkTime.cs b/Admin.Core.Model/ViewModels/WorkTime.cs new file mode 100644 index 00000000..78a61b27 --- /dev/null +++ b/Admin.Core.Model/ViewModels/WorkTime.cs @@ -0,0 +1,32 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Admin.Core.Model.ViewModels +{ + /// + /// 条码绑定扫描类型统计 + /// + [SugarTable("VIEW_CURRENT_TEAM_TIME", "AUCMA_MES")] + public class WorkTime + { + /// + /// 开始时间 + /// + [SugarColumn(ColumnName = "START_TIME")] + public DateTime startTime { get; set; } + /// + /// 结束时间 + /// + [SugarColumn(ColumnName = "END_TIME")] + public DateTime endTime { get; set; } + [SugarColumn(ColumnName = "HOUR_TIME")] + public string hourTime { get; set; } + [SugarColumn(ColumnName = "TEAM_NAME")] + public string teamName { get; set; } + + } +} diff --git a/Admin.Core.Service/Service_New/BaseBomInfoServices.cs b/Admin.Core.Service/Service_New/BaseBomInfoServices.cs index 2cf44d2c..ca4ca95b 100644 --- a/Admin.Core.Service/Service_New/BaseBomInfoServices.cs +++ b/Admin.Core.Service/Service_New/BaseBomInfoServices.cs @@ -2,9 +2,11 @@ using Admin.Core.IService; using Admin.Core.Model; using Admin.Core.Model.Model_New; +using Admin.Core.Model.ViewModels; using log4net; using Microsoft.AspNetCore.Razor.TagHelpers; using Microsoft.IdentityModel.Logging; +using NPOI.XSSF.UserModel; using System; using System.Collections.Generic; using System.Linq; @@ -22,6 +24,26 @@ namespace Admin.Core.Service base.BaseDal = dal; } + /// + /// 获取系统班组时间 + /// + public async Task> getWorkTime() + { + try + { + List list = null; + var _db = this.BaseDal.Db; + list = await _db.Ado.SqlQueryAsync("SELECT * FROM VIEW_CURRENT_TEAM_TIME ORDER BY START_TIME"); + return list; + } + catch (Exception) + { + return null; + } + } + + /// + /// public async Task GetBomInfoByMaterialCode(string materialCode) { BaseBomInfo bomInfo = null; diff --git a/Admin.Core.Service/Service_New/OffLineInfoServices.cs b/Admin.Core.Service/Service_New/OffLineInfoServices.cs index a565cf55..00a0ff75 100644 --- a/Admin.Core.Service/Service_New/OffLineInfoServices.cs +++ b/Admin.Core.Service/Service_New/OffLineInfoServices.cs @@ -2,6 +2,10 @@ using Admin.Core.IService; using Admin.Core.Model; using Admin.Core.Model.Model_New; +using Admin.Core.Model.ViewModels; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; namespace Admin.Core.Service { @@ -13,5 +17,22 @@ namespace Admin.Core.Service this._dal = dal; base.BaseDal = dal; } + /// + /// 图表统计,按白夜班时间 + /// + public async Task> QueryCharts(DateTime startTime, DateTime endTime) + { + try + { + List list = null; + var _db = this.BaseDal.Db; + list = await _db.Ado.SqlQueryAsync($"WITH AllHours AS (SELECT TO_CHAR(to_date('{startTime}', 'YYYY-MM-DD HH24:MI:SS') + (LEVEL-1)/24, 'YYYY-MM-DD HH24') AS Hour FROM dual CONNECT BY LEVEL <= 12)SELECT AllHours.Hour AS HourlyTime, COUNT(PRODUCT_OFFLINE.PRODUCT_SCANTIME) AS Amount FROM AllHours LEFT JOIN AUCMA_SCADA.PRODUCT_OFFLINE ON AllHours.Hour = TO_CHAR(PRODUCT_OFFLINE.PRODUCT_SCANTIME, 'YYYY-MM-DD HH24') AND PRODUCT_OFFLINE.PRODUCT_SCANTIME >= TO_DATE('{startTime}', 'YYYY-MM-DD HH24:MI:SS') AND PRODUCT_OFFLINE.PRODUCT_SCANTIME <= TO_DATE('{endTime}', 'YYYY-MM-DD HH24:MI:SS') GROUP BY AllHours.Hour ORDER BY AllHours.Hour"); + return list; + } + catch (Exception) + { + return null; + } + } } } \ No newline at end of file diff --git a/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs b/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs index 6029ed3c..bd5f054d 100644 --- a/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs @@ -129,10 +129,11 @@ namespace Aucma.Core.CodeBinding.ViewModels { } } - // 修改为统计近一天 + // 修改为统计近一天白班或夜班 private async void LoadCharts() { - List list = await _codeBindingRecordServices.QueryCharts(); + + List list = await _codeBindingRecordServices.QueryCharts(); // 图表赋值 ChartValues achievement = new ChartValues(); List chartList = new List(); diff --git a/Aucma.Core.ProductOffLine/Models/ChartsByTime.cs b/Aucma.Core.ProductOffLine/Models/ChartsByTime.cs new file mode 100644 index 00000000..b597b209 --- /dev/null +++ b/Aucma.Core.ProductOffLine/Models/ChartsByTime.cs @@ -0,0 +1,15 @@ +using NPOI.OpenXmlFormats.Dml.Chart; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Aucma.Core.ProductOffLine.Models +{ + public class ChartsByTime + { + public string time; + public int Amount; + } +} diff --git a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs index b3dbf712..583cdff6 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs @@ -35,6 +35,7 @@ using System.Windows; using System.Collections.ObjectModel; using Aucma.Core.ProductOffLine.Models; using System.Globalization; +using Admin.Core.Model.ViewModels; /* @@ -51,17 +52,18 @@ namespace Aucma.Core.ProductOffLine.ViewModels private readonly IOffLineInfoServices? _offLineInfoServices = App.ServiceProvider.GetService(); System.Timers.Timer timer = new System.Timers.Timer(1000 * 1);//界面刷新定时器 - + private readonly IBaseBomInfoServices? _baseBomInfoServices; private OffLineBusiness offLineBusiness = OffLineBusiness.Instance; int a = 0; public IndexPageViewModel() { offLineBusiness.test(); _offLineInfoServices = App.ServiceProvider.GetService(); + _baseBomInfoServices = App.ServiceProvider.GetService(); InitEveryDayMethod(); // 刷新界面信息 RefreshPageListen(); - + } #region 参数定义 @@ -303,10 +305,29 @@ namespace Aucma.Core.ProductOffLine.ViewModels } #endregion - private void InitEveryDayMethod() + private async void InitEveryDayMethod() { LoadData(); - BeginTime = DateTime.Now.ToString("yyyy-mm-dd HH:mm:ss"); + List listTime = await _baseBomInfoServices.getWorkTime(); + if (listTime == null) return; + List list = await _offLineInfoServices.QueryCharts(listTime[0].startTime, listTime[11].startTime); + if (list == null) return; + List xList =new List(); + ChartValues achievement2 = new ChartValues(); + for (int i = 0; i < 12; i++) + { + xList.Add(list[i].time.Substring(11, 2)+":00"); + achievement2.Add(list[i].Amount); + } + var column2 = new ColumnSeries(); + column2.DataLabels = true; + column2.Title = "产量"; + column2.Values = achievement2; + column2.Foreground = Brushes.White; + Achievement.Add(column2); + ProductionHourList = xList; + + ChartValues achievement = new ChartValues(); Random random = new Random(); for (int i = 0; i < 5; i++) @@ -329,29 +350,6 @@ namespace Aucma.Core.ProductOffLine.ViewModels "SC-439,背板", "SC-439VAM,元气森林,C", }; - ProductionHourList = new List() - { - "12", - "13", - "14", - "15", - "16", - }; - - ChartValues achievement2 = new ChartValues(); - Random random2 = new Random(); - for (int i = 0; i < 5; i++) - { - achievement2.Add(random2.Next(60, 100)); - } - var column2 = new ColumnSeries(); - column2.DataLabels = true; - column2.Title = "产量"; - column2.Values = achievement2; - column2.Foreground = Brushes.White; - Achievement.Add(column2); - // 加载datagrid - } public async void LoadData() { diff --git a/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml b/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml index 347f4f38..83347bf3 100644 --- a/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml +++ b/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml @@ -245,6 +245,7 @@ +