FrmHttLoading.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Windows.Forms;
  7. using com.steering.mes.mcp.entity;
  8. using Core.Mes.Client.Comm.Format;
  9. using Core.Mes.Client.Comm.Server;
  10. using Core.Mes.Client.Comm.Tool;
  11. using Core.StlMes.Client.Mcp.Control.Common;
  12. using Core.StlMes.Client.Mcp.Control.Entity;
  13. using Core.StlMes.Client.Mcp.Treatment.HeatTreatment;
  14. using CoreFS.CA06;
  15. using Infragistics.Win;
  16. using Infragistics.Win.UltraWinGrid;
  17. namespace Core.StlMes.Client.Mcp.Treatment
  18. {
  19. public partial class FrmHttLoadingResultEntity : FrmHttBase
  20. {
  21. private string plineCode = "";
  22. private string[] plineCodes;
  23. private int ProcessSeq = 1;
  24. public FrmHttLoadingResultEntity()
  25. {
  26. InitializeComponent();
  27. IsLoadUserView = true;
  28. }
  29. private string SlGx
  30. {
  31. get { return "600201"; }
  32. }
  33. protected override void OnLoad(EventArgs e)
  34. {
  35. base.OnLoad(e);
  36. base.ultraGrid1.DisplayLayout.Bands[0].Columns["ProCount"].Header.Caption = "上料支";
  37. base.ultraGrid1.DisplayLayout.Bands[0].Columns["ProWeight"].Header.Caption = "上料吨";
  38. base.ultraGrid1.DisplayLayout.Bands[0].Columns["PerStatus"].Header.Caption = "库存位置";
  39. httInstructionCardControl1.DisableFiltering();
  40. EntityHelper.ShowGridCaption<HttLoadingResultEntity>(LoadGrid.DisplayLayout.Bands[0]);
  41. comm.RefreshAndAutoSize(LoadGrid);
  42. comm.setOtherColumnReadOnly(LoadGrid,new string[]{});
  43. LoadGrid.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
  44. foreach (UltraGridColumn ugc in LoadGrid.DisplayLayout.Bands[0].Columns)
  45. {
  46. ugc.SortIndicator = SortIndicator.Disabled;
  47. }
  48. Font f1 = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Bold);
  49. httInstructionCardControl1.SetFont(f1);
  50. }
  51. public override void ToolBar_Click(object sender, string ToolbarKey)
  52. {
  53. //base.ToolBar_Click(sender, ToolbarKey);
  54. switch (ToolbarKey)
  55. {
  56. case "DoQuery":
  57. QuerySinglePlan();
  58. break;
  59. case "DoLoading":
  60. DoSave();
  61. break;
  62. case "DoReturn":
  63. DoReturn();
  64. break;
  65. case "DoBeside":
  66. DoBeside();
  67. break;
  68. case "CelBeside":
  69. DoCelBeside();
  70. break;
  71. case "DoClose":
  72. Close();
  73. break;
  74. case "doPrint":
  75. DoTransferPrint();
  76. break;
  77. case "Export":
  78. Mes.Client.Comm.Globals.ulGridToExcel(ultraGrid1, Text);
  79. break;
  80. }
  81. }
  82. /// <summary>
  83. /// 传递卡打印
  84. /// </summary>
  85. private void DoTransferPrint()
  86. {
  87. if (ActiveRow == null)
  88. {
  89. MessageUtil.ShowTips("请选择要打印的炉信息!");
  90. return;
  91. }
  92. var strurl = "";
  93. if (ActiveRow.PlineCode.Equals("C021")) //镦粗
  94. strurl =
  95. "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=MchDeliveryCard.cpt&T.HEAT_PLAN_NO=" +
  96. ActiveRow.HeatPlanNo + "&T.JUDGE_STOVE_NO=" + ActiveRow.JudgeStoveNo + "&T.PLINE_CODE=" + ActiveRow.PlineCode + "&T2.BATCH_GROUD_NO=" +
  97. ActiveRow.BatchGroudNo + "&TT.STATION_DESC='上料'";
  98. else
  99. strurl =
  100. "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=MchDeliveryCard.cpt&T.HEAT_PLAN_NO=" +
  101. ActiveRow.HeatPlanNo + "&T.JUDGE_STOVE_NO=" + ActiveRow.JudgeStoveNo + "&T.PLINE_CODE" + ActiveRow.PlineCode + "&T2.BATCH_GROUD_NO=" +
  102. ActiveRow.BatchGroudNo + "&TT.STATION_DESC='上料'";
  103. var fre = new FrmRepExcel(ob, strurl);
  104. fre.AutoSize = true;
  105. fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  106. fre.WindowState = FormWindowState.Maximized;
  107. fre.Show();
  108. }
  109. private void DoCelBeside()
  110. {
  111. if (ActiveRow == null) return;
  112. var list = new ArrayList();
  113. list.Add(ActiveRow.HeatPlanNo);
  114. list.Add(ActiveRow.PlineCode);
  115. list.Add(SlGx);
  116. if (MessageUtil.ShowYesNoAndQuestion("是否撤销结炉?") == DialogResult.No)
  117. return;
  118. var ccp = new CoreClientParam();
  119. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttLoadingService";
  120. ccp.MethodName = "undoBeside";
  121. ccp.ServerParams = new object[] {list};
  122. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  123. if (ccp.ReturnCode != -1)
  124. {
  125. MessageUtil.ShowTips(ccp.ReturnInfo);
  126. if (ccp.ReturnInfo.Equals("撤销结炉成功!"))
  127. {
  128. QuerySinglePlan();
  129. }
  130. }
  131. }
  132. /// <summary>
  133. /// 工序结炉
  134. /// </summary>
  135. private void DoBeside(bool ask = true)
  136. {
  137. if (ActiveRow == null)
  138. {
  139. MessageUtil.ShowTips("请选择需要结炉的炉计划!");
  140. return;
  141. }
  142. var list = new ArrayList();
  143. list.Add(ActiveRow.HeatPlanNo);
  144. list.Add(ActiveRow.PlineCode);
  145. list.Add(SlGx);
  146. list.Add(ActiveRow.JudgeStoveNo);
  147. list.Add(ActiveRow.BatchNo);
  148. list.Add(ActiveRow.BatchGroudNo);
  149. list.Add(ActiveRow.JugdeApplyCode);
  150. list.Add(ActiveRow.NextProcessCode);
  151. if (ask)
  152. if (MessageUtil.ShowYesNoAndQuestion("是否结炉?") == DialogResult.No)
  153. {
  154. return;
  155. }
  156. var ccp = new CoreClientParam();
  157. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttLoadingService";
  158. ccp.MethodName = "updateDoBeside";
  159. ccp.ServerParams = new object[] {list};
  160. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  161. if (ccp.ReturnCode != -1)
  162. {
  163. if (ccp.ReturnInfo.Equals("结炉成功!"))
  164. {
  165. if (ask)
  166. MessageUtil.ShowTips(ccp.ReturnInfo);
  167. QuerySinglePlan();
  168. }
  169. else
  170. {
  171. MessageUtil.ShowTips(ccp.ReturnInfo);
  172. }
  173. }
  174. }
  175. /// <summary>
  176. /// 简单查询
  177. /// </summary>
  178. private void QuerySinglePlan()
  179. {
  180. Query(plineCodes);
  181. }
  182. //查询管号队列
  183. private void QueryPortVrp(PlnZyRclCEntity PlnZyRclCEntity)
  184. {
  185. portHttBatchControl1.Query(PlnZyRclCEntity.HeatPlanNo, PlnZyRclCEntity.PlineCode, ProcessSeq,ActiveRow.GowhereCode);
  186. httInstructionCardControl1.PortHttBatchSampleResultEntitys = portHttBatchControl1.datas;
  187. }
  188. /// <summary>
  189. /// 根据计划号查询上料实绩
  190. /// </summary>
  191. /// <param name="planNo"></param>
  192. public void GetLoadResult(string heatNo,string sqe)
  193. {
  194. List<HttLoadingResultEntity> list =
  195. EntityHelper.GetData<HttLoadingResultEntity>(
  196. "com.steering.mes.mcp.heatTreatment.HttLoadingService.getLoadResult", new object[] { heatNo, sqe }, ob);
  197. httLoadingResultEntityBindingSource.DataSource = list;
  198. comm.RefreshAndAutoSize(LoadGrid);
  199. LoadGrid.ActiveRow = null;
  200. }
  201. /// <summary>
  202. /// 初始化控件
  203. /// </summary>
  204. private void initControl()
  205. {
  206. if (ActiveRow == null) return;
  207. var result = new HttLoadingResultEntity()
  208. {
  209. HeatPlanNo = ActiveRow.HeatPlanNo,
  210. FailNum = 0,
  211. LoadShift = UserInfo.GetUserOrder(),
  212. LoadGroup = UserInfo.GetUserGroup(),
  213. LoadUser = UserInfo.GetUserName(),
  214. LoadTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  215. ProcessSeq = ProcessSeq,
  216. ZyBatchId = ActiveRow.ZyBatchId,
  217. IfMonitorRcl = ActiveRow.IfMonitor,
  218. PrdcrNo =ActiveRow.PrdcrNo ,
  219. ProducerTime = ActiveRow.IfMonitor.Equals("1") ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : null,
  220. PlineCode = plineCode,
  221. MatSource = ActiveRow.MatSource
  222. };
  223. result.ProcessSeq = result.ProcessSeq ?? 1;
  224. result.ProNum = ActiveRow.ActCount;
  225. result.ProWt = ActiveRow.ActWeight;
  226. httInstructionCardControl1.ActCount = ActiveRow.ActCount??0;
  227. httInstructionCardControl1.FeedStoveNo = ActiveRow.FeedHeatNo;
  228. httInstructionCardControl1.BatchNo = ActiveRow.BatchNo;
  229. httInstructionCardControl1.GroupNo = ActiveRow.BatchGroudNo;
  230. httInstructionCardControl1.JudgeNo = ActiveRow.JugdeApplyCode;
  231. httInstructionCardControl1.ShowPro(ActiveRow.IfMonitor.Equals("1"));
  232. httInstructionCardControl1.Value = result;
  233. }
  234. /// <summary>
  235. /// 上料实绩保存
  236. /// </summary>
  237. private void DoSave()
  238. {
  239. if (ActiveRow!= null)
  240. {
  241. var groupNo = ActiveRow.BatchGroudNo.ToString2();
  242. var gxh = "0";
  243. var result = httInstructionCardControl1.Value;
  244. if (result.ProNum==null || result.ProNum ==0)
  245. {
  246. MessageUtil.ShowTips("上料支数不能为空或零");
  247. return;
  248. }
  249. if ((result.FailNum == null))
  250. result.FailNum = 0;
  251. if (result.ProcessSeq == null) result.ProcessSeq = 1;
  252. if (MessageUtil.ShowYesNoAndQuestion("是否上料?") == DialogResult.No)
  253. return;
  254. if (result.FailNum != null && result.FailNum > 0 &&
  255. result.FailNum != httInstructionCardControl1.ScrappedList.Sum(p => p.DefFillNum))
  256. {
  257. MessageUtil.ShowTips("废品数据异常,请重新录入");
  258. return;
  259. }
  260. var ccp = new CoreClientParam();
  261. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttLoadingService";
  262. ccp.MethodName = "saveHttLoadingResult";
  263. ccp.ServerParams = new object[] {JSONFormat.Format(result), ActiveRow.HeatPlanSqe, SlGx, ActiveRow.PlineCode, groupNo, new List<string>(),
  264. httInstructionCardControl1.ScrappedList.Select(JSONFormat.Format).ToList()};
  265. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  266. if (ccp.ReturnCode != -1)
  267. {
  268. MessageUtil.ShowTips(ccp.ReturnInfo);
  269. if (ccp.ReturnInfo.Equals("上料成功!"))
  270. {
  271. QuerySinglePlan();
  272. doOver();
  273. }
  274. }
  275. }
  276. //}
  277. }
  278. private void doOver()
  279. {
  280. if (ActiveRow == null) return;
  281. var dt1 = ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttLoadingService.getquerymaternum",
  282. new object[] { ActiveRow.HeatPlanNo}, ob);
  283. if (((dt1.Rows[0]["NUM"].ToString() == "0") || (dt1.Rows[0]["WT"].ToString() == "0.000"))&& ((ActiveRow.ProcessSeq??1).ToString3()== httInstructionCardControl1.Value.ProcessSeq.ToString3()))
  284. if (MessageUtil.ShowYesNoAndQuestion("待上料量或重量为0,是否结炉?") == DialogResult.No)
  285. return;
  286. else
  287. DoBeside(false);
  288. }
  289. /// <summary>
  290. /// 撤销上料
  291. /// </summary>
  292. private void DoReturn()
  293. {
  294. var Rows = LoadGrid.ActiveRow;
  295. if (Rows == null)
  296. {
  297. if (LoadGrid.Rows.Count <= 0) return;
  298. Rows = LoadGrid.Rows[0];
  299. }
  300. if (ActiveRow != null)
  301. {
  302. var result = Rows.ListObject as HttLoadingResultEntity;
  303. //查询是否存在上料之后的数据
  304. var dt = ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttLoadingService.getQueryInfoPlan",
  305. new object[] { SlGx, ActiveRow.HeatPlanNo }, ob);
  306. if (dt.Rows.Count > 0)
  307. if (MessageUtil.ShowYesNoAndQuestion("存在上料后工序,是否继续删除?") == DialogResult.No) return;
  308. if (MessageUtil.ShowYesNoAndQuestion("是否确认撤销上料?") == DialogResult.No)
  309. return;
  310. var ccp = new CoreClientParam();
  311. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttLoadingService";
  312. ccp.MethodName = "returnHttLoadingResult";
  313. ccp.ServerParams = new object[]
  314. {
  315. JSONFormat.Format(result), ActiveRow.HeatPlanSqe, SlGx,UserInfo.GetUserName(),result==null|| result.ProcessSeq>1?ActiveRow.JudgeStoveNo: ActiveRow.FeedHeatNo
  316. };
  317. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  318. if (ccp.ReturnCode != -1)
  319. {
  320. MessageUtil.ShowTips(ccp.ReturnInfo);
  321. if (ccp.ReturnInfo.Equals("删除上料成功!"))
  322. {
  323. QuerySinglePlan();
  324. }
  325. }
  326. }
  327. }
  328. private void FrmHttLoading_Load(object sender, EventArgs e)
  329. {
  330. plineCodes = comm.GetPlineCode(ValidDataPurviewIds, "F", ob);
  331. httInstructionCardControl1.Ob = ob;
  332. portHttBatchControl1.ob = ob;
  333. portHttBatchControl1.SetOfflineCode(new string[] { SlGx });
  334. httInstructionCardControl1.Value = new HttLoadingResultEntity() { PlineCode = plineCode };
  335. Gx = SlGx;
  336. //QuerySinglePlan();
  337. //initControl();
  338. }
  339. private void LoadGrid_AfterRowActivate(object sender, EventArgs e)
  340. {
  341. var urg = LoadGrid.ActiveRow;
  342. if (urg == null) return;
  343. httInstructionCardControl1.Value = urg.ListObject as HttLoadingResultEntity;
  344. }
  345. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  346. {
  347. plineCode = ActiveRow.PlineCode;
  348. ProcessSeq = (int) (ActiveRow.RealProcessSeq ?? 1);
  349. this.GetLoadResult(ActiveRow.HeatPlanNo,ActiveRow.HeatPlanSqe);
  350. QueryPortVrp(ActiveRow);
  351. initControl();
  352. }
  353. private void uteCard_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  354. {
  355. HttLoadingResultEntity entity = LoadGrid.ActiveRow.ListObject as HttLoadingResultEntity;
  356. string strurl =
  357. "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepHttDeliveryCard.cpt&op=view&RESULT_NO=" +
  358. entity.ResultNo;
  359. var fre = new FrmRepExcel(ob, strurl);
  360. fre.AutoSize = true;
  361. fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width,
  362. Screen.PrimaryScreen.WorkingArea.Height);
  363. fre.WindowState = FormWindowState.Maximized;
  364. fre.Show();
  365. }
  366. //工艺文件查询
  367. }
  368. }