change-成品下线图表展示

dev
liuwf 1 year ago
parent 35d5943504
commit ff0332569f

@ -18,6 +18,6 @@ namespace Admin.Core.IService
/// </summary>
public Task<List<ChartsByTime>> QueryCharts(DateTime startTime, DateTime endTime);
public List<dynamic> QueryCharts1(string stationCode);
}
}

@ -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; }
}
}

@ -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;
}
/// <summary>
/// 图表统计,按白夜班时间
/// </summary>
@ -26,7 +30,7 @@ namespace Admin.Core.Service
{
List<ChartsByTime> list = null;
var _db = this.BaseDal.Db;
list = await _db.Ado.SqlQueryAsync<ChartsByTime>($"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<ChartsByTime>("SELECT * FROM GET_OFFLINE_HOURAMOUNT");
return list;
}
catch (Exception)
@ -34,5 +38,27 @@ namespace Admin.Core.Service
return null;
}
}
/// <summary>
/// 图表统计,按白夜班时间
/// </summary>
public List<dynamic> QueryCharts1(string stationCode)
{
List<dynamic> result = null;
try
{
var _db = this.BaseDal.Db;
result = _db.Queryable<dynamic>().AS("GET_OFFLINE_HOURAMOUNT").Where("PRODUCTLINE_CODE = @stationCode", new { stationCode = stationCode }).ToList();
}
catch (Exception ex)
{
}
return result;
}
}
}

@ -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
{
{
/// <summary>
/// 成品下线按小时统计
/// </summary>
[SugarTable("GET_OFFLINE_HOURAMOUNT", "AUCMA_SCADA")]
public class ChartsByTime
{
public string time;
public int Amount;
/// <summary>
/// 产线
/// </summary>
[SugarColumn(ColumnName = "PRODUCTLINE_CODE")]
public string ProductCode { get; set; }
/// <summary>
/// 日期
/// </summary>
[SugarColumn(ColumnName = "PRODUCT_DATE")]
public DateTime ProductDate { get; set; }
/// <summary>
/// 小时
/// </summary>
[SugarColumn(ColumnName = "PRODUCT_HOUR")]
public int ProductHour { get; set; }
/// <summary>
/// 每小时产量
/// </summary>
[SugarColumn(ColumnName = "PRODUCT_AMOUNT")]
public int ProductAmount { get; set; }
}
}

@ -311,16 +311,20 @@ namespace Aucma.Core.ProductOffLine.ViewModels
LoadData();
List<WorkTime> 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<dynamic> hourAmount = _offLineInfoServices.QueryCharts1("CX_01");
List<Admin.Core.Model.ViewModels.ChartsByTime> 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<string> xList = new List<string>();
ChartValues<double> achievement2 = new ChartValues<double>();
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();

Loading…
Cancel
Save