Make_GetTestFileData.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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 LoadCollectedNum()
  49. {
  50. sql.Clear();
  51. sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
  52. sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
  53. sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  54. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  55. BaseUtil.SetFormValue(Controls, dt);
  56. }
  57. private void sncode_KeyDown(object sender, KeyEventArgs e)
  58. {
  59. //判断是enter事件
  60. if (e.KeyCode == Keys.Enter)
  61. {
  62. if (sncode.Text == "")
  63. {
  64. OperateResult.AppendText("<<输入不能为空\n", Color.Red);
  65. return;
  66. }
  67. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out oErrorMessage))
  68. {
  69. if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, sncode.Text, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
  70. {
  71. ma_code.Text = omakeCode;
  72. LoadCollectedNum();
  73. string ms_prodcode = dh.getFieldDataByCondition("makeserial", "ms_prodcode", "ms_id='" + oMsid + "'").ToString();
  74. DataTable dt = new DataTable();
  75. BaseUtil.GetDataFromDevice("GETFILE", WatchPath.Text + " ./" + DateTime.Now.ToString("yyyy-MM-dd") + @"/" + sncode.Text);
  76. string[] files = Directory.GetFiles(Application.StartupPath + "/" + DateTime.Now.ToString("yyyy-MM-dd") + @"/" + sncode.Text, "*.csv");
  77. BaseUtil.OpenCSVFile(ref dt, files[0]);
  78. //移除标题行
  79. dt.Rows.RemoveAt(0);
  80. //设置列名绑定数据
  81. dt.Columns[0].ColumnName = "std_class";
  82. dt.Columns[1].ColumnName = "std_testresult";
  83. dt.Columns[2].ColumnName = "std_sn";
  84. dt.Columns[3].ColumnName = "std_mac";
  85. dt.Columns[4].ColumnName = "std_bt";
  86. dt.Columns[5].ColumnName = "std_imei1";
  87. dt.Columns[6].ColumnName = "std_imei2";
  88. dt.Columns[7].ColumnName = "std_googlekey";
  89. dt.Columns[8].ColumnName = "std_videotest";
  90. dt.Columns[9].ColumnName = "std_version";
  91. dt.DefaultView.Sort = "std_testresult";
  92. CheckItemDGV.DataSource = dt;
  93. bool Result = true;
  94. for (int i = 0; i < dt.Rows.Count; i++)
  95. {
  96. PSN.Text = dt.Rows[0]["std_sn"].ToString();
  97. MAC.Text = dt.Rows[0]["std_mac"].ToString().Replace(":", "").ToUpper();
  98. BT.Text = dt.Rows[0]["std_bt"].ToString().Replace(":", "").ToUpper();
  99. IMEI1.Text = dt.Rows[0]["std_imei1"].ToString().Replace("null", "").Replace("unknow", "");
  100. IMEI2.Text = dt.Rows[0]["std_imei2"].ToString().Replace("null", "").Replace("unknow", "");
  101. GoogleKey.Text = dt.Rows[0]["std_googlekey"].ToString().Replace("null", "").Replace("unknow", "").ToUpper();
  102. Aging.Text = dt.Rows[0]["std_videotest"].ToString().Replace("null", "").Replace("unknow", "").ToUpper();
  103. Version.Text = dt.Rows[0]["std_version"].ToString().Replace("null", "").Replace("unknow", "");
  104. if (dt.Rows[i]["std_testresult"].ToString() != "OK" || dt.Rows[i]["std_testresult"].ToString() == "NOTEST")
  105. {
  106. Result = false;
  107. }
  108. 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");
  109. }
  110. if (Aging.Text == "")
  111. {
  112. OperateResult.AppendText(">>" + sncode.Text + "设备未进行老化测试\n");
  113. return;
  114. }
  115. if (Result)
  116. {
  117. if (LogicHandler.snChangeAndBurn(sncode.Text, PSN.Text, User.UserSourceCode, User.UserCode, omakeCode, 0, IMEI1.Text, IMEI2.Text, "", "", "", "", "", "", "", MAC.Text, BT.Text, "", "", "", out oErrorMessage))
  118. {
  119. //提示正确返回时传递的信息
  120. if (oErrorMessage.Contains("AFTERSUCCESS"))
  121. OperateResult.AppendText(">>" + oErrorMessage + "\n");
  122. //根据工单号查询makecraftdetail 表中的 mcd_okqty 计数,剩余数为ma_qty - nvl(mcd_inqty,0),刷新页面中工单信息的显示
  123. sql.Clear();
  124. sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
  125. sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
  126. sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  127. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  128. BaseUtil.SetFormValue(Controls, dt);
  129. //将SN,时间,结果记录在页面
  130. //记录日志
  131. //ftp.UpLoadFile(Application.StartupPath, sncode.Text + ".csv", "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + ms_prodcode + "/");
  132. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "标签核对", "参数核对成功", sncode.Text, "");
  133. //SN核对成功
  134. //>> 请输入SN
  135. OperateResult.AppendText("<<" + sncode.Text + "信息核对成功,转换SN" + PSN.Text + "\n", Color.Green, sncode);
  136. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  137. SetCheck set = new SetCheck("OK", Color.Green);
  138. BaseUtil.SetFormCenter(set);
  139. set.ShowDialog();
  140. if (ReSet.Checked)
  141. {
  142. BaseUtil.GetDataFromDevice("RESET");
  143. }
  144. }
  145. else
  146. {
  147. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  148. }
  149. //if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, sncode.Text, "", "OK", User.UserCode, out oErrorMessage))
  150. //{
  151. // //提示正确返回时传递的信息
  152. // if (oErrorMessage.Contains("AFTERSUCCESS"))
  153. // OperateResult.AppendText(">>" + oErrorMessage + "\n");
  154. // //根据工单号查询makecraftdetail 表中的 mcd_okqty 计数,剩余数为ma_qty - nvl(mcd_inqty,0),刷新页面中工单信息的显示
  155. // sql.Clear();
  156. // sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
  157. // sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
  158. // sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  159. // dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  160. // BaseUtil.SetFormValue(Controls, dt);
  161. // //将SN,时间,结果记录在页面
  162. // //记录日志
  163. // //ftp.UpLoadFile(Application.StartupPath, sncode.Text + ".csv", "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + ms_prodcode + "/");
  164. // LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "标签核对", "参数核对成功", sncode.Text, "");
  165. // //SN核对成功
  166. // //>> 请输入SN
  167. // OperateResult.AppendText("<<" + sncode.Text + "信息核对成功\n", Color.Green, sncode);
  168. // OperateResult.AppendText(">>请输入SN\n", Color.Black);
  169. // SetCheck set = new SetCheck("OK", Color.Green);
  170. // BaseUtil.SetFormCenter(set);
  171. // set.ShowDialog();
  172. // if (ReSet.Checked)
  173. // {
  174. // BaseUtil.GetDataFromDevice("RESET");
  175. // }
  176. //}
  177. //else
  178. //{
  179. // OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  180. //}
  181. }
  182. else
  183. {
  184. //ftp.UpLoadFile(Application.StartupPath, sncode.Text + ".csv", "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + ms_prodcode + "/");
  185. OperateResult.AppendText(">>序列号" + sncode.Text + "测试不通过\n", Color.Red, sncode);
  186. }
  187. }
  188. else
  189. {
  190. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  191. }
  192. }
  193. else
  194. {
  195. OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
  196. }
  197. }
  198. }
  199. private void StepCount_Load(object sender, EventArgs e)
  200. {
  201. }
  202. private void CheckItemDGV_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
  203. {
  204. //系统值和
  205. if (e.ColumnIndex >= 0)
  206. {
  207. if (CheckItemDGV.Columns[e.ColumnIndex].Name == "std_testresult")
  208. {
  209. if (e.RowIndex >= 0)
  210. {
  211. if (CheckItemDGV.Rows[e.RowIndex].Cells["std_testresult"].Value != null && (CheckItemDGV.Rows[e.RowIndex].Cells["std_testresult"].Value.ToString() == "OK"))
  212. {
  213. e.Graphics.FillRectangle(Brushes.ForestGreen, e.CellBounds);
  214. Rectangle border = e.CellBounds;
  215. border.Width -= 1;
  216. e.Graphics.DrawRectangle(Pens.Black, border);
  217. e.PaintContent(e.CellBounds);
  218. e.Handled = true;
  219. }
  220. else
  221. {
  222. e.Graphics.FillRectangle(Brushes.OrangeRed, e.CellBounds);
  223. Rectangle border = e.CellBounds;
  224. border.Width -= 1;
  225. e.Graphics.DrawRectangle(Pens.Black, border);
  226. e.PaintContent(e.CellBounds);
  227. e.Handled = true;
  228. }
  229. }
  230. }
  231. }
  232. }
  233. }
  234. }