using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Linq; using System.Windows.Forms; using Core.Mes.Client.Comm; using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Control; using Core.StlMes.Client.Mcp.Control.Common; using Core.StlMes.Client.Mcp.Control.Entity; using Core.StlMes.Client.Mcp.Control.Machining; using CoreFS.CA06; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; using System.Threading; namespace Core.StlMes.Client.Mcp.Mch.MchResult { public partial class FrmMchBase : FrmBase { protected MchControlBase mchControlBase1 = null; private string[] plineCodes; private bool isViewDelete = false; public FrmMchBase() { InitializeComponent(); } public string DefaultGx = ""; public string Gx { get { return mchControlBase1 == null ? DefaultGx : mchControlBase1.gx; } } public bool IsViewDelete { get { return isViewDelete; } set { isViewDelete = value; } } public PlnZyJgxCEntity ActiveRow { get { if (ultraGrid1.ActiveRow == null) return null; return ultraGrid1.ActiveRow.ListObject as PlnZyJgxCEntity; } } protected virtual UltraGridRow ActitveResultRow { get { return null; } } protected virtual object Value { get { return null; } } protected override void OnLoad(EventArgs e) { base.OnLoad(e); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); commHelper.RefreshAndAutoSize(ultraGrid1); ultraGrid1.DisplayLayout.Bands[0].Override.HeaderClickAction = HeaderClickAction.Select; if(ob==null) return; plineCodes = comm.InitDropPlinePower("G",ucePline, ValidDataPurviewIds,this.CustomInfo, ob); comm.InitDroCheckStation("G", uceFactory, ValidDataPurviewIds, ob); if (mchControlBase1 != null) { mchControlBase1.Ob = ob; mchControlBase1.DisableFiltering(); var f1 = new Font("宋体", 11F, FontStyle.Bold); mchControlBase1.SetFont(f1); } portMchBatchControl1.ob = ob; portMchBatchControl1.userName = this.UserInfo.GetUserName(); portMchBatchControl1.Shift = this.UserInfo.GetUserOrder(); portMchBatchControl1.Group = this.UserInfo.GetUserGroup(); portMchBatchControl1.DisableFiltering(); ultraGrid1.DisplayLayout.Bands[0].Columns["MeasureCount"].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["ProDate"].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["CurrentStatus"].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["BesideDate"].Hidden = true; ultraGrid1.DisplayLayout.Bands[0].Columns["BatchNo"].MergedCellStyle = MergedCellStyle.Always; ultraGrid1.DisplayLayout.Bands[0].Columns["BatchNo"].MergedCellEvaluator = new CustomMergedCellEvaluator(new[] { "JudgeStoveNo" }); ultraGrid1.DisplayLayout.Bands[0].Columns["ProCount"].EditorComponent = uteCard; } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "DoQuery": Query(true); break; case "DoAdd": DoAdd(); break; case "DoAddNew": DoAddNew(); break; case "DoDelete": DoDelete(); break; case "DoForceDelete": DoForceDelete(); break; case "DoUpdate": DoUpdate(); break; case "DoBeside": DoBeside(); break; case "CelBeside": DoCelBeside(); break; case "doBesideQuery": DoBesideQuery(); break; case "doPrint": DoTransferPrint(); break; case "SetGroup": SetGroup(); break; case "SetMesureData": SetMesureData(); break; case "Export": Globals.ulGridToExcel(ultraGrid1, Text); break; case "DoClose": Close(); break; case "DoApproval": DoApproval(); break; case "DoCancleApproval": DoCancleApproval(); break; case "Print": Print(); break; case "UpLoad": UpLoad(); break; case "updateLen": updateLen(); break; } } private void updateLen() { if (ActiveRow == null) { MessageUtil.ShowTips("请选择需要炉计划!"); return; } var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.Mch.MchComm"; ccp.MethodName = "updateLen"; ccp.ServerParams = new object[] { ActiveRow.OrderNo, ActiveRow.OrderSeq, ActiveRow.BatchGroudNo }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("操作成功!")) Query(); } } protected virtual void DoUpdate() { } private void SetGroup() { if (ActiveRow == null) { MessageUtil.ShowTips("请选择需要炉计划!"); return; } FrmGroupSetting fgs = new FrmGroupSetting(ActiveRow.OrderNoSeq,ActiveRow.HeatPlanNo,ob); fgs.ShowDialog(); } public void Query(bool ActiveFirst= false) { var starts = ""; var plnNo = ""; var judgeStoveNo = ""; var feedStoveNo = ""; var checkStaion = ""; string[] plines = plineCodes; var start = contorlPlanStatus1.statusArr; if (chkPlnNo.Checked) if (string.IsNullOrEmpty(txtRollBatchId.Text.Trim())) { MessageUtil.ShowTips("请输入炉次计划号!"); return; } else { plnNo = txtRollBatchId.Text.Trim(); start = new string[4] {"10", "20", "30", "40"}; } if (chkJuNo.Checked) if (string.IsNullOrEmpty(txtZyBatchId.Text.Trim())) { MessageUtil.ShowTips("请输入炉号!"); return; } else { judgeStoveNo = txtZyBatchId.Text.Trim(); start = new string[4] {"10", "20", "30", "40"}; } if (chkFeedNo.Checked) if (string.IsNullOrEmpty(txtFeedNo.Text.Trim())) { MessageUtil.ShowTips("请输入炉号!"); return; } else { feedStoveNo = txtFeedNo.Text.Trim(); start = new string[4] {"10", "20", "30", "40"}; } if (chkPline.Checked && ucePline.SelectedIndex >= 0) { plines = new string[] { ucePline.SelectedItem.DataValue.ToString2()}; } if (chkFactory.Checked && uceFactory.SelectedIndex >= 0) { checkStaion = uceFactory.SelectedItem.DataValue.ToString2(); } ResetUI(); plnZyJgxCEntityBindingSource.DataSource = EntityHelper.GetData( "com.steering.mes.mcp.common.PlanService.getSingleJGPlan", new object[] { Gx != "701301", plnNo, judgeStoveNo,feedStoveNo, plines, start, Gx, ultraOptionSet2.Visible ? ultraOptionSet2.Value.ToString2() : "2", checkStaion, ultraOptionOther.Value.ToString2() }, ob); if (ActiveFirst && ultraGrid1.Rows.Count > 0 && judgeStoveNo!="") ultraGrid1.Rows[0].Activated = true; commHelper.RefreshAndAutoSizeExceptColumns(ultraGrid1, new string[] { "ProdStandard", "StationRoad", "Lengthdisc" }); DecisionRed(ultraGrid1); } protected virtual void Print() { } protected virtual void ResetUI() { } protected virtual void UpLoad() { } protected virtual void UpLoadDelete() { } /// /// 实绩保存 /// protected virtual void DoAdd() { //} } /// /// 实绩保存 /// protected virtual void DoAddNew() { //} } protected virtual void DoApproval() { //} } protected virtual void DoCancleApproval() { //} } protected virtual void DecisionRed(UltraGrid DataGrid) { //} } /// /// 结炉实绩查询 /// private void DoBesideQuery() { //DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getMchBugD", new object[] { txtZyBatchId.Text.ToString(), txtRollBatchId.Text.ToString(), plineCode, start }, this.ob); //GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true); var heatno = ""; var lotno = ""; var plinename = ""; var urg = ultraGrid1.ActiveRow; var matfrm = new FrmReason(ob, urg, ""); matfrm.ShowDialog(); } /// /// 传递卡打印 /// private void DoTransferPrint() { if (ActiveRow == null) { MessageUtil.ShowTips("请选择要打印的炉信息!"); return; } var strurl = ""; if (ActiveRow.PlineCode.Equals("C021")) //镦粗 strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=MchDeliveryCard.cpt&T.HEAT_PLAN_NO=" + ActiveRow.HeatPlanNo + "&T.JUDGE_STOVE_NO=" + ActiveRow.JudgeStoveNo + "&T.PLINE_CODE=" + ActiveRow.PlineCode + "&T2.BATCH_GROUD_NO=" + ActiveRow.BatchGroudNo + "&TT.STATION_DESC='上料'"; else strurl = "http://localhost:8075/webroot/decision/view/report?viewlet=MchDeliveryCard.cpt&heatNo=" + ActiveRow.HeatPlanNo + "&judgeNo=" + ActiveRow.JudgeStoveNo + "&plineCode=" + ActiveRow.PlineCode + "&groupNo=" + ActiveRow.BatchGroudNo + "&batchNo=" + ActiveRow.BatchNo + "&abc=上料"; var fre = new FrmRepExcel(ob, strurl); fre.AutoSize = true; fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fre.WindowState = FormWindowState.Maximized; fre.Show(); } private void DoCelBeside() { if (ActiveRow == null) return; if (MessageUtil.ShowYesNoAndQuestion("是否撤销结炉?") == DialogResult.No) return; var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.Mch.MchComm"; ccp.MethodName = "undoBeside"; ccp.ServerParams = new object[] {ActiveRow.HeatPlanNo, ActiveRow.BatchNo, Gx, ActiveRow.PlineCode}; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("撤销结炉成功!")) Query(); } } /// /// 工序结炉 /// protected void DoBeside(bool DoNotQuey = false) { if (ActiveRow == null) { MessageUtil.ShowTips("请选择需要结炉的炉计划!"); return; } if (Gx=="701313"){ DataTable CountDt = ServerHelper.GetData("com.steering.mes.mcp.Mch.MchComm.getUnCheckCout", new object[] { ActiveRow.HeatPlanNo, ActiveRow.BatchNo }, ob); if (CountDt.Rows.Count > 0) { int Count = 0; if (int.TryParse(CountDt.Rows[0]["COUNT"].ToString3(), out Count)) { if (Count > 0) { if (MessageUtil.ShowYesNoAndQuestion("有"+Count+ "支管未检验,是否确认依然结炉?") == DialogResult.No) return; } } } } if (MessageUtil.ShowYesNoAndQuestion("是否结炉?") == DialogResult.No) return; var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.Mch.MchComm"; ccp.MethodName = "updateDoBeside"; ccp.ServerParams = new object[] {ActiveRow.HeatPlanNo, ActiveRow.BatchNo, Gx, ActiveRow.PlineCode}; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("结炉成功!")) if (!DoNotQuey) Query(); } } /// /// 撤销上料 /// protected virtual void DoDelete() { } /// /// 撤销上料 /// protected virtual void DoForceDelete() { } private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { var PlnZyRclCEntity = e.Row.ListObject as PlnZyJgxCEntity; if (PlnZyRclCEntity == null) return; if (PlnZyRclCEntity.Planstatus == "20") { e.Row.Cells["Planstatus"].Appearance.BackColor = Color.LightGreen; } else if ((PlnZyRclCEntity.Planstatus == "30") || (PlnZyRclCEntity.Planstatus == "40")) { e.Row.Cells["Planstatus"].Appearance.BackColor = Color.Red; e.Row.Appearance.BackColor = Color.LightGray; } if (PlnZyRclCEntity.ActCount > 0) e.Row.Cells["ActCount"].Appearance.BackColor = Color.LightGreen; } private void craftImg_EditorButtonClick(object sender, EditorButtonEventArgs e) { if (ActiveRow == null) return; var craftPath = YdmBaseClass.getQueryCraftNo(ActiveRow.CraftFileNo, ActiveRow.CraftSeq.ToString2(), ob); if (e.Button.Key.ToLower().Equals("select")) { var down = new FormFileDown(ob, craftPath); down.CtrlFileDown1.Button3.Visible = false; down.ShowDialog(); } } private void chkStarts_CheckedChanged(object sender, EventArgs e) { if (chkPlnNo.Checked) txtRollBatchId.Enabled = true; else txtRollBatchId.Enabled = false; if (chkJuNo.Checked) txtZyBatchId.Enabled = true; else txtZyBatchId.Enabled = false; if (chkFeedNo.Checked) txtFeedNo.Enabled = true; else txtFeedNo.Enabled = false; } private void uteCraft2_EditorButtonClick(object sender, EditorButtonEventArgs e) { if (ActiveRow == null) return; if (e.Button.Key.ToLower().Equals("select")) { var down = new FormFileDown(ob, "Qcm/CraftLv2/" + ActiveRow.OrderNoSeq + "/" + ActiveRow.SecCraftFileNo); down.CtrlFileDown1.Button3.Visible = false; down.ShowDialog(); } } protected void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { if (mchControlBase1!=null) mchControlBase1.PlnZyJgxCEntity = ActiveRow; portMchBatchControl1.Query(ActiveRow.HeatPlanNo, ActiveRow.BatchNo, Gx, ActiveRow.ProducType == "C" || ActiveRow.ProducType=="E"); GetResultData(); } /// /// 获取当前工序的实绩 /// protected virtual void GetResultData() { if (mchControlBase1 != null) mchControlBase1.PortHttBatchSampleResultEntitys = portMchBatchControl1.Data; } public class CustomMergedCellEvaluator : IMergedCellEvaluator { private readonly string[] keys; public CustomMergedCellEvaluator(string[] GroupKey) { keys = GroupKey; } public bool ShouldCellsBeMerged(UltraGridRow row1, UltraGridRow row2, UltraGridColumn column) //控件自带的方法,会自动进行调用,column为初始化中设置的行 { foreach (var key in keys) if (row1.Cells[key].Value.ToString() != row2.Cells[key].Value.ToString()) return false; return row1.Cells[column].Value.ToString() == row2.Cells[column].Value.ToString(); } } private void uteMeasureData_EditorButtonClick(object sender, EditorButtonEventArgs e) { using (MesureData MesureData = new MesureData(ActiveRow, ob, this.UserInfo.GetUserName(), false, this.CustomInfo)) { MesureData.ShowDialog(); ultraGrid1.ActiveCell.Value =(decimal) MesureData.list.Where(p => p.Flag == "00").Select(p => p.MatNo).Distinct().Count(); portMchBatchControl1.Query(ActiveRow.HeatPlanNo, ActiveRow.BatchNo, Gx, ActiveRow.ProducType == "C" || ActiveRow.ProducType == "E"); ultraGrid1.UpdateData(); ultraGrid1.Refresh(); } } private void SetMesureData() { using (MesureData MesureData = new MesureData(ActiveRow, ob, this.UserInfo.GetUserName(), true,this.CustomInfo)) { MesureData.ShowDialog(); ultraGrid1.ActiveRow.Cells["MeasureCount"].Value = (decimal)MesureData.list.Where(p => p.Flag == "00").Select(p => p.MatNo).Distinct().Count(); portMchBatchControl1.Query(ActiveRow.HeatPlanNo, ActiveRow.BatchNo, Gx, ActiveRow.ProducType == "C" || ActiveRow.ProducType == "E"); ultraGrid1.UpdateData(); ultraGrid1.Refresh(); } } private void uteCard_EditorButtonClick(object sender, EditorButtonEventArgs e) { PlnZyJgxCEntity entity = ultraGrid1.ActiveRow.ListObject as PlnZyJgxCEntity; string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMchDeliveryCard.cpt&op=view&HEAT_PLAN_NO=" + entity.HeatPlanNo + "&BATCH_NO=" + entity.BatchNo; var fre = new FrmRepExcel(ob, strurl); fre.AutoSize = true; fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fre.WindowState = FormWindowState.Maximized; fre.Show(); } protected int GetReturnNum() { List OffList = EntityHelper.GetData( "com.steering.mes.mcp.common.OfflineHelper.QueryMchOffLineData", new object[] { ActiveRow.HeatPlanNo, ActiveRow.BatchNo }, ob); //返线到前工序的 return (int)(OffList.Where(p => p.ReturnProcess != p.StationCode && mchControlBase1.CheckGx2(p.StationCode, Gx) && mchControlBase1.CheckGx2(Gx, p.ReturnProcess)).Sum(p => p.ReNum) ?? 0); } private void uteFilePath_EditorButtonClick(object sender, EditorButtonEventArgs e) { if (ActiveRow == null) return; UltraGridRow row = ultraGrid1.ActiveRow; FormFileDown down = new FormFileDown(this.ob, row.Cells["FilePath"].Text); if (!IsViewDelete) { down.CtrlFileDown1.Button3.Visible = false; } else { down.CtrlFileDown1.FileDeleteEvent += (() => { List list = down.CtrlFileDown1.List; if (list == null || list.Count <= 0) { UpLoadDelete(); } }); } down.ShowDialog(); } private void FilePath2Editor_EditorButtonClick(object sender, EditorButtonEventArgs e) { if (ActiveRow == null) return; UltraGridRow row = ultraGrid1.ActiveRow; if (e.Button.Key.ToLower().Equals("select")) { FormFileDown down = new FormFileDown(this.ob, row.Cells["FilePath2"].Text); down.ShowDialog(); } else { string filePath = "JGMESServer/" + "CMD" + "/" + ActiveRow.PlineCode + "/" + ActiveRow.JudgeStoveNo + "/"; FormFileDown down = new FormFileDown(this.ob, filePath); down.CtrlFileDown1.FilePath = filePath; List list = new List(); FileBean bean = new FileBean(); OpenFileDialog file = new OpenFileDialog(); file.Multiselect = true; DialogResult drStat; drStat = file.ShowDialog(); if (drStat == DialogResult.OK) { foreach (string fileName in file.FileNames) { bean = new FileBean(); string filena = System.IO.Path.GetFileName(fileName); bean.setFileName(filena); bean.setPathName(filePath); bean.setFile(FileHelper.FileToArray(fileName)); list.Add(bean); } bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list); if (isSuccess) { Thread.Sleep(100); //等待一下下 DoUpdateFilePath(filePath, true); } else { MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question); } } } } public void DoUpdateFilePath(string filePath, bool showTips) { var ccp = new CoreClientParam { ServerName = "com.steering.mes.mcp.Mch.FrmMcpLoading", MethodName = "DoUpdateFilePath2", ServerParams = new object[] { ActiveRow.HeatPlanNo, filePath } }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1 && showTips) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Contains("成功!")) Query(true); } else if (!showTips) { Query(true); } } } }