using System; using System.Collections; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Windows.Forms; using com.steering.mes.mcp.entity; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Control.Common; using Core.StlMes.Client.Mcp.Control.Entity; using Core.StlMes.Client.Mcp.Treatment.HeatTreatment; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.Mcp.Treatment { public partial class FrmHttLoadingResultEntity : FrmHttBase { private string plineCode = ""; private string[] plineCodes; private int ProcessSeq = 1; public FrmHttLoadingResultEntity() { InitializeComponent(); IsLoadUserView = true; } private string SlGx { get { return "600201"; } } protected override void OnLoad(EventArgs e) { base.OnLoad(e); base.ultraGrid1.DisplayLayout.Bands[0].Columns["ProCount"].Header.Caption = "上料支"; base.ultraGrid1.DisplayLayout.Bands[0].Columns["ProWeight"].Header.Caption = "上料吨"; base.ultraGrid1.DisplayLayout.Bands[0].Columns["PerStatus"].Header.Caption = "库存位置"; httInstructionCardControl1.DisableFiltering(); EntityHelper.ShowGridCaption(LoadGrid.DisplayLayout.Bands[0]); comm.RefreshAndAutoSize(LoadGrid); comm.setOtherColumnReadOnly(LoadGrid,new string[]{}); LoadGrid.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False; foreach (UltraGridColumn ugc in LoadGrid.DisplayLayout.Bands[0].Columns) { ugc.SortIndicator = SortIndicator.Disabled; } Font f1 = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Bold); httInstructionCardControl1.SetFont(f1); } public override void ToolBar_Click(object sender, string ToolbarKey) { //base.ToolBar_Click(sender, ToolbarKey); switch (ToolbarKey) { case "DoQuery": QuerySinglePlan(); break; case "DoLoading": DoSave(); break; case "DoReturn": DoReturn(); break; case "DoBeside": DoBeside(); break; case "CelBeside": DoCelBeside(); break; case "DoClose": Close(); break; case "doPrint": DoTransferPrint(); break; case "Export": Mes.Client.Comm.Globals.ulGridToExcel(ultraGrid1, Text); break; } } /// /// 传递卡打印 /// 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://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='上料'"; 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; var list = new ArrayList(); list.Add(ActiveRow.HeatPlanNo); list.Add(ActiveRow.PlineCode); list.Add(SlGx); if (MessageUtil.ShowYesNoAndQuestion("是否撤销结炉?") == DialogResult.No) return; var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttLoadingService"; ccp.MethodName = "undoBeside"; ccp.ServerParams = new object[] {list}; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("撤销结炉成功!")) { QuerySinglePlan(); } } } /// /// 工序结炉 /// private void DoBeside(bool ask = true) { if (ActiveRow == null) { MessageUtil.ShowTips("请选择需要结炉的炉计划!"); return; } var list = new ArrayList(); list.Add(ActiveRow.HeatPlanNo); list.Add(ActiveRow.PlineCode); list.Add(SlGx); list.Add(ActiveRow.JudgeStoveNo); list.Add(ActiveRow.BatchNo); list.Add(ActiveRow.BatchGroudNo); list.Add(ActiveRow.JugdeApplyCode); list.Add(ActiveRow.NextProcessCode); if (ask) if (MessageUtil.ShowYesNoAndQuestion("是否结炉?") == DialogResult.No) { return; } var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttLoadingService"; ccp.MethodName = "updateDoBeside"; ccp.ServerParams = new object[] {list}; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("结炉成功!")) { if (ask) MessageUtil.ShowTips(ccp.ReturnInfo); QuerySinglePlan(); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 简单查询 /// private void QuerySinglePlan() { Query(plineCodes); } //查询管号队列 private void QueryPortVrp(PlnZyRclCEntity PlnZyRclCEntity) { portHttBatchControl1.Query(PlnZyRclCEntity.HeatPlanNo, PlnZyRclCEntity.PlineCode, ProcessSeq,ActiveRow.GowhereCode); httInstructionCardControl1.PortHttBatchSampleResultEntitys = portHttBatchControl1.datas; } /// /// 根据计划号查询上料实绩 /// /// public void GetLoadResult(string heatNo,string sqe) { List list = EntityHelper.GetData( "com.steering.mes.mcp.heatTreatment.HttLoadingService.getLoadResult", new object[] { heatNo, sqe }, ob); httLoadingResultEntityBindingSource.DataSource = list; comm.RefreshAndAutoSize(LoadGrid); LoadGrid.ActiveRow = null; } /// /// 初始化控件 /// private void initControl() { if (ActiveRow == null) return; var result = new HttLoadingResultEntity() { HeatPlanNo = ActiveRow.HeatPlanNo, FailNum = 0, LoadShift = UserInfo.GetUserOrder(), LoadGroup = UserInfo.GetUserGroup(), LoadUser = UserInfo.GetUserName(), LoadTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), ProcessSeq = ProcessSeq, ZyBatchId = ActiveRow.ZyBatchId, IfMonitorRcl = ActiveRow.IfMonitor, PrdcrNo =ActiveRow.PrdcrNo , ProducerTime = ActiveRow.IfMonitor.Equals("1") ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : null, PlineCode = plineCode, MatSource = ActiveRow.MatSource }; result.ProcessSeq = result.ProcessSeq ?? 1; result.ProNum = ActiveRow.ActCount; result.ProWt = ActiveRow.ActWeight; httInstructionCardControl1.ActCount = ActiveRow.ActCount??0; httInstructionCardControl1.FeedStoveNo = ActiveRow.FeedHeatNo; httInstructionCardControl1.BatchNo = ActiveRow.BatchNo; httInstructionCardControl1.GroupNo = ActiveRow.BatchGroudNo; httInstructionCardControl1.JudgeNo = ActiveRow.JugdeApplyCode; httInstructionCardControl1.ShowPro(ActiveRow.IfMonitor.Equals("1")); httInstructionCardControl1.Value = result; } /// /// 上料实绩保存 /// private void DoSave() { if (ActiveRow!= null) { var groupNo = ActiveRow.BatchGroudNo.ToString2(); var gxh = "0"; var result = httInstructionCardControl1.Value; if (result.ProNum==null || result.ProNum ==0) { MessageUtil.ShowTips("上料支数不能为空或零"); return; } if ((result.FailNum == null)) result.FailNum = 0; if (result.ProcessSeq == null) result.ProcessSeq = 1; if (MessageUtil.ShowYesNoAndQuestion("是否上料?") == DialogResult.No) return; if (result.FailNum != null && result.FailNum > 0 && result.FailNum != httInstructionCardControl1.ScrappedList.Sum(p => p.DefFillNum)) { MessageUtil.ShowTips("废品数据异常,请重新录入"); return; } var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttLoadingService"; ccp.MethodName = "saveHttLoadingResult"; ccp.ServerParams = new object[] {JSONFormat.Format(result), ActiveRow.HeatPlanSqe, SlGx, ActiveRow.PlineCode, groupNo, new List(), httInstructionCardControl1.ScrappedList.Select(JSONFormat.Format).ToList()}; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("上料成功!")) { QuerySinglePlan(); doOver(); } } } //} } private void doOver() { if (ActiveRow == null) return; var dt1 = ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttLoadingService.getquerymaternum", new object[] { ActiveRow.HeatPlanNo}, ob); if (((dt1.Rows[0]["NUM"].ToString() == "0") || (dt1.Rows[0]["WT"].ToString() == "0.000"))&& ((ActiveRow.ProcessSeq??1).ToString3()== httInstructionCardControl1.Value.ProcessSeq.ToString3())) if (MessageUtil.ShowYesNoAndQuestion("待上料量或重量为0,是否结炉?") == DialogResult.No) return; else DoBeside(false); } /// /// 撤销上料 /// private void DoReturn() { var Rows = LoadGrid.ActiveRow; if (Rows == null) { if (LoadGrid.Rows.Count <= 0) return; Rows = LoadGrid.Rows[0]; } if (ActiveRow != null) { var result = Rows.ListObject as HttLoadingResultEntity; //查询是否存在上料之后的数据 var dt = ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttLoadingService.getQueryInfoPlan", new object[] { SlGx, ActiveRow.HeatPlanNo }, ob); if (dt.Rows.Count > 0) if (MessageUtil.ShowYesNoAndQuestion("存在上料后工序,是否继续删除?") == DialogResult.No) return; if (MessageUtil.ShowYesNoAndQuestion("是否确认撤销上料?") == DialogResult.No) return; var ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttLoadingService"; ccp.MethodName = "returnHttLoadingResult"; ccp.ServerParams = new object[] { JSONFormat.Format(result), ActiveRow.HeatPlanSqe, SlGx,UserInfo.GetUserName(),result==null|| result.ProcessSeq>1?ActiveRow.JudgeStoveNo: ActiveRow.FeedHeatNo }; ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("删除上料成功!")) { QuerySinglePlan(); } } } } private void FrmHttLoading_Load(object sender, EventArgs e) { plineCodes = comm.GetPlineCode(ValidDataPurviewIds, "F", ob); httInstructionCardControl1.Ob = ob; portHttBatchControl1.ob = ob; portHttBatchControl1.SetOfflineCode(new string[] { SlGx }); httInstructionCardControl1.Value = new HttLoadingResultEntity() { PlineCode = plineCode }; Gx = SlGx; //QuerySinglePlan(); //initControl(); } private void LoadGrid_AfterRowActivate(object sender, EventArgs e) { var urg = LoadGrid.ActiveRow; if (urg == null) return; httInstructionCardControl1.Value = urg.ListObject as HttLoadingResultEntity; } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { plineCode = ActiveRow.PlineCode; ProcessSeq = (int) (ActiveRow.RealProcessSeq ?? 1); this.GetLoadResult(ActiveRow.HeatPlanNo,ActiveRow.HeatPlanSqe); QueryPortVrp(ActiveRow); initControl(); } private void uteCard_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { HttLoadingResultEntity entity = LoadGrid.ActiveRow.ListObject as HttLoadingResultEntity; string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepHttDeliveryCard.cpt&op=view&RESULT_NO=" + entity.ResultNo; 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(); } //工艺文件查询 } }