FrmMcpLoading.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Windows.Forms;
  7. using Infragistics.Win.UltraWinGrid;
  8. using Core.Mes.Client.Comm.Tool;
  9. using Core.Mes.Client.Comm.Server;
  10. using com.steering.mes.mcp.entity;
  11. using Core.Mes.Client.Comm.Control;
  12. using Core.Mes.Client.Comm.Format;
  13. using Core.StlMes.Client.Mcp.Control.Common;
  14. using Core.StlMes.Client.Mcp.Control.Machining;
  15. using CoreFS.CA06;
  16. using Infragistics.Win;
  17. using FrmMchBase = Core.StlMes.Client.Mcp.Mch.MchResult.FrmMchBase;
  18. using System.IO;
  19. using System.Threading;
  20. namespace Core.StlMes.Client.Mcp.Mch
  21. {
  22. public partial class FrmMcpLoading : FrmMchBase
  23. {
  24. public FrmMcpLoading()
  25. {
  26. InitializeComponent();
  27. IsLoadUserView = true;
  28. mchControlBase1 = new InstructionCardControl
  29. {
  30. Dock = DockStyle.Fill
  31. };
  32. plnEdit.Controls.Add(mchControlBase1);
  33. }
  34. private string fileName = "";//路径
  35. protected override UltraGridRow ActitveResultRow { get { return LoadGrid.ActiveRow; } }
  36. protected override object Value { get { return (mchControlBase1 as InstructionCardControl).Value; } }
  37. protected override void OnLoad(EventArgs e)
  38. {
  39. base.OnLoad(e);
  40. base.ultraGrid1.DisplayLayout.Bands[0].Columns["OperateCount"].Hidden = true;
  41. base.ultraGrid1.DisplayLayout.Bands[0].Columns["OperateWeight"].Hidden = true;
  42. base.ultraGrid1.DisplayLayout.Bands[0].Columns["PerStatus"].Header.Caption = "库存位置";
  43. EntityHelper.ShowGridCaption<MchLoadingResultEntity>(LoadGrid.DisplayLayout.Bands[0]);
  44. LoadGrid.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
  45. LoadGrid.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default;
  46. IsViewDelete = true;
  47. }
  48. protected override void DoAdd()
  49. {
  50. if (ActiveRow != null)
  51. {
  52. if (MessageUtil.ShowYesNoAndQuestion("是否上料?") == DialogResult.No)
  53. return;
  54. var ccp = new CoreClientParam();
  55. ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMcpLoading";
  56. ccp.MethodName = "DoAdd";
  57. ccp.ServerParams = new object[]
  58. {
  59. ActiveRow.HeatPlanNo,
  60. ActiveRow.HeatPlanSqe,
  61. JSONFormat.Format(Value), Gx,
  62. mchControlBase1.ScrappedList.Select(JSONFormat.Format).ToList(),
  63. mchControlBase1.SuspiciousList.Select(JSONFormat.Format).ToList()
  64. };
  65. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  66. if (ccp.ReturnCode != -1)
  67. {
  68. MessageUtil.ShowTips(ccp.ReturnInfo);
  69. if (ccp.ReturnInfo.Equals("上料成功!"))
  70. {
  71. Query();
  72. doOver();
  73. }
  74. }
  75. }
  76. }
  77. protected override void DoDelete()
  78. {
  79. {
  80. if (ActiveRow != null && ActitveResultRow!=null)
  81. {
  82. //查询是否存在上料之后的数据
  83. var dt =
  84. ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttLoadingService.getQueryInfoPlan",
  85. new object[] {Gx, ActiveRow.HeatPlanNo}, ob);
  86. if (dt.Rows.Count > 0)
  87. {
  88. MessageBox.Show("已存在后工序实绩,请先删除实绩");
  89. }
  90. if (MessageUtil.ShowYesNoAndQuestion("是否确认撤销上料?") == DialogResult.No)
  91. return;
  92. var ccp = new CoreClientParam();
  93. ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMcpLoading";
  94. ccp.MethodName = "DoDelete";
  95. ccp.ServerParams = new object[]
  96. {
  97. JSONFormat.Format(ActitveResultRow.ListObject), Gx, UserInfo.GetUserName()
  98. };
  99. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  100. if (ccp.ReturnCode != -1)
  101. {
  102. MessageUtil.ShowTips(ccp.ReturnInfo);
  103. if (ccp.ReturnInfo.Equals("删除上料成功!"))
  104. Query();
  105. }
  106. }
  107. }
  108. }
  109. public void doOver()
  110. {
  111. if (ActiveRow == null) return;
  112. var dt1 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMcpLoading.getquerymaternum",
  113. new object[] { ActiveRow.HeatPlanNo, ActiveRow.BatchNo}, ob);
  114. if ((dt1.Rows[0]["NUM"].ToString() == "0") || (dt1.Rows[0]["WT"].ToString() == "0.000"))
  115. if (MessageUtil.ShowYesNoAndQuestion("待上料量或重量为0,是否结炉?") == DialogResult.No)
  116. return;
  117. else
  118. DoBeside();
  119. }
  120. protected override void GetResultData()
  121. {
  122. base.GetResultData();
  123. mchLoadingResultEntityBindingSource.DataSource = EntityHelper.GetData<MchLoadingResultEntity>(
  124. "com.steering.mes.mcp.Mch.FrmMcpLoading.getLoadResult",
  125. new object[] { ActiveRow.HeatPlanNo, ActiveRow.BatchNo },
  126. ob);
  127. commHelper.RefreshAndAutoSize(LoadGrid);
  128. if (ActiveRow == null) return;
  129. var result = new MchLoadingResultEntity
  130. {
  131. HeatPlanNo = ActiveRow.HeatPlanNo,
  132. ZyBatchId = ActiveRow.ZyBatchId,
  133. ProPlanId = ActiveRow.ProPlanId,
  134. GxPlanNo = ActiveRow.GxPlanNo,
  135. JudgeStoveNo = ActiveRow.JudgeStoveNo,
  136. BatchNo = ActiveRow.BatchNo,
  137. BatchGroudNo = ActiveRow.BatchGroudNo,
  138. PlineCode = ActiveRow.PlineCode,
  139. PlineName = ActiveRow.PlineName,
  140. IfMonitorRcl = ActiveRow.IfMonitor,
  141. PrdcrNo = ActiveRow.PrdcrNo,
  142. ProducerTime = ActiveRow.IfMonitor.Equals("1") ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : null,
  143. ProNum = ActiveRow.ActCount,
  144. ProWt = ActiveRow.ActWeight,
  145. FailNum = 0,
  146. FailWt = 0,
  147. LoadShift = UserInfo.GetUserOrder(),
  148. LoadGroup = UserInfo.GetUserGroup(),
  149. CreatetUser = UserInfo.GetUserName(),
  150. LoadTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  151. OutnumCut = ActiveRow.OutnumCut,
  152. LengthIn = ActiveRow.LengthIn,
  153. LengthmaxIn = ActiveRow.LengthmaxIn,
  154. LengthminIn = ActiveRow.LengthminIn,
  155. HeatPlanSqe = ActiveRow.HeatPlanSqe,
  156. MatSource = ActiveRow.MatSource
  157. };
  158. var instructionCardControl = mchControlBase1 as InstructionCardControl;
  159. if (instructionCardControl != null) instructionCardControl.Value = result;
  160. }
  161. protected override void UpLoadDelete()
  162. {
  163. if (ActiveRow != null && ActitveResultRow != null)
  164. {
  165. DoUpdateFilePath("",false);
  166. }
  167. }
  168. protected override void UpLoad()
  169. {
  170. if (ActiveRow != null && ActitveResultRow != null)
  171. {
  172. string filePath = "JGMESServer/" + "SC" + "/" + ActiveRow.PlineCode + "/" + ActiveRow.JudgeStoveNo + "/";
  173. FormFileDown down = new FormFileDown(this.ob, filePath);
  174. down.CtrlFileDown1.FilePath = filePath;
  175. List<FileBean> list = new List<FileBean>();
  176. FileBean bean = new FileBean();
  177. OpenFileDialog file = new OpenFileDialog();
  178. file.Multiselect = true;
  179. DialogResult drStat;
  180. drStat = file.ShowDialog();
  181. if (drStat == DialogResult.OK)
  182. {
  183. foreach (string fileName in file.FileNames)
  184. {
  185. bean = new FileBean();
  186. string filena = System.IO.Path.GetFileName(fileName);
  187. bean.setFileName(filena);
  188. bean.setPathName(filePath);
  189. bean.setFile(FileHelper.FileToArray(fileName));
  190. list.Add(bean);
  191. }
  192. bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
  193. if (isSuccess)
  194. {
  195. Thread.Sleep(100); //等待一下下
  196. DoUpdateFilePath(filePath,true);
  197. }
  198. else
  199. {
  200. MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
  201. }
  202. }
  203. }
  204. }
  205. public void DoUpdateFilePath(string filePath, bool showTips)
  206. {
  207. var ccp = new CoreClientParam
  208. {
  209. ServerName = "com.steering.mes.mcp.Mch.FrmMcpLoading",
  210. MethodName = "DoUpdateFilePath",
  211. ServerParams = new object[]
  212. {
  213. ActiveRow.HeatPlanNo,
  214. filePath
  215. }
  216. };
  217. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  218. if (ccp.ReturnCode != -1 && showTips)
  219. {
  220. MessageUtil.ShowTips(ccp.ReturnInfo);
  221. if (ccp.ReturnInfo.Contains("成功!"))
  222. Query(true);
  223. }
  224. else if (!showTips)
  225. {
  226. Query(true);
  227. }
  228. }
  229. private void uteCard_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  230. {
  231. MchLoadingResultEntity entity = LoadGrid.ActiveRow.ListObject as MchLoadingResultEntity;
  232. string strurl =
  233. "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMchDeliveryCard.cpt&op=view&RESULT_NO=" +
  234. entity.ResultNo;
  235. var fre = new FrmRepExcel(ob, strurl);
  236. fre.AutoSize = true;
  237. fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width,
  238. Screen.PrimaryScreen.WorkingArea.Height);
  239. fre.WindowState = FormWindowState.Maximized;
  240. fre.Show();
  241. }
  242. }
  243. }