|
|
|
|
using DataBlockHelper.DBHelpers;
|
|
|
|
|
|
|
|
|
|
using DevExpress.DataProcessing;
|
|
|
|
|
using DevExpress.Utils.Extensions;
|
|
|
|
|
|
|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.FreeDb;
|
|
|
|
|
using Mesnac.Codd.Session;
|
|
|
|
|
using Mesnac.Controls.Default;
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.LjReport.DayWhiteEmbryo
|
|
|
|
|
{
|
|
|
|
|
internal class HuYuMiFenInitDb: ChemicalWeighingAction, IAction
|
|
|
|
|
{
|
|
|
|
|
//BtnOk MCDateTimePicker1 MCDataGridView1
|
|
|
|
|
private RuntimeParameter _runtime;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MCButton selectButton;
|
|
|
|
|
MCDateTimePicker startDate;
|
|
|
|
|
MCDateTimePicker startTime;
|
|
|
|
|
MCDateTimePicker endDate;
|
|
|
|
|
MCDateTimePicker endTime;
|
|
|
|
|
|
|
|
|
|
MCDataGridView dataGridView;
|
|
|
|
|
MCDataGridView moreData;
|
|
|
|
|
|
|
|
|
|
DataTable dt;
|
|
|
|
|
DataTable MoreDataTable;
|
|
|
|
|
|
|
|
|
|
List<DayWhiteEmbryoEntity> list;
|
|
|
|
|
|
|
|
|
|
MCButton WhiteWork;
|
|
|
|
|
MCButton NightWork;
|
|
|
|
|
|
|
|
|
|
List<DayWhiteEmbryoEntity> listMore;
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
|
|
{
|
|
|
|
|
base.RunIni(runtime); //必须调用
|
|
|
|
|
this._runtime = runtime;
|
|
|
|
|
var control = GetAllControls();
|
|
|
|
|
|
|
|
|
|
moreData = control.FirstOrDefault(x => x.Name == "MoreData") as MCDataGridView;
|
|
|
|
|
dataGridView = control.FirstOrDefault(x => x.Name == "MCDataGridView1") as MCDataGridView;
|
|
|
|
|
selectButton = control.FirstOrDefault(x => x.Name == "SelectButton") as MCButton;
|
|
|
|
|
startDate = control.FirstOrDefault(x => x.Name == "startDate") as MCDateTimePicker;
|
|
|
|
|
startTime = control.FirstOrDefault(x => x.Name == "startTime") as MCDateTimePicker;
|
|
|
|
|
endDate = control.FirstOrDefault(x => x.Name == "endDate") as MCDateTimePicker;
|
|
|
|
|
endTime = control.FirstOrDefault(x => x.Name == "endTime") as MCDateTimePicker;
|
|
|
|
|
dataGridView.AutoGenerateColumns = true;
|
|
|
|
|
|
|
|
|
|
startDate.Value = DateTime.Now.AddDays(-1);
|
|
|
|
|
|
|
|
|
|
selectButton.Click += SelectButton_Click;
|
|
|
|
|
dataGridView.CellClick += MoreData_Click;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WhiteWork = control.FirstOrDefault(x => x.Name == "WhiteWork") as MCButton;
|
|
|
|
|
NightWork = control.FirstOrDefault(x => x.Name == "NightWork") as MCButton;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dt = new DataTable();
|
|
|
|
|
dt.Columns.Add("机台", typeof(string));
|
|
|
|
|
dt.Columns.Add("玉米粉总量", typeof(string));
|
|
|
|
|
dt.Columns.Add("木薯粉总量", typeof(string));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MoreDataTable = new DataTable();
|
|
|
|
|
MoreDataTable.Columns.Add("物料", typeof(string));
|
|
|
|
|
MoreDataTable.Columns.Add("总量", typeof(string));
|
|
|
|
|
MoreDataTable.Columns.Add("时间", typeof(string));
|
|
|
|
|
|
|
|
|
|
//MoreDataTable = new DataTable();
|
|
|
|
|
//MoreDataTable.Columns.Add("重量", typeof(string));
|
|
|
|
|
//MoreDataTable.Columns.Add("时间", typeof(string));
|
|
|
|
|
|
|
|
|
|
//btnOk.Click += BtnOk_Click;
|
|
|
|
|
//selectButton.Click += SelectButton_Click;
|
|
|
|
|
//dataGridView.CellClick += MoreData_Click;
|
|
|
|
|
//dataGridView.CellValueChanged += MoreData_Click;
|
|
|
|
|
WhiteWork.Click += WhiteWork_Click;
|
|
|
|
|
NightWork.Click += WhiteWork_Click;
|
|
|
|
|
|
|
|
|
|
SelectButton_Click(new object(),new EventArgs());
|
|
|
|
|
MoreData_Click(new object(), new EventArgs());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<HuYuMiFenEntity> hus = new List<HuYuMiFenEntity>();
|
|
|
|
|
|
|
|
|
|
private void SelectButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DateTime starttime = startDate.Value.Date.AddHours(startTime.Value.Hour).AddMinutes(startTime.Value.Minute).AddSeconds(startTime.Value.Second);
|
|
|
|
|
DateTime endtime = endDate.Value.Date.AddHours(endTime.Value.Hour).AddMinutes(endTime.Value.Minute).AddSeconds(endTime.Value.Second);
|
|
|
|
|
|
|
|
|
|
string statValue = starttime.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
string endValue = endtime.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
FileData(statValue, endValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WhiteWork_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DateTime nowTime = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
DateTime starttime;
|
|
|
|
|
DateTime endtime;
|
|
|
|
|
|
|
|
|
|
if (((Button)sender).Text.Contains("白"))
|
|
|
|
|
{
|
|
|
|
|
//如果大于当天8点 就展示当天的白班 否则展示上一个白班
|
|
|
|
|
if (nowTime >= DateTime.Now.Date.AddHours(8))
|
|
|
|
|
{
|
|
|
|
|
starttime = DateTime.Now.Date.AddHours(7).AddMinutes(30);
|
|
|
|
|
endtime = DateTime.Now.Date.AddHours(19).AddMinutes(30);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
starttime = DateTime.Now.Date.AddHours(-17).AddMinutes(30);
|
|
|
|
|
endtime = DateTime.Now.Date.AddHours(-5).AddMinutes(30);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//如果小于当天20点 就展示当天的前一个晚班
|
|
|
|
|
if (nowTime <= DateTime.Now.Date.AddHours(20))
|
|
|
|
|
{
|
|
|
|
|
starttime = DateTime.Now.Date.AddHours(-5).AddMinutes(30);
|
|
|
|
|
endtime = DateTime.Now.Date.AddHours(7).AddMinutes(30);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
starttime = DateTime.Now.Date.AddHours(19).AddMinutes(30);
|
|
|
|
|
endtime = DateTime.Now.Date.AddHours(31).AddMinutes(30);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startDate.Value = Convert.ToDateTime(starttime.ToString("yyyy-MM-dd"));
|
|
|
|
|
endDate.Value = Convert.ToDateTime(endtime.ToString("yyyy-MM-dd"));
|
|
|
|
|
|
|
|
|
|
startTime.Value = Convert.ToDateTime(starttime.ToString("HH:mm:ss"));
|
|
|
|
|
endTime.Value = Convert.ToDateTime(endtime.ToString("HH:mm:ss"));
|
|
|
|
|
|
|
|
|
|
string statValue = starttime.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
string endValue = endtime.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
FileData(statValue, endValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void FileData(string statValue, string endValue)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
dt.Rows.Clear();
|
|
|
|
|
hus.Clear();
|
|
|
|
|
for (int i = 1; i < 9; i++)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string sql = "select t1.matCode, t2.MName as 物料,t1.actValue as 实际重量\r\n," +
|
|
|
|
|
"t1.actToler as 实际公差 , t1.kinds ,t1.recordTime from Report_GelDoser_Detail t1\r\n" +
|
|
|
|
|
"left join lj_stock_material t2 on t1.matCode = t2.Code\r\nwhere t2.MTypeId=1 " +
|
|
|
|
|
$"and t1.eqNo='{i}' and recordTime>='{statValue}' and recordTime<'{endValue}'\r\norder by recordTime desc";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dbHelper.CommandText = sql.ToString();
|
|
|
|
|
dbHelper.CommandType = System.Data.CommandType.Text;
|
|
|
|
|
DataTable table2 = dbHelper.ToDataTable();
|
|
|
|
|
|
|
|
|
|
foreach (DataRow dr in table2.Rows)
|
|
|
|
|
{
|
|
|
|
|
HuYuMiFenEntity en = new HuYuMiFenEntity();
|
|
|
|
|
en.Name = "糊化机" + i;
|
|
|
|
|
en.MName = dr["物料"].ToString();
|
|
|
|
|
en.ActValue = Convert.ToSingle(dr["实际重量"]).ToString("#0.00");
|
|
|
|
|
en.RecordTime = Convert.ToDateTime(dr["recordTime"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
hus.Add(en);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sql = "select t1.matCode, t2.MName as 物料,t1.actValue as 实际重量\r\n," +
|
|
|
|
|
"t1.actToler as 实际公差 , t1.kinds ,t1.recordTime " +
|
|
|
|
|
"from Report_GelDoser_Detail t1\r\n" +
|
|
|
|
|
"left join lj_stock_material t2 on t1.matCode = t2.Code\r\n" +
|
|
|
|
|
$"where t1.kinds<>1 and t1.eqNo='111111' and recordTime>'{statValue}' and recordTime<'{endValue}'\r\norder by recordTime desc";
|
|
|
|
|
|
|
|
|
|
dbHelper.CommandText = sql.ToString();
|
|
|
|
|
dbHelper.CommandType = System.Data.CommandType.Text;
|
|
|
|
|
table2 = dbHelper.ToDataTable();
|
|
|
|
|
|
|
|
|
|
foreach (DataRow dr in table2.Rows)
|
|
|
|
|
{
|
|
|
|
|
HuYuMiFenEntity en = new HuYuMiFenEntity();
|
|
|
|
|
en.Name = "糊化机" + i;
|
|
|
|
|
if (dr["kinds"].ToString() == "2")
|
|
|
|
|
{
|
|
|
|
|
en.MName = "热水";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
en.MName = "冷水";
|
|
|
|
|
}
|
|
|
|
|
en.RecordTime = Convert.ToDateTime(dr["recordTime"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
en.ActValue = Convert.ToSingle(dr["实际重量"]).ToString("#0.00");
|
|
|
|
|
hus.Add(en);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < 9; i++)
|
|
|
|
|
{
|
|
|
|
|
var dow = dt.NewRow();
|
|
|
|
|
string name = "糊化机" + i;
|
|
|
|
|
var list = hus.Where(x => x.Name == name);
|
|
|
|
|
dow[0] = name;
|
|
|
|
|
dow[1] = Convert.ToSingle(list.Where(x => x.MName == "玉米粉").Sum(x => Convert.ToSingle(x.ActValue))).ToString("#0.00");
|
|
|
|
|
dow[2] = Convert.ToSingle(list.Where(x => x.MName == "木薯粉").Sum(x => Convert.ToSingle(x.ActValue))).ToString("#0.00");
|
|
|
|
|
|
|
|
|
|
dt.Rows.Add(dow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float a = 0;
|
|
|
|
|
float b = 0;
|
|
|
|
|
float c = 0;
|
|
|
|
|
float d = 0;
|
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
a += Convert.ToSingle(dr[1]);
|
|
|
|
|
b += Convert.ToSingle(dr[2]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var totalDow = dt.NewRow();
|
|
|
|
|
totalDow[0] = "总计";
|
|
|
|
|
totalDow[1] = a.ToString("#0.00");
|
|
|
|
|
totalDow[2] = b.ToString("#0.00");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dt.Rows.Add(totalDow);
|
|
|
|
|
|
|
|
|
|
dataGridView.DataSource = dt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MoreData_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MoreDataTable.Rows.Clear();
|
|
|
|
|
string dID = dataGridView.SelectedRows[0].Cells["机台"].Value as string;
|
|
|
|
|
var list= hus.Where(x => x.Name == dID).ToList();
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
var dr= MoreDataTable.NewRow();
|
|
|
|
|
dr[0] = item.MName;
|
|
|
|
|
dr[1] = item.ActValue;
|
|
|
|
|
dr[2] = item.RecordTime;
|
|
|
|
|
MoreDataTable.Rows.Add(dr);
|
|
|
|
|
}
|
|
|
|
|
moreData.AutoGenerateColumns = true;
|
|
|
|
|
moreData.DataSource = MoreDataTable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class HuYuMiFenEntity
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public string MName { get; set; }
|
|
|
|
|
public string ActValue { get; set; }
|
|
|
|
|
|
|
|
|
|
public string RecordTime { get; set; }
|
|
|
|
|
}
|
|
|
|
|
}
|