SteelMakingColligateQueryFrm.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.Judge.Commons;
  5. using Core.StlMes.Client.Judge.Controls;
  6. using CoreFS.CA06;
  7. using Infragistics.Win.UltraWinGrid;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Net;
  14. using System.Windows.Forms;
  15. namespace Core.StlMes.Client.Judge.Forms
  16. {
  17. public partial class SteelMakingColligateQueryFrm : FrmBase
  18. {
  19. private SteelMakingColligateQueryCtrl _colligateQueryCtrl;
  20. private StlIncisionDtlCtrl _stlDtlCtrl;
  21. private QcmJhyElementsCtrl _jhyElementsCtrl;
  22. private QcmJhyPhyDbResultCtrl _jhyPhyDbResultCtrl;
  23. private FaceFileCtrl _faceFileCtrl;
  24. private DetectFileCtrl _detectFileCtrl;
  25. private Dal _d;
  26. public SteelMakingColligateQueryFrm()
  27. {
  28. InitializeComponent();
  29. _colligateQueryCtrl = new SteelMakingColligateQueryCtrl(splitContainer1.Panel1, ob);
  30. _colligateQueryCtrl.SteelMakingColligateQueryGrid.AfterRowActivate += colligateQueryCtrl_AfterRowActivate;
  31. _colligateQueryCtrl.SteelMakingColligateQueryGrid.ClickCell += colligateQueryCtrl_ClickCell;
  32. this.IsLoadUserView = true;
  33. }
  34. public override void ToolBar_Click(object sender, string ToolbarKey)
  35. {
  36. base.ToolBar_Click(sender, ToolbarKey);
  37. switch (ToolbarKey)
  38. {
  39. case "Query":
  40. Query();
  41. break;
  42. case "ReviewGpCertificate":
  43. ReviewGpCertificate();
  44. break;
  45. case "Export":
  46. Export();
  47. break;
  48. case "BatchDownload":
  49. BatchDownload();
  50. break;
  51. }
  52. }
  53. private void SteelMakingColligateQueryFrm_Load(object sender, EventArgs e)
  54. {
  55. _d = new Dal(ob);
  56. _colligateQueryCtrl.D.Ob = ob;
  57. _stlDtlCtrl = new StlIncisionDtlCtrl(splitContainer1.Panel2, ob);
  58. _jhyElementsCtrl = new QcmJhyElementsCtrl(ultraTabPageControl1, ob, false);
  59. _jhyPhyDbResultCtrl = new QcmJhyPhyDbResultCtrl(ultraTabPageControl2, ob);
  60. _faceFileCtrl = new FaceFileCtrl(ultraTabPageControl4, ob, false);
  61. _detectFileCtrl = new DetectFileCtrl(ultraTabPageControl3, ob, false);
  62. JudgeBaseInfo.LoadPlineName(labelComboBox1.ComboBox, ob, false, "A");
  63. JudgeBaseInfo.LoadPlineName(labelComboBox5.ComboBox, ob, false, "B", "C");
  64. ClsBaseInfo.FillComBaseInfo(labelComboBox2.ComboBox, "407407", ob, false);
  65. //判定结果只显示内控合格和不合格。 40740101内控合格 40740102内控不合格
  66. DataTable dt = (DataTable)labelComboBox2.ComboBox.DataSource;
  67. DataRow dr = dt.NewRow();
  68. dr["BASECODE"] = "1";
  69. dr["BASENAME"] = "已判";
  70. dt.Rows.InsertAt(dr, 0);
  71. dr = dt.NewRow();
  72. dr["BASECODE"] = "0";
  73. dr["BASENAME"] = "未判";
  74. dt.Rows.InsertAt(dr, 0);
  75. dt.AcceptChanges();
  76. dt.DefaultView.RowFilter = "BASECODE NOT IN ('40740703', '40740706')";
  77. ClsBaseInfo.SetComboItemHeight(labelComboBox2.ComboBox);
  78. labelDateTimePicker1.Checked = true;
  79. labelDateTimePicker1.DateTimePicker.Value = DateTime.Now.Date.AddDays(-3);
  80. labelDateTimePicker2.DateTimePicker.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  81. labelDateTimePicker3.DateTimePicker.Value = DateTime.Now.Date.AddDays(-3);
  82. labelDateTimePicker4.DateTimePicker.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  83. for (int i = DateTime.Now.Year - 10; i <= DateTime.Now.Year + 10; i++)
  84. {
  85. ultraComboEditor1.Items.Add(i);
  86. }
  87. ultraComboEditor1.Value = DateTime.Now.Year;
  88. ultraComboEditor2.Value = DateTime.Now.Month.ToString().PadLeft(2, '0');
  89. }
  90. private void Export()
  91. {
  92. GridHelper.ulGridToExcel(_colligateQueryCtrl.SteelMakingColligateQueryGrid, "炼钢综合判定查询");
  93. }
  94. void colligateQueryCtrl_ClickCell(object sender, ClickCellEventArgs e)
  95. {
  96. if(e.Cell.Column.Key.Equals("chk")){
  97. _colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow.Cells["chk"].Value = !Boolean.Parse(_colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow.Cells["chk"].Value.ToString());
  98. }
  99. }
  100. void colligateQueryCtrl_AfterRowActivate(object sender, EventArgs e)
  101. {
  102. try
  103. {
  104. this.Cursor = Cursors.WaitCursor;
  105. //查询倍尺、长度、重量等信息
  106. var row = _colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow;
  107. DataRow craftDbCnt = _d.GetRowByXmlId("QcmJhyPhyDbResultDAL.queryJhyDbCnt", row.GetValue("judgeStoveNo"));
  108. if (craftDbCnt["COUNT"].ToString() == "0" && !row.GetValue("steelStandrad").Contains("PIC"))
  109. {
  110. ultraTabControl1.Tabs[1].Visible = false;
  111. }
  112. else
  113. {
  114. ultraTabControl1.Tabs[1].Visible = true;
  115. }
  116. DataRow drGpApply;
  117. if (row.GetValue("jugdeApplyCode") == "")
  118. {
  119. drGpApply = _d.GetRowByXmlId("QcmGpJugdeApplyDAL.queryGpApplyByJudgeStoveNo2", row.GetValue("judgeStoveNo"));
  120. }
  121. else
  122. {
  123. drGpApply = _d.GetRowByXmlId("QcmGpJugdeApplyDAL.queryGpApplyByJudgeStoveNo", row.GetValue("jugdeApplyCode"),
  124. row.GetValue("jugdeApplySqe"), row.GetValue("JudgeStoveNo"));
  125. }
  126. if (drGpApply != null && drGpApply["DetectResultPath"].ToString() != "")
  127. {
  128. ultraTabControl1.Tabs[2].Visible = true;
  129. }
  130. else
  131. {
  132. ultraTabControl1.Tabs[2].Visible = false;
  133. }
  134. //查询倍尺
  135. if (row.GetValue("jugdeApplyCode") == "")
  136. {
  137. _stlDtlCtrl.QueryStl(row.GetValue("judgeStoveNo"));
  138. }
  139. else
  140. {
  141. _stlDtlCtrl.QueryApply(row.GetValue("jugdeApplyCode"), row.GetValue("jugdeApplySqe"), row.GetValue("judgeStoveNo"));
  142. }
  143. QueryGpJudgeApplyDown(drGpApply);
  144. }
  145. finally
  146. {
  147. this.Cursor = Cursors.Default;
  148. }
  149. }
  150. //private string[] GetGpJudgeApplyZgPlanId()
  151. //{
  152. // if (_colligateQueryCtrl == null) return new string[] { "", "" };
  153. // var row = _colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow;
  154. // if (row == null) return new string[] { "", "" };
  155. // DataTable dtGpApply = _d.GetTableByXmlId("QcmGpJugdeApplyDAL.getApplyPlnIdByJudgeStoveNo", row.GetValue("JudgeStoveNo"));
  156. // List<string> zgProPlanIds = new List<string>();
  157. // foreach (DataRow gpJudgeApply in dtGpApply.Rows)
  158. // {
  159. // string proPlanIdNext = gpJudgeApply["proPlanIdNext"].ToString();
  160. // string proPlanId = gpJudgeApply["proPlanId"].ToString();
  161. // if (proPlanIdNext != "" && proPlanIdNext.StartsWith("ZG"))
  162. // {
  163. // zgProPlanIds.Add(proPlanIdNext);
  164. // }
  165. // else
  166. // {
  167. // string zzProPlanId = "";
  168. // if (proPlanIdNext != "")
  169. // {
  170. // zzProPlanId = proPlanIdNext;
  171. // }
  172. // else
  173. // {
  174. // zzProPlanId = proPlanId;
  175. // }
  176. // DataTable dtZgProPlanIds = _d.GetTableByXmlId("JdgPlnOrderZgS.queryByGpreqId", zzProPlanId);
  177. // foreach (DataRow drZgProPlanId in dtZgProPlanIds.Rows)
  178. // {
  179. // zgProPlanIds.Add(drZgProPlanId["proPlanId"].ToString());
  180. // }
  181. // }
  182. // }
  183. // return zgProPlanIds.ToArray();
  184. //}
  185. private void QueryGpJudgeApplyDown(DataRow drGpApply)
  186. {
  187. if (_colligateQueryCtrl == null) return;
  188. var row = _colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow;
  189. if (row == null) return;
  190. switch (ultraTabControl1.SelectedTab.Text)
  191. {
  192. case "成分信息":
  193. _jhyElementsCtrl.ClearData();
  194. string[] zgProPlanIds;
  195. if (row.GetValue("jugdeApplyCode") == "")
  196. {
  197. zgProPlanIds = SteelMakingChemJudgeFrm.GetStlInsitionZgPlanId(row.GetValue("judgeStoveNo"), row.GetValue("stoveNo"), _d.Ob);
  198. }
  199. else
  200. {
  201. zgProPlanIds = SteelMakingChemJudgeFrm.GetGpJudgeApplyZgPlanId(row.GetValue("jugdeApplyCode"),
  202. row.GetValue("jugdeApplySqe"), row.GetValue("judgeStoveNo"), row.GetValue("stoveNo"), _d.Ob);
  203. }
  204. DataRow drPlnCic = _d.GetRowByXmlId("PlnSteelforOrdDAL.getCicByJudgeStoveNo", row.GetValue("judgeStoveNo"));
  205. string[] cics = new string[1];
  206. if (drPlnCic != null)
  207. {
  208. cics = drPlnCic["cic"].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  209. }
  210. else if (drGpApply != null)
  211. {
  212. cics[0] = drGpApply["cic"].ToString();
  213. }
  214. DataTable dtCraftCic = _d.GetTableByXmlId("JdgPlnOrderZgS.queryCraftCicByZgProPlanId", new object[] { zgProPlanIds, cics.Length, cics });
  215. //增加余材获取成分
  216. if (dtCraftCic.Rows.Count <= 0)
  217. {
  218. drPlnCic = _d.GetRowByXmlId("PlnSteelforOrdDAL.getCicByProPlanId", new object[] { zgProPlanIds });
  219. cics = new string[1];
  220. if (drPlnCic != null)
  221. {
  222. cics = drPlnCic["cic"].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  223. }
  224. else if (drGpApply != null)
  225. {
  226. cics[0] = drGpApply["cic"].ToString();
  227. }
  228. if (cics.Length != 0 && cics[0] == null)
  229. {
  230. break;
  231. }
  232. dtCraftCic = _d.GetTableByXmlId("JdgPlnOrderZgS.queryCraftCicByZgProPlanId", new object[] { zgProPlanIds, cics.Length, cics });
  233. if (dtCraftCic.Rows.Count <= 0)
  234. {
  235. dtCraftCic = _d.GetTableByXmlId("JdgPlnOrderZgS.queryCraftCicByZgProPlanIdNew", new object[] { zgProPlanIds });
  236. }
  237. }
  238. //FillLkCic(drGpApply, dtCraftCic);
  239. _jhyElementsCtrl.QueryCraftResultByStoveNo(row.GetValue("stoveNo"), row.GetValue("judgeStoveNo"), dtCraftCic, "A",zgProPlanIds);
  240. break;
  241. case "低倍信息":
  242. _jhyPhyDbResultCtrl.ClearData();
  243. string lgJudgeStoveNo = row.GetValue("judgeStoveNo");
  244. if (drGpApply != null && drGpApply["judgeStoveNoLg"].ToString() != "")
  245. {
  246. lgJudgeStoveNo = drGpApply["judgeStoveNoLg"].ToString();
  247. }
  248. _jhyPhyDbResultCtrl.Query(lgJudgeStoveNo);
  249. break;
  250. case "探伤信息":
  251. _detectFileCtrl.Query(row.GetValue("judgeStoveNo"));
  252. break;
  253. case "表检尺寸":
  254. _faceFileCtrl.Query(row.GetValue("judgeStoveNo"));
  255. break;
  256. }
  257. }
  258. private void FillLkCic(DataRow drGpApply, DataTable dtCraftCic)
  259. {
  260. if (drGpApply != null && drGpApply["Cic"].ToString() != "" && drGpApply["lkFlag"].ToString() == "1")
  261. {
  262. bool sameCic = false;
  263. foreach (DataRow drCraftCic in dtCraftCic.Rows)
  264. {
  265. if (drCraftCic["cic"].ToString() == drGpApply["cic"].ToString())
  266. {
  267. sameCic = true;
  268. }
  269. }
  270. if (!sameCic)
  271. {
  272. foreach (DataRow drCraftCic in dtCraftCic.Rows)
  273. {
  274. drCraftCic["cic"] = drGpApply["cic"].ToString();
  275. }
  276. }
  277. }
  278. }
  279. private void Query()
  280. {
  281. try
  282. {
  283. this.Cursor = Cursors.WaitCursor;
  284. string judgeStoveNo = labelTextBox4.Checked ? labelTextBox4.Text.Trim() : "";
  285. string judgeState = labelComboBox2.Checked ? labelComboBox2.SelecteValue.ToString2() : "";
  286. string orderNo = labelTextBox9.Checked ? labelTextBox9.Text.Trim() : "";
  287. string[] plines;
  288. if (labelComboBox1.ComboBox.Value == null || !labelComboBox1.Checked)
  289. {
  290. plines = new string[0];
  291. }
  292. else
  293. {
  294. plines = ((List<object>)labelComboBox1.ComboBox.Value).Select(a => a.ToString()).ToArray();
  295. }
  296. string timeB = labelDateTimePicker1.Checked ? labelDateTimePicker1.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
  297. string timeE = labelDateTimePicker1.Checked ? labelDateTimePicker2.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
  298. string proTimeB = labelDateTimePicker3.Checked ? labelDateTimePicker3.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
  299. string proTimeE = labelDateTimePicker3.Checked ? labelDateTimePicker4.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
  300. string chemType = ultraOptionSet2.Value.ToString2();
  301. string gpSource = ultraOptionSet1.Value.ToString2();
  302. string[] plinesGp;
  303. if (labelComboBox5.ComboBox.Value == null || !labelComboBox5.Checked)
  304. {
  305. plinesGp = new string[0];
  306. }
  307. else
  308. {
  309. plinesGp = ((List<object>)labelComboBox5.ComboBox.Value).Select(a => a.ToString()).ToArray();
  310. }
  311. string balYearMonth = ultraCheckEditor1.Checked ? ultraComboEditor1.Value.ToString2() + ultraComboEditor2.Value.ToString() : "";
  312. _colligateQueryCtrl.Query(judgeStoveNo, judgeState, plines, timeB, timeE, chemType, gpSource, plinesGp, balYearMonth, proTimeB, proTimeE, orderNo);
  313. }
  314. finally
  315. {
  316. this.Cursor = Cursors.Default;
  317. }
  318. }
  319. private void ReviewGpCertificate()
  320. {
  321. try
  322. {
  323. this.Cursor = Cursors.WaitCursor;
  324. var row = _colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow;
  325. if (row == null)
  326. {
  327. MessageUtil.ShowWarning("请选择一行记录!");
  328. return;
  329. }
  330. string judgeApplyCode = row.Cells["jugdeApplyCode"].Value.ToString();
  331. string judgeApplySeq = row.Cells["jugdeApplySqe"].Value.ToString();
  332. string judgeStoveNo = row.Cells["judgeStoveNo"].Value.ToString();
  333. if (judgeApplyCode == "")
  334. {
  335. MessageUtil.ShowWarning("该记录还未进行综合判定,无法查看判定书!", _colligateQueryCtrl.SteelMakingColligateQueryGrid,
  336. _colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow);
  337. return;
  338. }
  339. string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepGpCertificate.cpt&_bypagesize__=false" + "&JUGDE_APPLY_CODE="
  340. + judgeApplyCode + judgeApplySeq + "&JUDGE_STOVE_NO=" + judgeStoveNo;
  341. FrmOrderRepExcel fBug = new FrmOrderRepExcel(ob, strurl);
  342. fBug.AutoSize = true;
  343. fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  344. fBug.WindowState = FormWindowState.Maximized;
  345. fBug.Text = "管坯判定书";
  346. fBug.Show();
  347. }
  348. finally
  349. {
  350. this.Cursor = Cursors.Default;
  351. }
  352. }
  353. private void BatchDownload()
  354. {
  355. //int count = _colligateQueryCtrl.SteelMakingColligateQueryGrid.Selected.Rows.Count;
  356. IQueryable<UltraGridRow> ugrs = _colligateQueryCtrl.SteelMakingColligateQueryGrid.Rows.AsQueryable().Where(" CHK = 'True'");
  357. if (ugrs.Count() <= 0)
  358. {
  359. MessageUtil.ShowWarning("请选择您要批量下载的报告!");
  360. return;
  361. }
  362. if (ugrs.Count() > 50)
  363. {
  364. MessageUtil.ShowWarning("导出数量不能大于50条!");
  365. return;
  366. }
  367. //if (count > 50 && MessageUtil.ShowYesNoAndQuestion("是否确定添加?") == DialogResult.No)
  368. //{
  369. // return;
  370. //}
  371. WaitingForm2 wf = new WaitingForm2("系统生成PDF中....");
  372. List<string> pathList = new List<string>();
  373. foreach (UltraGridRow row in ugrs)
  374. {
  375. string judgeApplyCode = row.Cells["jugdeApplyCode"].Value.ToString();
  376. string judgeApplySeq = row.Cells["jugdeApplySqe"].Value.ToString();
  377. string judgeStoveNo = row.Cells["judgeStoveNo"].Value.ToString();
  378. if (judgeApplyCode == "")
  379. {
  380. wf.Close();
  381. MessageUtil.ShowWarning(judgeStoveNo+"该记录还未进行综合判定,无法生成判定书!");
  382. return;
  383. }
  384. string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepGpCertificate.cpt&bypagesize=false&format=pdf&embed=true" + "&JUGDE_APPLY_CODE="
  385. + judgeApplyCode + judgeApplySeq + "&JUDGE_STOVE_NO=" + judgeStoveNo;
  386. string savePath = "judge/PipeMaterialJudgment/A/" + judgeApplyCode + judgeApplySeq + "/";
  387. if (!FlileUploadcomm.CreatePdfToFtp(strurl, savePath, judgeStoveNo))
  388. {
  389. wf.Close();
  390. MessageUtil.ShowError("系统生成PDF失败,请稍后再试!");
  391. return;
  392. }
  393. pathList.Add(savePath);
  394. }
  395. wf.Close();
  396. dlgOrderAskDown down = new dlgOrderAskDown(this.ob, pathList);
  397. down.DeleteButton.Visible = false;
  398. down.ShowDialog();
  399. //打开下载后的文件夹
  400. if (down.Pic != "")
  401. System.Diagnostics.Process.Start("Explorer.exe", down.Pic);
  402. }
  403. private void labelDateTimePicker1_CheckBox_CheckedChanged(object sender, EventArgs e)
  404. {
  405. labelDateTimePicker2.DateTimeEnabled = labelDateTimePicker1.Checked;
  406. }
  407. private void labelTextBox4_TextBox_KeyDown(object sender, KeyEventArgs e)
  408. {
  409. if (e.KeyData == Keys.Enter)
  410. {
  411. Query();
  412. }
  413. }
  414. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  415. {
  416. try
  417. {
  418. this.Cursor = Cursors.WaitCursor;
  419. if (_colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow == null) return;
  420. var row = _colligateQueryCtrl.SteelMakingColligateQueryGrid.ActiveRow;
  421. DataRow drGpApply = _d.GetRowByXmlId("QcmGpJugdeApplyDAL.queryGpApplyByJudgeStoveNo2", row.GetValue("judgeStoveNo"));
  422. QueryGpJudgeApplyDown(drGpApply);
  423. }
  424. finally
  425. {
  426. this.Cursor = Cursors.Default;
  427. }
  428. }
  429. private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
  430. {
  431. ultraComboEditor1.Enabled = ultraComboEditor2.Enabled = ultraCheckEditor1.Checked;
  432. }
  433. private void labelDateTimePicker3_CheckBox_CheckedChanged(object sender, EventArgs e)
  434. {
  435. labelDateTimePicker4.DateTimeEnabled = labelDateTimePicker3.DateTimeEnabled;
  436. }
  437. }
  438. }