Make_GetTestFileData.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using UAS_MES_NEW.DataOperate;
  11. using UAS_MES_NEW.Entity;
  12. using UAS_MES_NEW.PublicForm;
  13. using UAS_MES_NEW.PublicMethod;
  14. namespace UAS_MES_NEW.Make
  15. {
  16. public partial class Make_GetTestFileData : Form
  17. {
  18. AutoSizeFormClass asc = new AutoSizeFormClass();
  19. DataHelper dh;
  20. LogStringBuilder sql;
  21. string oErrorMessage = "";
  22. string omakeCode = "";
  23. string oMsid = "";
  24. ftpOperater ftp = new ftpOperater();
  25. public Make_GetTestFileData()
  26. {
  27. InitializeComponent();
  28. }
  29. private void Make_LabelCheck_Load(object sender, EventArgs e)
  30. {
  31. asc.controllInitializeSize(this);
  32. //聚焦SN号
  33. sncode.Focus();
  34. //打开界面提示用户:请输入SN
  35. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  36. sql = new LogStringBuilder();
  37. dh = SystemInf.dh;
  38. StepCount.StepCode = User.CurrentStepCode;
  39. StepCount.Source = User.UserSourceCode;
  40. StepCount.LineCode = User.UserLineCode;
  41. StepCount.Dh = dh;
  42. StepCount.Start();
  43. }
  44. private void Make_LabelCheck_SizeChanged(object sender, EventArgs e)
  45. {
  46. asc.controlAutoSize(this);
  47. }
  48. private void sncode_KeyDown(object sender, KeyEventArgs e)
  49. {
  50. //判断是enter事件
  51. if (e.KeyCode == Keys.Enter)
  52. {
  53. if (sncode.Text == "")
  54. {
  55. OperateResult.AppendText("<<输入不能为空\n", Color.Red);
  56. return;
  57. }
  58. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out oErrorMessage))
  59. {
  60. if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, sncode.Text, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
  61. {
  62. string ms_prodcode = dh.getFieldDataByCondition("makeserial", "ms_prodcode", "ms_id='" + oMsid + "'").ToString();
  63. DataTable dt = new DataTable();
  64. BaseUtil.GetDataFromDevice("GETFILE", WatchPath.Text + " ./" + DateTime.Now.ToString("yyyy-MM-dd") + @"/" + sncode.Text);
  65. string[] files = Directory.GetFiles(Application.StartupPath + "/" + DateTime.Now.ToString("yyyy-MM-dd") + @"/" + sncode.Text, "*.csv");
  66. BaseUtil.OpenCSVFile(ref dt, files[0]);
  67. //移除标题行
  68. dt.Rows.RemoveAt(0);
  69. //设置列名绑定数据
  70. dt.Columns[0].ColumnName = "std_class";
  71. //dt.Columns[1].ColumnName = "std_testtimes";
  72. dt.Columns[1].ColumnName = "std_testresult";
  73. //dt.Columns[3].ColumnName = "std_badcode";
  74. CheckItemDGV.DataSource = dt;
  75. bool Result = true;
  76. for (int i = 0; i < dt.Rows.Count; i++)
  77. {
  78. if (dt.Rows[i]["std_testresult"].ToString() != "OK" || dt.Rows[i]["std_testresult"].ToString() == "NOTEST")
  79. {
  80. Result = false;
  81. }
  82. //dh.ExecuteSql("insert into STEPTESTDETAIL(std_id,std_sn,std_indate,std_class,std_testtimes,std_testresult,std_badcode) values(STEPTESTDETAIL_seq.nextval,'" + sncode.Text + "',sysdate,'" + dt.Rows[i]["std_class"].ToString() + "','" + dt.Rows[i]["std_testtimes"].ToString() + "','" + dt.Rows[i]["std_testresult"].ToString() + "','" + dt.Rows[i]["std_badcode"].ToString() + "')", "insert");
  83. dh.ExecuteSql("insert into STEPTESTDETAIL(std_id,std_sn,std_indate,std_class,std_testtimes,std_testresult,std_badcode) values(STEPTESTDETAIL_seq.nextval,'" + sncode.Text + "',sysdate,'" + dt.Rows[i]["std_class"].ToString() + "','','" + dt.Rows[i]["std_testresult"].ToString() + "','')", "insert");
  84. }
  85. if (Result)
  86. {
  87. if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, sncode.Text, "", "OK", User.UserCode, out oErrorMessage))
  88. {
  89. //提示正确返回时传递的信息
  90. if (oErrorMessage.Contains("AFTERSUCCESS"))
  91. OperateResult.AppendText(">>" + oErrorMessage + "\n");
  92. //根据工单号查询makecraftdetail 表中的 mcd_okqty 计数,剩余数为ma_qty - nvl(mcd_inqty,0),刷新页面中工单信息的显示
  93. sql.Clear();
  94. sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
  95. sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
  96. sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  97. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  98. BaseUtil.SetFormValue(Controls, dt);
  99. //将SN,时间,结果记录在页面
  100. //记录日志
  101. //ftp.UpLoadFile(Application.StartupPath, sncode.Text + ".csv", "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + ms_prodcode + "/");
  102. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "标签核对", "参数核对成功", sncode.Text, "");
  103. //SN核对成功
  104. //>> 请输入SN
  105. OperateResult.AppendText("<<" + sncode.Text + "信息核对成功\n", Color.Green, sncode);
  106. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  107. SetCheck set = new SetCheck("OK", Color.Green);
  108. BaseUtil.SetFormCenter(set);
  109. set.ShowDialog();
  110. if (ReSet.Checked)
  111. {
  112. BaseUtil.GetDataFromDevice("RESET");
  113. }
  114. }
  115. else
  116. {
  117. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  118. }
  119. }
  120. else
  121. {
  122. //ftp.UpLoadFile(Application.StartupPath, sncode.Text + ".csv", "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + ms_prodcode + "/");
  123. OperateResult.AppendText(">>序列号" + sncode.Text + "测试不通过\n", Color.Red, sncode);
  124. }
  125. }
  126. else
  127. {
  128. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  129. }
  130. }
  131. else
  132. {
  133. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  134. }
  135. }
  136. }
  137. private void StepCount_Load(object sender, EventArgs e)
  138. {
  139. }
  140. private void CheckItemDGV_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
  141. {
  142. //系统值和
  143. if (e.ColumnIndex >= 0)
  144. {
  145. if (CheckItemDGV.Columns[e.ColumnIndex].Name == "std_testresult")
  146. {
  147. if (e.RowIndex >= 0)
  148. {
  149. if (CheckItemDGV.Rows[e.RowIndex].Cells["std_testresult"].Value != null && (CheckItemDGV.Rows[e.RowIndex].Cells["std_testresult"].Value.ToString() == "OK"))
  150. {
  151. e.Graphics.FillRectangle(Brushes.ForestGreen, e.CellBounds);
  152. Rectangle border = e.CellBounds;
  153. border.Width -= 1;
  154. e.Graphics.DrawRectangle(Pens.Black, border);
  155. e.PaintContent(e.CellBounds);
  156. e.Handled = true;
  157. }
  158. else
  159. {
  160. e.Graphics.FillRectangle(Brushes.OrangeRed, e.CellBounds);
  161. Rectangle border = e.CellBounds;
  162. border.Width -= 1;
  163. e.Graphics.DrawRectangle(Pens.Black, border);
  164. e.PaintContent(e.CellBounds);
  165. e.Handled = true;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. }
  172. }