CommonCrackDetection.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  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 com.steering.mes.mcp.entity;
  8. using Core.Mes.Client.Comm.Tool;
  9. using Core.StlMes.Client.Mcp.Control.Entity;
  10. using CoreFS.CA06;
  11. using Infragistics.Win;
  12. using Infragistics.Win.UltraWinGrid;
  13. using Infragistics.Win.UltraWinTabControl;
  14. using Core.Mes.Client.Comm.Server;
  15. namespace Core.StlMes.Client.Mcp.Control.Common
  16. {
  17. public partial class CommonCrackDetection : UserControl
  18. {
  19. public CommonCrackDetection()
  20. {
  21. InitializeComponent();
  22. commonCrackHeadControl1.ultraGrid1.CellChange +=ultraGrid1_CellChange;
  23. }
  24. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  25. {
  26. if (e.Cell.Column.Key.Equals("ColTime") || e.Cell.Column.Key.Equals("ColEndTime"))
  27. {
  28. return;
  29. }
  30. commonCrackHeadControl1.ultraGrid1.UpdateData();
  31. if (e.Cell.Column.Key == "TestingNum")
  32. {
  33. var CommonCrackMainList = tbMainType.ActiveTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  34. CommonCrackMainList.ForEach(
  35. p => p.ChangeValue(commonCrackHeadControl1.Value, HttReportDefaultEntity.Where(q => q.ReportNo == tbMainType.ActiveTab.Key).ToList()));
  36. }
  37. if (e.Cell.Column.Key == "BatchNo")
  38. {
  39. if (ChangeData != null)
  40. {
  41. ChangeData(commonCrackHeadControl1.Value);
  42. }
  43. }
  44. }
  45. private OpeBase Ob;
  46. private bool resetTab = false;
  47. private List<HttReportDefaultEntity> HttReportDefaultEntity = null;
  48. private string _plineCode = "";
  49. private DataTable _standInfo = null;
  50. public bool SettingMode { get; set; }
  51. private bool setWorkUnit;
  52. public Action< HttCrackDetectionEtEntity> ChangeData = null;
  53. public void Init(OpeBase _ob, Func<List<PortMchBatchSampleResultEntityWithCheck>> func)
  54. {
  55. Ob = _ob;
  56. commonCrackHeadControl1.DisableFiltering();
  57. var f1 = new Font("宋体", 11F, FontStyle.Bold);
  58. commonCrackHeadControl1.SetFont(f1);
  59. foreach (var ultraTab in tbMainType.Tabs)
  60. {
  61. var CommonCrackMainList = ultraTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  62. CommonCrackMainList.ForEach(
  63. p =>
  64. {
  65. p.DisableFiltering();
  66. p.Ob = _ob;
  67. p.SetFont(f1);
  68. p.SetGetMatNoFunc(func);
  69. });
  70. }
  71. GetWorkUnit();
  72. }
  73. public string SuspiciousCode
  74. {
  75. get { return commonCrackMain1.SuspiciousCode; }
  76. set
  77. {
  78. /* commonCrackMain1.SuspiciousCode = value;
  79. commonCrackMain2.SuspiciousCode = value;
  80. commonCrackMain3.SuspiciousCode = value;
  81. commonCrackMain4.SuspiciousCode = value;
  82. commonCrackMain5.SuspiciousCode = value;
  83. commonCrackMain6.SuspiciousCode = value;
  84. commonCrackMain7.SuspiciousCode = value;
  85. commonCrackMain8.SuspiciousCode = value;
  86. commonCrackMain9.SuspiciousCode = value;*/
  87. foreach (var tab in tbMainType.Tabs)
  88. {
  89. var CommonCrackMainList = tab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  90. CommonCrackMainList.ForEach(
  91. p =>
  92. {
  93. p.SuspiciousCode = value;
  94. });
  95. }
  96. }
  97. }
  98. public string ScrappedCode
  99. {
  100. get { return commonCrackMain1.ScrappedCode; }
  101. set
  102. {
  103. /* commonCrackMain1.ScrappedCode = value;
  104. commonCrackMain2.ScrappedCode = value;
  105. commonCrackMain3.ScrappedCode = value;
  106. commonCrackMain4.ScrappedCode = value;
  107. commonCrackMain5.ScrappedCode = value;
  108. commonCrackMain6.ScrappedCode = value;
  109. commonCrackMain7.ScrappedCode = value;
  110. commonCrackMain8.ScrappedCode = value;
  111. commonCrackMain9.ScrappedCode = value;*/
  112. foreach (var tab in tbMainType.Tabs)
  113. {
  114. var CommonCrackMainList = tab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  115. CommonCrackMainList.ForEach(
  116. p =>
  117. {
  118. p.ScrappedCode = value;
  119. });
  120. }
  121. }
  122. }
  123. public string UnPassCode
  124. {
  125. get { return commonCrackMain1.UnPassCode; }
  126. set
  127. {
  128. /* commonCrackMain1.UnPassCode = value;
  129. commonCrackMain2.UnPassCode = value;
  130. commonCrackMain3.UnPassCode = value;
  131. commonCrackMain4.UnPassCode = value;
  132. commonCrackMain5.UnPassCode = value;
  133. commonCrackMain6.UnPassCode = value;
  134. commonCrackMain7.UnPassCode = value;
  135. commonCrackMain8.UnPassCode = value;
  136. commonCrackMain9.UnPassCode = value;*/
  137. foreach (var tab in tbMainType.Tabs)
  138. {
  139. var CommonCrackMainList = tab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  140. CommonCrackMainList.ForEach(
  141. p =>
  142. {
  143. p.UnPassCode = value;
  144. });
  145. }
  146. }
  147. }
  148. public string ReportType {get { return tbMainType.ActiveTab.Key; } }
  149. private void ChangeLine(HttCrackDetectionEtEntity data)
  150. {
  151. if (data.PlineCode== _plineCode) return;
  152. _plineCode = data.PlineCode;
  153. HttReportDefaultEntity = EntityHelper.GetData<HttReportDefaultEntity>(
  154. "com.steering.mes.mcp.heatTreatment.FrmReportDefault.Query",
  155. new object[] { _plineCode,"" }, Ob);
  156. List<string> keys = new List<string>(){"c"};
  157. if (HttReportDefaultEntity.Any())
  158. {
  159. keys = HttReportDefaultEntity.Select(p => p.ReportNo).Distinct().ToList();
  160. }
  161. resetTab = true;
  162. foreach (var tab in tbMainType.Tabs)
  163. {
  164. tab.Visible =keys.Contains(tab.Key);
  165. if (!tab.Visible) continue;
  166. if (data.PlineCode == "C084" || data.PlineCode == "C085") // 委外报告 管体和管端用一封报告 特殊处理
  167. {
  168. var CommonCrackMainList = tab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  169. CommonCrackMainList.ForEach(
  170. p =>
  171. {
  172. if(p.Type == "1") p.Type = "5";
  173. if (p.Type == "3") p.Type = "6";
  174. });
  175. commonCrackMain6.Type = "3";
  176. commonCrackMain4.Type = "3";
  177. }
  178. else if (data.PlineCode == "C092" && tab.Key == "12")
  179. {
  180. commonCrackMain6.Type = "7";
  181. }
  182. else if (data.PlineCode == "C092" && tab.Key == "10")
  183. {
  184. commonCrackMain4.Type = "8";
  185. }
  186. else if (data.PlineCode == "C092" && tab.Key == "0")
  187. {
  188. commonCrackMain1.Type = "8";
  189. }
  190. else
  191. {
  192. var CommonCrackMainList = tab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  193. CommonCrackMainList.ForEach(
  194. p =>
  195. {
  196. if (p.Type == "5") p.Type = "1";
  197. if (p.Type == "6") p.Type = "3";
  198. });
  199. commonCrackMain6.Type = "3";
  200. commonCrackMain4.Type = "3";
  201. commonCrackMain1.Type = "1";
  202. }
  203. }
  204. tbMainType.Tabs["c"].Visible = keys.All(p => p == "c");
  205. if (tbMainType.Tabs["0"].Visible || tbMainType.Tabs["1"].Visible || tbMainType.Tabs["10"].Visible || tbMainType.Tabs["15"].Visible)
  206. {
  207. commonCrackHeadControl1.ultraGrid1.DisplayLayout.Bands[0].Columns["NotchLength"].Hidden = false;
  208. commonCrackHeadControl1.ultraGrid1.DisplayLayout.Bands[0].Columns["NotchDepth"].Hidden = false;
  209. commonCrackHeadControl1.ultraGrid1.DisplayLayout.Bands[0].Columns["NotchWidth"].Hidden = false;
  210. }
  211. else
  212. {
  213. commonCrackHeadControl1.ultraGrid1.DisplayLayout.Bands[0].Columns["NotchLength"].Hidden = true;
  214. commonCrackHeadControl1.ultraGrid1.DisplayLayout.Bands[0].Columns["NotchDepth"].Hidden = true;
  215. commonCrackHeadControl1.ultraGrid1.DisplayLayout.Bands[0].Columns["NotchWidth"].Hidden = true;
  216. }
  217. resetTab = false;
  218. ResetActiveTab(data);
  219. }
  220. private void GetWorkUnit()
  221. {
  222. var dt = ServerHelper.GetData(
  223. "com.steering.mes.mcp.collarMaterial.ComBaseInfo.getBaseInfo",
  224. new object[] { "7039" }, Ob);
  225. List<string> vlist = new List<string>();
  226. foreach (DataRow row in dt.Rows)
  227. {
  228. vlist.Add(row["BASENAME"].ToString());
  229. }
  230. getWorkUnit(vlist);
  231. }
  232. private void ResetActiveTab(HttCrackDetectionEtEntity data)
  233. {
  234. var CommonCrackMainList = tbMainType.ActiveTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  235. CommonCrackMainList.ForEach(
  236. p =>
  237. {
  238. data.ReportNo = tbMainType.ActiveTab.Key;
  239. p.ChangeValue(data,
  240. HttReportDefaultEntity.Where(q => q.ReportNo == tbMainType.ActiveTab.Key).ToList());
  241. // p.DefaultCraftInfo(_standInfo, ReportType);
  242. });
  243. commonCrackHeadControl1.Value = data;
  244. }
  245. public void ChangeValue(HttCrackDetectionEtEntity data)
  246. {
  247. if (data.PlineCode != _plineCode)
  248. {
  249. ChangeLine(data);
  250. }
  251. else
  252. {
  253. ResetActiveTab(data);
  254. }
  255. }
  256. public void SetBatchNo(List<string> BatchNo)
  257. {
  258. commonCrackHeadControl1.setBatchNo(BatchNo);
  259. }
  260. public void getWorkUnit(List<string> WorkUnit)
  261. {
  262. commonCrackHeadControl1.getWorkUnit(WorkUnit);
  263. }
  264. public void DefaultCraftInfo(DataTable Stand)
  265. {
  266. _standInfo = Stand;
  267. foreach (var tab in tbMainType.Tabs)
  268. {
  269. var CommonCrackMainList = tab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  270. CommonCrackMainList.ForEach(
  271. p =>
  272. {
  273. p.DefaultCraftInfo(_standInfo, "");
  274. });
  275. }
  276. }
  277. public void SetReportNumber(DataTable ReportDt)
  278. {
  279. HttReportDefaultEntity.Where(p => p.ReportColumn == "REPORT_NUMBER").ToList().ForEach(
  280. q =>
  281. {
  282. var data = ReportDt.AsEnumerable().Where(r => r["REPORT_NO"].ToString2() == q.ReportNo).ToList();
  283. string ReportNum = "001";
  284. if (data.Any())
  285. {
  286. ReportNum = data.First()["REPORT_NUMBER"].ToString2();
  287. }
  288. q.TextDefault = ReportNum;
  289. }
  290. );
  291. var CommonCrackMainList = tbMainType.ActiveTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  292. CommonCrackMainList.ForEach(
  293. p =>
  294. {
  295. var data = ReportDt.AsEnumerable().Where(r => r["REPORT_NO"].ToString2() == tbMainType.ActiveTab.Key).ToList();
  296. string ReportNum = "001";
  297. if (data.Any())
  298. {
  299. ReportNum = data.First()["REPORT_NUMBER"].ToString2();
  300. }
  301. p.SetReportNumber(ReportNum);
  302. });
  303. }
  304. public void SettingModeValue(List<HttReportDefaultEntity> list,string PlineCode)
  305. {
  306. List<string> keys = new List<string>() { "c" };
  307. HttReportDefaultEntity = list;
  308. if ( HttReportDefaultEntity.Any())
  309. {
  310. keys = HttReportDefaultEntity.Select(p => p.ReportNo).Distinct().ToList();
  311. }
  312. resetTab = true;
  313. foreach (var tab in tbMainType.Tabs)
  314. {
  315. tab.Visible = keys.Contains(tab.Key);
  316. if (tab.Visible)
  317. {
  318. var CommonCrackMainList = tab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  319. CommonCrackMainList.ForEach(
  320. p => p.commonCrackPara1.SetValue(PlineCode, list.Where(q=> q.ReportNo == tab.Key).ToList()));
  321. }
  322. }
  323. tbMainType.Tabs["c"].Visible = keys.All(p => p == "c");
  324. if (tbMainType.Tabs["0"].Visible || tbMainType.Tabs["4"].Visible)
  325. {
  326. commonCrackHeadControl1.ultraGrid1.DisplayLayout.Bands[0].Columns["NotchLength"].Hidden = false;
  327. commonCrackHeadControl1.ultraGrid1.DisplayLayout.Bands[0].Columns["NotchDepth"].Hidden = false;
  328. commonCrackHeadControl1.ultraGrid1.DisplayLayout.Bands[0].Columns["NotchWidth"].Hidden = false;
  329. }
  330. else
  331. {
  332. commonCrackHeadControl1.ultraGrid1.DisplayLayout.Bands[0].Columns["NotchLength"].Hidden = true;
  333. commonCrackHeadControl1.ultraGrid1.DisplayLayout.Bands[0].Columns["NotchDepth"].Hidden = true;
  334. commonCrackHeadControl1.ultraGrid1.DisplayLayout.Bands[0].Columns["NotchWidth"].Hidden = true;
  335. }
  336. resetTab = false;
  337. }
  338. public void SetValue(string ReportNo, HttReportDefaultEntity dt, string key)
  339. {
  340. var CommonCrackMainList = tbMainType.Tabs[ReportNo].TabPage.Controls.OfType<CommonCrackMain>().ToList();
  341. CommonCrackMainList.ForEach(
  342. p => p.commonCrackPara1.SetValue(dt, key));
  343. }
  344. private void tbMainType_SelectedTabChanged(object sender, SelectedTabChangedEventArgs e)
  345. {
  346. if (resetTab) return;
  347. if (ChangeData != null)
  348. {
  349. ChangeData(commonCrackHeadControl1.Value);
  350. }
  351. }
  352. public string ActiveMchineNo()
  353. {
  354. var CommonCrackMainList = tbMainType.ActiveTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  355. var data = CommonCrackMainList[0].commonCrackBodyNum1.Value;
  356. return data.MachineNo;
  357. }
  358. public string ActiveBatchNo()
  359. {
  360. return commonCrackHeadControl1.Value.BatchNo;
  361. }
  362. public HttCrackDetectionEtEntity GetValue()
  363. {
  364. var CommonCrackMainList = tbMainType.ActiveTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  365. var data = CommonCrackMainList[0].commonCrackBodyNum1.Value;
  366. if (tbMainType.ActiveTab.Key != "c")
  367. {
  368. data.TestingType = tbMainType.ActiveTab.Tag.ToString2();
  369. data.TestingGrade = string.IsNullOrWhiteSpace(CommonCrackMainList[0].commonCrackPara1.list[0].AccpetanceLevel) || CommonCrackMainList[0].commonCrackPara1.list[0].AccpetanceLevel == "/" ? CommonCrackMainList[0].commonCrackPara1.list[0].LongitudinalExternal : CommonCrackMainList[0].commonCrackPara1.list[0].AccpetanceLevel;
  370. data.TestingStandard = GetStand().Any() ?
  371. GetStand().Select(p => p.StandardName).Aggregate((a, b) => a + (a == "" ? "" : ",") + b) : "";
  372. }
  373. data.ReportNo = tbMainType.ActiveTab.Key;
  374. return data;
  375. }
  376. public bool CheckNull(out string Message)
  377. {
  378. var CommonCrackMainList = tbMainType.ActiveTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  379. return CommonCrackMainList[0].commonCrackPara1.CheckNull(out Message);
  380. }
  381. public HttCrackDetectionParaEntity GetPara()
  382. {
  383. var CommonCrackMainList = tbMainType.ActiveTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  384. var data = CommonCrackMainList[0].commonCrackPara1.list[0];
  385. data.ReportNo = tbMainType.ActiveTab.Key;
  386. return data;
  387. }
  388. public List<HttWasteResultEntity> GetScrapListHtt()
  389. {
  390. var CommonCrackMainList = tbMainType.ActiveTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  391. return CommonCrackMainList[0].commonCrackBodyNum1.ScrappedList.Select(p =>
  392. new HttWasteResultEntity()
  393. {
  394. BatchNo = p.BatchNo,
  395. DefFillCode = p.FailTypeCode,
  396. DefFillName = p.FailTypeName,
  397. DefFillNum = p.FailNum,
  398. DefFillWt = p.FailWt,
  399. MatNo = p.MatNo
  400. }
  401. ).ToList(); ;
  402. }
  403. public List<HttWasteResultEntity> GetSuspiciousListHtt()
  404. {
  405. var CommonCrackMainList = tbMainType.ActiveTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  406. return CommonCrackMainList[0].commonCrackBodyNum1.SuspiciousList.Select(p =>
  407. new HttWasteResultEntity()
  408. {
  409. BatchNo = p.BatchNo,
  410. DefFillCode = p.FailTypeCode,
  411. DefFillName = p.FailTypeName,
  412. DefFillNum = p.FailNum,
  413. DefFillWt = p.FailWt,
  414. MatNo = p.MatNo
  415. }
  416. ).ToList();
  417. }
  418. public List<HttWasteResultEntity> GetUnPassListHtt()
  419. {
  420. var CommonCrackMainList = tbMainType.ActiveTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  421. return CommonCrackMainList[0].commonCrackBodyNum1.UnPassList.Select(p=>
  422. new HttWasteResultEntity()
  423. {
  424. BatchNo = p.BatchNo,
  425. DefFillCode = p.FailTypeCode,
  426. DefFillName = p.FailTypeName,
  427. DefFillNum = p.FailNum,
  428. DefFillWt = p.FailWt,
  429. MatNo = p.MatNo
  430. }
  431. ).ToList();
  432. }
  433. public List<MchBugDEntity> GetScrapList()
  434. {
  435. var CommonCrackMainList = tbMainType.ActiveTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  436. return CommonCrackMainList[0].commonCrackBodyNum1.ScrappedList;
  437. }
  438. public List<MchBugDEntity> GetSuspiciousList()
  439. {
  440. var CommonCrackMainList = tbMainType.ActiveTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  441. return CommonCrackMainList[0].commonCrackBodyNum1.SuspiciousList;
  442. }
  443. public List<MchBugDEntity> GetUnPassList()
  444. {
  445. var CommonCrackMainList = tbMainType.ActiveTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  446. return CommonCrackMainList[0].commonCrackBodyNum1.UnPassList;
  447. }
  448. public List<HttCrackDetectionProbeEntity> GetProbe()
  449. {
  450. var CommonCrackMainList = tbMainType.ActiveTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  451. return CommonCrackMainList[0].commonCrackPara1.listProbe;
  452. }
  453. public List<HttCrackDetectionStandardEntity> GetStand()
  454. {
  455. var CommonCrackMainList = tbMainType.ActiveTab.TabPage.Controls.OfType<CommonCrackMain>().ToList();
  456. List<HttCrackDetectionStandardEntity> list = CommonCrackMainList[0].commonCrackPara1.listStand.ToList();
  457. if (!list.Any())
  458. {
  459. HttCrackDetectionParaEntity para = GetPara();
  460. if (para.StandardDefect != "" && para.StandardDefect != "/")
  461. {
  462. list.Add(new HttCrackDetectionStandardEntity() { StandardName = para.StandardDefect });
  463. }
  464. if (para.StandardLam != "" && para.StandardLam != "/")
  465. {
  466. list.Add(new HttCrackDetectionStandardEntity() { StandardName = para.StandardLam });
  467. }
  468. if (para.StandardOblique != "" && para.StandardOblique != "/")
  469. {
  470. list.Add(new HttCrackDetectionStandardEntity() { StandardName = para.StandardOblique });
  471. }
  472. if (para.StandardWall != "" && para.StandardWall != "/")
  473. {
  474. list.Add(new HttCrackDetectionStandardEntity() { StandardName = para.StandardWall });
  475. }
  476. }
  477. return list;
  478. }
  479. public int ContextHigh
  480. {
  481. get
  482. {
  483. return commonCrackHeadControl1.Height + 20 +
  484. commonCrackMain1.ContextHight;
  485. }
  486. }
  487. /// <summary>
  488. /// 设置作业单位是否可见
  489. /// </summary>
  490. public bool SetWorkUnit
  491. {
  492. get
  493. {
  494. return setWorkUnit;
  495. }
  496. set
  497. {
  498. if (value == false)
  499. {
  500. // GetWorkUnit();
  501. commonCrackHeadControl1.WorkUnitbool = false;
  502. setWorkUnit = value;
  503. }
  504. else {
  505. // GetWorkUnit();
  506. commonCrackHeadControl1.WorkUnitbool = true;
  507. setWorkUnit = value;
  508. }
  509. }
  510. }
  511. }
  512. }