|
@@ -10,8 +10,10 @@ using OfficeOpenXml.Drawing.Chart;
|
|
using OfficeOpenXml.Style;
|
|
using OfficeOpenXml.Style;
|
|
using ProductionLineMonitor.Application.Services.FaultService;
|
|
using ProductionLineMonitor.Application.Services.FaultService;
|
|
using ProductionLineMonitor.Application.Services.OEEService;
|
|
using ProductionLineMonitor.Application.Services.OEEService;
|
|
|
|
+using ProductionLineMonitor.Application.Services.OEEService.Dtos;
|
|
using ProductionLineMonitor.Core.Dtos;
|
|
using ProductionLineMonitor.Core.Dtos;
|
|
using ProductionLineMonitor.Core.IRepositories;
|
|
using ProductionLineMonitor.Core.IRepositories;
|
|
|
|
+using ProductionLineMonitor.Core.Models;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Drawing;
|
|
@@ -50,11 +52,13 @@ namespace ProductionLineMonitor.Application.Services
|
|
}
|
|
}
|
|
|
|
|
|
JToken? UtilizationRateEmailList;
|
|
JToken? UtilizationRateEmailList;
|
|
|
|
+ JToken? ExcelChartsSettings;
|
|
using (StreamReader file = File.OpenText("D:\\ReportForms\\Email.json"))
|
|
using (StreamReader file = File.OpenText("D:\\ReportForms\\Email.json"))
|
|
{
|
|
{
|
|
using JsonTextReader reader = new JsonTextReader(file);
|
|
using JsonTextReader reader = new JsonTextReader(file);
|
|
JObject jsonObject = (JObject)JToken.ReadFrom(reader);
|
|
JObject jsonObject = (JObject)JToken.ReadFrom(reader);
|
|
UtilizationRateEmailList = jsonObject["UtilizationRateEmail"];
|
|
UtilizationRateEmailList = jsonObject["UtilizationRateEmail"];
|
|
|
|
+ ExcelChartsSettings = jsonObject["ExcelChartsSettings"];
|
|
}
|
|
}
|
|
|
|
|
|
if (UtilizationRateEmailList == null || UtilizationRateEmailList.Count() == 0)
|
|
if (UtilizationRateEmailList == null || UtilizationRateEmailList.Count() == 0)
|
|
@@ -90,6 +94,18 @@ namespace ProductionLineMonitor.Application.Services
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ var HideEquipmentProduction = ExcelChartsSettings["HideEquipmentProduction"].ToString().Split(',');
|
|
|
|
+
|
|
|
|
+ //List<int> [产能,稼动,待机,报警,待料,合计]
|
|
|
|
+ Dictionary<string, List<int>> OEE_Temp1 = new Dictionary<string, List<int>>();
|
|
|
|
+ //List<int> [运行时间,报警时间,待料时间,换料时间,产能,报警次数]
|
|
|
|
+ Dictionary<string, List<int>> OEE_Temp2 = new Dictionary<string, List<int>>();
|
|
|
|
+ //机种
|
|
|
|
+ List<List<string>> ModuleType = new List<List<string>>();
|
|
|
|
+ for (int i = 0; i < 24; i++)
|
|
|
|
+ ModuleType.Add(new List<string>());
|
|
|
|
+
|
|
|
|
+
|
|
foreach (var machineId in machineIdString)
|
|
foreach (var machineId in machineIdString)
|
|
{
|
|
{
|
|
var machine = _unitOfWork.MachineRepository.GetById(machineId);
|
|
var machine = _unitOfWork.MachineRepository.GetById(machineId);
|
|
@@ -108,6 +124,7 @@ namespace ProductionLineMonitor.Application.Services
|
|
using ExcelPackage package = new ExcelPackage(file);
|
|
using ExcelPackage package = new ExcelPackage(file);
|
|
|
|
|
|
ExcelWorksheet worksheet = package.Workbook.Worksheets.Add($"{line.Name} {machine.Name}");
|
|
ExcelWorksheet worksheet = package.Workbook.Worksheets.Add($"{line.Name} {machine.Name}");
|
|
|
|
+
|
|
worksheet.View.ZoomScale = 80;
|
|
worksheet.View.ZoomScale = 80;
|
|
|
|
|
|
worksheet.Cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
|
worksheet.Cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
|
@@ -235,8 +252,9 @@ namespace ProductionLineMonitor.Application.Services
|
|
|
|
|
|
for (int i = 0; i < machineOEE.Count; i++)
|
|
for (int i = 0; i < machineOEE.Count; i++)
|
|
{
|
|
{
|
|
|
|
+ string dateStr = machineOEE[i].Date + " " + machineOEE[i].Shift;
|
|
worksheet.Cells[i + 2, 1].Value = i + 1;
|
|
worksheet.Cells[i + 2, 1].Value = i + 1;
|
|
- worksheet.Cells[i + 2, 2].Value = machineOEE[i].Date + " " + machineOEE[i].Shift;
|
|
|
|
|
|
+ worksheet.Cells[i + 2, 2].Value = dateStr;
|
|
worksheet.Cells[i + 2, 3].Value = (int)machineOEE[i].RunTimeRate;
|
|
worksheet.Cells[i + 2, 3].Value = (int)machineOEE[i].RunTimeRate;
|
|
worksheet.Cells[i + 2, 4].Value = (int)machineOEE[i].IdelTimeRate;
|
|
worksheet.Cells[i + 2, 4].Value = (int)machineOEE[i].IdelTimeRate;
|
|
worksheet.Cells[i + 2, 5].Value = (int)machineOEE[i].DownTimeRate;
|
|
worksheet.Cells[i + 2, 5].Value = (int)machineOEE[i].DownTimeRate;
|
|
@@ -248,12 +266,34 @@ namespace ProductionLineMonitor.Application.Services
|
|
worksheet.Cells[i + 2, 11].Value = machineOEE[i].LoadMATTime / 60;
|
|
worksheet.Cells[i + 2, 11].Value = machineOEE[i].LoadMATTime / 60;
|
|
worksheet.Cells[i + 2, 12].Value
|
|
worksheet.Cells[i + 2, 12].Value
|
|
= (machineOEE[i].RunTime + machineOEE[i].IdelTime + machineOEE[i].DownTime + machineOEE[i].LoadMATTime) / 60;
|
|
= (machineOEE[i].RunTime + machineOEE[i].IdelTime + machineOEE[i].DownTime + machineOEE[i].LoadMATTime) / 60;
|
|
|
|
+ if (OEE_Temp1.ContainsKey(dateStr))
|
|
|
|
+ {
|
|
|
|
+ OEE_Temp1[dateStr][0] += machineOEE[i].Outputs;
|
|
|
|
+ OEE_Temp1[dateStr][1] += machineOEE[i].RunTime;
|
|
|
|
+ OEE_Temp1[dateStr][2] += machineOEE[i].IdelTime;
|
|
|
|
+ OEE_Temp1[dateStr][3] += machineOEE[i].DownTime;
|
|
|
|
+ OEE_Temp1[dateStr][4] += machineOEE[i].LoadMATTime;
|
|
|
|
+ OEE_Temp1[dateStr][5]
|
|
|
|
+ += machineOEE[i].RunTime + machineOEE[i].IdelTime + machineOEE[i].DownTime + machineOEE[i].LoadMATTime;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ List<int> list_temp = new List<int>();
|
|
|
|
+ list_temp.Add(machineOEE[i].Outputs);
|
|
|
|
+ list_temp.Add(machineOEE[i].RunTime);
|
|
|
|
+ list_temp.Add(machineOEE[i].IdelTime);
|
|
|
|
+ list_temp.Add(machineOEE[i].DownTime);
|
|
|
|
+ list_temp.Add(machineOEE[i].LoadMATTime);
|
|
|
|
+ list_temp.Add(machineOEE[i].RunTime + machineOEE[i].IdelTime + machineOEE[i].DownTime + machineOEE[i].LoadMATTime);
|
|
|
|
+ OEE_Temp1.Add(dateStr, list_temp);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if (machineHourDatas != null)
|
|
if (machineHourDatas != null)
|
|
{
|
|
{
|
|
if (machineHourDatas.Count == 24)
|
|
if (machineHourDatas.Count == 24)
|
|
{
|
|
{
|
|
|
|
+ List<string> temp = new List<string>();
|
|
{
|
|
{
|
|
int autoSum = 0;
|
|
int autoSum = 0;
|
|
int alarmTimeSum = 0;
|
|
int alarmTimeSum = 0;
|
|
@@ -264,11 +304,11 @@ namespace ProductionLineMonitor.Application.Services
|
|
int loadTimeSum = 0;
|
|
int loadTimeSum = 0;
|
|
for (int i = 0; i < 12; i++)
|
|
for (int i = 0; i < 12; i++)
|
|
{
|
|
{
|
|
- int auto = machineHourDatas[i].AutoRunTime.Value / 60;
|
|
|
|
|
|
+ int auto = (int)Math.Round(machineHourDatas[i].AutoRunTime.Value / 60.0);
|
|
autoSum += auto;
|
|
autoSum += auto;
|
|
- int alarmTime = machineHourDatas[i].AlarmTime.Value / 60;
|
|
|
|
|
|
+ int alarmTime = (int)Math.Round(machineHourDatas[i].AlarmTime.Value / 60.0);
|
|
alarmTimeSum += alarmTime;
|
|
alarmTimeSum += alarmTime;
|
|
- int idel = machineHourDatas[i].IdleTime.Value / 60;
|
|
|
|
|
|
+ int idel = (int)Math.Round(machineHourDatas[i].IdleTime.Value / 60.0);
|
|
idelSum += idel;
|
|
idelSum += idel;
|
|
int output = machineHourDatas[i].OutPut.Value;
|
|
int output = machineHourDatas[i].OutPut.Value;
|
|
outputSum += output;
|
|
outputSum += output;
|
|
@@ -276,11 +316,19 @@ namespace ProductionLineMonitor.Application.Services
|
|
//ttSum += tt;
|
|
//ttSum += tt;
|
|
int alarm = machineHourDatas[i].AlarmSum.Value;
|
|
int alarm = machineHourDatas[i].AlarmSum.Value;
|
|
alarmSum += alarm;
|
|
alarmSum += alarm;
|
|
- int loadTime = machineHourDatas[i].LoadMATTime.Value / 60;
|
|
|
|
|
|
+ int loadTime = (int)Math.Round(machineHourDatas[i].LoadMATTime.Value / 60.0);
|
|
loadTimeSum += loadTime;
|
|
loadTimeSum += loadTime;
|
|
|
|
|
|
|
|
+ string periodStr = machineHourDatas[i].Period;
|
|
|
|
+ string moduleTypeStr = machineHourDatas[i].ModuleType;
|
|
|
|
+
|
|
|
|
+ if (ModuleType[i] == null || ModuleType[i].Count == 0 || !ModuleType[i].Contains(moduleTypeStr))
|
|
|
|
+ {
|
|
|
|
+ ModuleType[i].Add(moduleTypeStr);
|
|
|
|
+ }
|
|
|
|
+
|
|
worksheet.Cells[i + 3, 15].Value = i + 1;
|
|
worksheet.Cells[i + 3, 15].Value = i + 1;
|
|
- worksheet.Cells[i + 3, 16].Value = machineHourDatas[i].Period;
|
|
|
|
|
|
+ worksheet.Cells[i + 3, 16].Value = periodStr;
|
|
worksheet.Cells[i + 3, 17].Value = machineHourDatas[i].ModuleType;
|
|
worksheet.Cells[i + 3, 17].Value = machineHourDatas[i].ModuleType;
|
|
worksheet.Cells[i + 3, 18].Value = auto;
|
|
worksheet.Cells[i + 3, 18].Value = auto;
|
|
worksheet.Cells[i + 3, 19].Value = alarmTime;
|
|
worksheet.Cells[i + 3, 19].Value = alarmTime;
|
|
@@ -289,6 +337,28 @@ namespace ProductionLineMonitor.Application.Services
|
|
worksheet.Cells[i + 3, 22].Value = output;
|
|
worksheet.Cells[i + 3, 22].Value = output;
|
|
worksheet.Cells[i + 3, 23].Value = Math.Round(tt, 2);
|
|
worksheet.Cells[i + 3, 23].Value = Math.Round(tt, 2);
|
|
worksheet.Cells[i + 3, 24].Value = alarm;
|
|
worksheet.Cells[i + 3, 24].Value = alarm;
|
|
|
|
+
|
|
|
|
+ if (OEE_Temp2.ContainsKey(periodStr))
|
|
|
|
+ {
|
|
|
|
+ OEE_Temp2[periodStr][0] += auto;
|
|
|
|
+ OEE_Temp2[periodStr][1] += alarmTime;
|
|
|
|
+ OEE_Temp2[periodStr][2] += idel;
|
|
|
|
+ OEE_Temp2[periodStr][3] += loadTime;
|
|
|
|
+ OEE_Temp2[periodStr][4] += output;
|
|
|
|
+ OEE_Temp2[periodStr][5] += alarm;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ List<int> list_temp = new List<int>();
|
|
|
|
+ list_temp.Add(auto);
|
|
|
|
+ list_temp.Add(alarmTime);
|
|
|
|
+ list_temp.Add(idel);
|
|
|
|
+ list_temp.Add(loadTime);
|
|
|
|
+ list_temp.Add(output);
|
|
|
|
+ list_temp.Add(alarm);
|
|
|
|
+ OEE_Temp2.Add(periodStr, list_temp);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
worksheet.Cells[15, 15].Value = "合计";
|
|
worksheet.Cells[15, 15].Value = "合计";
|
|
@@ -326,11 +396,11 @@ namespace ProductionLineMonitor.Application.Services
|
|
int loadTimeSum = 0;
|
|
int loadTimeSum = 0;
|
|
for (int i = 12; i < 24; i++)
|
|
for (int i = 12; i < 24; i++)
|
|
{
|
|
{
|
|
- int auto = machineHourDatas[i].AutoRunTime.Value / 60;
|
|
|
|
|
|
+ int auto = (int)Math.Round(machineHourDatas[i].AutoRunTime.Value / 60.0);
|
|
autoSum += auto;
|
|
autoSum += auto;
|
|
- int alarmTime = machineHourDatas[i].AlarmTime.Value / 60;
|
|
|
|
|
|
+ int alarmTime = (int)Math.Round(machineHourDatas[i].AlarmTime.Value / 60.0);
|
|
alarmTimeSum += alarmTime;
|
|
alarmTimeSum += alarmTime;
|
|
- int idel = machineHourDatas[i].IdleTime.Value / 60;
|
|
|
|
|
|
+ int idel = (int)Math.Round(machineHourDatas[i].IdleTime.Value / 60.0);
|
|
idelSum += idel;
|
|
idelSum += idel;
|
|
int output = machineHourDatas[i].OutPut.Value;
|
|
int output = machineHourDatas[i].OutPut.Value;
|
|
outputSum += output;
|
|
outputSum += output;
|
|
@@ -338,9 +408,17 @@ namespace ProductionLineMonitor.Application.Services
|
|
//ttSum += tt;
|
|
//ttSum += tt;
|
|
int alarm = machineHourDatas[i].AlarmSum.Value;
|
|
int alarm = machineHourDatas[i].AlarmSum.Value;
|
|
alarmSum += alarm;
|
|
alarmSum += alarm;
|
|
- int loadTime = machineHourDatas[i].LoadMATTime.Value / 60;
|
|
|
|
|
|
+ int loadTime = (int)Math.Round(machineHourDatas[i].LoadMATTime.Value / 60.0);
|
|
loadTimeSum += loadTime;
|
|
loadTimeSum += loadTime;
|
|
|
|
|
|
|
|
+ string periodStr = machineHourDatas[i].Period;
|
|
|
|
+ string moduleTypeStr = machineHourDatas[i].ModuleType;
|
|
|
|
+
|
|
|
|
+ if (ModuleType[i] == null || ModuleType[i].Count == 0 || !ModuleType[i].Contains(moduleTypeStr))
|
|
|
|
+ {
|
|
|
|
+ ModuleType[i].Add(moduleTypeStr);
|
|
|
|
+ }
|
|
|
|
+
|
|
worksheet.Cells[i - 12 + 3, 26].Value = i + 1;
|
|
worksheet.Cells[i - 12 + 3, 26].Value = i + 1;
|
|
worksheet.Cells[i - 12 + 3, 27].Value = machineHourDatas[i].Period;
|
|
worksheet.Cells[i - 12 + 3, 27].Value = machineHourDatas[i].Period;
|
|
worksheet.Cells[i - 12 + 3, 28].Value = machineHourDatas[i].ModuleType;
|
|
worksheet.Cells[i - 12 + 3, 28].Value = machineHourDatas[i].ModuleType;
|
|
@@ -351,6 +429,27 @@ namespace ProductionLineMonitor.Application.Services
|
|
worksheet.Cells[i - 12 + 3, 33].Value = output;
|
|
worksheet.Cells[i - 12 + 3, 33].Value = output;
|
|
worksheet.Cells[i - 12 + 3, 34].Value = Math.Round(tt, 2);
|
|
worksheet.Cells[i - 12 + 3, 34].Value = Math.Round(tt, 2);
|
|
worksheet.Cells[i - 12 + 3, 35].Value = alarm;
|
|
worksheet.Cells[i - 12 + 3, 35].Value = alarm;
|
|
|
|
+
|
|
|
|
+ if (OEE_Temp2.ContainsKey(periodStr))
|
|
|
|
+ {
|
|
|
|
+ OEE_Temp2[periodStr][0] += auto;
|
|
|
|
+ OEE_Temp2[periodStr][1] += alarmTime;
|
|
|
|
+ OEE_Temp2[periodStr][2] += idel;
|
|
|
|
+ OEE_Temp2[periodStr][3] += loadTime;
|
|
|
|
+ OEE_Temp2[periodStr][4] += output;
|
|
|
|
+ OEE_Temp2[periodStr][5] += alarm;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ List<int> list_temp = new List<int>();
|
|
|
|
+ list_temp.Add(auto);
|
|
|
|
+ list_temp.Add(alarmTime);
|
|
|
|
+ list_temp.Add(idel);
|
|
|
|
+ list_temp.Add(loadTime);
|
|
|
|
+ list_temp.Add(output);
|
|
|
|
+ list_temp.Add(alarm);
|
|
|
|
+ OEE_Temp2.Add(periodStr, list_temp);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
worksheet.Cells[15, 26].Value = "合计";
|
|
worksheet.Cells[15, 26].Value = "合计";
|
|
@@ -456,25 +555,303 @@ namespace ProductionLineMonitor.Application.Services
|
|
pieSerie.DataLabel.ShowValue = true;
|
|
pieSerie.DataLabel.ShowValue = true;
|
|
}
|
|
}
|
|
|
|
|
|
- ExcelChart chart1 = worksheet.Drawings.AddChart("chart1", eChartType.ColumnStacked);
|
|
|
|
- chart1.Legend.Position = eLegendPosition.Bottom;
|
|
|
|
- chart1.Legend.Add();
|
|
|
|
- chart1.Title.Text = "设备产能曲线"; //设置图表的名称
|
|
|
|
- chart1.SetPosition(540, 1030); //设置图表位置
|
|
|
|
- chart1.SetSize(1000, 400); //设置图表大小
|
|
|
|
- chart1.ShowHiddenData = true;
|
|
|
|
- chart1.YAxis.Format = "0 \"pcs\"";
|
|
|
|
- ExcelChartSerie chartSerie1;
|
|
|
|
- chartSerie1 = chart1.Series.Add(worksheet.Cells[2, 7, machineOEE.Count + 1, 7], worksheet.Cells[2, 2, machineOEE.Count + 1, 2]);
|
|
|
|
- chartSerie1.HeaderAddress = worksheet.Cells[1, 7];
|
|
|
|
- foreach (var item in chart1.Series)
|
|
|
|
|
|
+ if (HideEquipmentProduction == null || HideEquipmentProduction.Count() == 0 || !HideEquipmentProduction.Contains(machineId))
|
|
|
|
+ {
|
|
|
|
+ ExcelChart chart1 = worksheet.Drawings.AddChart("chart1", eChartType.ColumnStacked);
|
|
|
|
+ chart1.Legend.Position = eLegendPosition.Bottom;
|
|
|
|
+ chart1.Legend.Add();
|
|
|
|
+ chart1.Title.Text = "设备产能曲线"; //设置图表的名称
|
|
|
|
+ chart1.SetPosition(540, 1030); //设置图表位置
|
|
|
|
+ chart1.SetSize(1000, 400); //设置图表大小
|
|
|
|
+ chart1.ShowHiddenData = true;
|
|
|
|
+ chart1.YAxis.Format = "0 \"pcs\"";
|
|
|
|
+ ExcelChartSerie chartSerie1;
|
|
|
|
+ chartSerie1 = chart1.Series.Add(worksheet.Cells[2, 7, machineOEE.Count + 1, 7], worksheet.Cells[2, 2, machineOEE.Count + 1, 2]);
|
|
|
|
+ chartSerie1.HeaderAddress = worksheet.Cells[1, 7];
|
|
|
|
+ foreach (var item in chart1.Series)
|
|
|
|
+ {
|
|
|
|
+ var pieSerie = (ExcelBarChartSerie)item;
|
|
|
|
+ pieSerie.DataLabel.ShowValue = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ package.Save();
|
|
|
|
+ }
|
|
|
|
+ if ((bool)UtilizationRateEmail["DataSummary"]["IsAble"])
|
|
|
|
+ {
|
|
|
|
+ FileInfo file = new FileInfo(path);
|
|
|
|
+
|
|
|
|
+ using ExcelPackage package = new ExcelPackage(file);
|
|
|
|
+
|
|
|
|
+ ExcelWorksheet worksheet = package.Workbook.Worksheets.Add($"汇总");
|
|
|
|
+
|
|
|
|
+ worksheet.View.ZoomScale = 80;
|
|
|
|
+
|
|
|
|
+ worksheet.Cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
|
|
|
+
|
|
|
|
+ #region tab header
|
|
|
|
+
|
|
|
|
+ worksheet.Cells[1, 1].Value = "NO";
|
|
|
|
+ worksheet.Cells[1, 2].Value = "时间";
|
|
|
|
+ worksheet.Cells[1, 3].Value = "稼动率(%)";
|
|
|
|
+ worksheet.Cells[1, 4].Value = "待机率(%)";
|
|
|
|
+ worksheet.Cells[1, 5].Value = "报警率(%)";
|
|
|
|
+ worksheet.Cells[1, 6].Value = "换料率(%)";
|
|
|
|
+ worksheet.Cells[1, 7].Value = "产能(pcs)";
|
|
|
|
+ worksheet.Cells[1, 8].Value = "稼动(min)";
|
|
|
|
+ worksheet.Cells[1, 9].Value = "待机(min)";
|
|
|
|
+ worksheet.Cells[1, 10].Value = "报警(min)";
|
|
|
|
+ worksheet.Cells[1, 11].Value = "换料(min)";
|
|
|
|
+ worksheet.Cells[1, 12].Value = "合计(min)";
|
|
|
|
+
|
|
|
|
+ worksheet.Cells[1, 15].Value = $"{startTime:yyyy-MM-dd} 早班";
|
|
|
|
+ worksheet.Cells[1, 15, 1, 24].Merge = true;
|
|
|
|
+
|
|
|
|
+ worksheet.Cells[2, 15].Value = "NO";
|
|
|
|
+ worksheet.Cells[2, 16].Value = "时段";
|
|
|
|
+ worksheet.Cells[2, 17].Value = "机种";
|
|
|
|
+ worksheet.Cells[2, 18].Value = "运行时间";
|
|
|
|
+ worksheet.Cells[2, 19].Value = "报警时间";
|
|
|
|
+ worksheet.Cells[2, 20].Value = "待料时间";
|
|
|
|
+ worksheet.Cells[2, 21].Value = "换料时间";
|
|
|
|
+ worksheet.Cells[2, 22].Value = "产能";
|
|
|
|
+ worksheet.Cells[2, 23].Value = "TT";
|
|
|
|
+ worksheet.Cells[2, 24].Value = "报警次数";
|
|
|
|
+
|
|
|
|
+ worksheet.Cells[1, 26].Value = $"{startTime:yyyy-MM-dd} 夜班";
|
|
|
|
+ worksheet.Cells[1, 26, 1, 35].Merge = true;
|
|
|
|
+
|
|
|
|
+ worksheet.Cells[2, 26].Value = "NO";
|
|
|
|
+ worksheet.Cells[2, 27].Value = "时段";
|
|
|
|
+ worksheet.Cells[2, 28].Value = "机种";
|
|
|
|
+ worksheet.Cells[2, 29].Value = "运行时间";
|
|
|
|
+ worksheet.Cells[2, 30].Value = "报警时间";
|
|
|
|
+ worksheet.Cells[2, 31].Value = "待料时间";
|
|
|
|
+ worksheet.Cells[2, 32].Value = "换料时间";
|
|
|
|
+ worksheet.Cells[2, 33].Value = "产能";
|
|
|
|
+ worksheet.Cells[2, 34].Value = "TT";
|
|
|
|
+ worksheet.Cells[2, 35].Value = "报警次数";
|
|
|
|
+
|
|
|
|
+ worksheet.Column(1).Width = 5;
|
|
|
|
+ worksheet.Column(2).Width = 12;
|
|
|
|
+ worksheet.Column(3).Width = 12;
|
|
|
|
+ worksheet.Column(4).Width = 12;
|
|
|
|
+ worksheet.Column(5).Width = 12;
|
|
|
|
+ worksheet.Column(6).Width = 12;
|
|
|
|
+ worksheet.Column(7).Width = 12;
|
|
|
|
+ worksheet.Column(8).Width = 12;
|
|
|
|
+ worksheet.Column(9).Width = 12;
|
|
|
|
+ worksheet.Column(10).Width = 12;
|
|
|
|
+ worksheet.Column(11).Width = 12;
|
|
|
|
+ worksheet.Column(12).Width = 12;
|
|
|
|
+
|
|
|
|
+ worksheet.Column(13).Width = 2;
|
|
|
|
+ worksheet.Column(14).Width = 2;
|
|
|
|
+
|
|
|
|
+ worksheet.Column(15).Width = 5;
|
|
|
|
+ worksheet.Column(16).Width = 12;
|
|
|
|
+ worksheet.Column(17).Width = 12;
|
|
|
|
+ worksheet.Column(18).Width = 12;
|
|
|
|
+ worksheet.Column(19).Width = 12;
|
|
|
|
+ worksheet.Column(20).Width = 12;
|
|
|
|
+ worksheet.Column(21).Width = 12;
|
|
|
|
+ worksheet.Column(22).Width = 12;
|
|
|
|
+ worksheet.Column(23).Width = 12;
|
|
|
|
+ worksheet.Column(24).Width = 12;
|
|
|
|
+ worksheet.Column(22).Width = 12;
|
|
|
|
+ worksheet.Column(23).Width = 12;
|
|
|
|
+
|
|
|
|
+ worksheet.Column(25).Width = 2;
|
|
|
|
+
|
|
|
|
+ worksheet.Column(26).Width = 5;
|
|
|
|
+ worksheet.Column(27).Width = 12;
|
|
|
|
+ worksheet.Column(28).Width = 12;
|
|
|
|
+ worksheet.Column(29).Width = 12;
|
|
|
|
+ worksheet.Column(30).Width = 12;
|
|
|
|
+ worksheet.Column(31).Width = 12;
|
|
|
|
+ worksheet.Column(32).Width = 12;
|
|
|
|
+ worksheet.Column(33).Width = 12;
|
|
|
|
+ worksheet.Column(34).Width = 12;
|
|
|
|
+ worksheet.Column(35).Width = 12;
|
|
|
|
+
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ List<string> OEE1Keys = new List<string>(OEE_Temp1.Keys);
|
|
|
|
+ for (int i = 0; i < OEE1Keys.Count(); i++)
|
|
|
|
+ {
|
|
|
|
+ int total = OEE_Temp1[OEE1Keys[i]][5];
|
|
|
|
+ worksheet.Cells[i + 2, 1].Value = i + 1;
|
|
|
|
+ worksheet.Cells[i + 2, 2].Value = OEE1Keys[i];
|
|
|
|
+ worksheet.Cells[i + 2, 3].Value = Math.Round(OEE_Temp1[OEE1Keys[i]][1] * 100.0 / total);
|
|
|
|
+ worksheet.Cells[i + 2, 4].Value = Math.Round(OEE_Temp1[OEE1Keys[i]][2] * 100.0 / total);
|
|
|
|
+ worksheet.Cells[i + 2, 5].Value = Math.Round(OEE_Temp1[OEE1Keys[i]][3] * 100.0 / total);
|
|
|
|
+ worksheet.Cells[i + 2, 6].Value = Math.Round(OEE_Temp1[OEE1Keys[i]][4] * 100.0 / total);
|
|
|
|
+ worksheet.Cells[i + 2, 7].Value = OEE_Temp1[OEE1Keys[i]][0];
|
|
|
|
+ worksheet.Cells[i + 2, 8].Value = OEE_Temp1[OEE1Keys[i]][1] / 60;
|
|
|
|
+ worksheet.Cells[i + 2, 9].Value = OEE_Temp1[OEE1Keys[i]][2] / 60;
|
|
|
|
+ worksheet.Cells[i + 2, 10].Value = OEE_Temp1[OEE1Keys[i]][3] / 60;
|
|
|
|
+ worksheet.Cells[i + 2, 11].Value = OEE_Temp1[OEE1Keys[i]][4] / 60;
|
|
|
|
+ worksheet.Cells[i + 2, 12].Value = total / 60;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (OEE_Temp2 != null && OEE_Temp2.Count == 24)
|
|
|
|
+ {
|
|
|
|
+ List<string> OEE2Keys = new List<string>(OEE_Temp2.Keys);
|
|
|
|
+ {
|
|
|
|
+ int autoTimeSum = 0;
|
|
|
|
+ int alarmTimeSum = 0;
|
|
|
|
+ int idelTimeSum = 0;
|
|
|
|
+ int loadTimeSum = 0;
|
|
|
|
+ int outputSum = 0;
|
|
|
|
+ int alarmSum = 0;
|
|
|
|
+ double ttSum;
|
|
|
|
+ for (int i = 0; i < 12; i++)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ int autoTime = OEE_Temp2[OEE2Keys[i]][0];
|
|
|
|
+ autoTimeSum += autoTime;
|
|
|
|
+ int alarmTime = OEE_Temp2[OEE2Keys[i]][1];
|
|
|
|
+ alarmTimeSum += alarmTime;
|
|
|
|
+ int idelTime = OEE_Temp2[OEE2Keys[i]][2];
|
|
|
|
+ idelTimeSum += idelTime;
|
|
|
|
+ int loadTime = OEE_Temp2[OEE2Keys[i]][3];
|
|
|
|
+ loadTimeSum += loadTime;
|
|
|
|
+ int output = OEE_Temp2[OEE2Keys[i]][4];
|
|
|
|
+ outputSum += output;
|
|
|
|
+ int alarm = OEE_Temp2[OEE2Keys[i]][5];
|
|
|
|
+ alarmSum += alarm;
|
|
|
|
+ worksheet.Cells[i + 3, 15].Value = i + 1;
|
|
|
|
+ worksheet.Cells[i + 3, 16].Value = OEE2Keys[i];
|
|
|
|
+ worksheet.Cells[i + 3, 17].Value = String.Join(",", ModuleType[i]);
|
|
|
|
+ worksheet.Cells[i + 3, 18].Value = autoTime;
|
|
|
|
+ worksheet.Cells[i + 3, 19].Value = alarmTime;
|
|
|
|
+ worksheet.Cells[i + 3, 20].Value = idelTime;
|
|
|
|
+ worksheet.Cells[i + 3, 21].Value = loadTimeSum;
|
|
|
|
+ worksheet.Cells[i + 3, 22].Value = output;
|
|
|
|
+ worksheet.Cells[i + 3, 23].Value = output == 0 ? 0 : Math.Round(OEE_Temp2[OEE2Keys[i]][0] * 60.0 / OEE_Temp2[OEE2Keys[i]][4], 2);
|
|
|
|
+ worksheet.Cells[i + 3, 24].Value = alarm;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ worksheet.Cells[15, 15].Value = "合计";
|
|
|
|
+ worksheet.Cells[15, 15, 15, 17].Merge = true;
|
|
|
|
+ worksheet.Cells[15, 18].Value = autoTimeSum;
|
|
|
|
+ worksheet.Cells[15, 19].Value = alarmTimeSum;
|
|
|
|
+ worksheet.Cells[15, 20].Value = idelTimeSum;
|
|
|
|
+ worksheet.Cells[15, 21].Value = loadTimeSum;
|
|
|
|
+ worksheet.Cells[15, 22].Value = outputSum;
|
|
|
|
+ if (outputSum != 0)
|
|
|
|
+ ttSum = autoTimeSum * 60.0 / outputSum;
|
|
|
|
+ else
|
|
|
|
+ ttSum = 0;
|
|
|
|
+ worksheet.Cells[15, 23].Value = Math.Round(ttSum, 2);
|
|
|
|
+ worksheet.Cells[15, 24].Value = alarmSum;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ {
|
|
|
|
+ int autoTimeSum = 0;
|
|
|
|
+ int alarmTimeSum = 0;
|
|
|
|
+ int idelTimeSum = 0;
|
|
|
|
+ int loadTimeSum = 0;
|
|
|
|
+ int outputSum = 0;
|
|
|
|
+ int alarmSum = 0;
|
|
|
|
+ double ttSum;
|
|
|
|
+ for (int i = 12; i < 24; i++)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ int autoTime = OEE_Temp2[OEE2Keys[i]][0]; ;
|
|
|
|
+ autoTimeSum += autoTime;
|
|
|
|
+ int alarmTime = OEE_Temp2[OEE2Keys[i]][1];
|
|
|
|
+ alarmTimeSum += alarmTime;
|
|
|
|
+ int idelTime = OEE_Temp2[OEE2Keys[i]][2];
|
|
|
|
+ idelTimeSum += idelTime;
|
|
|
|
+ int loadTime = OEE_Temp2[OEE2Keys[i]][3];
|
|
|
|
+ loadTimeSum += loadTime;
|
|
|
|
+ int output = OEE_Temp2[OEE2Keys[i]][4];
|
|
|
|
+ outputSum += output;
|
|
|
|
+ int alarm = OEE_Temp2[OEE2Keys[i]][5];
|
|
|
|
+ alarmSum += alarm;
|
|
|
|
+ worksheet.Cells[i - 12 + 3, 26].Value = i + 1;
|
|
|
|
+ worksheet.Cells[i - 12 + 3, 27].Value = OEE2Keys[i];
|
|
|
|
+ worksheet.Cells[i - 12 + 3, 28].Value = String.Join(",", ModuleType[i]);
|
|
|
|
+ worksheet.Cells[i - 12 + 3, 29].Value = autoTime;
|
|
|
|
+ worksheet.Cells[i - 12 + 3, 30].Value = alarmTime;
|
|
|
|
+ worksheet.Cells[i - 12 + 3, 31].Value = idelTime;
|
|
|
|
+ worksheet.Cells[i - 12 + 3, 32].Value = loadTimeSum;
|
|
|
|
+ worksheet.Cells[i - 12 + 3, 33].Value = output;
|
|
|
|
+ worksheet.Cells[i - 12 + 3, 34].Value = output == 0 ? 0 : Math.Round(OEE_Temp2[OEE2Keys[i]][0] * 60.0 / OEE_Temp2[OEE2Keys[i]][4], 2);
|
|
|
|
+ worksheet.Cells[i - 12 + 3, 35].Value = alarm;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ worksheet.Cells[15, 26].Value = "合计";
|
|
|
|
+ worksheet.Cells[15, 26, 15, 28].Merge = true;
|
|
|
|
+ worksheet.Cells[15, 29].Value = autoTimeSum;
|
|
|
|
+ worksheet.Cells[15, 30].Value = alarmTimeSum;
|
|
|
|
+ worksheet.Cells[15, 31].Value = idelTimeSum;
|
|
|
|
+ worksheet.Cells[15, 32].Value = loadTimeSum;
|
|
|
|
+ worksheet.Cells[15, 33].Value = outputSum;
|
|
|
|
+ if (outputSum != 0)
|
|
|
|
+ ttSum = autoTimeSum * 60.0 / outputSum;
|
|
|
|
+ else
|
|
|
|
+ ttSum = 0;
|
|
|
|
+ worksheet.Cells[15, 34].Value = Math.Round(ttSum, 2);
|
|
|
|
+ worksheet.Cells[15, 35].Value = alarmSum;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ExcelChartSerie chartSerie;
|
|
|
|
+ ExcelChart chart = worksheet.Drawings.AddChart("chart", eChartType.ColumnStacked);
|
|
|
|
+
|
|
|
|
+ chart.YAxis.MinValue = 0;
|
|
|
|
+ chart.YAxis.MaxValue = 100;
|
|
|
|
+ chart.YAxis.Format = "0 \"%\"";
|
|
|
|
+
|
|
|
|
+ chart.Legend.Position = eLegendPosition.Bottom;
|
|
|
|
+ chart.Legend.Add();
|
|
|
|
+ chart.Title.Text = "设备稼动曲线"; //设置图表的名称
|
|
|
|
+ chart.SetPosition(540, 20); //设置图表位置
|
|
|
|
+ chart.SetSize(1000, 400); //设置图表大小
|
|
|
|
+ chart.ShowHiddenData = true;
|
|
|
|
+
|
|
|
|
+ chartSerie = chart.Series.Add(worksheet.Cells[2, 3, OEE_Temp1.Count() + 1, 3], worksheet.Cells[2, 2, OEE_Temp1.Count() + 1, 2]);
|
|
|
|
+ chartSerie.HeaderAddress = worksheet.Cells[1, 3];
|
|
|
|
+ chartSerie = chart.Series.Add(worksheet.Cells[2, 4, OEE_Temp1.Count() + 1, 4], worksheet.Cells[2, 2, OEE_Temp1.Count() + 1, 2]);
|
|
|
|
+ chartSerie.HeaderAddress = worksheet.Cells[1, 4];
|
|
|
|
+ chartSerie = chart.Series.Add(worksheet.Cells[2, 5, OEE_Temp1.Count() + 1, 5], worksheet.Cells[2, 2, OEE_Temp1.Count() + 1, 2]);
|
|
|
|
+ chartSerie.HeaderAddress = worksheet.Cells[1, 5];
|
|
|
|
+ chartSerie = chart.Series.Add(worksheet.Cells[2, 6, OEE_Temp1.Count() + 1, 6], worksheet.Cells[2, 2, OEE_Temp1.Count() + 1, 2]);
|
|
|
|
+ chartSerie.HeaderAddress = worksheet.Cells[1, 6];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ foreach (var item in chart.Series)
|
|
{
|
|
{
|
|
var pieSerie = (ExcelBarChartSerie)item;
|
|
var pieSerie = (ExcelBarChartSerie)item;
|
|
pieSerie.DataLabel.ShowValue = true;
|
|
pieSerie.DataLabel.ShowValue = true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (!(bool)UtilizationRateEmail["DataSummary"]["HideProductionUtilizationChart"])
|
|
|
|
+ {
|
|
|
|
+ ExcelChart chart1 = worksheet.Drawings.AddChart("chart1", eChartType.ColumnStacked);
|
|
|
|
+ chart1.Legend.Position = eLegendPosition.Bottom;
|
|
|
|
+ chart1.Legend.Add();
|
|
|
|
+ chart1.Title.Text = "设备产能曲线"; //设置图表的名称
|
|
|
|
+ chart1.SetPosition(540, 1030); //设置图表位置
|
|
|
|
+ chart1.SetSize(1000, 400); //设置图表大小
|
|
|
|
+ chart1.ShowHiddenData = true;
|
|
|
|
+ chart1.YAxis.Format = "0 \"pcs\"";
|
|
|
|
+ ExcelChartSerie chartSerie1;
|
|
|
|
+ chartSerie1 = chart1.Series.Add(worksheet.Cells[2, 7, OEE_Temp1.Count() + 1, 7], worksheet.Cells[2, 2, OEE_Temp1.Count() + 1, 2]);
|
|
|
|
+ chartSerie1.HeaderAddress = worksheet.Cells[1, 7];
|
|
|
|
+ foreach (var item in chart1.Series)
|
|
|
|
+ {
|
|
|
|
+ var pieSerie = (ExcelBarChartSerie)item;
|
|
|
|
+ pieSerie.DataLabel.ShowValue = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ package.Workbook.Worksheets.MoveToStart("汇总");
|
|
package.Save();
|
|
package.Save();
|
|
}
|
|
}
|
|
|
|
+
|
|
string ReceiverAppSettingName = UtilizationRateEmail["ReceiverAppSettingName"].ToString();
|
|
string ReceiverAppSettingName = UtilizationRateEmail["ReceiverAppSettingName"].ToString();
|
|
if (ReceiverAppSettingName == null || String.IsNullOrEmpty(ReceiverAppSettingName))
|
|
if (ReceiverAppSettingName == null || String.IsNullOrEmpty(ReceiverAppSettingName))
|
|
{
|
|
{
|