FrmThreadInspectResult.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. 
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Windows.Forms;
  6. using com.steering.mes.mcp.entity;
  7. using Core.Mes.Client.Comm.Format;
  8. using Core.Mes.Client.Comm.Tool;
  9. using Core.StlMes.Client.Mcp.Control;
  10. using Core.StlMes.Client.Mcp.Control.Common;
  11. using Core.StlMes.Client.Mcp.Control.Entity;
  12. using Core.StlMes.Client.Mcp.Mch.MchResult;
  13. using CoreFS.CA06;
  14. using Infragistics.Win;
  15. using Infragistics.Win.UltraWinGrid;
  16. namespace Core.StlMes.Client.Mcp.Mch
  17. {
  18. public partial class FrmThreadInspectResult : FrmMchBase
  19. {
  20. public FrmThreadInspectResult()
  21. {
  22. InitializeComponent();
  23. mchControlBase1 = new ThreadInspectMachiningControl()
  24. {
  25. Dock = DockStyle.Fill
  26. };
  27. plnEdit.Controls.Add(mchControlBase1);
  28. }
  29. protected override UltraGridRow ActitveResultRow { get { return CrackDetectGrid.ActiveRow; } }
  30. protected override object Value { get { return (mchControlBase1 as ThreadInspectMachiningControl).Value; } }
  31. protected override void OnLoad(EventArgs e)
  32. {
  33. base.OnLoad(e);
  34. EntityHelper.ShowGridCaption<MchHreadResultEntity>(CrackDetectGrid.DisplayLayout.Bands[0]);
  35. base.ultraGrid1.DisplayLayout.Bands[0].Columns["ActCount"].Hidden = true;
  36. base.ultraGrid1.DisplayLayout.Bands[0].Columns["ActWeight"].Hidden = true;
  37. base.ultraGrid1.DisplayLayout.Bands[0].Columns["BatchGroudNo"].Hidden = true;
  38. base.ultraGrid1.DisplayLayout.Bands[0].Columns["PerStatus"].Hidden = true;
  39. base.ultraGrid1.DisplayLayout.Bands[0].Columns["BesideStatus"].Hidden = true;
  40. ultraGrid1.DisplayLayout.Bands[0].Columns["BesideDate"].Hidden = false;
  41. CrackDetectGrid.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
  42. CrackDetectGrid.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default;
  43. ultraOptionSet2.Visible = false;
  44. mchControlBase1.ultraGrid1.CellChange += (sender, args) =>
  45. {
  46. if (args.Cell.Column.Key == "MachineNo")
  47. {
  48. ChangeData(Value as MchHreadResultEntity);
  49. }
  50. };
  51. }
  52. protected override void DoAdd()
  53. {
  54. if (ActiveRow != null)
  55. {
  56. if (MessageUtil.ShowYesNoAndQuestion("是否增加实绩?") == DialogResult.No)
  57. return;
  58. var ccp = new CoreClientParam();
  59. ccp.ServerName = "com.steering.mes.mcp.Mch.FrmThreadInspectResult";
  60. ccp.MethodName = "DoAdd";
  61. ccp.ServerParams = new object[]
  62. {
  63. JSONFormat.Format(Value),
  64. Gx,
  65. mchControlBase1.ScrappedList.Select(JSONFormat.Format).ToList(),
  66. mchControlBase1.SuspiciousList.Select(JSONFormat.Format).ToList()
  67. };
  68. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  69. if (ccp.ReturnCode != -1)
  70. {
  71. MessageUtil.ShowTips(ccp.ReturnInfo);
  72. if (ccp.ReturnInfo.Equals("新增成功!"))
  73. {
  74. Query();
  75. }
  76. }
  77. }
  78. }
  79. protected override void DoDelete()
  80. {
  81. {
  82. if (ActiveRow != null && ActitveResultRow != null)
  83. {
  84. if (MessageUtil.ShowYesNoAndQuestion("是否删除实绩?") == DialogResult.No)
  85. return;
  86. var ccp = new CoreClientParam();
  87. ccp.ServerName = "com.steering.mes.mcp.Mch.FrmThreadInspectResult";
  88. ccp.MethodName = "DoDelete";
  89. ccp.ServerParams = new object[]
  90. {
  91. JSONFormat.Format(ActitveResultRow.ListObject), Gx
  92. };
  93. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  94. if (ccp.ReturnCode != -1)
  95. {
  96. MessageUtil.ShowTips(ccp.ReturnInfo);
  97. if (ccp.ReturnInfo.Equals("删除成功!"))
  98. Query();
  99. }
  100. }
  101. }
  102. }
  103. protected override void GetResultData()
  104. {
  105. base.GetResultData();
  106. mchHreadResultEntityBindingSource.DataSource = EntityHelper.GetData<MchHreadResultEntity>(
  107. "com.steering.mes.mcp.Mch.FrmThreadInspectResult.getQueryExpandResult",
  108. new object[] { ActiveRow.HeatPlanNo, ActiveRow.BatchNo },
  109. ob);
  110. commHelper.RefreshAndAutoSize(CrackDetectGrid);
  111. if (ActiveRow == null) return;
  112. var ThreadInspectMachiningControl = mchControlBase1 as ThreadInspectMachiningControl;
  113. if (ThreadInspectMachiningControl == null) return;
  114. var result = new MchHreadResultEntity
  115. {
  116. HeatPlanNo = ActiveRow.HeatPlanNo,
  117. JudgeStoveNo = ActiveRow.JudgeStoveNo,
  118. BatchNo = ActiveRow.BatchNo,
  119. PlineCode = ActiveRow.PlineCode,
  120. PlineName = ActiveRow.PlineName,
  121. ProNum = ThreadInspectMachiningControl.OkPort.Count > (ActiveRow.OperateCount ?? 0) ? ThreadInspectMachiningControl.OkPort.Count - (ActiveRow.OperateCount ?? 0) : 0,
  122. FailNum = 0,
  123. FailWt = 0,
  124. HeadCutNum = 0,
  125. MachineNo = 1,
  126. ProShift = UserInfo.GetUserOrder(),
  127. ProGroup = UserInfo.GetUserGroup(),
  128. ProUser = UserInfo.GetUserName(),
  129. ProTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  130. };
  131. ChangeData(result);
  132. }
  133. private void ChangeData(MchHreadResultEntity data)
  134. {
  135. if (ActiveRow == null) return;
  136. int NeedTest = mchControlBase1.OkPort.Count;
  137. List<MchHreadResultEntity> ProductionList =
  138. mchHreadResultEntityBindingSource.DataSource as List<MchHreadResultEntity>;
  139. int TestedNum = (int)ProductionList.Where(p => p.MachineNo == data.MachineNo).Sum(p => p.ProNum);
  140. int WasteNum = (int)ProductionList.Sum(p => (p.FailNum ?? 0));
  141. data.ProNum = NeedTest - TestedNum - WasteNum;
  142. if (data.ProNum < 0)
  143. {
  144. //返线到前工序的
  145. int OffNum = GetReturnNum();
  146. data.ProNum = data.ProNum + OffNum;
  147. if (data.ProNum < 0)
  148. {
  149. data.ProNum = 0;
  150. }
  151. }
  152. var ThreadInspectMachiningControl = mchControlBase1 as ThreadInspectMachiningControl;
  153. if (ThreadInspectMachiningControl == null) return;
  154. ThreadInspectMachiningControl.Value = data;
  155. }
  156. }
  157. }