diff --git a/Admin.Core.IService/IService_New/IOffLineInfoServices.cs b/Admin.Core.IService/IService_New/IOffLineInfoServices.cs index 169ab02f..f2b12fd8 100644 --- a/Admin.Core.IService/IService_New/IOffLineInfoServices.cs +++ b/Admin.Core.IService/IService_New/IOffLineInfoServices.cs @@ -18,6 +18,6 @@ namespace Admin.Core.IService /// public Task> QueryCharts(DateTime startTime, DateTime endTime); - + public List QueryCharts1(string stationCode); } } \ No newline at end of file diff --git a/Admin.Core.Model/ViewModels/ChartsByTime.cs b/Admin.Core.Model/ViewModels/ChartsByTime.cs index 85f366f4..a02839b5 100644 --- a/Admin.Core.Model/ViewModels/ChartsByTime.cs +++ b/Admin.Core.Model/ViewModels/ChartsByTime.cs @@ -10,9 +10,12 @@ namespace Admin.Core.Model.ViewModels [SugarTable("PRODUCT_OFFLINE", "AUCMA_SCADA")] public class ChartsByTime { - [SugarColumn(ColumnName = "HourlyTime")] - public string time { get; set; } - [SugarColumn(ColumnName = "AMOUNT")] + [SugarColumn(ColumnName = "PRODUCTLINE_CODE")] + public string productLineCode { get; set; } + + [SugarColumn(ColumnName = "PRODUCT_HOUR")] + public string hour { get; set; } + [SugarColumn(ColumnName = "PRODUCT_AMOUNT")] public int Amount { get; set; } } } diff --git a/Admin.Core.Service/Service_New/OffLineInfoServices.cs b/Admin.Core.Service/Service_New/OffLineInfoServices.cs index 00a0ff75..3a47bfc5 100644 --- a/Admin.Core.Service/Service_New/OffLineInfoServices.cs +++ b/Admin.Core.Service/Service_New/OffLineInfoServices.cs @@ -3,6 +3,7 @@ using Admin.Core.IService; using Admin.Core.Model; using Admin.Core.Model.Model_New; using Admin.Core.Model.ViewModels; +using Microsoft.IdentityModel.Logging; using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -17,6 +18,9 @@ namespace Admin.Core.Service this._dal = dal; base.BaseDal = dal; } + + + /// /// 图表统计,按白夜班时间 /// @@ -26,7 +30,7 @@ namespace Admin.Core.Service { 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"); + list = await _db.Ado.SqlQueryAsync("SELECT * FROM GET_OFFLINE_HOURAMOUNT"); return list; } catch (Exception) @@ -34,5 +38,27 @@ namespace Admin.Core.Service return null; } } + + + /// + /// 图表统计,按白夜班时间 + /// + public List QueryCharts1(string stationCode) + { + List result = null; + try + { + var _db = this.BaseDal.Db; + + + result = _db.Queryable().AS("GET_OFFLINE_HOURAMOUNT").Where("PRODUCTLINE_CODE = @stationCode", new { stationCode = stationCode }).ToList(); + + } + catch (Exception ex) + { + + } + return result; + } } } \ No newline at end of file diff --git a/Aucma.Core.ProductOffLine/Models/ChartsByTime.cs b/Aucma.Core.ProductOffLine/Models/ChartsByTime.cs index b597b209..3bdd2d94 100644 --- a/Aucma.Core.ProductOffLine/Models/ChartsByTime.cs +++ b/Aucma.Core.ProductOffLine/Models/ChartsByTime.cs @@ -1,4 +1,5 @@ using NPOI.OpenXmlFormats.Dml.Chart; +using SqlSugar; using System; using System.Collections.Generic; using System.Linq; @@ -6,10 +7,33 @@ using System.Text; using System.Threading.Tasks; namespace Aucma.Core.ProductOffLine.Models -{ +{ + /// + /// 成品下线按小时统计 + /// + [SugarTable("GET_OFFLINE_HOURAMOUNT", "AUCMA_SCADA")] public class ChartsByTime { - public string time; - public int Amount; + /// + /// 产线 + /// + [SugarColumn(ColumnName = "PRODUCTLINE_CODE")] + public string ProductCode { get; set; } + /// + /// 日期 + /// + [SugarColumn(ColumnName = "PRODUCT_DATE")] + public DateTime ProductDate { get; set; } + /// + /// 小时 + /// + [SugarColumn(ColumnName = "PRODUCT_HOUR")] + public int ProductHour { get; set; } + /// + /// 每小时产量 + /// + [SugarColumn(ColumnName = "PRODUCT_AMOUNT")] + public int ProductAmount { get; set; } + } } diff --git a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs index 932d86d3..4e53c4a5 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs @@ -311,16 +311,20 @@ namespace Aucma.Core.ProductOffLine.ViewModels LoadData(); List listTime = await _baseBomInfoServices.getWorkTime(); if (listTime == null) return; - // var aa =_offLineInfoServices.Query(x=>x.ProductScanTime>= listTime[0].startTime && x.ProductScanTime<= listTime[11].startTime); - + // var aa =_offLineInfoServices.Query(x=>x.ProductScanTime>= listTime[0].startTime && x.ProductScanTime<= listTime[11].startTime); + // List hourAmount = _offLineInfoServices.QueryCharts1("CX_01"); List list = await _offLineInfoServices.QueryCharts(listTime[0].startTime, listTime[11].startTime); if (list == null) return; + var aaa= list.Where(x => int.Parse(x.hour) >= listTime[0].startTime.Hour && int.Parse(x.hour) <= listTime[11].startTime.Hour && x.productLineCode.Equals("CX_02")); + string aa =listTime.First().hourTime.Substring(0, 2); + List xList = new List(); ChartValues achievement2 = new ChartValues(); + for (int i = 0; i < 12; i++) { - xList.Add(list[i].time.Substring(11, 2) + ":00"); + // xList.Add(list[i].time.Substring(11, 2) + ":00"); achievement2.Add(list[i].Amount); } var column2 = new ColumnSeries();