|
|
using HighWayIot.Repository.domain;
|
|
|
using HighWayIot.Repository.service;
|
|
|
using HighWayIot.Winform.Business;
|
|
|
using HighWayIot.Winform.UserControlPages.LogPages;
|
|
|
using System;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
using System.Data;
|
|
|
using System.Diagnostics;
|
|
|
using System.Drawing;
|
|
|
using System.Linq;
|
|
|
using System.Net.Http;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
|
|
|
namespace HighWayIot.Winform.UserControlPages
|
|
|
{
|
|
|
public partial class DailyReportPage : UserControl
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 报表服务类
|
|
|
/// </summary>
|
|
|
private ZxDailyReportService _zxDailyReportService = ZxDailyReportService.Instance;
|
|
|
|
|
|
private List<ZxDailyReportEntity> dailyEntities = new List<ZxDailyReportEntity>();
|
|
|
|
|
|
/// <summary>
|
|
|
/// datagridview 数据源
|
|
|
/// 必须使用BindingList, 如果使用LIST,无法实现更改,添加、删除数据源自动更新datagridview
|
|
|
/// </summary>
|
|
|
private BindingList<MonitorDataSource> _monitorDataSources = new BindingList<MonitorDataSource>();
|
|
|
|
|
|
public DailyReportPage()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
|
|
|
Init();
|
|
|
}
|
|
|
|
|
|
private void Init()
|
|
|
{
|
|
|
ReportDataGridView.AutoGenerateColumns = false;
|
|
|
|
|
|
SelectStartTime.Value = DateTime.Now.AddDays(-1);
|
|
|
SelectEndTime.Value = DateTime.Now;
|
|
|
|
|
|
ReportDataGridView.DataSource = null;
|
|
|
ReportDataGridView.DataSource = _monitorDataSources;
|
|
|
DataRefresh();
|
|
|
}
|
|
|
|
|
|
private void SelectReport_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
DataRefresh();
|
|
|
}
|
|
|
|
|
|
private void DataRefresh()
|
|
|
{
|
|
|
dailyEntities.Clear();
|
|
|
this.dailyEntities =
|
|
|
_zxDailyReportService.GetDailyReportInfos(x =>
|
|
|
x.StartTime >= SelectStartTime.Value
|
|
|
&& x.StartTime <= SelectEndTime.Value
|
|
|
&& (string.IsNullOrEmpty(RecipeCodeCombobox.Text) || x.RecipeCode == RecipeCodeCombobox.Text)
|
|
|
&& (string.IsNullOrEmpty(VulcanizationNoCombobox.Text) || x.VulcanizationNo == VulcanizationNoCombobox.Text)
|
|
|
&& (string.IsNullOrEmpty(DeviceNoCombobox.Text) || x.DeviceNo.ToString() == DeviceNoCombobox.Text))
|
|
|
.OrderByDescending(x => x.StartTime)
|
|
|
.ToList();
|
|
|
|
|
|
_monitorDataSources.Clear();
|
|
|
|
|
|
for (int i = 0; i < dailyEntities.Count; i++)
|
|
|
{
|
|
|
_monitorDataSources.Add(new MonitorDataSource()
|
|
|
{
|
|
|
No = i + 1,
|
|
|
VulcanizationNo = dailyEntities[i].VulcanizationNo,
|
|
|
StartTime = dailyEntities[i].StartTime.ToString("MM月dd日 HH:mm:ss"),
|
|
|
RecipeName = dailyEntities[i].RecipeName,
|
|
|
RecipeCode = dailyEntities[i].RecipeCode,
|
|
|
SpecCode = dailyEntities[i].SpecCode,
|
|
|
DeviceNo = dailyEntities[i].DeviceNo.ToString(),
|
|
|
StandardWeight = dailyEntities[i].StandardWeight ?? 0,
|
|
|
RawTireWeight = dailyEntities[i].RawTireWeight ?? 0,
|
|
|
BaseRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntities[i].StartTime, dailyEntities[i].BaseEndTime),
|
|
|
MidRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntities[i].StartTime, dailyEntities[i].MidEndTime),
|
|
|
FaceRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntities[i].StartTime, dailyEntities[i].FaceEndTime),
|
|
|
IsDone = dailyEntities[i].IsDone == 1 ? "已完成" : "未完成"
|
|
|
});
|
|
|
}
|
|
|
|
|
|
List<string> ds1 = new List<string>() { "" };
|
|
|
ds1.AddRange(_monitorDataSources
|
|
|
.Select(x => x.VulcanizationNo)
|
|
|
.Distinct()
|
|
|
.OrderBy(x => x)
|
|
|
.ToList());
|
|
|
VulcanizationNoCombobox.DataSource = ds1;
|
|
|
VulcanizationNoCombobox.SelectedIndex = 0;
|
|
|
|
|
|
List<string> ds2 = new List<string>() { "" };
|
|
|
ds2.AddRange(_monitorDataSources
|
|
|
.Select(x => x.DeviceNo)
|
|
|
.Distinct()
|
|
|
.OrderBy(x => x)
|
|
|
.ToList());
|
|
|
DeviceNoCombobox.DataSource = ds2;
|
|
|
DeviceNoCombobox.SelectedIndex = 0;
|
|
|
|
|
|
List<string> ds3 = new List<string>() { "" };
|
|
|
ds3.AddRange(_monitorDataSources
|
|
|
.Select(x => x.RecipeCode)
|
|
|
.Distinct()
|
|
|
.OrderBy(x => x)
|
|
|
.ToList());
|
|
|
RecipeCodeCombobox.DataSource = ds3;
|
|
|
RecipeCodeCombobox.SelectedIndex = 0;
|
|
|
|
|
|
DataCountLabel.Text = _monitorDataSources.Count.ToString();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 导出报表
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void ExportTableButton_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
ExportPreviewForm exportPreviewForm = new ExportPreviewForm(dailyEntities);
|
|
|
if (exportPreviewForm.ShowDialog() == DialogResult.OK)
|
|
|
{
|
|
|
//MessageBox.Show("导出成功");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除多余数据
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void DeleteUselessData_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
if (_zxDailyReportService.DeleteMoreData())
|
|
|
{
|
|
|
MessageBox.Show("删除成功");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|