123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using UAS_MES_NEW.DataOperate;
- using UAS_MES_NEW.Entity;
- using UAS_MES_NEW.PublicForm;
- using UAS_MES_NEW.PublicMethod;
- namespace UAS_MES_NEW.Make
- {
- public partial class Make_GetTestFileData : Form
- {
- AutoSizeFormClass asc = new AutoSizeFormClass();
- DataHelper dh;
- LogStringBuilder sql;
- string oErrorMessage = "";
- string omakeCode = "";
- string oMsid = "";
- ftpOperater ftp = new ftpOperater();
- public Make_GetTestFileData()
- {
- InitializeComponent();
- }
- private void Make_LabelCheck_Load(object sender, EventArgs e)
- {
- asc.controllInitializeSize(this);
- //聚焦SN号
- sncode.Focus();
- //打开界面提示用户:请输入SN
- OperateResult.AppendText(">>请输入SN\n", Color.Black);
- sql = new LogStringBuilder();
- dh = SystemInf.dh;
- StepCount.StepCode = User.CurrentStepCode;
- StepCount.Source = User.UserSourceCode;
- StepCount.LineCode = User.UserLineCode;
- StepCount.Dh = dh;
- StepCount.Start();
- }
- private void Make_LabelCheck_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- private void LoadCollectedNum()
- {
- sql.Clear();
- sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
- sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
- sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
- DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- BaseUtil.SetFormValue(Controls, dt);
- }
- private void sncode_KeyDown(object sender, KeyEventArgs e)
- {
- //判断是enter事件
- if (e.KeyCode == Keys.Enter)
- {
- if (sncode.Text == "")
- {
- OperateResult.AppendText("<<输入不能为空\n", Color.Red);
- return;
- }
- if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out oErrorMessage))
- {
- DataTable dt1 = new DataTable();
- dt1 = (DataTable)dh.ExecuteSql("select 1 from makeserial where ms_sncode='" + sncode.Text + "'", "select");
- if (dt1.Rows.Count == 0)
- {
- OperateResult.AppendText("序列号" + sncode.Text + "不存在\n", Color.Red);
- return;
- }
- //if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, sncode.Text, User.UserCode, out omakeCode, out oMsid, out oErrorMessage))
- //{
- ma_code.Text = omakeCode;
- LoadCollectedNum();
- //发送对应平台的指令
- if (MTK.Checked)
- {
- BaseUtil.GetDataFromDevice("MTK");
- }
- else
- {
- BaseUtil.GetDataFromDevice("ZHANXUN");
- }
- string ms_prodcode = dh.getFieldDataByCondition("makeserial", "ms_prodcode", "ms_id='" + oMsid + "'").ToString();
- DataTable dt = new DataTable();
- if (Directory.Exists(Application.StartupPath + "/" + DateTime.Now.ToString("yyyy-MM-dd") + @"/" + sncode.Text))
- {
- DirectoryInfo di = new DirectoryInfo(Application.StartupPath + "/" + DateTime.Now.ToString("yyyy-MM-dd") + @"/" + sncode.Text);
- FileInfo[] file = di.GetFiles();
- for (int i = 0; i < file.Length; i++)
- {
- File.Delete(file[i].FullName);
- }
- }
- BaseUtil.GetDataFromDevice("GETFILE", WatchPath.Text + " ./" + DateTime.Now.ToString("yyyy-MM-dd") + @"/" + sncode.Text);
- string[] files = Directory.GetFiles(Application.StartupPath + "/" + DateTime.Now.ToString("yyyy-MM-dd") + @"/" + sncode.Text + "", "*.csv");
- if (files.Length == 0)
- {
- files = Directory.GetFiles(Application.StartupPath + "/" + DateTime.Now.ToString("yyyy-MM-dd") + @"/" + sncode.Text + "/factory", "*.csv");
- }
- if (!BaseUtil.OpenCSVFile(ref dt, files[0]))
- {
- if (files.Length > 1)
- {
- dt = new DataTable();
- BaseUtil.OpenCSVFile(ref dt, files[1]);
- }
- }
- //移除标题行
- dt.Rows.RemoveAt(0);
- if (dt.Columns.Count == 12 || dt.Columns.Count == 13)
- {
- //设置列名绑定数据
- dt.Columns[0].ColumnName = "std_class";
- dt.Columns[1].ColumnName = "std_testresult";
- dt.Columns[2].ColumnName = "std_sn";
- dt.Columns[3].ColumnName = "std_mac";
- dt.Columns[4].ColumnName = "std_bt";
- dt.Columns[5].ColumnName = "std_imei1";
- dt.Columns[6].ColumnName = "std_imei2";
- dt.Columns[7].ColumnName = "std_googlekey";
- dt.Columns[8].ColumnName = "std_videotest";
- dt.Columns[9].ColumnName = "std_version";
- dt.Columns[10].ColumnName = "std_rom";
- dt.Columns[11].ColumnName = "std_ram";
- if (dt.Rows.Count > 0)
- {
- PSN.Text = dt.Rows[0]["std_sn"].ToString();
- if (sncode.Text != PSN.Text)
- {
- OperateResult.AppendText("扫描SN【" + sncode.Text + "】和设备读取SN【" + PSN.Text + "不相符】\n", Color.Red);
- BaseUtil.CleanControls(this.Controls);
- WatchPath.Text = "/sdcard/factory";
- return;
- }
- MAC.Text = dt.Rows[0]["std_mac"].ToString().Replace(":", "").ToUpper();
- BT.Text = dt.Rows[0]["std_bt"].ToString().Replace(":", "").ToUpper();
- IMEI1.Text = dt.Rows[0]["std_imei1"].ToString().Replace("null", "").Replace("unknow", "");
- IMEI2.Text = dt.Rows[0]["std_imei2"].ToString().Replace("null", "").Replace("unknow", "");
- GoogleKey.Text = dt.Rows[0]["std_googlekey"].ToString().Replace("null", "").Replace("unknow", "").ToUpper();
- Aging.Text = dt.Rows[0]["std_videotest"].ToString().Replace("null", "").Replace("unknow", "").ToUpper();
- Version.Text = dt.Rows[0]["std_version"].ToString().Replace("null", "").Replace("unknow", "");
- ram.Text = dt.Rows[0]["std_ram"].ToString().Replace("null", "").Replace("unknow", "");
- rom.Text = dt.Rows[0]["std_rom"].ToString().Replace("null", "").Replace("unknow", "");
- }
- }
- if (dt.Columns.Count == 9 || dt.Columns.Count == 8)
- {
- //设置列名绑定数据
- dt.Columns[0].ColumnName = "std_class";
- dt.Columns[1].ColumnName = "std_testresult";
- dt.Columns[2].ColumnName = "std_sn";
- dt.Columns[3].ColumnName = "std_mac";
- dt.Columns[4].ColumnName = "std_bt";
- dt.Columns[5].ColumnName = "std_version";
- dt.Columns[6].ColumnName = "std_rom";
- dt.Columns[7].ColumnName = "std_ram";
- if (dt.Rows.Count > 0)
- {
- PSN.Text = dt.Rows[0]["std_sn"].ToString();
- if (sncode.Text != PSN.Text)
- {
- OperateResult.AppendText("扫描SN【" + sncode.Text + "】和设备读取SN【" + PSN.Text + "不相符】\n", Color.Red);
- BaseUtil.CleanControls(this.Controls);
- WatchPath.Text = "/sdcard/factory";
- return;
- }
- MAC.Text = dt.Rows[0]["std_mac"].ToString().Replace(":", "").ToUpper();
- BT.Text = dt.Rows[0]["std_bt"].ToString().Replace(":", "").ToUpper();
- Version.Text = dt.Rows[0]["std_version"].ToString().Replace("null", "").Replace("unknow", "");
- ram.Text = dt.Rows[0]["std_ram"].ToString().Replace("null", "").Replace("unknow", "");
- rom.Text = dt.Rows[0]["std_rom"].ToString().Replace("null", "").Replace("unknow", "");
- }
- }
- DataView dv = dt.DefaultView;
- dv.Sort = "std_testresult Asc";
- dt = dv.ToTable();
- CheckItemDGV.DataSource = dt;
- bool Result = true;
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (dt.Rows[i]["std_testresult"].ToString() != "OK" || dt.Rows[i]["std_testresult"].ToString() == "NOTEST")
- {
- Result = false;
- }
- 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");
- }
- //IMEI核对
- dt = (DataTable)dh.ExecuteSql("select mil_imei1,mil_imei2 from makeimeilist where mil_psn='" + PSN.Text + "'", "select");
- if (dt.Rows.Count > 0)
- {
- string imei1 = dt.Rows[0]["mil_imei1"].ToString();
- string imei2 = dt.Rows[0]["mil_imei2"].ToString();
- if (IMEI1.Text == imei1 && IMEI1.Text != "")
- {
- OperateResult.AppendText(PSN.Text + "【IMEI1】比对成功\n", Color.Green);
- }
- else
- {
- OperateResult.AppendText(PSN.Text + "读取【IMEI1】:" + IMEI1.Text + ",系统导入:" + imei1 + ",比对失败\n", Color.Red);
- }
- if (IMEI2.Text == imei2 && IMEI2.Text != "")
- {
- OperateResult.AppendText(PSN.Text + "【IMEI2】比对成功\n", Color.Green);
- }
- else
- {
- OperateResult.AppendText(PSN.Text + "读取【IMEI2】:" + IMEI2.Text + ",系统导入:" + imei2 + ",比对失败\n", Color.Red);
- }
- }
- else
- {
- OperateResult.AppendText(PSN.Text + "未导入IMEI\n", Color.Red);
- }
- //MAC核对
- dt = (DataTable)dh.ExecuteSql("select mal_mac,mal_bt from makeaddresslist where mal_sncode='" + PSN.Text + "'", "select");
- if (dt.Rows.Count > 0)
- {
- string mac = dt.Rows[0]["mal_mac"].ToString();
- string bt = dt.Rows[0]["mal_bt"].ToString();
- if (MAC.Text == mac && MAC.Text != "")
- {
- OperateResult.AppendText(PSN.Text + "【MAC】比对成功\n", Color.Green);
- }
- else
- {
- OperateResult.AppendText(PSN.Text + "读取【MAC】:" + MAC.Text + ",系统导入:" + mac + ",比对失败\n", Color.Red);
- }
- if (BT.Text == bt && BT.Text != "")
- {
- OperateResult.AppendText(PSN.Text + "【BT】比对成功\n", Color.Green);
- }
- else
- {
- OperateResult.AppendText(PSN.Text + "读取【BT】:" + BT.Text + ",系统导入:" + bt + ",比对失败\n", Color.Red);
- }
- }
- else
- {
- OperateResult.AppendText(PSN.Text + "未导入MAC/BT\n", Color.Red);
- }
- //if (Aging.Text == "")
- //{
- // OperateResult.AppendText(">>" + sncode.Text + "设备未进行老化测试\n");
- // return;
- //}
- if (true)
- {
- //提示正确返回时传递的信息
- if (oErrorMessage.Contains("AFTERSUCCESS"))
- OperateResult.AppendText(">>" + oErrorMessage + "\n");
- //根据工单号查询makecraftdetail 表中的 mcd_okqty 计数,剩余数为ma_qty - nvl(mcd_inqty,0),刷新页面中工单信息的显示
- sql.Clear();
- sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
- sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
- sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- BaseUtil.SetFormValue(Controls, dt);
- //将SN,时间,结果记录在页面1
- //记录日志
- //ftp.UpLoadFile(Application.StartupPath, sncode.Text + ".csv", "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + ms_prodcode + "/");
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "标签核对", "参数核对成功", sncode.Text, "");
- //SN核对成功
- //>> 请输入SN
- OperateResult.AppendText("<<" + sncode.Text + "信息核对完成\n", Color.Green, sncode);
- OperateResult.AppendText(">>请输入SN\n", Color.Black);
- SetCheck set = new SetCheck("OK", Color.Green);
- BaseUtil.SetFormCenter(set);
- set.ShowDialog();
- if (ReSet.Checked)
- {
- BaseUtil.GetDataFromDevice("RESET");
- }
- //if (LogicHandler.snChangeAndBurn(sncode.Text, PSN.Text, User.UserSourceCode, User.UserCode, omakeCode, 0, IMEI1.Text, IMEI2.Text, "", "", "", "", "", "", "", MAC.Text, BT.Text, "", "", "", out oErrorMessage))
- //{
- //}
- //else
- //{
- // OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
- //}
- //if (LogicHandler.SetStepResult(omakeCode, User.UserSourceCode, sncode.Text, "", "OK", User.UserCode, out oErrorMessage))
- //{
- // //提示正确返回时传递的信息
- // if (oErrorMessage.Contains("AFTERSUCCESS"))
- // OperateResult.AppendText(">>" + oErrorMessage + "\n");
- // //根据工单号查询makecraftdetail 表中的 mcd_okqty 计数,剩余数为ma_qty - nvl(mcd_inqty,0),刷新页面中工单信息的显示
- // sql.Clear();
- // sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode,pr_detail,");
- // sql.Append("ma_qty - nvl(mcd_okqty, 0) remain_qty from make left join makecraftdetail on ");
- // sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + omakeCode + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
- // dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- // BaseUtil.SetFormValue(Controls, dt);
- // //将SN,时间,结果记录在页面
- // //记录日志
- // //ftp.UpLoadFile(Application.StartupPath, sncode.Text + ".csv", "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + ms_prodcode + "/");
- // LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "标签核对", "参数核对成功", sncode.Text, "");
- // //SN核对成功
- // //>> 请输入SN
- // OperateResult.AppendText("<<" + sncode.Text + "信息核对成功\n", Color.Green, sncode);
- // OperateResult.AppendText(">>请输入SN\n", Color.Black);
- // SetCheck set = new SetCheck("OK", Color.Green);
- // BaseUtil.SetFormCenter(set);
- // set.ShowDialog();
- // if (ReSet.Checked)
- // {
- // BaseUtil.GetDataFromDevice("RESET");
- // }
- //}
- //else
- //{
- // OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
- //}
- }
- else
- {
- //ftp.UpLoadFile(Application.StartupPath, sncode.Text + ".csv", "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + ms_prodcode + "/");
- OperateResult.AppendText(">>序列号" + sncode.Text + "测试不通过\n", Color.Red, sncode);
- }
- }
- //else
- //{
- // OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
- //}
- //}
- else
- {
- OperateResult.AppendText(">>" + oErrorMessage + "\n", Color.Red, sncode);
- }
- }
- }
- private void StepCount_Load(object sender, EventArgs e)
- {
- }
- private void CheckItemDGV_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
- {
- //系统值和
- if (e.ColumnIndex >= 0)
- {
- if (CheckItemDGV.Columns[e.ColumnIndex].Name == "std_testresult")
- {
- if (e.RowIndex >= 0)
- {
- if (CheckItemDGV.Rows[e.RowIndex].Cells["std_testresult"].Value != null && (CheckItemDGV.Rows[e.RowIndex].Cells["std_testresult"].Value.ToString() == "OK"))
- {
- e.Graphics.FillRectangle(Brushes.ForestGreen, e.CellBounds);
- Rectangle border = e.CellBounds;
- border.Width -= 1;
- e.Graphics.DrawRectangle(Pens.Black, border);
- e.PaintContent(e.CellBounds);
- e.Handled = true;
- }
- else
- {
- e.Graphics.FillRectangle(Brushes.OrangeRed, e.CellBounds);
- Rectangle border = e.CellBounds;
- border.Width -= 1;
- e.Graphics.DrawRectangle(Pens.Black, border);
- e.PaintContent(e.CellBounds);
- e.Handled = true;
- }
- }
- }
- }
- }
- }
- }
|