FrmVrpMchBase.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  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 Core.Mes.Client.Comm;
  8. using Core.Mes.Client.Comm.Control;
  9. using Core.Mes.Client.Comm.Server;
  10. using Core.Mes.Client.Comm.Tool;
  11. using Core.StlMes.Client.Mcp.Control;
  12. using Core.StlMes.Client.Mcp.Control.Common;
  13. using Core.StlMes.Client.Mcp.Control.Entity;
  14. using Core.StlMes.Client.Mcp.Control.Machining;
  15. using CoreFS.CA06;
  16. using Infragistics.Win.UltraWinEditors;
  17. using Infragistics.Win.UltraWinGrid;
  18. namespace Core.StlMes.Client.Mcp.VRP.Vrp
  19. {
  20. public partial class FrmVrpMchBase : FrmBase
  21. {
  22. protected MchControlBase mchControlBase1 = null;
  23. private string[] plineCodes;
  24. public FrmVrpMchBase()
  25. {
  26. InitializeComponent();
  27. }
  28. public string DefaultGx = "";
  29. public string Gx
  30. {
  31. get { return mchControlBase1 == null ? DefaultGx : (mchControlBase1.gx= "650108"); }
  32. }
  33. public PlnZyJgxCEntity ActiveRow
  34. {
  35. get
  36. {
  37. if (ultraGrid1.ActiveRow == null) return null;
  38. return ultraGrid1.ActiveRow.ListObject as PlnZyJgxCEntity;
  39. }
  40. }
  41. protected virtual UltraGridRow ActitveResultRow
  42. {
  43. get { return null; }
  44. }
  45. protected virtual object Value
  46. {
  47. get { return null; }
  48. }
  49. protected override void OnLoad(EventArgs e)
  50. {
  51. base.OnLoad(e);
  52. EntityHelper.ShowGridCaption<PlnZyJgxCEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  53. commHelper.RefreshAndAutoSize(ultraGrid1);
  54. ultraGrid1.DisplayLayout.Bands[0].Override.HeaderClickAction = HeaderClickAction.Select;
  55. if(ob==null) return;//tudo:这里需要改线序的代号
  56. plineCodes = comm.InitDropPlinePower("E",ucePline, ValidDataPurviewIds, ob);//加工线是G开头
  57. // comm.InitDroCheckStation("G", uceFactory, ValidDataPurviewIds, ob);
  58. if (mchControlBase1 != null)
  59. {
  60. mchControlBase1.Ob = ob;
  61. mchControlBase1.DisableFiltering();
  62. var f1 = new Font("宋体", 11F, FontStyle.Bold);
  63. mchControlBase1.SetFont(f1);
  64. }
  65. portMchBatchControl1.ob = ob;
  66. portMchBatchControl1.userName = this.UserInfo.GetUserName();
  67. portMchBatchControl1.Shift = this.UserInfo.GetUserOrder();
  68. portMchBatchControl1.Group = this.UserInfo.GetUserGroup();
  69. portMchBatchControl1.DisableFiltering();
  70. ultraGrid1.DisplayLayout.Bands[0].Columns["MeasureCount"].Hidden = true;
  71. ultraGrid1.DisplayLayout.Bands[0].Columns["ProDate"].Hidden = true;
  72. ultraGrid1.DisplayLayout.Bands[0].Columns["CurrentStatus"].Hidden = true;
  73. ultraGrid1.DisplayLayout.Bands[0].Columns["BesideDate"].Hidden = true;
  74. ultraGrid1.DisplayLayout.Bands[0].Columns["BatchNo"].MergedCellStyle = MergedCellStyle.Always;
  75. ultraGrid1.DisplayLayout.Bands[0].Columns["BatchNo"].MergedCellEvaluator =
  76. new CustomMergedCellEvaluator(new[] { "JudgeStoveNo" });
  77. ultraGrid1.DisplayLayout.Bands[0].Columns["ProCount"].EditorComponent = uteCard;
  78. }
  79. public override void ToolBar_Click(object sender, string ToolbarKey)
  80. {
  81. switch (ToolbarKey)
  82. {
  83. case "DoQuery":
  84. Query(true);
  85. break;
  86. case "DoAdd":
  87. DoAdd();
  88. break;
  89. case "DoAddNew":
  90. DoAddNew();
  91. break;
  92. case "DoDelete":
  93. DoDelete();
  94. break;
  95. case "DoForceDelete":
  96. DoForceDelete();
  97. break;
  98. case "DoUpdate":
  99. DoUpdate();
  100. break;
  101. case "DoBeside":
  102. DoBeside();
  103. break;
  104. case "CelBeside":
  105. DoCelBeside();
  106. break;
  107. case "doBesideQuery":
  108. DoBesideQuery();
  109. break;
  110. case "doPrint":
  111. DoTransferPrint();
  112. break;
  113. case "SetGroup":
  114. SetGroup();
  115. break;
  116. case "SetMesureData":
  117. SetMesureData();
  118. break;
  119. case "Export":
  120. Globals.ulGridToExcel(ultraGrid1, Text);
  121. break;
  122. case "DoClose":
  123. Close();
  124. break;
  125. case "DoApproval":
  126. DoApproval();
  127. break;
  128. case "DoCancleApproval":
  129. DoCancleApproval();
  130. break;
  131. case "Print":
  132. Print();
  133. break;
  134. }
  135. }
  136. protected virtual void DoUpdate()
  137. {
  138. }
  139. private void SetGroup()
  140. {
  141. //if (ActiveRow == null)
  142. //{
  143. // MessageUtil.ShowTips("请选择需要炉计划!");
  144. // return;
  145. //}
  146. //FrmGroupSetting fgs = new FrmGroupSetting(ActiveRow.OrderNoSeq,ActiveRow.HeatPlanNo,ob);
  147. //fgs.ShowDialog();
  148. }
  149. public void Query(bool ActiveFirst= false)
  150. {
  151. var starts = "";
  152. var plnNo = "";
  153. var judgeStoveNo = "";
  154. var feedStoveNo = "";
  155. var checkStaion = "";
  156. string[] plines = plineCodes;
  157. var start = contorlPlanStatus1.statusArr;
  158. if (chkPlnNo.Checked)
  159. if (string.IsNullOrEmpty(txtRollBatchId.Text.Trim()))
  160. {
  161. MessageUtil.ShowTips("请输入炉次计划号!");
  162. return;
  163. }
  164. else
  165. {
  166. plnNo = txtRollBatchId.Text.Trim();
  167. start = new string[4] {"10", "20", "30", "40"};
  168. }
  169. if (chkJuNo.Checked)
  170. if (string.IsNullOrEmpty(txtZyBatchId.Text.Trim()))
  171. {
  172. MessageUtil.ShowTips("请输入炉号!");
  173. return;
  174. }
  175. else
  176. {
  177. judgeStoveNo = txtZyBatchId.Text.Trim();
  178. start = new string[4] {"10", "20", "30", "40"};
  179. }
  180. if (chkFeedNo.Checked)
  181. if (string.IsNullOrEmpty(txtFeedNo.Text.Trim()))
  182. {
  183. MessageUtil.ShowTips("请输入炉号!");
  184. return;
  185. }
  186. else
  187. {
  188. feedStoveNo = txtFeedNo.Text.Trim();
  189. start = new string[4] {"10", "20", "30", "40"};
  190. }
  191. if (chkPline.Checked && ucePline.SelectedIndex >= 0)
  192. {
  193. plines = new string[] { ucePline.SelectedItem.DataValue.ToString2()};
  194. }
  195. if (chkFactory.Checked && uceFactory.SelectedIndex >= 0)
  196. {
  197. checkStaion = uceFactory.SelectedItem.DataValue.ToString2();
  198. }
  199. ResetUI();
  200. plnZyJgxCEntityBindingSource.DataSource = EntityHelper.GetData<PlnZyJgxCEntity>(
  201. "com.steering.mes.mcp.common.PlanService.getSingleJGPlan",
  202. new object[] { Gx != "701301", plnNo, judgeStoveNo,feedStoveNo, plines, start, Gx, ultraOptionSet2.Visible ? ultraOptionSet2.Value.ToString2() : "2", checkStaion, ultraOptionOther.Value.ToString2() },
  203. ob);
  204. if (ActiveFirst && ultraGrid1.Rows.Count > 0 && judgeStoveNo!="") ultraGrid1.Rows[0].Activated = true;
  205. commHelper.RefreshAndAutoSizeExceptColumns(ultraGrid1, new string[] { "ProdStandard", "StationRoad", "Lengthdisc" });
  206. }
  207. protected virtual void Print()
  208. {
  209. }
  210. protected virtual void ResetUI()
  211. {
  212. }
  213. /// <summary>
  214. /// 实绩保存
  215. /// </summary>
  216. protected virtual void DoAdd()
  217. {
  218. //}
  219. }
  220. /// <summary>
  221. /// 实绩保存
  222. /// </summary>
  223. protected virtual void DoAddNew()
  224. {
  225. //}
  226. }
  227. protected virtual void DoApproval()
  228. {
  229. //}
  230. }
  231. protected virtual void DoCancleApproval()
  232. {
  233. //}
  234. }
  235. /// <summary>
  236. /// 结炉实绩查询
  237. /// </summary>
  238. private void DoBesideQuery()
  239. {
  240. //DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getMchBugD", new object[] { txtZyBatchId.Text.ToString(), txtRollBatchId.Text.ToString(), plineCode, start }, this.ob);
  241. //GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);
  242. //var heatno = "";
  243. //var lotno = "";
  244. //var plinename = "";
  245. //var urg = ultraGrid1.ActiveRow;
  246. //var matfrm = new FrmReason(ob, urg, "");
  247. //matfrm.ShowDialog();
  248. }
  249. /// <summary>
  250. /// 传递卡打印
  251. /// </summary>
  252. private void DoTransferPrint()
  253. {
  254. if (ActiveRow == null)
  255. {
  256. MessageUtil.ShowTips("请选择要打印的炉信息!");
  257. return;
  258. }
  259. var strurl = "";
  260. if (ActiveRow.PlineCode.Equals("C021")) //镦粗
  261. strurl =
  262. "http://172.16.2.145/WebReport/ReportServer?reportlet=MchDeliveryCard.cpt&T.HEAT_PLAN_NO=" +
  263. ActiveRow.HeatPlanNo + "&T.JUDGE_STOVE_NO=" + ActiveRow.JudgeStoveNo + "&T.PLINE_CODE=" +
  264. ActiveRow.PlineCode + "&T2.BATCH_GROUD_NO=" + ActiveRow.BatchGroudNo + "&TT.STATION_DESC='上料'";
  265. else
  266. strurl = "http://localhost:8075/WebReport/ReportServer?reportlet=MchDeliveryCard.cpt&heatNo=" +
  267. ActiveRow.HeatPlanNo + "&judgeNo=" + ActiveRow.JudgeStoveNo + "&plineCode=" +
  268. ActiveRow.PlineCode + "&groupNo=" + ActiveRow.BatchGroudNo + "&batchNo=" + ActiveRow.BatchNo +
  269. "&abc=上料";
  270. var fre = new FrmRepExcel(ob, strurl);
  271. fre.AutoSize = true;
  272. fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  273. fre.WindowState = FormWindowState.Maximized;
  274. fre.Show();
  275. }
  276. private void DoCelBeside()
  277. {
  278. if (ActiveRow == null) return;
  279. if (MessageUtil.ShowYesNoAndQuestion("是否撤销结炉?") == DialogResult.No)
  280. return;
  281. var ccp = new CoreClientParam();
  282. ccp.ServerName = "com.steering.mes.mcp.Mch.MchComm";
  283. ccp.MethodName = "undoBeside";
  284. ccp.ServerParams = new object[] {ActiveRow.HeatPlanNo, ActiveRow.BatchNo, Gx, ActiveRow.PlineCode};
  285. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  286. if (ccp.ReturnCode != -1)
  287. {
  288. MessageUtil.ShowTips(ccp.ReturnInfo);
  289. if (ccp.ReturnInfo.Equals("撤销结炉成功!"))
  290. Query();
  291. }
  292. }
  293. /// <summary>
  294. /// 工序结炉
  295. /// </summary>
  296. protected void DoBeside(bool DoNotQuey = false)
  297. {
  298. if (ActiveRow == null)
  299. {
  300. MessageUtil.ShowTips("请选择需要结炉的炉计划!");
  301. return;
  302. }
  303. if (Gx=="701313"){
  304. DataTable CountDt = ServerHelper.GetData("com.steering.mes.mcp.Mch.MchComm.getUnCheckCout", new object[] { ActiveRow.HeatPlanNo, ActiveRow.BatchNo }, ob);
  305. if (CountDt.Rows.Count > 0)
  306. {
  307. int Count = 0;
  308. if (int.TryParse(CountDt.Rows[0]["COUNT"].ToString3(), out Count))
  309. {
  310. if (Count > 0)
  311. {
  312. if (MessageUtil.ShowYesNoAndQuestion("有"+Count+ "支管未检验,是否确认依然结炉?") == DialogResult.No)
  313. return;
  314. }
  315. }
  316. }
  317. }
  318. if (MessageUtil.ShowYesNoAndQuestion("是否结炉?") == DialogResult.No)
  319. return;
  320. var ccp = new CoreClientParam();
  321. ccp.ServerName = "com.steering.mes.mcp.Mch.MchComm";
  322. ccp.MethodName = "updateDoBeside";
  323. ccp.ServerParams = new object[] {ActiveRow.HeatPlanNo, ActiveRow.BatchNo, Gx, ActiveRow.PlineCode};
  324. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  325. if (ccp.ReturnCode != -1)
  326. {
  327. MessageUtil.ShowTips(ccp.ReturnInfo);
  328. if (ccp.ReturnInfo.Equals("结炉成功!"))
  329. if (!DoNotQuey) Query();
  330. }
  331. }
  332. /// <summary>
  333. /// 撤销上料
  334. /// </summary>
  335. protected virtual void DoDelete()
  336. {
  337. }
  338. /// <summary>
  339. /// 撤销上料
  340. /// </summary>
  341. protected virtual void DoForceDelete()
  342. {
  343. }
  344. private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
  345. {
  346. var PlnZyRclCEntity = e.Row.ListObject as PlnZyJgxCEntity;
  347. if (PlnZyRclCEntity == null) return;
  348. if (PlnZyRclCEntity.Planstatus == "20")
  349. {
  350. e.Row.Cells["Planstatus"].Appearance.BackColor = Color.LightGreen;
  351. }
  352. else if ((PlnZyRclCEntity.Planstatus == "30") || (PlnZyRclCEntity.Planstatus == "40"))
  353. {
  354. e.Row.Cells["Planstatus"].Appearance.BackColor = Color.Red;
  355. e.Row.Appearance.BackColor = Color.LightGray;
  356. }
  357. if (PlnZyRclCEntity.ActCount > 0)
  358. e.Row.Cells["ActCount"].Appearance.BackColor = Color.LightGreen;
  359. }
  360. private void craftImg_EditorButtonClick(object sender, EditorButtonEventArgs e)
  361. {
  362. if (ActiveRow == null) return;
  363. var craftPath = YdmBaseClass.getQueryCraftNo(ActiveRow.CraftFileNo, ActiveRow.CraftSeq.ToString2(),
  364. ob);
  365. if (e.Button.Key.ToLower().Equals("select"))
  366. {
  367. var down = new FormFileDown(ob, craftPath);
  368. down.CtrlFileDown1.Button3.Visible = false;
  369. down.ShowDialog();
  370. }
  371. }
  372. private void chkStarts_CheckedChanged(object sender, EventArgs e)
  373. {
  374. if (chkPlnNo.Checked) txtRollBatchId.Enabled = true;
  375. else txtRollBatchId.Enabled = false;
  376. if (chkJuNo.Checked) txtZyBatchId.Enabled = true;
  377. else txtZyBatchId.Enabled = false;
  378. if (chkFeedNo.Checked) txtFeedNo.Enabled = true;
  379. else txtFeedNo.Enabled = false;
  380. }
  381. private void uteCraft2_EditorButtonClick(object sender, EditorButtonEventArgs e)
  382. {
  383. if (ActiveRow == null) return;
  384. if (e.Button.Key.ToLower().Equals("select"))
  385. {
  386. var down = new FormFileDown(ob, "Qcm/CraftLv2/" + ActiveRow.OrderNoSeq + "/" + ActiveRow.SecCraftFileNo);
  387. down.CtrlFileDown1.Button3.Visible = false;
  388. down.ShowDialog();
  389. }
  390. }
  391. protected void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  392. {
  393. if (mchControlBase1!=null) mchControlBase1.PlnZyJgxCEntity = ActiveRow;
  394. portMchBatchControl1.Query(ActiveRow.HeatPlanNo, ActiveRow.BatchNo, Gx, ActiveRow.ProducType == "C" || ActiveRow.ProducType=="E");
  395. GetResultData();
  396. }
  397. /// <summary>
  398. /// 获取当前工序的实绩
  399. /// </summary>
  400. protected virtual void GetResultData()
  401. {
  402. if (mchControlBase1 != null) mchControlBase1.PortHttBatchSampleResultEntitys = portMchBatchControl1.Data;
  403. }
  404. public class CustomMergedCellEvaluator : IMergedCellEvaluator
  405. {
  406. private readonly string[] keys;
  407. public CustomMergedCellEvaluator(string[] GroupKey)
  408. {
  409. keys = GroupKey;
  410. }
  411. public bool ShouldCellsBeMerged(UltraGridRow row1, UltraGridRow row2, UltraGridColumn column)
  412. //控件自带的方法,会自动进行调用,column为初始化中设置的行
  413. {
  414. foreach (var key in keys)
  415. if (row1.Cells[key].Value.ToString() != row2.Cells[key].Value.ToString()) return false;
  416. return row1.Cells[column].Value.ToString() == row2.Cells[column].Value.ToString();
  417. }
  418. }
  419. private void uteMeasureData_EditorButtonClick(object sender, EditorButtonEventArgs e)
  420. {
  421. using (VrpMesureData MesureData = new VrpMesureData(ActiveRow,ob,this.UserInfo.GetUserName(),false))
  422. {
  423. MesureData.ShowDialog();
  424. ultraGrid1.ActiveCell.Value =(decimal) MesureData.list.Where(p => p.Flag == "00").Select(p => p.MatNo).Distinct().Count();
  425. portMchBatchControl1.Query(ActiveRow.HeatPlanNo, ActiveRow.BatchNo, Gx, ActiveRow.ProducType == "C" || ActiveRow.ProducType == "E");
  426. ultraGrid1.UpdateData();
  427. ultraGrid1.Refresh();
  428. }
  429. }
  430. private void SetMesureData()
  431. {
  432. using (VrpMesureData MesureData = new VrpMesureData(ActiveRow, ob, this.UserInfo.GetUserName(), true))
  433. {
  434. MesureData.ShowDialog();
  435. ultraGrid1.ActiveRow.Cells["MeasureCount"].Value = (decimal)MesureData.list.Where(p => p.Flag == "00").Select(p => p.MatNo).Distinct().Count();
  436. portMchBatchControl1.Query(ActiveRow.HeatPlanNo, ActiveRow.BatchNo, Gx, ActiveRow.ProducType == "C" || ActiveRow.ProducType == "E");
  437. ultraGrid1.UpdateData();
  438. ultraGrid1.Refresh();
  439. }
  440. }
  441. private void uteCard_EditorButtonClick(object sender, EditorButtonEventArgs e)
  442. {
  443. PlnZyJgxCEntity entity = ultraGrid1.ActiveRow.ListObject as PlnZyJgxCEntity;
  444. string strurl =
  445. "http://172.16.2.145/WebReport/ReportServer?reportlet=RepMchDeliveryCard.cpt&op=view&HEAT_PLAN_NO=" +
  446. entity.HeatPlanNo + "&BATCH_NO=" + entity.BatchNo;
  447. var fre = new FrmRepExcel(ob, strurl);
  448. fre.AutoSize = true;
  449. fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width,
  450. Screen.PrimaryScreen.WorkingArea.Height);
  451. fre.WindowState = FormWindowState.Maximized;
  452. fre.Show();
  453. }
  454. protected int GetReturnNum()
  455. {
  456. List<MchOfflineResultEntity> OffList = EntityHelper.GetData<MchOfflineResultEntity>(
  457. "com.steering.mes.mcp.common.OfflineHelper.QueryMchOffLineData",
  458. new object[] { ActiveRow.HeatPlanNo, ActiveRow.BatchNo },
  459. ob);
  460. //返线到前工序的
  461. return (int)(OffList.Where(p => p.ReturnProcess != p.StationCode && mchControlBase1.CheckGx2(p.StationCode, Gx) && mchControlBase1.CheckGx2(Gx, p.ReturnProcess)).Sum(p => p.ReNum) ?? 0);
  462. }
  463. }
  464. }