You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
220 lines
8.7 KiB
C#
220 lines
8.7 KiB
C#
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;
|
|
|
|
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;
|
|
|
|
|
|
dt = new DataTable();
|
|
dt.Columns.Add("机台", typeof(string));
|
|
dt.Columns.Add("玉米粉总量", typeof(string));
|
|
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 += NightWork_Click;
|
|
}
|
|
|
|
List<HuYuMiFenEntity> hus = new List<HuYuMiFenEntity>();
|
|
|
|
private void SelectButton_Click(object sender, EventArgs e)
|
|
{
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
dt.Rows.Clear();
|
|
hus.Clear();
|
|
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");
|
|
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='{i}' 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");
|
|
dow[3] = Convert.ToSingle(list.Where(x => x.MName == "冷水").Sum(x => Convert.ToSingle(x.ActValue))).ToString("#0.00");
|
|
dow[4] = 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]);
|
|
c += Convert.ToSingle(dr[3]);
|
|
d += Convert.ToSingle(dr[4]);
|
|
}
|
|
|
|
var totalDow = dt.NewRow();
|
|
totalDow[0] = "总计";
|
|
totalDow[1] = a.ToString("#0.00");
|
|
totalDow[2] = b.ToString("#0.00");
|
|
totalDow[3] = c.ToString("#0.00");
|
|
totalDow[4] = d.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; }
|
|
}
|
|
}
|