using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Control.Base; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Core.StlMes.Client.Mcp.Control.Entity; namespace Core.StlMes.Client.Mcp.Treatment.Report { public partial class FrmStatisticalPub : FrmBase { private string _bc = ""; private int days = 0; private string effic720 = ""; private string effic1720 = ""; private string effic2720 = ""; private string efficlz = ""; private string effic1lz = ""; private string effic2lz = ""; private string efficlb = ""; private string effic1lb = ""; private string effic2lb = ""; private string efficdc = ""; private string effic1dc = ""; private string effic2dc = ""; private string efficrk = ""; private string effic1rk = ""; private string effic2rk = ""; public FrmStatisticalPub() { InitializeComponent(); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.statisticalControl1.Grid.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False; this.statisticalControl2.Grid.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False; this.statisticalControl3.Grid.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False; } private void FrmStatisticalPub_Load(object sender, EventArgs e) { DataTable dt1 = ServerHelper.GetData("com.steering.mes.mcp.common.McpBaseHelper.getPlineCode", new object[] { "F", "002001002" }, this.ob); comPlineCode.DataSource = dt1; comPlineCode.ValueMember = "PLINE_CODE"; comPlineCode.DisplayMember = "PLINE_NAME"; comPlineCode.SelectedIndex = 0; cmbBc.Value = this.UserInfo.GetUserOrder(); //cmbBz.Value = this.UserInfo.GetUserGroup(); dateDayTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(DateTime.Now.Year, DateTime.Now.Month); DataTable dt = dataTable1; dt.Columns.Add(new DataColumn("Month") { Caption = "停机汇总" }); TubeRoll.GridColumnSum(ultraGrid3, new string[] { "Month" }); for (int i = 0; i < days; i++) { string key = "DAY" + (i + 1); string name = (i + 1).ToString(); dt.Columns.Add(new DataColumn(key) { Caption = name }); TubeRoll.GridColumnSum(ultraGrid3, new string[] { key }); } EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid4.DisplayLayout.Bands[0]); var list2 = new ValueList(); list2.ValueListItems.Add("000000", "所有"); list2.ValueListItems.Add("600202", "高温炉"); list2.ValueListItems.Add("600203", "淬火"); list2.ValueListItems.Add("600204", "低温炉"); list2.ValueListItems.Add("600205", "定径"); list2.ValueListItems.Add("600206", "热矫"); list2.ValueListItems.Add("600207", "冷矫"); list2.ValueListItems.Add("600208", "表面检验"); list2.ValueListItems.Add("600209", "探伤"); ultraGrid4.DisplayLayout.Bands[0].Columns["StationCode"].ValueList = list2; doOutlibrary(); doMinutesQuery(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Outlibrary"://查询 doOutlibrary(); break; case "ClassPint"://班报打印 doClassPint(); break; case "DayPrint"://日报打印 doDayPrint(); break; case "MonthPrint"://月报打印 doMonthPrint(); break; case "Close": this.Close(); break; default: break; } } /// /// 生产实绩 /// private void doOutlibrary() { //月 string fistMonthD = ""; //日 string fistday = ""; fistMonthD = dateDayTime.Value.ToString("yyyyMM"); fistday = dateDayTime.Value.ToString("yyyyMMdd"); string plineCode = this.comPlineCode.Value.ToString(); _bc = cmbBc.Value.ToString(); //_bz = cmbBz.Value.ToString(); //查询当班生产实绩 DataTable dtlb = ServerHelper.GetData("com.steering.mes.mcp.Report.FrmHttControlLog.doQueryActual", new object[] { fistday, _bc, plineCode }, this.ob); if (dtlb != null && dtlb.Rows.Count > 0) { //if (!dtlb.Rows[0]["JUDGE_STOVE_NO"].ToString().Equals("0")) //{ DataRow row = dtlb.Rows[0]; this.statisticalControl1.Value.JudgeStoveNo = row["JUDGE_STOVE_NO"].ToString(); this.statisticalControl1.Value.QualifiedNum = row["QUALIFIED_NUM"].ToString(); this.statisticalControl1.Value.QualifiedWt = row["QUALIFIED_WT"].ToString(); this.statisticalControl1.Value.Minutes = row["MINUTES"].ToString(); this.statisticalControl1.Value.AbaMinutes = row["ABSMINUTES"].ToString(); this.statisticalControl1.Value.SumMinutes = row["SUMMINUTES"].ToString(); double feizi = double.Parse(row["YOUMINUTES"].ToString()) - double.Parse(row["SUMMINUTES"].ToString()); double feimu = double.Parse(row["YOUMINUTES"].ToString()); if (feizi <= 0 || dtlb.Rows[0]["JUDGE_STOVE_NO"].ToString().Equals("0")) { efficlb = "0"; } else { efficlb = ((feizi / feimu) * 100).ToString("f2"); } this.statisticalControl1.Value.Effic = efficlb + "%"; this.statisticalControl1.UpdateData(); } else { StatisticalClass result = new StatisticalClass(); this.statisticalControl1.Value = result; } //查询当天生产实绩 DataTable dt1lb = ServerHelper.GetData("com.steering.mes.mcp.Report.FrmHttControlLog.doQueryDayActual", new object[] { fistday, plineCode }, this.ob); if (dt1lb != null && dt1lb.Rows.Count > 0) { //if (!dt1lb.Rows[0]["JUDGE_STOVE_NO"].ToString().Equals("0")) //{ DataRow row1 = dt1lb.Rows[0]; this.statisticalControl3.Value.JudgeStoveNo = row1["JUDGE_STOVE_NO"].ToString(); this.statisticalControl3.Value.QualifiedNum = row1["QUALIFIED_NUM"].ToString(); this.statisticalControl3.Value.QualifiedWt = row1["QUALIFIED_WT"].ToString(); this.statisticalControl3.Value.Minutes = row1["MINUTES"].ToString(); this.statisticalControl3.Value.AbaMinutes = row1["ABSMINUTES"].ToString(); this.statisticalControl3.Value.SumMinutes = row1["SUMMINUTES"].ToString(); double feizi = double.Parse(row1["YOUMINUTES"].ToString()) - double.Parse(row1["SUMMINUTES"].ToString()); double feimu = double.Parse(row1["YOUMINUTES"].ToString()); if (feizi <= 0 || dt1lb.Rows[0]["JUDGE_STOVE_NO"].ToString().Equals("0")) { effic1lb = "0"; } else { effic1lb = ((feizi / feimu) * 100).ToString("f2"); } this.statisticalControl3.Value.Effic = effic1lb + "%"; this.statisticalControl3.UpdateData(); } else { StatisticalClass result = new StatisticalClass(); this.statisticalControl3.Value = result; } //查询当月生产实绩 DataTable dt2lb = ServerHelper.GetData("com.steering.mes.mcp.Report.FrmHttControlLog.doQueryMonthActual", new object[] { fistMonthD, plineCode }, this.ob); if (dt2lb != null && dt2lb.Rows.Count > 0) { //if (!dt2lb.Rows[0]["JUDGE_STOVE_NO"].ToString().Equals("0")) //{ DataRow row2 = dt2lb.Rows[0]; this.statisticalControl2.Value.JudgeStoveNo = row2["JUDGE_STOVE_NO"].ToString(); this.statisticalControl2.Value.QualifiedNum = row2["QUALIFIED_NUM"].ToString(); this.statisticalControl2.Value.QualifiedWt = row2["QUALIFIED_WT"].ToString(); this.statisticalControl2.Value.Minutes = row2["MINUTES"].ToString(); this.statisticalControl2.Value.AbaMinutes = row2["ABSMINUTES"].ToString(); this.statisticalControl2.Value.SumMinutes = row2["SUMMINUTES"].ToString(); double feizi = double.Parse(row2["YOUMINUTES"].ToString()) - double.Parse(row2["SUMMINUTES"].ToString()); double feimu = double.Parse(row2["YOUMINUTES"].ToString()); if (feizi <= 0 || dt2lb.Rows[0]["JUDGE_STOVE_NO"].ToString().Equals("0")) { effic2lb = "0"; } else { effic2lb = ((feizi / feimu) * 100).ToString("f2"); } this.statisticalControl2.Value.Effic = effic2lb + "%"; this.statisticalControl2.UpdateData(); } else { StatisticalClass result = new StatisticalClass(); this.statisticalControl2.Value = result; } doMinutesQuery(); } /// /// 班报打印 /// private void doClassPint() { doOutlibrary(); //日 string fistday = ""; //string lastday = ""; fistday = dateDayTime.Value.ToString("yyyyMMdd"); //lastday = dateDayTime.Value.ToString("yyyyMMdd"); //if (_bc.Equals("3")) //{ // fistday = fistday + "18"; // lastday = lastday + "10"; //} //if (_bc.Equals("1")) //{ // fistday = lastday + "00"; // lastday = lastday + "18"; //} //if (_bc.Equals("2")) //{ // fistday = lastday + "12"; // lastday = lastday + "23"; //} string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepScheduClassAll.cpt&__bypagesize__=false&PROBC=" + _bc + "&startTim=" + fistday + "&p1=" + efficlb + "&PLINECODE=" + this.comPlineCode.Value.ToString() + ""; FrmRepExcel fre = new FrmRepExcel(this.ob, url); fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fre.Text = "调度班报统计"; fre.ShowDialog(); } /// /// 日报打印 /// private void doDayPrint() { doOutlibrary(); //日 string fistday = ""; //string lastday = ""; fistday = dateDayTime.Value.ToString("yyyyMMdd"); //lastday = dateDayTime.Value.ToString("yyyyMMdd"); string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepScheduDayAll.cpt&__bypagesize__=false&startTim=" + fistday + "&p1=" + efficlb + "&PLINECODE=" + this.comPlineCode.Value.ToString() + ""; FrmRepExcel fre = new FrmRepExcel(this.ob, url); fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fre.Text = "调度日报统计"; fre.ShowDialog(); } /// /// 月报打印 /// private void doMonthPrint() { doOutlibrary(); //月 string fistMonthD = ""; //string lrktMonthD = ""; //DateTime t = DateTime.Parse(dateDayTime.Value.ToString()); //DateTime t1 = new DateTime(t.Year, t.Month, 1); //lastMonthD = DateTime.Parse(t.ToString("yyyy-MM-dd 21:06")).ToString("yyyyMMdd"); fistMonthD = dateDayTime.Value.ToString("yyyyMM"); string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepScheduMonthAll.cpt&__bypagesize__=false&startTim=" + fistMonthD + "&p1=" + efficlb + "&PLINECODE=" + this.comPlineCode.Value.ToString() + ""; FrmRepExcel fre = new FrmRepExcel(this.ob, url); fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fre.Text = "调度月报统计"; fre.ShowDialog(); } private void doStopQuery(string date, string plinCode) { List listEntity1 = EntityHelper.GetData("com.steering.mes.mcp.Report.FrmHttControlLog.doStopQuery", new object[] { date, plinCode }, ob); httControlLogEntityBindingSource1.DataSource = listEntity1; HeatTreatment.comm.RefreshAndAutoSize(ultraGrid2, new string[] { "LogsBeg", "LogsEnd", "Memo" }); ultraExpandableGroupBox1.Expanded = true; // doAnalysis(); } /// /// 停机汇总 /// private void doMinutesQuery() { string time = dateDayTime.Value.ToString("yyyyMM"); DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Report.FrmHttControlLog.doMinutesQuery", new object[] { time, days.ToString() }, this.ob); GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true); //foreach (UltraGridColumn column in ultraGrid3.DisplayLayout.Bands[0].Columns) // column.Width = 50; foreach (UltraGridRow urg in ultraGrid3.Rows) { double MonthCount = 0; foreach (UltraGridColumn column in ultraGrid3.DisplayLayout.Bands[0].Columns) { column.Width = 50; column.CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly; column.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right; if (column.Key.Contains("DAY")) { urg.Cells[column.Key].Value = (double.Parse(urg.Cells[column.Key].Value.ToString()) / 60).ToString("f2"); if (double.Parse(urg.Cells[column.Key].Value.ToString()) >= 4.0 && double.Parse(urg.Cells[column.Key].Value.ToString()) < 12.0) { urg.Cells[column.Key].Appearance.BackColor = Color.Yellow; } else if (double.Parse(urg.Cells[column.Key].Value.ToString()) >= 12.0 && double.Parse(urg.Cells[column.Key].Value.ToString()) < 24.0) { urg.Cells[column.Key].Appearance.BackColor = Color.Orange; } else if (double.Parse(urg.Cells[column.Key].Value.ToString()) >= 24.0) { urg.Cells[column.Key].Appearance.BackColor = Color.Red; } MonthCount += double.Parse(urg.Cells[column.Key].Value.ToString()); } } urg.Cells["Month"].Value = MonthCount; } } #region 冷拔 /// /// 冷拔 /// /// /// private void ultraButton1_Click(object sender, EventArgs e) { doStopQuery(dateDayTime.Value.ToString("yyyyMMdd"), this.comPlineCode.Value.ToString()); } private void ultraButton6_Click(object sender, EventArgs e) { FrmProductionDetails pro = new FrmProductionDetails(dateDayTime.Value.ToString("yyyyMMdd"), this.comPlineCode.Value.ToString(), this.ob); pro.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); pro.Text = "生产详细"; pro.ShowDialog(); } #endregion /// ///停机时间差 /// /* private void doAnalysis() { foreach (UltraGridRow ugr in ultraGrid1.Rows) { string loagEnd = ugr.Cells["LOGS_END"].Value.ToString(); string loagBeg = ugr.Cells["LOGS_BEG"].Value.ToString(); TimeSpan timeSpan = DateTime.Parse(loagEnd) - DateTime.Parse(loagBeg); ugr.Cells["TimeDiff"].Value = timeSpan.TotalMinutes.ToString(); } }*/ private string DateDiff(DateTime DateTime1, DateTime DateTime2) { string dateDiff = null; try { TimeSpan ts1 = new TimeSpan(DateTime1.Ticks); TimeSpan ts2 = new TimeSpan(DateTime2.Ticks); TimeSpan ts = ts1.Subtract(ts2).Duration(); dateDiff = ts.Minutes.ToString(); } catch { } return dateDiff; } private void ultraGrid2_AfterRowActivate(object sender, EventArgs e) { if (ultraGrid2.ActiveRow == null) return; HttControlLogEntity entity = ultraGrid2.ActiveRow.ListObject as HttControlLogEntity; if (entity == null) return; if (entity.ProType == "停机") { egpGroupBox1.Expanded = true; var lists = EntityHelper.GetData("com.steering.mes.mcp.Report.FrmHttControlLog.doQueryDetail1", new object[] { entity.ControlId }, ob); httControlLogDetailEntityBindingSource1.DataSource = lists; } else { egpGroupBox1.Expanded = false; httControlLogDetailEntityBindingSource1.DataSource = new List(); } } } }